Skip to content

Commit

Permalink
add notes on next refactor step
Browse files Browse the repository at this point in the history
  • Loading branch information
goatshriek committed Nov 2, 2024
1 parent 3171291 commit 4c5601f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 6 additions & 0 deletions lib/wrapture/function_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ def initialize(spec, owner = Scope.new, constructor: false,

# True if the return value of the wrapped call is saved.
def capture_return?
# TODO this should be factored into the C++ wrapper, as it's only relevant
# for languages where the C type is directly compatible
!@constructor && (@wrapped.use_return? || returns_return_val?)
end

Expand Down Expand Up @@ -312,6 +314,8 @@ def return_overloaded?
# True if the function returns the result of the wrapped function call
# directly without any after actions.
def returns_call_directly?
# TODO this should be factored into the C++ wrapper, as it's only relevant
# for languages where the C type is directly compatible
!@constructor &&
!@destructor &&
!%w[void self-reference].include?(@spec['return']['type']) &&
Expand Down Expand Up @@ -342,6 +346,8 @@ def void_return?

# True if the function returns the return_val variable.
def returns_return_val?
# TODO this should be factored into the C++ wrapper, as it's only relevant
# for languages where the C type is directly compatible
!@return_type.self_reference? &&
@spec['return']['type'] != 'void' &&
!returns_call_directly?
Expand Down
3 changes: 2 additions & 1 deletion lib/wrapture/python_wrapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,8 @@ def function_locals(func_spec, &block)
yield "#{type_struct_name} *self;"
end

unless func_spec.void_return?
# unless func_spec.void_return?
if func_spec.capture_return?
effective_return = func_spec.wrapped.return_val_type
if effective_return.name == 'void'
effective_return = func_spec.return_type
Expand Down

0 comments on commit 4c5601f

Please sign in to comment.