Skip to content

Commit

Permalink
just return :erlang.nif_error(:undef) if a function is not in NIF
Browse files Browse the repository at this point in the history
  • Loading branch information
cocoa-xu committed Jun 7, 2024
1 parent 9307539 commit f761add
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
6 changes: 3 additions & 3 deletions py_src/fixes.py
Original file line number Diff line number Diff line change
Expand Up @@ -609,9 +609,9 @@ def softNMSBoxes(bboxes, scores, score_threshold, nms_threshold) when (is_struct
end
end
""", """
def dnn_NMSBoxes(_opts \\\\ []), do: :erlang.nif_error("dnn::NMSBoxes not loaded")
def dnn_NMSBoxesBatched(_opts \\\\ []), do: :erlang.nif_error("dnn::NMSBoxesBatched not loaded")
def dnn_softNMSBoxes(_opts \\\\ []), do: :erlang.nif_error("dnn::softNMSBoxes not loaded")
def dnn_NMSBoxes(_opts \\\\ []), do: :erlang.nif_error(:undef)
def dnn_NMSBoxesBatched(_opts \\\\ []), do: :erlang.nif_error(:undef)
def dnn_softNMSBoxes(_opts \\\\ []), do: :erlang.nif_error(:undef)
""")
]}

Expand Down
2 changes: 1 addition & 1 deletion py_src/gen2.py
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ def gen_enabled_modules(self):

self.code_funcs.write("}\n")
self.code_ns_reg.write(f' F(enabled_modules, evision_cv_enabled_modules, 0),\n')
self.evision_nif.write(f' def enabled_modules, do: :erlang.nif_error("enabled_modules not loaded")\n')
self.evision_nif.write(f' def enabled_modules, do: :erlang.nif_error(:undef)\n')
self.evision_nif_erlang.write(f'enabled_modules() ->\n not_loaded(?LINE).\n')

def gen(self, srcfiles, output_path, erl_output_path, erlang_output_path):
Expand Down
9 changes: 3 additions & 6 deletions py_src/module_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,7 @@ def gen_property(self, full_qualified_name: str, class_name: str, property_name:
"elixir": {
"getter_template": ET.elixir_property_getter,
"nif_args": '_self',
"nif_template": Template(' def ${nif_name}(${nif_args}), do: :erlang.nif_error("${nif_error_msg}")\n'),
"nif_error_msg": f"{class_name}::{property_name} {generating_type}ter not loaded",
"nif_template": Template(' def ${nif_name}(${nif_args}), do: :erlang.nif_error(:undef)\n'),
"self_spec": self_spec_in["elixir"],
'prop_spec': prop_spec_out["elixir"]
},
Expand Down Expand Up @@ -211,8 +210,7 @@ def gen_property(self, full_qualified_name: str, class_name: str, property_name:
"elixir": {
"setter_template": ET.elixir_property_setter,
"nif_args": '_self, _prop',
"nif_template": Template(' def ${nif_name}(${nif_args}), do: :erlang.nif_error("${nif_error_msg}")\n'),
"nif_error_msg": f"{class_name}::{property_name} {generating_type}ter not loaded",
"nif_template": Template(' def ${nif_name}(${nif_args}), do: :erlang.nif_error(:undef)\n'),
"self_spec_in": self_spec_in["elixir"],
"self_spec_out": self_spec_out["elixir"],
'prop_spec': prop_spec_in["elixir"]
Expand Down Expand Up @@ -268,8 +266,7 @@ def _process_function(self, full_qualified_name: str, name: str, func: FuncInfo,
function_templates = {
"elixir": {
"nif_args": '_opts \\\\ []',
"nif_template": Template(' def ${nif_name}(${nif_args}), do: :erlang.nif_error("${nif_error_msg}")\n'),
"nif_error_msg": f"{full_qualified_name}::{name} not loaded"
"nif_template": Template(' def ${nif_name}(${nif_args}), do: :erlang.nif_error(:undef)\n'),
},
"erlang": {
"nif_args": '_opts',
Expand Down

0 comments on commit f761add

Please sign in to comment.