Commit 27751aae authored by yoogx's avatar yoogx

* Add reset() method to reinitialize Ocarina Python bindings

parent 1d1f5093
...@@ -25,6 +25,11 @@ def status (): ...@@ -25,6 +25,11 @@ def status ():
'''Print Ocarina status''' '''Print Ocarina status'''
libocarina_python.status(); libocarina_python.status();
################################################################################
def reset ():
'''Reset Ocarina'''
libocarina_python.reset();
################################################################################ ################################################################################
def load (filename): def load (filename):
'''Load a file '''Load a file
......
...@@ -34,11 +34,26 @@ ...@@ -34,11 +34,26 @@
with GNATCOLL.Scripts; use GNATCOLL.Scripts; with GNATCOLL.Scripts; use GNATCOLL.Scripts;
with GNATCOLL.Scripts.Python; use GNATCOLL.Scripts.Python; with GNATCOLL.Scripts.Python; use GNATCOLL.Scripts.Python;
with Ocarina.Configuration; use Ocarina.Configuration; with Ocarina.Configuration; use Ocarina.Configuration;
with Ocarina.Utils; with Ocarina.Utils;
package body Ocarina.Python_Cmd is package body Ocarina.Python_Cmd is
--------------
-- On_Reset --
--------------
procedure On_Reset (Data : in out Callback_Data'Class; Command : String);
procedure On_Reset
(Data : in out Callback_Data'Class;
Command : String)
is
pragma Unreferenced (Data, Command);
begin
Ocarina.Utils.Reset;
end On_Reset;
---------------- ----------------
-- On_Version -- -- On_Version --
---------------- ----------------
...@@ -151,6 +166,10 @@ package body Ocarina.Python_Cmd is ...@@ -151,6 +166,10 @@ package body Ocarina.Python_Cmd is
-- Register our custom functions -- Register our custom functions
-- reset() function
Register_Command
(Repo, "reset", 0, 0, Handler => On_Reset'Unrestricted_Access);
-- version() function -- version() function
Register_Command Register_Command
(Repo, "version", 0, 0, Handler => On_Version'Unrestricted_Access); (Repo, "version", 0, 0, Handler => On_Version'Unrestricted_Access);
......
...@@ -56,9 +56,34 @@ with Ocarina.Files; use Ocarina.Files; ...@@ -56,9 +56,34 @@ with Ocarina.Files; use Ocarina.Files;
package body Ocarina.Utils is package body Ocarina.Utils is
AADL_Root : Node_Id := No_Node; AADL_Root : Node_Id := No_Node;
File_Name : Name_Id; File_Name : Name_Id := No_Name;
Buffer : Location; Buffer : Location;
Language : Name_Id; Language : Name_Id := No_Name;
-----------
-- Reset --
-----------
procedure Reset is
begin
-- Reset Ocarina
Ocarina.Configuration.Reset_Modules;
Ocarina.Reset;
-- Initialize Ocarina
Ocarina.AADL_Version := Get_Default_AADL_Version;
AADL_Version := Ocarina.AADL_V2;
Ocarina.Initialize;
Ocarina.Configuration.Init_Modules;
-- Reset library
AADL_Root := No_Node;
File_Name := No_Name;
Language := No_Name;
end Reset;
------------- -------------
-- Version -- -- Version --
......
...@@ -46,5 +46,6 @@ package Ocarina.Utils is ...@@ -46,5 +46,6 @@ package Ocarina.Utils is
procedure Analyze; procedure Analyze;
procedure Instantiate (Root_System : String); procedure Instantiate (Root_System : String);
procedure Generate (Backend_Name : String); procedure Generate (Backend_Name : String);
procedure Reset;
end Ocarina.Utils; end Ocarina.Utils;
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment