Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Generic method in Jurassic #98

Open
823639792 opened this issue Mar 31, 2017 · 0 comments
Open

Use Generic method in Jurassic #98

823639792 opened this issue Mar 31, 2017 · 0 comments

Comments

@823639792
Copy link

I am using Jurassic in Unity3d and can't edit unity source code.
and I want to use generic method such as "List"、"Dictionary"。
So I edit Jurassic code in Jurassic.Compiler.BinderUtilities.ResolveOverloads():

// Get methods from the handles.
var methods = new BinderMethod[methodHandles.Length];
for (int i = 0; i < methodHandles.Length; i++)
{
	//add by hzy  support generic class
	if(thisValue is ClrInstanceWrapper)
	{
		if((thisValue as ClrInstanceWrapper).WrappedInstance.GetType().IsGenericType)
		{
			methods[i] = new BinderMethod(MethodBase.GetMethodFromHandle(methodHandles[i], 
				(thisValue as ClrInstanceWrapper).WrappedInstance.GetType().TypeHandle));
		}
		else
		{
			methods[i] = new BinderMethod(MethodBase.GetMethodFromHandle(methodHandles[i]));
		}
	}
	else if(thisValue is ClrStaticTypeWrapper)
	{
		if((thisValue as ClrStaticTypeWrapper).WrappedType.IsGenericType)
		{
			methods[i] = new BinderMethod(MethodBase.GetMethodFromHandle(methodHandles[i], 
				(thisValue as ClrStaticTypeWrapper).WrappedType.TypeHandle));
		}
		else
		{
			methods[i] = new BinderMethod(MethodBase.GetMethodFromHandle(methodHandles[i]));
		}
	}
	else
	{
		methods[i] = new BinderMethod(MethodBase.GetMethodFromHandle(methodHandles[i]));
	}
}

It's work well。
Does this make any mistakes?

And I also want to extend unity inner class, such as

        public static int Add100(this Transform input)
        {
            return input.public_value + 100;
        }

I edit Jurassic source code, In win32 process I success, but int unity3d I failed. the extended function can not access in javascript.

Do you have any advice?
@paulbartrum

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant