
system.reflection.emit.DynamicMethod Maven / Gradle / Ivy
/*
* MIT License
*
* Copyright (c) 2022 MASES s.r.l.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/**************************************************************************************
*
* This code was generated from a template using JCOReflector
*
* Manual changes to this file may cause unexpected behavior in your application.
* Manual changes to this file will be overwritten if the code is regenerated.
*
*************************************************************************************/
package system.reflection.emit;
import org.mases.jcobridge.*;
import org.mases.jcobridge.netreflection.*;
import java.util.ArrayList;
// Import section
import system.reflection.MethodInfo;
import system.reflection.MethodAttributes;
import system.reflection.CallingConventions;
import system.reflection.Module;
import system.reflection.BindingFlags;
import system.reflection.Binder;
import system.globalization.CultureInfo;
import system.reflection.emit.DynamicILInfo;
import system.reflection.emit.ILGenerator;
import system.reflection.emit.ParameterBuilder;
import system.reflection.ParameterAttributes;
import system.reflection.MethodImplAttributes;
import system.reflection.ParameterInfo;
import system.reflection.ICustomAttributeProvider;
import system.reflection.ICustomAttributeProviderImplementation;
import system.RuntimeMethodHandle;
/**
* The base .NET class managing System.Reflection.Emit.DynamicMethod, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e.
*
*
* See: https://docs.microsoft.com/en-us/dotnet/api/System.Reflection.Emit.DynamicMethod
*/
public class DynamicMethod extends MethodInfo {
/**
* Fully assembly qualified name: System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
*/
public static final String assemblyFullName = "System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e";
/**
* Assembly name: System.Private.CoreLib
*/
public static final String assemblyShortName = "System.Private.CoreLib";
/**
* Qualified class name: System.Reflection.Emit.DynamicMethod
*/
public static final String className = "System.Reflection.Emit.DynamicMethod";
static JCOBridge bridge = JCOBridgeInstance.getInstance(assemblyFullName);
/**
* The type managed from JCOBridge. See {@link JCType}
*/
public static JCType classType = createType();
static JCEnum enumInstance = null;
JCObject classInstance = null;
static JCType createType() {
try {
String classToCreate = className + ", "
+ (JCOReflector.getUseFullAssemblyName() ? assemblyFullName : assemblyShortName);
if (JCOReflector.getDebug())
JCOReflector.writeLog("Creating %s", classToCreate);
JCType typeCreated = bridge.GetType(classToCreate);
if (JCOReflector.getDebug())
JCOReflector.writeLog("Created: %s",
(typeCreated != null) ? typeCreated.toString() : "Returned null value");
return typeCreated;
} catch (JCException e) {
JCOReflector.writeLog(e);
return null;
}
}
void addReference(String ref) throws Throwable {
try {
bridge.AddReference(ref);
} catch (JCNativeException jcne) {
throw translateException(jcne);
}
}
/**
* Internal constructor. Use with caution
*/
public DynamicMethod(java.lang.Object instance) throws Throwable {
super(instance);
if (instance instanceof JCObject) {
classInstance = (JCObject) instance;
} else
throw new Exception("Cannot manage object, it is not a JCObject");
}
public String getJCOAssemblyName() {
return assemblyFullName;
}
public String getJCOClassName() {
return className;
}
public String getJCOObjectName() {
return className + ", " + (JCOReflector.getUseFullAssemblyName() ? assemblyFullName : assemblyShortName);
}
public java.lang.Object getJCOInstance() {
return classInstance;
}
public void setJCOInstance(JCObject instance) {
classInstance = instance;
super.setJCOInstance(classInstance);
}
public JCType getJCOType() {
return classType;
}
/**
* Try to cast the {@link IJCOBridgeReflected} instance into {@link DynamicMethod}, a cast assert is made to check if types are compatible.
* @param from {@link IJCOBridgeReflected} instance to be casted
* @return {@link DynamicMethod} instance
* @throws java.lang.Throwable in case of error during cast operation
*/
public static DynamicMethod cast(IJCOBridgeReflected from) throws Throwable {
NetType.AssertCast(classType, from);
return new DynamicMethod(from.getJCOInstance());
}
// Constructors section
public DynamicMethod() throws Throwable {
}
public DynamicMethod(java.lang.String name, MethodAttributes attributes, CallingConventions callingConvention, NetType returnType, NetType[] parameterTypes, Module m, boolean skipVisibility) throws Throwable, system.ArgumentException, system.ArgumentOutOfRangeException, system.ArgumentNullException, system.InvalidOperationException, system.PlatformNotSupportedException, system.IndexOutOfRangeException, system.NotSupportedException, system.ObjectDisposedException, system.RankException, system.ArrayTypeMismatchException {
try {
// add reference to assemblyName.dll file
addReference(JCOReflector.getUseFullAssemblyName() ? assemblyFullName : assemblyShortName);
setJCOInstance((JCObject)classType.NewObject(name, attributes == null ? null : attributes.getJCOInstance(), callingConvention == null ? null : callingConvention.getJCOInstance(), returnType == null ? null : returnType.getJCOInstance(), toObjectFromArray(parameterTypes), m == null ? null : m.getJCOInstance(), skipVisibility));
} catch (JCNativeException jcne) {
throw translateException(jcne);
}
}
public DynamicMethod(java.lang.String name, MethodAttributes attributes, CallingConventions callingConvention, NetType returnType, NetType[] parameterTypes, NetType owner, boolean skipVisibility) throws Throwable, system.ArgumentException, system.ArgumentOutOfRangeException, system.ArgumentNullException, system.InvalidOperationException, system.PlatformNotSupportedException, system.IndexOutOfRangeException, system.NotSupportedException, system.ObjectDisposedException, system.RankException, system.ArrayTypeMismatchException {
try {
// add reference to assemblyName.dll file
addReference(JCOReflector.getUseFullAssemblyName() ? assemblyFullName : assemblyShortName);
setJCOInstance((JCObject)classType.NewObject(name, attributes == null ? null : attributes.getJCOInstance(), callingConvention == null ? null : callingConvention.getJCOInstance(), returnType == null ? null : returnType.getJCOInstance(), toObjectFromArray(parameterTypes), owner == null ? null : owner.getJCOInstance(), skipVisibility));
} catch (JCNativeException jcne) {
throw translateException(jcne);
}
}
public DynamicMethod(java.lang.String name, NetType returnType, NetType[] parameterTypes, boolean restrictedSkipVisibility) throws Throwable, system.ArgumentException, system.ArgumentOutOfRangeException, system.IndexOutOfRangeException, system.NotSupportedException, system.ArgumentNullException, system.ObjectDisposedException, system.InvalidOperationException, system.RankException, system.ArrayTypeMismatchException, system.PlatformNotSupportedException {
try {
// add reference to assemblyName.dll file
addReference(JCOReflector.getUseFullAssemblyName() ? assemblyFullName : assemblyShortName);
setJCOInstance((JCObject)classType.NewObject(name, returnType == null ? null : returnType.getJCOInstance(), toObjectFromArray(parameterTypes), restrictedSkipVisibility));
} catch (JCNativeException jcne) {
throw translateException(jcne);
}
}
public DynamicMethod(java.lang.String name, NetType returnType, NetType[] parameterTypes, Module m, boolean skipVisibility) throws Throwable, system.ArgumentException, system.ArgumentOutOfRangeException, system.ArgumentNullException, system.InvalidOperationException, system.PlatformNotSupportedException, system.IndexOutOfRangeException, system.NotSupportedException, system.ObjectDisposedException, system.RankException, system.ArrayTypeMismatchException {
try {
// add reference to assemblyName.dll file
addReference(JCOReflector.getUseFullAssemblyName() ? assemblyFullName : assemblyShortName);
setJCOInstance((JCObject)classType.NewObject(name, returnType == null ? null : returnType.getJCOInstance(), toObjectFromArray(parameterTypes), m == null ? null : m.getJCOInstance(), skipVisibility));
} catch (JCNativeException jcne) {
throw translateException(jcne);
}
}
public DynamicMethod(java.lang.String name, NetType returnType, NetType[] parameterTypes, Module m) throws Throwable, system.ArgumentException, system.ArgumentOutOfRangeException, system.ArgumentNullException, system.InvalidOperationException, system.PlatformNotSupportedException, system.IndexOutOfRangeException, system.NotSupportedException, system.ObjectDisposedException, system.RankException, system.ArrayTypeMismatchException {
try {
// add reference to assemblyName.dll file
addReference(JCOReflector.getUseFullAssemblyName() ? assemblyFullName : assemblyShortName);
setJCOInstance((JCObject)classType.NewObject(name, returnType == null ? null : returnType.getJCOInstance(), toObjectFromArray(parameterTypes), m == null ? null : m.getJCOInstance()));
} catch (JCNativeException jcne) {
throw translateException(jcne);
}
}
public DynamicMethod(java.lang.String name, NetType returnType, NetType[] parameterTypes, NetType owner, boolean skipVisibility) throws Throwable, system.ArgumentException, system.ArgumentOutOfRangeException, system.ArgumentNullException, system.InvalidOperationException, system.PlatformNotSupportedException, system.IndexOutOfRangeException, system.NotSupportedException, system.ObjectDisposedException, system.RankException, system.ArrayTypeMismatchException {
try {
// add reference to assemblyName.dll file
addReference(JCOReflector.getUseFullAssemblyName() ? assemblyFullName : assemblyShortName);
setJCOInstance((JCObject)classType.NewObject(name, returnType == null ? null : returnType.getJCOInstance(), toObjectFromArray(parameterTypes), owner == null ? null : owner.getJCOInstance(), skipVisibility));
} catch (JCNativeException jcne) {
throw translateException(jcne);
}
}
public DynamicMethod(java.lang.String name, NetType returnType, NetType[] parameterTypes, NetType owner) throws Throwable, system.ArgumentException, system.ArgumentOutOfRangeException, system.ArgumentNullException, system.InvalidOperationException, system.PlatformNotSupportedException, system.IndexOutOfRangeException, system.NotSupportedException, system.ObjectDisposedException, system.RankException, system.ArrayTypeMismatchException {
try {
// add reference to assemblyName.dll file
addReference(JCOReflector.getUseFullAssemblyName() ? assemblyFullName : assemblyShortName);
setJCOInstance((JCObject)classType.NewObject(name, returnType == null ? null : returnType.getJCOInstance(), toObjectFromArray(parameterTypes), owner == null ? null : owner.getJCOInstance()));
} catch (JCNativeException jcne) {
throw translateException(jcne);
}
}
public DynamicMethod(java.lang.String name, NetType returnType, NetType[] parameterTypes) throws Throwable, system.ArgumentException, system.ArgumentOutOfRangeException, system.IndexOutOfRangeException, system.NotSupportedException, system.ArgumentNullException, system.ObjectDisposedException, system.InvalidOperationException, system.RankException, system.ArrayTypeMismatchException, system.PlatformNotSupportedException {
try {
// add reference to assemblyName.dll file
addReference(JCOReflector.getUseFullAssemblyName() ? assemblyFullName : assemblyShortName);
setJCOInstance((JCObject)classType.NewObject(name, returnType == null ? null : returnType.getJCOInstance(), toObjectFromArray(parameterTypes)));
} catch (JCNativeException jcne) {
throw translateException(jcne);
}
}
// Methods section
public boolean IsDefined(NetType attributeType, boolean inherit) throws Throwable {
if (classInstance == null)
throw new UnsupportedOperationException("classInstance is null.");
try {
return (boolean)classInstance.Invoke("IsDefined", attributeType == null ? null : attributeType.getJCOInstance(), inherit);
} catch (JCNativeException jcne) {
throw translateException(jcne);
}
}
public NetObject Invoke(NetObject obj, BindingFlags invokeAttr, Binder binder, NetObject[] parameters, CultureInfo culture) throws Throwable, system.ArgumentException, system.ArgumentOutOfRangeException, system.ArgumentNullException, system.InvalidOperationException, system.PlatformNotSupportedException, system.IndexOutOfRangeException, system.NotSupportedException, system.globalization.CultureNotFoundException, system.ObjectDisposedException, system.ArrayTypeMismatchException, system.reflection.TargetParameterCountException {
if (classInstance == null)
throw new UnsupportedOperationException("classInstance is null.");
try {
JCObject objInvoke = (JCObject)classInstance.Invoke("Invoke", obj == null ? null : obj.getJCOInstance(), invokeAttr == null ? null : invokeAttr.getJCOInstance(), binder == null ? null : binder.getJCOInstance(), toObjectFromArray(parameters), culture == null ? null : culture.getJCOInstance());
return new NetObject(objInvoke);
} catch (JCNativeException jcne) {
throw translateException(jcne);
}
}
public NetObject[] GetCustomAttributes(boolean inherit) throws Throwable {
if (classInstance == null)
throw new UnsupportedOperationException("classInstance is null.");
try {
ArrayList resultingArrayList = new ArrayList();
JCObject resultingObjects = (JCObject)classInstance.Invoke("GetCustomAttributes", inherit);
for (java.lang.Object resultingObject : resultingObjects) {
resultingArrayList.add(new NetObject(resultingObject));
}
NetObject[] resultingArray = new NetObject[resultingArrayList.size()];
resultingArray = resultingArrayList.toArray(resultingArray);
return resultingArray;
} catch (JCNativeException jcne) {
throw translateException(jcne);
}
}
public NetObject[] GetCustomAttributes(NetType attributeType, boolean inherit) throws Throwable {
if (classInstance == null)
throw new UnsupportedOperationException("classInstance is null.");
try {
ArrayList resultingArrayList = new ArrayList();
JCObject resultingObjects = (JCObject)classInstance.Invoke("GetCustomAttributes", attributeType == null ? null : attributeType.getJCOInstance(), inherit);
for (java.lang.Object resultingObject : resultingObjects) {
resultingArrayList.add(new NetObject(resultingObject));
}
NetObject[] resultingArray = new NetObject[resultingArrayList.size()];
resultingArray = resultingArrayList.toArray(resultingArray);
return resultingArray;
} catch (JCNativeException jcne) {
throw translateException(jcne);
}
}
public DynamicILInfo GetDynamicILInfo() throws Throwable, system.ArgumentException, system.IndexOutOfRangeException, system.NotSupportedException, system.ArgumentNullException, system.InvalidOperationException, system.ArgumentOutOfRangeException, system.PlatformNotSupportedException, system.ArrayTypeMismatchException, system.FormatException {
if (classInstance == null)
throw new UnsupportedOperationException("classInstance is null.");
try {
JCObject objGetDynamicILInfo = (JCObject)classInstance.Invoke("GetDynamicILInfo");
return new DynamicILInfo(objGetDynamicILInfo);
} catch (JCNativeException jcne) {
throw translateException(jcne);
}
}
public ILGenerator GetILGenerator() throws Throwable, system.NotSupportedException, system.ArgumentNullException, system.ArgumentException, system.ArgumentOutOfRangeException, system.ArrayTypeMismatchException, system.PlatformNotSupportedException, system.InvalidOperationException, system.FormatException, system.IndexOutOfRangeException, system.RankException {
if (classInstance == null)
throw new UnsupportedOperationException("classInstance is null.");
try {
JCObject objGetILGenerator = (JCObject)classInstance.Invoke("GetILGenerator");
return new ILGenerator(objGetILGenerator);
} catch (JCNativeException jcne) {
throw translateException(jcne);
}
}
public ILGenerator GetILGenerator(int streamSize) throws Throwable, system.ArgumentException, system.IndexOutOfRangeException, system.NotSupportedException, system.ArgumentNullException, system.InvalidOperationException, system.ArgumentOutOfRangeException, system.PlatformNotSupportedException, system.ArrayTypeMismatchException, system.FormatException {
if (classInstance == null)
throw new UnsupportedOperationException("classInstance is null.");
try {
JCObject objGetILGenerator = (JCObject)classInstance.Invoke("GetILGenerator", streamSize);
return new ILGenerator(objGetILGenerator);
} catch (JCNativeException jcne) {
throw translateException(jcne);
}
}
public ParameterBuilder DefineParameter(int position, ParameterAttributes attributes, java.lang.String parameterName) throws Throwable, system.ArgumentException, system.ArgumentOutOfRangeException, system.ArgumentNullException, system.InvalidOperationException, system.PlatformNotSupportedException, system.IndexOutOfRangeException, system.NotSupportedException, system.globalization.CultureNotFoundException, system.ObjectDisposedException {
if (classInstance == null)
throw new UnsupportedOperationException("classInstance is null.");
try {
JCObject objDefineParameter = (JCObject)classInstance.Invoke("DefineParameter", position, attributes == null ? null : attributes.getJCOInstance(), parameterName);
return new ParameterBuilder(objDefineParameter);
} catch (JCNativeException jcne) {
throw translateException(jcne);
}
}
public MethodImplAttributes GetMethodImplementationFlags() throws Throwable {
if (classInstance == null)
throw new UnsupportedOperationException("classInstance is null.");
try {
JCObject objGetMethodImplementationFlags = (JCObject)classInstance.Invoke("GetMethodImplementationFlags");
return new MethodImplAttributes(objGetMethodImplementationFlags);
} catch (JCNativeException jcne) {
throw translateException(jcne);
}
}
public MethodInfo GetBaseDefinition() throws Throwable {
if (classInstance == null)
throw new UnsupportedOperationException("classInstance is null.");
try {
JCObject objGetBaseDefinition = (JCObject)classInstance.Invoke("GetBaseDefinition");
return new MethodInfo(objGetBaseDefinition);
} catch (JCNativeException jcne) {
throw translateException(jcne);
}
}
public ParameterInfo[] GetParameters() throws Throwable {
if (classInstance == null)
throw new UnsupportedOperationException("classInstance is null.");
try {
ArrayList resultingArrayList = new ArrayList();
JCObject resultingObjects = (JCObject)classInstance.Invoke("GetParameters");
for (java.lang.Object resultingObject : resultingObjects) {
resultingArrayList.add(new ParameterInfo(resultingObject));
}
ParameterInfo[] resultingArray = new ParameterInfo[resultingArrayList.size()];
resultingArray = resultingArrayList.toArray(resultingArray);
return resultingArray;
} catch (JCNativeException jcne) {
throw translateException(jcne);
}
}
// Properties section
public boolean getInitLocals() throws Throwable {
if (classInstance == null)
throw new UnsupportedOperationException("classInstance is null.");
try {
return (boolean)classInstance.Get("InitLocals");
} catch (JCNativeException jcne) {
throw translateException(jcne);
}
}
public void setInitLocals(boolean InitLocals) throws Throwable {
if (classInstance == null)
throw new UnsupportedOperationException("classInstance is null.");
try {
classInstance.Set("InitLocals", InitLocals);
} catch (JCNativeException jcne) {
throw translateException(jcne);
}
}
// Instance Events section
}