Created
June 13, 2010 08:50
-
-
Save andyli/436483 to your computer and use it in GitHub Desktop.
To illustrate a hxcpp bug.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <hxcpp.h> | |
#ifndef INCLUDED_A | |
#include <A.h> | |
#endif | |
#ifndef INCLUDED_Main | |
#include <Main.h> | |
#endif | |
#ifndef INCLUDED_haxe_Log | |
#include <haxe/Log.h> | |
#endif | |
Void Main_obj::__construct() | |
{ | |
return null(); | |
} | |
Main_obj::~Main_obj() { } | |
Dynamic Main_obj::__CreateEmpty() { return new Main_obj; } | |
hx::ObjectPtr< Main_obj > Main_obj::__new() | |
{ hx::ObjectPtr< Main_obj > result = new Main_obj(); | |
result->__construct(); | |
return result;} | |
Dynamic Main_obj::__Create(hx::DynamicArray inArgs) | |
{ hx::ObjectPtr< Main_obj > result = new Main_obj(); | |
result->__construct(); | |
return result;} | |
Void Main_obj::main( ){ | |
{ | |
__SAFE_POINT | |
HX_BEGIN_LOCAL_FUNC0(_Function_1_1) | |
Void run(){ | |
{ | |
__SAFE_POINT | |
struct _Function_2_1{ | |
inline static Dynamic Block( ){ | |
hx::Anon __result = hx::Anon_obj::Create(); | |
__result->Add(HX_STRING(L"fileName",8) , HX_STRING(L"Main.hx",7)); | |
__result->Add(HX_STRING(L"lineNumber",10) , 11); | |
__result->Add(HX_STRING(L"className",9) , HX_STRING(L"Main",4)); | |
__result->Add(HX_STRING(L"methodName",10) , HX_STRING(L"main",4)); | |
return __result; | |
} | |
}; | |
::haxe::Log_obj::trace(HX_STRING(L"f2",2),_Function_2_1::Block()); | |
} | |
return null(); | |
} | |
HX_END_LOCAL_FUNC0((void)) | |
HX_BEGIN_LOCAL_FUNC0(_Function_1_2) | |
Void run(){ | |
{ | |
__SAFE_POINT | |
struct _Function_2_1{ | |
inline static Dynamic Block( ){ | |
hx::Anon __result = hx::Anon_obj::Create(); | |
__result->Add(HX_STRING(L"fileName",8) , HX_STRING(L"Main.hx",7)); | |
__result->Add(HX_STRING(L"lineNumber",10) , 10); | |
__result->Add(HX_STRING(L"className",9) , HX_STRING(L"Main",4)); | |
__result->Add(HX_STRING(L"methodName",10) , HX_STRING(L"main",4)); | |
return __result; | |
} | |
}; | |
::haxe::Log_obj::trace(HX_STRING(L"f1",2),_Function_2_1::Block()); | |
} | |
return null(); | |
} | |
HX_END_LOCAL_FUNC0((void)) | |
::A_obj::__new()->callFunction( Dynamic(new _Function_1_1()))->callFunction( Dynamic(new _Function_1_2())); | |
} | |
return null(); | |
} | |
STATIC_HX_DEFINE_DYNAMIC_FUNC0(Main_obj,main,(void)) | |
Main_obj::Main_obj() | |
{ | |
} | |
void Main_obj::__Mark() | |
{ | |
} | |
Dynamic Main_obj::__Field(const ::String &inName) | |
{ | |
switch(inName.length) { | |
case 4: | |
if (!memcmp(inName.__s,L"main",sizeof(wchar_t)*4) ) { return main_dyn(); } | |
} | |
return super::__Field(inName); | |
} | |
Dynamic Main_obj::__SetField(const ::String &inName,const Dynamic &inValue) | |
{ | |
return super::__SetField(inName,inValue); | |
} | |
void Main_obj::__GetFields(Array< ::String> &outFields) | |
{ | |
super::__GetFields(outFields); | |
}; | |
static ::String sStaticFields[] = { | |
HX_STRING(L"main",4), | |
String(null()) }; | |
static ::String sMemberFields[] = { | |
String(null()) }; | |
static void sMarkStatics() { | |
}; | |
Class Main_obj::__mClass; | |
void Main_obj::__register() | |
{ | |
Static(__mClass) = hx::RegisterClass(HX_STRING(L"Main",4), hx::TCanCast< Main_obj> ,sStaticFields,sMemberFields, | |
&__CreateEmpty, &__Create, | |
&super::__SGetClass(), 0, sMarkStatics); | |
} | |
void Main_obj::__boot() | |
{ | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class A { | |
public function new() {} | |
public function callFunction(func:Void->Void):A { func(); return this; } | |
} | |
class Main{ | |
static function main() { | |
new A() | |
.callFunction(function(){trace("f1");}) | |
.callFunction(function(){trace("f2");}); | |
} | |
} |
The following code will produce correct output, tested on windows with msvc 2005:
class A {
public function new() {}
public function callFunction(func:Void->Void):A { func(); return this; }
}
class Main{
static function main() {
var f1 = function() { trace("f1"); };
var f2 = function() { trace("f2"); };
new A()
.callFunction(f1)
.callFunction(f2);
}
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
"Main.cpp" is compiled from "Main.hx".
The program should trace out "f1, f2". But it traces out "f2, f1".
"Main.cpp" is generated wrong.
Reported to http://code.google.com/p/hxcpp/issues/detail?id=27