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

Introduce script wrapping classes #46

Open
nemerle opened this issue Mar 8, 2020 · 0 comments
Open

Introduce script wrapping classes #46

nemerle opened this issue Mar 8, 2020 · 0 comments
Labels

Comments

@nemerle
Copy link
Collaborator

nemerle commented Mar 8, 2020

Right now many of the components accessible from the scripting language are made available through the following pattern:

  1. Store a pointer to script instance in the object ScriptInstance *script_instance;
  2. A method that can be overridden by a script is constructed using this template:
return_type ClassName::method(int argument) {

  if (get_script_instance() && get_script_instance()->has_method(StringNames(method)))
      return get_script_instance()->call(StringName(_estimate_cost), argument).as<return_type>();

This causes all of those methods to provide sub-optimal performance, since all calls have to perform those checks, even if the object itself was not created from the script-side.

I think this is a thing that was solved much more elegantly by SWIG's Director classes, where every class that has methods overrideable from script-side has a companion Director class that handles script langue calls, thus the main c++ code doesn't have to carry so much script-side baggage :)

To be honest, I'd much prefer if we were using SWIG to generate all bindings and had all of those things automated for us, but that'd require some work on the SWIG generator for Gdscript + maybe changing the way c# swig generator works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant