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

Add support for long enumification #1187

Open
jpobst opened this issue Feb 8, 2024 · 0 comments
Open

Add support for long enumification #1187

jpobst opened this issue Feb 8, 2024 · 0 comments
Labels
enhancement Proposed change to current functionality generator Issues binding a Java library (generator, class-parse, etc.)

Comments

@jpobst
Copy link
Contributor

jpobst commented Feb 8, 2024

Context: xamarin/xamarin-android#8182
Context: xamarin/xamarin-android#8707

We have now had 2 instances of enumification values in android.jar requiring long enums instead of int enums. As generator doesn't have any support for long enums, these had to be handled manually. Additionally, if the long enum is manually created and added to the api with:

  <add-node api-since="34" path="/api">
    <enum name="Android.Hardware.HardwareBufferUsage" />
  </add-node>

it will create the correct API, but the binding code will be created as int rather than long:

[Register ("create", "(IIIII)Landroid/hardware/HardwareBuffer;", "", ApiSince = 26)]
public static unsafe Android.Hardware.HardwareBuffer Create (int width, int height, [global::Android.Runtime.GeneratedEnum] Android.Hardware.HardwareBufferFormat format, int layers, Android.Hardware.HardwareBufferUsage usage)
{
	const string __id = "create.(IIIII)Landroid/hardware/HardwareBuffer;";
	try {
		JniArgumentValue* __args = stackalloc JniArgumentValue [5];
		__args [0] = new JniArgumentValue (width);
		__args [1] = new JniArgumentValue (height);
		__args [2] = new JniArgumentValue ((int) format);
		__args [3] = new JniArgumentValue (layers);
		__args [4] = new JniArgumentValue ((int) usage);
		var __rm = _members.StaticMethods.InvokeObjectMethod (__id, __args);
		return global::Java.Lang.Object.GetObject<Android.Hardware.HardwareBuffer> (__rm.Handle, JniHandleOwnership.TransferLocalRef)!;
	} finally {
	}
}

This requires the method to be hand-bound to fix the binding.

@jpobst jpobst added enhancement Proposed change to current functionality generator Issues binding a Java library (generator, class-parse, etc.) labels Feb 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Proposed change to current functionality generator Issues binding a Java library (generator, class-parse, etc.)
Projects
None yet
Development

No branches or pull requests

1 participant