-
Notifications
You must be signed in to change notification settings - Fork 0
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
First stab at generating JNI callbacks #1
base: master
Are you sure you want to change the base?
Conversation
This doesn't seem like a change to commit into master. It's more of a starting point for a conversation about the pieces that are still missing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are the holes in the current approach that I'm not sure how to fill
. # TODO: verify that these don't duplicate | ||
$(type)_cb_wrapper(\ | ||
. # This method signature needs to be built on the model's knowledge of | ||
. # the function callback type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is really a recurring theme here.
. elsif type = "zloop_timer_fn" | ||
zloop_t *loop, int timer_id, void *arg\ | ||
. else | ||
garbage *unknown, void *arg\ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need a better way to shortcut on "unknown callback type."
But the root cause is that I don't know how to find out what we know about this callback
. else | ||
Int\ | ||
. endif | ||
Method(env, wrapper->obj, wrapper->mid, wrapper->args); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a different, but related, issue here.
We need to invoke the callback with the relevant callback args that we got here in addition to wrapper->args.
It's easy enough to do with the same sort of if/elsif construct I used above, but that approach already feels ridiculous.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In order to make this happen with the current approach, we really need multiple ICallback variations. Each with an appropriate method signature.
// Shortcut to throw a NoSuchMethodError | ||
return; | ||
} | ||
$(type) $(c_name)_$(type) = $(type)_cb_wrapper; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This
If nothing else, it's duplicated in too many places for comfort and should be part of the container's data instead.
@@ -899,6 +948,14 @@ $(project.GENERATED_WARNING_HEADER:) | |||
#include "$(project.header:)" | |||
#include "$(my.cname:).h" | |||
|
|||
// TODO: This doesn't really belong in here |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm just fuzzy about a) where would be better and b) the best way to make that happen
@@ -169,6 +195,7 @@ function resolve_method (method) | |||
|
|||
if variadic = 1 | |||
if va_start <> "format" | |||
# I think this is where the Zloop constructor breaks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Different issue. Doesn't belong here.
@@ -197,6 +224,8 @@ function resolve_method (method) | |||
jni_native_invocation_c += "$(comma)($(argument.c_type)) (intptr_t) &$(argument.c_name)" | |||
elsif jni_is_class = 1 | type = "anything" | type = "sockish" | |||
jni_native_invocation_c += "$(comma)($(argument.c_type)) (intptr_t) $(argument.c_name)" | |||
elsif argument.callback ?= 1 | |||
jni_native_invocation_c += "$(comma) $(argument.c_name)_$(argument.type)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Big gaping hole: need to replace the "args" parameter with a pointer to a jni_cb_struct.
Which means we need to malloc that. And make sure it gets freed.
This doesn't seem like a change to commit into master. It's more of a
starting point for a conversation about the pieces that are still
missing.