home.social

#javascriptcoregtk — Public Fediverse posts

Live and recent posts from across the Fediverse tagged #javascriptcoregtk, aggregated by home.social.

fetched live
  1. I'm trying to write a thing in #vala with #javascriptcoregtk to run some user-defined scripts. I want to create an object which 'proxies' data from the app.

    I'm trying to use Context.register_class to register a class with some properties, and then create an instance via JSC.Value.object, but I can't manage to get the object I want.

    // test.vala
    // valac -o test --pkg javascriptcoregtk-6.0 test.vala && G_MESSAGES_DEBUG=all ./test
    
    static void main() {
      var vm = new JSC.VirtualMachine ();
      var ctx = new JSC.Context.with_virtual_machine (vm);
    
      var test_cls = ctx.register_class ("Test", null, null, null);
    
      var test = new JSC.Value.object (ctx, null, test_cls);
      info ("test is %s? %s", test_cls.name, test.object_is_instance_of (test_cls.name) ? "true": "false");
    }

    I get test is Test? false. What I understand from the docs is I should get a new instance of the class "Test".

    Anyone can tell what I'm doing wrong? 😊