Questions tagged [duktape]

Duktape is a highly optimized embedded JavaScript engine for C/C++

Duktape is an MIT-licensed embedded engine for /.
Its main features are :

  • Embeddable, portable, compact:
    • 200kB code
    • 46kB startup RAM (x86, default options)
    • 22kB startup RAM (x86, lowmem options)
    • 42kLoC source (excluding comments etc)
    • Can run on platforms with 256kB flash and 96kB system RAM
  • Ecmascript E5/E5.1 compliant, some features borrowed from E6 draft
  • Built-in regular expression engine
  • Built-in Unicode support
  • Minimal platform dependencies
  • Combined reference counting and mark-and-sweep garbage collection with finalization
  • Custom features like coroutines, built-in logging framework, and built-in CommonJS-based module loading framework
  • Property virtualization using a subset of Ecmascript E6 Proxy object
93 questions
2
votes
1 answer

duktape exposing a c++ object (methods + properties)

I'm trying to export my objects to javascript but I still don't get how to bind a property "getter" and "setter". a.g: class MyObjectWrapper : public MyObject { public: void MethodToBind() { ... }; void PropertySetter(String& s) { Property =…
user3813522
  • 37
  • 1
  • 6
2
votes
1 answer

In Duktape, how to convert a JS source file content to bytecode

I would like to know how the step described below are done: How to convert a JS source file (test.js with two functions, funcA() and funcB()) to bytecode? How to load the generated bytecode into duktape and invoke one of the functions, say…
Alex Net
  • 164
  • 12
2
votes
1 answer

Use promise on Duktape

How can we use promise on top of Duktape? My Scenario: Migrating a client side javascript code that loads well on web browsers to Duktape. I am using Dukluv (binding with Duktape and libuv library) binary to run the JavaScript. However my javascript…
Romaan
  • 2,645
  • 5
  • 32
  • 63
1
vote
0 answers

Duktape Copying Objects

I've got a duktape stack with the item on the top of the stack being effectively a JSON object, built with duk_push_string() / duk_put_prop_string(). My resulting object in javascript land is called 'obj', and I want to create a copy of obj, and…
Trumpton
  • 11
  • 1
1
vote
1 answer

How can I do some clean up jobs when an object is being deleted / disposed in duktape?

I have a self-defined class that calls a native method to allocate buffer in the constructor method, like below: MyClass = function () { this.buffer = native.alloc() } The buffer has to be released when the instance of MyClass is being…
Link Hylia
  • 63
  • 6
1
vote
1 answer

How to use multiple js files with Duktape?

I'm using Duktape in embedded MCU. For test case i have: main.js file: (function(){ test(); })(); test.js file: (function test(){ print("func"); }) Both compiled as global default code and main.js is executed with duk_call(ctx, 0); The…
Waymaker
  • 23
  • 6
1
vote
0 answers

Print function call stack in fatal handler of the duktape

I would like to print the function call stack in the fatal handler of the duktape: void duktape_fatal(void *d, const char *m) { int line, pc, level; const char *fnName = NULL; printf("JSE fatal: %s!\n", (m ? m : "")); level = -1; …
1
vote
0 answers

How to get Duktape to run on Mac 68k (like it does on PPC?)

I'm writing a small app that runs on MacOS 7.x - 9.x (using Macintosh Toolbox) and I've decided to include Duktape. I use CodeWarrior 6.0 running on MacOS 9. I use the Low Memory configuration, found here. It runs perfectly when I compile for PPC -…
ejder
  • 11
  • 1
1
vote
1 answer

Exponential calculation bugs in Duktape engine?

I am testing a real-time algorithm adoption with duktape and C language but found that the result return is not always correct. A simple example of passing three floating point numbers to the javascript engine and do some simple exponential…
Ben Chan
  • 13
  • 2
1
vote
1 answer

How to create C++ object in Duktape

Base on http://wiki.duktape.org/HowtoNativeConstructor.html, I can create a c++ class and export to JavaScript, JavaScript code can create object as well But. when I create a object in c++ native code, it's can't work, JavaScript code can't see the…
ChiaYen
  • 11
  • 3
1
vote
1 answer

Add auto-complete with non-standard builtins w/Visual Studio Code/JS

Visual studio code seems to have good support for javascript autocomplete, but I have a project which uses duktape to export a large and growing library of objects from my application. The library is growing quite quickly as more functionality gets…
Shawn
  • 621
  • 5
  • 10
1
vote
1 answer

duktape use common c function for multiple bound js functions

I'm trying to bind a common c function to multiple javascript functions using the duktape engine. My problem is that i need to find out the name of the calling function inside the common c function. I feel like it's possible to implement this using…
user3272529
  • 115
  • 9
1
vote
1 answer

Load native C modules in duktape 2.1.0 to

I am still lost after reading the how-to article. https://github.com/svaarala/duktape/tree/master/extras/module-node It is said that The load callback is a Duktape/C function which takes the resolved module ID and: (1) returns the Ecmascript…
Sean
  • 31
  • 2
1
vote
1 answer

Invoke JS object constructor from C when object constructor defined inside js module

Using Duktape over microchip 32, everything running well. BTW, when using module loading( which is also working like a charm), i'm facing a kind of pattern question. lets me explains: I define a constructor inside a js module var MyObject =…
1
vote
1 answer

Build Duktape for specific platform (ARM 32/ ARM 64)

I'm going to use Duktape for javascript evaluation for ARM 32/64 platforms. I want to build Duktape only for specific platform & architecture, not for all range. It seems, that I can build it successfully: python tools/configure.py \ …