diff --git a/interfaces/sourcegen/sourcegen/_dataclasses.py b/interfaces/sourcegen/sourcegen/_dataclasses.py index dcd4d0cd7e..102e83dcca 100644 --- a/interfaces/sourcegen/sourcegen/_dataclasses.py +++ b/interfaces/sourcegen/sourcegen/_dataclasses.py @@ -109,14 +109,13 @@ def n_optional(self): class Func: """Represents a function parsed from a C header file.""" - annotations: str # documentation block ret_type: str # may include leading specifier name: str params: List[Param] spec: str # trailing specifier @classmethod - def from_str(cls, func: str, annotations: str="") -> 'Func': + def from_str(cls, func: str) -> 'Func': """Generate Func from string function signature""" func = func.strip() name = re.findall(re.compile(r'.*?(?=\(|$)'), func)[0] @@ -124,7 +123,7 @@ def from_str(cls, func: str, annotations: str="") -> 'Func': r_type = "" if " " in name: r_type, name = name.rsplit(" ", 1) - return cls(annotations, r_type, name, arglist.params, arglist.spec) + return cls(r_type, name, arglist.params, arglist.spec) def declaration(self) -> str: """Return a string representation of the function (without semi-colon).""" diff --git a/interfaces/sourcegen/sourcegen/clib/_CLibSourceGenerator.py b/interfaces/sourcegen/sourcegen/clib/_CLibSourceGenerator.py index ef5e174a82..30ca00bdc6 100644 --- a/interfaces/sourcegen/sourcegen/clib/_CLibSourceGenerator.py +++ b/interfaces/sourcegen/sourcegen/clib/_CLibSourceGenerator.py @@ -195,7 +195,7 @@ def merge_params(implements, details: TagDetails) -> List[Param]: recipe.name, recipe.what) sys.exit(1) - c_func = Func("", ret_param.p_type, recipe.name, args, "") + c_func = Func(ret_param.p_type, recipe.name, args, "") declaration = c_func.declaration() annotations = self._build_annotation(details, ret_param, args, recipe.relates) diff --git a/interfaces/sourcegen/sourcegen/csharp/_CSharpSourceGenerator.py b/interfaces/sourcegen/sourcegen/csharp/_CSharpSourceGenerator.py index 4fdc1c01be..be79588bbf 100644 --- a/interfaces/sourcegen/sourcegen/csharp/_CSharpSourceGenerator.py +++ b/interfaces/sourcegen/sourcegen/csharp/_CSharpSourceGenerator.py @@ -26,18 +26,11 @@ def _join_params(params: List[Param]) -> str: return ", ".join(p.p_type + " " + p.name for p in params) def _get_interop_func_text(self, func: CsFunc) -> str: - comments, ret_type, name, params, _, _, _ = func + ret_type, name, params, _, _, _ = func requires_unsafe_keyword = any(p.p_type.endswith("*") for p in params) params_text = self._join_params(params) - ret = "" - if comments: - # convert trailing C++ doxygen comments, but retain C++ formatting - # comment blocks will not be parsed by .NET - comments = comments.replace("//!< ", "//! ").strip() - ret += f"{comments}\n" - - ret += f"{self._config.func_prolog} " + ret = f"{self._config.func_prolog} " if requires_unsafe_keyword: ret += "unsafe " ret += f"{ret_type} {name}({params_text});" # function text @@ -137,7 +130,7 @@ def _get_handle_class_name(self, clib_area: str) -> str: return self._get_wrapper_class_name(clib_area) + "Handle" def _convert_func(self, parsed: Func) -> CsFunc: - comments, ret_type, name, _, _ = parsed + ret_type, name, _, _ = parsed clib_area, method = name.split("_", 1) # Shallow copy the params list @@ -205,8 +198,7 @@ def _convert_func(self, parsed: Func) -> CsFunc: params[i] = Param(param_type, param_name) - func = CsFunc(comments, - ret_type, + func = CsFunc(ret_type, name, params, "",