How to export a c/c++ module for Espruino?

Posted on
  • How to expose a c/c++ module to Espruino JS?

    For example, the jswrap_hello.c defines the 'Hello' class , it has a method 'world()', then we can do in Espruino:

    Hello.world();
    

    How to expose 'Hello' as a module just like 'net' or 'Wifi'? I mean 'Hello' can be required like this:

    var hello = require('Hello');
    hello.world();
    

    or

    require('Hello').world();
    
  • Just opening this again to mention this page, which has your answer: https://github.com/espruino/Espruino/blob/master/libs/README.md

  • Thank you, Gordon.

    "type" : "library" , for a built-in module as a library,
    and in JS code: var m = require('yourmodule');

    "type" : "class" , for a built-in module as a Object,
    and in JS code: yourmodule.method();

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

How to export a c/c++ module for Espruino?

Posted by Avatar for Aifer @Aifer

Actions