comp.lang.ada
 help / color / mirror / Atom feed
From: Kylix <likai3g@gmail.com>
Subject: Ann: ada binding  to v8(google javascript engine)
Date: Mon, 23 Jan 2012 03:44:18 -0800 (PST)
Date: 2012-01-23T03:44:18-08:00	[thread overview]
Message-ID: <f4f9f832-333a-42a6-abdb-c13fdd85aca7@kg1g2000pbb.googlegroups.com> (raw)

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;



             reply	other threads:[~2012-01-23 11:46 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-23 11:44 Kylix [this message]
2012-01-23 11:47 ` Ann: ada binding to v8(google javascript engine) Kylix
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox