Skip to content
This repository was archived by the owner on Nov 11, 2025. It is now read-only.

Commit 1c5261b

Browse files
wangxfrwgk
authored andcommitted
Use return_value_policy::_clif_automatic everywhere.
PiperOrigin-RevId: 493392653
1 parent 455e0e6 commit 1c5261b

File tree

1 file changed

+1
-26
lines changed

1 file changed

+1
-26
lines changed

clif/pybind11/function_lib.py

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -411,29 +411,4 @@ def generate_return_value_policy(func_decl: ast_pb2.FuncDecl) -> str:
411411
if func_decl.return_value_policy == ast_pb2.FuncDecl.RETURN_AS_BYTES:
412412
return prefix + '_return_as_bytes'
413413
return prefix + 'automatic'
414-
return_type = func_decl.returns[0]
415-
# For smart pointers, it is unnecessary to specify a return value policy in
416-
# pybind11.
417-
if re.match('::std::unique_ptr<.*>', return_type.cpp_exact_type):
418-
return prefix + 'automatic'
419-
elif re.match('::std::shared_ptr<.*>', return_type.cpp_exact_type):
420-
return prefix + 'automatic'
421-
elif return_type.type.cpp_raw_pointer:
422-
# Const pointers to uncopyable object are not supported by PyCLIF.
423-
if return_type.cpp_exact_type.startswith('const '):
424-
return prefix + 'copy'
425-
else:
426-
return prefix + 'reference'
427-
elif return_type.cpp_exact_type.endswith('&'):
428-
if return_type.cpp_exact_type.startswith('const '):
429-
return prefix + 'copy'
430-
elif return_type.type.cpp_movable:
431-
return prefix + 'move'
432-
else:
433-
return prefix + 'automatic'
434-
else: # Function returns objects directly.
435-
if return_type.type.cpp_movable:
436-
return prefix + 'move'
437-
elif return_type.type.cpp_copyable:
438-
return prefix + 'copy'
439-
return prefix + 'automatic'
414+
return prefix + '_clif_automatic'

0 commit comments

Comments
 (0)