Compare commits

..
45838 changed files with 3166966 additions and 2306709 deletions

No files matched your search

+22
View File
@@ -187,6 +187,28 @@ devtools/client/framework/test/code_ugly*
devtools/server/tests/unit/babel_and_browserify_script_with_source_map.js
devtools/server/tests/unit/setBreakpoint*
# mobile/android/ exclusions
mobile/android/tests/
# Uses `#filter substitution`
mobile/android/b2gdroid/app/b2gdroid.js
mobile/android/app/mobile.js
mobile/android/chrome/content/healthreport-prefs.js
# Uses `#expand`
mobile/android/chrome/content/about.js
# Not much JS to lint and non-standard at that
mobile/android/installer/
mobile/android/locales/
# Non-standard `(catch ex if ...)`
mobile/android/chrome/content/browser.js
mobile/android/components/Snippets.js
# Bug 1178739: Ignore this file as a quick fix for "Illegal yield expression"
mobile/android/modules/HomeProvider.jsm
# services/ exclusions
# Uses `#filter substitution`
+3
View File
@@ -91,6 +91,9 @@ GPATH
# Git clone directory for updating web-platform-tests
testing/web-platform/sync/
# Android Gradle artifacts.
mobile/android/gradle/.gradle
# XCode project cruft
embedding/ios/GoannaEmbed/GoannaEmbed.xcodeproj/project.xcworkspace/xcuserdata
embedding/ios/GoannaEmbed/GoannaEmbed.xcodeproj/xcuserdata
+5
View File
@@ -36,6 +36,11 @@ def FlagsForFile(filename):
flag_list = shlex.split(out.getvalue())
# This flag is added by Fennec for android build and causes ycmd to fail to parse the file.
# Removing this flag is a workaround until ycmd starts to handle this flag properly.
# https://github.com/Valloric/YouCompleteMe/issues/1490
final_flags = [x for x in flag_list if not x.startswith('-march=armv')]
return {
'flags': final_flags,
'do_cache': True
+1 -1
View File
@@ -22,4 +22,4 @@
# changes to stick? As of bug 928195, this shouldn't be necessary! Please
# don't change CLOBBER for WebIDL changes any more.
Touching ICU's build system requires a CLOBBER. (Issue #2165)
Clobber for CSS flow-root implementation
+50 -7
View File
@@ -137,10 +137,16 @@ default:: $(BUILD_BACKEND_FILES)
endif
install_manifests := \
$(addprefix dist/,branding bin idl include public private sdk xpi-stage) \
$(addprefix dist/,branding idl include public private sdk xpi-stage) \
_tests \
$(NULL)
# Skip the dist/bin install manifest when using the hybrid
# FasterMake/RecursiveMake backend. This is a hack until bug 1241744 moves
# xpidl handling to FasterMake in that case, mechanically making the dist/bin
# install manifest non-existent (non-existent manifests being skipped)
ifeq (,$(filter FasterMake+RecursiveMake,$(BUILD_BACKENDS)))
install_manifests += dist/bin
endif
install_manifest_depends = \
CLOBBER \
$(configure_dir)/configure \
@@ -160,9 +166,45 @@ endif
.PHONY: install-manifests
install-manifests: $(addprefix install-,$(install_manifests))
.PHONY: $(addprefix install-,$(install_manifests))
# If we're using the hybrid FasterMake/RecursiveMake backend, we want
# to recurse in the faster/ directory in parallel of install manifests.
# But dist/idl needs to happen before (cf. dependencies in
# config/faster/rules.mk)
ifneq (,$(filter FasterMake+RecursiveMake,$(BUILD_BACKENDS)))
install-manifests: faster
.PHONY: faster
faster: install-dist/idl
$(MAKE) -C faster FASTER_RECURSIVE_MAKE=1
endif
.PHONY: tup
tup:
$(call BUILDSTATUS,TIERS make tup)
$(call BUILDSTATUS,TIER_START make)
$(MAKE) install-manifests buildid.h source-repo.h
$(call BUILDSTATUS,TIER_FINISH make)
$(call BUILDSTATUS,TIER_START tup)
@$(TUP) $(if $(findstring s,$(filter-out --%,$(MAKEFLAGS))),,--verbose)
$(call BUILDSTATUS,TIER_FINISH tup)
# process_install_manifest needs to be invoked with --no-remove when building
# js as standalone because automated builds are building nspr separately and
# that would remove the resulting files.
# Eventually, a standalone js build would just be able to build nspr itself,
# removing the need for the former.
ifdef JS_STANDALONE
NO_REMOVE=1
endif
.PHONY: $(addprefix install-,$(subst /,_,$(install_manifests)))
$(addprefix install-,$(install_manifests)): install-%: $(install_manifest_depends)
$(addprefix $(call py_action,process_install_manifest,--track install_$(subst /,_,$*).track $*) ,$(wildcard _build_manifests/install/$(subst /,_,$*)))
ifneq (,$(filter FasterMake+RecursiveMake,$(BUILD_BACKENDS)))
@# If we're using the hybrid FasterMake/RecursiveMake backend, we want
@# to ensure the FasterMake end doesn't have install manifests for the
@# same directory, because that would blow up
$(if $(wildcard _build_manifests/install/$(subst /,_,$*)),$(if $(wildcard faster/install_$(subst /,_,$*)*),$(error FasterMake and RecursiveMake ends of the hybrid build system want to handle $*)))
endif
$(addprefix $(call py_action,process_install_manifest,$(if $(NO_REMOVE),--no-remove )$*) ,$(wildcard _build_manifests/install/$(subst /,_,$*)))
# Dummy wrapper rule to allow the faster backend to piggy back
$(addprefix install-,$(subst /,_,$(filter dist/%,$(install_manifests)))): install-dist_%: install-dist/% ;
@@ -175,9 +217,10 @@ install-tests: install-test-files
.PHONY: run-tests-deps
run-tests-deps: $(install_manifest_depends)
# Force --no-remove, because $objdir/_tests is handled by multiple manifests.
.PHONY: install-test-files
install-test-files:
$(call py_action,process_install_manifest,--track install__test_files.track _tests _build_manifests/install/_test_files)
$(call py_action,process_install_manifest,--no-remove _tests _build_manifests/install/_test_files)
include $(topsrcdir)/build/moz-automation.mk
@@ -197,13 +240,13 @@ ifndef NO_PROFILE_GUIDED_OPTIMIZE
ifneq ($(OS_ARCH)_$(GNU_CC), WINNT_)
recurse_pre-export:: install-manifests
binaries::
@$(MAKE) install-manifests install_manifests=dist/include
@$(MAKE) install-manifests NO_REMOVE=1 install_manifests=dist/include
endif
endif
else # !MOZ_PROFILE_USE (normal build)
recurse_pre-export:: install-manifests
binaries::
@$(MAKE) install-manifests install_manifests=dist/include
@$(MAKE) install-manifests NO_REMOVE=1 install_manifests=dist/include
endif
# For historical reasons that are unknown, $(DIST)/sdk is always blown away
+5 -5
View File
@@ -9,6 +9,8 @@ selective cherry-picking of directly-applicable patches, this repository has its
own development and holds the base for a maintained platform to be used by XUL
applications.
For a list of active projects making use of the Unified XUL Platform, checkout http://thereisonlyxul.org/.
## Additional documentation
Additional documentation relevant to this source code can be found in the `/docs`
@@ -21,7 +23,7 @@ You are also always welcome to get in touch with our community on the [Pale Moon
### A note about trademarks and branding
Although this repository is primarily licensed under Mozilla Public License v2.0, the
Although this repository is licensed under Mozilla Public License v2.0, the
trademarks and brands contained herein remain the property of their respective
owners. For more details, please see the notifications in the respective directories.
@@ -33,7 +35,5 @@ If you fork this repository to perform your own work on it, please consider offe
improvement patches upstream to its origin to mutually improve the platform and build
a future for XUL.
## Looking for Pale Moon?
As of [`Issue #969`](https://repo.palemoon.org/MoonchildProductions/UXP/issues/969), release version `28.9.0`,
applications have been split off into their own dedicated (front-end) repositories, with Pale Moon located at
[`MoonchildProductions/Pale-Moon`](https://repo.palemoon.org/MoonchildProductions/Pale-Moon).
## Looking for Pale Moon and Basilisk?
As of [`Issue #969`](https://repo.palemoon.org/MoonchildProductions/UXP/issues/969), release versions `28.9.0` and `2020.03.04` respectively, they have been split off into their own dedicated repositories located at [`MoonchildProductions/Pale-Moon`](https://repo.palemoon.org/MoonchildProductions/Pale-Moon) and [`MoonchildProductions/Basilisk`](https://repo.palemoon.org/MoonchildProductions/Basilisk).
+3 -2
View File
@@ -15,14 +15,14 @@ What should be considered vulnerabilities or security hazards by default:
Generally not security vulnerabilities:
- Null dereferencing crashes;
- Malware extensions (but please do report those on the forum in the add-ons board!);
- Malware extensions (but please do report those on the forum in the extensions board!);
- Denial-of-service (AKA "evil trap sites")
- Browser hangs
- Issues with non-standard manual configuration (either at build time or by manipulating about:config directly)
## Reporting a Vulnerability
If you find an issue in UXP, or the applications building on it, that could impact the security or safety of users please **do not**
If you find an issue in UXP or the applications it builds on that could impact the security or safety of users please **do not**
make an issue on Gitea about it. Gitea does not support restricted viewability for security sensitive bugs.
If you want to report a security-sensitive issue then please go to the [forum](https://forum.palemoon.org) and report the issue
@@ -33,3 +33,4 @@ except the recipient (not even moderators!).
You will be informed via private message if the vulnerability report is accepted or declined, with reasoning.
Security updates occur regularly and are given priority over most other development tasks. In general, they can be solved
relatively quickly and will be included in the next point release (third digit if not rolled into a more major one).
+2
View File
@@ -1,4 +1,6 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:expandtab:shiftwidth=2:tabstop=2:
*/
/* 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/. */
+2
View File
@@ -1,4 +1,6 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:expandtab:shiftwidth=2:tabstop=2:
*/
/* 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/. */
+2
View File
@@ -5,7 +5,9 @@
#include "AccIterator.h"
#include "AccGroupInfo.h"
#ifdef MOZ_XUL
#include "XULTreeAccessible.h"
#endif
#include "mozilla/dom/HTMLLabelElement.h"
+2
View File
@@ -341,6 +341,8 @@ LogRequest(nsIRequest* aRequest)
printf("targeted; ");
if (loadFlags & nsIChannel::LOAD_CALL_CONTENT_SNIFFERS)
printf("call content sniffers; ");
if (loadFlags & nsIChannel::LOAD_CLASSIFY_URI)
printf("classify uri; ");
} else {
printf(" no request");
}
+2
View File
@@ -1,4 +1,6 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:expandtab:shiftwidth=2:tabstop=2:
*/
/* 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/. */
@@ -13,6 +13,7 @@
#include "mozilla/dom/TabChild.h"
#include "mozilla/dom/Element.h"
#include "mozilla/Telemetry.h"
using namespace mozilla;
using namespace mozilla::a11y;
+26 -8
View File
@@ -18,6 +18,10 @@
#include "mozilla/AppUnits.h"
#include "mozilla/gfx/2D.h"
#if defined(MOZ_WIDGET_GTK)
#include "gfxPlatformGtk.h" // xxx - for UseFcFontList
#endif
using namespace mozilla;
using namespace mozilla::a11y;
@@ -649,14 +653,28 @@ TextAttrsMgr::FontWeightTextAttr::
if (font->IsSyntheticBold())
return 700;
// On Windows, font->GetStyle()->weight will give the same weight as
// fontEntry->Weight(), the weight of the first font in the font group,
// which may not be the weight of the font face used to render the
// characters. On Mac, font->GetStyle()->weight will just give the same
// number as getComputedStyle(). fontEntry->Weight() will give the weight
// of the font face used.
gfxFontEntry *fontEntry = font->GetFontEntry();
return fontEntry->Weight();
bool useFontEntryWeight = true;
// Under Linux, when gfxPangoFontGroup code is used,
// font->GetStyle()->weight will give the absolute weight requested of the
// font face. The gfxPangoFontGroup code uses the gfxFontEntry constructor
// which doesn't initialize the weight field.
#if defined(MOZ_WIDGET_GTK)
useFontEntryWeight = gfxPlatformGtk::UseFcFontList();
#endif
if (useFontEntryWeight) {
// On Windows, font->GetStyle()->weight will give the same weight as
// fontEntry->Weight(), the weight of the first font in the font group,
// which may not be the weight of the font face used to render the
// characters. On Mac, font->GetStyle()->weight will just give the same
// number as getComputedStyle(). fontEntry->Weight() will give the weight
// of the font face used.
gfxFontEntry *fontEntry = font->GetFontEntry();
return fontEntry->Weight();
} else {
return font->GetStyle()->weight;
}
}
////////////////////////////////////////////////////////////////////////////////
@@ -68,6 +68,7 @@
#include "mozilla/Services.h"
#include "nsDeckFrame.h"
#ifdef MOZ_XUL
#include "XULAlertAccessible.h"
#include "XULColorPickerAccessible.h"
#include "XULComboboxAccessible.h"
@@ -78,6 +79,7 @@
#include "XULSliderAccessible.h"
#include "XULTabAccessible.h"
#include "XULTreeGridAccessibleWrap.h"
#endif
#if defined(XP_WIN) || defined(MOZ_ACCESSIBILITY_ATK)
#include "nsNPAPIPluginInstance.h"
@@ -1354,6 +1356,7 @@ nsAccessibilityService::CreateAccessibleByType(nsIContent* aContent,
}
RefPtr<Accessible> accessible;
#ifdef MOZ_XUL
// XUL controls
if (role.EqualsLiteral("xul:alert")) {
accessible = new XULAlertAccessible(aContent, aDoc);
@@ -1512,6 +1515,7 @@ nsAccessibilityService::CreateAccessibleByType(nsIContent* aContent,
accessible = new XULToolbarButtonAccessible(aContent, aDoc);
}
#endif // MOZ_XUL
return accessible.forget();
}
@@ -1735,6 +1739,7 @@ nsAccessibilityService::HasAccessible(nsIDOMNode* aDOMNode)
////////////////////////////////////////////////////////////////////////////////
// nsAccessibilityService private (DON'T put methods here)
#ifdef MOZ_XUL
already_AddRefed<Accessible>
nsAccessibilityService::CreateAccessibleForXULTree(nsIContent* aContent,
DocAccessible* aDoc)
@@ -1764,6 +1769,7 @@ nsAccessibilityService::CreateAccessibleForXULTree(nsIContent* aContent,
new XULTreeGridAccessibleWrap(aContent, aDoc, treeFrame);
return accessible.forget();
}
#endif
nsAccessibilityService*
GetOrCreateAccService(uint32_t aNewConsumer)
+2
View File
@@ -274,11 +274,13 @@ private:
CreateAccessibleByFrameType(nsIFrame* aFrame, nsIContent* aContent,
Accessible* aContext);
#ifdef MOZ_XUL
/**
* Create accessible for XUL tree element.
*/
already_AddRefed<Accessible>
CreateAccessibleForXULTree(nsIContent* aContent, DocAccessible* aDoc);
#endif
/**
* Reference for accessibility service instance.
+2
View File
@@ -1,4 +1,6 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:expandtab:shiftwidth=2:tabstop=2:
*/
/* 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/. */
+2
View File
@@ -1,4 +1,6 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:expandtab:shiftwidth=2:tabstop=2:
*/
/* 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/. */
@@ -1,4 +1,6 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:expandtab:shiftwidth=2:tabstop=2:
*/
/* 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/. */
@@ -1,4 +1,6 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:expandtab:shiftwidth=2:tabstop=2:
*/
/* 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/. */
+6
View File
@@ -48,7 +48,9 @@
#include "mozilla/dom/DocumentType.h"
#include "mozilla/dom/Element.h"
#ifdef MOZ_XUL
#include "nsIXULDocument.h"
#endif
using namespace mozilla;
using namespace mozilla::a11y;
@@ -208,9 +210,11 @@ DocAccessible::NativeRole()
return roles::CHROME_WINDOW;
if (itemType == nsIDocShellTreeItem::typeContent) {
#ifdef MOZ_XUL
nsCOMPtr<nsIXULDocument> xulDoc(do_QueryInterface(mDocumentNode));
if (xulDoc)
return roles::APPLICATION;
#endif
return roles::DOCUMENT;
}
}
@@ -383,11 +387,13 @@ DocAccessible::URL(nsAString& aURL) const
void
DocAccessible::DocType(nsAString& aType) const
{
#ifdef MOZ_XUL
nsCOMPtr<nsIXULDocument> xulDoc(do_QueryInterface(mDocumentNode));
if (xulDoc) {
aType.AssignLiteral("window"); // doctype not implemented for XUL at time of writing - causes assertion
return;
}
#endif
dom::DocumentType* docType = mDocumentNode->GetDoctype();
if (docType)
docType->GetPublicId(aType);
+31 -8
View File
@@ -19,7 +19,9 @@
#include "Relation.h"
#include "Role.h"
#include "States.h"
#ifdef MOZ_XUL
#include "XULTreeAccessible.h"
#endif
#include "mozilla/dom/Element.h"
@@ -41,8 +43,10 @@
#include "nsFocusManager.h"
#include "nsGlobalWindow.h"
#ifdef MOZ_XUL
#include "nsIXULDocument.h"
#include "nsIXULWindow.h"
#endif
using namespace mozilla;
using namespace mozilla::a11y;
@@ -98,6 +102,7 @@ RootAccessible::NativeRole()
}
// RootAccessible protected member
#ifdef MOZ_XUL
uint32_t
RootAccessible::GetChromeFlags()
{
@@ -117,6 +122,7 @@ RootAccessible::GetChromeFlags()
xulWin->GetChromeFlags(&chromeFlags);
return chromeFlags;
}
#endif
uint64_t
RootAccessible::NativeState()
@@ -125,6 +131,7 @@ RootAccessible::NativeState()
if (state & states::DEFUNCT)
return state;
#ifdef MOZ_XUL
uint32_t chromeFlags = GetChromeFlags();
if (chromeFlags & nsIWebBrowserChrome::CHROME_WINDOW_RESIZE)
state |= states::SIZEABLE;
@@ -135,6 +142,7 @@ RootAccessible::NativeState()
state |= states::MOVEABLE;
if (chromeFlags & nsIWebBrowserChrome::CHROME_MODAL)
state |= states::MODAL;
#endif
nsFocusManager* fm = nsFocusManager::GetFocusManager();
if (fm && fm->GetActiveWindow() == mDocumentNode->GetWindow())
@@ -284,6 +292,7 @@ RootAccessible::ProcessDOMEvent(nsIDOMEvent* aDOMEvent)
if (!accessible)
return;
#ifdef MOZ_XUL
XULTreeAccessible* treeAcc = accessible->AsXULTree();
if (treeAcc) {
if (eventType.EqualsLiteral("TreeRowCountChanged")) {
@@ -296,6 +305,7 @@ RootAccessible::ProcessDOMEvent(nsIDOMEvent* aDOMEvent)
return;
}
}
#endif
if (eventType.EqualsLiteral("RadioStateChange")) {
uint64_t state = accessible->State();
@@ -331,6 +341,7 @@ RootAccessible::ProcessDOMEvent(nsIDOMEvent* aDOMEvent)
}
Accessible* treeItemAcc = nullptr;
#ifdef MOZ_XUL
// If it's a tree element, need the currently selected item.
if (treeAcc) {
treeItemAcc = accessible->CurrentItem();
@@ -374,22 +385,29 @@ RootAccessible::ProcessDOMEvent(nsIDOMEvent* aDOMEvent)
nsEventShell::FireEvent(selChangeEvent);
return;
}
} else if (eventType.EqualsLiteral("AlertActive")) {
}
else
#endif
if (eventType.EqualsLiteral("AlertActive")) {
nsEventShell::FireEvent(nsIAccessibleEvent::EVENT_ALERT, accessible);
} else if (eventType.EqualsLiteral("popupshown")) {
}
else if (eventType.EqualsLiteral("popupshown")) {
HandlePopupShownEvent(accessible);
} else if (eventType.EqualsLiteral("DOMMenuInactive")) {
}
else if (eventType.EqualsLiteral("DOMMenuInactive")) {
if (accessible->Role() == roles::MENUPOPUP) {
nsEventShell::FireEvent(nsIAccessibleEvent::EVENT_MENUPOPUP_END,
accessible);
}
} else if (eventType.EqualsLiteral("DOMMenuItemActive")) {
}
else if (eventType.EqualsLiteral("DOMMenuItemActive")) {
FocusMgr()->ActiveItemChanged(accessible);
#ifdef A11Y_LOG
if (logging::IsEnabled(logging::eFocus))
logging::ActiveItemChangeCausedBy("DOMMenuItemActive", accessible);
#endif
} else if (eventType.EqualsLiteral("DOMMenuItemInactive")) {
}
else if (eventType.EqualsLiteral("DOMMenuItemInactive")) {
// Process DOMMenuItemInactive event for autocomplete only because this is
// unique widget that may acquire focus from autocomplete popup while popup
// stays open and has no active item. In case of XUL tree autocomplete
@@ -403,7 +421,8 @@ RootAccessible::ProcessDOMEvent(nsIDOMEvent* aDOMEvent)
logging::ActiveItemChangeCausedBy("DOMMenuItemInactive", accessible);
#endif
}
} else if (eventType.EqualsLiteral("DOMMenuBarActive")) { // Always from user input
}
else if (eventType.EqualsLiteral("DOMMenuBarActive")) { // Always from user input
nsEventShell::FireEvent(nsIAccessibleEvent::EVENT_MENU_START,
accessible, eFromUserInput);
@@ -421,7 +440,8 @@ RootAccessible::ProcessDOMEvent(nsIDOMEvent* aDOMEvent)
logging::ActiveItemChangeCausedBy("DOMMenuBarActive", accessible);
#endif
}
} else if (eventType.EqualsLiteral("DOMMenuBarInactive")) { // Always from user input
}
else if (eventType.EqualsLiteral("DOMMenuBarInactive")) { // Always from user input
nsEventShell::FireEvent(nsIAccessibleEvent::EVENT_MENU_END,
accessible, eFromUserInput);
@@ -430,7 +450,8 @@ RootAccessible::ProcessDOMEvent(nsIDOMEvent* aDOMEvent)
if (logging::IsEnabled(logging::eFocus))
logging::ActiveItemChangeCausedBy("DOMMenuBarInactive", accessible);
#endif
} else if (accessible->NeedsDOMUIEvent() &&
}
else if (accessible->NeedsDOMUIEvent() &&
eventType.EqualsLiteral("ValueChange")) {
uint32_t event = accessible->HasNumericValue()
? nsIAccessibleEvent::EVENT_VALUE_CHANGE
@@ -629,6 +650,7 @@ RootAccessible::HandlePopupHidingEvent(nsINode* aPopupNode)
}
}
#ifdef MOZ_XUL
void
RootAccessible::HandleTreeRowCountChangedEvent(nsIDOMEvent* aEvent,
XULTreeAccessible* aAccessible)
@@ -692,6 +714,7 @@ RootAccessible::HandleTreeInvalidatedEvent(nsIDOMEvent* aEvent,
aAccessible->TreeViewInvalidated(startRow, endRow, startCol, endCol);
}
#endif
ProxyAccessible*
RootAccessible::GetPrimaryRemoteTopLevelContentDoc() const
+7 -5
View File
@@ -70,12 +70,14 @@ protected:
*/
void HandlePopupHidingEvent(nsINode* aNode);
void HandleTreeRowCountChangedEvent(nsIDOMEvent* aEvent,
XULTreeAccessible* aAccessible);
void HandleTreeInvalidatedEvent(nsIDOMEvent* aEvent,
XULTreeAccessible* aAccessible);
#ifdef MOZ_XUL
void HandleTreeRowCountChangedEvent(nsIDOMEvent* aEvent,
XULTreeAccessible* aAccessible);
void HandleTreeInvalidatedEvent(nsIDOMEvent* aEvent,
XULTreeAccessible* aAccessible);
uint32_t GetChromeFlags();
uint32_t GetChromeFlags();
#endif
};
inline RootAccessible*
+26 -5
View File
@@ -64,7 +64,9 @@ this.AccessFu = { // jshint ignore:line
if (this._enabled) {
this._disable();
}
if (Utils.win.navigator.mozSettings) {
if (Utils.MozBuildApp === 'mobile/android') {
Services.obs.removeObserver(this, 'Accessibility:Settings');
} else if (Utils.win.navigator.mozSettings) {
Utils.win.navigator.mozSettings.removeObserver(
SCREENREADER_SETTING, this.handleEvent);
}
@@ -583,7 +585,11 @@ var Output = {
get androidBridge() {
delete this.androidBridge;
this.androidBridge = null;
if (Utils.MozBuildApp === 'mobile/android') {
this.androidBridge = Services.androidBridge;
} else {
this.androidBridge = null;
}
return this.androidBridge;
},
@@ -809,6 +815,12 @@ var Input = {
target.blur();
}
}
if (Utils.MozBuildApp == 'mobile/android') {
// Return focus to native Android browser chrome.
Services.androidBridge.handleGeckoMessage(
{ type: 'ToggleChrome:Focus' });
}
break;
case aEvent.DOM_VK_RETURN:
if (this.editState.editing) {
@@ -825,9 +837,18 @@ var Input = {
},
moveToPoint: function moveToPoint(aRule, aX, aY) {
let win = Utils.win;
Utils.winUtils.sendMouseEvent('mousemove',
aX - win.mozInnerScreenX, aY - win.mozInnerScreenY, 0, 0, 0);
// XXX: Bug 1013408 - There is no alignment between the chrome window's
// viewport size and the content viewport size in Android. This makes
// sending mouse events beyond its bounds impossible.
if (Utils.MozBuildApp === 'mobile/android') {
let mm = Utils.getMessageManager(Utils.CurrentBrowser);
mm.sendAsyncMessage('AccessFu:MoveToPoint',
{rule: aRule, x: aX, y: aY, origin: 'top'});
} else {
let win = Utils.win;
Utils.winUtils.sendMouseEvent('mousemove',
aX - win.mozInnerScreenX, aY - win.mozInnerScreenY, 0, 0, 0);
}
},
moveCursor: function moveCursor(aAction, aRule, aInputType, aAdjustRange) {
+3 -1
View File
@@ -76,6 +76,8 @@ const EDGE = 0.1;
const TIMEOUT_MULTIPLIER = 1;
// A single pointer down/up sequence periodically precedes the tripple swipe
// gesture on Android. This delay acounts for that.
const IS_ANDROID = Utils.MozBuildApp === 'mobile/android' &&
Utils.AndroidSdkVersion >= 14;
/**
* A point object containing distance travelled data.
@@ -204,7 +206,7 @@ this.GestureTracker = { // jshint ignore:line
if (aDetail.type !== 'pointerdown') {
return;
}
let GestureConstructor = aGesture || Tap;
let GestureConstructor = aGesture || (IS_ANDROID ? DoubleTap : Tap);
this._create(GestureConstructor);
this._update(aDetail, aTimeStamp);
},
+1 -1
View File
@@ -786,7 +786,7 @@ this.UtteranceGenerator = { // jshint ignore:line
// This is because we expose the checked information on the node itself.
// XXX: this means the checked state is always appended to the end,
// regardless of the utterance ordering preference.
if (Utils.MozBuildApp === 'browser' &&
if ((Utils.AndroidSdkVersion < 16 || Utils.MozBuildApp === 'browser') &&
aState.contains(States.CHECKABLE)) {
let checked = aState.contains(States.CHECKED);
let statetr;
+12
View File
@@ -39,6 +39,13 @@ var PointerRelay = { // jshint ignore:line
delete this._eventsOfInterest;
switch (Utils.widgetToolkit) {
case 'android':
this._eventsOfInterest = {
'touchstart' : true,
'touchmove' : true,
'touchend' : true };
break;
default:
// Desktop.
this._eventsOfInterest = {
@@ -103,6 +110,11 @@ var PointerRelay = { // jshint ignore:line
target: aEvent.target
}];
if (Utils.widgetToolkit === 'android' &&
changedTouches.length === 1 && changedTouches[0].identifier === 1) {
return;
}
if (changedTouches.length === 1 &&
changedTouches[0].identifier === SYNTH_ID) {
return;
+30 -17
View File
@@ -257,8 +257,11 @@ AndroidPresenter.prototype.pivotChanged =
let androidEvents = [];
let isExploreByTouch = (aReason == Ci.nsIAccessiblePivot.REASON_POINT);
let focusEventType = this.ANDROID_VIEW_ACCESSIBILITY_FOCUSED;
let isExploreByTouch = (aReason == Ci.nsIAccessiblePivot.REASON_POINT &&
Utils.AndroidSdkVersion >= 14);
let focusEventType = (Utils.AndroidSdkVersion >= 16) ?
this.ANDROID_VIEW_ACCESSIBILITY_FOCUSED :
this.ANDROID_VIEW_FOCUSED;
if (isExploreByTouch) {
// This isn't really used by TalkBack so this is a half-hearted attempt
@@ -267,21 +270,25 @@ AndroidPresenter.prototype.pivotChanged =
}
let brailleOutput = {};
if (!this._braillePresenter) {
this._braillePresenter = new BraillePresenter();
if (Utils.AndroidSdkVersion >= 16) {
if (!this._braillePresenter) {
this._braillePresenter = new BraillePresenter();
}
brailleOutput = this._braillePresenter.pivotChanged(aContext, aReason).
details;
}
brailleOutput = this._braillePresenter.pivotChanged(aContext, aReason).
details;
if (aReason === Ci.nsIAccessiblePivot.REASON_TEXT) {
let adjustedText = aContext.textAndAdjustedOffsets;
if (Utils.AndroidSdkVersion >= 16) {
let adjustedText = aContext.textAndAdjustedOffsets;
androidEvents.push({
eventType: this.ANDROID_VIEW_TEXT_TRAVERSED_AT_MOVEMENT_GRANULARITY,
text: [adjustedText.text],
fromIndex: adjustedText.startOffset,
toIndex: adjustedText.endOffset
});
androidEvents.push({
eventType: this.ANDROID_VIEW_TEXT_TRAVERSED_AT_MOVEMENT_GRANULARITY,
text: [adjustedText.text],
fromIndex: adjustedText.startOffset,
toIndex: adjustedText.endOffset
});
}
} else {
let state = Utils.getState(aContext.accessible);
androidEvents.push({eventType: (isExploreByTouch) ?
@@ -364,7 +371,7 @@ AndroidPresenter.prototype.textSelectionChanged =
aOldEnd, aIsFromUserInput) {
let androidEvents = [];
if (!aIsFromUserInput) {
if (Utils.AndroidSdkVersion >= 14 && !aIsFromUserInput) {
if (!this._braillePresenter) {
this._braillePresenter = new BraillePresenter();
}
@@ -381,7 +388,7 @@ AndroidPresenter.prototype.textSelectionChanged =
});
}
if (aIsFromUserInput) {
if (Utils.AndroidSdkVersion >= 16 && aIsFromUserInput) {
let [from, to] = aOldStart < aStart ?
[aOldStart, aStart] : [aStart, aOldStart];
androidEvents.push({
@@ -400,6 +407,10 @@ AndroidPresenter.prototype.textSelectionChanged =
AndroidPresenter.prototype.viewportChanged =
function AndroidPresenter_viewportChanged(aWindow, aCurrentContext) {
if (Utils.AndroidSdkVersion < 14) {
return null;
}
let events = [{
eventType: this.ANDROID_VIEW_SCROLLED,
text: [],
@@ -409,7 +420,7 @@ AndroidPresenter.prototype.viewportChanged =
maxScrollY: aWindow.scrollMaxY
}];
if (aCurrentContext) {
if (Utils.AndroidSdkVersion >= 16 && aCurrentContext) {
let currentAcc = aCurrentContext.accessibleForBounds;
if (Utils.isAliveAndVisible(currentAcc)) {
events.push({
@@ -436,7 +447,8 @@ AndroidPresenter.prototype.announce =
return {
type: this.type,
details: [{
eventType: this.ANDROID_ANNOUNCEMENT,
eventType: (Utils.AndroidSdkVersion >= 16) ?
this.ANDROID_ANNOUNCEMENT : this.ANDROID_VIEW_TEXT_CHANGED,
text: [localizedAnnouncement],
addedCount: localizedAnnouncement.length,
removedCount: 0,
@@ -668,6 +680,7 @@ this.Presentation = { // jshint ignore:line
get presenters() {
delete this.presenters;
let presenterMap = {
'mobile/android': [VisualPresenter, AndroidPresenter],
'b2g': [VisualPresenter, B2GPresenter],
'browser': [VisualPresenter, B2GPresenter, AndroidPresenter]
};
+28 -1
View File
@@ -33,7 +33,9 @@ this.Utils = { // jshint ignore:line
_buildAppMap: {
'{3c2e2abc-06d4-11e1-ac3b-374f68613e61}': 'b2g',
'{d1bfe7d9-c01e-4237-998b-7b5f960a4314}': 'graphene',
'{ec8030f7-c20a-464f-9b0e-13a3a9e97384}': 'browser'
'{ec8030f7-c20a-464f-9b0e-13a3a9e97384}': 'browser',
'{aa3c5121-dab2-40e2-81ca-7ea25febc110}': 'mobile/android',
'{a23983c0-fd0e-11dc-95ff-0800200c9a66}': 'mobile/xul'
},
init: function Utils_init(aWindow) {
@@ -109,13 +111,35 @@ this.Utils = { // jshint ignore:line
return this._ScriptName;
},
get AndroidSdkVersion() {
if (!this._AndroidSdkVersion) {
if (Services.appinfo.OS == 'Android') {
this._AndroidSdkVersion = Services.sysinfo.getPropertyAsInt32(
'version');
} else {
// Most useful in desktop debugging.
this._AndroidSdkVersion = 16;
}
}
return this._AndroidSdkVersion;
},
set AndroidSdkVersion(value) {
// When we want to mimic another version.
this._AndroidSdkVersion = value;
},
get BrowserApp() {
if (!this.win) {
return null;
}
switch (this.MozBuildApp) {
case 'mobile/android':
return this.win.BrowserApp;
case 'browser':
return this.win.gBrowser;
case 'b2g':
return this.win.shell;
default:
return null;
}
@@ -125,6 +149,9 @@ this.Utils = { // jshint ignore:line
if (!this.BrowserApp) {
return null;
}
if (this.MozBuildApp == 'b2g') {
return this.BrowserApp.contentBrowser;
}
return this.BrowserApp.selectedBrowser;
},
+2
View File
@@ -1,4 +1,6 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:expandtab:shiftwidth=2:tabstop=2:
*/
/* 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/. */
@@ -1,4 +1,6 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* vim:expandtab:shiftwidth=4:tabstop=4:
*/
/* 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/. */
+2
View File
@@ -1,4 +1,6 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:expandtab:shiftwidth=2:tabstop=2:
*/
/* 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/. */
+2
View File
@@ -1,4 +1,6 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:expandtab:shiftwidth=2:tabstop=2:
*/
/* 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/. */
+2
View File
@@ -1,4 +1,6 @@
/* -*- Mode: Objective-C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:expandtab:shiftwidth=2:tabstop=2:
*/
/* 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/. */
+2
View File
@@ -1,4 +1,6 @@
/* -*- Mode: Objective-C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:expandtab:shiftwidth=2:tabstop=2:
*/
/* 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/. */
+2
View File
@@ -1,4 +1,6 @@
/* -*- Mode: Objective-C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:expandtab:shiftwidth=2:tabstop=2:
*/
/* 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/. */
+2
View File
@@ -1,4 +1,6 @@
/* -*- Mode: Objective-C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:expandtab:shiftwidth=2:tabstop=2:
*/
/* 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/. */
+4 -2
View File
@@ -21,10 +21,12 @@ DIRS += [ 'aom',
'interfaces',
'ipc',
'jsat',
'xpcom',
'xul'
'xpcom'
]
if CONFIG['MOZ_XUL']:
DIRS += ['xul']
TEST_DIRS += ['tests/mochitest']
BROWSER_CHROME_MANIFESTS += [
@@ -1,4 +1,6 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:expandtab:shiftwidth=2:tabstop=2:
*/
/* 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/. */
@@ -1,4 +1,6 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* vim:expandtab:shiftwidth=4:tabstop=4:
*/
/* 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/. */
@@ -1,4 +1,6 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:expandtab:shiftwidth=2:tabstop=2:
*/
/* 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/. */
+2
View File
@@ -1,4 +1,6 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:expandtab:shiftwidth=2:tabstop=2:
*/
/* 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/. */
@@ -67,7 +67,7 @@
* Change scrollbar styles from hidden to auto. That makes us to create an
* accessible for scroll area.
*/
function changeScrollStyles(aContainerID, aScrollAreaID)
function changeScrollbarStyles(aContainerID, aScrollAreaID)
{
this.container = getAccessible(aContainerID);
this.scrollAreaNode = getNode(aScrollAreaID);
@@ -77,7 +77,7 @@
new invokerChecker(EVENT_REORDER, this.container)
];
this.invoke = function changeScrollStyles_invoke()
this.invoke = function changeScrollbarStyles_invoke()
{
var accTree =
{ SECTION: [] };
@@ -86,7 +86,7 @@
this.scrollAreaNode.style.overflow = "auto";
}
this.finalCheck = function changeScrollStyles_finalCheck()
this.finalCheck = function changeScrollbarStyles_finalCheck()
{
var accTree =
{ SECTION: [ // container
@@ -95,7 +95,7 @@
testAccessibleTree(this.container, accTree);
}
this.getID = function changeScrollStyles_getID()
this.getID = function changeScrollbarStyles_getID()
{
return "change scrollbar styles " + prettyName(aScrollAreaID);
}
@@ -114,7 +114,7 @@
gQueue = new eventQueue();
gQueue.push(new changeScrollRange("container", "scrollarea"));
gQueue.push(new changeScrollStyles("container2", "scrollarea2"));
gQueue.push(new changeScrollbarStyles("container2", "scrollarea2"));
gQueue.invoke(); // Will call SimpleTest.finish();
}
@@ -1,4 +1,6 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:expandtab:shiftwidth=2:tabstop=2:
*/
/* 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/. */
@@ -1,4 +1,6 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:expandtab:shiftwidth=2:tabstop=2:
*/
/* 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/. */
@@ -1,4 +1,6 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:expandtab:shiftwidth=2:tabstop=2:
*/
/* 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/. */
@@ -1,4 +1,6 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:expandtab:shiftwidth=2:tabstop=2:
*/
/* 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/. */
@@ -1,4 +1,6 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:expandtab:shiftwidth=2:tabstop=2:
*/
/* 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/. */
@@ -1,4 +1,6 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:expandtab:shiftwidth=2:tabstop=2:
*/
/* 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/. */
@@ -1,4 +1,6 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:expandtab:shiftwidth=2:tabstop=2:
*/
/* 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/. */
@@ -1,4 +1,6 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:expandtab:shiftwidth=2:tabstop=2:
*/
/* 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/. */
@@ -1,4 +1,6 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:expandtab:shiftwidth=2:tabstop=2:
*/
/* 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/. */
@@ -1,4 +1,6 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:expandtab:shiftwidth=2:tabstop=2:
*/
/* 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/. */
@@ -1,4 +1,6 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:expandtab:shiftwidth=2:tabstop=2:
*/
/* 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/. */
@@ -1,4 +1,6 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:expandtab:shiftwidth=2:tabstop=2:
*/
/* 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/. */
@@ -1,4 +1,6 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:expandtab:shiftwidth=2:tabstop=2:
*/
/* 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/. */
@@ -1,4 +1,6 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:expandtab:shiftwidth=2:tabstop=2:
*/
/* 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/. */
@@ -1,4 +1,6 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:expandtab:shiftwidth=2:tabstop=2:
*/
/* 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/. */
@@ -1,4 +1,6 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:expandtab:shiftwidth=2:tabstop=2:
*/
/* 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/. */
@@ -1,4 +1,6 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:expandtab:shiftwidth=2:tabstop=2:
*/
/* 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/. */
@@ -1,4 +1,6 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:expandtab:shiftwidth=2:tabstop=2:
*/
/* 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/. */
@@ -1,4 +1,6 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:expandtab:shiftwidth=2:tabstop=2:
*/
/* 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/. */
@@ -1,4 +1,6 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:expandtab:shiftwidth=2:tabstop=2:
*/
/* 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/. */
@@ -1,4 +1,6 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:expandtab:shiftwidth=2:tabstop=2:
*/
/* 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/. */
@@ -1,4 +1,6 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:expandtab:shiftwidth=2:tabstop=2:
*/
/* 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/. */
@@ -1,4 +1,6 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:expandtab:shiftwidth=2:tabstop=2:
*/
/* 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/. */
@@ -1,4 +1,6 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:expandtab:shiftwidth=2:tabstop=2:
*/
/* 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/. */
@@ -1,4 +1,6 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* vim:expandtab:shiftwidth=4:tabstop=4:
*/
/* 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/. */
@@ -1,4 +1,6 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* vim:expandtab:shiftwidth=4:tabstop=4:
*/
/* 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/. */
@@ -1,4 +1,6 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:expandtab:shiftwidth=2:tabstop=2:
*/
/* 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/. */
@@ -1,4 +1,6 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:expandtab:shiftwidth=2:tabstop=2:
*/
/* 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/. */
@@ -1,4 +1,6 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:expandtab:shiftwidth=2:tabstop=2:
*/
/* 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/. */
@@ -1,4 +1,6 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:expandtab:shiftwidth=2:tabstop=2:
*/
/* 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/. */
@@ -1,4 +1,6 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:expandtab:shiftwidth=2:tabstop=2:
*/
/* 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/. */
@@ -1,4 +1,6 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:expandtab:shiftwidth=2:tabstop=2:
*/
/* 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/. */
+13
View File
@@ -35,6 +35,19 @@ a11y::PlatformInit()
nsWinUtils::MaybeStartWindowEmulation();
ia2AccessibleText::InitTextChangeData();
if (BrowserTabsRemoteAutostart()) {
mscom::InterceptorLog::Init();
UniquePtr<RegisteredProxy> regProxy(
mscom::RegisterProxy(L"ia2marshal.dll"));
gRegProxy = regProxy.release();
UniquePtr<RegisteredProxy> regAccTlb(
mscom::RegisterTypelib(L"oleacc.dll",
RegistrationFlags::eUseSystemDirectory));
gRegAccTlb = regAccTlb.release();
UniquePtr<RegisteredProxy> regMiscTlb(
mscom::RegisterTypelib(L"Accessible.tlb"));
gRegMiscTlb = regMiscTlb.release();
}
}
void
+7 -3
View File
@@ -33,11 +33,15 @@ SOURCES += [
'RootAccessibleWrap.cpp',
'ServiceProvider.cpp',
'TextLeafAccessibleWrap.cpp',
'XULListboxAccessibleWrap.cpp',
'XULMenuAccessibleWrap.cpp',
'XULTreeGridAccessibleWrap.cpp',
]
if CONFIG['MOZ_XUL']:
SOURCES += [
'XULListboxAccessibleWrap.cpp',
'XULMenuAccessibleWrap.cpp',
'XULTreeGridAccessibleWrap.cpp',
]
LOCAL_INCLUDES += [
'/accessible/base',
'/accessible/generic',
+2
View File
@@ -1,4 +1,6 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* vim:expandtab:shiftwidth=4:tabstop=4:
*/
/* 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/. */
+2
View File
@@ -1,4 +1,6 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:expandtab:shiftwidth=2:tabstop=2:
*/
/* 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/. */
+2
View File
@@ -1,4 +1,6 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:expandtab:shiftwidth=2:tabstop=2:
*/
/* 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/. */
Vendored
+2
View File
@@ -21,10 +21,12 @@ builtin(include, build/autoconf/frameptr.m4)dnl
builtin(include, build/autoconf/compiler-opts.m4)dnl
builtin(include, build/autoconf/expandlibs.m4)dnl
builtin(include, build/autoconf/arch.m4)dnl
builtin(include, build/autoconf/android.m4)dnl
builtin(include, build/autoconf/zlib.m4)dnl
builtin(include, build/autoconf/icu.m4)dnl
builtin(include, build/autoconf/clang-plugin.m4)dnl
builtin(include, build/autoconf/alloc.m4)dnl
builtin(include, build/autoconf/ios.m4)dnl
builtin(include, build/autoconf/sanitize.m4)dnl
MOZ_PROG_CHECKMSYS()
+129
View File
@@ -0,0 +1,129 @@
import java.util.regex.Pattern
allprojects {
// Expose the per-object-directory configuration to all projects.
ext {
mozconfig = gradle.mozconfig
topsrcdir = gradle.mozconfig.topsrcdir
topobjdir = gradle.mozconfig.topobjdir
}
repositories {
if (gradle.mozconfig.substs.GRADLE_MAVEN_REPOSITORY) {
maven {
url gradle.mozconfig.substs.GRADLE_MAVEN_REPOSITORY
}
}
}
}
buildDir "${topobjdir}/gradle/build"
buildscript {
repositories {
if (gradle.mozconfig.substs.GRADLE_MAVEN_REPOSITORY) {
maven {
url gradle.mozconfig.substs.GRADLE_MAVEN_REPOSITORY
}
}
// For android-sdk-manager SNAPSHOT releases.
maven {
url "file://${gradle.mozconfig.topsrcdir}/mobile/android/gradle/m2repo"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.3'
classpath('com.stanfy.spoon:spoon-gradle-plugin:1.0.4') {
// Without these, we get errors linting.
exclude module: 'guava'
}
// Provided in tree.
classpath 'com.jakewharton.sdkmanager:gradle-plugin:1.5.0-SNAPSHOT'
}
}
task generateCodeAndResources(type:Exec) {
workingDir "${topobjdir}"
commandLine mozconfig.substs.GMAKE
args '-C'
args "${topobjdir}/mobile/android/base"
args 'gradle-targets'
// Only show the output if something went wrong.
ignoreExitValue = true
standardOutput = new ByteArrayOutputStream()
errorOutput = standardOutput
doLast {
if (execResult.exitValue != 0) {
throw new GradleException("Process '${commandLine}' finished with non-zero exit value ${execResult.exitValue}:\n\n${standardOutput.toString()}")
}
}
}
// Skip unit test for all build variants, unless if it was specifically requested by user.
// The enabled property for the unit test tasks is reset based on the command line task names just before the task execution.
// I bet there is a easier/cleaner way to do this, but this gets the job done for now.
Pattern pattern = Pattern.compile('.*test(.+UnitTest)?.*')
boolean startTasksIncludeTest = gradle.startParameter.taskNames.any {
taskName ->
taskName.matches(pattern)
}
gradle.taskGraph.beforeTask {
Task task ->
if (task.name.matches(pattern)) {
task.enabled = startTasksIncludeTest
}
}
afterEvaluate {
subprojects {
if (!hasProperty('android')) {
return
}
android.applicationVariants.all {
preBuild.dependsOn rootProject.generateCodeAndResources
}
android.libraryVariants.all {
preBuild.dependsOn rootProject.generateCodeAndResources
}
}
}
apply plugin: 'idea'
idea {
project {
languageLevel = '1.7'
}
module {
// Object directories take a huge amount of time for IntelliJ to index.
// Exclude them. Convention is that object directories start with obj.
// IntelliJ is clever and will not exclude the parts of the object
// directory that are referenced, if there are any. In practice,
// indexing the entirety of the tree is taking too long, so exclude all
// but mobile/.
def topsrcdirURI = file(topsrcdir).toURI()
excludeDirs += files(file(topsrcdir)
.listFiles({it.isDirectory()} as FileFilter)
.collect({topsrcdirURI.relativize(it.toURI()).toString()}) // Relative paths.
.findAll({!it.equals('mobile/')}))
// If topobjdir is below topsrcdir, hide only some portions of that tree.
def topobjdirURI = file(topobjdir).toURI()
if (!topsrcdirURI.relativize(topobjdirURI).isAbsolute()) {
excludeDirs -= file(topobjdir)
excludeDirs += files(file(topobjdir).listFiles())
excludeDirs -= file("${topobjdir}/gradle")
}
if (!mozconfig.substs.MOZ_INSTALL_TRACKING) {
excludeDirs += file("${topsrcdir}/mobile/android/thirdparty/com/adjust")
}
}
}
task wrapper(type: Wrapper) {
}
@@ -0,0 +1,54 @@
/* 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/. */
package org.mozilla.gecko.annotationProcessors;
/**
* Object holding annotation data. Used by GeneratableElementIterator.
*/
public class AnnotationInfo {
public enum ExceptionMode {
ABORT,
NSRESULT,
IGNORE;
String nativeValue() {
return "mozilla::jni::ExceptionMode::" + name();
}
}
public enum CallingThread {
GECKO,
UI,
ANY;
String nativeValue() {
return "mozilla::jni::CallingThread::" + name();
}
}
public enum DispatchTarget {
GECKO,
PROXY,
CURRENT;
String nativeValue() {
return "mozilla::jni::DispatchTarget::" + name();
}
}
public final String wrapperName;
public final ExceptionMode exceptionMode;
public final CallingThread callingThread;
public final DispatchTarget dispatchTarget;
public AnnotationInfo(String wrapperName, ExceptionMode exceptionMode,
CallingThread callingThread, DispatchTarget dispatchTarget) {
this.wrapperName = wrapperName;
this.exceptionMode = exceptionMode;
this.callingThread = callingThread;
this.dispatchTarget = dispatchTarget;
}
}
@@ -0,0 +1,175 @@
/* 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/. */
package org.mozilla.gecko.annotationProcessors;
import org.mozilla.gecko.annotationProcessors.classloader.AnnotatableEntity;
import org.mozilla.gecko.annotationProcessors.classloader.ClassWithOptions;
import org.mozilla.gecko.annotationProcessors.classloader.IterableJarLoadingURLClassLoader;
import org.mozilla.gecko.annotationProcessors.utils.GeneratableElementIterator;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Arrays;
import java.util.Iterator;
public class AnnotationProcessor {
public static final String GENERATED_COMMENT =
"// GENERATED CODE\n" +
"// Generated by the Java program at /build/annotationProcessors at compile time\n" +
"// from annotations on Java methods. To update, change the annotations on the\n" +
"// corresponding Java methods and rerun the build. Manually updating this file\n" +
"// will cause your build to fail.\n" +
"\n";
private static final StringBuilder headerFile = new StringBuilder(GENERATED_COMMENT);
private static final StringBuilder implementationFile = new StringBuilder(GENERATED_COMMENT);
private static final StringBuilder nativesFile = new StringBuilder(GENERATED_COMMENT);
public static void main(String[] args) {
// We expect a list of jars on the commandline. If missing, whinge about it.
if (args.length <= 2) {
System.err.println("Usage: java AnnotationProcessor outprefix jarfiles ...");
System.exit(1);
}
final String OUTPUT_PREFIX = args[0];
final String SOURCE_FILE = OUTPUT_PREFIX + "JNIWrappers.cpp";
final String HEADER_FILE = OUTPUT_PREFIX + "JNIWrappers.h";
final String NATIVES_FILE = OUTPUT_PREFIX + "JNINatives.h";
System.out.println("Processing annotations...");
// We want to produce the same output as last time as often as possible. Ordering of
// generated statements, therefore, needs to be consistent.
final String[] jars = Arrays.copyOfRange(args, 1, args.length);
Arrays.sort(jars);
// Start the clock!
long s = System.currentTimeMillis();
// Get an iterator over the classes in the jar files given...
Iterator<ClassWithOptions> jarClassIterator = IterableJarLoadingURLClassLoader.getIteratorOverJars(jars);
headerFile.append(
"#ifndef " + getHeaderGuardName(HEADER_FILE) + "\n" +
"#define " + getHeaderGuardName(HEADER_FILE) + "\n" +
"\n" +
"#include \"mozilla/jni/Refs.h\"\n" +
"\n" +
"namespace mozilla {\n" +
"namespace java {\n" +
"\n");
implementationFile.append(
"#include \"" + HEADER_FILE + "\"\n" +
"#include \"mozilla/jni/Accessors.h\"\n" +
"\n" +
"namespace mozilla {\n" +
"namespace java {\n" +
"\n");
nativesFile.append(
"#ifndef " + getHeaderGuardName(NATIVES_FILE) + "\n" +
"#define " + getHeaderGuardName(NATIVES_FILE) + "\n" +
"\n" +
"#include \"" + HEADER_FILE + "\"\n" +
"#include \"mozilla/jni/Natives.h\"\n" +
"\n" +
"namespace mozilla {\n" +
"namespace java {\n" +
"\n");
while (jarClassIterator.hasNext()) {
generateClass(jarClassIterator.next());
}
implementationFile.append(
"} /* java */\n" +
"} /* mozilla */\n");
headerFile.append(
"} /* java */\n" +
"} /* mozilla */\n" +
"#endif // " + getHeaderGuardName(HEADER_FILE) + "\n");
nativesFile.append(
"} /* java */\n" +
"} /* mozilla */\n" +
"#endif // " + getHeaderGuardName(NATIVES_FILE) + "\n");
writeOutputFile(SOURCE_FILE, implementationFile);
writeOutputFile(HEADER_FILE, headerFile);
writeOutputFile(NATIVES_FILE, nativesFile);
long e = System.currentTimeMillis();
System.out.println("Annotation processing complete in " + (e - s) + "ms");
}
private static void generateClass(final ClassWithOptions annotatedClass) {
// Get an iterator over the appropriately generated methods of this class
final GeneratableElementIterator methodIterator
= new GeneratableElementIterator(annotatedClass);
final ClassWithOptions[] innerClasses = methodIterator.getInnerClasses();
if (!methodIterator.hasNext() && innerClasses.length == 0) {
return;
}
final CodeGenerator generatorInstance = new CodeGenerator(annotatedClass);
generatorInstance.generateClasses(innerClasses);
// Iterate all annotated members in this class..
while (methodIterator.hasNext()) {
AnnotatableEntity aElementTuple = methodIterator.next();
switch (aElementTuple.mEntityType) {
case METHOD:
generatorInstance.generateMethod(aElementTuple);
break;
case NATIVE:
generatorInstance.generateNative(aElementTuple);
break;
case FIELD:
generatorInstance.generateField(aElementTuple);
break;
case CONSTRUCTOR:
generatorInstance.generateConstructor(aElementTuple);
break;
}
}
headerFile.append(generatorInstance.getHeaderFileContents());
implementationFile.append(generatorInstance.getWrapperFileContents());
nativesFile.append(generatorInstance.getNativesFileContents());
for (ClassWithOptions innerClass : innerClasses) {
generateClass(innerClass);
}
}
private static String getHeaderGuardName(final String name) {
return name.replaceAll("\\W", "_");
}
private static void writeOutputFile(final String name,
final StringBuilder content) {
FileOutputStream outStream = null;
try {
outStream = new FileOutputStream(name);
outStream.write(content.toString().getBytes());
} catch (IOException e) {
System.err.println("Unable to write " + name + ". Perhaps a permissions issue?");
e.printStackTrace(System.err);
} finally {
if (outStream != null) {
try {
outStream.close();
} catch (IOException e) {
System.err.println("Unable to close outStream due to "+e);
e.printStackTrace(System.err);
}
}
}
}
}
@@ -0,0 +1,627 @@
/* 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/. */
package org.mozilla.gecko.annotationProcessors;
import org.mozilla.gecko.annotationProcessors.classloader.AnnotatableEntity;
import org.mozilla.gecko.annotationProcessors.classloader.ClassWithOptions;
import org.mozilla.gecko.annotationProcessors.utils.Utils;
import java.lang.annotation.Annotation;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Member;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.HashSet;
public class CodeGenerator {
private static final Class<?>[] EMPTY_CLASS_ARRAY = new Class<?>[0];
// Buffers holding the strings to ultimately be written to the output files.
private final StringBuilder cpp = new StringBuilder();
private final StringBuilder header = new StringBuilder();
private final StringBuilder natives = new StringBuilder();
private final StringBuilder nativesInits = new StringBuilder();
private final Class<?> cls;
private final String clsName;
private AnnotationInfo.CallingThread callingThread = null;
private int numNativesInits;
private final HashSet<String> takenMethodNames = new HashSet<String>();
public CodeGenerator(ClassWithOptions annotatedClass) {
this.cls = annotatedClass.wrappedClass;
this.clsName = annotatedClass.generatedName;
final String unqualifiedName = Utils.getUnqualifiedName(clsName);
header.append(
"class " + clsName + " : public mozilla::jni::ObjectBase<" +
unqualifiedName + ">\n" +
"{\n" +
"public:\n" +
" static const char name[];\n" +
"\n" +
" explicit " + unqualifiedName + "(const Context& ctx) : ObjectBase<" +
unqualifiedName + ">(ctx) {}\n" +
"\n");
cpp.append(
"const char " + clsName + "::name[] =\n" +
" \"" + cls.getName().replace('.', '/') + "\";\n" +
"\n");
natives.append(
"template<class Impl>\n" +
"class " + clsName + "::Natives : " +
"public mozilla::jni::NativeImpl<" + unqualifiedName + ", Impl>\n" +
"{\n" +
"public:\n");
}
private String getTraitsName(String uniqueName, boolean includeScope) {
return (includeScope ? clsName + "::" : "") + uniqueName + "_t";
}
/**
* Return the C++ type name for this class or any class within the chain
* of declaring classes, if the target class matches the given type.
*
* Return null if the given type does not match any class searched.
*/
private String getMatchingClassType(final Class<?> type) {
Class<?> cls = this.cls;
String clsName = this.clsName;
while (cls != null) {
if (type.equals(cls)) {
return clsName;
}
cls = cls.getDeclaringClass();
clsName = clsName.substring(0, Math.max(0, clsName.lastIndexOf("::")));
}
return null;
}
private String getNativeParameterType(Class<?> type, AnnotationInfo info) {
final String clsName = getMatchingClassType(type);
if (clsName != null) {
return Utils.getUnqualifiedName(clsName) + "::Param";
}
return Utils.getNativeParameterType(type, info);
}
private String getNativeReturnType(Class<?> type, AnnotationInfo info) {
final String clsName = getMatchingClassType(type);
if (clsName != null) {
return Utils.getUnqualifiedName(clsName) + "::LocalRef";
}
return Utils.getNativeReturnType(type, info);
}
private void generateMember(AnnotationInfo info, Member member,
String uniqueName, Class<?> type, Class<?>[] argTypes) {
final StringBuilder args = new StringBuilder();
for (Class<?> argType : argTypes) {
args.append("\n " + getNativeParameterType(argType, info) + ",");
}
if (args.length() > 0) {
args.setLength(args.length() - 1);
}
header.append(
" struct " + getTraitsName(uniqueName, /* includeScope */ false) + " {\n" +
" typedef " + Utils.getUnqualifiedName(clsName) + " Owner;\n" +
" typedef " + getNativeReturnType(type, info) + " ReturnType;\n" +
" typedef " + getNativeParameterType(type, info) + " SetterType;\n" +
" typedef mozilla::jni::Args<" + args + "> Args;\n" +
" static constexpr char name[] = \"" +
Utils.getMemberName(member) + "\";\n" +
" static constexpr char signature[] =\n" +
" \"" + Utils.getSignature(member) + "\";\n" +
" static const bool isStatic = " + Utils.isStatic(member) + ";\n" +
" static const mozilla::jni::ExceptionMode exceptionMode =\n" +
" " + info.exceptionMode.nativeValue() + ";\n" +
" static const mozilla::jni::CallingThread callingThread =\n" +
" " + info.callingThread.nativeValue() + ";\n" +
" static const mozilla::jni::DispatchTarget dispatchTarget =\n" +
" " + info.dispatchTarget.nativeValue() + ";\n" +
" };\n" +
"\n");
cpp.append(
"constexpr char " + getTraitsName(uniqueName, /* includeScope */ true) +
"::name[];\n" +
"constexpr char " + getTraitsName(uniqueName, /* includeScope */ true) +
"::signature[];\n" +
"\n");
if (this.callingThread == null) {
this.callingThread = info.callingThread;
} else if (this.callingThread != info.callingThread) {
// We have a mix of calling threads, so specify "any" for the whole class.
this.callingThread = AnnotationInfo.CallingThread.ANY;
}
}
private String getUniqueMethodName(String basename) {
String newName = basename;
int index = 1;
while (takenMethodNames.contains(newName)) {
newName = basename + (++index);
}
takenMethodNames.add(newName);
return newName;
}
/**
* Generate a method prototype that includes return and argument types,
* without specifiers (static, const, etc.).
*/
private String generatePrototype(String name, Class<?>[] argTypes,
Class<?> returnType, AnnotationInfo info,
boolean includeScope, boolean includeArgName,
boolean isConst) {
final StringBuilder proto = new StringBuilder();
int argIndex = 0;
proto.append("auto ");
if (includeScope) {
proto.append(clsName).append("::");
}
proto.append(name).append('(');
for (Class<?> argType : argTypes) {
proto.append(getNativeParameterType(argType, info));
if (includeArgName) {
proto.append(" a").append(argIndex++);
}
proto.append(", ");
}
if (info.exceptionMode == AnnotationInfo.ExceptionMode.NSRESULT &&
!returnType.equals(void.class)) {
proto.append(getNativeReturnType(returnType, info)).append('*');
if (includeArgName) {
proto.append(" a").append(argIndex++);
}
proto.append(", ");
}
if (proto.substring(proto.length() - 2).equals(", ")) {
proto.setLength(proto.length() - 2);
}
proto.append(')');
if (isConst) {
proto.append(" const");
}
if (info.exceptionMode == AnnotationInfo.ExceptionMode.NSRESULT) {
proto.append(" -> nsresult");
} else {
proto.append(" -> ").append(getNativeReturnType(returnType, info));
}
return proto.toString();
}
/**
* Generate a method declaration that includes the prototype with specifiers,
* but without the method body.
*/
private String generateDeclaration(String name, Class<?>[] argTypes,
Class<?> returnType, AnnotationInfo info,
boolean isStatic) {
return (isStatic ? "static " : "") +
generatePrototype(name, argTypes, returnType, info,
/* includeScope */ false, /* includeArgName */ false,
/* isConst */ !isStatic) + ';';
}
/**
* Generate a method definition that includes the prototype with specifiers,
* and with the method body.
*/
private String generateDefinition(String accessorName, String name, Class<?>[] argTypes,
Class<?> returnType, AnnotationInfo info, boolean isStatic) {
final StringBuilder def = new StringBuilder(
generatePrototype(name, argTypes, returnType, info,
/* includeScope */ true, /* includeArgName */ true,
/* isConst */ !isStatic));
def.append("\n{\n");
// Generate code to handle the return value, if needed.
// We initialize rv to NS_OK instead of NS_ERROR_* because loading NS_OK (0) uses
// fewer instructions. We are guaranteed to set rv to the correct value later.
if (info.exceptionMode == AnnotationInfo.ExceptionMode.NSRESULT &&
returnType.equals(void.class)) {
def.append(
" nsresult rv = NS_OK;\n" +
" ");
} else if (info.exceptionMode == AnnotationInfo.ExceptionMode.NSRESULT) {
// Non-void return type
final String resultArg = "a" + argTypes.length;
def.append(
" MOZ_ASSERT(" + resultArg + ");\n" +
" nsresult rv = NS_OK;\n" +
" *" + resultArg + " = ");
} else {
def.append(
" return ");
}
// Generate a call, e.g., Method<Traits>::Call(a0, a1, a2);
def.append(accessorName).append("(")
.append(Utils.getUnqualifiedName(clsName) +
(isStatic ? "::Context()" : "::mCtx"));
if (info.exceptionMode == AnnotationInfo.ExceptionMode.NSRESULT) {
def.append(", &rv");
} else {
def.append(", nullptr");
}
// Generate the call argument list.
for (int argIndex = 0; argIndex < argTypes.length; argIndex++) {
def.append(", a").append(argIndex);
}
def.append(");\n");
if (info.exceptionMode == AnnotationInfo.ExceptionMode.NSRESULT) {
def.append(" return rv;\n");
}
return def.append("}").toString();
}
/**
* Append the appropriate generated code to the buffers for the method provided.
*
* @param annotatedMethod The Java method, plus annotation data.
*/
public void generateMethod(AnnotatableEntity annotatedMethod) {
// Unpack the tuple and extract some useful fields from the Method..
final Method method = annotatedMethod.getMethod();
final AnnotationInfo info = annotatedMethod.mAnnotationInfo;
final String uniqueName = getUniqueMethodName(info.wrapperName);
final Class<?>[] argTypes = method.getParameterTypes();
final Class<?> returnType = method.getReturnType();
if (method.isSynthetic()) {
return;
}
// Sanity check
if (info.dispatchTarget != AnnotationInfo.DispatchTarget.CURRENT) {
throw new IllegalStateException("Invalid dispatch target \"" +
info.dispatchTarget.name().toLowerCase() +
"\" for non-native method " + clsName + "::" + uniqueName);
}
generateMember(info, method, uniqueName, returnType, argTypes);
final boolean isStatic = Utils.isStatic(method);
header.append(
" " + generateDeclaration(info.wrapperName, argTypes,
returnType, info, isStatic) + "\n" +
"\n");
cpp.append(
generateDefinition(
"mozilla::jni::Method<" +
getTraitsName(uniqueName, /* includeScope */ false) + ">::Call",
info.wrapperName, argTypes, returnType, info, isStatic) + "\n" +
"\n");
}
/**
* Append the appropriate generated code to the buffers for the native method provided.
*
* @param annotatedMethod The Java native method, plus annotation data.
*/
public void generateNative(AnnotatableEntity annotatedMethod) {
// Unpack the tuple and extract some useful fields from the Method..
final Method method = annotatedMethod.getMethod();
final AnnotationInfo info = annotatedMethod.mAnnotationInfo;
final String uniqueName = getUniqueMethodName(info.wrapperName);
final Class<?>[] argTypes = method.getParameterTypes();
final Class<?> returnType = method.getReturnType();
// Sanity check
if (info.exceptionMode != AnnotationInfo.ExceptionMode.ABORT &&
info.exceptionMode != AnnotationInfo.ExceptionMode.IGNORE) {
throw new IllegalStateException("Invalid exception mode \"" +
info.exceptionMode.name().toLowerCase() +
"\" for native method " + clsName + "::" + uniqueName);
}
if (info.dispatchTarget != AnnotationInfo.DispatchTarget.CURRENT &&
returnType != void.class) {
throw new IllegalStateException(
"Must return void when not dispatching to current thread for native method " +
clsName + "::" + uniqueName);
}
generateMember(info, method, uniqueName, returnType, argTypes);
final String traits = getTraitsName(uniqueName, /* includeScope */ true);
if (nativesInits.length() > 0) {
nativesInits.append(',');
}
nativesInits.append(
"\n" +
"\n" +
" mozilla::jni::MakeNativeMethod<" + traits + ">(\n" +
" mozilla::jni::NativeStub<" + traits + ", Impl>\n" +
" ::template Wrap<&Impl::" + info.wrapperName + ">)");
numNativesInits++;
}
private String getLiteral(Object val, AnnotationInfo info) {
final Class<?> type = val.getClass();
if (type.equals(char.class) || type.equals(Character.class)) {
final char c = (char) val;
if (c >= 0x20 && c < 0x7F) {
return "'" + c + '\'';
}
return "u'\\u" + Integer.toHexString(0x10000 | (int) c).substring(1) + '\'';
} else if (type.equals(CharSequence.class) || type.equals(String.class)) {
final CharSequence str = (CharSequence) val;
final StringBuilder out = new StringBuilder("u\"");
for (int i = 0; i < str.length(); i++) {
final char c = str.charAt(i);
if (c >= 0x20 && c < 0x7F) {
out.append(c);
} else {
out.append("\\u").append(Integer.toHexString(0x10000 | (int) c).substring(1));
}
}
return out.append('"').toString();
}
return String.valueOf(val);
}
public void generateField(AnnotatableEntity annotatedField) {
final Field field = annotatedField.getField();
final AnnotationInfo info = annotatedField.mAnnotationInfo;
final String uniqueName = info.wrapperName;
final Class<?> type = field.getType();
// Handles a peculiar case when dealing with enum types. We don't care about this field.
// It just gets in the way and stops our code from compiling.
if (field.isSynthetic() || field.getName().equals("$VALUES")) {
return;
}
// Sanity check
if (info.dispatchTarget != AnnotationInfo.DispatchTarget.CURRENT) {
throw new IllegalStateException("Invalid dispatch target \"" +
info.dispatchTarget.name().toLowerCase() +
"\" for field " + clsName + "::" + uniqueName);
}
final boolean isStatic = Utils.isStatic(field);
final boolean isFinal = Utils.isFinal(field);
if (isStatic && isFinal && (type.isPrimitive() || type.equals(String.class))) {
Object val = null;
try {
field.setAccessible(true);
val = field.get(null);
} catch (final IllegalAccessException e) {
}
if (val != null && type.isPrimitive()) {
// For static final primitive fields, we can use a "static const" declaration.
header.append(
" static const " + Utils.getNativeReturnType(type, info) +
' ' + info.wrapperName + " = " + getLiteral(val, info) + ";\n" +
"\n");
return;
} else if (val != null && type.equals(String.class)) {
final String nativeType = "char16_t";
header.append(
" static const " + nativeType + ' ' + info.wrapperName + "[];\n" +
"\n");
cpp.append(
"const " + nativeType + ' ' + clsName + "::" + info.wrapperName +
"[] = " + getLiteral(val, info) + ";\n" +
"\n");
return;
}
// Fall back to using accessors if we encounter an exception.
}
generateMember(info, field, uniqueName, type, EMPTY_CLASS_ARRAY);
final Class<?>[] getterArgs = EMPTY_CLASS_ARRAY;
header.append(
" " + generateDeclaration(info.wrapperName, getterArgs,
type, info, isStatic) + "\n" +
"\n");
cpp.append(
generateDefinition(
"mozilla::jni::Field<" +
getTraitsName(uniqueName, /* includeScope */ false) + ">::Get",
info.wrapperName, getterArgs, type, info, isStatic) + "\n" +
"\n");
if (isFinal) {
return;
}
final Class<?>[] setterArgs = new Class<?>[] { type };
header.append(
" " + generateDeclaration(info.wrapperName, setterArgs,
void.class, info, isStatic) + "\n" +
"\n");
cpp.append(
generateDefinition(
"mozilla::jni::Field<" +
getTraitsName(uniqueName, /* includeScope */ false) + ">::Set",
info.wrapperName, setterArgs, void.class, info, isStatic) + "\n" +
"\n");
}
public void generateConstructor(AnnotatableEntity annotatedConstructor) {
// Unpack the tuple and extract some useful fields from the Method..
final Constructor<?> method = annotatedConstructor.getConstructor();
final AnnotationInfo info = annotatedConstructor.mAnnotationInfo;
final String wrapperName = "New";
final String uniqueName = getUniqueMethodName(wrapperName);
final Class<?>[] argTypes = method.getParameterTypes();
final Class<?> returnType = cls;
if (method.isSynthetic()) {
return;
}
// Sanity check
if (info.dispatchTarget != AnnotationInfo.DispatchTarget.CURRENT) {
throw new IllegalStateException("Invalid dispatch target \"" +
info.dispatchTarget.name().toLowerCase() +
"\" for constructor " + clsName + "::" + uniqueName);
}
generateMember(info, method, uniqueName, returnType, argTypes);
header.append(
" " + generateDeclaration(wrapperName, argTypes,
returnType, info, /* isStatic */ true) + "\n" +
"\n");
cpp.append(
generateDefinition(
"mozilla::jni::Constructor<" +
getTraitsName(uniqueName, /* includeScope */ false) + ">::Call",
wrapperName, argTypes, returnType, info, /* isStatic */ true) + "\n" +
"\n");
}
public void generateMembers(Member[] members) {
for (Member m : members) {
if (!Modifier.isPublic(m.getModifiers())) {
continue;
}
String name = Utils.getMemberName(m);
name = name.substring(0, 1).toUpperCase() + name.substring(1);
// Default for SDK bindings.
final AnnotationInfo info = new AnnotationInfo(name,
AnnotationInfo.ExceptionMode.NSRESULT,
AnnotationInfo.CallingThread.ANY,
AnnotationInfo.DispatchTarget.CURRENT);
final AnnotatableEntity entity = new AnnotatableEntity(m, info);
if (m instanceof Constructor) {
generateConstructor(entity);
} else if (m instanceof Method) {
generateMethod(entity);
} else if (m instanceof Field) {
generateField(entity);
} else {
throw new IllegalArgumentException(
"expected member to be Constructor, Method, or Field");
}
}
}
public void generateClasses(final ClassWithOptions[] classes) {
if (classes.length == 0) {
return;
}
for (final ClassWithOptions cls : classes) {
// Extract "Inner" from "Outer::Inner".
header.append(
" class " + Utils.getUnqualifiedName(cls.generatedName) + ";\n");
}
header.append('\n');
}
/**
* Get the finalised bytes to go into the generated wrappers file.
*
* @return The bytes to be written to the wrappers file.
*/
public String getWrapperFileContents() {
return cpp.toString();
}
/**
* Get the finalised bytes to go into the generated header file.
*
* @return The bytes to be written to the header file.
*/
public String getHeaderFileContents() {
if (this.callingThread == null) {
this.callingThread = AnnotationInfo.CallingThread.ANY;
}
header.append(
" static const mozilla::jni::CallingThread callingThread =\n" +
" " + this.callingThread.nativeValue() + ";\n" +
"\n");
if (nativesInits.length() > 0) {
header.append(
" template<class Impl> class Natives;\n");
}
header.append(
"};\n" +
"\n");
return header.toString();
}
/**
* Get the finalised bytes to go into the generated natives header file.
*
* @return The bytes to be written to the header file.
*/
public String getNativesFileContents() {
if (nativesInits.length() == 0) {
return "";
}
natives.append(
" static const JNINativeMethod methods[" + numNativesInits + "];\n" +
"};\n" +
"\n" +
"template<class Impl>\n" +
"const JNINativeMethod " + clsName + "::Natives<Impl>::methods[] = {" + nativesInits + '\n' +
"};\n" +
"\n");
return natives.toString();
}
}
+10
View File
@@ -0,0 +1,10 @@
# 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/.
include $(topsrcdir)/config/rules.mk
# Include Android specific java flags, instead of what's in rules.mk.
include $(topsrcdir)/config/android-common.mk
export:: annotationProcessors.jar
@@ -0,0 +1,258 @@
/* 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/. */
package org.mozilla.gecko.annotationProcessors;
import com.android.tools.lint.checks.ApiLookup;
import com.android.tools.lint.LintCliClient;
import org.mozilla.gecko.annotationProcessors.classloader.AnnotatableEntity;
import org.mozilla.gecko.annotationProcessors.classloader.ClassWithOptions;
import org.mozilla.gecko.annotationProcessors.classloader.IterableJarLoadingURLClassLoader;
import org.mozilla.gecko.annotationProcessors.utils.GeneratableElementIterator;
import org.mozilla.gecko.annotationProcessors.utils.Utils;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Iterator;
import java.util.Properties;
import java.util.Scanner;
import java.util.Vector;
import java.net.URL;
import java.net.URLClassLoader;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Member;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
public class SDKProcessor {
public static final String GENERATED_COMMENT =
"// GENERATED CODE\n" +
"// Generated by the Java program at /build/annotationProcessors at compile time\n" +
"// from annotations on Java methods. To update, change the annotations on the\n" +
"// corresponding Javamethods and rerun the build. Manually updating this file\n" +
"// will cause your build to fail.\n" +
"\n";
private static ApiLookup sApiLookup;
private static int sMaxSdkVersion;
public static void main(String[] args) throws Exception {
// We expect a list of jars on the commandline. If missing, whinge about it.
if (args.length < 5) {
System.err.println("Usage: java SDKProcessor sdkjar classlistfile outdir fileprefix max-sdk-version");
System.exit(1);
}
System.out.println("Processing platform bindings...");
String sdkJar = args[0];
Vector classes = getClassList(args[1]);
String outdir = args[2];
String generatedFilePrefix = args[3];
sMaxSdkVersion = Integer.parseInt(args[4]);
LintCliClient lintClient = new LintCliClient();
sApiLookup = ApiLookup.get(lintClient);
// Start the clock!
long s = System.currentTimeMillis();
// Get an iterator over the classes in the jar files given...
// Iterator<ClassWithOptions> jarClassIterator = IterableJarLoadingURLClassLoader.getIteratorOverJars(args);
StringBuilder headerFile = new StringBuilder(GENERATED_COMMENT);
headerFile.append(
"#ifndef " + generatedFilePrefix + "_h__\n" +
"#define " + generatedFilePrefix + "_h__\n" +
"\n" +
"#include \"mozilla/jni/Refs.h\"\n" +
"\n" +
"namespace mozilla {\n" +
"namespace java {\n" +
"namespace sdk {\n" +
"\n");
StringBuilder implementationFile = new StringBuilder(GENERATED_COMMENT);
implementationFile.append(
"#include \"" + generatedFilePrefix + ".h\"\n" +
"#include \"mozilla/jni/Accessors.h\"\n" +
"\n" +
"namespace mozilla {\n" +
"namespace java {\n" +
"namespace sdk {\n" +
"\n");
// Used to track the calls to the various class-specific initialisation functions.
ClassLoader loader = null;
try {
loader = URLClassLoader.newInstance(new URL[] { new URL("file://" + sdkJar) },
SDKProcessor.class.getClassLoader());
} catch (Exception e) {
throw new RuntimeException(e.toString());
}
for (Iterator<String> i = classes.iterator(); i.hasNext(); ) {
String className = i.next();
System.out.println("Looking up: " + className);
generateClass(Class.forName(className, true, loader),
implementationFile,
headerFile);
}
implementationFile.append(
"} /* sdk */\n" +
"} /* java */\n" +
"} /* mozilla */\n");
headerFile.append(
"} /* sdk */\n" +
"} /* java */\n" +
"} /* mozilla */\n" +
"#endif\n");
writeOutputFiles(outdir, generatedFilePrefix, headerFile, implementationFile);
long e = System.currentTimeMillis();
System.out.println("SDK processing complete in " + (e - s) + "ms");
}
private static int getAPIVersion(Class<?> cls, Member m) {
if (m instanceof Method || m instanceof Constructor) {
return sApiLookup.getCallVersion(
cls.getName().replace('.', '/'),
Utils.getMemberName(m),
Utils.getSignature(m));
} else if (m instanceof Field) {
return sApiLookup.getFieldVersion(
Utils.getClassDescriptor(m.getDeclaringClass()), m.getName());
} else {
throw new IllegalArgumentException("expected member to be Method, Constructor, or Field");
}
}
private static Member[] sortAndFilterMembers(Class<?> cls, Member[] members) {
Arrays.sort(members, new Comparator<Member>() {
@Override
public int compare(Member a, Member b) {
return a.getName().compareTo(b.getName());
}
});
ArrayList<Member> list = new ArrayList<>();
for (Member m : members) {
// Sometimes (e.g. Bundle) has methods that moved to/from a superclass in a later SDK
// version, so we check for both classes and see if we can find a minimum SDK version.
int version = getAPIVersion(cls, m);
final int version2 = getAPIVersion(m.getDeclaringClass(), m);
if (version2 > 0 && version2 < version) {
version = version2;
}
if (version > sMaxSdkVersion) {
System.out.println("Skipping " + m.getDeclaringClass().getName() + "." + m.getName() +
", version " + version + " > " + sMaxSdkVersion);
continue;
}
// Sometimes (e.g. KeyEvent) a field can appear in both a class and a superclass. In
// that case we want to filter out the version that appears in the superclass, or
// we'll have bindings with duplicate names.
try {
if (m instanceof Field && !m.equals(cls.getField(m.getName()))) {
// m is a field in a superclass that has been hidden by
// a field with the same name in a subclass.
System.out.println("Skipping " + m.getName() +
" from " + m.getDeclaringClass());
continue;
}
} catch (final NoSuchFieldException e) {
}
list.add(m);
}
return list.toArray(new Member[list.size()]);
}
private static void generateClass(Class<?> clazz,
StringBuilder implementationFile,
StringBuilder headerFile) {
String generatedName = clazz.getSimpleName();
CodeGenerator generator = new CodeGenerator(new ClassWithOptions(clazz, generatedName));
generator.generateMembers(sortAndFilterMembers(clazz, clazz.getConstructors()));
generator.generateMembers(sortAndFilterMembers(clazz, clazz.getMethods()));
generator.generateMembers(sortAndFilterMembers(clazz, clazz.getFields()));
headerFile.append(generator.getHeaderFileContents());
implementationFile.append(generator.getWrapperFileContents());
}
private static Vector<String> getClassList(String path) {
Scanner scanner = null;
try {
scanner = new Scanner(new FileInputStream(path));
Vector lines = new Vector();
while (scanner.hasNextLine()) {
lines.add(scanner.nextLine());
}
return lines;
} catch (Exception e) {
System.out.println(e.toString());
return null;
} finally {
if (scanner != null) {
scanner.close();
}
}
}
private static void writeOutputFiles(String aOutputDir, String aPrefix, StringBuilder aHeaderFile,
StringBuilder aImplementationFile) {
FileOutputStream implStream = null;
try {
implStream = new FileOutputStream(new File(aOutputDir, aPrefix + ".cpp"));
implStream.write(aImplementationFile.toString().getBytes());
} catch (IOException e) {
System.err.println("Unable to write " + aOutputDir + ". Perhaps a permissions issue?");
e.printStackTrace(System.err);
} finally {
if (implStream != null) {
try {
implStream.close();
} catch (IOException e) {
System.err.println("Unable to close implStream due to "+e);
e.printStackTrace(System.err);
}
}
}
FileOutputStream headerStream = null;
try {
headerStream = new FileOutputStream(new File(aOutputDir, aPrefix + ".h"));
headerStream.write(aHeaderFile.toString().getBytes());
} catch (IOException e) {
System.err.println("Unable to write " + aOutputDir + ". Perhaps a permissions issue?");
e.printStackTrace(System.err);
} finally {
if (headerStream != null) {
try {
headerStream.close();
} catch (IOException e) {
System.err.println("Unable to close headerStream due to "+e);
e.printStackTrace(System.err);
}
}
}
}
}
@@ -0,0 +1,62 @@
/* 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/. */
package org.mozilla.gecko.annotationProcessors.classloader;
import org.mozilla.gecko.annotationProcessors.AnnotationInfo;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Member;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
/**
* Union type to hold either a method, field, or ctor. Allows us to iterate "The generatable stuff", despite
* the fact that such things can be of either flavour.
*/
public class AnnotatableEntity {
public enum ENTITY_TYPE {METHOD, NATIVE, FIELD, CONSTRUCTOR}
private final Member mMember;
public final ENTITY_TYPE mEntityType;
public final AnnotationInfo mAnnotationInfo;
public AnnotatableEntity(Member aObject, AnnotationInfo aAnnotationInfo) {
mMember = aObject;
mAnnotationInfo = aAnnotationInfo;
if (aObject instanceof Method) {
if (Modifier.isNative(aObject.getModifiers())) {
mEntityType = ENTITY_TYPE.NATIVE;
} else {
mEntityType = ENTITY_TYPE.METHOD;
}
} else if (aObject instanceof Field) {
mEntityType = ENTITY_TYPE.FIELD;
} else {
mEntityType = ENTITY_TYPE.CONSTRUCTOR;
}
}
public Method getMethod() {
if (mEntityType != ENTITY_TYPE.METHOD && mEntityType != ENTITY_TYPE.NATIVE) {
throw new UnsupportedOperationException("Attempt to cast to unsupported member type.");
}
return (Method) mMember;
}
public Field getField() {
if (mEntityType != ENTITY_TYPE.FIELD) {
throw new UnsupportedOperationException("Attempt to cast to unsupported member type.");
}
return (Field) mMember;
}
public Constructor<?> getConstructor() {
if (mEntityType != ENTITY_TYPE.CONSTRUCTOR) {
throw new UnsupportedOperationException("Attempt to cast to unsupported member type.");
}
return (Constructor<?>) mMember;
}
}
@@ -0,0 +1,15 @@
/* 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/. */
package org.mozilla.gecko.annotationProcessors.classloader;
public class ClassWithOptions {
public final Class<?> wrappedClass;
public final String generatedName;
public ClassWithOptions(Class<?> someClass, String name) {
wrappedClass = someClass;
generatedName = name;
}
}
@@ -0,0 +1,75 @@
/* 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/. */
package org.mozilla.gecko.annotationProcessors.classloader;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.Collections;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
/**
* A classloader which can be initialised with a list of jar files and which can provide an iterator
* over the top level classes in the jar files it was initialised with.
* classNames is kept sorted to ensure iteration order is consistent across program invocations.
* Otherwise, we'd forever be reporting the outdatedness of the generated code as we permute its
* contents.
*/
public class IterableJarLoadingURLClassLoader extends URLClassLoader {
LinkedList<String> classNames = new LinkedList<String>();
/**
* Create an instance and return its iterator. Provides an iterator over the classes in the jar
* files provided as arguments.
* Inner classes are not supported.
*
* @param args A list of jar file names an iterator over the classes of which is desired.
* @return An iterator over the top level classes in the jar files provided, in arbitrary order.
*/
public static Iterator<ClassWithOptions> getIteratorOverJars(String[] args) {
URL[] urlArray = new URL[args.length];
LinkedList<String> aClassNames = new LinkedList<String>();
for (int i = 0; i < args.length; i++) {
try {
urlArray[i] = (new File(args[i])).toURI().toURL();
Enumeration<JarEntry> entries = new JarFile(args[i]).entries();
while (entries.hasMoreElements()) {
JarEntry e = entries.nextElement();
String fName = e.getName();
if (!fName.endsWith(".class")) {
continue;
}
final String className = fName.substring(0, fName.length() - 6).replace('/', '.');
aClassNames.add(className);
}
} catch (IOException e) {
System.err.println("Error loading jar file \"" + args[i] + '"');
e.printStackTrace(System.err);
}
}
Collections.sort(aClassNames);
return new JarClassIterator(new IterableJarLoadingURLClassLoader(urlArray, aClassNames));
}
/**
* Constructs a classloader capable of loading all classes given as URLs in urls. Used by static
* method above.
*
* @param urls URLs for all classes the new instance shall be capable of loading.
* @param aClassNames A list of names of the classes this instance shall be capable of loading.
*/
protected IterableJarLoadingURLClassLoader(URL[] urls, LinkedList<String> aClassNames) {// Array to populate with URLs for each class in the given jars.
super(urls);
classNames = aClassNames;
}
}
@@ -0,0 +1,84 @@
/* 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/. */
package org.mozilla.gecko.annotationProcessors.classloader;
import java.util.Iterator;
/**
* Class for iterating over an IterableJarLoadingURLClassLoader's classes.
*
* This class is not thread safe: use it only from a single thread.
*/
public class JarClassIterator implements Iterator<ClassWithOptions> {
private IterableJarLoadingURLClassLoader mTarget;
private Iterator<String> mTargetClassListIterator;
private ClassWithOptions lookAhead;
public JarClassIterator(IterableJarLoadingURLClassLoader aTarget) {
mTarget = aTarget;
mTargetClassListIterator = aTarget.classNames.iterator();
}
@Override
public boolean hasNext() {
return fillLookAheadIfPossible();
}
@Override
public ClassWithOptions next() {
if (!fillLookAheadIfPossible()) {
throw new IllegalStateException("Failed to look ahead in next()!");
}
ClassWithOptions next = lookAhead;
lookAhead = null;
return next;
}
private boolean fillLookAheadIfPossible() {
if (lookAhead != null) {
return true;
}
if (!mTargetClassListIterator.hasNext()) {
return false;
}
String className = mTargetClassListIterator.next();
try {
Class<?> ret = mTarget.loadClass(className);
// Incremental builds can leave stale classfiles in the jar. Such classfiles will cause
// an exception at this point. We can safely ignore these classes - they cannot possibly
// ever be loaded as they conflict with their parent class and will be killed by
// Proguard later on anyway.
final Class<?> enclosingClass;
try {
enclosingClass = ret.getEnclosingClass();
} catch (IncompatibleClassChangeError e) {
return fillLookAheadIfPossible();
}
if (enclosingClass != null) {
// Anonymous inner class - unsupported.
// Or named inner class, which will be processed when we process the outer class.
return fillLookAheadIfPossible();
}
lookAhead = new ClassWithOptions(ret, ret.getSimpleName());
return true;
} catch (ClassNotFoundException e) {
System.err.println("Unable to enumerate class: " + className + ". Corrupted jar file?");
e.printStackTrace();
System.exit(2);
}
return false;
}
@Override
public void remove() {
throw new UnsupportedOperationException("Removal of classes from iterator not supported.");
}
}
+23
View File
@@ -0,0 +1,23 @@
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
# 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/.
jar = add_java_jar('annotationProcessors')
jar.sources += [
'AnnotationInfo.java',
'AnnotationProcessor.java',
'classloader/AnnotatableEntity.java',
'classloader/ClassWithOptions.java',
'classloader/IterableJarLoadingURLClassLoader.java',
'classloader/JarClassIterator.java',
'CodeGenerator.java',
'SDKProcessor.java',
'utils/AlphabeticAnnotatableEntityComparator.java',
'utils/GeneratableElementIterator.java',
'utils/Utils.java',
]
jar.extra_jars += [
CONFIG['ANDROID_TOOLS'] + '/lib/lint.jar',
CONFIG['ANDROID_TOOLS'] + '/lib/lint-checks.jar',
]
@@ -0,0 +1,81 @@
/* 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/. */
package org.mozilla.gecko.annotationProcessors.utils;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Member;
import java.lang.reflect.Method;
import java.util.Comparator;
public class AlphabeticAnnotatableEntityComparator<T extends Member> implements Comparator<T> {
@Override
public int compare(T aLhs, T aRhs) {
// Constructors, Methods, Fields.
boolean lIsConstructor = aLhs instanceof Constructor;
boolean rIsConstructor = aRhs instanceof Constructor;
boolean lIsMethod = aLhs instanceof Method;
boolean rIsField = aRhs instanceof Field;
if (lIsConstructor) {
if (!rIsConstructor) {
return -1;
}
} else if (lIsMethod) {
if (rIsConstructor) {
return 1;
} else if (rIsField) {
return -1;
}
} else {
if (!rIsField) {
return 1;
}
}
// Verify these objects are the same type and cast them.
if (aLhs instanceof Method) {
return compare((Method) aLhs, (Method) aRhs);
} else if (aLhs instanceof Field) {
return compare((Field) aLhs, (Field) aRhs);
} else {
return compare((Constructor) aLhs, (Constructor) aRhs);
}
}
// Alas, the type system fails us.
private static int compare(Method aLhs, Method aRhs) {
// Initially, attempt to differentiate the methods be name alone..
String lName = aLhs.getName();
String rName = aRhs.getName();
int ret = lName.compareTo(rName);
if (ret != 0) {
return ret;
}
// The names were the same, so we need to compare signatures to find their uniqueness..
lName = Utils.getSignature(aLhs);
rName = Utils.getSignature(aRhs);
return lName.compareTo(rName);
}
private static int compare(Constructor<?> aLhs, Constructor<?> aRhs) {
// The names will be the same, so we need to compare signatures to find their uniqueness..
String lName = Utils.getSignature(aLhs);
String rName = Utils.getSignature(aRhs);
return lName.compareTo(rName);
}
private static int compare(Field aLhs, Field aRhs) {
// Compare field names..
String lName = aLhs.getName();
String rName = aRhs.getName();
return lName.compareTo(rName);
}
}
@@ -0,0 +1,267 @@
/* 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/. */
package org.mozilla.gecko.annotationProcessors.utils;
import org.mozilla.gecko.annotationProcessors.AnnotationInfo;
import org.mozilla.gecko.annotationProcessors.classloader.AnnotatableEntity;
import org.mozilla.gecko.annotationProcessors.classloader.ClassWithOptions;
import java.lang.annotation.Annotation;
import java.lang.reflect.AnnotatedElement;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Member;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Iterator;
/**
* Iterator over the methods in a given method list which have the WrappedJNIMethod
* annotation. Returns an object containing both the annotation (Which may contain interesting
* parameters) and the argument.
*/
public class GeneratableElementIterator implements Iterator<AnnotatableEntity> {
private final ClassWithOptions mClass;
private final Member[] mObjects;
private AnnotatableEntity mNextReturnValue;
private int mElementIndex;
private AnnotationInfo mClassInfo;
private boolean mIterateEveryEntry;
private boolean mSkipCurrentEntry;
public GeneratableElementIterator(ClassWithOptions annotatedClass) {
mClass = annotatedClass;
final Class<?> aClass = annotatedClass.wrappedClass;
// Get all the elements of this class as AccessibleObjects.
Member[] aMethods = aClass.getDeclaredMethods();
Member[] aFields = aClass.getDeclaredFields();
Member[] aCtors = aClass.getDeclaredConstructors();
// Shove them all into one buffer.
Member[] objs = new Member[aMethods.length + aFields.length + aCtors.length];
int offset = 0;
System.arraycopy(aMethods, 0, objs, 0, aMethods.length);
offset += aMethods.length;
System.arraycopy(aFields, 0, objs, offset, aFields.length);
offset += aFields.length;
System.arraycopy(aCtors, 0, objs, offset, aCtors.length);
// Sort the elements to ensure determinism.
Arrays.sort(objs, new AlphabeticAnnotatableEntityComparator<Member>());
mObjects = objs;
// Check for "Wrap ALL the things" flag.
for (Annotation annotation : aClass.getDeclaredAnnotations()) {
mClassInfo = buildAnnotationInfo(aClass, annotation);
if (mClassInfo != null) {
mIterateEveryEntry = true;
break;
}
}
if (mSkipCurrentEntry) {
throw new IllegalArgumentException("Cannot skip entire class");
}
findNextValue();
}
private Class<?>[] getFilteredInnerClasses() {
// Go through all inner classes and see which ones we want to generate.
final Class<?>[] candidates = mClass.wrappedClass.getDeclaredClasses();
int count = 0;
for (int i = 0; i < candidates.length; ++i) {
final GeneratableElementIterator testIterator
= new GeneratableElementIterator(new ClassWithOptions(candidates[i], null));
if (testIterator.hasNext()
|| testIterator.getFilteredInnerClasses() != null) {
count++;
continue;
}
// Clear out ones that don't match.
candidates[i] = null;
}
return count > 0 ? candidates : null;
}
public ClassWithOptions[] getInnerClasses() {
final Class<?>[] candidates = getFilteredInnerClasses();
if (candidates == null) {
return new ClassWithOptions[0];
}
int count = 0;
for (Class<?> candidate : candidates) {
if (candidate != null) {
count++;
}
}
final ClassWithOptions[] ret = new ClassWithOptions[count];
count = 0;
for (Class<?> candidate : candidates) {
if (candidate != null) {
ret[count++] = new ClassWithOptions(
candidate, mClass.generatedName + "::" + candidate.getSimpleName());
}
}
assert ret.length == count;
Arrays.sort(ret, new Comparator<ClassWithOptions>() {
@Override public int compare(ClassWithOptions lhs, ClassWithOptions rhs) {
return lhs.generatedName.compareTo(rhs.generatedName);
}
});
return ret;
}
private static <T extends Enum<T>> T getEnumValue(Class<T> type, String name)
throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
try {
return Enum.valueOf(type, name.toUpperCase());
} catch (IllegalArgumentException e) {
Object[] values = (Object[]) type.getDeclaredMethod("values").invoke(null);
StringBuilder names = new StringBuilder();
for (int i = 0; i < values.length; i++) {
if (i != 0) {
names.append(", ");
}
names.append(values[i].toString().toLowerCase());
}
System.err.println("***");
System.err.println("*** Invalid value \"" + name + "\" for " + type.getSimpleName());
System.err.println("*** Specify one of " + names.toString());
System.err.println("***");
e.printStackTrace(System.err);
System.exit(6);
return null;
}
}
private AnnotationInfo buildAnnotationInfo(AnnotatedElement element, Annotation annotation) {
Class<? extends Annotation> annotationType = annotation.annotationType();
final String annotationTypeName = annotationType.getName();
if (!annotationTypeName.equals("org.mozilla.gecko.annotation.WrapForJNI")) {
return null;
}
String stubName = null;
AnnotationInfo.ExceptionMode exceptionMode = null;
AnnotationInfo.CallingThread callingThread = null;
AnnotationInfo.DispatchTarget dispatchTarget = null;
try {
final Method skipMethod = annotationType.getDeclaredMethod("skip");
skipMethod.setAccessible(true);
if ((Boolean) skipMethod.invoke(annotation)) {
mSkipCurrentEntry = true;
return null;
}
// Determine the explicitly-given name of the stub to generate, if any.
final Method stubNameMethod = annotationType.getDeclaredMethod("stubName");
stubNameMethod.setAccessible(true);
stubName = (String) stubNameMethod.invoke(annotation);
final Method exceptionModeMethod = annotationType.getDeclaredMethod("exceptionMode");
exceptionModeMethod.setAccessible(true);
exceptionMode = getEnumValue(
AnnotationInfo.ExceptionMode.class,
(String) exceptionModeMethod.invoke(annotation));
final Method calledFromMethod = annotationType.getDeclaredMethod("calledFrom");
calledFromMethod.setAccessible(true);
callingThread = getEnumValue(
AnnotationInfo.CallingThread.class,
(String) calledFromMethod.invoke(annotation));
final Method dispatchToMethod = annotationType.getDeclaredMethod("dispatchTo");
dispatchToMethod.setAccessible(true);
dispatchTarget = getEnumValue(
AnnotationInfo.DispatchTarget.class,
(String) dispatchToMethod.invoke(annotation));
} catch (NoSuchMethodException e) {
System.err.println("Unable to find expected field on WrapForJNI annotation. Did the signature change?");
e.printStackTrace(System.err);
System.exit(3);
} catch (IllegalAccessException e) {
System.err.println("IllegalAccessException reading fields on WrapForJNI annotation. Seems the semantics of Reflection have changed...");
e.printStackTrace(System.err);
System.exit(4);
} catch (InvocationTargetException e) {
System.err.println("InvocationTargetException reading fields on WrapForJNI annotation. This really shouldn't happen.");
e.printStackTrace(System.err);
System.exit(5);
}
// If the method name was not explicitly given in the annotation generate one...
if (stubName.isEmpty()) {
stubName = Utils.getNativeName(element);
}
return new AnnotationInfo(stubName, exceptionMode, callingThread, dispatchTarget);
}
/**
* Find and cache the next appropriately annotated method, plus the annotation parameter, if
* one exists. Otherwise cache null, so hasNext returns false.
*/
private void findNextValue() {
while (mElementIndex < mObjects.length) {
Member candidateElement = mObjects[mElementIndex];
mElementIndex++;
for (Annotation annotation : ((AnnotatedElement) candidateElement).getDeclaredAnnotations()) {
AnnotationInfo info = buildAnnotationInfo((AnnotatedElement)candidateElement, annotation);
if (info != null) {
mNextReturnValue = new AnnotatableEntity(candidateElement, info);
return;
}
}
if (mSkipCurrentEntry) {
mSkipCurrentEntry = false;
continue;
}
// If no annotation found, we might be expected to generate anyway
// using default arguments, thanks to the "Generate everything" annotation.
if (mIterateEveryEntry) {
AnnotationInfo annotationInfo = new AnnotationInfo(
Utils.getNativeName(candidateElement),
mClassInfo.exceptionMode,
mClassInfo.callingThread,
mClassInfo.dispatchTarget);
mNextReturnValue = new AnnotatableEntity(candidateElement, annotationInfo);
return;
}
}
mNextReturnValue = null;
}
@Override
public boolean hasNext() {
return mNextReturnValue != null;
}
@Override
public AnnotatableEntity next() {
AnnotatableEntity ret = mNextReturnValue;
findNextValue();
return ret;
}
@Override
public void remove() {
throw new UnsupportedOperationException("Removal of methods from GeneratableElementIterator not supported.");
}
}
+288
View File
@@ -0,0 +1,288 @@
/* 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/. */
package org.mozilla.gecko.annotationProcessors.utils;
import org.mozilla.gecko.annotationProcessors.AnnotationInfo;
import java.lang.reflect.AnnotatedElement;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Member;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.nio.ByteBuffer;
import java.util.HashMap;
/**
* A collection of utility methods used by CodeGenerator. Largely used for translating types.
*/
public class Utils {
// A collection of lookup tables to simplify the functions to follow...
private static final HashMap<String, String> NATIVE_TYPES = new HashMap<String, String>();
static {
NATIVE_TYPES.put("void", "void");
NATIVE_TYPES.put("boolean", "bool");
NATIVE_TYPES.put("byte", "int8_t");
NATIVE_TYPES.put("char", "char16_t");
NATIVE_TYPES.put("short", "int16_t");
NATIVE_TYPES.put("int", "int32_t");
NATIVE_TYPES.put("long", "int64_t");
NATIVE_TYPES.put("float", "float");
NATIVE_TYPES.put("double", "double");
}
private static final HashMap<String, String> NATIVE_ARRAY_TYPES = new HashMap<String, String>();
static {
NATIVE_ARRAY_TYPES.put("boolean", "mozilla::jni::BooleanArray");
NATIVE_ARRAY_TYPES.put("byte", "mozilla::jni::ByteArray");
NATIVE_ARRAY_TYPES.put("char", "mozilla::jni::CharArray");
NATIVE_ARRAY_TYPES.put("short", "mozilla::jni::ShortArray");
NATIVE_ARRAY_TYPES.put("int", "mozilla::jni::IntArray");
NATIVE_ARRAY_TYPES.put("long", "mozilla::jni::LongArray");
NATIVE_ARRAY_TYPES.put("float", "mozilla::jni::FloatArray");
NATIVE_ARRAY_TYPES.put("double", "mozilla::jni::DoubleArray");
}
private static final HashMap<String, String> CLASS_DESCRIPTORS = new HashMap<String, String>();
static {
CLASS_DESCRIPTORS.put("void", "V");
CLASS_DESCRIPTORS.put("boolean", "Z");
CLASS_DESCRIPTORS.put("byte", "B");
CLASS_DESCRIPTORS.put("char", "C");
CLASS_DESCRIPTORS.put("short", "S");
CLASS_DESCRIPTORS.put("int", "I");
CLASS_DESCRIPTORS.put("long", "J");
CLASS_DESCRIPTORS.put("float", "F");
CLASS_DESCRIPTORS.put("double", "D");
}
/**
* Get the C++ type corresponding to the provided type parameter.
*
* @param type Class to determine the corresponding JNI type for.
* @return C++ type as a String
*/
public static String getNativeParameterType(Class<?> type, AnnotationInfo info) {
final String name = type.getName().replace('.', '/');
if (NATIVE_TYPES.containsKey(name)) {
return NATIVE_TYPES.get(name);
}
if (type.isArray()) {
final String compName = type.getComponentType().getName();
if (NATIVE_ARRAY_TYPES.containsKey(compName)) {
return NATIVE_ARRAY_TYPES.get(compName) + "::Param";
}
return "mozilla::jni::ObjectArray::Param";
}
if (type.equals(String.class) || type.equals(CharSequence.class)) {
return "mozilla::jni::String::Param";
}
if (type.equals(Class.class)) {
// You're doing reflection on Java objects from inside C, returning Class objects
// to C, generating the corresponding code using this Java program. Really?!
return "mozilla::jni::Class::Param";
}
if (type.equals(Throwable.class)) {
return "mozilla::jni::Throwable::Param";
}
if (type.equals(ByteBuffer.class)) {
return "mozilla::jni::ByteBuffer::Param";
}
return "mozilla::jni::Object::Param";
}
public static String getNativeReturnType(Class<?> type, AnnotationInfo info) {
final String name = type.getName().replace('.', '/');
if (NATIVE_TYPES.containsKey(name)) {
return NATIVE_TYPES.get(name);
}
if (type.isArray()) {
final String compName = type.getComponentType().getName();
if (NATIVE_ARRAY_TYPES.containsKey(compName)) {
return NATIVE_ARRAY_TYPES.get(compName) + "::LocalRef";
}
return "mozilla::jni::ObjectArray::LocalRef";
}
if (type.equals(String.class)) {
return "mozilla::jni::String::LocalRef";
}
if (type.equals(Class.class)) {
// You're doing reflection on Java objects from inside C, returning Class objects
// to C, generating the corresponding code using this Java program. Really?!
return "mozilla::jni::Class::LocalRef";
}
if (type.equals(Throwable.class)) {
return "mozilla::jni::Throwable::LocalRef";
}
if (type.equals(ByteBuffer.class)) {
return "mozilla::jni::ByteBuffer::LocalRef";
}
return "mozilla::jni::Object::LocalRef";
}
/**
* Get the JNI class descriptor corresponding to the provided type parameter.
*
* @param type Class to determine the corresponding JNI descriptor for.
* @return Class descripor as a String
*/
public static String getClassDescriptor(Class<?> type) {
final String name = type.getName().replace('.', '/');
if (CLASS_DESCRIPTORS.containsKey(name)) {
return CLASS_DESCRIPTORS.get(name);
}
if (type.isArray()) {
// Array names are already in class descriptor form.
return name;
}
return "L" + name + ';';
}
/**
* Get the JNI signaure for a member.
*
* @param member Member to get the signature for.
* @return JNI signature as a string
*/
public static String getSignature(Member member) {
return member instanceof Field ? getSignature((Field) member) :
member instanceof Method ? getSignature((Method) member) :
getSignature((Constructor<?>) member);
}
/**
* Get the JNI signaure for a field.
*
* @param member Field to get the signature for.
* @return JNI signature as a string
*/
public static String getSignature(Field member) {
return getClassDescriptor(member.getType());
}
private static String getSignature(Class<?>[] args, Class<?> ret) {
final StringBuilder sig = new StringBuilder("(");
for (int i = 0; i < args.length; i++) {
sig.append(getClassDescriptor(args[i]));
}
return sig.append(')').append(getClassDescriptor(ret)).toString();
}
/**
* Get the JNI signaure for a method.
*
* @param member Method to get the signature for.
* @return JNI signature as a string
*/
public static String getSignature(Method member) {
return getSignature(member.getParameterTypes(), member.getReturnType());
}
/**
* Get the JNI signaure for a constructor.
*
* @param member Constructor to get the signature for.
* @return JNI signature as a string
*/
public static String getSignature(Constructor<?> member) {
return getSignature(member.getParameterTypes(), void.class);
}
/**
* Get the C++ name for a member.
*
* @param member Member to get the name for.
* @return JNI name as a string
*/
public static String getNativeName(Member member) {
final String name = getMemberName(member);
return name.substring(0, 1).toUpperCase() + name.substring(1);
}
/**
* Get the C++ name for a member.
*
* @param member Member to get the name for.
* @return JNI name as a string
*/
public static String getNativeName(Class<?> clz) {
final String name = clz.getName();
return name.substring(0, 1).toUpperCase() + name.substring(1);
}
/**
* Get the C++ name for a member.
*
* @param member Member to get the name for.
* @return JNI name as a string
*/
public static String getNativeName(AnnotatedElement element) {
if (element instanceof Class<?>) {
return getNativeName((Class<?>)element);
} else if (element instanceof Member) {
return getNativeName((Member)element);
} else {
return null;
}
}
/**
* Get the JNI name for a member.
*
* @param member Member to get the name for.
* @return JNI name as a string
*/
public static String getMemberName(Member member) {
if (member instanceof Constructor) {
return "<init>";
}
return member.getName();
}
public static String getUnqualifiedName(String name) {
return name.substring(name.lastIndexOf(':') + 1);
}
/**
* Determine if a member is declared static.
*
* @param member The Member to check.
* @return true if the member is declared static, false otherwise.
*/
public static boolean isStatic(final Member member) {
return Modifier.isStatic(member.getModifiers());
}
/**
* Determine if a member is declared final.
*
* @param member The Member to check.
* @return true if the member is declared final, false otherwise.
*/
public static boolean isFinal(final Member member) {
return Modifier.isFinal(member.getModifiers());
}
}
+376
View File
@@ -0,0 +1,376 @@
dnl This Source Code Form is subject to the terms of the Mozilla Public
dnl License, v. 2.0. If a copy of the MPL was not distributed with this
dnl file, You can obtain one at http://mozilla.org/MPL/2.0/.
AC_DEFUN([MOZ_ANDROID_NDK],
[
MOZ_ARG_WITH_STRING(android-cxx-stl,
[ --with-android-cxx-stl=VALUE
use the specified C++ STL (libstdc++, libc++)],
android_cxx_stl=$withval,
android_cxx_stl=libc++)
case "$target" in
*-android*|*-linuxandroid*)
dnl $android_platform will be set for us by Python configure.
CPPFLAGS="-idirafter $android_platform/usr/include $CPPFLAGS"
CFLAGS="-fno-short-enums -fno-exceptions $CFLAGS"
CXXFLAGS="-fno-short-enums -fno-exceptions $CXXFLAGS"
ASFLAGS="-idirafter $android_platform/usr/include -DANDROID $ASFLAGS"
dnl Add --allow-shlib-undefined, because libGLESv2 links to an
dnl undefined symbol (present on the hardware, just not in the
dnl NDK.)
LDFLAGS="-L$android_platform/usr/lib -Wl,-rpath-link=$android_platform/usr/lib --sysroot=$android_platform -Wl,--allow-shlib-undefined $LDFLAGS"
dnl Add -llog by default, since we use it all over the place.
LIBS="-llog $LIBS"
ANDROID_PLATFORM="${android_platform}"
AC_DEFINE(ANDROID)
AC_SUBST(ANDROID_PLATFORM)
;;
esac
])
AC_DEFUN([MOZ_ANDROID_CPU_ARCH],
[
if test "$OS_TARGET" = "Android"; then
case "${CPU_ARCH}-${MOZ_ARCH}" in
arm-armv7*)
ANDROID_CPU_ARCH=armeabi-v7a
;;
arm-*)
ANDROID_CPU_ARCH=armeabi
;;
x86-*)
ANDROID_CPU_ARCH=x86
;;
mips32-*) # When target_cpu is mipsel, CPU_ARCH is mips32
ANDROID_CPU_ARCH=mips
;;
aarch64-*)
ANDROID_CPU_ARCH=arm64-v8a
;;
esac
AC_SUBST(ANDROID_CPU_ARCH)
fi
])
AC_DEFUN([MOZ_ANDROID_STLPORT],
[
if test "$OS_TARGET" = "Android"; then
cpu_arch_dir="$ANDROID_CPU_ARCH"
# NDK r12 removed the arm/thumb library split and just made everything
# thumb by default. Attempt to compensate.
if test "$MOZ_THUMB2" = 1 -a -d "$cpu_arch_dir/thumb"; then
cpu_arch_dir="$cpu_arch_dir/thumb"
fi
if test -z "$STLPORT_CPPFLAGS$STLPORT_LIBS"; then
case "$android_cxx_stl" in
libstdc++)
# android-ndk-r8b and later
ndk_base="$android_ndk/sources/cxx-stl/gnu-libstdc++/$android_gnu_compiler_version"
ndk_libs_include="$ndk_base/libs/$ANDROID_CPU_ARCH"
ndk_libs="$ndk_base/libs/$cpu_arch_dir"
ndk_include="$ndk_base/include"
if ! test -e "$ndk_libs/libgnustl_static.a"; then
AC_MSG_ERROR([Couldn't find path to gnu-libstdc++ in the android ndk])
fi
STLPORT_LIBS="-L$ndk_libs -lgnustl_static"
STLPORT_CPPFLAGS="-I$ndk_include -I$ndk_include/backward -I$ndk_libs_include/include"
;;
libc++)
# android-ndk-r8b and later
ndk_base="$android_ndk/sources/cxx-stl"
cxx_base="$ndk_base/llvm-libc++"
cxx_libs="$cxx_base/libs/$cpu_arch_dir"
cxx_include="$cxx_base/libcxx/include"
cxxabi_base="$ndk_base/llvm-libc++abi"
cxxabi_include="$cxxabi_base/libcxxabi/include"
if ! test -e "$cxx_libs/libc++_static.a"; then
AC_MSG_ERROR([Couldn't find path to llvm-libc++ in the android ndk])
fi
STLPORT_LIBS="-L$cxx_libs -lc++_static"
# NDK r12 split the libc++ runtime libraries into pieces.
for lib in c++abi unwind android_support; do
if test -e "$cxx_libs/lib${lib}.a"; then
STLPORT_LIBS="$STLPORT_LIBS -l${lib}"
fi
done
# Add android/support/include/ for prototyping long double math
# functions, locale-specific C library functions, multibyte support,
# etc.
STLPORT_CPPFLAGS="-I$android_ndk/sources/android/support/include -I$cxx_include -I$cxxabi_include"
;;
*)
AC_MSG_ERROR([Bad value for --enable-android-cxx-stl])
;;
esac
fi
CXXFLAGS="$CXXFLAGS $STLPORT_CPPFLAGS"
fi
MOZ_ANDROID_CXX_STL=$android_cxx_stl
AC_SUBST([MOZ_ANDROID_CXX_STL])
AC_SUBST([STLPORT_LIBS])
])
AC_DEFUN([concat],[$1$2$3$4])
dnl Find a component of an AAR.
dnl Arg 1: variable name to expose, like ANDROID_SUPPORT_V4_LIB.
dnl Arg 2: path to component.
dnl Arg 3: if non-empty, expect and require component.
AC_DEFUN([MOZ_ANDROID_AAR_COMPONENT], [
ifelse([$3], ,
[
if test -e "$$1" ; then
AC_MSG_ERROR([Found unexpected exploded $1!])
fi
],
[
AC_MSG_CHECKING([for $1])
$1="$2"
if ! test -e "$$1" ; then
AC_MSG_ERROR([Could not find required exploded $1!])
fi
AC_MSG_RESULT([$$1])
AC_SUBST($1)
])
])
dnl Find an AAR and expose variables representing its exploded components.
dnl AC_SUBSTs ANDROID_NAME_{AAR,AAR_RES,AAR_LIB,AAR_INTERNAL_LIB}.
dnl Arg 1: name, like play-services-base
dnl Arg 2: version, like 7.8.0
dnl Arg 3: extras subdirectory, either android or google
dnl Arg 4: package subdirectory, like com/google/android/gms
dnl Arg 5: if non-empty, expect and require internal_impl JAR.
dnl Arg 6: if non-empty, expect and require assets/ directory.
AC_DEFUN([MOZ_ANDROID_AAR],[
define([local_aar_var_base], translit($1, [-a-z], [_A-Z]))
define([local_aar_var], concat(ANDROID_, local_aar_var_base, _AAR))
local_aar_var="$ANDROID_SDK_ROOT/extras/$3/m2repository/$4/$1/$2/$1-$2.aar"
AC_MSG_CHECKING([for $1 AAR])
if ! test -e "$local_aar_var" ; then
AC_MSG_ERROR([You must download the $1 AAR. Run the Android SDK tool and install the Android and Google Support Repositories under Extras. See https://developer.android.com/tools/extras/support-library.html for more info. (Looked for $local_aar_var)])
fi
AC_SUBST(local_aar_var)
AC_MSG_RESULT([$local_aar_var])
if ! $PYTHON -m mozbuild.action.explode_aar --destdir=$MOZ_BUILD_ROOT/dist/exploded-aar $local_aar_var ; then
AC_MSG_ERROR([Could not explode $local_aar_var!])
fi
define([root], $MOZ_BUILD_ROOT/dist/exploded-aar/$1-$2/)
MOZ_ANDROID_AAR_COMPONENT(concat(local_aar_var, _LIB), concat(root, $1-$2-classes.jar), REQUIRED)
MOZ_ANDROID_AAR_COMPONENT(concat(local_aar_var, _RES), concat(root, res), REQUIRED)
MOZ_ANDROID_AAR_COMPONENT(concat(local_aar_var, _INTERNAL_LIB), concat(root, libs/$1-$2-internal_impl-$2.jar), $5)
MOZ_ANDROID_AAR_COMPONENT(concat(local_aar_var, _ASSETS), concat(root, assets), $6)
])
AC_DEFUN([MOZ_ANDROID_GOOGLE_PLAY_SERVICES],
[
if test -n "$MOZ_NATIVE_DEVICES" ; then
AC_SUBST(MOZ_NATIVE_DEVICES)
MOZ_ANDROID_AAR(play-services-base, $ANDROID_GOOGLE_PLAY_SERVICES_VERSION, google, com/google/android/gms)
MOZ_ANDROID_AAR(play-services-basement, $ANDROID_GOOGLE_PLAY_SERVICES_VERSION, google, com/google/android/gms)
MOZ_ANDROID_AAR(play-services-cast, $ANDROID_GOOGLE_PLAY_SERVICES_VERSION, google, com/google/android/gms)
MOZ_ANDROID_AAR(mediarouter-v7, $ANDROID_SUPPORT_LIBRARY_VERSION, android, com/android/support, REQUIRED_INTERNAL_IMPL)
fi
])
AC_DEFUN([MOZ_ANDROID_GOOGLE_CLOUD_MESSAGING],
[
if test -n "$MOZ_ANDROID_GCM" ; then
MOZ_ANDROID_AAR(play-services-base, $ANDROID_GOOGLE_PLAY_SERVICES_VERSION, google, com/google/android/gms)
MOZ_ANDROID_AAR(play-services-basement, $ANDROID_GOOGLE_PLAY_SERVICES_VERSION, google, com/google/android/gms)
MOZ_ANDROID_AAR(play-services-gcm, $ANDROID_GOOGLE_PLAY_SERVICES_VERSION, google, com/google/android/gms)
MOZ_ANDROID_AAR(play-services-measurement, $ANDROID_GOOGLE_PLAY_SERVICES_VERSION, google, com/google/android/gms)
fi
])
AC_DEFUN([MOZ_ANDROID_INSTALL_TRACKING],
[
if test -n "$MOZ_INSTALL_TRACKING"; then
AC_SUBST(MOZ_INSTALL_TRACKING)
MOZ_ANDROID_AAR(play-services-ads, $ANDROID_GOOGLE_PLAY_SERVICES_VERSION, google, com/google/android/gms)
MOZ_ANDROID_AAR(play-services-basement, $ANDROID_GOOGLE_PLAY_SERVICES_VERSION, google, com/google/android/gms)
fi
])
dnl Configure an Android SDK.
dnl Arg 1: target SDK version, like 23.
dnl Arg 2: list of build-tools versions, like "23.0.3 23.0.1".
AC_DEFUN([MOZ_ANDROID_SDK],
[
MOZ_ARG_WITH_STRING(android-sdk,
[ --with-android-sdk=DIR
location where the Android SDK can be found (like ~/.mozbuild/android-sdk-linux)],
android_sdk_root=$withval)
android_sdk_root=${withval%/platforms/android-*}
case "$target" in
*-android*|*-linuxandroid*)
if test -z "$android_sdk_root" ; then
AC_MSG_ERROR([You must specify --with-android-sdk=/path/to/sdk when targeting Android.])
fi
# We were given an old-style
# --with-android-sdk=/path/to/sdk/platforms/android-*. We could warn, but
# we'll get compliance by forcing the issue.
if test -e "$withval"/source.properties ; then
AC_MSG_ERROR([Including platforms/android-* in --with-android-sdk arguments is deprecated. Use --with-android-sdk=$android_sdk_root.])
fi
android_target_sdk=$1
AC_MSG_CHECKING([for Android SDK platform version $android_target_sdk])
android_sdk=$android_sdk_root/platforms/android-$android_target_sdk
if ! test -e "$android_sdk/source.properties" ; then
AC_MSG_ERROR([You must download Android SDK platform version $android_target_sdk. Try |mach bootstrap|. (Looked for $android_sdk)])
fi
AC_MSG_RESULT([$android_sdk])
AC_MSG_CHECKING([for Android build-tools])
android_build_tools_base="$android_sdk_root"/build-tools
android_build_tools_version=""
for version in $2; do
android_build_tools="$android_build_tools_base"/$version
if test -d "$android_build_tools" -a -f "$android_build_tools/aapt"; then
android_build_tools_version=$version
AC_MSG_RESULT([$android_build_tools])
break
fi
done
if test "$android_build_tools_version" = ""; then
version=$(echo $2 | cut -d" " -f1)
AC_MSG_ERROR([You must install the Android build-tools version $version. Try |mach bootstrap|. (Looked for "$android_build_tools_base"/$version)])
fi
MOZ_PATH_PROG(ZIPALIGN, zipalign, :, [$android_build_tools])
MOZ_PATH_PROG(DX, dx, :, [$android_build_tools])
MOZ_PATH_PROG(AAPT, aapt, :, [$android_build_tools])
MOZ_PATH_PROG(AIDL, aidl, :, [$android_build_tools])
if test -z "$ZIPALIGN" -o "$ZIPALIGN" = ":"; then
AC_MSG_ERROR([The program zipalign was not found. Try |mach bootstrap|.])
fi
if test -z "$DX" -o "$DX" = ":"; then
AC_MSG_ERROR([The program dx was not found. Try |mach bootstrap|.])
fi
if test -z "$AAPT" -o "$AAPT" = ":"; then
AC_MSG_ERROR([The program aapt was not found. Try |mach bootstrap|.])
fi
if test -z "$AIDL" -o "$AIDL" = ":"; then
AC_MSG_ERROR([The program aidl was not found. Try |mach bootstrap|.])
fi
android_platform_tools="$android_sdk_root"/platform-tools
AC_MSG_CHECKING([for Android platform-tools])
if test -d "$android_platform_tools" -a -f "$android_platform_tools/adb"; then
AC_MSG_RESULT([$android_platform_tools])
else
AC_MSG_ERROR([You must install the Android platform-tools. Try |mach bootstrap|. (Looked for $android_platform_tools)])
fi
MOZ_PATH_PROG(ADB, adb, :, [$android_platform_tools])
if test -z "$ADB" -o "$ADB" = ":"; then
AC_MSG_ERROR([The program adb was not found. Try |mach bootstrap|.])
fi
android_tools="$android_sdk_root"/tools
AC_MSG_CHECKING([for Android tools])
if test -d "$android_tools" -a -f "$android_tools/emulator"; then
AC_MSG_RESULT([$android_tools])
else
AC_MSG_ERROR([You must install the Android tools. Try |mach bootstrap|. (Looked for $android_tools)])
fi
MOZ_PATH_PROG(EMULATOR, emulator, :, [$android_tools])
if test -z "$EMULATOR" -o "$EMULATOR" = ":"; then
AC_MSG_ERROR([The program emulator was not found. Try |mach bootstrap|.])
fi
ANDROID_TARGET_SDK="${android_target_sdk}"
ANDROID_SDK="${android_sdk}"
ANDROID_SDK_ROOT="${android_sdk_root}"
ANDROID_TOOLS="${android_tools}"
ANDROID_BUILD_TOOLS_VERSION="$android_build_tools_version"
AC_DEFINE_UNQUOTED(ANDROID_TARGET_SDK,$ANDROID_TARGET_SDK)
AC_SUBST(ANDROID_TARGET_SDK)
AC_SUBST(ANDROID_SDK_ROOT)
AC_SUBST(ANDROID_SDK)
AC_SUBST(ANDROID_TOOLS)
AC_SUBST(ANDROID_BUILD_TOOLS_VERSION)
MOZ_ANDROID_AAR(customtabs, $ANDROID_SUPPORT_LIBRARY_VERSION, android, com/android/support)
MOZ_ANDROID_AAR(appcompat-v7, $ANDROID_SUPPORT_LIBRARY_VERSION, android, com/android/support)
MOZ_ANDROID_AAR(support-vector-drawable, $ANDROID_SUPPORT_LIBRARY_VERSION, android, com/android/support)
MOZ_ANDROID_AAR(animated-vector-drawable, $ANDROID_SUPPORT_LIBRARY_VERSION, android, com/android/support)
MOZ_ANDROID_AAR(cardview-v7, $ANDROID_SUPPORT_LIBRARY_VERSION, android, com/android/support)
MOZ_ANDROID_AAR(design, $ANDROID_SUPPORT_LIBRARY_VERSION, android, com/android/support)
MOZ_ANDROID_AAR(recyclerview-v7, $ANDROID_SUPPORT_LIBRARY_VERSION, android, com/android/support)
MOZ_ANDROID_AAR(support-v4, $ANDROID_SUPPORT_LIBRARY_VERSION, android, com/android/support, REQUIRED_INTERNAL_IMPL)
MOZ_ANDROID_AAR(palette-v7, $ANDROID_SUPPORT_LIBRARY_VERSION, android, com/android/support)
ANDROID_SUPPORT_ANNOTATIONS_JAR="$ANDROID_SDK_ROOT/extras/android/m2repository/com/android/support/support-annotations/$ANDROID_SUPPORT_LIBRARY_VERSION/support-annotations-$ANDROID_SUPPORT_LIBRARY_VERSION.jar"
AC_MSG_CHECKING([for support-annotations JAR])
if ! test -e $ANDROID_SUPPORT_ANNOTATIONS_JAR ; then
AC_MSG_ERROR([You must download the support-annotations lib. Run the Android SDK tool and install the Android Support Repository under Extras. See https://developer.android.com/tools/extras/support-library.html for more info. (looked for $ANDROID_SUPPORT_ANNOTATIONS_JAR)])
fi
AC_MSG_RESULT([$ANDROID_SUPPORT_ANNOTATIONS_JAR])
AC_SUBST(ANDROID_SUPPORT_ANNOTATIONS_JAR)
ANDROID_SUPPORT_ANNOTATIONS_JAR_LIB=$ANDROID_SUPPORT_ANNOTATIONS_JAR
AC_SUBST(ANDROID_SUPPORT_ANNOTATIONS_JAR_LIB)
;;
esac
MOZ_ARG_WITH_STRING(android-min-sdk,
[ --with-android-min-sdk=[VER] Impose a minimum Firefox for Android SDK version],
[ MOZ_ANDROID_MIN_SDK_VERSION=$withval ])
MOZ_ARG_WITH_STRING(android-max-sdk,
[ --with-android-max-sdk=[VER] Impose a maximum Firefox for Android SDK version],
[ MOZ_ANDROID_MAX_SDK_VERSION=$withval ])
if test -n "$MOZ_ANDROID_MIN_SDK_VERSION"; then
if test -n "$MOZ_ANDROID_MAX_SDK_VERSION"; then
if test $MOZ_ANDROID_MAX_SDK_VERSION -lt $MOZ_ANDROID_MIN_SDK_VERSION ; then
AC_MSG_ERROR([--with-android-max-sdk must be at least the value of --with-android-min-sdk.])
fi
fi
if test $MOZ_ANDROID_MIN_SDK_VERSION -gt $ANDROID_TARGET_SDK ; then
AC_MSG_ERROR([--with-android-min-sdk is expected to be less than $ANDROID_TARGET_SDK])
fi
AC_DEFINE_UNQUOTED(MOZ_ANDROID_MIN_SDK_VERSION, $MOZ_ANDROID_MIN_SDK_VERSION)
AC_SUBST(MOZ_ANDROID_MIN_SDK_VERSION)
fi
if test -n "$MOZ_ANDROID_MAX_SDK_VERSION"; then
AC_DEFINE_UNQUOTED(MOZ_ANDROID_MAX_SDK_VERSION, $MOZ_ANDROID_MAX_SDK_VERSION)
AC_SUBST(MOZ_ANDROID_MAX_SDK_VERSION)
fi
])
+12
View File
@@ -28,12 +28,24 @@ MOZ_ARG_WITH_STRING(arch,
if test -z "$MOZ_ARCH"; then
dnl Defaults
case "${CPU_ARCH}-${OS_TARGET}" in
arm-Android)
MOZ_THUMB=yes
MOZ_ARCH=armv7-a
MOZ_FPU=vfp
MOZ_FLOAT_ABI=softfp
MOZ_ALIGN=no
;;
arm-Darwin)
MOZ_ARCH=toolchain-default
;;
esac
fi
if test "$MOZ_ARCH" = "armv6" -a "$OS_TARGET" = "Android"; then
MOZ_FPU=vfp
MOZ_FLOAT_ABI=softfp
fi
MOZ_ARG_WITH_STRING(thumb,
[ --with-thumb[[=yes|no|toolchain-default]]]
[ Use Thumb instruction set (-mthumb)],
+16 -8
View File
@@ -16,7 +16,7 @@ dnl set DEVELOPER_OPTIONS early; MOZ_DEFAULT_COMPILER is usually the first non-s
DEVELOPER_OPTIONS=,
DEVELOPER_OPTIONS=1)
dnl Default to MSVC for win32
dnl Default to MSVC for win32 and gcc-4.2 for darwin
dnl ==============================================================
if test -z "$CROSS_COMPILE"; then
case "$target" in
@@ -176,8 +176,8 @@ if test "$GNU_CC"; then
CFLAGS="$CFLAGS -ffunction-sections -fdata-sections"
CXXFLAGS="$CXXFLAGS -ffunction-sections -fdata-sections"
fi
CFLAGS="$CFLAGS -fno-math-errno -pipe"
CXXFLAGS="$CXXFLAGS -fno-exceptions -fno-math-errno -pipe"
CFLAGS="$CFLAGS -fno-math-errno"
CXXFLAGS="$CXXFLAGS -fno-exceptions -fno-math-errno"
if test "$CPU_ARCH" = "x86" -o "$CPU_ARCH" = "x86_64"; then
CFLAGS="$CFLAGS -msse2 -mfpmath=sse"
@@ -186,8 +186,7 @@ if test "$GNU_CC"; then
if test -z "$CLANG_CC"; then
case "$CC_VERSION" in
4.* | 5.* | 6.*)
AC_MSG_ERROR([Unsupported GCC version.])
4.* | 5.*)
;;
*)
# Lifetime Dead Store Elimination level 2 (default in GCC6+) breaks Gecko.
@@ -271,9 +270,18 @@ if test "$GNU_CC" -a "$GCC_USE_GNU_LD" -a -z "$DEVELOPER_OPTIONS"; then
fi
fi
# On some Unix systems, some file managers (e.g. Nautilus) can't start PIE programs
# so don't enable it by default.
MOZ_PIE=
# bionic in Android < 4.1 doesn't support PIE
# On OSX, the linker defaults to building PIE programs when targetting OSX 10.7+,
# but not when targetting OSX < 10.7. OSX < 10.7 doesn't support running PIE
# programs, so as long as support for OSX 10.6 is kept, we can't build PIE.
# Even after dropping 10.6 support, MOZ_PIE would not be useful since it's the
# default (and clang says the -pie option is not used).
# On other Unix systems, some file managers (Nautilus) can't start PIE programs
if test -n "$gonkdir" && test "$ANDROID_VERSION" -ge 16; then
MOZ_PIE=1
else
MOZ_PIE=
fi
MOZ_ARG_ENABLE_BOOL(pie,
[ --enable-pie Enable Position Independent Executables],
+6 -2
View File
@@ -114,7 +114,7 @@ esac
# Here we must recognize all the valid KERNEL-OS combinations.
maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
case $maybe_os in
nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | \
nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \
linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
knetbsd*-gnu* | netbsd*-gnu* | netbsd*-eabi* | \
kopensolaris*-gnu* | \
@@ -122,6 +122,10 @@ case $maybe_os in
os=-$maybe_os
basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
;;
android-linux)
os=-linux-android
basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown
;;
*)
basic_machine=`echo $1 | sed 's/-[^-]*$//'`
if [ $basic_machine != $1 ]
@@ -1385,7 +1389,7 @@ case $os in
| -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
| -chorusos* | -chorusrdb* | -cegcc* \
| -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
| -mingw32* | -mingw64* | -linux-gnu* \
| -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \
| -linux-newlib* | -linux-musl* | -linux-uclibc* \
| -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \
| -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
+5
View File
@@ -7,6 +7,11 @@ dnl disabling frame pointers in this architecture based on the configure
dnl options
AC_DEFUN([MOZ_SET_FRAMEPTR_FLAGS], [
case "$target" in
*android*)
unwind_tables="-funwind-tables"
;;
esac
if test "$GNU_CC"; then
MOZ_ENABLE_FRAME_PTR="-fno-omit-frame-pointer $unwind_tables"
MOZ_DISABLE_FRAME_PTR="-fomit-frame-pointer"
Loaded 100 of 45838 files, more files were not shown because too many files have changed in this diff. Show more