Skip to content

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

@lemz1

Description

@lemz1

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:

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<bool _HX_SUPER=false>
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*))));
}
 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<bool _HX_SUPER=false>
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*))));
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions