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

Bind delegates with higher-level managed types #511

Open
tritao opened this issue Jul 2, 2015 · 2 comments
Open

Bind delegates with higher-level managed types #511

tritao opened this issue Jul 2, 2015 · 2 comments

Comments

@tritao
Copy link
Collaborator

tritao commented Jul 2, 2015

Imagine a callback in native code:
void Callback(Class& c);

When bound in managed it ends up as:
delegate void Callback(IntPtr c);

And we need to do later:
var c = Class.__CreateInstance(c)

Not pretty.
I think we could improve this on the generator to generate a lower-level (same as what we already generate) and higher-level proxy delegate:
delegate void Callback(Class c);

@genuinelucifer
Copy link
Contributor

@tritao How to generate 'delegate' from the function 'Callback'.. I tried to recreate it but the function ended up as another function in managed code.

@realvictorprm
Copy link
Contributor

Sorry for posting duplicates. Blame me!

I'm presenting an update to the current situation:

The new generated code should look like this:

public delegate void HighLevelDelegate (SomeClass class, int someparam);
internal delegate void LowLevelDelegate(IntPtr class, int someparam);

public void SetCallback(HighLevelDelegate del);
internal void SetCallback(LowLevelDelegate del);

However our current approach includes that each callback will be saved until the life-time of a specific class or the application itself ends.

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

3 participants