@@ -53,12 +53,6 @@ namespace firebase {
5353%include " app/src/swig/null_check_this.i"
5454%include " app/src/swig/serial_dispose.i"
5555
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-
6256// The Future implementation is assembled in a series of three macros,
6357// The HEADER, the GET_TASK implementation, and the FOOTER. This componentized
6458// approach allows for custom GET_TASK implementations for various SDKs
@@ -110,10 +104,8 @@ namespace firebase {
110104// 4) The user's callback executes.
111105
112106
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"
117109
118110%typemap(cstype, out=" System.Threading.Tasks.Task" )
119111 firebase::Future<CTYPE> " CSNAME" ;
@@ -136,7 +128,7 @@ namespace firebase {
136128 return CSNAME.GetTask (new CSNAME (future, true ));
137129 }
138130
139- #endif // TYPE_## %mangle( CTYPE)
131+ #endif // " CTYPE"=="void"
140132
141133// Replace the default Dispose() method to delete the callback data if
142134// allocated.
@@ -181,15 +173,15 @@ namespace firebase {
181173%define %SWIG_FUTURE_GET_TASK (CSNAME, CSTYPE, CTYPE, EXTYPE)
182174 // Helper for csout typemap to convert futures into tasks.
183175 // This would be internal, but we need to share it accross assemblies.
184- #ifdef TYPE_## %mangle( CTYPE)
176+ #if " CTYPE"=="void"
185177 static public System.Threading .Tasks .Task GetTask (CSNAME fu) {
186178 System.Threading .Tasks .TaskCompletionSource <int > tcs =
187179 new System.Threading .Tasks .TaskCompletionSource <int >();
188180#else
189181 static public System.Threading .Tasks .Task <CSTYPE> GetTask (CSNAME fu) {
190182 System.Threading .Tasks .TaskCompletionSource <CSTYPE> tcs =
191183 new System.Threading .Tasks .TaskCompletionSource <CSTYPE>();
192- #endif // TYPE_## %mangle( CTYPE)
184+ #endif // " CTYPE"=="void"
193185
194186 // Check if an exception has occurred previously and propagate it if it has.
195187 // This has to be done before accessing the future because the future object
@@ -223,11 +215,11 @@ namespace firebase {
223215 tcs.SetException (new EXTYPE (error, fu.error_message ()));
224216 } else {
225217 // Success!
226- #ifdef TYPE_## %mangle( CTYPE)
218+ #if " CTYPE"=="void"
227219 tcs.SetResult (0 );
228220#else
229221 tcs.SetResult (fu.GetResult ());
230- #endif // TYPE_## %mangle( CTYPE)
222+ #endif // " CTYPE"=="void"
231223 }
232224 }
233225 } catch (System.Exception e) {
@@ -402,10 +394,8 @@ namespace firebase {
402394 delete reinterpret_cast <CSNAME##CallbackData*>(data);
403395 }
404396
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"
409399
410400 // This method copies the value return by Future::result() so that it's
411401 // possible to marshal the return value to C#.
@@ -417,7 +407,7 @@ namespace firebase {
417407 return *$self->result ();
418408 }
419409
420- #endif // !TYPE_void
410+ #endif // "CTYPE"!="void"
421411}
422412
423413} // namespace firebase
0 commit comments