aq1018 (owner)

Revisions

gist: 228710 Download_button fork
public
Description:
flusspferd dies with this...
Public Clone URL: git://gist.github.com/228710.git
Embed All Files: show embed
main.cpp #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#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_native_function(g, "gc", &gc);
    create_native_function(g, "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;
  }
}
 
test.js #
1
2
3
4
var test2 = require("./test2");
 
execute(test2.callback);
 
test2.js #
1
2
3
4
5
6
7
8
var sys = require("system");
 
var print = function(){
  sys.stdout.print.apply(sys.stdout, arguments);
}
 
exports.callback = function(){print("running callback");};