Skip to content

tiagosr/ofxDuktape

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
src
 
 
 
 

ofxDuktape

openFrameworks addon with bindings to the Duktape Javascript interpreter

This addon is distributed under the terms of the MIT License.

Usage

#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

#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\"");

About

Addon for openFrameworks with bindings to the Duktape Javascript interpreter

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published