Le 10-05-05 16:30 , chevalma@iro.umontreal.ca a écrit :
Pretty cool. Does it require the C++ functions to take V8 implementation specific objects as arguments (eg: some JSObject class), or do we declare the types that the C++ functions take?
They use an Arguments wrapper object. I'll dig further into this.
Just wondering if we will be able to use the same C++ code directly in V8 and in our own implementation.
- Maxime
Erick
I just found that the option to call native functions can simply be passed as an argument to the d8 executable.
Ex:
./d8 --allow_natives_syntax d8> var f = %CompileString("var x = 2;",false); d8> f function var x = 2; d8> f() d8>x 2
For other options, simply type:
./d8 --help
As a side note, to read a file as a string from the d8 prompt, simply do:
var s = read("my_test_file.js");
Erick
Le 10-05-05 14:49 , Erick Lavoie a écrit :
V8 provides a nice developer shell to interactively execute and debug javascript code using their Engine.
The build instructions as well as the dependencies can be found here http://code.google.com/apis/v8/build.html.
To allow calling native C++ functions from javascript directly such as what is done in the standard libraries (see src/v8natives.js), simply set the "allow_natives_syntax" flag from src/flag-definitions.h to "true". This will allow calling functions like %CompileString directly.
To see how C++ functions can be exposed to javascript, look at void Shell::Initialize() from src/d8.cc.
When an error occurs, the d8 shell automatically enters debug mode. The listing of available commands can be found at "function DebugRequest" of src/d8.js.
Erick
Tachyon-list mailing list Tachyon-list@iro.umontreal.ca https://webmail.iro.umontreal.ca/mailman/listinfo/tachyon-list