Skip to content

Instantly share code, notes, and snippets.

@RedHatter
Created January 27, 2018 21:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RedHatter/a722b9dba6377e22f2c490ebdac5aa8c to your computer and use it in GitHub Desktop.
Save RedHatter/a722b9dba6377e22f2c490ebdac5aa8c to your computer and use it in GitHub Desktop.
Gjs doesn't seem to execute Vala constructors. test.js should print 5 but instead it prints 0.
#!/bin/sh
valac gjs_constructor_test.vala -X -fPIC -X -shared -o gjs_constructor_test.so --library=GjsConstructorTest --gir GjsConstructorTest-0.1.gir
g-ir-compiler --shared-library=gjs_constructor_test.so --output=GjsConstructorTest-0.1.typelib GjsConstructorTest-0.1.gir
cp gjs_constructor_test.so /usr/lib/
cp GjsConstructorTest-0.1.typelib /usr/lib/girepository-1.0/
namespace GjsConstructorTest {
public class TestClass : GLib.Object
{
private int field;
public TestClass () {
this.field = 5;
}
public int getField () {
return this.field;
}
}
}
#!/bin/gjs
const TestClass = imports.gi.GjsConstructorTest.TestClass
let test = new TestClass()
print(test.getField())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment