Discussion:
[webkit-help] having trouble getting simple extensions working (C++)
Aeva Palecek
2016-03-25 20:21:47 UTC
Permalink
Hello!

I'm attempting to use WebKit2GTK+ to allow me to write behaviors in C
and expose bindings for those functions to a JavaScript environment.

I've put together a very minimal base code for this here
https://github.com/Aeva/webkit2gtk-experiment. Everything seems to
build ok, but I am unable to find any evidence that the extension is
actually getting loaded. Nothing is being written to stdout by the
extension, nor does "myCFunction" appear in the 'window' object of the
page's javascript environment as expected.

I've been able to find an igalia blog post that talk about extensions
and it was helpful getting this far, though it only contains very
partial sources so I had to guess on how it should all fit together. I
also found a simple web browser that has one extension, and I used it
as a reference https://github.com/vain/lariza but in building and
tinkering with the browser, I'm not 100% convince the extensions are
loading there either.

So I guess, what I'm hoping to find out:

1) is there a simple canonical example somewhere of how to write and
use extensions and verify that they are working?

2) if anyone has the time to look at a very small base code, is there
anything obviously wrong with the code in my repository linked above?

3) if I'm completely on the wrong track, is there a simpler way to
expose C functions to js in webkit2gtk+?

Thanks for your time,
Aeva Palecek
Aeva Palecek
2016-03-26 00:14:36 UTC
Permalink
Someone pointed me to the solution. For documentation's sake: I needed
to do `extern "C" G_MODULE_EXPORT` instead of just G_MODULE_EXPORT in
the extension module.
Post by Aeva Palecek
Hello!
I'm attempting to use WebKit2GTK+ to allow me to write behaviors in C
and expose bindings for those functions to a JavaScript environment.
I've put together a very minimal base code for this here
https://github.com/Aeva/webkit2gtk-experiment. Everything seems to
build ok, but I am unable to find any evidence that the extension is
actually getting loaded. Nothing is being written to stdout by the
extension, nor does "myCFunction" appear in the 'window' object of
the page's javascript environment as expected.
I've been able to find an igalia blog post that talk about extensions
and it was helpful getting this far, though it only contains very
partial sources so I had to guess on how it should all fit together.
I also found a simple web browser that has one extension, and I used
it as a reference https://github.com/vain/lariza but in building and
tinkering with the browser, I'm not 100% convince the extensions are
loading there either.
1) is there a simple canonical example somewhere of how to write and
use extensions and verify that they are working?
2) if anyone has the time to look at a very small base code, is there
anything obviously wrong with the code in my repository linked above?
3) if I'm completely on the wrong track, is there a simpler way to
expose C functions to js in webkit2gtk+?
Thanks for your time,
Aeva Palecek
_______________________________________________
webkit-help mailing list
https://lists.webkit.org/mailman/listinfo/webkit-help
Loading...