Skip to content

Commit a8fbd6a

Browse files
Googlera-maurice
authored andcommitted
Initial import of the Firebase Unity SDK - 387478200 Fix some errors with the Firestore Unity CMake build and ... by amaurice <[email protected]>
- 387392643 Add logic to handle newer versions of swig by amaurice <[email protected]> - 387390449 Update generated Firestore files by amaurice <[email protected]> PiperOrigin-RevId: 387478200
1 parent 290d308 commit a8fbd6a

Some content is hidden

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

50 files changed

+843
-1227
lines changed

app/src/swig/app.i

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1230,7 +1230,12 @@ static firebase::AppOptions* AppOptionsLoadFromJsonConfig(const char* config) {
12301230
// Replace the default Dispose() method to remove references to this instance
12311231
// from the map of FirebaseApp instances and notify listeners that the app has
12321232
// been disposed.
1233+
#if SWIG_VERSION >= 0x040000
1234+
%typemap(csdisposing, methodname="Dispose",
1235+
parameters="bool disposing", methodmodifiers="public")
1236+
#else
12331237
%typemap(csdestruct, methodname="Dispose", methodmodifiers="public")
1238+
#endif
12341239
firebase::App {
12351240
// If the name was not cached beforehand, do so now.
12361241
if (name == null) {
@@ -1247,13 +1252,14 @@ static firebase::AppOptions* AppOptionsLoadFromJsonConfig(const char* config) {
12471252
}
12481253

12491254
// Delete the underlying C++ object when all references to this object have been
1250-
// destroyed.
1255+
// destroyed. This is automatically done with newer versions of swig.
1256+
#if SWIG_VERSION < 0x040000
12511257
%typemap(csfinalize) firebase::App %{
12521258
~$csclassname() {
12531259
Dispose();
12541260
}
12551261
%}
1256-
1262+
#endif
12571263

12581264
%{
12591265
namespace firebase {

app/src/swig/future.i

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,12 @@ namespace firebase {
140140

141141
// Replace the default Dispose() method to delete the callback data if
142142
// allocated.
143+
#if SWIG_VERSION >= 0x040000
144+
%typemap(csdisposing_derived, methodname="Dispose",
145+
parameters="bool disposing", methodmodifiers="public")
146+
#else
143147
%typemap(csdestruct_derived, methodname="Dispose", methodmodifiers="public")
148+
#endif
144149
firebase::Future<CTYPE> {
145150
lock (FirebaseApp.disposeLock) {
146151
if (swigCPtr.Handle != System.IntPtr.Zero) {

app/src/swig/serial_dispose.i

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
// Copyright 2019 Google Inc. All Rights Reserved.
22

33
// Serialize the destruction of all objects.
4+
#if SWIG_VERSION >= 0x040000
5+
%typemap(csdisposing, methodname="Dispose",
6+
parameters="bool disposing", methodmodifiers="public") SWIGTYPE {
7+
#else
48
%typemap(csdestruct, methodname="Dispose", methodmodifiers="public") SWIGTYPE {
9+
#endif
510
lock (FirebaseApp.disposeLock) {
611
if (swigCPtr.Handle != global::System.IntPtr.Zero) {
712
if (swigCMemOwn) {
@@ -16,7 +21,11 @@
1621
}
1722

1823
// Serialize the destruction of all derived objects.
24+
#if SWIG_VERSION >= 0x040000
25+
%typemap(csdisposing_derived, methodname="Dispose", parameters="bool disposing",
26+
#else
1927
%typemap(csdestruct_derived, methodname="Dispose",
28+
#endif
2029
methodmodifiers="public") SWIGTYPE {
2130
lock (FirebaseApp.disposeLock) {
2231
if (swigCPtr.Handle != global::System.IntPtr.Zero) {

auth/src/swig/auth.i

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,13 @@
2828

2929
%typemap(csclassmodifiers) CTYPE "public static class";
3030
%typemap(csbody) CTYPE "";
31+
#if SWIG_VERSION >= 0x040000
32+
%typemap(csdispose) CTYPE "";
33+
%typemap(csdisposing) CTYPE "";
34+
#else
3135
%typemap(csdestruct) CTYPE "";
3236
%typemap(csfinalize) CTYPE "";
37+
#endif
3338
%typemap(csinterfaces) CTYPE "";
3439
%ignore CONSTRUCTOR;
3540

@@ -924,7 +929,12 @@ static CppInstanceManager<Auth> g_auth_instances;
924929

925930
// Replace the default Dispose() method to remove references to this instance
926931
// from the map of FirebaseAuth instances.
932+
#if SWIG_VERSION >= 0x040000
933+
%typemap(csdisposing, methodname="Dispose",
934+
parameters="bool disposing", methodmodifiers="public")
935+
#else
927936
%typemap(csdestruct, methodname="Dispose", methodmodifiers="public")
937+
#endif
928938
firebase::auth::Auth {
929939
DisposeInternal();
930940
}

crashlytics/src/swig/crashlytics.i

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,12 @@
3636
%typemap(cstype, out="global::System.Collections.Generic.IEnumerable<FirebaseCrashlyticsFrame>") std::vector<firebase::crashlytics::Frame> "StackFrames";
3737

3838
// Delete the C++ object if hasn't already been deleted.
39+
#if SWIG_VERSION >= 0x040000
40+
%typemap(csdisposing, methodname="Dispose",
41+
parameters="bool disposing", methodmodifiers="public")
42+
#else
3943
%typemap(csdestruct, methodname="Dispose", methodmodifiers="public")
44+
#endif
4045
firebase::crashlytics::Crashlytics {
4146
lock (FirebaseApp.disposeLock) {
4247
// TODO(@samedson) Do I need to call ReleaseReferenceInternal

database/src/swig/database.i

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,12 @@ static CppInstanceManager<Database> g_database_instances;
8686
firebase::database::DataSnapshot, FirebaseException)
8787

8888
// Delete the C++ object if hasn't already been deleted.
89+
#if SWIG_VERSION >= 0x040000
90+
%typemap(csdisposing, methodname="Dispose",
91+
parameters="bool disposing", methodmodifiers="public")
92+
#else
8993
%typemap(csdestruct, methodname="Dispose", methodmodifiers="public")
94+
#endif
9095
firebase::database::Database {
9196
lock (FirebaseApp.disposeLock) {
9297
ReleaseReferenceInternal(this);

firestore/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ firebase_swig_add_library(firebase_firestore_swig
9696
absl_variant
9797
)
9898

99-
set(FIRESTORE_SOURCE_DIR ${FIREBASE_CPP_SDK_DIR}/build/external/src/firestore)
99+
set(FIRESTORE_SOURCE_DIR ${PROJECT_BINARY_DIR}/bin/external/src/firestore)
100100

101101
# Additional public headers come from the Firestore core
102102
if(IOS)

firestore/generated/src/firestore.cpp

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,7 @@ template<typename T> class SwigValueWrapper {
2626
public:
2727
SwigValueWrapper() : pointer(0) { }
2828
#if __cplusplus >= 201103L
29-
SwigValueWrapper &operator=(T t) {
30-
SwigMovePointer tmp(new T(std::move(t)));
31-
pointer = tmp;
32-
return *this;
33-
}
29+
SwigValueWrapper& operator=(T t) { SwigMovePointer tmp(new T(std::move(t))); pointer = tmp; return *this; }
3430
#else
3531
SwigValueWrapper& operator=(const T& t) { SwigMovePointer tmp(new T(t)); pointer = tmp; return *this; }
3632
#endif
@@ -358,29 +354,39 @@ SWIGINTERN void SWIG_CSharpException(int code, const char *msg) {
358354
}
359355
}
360356

357+
361358
#include <stdexcept>
359+
360+
362361
#include <utility>
363362

363+
364+
#include "firestore/src/include/firebase/firestore.h"
365+
366+
367+
#include <stdexcept>
368+
369+
#include "firestore/src/common/firestore_exceptions_common.h"
370+
371+
364372
#include "app/src/callback.h"
365373
#include "app/src/include/firebase/future.h"
366-
#include "firestore/src/common/firestore_exceptions_common.h"
367-
#include "firestore/src/include/firebase/firestore.h"
368374

369-
// This adds the STDCALL thunk, necessary for C/C# interoperability.
370-
// The function pointer type declared in the C++ library should have the
371-
// exact same signature, however it lacks this explicit calling convention
372-
// declaration. We declare it here with explicit calling convention and use
373-
// a thin wrapper (just below) so that we can be certain we match the same
374-
// calling convention in C# when we trigger the callback.
375-
typedef void(SWIGSTDCALL *Future_QuerySnapshot_CB_Type)(int index);
376-
377-
// Associates callback data with each Future<firebase::firestore::QuerySnapshot>
378-
// instance.
379-
struct Future_QuerySnapshotCallbackData {
380-
// C# delegate method that should be called on the main thread.
381-
Future_QuerySnapshot_CB_Type cs_callback;
382-
// Key of the callback in the C# QuerySnapshotProxy.Callbacks dictionary.
383-
int cs_key;
375+
376+
// This adds the STDCALL thunk, necessary for C/C# interoperability.
377+
// The function pointer type declared in the C++ library should have the
378+
// exact same signature, however it lacks this explicit calling convention
379+
// declaration. We declare it here with explicit calling convention and use
380+
// a thin wrapper (just below) so that we can be certain we match the same
381+
// calling convention in C# when we trigger the callback.
382+
typedef void (SWIGSTDCALL* Future_QuerySnapshot_CB_Type)(int index);
383+
384+
// Associates callback data with each Future<firebase::firestore::QuerySnapshot> instance.
385+
struct Future_QuerySnapshotCallbackData {
386+
// C# delegate method that should be called on the main thread.
387+
Future_QuerySnapshot_CB_Type cs_callback;
388+
// Key of the callback in the C# QuerySnapshotProxy.Callbacks dictionary.
389+
int cs_key;
384390
};
385391

386392
// Use a static function to make callback so don't need to worry about

firestore/generated/src/proxy/ApiHeaders.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ internal ApiHeaders(global::System.IntPtr cPtr, bool cMemoryOwn) {
2626
}
2727

2828
public virtual void Dispose() {
29+
2930
lock (FirebaseApp.disposeLock) {
3031
if (swigCPtr.Handle != global::System.IntPtr.Zero) {
3132
if (swigCMemOwn) {

firestore/generated/src/proxy/DocumentChangeProxy.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ internal DocumentChangeProxy(global::System.IntPtr cPtr, bool cMemoryOwn) {
2626
}
2727

2828
public virtual void Dispose() {
29+
2930
lock (FirebaseApp.disposeLock) {
3031
if (swigCPtr.Handle != global::System.IntPtr.Zero) {
3132
if (swigCMemOwn) {

0 commit comments

Comments
 (0)