-
Notifications
You must be signed in to change notification settings - Fork 56
/
Copy pathField.cs
85 lines (70 loc) · 2.83 KB
/
Field.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
using System;
using System.Collections.Generic;
using Java.Interop.Tools.Generator;
namespace MonoDroid.Generation
{
public class Field : ApiVersionsSupport.IApiAvailability, ISourceLineInfo
{
public string AnnotatedVisibility { get; set; }
public string Annotation { get; set; }
public int ApiAvailableSince { get; set; }
public string DeprecatedComment { get; set; }
public int? DeprecatedSince { get; set; }
public bool IsAcw { get; set; }
public bool IsDeprecated { get; set; }
public bool IsDeprecatedError { get; set; }
public bool IsEnumified { get; set; }
public bool IsFinal { get; set; }
public bool IsStatic { get; set; }
public ParameterList SetParameters { get; private set; }
public ISymbol Symbol { get; private set; }
public string JavaName { get; set; }
public string Name { get; set; }
public bool NotNull { get; set; }
public Parameter SetterParameter { get; set; }
public string TypeName { get; set; }
public string Value { get; set; }
public string Visibility { get; set; }
public string JniSignature { get; set; }
public JavadocInfo JavadocInfo { get; set; }
public int LineNumber { get; set; } = -1;
public int LinePosition { get; set; } = -1;
public string SourceFile { get; set; }
internal string GetMethodPrefix => TypeNameUtilities.GetCallPrefix (Symbol);
internal string ID => JavaName + "_jfieldId";
public bool IsConst => IsFinal && IsStatic;
public bool NeedsProperty => !IsStatic || !IsFinal || string.IsNullOrEmpty (Value) || Symbol.IsArray || !primitive_types.Contains (Symbol.JavaName);
public string CachedMemberName => $"_{Name}_cache";
public bool Validate (CodeGenerationOptions opt, GenericParameterDefinitionList type_params, CodeGeneratorContext context)
{
Symbol = opt.SymbolTable.Lookup (TypeName, type_params);
if (Symbol == null || !Symbol.Validate (opt, type_params, context)) {
Report.LogCodedWarning (0, Report.WarningUnexpectedFieldType, this, TypeName, context.GetContextTypeMember ());
return false;
}
if (!string.IsNullOrEmpty (Value) && Symbol != null && Symbol.FullName == "char" && !Value.StartsWith ("(char)", StringComparison.Ordinal))
Value = "(char)" + Value;
SetParameters = new ParameterList {
SetterParameter,
};
if (!SetParameters.Validate (opt, type_params, context))
throw new NotSupportedException (
string.Format ("Unable to generate setter parameter list {0}", context.ContextString));
return true;
}
static readonly HashSet<string> primitive_types = new HashSet<string> {
"boolean",
"char",
"byte",
"short",
"int",
"long",
"float",
"double",
// while technically not a primitive type, Strings have the feature that
// their value is stored within bytecode and their value is thus accessible
// within the api.xml description.
"java.lang.String",
};
}
}