File tree Expand file tree Collapse file tree 6 files changed +66
-16
lines changed Expand file tree Collapse file tree 6 files changed +66
-16
lines changed Original file line number Diff line number Diff line change 37
37
- uses : actions/checkout@v4
38
38
39
39
- name : Setup emsdk
40
- uses : mymindstorm/setup-emsdk@v11
40
+ uses : mymindstorm/setup-emsdk@v14
41
41
with :
42
42
version : ${{ env.EMSCRIPTEN_VERSION }}
43
43
actions-cache-folder : emsdk-cache-${{ runner.os }}
Original file line number Diff line number Diff line change @@ -252,7 +252,12 @@ public void SetupPasses(ILibrary library)
252
252
253
253
passes . AddPass ( new CleanInvalidDeclNamesPass ( ) ) ;
254
254
passes . AddPass ( new FastDelegateToDelegatesPass ( ) ) ;
255
- passes . AddPass ( new FieldToPropertyPass ( ) ) ;
255
+
256
+ if ( Options . GeneratorKind != GeneratorKind . Emscripten )
257
+ {
258
+ passes . AddPass ( new FieldToPropertyPass ( ) ) ;
259
+ }
260
+
256
261
passes . AddPass ( new CheckIgnoredDeclsPass ( ) ) ;
257
262
passes . AddPass ( new CheckEnumsPass ( ) ) ;
258
263
passes . AddPass ( new MakeProtectedNestedTypesPublicPass ( ) ) ;
@@ -283,9 +288,14 @@ public void SetupPasses(ILibrary library)
283
288
284
289
passes . AddPass ( new CheckDuplicatedNamesPass ( ) ) ;
285
290
286
- if ( Options . IsCLIGenerator || Options . IsCSharpGenerator )
291
+ if ( Options . IsCLIGenerator || Options . IsCSharpGenerator
292
+ || Options . GeneratorKind . ID is GeneratorKind . Emscripten_ID )
287
293
{
288
294
passes . RenameDeclsUpperCase ( RenameTargets . Any & ~ RenameTargets . Parameter ) ;
295
+ }
296
+
297
+ if ( Options . IsCLIGenerator || Options . IsCSharpGenerator )
298
+ {
289
299
passes . AddPass ( new CheckKeywordNamesPass ( ) ) ;
290
300
}
291
301
Original file line number Diff line number Diff line change @@ -117,11 +117,6 @@ public override void VisitClassConstructors(IEnumerable<Method> ctors)
117
117
}
118
118
}
119
119
120
- public override bool VisitProperty ( Property property )
121
- {
122
- return true ;
123
- }
124
-
125
120
public override bool VisitMethodDecl ( Method method )
126
121
{
127
122
Indent ( ) ;
@@ -130,9 +125,33 @@ public override bool VisitMethodDecl(Method method)
130
125
return ret ;
131
126
}
132
127
128
+ public override bool VisitProperty ( Property property )
129
+ {
130
+ if ( property . Field != null )
131
+ return property . Field . Visit ( this ) ;
132
+
133
+ if ( ! property . GetMethod . IsConst )
134
+ {
135
+ Console . WriteLine ( $ "Cannot bind non-const property getter method: { property . GetMethod . QualifiedOriginalName } ") ;
136
+ return false ;
137
+ }
138
+
139
+ var @class = property . Namespace as Class ;
140
+ Indent ( ) ;
141
+ Write ( $ ".property(\" { property . Name } \" , &{ @class . QualifiedOriginalName } ::{ property . GetMethod . OriginalName } ") ;
142
+
143
+ if ( property . HasSetter )
144
+ Write ( $ ", &{ @class . QualifiedOriginalName } ::{ property . SetMethod . OriginalName } ") ;
145
+
146
+ WriteLine ( ")" ) ;
147
+ Unindent ( ) ;
148
+
149
+ return true ;
150
+ }
151
+
133
152
public override bool VisitFieldDecl ( Field field )
134
153
{
135
- WriteLineIndent ( $ ".field (\" { field . Name } \" , &{ field . Class . QualifiedOriginalName } ::{ field . OriginalName } )") ;
154
+ WriteLineIndent ( $ ".property (\" { field . Name } \" , &{ field . Class . QualifiedOriginalName } ::{ field . OriginalName } )") ;
136
155
return true ;
137
156
}
138
157
Original file line number Diff line number Diff line change @@ -6,8 +6,8 @@ class Class
6
6
{
7
7
public:
8
8
void ReturnsVoid () {}
9
- int ReturnsInt () { return 0 ; }
10
- // Class* PassAndReturnsClassPtr(Class* obj) { return obj; }
9
+ int ReturnsInt () const { return 0 ; }
10
+ Class* PassAndReturnsClassPtr (Class* obj) { return obj; }
11
11
};
12
12
13
13
class ClassWithField
@@ -18,7 +18,21 @@ class ClassWithField
18
18
{
19
19
}
20
20
int Field;
21
- int ReturnsField () { return Field; }
21
+ int ReturnsField () const { return Field; }
22
+ };
23
+
24
+ class ClassWithProperty
25
+ {
26
+ public:
27
+ ClassWithProperty ()
28
+ : Field(10 )
29
+ {
30
+ }
31
+ int GetField () const { return Field; }
32
+ void SetField (int value) { Field = value; }
33
+
34
+ private:
35
+ int Field;
22
36
};
23
37
24
38
class ClassWithOverloads
@@ -41,4 +55,4 @@ class ClassWithExternalInheritance : public ClassFromAnotherUnit
41
55
};
42
56
43
57
// void FunctionPassClassByRef(Class* klass) { }
44
- // Class* FunctionReturnsClassByRef() { return new Class(); }
58
+ // Class* FunctionReturnsClassByRef() { return new Class(); }
Original file line number Diff line number Diff line change @@ -111,7 +111,14 @@ function classes() {
111
111
112
112
var classWithField = new test . ClassWithField ( ) ;
113
113
eq ( classWithField . ReturnsField ( ) , 10 ) ;
114
- //eq(classWithField.Field, 10);
114
+ eq ( classWithField . Field , 10 ) ;
115
+ classWithField . Field = 20 ;
116
+ eq ( classWithField . ReturnsField ( ) , 20 ) ;
117
+
118
+ var classWithProperty = new test . ClassWithProperty ( ) ;
119
+ eq ( classWithProperty . Field , 10 ) ;
120
+ classWithProperty . Field = 20 ;
121
+ eq ( classWithProperty . Field , 20 ) ;
115
122
}
116
123
117
124
builtins ( ) ;
Original file line number Diff line number Diff line change @@ -38,8 +38,8 @@ generate=true
38
38
39
39
if [ $generate = true ]; then
40
40
echo " ${green} Generating bindings${reset} "
41
- dotnet $rootdir /bin/${dotnet_configuration} /CppSharp.CLI.dll \
42
- --gen=emscripten --platform=emscripten --arch=wasm32 \
41
+ dotnet $rootdir /bin/${dotnet_configuration} _ ${platform} /CppSharp.CLI.dll \
42
+ --gen=emscripten --platform=emscripten --arch=wasm32 --property=keywords \
43
43
-I$dir /.. -I$rootdir /include -o $dir /gen -m tests $dir /../* .h
44
44
fi
45
45
You can’t perform that action at this time.
0 commit comments