/// <summary> /// Constructor. /// </summary> /// <param name="input">The PCM stream to negate</param> public GenNegate(GenBase input) : base(0.0f, 0) { this.input = input; }
public GenSignNeg(int samplesPerSec, GenBase input) : base(0.0f, 0) { this.input = input; }
/// <summary> /// Constructor. /// </summary> /// <param name="gma">One of the PCM streams.</param> /// <param name="gmb">The other PCM stream.</param> public GenMax(GenBase gma, GenBase gmb) : base(0.0f, 0) { this.gma = gma; this.gmb = gmb; }
static void AddJavadoc(GenBase type, Dictionary <string, XElement> typeJavadocs, XmldocStyle style) { if (!typeJavadocs.TryGetValue(type.JniName, out XElement typeJavadoc)) { return; } if (typeJavadoc == null) { return; } if (type.JavadocInfo == null) { type.JavadocInfo = JavadocInfo.CreateInfo(typeJavadoc, style); } foreach (var method in type.Methods) { if (method.JavadocInfo != null) { continue; } var methodJavadoc = GetMemberJavadoc(typeJavadoc, "method", method.JavaName, method.JniSignature); method.JavadocInfo = JavadocInfo.CreateInfo(methodJavadoc?.Parent, style); } foreach (var property in type.Properties) { if (property.Getter != null && property.Getter.JavadocInfo == null) { var getterJavadoc = GetMemberJavadoc(typeJavadoc, "method", property.Getter.JavaName, property.Getter.JniSignature); property.Getter.JavadocInfo = JavadocInfo.CreateInfo(getterJavadoc?.Parent, style, appendCopyrightExtra: false); } if (property.Setter != null && property.Setter.JavadocInfo == null) { var setterJavadoc = GetMemberJavadoc(typeJavadoc, "method", property.Setter.JavaName, property.Setter.JniSignature); property.Setter.JavadocInfo = JavadocInfo.CreateInfo(setterJavadoc?.Parent, style, appendCopyrightExtra: false); } } foreach (var field in type.Fields) { if (field.JavadocInfo != null) { continue; } var fieldJavadoc = GetMemberJavadoc(typeJavadoc, "field", field.JavaName, field.JniSignature); field.JavadocInfo = JavadocInfo.CreateInfo(fieldJavadoc?.Parent, style); } if (type is ClassGen @class) { foreach (var ctor in @class.Ctors) { if (ctor.JavadocInfo != null) { continue; } var ctorJavadoc = GetMemberJavadoc(typeJavadoc, "constructor", null, ctor.JniSignature); ctor.JavadocInfo = JavadocInfo.CreateInfo(ctorJavadoc?.Parent, style); } } }
public BoundMethodAbstractDeclaration(GenBase gen, Method method, CodeGenerationOptions opt, GenBase impl) { this.method = method; this.opt = opt; ReturnType = new TypeReferenceWriter(opt.GetTypeReferenceName(method.RetVal)); this.AddMethodParameters(method.Parameters, opt); if (method.RetVal.IsGeneric && gen != null) { Name = method.Name; ExplicitInterfaceImplementation = opt.GetOutputName(gen.FullName); SourceWriterExtensions.AddMethodCustomAttributes(Attributes, method); Body.Add("throw new NotImplementedException ();"); return; } Name = method.AdjustedName; IsAbstract = true; IsShadow = impl.RequiresNew(method.Name, method); SetVisibility(method.Visibility); NewFirst = true; if (opt.CodeGenerationTarget != CodeGenerationTarget.JavaInterop1) { method_callback = new MethodCallback(impl, method, opt, null, method.IsReturnCharSequence); } method.JavadocInfo?.AddJavadocs(Comments); if (method.DeclaringType.IsGeneratable) { Comments.Add($"// Metadata.xml XPath method reference: path=\"{method.GetMetadataXPathReference (method.DeclaringType)}\""); } SourceWriterExtensions.AddSupportedOSPlatform(Attributes, method, opt); if (opt.CodeGenerationTarget != CodeGenerationTarget.JavaInterop1) { Attributes.Add(new RegisterAttr(method.JavaName, method.JniSignature, method.ConnectorName, additionalProperties: method.AdditionalAttributeString())); } SourceWriterExtensions.AddMethodCustomAttributes(Attributes, method); }
/// <summary> /// Constructor. /// </summary> /// <param name="input">The PCM stream.</param> public GenAbs(GenBase input) : base(0.0f, 0) { this.input = input; }
public static int Main() { GenBase deriv4 = new GenDerived4(); for (int i = 5; i <= 25; i += 5) { // Test for generic classes switch (i % 4) { case 0: GenClass <int> .DoTest_GenClass(i); break; case 1: GenClass <int> .DoTest_GenDerived(i); break; case 2: GenClass <int> .DoTest_GenDerived2(i); break; case 3: GenClass <int> .DoTest_GenDerived3(i); break; } // Test for generic methods DoTest(i); { AssemblyBuilder ab = AssemblyBuilder.DefineDynamicAssembly(new AssemblyName("CollectibleAsm" + i), AssemblyBuilderAccess.RunAndCollect); var tb = ab.DefineDynamicModule("CollectibleMod" + i).DefineType("CollectibleGenDerived" + i, TypeAttributes.Public, typeof(GenDerived2)); var t = tb.CreateType(); GenBase col_b = (GenBase)Activator.CreateInstance(t); col_b.VFunc(); ab = null; tb = null; t = null; col_b = null; for (int k = 0; k < 5; k++) { GC.Collect(); GC.WaitForPendingFinalizers(); } } } // After all expansions to existing dictionaries, use GenDerived4. GenDerived4 was allocated before any of its // base type dictionaries were expanded. for (int i = 0; i < 5; i++) { deriv4.VFunc(); } return(100); }
public GenAmplify(GenBase input, float amount) : base(0.0f, 0) { this.input = input; this.amount = amount; }
/// <summary> /// Constructor. /// </summary> /// <param name="input">The PCM stream to square.</param> public GenSquare(GenBase input) : base(0.0f, 0) { this.input = input; }
/// <summary> /// The input PCM stream. /// </summary> /// <param name="input"></param> public GenCube(GenBase input) : base(0.0f, 0) { this.input = input; }
public GenClampPos(GenBase input) : base(0.0f, 0) { this.input = input; }
public BoundMethod(GenBase type, Method method, CodeGenerationOptions opt, bool generateCallbacks) { JavaMethod = method; if (generateCallbacks && method.IsVirtual) { callback = new MethodCallback(type, method, opt, null, method.IsReturnCharSequence); } Name = method.AdjustedName; IsStatic = method.IsStatic; IsSealed = method.IsOverride && method.IsFinal; IsUnsafe = true; SetVisibility(type is InterfaceGen && !IsStatic ? string.Empty : method.Visibility); // TODO: Clean up this logic var is_explicit = opt.SupportDefaultInterfaceMethods && type is InterfaceGen && method.OverriddenInterfaceMethod != null; var virt_ov = is_explicit ? string.Empty : method.IsOverride ? (opt.SupportDefaultInterfaceMethods && method.OverriddenInterfaceMethod != null ? " virtual" : " override") : method.IsVirtual ? " virtual" : string.Empty; IsVirtual = virt_ov.Trim() == "virtual"; IsOverride = virt_ov.Trim() == "override"; // When using DIM, don't generate "virtual sealed" methods, remove both modifiers instead if (opt.SupportDefaultInterfaceMethods && method.OverriddenInterfaceMethod != null && IsVirtual && IsSealed) { IsVirtual = false; IsSealed = false; } if (is_explicit) { ExplicitInterfaceImplementation = GetDeclaringTypeOfExplicitInterfaceMethod(method.OverriddenInterfaceMethod); } if ((IsVirtual || !IsOverride) && type.RequiresNew(method.AdjustedName, method)) { IsShadow = true; } // Allow user to override our virtual/override logic if (method.ManagedOverride?.ToLowerInvariant() == "virtual") { IsVirtual = true; IsOverride = false; } else if (method.ManagedOverride?.ToLowerInvariant() == "override") { IsVirtual = false; IsOverride = true; } ReturnType = new TypeReferenceWriter(opt.GetTypeReferenceName(method.RetVal)); method.JavadocInfo?.AddJavadocs(Comments); if (method.DeclaringType.IsGeneratable) { Comments.Add($"// Metadata.xml XPath method reference: path=\"{method.GetMetadataXPathReference (method.DeclaringType)}\""); } if (method.Deprecated.HasValue()) { Attributes.Add(new ObsoleteAttr(method.Deprecated.Replace("\"", "\"\""))); } if (method.IsReturnEnumified) { Attributes.Add(new GeneratedEnumAttr(true)); } SourceWriterExtensions.AddSupportedOSPlatform(Attributes, method, opt); Attributes.Add(new RegisterAttr(method.JavaName, method.JniSignature, method.IsVirtual ? method.GetConnectorNameFull(opt) : string.Empty, additionalProperties: method.AdditionalAttributeString())); SourceWriterExtensions.AddMethodCustomAttributes(Attributes, method); this.AddMethodParameters(method.Parameters, opt); SourceWriterExtensions.AddMethodBody(Body, method, opt); }
public GenHold(GenBase input, int holdSamples) : base(0.0f, 0) { this.input = input; this.holdSamples = holdSamples; }
public BoundProperty(GenBase gen, Property property, CodeGenerationOptions opt, bool withCallbacks = true, bool forceOverride = false) { Name = property.AdjustedName; PropertyType = new TypeReferenceWriter(opt.GetTypeReferenceName(property.Getter.RetVal)); SetVisibility(gen is InterfaceGen ? string.Empty : property.Getter.IsAbstract && property.Getter.RetVal.IsGeneric ? "protected" : (property.Setter ?? property.Getter).Visibility); IsUnsafe = true; HasGet = true; var is_virtual = property.Getter.IsVirtual && (property.Setter == null || property.Setter.IsVirtual); if (is_virtual && withCallbacks) { IsVirtual = true; IsShadow = gen.RequiresNew(property); getter_callback = new MethodCallback(gen, property.Getter, opt, property.AdjustedName, false); if (property.Setter != null) { setter_callback = new MethodCallback(gen, property.Setter, opt, property.AdjustedName, false); } } if (forceOverride || ShouldForceOverride(property)) { IsVirtual = false; IsOverride = true; } if ((property.Getter ?? property.Setter).IsStatic) { IsStatic = true; IsVirtual = false; IsOverride = false; } else if (gen.BaseSymbol != null) { // It should be using AdjustedName instead of Name, but ICharSequence ("Formatted") properties are not caught by this... var base_prop = gen.BaseSymbol.GetPropertyByName(property.Name, true); // If the matching base getter we found is a DIM, we do not override it, it should stay virtual if (base_prop != null && !base_prop.Getter.IsInterfaceDefaultMethod) { IsVirtual = false; IsOverride = true; } } // Allow user to override our virtual/override logic if (!forceOverride && (property.Getter ?? property.Setter).ManagedOverride?.ToLowerInvariant() == "virtual") { IsVirtual = true; IsOverride = false; } else if (!forceOverride && (property.Getter ?? property.Setter).ManagedOverride?.ToLowerInvariant() == "override") { IsVirtual = false; IsOverride = true; } // Unlike [Register], [Obsolete] cannot be put on property accessors, so we can apply them only under limited condition... if (property.Getter.Deprecated != null && (property.Setter == null || property.Setter.Deprecated != null)) { Attributes.Add(new ObsoleteAttr(property.Getter.Deprecated.Replace("\"", "\"\"").Trim() + (property.Setter != null && property.Setter.Deprecated != property.Getter.Deprecated ? " " + property.Setter.Deprecated.Replace("\"", "\"\"").Trim() : null))); } SourceWriterExtensions.AddMethodCustomAttributes(GetterAttributes, property.Getter); if (gen.IsGeneratable) { GetterComments.Add($"// Metadata.xml XPath method reference: path=\"{gen.MetadataXPathReference}/method[@name='{property.Getter.JavaName}'{property.Getter.Parameters.GetMethodXPathPredicate ()}]\""); } SourceWriterExtensions.AddSupportedOSPlatform(GetterAttributes, property.Getter, opt); GetterAttributes.Add(new RegisterAttr(property.Getter.JavaName, property.Getter.JniSignature, property.Getter.IsVirtual ? property.Getter.GetConnectorNameFull(opt) : string.Empty, additionalProperties: property.Getter.AdditionalAttributeString())); SourceWriterExtensions.AddMethodBody(GetBody, property.Getter, opt); if (property.Setter != null) { HasSet = true; if (gen.IsGeneratable) { SetterComments.Add($"// Metadata.xml XPath method reference: path=\"{gen.MetadataXPathReference}/method[@name='{property.Setter.JavaName}'{property.Setter.Parameters.GetMethodXPathPredicate ()}]\""); } SourceWriterExtensions.AddSupportedOSPlatform(SetterAttributes, property.Setter, opt); SourceWriterExtensions.AddMethodCustomAttributes(SetterAttributes, property.Setter); SetterAttributes.Add(new RegisterAttr(property.Setter.JavaName, property.Setter.JniSignature, property.Setter.IsVirtual ? property.Setter.GetConnectorNameFull(opt) : string.Empty, additionalProperties: property.Setter.AdditionalAttributeString())); var pname = property.Setter.Parameters [0].Name; property.Setter.Parameters [0].Name = "value"; SourceWriterExtensions.AddMethodBody(SetBody, property.Setter, opt); property.Setter.Parameters [0].Name = pname; } else if (property.GenerateDispatchingSetter) { HasSet = true; SetterComments.Add("// This is a dispatching setter"); SetBody.Add($"Set{property.Name} (value);"); } AddJavadocs(property); }
public TestCtor(GenBase @class, string name) : base(@class) { Name = name; }
public GenLinDecay(double startTime, double duration, float sustain, int samplesPerSec, GenBase gen) : base(0.0f, samplesPerSec) { this.startTime = startTime; this.gen = gen; this.duration = duration; this.offsetSamples = (int)(startTime * samplesPerSec); this.durationSamples = (int)(duration * samplesPerSec); this.totalDurationSamples = this.durationSamples; this.sustain = sustain; this.invSustain = 1.0f - sustain; }
public GenMeter(GenBase input) : base(0.0f, 0) { this.input = input; this.meter = new MeterValue(); }