I tried your method of MakeCallback : your code with my jscode in between 
the anonymous function :
Local<Context> context = Context::GetCurrent(); 
  Context::Scope context_scope(context); 
 std::string source = "(function(x) { " + std::string(codeData.get()) + " 
return x; });"; 
  Local<String> script_source = String::New(source.c_str(), sizeof(source) 
- 1); 
  Local<Script> script = Script::New(script_source);
  Local<Script> compiledScript = Script::Compile(script_source);
  if(script.IsEmpty()) {
  return ;   <--------- Execution goes here with Error on Nodejs console : 
JavaScript 
error (Uncaught SyntaxError: Unexpected end of 
input)<http://stackoverflow.com/questions/3983088/javascript-error-uncaught-syntaxerror-unexpected-end-of-input>
  }
  assert(value.IsEmpty() == false); 
  assert(value->IsFunction() == true); 
  Local<Function> fn = value.As<Function>(); 
  Local<Value> arg = Integer::New(42); 
  Local<Value> rc = MakeCallback(context->Global(), fn, 1, &arg); 


Node console shows : JavaScript error (Uncaught SyntaxError: Unexpected end 
of 
input)<http://stackoverflow.com/questions/3983088/javascript-error-uncaught-syntaxerror-unexpected-end-of-input>
when the source is + "(function(x) { var fs = require('fs'); return x; });"

When i put it in a separate node process it shows [Function]. which means 
the syntax is right.

Any tips ?

-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to