Skip to content

Instantly share code, notes, and snippets.

@aristidb
Forked from aq1018/main.cpp
Created December 4, 2009 21:33
Show Gist options
  • Save aristidb/249372 to your computer and use it in GitHub Desktop.
Save aristidb/249372 to your computer and use it in GitHub Desktop.
#include <boost/spirit/home/phoenix/core.hpp>
#include <boost/spirit/home/phoenix/bind.hpp>
#include <boost/spirit/home/phoenix/operator.hpp>
#include <boost/bind.hpp>
#include "flusspferd.hpp"
using namespace flusspferd;
using namespace std;
namespace phoenix = boost::phoenix;
namespace args = phoenix::arg_names;
void callback(function& fn){
fn.call(global());
}
int main(int argc, char **argv)
{
try {
init::initialize();
context co = context::create();
current_context_scope scope(co);
object g = global();
security::create(g);
load_core(g, argv[0]);
create_on(g)
.create<function>("gc", &gc)
.create<function>("execute", &callback);
gc();
execute("test.js");
return 0;
} catch (flusspferd::exception &fe) {
std::cout << fe.what();
return 0;
} catch (std::exception &e) {
std::cout << e.what();
return 1;
}
}
var test2 = require("./test2");
execute(test2.callback);
var sys = require("system");
var print = function(){
sys.stdout.print.apply(sys.stdout, arguments);
}
exports.callback = function(){print("running callback");};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment