@@ -53,12 +53,6 @@ namespace firebase {
53
53
%include " app/src/swig/null_check_this.i"
54
54
%include " app/src/swig/serial_dispose.i"
55
55
56
- // This is defined so that it's possible to conditionally generate code that is
57
- // aware of type void. This allows us to different code for the void type as
58
- // required by "%extend Future<CTYPE>::result" below.
59
- %ignore TYPE_void;
60
- #define TYPE_void 1
61
-
62
56
// The Future implementation is assembled in a series of three macros,
63
57
// The HEADER, the GET_TASK implementation, and the FOOTER. This componentized
64
58
// approach allows for custom GET_TASK implementations for various SDKs
@@ -110,10 +104,8 @@ namespace firebase {
110
104
// 4) The user's callback executes.
111
105
112
106
113
- // Detect when the CTYPE is void by checking "TYPE_" + CTYPE, which yields:
114
- // TYPE_void. TYPE_void is only defined for "void" which allows this macro
115
- // mostly to be used but with some specializations for void.
116
- #ifdef TYPE_## %mangle(CTYPE)
107
+ // void is a special type since it isn't a real returnable type.
108
+ #if "CTYPE"=="void"
117
109
118
110
%typemap(cstype, out=" System.Threading.Tasks.Task" )
119
111
firebase::Future<CTYPE> " CSNAME" ;
@@ -136,7 +128,7 @@ namespace firebase {
136
128
return CSNAME.GetTask (new CSNAME (future, true ));
137
129
}
138
130
139
- #endif // TYPE_## %mangle( CTYPE)
131
+ #endif // " CTYPE"=="void"
140
132
141
133
// Replace the default Dispose() method to delete the callback data if
142
134
// allocated.
@@ -181,15 +173,15 @@ namespace firebase {
181
173
%define %SWIG_FUTURE_GET_TASK (CSNAME, CSTYPE, CTYPE, EXTYPE)
182
174
// Helper for csout typemap to convert futures into tasks.
183
175
// This would be internal, but we need to share it accross assemblies.
184
- #ifdef TYPE_## %mangle( CTYPE)
176
+ #if " CTYPE"=="void"
185
177
static public System.Threading .Tasks .Task GetTask (CSNAME fu) {
186
178
System.Threading .Tasks .TaskCompletionSource <int > tcs =
187
179
new System.Threading .Tasks .TaskCompletionSource <int >();
188
180
#else
189
181
static public System.Threading .Tasks .Task <CSTYPE> GetTask (CSNAME fu) {
190
182
System.Threading .Tasks .TaskCompletionSource <CSTYPE> tcs =
191
183
new System.Threading .Tasks .TaskCompletionSource <CSTYPE>();
192
- #endif // TYPE_## %mangle( CTYPE)
184
+ #endif // " CTYPE"=="void"
193
185
194
186
// Check if an exception has occurred previously and propagate it if it has.
195
187
// This has to be done before accessing the future because the future object
@@ -223,11 +215,11 @@ namespace firebase {
223
215
tcs.SetException (new EXTYPE (error, fu.error_message ()));
224
216
} else {
225
217
// Success!
226
- #ifdef TYPE_## %mangle( CTYPE)
218
+ #if " CTYPE"=="void"
227
219
tcs.SetResult (0 );
228
220
#else
229
221
tcs.SetResult (fu.GetResult ());
230
- #endif // TYPE_## %mangle( CTYPE)
222
+ #endif // " CTYPE"=="void"
231
223
}
232
224
}
233
225
} catch (System.Exception e) {
@@ -402,10 +394,8 @@ namespace firebase {
402
394
delete reinterpret_cast <CSNAME##CallbackData*>(data);
403
395
}
404
396
405
- // Detect when the CTYPE is void by checking "TYPE_" + CTYPE, which yields:
406
- // TYPE_void. TYPE_void is only defined for "void" which allows the result()
407
- // method to only be generated for non-void types.
408
- #ifndef TYPE_## %mangle(CTYPE)
397
+ // Only generate the return logic for non-void types.
398
+ #if "CTYPE"!="void"
409
399
410
400
// This method copies the value return by Future::result() so that it's
411
401
// possible to marshal the return value to C#.
@@ -417,7 +407,7 @@ namespace firebase {
417
407
return *$self->result ();
418
408
}
419
409
420
- #endif // !TYPE_void
410
+ #endif // "CTYPE"!="void"
421
411
}
422
412
423
413
} // namespace firebase
0 commit comments