Bug 1391438 - Move GECKOBUNDLE macros into their own header r=snorp
authorJ.C. Jones <jjones@mozilla.com>
Fri, 10 May 2019 17:59:46 +0000
changeset 532266 192ba11153b4c29512a9722caf8260292601e6aa
parent 532252 362df4629f8f1fd5ed0eece429b77499a77bb955
child 532267 d8e0bfeb5fa39545f737a6979c94a210d947ab22
push id11265
push userffxbld-merge
push dateMon, 13 May 2019 10:53:39 +0000
treeherdermozilla-beta@77e0fe8dbdd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssnorp
bugs1391438
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1391438 - Move GECKOBUNDLE macros into their own header r=snorp The GECKOBUNDLE macros are useful to more than just a11y code, so let's move them into the jni package so that all jni consumers may drink of their sweet nectar. Differential Revision: https://phabricator.services.mozilla.com/D30585
accessible/android/AccessibleWrap.cpp
accessible/android/SessionAccessibility.cpp
accessible/android/SessionAccessibility.h
widget/android/jni/GeckoBundleUtils.h
widget/android/jni/moz.build
--- a/accessible/android/AccessibleWrap.cpp
+++ b/accessible/android/AccessibleWrap.cpp
@@ -14,16 +14,17 @@
 #include "nsAccessibilityService.h"
 #include "nsPersistentProperties.h"
 #include "nsIAccessibleAnnouncementEvent.h"
 #include "nsIStringBundle.h"
 #include "nsAccUtils.h"
 #include "nsTextEquivUtils.h"
 
 #include "mozilla/a11y/PDocAccessibleChild.h"
+#include "mozilla/jni/GeckoBundleUtils.h"
 
 #define ROLE_STRINGS_URL "chrome://global/locale/AccessFu.properties"
 
 using namespace mozilla::a11y;
 
 // IDs should be a positive 32bit integer.
 IDSet sIDSet(31UL);
 
--- a/accessible/android/SessionAccessibility.cpp
+++ b/accessible/android/SessionAccessibility.cpp
@@ -14,16 +14,17 @@
 #include "nsAccessibilityService.h"
 #include "nsViewManager.h"
 #include "nsIPersistentProperties2.h"
 
 #include "mozilla/PresShell.h"
 #include "mozilla/dom/BrowserParent.h"
 #include "mozilla/a11y/DocAccessibleParent.h"
 #include "mozilla/a11y/DocManager.h"
+#include "mozilla/jni/GeckoBundleUtils.h"
 
 #ifdef DEBUG
 #  include <android/log.h>
 #  define AALOG(args...) \
     __android_log_print(ANDROID_LOG_INFO, "GeckoAccessibilityNative", ##args)
 #else
 #  define AALOG(args...) \
     do {                 \
--- a/accessible/android/SessionAccessibility.h
+++ b/accessible/android/SessionAccessibility.h
@@ -7,38 +7,16 @@
 #define mozilla_a11y_SessionAccessibility_h_
 
 #include "GeneratedJNINatives.h"
 #include "GeneratedJNIWrappers.h"
 #include "nsAppShell.h"
 #include "nsThreadUtils.h"
 #include "nsWindow.h"
 
-#define GECKOBUNDLE_START(name)                   \
-  nsTArray<jni::String::LocalRef> _##name##_keys; \
-  nsTArray<jni::Object::LocalRef> _##name##_values;
-
-#define GECKOBUNDLE_PUT(name, key, value)                                 \
-  _##name##_keys.AppendElement(jni::StringParam(NS_LITERAL_STRING(key))); \
-  _##name##_values.AppendElement(value);
-
-#define GECKOBUNDLE_FINISH(name)                                            \
-  MOZ_ASSERT(_##name##_keys.Length() == _##name##_values.Length());         \
-  auto _##name##_jkeys =                                                    \
-      jni::ObjectArray::New<jni::String>(_##name##_keys.Length());          \
-  auto _##name##_jvalues =                                                  \
-      jni::ObjectArray::New<jni::Object>(_##name##_values.Length());        \
-  for (size_t i = 0;                                                        \
-       i < _##name##_keys.Length() && i < _##name##_values.Length(); i++) { \
-    _##name##_jkeys->SetElement(i, _##name##_keys.ElementAt(i));            \
-    _##name##_jvalues->SetElement(i, _##name##_values.ElementAt(i));        \
-  }                                                                         \
-  auto name =                                                               \
-      mozilla::java::GeckoBundle::New(_##name##_jkeys, _##name##_jvalues);
-
 namespace mozilla {
 namespace a11y {
 
 class AccessibleWrap;
 class ProxyAccessible;
 class RootAccessibleWrap;
 class BatchData;
 
new file mode 100644
--- /dev/null
+++ b/widget/android/jni/GeckoBundleUtils.h
@@ -0,0 +1,38 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef mozilla_jni_GeckoBundleUtils_h
+#define mozilla_jni_GeckoBundleUtils_h
+
+namespace mozilla {
+namespace jni {
+
+#define GECKOBUNDLE_START(name)                   \
+  nsTArray<jni::String::LocalRef> _##name##_keys; \
+  nsTArray<jni::Object::LocalRef> _##name##_values;
+
+#define GECKOBUNDLE_PUT(name, key, value)                                 \
+  _##name##_keys.AppendElement(jni::StringParam(NS_LITERAL_STRING(key))); \
+  _##name##_values.AppendElement(value);
+
+#define GECKOBUNDLE_FINISH(name)                                            \
+  MOZ_ASSERT(_##name##_keys.Length() == _##name##_values.Length());         \
+  auto _##name##_jkeys =                                                    \
+      jni::ObjectArray::New<jni::String>(_##name##_keys.Length());          \
+  auto _##name##_jvalues =                                                  \
+      jni::ObjectArray::New<jni::Object>(_##name##_values.Length());        \
+  for (size_t i = 0;                                                        \
+       i < _##name##_keys.Length() && i < _##name##_values.Length(); i++) { \
+    _##name##_jkeys->SetElement(i, _##name##_keys.ElementAt(i));            \
+    _##name##_jvalues->SetElement(i, _##name##_values.ElementAt(i));        \
+  }                                                                         \
+  auto name =                                                               \
+      mozilla::java::GeckoBundle::New(_##name##_jkeys, _##name##_jvalues);
+
+}  // namespace jni
+}  // namespace mozilla
+
+#endif  // mozilla_jni_GeckoBundleUtils_h
--- a/widget/android/jni/moz.build
+++ b/widget/android/jni/moz.build
@@ -4,16 +4,17 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 with Files("**"):
     BUG_COMPONENT = ("Firefox for Android", "General")
 
 EXPORTS.mozilla.jni += [
     'Accessors.h',
+    'GeckoBundleUtils.h',
     'Natives.h',
     'Refs.h',
     'Types.h',
     'Utils.h',
 ]
 
 UNIFIED_SOURCES += [
     'Utils.cpp',