-
Notifications
You must be signed in to change notification settings - Fork 196
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
[cppia] Cant seem to get host to call extern super functions #1150
Comments
If i do the following (in the host): var superClass = Type.getSuperClass(Type.getClass(button));
while (superClass != null) {
trace(Type.getClassName(superClass));
superClass = Type.getSuperClass(superClass);
} (
/shrug |
This stuff can get a little confusing. |
Im not sure im fully following what you mean, but as far as i can tell, yeah, the issue seems to be that "super.xxx" calls the super class at the base of the class tree (thats an assumption on my part), but it certainly doesnt seem to call the "in between ones" |
FYI - @dazKind has also repro'd it and actually, extern classes arent needed at all - i didnt think to test that, i assumed |
I think |
Here is a minimal example: bar@foo /cygdrive/D/Development/regressions
$ make native
haxe native.hxml -debug
haxelib run hxcpp Build.xml haxe -Ddebug -Dhaxe="4.3.4" -Dhaxe3="1" -Dhaxe4="1" -Dhaxe_ver="4.304" -Dhxcpp_api_level="430" -Dhxcpp_smart_strings="1" -Dsource_header="Generated by Haxe 4.3.4" -Dstatic="1" -Dtarget.atomics="1" -Dtarget.name="cpp" -Dtarget.static="1" -Dtarget.sys="1" -Dtarget.threaded="1" -Dtarget.unicode="1" -Dtarget.utf16="1" -Dutf16="1" -Isrc/ -I -IC:\\haxe\\extraLibs/ -IC:\\haxe\\std/cpp/_std/ -IC:\\haxe\\std/
bin/Host-debug.exe
src/FakeTypes.hx:27: >>>>>>>>>>>>>>>>>>>>>>>>> SOME FUNCTION: FakeComponentBase
src/FakeTypes.hx:18: >>>>>>>>>>>>>>>>>>>>>>>>> SOME FUNCTION: FakeComponent
src/FakeTypes.hx:11: >>>>>>>>>>>>>>>>>>>>>>>>> SOME FUNCTION: FakeInteractiveComponent
src/FakeTypes.hx:4: >>>>>>>>>>>>>>>>>>>>>>>>> SOME FUNCTION: FakeButton
src/Script.hx:14: >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> MyFakeButton.someFunction
bar@foo /cygdrive/D/Development/regressions
$ make
haxe host.hxml -debug
haxelib run hxcpp Build.xml haxe -Ddebug -Ddll_export="bin/export_classes.info" -Dhaxe="4.3.4" -Dhaxe3="1" -Dhaxe4="1" -Dhaxe_ver="4.304" -Dhxcpp_api_level="430" -Dhxcpp_smart_strings="1" -Dscriptable="1" -Dsource_header="Generated by Haxe 4.3.4" -Dstatic="1" -Dtarget.atomics="1" -Dtarget.name="cpp" -Dtarget.static="1" -Dtarget.sys="1" -Dtarget.threaded="1" -Dtarget.unicode="1" -Dtarget.utf16="1" -Dutf16="1" -Isrc/ -I -IC:\\haxe\\extraLibs/ -IC:\\haxe\\std/cpp/_std/ -IC:\\haxe\\std/
Link: D:/.hxcpp_cache/hxcpp_runtime/lib/msvc1964_debug_c_hxcpp_runtime.lib
Link: Host-debug.exe
Creating library Host-debug.lib and object Host-debug.exp
haxe script.hxml -debug
bin/Host-debug.exe
src/Host.hx:7: Hello from cppia HOST
src/FakeTypes.hx:27: >>>>>>>>>>>>>>>>>>>>>>>>> SOME FUNCTION: FakeComponentBase
src/Script.hx:14: >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> MyFakeButton.someFunction |
I had a look at this since I got abstract classes working on cppia a while back. Turning on the cppia logging everything looked alright, it recognised The problems seems to be registering those classes in the host which are between the cppia child and the root parent, all those intermediate parents have Looking at gencpp the function which builds the list of scriptable functions does something very odd when it encounters a function marked as override let current_virtual_functions_rev clazz base_functions =
List.fold_left (fun result elem -> match follow elem.cf_type, elem.cf_kind with
| _, Method MethDynamic -> result
| TFun (args,return_type), Method _ ->
if (is_override elem ) then
List.map (fun (e,a,r) -> if e.cf_name<>elem.cf_name then (e,a,r) else (elem,args,return_type) ) result
else
(elem,args,return_type) :: result
| _,_ -> result
) base_functions clazz.cl_ordered_fields
;; It just maps the existing accumulated results, never adding the overridden function, hence the null scriptable functions. I'm assuming at some point in history it traversed the class tree since thats the only thing I can think of where this code might make sense, but if it once did it does not anymore. https://github.com/Aidan63/haxe/tree/cppia-overloads I seem to have a fix in the above branch, I'm a bit nervous about it due to the odd original code and the big comment warning about the order of functions for cppia. But all tests still pass and the posted sample works, so hopefully even if its not perfect its a bit better than before and nothing has regressed. I'll give it another look tomorrow and open a PR. |
So Ive reduced my problem scope to the following:
In the cppia host:
As expected if you create an instance of this in the host (
new FakeButton()
) and call thesomeFunction()
then things trace as you would imagine:All fine, however, in the script file, i have a set of externs for these classes, as well as a class that extends one of these externs:
When i load this script into the host, create an instance of the
FakeButton
(viacpp.cppia.Module.resolveClass
) and callsomeFunction
i, weirdly, get the following:Its like its skipped the rest of the class hierarchy or something, ive tried various things but can never seem to get it to call, for example,
FakeComponent.someFunction
Any thoughts, is there something ive doing incredibly wrong here?
Note1: i tried adding
override
to the extern functions, same thingNote2: a similar thing is perfectly fine with js (obviously not using cppia), but dynamically loading a .js file and creating class instances
Note3: i thought it might be somewhat related to: #423 - albiet not using externs, etc - but my understanding is that issue was fixed anyway
The text was updated successfully, but these errors were encountered: