public InterfaceListenerProperty(InterfaceGen iface, string name, string nameSpec, string methodName, string fullDelegateName, CodeGenerationOptions opt) { Name = name; PropertyType = new TypeReferenceWriter(opt.GetOutputName(fullDelegateName)) { Nullable = opt.SupportNullableReferenceTypes }; IsPublic = true; HasGet = true; var handlerPrefix = iface.Methods.Count > 1 ? methodName : string.Empty; GetBody.Add($"{opt.GetOutputName (iface.FullName)}Implementor{opt.NullableOperator} impl = Impl{name};"); GetBody.Add($"return impl == null ? null : impl.{handlerPrefix}Handler;"); HasSet = true; SetBody.Add($"{opt.GetOutputName (iface.FullName)}Implementor{opt.NullableOperator} impl = Impl{name};"); SetBody.Add($"if (impl == null) {{"); SetBody.Add($"\timpl = new {opt.GetOutputName (iface.FullName)}Implementor ({(iface.NeedsSender ? "this" : string.Empty)});"); SetBody.Add($"\tImpl{name} = impl;"); SetBody.Add($"}} else"); SetBody.Add($"impl.{nameSpec}Handler = value;"); }
// static IntPtr java_class_ref { // get { return _members.JniPeerType.PeerReference.Handle; } // } public InterfaceHandleGetter() { Name = "java_class_ref"; PropertyType = TypeReferenceWriter.IntPtr; IsStatic = true; HasGet = true; GetBody.Add("return _members.JniPeerType.PeerReference.Handle;"); }
public GenericExplicitInterfaceImplementationProperty(Property property, GenericSymbol gen, string adapter, Dictionary <string, string> mappings, CodeGenerationOptions opt) { Name = property.AdjustedName; PropertyType = new TypeReferenceWriter(opt.GetTypeReferenceName(property)); ExplicitInterfaceImplementation = opt.GetOutputName(gen.Gen.FullName); Comments.Add($"// This method is explicitly implemented as a member of an instantiated {gen.FullName}"); if (property.Getter != null) { HasGet = true; if (gen.Gen.IsGeneratable) { GetterComments.Add($"// Metadata.xml XPath method reference: path=\"{gen.Gen.MetadataXPathReference}/method[@name='{property.Getter.JavaName}'{property.Getter.Parameters.GetMethodXPathPredicate ()}]\""); } if (property.Getter.GenericArguments != null && property.Getter.GenericArguments.Any()) { GetterAttributes.Add(new CustomAttr(property.Getter.GenericArguments.ToGeneratedAttributeString())); } SourceWriterExtensions.AddSupportedOSPlatform(GetterAttributes, property.Getter, opt); GetterAttributes.Add(new RegisterAttr(property.Getter.JavaName, property.Getter.JniSignature, property.Getter.ConnectorName + ":" + property.Getter.GetAdapterName(opt, adapter), additionalProperties: property.Getter.AdditionalAttributeString())); GetBody.Add($"return {property.Name};"); } if (property.Setter != null) { HasSet = true; if (gen.Gen.IsGeneratable) { SetterComments.Add($"// Metadata.xml XPath method reference: path=\"{gen.Gen.MetadataXPathReference}/method[@name='{property.Setter.JavaName}'{property.Setter.Parameters.GetMethodXPathPredicate ()}]\""); } if (property.Setter.GenericArguments != null && property.Setter.GenericArguments.Any()) { SetterAttributes.Add(new CustomAttr(property.Setter.GenericArguments.ToGeneratedAttributeString())); } SourceWriterExtensions.AddSupportedOSPlatform(SetterAttributes, property.Setter, opt); SetterAttributes.Add(new RegisterAttr(property.Setter.JavaName, property.Setter.JniSignature, property.Setter.ConnectorName + ":" + property.Setter.GetAdapterName(opt, adapter), additionalProperties: property.Setter.AdditionalAttributeString())); // Temporarily rename the parameter to "value" var pname = property.Setter.Parameters [0].Name; property.Setter.Parameters [0].Name = "value"; SetBody.Add($"{property.Name} = {property.Setter.Parameters.GetGenericCall (opt, mappings)};"); property.Setter.Parameters [0].Name = pname; } }
// internal static new IntPtr class_ref { // get { return _members.JniPeerType.PeerReference.Handle; } // } public ClassHandleGetter(bool requireNew) { Name = "class_ref"; PropertyType = TypeReferenceWriter.IntPtr; IsInternal = true; IsStatic = true; IsShadow = requireNew; HasGet = true; GetBody.Add("return _members.JniPeerType.PeerReference.Handle;"); }
public HandledProperty() { Name = "Handled"; PropertyType = TypeReferenceWriter.Bool; IsPublic = true; HasGet = true; GetBody.Add("return handled;"); HasSet = true; SetBody.Add("handled = value;"); }
// [DebuggerBrowsable (DebuggerBrowsableState.Never)] // [EditorBrowsable (EditorBrowsableState.Never)] // protected override IntPtr ThresholdClass { // get { return class_ref; } // } public InterfaceThresholdClassGetter() { Name = "ThresholdClass"; PropertyType = TypeReferenceWriter.IntPtr; IsProtected = true; IsOverride = true; Attributes.Add(new DebuggerBrowsableAttr()); Attributes.Add(new EditorBrowsableAttr()); HasGet = true; GetBody.Add("return class_ref;"); }
// [DebuggerBrowsable (DebuggerBrowsableState.Never)] // [EditorBrowsable (EditorBrowsableState.Never)] // protected override IntPtr ThresholdClass { // get { return _members.JniPeerType.PeerReference.Handle; } // } public ClassThresholdClassGetter() { Name = "ThresholdClass"; PropertyType = TypeReferenceWriter.IntPtr; IsProtected = true; IsOverride = true; Attributes.Add(new DebuggerBrowsableAttr()); Attributes.Add(new EditorBrowsableAttr()); HasGet = true; GetBody.Add("return _members.JniPeerType.PeerReference.Handle;"); }
// [DebuggerBrowsable (DebuggerBrowsableState.Never)] // [EditorBrowsable (EditorBrowsableState.Never)] // public override global::Java.Interop.JniPeerMembers JniPeerMembers { // get { return _members; } // } public JniPeerMembersGetter() { Name = "JniPeerMembers"; PropertyType = new TypeReferenceWriter("global::Java.Interop.JniPeerMembers"); IsPublic = true; IsOverride = true; Attributes.Add(new DebuggerBrowsableAttr()); Attributes.Add(new EditorBrowsableAttr()); HasGet = true; GetBody.Add("return _members;"); }
// [DebuggerBrowsable (DebuggerBrowsableState.Never)] // [EditorBrowsable (EditorBrowsableState.Never)] // protected override global::System.Type ThresholdType { // get { return _members.ManagedPeerType; } // } public ThresholdTypeGetter() { Name = "ThresholdType"; PropertyType = new TypeReferenceWriter("global::System.Type"); IsProtected = true; IsOverride = true; Attributes.Add(new DebuggerBrowsableAttr()); Attributes.Add(new EditorBrowsableAttr()); HasGet = true; GetBody.Add("return _members.ManagedPeerType;"); }
public BoundPropertyStringVariant(Property property, CodeGenerationOptions opt) { var is_array = property.Getter.RetVal.IsArray; Name = property.Name; PropertyType = new TypeReferenceWriter("string" + (is_array ? "[]" : string.Empty)) { Nullable = opt.SupportNullableReferenceTypes }; SetVisibility((property.Setter ?? property.Getter).Visibility); SourceWriterExtensions.AddSupportedOSPlatform(Attributes, property.Getter, opt); HasGet = true; if (is_array) { GetBody.Add($"return CharSequence.ArrayToStringArray ({property.AdjustedName});"); } else { GetBody.Add($"return {property.AdjustedName} == null ? null : {property.AdjustedName}.ToString ();"); } if (property.Setter is null) { return; } HasSet = true; if (is_array) { SetBody.Add($"global::Java.Lang.ICharSequence[] jlsa = CharSequence.ArrayFromStringArray (value);"); SetBody.Add($"{property.AdjustedName} = jlsa;"); SetBody.Add($"foreach (var jls in jlsa) if (jls != null) jls.Dispose ();"); } else { SetBody.Add($"var jls = value == null ? null : new global::Java.Lang.String (value);"); SetBody.Add($"{property.AdjustedName} = jls;"); SetBody.Add($"if (jls != null) jls.Dispose ();"); } }
public InterfaceListenerPropertyImplementor(InterfaceGen iface, string name, CodeGenerationOptions opt) { this.name = name; this.opt = opt; Name = "Impl" + name; PropertyType = new TypeReferenceWriter(opt.GetOutputName(iface.FullName) + "Implementor") { Nullable = opt.SupportNullableReferenceTypes }; HasGet = true; GetBody.Add($"if (weak_implementor_{name} == null || !weak_implementor_{name}.IsAlive)"); GetBody.Add($"\treturn null;"); GetBody.Add($"return weak_implementor_{name}.Target as {opt.GetOutputName (iface.FullName)}Implementor;"); HasSet = true; SetBody.Add($"weak_implementor_{name} = new WeakReference (value, true);"); }