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
12
votes
2 answers

How to access Javascript module with Duktape in Android

I am successfully parsing and evaluating a javascript file with Duktape in my Android application using Kotlin. val file_name = "lib.js" val js_string = application.assets.open(file_name).bufferedReader().use { it.readText() } val duktape =…
erickva
  • 513
  • 6
  • 17
9
votes
1 answer

export c++ class to duktape

say I have a c++ class Point class Point { public: Point(); Point(float x, float y); ~Point(); float X; float Y; }; I'd like to add javascript functionality to it and chose duktape. is it possible to reuse this class in…
mika
  • 420
  • 3
  • 12
5
votes
1 answer

Iterating over an unknown object in Duktape

So I have this duktape function which accepts an object as one of the parameters. Under normal circumstances, to retrieve the values of each of the objects attributes, I would use duk_get_prop() and duk_push_string(), however this assumes I know…
Adrien
  • 273
  • 2
  • 8
5
votes
4 answers

Can Duktape make http requests

I have a very simple duktape plugin running embedded in another program. Simple stuff works, but I am not sure how to make HTTP requests. Is it even possible to make HTTP Request from within a Duktape VM?
toddgeist
  • 902
  • 9
  • 21
4
votes
1 answer

duktape example for passing arguments to a js script and getting the result

Hi so I am looking at duktape, but I can't seem to find a simple example which does something like: pre compile some js. pass that js some input e.g. strings and numbers and run it. get the result of that js. It seems the examples go from here is…
Luke
  • 884
  • 8
  • 21
4
votes
1 answer

In Ductape has to save a Js Callback function passed a parameter to a C function

C++ calls the JS function, JsFunc(), passsing a C-function, MyCFunc(), as a parameter. JsFunc() calls MyCFunc() passsing a JS callback function as parameter. How do I save in MyCFunc() the JS callback function parameter so that I can call it later…
Alex Net
  • 164
  • 12
4
votes
0 answers

How to wrap C++ classes with Duktape

I am playing around with Duktape as a replacement to v8. Skimmed through the docs and managed to call C functions from Javascript and vice-versa. However it is not clear to me how to proceed when you need to access C++ classes from JavaScript in a…
BigONotation
  • 4,406
  • 5
  • 43
  • 72
4
votes
2 answers

Why does `require` cause an error in Duktape?

I am using Duktape to embed JavaScript, but using require always causes an error: int main(){ duk_context *ctx = duk_create_heap_default(); duk_peval_file(ctx, "example.js"); printf("file load err %s", duk_safe_to_string(ctx, -1)); …
caydanlik
  • 41
  • 3
3
votes
1 answer

Using json objects in duktape

everybody. I've just integrated duktape in my c++ code so that I'm able to use javascript. But the problem I can't solve right now : how to use json objects in javascript. Assume I've got some javascript like function hi(person) { print ('hi,…
3
votes
1 answer

How do you make a native javascript function taking a variable number of arguments using duktape?

Using the duktape javascript implementation, you can expose native C functions to javascript and implement them like this: static duk_ret_t native_prime_check(duk_context *ctx) { int arg1 = duk_require_int(ctx, 0); int arg2 =…
Steve Hanov
  • 11,316
  • 16
  • 62
  • 69
3
votes
1 answer

Postgres equivalient in SQLite to search JSON object

I have got the below Postgres Query: db.queryAsync('SELECT _id, value FROM ' + store + ' WHERE (value->>$1)=$2;', [index, id]); I want to write the same in SQLite. I have created the value field as TEXT type, but then not sure how to query. I am…
Romaan
  • 2,645
  • 5
  • 32
  • 63
3
votes
1 answer

Duktape - catch errors in C

I just started using Duktape in my C++ framework today, and I've read the entire api without being able to understand how do i catch errors. I found some clues about an error object that is put on the stack However, every time there is an error…
Lordrem
  • 133
  • 7
2
votes
0 answers

passing flatbuffers from C to duktape javascript

Wondering if anyone out there has had any success or attempted to integrate flatbuffers with duktape, so far I can only get about 1/2 way there... I can push a flatbuffer from C, and access it from JS with the following code, and it seems to work…
2
votes
1 answer

How to configure Duktape?

Duktape doesn't seem to have Android as a platform out of the box. How should i configure it to be able to build a native c/c++ shared library out of it myself, to be run on Android? Please let me know the different flags to get it to configure and…
Itay Bianco
  • 697
  • 6
  • 16
2
votes
2 answers

go-duktape examples of calling a function

The go-duktape repository has no "issues" section or anyway to ask for help. There are no useful examples in the README. I am trying to define a function in a javascript file (with parameters and return values) and call this function from…
Nathan H
  • 48,033
  • 60
  • 165
  • 247
1
2 3 4 5 6 7