Skip to content

Commit 2abe6f5

Browse files
authored
[ffigen] Change ffigen's renaming logic to match jnigen (#2035)
1 parent 23c8dee commit 2abe6f5

File tree

55 files changed

+828
-599
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+828
-599
lines changed

pkgs/ffigen/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
- Change how protocols are implemented to fix
1414
[a bug](https://github.com/dart-lang/http/issues/1702), by removing all uses
1515
of `NSProxy`.
16+
- __Breaking change__: Change how duplicate identifiers are renamed to match
17+
jnigen. The main change is that `$` is used as a delimiter now, to avoid
18+
renamed identifiers from colliding with other identifiers. For example, `foo`
19+
is renamed to `foo$1` if there's already a `foo` in the namespace.
1620

1721
## 17.0.0
1822

pkgs/ffigen/example/libclang-example/generated_bindings.dart

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,10 @@ class LibClang {
5858

5959
/// Free the given string set.
6060
void clang_disposeStringSet(
61-
ffi.Pointer<CXStringSet> set1,
61+
ffi.Pointer<CXStringSet> set$,
6262
) {
6363
return _clang_disposeStringSet(
64-
set1,
64+
set$,
6565
);
6666
}
6767

@@ -7668,9 +7668,9 @@ typedef DartClang_getCString = ffi.Pointer<ffi.Char> Function(CXString string);
76687668
typedef NativeClang_disposeString = ffi.Void Function(CXString string);
76697669
typedef DartClang_disposeString = void Function(CXString string);
76707670
typedef NativeClang_disposeStringSet = ffi.Void Function(
7671-
ffi.Pointer<CXStringSet> set1);
7671+
ffi.Pointer<CXStringSet> set$);
76727672
typedef DartClang_disposeStringSet = void Function(
7673-
ffi.Pointer<CXStringSet> set1);
7673+
ffi.Pointer<CXStringSet> set$);
76747674

76757675
/// An "index" that consists of a set of translation units that would
76767676
/// typically be linked together into an executable or library.
@@ -7737,7 +7737,7 @@ enum CXAvailabilityKind {
77377737
2 => CXAvailability_NotAvailable,
77387738
3 => CXAvailability_NotAccessible,
77397739
_ =>
7740-
throw ArgumentError("Unknown value for CXAvailabilityKind: $value"),
7740+
throw ArgumentError('Unknown value for CXAvailabilityKind: $value'),
77417741
};
77427742
}
77437743

@@ -7798,7 +7798,7 @@ enum CXGlobalOptFlags {
77987798
1 => CXGlobalOpt_ThreadBackgroundPriorityForIndexing,
77997799
2 => CXGlobalOpt_ThreadBackgroundPriorityForEditing,
78007800
3 => CXGlobalOpt_ThreadBackgroundPriorityForAll,
7801-
_ => throw ArgumentError("Unknown value for CXGlobalOptFlags: $value"),
7801+
_ => throw ArgumentError('Unknown value for CXGlobalOptFlags: $value'),
78027802
};
78037803
}
78047804

@@ -8035,7 +8035,7 @@ enum CXDiagnosticSeverity {
80358035
3 => CXDiagnostic_Error,
80368036
4 => CXDiagnostic_Fatal,
80378037
_ =>
8038-
throw ArgumentError("Unknown value for CXDiagnosticSeverity: $value"),
8038+
throw ArgumentError('Unknown value for CXDiagnosticSeverity: $value'),
80398039
};
80408040
}
80418041

@@ -8079,7 +8079,7 @@ enum CXLoadDiag_Error {
80798079
1 => CXLoadDiag_Unknown,
80808080
2 => CXLoadDiag_CannotLoad,
80818081
3 => CXLoadDiag_InvalidFile,
8082-
_ => throw ArgumentError("Unknown value for CXLoadDiag_Error: $value"),
8082+
_ => throw ArgumentError('Unknown value for CXLoadDiag_Error: $value'),
80838083
};
80848084
}
80858085

@@ -8220,7 +8220,7 @@ enum CXErrorCode {
82208220
2 => CXError_Crashed,
82218221
3 => CXError_InvalidArguments,
82228222
4 => CXError_ASTReadError,
8223-
_ => throw ArgumentError("Unknown value for CXErrorCode: $value"),
8223+
_ => throw ArgumentError('Unknown value for CXErrorCode: $value'),
82248224
};
82258225
}
82268226

@@ -8356,7 +8356,7 @@ enum CXTUResourceUsageKind {
83568356
13 => CXTUResourceUsage_SourceManager_DataStructures,
83578357
14 => CXTUResourceUsage_Preprocessor_HeaderSearch,
83588358
_ => throw ArgumentError(
8359-
"Unknown value for CXTUResourceUsageKind: $value"),
8359+
'Unknown value for CXTUResourceUsageKind: $value'),
83608360
};
83618361

83628362
@override
@@ -9445,7 +9445,7 @@ enum CXCursorKind {
94459445
602 => CXCursor_StaticAssert,
94469446
603 => CXCursor_FriendDecl,
94479447
700 => CXCursor_OverloadCandidate,
9448-
_ => throw ArgumentError("Unknown value for CXCursorKind: $value"),
9448+
_ => throw ArgumentError('Unknown value for CXCursorKind: $value'),
94499449
};
94509450

94519451
@override
@@ -9595,7 +9595,7 @@ enum CXLinkageKind {
95959595
2 => CXLinkage_Internal,
95969596
3 => CXLinkage_UniqueExternal,
95979597
4 => CXLinkage_External,
9598-
_ => throw ArgumentError("Unknown value for CXLinkageKind: $value"),
9598+
_ => throw ArgumentError('Unknown value for CXLinkageKind: $value'),
95999599
};
96009600
}
96019601

@@ -9625,7 +9625,7 @@ enum CXVisibilityKind {
96259625
1 => CXVisibility_Hidden,
96269626
2 => CXVisibility_Protected,
96279627
3 => CXVisibility_Default,
9628-
_ => throw ArgumentError("Unknown value for CXVisibilityKind: $value"),
9628+
_ => throw ArgumentError('Unknown value for CXVisibilityKind: $value'),
96299629
};
96309630
}
96319631

@@ -9701,7 +9701,7 @@ enum CXLanguageKind {
97019701
1 => CXLanguage_C,
97029702
2 => CXLanguage_ObjC,
97039703
3 => CXLanguage_CPlusPlus,
9704-
_ => throw ArgumentError("Unknown value for CXLanguageKind: $value"),
9704+
_ => throw ArgumentError('Unknown value for CXLanguageKind: $value'),
97059705
};
97069706
}
97079707

@@ -9723,7 +9723,7 @@ enum CXTLSKind {
97239723
0 => CXTLS_None,
97249724
1 => CXTLS_Dynamic,
97259725
2 => CXTLS_Static,
9726-
_ => throw ArgumentError("Unknown value for CXTLSKind: $value"),
9726+
_ => throw ArgumentError('Unknown value for CXTLSKind: $value'),
97279727
};
97289728
}
97299729

@@ -10028,7 +10028,7 @@ enum CXTypeKind {
1002810028
174 => CXType_OCLIntelSubgroupAVCImeSingleRefStreamin,
1002910029
175 => CXType_OCLIntelSubgroupAVCImeDualRefStreamin,
1003010030
176 => CXType_ExtVector,
10031-
_ => throw ArgumentError("Unknown value for CXTypeKind: $value"),
10031+
_ => throw ArgumentError('Unknown value for CXTypeKind: $value'),
1003210032
};
1003310033

1003410034
@override
@@ -10088,7 +10088,7 @@ enum CXCallingConv {
1008810088
16 => CXCallingConv_AArch64VectorCall,
1008910089
100 => CXCallingConv_Invalid,
1009010090
200 => CXCallingConv_Unexposed,
10091-
_ => throw ArgumentError("Unknown value for CXCallingConv: $value"),
10091+
_ => throw ArgumentError('Unknown value for CXCallingConv: $value'),
1009210092
};
1009310093

1009410094
@override
@@ -10163,7 +10163,7 @@ enum CXTemplateArgumentKind {
1016310163
8 => CXTemplateArgumentKind_Pack,
1016410164
9 => CXTemplateArgumentKind_Invalid,
1016510165
_ => throw ArgumentError(
10166-
"Unknown value for CXTemplateArgumentKind: $value"),
10166+
'Unknown value for CXTemplateArgumentKind: $value'),
1016710167
};
1016810168
}
1016910169

@@ -10295,7 +10295,7 @@ enum CXTypeNullabilityKind {
1029510295
2 => CXTypeNullability_Unspecified,
1029610296
3 => CXTypeNullability_Invalid,
1029710297
_ => throw ArgumentError(
10298-
"Unknown value for CXTypeNullabilityKind: $value"),
10298+
'Unknown value for CXTypeNullabilityKind: $value'),
1029910299
};
1030010300
}
1030110301

@@ -10342,7 +10342,7 @@ enum CXRefQualifierKind {
1034210342
1 => CXRefQualifier_LValue,
1034310343
2 => CXRefQualifier_RValue,
1034410344
_ =>
10345-
throw ArgumentError("Unknown value for CXRefQualifierKind: $value"),
10345+
throw ArgumentError('Unknown value for CXRefQualifierKind: $value'),
1034610346
};
1034710347
}
1034810348

@@ -10377,7 +10377,7 @@ enum CX_CXXAccessSpecifier {
1037710377
2 => CX_CXXProtected,
1037810378
3 => CX_CXXPrivate,
1037910379
_ => throw ArgumentError(
10380-
"Unknown value for CX_CXXAccessSpecifier: $value"),
10380+
'Unknown value for CX_CXXAccessSpecifier: $value'),
1038110381
};
1038210382
}
1038310383

@@ -10409,7 +10409,7 @@ enum CX_StorageClass {
1040910409
5 => CX_SC_OpenCLWorkGroupLocal,
1041010410
6 => CX_SC_Auto,
1041110411
7 => CX_SC_Register,
10412-
_ => throw ArgumentError("Unknown value for CX_StorageClass: $value"),
10412+
_ => throw ArgumentError('Unknown value for CX_StorageClass: $value'),
1041310413
};
1041410414
}
1041510415

@@ -10451,7 +10451,7 @@ enum CXChildVisitResult {
1045110451
1 => CXChildVisit_Continue,
1045210452
2 => CXChildVisit_Recurse,
1045310453
_ =>
10454-
throw ArgumentError("Unknown value for CXChildVisitResult: $value"),
10454+
throw ArgumentError('Unknown value for CXChildVisitResult: $value'),
1045510455
};
1045610456
}
1045710457

@@ -10580,7 +10580,7 @@ enum CXPrintingPolicyProperty {
1058010580
24 => CXPrintingPolicy_SuppressImplicitBase,
1058110581
25 => CXPrintingPolicy_FullyQualifiedName,
1058210582
_ => throw ArgumentError(
10583-
"Unknown value for CXPrintingPolicyProperty: $value"),
10583+
'Unknown value for CXPrintingPolicyProperty: $value'),
1058410584
};
1058510585

1058610586
@override
@@ -10775,7 +10775,7 @@ enum CXTokenKind {
1077510775
2 => CXToken_Identifier,
1077610776
3 => CXToken_Literal,
1077710777
4 => CXToken_Comment,
10778-
_ => throw ArgumentError("Unknown value for CXTokenKind: $value"),
10778+
_ => throw ArgumentError('Unknown value for CXTokenKind: $value'),
1077910779
};
1078010780
}
1078110781

@@ -11063,7 +11063,7 @@ enum CXCompletionChunkKind {
1106311063
19 => CXCompletionChunk_HorizontalSpace,
1106411064
20 => CXCompletionChunk_VerticalSpace,
1106511065
_ => throw ArgumentError(
11066-
"Unknown value for CXCompletionChunkKind: $value"),
11066+
'Unknown value for CXCompletionChunkKind: $value'),
1106711067
};
1106811068
}
1106911069

@@ -11248,7 +11248,7 @@ enum CXEvalResultKind {
1124811248
5 => CXEval_CFStr,
1124911249
6 => CXEval_Other,
1125011250
0 => CXEval_UnExposed,
11251-
_ => throw ArgumentError("Unknown value for CXEvalResultKind: $value"),
11251+
_ => throw ArgumentError('Unknown value for CXEvalResultKind: $value'),
1125211252
};
1125311253
}
1125411254

@@ -11319,7 +11319,7 @@ enum CXVisitorResult {
1131911319
static CXVisitorResult fromValue(int value) => switch (value) {
1132011320
0 => CXVisit_Break,
1132111321
1 => CXVisit_Continue,
11322-
_ => throw ArgumentError("Unknown value for CXVisitorResult: $value"),
11322+
_ => throw ArgumentError('Unknown value for CXVisitorResult: $value'),
1132311323
};
1132411324
}
1132511325

@@ -11350,7 +11350,7 @@ enum CXResult {
1135011350
0 => CXResult_Success,
1135111351
1 => CXResult_Invalid,
1135211352
2 => CXResult_VisitBreak,
11353-
_ => throw ArgumentError("Unknown value for CXResult: $value"),
11353+
_ => throw ArgumentError('Unknown value for CXResult: $value'),
1135411354
};
1135511355
}
1135611356

@@ -11486,7 +11486,7 @@ enum CXIdxEntityKind {
1148611486
24 => CXIdxEntity_CXXConversionFunction,
1148711487
25 => CXIdxEntity_CXXTypeAlias,
1148811488
26 => CXIdxEntity_CXXInterface,
11489-
_ => throw ArgumentError("Unknown value for CXIdxEntityKind: $value"),
11489+
_ => throw ArgumentError('Unknown value for CXIdxEntityKind: $value'),
1149011490
};
1149111491
}
1149211492

@@ -11507,7 +11507,7 @@ enum CXIdxEntityLanguage {
1150711507
3 => CXIdxEntityLang_CXX,
1150811508
4 => CXIdxEntityLang_Swift,
1150911509
_ =>
11510-
throw ArgumentError("Unknown value for CXIdxEntityLanguage: $value"),
11510+
throw ArgumentError('Unknown value for CXIdxEntityLanguage: $value'),
1151111511
};
1151211512
}
1151311513

@@ -11534,7 +11534,7 @@ enum CXIdxEntityCXXTemplateKind {
1153411534
2 => CXIdxEntity_TemplatePartialSpecialization,
1153511535
3 => CXIdxEntity_TemplateSpecialization,
1153611536
_ => throw ArgumentError(
11537-
"Unknown value for CXIdxEntityCXXTemplateKind: $value"),
11537+
'Unknown value for CXIdxEntityCXXTemplateKind: $value'),
1153811538
};
1153911539
}
1154011540

@@ -11552,7 +11552,7 @@ enum CXIdxAttrKind {
1155211552
1 => CXIdxAttr_IBAction,
1155311553
2 => CXIdxAttr_IBOutlet,
1155411554
3 => CXIdxAttr_IBOutletCollection,
11555-
_ => throw ArgumentError("Unknown value for CXIdxAttrKind: $value"),
11555+
_ => throw ArgumentError('Unknown value for CXIdxAttrKind: $value'),
1155611556
};
1155711557
}
1155811558

@@ -11661,7 +11661,7 @@ enum CXIdxObjCContainerKind {
1166111661
1 => CXIdxObjCContainer_Interface,
1166211662
2 => CXIdxObjCContainer_Implementation,
1166311663
_ => throw ArgumentError(
11664-
"Unknown value for CXIdxObjCContainerKind: $value"),
11664+
'Unknown value for CXIdxObjCContainerKind: $value'),
1166511665
};
1166611666
}
1166711667

@@ -11754,7 +11754,7 @@ enum CXIdxEntityRefKind {
1175411754
1 => CXIdxEntityRef_Direct,
1175511755
2 => CXIdxEntityRef_Implicit,
1175611756
_ =>
11757-
throw ArgumentError("Unknown value for CXIdxEntityRefKind: $value"),
11757+
throw ArgumentError('Unknown value for CXIdxEntityRefKind: $value'),
1175811758
};
1175911759
}
1176011760

@@ -11788,7 +11788,7 @@ enum CXSymbolRole {
1178811788
64 => CXSymbolRole_Dynamic,
1178911789
128 => CXSymbolRole_AddressOf,
1179011790
256 => CXSymbolRole_Implicit,
11791-
_ => throw ArgumentError("Unknown value for CXSymbolRole: $value"),
11791+
_ => throw ArgumentError('Unknown value for CXSymbolRole: $value'),
1179211792
};
1179311793
}
1179411794

0 commit comments

Comments
 (0)