@@ -18,7 +18,9 @@ enum CppMethodKind { constructor, method }
1818/// A method or constructor belonging to a C++ class.
1919class CppMethod extends AstNode with HasLocalScope {
2020 final Symbol name;
21+ final Symbol cBindingSymbol;
2122 final String originalName;
23+
2224 final Type returnType;
2325 final List <Parameter > parameters;
2426 final bool isConstant;
@@ -30,6 +32,7 @@ class CppMethod extends AstNode with HasLocalScope {
3032
3133 CppMethod ({
3234 required this .name,
35+ required this .cBindingSymbol,
3336 required this .originalName,
3437 required this .returnType,
3538 required this .parameters,
@@ -43,7 +46,8 @@ class CppMethod extends AstNode with HasLocalScope {
4346
4447 CppMethod cloneForClass (CppClass targetClass, CppClass baseClass) {
4548 return CppMethod (
46- name: Symbol (
49+ name: name.clone (),
50+ cBindingSymbol: Symbol (
4751 '${targetClass .originalName }_$originalName ' ,
4852 SymbolKind .method,
4953 ),
@@ -70,6 +74,7 @@ class CppMethod extends AstNode with HasLocalScope {
7074 void visitChildren (Visitor visitor) {
7175 super .visitChildren (visitor);
7276 visitor.visit (name);
77+ visitor.visit (cBindingSymbol);
7378 visitor.visit (returnType);
7479 visitor.visitAll (parameters);
7580 visitor.visit (originatingClass);
@@ -136,6 +141,10 @@ class CppClass extends BindingType with HasLocalScope {
136141 methods.add (cloned);
137142 }
138143
144+ void filterMethods (bool Function (CppMethod method) predicate) {
145+ methods.retainWhere (predicate);
146+ }
147+
139148 @override
140149 BindingString toBindingString (Writer w) {
141150 final s = StringBuffer ();
@@ -257,7 +266,7 @@ class $name implements $implementsClause {
257266''' );
258267
259268 for (final ctor in constructors) {
260- final glueName = ctor.name .name;
269+ final glueName = ctor.cBindingSymbol .name;
261270 final privateName = '_$glueName ' ;
262271
263272 final dartParams = dartParamList (ctor.parameters);
@@ -284,7 +293,7 @@ class $name implements $implementsClause {
284293 }
285294
286295 for (final method in classMethods) {
287- final glue = '_${method .name .name }' ;
296+ final glue = '_${method .cBindingSymbol .name }' ;
288297 final dartReturn = method.returnType.getDartType (ctx);
289298 final dartParams = dartParamList (method.parameters);
290299 final localVars = LocalVariables (method.localScope);
@@ -314,14 +323,14 @@ class $name implements $implementsClause {
314323
315324 if (method.isStatic) {
316325 s.write ('''\
317- static $dartReturn ${method .originalName }($dartParams ) {
326+ static $dartReturn ${method .name }($dartParams ) {
318327 $decls
319328 $callLine
320329 }
321330''' );
322331 } else {
323332 s.write ('''\
324- $dartReturn ${method .originalName }($dartParams ) {
333+ $dartReturn ${method .name }($dartParams ) {
325334 if (_ptr == $ffiPrefix .nullptr) {
326335 throw StateError('This object has already been disposed.');
327336 }
@@ -370,7 +379,7 @@ class $name implements $implementsClause {
370379 }
371380
372381 for (final method in methods) {
373- final symbol = method.name .name;
382+ final symbol = method.cBindingSymbol .name;
374383 final glue = '_$symbol ' ;
375384
376385 final cReturn = method.isConstructor
@@ -428,7 +437,7 @@ FFIGEN_EXPORT void ${name}_delete($originalName* self) {
428437
429438 final methodBindings = methods
430439 .map ((method) {
431- final symbol = method.name .name;
440+ final symbol = method.cBindingSymbol .name;
432441
433442 final String returnTypeString;
434443 final String params;
0 commit comments