protected virtual bool OnValidate(CodeGenerationOptions opt, GenericParameterDefinitionList type_params) { if (Name.Length > TypeNamePrefix.Length && (Name [TypeNamePrefix.Length] == '.' || Char.IsDigit(Name [TypeNamePrefix.Length]))) // see bug #5111 { return(false); } if (!support.ValidateNamespace()) { return(false); } List <GenBase> valid_nests = new List <GenBase> (); foreach (GenBase gen in nested_types) { if (gen.Validate(opt, TypeParameters)) { valid_nests.Add(gen); } } nested_types = valid_nests; AdjustNestedTypeFullName(this); foreach (string iface_name in iface_names) { ISymbol isym = SymbolTable.Lookup(iface_name); if (isym != null && isym.Validate(opt, TypeParameters)) { ifaces.Add(isym); } else { if (isym == null) { Report.Warning(0, Report.WarningGenBase + 0, "For type {0}, base interface {1} does not exist.", FullName, iface_name); } else { Report.Warning(0, Report.WarningGenBase + 0, "For type {0}, base interface {1} is invalid.", FullName, iface_name); } iface_validation_failed = true; } } List <Field> valid_fields = new List <Field> (); foreach (Field f in fields) { if (!f.Validate(opt, TypeParameters)) { continue; } valid_fields.Add(f); } fields = valid_fields; int method_cnt = methods.Count; methods = methods.Where(m => ValidateMethod(opt, m)).ToList(); method_validation_failed = method_cnt != methods.Count; foreach (Method m in methods) { if (m.IsVirtual) { has_virtual_methods = true; } if (m.Name == "HashCode" && m.Parameters.Count == 0) { m.IsOverride = true; m.Name = "GetHashCode"; } jni_sig_hash [m.JavaName + m.JniSignature] = m; if ((m.Name == "ToString" && m.Parameters.Count == 0) || (BaseSymbol != null && BaseSymbol.ContainsMethod(m, true))) { m.IsOverride = true; } } return(true); }
public string ToInteroperableJavaObject(string var_name) { return(GetGenericJavaObjectTypeOverride() != null?SymbolTable.GetNativeName(var_name) : var_name); }
public string Call(CodeGenerationOptions opt, string var_name) { return(opt.GetSafeIdentifier(SymbolTable.GetNativeName(var_name))); }
protected override bool OnValidate(CodeGenerationOptions opt, GenericParameterDefinitionList type_params) { if (validated) { return(is_valid); } validated = true; // We're validating this in prior to BaseType. if (TypeParameters != null && !TypeParameters.Validate(opt, type_params)) { return(false); } if (Char.IsNumber(Name [0])) { // it is an anonymous class which does not need output. is_valid = false; return(false); } base_symbol = IsAnnotation ? SymbolTable.Lookup("java.lang.Object") : BaseType != null?SymbolTable.Lookup(BaseType) : null; if (base_symbol == null && FullName != "Java.Lang.Object" && FullName != "System.Object") { Report.Warning(0, Report.WarningClassGen + 2, "Class {0} has unknown base type {1}.", FullName, BaseType); is_valid = false; return(false); } if ((base_symbol != null && !base_symbol.Validate(opt, TypeParameters)) || !base.OnValidate(opt, type_params)) { Report.Warning(0, Report.WarningClassGen + 3, "Class {0} has invalid base type {1}.", FullName, BaseType); is_valid = false; return(false); } List <Ctor> valid_ctors = new List <Ctor> (); foreach (Ctor c in ctors) { if (c.Validate(opt, TypeParameters)) { valid_ctors.Add(c); } } ctors = valid_ctors; return(true); }
public string[] PreCall(CodeGenerationOptions opt, string var_name) { return(new string[] { String.Format("IntPtr {0} = CharSequence.ToLocalJniHandle ({1});", opt.GetSafeIdentifier(SymbolTable.GetNativeName(var_name)), opt.GetSafeIdentifier(var_name)) }); }
public string[] PreCallback(CodeGenerationOptions opt, string var_name, bool owned) { return(new string[] { String.Format("global::Java.Lang.ICharSequence {0} = global::Java.Lang.Object.GetObject<global::Java.Lang.ICharSequence> ({1}, JniHandleOwnership.DoNotTransfer);", var_name, SymbolTable.GetNativeName(var_name)) }); }
public string[] PostCall(CodeGenerationOptions opt, string var_name) { return(new string[] { string.Format("JNIEnv.DeleteLocalRef ({0});", opt.GetSafeIdentifier(SymbolTable.GetNativeName(var_name))), }); }