Ann: ada binding to v8(google javascript engine)

64 views
Skip to first unread message

Kylix

unread,
Jan 23, 2012, 6:44:18 AM1/23/12
to
I made a binding to v8(google javascript engine), with some examples,
such as a simple shell:
procedure Shell is
p : v8.Class_Handle_Scope.Handle_Scope;
pragma Unreferenced (p);
c : v8.Class_Context.Handles.Persistent :=
v8.Class_Context.Create;
cs : v8.Class_Context.Scope (c.As_Object);
ver : v8.Class_String.Pointer := v8.Class_String.Create
(v8.Class_V8.Get_Version);
tc : v8.Class_Try_Catch.Holder;
pragma Warnings (Off);
begin
loop
Ada.Text_IO.Put("input code to execute or enter exit:");
declare
code : String := Ada.Text_IO.Get_Line;
bin : v8.Class_Script_Data.Pointer;
begin
exit when code = "exit";
bin := v8.Class_Script_Data.Pre_Compile (code);
if not bin.Has_Error then
declare
js : v8.CLass_Script.Pointer :=
v8.Class_Script.Compile (source => v8.Class_String.Create (code),
pre_data => bin);
result : v8.Class_Value.Pointer := js.Run;
use type v8.Class_Value.Pointer;
begin
if result /= null then
Show_Result(result);
else
Ada.Text_IO.Put_Line
(int'Image(tc.Message.Get_Line_Number));
tc.Reset;
end if;
end;
end if;
bin.Free;
end;
end loop;
end Shell;

Kylix

unread,
Jan 23, 2012, 6:47:59 AM1/23/12
to
the project url is :
http://code.google.com/p/v8a/
Reply all
Reply to author
Forward
0 new messages