ocarina-python_cmd.adb 3.86 KB
Newer Older
yoogx's avatar
yoogx committed
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 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
with GNATCOLL.Scripts;        use GNATCOLL.Scripts;
with GNATCOLL.Scripts.Python; use GNATCOLL.Scripts.Python;

with Ocarina.Utils;

package body Ocarina.Python_Cmd is

   ----------------
   -- On_Version --
   ----------------

   procedure On_Version (Data : in out Callback_Data'Class; Command : String);

   procedure On_Version
     (Data : in out Callback_Data'Class;
      Command : String)
   is
      pragma Unreferenced (Data, Command);
   begin
      Ocarina.Utils.Version;
   end On_Version;

   ---------------
   -- On_Status --
   ---------------

   procedure On_Status (Data : in out Callback_Data'Class; Command : String);

   procedure On_Status
     (Data : in out Callback_Data'Class;
      Command : String)
   is
      pragma Unreferenced (Data, Command);
   begin
      Ocarina.Utils.Print_Status;
   end On_Status;

   -----------------------
   -- On_Load_AADL_File --
   -----------------------

   procedure On_Load_AADL_File
     (Data : in out Callback_Data'Class; Command : String);

   procedure On_Load_AADL_File
     (Data : in out Callback_Data'Class;
      Command : String)
   is
      pragma Unreferenced (Command);
   begin
      Ocarina.Utils.Load_AADL_File (Nth_Arg (Data, 1, ""));
   end On_Load_AADL_File;

   --------------------
   -- On_Instantiate --
   ---------------------

   procedure On_Instantiate
     (Data : in out Callback_Data'Class; Command : String);

   procedure On_Instantiate
     (Data : in out Callback_Data'Class;
      Command : String)
   is
      pragma Unreferenced (Command);
   begin
      Ocarina.Utils.Instantiate (Nth_Arg (Data, 1, ""));
   end On_Instantiate;

   ----------------
   -- On_Analyze --
   ----------------

   procedure On_Analyze
     (Data : in out Callback_Data'Class; Command : String);

   procedure On_Analyze
     (Data : in out Callback_Data'Class;
      Command : String)
   is
      pragma Unreferenced (Command, Data);
   begin
      Ocarina.Utils.Analyze;
   end On_Analyze;

   -----------------
   -- On_Generate --
   -----------------

   procedure On_Generate
     (Data : in out Callback_Data'Class; Command : String);

   procedure On_Generate
     (Data : in out Callback_Data'Class;
      Command : String)
   is
      pragma Unreferenced (Command);
   begin
      Ocarina.Utils.Generate (Nth_Arg (Data, 1, ""));
   end On_Generate;

   ------------------------------------
   -- Register_Scripts_And_Functions --
   ------------------------------------

   function Register_Scripts_And_Functions return Scripts_Repository is
      Repo : Scripts_Repository;
   begin
      --  Register all scripting languages. In practice, you only need to
      --  register those you intend to support

      Repo := new Scripts_Repository_Record;
      Register_Python_Scripting (Repo, "ocarina");
      Register_Standard_Classes (Repo, "Console");

      --  Register our custom functions

      --  version() function
      Register_Command
        (Repo, "version", 0, 0, Handler => On_Version'Unrestricted_Access);

      --  status() function
      Register_Command
        (Repo, "status", 0, 0, Handler => On_Status'Unrestricted_Access);

      --  load() function
      Register_Command
        (Repo, "load", 1, 1, Handler => On_Load_AADL_File'Unrestricted_Access);

      --  analyze() function
      Register_Command
        (Repo, "analyze", 0, 0,
         Handler => On_Analyze'Unrestricted_Access);

      --  instantiate() function
      Register_Command
        (Repo, "instantiate", 1, 1,
         Handler => On_Instantiate'Unrestricted_Access);

      --  generate() function
      Register_Command
        (Repo, "generate", 1, 1,
         Handler => On_Generate'Unrestricted_Access);

      return Repo;
   end Register_Scripts_And_Functions;

148 149 150 151 152 153 154 155 156
   ----------------
   -- Initialize --
   ----------------

   procedure Initialize is
   begin
      Repo := Register_Scripts_And_Functions;
   end Initialize;

yoogx's avatar
yoogx committed
157
end Ocarina.Python_Cmd;