diff options
author | Tristan Gingold <tgingold@free.fr> | 2017-10-09 20:34:04 +0200 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2017-10-09 20:34:04 +0200 |
commit | e1c3b171231c7fe50975775a2e904eed8aeaa098 (patch) | |
tree | f05286d2261d88becf771750b01119e34ab5f887 | |
parent | f111087acd05068f8bdf1a191bbd47a0c7f39381 (diff) | |
download | ghdl-e1c3b171231c7fe50975775a2e904eed8aeaa098.tar.gz ghdl-e1c3b171231c7fe50975775a2e904eed8aeaa098.tar.bz2 ghdl-e1c3b171231c7fe50975775a2e904eed8aeaa098.zip |
python: add more interfaces.
-rw-r--r-- | src/vhdl/python/libghdl/thin.py | 19 | ||||
-rwxr-xr-x | src/vhdl/python/pnodespy.py | 21 |
2 files changed, 37 insertions, 3 deletions
diff --git a/src/vhdl/python/libghdl/thin.py b/src/vhdl/python/libghdl/thin.py index ae12c3864..2fb75f651 100644 --- a/src/vhdl/python/libghdl/thin.py +++ b/src/vhdl/python/libghdl/thin.py @@ -1,5 +1,5 @@ from libghdl import libghdl -from ctypes import (c_char_p, c_int32, c_int, c_bool, sizeof) +from ctypes import (c_char_p, c_int32, c_int, c_bool, sizeof, c_void_p) import iirs import nodes_meta from nodes_meta import (Attr, types) @@ -44,7 +44,7 @@ location_File_Line_To_Col = libghdl.files_map__location_file_line_to_col Get_File_Name = libghdl.files_map__get_file_name Get_File_Buffer = libghdl.files_map__get_file_buffer -Get_File_Buffer.restype = c_char_p +Get_File_Buffer.restype = c_void_p Get_File_Length = libghdl.files_map__get_file_length @@ -92,12 +92,27 @@ class Parse: # std.standard +# Use .value Standard_Package = c_int32.in_dll(libghdl, "std_package__standard_package") +# Use .value +Character_Type_Definition = c_int32.in_dll( + libghdl, "std_package__character_type_definition") + # libraries Get_Libraries_Chain = libghdl.libraries__get_libraries_chain +Add_Design_Unit_Into_Library = libghdl.libraries__add_design_unit_into_library + +Finish_Compilation = libghdl.libraries__finish_compilation + +Library_Location = c_int32.in_dll(libghdl, "libraries__library_location") + +# + +Disp_Iir = libghdl.disp_tree__disp_iir + Null_Iir = 0 Null_Iir_List = 0 diff --git a/src/vhdl/python/pnodespy.py b/src/vhdl/python/pnodespy.py index c7f23f73f..89b288995 100755 --- a/src/vhdl/python/pnodespy.py +++ b/src/vhdl/python/pnodespy.py @@ -66,9 +66,28 @@ def do_class_fields(): print_enum('fields', [f.name for f in pnodes.funcs]) +def read_spec_enum(type_name, prefix, class_name): + """Read an enumeration declaration from iirs.ads""" + pat_decl = re.compile(r' type {0} is$'.format(type_name)) + pat_enum = re.compile(r' {0}_(\w+),?(-- .*)?$'.format(prefix)) + lr = pnodes.linereader(pnodes.spec_file) + while not pat_decl.match(lr.get()): + pass + toks = [] + while True: + line = lr.get() + if line == ' );\n': + break + m = pat_enum.match(line) + if m: + toks.append(m.group(1)) + print_enum(class_name, toks) + + def do_libghdl_iirs(): print 'from libghdl import libghdl' do_class_kinds() + read_spec_enum('Iir_Mode', 'Iir', 'Iir_Mode') do_iirs_subprg() @@ -138,7 +157,7 @@ def do_libghdl_names(): def do_libghdl_tokens(): - pat_token = re.compile(' Tok_(\w+),?\s*(--.*)?$') + pat_token = re.compile(r' Tok_(\w+),?\s*(--.*)?$') lr = pnodes.linereader('tokens.ads') toks = [] while True: |