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

[jnimarshalmethod-gen] Fix registration on Windows #721

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion tools/jnimarshalmethod-gen/App.cs
Expand Up @@ -489,8 +489,12 @@ static Expression CreateRegistration (string method, string signature, LambdaExp

static void AddRegisterNativeMembers (TypeBuilder dt, ParameterExpression targetType, List<Expression> registrationElements)
{
var args = Expression.Parameter (typeof (JniNativeMethodRegistrationArguments), "args");
if (Verbose) {
Console.Write ("Adding registration method for ");
ColorWriteLine ($"{dt.FullName}", ConsoleColor.Green);
}

var args = Expression.Parameter (typeof (JniNativeMethodRegistrationArguments), "args");
var body = Expression.Block (
new[]{targetType},
Expression.Assign (targetType, Expression.Call (Type_GetType, Expression.Constant (dt.FullName))),
Expand All @@ -500,6 +504,7 @@ static void AddRegisterNativeMembers (TypeBuilder dt, ParameterExpression target

var rb = dt.DefineMethod ("__RegisterNativeMembers",
System.Reflection.MethodAttributes.Public | System.Reflection.MethodAttributes.Static);
rb.SetParameters (typeof (JniNativeMethodRegistrationArguments));
rb.SetCustomAttribute (new CustomAttributeBuilder (typeof (JniAddNativeMethodRegistrationAttribute).GetConstructor (Type.EmptyTypes), new object[0]));
#if _DUMP_REGISTER_NATIVE_MEMBERS
Console.WriteLine ($"## Dumping contents of `{dt.FullName}::__RegisterNativeMembers`: ");
Expand Down