Questions tagged [duktape]
Duktape is a highly optimized embedded JavaScript engine for C/C++
93
questions
0
votes
0
answers
15
views
how to properly cleanup libuv across a duktape app soft reloads
I'm using libuv with duktape and my app needs to be able to reload itself live.
is there an official proper way to "cleanup" or "restart" libuv?
I'm already doing "...
1
vote
0
answers
21
views
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 '...
-1
votes
1
answer
68
views
lambdas with duktape (using C++) [duplicate]
I want to call duk_push_c_function() with a lambda defined in C++, a bit like this:
SomeObjType parameter;
// store stuff in 'parameter'
auto myLambda = [parameter](duk_context* ctx) {
// do stuff ...
0
votes
1
answer
46
views
Timeout stopped working for me with Duktape v2.7.0
I had timeouts working nicely with Duktape v2.5.0.
In my duktape.h file, I appended:
#define DUK_USE_EXEC_TIMEOUT_CHECK JSduk_timeout_check // our timeout check function
duk_bool_t JSduk_timeout_check(...
0
votes
2
answers
141
views
Why is my Kotlin/JS program failing with "RangeError: Maximum call stack size exceeded"?
I’ve written a Kotlin/JS program that is crashing on some JavaScript engines.
It’s crashing on GraalVM like this:
RangeError: Maximum call stack size exceeded
at <js> 839(myprogram.js:394:...
0
votes
2
answers
228
views
duktape js - have multiple contexts with own global and reference to one common 'singleton'
We are in the process of embedding JS in our application, and we will use a few dozen scripts each assigned to an event. Inside these scripts we provide a minimal callback api,
function onevent(value)
...
1
vote
1
answer
77
views
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 ...
0
votes
2
answers
148
views
How can I get an error object after an ECMAscript throw( )?
I can throw errors in C++ code by pushing an error object and then calling duk_throw(). duk_pcall() returns with 'outcome != DUK_EXEC_SUCCESS' and I can examine the error object to determine, for ...
0
votes
1
answer
165
views
How to run a whole js files multiple times using duk_pcall?
I want to use duk_pcall to do it, here is what I tried:
Firstly, I load the script file into a char* string.
Secondly, use duk_pcompile_string(ctx, 0, programBody) to compile it.
Then, I can use ...
0
votes
1
answer
118
views
Catching and recovering from error in C++ function called from Duktape
I have created a plugin for the OpenCPN marine navigation program that incorporates Duktape to provide a scripting capability. OpenCPN uses wxWidgets.
Basically, the plugin presents the user with a ...
0
votes
0
answers
50
views
Android Duktape NullPointerException while Internet is not there
I am getting a null Exception when there is no internet on my mobile.
it is showing error here:
val results: String? = jsBinder.androidWrapper(functionName, gson.toJson(input))
input is Any type
...
-1
votes
1
answer
143
views
Duktape - error with for of loop when evaluating
With the following code duktape gives me a parse error for the for of loop.
string script = u8R"(var foo = [
"foo",
"bar"
]
for (var ...
0
votes
1
answer
128
views
How to use time-out to protect against JavaScript loops etc. in Duktape 2.5.0
I am successfully running Duktape JavaScripts using protected calls - actually invoked with duk_peval().
I want to catch indefinite loops etc. I have read the guide and understand I need to set up a ...
0
votes
0
answers
412
views
How to implement nonblocking event loop in Duktape?
I'm embedding Duktape into esp32 which runs FreeRTOS.
And I'm stuck with implementing a nonblocking event loop.
As I understood it is pretty trivial to implement an event loop in terms of async-...
1
vote
1
answer
634
views
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 ...
0
votes
1
answer
35
views
Configuring Duktape 2.5.0 for use under MacOSX (Catalina)
I am wanting to build Duktape to run under MacOSX.
The instructions here say to run the supplied configuration tool at tools/configure.py
There are different instructions here saying to run tools/...
1
vote
0
answers
162
views
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("...
0
votes
1
answer
175
views
JS spread syntax in Android using Kotlin and Duktape
I am using Duktape to run JS code in my Android application. I am trying to implement a log function in JS which receives multiple varargs arguments.
When running the code I am getting an exception:
...
0
votes
1
answer
301
views
Does Duktape has a Function for Executing an External Program in Linux?
I am using Duktape on Linux (Command Line, not Browser),
and would like my code to execute an external program in Linux, for example ls.
I went over Duktape's website, looking for Reference of the ...
1
vote
0
answers
88
views
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 ...
0
votes
1
answer
621
views
How to use typescript modules with Duktape
I am trying to use JS as a scripting language in a game engine, with TypeScript on top. As runtime I use Duktape. I am a complete noob regarding JavaScript and currently I am trying to wrap my head ...
0
votes
0
answers
276
views
How would one use a ES6 module that's been translated in to vanilla JS using Babel *from vanilla js* [duplicate]
So I'm writing an ES6 application that uses multiple files and dependencies. I bundle this up using webpack in to a single bundle.js. From here I want to run it through Babel to get ES5 JS inside of a ...
0
votes
1
answer
59
views
Questions regarding Javascript Engine error
I have a question regarding Javascript engine error. This might be a very specific question, is there anyone saw this error before? Would you please help take a look?
Here is the error message:
...
0
votes
1
answer
114
views
Javascript import command
Does it matter where require is put within a file? This is using duktape to use js function in my android app.
For Example:
some javascript code
var calc = require('calculate')
Then call calc....
0
votes
1
answer
121
views
Run rxjs in kotlin using Duktape Android return SyntaxError
I try to run simple script of rxjs in android application using duktape-android library and I can not find it a way to go.
val duktape = Duktape.create()
implementConsole(duktape)
duktape.evaluate("...
-2
votes
1
answer
293
views
How create inserted object use duktape?
Have this code:
auto obj_idx = duk_push_object( ctx );
duk_push_string( ctx, "key" );
duk_push_string( ctx, "value" );
duk_put_prop( ctx, obj_idx );
duk_push_string( ctx, "key2" );
duk_push_string( ...
0
votes
1
answer
2k
views
DukTape `require()` throws `TypeError: undefined not callable`
I am trying to use Duktape for Android and JavaScript bindings.
I followed the documentation here https://wiki.duktape.org/HowtoModules.html and as per the steps, I have the following calling code:
...
2
votes
0
answers
158
views
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 ...
1
vote
1
answer
102
views
Exponential calculation bugs in Duktape engine? [duplicate]
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 ...
0
votes
0
answers
307
views
How to stop execution of a js function in go duktape
I have the following go-duktape code:
package main
import (
"fmt"
"gopkg.in/olebedev/go-duktape.v3"
"time"
)
func main() {
code := "function test(){log('testing');log('testing2');...
0
votes
1
answer
75
views
Problems to build duktape using low_memory.yaml and pointer compression options
I'm trying to build duktape using the low_memory.yaml profile, and enabling the pointer compression options. Specifically, I uncommented the following lines:
DUK_USE_STRTAB_PTRCOMP: true # ...
1
vote
1
answer
1k
views
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 ...
12
votes
2
answers
1k
views
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)....
2
votes
1
answer
325
views
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 ...
4
votes
1
answer
2k
views
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 ...
2
votes
2
answers
559
views
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 ...
0
votes
0
answers
224
views
duktape reference counter and finalizer C/C++
I'm binding my C++ objects by using duktape and I would like to automatically delete the instances when they are not used anymore. I've tried to set a finalizer to these objects but for some reason ...
1
vote
1
answer
161
views
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 ...
0
votes
1
answer
414
views
duktape how to parse argument of type String Object (similarly Number object) in duktape c function
How to type check the String object/Number object argument types in duktape c function and parse the value from String object/Number object. There is generic api like duk_is_object() but I need the ...
0
votes
1
answer
91
views
Integrating duktape with android ndk
I'm trying to integrate duktape with android jni. My jni's android.mk is pretty standard:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := mynativelib
LOCAL_SRC_FILES := ...
0
votes
2
answers
667
views
Can Duktape use javascript websocket libraries or any form of socket libraries?
I am trying to use duktape as an embedded JS engine, however I can't seem to use Websockets which work typically in browser based JS engine. Does duktape have support for this or any other network ...
0
votes
1
answer
137
views
How to write a central function dispatcher for duktape?
The situation is this: I want to use a single duktape/C function for all functions I define on my objects + prototypes. For that I have a function map which takes a function name and a callback (a std:...
0
votes
1
answer
138
views
Inheritance and the constructor chain with native duktape/C functions
Using native functions to implement a class constructor is described in the duktape wiki. What's left out there however is how to implement a class hierarchy.
When your native constructor is called ...
0
votes
1
answer
271
views
How to get the class name when running a constructor function in duktape?
I'd like to use a single duktape/C constructor function as dispatcher for these kind of calls. When the dispatcher function is called I need to know for which class this happend to call the ...
0
votes
1
answer
584
views
Understanding Closure Compiler warnings
I am in the process of using Google's closure compiler to optimize+ obfuscate code which I run in an Android app via Duktape. I have successfully dealt with the majority of the warning messages that ...
0
votes
1
answer
231
views
Executing function twice
Okay, so basically I've got a long array of objects and I need to call a JavaScript function multiple times with the array as a parameter. I already got it working when recreating the list every time ...
0
votes
1
answer
330
views
duktape, modify variable argument in native C code
I'm trying to modify a variable passed in an argument in a native function like this:
var MyVar = 'foo';
myNativeFunc(MyVar);
and inside my native, I can read the content of MyVar, with :
std::...
1
vote
1
answer
512
views
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. ...
0
votes
1
answer
357
views
how to execute shell commands from duktape
I need to build a javascript engine (duktape or jerryscript) for a embedded device which should be capable of executing shell commands. how can this be achieved?
1
vote
1
answer
501
views
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 ...