Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[Feature] Call any Function #45

Open
xunilrj opened this issue Sep 9, 2019 · 0 comments
Open

[Feature] Call any Function #45

xunilrj opened this issue Sep 9, 2019 · 0 comments
Labels

Comments

@xunilrj
Copy link

xunilrj commented Sep 9, 2019

I don't know if this is goes against the philosophy of the library or not, but I created a fork where you can call any function. With an extra syntax for C++.

My first try is here: xunilrj@c1638e8

I created some flags that makes this feature totally opt-in.

#define CR_HOST
#define CR_ANYFUNCTION
#define CR_CPP
#include "cr.h"
...
cr_plugin_load(plugin, "c:/game.dll");
cr_plugin_load_functions(plugin, "f1,f2,f3");
...

The C version:

auto f1 = (double(*)(double))cr_plugin_get_function(plugin, 0);
auto r1 = f(1.0f);
auto f2 = (double(*)(double,double))cr_plugin_get_function(plugin, 1);
auto r2 = f(1.0f, 2.0f);

The C++ version:

auto r1 = cr_plugin_call<double>(plugin, 0, 1.0f);
auto r2 = cr_plugin_call<double>(plugin, 1, 1.0f, 2.0f);
@fungos fungos added the tip label Jan 10, 2020
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants