HaxeFoundation / HaxeFoundation/hxcpp

[`-D scriptable`]: functions with raw pointer arguments or return type don't compile

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

Description

I have noticed an issue when compiling a project with `-D scriptable` that uses `hxvlc` and `hxdiscord_rpc`.
Seemingly functions that have arguments that are raw pointers or a return type that is a raw pointer, don't compile.
Also functions that return a defined type from raw cpp code, also don't compile.

For example: It tries to cast `Dynamic` to `void*`, which isn't possible. The reason this happens is because it uses `StackContext::runObject` and `StackContext::getObject` return `Dynamic`.

generated cpp code snippets:
```cpp
void* videoLock( void** planes ) {
if (__scriptVTable[140] ) {
::hx::CppiaCtx *__ctx = ::hx::CppiaCtx::getCurrent();
::hx::AutoStack __as(__ctx);
__ctx->pushObject(this);
__ctx->pushObject(planes);
return __ctx->runObject(__scriptVTable[140] ); // returns Dynamic, but we need void*
} else return Video_obj::videoLock(planes);return null();}

// ...

template
static void CPPIA_CALL __s_videoLock(::hx::CppiaCtx *ctx) {
ctx->returnObject( _HX_SUPER ? ((Video_obj*)ctx->getThis())->Video_obj::videoLock(ctx->getObject(sizeof(void*))) : ((Video_obj*)ctx->getThis())->videoLock(ctx->getObject(sizeof(void*))));
}
```

```cpp
DiscordRichPresence buildPresence( ::Dynamic params ) {
if (__scriptVTable[6] ) {
::hx::CppiaCtx *__ctx = ::hx::CppiaCtx::getCurrent();
::hx::AutoStack __as(__ctx);
__ctx->pushObject(this);
__ctx->pushObject(params);
return __ctx->runObject(__scriptVTable[6] ); // returns Dynamic, but we need DiscordRichPresence
} else return DiscordClient_obj::buildPresence(params);return null();}

// ...

template
static void CPPIA_CALL __s_buildPresence(::hx::CppiaCtx *ctx) {
ctx->returnObject( _HX_SUPER ? ((DiscordClient_obj*)ctx->getThis())->DiscordClient_obj::buildPresence(ctx->getObject(sizeof(void*))) : ((DiscordClient_obj*)ctx->getThis())->buildPresence(ctx->getObject(sizeof(void*))));
}
```

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.