ceylon / ceylon-js

DEPRECATED
Apache License 2.0
54 stars 9 forks source link

Stitched native declarations don't get properly exported #646

Closed quintesse closed 9 years ago

quintesse commented 9 years ago

At least that's what I think is the problem. Running the following code fails with a message saying run doesn't exist:

run.ceylon:

native
shared void run();

native("jvm")
shared void run() {
}

run.js:

function run() {
    console.log("Who am I?");
}

The run.js file gets stitched in properly I can see it in the output file, but it just doesn't get mentioned in the exports (if I add a native("js") section instead of using stitching everything works just fine)

FroMage commented 9 years ago

AFAICT exporting native code has to be done by hand. Something like ex$.run = run; after your function.

FroMage commented 9 years ago

See numbers.js in the language module for example: ex$.JSNumber=JSNumber;

FroMage commented 9 years ago

So I believe with stitching and native JS this has to be done by hand.

quintesse commented 9 years ago

Then that should at least be documented: https://github.com/ceylon/ceylon-js/wiki/Native-Compilation

FroMage commented 9 years ago

It's a Wiki, be my guest ;)

quintesse commented 9 years ago

I'm not the one that knows how this works ;)

FroMage commented 9 years ago

Well, let's ask @chochos if the current behaviour is right, or if it's even possible/desirable for the stitcher to generate the exporting itself.