IKVM11  11
Java SE 11 Virtual Machine for .NET
Loading...
Searching...
No Matches
IKVM.Runtime.Annotation Class Referenceabstract

Static Protected Member Functions

static object ConvertValue (RuntimeClassLoader loader, Type targetType, object obj)
 
static object QualifyClassNames (RuntimeClassLoader loader, object annotation)
 

Detailed Description

Definition at line 52 of file Annotation.cs.

Member Function Documentation

◆ ConvertValue()

static object IKVM.Runtime.Annotation.ConvertValue ( RuntimeClassLoader loader,
Type targetType,
object obj )
staticprotected

Definition at line 133 of file Annotation.cs.

134 {
135 if (targetType.IsEnum)
136 {
137 // TODO check the obj descriptor matches the type we expect
138 if (((object[])obj)[0].Equals(AnnotationDefaultAttribute.TAG_ARRAY))
139 {
140 object[] arr = (object[])obj;
141 object value = null;
142 for (int i = 1; i < arr.Length; i++)
143 {
144 // TODO check the obj descriptor matches the type we expect
145 string s = ((object[])arr[i])[2].ToString();
146 object newval = LookupEnumValue(loader.Context, targetType, s);
147 if (value == null)
148 {
149 value = newval;
150 }
151 else
152 {
153 value = EnumHelper.OrBoxedIntegrals(loader.Context, value, newval);
154 }
155 }
156 return value;
157 }
158 else
159 {
160 string s = ((object[])obj)[2].ToString();
161 if (s == "__unspecified")
162 {
163 // TODO we should probably return null and handle that
164 }
165 return LookupEnumValue(loader.Context, targetType, s);
166 }
167 }
168 else if (targetType == loader.Context.Types.Type)
169 {
170 // TODO check the obj descriptor matches the type we expect
171 return loader.FieldTypeWrapperFromSig(((string)((object[])obj)[1]).Replace('/', '.'), LoadMode.LoadOrThrow).TypeAsTBD;
172 }
173 else if (targetType.IsArray)
174 {
175 // TODO check the obj descriptor matches the type we expect
176 object[] arr = (object[])obj;
177 Type elementType = targetType.GetElementType();
178 object[] targetArray = new object[arr.Length - 1];
179 for (int i = 1; i < arr.Length; i++)
180 {
181 targetArray[i - 1] = ConvertValue(loader, elementType, arr[i]);
182 }
183 return targetArray;
184 }
185 else
186 {
187 return obj;
188 }
189 }
IKVM.Reflection.Type Type
static object ConvertValue(RuntimeClassLoader loader, Type targetType, object obj)

◆ QualifyClassNames()

static object IKVM.Runtime.Annotation.QualifyClassNames ( RuntimeClassLoader loader,
object annotation )
staticprotected

Definition at line 237 of file Annotation.cs.

238 {
239 bool copy = false;
240 object[] def = (object[])annotation;
241 for (int i = 3; i < def.Length; i += 2)
242 {
243 object[] val = def[i] as object[];
244 if (val != null)
245 {
246 object[] newval = ValueQualifyClassNames(loader, val);
247 if (newval != val)
248 {
249 if (!copy)
250 {
251 copy = true;
252 object[] newdef = new object[def.Length];
253 Array.Copy(def, newdef, def.Length);
254 def = newdef;
255 }
256 def[i] = newval;
257 }
258 }
259 }
260 return def;
261 }

The documentation for this class was generated from the following file: