Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Where can I find documents about node-gir please? #33

Open
tiye opened this issue Dec 1, 2012 · 4 comments
Open

Where can I find documents about node-gir please? #33

tiye opened this issue Dec 1, 2012 · 4 comments

Comments

@tiye
Copy link

tiye commented Dec 1, 2012

As I discovered that GNOME's docs are really unfriendly to JS-only developers.
And after a long time I didn't find a document about seed or gjs as friendly as Node APIs.
That's why I want to try node-gir.
Please is there any document I can refer to in writing GTK applications with node-gir?
I mean is there a plain description about gir when you implement node-gir?

Thanks.

@piotras
Copy link
Collaborator

piotras commented Dec 1, 2012

Current "plain description" is let's make it work and cover all fundamental operations with tests. Depending on expectation I would place node-gir between alfa na beta. GIR itself is not mature enough (though it's stable enough) to describe every single detail. GTK itself has been designed for C developers and docs are friendly for such. Node-gir provides runtime dynamic bindings so if you expect API docs, one should provide special routines to generate Node ones. The more feedback we have the node-gir design is more strict and clear.

@tiye
Copy link
Author

tiye commented Dec 2, 2012

@piotras You mean node-gir is now alpha version.
No wonder loading "Gtk" module is slower than that in Seed.
By now only Gjs is mature enough then?

@piotras
Copy link
Collaborator

piotras commented Dec 2, 2012

@jiyinyiyong I would say it's between alpha and beta. Check tests: https://travis-ci.org/piotras/node-gir/builds/2897206.
They pass for most fundamental types and options. Still there's a lack of in&out arguments, but I find them only C level friendly. Wrt module loading speed. Do you have some real numbers? What about runtime performance? I can take a look and check module loading time, but I would like to know whether I need to fix 5% or 65% for example.

@tiye
Copy link
Author

tiye commented Dec 3, 2012

Test two files here:
load.js

// Generated by CoffeeScript 1.4.0
var Gtk, gir;

if (typeof console !== "undefined" && console !== null) {
  gir = require('gir');
  gir.load('Gtk', '3.0');
} else if (typeof print !== "undefined" && print !== null) {
  Gtk = imports.gi.Gtk;
}

log.js

// Generated by CoffeeScript 1.4.0

if (typeof console !== "undefined" && console !== null) {
  console.log('node');
} else if (typeof print !== "undefined" && print !== null) {
  print('seed');
}

Run in terminal

➤➤ time node load.js 

real    0m1.482s
user    0m1.367s
sys 0m0.123s
➤➤ time seed load.js 

real    0m0.112s
user    0m0.083s
sys 0m0.027s
➤➤ time node log.js 
node

real    0m0.057s
user    0m0.050s
sys 0m0.003s
➤➤ time seed log.js 
seed

real    0m0.039s
user    0m0.023s
sys 0m0.013s
➤➤ uname -a
Linux up 3.6.8-1-ARCH #1 SMP PREEMPT Mon Nov 26 22:10:40 CET 2012 x86_64 GNU/Linux
➤➤ node -v
v0.8.15
➤➤ seed --version
Seed 3.2.0

I found a problem... and I made it work(however I dont't know why is that)

➤➤ node load.js 

module.js:340
    throw err;
          ^
Error: Cannot find module './build/Release/lib.target/girepository.node'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:362:17)
    at require (module.js:378:17)
    at Object.<anonymous> (/home/chen/code/tmp/node_modules/gir/gir.js:8:28)
    at Module._compile (module.js:449:26)
    at Object.Module._extensions..js (module.js:467:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:362:17)
➤➤ c node_modules/gir/build/Release/lib.target/
girepository.so
➤➤ cp girepository.so girepository.node
➤➤ c -
load.coffee  load.js  log.coffee  log.js  node_modules/
➤➤ time node load

real    0m1.614s
user    0m1.400s
sys 0m0.120s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants