Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tiagosr/ofxDuktape
Addon for openFrameworks with bindings to the Duktape Javascript interpreter
https://github.com/tiagosr/ofxDuktape
duktape javascript-interpreter openframeworks-addon
Last synced: 2 months ago
JSON representation
Addon for openFrameworks with bindings to the Duktape Javascript interpreter
- Host: GitHub
- URL: https://github.com/tiagosr/ofxDuktape
- Owner: tiagosr
- Created: 2015-07-07T01:17:18.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2023-02-01T23:05:53.000Z (almost 2 years ago)
- Last Synced: 2024-08-03T18:16:36.758Z (6 months ago)
- Topics: duktape, javascript-interpreter, openframeworks-addon
- Language: C
- Homepage:
- Size: 2.49 MB
- Stars: 10
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- AwesomeInterpreter - ofxDuktape
README
# ofxDuktape
openFrameworks addon with bindings to the [Duktape](http://www.duktape.org) Javascript interpreter
This addon is distributed under the terms of the MIT License.
## Usage
```c++
#include "ofxDuktape.h"// create a duktape context anywhere
ofxDuktape duk;// use it in your code
int retcode = duk.pEval("log(\"hello openFrameworks!\"");// pEval returns 0 if code was executed correctly, and other values for errors
if (!retcode) {
// -1 is the index to the last object stored in duktape's stack, i.e. the result of the call
ofLogInfo() << "return value is " << duk.safeToString(-1);
} else {
ofLogError() << "error while executing javascript";
}
```## Extensions
The header file ```ofxDukOFBindings.h``` has most of openFrameworks 0.9 API implemented inside the ```of``` object,
and a lot of syntactic sugar - ofSetXXX methods with single parameters and ofGetXXX methods are mostly implemented as properties```c++
#include "ofxDukOFBindings.h"
ofxDuktape duk;// setup the 'of' object in the javascript context
ofxDukBindings::setup(duk);// interact with openFrameworks
duk.pEval("of.windowTitle = \"New window title\"");
```