Skip to content

Commit

Permalink
nw.js with nw-gyp auto build hello world works.
Browse files Browse the repository at this point in the history
  • Loading branch information
brett committed Dec 1, 2015
1 parent 99906f6 commit f341df4
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
30 changes: 26 additions & 4 deletions examples/hello_nw_gyp.md
Expand Up @@ -40,8 +40,30 @@ NODE_MODULE(binding, init)

```

Nw.js
------
tests the c++ module from javascript

var assert = require('assert');
var binding = require('./build/Release/binding');
assert.equal('world', binding.hello());
console.log('binding.hello() =', binding.hello());
@myscript.js
```rusthon
#backend:javascript
mymodule = require('./build/Release/binding')
def test():
alert( mymodule.hello() )

```

HTML
-----

@index.html
```html
<html>
<head>
<@myscript.js>
</head>
<body>
<button onclick="javascript:test()">clickme</button>
</body>
</html>
```
5 changes: 4 additions & 1 deletion rusthon.py
Expand Up @@ -1736,8 +1736,11 @@ def main():
tmpdir = tempfile.gettempdir()
for pak in package['javascript']:
fname = pak['name']
if not fname.endswith('.js'):
if fname is None:
fname = 'rusthon-temp.js'
elif not fname.endswith('.js'):
fname += '.js'

fpath = os.path.join(tmpdir, fname)
open(fpath, 'wb').write( pak['script'] )
#xxx = pak['script'].decode('utf-8')
Expand Down

0 comments on commit f341df4

Please sign in to comment.