HaxeFoundation / HaxeFoundation/hxcpp

cppia: add scripting support code only for selected classes

Open
#1,051 2 comments 1 reaction 0 assignees View on GitHub
Dominant language
C++
Stars
330
Forks
227
Avg merge
2d 16h
Merged PRs (30d)
18

Description

When compiling haxe code with the '-D scriptable' option, the compiler adds additional C++ code to provide support for scripting. However, this code does not compile when the original Haxe code interacts with native C++ types.

```haxe
class Main {
static function main() {
trace('Hello from cppia HOST');
var scriptname = './script.cppia';
cpp.cppia.Host.runFile(scriptname);
}

// the problem is here: I'm using cpp type `void*`
static function cppTest(param: cpp.Star): Void {
trace(param);
}
}
```

Cpp compiler error and corresponding code:
```
./src/Main.cpp:108:19: error: no viable conversion from 'Dynamic' to 'void *'

static void CPPIA_CALL __s_cppTest(::hx::CppiaCtx *ctx) {
Main_obj::cppTest(ctx->getObject(sizeof(void*)));
}
```
Here, `ctx->getObject()` returns `Dynamic`, but `cppTest` expects `void*`.

I do not need this function to be available for cppia scripts, as there is a limited set of classes and functions that should be available. Is it possible to generate the scripting support code only for selected classes and functions?

This is a duplicate of https://community.haxe.org/t/cppia-do-not-add-scripting-support-to-some-classes/3933

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.