Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do minimal processing of ignored functions #221

Merged
merged 1 commit into from
Nov 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 35 additions & 2 deletions robotpy_build/autowrap/cxxparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ class ClassStateData(typing.NamedTuple):

# have to defer processing these
defer_protected_methods: typing.List[Method]
defer_private_nonvirtual_methods: typing.List[Method]
defer_private_virtual_methods: typing.List[Method]
defer_protected_fields: typing.List[Field]

Expand Down Expand Up @@ -750,6 +751,7 @@ def on_class_start(self, state: AWClassBlockState) -> typing.Optional[bool]:
typealias_names=typealias_names,
# Method data
defer_protected_methods=[],
defer_private_nonvirtual_methods=[],
defer_private_virtual_methods=[],
defer_protected_fields=[],
# Trampoline data
Expand Down Expand Up @@ -983,8 +985,11 @@ def on_class_method(self, state: AWClassBlockState, method: Method) -> None:
self._on_class_method(state, method, cctx.wrapped_public_methods)
elif access == "protected":
cdata.defer_protected_methods.append(method)
elif access == "private" and is_polymorphic:
cdata.defer_private_virtual_methods.append(method)
elif access == "private":
if is_polymorphic:
cdata.defer_private_virtual_methods.append(method)
else:
cdata.defer_private_nonvirtual_methods.append(method)

def _on_class_method(
self,
Expand Down Expand Up @@ -1152,6 +1157,23 @@ def _on_class_method(
f"{cdata.cls_key}::{method_name}: has && ref-qualifier which cannot be directly bound by pybind11, must specify cpp_code or ignore_py"
)

def _on_class_method_process_overload_only(
self, state: AWClassBlockState, method: Method
):
cdata = state.user_data

method_name = self._get_fn_name(method)
if not method_name:
return

self.gendata.get_function_data(
method_name,
method,
cdata.cls_key,
cdata.data,
True,
)

def _is_copy_move_constructor(
self, cctx: ClassContext, first_type_param: DecoratedType
) -> bool:
Expand Down Expand Up @@ -1242,6 +1264,17 @@ def on_class_end(self, state: AWClassBlockState) -> None:
f"{cdata.cls_key} has trampoline_inline_code specified, but there is no trampoline!"
)

else:
# still need to do minimal processing to add deferred functions
# to the overload tracker, otherwise we won't handle it correctly
for m in cdata.defer_protected_methods:
self._on_class_method_process_overload_only(state, m)
for m in cdata.defer_private_virtual_methods:
self._on_class_method_process_overload_only(state, m)

for m in cdata.defer_private_nonvirtual_methods:
self._on_class_method_process_overload_only(state, m)

#
# Function/method processing
#
Expand Down
6 changes: 6 additions & 0 deletions tests/cpp/rpytest/ft/include/overloads.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ struct OverloadedObject
return 0x4;
}

void overloaded_private(int a) {}

private:

// this causes errors if we don't account for it
void overloaded_private(int a, int b) {}

int o;
};