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

[cppia] extern static property getter #1183

Open
kevinresol opened this issue Jan 29, 2025 · 1 comment
Open

[cppia] extern static property getter #1183

kevinresol opened this issue Jan 29, 2025 · 1 comment

Comments

@kevinresol
Copy link

cpp host code:

class Host {
	public static function main() {
		trace(Test.foo); // bring the class into compilation
		cpp.cppia.Host.runFile('bin/script.cppia');
	}
}

cppia script code:

class Script {
	static function main() {
		trace("Hello from script!");
		trace(Test.foo);
	}
}

and Test.hx file for both

#if cppia
extern class Test {
	static var foo(get, never):Int;
}
#else
class Test {
	public static var foo(get, never):Int;
	static function get_foo():Int return 42;
}
#end

will result in error:

Unknown function : Test_obj::get_foo(0)
Error : Unknown global:Test_obj::get_foo
@kevinresol
Copy link
Author

Turns out I need to also declare the get_foo function in the extern.
But that's weird because instance properties (i.e. non-static) work without the getter declaration in the extern.

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

No branches or pull requests

1 participant