Skip to content

Commit

Permalink
fix: Fix generation of optional casts in binding_generator.
Browse files Browse the repository at this point in the history
  • Loading branch information
fuzzybinary committed Dec 23, 2024
1 parent 945a905 commit 65e822a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tools/binding_generator/lib/src/common_helpers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,15 @@ void writeReturnRead(ArgumentProxy returnType, CodeSink o) {
o.p('return retPtr.value;');
break;
case TypeCategory.engineClass:
final question = returnType.isOptional ? '?' : '';
if (returnType.isRefCounted) {
final question = returnType.isOptional ? '?' : '';
o.p('final realObj = gde.ffiBindings.gde_ref_get_object(retPtr.cast());');
o.p('final retVal = gde.dartBindings.gdObjectToDartObject(realObj.cast()) as ${returnType.rawDartType}$question;');
// Need to unreference the Ref<T> as its destructor is never called
o.p('retVal$question.unreference();');
o.p('return retVal;');
} else {
o.p('return gde.dartBindings.gdObjectToDartObject(retPtr.value) as ${returnType.rawDartType};');
o.p('return gde.dartBindings.gdObjectToDartObject(retPtr.value) as ${returnType.rawDartType}$question;');
}
break;
case TypeCategory.builtinClass:
Expand Down

0 comments on commit 65e822a

Please sign in to comment.