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

Registrable generators: add support for lua, python #1808

Draft
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

deadlocklogic
Copy link
Contributor

@deadlocklogic deadlocklogic commented Dec 14, 2023

This PR will add support for registrable generators: lua, python etc..., basically any language which has a registration API.
This will be the migration of my own work which I talked about many times before, it should be a straightforward task, bear with me.

@deadlocklogic deadlocklogic marked this pull request as draft December 14, 2023 06:29
@deadlocklogic
Copy link
Contributor Author

deadlocklogic commented Dec 14, 2023

I have to refactor the last part which interferes with this PR: the passes.
Right now some passes have undesired effects, like templates, bitfields are automatically excluded from generation, which shouldn't be generalized.
FieldToPropertyPass shouldn't be forced on all generators, especially for scripting languages.

@tritao
Copy link
Collaborator

tritao commented Dec 14, 2023

Haven't gone through this in detail yet, but can you explain what it means for a generator to be registrable? Why do we need this new concept?

@deadlocklogic
Copy link
Contributor Author

deadlocklogic commented Dec 15, 2023

I am not finished yet though, this is just is bare minimal implementation, still many concepts missing: templates, protected base classes, typemaps to name a few. So I advise you to not review the code in detail because, the common code will be extracted away.
Basically from my experience, there are 3 major techniques to bind with C++, we can call them generator families/categories:

Structural:

Just like the C# generator, it is C++-like code structure for binding.
Such family is useful too for generating API functions, just like the typescript one.
Pseudocode:

class Type {
    Type();
    void method();
}

Registrable:

Like sol, pybind, luabind, and any C++ helper library built on top of a C style API
Pseudocode:

Scope {
type<Type>(state)
.constructor<Type>()
.method("method", &method);
}

Functional:

Here bindings will heavily rely on creating a separate function for each binding entity (just like with pure C API):
Pseudocode:

void wrapper_type_constructor(state s) {
// ...
}
void wrapper_type_method(state s) {
// ...
}
// And then we register all the functions to the state.

So I thought creating a base generator for each of these 3 concepts will ease the extension for newer one.

I prefer these categories to reside in separate folders not in the current hierarchy, but for now I will keep them there to avoid messing with the build system.

Haven't gone through this in detail yet, but can you explain what it means for a generator to be registrable? Why do we need this new concept?

As far as I noticed, the only feature complete generator to some extent is the C#/CLI one (it is a general assessment), the others are just prototypes, incomplete work etc..., with a lot of redundancy between them.
What I am trying to do is introducing common concepts which will implement all the needed boilerplate in a methodical/documented way, the user's task will be easy with minimum margin of errors.

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.

None yet

2 participants