Skip to content

Commit 25de448

Browse files
committed
Add comments
1 parent eb775e1 commit 25de448

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

analytics/src/analytics_android.cc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,7 @@ void AddToBundle(JNIEnv* env, jobject bundle, const char* key, int64_t value) {
355355
env->DeleteLocalRef(key_string);
356356
}
357357

358+
// Add an ArrayList to the given Bundle.
358359
void AddArrayListToBundle(JNIEnv* env, jobject bundle, const char* key,
359360
jobject arraylist) {
360361
jstring key_string = env->NewStringUTF(key);
@@ -365,6 +366,7 @@ void AddArrayListToBundle(JNIEnv* env, jobject bundle, const char* key,
365366
env->DeleteLocalRef(key_string);
366367
}
367368

369+
// Add a Bundle to the given Bundle.
368370
void AddBundleToBundle(JNIEnv* env, jobject bundle, const char* key,
369371
jobject inner_bundle) {
370372
jstring key_string = env->NewStringUTF(key);
@@ -375,8 +377,11 @@ void AddBundleToBundle(JNIEnv* env, jobject bundle, const char* key,
375377
env->DeleteLocalRef(key_string);
376378
}
377379

380+
// Declared here so that it can be used, defined below.
378381
jobject MapToBundle(JNIEnv* env, const std::map<Variant, Variant>& map);
379382

383+
// Converts the given vector into a Java ArrayList. It is up to the
384+
// caller to delete the local reference when done.
380385
jobject VectorToArrayList(JNIEnv* env, const std::vector<Variant>& vector) {
381386
jobject arraylist = env->NewObject(
382387
util::array_list::GetClass(),
@@ -388,6 +393,7 @@ jobject VectorToArrayList(JNIEnv* env, const std::vector<Variant>& vector) {
388393
env->CallBooleanMethod(
389394
arraylist, util::array_list::GetMethodId(util::array_list::kAdd),
390395
bundle);
396+
util::CheckAndClearJniExceptions(env);
391397
env->DeleteLocalRef(bundle);
392398
} else {
393399
LogError("VectorToArrayList: Unsupported type (%s) within vector.",
@@ -397,6 +403,7 @@ jobject VectorToArrayList(JNIEnv* env, const std::vector<Variant>& vector) {
397403
return arraylist;
398404
}
399405

406+
// Converts and adds the Variant to the given Bundle.
400407
bool AddVariantToBundle(JNIEnv* env, jobject bundle, const char* key,
401408
const Variant& value) {
402409
if (value.is_int64()) {
@@ -428,6 +435,8 @@ bool AddVariantToBundle(JNIEnv* env, jobject bundle, const char* key,
428435
return true;
429436
}
430437

438+
// Converts the given map into a Java Bundle. It is up to the caller
439+
// to delete the local reference when done.
431440
jobject MapToBundle(JNIEnv* env, const std::map<Variant, Variant>& map) {
432441
jobject bundle =
433442
env->NewObject(util::bundle::GetClass(),

analytics/src/analytics_ios.mm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,10 @@ void LogEvent(const char* name) {
231231
[FIRAnalytics logEventWithName:@(name) parameters:@{}];
232232
}
233233

234+
// Declared here so that it can be used, defined below.
234235
NSDictionary* MapToDictionary(const std::map<Variant, Variant>& map);
235236

237+
// Converts the given vector into an ObjC NSArray of ObjC objects.
236238
NSArray* VectorToArray(const std::vector<Variant>& vector) {
237239
NSMutableArray* array = [NSMutableArray arrayWithCapacity:vector.size()];
238240
for (const Variant& element : vector) {
@@ -247,6 +249,7 @@ void LogEvent(const char* name) {
247249
return array;
248250
}
249251

252+
// Converts and adds the Variant to the given Dictionary.
250253
bool AddVariantToDictionary(NSMutableDictionary* dict, NSString* key, const Variant& value) {
251254
if (value.is_int64()) {
252255
[dict setObject:[NSNumber numberWithLongLong:value.int64_value()] forKey:key];
@@ -273,6 +276,7 @@ bool AddVariantToDictionary(NSMutableDictionary* dict, NSString* key, const Vari
273276
return true;
274277
}
275278

279+
// Converts the given map into an ObjC dictionary of ObjC objects.
276280
NSDictionary* MapToDictionary(const std::map<Variant, Variant>& map) {
277281
NSMutableDictionary* dict = [NSMutableDictionary dictionaryWithCapacity:map.size()];
278282
for (const auto& pair : map) {

0 commit comments

Comments
 (0)