diff --git a/py_src/class_info.py b/py_src/class_info.py index b939dc67..24046808 100644 --- a/py_src/class_info.py +++ b/py_src/class_info.py @@ -321,7 +321,7 @@ def gen_def(self, codegen, evision_modules, evision_erlang_hrl): module_file_generator.write_erlang(f'-module({atom_erlang_module_name.lower()}).\n-compile(nowarn_export_all).\n-compile([export_all]).\n-include("evision.hrl").\n\n') module_file_generator.write_erlang( ES.generic_struct_template_erlang.substitute( - atom_elixir_module_name=atom_elixir_module_name.replace('"', ''), + atom_elixir_module_name=f"Elixir1.{atom_elixir_module_name.replace('"', '')}", atom_erlang_module_name=atom_erlang_module_name ) ) diff --git a/py_src/gen2.py b/py_src/gen2.py index b89661f3..1e28de8d 100755 --- a/py_src/gen2.py +++ b/py_src/gen2.py @@ -85,7 +85,7 @@ def clear(self): self.evision_constant_elixir.write(ET.gen_cv_types_elixir) self.evision_erlang.write('-module(evision).\n-compile(nowarn_export_all).\n-compile([export_all]).\n-include("evision.hrl").\n\n') - self.evision_erlang.write('\'__to_struct__\'(Any) ->\n evision_internal_structurise:from_struct(Any).\n\n') + self.evision_erlang.write('\'__to_struct__\'(Any) ->\n evision_internal_structurise:to_struct(Any).\n\n') self.evision_constant_erlang.write('-module(evision_constant).\n-compile(nowarn_export_all).\n-compile([export_all]).\n\n') @@ -442,7 +442,7 @@ def get_module_writer(self, module_name, wname, name, is_ns): atom_erlang_module_name = f"evision_{atom_erlang_module_name}" module_file_generator.write_erlang( ES.generic_struct_template_erlang.substitute( - atom_elixir_module_name=f"Elixir.{mapped_elixir_module_name}", + atom_elixir_module_name=f"Elixir.{atom_elixir_module_name}", atom_erlang_module_name=atom_erlang_module_name ) ) diff --git a/src/evision_internal_structurise.erl b/src/evision_internal_structurise.erl index 28b37628..95847d02 100644 --- a/src/evision_internal_structurise.erl +++ b/src/evision_internal_structurise.erl @@ -5,11 +5,18 @@ to_struct(Ret) when is_map(Ret) -> case maps:is_key(class, Ret) of true -> Class = maps:get(class, Ret), - Module = list_to_atom(string:to_lower(io_lib:fwrite("evision_~s", [Class]))), - case erlang:function_exported(Module, '__to_struct__', 1) of - true -> - Module:'__to_struct__'(Ret); - false -> + ClassName = atom_to_list(Class), + Module = case string:prefix(ClassName, "Elixir.Evision.") of + nomatch -> + list_to_atom(string:to_lower(io_lib:fwrite("evision_~s", [ClassName]))); + Name -> + list_to_atom(string:to_lower("evision_" ++ Name)) + end, + try Module:'__to_struct__'(Ret) of + Result -> + Result + catch + _ -> Ret end; false -> diff --git a/src/evision_mat.erl b/src/evision_mat.erl index 818c9f94..36d6d029 100644 --- a/src/evision_mat.erl +++ b/src/evision_mat.erl @@ -4,7 +4,7 @@ -include("generated/evision.hrl"). -'__to_struct__'(#{class := 'Mat', channels := Channels, dims := Dims, type := Type, raw_type := RawType, shape := Shape, ref := Ref}) -> +'__to_struct__'(#{class := 'Elixir.Evision.Mat', channels := Channels, dims := Dims, type := Type, raw_type := RawType, shape := Shape, ref := Ref}) -> #evision_mat{ channels = Channels, dims = Dims,