property dynamic getter/setter issue on Android

79 views
Skip to first unread message

Aleksandar Bogdanovic

unread,
Oct 3, 2012, 5:17:57 PM10/3/12
to haxe...@googlegroups.com
Hi, all.

I'm playing with HAXE these days. Trying to make cross-platform library and I need for it dynamically added setters and getters.
As I see it works on Flash and Windows but when I try to compile for Android I get following error:

./src/be/zajac/test/Test.cpp: In member function 'virtual Dynamic be::zajac::test::Test_obj::__Field(const String&, bool)':
./src/be/zajac/test/Test.cpp:307: error: operands to ?: have different types 'Dynamic' and 'int'

Which is related to this line:

public var backgroundColor(dynamic, dynamic): Int;

But when I replace Int with Dynamic it passes compilation and it works.
As this is library I want to limit 3rd party to set other values than Int.

I was digging deeper and figure out why is this error raising. My backgroundColor variable is compiled to Test.h file as this:

int backgroundColor; /* REM */ 
Dynamic get_backgroundColor;
Dynamic set_backgroundColor;

And in Test.cpp getting value from backgroundColor is compiled like this:

if (HX_FIELD_EQ(inName,"backgroundColor") ) { return inCallProp ? get_backgroundColor() : backgroundColor; }

so VisualC++ do not care about data type returned after "?", but Android NDK is strict in this case.

Is there any way to solve this situation? I need interface to stay as it is.

Boky

Hugh

unread,
Oct 4, 2012, 12:26:56 AM10/4/12
to haxe...@googlegroups.com
Hi,
This looks like a bug in the cpp backend that can't be resolved without a compiler update.
You could work around it by not using (dynamic,dynamic), like:


public var backgroundColor(_getBG, _setBg): Int;
public var get_backgroundColor:Void->Int;
var backgroundColor:Int;
inline function _getBg():Int { return get_backgroundColor(); } 

Hugh
Reply all
Reply to author
Forward
0 new messages