X Tutup
Skip to content

[cppia] Cant seem to get host to call extern super functions #1150

@ianharrigan

Description

@ianharrigan

So Ive reduced my problem scope to the following:

In the cppia host:

class FakeButton extends FakeInteractiveComponent {
    public override function someFunction() {
        super.someFunction();
        trace(">>>>>>>>>>>>>>>>>>>>>>>>> SOME FUNCTION: FakeButton");
    }
}

class FakeInteractiveComponent extends FakeComponent {
    public override function someFunction() {
        super.someFunction();
        trace(">>>>>>>>>>>>>>>>>>>>>>>>> SOME FUNCTION: FakeInteractiveComponent");
    }
}

class FakeComponent extends FakeComponentBase {
    public override function someFunction() {
        super.someFunction();
        trace(">>>>>>>>>>>>>>>>>>>>>>>>> SOME FUNCTION: FakeComponent");
    }
}

class FakeComponentBase {
    public function new() {
    }

    public function someFunction() {
        trace(">>>>>>>>>>>>>>>>>>>>>>>>> SOME FUNCTION: FakeComponentBase");
    }
}

As expected if you create an instance of this in the host (new FakeButton()) and call the someFunction() then things trace as you would imagine:

src/fake/FakeComponentBase.hx:8: >>>>>>>>>>>>>>>>>>>>>>>>> SOME FUNCTION: FakeComponentBase
src/fake/FakeComponent.hx:6: >>>>>>>>>>>>>>>>>>>>>>>>> SOME FUNCTION: FakeComponent
src/fake/FakeInteractiveComponent.hx:6: >>>>>>>>>>>>>>>>>>>>>>>>> SOME FUNCTION: FakeInteractiveComponent
src/fake/FakeButton.hx:6: >>>>>>>>>>>>>>>>>>>>>>>>> SOME FUNCTION: FakeButton

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:

@:expose("MyFakeButton")
class MyFakeButton extends FakeButton {
    public override function someFunction() {
        super.someFunction();
        trace(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> MyFakeButton.someFunction");
    }
}

extern class FakeButton extends FakeInteractiveComponent {
    public function someFunction():Void;
}

extern class FakeInteractiveComponent extends FakeComponent {
    public function someFunction():Void;
}

extern class FakeComponent extends FakeComponentBase {
    public function someFunction():Void;
}

extern class FakeComponentBase {
    public function someFunction():Void;
}

When i load this script into the host, create an instance of the FakeButton (via cpp.cppia.Module.resolveClass) and call someFunction i, weirdly, get the following:

src/fake/FakeComponentBase.hx:8: >>>>>>>>>>>>>>>>>>>>>>>>> SOME FUNCTION: FakeComponentBase
src/MyFakeButton.hx:9: >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> MyFakeButton.someFunction

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 thing

Note2: 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

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

      X Tutup