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

python generator for capi interface stubs #1

Closed
wants to merge 2 commits into from

Conversation

schachmat
Copy link

Heyho,

here is a python script for automatic implementation of the cef capi interface as listed in the TODO section of README.md. Some remarks:

  • works not with the old cef version you are using, but with current one (2272)
  • the pycparser fake includes have to be copied (I can also add them to the pullreq, if you want)
  • mkdir cef/stubs has to be run
  • my version of refcounting is implemented in cef/base.[ch] If you find errors, let me know
  • script has to be called with one argument (e.g. the supplied gen.c file) and then iterates through all structs in this compilation unit after preprocessing. The main_linux.c could also be used as argument, then only the used structs from include/capi/ are generated to cef/stubs/
  • To change the code of a stub, just copy it to cef/, change it there and built with your new version instead of the stub.
  • Note: automatically release()-ing the refcounts on parameters supplied to functions is not implemented yet, but maybe soon to come.

I wrote this mainly because I want to use the C api from cef and documentation seems rare. The http://code.google.com/p/chromiumembedded/wiki/UsingTheCAPI page could also be updated with this refcounting example, if it indeed is implemented correctly (works so far for me).

--schachmat

@cztomczak
Copy link
Owner

Thanks schachmat. Will test it at the earliest opportunity.

Did you test it on Windows? I don't think pthread.h is available on Windows.

I think that the generator should also automate creation of the gen.c file.

@schachmat
Copy link
Author

I did not test it on windows, since I have no windows machine and also have no idea how to do thread locking with windows.

So I propose that implement_interface.py takes one arg which is the path to the include/capi folder, automatically generates the gen.c file which includes all headers from the capi.

For the automatic release()-ing of refcounts, I think a first pass through the struct visitor should work: In the first pass I remember all struct names, which start with a cef_base_t*, in the second pass when generating the function stubs, I check every argument to a function if it has a pointer to one remembered struct as type and if yes, I add a RDEC(argument_name) call before the return.

@schachmat
Copy link
Author

I updated my branch to automatically generate the gen.c file as you requested.

@cztomczak
Copy link
Owner

Updated to CEF branch 3029 and created Issue #5.

@cztomczak cztomczak closed this Apr 28, 2017
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

Successfully merging this pull request may close these issues.

2 participants