Open dannote opened 9 years ago
lgi normally uses _native
to unbox both objects and records. Does web_view:get_main_frame():get_global_context()._native
work?
Yes, it does. But if then I pass this pointer to JSEvaluateScript
, I get a segfault. I'm currently using ffi.C.webkit_web_frame_get_global_context(web_view:get_main_frame()._native)
for workaround.
Wait, if I push a native GObjec pointert to _native
in a table using the native Lua API then am I able to make my C code work with LGI?
@RossComputerGuy I'm not quite sure what you are asking. Perhaps https://github.com/pavouk/lgi/blob/master/docs/guide.md#8-interoperability-with-native-code already answers your question?
First of all, thank you for starting this awesome project!
I'm currently working on a service using WebKitGTK+ (It's WebKit1 interface) and I faced with the problem of JavaScriptCore GTK bindings which simply do not exist. As there is
gir
file describing two foreign structures -JavaScriptCore.GlobalContext
andJavaScriptCore.Value
- I decided to try to use LuaJIT's FFI to operate with this structures directly.So, I'm calling
web_view:get_main_frame():get_global_context()
to getJSGlobalContextRef
but the returning pointer value is slightly different from the value returned by direct FFI callffi.C.webkit_web_frame_get_global_context(web_view:get_main_frame()._native)
. It looks likeJavaScriptCore.GlobalContext
is boxed but I'm unable to find a proper way to unbox it. I've already tried someGValue
magic but it seems I'm doing it wrong. Here is what I always get:What is the recommended way to handle foreign pointers in this case?