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

duplicate_definition for internal classes with throwing constructors #1548

Merged
merged 1 commit into from
Aug 29, 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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
* Added new lambda syntax that allows to specify parameter name.
### Bug fixes:
* Fixed documentation generation for lambdas.
* Fixed name clash and compilation errors for internally generated dart functions in case lime file contains
internal classes/structs with throwing functions/constructors that have the same name and classes/structs are contained
in the same external class.

## 13.6.4
### Features:
Expand Down
14 changes: 14 additions & 0 deletions functional-tests/functional/input/lime/StructsWithMethods.lime
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,20 @@ class StructsWithMethodsInterface {
) throws ValidationUtils.Validation
}

struct Vector4 {
x: Double = 2.0
@Dart(Default)
constructor create(
) throws ValidationUtils.Validation
}

struct Vector5 {
y: Double = 7.0
@Dart(Default)
constructor create(
) throws ValidationUtils.Validation
}

struct StructWithStaticMethodsOnly {
static fun doStuff()
}
Expand Down
14 changes: 14 additions & 0 deletions functional-tests/functional/input/src/cpp/StructsWithMethods.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,20 @@ StructsWithMethodsInterface::Vector3::create( const StructsWithMethodsInterface:
);
}

lorem_ipsum::test::Return< StructsWithMethodsInterface::Vector4, std::error_code >
StructsWithMethodsInterface::Vector4::create( )
{
return lorem_ipsum::test::Return< StructsWithMethodsInterface::Vector4, std::error_code >(
StructsWithMethodsInterface::Vector4( ) );
}

lorem_ipsum::test::Return< StructsWithMethodsInterface::Vector5, std::error_code >
StructsWithMethodsInterface::Vector5::create( )
{
return lorem_ipsum::test::Return< StructsWithMethodsInterface::Vector5, std::error_code >(
StructsWithMethodsInterface::Vector5( ) );
}

void
StructsWithMethodsInterface::StructWithStaticMethodsOnly::do_stuff( )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,19 @@
{{#resolveName}}{{#setJoin "varName" "_" this "Handle" delimiter=""}}{{>dart/DartFfiReleaseHandle}}{{/setJoin}}{{/resolveName}}
{{/parameters}}
{{#if this.thrownType}}
if (_{{resolveName}}ReturnHasError(__callResultHandle) != 0) {
final __errorHandle = _{{resolveName}}ReturnGetError(__callResultHandle);
_{{resolveName}}ReturnReleaseHandle(__callResultHandle);
if (_{{resolveName}}{{resolveName "Ffi"}}ReturnHasError(__callResultHandle) != 0) {
final __errorHandle = _{{resolveName}}{{resolveName "Ffi"}}ReturnGetError(__callResultHandle);
_{{resolveName}}{{resolveName "Ffi"}}ReturnReleaseHandle(__callResultHandle);
try {
throw {{resolveName exception}}({{#set call="FromFfi" typeRef=exception.errorType}}{{>dart/DartFfiConversionCall}}{{/set}}(__errorHandle));
} finally {
{{#set typeRef=exception.errorType varName="__errorHandle"}}{{>dart/DartFfiReleaseHandle}}{{/set}}
}
}
{{#unless returnType.isVoid}}
final __resultHandle = _{{resolveName}}ReturnGetResult(__callResultHandle);
final __resultHandle = _{{resolveName}}{{resolveName "Ffi"}}ReturnGetResult(__callResultHandle);
{{/unless}}
_{{resolveName}}ReturnReleaseHandle(__callResultHandle);
_{{resolveName}}{{resolveName "Ffi"}}ReturnReleaseHandle(__callResultHandle);
{{/if}}
{{#if isConstructor}}{{#if isStruct}}{{>ffiReturnConversion}}{{/if}}{{!!
}}{{#unless isStruct}} return __resultHandle;{{/unless}}{{/if}}{{!!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,21 @@
!
!}}
{{#if thrownType}}{{#unless attributes.async}}
final _{{resolveName}}ReturnReleaseHandle = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction<
final _{{resolveName}}{{resolveName "Ffi"}}ReturnReleaseHandle = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction<
Void Function(Pointer<Void>),
void Function(Pointer<Void>)
>('{{>dart/DartFunctionFfiName}}_return_release_handle'));
{{#unless returnType.isVoid}}
final _{{resolveName}}ReturnGetResult = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction<
final _{{resolveName}}{{resolveName "Ffi"}}ReturnGetResult = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction<
{{resolveName returnType.typeRef "FfiApiTypes"}} Function(Pointer<Void>),
{{resolveName returnType.typeRef "FfiDartTypes"}} Function(Pointer<Void>)
>('{{>dart/DartFunctionFfiName}}_return_get_result'));
{{/unless}}
final _{{resolveName}}ReturnGetError = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction<
final _{{resolveName}}{{resolveName "Ffi"}}ReturnGetError = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction<
{{resolveName exception.errorType "FfiApiTypes"}} Function(Pointer<Void>),
{{resolveName exception.errorType "FfiDartTypes"}} Function(Pointer<Void>)
>('{{>dart/DartFunctionFfiName}}_return_get_error'));
final _{{resolveName}}ReturnHasError = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction<
final _{{resolveName}}{{resolveName "Ffi"}}ReturnHasError = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction<
Uint8 Function(Pointer<Void>),
int Function(Pointer<Void>)
>('{{>dart/DartFunctionFfiName}}_return_has_error'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,19 +341,19 @@ final _smokeCommentsReleaseHandle = __lib.catchArgumentError(() => __lib.nativeL
Void Function(Pointer<Void>),
void Function(Pointer<Void>)
>('library_smoke_Comments_release_handle'));
final _someMethodWithAllCommentsReturnReleaseHandle = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction<
final _someMethodWithAllCommentssmokeCommentsSomemethodwithallcommentsStringReturnReleaseHandle = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction<
Void Function(Pointer<Void>),
void Function(Pointer<Void>)
>('library_smoke_Comments_someMethodWithAllComments__String_return_release_handle'));
final _someMethodWithAllCommentsReturnGetResult = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction<
final _someMethodWithAllCommentssmokeCommentsSomemethodwithallcommentsStringReturnGetResult = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction<
Uint8 Function(Pointer<Void>),
int Function(Pointer<Void>)
>('library_smoke_Comments_someMethodWithAllComments__String_return_get_result'));
final _someMethodWithAllCommentsReturnGetError = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction<
final _someMethodWithAllCommentssmokeCommentsSomemethodwithallcommentsStringReturnGetError = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction<
Uint32 Function(Pointer<Void>),
int Function(Pointer<Void>)
>('library_smoke_Comments_someMethodWithAllComments__String_return_get_error'));
final _someMethodWithAllCommentsReturnHasError = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction<
final _someMethodWithAllCommentssmokeCommentsSomemethodwithallcommentsStringReturnHasError = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction<
Uint8 Function(Pointer<Void>),
int Function(Pointer<Void>)
>('library_smoke_Comments_someMethodWithAllComments__String_return_has_error'));
Expand All @@ -366,17 +366,17 @@ class Comments$Impl extends __lib.NativeBase implements Comments {
final _handle = this.handle;
final __callResultHandle = _someMethodWithAllCommentsFfi(_handle, __lib.LibraryContext.isolateId, _inputParameterHandle);
stringReleaseFfiHandle(_inputParameterHandle);
if (_someMethodWithAllCommentsReturnHasError(__callResultHandle) != 0) {
final __errorHandle = _someMethodWithAllCommentsReturnGetError(__callResultHandle);
_someMethodWithAllCommentsReturnReleaseHandle(__callResultHandle);
if (_someMethodWithAllCommentssmokeCommentsSomemethodwithallcommentsStringReturnHasError(__callResultHandle) != 0) {
final __errorHandle = _someMethodWithAllCommentssmokeCommentsSomemethodwithallcommentsStringReturnGetError(__callResultHandle);
_someMethodWithAllCommentssmokeCommentsSomemethodwithallcommentsStringReturnReleaseHandle(__callResultHandle);
try {
throw Comments_SomethingWrongException(smokeCommentsSomeenumFromFfi(__errorHandle));
} finally {
smokeCommentsSomeenumReleaseFfiHandle(__errorHandle);
}
}
final __resultHandle = _someMethodWithAllCommentsReturnGetResult(__callResultHandle);
_someMethodWithAllCommentsReturnReleaseHandle(__callResultHandle);
final __resultHandle = _someMethodWithAllCommentssmokeCommentsSomemethodwithallcommentsStringReturnGetResult(__callResultHandle);
_someMethodWithAllCommentssmokeCommentsSomemethodwithallcommentsStringReturnReleaseHandle(__callResultHandle);
try {
return booleanFromFfi(__resultHandle);
} finally {
Expand Down Expand Up @@ -540,4 +540,4 @@ Comments? smokeCommentsFromFfiNullable(Pointer<Void> handle) =>
handle.address != 0 ? smokeCommentsFromFfi(handle) : null;
void smokeCommentsReleaseFfiHandleNullable(Pointer<Void> handle) =>
_smokeCommentsReleaseHandle(handle);
// End of Comments "private" section.
// End of Comments "private" section.
Original file line number Diff line number Diff line change
Expand Up @@ -139,19 +139,19 @@ final _smokeCommentslinksReleaseHandle = __lib.catchArgumentError(() => __lib.na
Void Function(Pointer<Void>),
void Function(Pointer<Void>)
>('library_smoke_CommentsLinks_release_handle'));
final _randomMethodReturnReleaseHandle = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction<
final _randomMethodsmokeCommentslinksRandommethodSomeenumReturnReleaseHandle = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction<
Void Function(Pointer<Void>),
void Function(Pointer<Void>)
>('library_smoke_CommentsLinks_randomMethod__SomeEnum_return_release_handle'));
final _randomMethodReturnGetResult = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction<
final _randomMethodsmokeCommentslinksRandommethodSomeenumReturnGetResult = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction<
Uint32 Function(Pointer<Void>),
int Function(Pointer<Void>)
>('library_smoke_CommentsLinks_randomMethod__SomeEnum_return_get_result'));
final _randomMethodReturnGetError = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction<
final _randomMethodsmokeCommentslinksRandommethodSomeenumReturnGetError = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction<
Uint32 Function(Pointer<Void>),
int Function(Pointer<Void>)
>('library_smoke_CommentsLinks_randomMethod__SomeEnum_return_get_error'));
final _randomMethodReturnHasError = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction<
final _randomMethodsmokeCommentslinksRandommethodSomeenumReturnHasError = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction<
Uint8 Function(Pointer<Void>),
int Function(Pointer<Void>)
>('library_smoke_CommentsLinks_randomMethod__SomeEnum_return_has_error'));
Expand All @@ -164,17 +164,17 @@ class CommentsLinks$Impl extends __lib.NativeBase implements CommentsLinks {
final _handle = this.handle;
final __callResultHandle = _randomMethodFfi(_handle, __lib.LibraryContext.isolateId, _inputParameterHandle);
smokeCommentsSomeenumReleaseFfiHandle(_inputParameterHandle);
if (_randomMethodReturnHasError(__callResultHandle) != 0) {
final __errorHandle = _randomMethodReturnGetError(__callResultHandle);
_randomMethodReturnReleaseHandle(__callResultHandle);
if (_randomMethodsmokeCommentslinksRandommethodSomeenumReturnHasError(__callResultHandle) != 0) {
final __errorHandle = _randomMethodsmokeCommentslinksRandommethodSomeenumReturnGetError(__callResultHandle);
_randomMethodsmokeCommentslinksRandommethodSomeenumReturnReleaseHandle(__callResultHandle);
try {
throw Comments_SomethingWrongException(smokeCommentsSomeenumFromFfi(__errorHandle));
} finally {
smokeCommentsSomeenumReleaseFfiHandle(__errorHandle);
}
}
final __resultHandle = _randomMethodReturnGetResult(__callResultHandle);
_randomMethodReturnReleaseHandle(__callResultHandle);
final __resultHandle = _randomMethodsmokeCommentslinksRandommethodSomeenumReturnGetResult(__callResultHandle);
_randomMethodsmokeCommentslinksRandommethodSomeenumReturnReleaseHandle(__callResultHandle);
try {
return smokeCommentsSomeenumFromFfi(__resultHandle);
} finally {
Expand Down Expand Up @@ -212,4 +212,4 @@ CommentsLinks? smokeCommentslinksFromFfiNullable(Pointer<Void> handle) =>
handle.address != 0 ? smokeCommentslinksFromFfi(handle) : null;
void smokeCommentslinksReleaseFfiHandleNullable(Pointer<Void> handle) =>
_smokeCommentslinksReleaseHandle(handle);
// End of CommentsLinks "private" section.
// End of CommentsLinks "private" section.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import 'package:library/src/builtin_types__conversion.dart';
/// This is some very useful class.
/// @nodoc
abstract class ExcludedComments {

/// This is some very useful constant.
/// @nodoc
static final bool veryUseful = true;
Expand Down Expand Up @@ -274,43 +273,42 @@ final _smokeExcludedcommentsReleaseHandle = __lib.catchArgumentError(() => __lib
Void Function(Pointer<Void>),
void Function(Pointer<Void>)
>('library_smoke_ExcludedComments_release_handle'));
final _someMethodWithAllCommentsReturnReleaseHandle = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction<
final _someMethodWithAllCommentssmokeExcludedcommentsSomemethodwithallcommentsStringReturnReleaseHandle = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction<
Void Function(Pointer<Void>),
void Function(Pointer<Void>)
>('library_smoke_ExcludedComments_someMethodWithAllComments__String_return_release_handle'));
final _someMethodWithAllCommentsReturnGetResult = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction<
final _someMethodWithAllCommentssmokeExcludedcommentsSomemethodwithallcommentsStringReturnGetResult = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction<
Uint8 Function(Pointer<Void>),
int Function(Pointer<Void>)
>('library_smoke_ExcludedComments_someMethodWithAllComments__String_return_get_result'));
final _someMethodWithAllCommentsReturnGetError = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction<
final _someMethodWithAllCommentssmokeExcludedcommentsSomemethodwithallcommentsStringReturnGetError = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction<
Uint32 Function(Pointer<Void>),
int Function(Pointer<Void>)
>('library_smoke_ExcludedComments_someMethodWithAllComments__String_return_get_error'));
final _someMethodWithAllCommentsReturnHasError = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction<
final _someMethodWithAllCommentssmokeExcludedcommentsSomemethodwithallcommentsStringReturnHasError = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction<
Uint8 Function(Pointer<Void>),
int Function(Pointer<Void>)
>('library_smoke_ExcludedComments_someMethodWithAllComments__String_return_has_error'));
class ExcludedComments$Impl extends __lib.NativeBase implements ExcludedComments {
ExcludedComments$Impl(Pointer<Void> handle) : super(handle);

@override
bool someMethodWithAllComments(String inputParameter) {
final _someMethodWithAllCommentsFfi = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction<Pointer<Void> Function(Pointer<Void>, Int32, Pointer<Void>), Pointer<Void> Function(Pointer<Void>, int, Pointer<Void>)>('library_smoke_ExcludedComments_someMethodWithAllComments__String'));
final _inputParameterHandle = stringToFfi(inputParameter);
final _handle = this.handle;
final __callResultHandle = _someMethodWithAllCommentsFfi(_handle, __lib.LibraryContext.isolateId, _inputParameterHandle);
stringReleaseFfiHandle(_inputParameterHandle);
if (_someMethodWithAllCommentsReturnHasError(__callResultHandle) != 0) {
final __errorHandle = _someMethodWithAllCommentsReturnGetError(__callResultHandle);
_someMethodWithAllCommentsReturnReleaseHandle(__callResultHandle);
if (_someMethodWithAllCommentssmokeExcludedcommentsSomemethodwithallcommentsStringReturnHasError(__callResultHandle) != 0) {
final __errorHandle = _someMethodWithAllCommentssmokeExcludedcommentsSomemethodwithallcommentsStringReturnGetError(__callResultHandle);
_someMethodWithAllCommentssmokeExcludedcommentsSomemethodwithallcommentsStringReturnReleaseHandle(__callResultHandle);
try {
throw ExcludedComments_SomethingWrongException(smokeExcludedcommentsSomeenumFromFfi(__errorHandle));
} finally {
smokeExcludedcommentsSomeenumReleaseFfiHandle(__errorHandle);
}
}
final __resultHandle = _someMethodWithAllCommentsReturnGetResult(__callResultHandle);
_someMethodWithAllCommentsReturnReleaseHandle(__callResultHandle);
final __resultHandle = _someMethodWithAllCommentssmokeExcludedcommentsSomemethodwithallcommentsStringReturnGetResult(__callResultHandle);
_someMethodWithAllCommentssmokeExcludedcommentsSomemethodwithallcommentsStringReturnReleaseHandle(__callResultHandle);
try {
return booleanFromFfi(__resultHandle);
} finally {
Expand Down Expand Up @@ -363,4 +361,4 @@ ExcludedComments? smokeExcludedcommentsFromFfiNullable(Pointer<Void> handle) =>
handle.address != 0 ? smokeExcludedcommentsFromFfi(handle) : null;
void smokeExcludedcommentsReleaseFfiHandleNullable(Pointer<Void> handle) =>
_smokeExcludedcommentsReleaseHandle(handle);
// End of ExcludedComments "private" section.
// End of ExcludedComments "private" section.
Loading
Loading