Compare commits
1 Commits
tags/commi
...
tags/BLACK
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
654a71e314 |
@@ -1,816 +0,0 @@
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Netscape Communications Corporation.
|
||||
# Portions created by the Initial Developer are Copyright (C) 1998
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Stephen Lamm
|
||||
# Benjamin Smedberg <bsmedberg@covad.net>
|
||||
# Chase Phillips <chase@mozilla.org>
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
# Build a mozilla application.
|
||||
#
|
||||
# To checkout and build a tree,
|
||||
# 1. cvs co mozilla/client.mk
|
||||
# 2. cd mozilla
|
||||
# 3. create your .mozconfig file with
|
||||
# mk_add_options MOZ_CO_PROJECT=suite,browser,mail,minimo,xulrunner
|
||||
# 4. gmake -f client.mk
|
||||
#
|
||||
# This script will pick up the CVSROOT from the CVS/Root file. If you wish
|
||||
# to use a different CVSROOT, you must set CVSROOT in your environment:
|
||||
#
|
||||
# export CVSROOT=:pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot
|
||||
# export CVSROOT=:pserver:username%somedomain.org@cvs.mozilla.org:/cvsroot
|
||||
#
|
||||
# You must specify which products/modules you wish to checkout, with
|
||||
# MOZ_CO_PROJECT, MOZ_CO_MODULE, and BUILD_MODULES variables.
|
||||
#
|
||||
# MOZ_CO_PROJECT possibilities include the following:
|
||||
# suite (Seamonkey suite)
|
||||
# browser (aka Firefox)
|
||||
# mail (aka Thunderbird)
|
||||
# minimo (small browser for devices)
|
||||
# composer (standalone composer, aka NVU)
|
||||
# calendar (aka Sunbird, use this to build the calendar extensions also)
|
||||
# xulrunner
|
||||
# macbrowser (aka Camino)
|
||||
#
|
||||
# Other common MOZ_CO_MODULE options include the following:
|
||||
# mozilla/other-licenses/libart_lgpl
|
||||
# mozilla/other-licenses/bsdiff
|
||||
# mozilla/tools/codesighs
|
||||
#
|
||||
# Other targets (gmake -f client.mk [targets...]),
|
||||
# checkout
|
||||
# build
|
||||
# clean (realclean is now the same as clean)
|
||||
# distclean
|
||||
#
|
||||
# See http://www.mozilla.org/build/ for more information.
|
||||
#
|
||||
# Options:
|
||||
# MOZ_OBJDIR - Destination object directory
|
||||
# MOZ_CO_DATE - Date tag to use for checkout (default: none)
|
||||
# MOZ_CO_MODULE - Module to checkout
|
||||
# MOZ_CVS_FLAGS - Flags to pass cvs (default: -q -z3)
|
||||
# MOZ_CO_FLAGS - Flags to pass after 'cvs co' (default: -P)
|
||||
# MOZ_MAKE_FLAGS - Flags to pass to $(MAKE)
|
||||
# MOZ_CO_LOCALES - localizations to pull (MOZ_CO_LOCALES="de-DE,pt-BR")
|
||||
# MOZ_LOCALE_DIRS - directories which contain localizations
|
||||
# LOCALES_CVSROOT - CVSROOT to use to pull localizations
|
||||
#
|
||||
|
||||
AVAILABLE_PROJECTS = \
|
||||
all \
|
||||
suite \
|
||||
toolkit \
|
||||
browser \
|
||||
mail \
|
||||
minimo \
|
||||
composer \
|
||||
calendar \
|
||||
xulrunner \
|
||||
macbrowser \
|
||||
$(NULL)
|
||||
|
||||
MODULES_core := \
|
||||
SeaMonkeyAll \
|
||||
mozilla/browser/config/version.txt \
|
||||
mozilla/mail/config/version.txt \
|
||||
mozilla/ipc/ipcd \
|
||||
mozilla/modules/libpr0n \
|
||||
mozilla/modules/libmar \
|
||||
mozilla/modules/libbz2 \
|
||||
mozilla/accessible \
|
||||
mozilla/security/manager \
|
||||
mozilla/toolkit \
|
||||
mozilla/storage \
|
||||
mozilla/db/sqlite3 \
|
||||
$(NULL)
|
||||
|
||||
LOCALES_core := \
|
||||
netwerk \
|
||||
dom \
|
||||
$(NULL)
|
||||
|
||||
MODULES_toolkit := \
|
||||
$(MODULES_core) \
|
||||
mozilla/chrome \
|
||||
$(NULL)
|
||||
|
||||
LOCALES_toolkit := \
|
||||
$(LOCALES_core) \
|
||||
toolkit \
|
||||
security/manager \
|
||||
$(NULL)
|
||||
|
||||
MODULES_suite := \
|
||||
$(MODULES_core) \
|
||||
mozilla/suite \
|
||||
$(NULL)
|
||||
|
||||
LOCALES_suite := \
|
||||
$(LOCALES_core) \
|
||||
$(NULL)
|
||||
|
||||
MODULES_browser := \
|
||||
$(MODULES_toolkit) \
|
||||
mozilla/browser \
|
||||
mozilla/other-licenses/branding/firefox \
|
||||
mozilla/other-licenses/7zstub/firefox \
|
||||
$(NULL)
|
||||
|
||||
LOCALES_browser := \
|
||||
$(LOCALES_toolkit) \
|
||||
browser \
|
||||
other-licenses/branding/firefox \
|
||||
$(NULL)
|
||||
|
||||
BOOTSTRAP_browser := mozilla/browser/config/mozconfig
|
||||
|
||||
MODULES_minimo := \
|
||||
$(MODULES_toolkit) \
|
||||
mozilla/minimo \
|
||||
$(NULL)
|
||||
|
||||
MODULES_mail := \
|
||||
$(MODULES_toolkit) \
|
||||
mozilla/mail \
|
||||
mozilla/other-licenses/branding/thunderbird \
|
||||
mozilla/other-licenses/7zstub/thunderbird \
|
||||
$(NULL)
|
||||
|
||||
LOCALES_mail := \
|
||||
$(LOCALES_toolkit) \
|
||||
mail \
|
||||
other-licenses/branding/thunderbird \
|
||||
editor/ui \
|
||||
$(NULL)
|
||||
|
||||
BOOTSTRAP_mail := mozilla/mail/config/mozconfig
|
||||
|
||||
MODULES_composer := \
|
||||
$(MODULES_toolkit) \
|
||||
mozilla/composer \
|
||||
$(NULL)
|
||||
|
||||
MODULES_calendar := \
|
||||
$(MODULES_toolkit) \
|
||||
mozilla/storage \
|
||||
mozilla/db/sqlite3 \
|
||||
mozilla/calendar \
|
||||
$(NULL)
|
||||
|
||||
BOOTSTRAP_calendar := mozilla/calendar/sunbird/config/mozconfig
|
||||
|
||||
MODULES_xulrunner := \
|
||||
$(MODULES_toolkit) \
|
||||
mozilla/xulrunner \
|
||||
$(NULL)
|
||||
|
||||
LOCALES_xulrunner := \
|
||||
$(LOCALES_toolkit) \
|
||||
$(NULL)
|
||||
|
||||
BOOTSTRAP_xulrunner := mozilla/xulrunner/config/mozconfig
|
||||
|
||||
MODULES_macbrowser := \
|
||||
$(MODULES_core) \
|
||||
mozilla/camino \
|
||||
$(NULL)
|
||||
|
||||
BOOTSTRAP_macbrowser := mozilla/camino/config/mozconfig
|
||||
|
||||
MODULES_all := \
|
||||
mozilla/other-licenses/bsdiff \
|
||||
mozilla/other-licenses/libart_lgpl \
|
||||
mozilla/tools/trace-malloc \
|
||||
mozilla/tools/jprof \
|
||||
mozilla/tools/codesighs \
|
||||
mozilla/tools/update-packaging \
|
||||
mozilla/other-licenses/branding \
|
||||
mozilla/other-licenses/7zstub \
|
||||
$(NULL)
|
||||
|
||||
#######################################################################
|
||||
# Checkout Tags
|
||||
#
|
||||
# For branches, uncomment the MOZ_CO_TAG line with the proper tag,
|
||||
# and commit this file on that tag.
|
||||
MOZ_CO_TAG = MOZILLA_1_8_BRANCH
|
||||
NSPR_CO_TAG = MOZILLA_1_8_BRANCH
|
||||
NSS_CO_TAG = MOZILLA_1_8_BRANCH
|
||||
LDAPCSDK_CO_TAG = MOZILLA_1_8_BRANCH
|
||||
LOCALES_CO_TAG = MOZILLA_1_8_BRANCH
|
||||
|
||||
BUILD_MODULES = all
|
||||
|
||||
#######################################################################
|
||||
# Defines
|
||||
#
|
||||
CVS = cvs
|
||||
comma := ,
|
||||
|
||||
CWD := $(shell pwd)
|
||||
|
||||
ifeq "$(CWD)" "/"
|
||||
CWD := /.
|
||||
endif
|
||||
|
||||
ifneq (, $(wildcard client.mk))
|
||||
# Ran from mozilla directory
|
||||
ROOTDIR := $(shell dirname $(CWD))
|
||||
TOPSRCDIR := $(CWD)
|
||||
else
|
||||
# Ran from mozilla/.. directory (?)
|
||||
ROOTDIR := $(CWD)
|
||||
TOPSRCDIR := $(CWD)/mozilla
|
||||
endif
|
||||
|
||||
# on os2, TOPSRCDIR may have two forward slashes in a row, which doesn't
|
||||
# work; replace first instance with one forward slash
|
||||
TOPSRCDIR := $(shell echo "$(TOPSRCDIR)" | sed -e 's%//%/%')
|
||||
|
||||
ifndef TOPSRCDIR_MOZ
|
||||
TOPSRCDIR_MOZ=$(TOPSRCDIR)
|
||||
endif
|
||||
|
||||
# if ROOTDIR equals only drive letter (i.e. "C:"), set to "/"
|
||||
DIRNAME := $(shell echo "$(ROOTDIR)" | sed -e 's/^.://')
|
||||
ifeq ($(DIRNAME),)
|
||||
ROOTDIR := /.
|
||||
endif
|
||||
|
||||
AUTOCONF := autoconf
|
||||
MKDIR := mkdir
|
||||
SH := /bin/sh
|
||||
ifndef MAKE
|
||||
MAKE := gmake
|
||||
endif
|
||||
|
||||
CONFIG_GUESS_SCRIPT := $(wildcard $(TOPSRCDIR)/build/autoconf/config.guess)
|
||||
ifdef CONFIG_GUESS_SCRIPT
|
||||
CONFIG_GUESS = $(shell $(CONFIG_GUESS_SCRIPT))
|
||||
else
|
||||
_IS_FIRST_CHECKOUT := 1
|
||||
endif
|
||||
|
||||
####################################
|
||||
# CVS
|
||||
|
||||
# Add the CVS root to CVS_FLAGS if needed
|
||||
CVS_ROOT_IN_TREE := $(shell cat $(TOPSRCDIR)/CVS/Root 2>/dev/null)
|
||||
ifneq ($(CVS_ROOT_IN_TREE),)
|
||||
ifneq ($(CVS_ROOT_IN_TREE),$(CVSROOT))
|
||||
CVS_FLAGS := -d $(CVS_ROOT_IN_TREE)
|
||||
endif
|
||||
endif
|
||||
|
||||
CVS_CO_DATE_FLAGS = $(if $(MOZ_CO_DATE),-D "$(MOZ_CO_DATE)")
|
||||
CVSCO = $(CVS) $(CVS_FLAGS) co $(MOZ_CO_FLAGS) $(if $(MOZ_CO_TAG),-r $(MOZ_CO_TAG)) $(CVS_CO_DATE_FLAGS)
|
||||
|
||||
CVSCO_LOGFILE := $(ROOTDIR)/cvsco.log
|
||||
CVSCO_LOGFILE := $(shell echo $(CVSCO_LOGFILE) | sed s%//%/%)
|
||||
|
||||
# if LOCALES_CVSROOT is not specified, set it here
|
||||
# (and let mozconfig override it)
|
||||
LOCALES_CVSROOT ?= :pserver:anonymous@cvs-mirror.mozilla.org:/l10n
|
||||
|
||||
####################################
|
||||
# Load mozconfig Options
|
||||
|
||||
# See build pages, http://www.mozilla.org/build/ for how to set up mozconfig.
|
||||
|
||||
MOZCONFIG_LOADER := mozilla/build/autoconf/mozconfig2client-mk
|
||||
MOZCONFIG_FINDER := mozilla/build/autoconf/mozconfig-find
|
||||
MOZCONFIG_MODULES := mozilla/build/unix/modules.mk mozilla/build/unix/uniq.pl
|
||||
run_for_side_effects := \
|
||||
$(shell cd $(ROOTDIR); \
|
||||
if test "$(_IS_FIRST_CHECKOUT)"; then \
|
||||
$(CVSCO) $(MOZCONFIG_FINDER) $(MOZCONFIG_LOADER) $(MOZCONFIG_MODULES); \
|
||||
else true; \
|
||||
fi; \
|
||||
$(MOZCONFIG_LOADER) $(TOPSRCDIR) mozilla/.mozconfig.mk > mozilla/.mozconfig.out)
|
||||
include $(TOPSRCDIR)/.mozconfig.mk
|
||||
include $(TOPSRCDIR)/build/unix/modules.mk
|
||||
|
||||
####################################
|
||||
# Options that may come from mozconfig
|
||||
|
||||
MOZ_PROJECT_LIST := $(subst $(comma), ,$(MOZ_CO_PROJECT))
|
||||
|
||||
ifneq (,$(filter-out $(AVAILABLE_PROJECTS),$(MOZ_PROJECT_LIST)))
|
||||
$(error MOZ_CO_PROJECT contains an unrecognized project.)
|
||||
endif
|
||||
|
||||
ifeq (all,$(filter all,$(MOZ_PROJECT_LIST)))
|
||||
MOZ_PROJECT_LIST := $(AVAILABLE_PROJECTS)
|
||||
endif
|
||||
|
||||
MOZ_MODULE_LIST := $(subst $(comma), ,$(MOZ_CO_MODULE)) $(foreach project,$(MOZ_PROJECT_LIST),$(MODULES_$(project)))
|
||||
LOCALE_DIRS := $(MOZ_LOCALE_DIRS) $(foreach project,$(MOZ_PROJECT_LIST),$(LOCALES_$(project)))
|
||||
|
||||
MOZCONFIG_MODULES += $(foreach project,$(MOZ_PROJECT_LIST),$(BOOTSTRAP_$(project)))
|
||||
|
||||
# Using $(sort) here because it also removes duplicate entries.
|
||||
MOZ_MODULE_LIST := $(sort $(MOZ_MODULE_LIST))
|
||||
LOCALE_DIRS := $(sort $(LOCALE_DIRS))
|
||||
MOZCONFIG_MODULES := $(sort $(MOZCONFIG_MODULES))
|
||||
|
||||
# Change CVS flags if anonymous root is requested
|
||||
ifdef MOZ_CO_USE_MIRROR
|
||||
CVS_FLAGS := -d :pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot
|
||||
endif
|
||||
|
||||
# MOZ_CVS_FLAGS - Basic CVS flags
|
||||
ifeq "$(origin MOZ_CVS_FLAGS)" "undefined"
|
||||
CVS_FLAGS := $(CVS_FLAGS) -q -z 3
|
||||
else
|
||||
CVS_FLAGS := $(MOZ_CVS_FLAGS)
|
||||
endif
|
||||
|
||||
ifdef MOZ_OBJDIR
|
||||
OBJDIR := $(MOZ_OBJDIR)
|
||||
MOZ_MAKE := $(MAKE) $(MOZ_MAKE_FLAGS) -C $(OBJDIR)
|
||||
else
|
||||
OBJDIR := $(TOPSRCDIR)
|
||||
MOZ_MAKE := $(MAKE) $(MOZ_MAKE_FLAGS)
|
||||
endif
|
||||
|
||||
####################################
|
||||
# CVS defines for NSS
|
||||
#
|
||||
NSS_CO_MODULE = \
|
||||
mozilla/security/nss \
|
||||
mozilla/security/coreconf \
|
||||
$(NULL)
|
||||
|
||||
NSS_CO_FLAGS := -P
|
||||
ifdef MOZ_CO_FLAGS
|
||||
NSS_CO_FLAGS := $(MOZ_CO_FLAGS)
|
||||
endif
|
||||
NSS_CO_FLAGS := $(NSS_CO_FLAGS) $(if $(NSS_CO_TAG),-r $(NSS_CO_TAG),-A)
|
||||
|
||||
# Cannot pull static tags by date
|
||||
ifeq ($(NSS_CO_TAG),NSS_CLIENT_TAG)
|
||||
CVSCO_NSS = $(CVS) $(CVS_FLAGS) co $(NSS_CO_FLAGS) $(NSS_CO_MODULE)
|
||||
else
|
||||
CVSCO_NSS = $(CVS) $(CVS_FLAGS) co $(NSS_CO_FLAGS) $(CVS_CO_DATE_FLAGS) $(NSS_CO_MODULE)
|
||||
endif
|
||||
|
||||
####################################
|
||||
# CVS defines for NSPR
|
||||
#
|
||||
NSPR_CO_MODULE = mozilla/nsprpub
|
||||
NSPR_CO_FLAGS := -P
|
||||
ifdef MOZ_CO_FLAGS
|
||||
NSPR_CO_FLAGS := $(MOZ_CO_FLAGS)
|
||||
endif
|
||||
NSPR_CO_FLAGS := $(NSPR_CO_FLAGS) $(if $(NSPR_CO_TAG),-r $(NSPR_CO_TAG),-A)
|
||||
|
||||
# Cannot pull static tags by date
|
||||
ifeq ($(NSPR_CO_TAG),NSPRPUB_CLIENT_TAG)
|
||||
CVSCO_NSPR = $(CVS) $(CVS_FLAGS) co $(NSPR_CO_FLAGS) $(NSPR_CO_MODULE)
|
||||
else
|
||||
CVSCO_NSPR = $(CVS) $(CVS_FLAGS) co $(NSPR_CO_FLAGS) $(CVS_CO_DATE_FLAGS) $(NSPR_CO_MODULE)
|
||||
endif
|
||||
|
||||
####################################
|
||||
# CVS defines for the C LDAP SDK
|
||||
#
|
||||
LDAPCSDK_CO_MODULE = mozilla/directory/c-sdk
|
||||
LDAPCSDK_CO_FLAGS := -P
|
||||
ifdef MOZ_CO_FLAGS
|
||||
LDAPCSDK_CO_FLAGS := $(MOZ_CO_FLAGS)
|
||||
endif
|
||||
LDAPCSDK_CO_FLAGS := $(LDAPCSDK_CO_FLAGS) $(if $(LDAPCSDK_CO_TAG),-r $(LDAPCSDK_CO_TAG),-A)
|
||||
CVSCO_LDAPCSDK = $(CVS) $(CVS_FLAGS) co $(LDAPCSDK_CO_FLAGS) $(CVS_CO_DATE_FLAGS) $(LDAPCSDK_CO_MODULE)
|
||||
|
||||
####################################
|
||||
# CVS defines for standalone modules
|
||||
#
|
||||
ifeq ($(BUILD_MODULES),all)
|
||||
CHECKOUT_STANDALONE := true
|
||||
CHECKOUT_STANDALONE_NOSUBDIRS := true
|
||||
else
|
||||
STANDALONE_CO_MODULE := $(filter-out $(NSPRPUB_DIR) security directory/c-sdk, $(BUILD_MODULE_CVS))
|
||||
STANDALONE_CO_MODULE += allmakefiles.sh client.mk aclocal.m4 configure configure.in
|
||||
STANDALONE_CO_MODULE += Makefile.in
|
||||
|
||||
MOZ_MODULE_LIST += $(addprefix mozilla/,$(STANDALONE_CO_MODULE))
|
||||
NOSUBDIRS_MODULE := $(addprefix mozilla/,$(BUILD_MODULE_CVS_NS))
|
||||
|
||||
ifeq (,$(filter $(NSPRPUB_DIR), $(BUILD_MODULE_CVS))$(MOZ_CO_PROJECT))
|
||||
CVSCO_NSPR :=
|
||||
endif
|
||||
ifeq (,$(filter security security/manager, $(BUILD_MODULE_CVS))$(MOZ_CO_PROJECT))
|
||||
CVSCO_NSS :=
|
||||
endif
|
||||
ifeq (,$(filter directory/c-sdk, $(BUILD_MODULE_CVS))$(MOZ_CO_PROJECT))
|
||||
CVSCO_LDAPCSDK :=
|
||||
endif
|
||||
endif
|
||||
|
||||
####################################
|
||||
# Error on obsolete variables.
|
||||
#
|
||||
|
||||
ifdef MOZ_MAPINFO
|
||||
$(warning MOZ_MAPINFO is obsolete, use MOZ_CO_MODULE=mozilla/tools/codesighs instead.)
|
||||
MOZ_MODULE_LIST += mozilla/tools/codesighs
|
||||
endif
|
||||
ifdef MOZ_INTERNAL_LIBART_LGPL
|
||||
$(error MOZ_INTERNAL_LIBART_LGPL is obsolete, use MOZ_CO_MODULE=mozilla/other-licenses/libart_lgpl instead.)
|
||||
endif
|
||||
ifdef MOZ_PHOENIX
|
||||
$(warning MOZ_PHOENIX is obsolete.)
|
||||
MOZ_MODULE_LIST += $(MODULES_browser)
|
||||
# $(error MOZ_PHOENIX is obsolete, use MOZ_CO_PROJECT=browser and --enable-application=browser)
|
||||
endif
|
||||
ifdef MOZ_THUNDERBIRD
|
||||
$(warning MOZ_THUNDERBIRD is obsolete.)
|
||||
MOZ_MODULE_LIST += $(MODULES_mail)
|
||||
# $(error MOZ_THUNDERBIRD is obsolete, use MOZ_CO_PROJECT=mail and --enable-application=mail)
|
||||
endif
|
||||
|
||||
###################################
|
||||
# Checkout main modules
|
||||
#
|
||||
|
||||
# sort is used to remove duplicates. SeaMonkeyAll is special-cased to
|
||||
# checkout last, because if you check it out first, there is a sticky
|
||||
# tag left over from checking out the LDAP SDK, which causes files in
|
||||
# the root directory to be missed.
|
||||
MOZ_MODULE_LIST := $(sort $(filter-out SeaMonkeyAll,$(MOZ_MODULE_LIST))) $(firstword $(filter SeaMonkeyAll,$(MOZ_MODULE_LIST)))
|
||||
|
||||
MODULES_CO_FLAGS := -P
|
||||
ifdef MOZ_CO_FLAGS
|
||||
MODULES_CO_FLAGS := $(MOZ_CO_FLAGS)
|
||||
endif
|
||||
MODULES_CO_FLAGS := $(MODULES_CO_FLAGS) $(if $(MOZ_CO_TAG),-r $(MOZ_CO_TAG),-A)
|
||||
|
||||
CVSCO_MODULES_NS = $(CVS) $(CVS_FLAGS) co $(MODULES_CO_FLAGS) $(CVS_CO_DATE_FLAGS) -l $(NOSUBDIRS_MODULE)
|
||||
|
||||
ifeq (,$(strip $(MOZ_MODULE_LIST)))
|
||||
FASTUPDATE_MODULES = $(error No modules or projects were specified. Use MOZ_CO_PROJECT to specify a project for checkout.)
|
||||
CHECKOUT_MODULES = $(error No modules or projects were specified. Use MOZ_CO_PROJECT to specify a project for checkout.)
|
||||
else
|
||||
FASTUPDATE_MODULES := fast_update $(CVS) $(CVS_FLAGS) co $(MODULES_CO_FLAGS) $(CVS_CO_DATE_FLAGS) $(MOZ_MODULE_LIST)
|
||||
CHECKOUT_MODULES := $(foreach module,$(MOZ_MODULE_LIST),cvs_co $(CVS) $(CVS_FLAGS) co $(MODULES_CO_FLAGS) $(CVS_CO_DATE_FLAGS) $(module);)
|
||||
endif
|
||||
ifeq (,$(NOSUBDIRS_MODULE))
|
||||
FASTUPDATE_MODULES_NS := true
|
||||
CHECKOUT_MODULES_NS := true
|
||||
else
|
||||
FASTUPDATE_MODULES_NS := fast_update $(CVSCO_MODULES_NS)
|
||||
CHECKOUT_MODULES_NS := cvs_co $(CVSCO_MODULES_NS)
|
||||
endif
|
||||
|
||||
###################################
|
||||
# CVS defines for locales
|
||||
#
|
||||
|
||||
LOCALES_CO_FLAGS := -P
|
||||
ifdef MOZ_CO_FLAGS
|
||||
LOCALES_CO_FLAGS := $(MOZ_CO_FLAGS)
|
||||
endif
|
||||
LOCALES_CO_FLAGS := $(LOCALES_CO_FLAGS) $(if $(LOCALES_CO_TAG),-r $(LOCALES_CO_TAG),-A)
|
||||
|
||||
ifndef MOZ_CO_LOCALES
|
||||
FASTUPDATE_LOCALES := true
|
||||
CHECKOUT_LOCALES := true
|
||||
else
|
||||
|
||||
override MOZ_CO_LOCALES := $(subst $(comma), ,$(MOZ_CO_LOCALES))
|
||||
|
||||
ifeq (all,$(MOZ_CO_LOCALES))
|
||||
MOZCONFIG_MODULES += $(foreach project,$(MOZ_PROJECT_LIST),mozilla/$(project)/locales/all-locales)
|
||||
|
||||
LOCALE_CO_DIRS := $(sort $(foreach project,$(MOZ_PROJECT_LIST),$(foreach locale,$(shell cat mozilla/$(project)/locales/all-locales),$(foreach dir,$(LOCALES_$(project)),l10n/$(locale)/$(dir)))))
|
||||
else # MOZ_CO_LOCALES != all
|
||||
LOCALE_CO_DIRS = $(sort $(foreach locale,$(MOZ_CO_LOCALES),$(foreach dir,$(LOCALE_DIRS),l10n/$(locale)/$(dir))))
|
||||
endif
|
||||
|
||||
CVSCO_LOCALES := $(CVS) $(CVS_FLAGS) -d $(LOCALES_CVSROOT) co $(LOCALES_CO_FLAGS) $(LOCALE_CO_DIRS)
|
||||
|
||||
FASTUPDATE_LOCALES := fast_update $(CVSCO_LOCALES)
|
||||
CHECKOUT_LOCALES := cvs_co $(CVSCO_LOCALES)
|
||||
endif #MOZ_CO_LOCALES
|
||||
|
||||
#######################################################################
|
||||
# Rules
|
||||
#
|
||||
|
||||
# Print out any options loaded from mozconfig.
|
||||
all build checkout clean depend distclean export libs install realclean::
|
||||
@if test -f .mozconfig.out; then \
|
||||
cat .mozconfig.out; \
|
||||
rm -f .mozconfig.out; \
|
||||
else true; \
|
||||
fi
|
||||
|
||||
ifdef _IS_FIRST_CHECKOUT
|
||||
all:: checkout build
|
||||
else
|
||||
all:: checkout alldep
|
||||
endif
|
||||
|
||||
# Windows equivalents
|
||||
pull_all: checkout
|
||||
build_all: build
|
||||
build_all_dep: alldep
|
||||
build_all_depend: alldep
|
||||
clobber clobber_all: clean
|
||||
pull_and_build_all: checkout alldep
|
||||
|
||||
# Do everything from scratch
|
||||
everything: checkout clean build
|
||||
|
||||
####################################
|
||||
# CVS checkout
|
||||
#
|
||||
checkout::
|
||||
# @: Backup the last checkout log.
|
||||
@if test -f $(CVSCO_LOGFILE) ; then \
|
||||
mv $(CVSCO_LOGFILE) $(CVSCO_LOGFILE).old; \
|
||||
else true; \
|
||||
fi
|
||||
ifdef RUN_AUTOCONF_LOCALLY
|
||||
@echo "Removing local configures" ; \
|
||||
cd $(ROOTDIR) && \
|
||||
$(RM) -f mozilla/configure mozilla/nsprpub/configure \
|
||||
mozilla/directory/c-sdk/configure
|
||||
endif
|
||||
@echo "checkout start: "`date` | tee $(CVSCO_LOGFILE)
|
||||
@echo '$(CVSCO) $(CVS_CO_DATE_FLAGS) mozilla/client.mk $(MOZCONFIG_MODULES)'; \
|
||||
cd $(ROOTDIR) && \
|
||||
$(CVSCO) $(CVS_CO_DATE_FLAGS) mozilla/client.mk $(MOZCONFIG_MODULES)
|
||||
@cd $(ROOTDIR) && $(MAKE) -f mozilla/client.mk real_checkout
|
||||
|
||||
# Start the checkout. Split the output to the tty and a log file.
|
||||
|
||||
real_checkout:
|
||||
@set -e; \
|
||||
cvs_co() { set -e; echo "$$@" ; \
|
||||
"$$@" 2>&1 | tee -a $(CVSCO_LOGFILE); }; \
|
||||
cvs_co $(CVSCO_NSPR); \
|
||||
cvs_co $(CVSCO_NSS); \
|
||||
cvs_co $(CVSCO_LDAPCSDK); \
|
||||
$(CHECKOUT_MODULES) \
|
||||
$(CHECKOUT_MODULES_NS); \
|
||||
$(CHECKOUT_LOCALES);
|
||||
@echo "checkout finish: "`date` | tee -a $(CVSCO_LOGFILE)
|
||||
# update the NSS checkout timestamp
|
||||
@if test `egrep -c '^(U|C) mozilla/security/(nss|coreconf)' $(CVSCO_LOGFILE) 2>/dev/null` != 0; then \
|
||||
touch $(TOPSRCDIR)/security/manager/.nss.checkout; \
|
||||
fi
|
||||
# @: Check the log for conflicts. ;
|
||||
@conflicts=`egrep "^C " $(CVSCO_LOGFILE)` ;\
|
||||
if test "$$conflicts" ; then \
|
||||
echo "$(MAKE): *** Conflicts during checkout." ;\
|
||||
echo "$$conflicts" ;\
|
||||
echo "$(MAKE): Refer to $(CVSCO_LOGFILE) for full log." ;\
|
||||
false; \
|
||||
else true; \
|
||||
fi
|
||||
ifdef RUN_AUTOCONF_LOCALLY
|
||||
@echo Generating configures using $(AUTOCONF) ; \
|
||||
cd $(TOPSRCDIR) && $(AUTOCONF) && \
|
||||
cd $(TOPSRCDIR)/nsprpub && $(AUTOCONF) && \
|
||||
cd $(TOPSRCDIR)/directory/c-sdk && $(AUTOCONF)
|
||||
endif
|
||||
|
||||
fast-update:
|
||||
# @: Backup the last checkout log.
|
||||
@if test -f $(CVSCO_LOGFILE) ; then \
|
||||
mv $(CVSCO_LOGFILE) $(CVSCO_LOGFILE).old; \
|
||||
else true; \
|
||||
fi
|
||||
ifdef RUN_AUTOCONF_LOCALLY
|
||||
@echo "Removing local configures" ; \
|
||||
cd $(ROOTDIR) && \
|
||||
$(RM) -f mozilla/configure mozilla/nsprpub/configure \
|
||||
mozilla/directory/c-sdk/configure
|
||||
endif
|
||||
@echo "checkout start: "`date` | tee $(CVSCO_LOGFILE)
|
||||
@echo '$(CVSCO) mozilla/client.mk $(MOZCONFIG_MODULES)'; \
|
||||
cd $(ROOTDIR) && \
|
||||
$(CVSCO) mozilla/client.mk $(MOZCONFIG_MODULES)
|
||||
@cd $(TOPSRCDIR) && \
|
||||
$(MAKE) -f client.mk real_fast-update
|
||||
|
||||
# Start the update. Split the output to the tty and a log file.
|
||||
real_fast-update:
|
||||
@set -e; \
|
||||
fast_update() { set -e; config/cvsco-fast-update.pl $$@ 2>&1 | tee -a $(CVSCO_LOGFILE); }; \
|
||||
cvs_co() { set -e; echo "$$@" ; \
|
||||
"$$@" 2>&1 | tee -a $(CVSCO_LOGFILE); }; \
|
||||
fast_update $(CVSCO_NSPR); \
|
||||
cd $(ROOTDIR); \
|
||||
cvs_co $(CVSCO_NSS); \
|
||||
cd mozilla; \
|
||||
fast_update $(CVSCO_LDAPCSDK); \
|
||||
$(FASTUPDATE_MODULES); \
|
||||
$(FASTUPDATE_MODULES_NS); \
|
||||
$(FASTUPDATE_LOCALES);
|
||||
@echo "fast_update finish: "`date` | tee -a $(CVSCO_LOGFILE)
|
||||
# update the NSS checkout timestamp
|
||||
@if test `egrep -c '^(U|C) mozilla/security/(nss|coreconf)' $(CVSCO_LOGFILE) 2>/dev/null` != 0; then \
|
||||
touch $(TOPSRCDIR)/security/manager/.nss.checkout; \
|
||||
fi
|
||||
# @: Check the log for conflicts. ;
|
||||
@conflicts=`egrep "^C " $(CVSCO_LOGFILE)` ;\
|
||||
if test "$$conflicts" ; then \
|
||||
echo "$(MAKE): *** Conflicts during fast-update." ;\
|
||||
echo "$$conflicts" ;\
|
||||
echo "$(MAKE): Refer to $(CVSCO_LOGFILE) for full log." ;\
|
||||
false; \
|
||||
else true; \
|
||||
fi
|
||||
ifdef RUN_AUTOCONF_LOCALLY
|
||||
@echo Generating configures using $(AUTOCONF) ; \
|
||||
cd $(TOPSRCDIR) && $(AUTOCONF) && \
|
||||
cd $(TOPSRCDIR)/nsprpub && $(AUTOCONF) && \
|
||||
cd $(TOPSRCDIR)/directory/c-sdk && $(AUTOCONF)
|
||||
endif
|
||||
|
||||
####################################
|
||||
# Web configure
|
||||
|
||||
WEBCONFIG_FILE := $(HOME)/.mozconfig
|
||||
|
||||
MOZCONFIG2CONFIGURATOR := build/autoconf/mozconfig2configurator
|
||||
webconfig:
|
||||
@cd $(TOPSRCDIR); \
|
||||
url=`$(MOZCONFIG2CONFIGURATOR) $(TOPSRCDIR)`; \
|
||||
echo Running mozilla with the following url: ;\
|
||||
echo ;\
|
||||
echo $$url ;\
|
||||
mozilla -remote "openURL($$url)" || \
|
||||
netscape -remote "openURL($$url)" || \
|
||||
mozilla $$url || \
|
||||
netscape $$url ;\
|
||||
echo ;\
|
||||
echo 1. Fill out the form on the browser. ;\
|
||||
echo 2. Save the results to $(WEBCONFIG_FILE)
|
||||
|
||||
#####################################################
|
||||
# First Checkout
|
||||
|
||||
ifdef _IS_FIRST_CHECKOUT
|
||||
# First time, do build target in a new process to pick up new files.
|
||||
build::
|
||||
$(MAKE) -f $(TOPSRCDIR)/client.mk build
|
||||
else
|
||||
|
||||
#####################################################
|
||||
# After First Checkout
|
||||
|
||||
|
||||
####################################
|
||||
# Configure
|
||||
|
||||
CONFIG_STATUS := $(wildcard $(OBJDIR)/config.status)
|
||||
CONFIG_CACHE := $(wildcard $(OBJDIR)/config.cache)
|
||||
|
||||
ifdef RUN_AUTOCONF_LOCALLY
|
||||
EXTRA_CONFIG_DEPS := \
|
||||
$(TOPSRCDIR)/aclocal.m4 \
|
||||
$(wildcard $(TOPSRCDIR)/build/autoconf/*.m4) \
|
||||
$(NULL)
|
||||
|
||||
$(TOPSRCDIR)/configure: $(TOPSRCDIR)/configure.in $(EXTRA_CONFIG_DEPS)
|
||||
@echo Generating $@ using autoconf
|
||||
cd $(TOPSRCDIR); $(AUTOCONF)
|
||||
endif
|
||||
|
||||
CONFIG_STATUS_DEPS := \
|
||||
$(TOPSRCDIR)/configure \
|
||||
$(TOPSRCDIR)/allmakefiles.sh \
|
||||
$(TOPSRCDIR)/.mozconfig.mk \
|
||||
$(wildcard $(TOPSRCDIR)/nsprpub/configure) \
|
||||
$(wildcard $(TOPSRCDIR)/directory/c-sdk/configure) \
|
||||
$(wildcard $(TOPSRCDIR)/mailnews/makefiles) \
|
||||
$(wildcard $(TOPSRCDIR)/themes/makefiles) \
|
||||
$(wildcard $(TOPSRCDIR)/config/milestone.txt) \
|
||||
$(wildcard $(TOPSRCDIR)/config/chrome-versions.sh) \
|
||||
$(NULL)
|
||||
|
||||
# configure uses the program name to determine @srcdir@. Calling it without
|
||||
# $(TOPSRCDIR) will set @srcdir@ to "."; otherwise, it is set to the full
|
||||
# path of $(TOPSRCDIR).
|
||||
ifeq ($(TOPSRCDIR),$(OBJDIR))
|
||||
CONFIGURE := ./configure
|
||||
else
|
||||
CONFIGURE := $(TOPSRCDIR)/configure
|
||||
endif
|
||||
|
||||
ifdef MOZ_TOOLS
|
||||
CONFIGURE := $(TOPSRCDIR)/configure
|
||||
endif
|
||||
|
||||
configure:
|
||||
@if test ! -d $(OBJDIR); then $(MKDIR) $(OBJDIR); else true; fi
|
||||
@echo cd $(OBJDIR);
|
||||
@echo $(CONFIGURE) $(CONFIGURE_ARGS)
|
||||
@cd $(OBJDIR) && $(CONFIGURE_ENV_ARGS) $(CONFIGURE) $(CONFIGURE_ARGS) \
|
||||
|| ( echo "*** Fix above errors and then restart with\
|
||||
\"$(MAKE) -f client.mk build\"" && exit 1 )
|
||||
@touch $(OBJDIR)/Makefile
|
||||
|
||||
$(OBJDIR)/Makefile $(OBJDIR)/config.status: $(CONFIG_STATUS_DEPS)
|
||||
@$(MAKE) -f $(TOPSRCDIR)/client.mk configure
|
||||
|
||||
ifdef CONFIG_STATUS
|
||||
$(OBJDIR)/config/autoconf.mk: $(TOPSRCDIR)/config/autoconf.mk.in
|
||||
cd $(OBJDIR); \
|
||||
CONFIG_FILES=config/autoconf.mk ./config.status
|
||||
endif
|
||||
|
||||
|
||||
####################################
|
||||
# Depend
|
||||
|
||||
depend:: $(OBJDIR)/Makefile $(OBJDIR)/config.status
|
||||
$(MOZ_MAKE) export && $(MOZ_MAKE) depend
|
||||
|
||||
####################################
|
||||
# Build it
|
||||
|
||||
build:: $(OBJDIR)/Makefile $(OBJDIR)/config.status
|
||||
$(MOZ_MAKE)
|
||||
|
||||
####################################
|
||||
# Profile-feedback build (gcc only)
|
||||
# To use this, you should set the following variables in your mozconfig
|
||||
# mk_add_options PROFILE_GEN_SCRIPT=/path/to/profile-script
|
||||
#
|
||||
# The profile script should exercise the functionality to be included
|
||||
# in the profile feedback.
|
||||
|
||||
profiledbuild:: $(OBJDIR)/Makefile $(OBJDIR)/config.status
|
||||
$(MOZ_MAKE) MOZ_PROFILE_GENERATE=1
|
||||
OBJDIR=${OBJDIR} $(PROFILE_GEN_SCRIPT)
|
||||
$(MOZ_MAKE) clobber_all
|
||||
$(MOZ_MAKE) MOZ_PROFILE_USE=1
|
||||
find $(OBJDIR) -name "*.da" -exec rm {} \;
|
||||
|
||||
####################################
|
||||
# Other targets
|
||||
|
||||
# Pass these target onto the real build system
|
||||
install export libs clean realclean distclean alldep:: $(OBJDIR)/Makefile $(OBJDIR)/config.status
|
||||
$(MOZ_MAKE) $@
|
||||
|
||||
cleansrcdir:
|
||||
@cd $(TOPSRCDIR); \
|
||||
if [ -f webshell/embed/gtk/Makefile ]; then \
|
||||
$(MAKE) -C webshell/embed/gtk distclean; \
|
||||
fi; \
|
||||
if [ -f Makefile ]; then \
|
||||
$(MAKE) distclean ; \
|
||||
else \
|
||||
echo "Removing object files from srcdir..."; \
|
||||
rm -fr `find . -type d \( -name .deps -print -o -name CVS \
|
||||
-o -exec test ! -d {}/CVS \; \) -prune \
|
||||
-o \( -name '*.[ao]' -o -name '*.so' \) -type f -print`; \
|
||||
build/autoconf/clean-config.sh; \
|
||||
fi;
|
||||
|
||||
# (! IS_FIRST_CHECKOUT)
|
||||
endif
|
||||
|
||||
echo_objdir:
|
||||
@echo $(OBJDIR)
|
||||
|
||||
.PHONY: checkout real_checkout depend build export libs alldep install clean realclean distclean cleansrcdir pull_all build_all clobber clobber_all pull_and_build_all everything configure
|
||||
37
mozilla/java/xpcom/Makefile
Normal file
37
mozilla/java/xpcom/Makefile
Normal file
@@ -0,0 +1,37 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Igor Kushnirskiy <idk@eng.sun.com>
|
||||
#
|
||||
DEPTH = ../..
|
||||
topsrcdir = ../..
|
||||
VPATH = .
|
||||
srcdir = .
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
DIRS= \
|
||||
connect \
|
||||
xpcom \
|
||||
java \
|
||||
xpcom/test/ \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
37
mozilla/java/xpcom/Makefile.in
Normal file
37
mozilla/java/xpcom/Makefile.in
Normal file
@@ -0,0 +1,37 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Igor Kushnirskiy <idk@eng.sun.com>
|
||||
#
|
||||
DEPTH = ../..
|
||||
topsrcdir = @top_srcdir@
|
||||
VPATH = @srcdir@
|
||||
srcdir = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
DIRS= \
|
||||
connect \
|
||||
xpcom \
|
||||
java \
|
||||
xpcom/test/ \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
78
mozilla/java/xpcom/README
Normal file
78
mozilla/java/xpcom/README
Normal file
@@ -0,0 +1,78 @@
|
||||
Black Connect
|
||||
================================
|
||||
|
||||
This directory contains the Black Connect
|
||||
|
||||
The sources is divided into three directories
|
||||
|
||||
connect
|
||||
public headers.
|
||||
ORB implementation.
|
||||
|
||||
xpcom
|
||||
XPCOM stubs and proxy implementation
|
||||
|
||||
java
|
||||
JAVA stubs and proxy implementation
|
||||
Java component loader
|
||||
|
||||
===============================================
|
||||
Solaris directions
|
||||
===============================================
|
||||
|
||||
Requirements:
|
||||
|
||||
* current mozilla built tree
|
||||
|
||||
* JDK1.3
|
||||
|
||||
* Perl 5 must be in your path
|
||||
|
||||
How To Build:
|
||||
|
||||
* make sure the environment var JDKHOME is set to your jdk installation
|
||||
directory, ie export JDKHOME=/usr/local/jdk1.3
|
||||
|
||||
* Add following directories to to your LD_LIBRARY_PATH:
|
||||
|
||||
|
||||
$MOZILLA_FIVE_HOME:$JDKHOME/jre/lib/$HOSTTYPE/native_threads:$JDKHOME/jre/lib/$HOSTTYPE/classic:
|
||||
$JDKHOME/jre/lib/$HOSTTYPE/:
|
||||
|
||||
* type "gmake"
|
||||
|
||||
|
||||
==============================================
|
||||
Linux directions
|
||||
===============================================
|
||||
|
||||
Requirements:
|
||||
|
||||
* mozilla m16 build tree
|
||||
|
||||
* JDK1.3 from IBM
|
||||
|
||||
* Perl 5 must be in your path
|
||||
|
||||
How To Build:
|
||||
|
||||
* make sure the environment var JDKHOME is set to your jdk installation
|
||||
directory, ie export JDKHOME=/usr/local/jdk1.3
|
||||
|
||||
* Add following directories to to your LD_LIBRARY_PATH:
|
||||
|
||||
$MOZILLA_FIVE_HOME:$JDKHOME/jre/bin:$JDKHOME/jre/bin/classic:
|
||||
|
||||
* remove jni* jri* from MOZILLA_FIVE_HOME/dist/include
|
||||
|
||||
* type "gmake"
|
||||
|
||||
==============================================
|
||||
How to run test java component
|
||||
===============================================
|
||||
* cd java/test
|
||||
* gmake
|
||||
* add $MOZILLA_FIVE_HOME/dist/classes to your CLASSPATH
|
||||
Test component would be placed in dist/bin/componets and loaded on mozilla
|
||||
sturtup (or you can use regxpcom for testing)
|
||||
|
||||
34
mozilla/java/xpcom/connect/Makefile.in
Normal file
34
mozilla/java/xpcom/connect/Makefile.in
Normal file
@@ -0,0 +1,34 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Igor Kushnirskiy <idk@eng.sun.com>
|
||||
#
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
VPATH = @srcdir@
|
||||
srcdir = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
DIRS= \
|
||||
xpcom \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
33
mozilla/java/xpcom/connect/makefile.win
Normal file
33
mozilla/java/xpcom/connect/makefile.win
Normal file
@@ -0,0 +1,33 @@
|
||||
#!nmake
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Sun Microsystems,
|
||||
# Inc. Portions created by Sun are
|
||||
# Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Igor Kushnirskiy <idk@eng.sun.com>
|
||||
#
|
||||
|
||||
DEPTH = ../../..
|
||||
|
||||
DIRS= \
|
||||
src \
|
||||
xpcom \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
|
||||
80
mozilla/java/xpcom/connect/public/bcDefs.h
Normal file
80
mozilla/java/xpcom/connect/public/bcDefs.h
Normal file
@@ -0,0 +1,80 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are
|
||||
* Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
#ifndef __bcDefs_h
|
||||
#define __bcDefs_h
|
||||
#include "prtypes.h"
|
||||
#include "nsID.h"
|
||||
|
||||
enum bcXPType {
|
||||
bc_T_I8 = 1, bc_T_U8, bc_T_I16, bc_T_U16,
|
||||
bc_T_I32, bc_T_U32, bc_T_I64, bc_T_U64,
|
||||
bc_T_FLOAT, bc_T_DOUBLE, bc_T_BOOL,
|
||||
bc_T_CHAR, bc_T_WCHAR,
|
||||
bc_T_IID ,
|
||||
bc_T_CHAR_STR, bc_T_WCHAR_STR,
|
||||
bc_T_ARRAY,
|
||||
bc_T_INTERFACE,
|
||||
bc_T_UNDEFINED
|
||||
};
|
||||
|
||||
typedef long bcOID;
|
||||
typedef nsID bcIID;
|
||||
typedef long bcTID ;
|
||||
|
||||
typedef unsigned int bcMID;
|
||||
typedef unsigned int size_t;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
35
mozilla/java/xpcom/connect/public/bcIAllocator.h
Normal file
35
mozilla/java/xpcom/connect/public/bcIAllocator.h
Normal file
@@ -0,0 +1,35 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are
|
||||
* Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
|
||||
#ifndef __bcIAllocator_h
|
||||
#define __bcIAllocator_h
|
||||
#include "bcDefs.h"
|
||||
|
||||
class bcIAllocator {
|
||||
public:
|
||||
virtual void * Alloc(size_t size) = 0;
|
||||
virtual void Free(void *ptr) = 0;
|
||||
virtual void * Realloc(void* ptr, size_t size) = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
48
mozilla/java/xpcom/connect/public/bcICall.h
Normal file
48
mozilla/java/xpcom/connect/public/bcICall.h
Normal file
@@ -0,0 +1,48 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are
|
||||
* Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
|
||||
#ifndef __bcICall_h
|
||||
#define __bcICall_h
|
||||
#include "bcIMarshaler.h"
|
||||
#include "bcIUnMarshaler.h"
|
||||
|
||||
class bcIORB;
|
||||
|
||||
class bcICall {
|
||||
public:
|
||||
virtual int GetParams(bcIID *, bcOID *, bcMID *) = 0;
|
||||
virtual bcIMarshaler * GetMarshaler() = 0;
|
||||
virtual bcIUnMarshaler * GetUnMarshaler() = 0;
|
||||
virtual bcIORB * GetORB() = 0;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
39
mozilla/java/xpcom/connect/public/bcIMarshaler.h
Normal file
39
mozilla/java/xpcom/connect/public/bcIMarshaler.h
Normal file
@@ -0,0 +1,39 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are
|
||||
* Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
|
||||
#ifndef __bcIMarshaler_h
|
||||
#define __bcIMarshaler_h
|
||||
#include "bcIAllocator.h"
|
||||
#include "bcDefs.h"
|
||||
|
||||
class bcIMarshaler {
|
||||
public:
|
||||
virtual int WriteSimple(void *ptr, bcXPType type) = 0;
|
||||
virtual int WriteString(void *ptr, size_t size) = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
38
mozilla/java/xpcom/connect/public/bcIORB.h
Normal file
38
mozilla/java/xpcom/connect/public/bcIORB.h
Normal file
@@ -0,0 +1,38 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are
|
||||
* Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
|
||||
#ifndef __bcIORB_h
|
||||
#define __bcIORB_h
|
||||
#include "bcICall.h"
|
||||
#include "bcDefs.h"
|
||||
#include "bcIStub.h"
|
||||
|
||||
|
||||
class bcIORB {
|
||||
public:
|
||||
virtual bcOID RegisterStub(bcIStub *stub) = 0;
|
||||
virtual bcICall * CreateCall(bcIID *, bcOID *, bcMID) = 0;
|
||||
virtual int SendReceive(bcICall *) = 0;
|
||||
//virtual IThread * GetThread(TID) = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
31
mozilla/java/xpcom/connect/public/bcIStub.h
Normal file
31
mozilla/java/xpcom/connect/public/bcIStub.h
Normal file
@@ -0,0 +1,31 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are
|
||||
* Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
#ifndef __bcIStub_h
|
||||
#define __bcIStub_h
|
||||
#include "bcICall.h"
|
||||
|
||||
class bcIStub {
|
||||
public:
|
||||
virtual void Dispatch(bcICall *call) = 0;
|
||||
//nb shortcut
|
||||
};
|
||||
#endif
|
||||
29
mozilla/java/xpcom/connect/public/bcIThread.h
Normal file
29
mozilla/java/xpcom/connect/public/bcIThread.h
Normal file
@@ -0,0 +1,29 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are
|
||||
* Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
#ifndef __bcIThread_h
|
||||
#define __bcIThread_h
|
||||
|
||||
class bcIThread {
|
||||
public:
|
||||
virtual AttachCall(bcICall *, short isAsync) = 0;
|
||||
};
|
||||
#endif
|
||||
35
mozilla/java/xpcom/connect/public/bcIUnMarshaler.h
Normal file
35
mozilla/java/xpcom/connect/public/bcIUnMarshaler.h
Normal file
@@ -0,0 +1,35 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are
|
||||
* Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
#ifndef __bcIUnMarshaler_h
|
||||
#define __bcIUnMarshaler_h
|
||||
#include "bcIAllocator.h"
|
||||
#include "bcDefs.h"
|
||||
|
||||
class bcIUnMarshaler {
|
||||
public:
|
||||
virtual int ReadSimple(void *ptr, bcXPType type) = 0;
|
||||
virtual int ReadString(void *ptr, size_t *size, bcIAllocator * allocator = 0) = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
46
mozilla/java/xpcom/connect/src/Allocator.cpp
Normal file
46
mozilla/java/xpcom/connect/src/Allocator.cpp
Normal file
@@ -0,0 +1,46 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are
|
||||
* Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include "Allocator.h"
|
||||
|
||||
#include <iostream.h>
|
||||
|
||||
Allocator::Allocator() {
|
||||
}
|
||||
|
||||
Allocator::~Allocator() {
|
||||
}
|
||||
|
||||
void * Allocator::Alloc(size_t size) {
|
||||
cout<<"Allocator::Alloc("<<size<<")\n";
|
||||
return malloc(size);
|
||||
}
|
||||
|
||||
void Allocator::Free(void *ptr) {
|
||||
free(ptr);
|
||||
}
|
||||
|
||||
void * Allocator::Realloc(void *ptr, size_t size) {
|
||||
return realloc(ptr,size);
|
||||
}
|
||||
|
||||
|
||||
35
mozilla/java/xpcom/connect/src/Allocator.h
Normal file
35
mozilla/java/xpcom/connect/src/Allocator.h
Normal file
@@ -0,0 +1,35 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are
|
||||
* Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
|
||||
#ifndef __Allocator_h
|
||||
#define __Allocator_h
|
||||
#include "bcIAllocator.h"
|
||||
|
||||
class Allocator : public bcIAllocator {
|
||||
public:
|
||||
Allocator();
|
||||
virtual ~Allocator();
|
||||
virtual void * Alloc(size_t size);
|
||||
virtual void Free(void *ptr);
|
||||
virtual void * Realloc(void* ptr, size_t size);
|
||||
};
|
||||
#endif
|
||||
78
mozilla/java/xpcom/connect/src/Call.cpp
Normal file
78
mozilla/java/xpcom/connect/src/Call.cpp
Normal file
@@ -0,0 +1,78 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are
|
||||
* Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
|
||||
#include "Call.h"
|
||||
#include "Marshaler.h"
|
||||
#include "UnMarshaler.h"
|
||||
|
||||
Call::Call() {
|
||||
}
|
||||
|
||||
Call::Call(bcIID *_iid, bcOID *_oid, bcMID _mid, bcIORB *_orb):out(0),in(0) {
|
||||
iid = *_iid;
|
||||
oid = *_oid;
|
||||
mid = _mid;
|
||||
orb = _orb;
|
||||
}
|
||||
|
||||
Call::~Call() {
|
||||
if (out)
|
||||
delete out;
|
||||
if (in)
|
||||
delete in;
|
||||
}
|
||||
|
||||
int Call::GetParams(bcIID *_iid, bcOID *_oid, bcMID *_mid) {
|
||||
*_iid = iid;
|
||||
*_oid = oid;
|
||||
*_mid = mid;
|
||||
return 0;
|
||||
}
|
||||
|
||||
bcIMarshaler * Call::GetMarshaler() {
|
||||
out = new ostrstream();
|
||||
return new Marshaler(out);
|
||||
}
|
||||
|
||||
bcIUnMarshaler * Call::GetUnMarshaler() {
|
||||
if (!out) {
|
||||
return NULL;
|
||||
}
|
||||
char *buf = out->str();
|
||||
// cout<<"Call::GetUnMarshaler "<<out->pcount()<<"\n";
|
||||
#if 0
|
||||
cout<<"Call::GetUnMarshaler buf:\n";
|
||||
for (int i = 0; i < out->pcount(); i++) {
|
||||
cout<<" buf["<<i<<"]"<<(unsigned)buf[i]<<"\n";
|
||||
}
|
||||
#endif
|
||||
if (out->pcount()) {
|
||||
in = new istrstream(buf,out->pcount());
|
||||
}
|
||||
return new UnMarshaler(in);
|
||||
}
|
||||
|
||||
bcIORB * Call::GetORB() {
|
||||
return orb;
|
||||
}
|
||||
|
||||
|
||||
51
mozilla/java/xpcom/connect/src/Call.h
Normal file
51
mozilla/java/xpcom/connect/src/Call.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are
|
||||
* Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
|
||||
#ifndef __Call_h
|
||||
#define __Call_h
|
||||
|
||||
#ifdef WIN32
|
||||
#include <strstrea.h>
|
||||
#else
|
||||
#include <strstream.h>
|
||||
#endif
|
||||
#include "bcICall.h"
|
||||
|
||||
class Call : public bcICall {
|
||||
public:
|
||||
Call();
|
||||
Call(bcIID *, bcOID *, bcMID, bcIORB *orb);
|
||||
virtual ~Call();
|
||||
virtual int GetParams(bcIID *, bcOID *, bcMID*);
|
||||
virtual bcIORB * GetORB();
|
||||
virtual bcIMarshaler * GetMarshaler();
|
||||
virtual bcIUnMarshaler * GetUnMarshaler();
|
||||
private :
|
||||
ostrstream *out;
|
||||
istrstream *in;
|
||||
bcIID iid;
|
||||
bcOID oid;
|
||||
bcMID mid;
|
||||
bcIORB *orb;
|
||||
};
|
||||
|
||||
#endif
|
||||
52
mozilla/java/xpcom/connect/src/Marshaler.cpp
Normal file
52
mozilla/java/xpcom/connect/src/Marshaler.cpp
Normal file
@@ -0,0 +1,52 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are
|
||||
* Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
|
||||
#include <iostream.h>
|
||||
|
||||
#include <string.h>
|
||||
#include "Marshaler.h"
|
||||
#include "util.h"
|
||||
|
||||
Marshaler::Marshaler(ostream *_out) {
|
||||
out = _out;
|
||||
}
|
||||
|
||||
Marshaler::~Marshaler() {
|
||||
}
|
||||
|
||||
int Marshaler::WriteSimple(void *ptr, bcXPType type) {
|
||||
out->write((const char*)ptr, type2size(type));
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Marshaler::WriteString(void *ptr, size_t size) {
|
||||
if (!size
|
||||
&& ptr) {
|
||||
size = 1;
|
||||
}
|
||||
out->write((const char*)&size, sizeof(size_t));
|
||||
if (size) {
|
||||
out->write((const char*)ptr,type2size(bc_T_CHAR)*size);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
41
mozilla/java/xpcom/connect/src/Marshaler.h
Normal file
41
mozilla/java/xpcom/connect/src/Marshaler.h
Normal file
@@ -0,0 +1,41 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are
|
||||
* Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
|
||||
#ifndef __Marshaler_h
|
||||
#define __Marshaler_h
|
||||
#include <iostream.h>
|
||||
#include "bcIMarshaler.h"
|
||||
|
||||
|
||||
class Marshaler : public bcIMarshaler {
|
||||
public:
|
||||
Marshaler(ostream *out);
|
||||
virtual ~Marshaler();
|
||||
virtual int WriteSimple(void *ptr, bcXPType type);
|
||||
virtual int WriteString(void *ptr, size_t size);
|
||||
private:
|
||||
ostream * out;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
65
mozilla/java/xpcom/connect/src/ORB.cpp
Normal file
65
mozilla/java/xpcom/connect/src/ORB.cpp
Normal file
@@ -0,0 +1,65 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are
|
||||
* Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
|
||||
#include "ORB.h"
|
||||
#include "Call.h"
|
||||
|
||||
ORB::ORB() {
|
||||
currentID = 1;
|
||||
for (int i = 0; i < STUBS_COUNT; i++) {
|
||||
stubs[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ORB::~ORB() {
|
||||
}
|
||||
|
||||
bcOID ORB::RegisterStub(bcIStub *stub) {
|
||||
stubs[currentID] = stub;
|
||||
return currentID++;
|
||||
}
|
||||
|
||||
bcICall * ORB::CreateCall(bcIID *iid, bcOID *oid, bcMID mid) {
|
||||
return new Call(iid, oid, mid,this);
|
||||
}
|
||||
|
||||
int ORB::SendReceive(bcICall *call) {
|
||||
bcIID iid;
|
||||
bcOID oid;
|
||||
bcMID mid;
|
||||
call->GetParams(&iid,&oid,&mid);
|
||||
bcIStub *stub = GetStub(&oid);
|
||||
if (stub) {
|
||||
stub->Dispatch(call);
|
||||
return 0;
|
||||
} else {
|
||||
return 1; //nb need to think about error values
|
||||
}
|
||||
}
|
||||
|
||||
bcIStub * ORB::GetStub(bcOID *oid) {
|
||||
return stubs[*oid];
|
||||
}
|
||||
|
||||
|
||||
|
||||
40
mozilla/java/xpcom/connect/src/ORB.h
Normal file
40
mozilla/java/xpcom/connect/src/ORB.h
Normal file
@@ -0,0 +1,40 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are
|
||||
* Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
|
||||
#ifndef __ORB_h
|
||||
#define __ORB_h
|
||||
#include "bcIORB.h"
|
||||
|
||||
#define STUBS_COUNT (100)
|
||||
class ORB : public bcIORB {
|
||||
public:
|
||||
ORB();
|
||||
virtual ~ORB();
|
||||
virtual bcOID RegisterStub(bcIStub *stub);
|
||||
virtual bcICall * CreateCall(bcIID *, bcOID *, bcMID);
|
||||
virtual int SendReceive(bcICall *);
|
||||
private:
|
||||
bcIStub * GetStub(bcOID *);
|
||||
bcIStub * stubs[STUBS_COUNT]; //nb :) it's jast for now. (Mon Mar 13 16:53:03 PST 2000)
|
||||
int currentID;
|
||||
};
|
||||
#endif
|
||||
53
mozilla/java/xpcom/connect/src/UnMarshaler.cpp
Normal file
53
mozilla/java/xpcom/connect/src/UnMarshaler.cpp
Normal file
@@ -0,0 +1,53 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are
|
||||
* Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
|
||||
#include "UnMarshaler.h"
|
||||
#include "util.h"
|
||||
|
||||
UnMarshaler::UnMarshaler(istream *_in) {
|
||||
in = _in;
|
||||
}
|
||||
|
||||
UnMarshaler::~UnMarshaler() {
|
||||
}
|
||||
|
||||
int UnMarshaler::ReadSimple(void *ptr, bcXPType type) {
|
||||
char *p = (char *)ptr;
|
||||
int size = type2size(type);
|
||||
in->read(p,size );
|
||||
return 0;
|
||||
}
|
||||
int UnMarshaler::ReadString(void *ptr, size_t *size, bcIAllocator * allocator) {
|
||||
size_t length;
|
||||
in->read((char*)size,sizeof(size_t));
|
||||
*(char**)ptr = (char *)allocator->Alloc(*size * type2size(bc_T_CHAR));
|
||||
if (*size) {
|
||||
in->read(*(char**)ptr,*size * type2size(bc_T_CHAR));
|
||||
}
|
||||
|
||||
if (*size == 1) {
|
||||
if (!(*(char**)ptr)[0]) {
|
||||
*size = 0;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
38
mozilla/java/xpcom/connect/src/UnMarshaler.h
Normal file
38
mozilla/java/xpcom/connect/src/UnMarshaler.h
Normal file
@@ -0,0 +1,38 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are
|
||||
* Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
|
||||
#ifndef __UnMarshaler_h
|
||||
#define __UnMarshaler_h
|
||||
#include <iostream.h>
|
||||
#include "bcIUnMarshaler.h"
|
||||
|
||||
class UnMarshaler : public bcIUnMarshaler {
|
||||
public:
|
||||
UnMarshaler(istream *in);
|
||||
virtual ~UnMarshaler();
|
||||
virtual int ReadSimple(void *ptr, bcXPType type);
|
||||
virtual int ReadString(void *ptr, size_t *size, bcIAllocator * allocator);
|
||||
private:
|
||||
istream *in;
|
||||
};
|
||||
|
||||
#endif
|
||||
62
mozilla/java/xpcom/connect/src/makefile.win
Normal file
62
mozilla/java/xpcom/connect/src/makefile.win
Normal file
@@ -0,0 +1,62 @@
|
||||
#!nmake
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Sun Microsystems,
|
||||
# Inc. Portions created by Sun are
|
||||
# Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Igor Kushnirskiy <idk@eng.sun.com>
|
||||
#
|
||||
|
||||
DEPTH=..\..\..\..
|
||||
|
||||
MAKE_OBJ_TYPE = lib
|
||||
LIBRARY_NAME = bcorbcore
|
||||
LIB=.\$(OBJDIR)\bcorbcore.lib
|
||||
|
||||
OBJS= \
|
||||
.\$(OBJDIR)\Allocator.obj \
|
||||
.\$(OBJDIR)\Call.obj \
|
||||
.\$(OBJDIR)\Marshaler.obj \
|
||||
.\$(OBJDIR)\ORB.obj \
|
||||
.\$(OBJDIR)\UnMarshaler.obj \
|
||||
.\$(OBJDIR)\util.obj \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = \
|
||||
..\public\bcIORB.h \
|
||||
..\public\bcDefs.h \
|
||||
..\public\bcICall.h \
|
||||
..\public\bcIUnMarshaler.h \
|
||||
..\public\bcIAllocator.h \
|
||||
..\public\bcIMarshaler.h \
|
||||
..\public\bcIStub.h \
|
||||
..\public\bcIThread.h
|
||||
|
||||
LLIBS=$(LLIBS) $(LIBNSPR) $(DIST)\lib\xpcom.lib
|
||||
|
||||
INCS = \
|
||||
-I..\public -I..\src \
|
||||
$(INCS) \
|
||||
$(NULL)
|
||||
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
install:: $(LIB)
|
||||
$(MAKE_INSTALL) $(LIB) $(DIST)\lib
|
||||
clobber::
|
||||
rm -f $(DIST)\lib\$(LIBRARY_NAME).lib
|
||||
72
mozilla/java/xpcom/connect/src/util.cpp
Normal file
72
mozilla/java/xpcom/connect/src/util.cpp
Normal file
@@ -0,0 +1,72 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are
|
||||
* Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
|
||||
#include "util.h"
|
||||
#include "bcDefs.h"
|
||||
|
||||
size_t type2size(bcXPType type) {
|
||||
size_t res = 0;
|
||||
switch (type) {
|
||||
case bc_T_CHAR :
|
||||
res = sizeof(char);
|
||||
break;
|
||||
case bc_T_WCHAR:
|
||||
res = 2; //nb
|
||||
break;
|
||||
case bc_T_I8:
|
||||
case bc_T_U8:
|
||||
res = sizeof(PRInt8);
|
||||
break;
|
||||
case bc_T_I16:
|
||||
case bc_T_U16:
|
||||
res = sizeof(PRInt16);
|
||||
break;
|
||||
case bc_T_I32:
|
||||
case bc_T_U32:
|
||||
res = sizeof(PRInt32);
|
||||
break;
|
||||
case bc_T_I64:
|
||||
case bc_T_U64:
|
||||
res = sizeof(PRInt64);
|
||||
break;
|
||||
case bc_T_FLOAT:
|
||||
res = sizeof(float);
|
||||
break;
|
||||
case bc_T_DOUBLE:
|
||||
res = sizeof(double);
|
||||
break;
|
||||
case bc_T_BOOL:
|
||||
res = sizeof(PRBool);
|
||||
break;
|
||||
case bc_T_IID:
|
||||
res = sizeof(nsID);
|
||||
break;
|
||||
case bc_T_INTERFACE:
|
||||
res = sizeof(bcOID);
|
||||
break;
|
||||
default:
|
||||
res = 0;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
27
mozilla/java/xpcom/connect/src/util.h
Normal file
27
mozilla/java/xpcom/connect/src/util.h
Normal file
@@ -0,0 +1,27 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are
|
||||
* Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
#ifndef __util_h
|
||||
#define __util_h
|
||||
#include "bcDefs.h"
|
||||
|
||||
size_t type2size(bcXPType type);
|
||||
#endif
|
||||
65
mozilla/java/xpcom/connect/xpcom/Makefile.in
Normal file
65
mozilla/java/xpcom/connect/xpcom/Makefile.in
Normal file
@@ -0,0 +1,65 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Igor Kushnirskiy <idk@eng.sun.com>
|
||||
#
|
||||
|
||||
DEPTH=../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
LIBRARY_NAME = bcorb
|
||||
MODULE = bcorb
|
||||
IS_COMPONENT = 1
|
||||
|
||||
CPPSRCS = \
|
||||
bcORB.cpp \
|
||||
../src/Allocator.cpp \
|
||||
../src/Call.cpp \
|
||||
../src/Marshaler.cpp \
|
||||
../src/ORB.cpp \
|
||||
../src/UnMarshaler.cpp \
|
||||
../src/util.cpp \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = \
|
||||
bcORB.h \
|
||||
../public/bcIORB.h \
|
||||
../public/bcDefs.h \
|
||||
../public/bcICall.h \
|
||||
../public/bcIUnMarshaler.h \
|
||||
../public/bcIAllocator.h \
|
||||
../public/bcIMarshaler.h \
|
||||
../public/bcIStub.h \
|
||||
../public/bcIThread.h
|
||||
|
||||
|
||||
CXXFLAGS += -I../public -I../src
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
|
||||
|
||||
|
||||
76
mozilla/java/xpcom/connect/xpcom/bcORB.cpp
Normal file
76
mozilla/java/xpcom/connect/xpcom/bcORB.cpp
Normal file
@@ -0,0 +1,76 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are
|
||||
* Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
#include "bcORB.h"
|
||||
#include "../src/ORB.h"
|
||||
#include "nsIGenericFactory.h"
|
||||
#include "nsIModule.h"
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(bcORB);
|
||||
|
||||
static nsModuleComponentInfo components[] =
|
||||
{
|
||||
{
|
||||
"Black Connect ORB",
|
||||
BC_ORB_CID,
|
||||
BC_ORB_PROGID,
|
||||
bcORBConstructor
|
||||
}
|
||||
};
|
||||
|
||||
NS_IMPL_NSGETMODULE("BlackConnectORB",components);
|
||||
|
||||
|
||||
|
||||
NS_IMPL_ISUPPORTS(bcORB,NS_GET_IID(bcORB));
|
||||
|
||||
bcORB::bcORB() :
|
||||
orb(0)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
bcORB::~bcORB() {
|
||||
if (orb) {
|
||||
delete orb; //nb should we destroy it?
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP bcORB::GetORB(bcIORB **_orb) {
|
||||
if (!_orb) {
|
||||
printf("--bcORB::GetORB\n");
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
if (!orb) {
|
||||
orb = new ORB();
|
||||
}
|
||||
*_orb = orb;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
54
mozilla/java/xpcom/connect/xpcom/bcORB.h
Normal file
54
mozilla/java/xpcom/connect/xpcom/bcORB.h
Normal file
@@ -0,0 +1,54 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are
|
||||
* Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
|
||||
#ifndef _bcORB_h
|
||||
#define _bcORB_h
|
||||
#include "nsISupports.h"
|
||||
#include "bcIORB.h"
|
||||
|
||||
|
||||
/*29bde10c-1dd2-11b2-ab23-ebe06c6baec5*/
|
||||
#define BC_ORB_IID \
|
||||
{ 0x29bde10c, 0x1dd2, 0x11b2, \
|
||||
{0xab, 0x23, 0xeb, 0xe0, 0x6c, 0x6b, 0xae, 0xc5}}
|
||||
|
||||
|
||||
#define BC_ORB_PROGID "component://netscape/blackwood/blackconnect/orb"
|
||||
|
||||
/*ffa0d768-1dd1-11b2-8bf2-ab56f26ea844*/
|
||||
#define BC_ORB_CID \
|
||||
{ 0xffa0d768, 0x1dd1, 0x11b2, \
|
||||
{0x8b, 0xf2, 0xab, 0x56, 0xf2, 0x6e, 0xa8, 0x44 }}
|
||||
|
||||
|
||||
class bcORB : public nsISupports {
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(BC_ORB_IID)
|
||||
NS_IMETHOD GetORB(bcIORB **orb);
|
||||
bcORB();
|
||||
virtual ~bcORB();
|
||||
private:
|
||||
bcIORB *orb;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
47
mozilla/java/xpcom/connect/xpcom/makefile.win
Normal file
47
mozilla/java/xpcom/connect/xpcom/makefile.win
Normal file
@@ -0,0 +1,47 @@
|
||||
#!nmake
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Sun Microsystems,
|
||||
# Inc. Portions created by Sun are
|
||||
# Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Igor Kushnirskiy <idk@eng.sun.com>
|
||||
#
|
||||
|
||||
DEPTH=..\..\..\..
|
||||
|
||||
MAKE_OBJ_TYPE = DLL
|
||||
MODULE=bcorb
|
||||
COMPONENT = 1
|
||||
DLLNAME = bcorb
|
||||
DLL=.\$(OBJDIR)\$(DLLNAME).dll
|
||||
|
||||
OBJS= \
|
||||
.\$(OBJDIR)\bcORB.obj \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = \
|
||||
bcORB.h \
|
||||
$(NULL)
|
||||
|
||||
LLIBS=$(LLIBS) $(LIBNSPR) $(DIST)\lib\xpcom.lib $(DIST)\lib\bcorbcore.lib
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
install:: $(DLL)
|
||||
$(MAKE_INSTALL) $(DLL) $(DIST)\bin\components
|
||||
clobber::
|
||||
rm -f $(DIST)\bin\components\$(DLLNAME).dll
|
||||
32
mozilla/java/xpcom/java/Makefile.in
Normal file
32
mozilla/java/xpcom/java/Makefile.in
Normal file
@@ -0,0 +1,32 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Igor Kushnirskiy <idk@eng.sun.com>
|
||||
#
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
VPATH = @srcdir@
|
||||
srcdir = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
DIRS= src loader classes test
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
43
mozilla/java/xpcom/java/classes/Makefile.in
Normal file
43
mozilla/java/xpcom/java/classes/Makefile.in
Normal file
@@ -0,0 +1,43 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Igor Kushnirskiy <idk@eng.sun.com>
|
||||
#
|
||||
|
||||
DEPTH = ../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
VPATH = @srcdir@
|
||||
srcdir = @srcdir@
|
||||
|
||||
JAVA_OR_NSJVM=1
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
|
||||
JAR_PLUGLET_CLASSES = \
|
||||
org/mozilla/xpcom \
|
||||
$(NULL)
|
||||
|
||||
JDIRS = $(JAR_PLUGLET_CLASSES)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
JAVAC=$(JDKHOME)/bin/javac -classpath .:$(CLASSPATH) -d $(DIST)/classes
|
||||
|
||||
39
mozilla/java/xpcom/java/classes/makefile.win
Normal file
39
mozilla/java/xpcom/java/classes/makefile.win
Normal file
@@ -0,0 +1,39 @@
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Sun Microsystems,
|
||||
# Inc. Portions created by Sun are
|
||||
# Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Igor Kushnirskiy <idk@eng.sun.com>
|
||||
#
|
||||
|
||||
IGNORE_MANIFEST=1
|
||||
DEPTH = ..\..\..\..
|
||||
|
||||
JAVA_OR_NSJVM=1
|
||||
NO_CAFE=1
|
||||
|
||||
include <$(DEPTH)\config\config.mak>
|
||||
|
||||
JAR_PLUGLET_CLASSES = \
|
||||
org\mozilla\xpcom \
|
||||
$(NULL)
|
||||
|
||||
JDIRS = $(JAR_PLUGLET_CLASSES)
|
||||
JAVAC_PROG=$(JDKHOME)\bin\javac
|
||||
JAVAC_FLAGS=-classpath "$(CLASSPATH);$(JAVA_DESTPATH)" -d "$(JAVA_DESTPATH)"
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
@@ -0,0 +1,62 @@
|
||||
/* -*- Mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are
|
||||
* Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
package org.mozilla.xpcom;
|
||||
|
||||
import java.net.URLClassLoader;
|
||||
import java.net.URL;
|
||||
import java.util.jar.Manifest;
|
||||
import java.util.jar.Attributes;
|
||||
import java.io.InputStream;
|
||||
import java.io.File;
|
||||
|
||||
public class ComponentLoader {
|
||||
// path to jar file. Name of main class sould to be in MANIFEST.
|
||||
public static Object loadComponent(String location) {
|
||||
try {
|
||||
File file = (new File(location)).getCanonicalFile(); //To avoid spelling diffs, e.g c: and C:
|
||||
location = file.getAbsolutePath();
|
||||
if (File.separatorChar != '/') {
|
||||
location = location.replace(File.separatorChar,'/');
|
||||
}
|
||||
if (!location.startsWith("/")) {
|
||||
location = "/" + location;
|
||||
}
|
||||
URL url = new URL("file:"+location);
|
||||
URLClassLoader loader = URLClassLoader.newInstance(new URL[]{url});
|
||||
URL manifestURL = new URL("jar:file:"+location+"!/META-INF/MANIFEST.MF");
|
||||
InputStream inputStream = manifestURL.openStream();
|
||||
Manifest manifest = new Manifest(inputStream);
|
||||
Attributes attr = manifest.getMainAttributes();
|
||||
String componentClassName = attr.getValue("Component-Class");
|
||||
if (componentClassName == null) {
|
||||
//nb
|
||||
return null;
|
||||
}
|
||||
Object object = loader.loadClass(componentClassName).newInstance();
|
||||
return object;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
58
mozilla/java/xpcom/java/classes/org/mozilla/xpcom/IID.java
Normal file
58
mozilla/java/xpcom/java/classes/org/mozilla/xpcom/IID.java
Normal file
@@ -0,0 +1,58 @@
|
||||
/* -*- Mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are
|
||||
* Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
package org.mozilla.xpcom;
|
||||
|
||||
public class IID {
|
||||
public IID(String iid) {
|
||||
this.iid = (iid == null) ? "" : iid;
|
||||
}
|
||||
public boolean equals(Object obj) {
|
||||
if (! (obj instanceof IID)) {
|
||||
return false;
|
||||
}
|
||||
boolean res = iid.equals(((IID)obj).iid);
|
||||
return res;
|
||||
}
|
||||
public String toString() {
|
||||
return "org.mozilla.xpcom.IID@"+iid;
|
||||
}
|
||||
public int hashCode() {
|
||||
int h = iid.hashCode();
|
||||
return h;
|
||||
}
|
||||
public String getString() {
|
||||
return iid;
|
||||
}
|
||||
private String iid;
|
||||
public static Class TYPE;
|
||||
static {
|
||||
try {
|
||||
TYPE = Class.forName("org.mozilla.xpcom.Proxy");
|
||||
} catch (Exception e) { //it could not happen
|
||||
TYPE = null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are
|
||||
* Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
package org.mozilla.xpcom;
|
||||
|
||||
import java.lang.reflect.*;
|
||||
import java.util.*;
|
||||
|
||||
public class ProxyClass { //nb it should not be public
|
||||
public ProxyClass(IID _iid, Method[] _methods) { //nb it should not be public
|
||||
iid = _iid;
|
||||
methods = _methods;
|
||||
if (classes == null) {
|
||||
classes = new Hashtable();
|
||||
}
|
||||
classes.put(iid, this);
|
||||
}
|
||||
Method getMethodByIndex(int mid) { //first method has index equal to 'offset'
|
||||
System.out.println("--[java]ProxyClass.GetMehodByIndex "+mid);
|
||||
Method result = null;
|
||||
try {
|
||||
result = methods[mid-offset];
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
int getIndexByMethod(Method method) {
|
||||
int result = 0;
|
||||
if (method == null
|
||||
||methods == null) {
|
||||
return result;
|
||||
}
|
||||
for (int i = 0; i < methods.length; i++) {
|
||||
if (method.equals(methods[i])) {
|
||||
result = i + offset;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static ProxyClass getProxyClass(IID iid) {
|
||||
ProxyClass result = null;
|
||||
Object obj = null;
|
||||
if (classes != null) {
|
||||
obj = classes.get(iid);
|
||||
if (obj != null
|
||||
&& (obj instanceof ProxyClass)) {
|
||||
result = (ProxyClass)obj;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
private IID iid;
|
||||
private Method[] methods;
|
||||
private final int offset = 0; //from xpcom
|
||||
static Hashtable classes = null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are
|
||||
* Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
package org.mozilla.xpcom;
|
||||
|
||||
import java.util.*;
|
||||
import java.lang.reflect.*;
|
||||
import java.lang.ref.*;
|
||||
|
||||
class ProxyKey {
|
||||
ProxyKey(long _oid, IID _iid) {
|
||||
oid = new Long(_oid);
|
||||
iid = _iid;
|
||||
}
|
||||
public boolean equals(Object obj) {
|
||||
if (! (obj instanceof ProxyKey)) {
|
||||
return false;
|
||||
}
|
||||
return (oid.equals(((ProxyKey)obj).oid) && iid.equals(((ProxyKey)obj).iid));
|
||||
}
|
||||
public int hashCode() {
|
||||
return oid.hashCode();
|
||||
}
|
||||
public String toString() {
|
||||
return "org.mozilla.xpcom.ProxyFactory.ProxyKey "+oid+" "+iid;
|
||||
}
|
||||
Long oid;
|
||||
IID iid;
|
||||
}
|
||||
|
||||
public class ProxyFactory {
|
||||
public static void registerInterfaceForIID(Class inter, IID iid) {
|
||||
System.out.println("--[java] ProxyFactory.registerInterfaceForIID "+iid);
|
||||
if (interfaces == null) {
|
||||
interfaces = new Hashtable();
|
||||
}
|
||||
interfaces.put(iid, inter); //nb who is gonna remove object from cache?
|
||||
}
|
||||
public static Class getInterface(IID iid) {
|
||||
System.out.println("--[java] ProxyFactory.getInterface "+iid);
|
||||
Object obj = null;
|
||||
if (interfaces != null) {
|
||||
obj = interfaces.get(iid);
|
||||
if (obj == null) {
|
||||
System.out.println("--[java] ProxyFactory.getInterface interface== null");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
if (!(obj instanceof Class)) {
|
||||
System.out.println("--[java] ProxyFactory.getInterface !(obj instanceof Class"+obj);
|
||||
return null;
|
||||
}
|
||||
return (Class)obj;
|
||||
}
|
||||
|
||||
public static Object getProxy(long oid, IID iid, long orb) {
|
||||
try {
|
||||
System.out.println("--[java] ProxyFactory.getProxy "+iid);
|
||||
ProxyKey key = new ProxyKey(oid, iid);
|
||||
Object obj = null;
|
||||
Object result = null;
|
||||
if (proxies != null) {
|
||||
obj = proxies.get(key);
|
||||
if (obj != null
|
||||
&& (obj instanceof Reference)) {
|
||||
result = ((Reference)obj).get();
|
||||
}
|
||||
} else {
|
||||
proxies = new Hashtable();
|
||||
}
|
||||
if (result == null) {
|
||||
Class inter = getInterface(iid);
|
||||
if (inter == null) {
|
||||
System.out.println("--[java] ProxyFactory.getProxy we did not find interface for iid="+iid+"returing null");
|
||||
return null;
|
||||
}
|
||||
InvocationHandler handler = new ProxyHandler(oid, iid, orb);
|
||||
result = Proxy.newProxyInstance(inter.getClassLoader(), new Class[] {inter},handler);
|
||||
proxies.put(new WeakReference(result), key);
|
||||
}
|
||||
System.out.println("--[java] ProxyFactory.getProxy we got proxy "+result);
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
System.out.println("--[java] ProxyFactory.getProxy we got exception "+e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
protected static Hashtable proxies = null;
|
||||
private static Hashtable interfaces = null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are
|
||||
* Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
package org.mozilla.xpcom;
|
||||
|
||||
import java.lang.reflect.*;
|
||||
|
||||
class ProxyHandler implements InvocationHandler {
|
||||
ProxyHandler(long _oid, IID _iid, long _orb) {
|
||||
oid = _oid;
|
||||
iid = _iid;
|
||||
orb = _orb;
|
||||
}
|
||||
public Object invoke(Object proxy,
|
||||
Method method,
|
||||
Object[] args) throws Throwable {
|
||||
System.out.println("--[java]ProxyHandler.invoke "+method);
|
||||
if ("toString".equals(method.getName())) {
|
||||
return "ProxyObject@{oid = "+oid+" iid = "+iid+"}";
|
||||
}
|
||||
return Utilities.callMethod(oid, method, iid, orb, args);
|
||||
}
|
||||
private long oid;
|
||||
private IID iid;
|
||||
private long orb;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
/* -*- Mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are
|
||||
* Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
package org.mozilla.xpcom;
|
||||
|
||||
import java.lang.reflect.*;
|
||||
|
||||
public class Utilities {
|
||||
|
||||
static Object callMethodByIndex(Object obj, IID iid, int mid, Object[] args) {
|
||||
System.out.println("--[java]org.mozilla.xpcom.Utilities.callMethodByIndex "+args.length+" "+mid);
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
System.out.println("--[java]callMethodByIndex args["+i+"] = "+args[i]);
|
||||
}
|
||||
Method method = getMethodByIndex(mid,iid);
|
||||
System.out.println("--[java] org.mozilla.xpcom.Utilities.callMethodByIndex method "+method);
|
||||
try {
|
||||
if (method != null) {
|
||||
method.invoke(obj,args);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
System.out.println("--callMethodByIndex method finished"+method);
|
||||
return null; //nb for testing
|
||||
}
|
||||
static Object callMethod(long oid, Method method, IID iid, long orb , Object[] args) {
|
||||
System.out.println("--[java]Utilities.callMethod "+method);
|
||||
int mid = getIndexByMethod(method, iid);
|
||||
if (mid <= 0) {
|
||||
System.out.println("--[java]Utilities.callMethod we do not have implementation for "+method);
|
||||
return null;
|
||||
}
|
||||
System.out.println("--[java]Utilities.callMethod "+mid);
|
||||
return callMethodByIndex(oid,mid,iid.getString(), orb, args);
|
||||
}
|
||||
|
||||
private static Method getMethodByIndex(int index, IID iid) {
|
||||
Method result = null;
|
||||
ProxyClass proxyClass = ProxyClass.getProxyClass(iid);
|
||||
if (proxyClass != null) {
|
||||
result = proxyClass.getMethodByIndex(index);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
private static int getIndexByMethod(Method method, IID iid) {
|
||||
int result = 0;
|
||||
ProxyClass proxyClass = ProxyClass.getProxyClass(iid);
|
||||
if (proxyClass != null) {
|
||||
result = proxyClass.getIndexByMethod(method);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
private static native Object callMethodByIndex(long oid, int index, String iid, long orb, Object[] args);
|
||||
static {
|
||||
System.loadLibrary("bcjavastubs");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
49
mozilla/java/xpcom/java/loader/Makefile.in
Normal file
49
mozilla/java/xpcom/java/loader/Makefile.in
Normal file
@@ -0,0 +1,49 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Sun Microsystems,
|
||||
# Inc. Portions created by Sun are
|
||||
# Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Igor Kushnirskiy <idk@eng.sun.com>
|
||||
#
|
||||
|
||||
DEPTH = ../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
MODULE = javaloader
|
||||
LIBRARY_NAME = javaloader
|
||||
IS_COMPONENT = 1
|
||||
|
||||
CPPSRCS = \
|
||||
bcJavaComponentLoader.cpp \
|
||||
bcJavaModule.cpp \
|
||||
bcJavaComponentFactory.cpp \
|
||||
$(NULL)
|
||||
|
||||
CXXFLAGS += -I$(JDKHOME)/include -I$(JDKHOME)/include/linux $(MOZ_TOOLKIT_REGISTRY_CFLAGS) -D_REENTRANT -DOJI_DISABLE -I$(CONNECT_SRC)/public
|
||||
|
||||
EXTRA_DSO_LDOPTS += \
|
||||
-L$(DIST)/bin/components/ \
|
||||
-lbcorb -lbcxpcomstubs -lbcjavastubs \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
90
mozilla/java/xpcom/java/loader/bcJavaComponentFactory.cpp
Normal file
90
mozilla/java/xpcom/java/loader/bcJavaComponentFactory.cpp
Normal file
@@ -0,0 +1,90 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are
|
||||
* Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsCRT.h"
|
||||
#include "bcJavaComponentFactory.h"
|
||||
#include "bcJavaStubsAndProxies.h"
|
||||
#include "bcXPCOMStubsAndProxies.h"
|
||||
#include "bcORB.h"
|
||||
|
||||
static NS_DEFINE_CID(kJavaStubsAndProxies,BC_JAVASTUBSANDPROXIES_CID);
|
||||
static NS_DEFINE_CID(kXPCOMStubsAndProxies,BC_XPCOMSTUBSANDPROXIES_CID);
|
||||
static NS_DEFINE_CID(kORBCIID,BC_ORB_CID);
|
||||
|
||||
NS_IMPL_ISUPPORTS1(bcJavaComponentFactory, nsIFactory)
|
||||
|
||||
|
||||
bcJavaComponentFactory::bcJavaComponentFactory(const char *_location) {
|
||||
NS_INIT_ISUPPORTS();
|
||||
location = nsCRT::strdup(_location);
|
||||
}
|
||||
|
||||
bcJavaComponentFactory::~bcJavaComponentFactory() {
|
||||
nsCRT::free((char*)location);
|
||||
}
|
||||
|
||||
/* void CreateInstance (in nsISupports aOuter, in nsIIDRef iid, [iid_is (iid), retval] out nsQIResult result);
|
||||
*/
|
||||
NS_IMETHODIMP bcJavaComponentFactory::CreateInstance(nsISupports *aOuter, const nsIID & iid, void * *result) {
|
||||
printf("--bcJavaComponentFactory::CreateInstance\n");
|
||||
nsresult r;
|
||||
NS_WITH_SERVICE(bcJavaStubsAndProxies, javaStubsAndProxies, kJavaStubsAndProxies, &r);
|
||||
if (NS_FAILED(r)) {
|
||||
printf("--bcJavaComponentFactory::CreateInstance javaStubsAndProxies failed \n");
|
||||
return r;
|
||||
}
|
||||
NS_WITH_SERVICE(bcXPCOMStubsAndProxies, xpcomStubsAndProxies, kXPCOMStubsAndProxies, &r);
|
||||
if (NS_FAILED(r)) {
|
||||
printf("--bcJavaComponentFactory::CreateInstance xpcomStubsAndProxies failed \n");
|
||||
return r;
|
||||
}
|
||||
NS_WITH_SERVICE(bcORB, _orb, kORBCIID, &r);
|
||||
if (NS_FAILED(r)) {
|
||||
printf("--bcJavaComponentFactory::CreateInstance bcORB failed \n");
|
||||
return r;
|
||||
}
|
||||
bcIORB *orb;
|
||||
_orb->GetORB(&orb);
|
||||
bcOID oid;
|
||||
r = javaStubsAndProxies->GetOID(location, &oid);
|
||||
printf("--bcJavaComponentFactory::CreateInstance after GetOID");
|
||||
nsISupports *proxy;
|
||||
printf("--[c++]bcJavaComponentFactory::CreateInstance iid:%s\n",iid.ToString());
|
||||
xpcomStubsAndProxies->GetProxy(oid, iid, orb, &proxy);
|
||||
*result = proxy;
|
||||
printf("--bcJavaComponentFactory::CreateInstance end");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void LockFactory (in PRBool lock); */
|
||||
NS_IMETHODIMP bcJavaComponentFactory::LockFactory(PRBool lock)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
39
mozilla/java/xpcom/java/loader/bcJavaComponentFactory.h
Normal file
39
mozilla/java/xpcom/java/loader/bcJavaComponentFactory.h
Normal file
@@ -0,0 +1,39 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are
|
||||
* Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
#ifndef __bcJavaComponentFactory_h
|
||||
#define __bcJavaComponentFactory_h
|
||||
#include "nsIFactory.h"
|
||||
|
||||
class bcJavaComponentFactory : public nsIFactory {
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIFACTORY
|
||||
bcJavaComponentFactory(const char *location);
|
||||
virtual ~bcJavaComponentFactory();
|
||||
private:
|
||||
char *location;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
466
mozilla/java/xpcom/java/loader/bcJavaComponentLoader.cpp
Normal file
466
mozilla/java/xpcom/java/loader/bcJavaComponentLoader.cpp
Normal file
@@ -0,0 +1,466 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are
|
||||
* Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
|
||||
/*
|
||||
A bunch of stuff was copied from mozJSComponentLoader.cpp
|
||||
*/
|
||||
#include "nsICategoryManager.h"
|
||||
#include "bcJavaComponentLoader.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIModule.h"
|
||||
#include "nsIGenericFactory.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsCRT.h"
|
||||
#include "bcJavaModule.h"
|
||||
|
||||
|
||||
|
||||
const char javaComponentTypeName[] = JAVACOMPONENTTYPENAME;
|
||||
|
||||
/* XXX export properly from libxpcom, for now this will let Mac build */
|
||||
#ifdef RHAPSODY
|
||||
extern const char fileSizeValueName[]; // = "FileSize";
|
||||
extern const char lastModValueName[]; // = "LastModTimeStamp";
|
||||
extern const char xpcomKeyName[]; // = "Software/Mozilla/XPCOM";
|
||||
#else
|
||||
const char fileSizeValueName[] = "FileSize";
|
||||
const char lastModValueName[] = "LastModTimeStamp";
|
||||
const char xpcomKeyName[] = "software/mozilla/XPCOM/components";
|
||||
#endif
|
||||
|
||||
NS_IMPL_ISUPPORTS(bcJavaComponentLoader,NS_GET_IID(nsIComponentLoader));
|
||||
|
||||
bcJavaComponentLoader::bcJavaComponentLoader()
|
||||
: mCompMgr(NULL),
|
||||
|
||||
mXPCOMKey(0)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
printf("--bcJavaComponentLoader::bcJavaComponentLoader \n");
|
||||
}
|
||||
|
||||
bcJavaComponentLoader::~bcJavaComponentLoader() { //nb
|
||||
printf("--bcJavaComponentLoader::~bcJavaComponentLoader \n");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the factory for a given component.
|
||||
*/
|
||||
/* nsIFactory getFactory (in nsIIDRef aCID, in string aLocation, in string aType); */
|
||||
NS_IMETHODIMP bcJavaComponentLoader::GetFactory(const nsIID & aCID, const char *aLocation, const char *aType, nsIFactory **_retval) {
|
||||
printf("--bcJavaComponentLoader::GetFactory \n");
|
||||
if (!_retval)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
#ifdef DEBUG
|
||||
char *cidString = aCID.ToString();
|
||||
fprintf(stderr, "--bcJavaComponentLoader::GetFactory(%s,%s,%s)\n", cidString, aLocation, aType);
|
||||
delete [] cidString;
|
||||
#endif
|
||||
nsIModule * module = ModuleForLocation(aLocation, 0);
|
||||
if (!module) {
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "ERROR: couldn't get module for %s\n", aLocation);
|
||||
#endif
|
||||
return NS_ERROR_FACTORY_NOT_LOADED;
|
||||
}
|
||||
|
||||
nsresult rv = module->GetClassObject(mCompMgr, aCID,
|
||||
NS_GET_IID(nsIFactory),
|
||||
(void **)_retval);
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "GetClassObject %s\n", NS_FAILED(rv) ? "FAILED" : "ok");
|
||||
#endif
|
||||
return rv;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the loader.
|
||||
*
|
||||
* We use nsISupports here because nsIRegistry isn't IDLized yet.
|
||||
*/
|
||||
/* void init (in nsIComponentManager aCompMgr, in nsISupports aRegistry); */
|
||||
NS_IMETHODIMP bcJavaComponentLoader::Init(nsIComponentManager *aCompMgr, nsISupports *aReg) {
|
||||
printf("--bcJavaComponentLoader::Init \n");
|
||||
nsresult rv;
|
||||
mCompMgr = aCompMgr;
|
||||
mRegistry = do_QueryInterface(aReg, &rv);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = mRegistry->GetSubtree(nsIRegistry::Common, xpcomKeyName,
|
||||
&mXPCOMKey);
|
||||
if (NS_FAILED(rv))
|
||||
/* if we can't get the XPCOM key, just skip all registry ops */
|
||||
mRegistry = nsnull;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a component of the appropriate type is registered,
|
||||
* to give the component loader an opportunity to do things like
|
||||
* annotate the registry and such.
|
||||
*/
|
||||
/* void onRegister (in nsIIDRef aCID, in string aType, in string aClassName, in string aProgID, in string aLocation, in boolean aReplace, in boolean aPersist); */
|
||||
NS_IMETHODIMP bcJavaComponentLoader::OnRegister(const nsIID & aCID, const char *aType, const char *aClassName, const char *aProgID, const char *aLocation, PRBool aReplace, PRBool aPersist) { //nb
|
||||
printf("--bcJavaComponentLoader::OnRegister \n");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* AutoRegister components in the given directory.
|
||||
*/
|
||||
NS_IMETHODIMP bcJavaComponentLoader::AutoRegisterComponents(PRInt32 aWhen, nsIFile *aDirectory) {
|
||||
printf("--bcJavaComponentLoader::AutoRegisterComponents \n");
|
||||
return RegisterComponentsInDir(aWhen,aDirectory);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP bcJavaComponentLoader::AutoUnregisterComponent(PRInt32 when,
|
||||
nsIFile *component,
|
||||
PRBool *unregistered) {
|
||||
//nb need to impelement
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult bcJavaComponentLoader::RegisterComponentsInDir(PRInt32 when, nsIFile *dir)
|
||||
{
|
||||
nsresult rv;
|
||||
PRBool isDir;
|
||||
|
||||
if (NS_FAILED(rv = dir->IsDirectory(&isDir)))
|
||||
return rv;
|
||||
|
||||
if (!isDir)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
// Create a directory iterator
|
||||
nsCOMPtr<nsISimpleEnumerator> dirIterator;
|
||||
rv = dir->GetDirectoryEntries(getter_AddRefs(dirIterator));
|
||||
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// whip through the directory to register every file
|
||||
nsIFile *dirEntry = NULL;
|
||||
PRBool more = PR_FALSE;
|
||||
|
||||
rv = dirIterator->HasMoreElements(&more);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
while (more == PR_TRUE)
|
||||
{
|
||||
rv = dirIterator->GetNext((nsISupports**)&dirEntry);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
rv = dirEntry->IsDirectory(&isDir);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
if (isDir == PR_TRUE)
|
||||
{
|
||||
// This is a directory. Grovel for components into the directory.
|
||||
rv = RegisterComponentsInDir(when, dirEntry);
|
||||
}
|
||||
else
|
||||
{
|
||||
PRBool registered;
|
||||
// This is a file. Try to register it.
|
||||
rv = AutoRegisterComponent(when, dirEntry, ®istered);
|
||||
}
|
||||
}
|
||||
NS_RELEASE(dirEntry);
|
||||
}
|
||||
rv = dirIterator->HasMoreElements(&more);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* AutoRegister the given component.
|
||||
*
|
||||
* Returns true if the component was registered, false if it couldn't
|
||||
* attempt to register the component (wrong type) and ``throws'' an
|
||||
* NS_FAILED code if there was an error during registration.
|
||||
*/
|
||||
/* boolean autoRegisterComponent (in long aWhen, in nsIFile aComponent); */
|
||||
|
||||
/* copied from mozJSComponentLoader.cpp */
|
||||
NS_IMETHODIMP bcJavaComponentLoader::AutoRegisterComponent(PRInt32 when, nsIFile *component, PRBool *registered) {
|
||||
//printf("--bcJavaComponentLoader::AutoRegisterComponent \n");
|
||||
nsresult rv;
|
||||
if (!registered)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
const char javaExtension[] = ".jar.info";
|
||||
int javaExtensionLen = 9;
|
||||
nsXPIDLCString leafName;
|
||||
|
||||
*registered = PR_FALSE;
|
||||
|
||||
/* we only do files */
|
||||
PRBool isFile = PR_FALSE;
|
||||
if (NS_FAILED(rv = component->IsFile(&isFile)) || !isFile)
|
||||
return rv;
|
||||
|
||||
if (NS_FAILED(rv = component->GetLeafName(getter_Copies(leafName))))
|
||||
return rv;
|
||||
int len = PL_strlen(leafName);
|
||||
|
||||
/* if it's not javaExtension return now */
|
||||
if (len < javaExtensionLen || // too short
|
||||
PL_strcasecmp(leafName + len - javaExtensionLen, javaExtension))
|
||||
return NS_OK;
|
||||
|
||||
printf("--bcJavaComponentLoader: registering bcJavaComponent component %s\n",(const char *)leafName);
|
||||
rv = AttemptRegistration(component, PR_FALSE);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
printf("registered module %s\n", (const char *)leafName);
|
||||
else if (rv == NS_ERROR_FACTORY_REGISTER_AGAIN)
|
||||
printf("deferred module %s\n", (const char *)leafName);
|
||||
else
|
||||
printf("failed to register %s\n", (const char *)leafName);
|
||||
*registered = (PRBool) NS_SUCCEEDED(rv);
|
||||
return NS_OK;
|
||||
|
||||
}
|
||||
|
||||
|
||||
nsresult bcJavaComponentLoader::AttemptRegistration(nsIFile *component,
|
||||
PRBool deferred) {
|
||||
nsXPIDLCString registryLocation;
|
||||
nsresult rv;
|
||||
nsIModule *module;
|
||||
|
||||
rv = mCompMgr->RegistryLocationForSpec(component,
|
||||
getter_Copies(registryLocation));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
/* no need to check registry data on deferred reg */
|
||||
if (deferred || HasChanged(registryLocation, component)) {
|
||||
module = ModuleForLocation(registryLocation, component);
|
||||
if (module) {
|
||||
rv = module->RegisterSelf(mCompMgr, component, registryLocation,
|
||||
javaComponentTypeName);
|
||||
if (rv == NS_ERROR_FACTORY_REGISTER_AGAIN) {
|
||||
mDeferredComponents.AppendElement(component);
|
||||
/*
|
||||
* we don't enter in the registry because we may want to
|
||||
* try again on a later autoreg, in case a dependency has
|
||||
* become available.
|
||||
*/
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
}
|
||||
SetRegistryInfo(registryLocation, component);
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult bcJavaComponentLoader::SetRegistryInfo(const char *registryLocation,
|
||||
nsIFile *component)
|
||||
{
|
||||
if (!mRegistry.get())
|
||||
return NS_OK; // silent failure
|
||||
|
||||
nsresult rv;
|
||||
nsRegistryKey key;
|
||||
|
||||
rv = mRegistry->AddSubtreeRaw(mXPCOMKey, registryLocation, &key);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
PRInt64 modDate;
|
||||
|
||||
if (NS_FAILED(rv = component->GetLastModificationDate(&modDate)) ||
|
||||
NS_FAILED(rv = mRegistry->SetLongLong(key, lastModValueName, &modDate)))
|
||||
return rv;
|
||||
|
||||
PRInt64 fileSize;
|
||||
if (NS_FAILED(rv = component->GetFileSize(&fileSize)) ||
|
||||
NS_FAILED(rv = mRegistry->SetLongLong(key, fileSizeValueName, &fileSize)))
|
||||
return rv;
|
||||
printf("SetRegistryInfo(%s) => (%d,%d)\n", registryLocation,
|
||||
(int)modDate, (int)fileSize);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
PRBool bcJavaComponentLoader::HasChanged(const char *registryLocation, nsIFile *component) {
|
||||
/* if we don't have a registry handle, force registration of component */
|
||||
if (!mRegistry)
|
||||
return PR_TRUE;
|
||||
|
||||
nsRegistryKey key;
|
||||
if (NS_FAILED(mRegistry->GetSubtreeRaw(mXPCOMKey, registryLocation, &key)))
|
||||
return PR_TRUE;
|
||||
|
||||
/* check modification date */
|
||||
PRInt64 regTime, lastTime;
|
||||
if (NS_FAILED(mRegistry->GetLongLong(key, lastModValueName, ®Time)))
|
||||
return PR_TRUE;
|
||||
|
||||
if (NS_FAILED(component->GetLastModificationDate(&lastTime)) || LL_NE(lastTime, regTime))
|
||||
return PR_TRUE;
|
||||
|
||||
/* check file size */
|
||||
PRInt64 regSize;
|
||||
if (NS_FAILED(mRegistry->GetLongLong(key, fileSizeValueName, ®Size)))
|
||||
return PR_TRUE;
|
||||
PRInt64 size;
|
||||
if (NS_FAILED(component->GetFileSize(&size)) || LL_NE(size,regSize) )
|
||||
return PR_TRUE;
|
||||
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
nsIModule * bcJavaComponentLoader::ModuleForLocation(const char *registryLocation, nsIFile *component) {
|
||||
nsStringKey key(registryLocation);
|
||||
nsIModule *res = NULL;
|
||||
res = (nsIModule*)mModules.Get(&key);
|
||||
PRBool needRelease = PR_FALSE;
|
||||
if (res) {
|
||||
return res;
|
||||
}
|
||||
if (!component) {
|
||||
if (NS_FAILED(mCompMgr->SpecForRegistryLocation(registryLocation, &component)))
|
||||
return NULL;
|
||||
needRelease = PR_TRUE;
|
||||
}
|
||||
res = new bcJavaModule(registryLocation, component);
|
||||
if (needRelease) {
|
||||
NS_IF_RELEASE(component);
|
||||
}
|
||||
|
||||
if (res) {
|
||||
mModules.Put(&key,res);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
/**
|
||||
* Register any deferred (NS_ERROR_FACTORY_REGISTER_AGAIN) components.
|
||||
* Return registered-any-components?
|
||||
*/
|
||||
/* boolean registerDeferredComponents (in long aWhen); */
|
||||
NS_IMETHODIMP bcJavaComponentLoader::RegisterDeferredComponents(PRInt32 aWhen, PRBool *aRegistered) {
|
||||
printf("--bcJavaComponentLoader::RegisterDeferredComponents \n");
|
||||
nsresult rv;
|
||||
*aRegistered = PR_FALSE;
|
||||
PRUint32 count;
|
||||
rv = mDeferredComponents.Count(&count);
|
||||
printf("mJCL: registering deferred (%d)\n", count);
|
||||
if (NS_FAILED(rv) || !count)
|
||||
return NS_OK;
|
||||
|
||||
for (PRUint32 i = 0; i < count; i++) {
|
||||
nsCOMPtr<nsISupports> supports;
|
||||
nsCOMPtr<nsIFile> component;
|
||||
|
||||
rv = mDeferredComponents.GetElementAt(i, getter_AddRefs(supports));
|
||||
if (NS_FAILED(rv))
|
||||
continue;
|
||||
|
||||
component = do_QueryInterface(supports, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
continue;
|
||||
|
||||
rv = AttemptRegistration(component, PR_TRUE /* deferred */);
|
||||
if (rv != NS_ERROR_FACTORY_REGISTER_AGAIN) {
|
||||
if (NS_SUCCEEDED(rv))
|
||||
*aRegistered = PR_TRUE;
|
||||
mDeferredComponents.RemoveElementAt(i);
|
||||
}
|
||||
}
|
||||
rv = mDeferredComponents.Count(&count);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
if (*aRegistered)
|
||||
printf("mJCL: registered deferred, %d left\n", count);
|
||||
else
|
||||
printf("mJCL: didn't register any components, %d left\n", count);
|
||||
}
|
||||
/* are there any fatal errors? */
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Unload all components that are willing.
|
||||
*/
|
||||
/* void unloadAll (in long aWhen); */
|
||||
NS_IMETHODIMP bcJavaComponentLoader::UnloadAll(PRInt32 aWhen) { //nb
|
||||
printf("--bcJavaComponentLoader::UnloadAll \n");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------------------
|
||||
|
||||
/* XXX this should all be data-driven, via NS_IMPL_GETMODULE_WITH_CATEGORIES */
|
||||
static NS_METHOD
|
||||
RegisterJavaLoader(nsIComponentManager *aCompMgr, nsIFile *aPath,
|
||||
const char *registryLocation, const char *componentType)
|
||||
{
|
||||
printf("--JavaLoader got registered\n");
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsICategoryManager> catman =
|
||||
do_GetService(NS_CATEGORYMANAGER_PROGID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
nsXPIDLCString previous;
|
||||
return catman->AddCategoryEntry("component-loader", javaComponentTypeName,
|
||||
BC_JAVACOMPONENTLOADER_PROGID,
|
||||
PR_TRUE, PR_TRUE, getter_Copies(previous));
|
||||
|
||||
}
|
||||
|
||||
static NS_METHOD
|
||||
UnregisterJavaLoader(nsIComponentManager *aCompMgr, nsIFile *aPath,
|
||||
const char *registryLocation)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsICategoryManager> catman =
|
||||
do_GetService(NS_CATEGORYMANAGER_PROGID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
nsXPIDLCString javaLoader;
|
||||
rv = catman->GetCategoryEntry("component-loader", javaComponentTypeName,
|
||||
getter_Copies(javaLoader));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// only unregister if we're the current JS component loader
|
||||
if (!strcmp(javaLoader, BC_JAVACOMPONENTLOADER_PROGID)) {
|
||||
return catman->DeleteCategoryEntry("component-loader",
|
||||
javaComponentTypeName, PR_TRUE,
|
||||
getter_Copies(javaLoader));
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(bcJavaComponentLoader);
|
||||
static nsModuleComponentInfo components[] = {
|
||||
{ "Java component loader", BC_JAVACOMPONENTLOADER_CID,
|
||||
BC_JAVACOMPONENTLOADER_PROGID,
|
||||
bcJavaComponentLoaderConstructor,
|
||||
RegisterJavaLoader, UnregisterJavaLoader }
|
||||
};
|
||||
|
||||
NS_IMPL_NSGETMODULE("Java component loader", components);
|
||||
|
||||
|
||||
|
||||
67
mozilla/java/xpcom/java/loader/bcJavaComponentLoader.h
Normal file
67
mozilla/java/xpcom/java/loader/bcJavaComponentLoader.h
Normal file
@@ -0,0 +1,67 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are
|
||||
* Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
#ifndef _bcJavaComponentLoader_h
|
||||
#define _bcJavaComponentLoader_h
|
||||
#include "nsIComponentLoader.h"
|
||||
#include "nsIModule.h"
|
||||
#include "nsHashtable.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIFileSpec.h"
|
||||
#include "nsIFile.h"
|
||||
#include "nsIRegistry.h"
|
||||
#include "nsSupportsArray.h"
|
||||
|
||||
#define BC_JAVACOMPONENTLOADER_PROGID \
|
||||
"component://netscape/blackwood/blackconnect/java-component-loader"
|
||||
|
||||
/* 0d6b5198-1dd2-11b2-b2f0-ed49ba755db8 */
|
||||
#define BC_JAVACOMPONENTLOADER_CID \
|
||||
{ 0x0d6b5198, 0x1dd2, 0x11b2, \
|
||||
{0xb2, 0xf0, 0xed, 0x49, 0xba, 0x75, 0x5d, 0xb8 }}
|
||||
|
||||
#define JAVACOMPONENTTYPENAME "text/java"
|
||||
|
||||
class bcJavaComponentLoader : public nsIComponentLoader {
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSICOMPONENTLOADER
|
||||
|
||||
bcJavaComponentLoader();
|
||||
virtual ~bcJavaComponentLoader();
|
||||
protected:
|
||||
nsHashtable mModules;
|
||||
nsCOMPtr<nsIRegistry> mRegistry;
|
||||
nsIComponentManager* mCompMgr; // weak ref, should make it strong?
|
||||
nsRegistryKey mXPCOMKey;
|
||||
nsSupportsArray mDeferredComponents;
|
||||
|
||||
nsresult RegisterComponentsInDir(PRInt32 when, nsIFile *dir);
|
||||
nsresult AttemptRegistration(nsIFile *component, PRBool deferred);
|
||||
nsIModule * ModuleForLocation(const char *registryLocation, nsIFile *component);
|
||||
PRBool HasChanged(const char *registryLocation, nsIFile *component);
|
||||
nsresult SetRegistryInfo(const char *registryLocation, nsIFile *component);
|
||||
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
88
mozilla/java/xpcom/java/loader/bcJavaModule.cpp
Normal file
88
mozilla/java/xpcom/java/loader/bcJavaModule.cpp
Normal file
@@ -0,0 +1,88 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are
|
||||
* Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
#include <fstream.h>
|
||||
#include "nsCRT.h"
|
||||
#include "nsIAllocator.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "bcJavaModule.h"
|
||||
#include "bcJavaComponentFactory.h"
|
||||
|
||||
NS_IMPL_ISUPPORTS(bcJavaModule,NS_GET_IID(nsIModule));
|
||||
bcJavaModule::bcJavaModule(const char *registryLocation, nsIFile *component)
|
||||
: location(NULL) {
|
||||
NS_INIT_REFCNT();
|
||||
nsXPIDLCString str;
|
||||
component->GetPath(getter_Copies(str));
|
||||
location = nsCRT::strdup(str);
|
||||
printf("--JavaModule::JavaModule %s\n",(const char*)str);
|
||||
}
|
||||
|
||||
bcJavaModule::~bcJavaModule() {
|
||||
if (location) {
|
||||
nsCRT::free((char*)location);
|
||||
}
|
||||
}
|
||||
|
||||
/* void getClassObject (in nsIComponentManager aCompMgr, in nsCIDRef aClass, in nsIIDRef aIID, [iid_is (aIID), retval] out nsQIResult result); */
|
||||
NS_IMETHODIMP bcJavaModule::GetClassObject(nsIComponentManager *aCompMgr, const nsCID & aClass, const nsIID & aIID, void * *result) {
|
||||
printf("--JavaModule::GetClassObject\n");
|
||||
nsIFactory *f;
|
||||
f = new bcJavaComponentFactory(location);
|
||||
NS_ADDREF(f);
|
||||
*result = f;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void registerSelf (in nsIComponentManager aCompMgr, in nsIFile location, in string registryLocation, in string componentType); */
|
||||
NS_IMETHODIMP bcJavaModule::RegisterSelf(nsIComponentManager *aCompMgr, nsIFile *_location, const char *registryLocation, const char *componentType) {
|
||||
nsresult result = NS_OK;
|
||||
printf("--JavaModule::RegisterSelf\n");
|
||||
ifstream in(location);
|
||||
char cidStr[500], progid[1000], desc[1000];
|
||||
in.getline(cidStr,1000);
|
||||
in.getline(progid,1000);
|
||||
in.getline(desc,1000);
|
||||
printf("%s %s %s", cidStr, progid, desc);
|
||||
nsCID cid;
|
||||
cid.Parse((const char *)cidStr);
|
||||
aCompMgr->RegisterComponentWithType(cid, desc, progid, _location, registryLocation, PR_TRUE, PR_TRUE, componentType);
|
||||
return result;
|
||||
}
|
||||
|
||||
/* void unregisterSelf (in nsIComponentManager aCompMgr, in nsIFile location, in string registryLocation); */
|
||||
NS_IMETHODIMP bcJavaModule::UnregisterSelf(nsIComponentManager *aCompMgr, nsIFile *_location, const char *registryLocation) { //nb
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* boolean canUnload (in nsIComponentManager aCompMgr); */
|
||||
NS_IMETHODIMP bcJavaModule::CanUnload(nsIComponentManager *aCompMgr, PRBool *_retval) {
|
||||
if (!_retval) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
*_retval = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
35
mozilla/java/xpcom/java/loader/bcJavaModule.h
Normal file
35
mozilla/java/xpcom/java/loader/bcJavaModule.h
Normal file
@@ -0,0 +1,35 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are
|
||||
* Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
#ifndef _bcJavaModule_h
|
||||
#define _bcJavaModule_h
|
||||
#include "nsIModule.h"
|
||||
|
||||
class bcJavaModule : public nsIModule {
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIMODULE
|
||||
|
||||
bcJavaModule(const char *registryLocation, nsIFile *component);
|
||||
virtual ~bcJavaModule();
|
||||
protected:
|
||||
const char *location;
|
||||
};
|
||||
#endif
|
||||
48
mozilla/java/xpcom/java/loader/makefile.win
Normal file
48
mozilla/java/xpcom/java/loader/makefile.win
Normal file
@@ -0,0 +1,48 @@
|
||||
#!nmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Igor Kushnirskiy <idk@eng.sun.com>
|
||||
#
|
||||
|
||||
DEPTH=..\..\..\..
|
||||
|
||||
MAKE_OBJ_TYPE = DLL
|
||||
MODULE=bcjavaloader
|
||||
COMPONENT = 1
|
||||
DLLNAME = bcjavaloader
|
||||
|
||||
DLL=.\$(OBJDIR)\$(DLLNAME).dll
|
||||
|
||||
OBJS= \
|
||||
.\$(OBJDIR)\bcJavaComponentLoader.obj \
|
||||
.\$(OBJDIR)\bcJavaModule.obj \
|
||||
.\$(OBJDIR)\bcJavaComponentFactory.obj \
|
||||
$(NULL)
|
||||
|
||||
LLIBS=$(LLIBS) $(LIBNSPR) $(DIST)\lib\xpcom.lib
|
||||
|
||||
LINCS=-I$(JDKHOME)\include -I$(JDKHOME)\include\win32
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
install:: $(DLL)
|
||||
$(MAKE_INSTALL) $(DLL) $(DIST)\bin\components
|
||||
clobber::
|
||||
rm -f $(DIST)\bin\components\$(DLLNAME).dll
|
||||
35
mozilla/java/xpcom/java/makefile.win
Normal file
35
mozilla/java/xpcom/java/makefile.win
Normal file
@@ -0,0 +1,35 @@
|
||||
#!nmake
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Sun Microsystems,
|
||||
# Inc. Portions created by Sun are
|
||||
# Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Igor Kushnirskiy <idk@eng.sun.com>
|
||||
#
|
||||
|
||||
DEPTH = ..\..\..
|
||||
|
||||
DIRS= \
|
||||
loader \
|
||||
src \
|
||||
classes \
|
||||
test \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
|
||||
81
mozilla/java/xpcom/java/src/Makefile.in
Normal file
81
mozilla/java/xpcom/java/src/Makefile.in
Normal file
@@ -0,0 +1,81 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Igor Kushnirskiy <idk@eng.sun.com>
|
||||
#
|
||||
|
||||
|
||||
DEPTH =../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
LIBRARY_NAME = bcjavastubs
|
||||
MODULE = bcjavastubs
|
||||
IS_COMPONENT = 1
|
||||
|
||||
EXPORTS = \
|
||||
bcJavaStubsAndProxies.h
|
||||
|
||||
CPPSRCS = \
|
||||
bcJavaMarshalToolkit.cpp \
|
||||
bcJavaStub.cpp \
|
||||
bcJavaGlobal.cpp \
|
||||
bcJavaStubsAndProxies.cpp \
|
||||
bcIIDJava.cpp \
|
||||
org_mozilla_xpcom_Utilities.cpp \
|
||||
$(NULL)
|
||||
|
||||
CXXFLAGS += -I$(JDKHOME)/include -I$(JDKHOME)/include/linux $(MOZ_TOOLKIT_REGISTRY_CFLAGS) -D_REENTRANT -DOJI_DISABLE -I$(CONNECT_SRC)/public
|
||||
|
||||
|
||||
DSO_LDOPTS += \
|
||||
-L$(JDKHOME)/jre/lib/$(HOSTTYPE)/ \
|
||||
-L$(JDKHOME)/jre/lib/$(HOSTTYPE)/classic \
|
||||
-L$(JDKHOME)/jre/lib/$(HOSTTYPE)/native_threads \
|
||||
-ljvm -lhpi -ljava\
|
||||
$(NULL)
|
||||
|
||||
#DSO_LDOPTS += \
|
||||
# -L$(JDKHOME)/jre/bin \
|
||||
# -L$(JDKHOME)/jre/bin/classic \
|
||||
# -ljvm \
|
||||
# $(NULL)
|
||||
|
||||
ifneq ($(OS_ARCH), Linux)
|
||||
DSO_LDOPTS += \
|
||||
-lthread -lXm -lX11 -lXt -lm
|
||||
endif
|
||||
|
||||
EXTRA_DSO_LDOPTS += \
|
||||
-L$(DIST)/bin/components/ \
|
||||
-lbcorb \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
|
||||
|
||||
|
||||
99
mozilla/java/xpcom/java/src/bcIIDJava.cpp
Normal file
99
mozilla/java/xpcom/java/src/bcIIDJava.cpp
Normal file
@@ -0,0 +1,99 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are
|
||||
* Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
#include "bcIIDJava.h"
|
||||
#include "bcJavaGlobal.h"
|
||||
|
||||
jclass bcIIDJava::iidClass = NULL;
|
||||
jmethodID bcIIDJava::iidInitMID = NULL;
|
||||
jmethodID bcIIDJava::getStringMID = NULL;
|
||||
|
||||
|
||||
void bcIIDJava::Init(void) {
|
||||
JNIEnv * env = bcJavaGlobal::GetJNIEnv();
|
||||
if (env) {
|
||||
if (!(iidClass = env->FindClass("org/mozilla/xpcom/IID"))
|
||||
|| !(iidClass = (jclass) env->NewGlobalRef(iidClass))) {
|
||||
env->ExceptionDescribe();
|
||||
Destroy();
|
||||
return;
|
||||
}
|
||||
if (!(iidInitMID = env->GetMethodID(iidClass,"<init>","(Ljava/lang/String;)V"))) {
|
||||
env->ExceptionDescribe();
|
||||
Destroy();
|
||||
return;
|
||||
}
|
||||
if (!(getStringMID = env->GetMethodID(iidClass,"getString","()Ljava/lang/String;"))) {
|
||||
env->ExceptionDescribe();
|
||||
Destroy();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
void bcIIDJava::Destroy() {
|
||||
JNIEnv * env = bcJavaGlobal::GetJNIEnv();
|
||||
if (env) {
|
||||
if (iidClass) {
|
||||
env->DeleteGlobalRef(iidClass);
|
||||
iidClass = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
jobject bcIIDJava::GetObject(nsIID *iid) {
|
||||
JNIEnv * env = bcJavaGlobal::GetJNIEnv();
|
||||
if (!iid
|
||||
|| !env ) {
|
||||
return NULL;
|
||||
}
|
||||
if (!iidClass) {
|
||||
Init();
|
||||
}
|
||||
char *str = iid->ToString(); //nb free ?
|
||||
jstring jstr = NULL;
|
||||
if (str) {
|
||||
char *siid = str+1; //we do need to have it. The format is {_xxx-xxx-xxx_}
|
||||
siid[strlen(siid)-1] = 0;
|
||||
jstr = env->NewStringUTF((const char *)siid);
|
||||
}
|
||||
return env->NewObject(iidClass,iidInitMID,jstr);
|
||||
}
|
||||
|
||||
jclass bcIIDJava::GetClass() {
|
||||
return iidClass;
|
||||
}
|
||||
|
||||
nsIID bcIIDJava::GetIID(jobject obj) {
|
||||
nsIID iid;
|
||||
JNIEnv * env = bcJavaGlobal::GetJNIEnv();
|
||||
if (env) {
|
||||
if (!iidClass) {
|
||||
Init();
|
||||
}
|
||||
jstring jstr = (jstring)env->CallObjectMethod(obj, getStringMID);
|
||||
const char * str = NULL;
|
||||
str = env->GetStringUTFChars(jstr,NULL);
|
||||
iid.Parse(str);
|
||||
env->ReleaseStringUTFChars(jstr,str);
|
||||
|
||||
}
|
||||
return iid;
|
||||
}
|
||||
41
mozilla/java/xpcom/java/src/bcIIDJava.h
Normal file
41
mozilla/java/xpcom/java/src/bcIIDJava.h
Normal file
@@ -0,0 +1,41 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are
|
||||
* Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
#ifndef __bcIIDJava_H
|
||||
#define __bcIIDJava_H
|
||||
|
||||
#include "nsIID.h"
|
||||
#include "jni.h"
|
||||
|
||||
class bcIIDJava {
|
||||
public:
|
||||
static jobject GetObject(nsIID * iid);
|
||||
static nsIID GetIID(jobject obj);
|
||||
static jclass GetClass();
|
||||
private:
|
||||
static jclass iidClass;
|
||||
static jmethodID iidInitMID;
|
||||
static jmethodID getStringMID;
|
||||
static void Init(void);
|
||||
static void Destroy(void);
|
||||
};
|
||||
|
||||
#endif
|
||||
113
mozilla/java/xpcom/java/src/bcJavaGlobal.cpp
Normal file
113
mozilla/java/xpcom/java/src/bcJavaGlobal.cpp
Normal file
@@ -0,0 +1,113 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are
|
||||
* Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
#include "bcJavaGlobal.h"
|
||||
#include "prenv.h"
|
||||
|
||||
|
||||
JavaVM *bcJavaGlobal::jvm = NULL;
|
||||
|
||||
#ifdef XP_PC
|
||||
#define PATH_SEPARATOR ';'
|
||||
#else
|
||||
#define PATH_SEPARATOR ':'
|
||||
#endif
|
||||
|
||||
#ifdef JRI_MD_H //we are using jni.h from netscape
|
||||
#define JNIENV
|
||||
#else
|
||||
#define JNIENV (void**)
|
||||
#endif
|
||||
|
||||
JNIEnv * bcJavaGlobal::GetJNIEnv(void) {
|
||||
JNIEnv * env;
|
||||
int res;
|
||||
if (!jvm) {
|
||||
StartJVM();
|
||||
}
|
||||
if (jvm) {
|
||||
res = jvm->AttachCurrentThread(JNIENV &env,NULL);
|
||||
}
|
||||
return env;
|
||||
}
|
||||
|
||||
|
||||
void bcJavaGlobal::StartJVM() {
|
||||
printf("--bcJavaGlobal::StartJVM begin\n");
|
||||
JNIEnv *env = NULL;
|
||||
jint res;
|
||||
jsize jvmCount;
|
||||
JNI_GetCreatedJavaVMs(&jvm, 1, &jvmCount);
|
||||
printf("--bcJavaGlobal::StartJVM after GetCreatedJavaVMs\n");
|
||||
if (jvmCount) {
|
||||
return;
|
||||
}
|
||||
#if 0
|
||||
JDK1_1InitArgs vm_args;
|
||||
char classpath[1024];
|
||||
JNI_GetDefaultJavaVMInitArgs(&vm_args);
|
||||
printf("--[c++] version %d",(int)vm_args.version);
|
||||
vm_args.version = 0x00010001;
|
||||
/* Append USER_CLASSPATH to the default system class path */
|
||||
sprintf(classpath, "%s%c%s",
|
||||
vm_args.classpath, PATH_SEPARATOR, PR_GetEnv("CLASSPATH"));
|
||||
printf("--[c++] classpath %s\n",classpath);
|
||||
char **props = new char*[2];
|
||||
props[0]="java.compiler=NONE";
|
||||
props[1]=0;
|
||||
vm_args.properties = props;
|
||||
vm_args.classpath = classpath;
|
||||
/* Create the Java VM */
|
||||
res = JNI_CreateJavaVM(&jvm, JNIENV &env, &vm_args);
|
||||
#else
|
||||
char classpath[1024];
|
||||
JavaVMInitArgs vm_args;
|
||||
JavaVMOption options[2];
|
||||
sprintf(classpath, "-Djava.class.path=%s",PR_GetEnv("CLASSPATH"));
|
||||
printf("--[c++] classpath %s\n",classpath);
|
||||
options[0].optionString = classpath;
|
||||
options[1].optionString=""; //-Djava.compiler=NONE";
|
||||
vm_args.version = 0x00010002;
|
||||
vm_args.options = options;
|
||||
vm_args.nOptions = 2;
|
||||
vm_args.ignoreUnrecognized = JNI_TRUE;
|
||||
/* Create the Java VM */
|
||||
res = JNI_CreateJavaVM(&jvm, (void**)&env, &vm_args);
|
||||
#endif
|
||||
printf("--bcJavaGlobal::StartJVM jvm started res %d\n",res);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
34
mozilla/java/xpcom/java/src/bcJavaGlobal.h
Normal file
34
mozilla/java/xpcom/java/src/bcJavaGlobal.h
Normal file
@@ -0,0 +1,34 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are
|
||||
* Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
#ifndef __bcJavaGlobal_h_
|
||||
#define __bcJavaGlobal_h_
|
||||
#include "nscore.h"
|
||||
#include "jni.h"
|
||||
|
||||
class bcJavaGlobal {
|
||||
public:
|
||||
static JNIEnv * GetJNIEnv(void);
|
||||
private:
|
||||
static JavaVM *jvm;
|
||||
static void StartJVM(void);
|
||||
};
|
||||
#endif
|
||||
787
mozilla/java/xpcom/java/src/bcJavaMarshalToolkit.cpp
Normal file
787
mozilla/java/xpcom/java/src/bcJavaMarshalToolkit.cpp
Normal file
@@ -0,0 +1,787 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are
|
||||
* Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
|
||||
#include "nsIAllocator.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "bcJavaMarshalToolkit.h"
|
||||
#include "bcIIDJava.h"
|
||||
#include "bcJavaStubsAndProxies.h"
|
||||
#include "nsIServiceManager.h"
|
||||
|
||||
jclass bcJavaMarshalToolkit::objectClass = NULL;
|
||||
jclass bcJavaMarshalToolkit::objectArrayClass = NULL;
|
||||
jclass bcJavaMarshalToolkit::booleanClass = NULL;
|
||||
jclass bcJavaMarshalToolkit::booleanArrayClass = NULL;
|
||||
jmethodID bcJavaMarshalToolkit::booleanInitMID = NULL;
|
||||
jmethodID bcJavaMarshalToolkit::booleanValueMID = NULL;
|
||||
|
||||
jclass bcJavaMarshalToolkit::charClass = NULL;
|
||||
jclass bcJavaMarshalToolkit::charArrayClass = NULL;
|
||||
jmethodID bcJavaMarshalToolkit::charInitMID = NULL;
|
||||
jmethodID bcJavaMarshalToolkit::charValueMID = NULL;
|
||||
|
||||
jclass bcJavaMarshalToolkit::byteClass = NULL;
|
||||
jclass bcJavaMarshalToolkit::byteArrayClass = NULL;
|
||||
jmethodID bcJavaMarshalToolkit::byteInitMID = NULL;
|
||||
jmethodID bcJavaMarshalToolkit::byteValueMID = NULL;
|
||||
|
||||
jclass bcJavaMarshalToolkit::shortClass = NULL;
|
||||
jclass bcJavaMarshalToolkit::shortArrayClass = NULL;
|
||||
jmethodID bcJavaMarshalToolkit::shortInitMID = NULL;
|
||||
jmethodID bcJavaMarshalToolkit::shortValueMID = NULL;
|
||||
|
||||
jclass bcJavaMarshalToolkit::intClass = NULL;
|
||||
jclass bcJavaMarshalToolkit::intArrayClass = NULL;
|
||||
jmethodID bcJavaMarshalToolkit::intInitMID = NULL;
|
||||
jmethodID bcJavaMarshalToolkit::intValueMID = NULL;
|
||||
|
||||
jclass bcJavaMarshalToolkit::longClass = NULL;
|
||||
jclass bcJavaMarshalToolkit::longArrayClass = NULL;
|
||||
jmethodID bcJavaMarshalToolkit::longInitMID = NULL;
|
||||
jmethodID bcJavaMarshalToolkit::longValueMID = NULL;
|
||||
|
||||
jclass bcJavaMarshalToolkit::floatClass = NULL;
|
||||
jclass bcJavaMarshalToolkit::floatArrayClass = NULL;
|
||||
jmethodID bcJavaMarshalToolkit::floatInitMID = NULL;
|
||||
jmethodID bcJavaMarshalToolkit::floatValueMID = NULL;
|
||||
|
||||
jclass bcJavaMarshalToolkit::doubleClass = NULL;
|
||||
jclass bcJavaMarshalToolkit::doubleArrayClass = NULL;
|
||||
jmethodID bcJavaMarshalToolkit::doubleInitMID = NULL;
|
||||
jmethodID bcJavaMarshalToolkit::doubleValueMID = NULL;
|
||||
|
||||
jclass bcJavaMarshalToolkit::stringClass = NULL;
|
||||
jclass bcJavaMarshalToolkit::stringArrayClass = NULL;
|
||||
|
||||
jclass bcJavaMarshalToolkit::iidClass = NULL;
|
||||
jclass bcJavaMarshalToolkit::iidArrayClass = NULL;
|
||||
|
||||
jmethodID bcJavaMarshalToolkit::getClassMID = NULL;
|
||||
|
||||
|
||||
static NS_DEFINE_CID(kJavaStubsAndProxies,BC_JAVASTUBSANDPROXIES_CID);
|
||||
|
||||
bcJavaMarshalToolkit::bcJavaMarshalToolkit(PRUint16 _methodIndex,
|
||||
nsIInterfaceInfo *_interfaceInfo, jobjectArray _args, JNIEnv *_env, int isOnServer, bcIORB *_orb) {
|
||||
env = _env;
|
||||
callSide = (isOnServer) ? onServer : onClient;
|
||||
methodIndex = _methodIndex;
|
||||
interfaceInfo = _interfaceInfo;
|
||||
interfaceInfo->GetMethodInfo(methodIndex,(const nsXPTMethodInfo **)&info); // These do *not* make copies ***explicit bending of XPCOM rules***
|
||||
args = _args;
|
||||
if(!objectClass) {
|
||||
InitializeStatic();
|
||||
if(!objectClass) {
|
||||
//nb ? we do not have java classes. What could we do?
|
||||
}
|
||||
}
|
||||
orb = _orb;
|
||||
}
|
||||
|
||||
bcJavaMarshalToolkit::~bcJavaMarshalToolkit() {
|
||||
}
|
||||
|
||||
class javaAllocator : public bcIAllocator {
|
||||
public:
|
||||
javaAllocator(nsIAllocator *_allocator) {
|
||||
allocator = _allocator;
|
||||
}
|
||||
virtual ~javaAllocator() {}
|
||||
virtual void * Alloc(size_t size) {
|
||||
return allocator->Alloc(size);
|
||||
}
|
||||
virtual void Free(void *ptr) {
|
||||
allocator->Free(ptr);
|
||||
}
|
||||
virtual void * Realloc(void* ptr, size_t size) {
|
||||
return allocator->Realloc(ptr,size);
|
||||
}
|
||||
private:
|
||||
nsCOMPtr<nsIAllocator> allocator;
|
||||
};
|
||||
|
||||
|
||||
nsresult bcJavaMarshalToolkit::Marshal(bcIMarshaler *m) {
|
||||
|
||||
PRUint32 paramCount = info->GetParamCount();
|
||||
nsresult r = NS_OK;
|
||||
for (unsigned int i = 0; (i < paramCount) && NS_SUCCEEDED(r); i++) {
|
||||
nsXPTParamInfo param = info->GetParam(i);
|
||||
if ((callSide == onClient && !param.IsIn())
|
||||
|| (callSide == onServer && !param.IsOut())) {
|
||||
continue;
|
||||
}
|
||||
jobject object = env->GetObjectArrayElement(args,i);
|
||||
r = MarshalElement(m, object, param.IsOut(), ¶m, XPTType2bcXPType(param.GetType().TagPart()), i);
|
||||
}
|
||||
return r;
|
||||
|
||||
}
|
||||
|
||||
nsresult bcJavaMarshalToolkit::UnMarshal(bcIUnMarshaler *um) {
|
||||
printf("--nsresult bcJavaMarshalToolkit::UnMarshal\n");
|
||||
bcIAllocator * allocator = new javaAllocator(nsAllocator::GetGlobalAllocator());
|
||||
PRUint32 paramCount = info->GetParamCount();
|
||||
jobject value;
|
||||
for (unsigned int i = 0; i < paramCount; i++) {
|
||||
nsXPTParamInfo param = info->GetParam(i);
|
||||
PRBool isOut = param.IsOut();
|
||||
nsXPTType type = param.GetType();
|
||||
if ( (callSide == onServer && !param.IsIn()
|
||||
|| (callSide == onClient && !param.IsOut()))){
|
||||
if (callSide == onServer
|
||||
&& isOut) { //we need to allocate memory for out parametr
|
||||
UnMarshalElement(&value, i, NULL, 1, ¶m, XPTType2bcXPType(type.TagPart()),allocator);
|
||||
env->SetObjectArrayElement(args,i,value);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
UnMarshalElement(&value, i, um, isOut, ¶m, XPTType2bcXPType(type.TagPart()),allocator);
|
||||
env->SetObjectArrayElement(args,i,value);
|
||||
}
|
||||
delete allocator;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#define MARSHAL_SIMPLE_ELEMENT(_type_,_Type_) \
|
||||
do { \
|
||||
int indexInArray; \
|
||||
j##_type_ data; \
|
||||
if (! isOut \
|
||||
&& (modifier == none)) { \
|
||||
data = env->Call##_Type_##Method(value,_type_##ValueMID); \
|
||||
} else if (isOut && (modifier == array)) { \
|
||||
/* could not happend. We take care about it in T_ARRAY case */ \
|
||||
} else if (modifier == arrayElement \
|
||||
|| (isOut && (modifier == none))) { \
|
||||
indexInArray = (modifier == arrayElement) ? ind : 0; \
|
||||
env->Get##_Type_##ArrayRegion((j##_type_##Array)value, indexInArray, 1, &data); \
|
||||
} \
|
||||
m->WriteSimple(&data,type); \
|
||||
} while (0)
|
||||
|
||||
nsresult
|
||||
bcJavaMarshalToolkit::MarshalElement(bcIMarshaler *m, jobject value, PRBool isOut, nsXPTParamInfo * param,
|
||||
bcXPType type, uint8 ind, ArrayModifier modifier) {
|
||||
nsresult r = NS_OK;
|
||||
|
||||
switch(type) {
|
||||
case bc_T_I8:
|
||||
case bc_T_U8:
|
||||
{
|
||||
MARSHAL_SIMPLE_ELEMENT(byte,Byte);
|
||||
break;
|
||||
}
|
||||
case bc_T_I16:
|
||||
case bc_T_U16:
|
||||
{
|
||||
MARSHAL_SIMPLE_ELEMENT(short,Short);
|
||||
break;
|
||||
};
|
||||
case bc_T_I32:
|
||||
case bc_T_U32:
|
||||
{
|
||||
MARSHAL_SIMPLE_ELEMENT(int,Int);
|
||||
break;
|
||||
}
|
||||
case bc_T_I64:
|
||||
case bc_T_U64:
|
||||
{
|
||||
MARSHAL_SIMPLE_ELEMENT(long,Long);
|
||||
break;
|
||||
}
|
||||
case bc_T_FLOAT:
|
||||
{
|
||||
MARSHAL_SIMPLE_ELEMENT(float,Float);
|
||||
break;
|
||||
}
|
||||
|
||||
case bc_T_DOUBLE:
|
||||
{
|
||||
MARSHAL_SIMPLE_ELEMENT(double,Double);
|
||||
break;
|
||||
}
|
||||
case bc_T_BOOL:
|
||||
{
|
||||
MARSHAL_SIMPLE_ELEMENT(boolean,Boolean);
|
||||
break;
|
||||
}
|
||||
case bc_T_CHAR:
|
||||
case bc_T_WCHAR:
|
||||
{
|
||||
MARSHAL_SIMPLE_ELEMENT(char,Char);
|
||||
break;
|
||||
}
|
||||
case bc_T_CHAR_STR:
|
||||
case bc_T_WCHAR_STR: //nb not sure about this
|
||||
{
|
||||
int indexInArray;
|
||||
jstring data = NULL;
|
||||
if (! isOut
|
||||
&& (modifier == none)) {
|
||||
data = (jstring)value;
|
||||
} else if (modifier == arrayElement
|
||||
|| (isOut && (modifier == none))) {
|
||||
indexInArray = (modifier == arrayElement) ? ind : 0;
|
||||
data = (jstring)env->GetObjectArrayElement((jobjectArray)value,indexInArray);
|
||||
}
|
||||
char * str = NULL;
|
||||
if (data) {
|
||||
str = (char*)env->GetStringUTFChars((jstring)data,NULL);
|
||||
m->WriteString(str,strlen(str)+1);
|
||||
env->ReleaseStringUTFChars(data,str);
|
||||
} else {
|
||||
m->WriteString(str,0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case bc_T_IID:
|
||||
{
|
||||
int indexInArray;
|
||||
jobject data = NULL;
|
||||
if (! isOut
|
||||
&& (modifier == none)) {
|
||||
data = value;
|
||||
} else if (modifier == arrayElement
|
||||
|| (isOut && (modifier == none))) {
|
||||
indexInArray = (modifier == arrayElement) ? ind : 0;
|
||||
data = (jstring)env->GetObjectArrayElement((jobjectArray)value,indexInArray);
|
||||
}
|
||||
nsIID iid = bcIIDJava::GetIID(data);
|
||||
m->WriteSimple(&iid, type);
|
||||
break;
|
||||
}
|
||||
|
||||
case bc_T_INTERFACE:
|
||||
{
|
||||
int indexInArray;
|
||||
jobject data = NULL;
|
||||
printf("--marshalElement we got interface\n");
|
||||
bcOID oid = 0;
|
||||
nsIID *iid;
|
||||
if (! isOut
|
||||
&& (modifier == none)) {
|
||||
data = value;
|
||||
} else if (modifier == arrayElement
|
||||
|| (isOut && (modifier == none))) {
|
||||
indexInArray = (modifier == arrayElement) ? ind : 0;
|
||||
data = env->GetObjectArrayElement((jobjectArray)value,indexInArray);
|
||||
}
|
||||
if (data != NULL) {
|
||||
NS_WITH_SERVICE(bcJavaStubsAndProxies, javaStubsAndProxies, kJavaStubsAndProxies, &r);
|
||||
if (NS_FAILED(r)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
javaStubsAndProxies->GetOID(data, orb, &oid);
|
||||
}
|
||||
m->WriteSimple(&oid,type);
|
||||
|
||||
if (param->GetType().TagPart() == nsXPTType::T_INTERFACE) {
|
||||
if(NS_FAILED(r = interfaceInfo->
|
||||
GetIIDForParam(methodIndex, param, &iid))) {
|
||||
return r;
|
||||
}
|
||||
m->WriteSimple(iid,bc_T_IID);
|
||||
} else {
|
||||
uint8 argnum;
|
||||
if (NS_FAILED(r = interfaceInfo->GetInterfaceIsArgNumberForParam(methodIndex,
|
||||
param, &argnum))) {
|
||||
return r;
|
||||
}
|
||||
const nsXPTParamInfo& arg_param = info->GetParam(argnum);
|
||||
jobject object = env->GetObjectArrayElement(args,argnum);
|
||||
r = MarshalElement(m, object, arg_param.IsOut(),(nsXPTParamInfo*)&arg_param,
|
||||
XPTType2bcXPType(arg_param.GetType().TagPart()), (uint8)0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case bc_T_ARRAY:
|
||||
{
|
||||
nsXPTType datumType;
|
||||
if(NS_FAILED(interfaceInfo->GetTypeForParam(methodIndex, param, 1,&datumType))) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
bcXPType type = XPTType2bcXPType(datumType.TagPart());
|
||||
jobject arrayValue = value;
|
||||
if (isOut) {
|
||||
arrayValue = env->GetObjectArrayElement((jobjectArray)value,0);
|
||||
}
|
||||
if (m != NULL) {
|
||||
PRUint32 arraySize = (arrayValue == NULL) ? 0 : env->GetArrayLength((jarray)arrayValue);
|
||||
m->WriteSimple(&arraySize,bc_T_U32);
|
||||
for (PRUint32 i = 0; i < arraySize; i++) {
|
||||
MarshalElement(m,arrayValue,PR_FALSE,param,type,i,arrayElement);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
printf("--it should not happend\n");
|
||||
;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
#define UNMARSHAL_SIMPLE_ELEMENT(_type_,_Type_) \
|
||||
do { \
|
||||
int indexInArray; \
|
||||
j##_type_ data; \
|
||||
if (um) { \
|
||||
um->ReadSimple(&data,type); \
|
||||
} \
|
||||
if ( ! isOut \
|
||||
&& (modifier == none) ) { \
|
||||
*value = env->NewObject(_type_##Class,_type_##InitMID,data); \
|
||||
} else if (isOut && (modifier == array)) { \
|
||||
*value = env->NewObjectArray(1, _type_##ArrayClass, NULL); \
|
||||
} else if (isOut \
|
||||
|| (modifier == array)) { \
|
||||
int arraySize; \
|
||||
arraySize = (modifier == array) ? ind : 1; \
|
||||
*value = env->New##_Type_##Array(arraySize); \
|
||||
} \
|
||||
if (modifier == arrayElement \
|
||||
|| (isOut && (modifier == none)) \
|
||||
) { \
|
||||
indexInArray = (modifier == arrayElement) ? ind : 0; \
|
||||
env->Set##_Type_##ArrayRegion((j##_type_##Array)*value, indexInArray, 1, &data); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
nsresult
|
||||
bcJavaMarshalToolkit::UnMarshalElement(jobject *value, uint8 ind, bcIUnMarshaler *um, int isOut, nsXPTParamInfo * param,
|
||||
bcXPType type, bcIAllocator *allocator, ArrayModifier modifier) {
|
||||
switch(type) {
|
||||
case bc_T_I8:
|
||||
case bc_T_U8:
|
||||
{
|
||||
UNMARSHAL_SIMPLE_ELEMENT(byte,Byte);
|
||||
break;
|
||||
}
|
||||
case bc_T_I16:
|
||||
case bc_T_U16:
|
||||
{
|
||||
UNMARSHAL_SIMPLE_ELEMENT(short,Short);
|
||||
break;
|
||||
};
|
||||
case bc_T_I32:
|
||||
case bc_T_U32:
|
||||
{
|
||||
UNMARSHAL_SIMPLE_ELEMENT(int,Int);
|
||||
break;
|
||||
}
|
||||
case bc_T_I64:
|
||||
case bc_T_U64:
|
||||
{
|
||||
UNMARSHAL_SIMPLE_ELEMENT(long,Long);
|
||||
break;
|
||||
}
|
||||
case bc_T_FLOAT:
|
||||
{
|
||||
UNMARSHAL_SIMPLE_ELEMENT(float,Float);
|
||||
break;
|
||||
}
|
||||
|
||||
case bc_T_DOUBLE:
|
||||
{
|
||||
UNMARSHAL_SIMPLE_ELEMENT(double,Double);
|
||||
break;
|
||||
}
|
||||
case bc_T_BOOL:
|
||||
{
|
||||
UNMARSHAL_SIMPLE_ELEMENT(boolean,Boolean);
|
||||
break;
|
||||
}
|
||||
case bc_T_CHAR:
|
||||
case bc_T_WCHAR:
|
||||
{
|
||||
UNMARSHAL_SIMPLE_ELEMENT(char,Char);
|
||||
break;
|
||||
}
|
||||
case bc_T_CHAR_STR:
|
||||
case bc_T_WCHAR_STR: //nb not sure about this
|
||||
{
|
||||
int indexInArray;
|
||||
size_t size;
|
||||
jstring data = NULL;
|
||||
if (um) {
|
||||
um->ReadString(&data,&size,allocator);
|
||||
data = env->NewStringUTF((const char*)data);
|
||||
}
|
||||
if ( ! isOut
|
||||
&& (modifier == none) ) {
|
||||
*value = data;
|
||||
} else if (isOut && (modifier == array)) {
|
||||
*value = env->NewObjectArray(1, stringArrayClass, NULL);
|
||||
} else if (isOut
|
||||
|| (modifier == array)) {
|
||||
int arraySize;
|
||||
arraySize = (modifier == array) ? ind : 1;
|
||||
*value = env->NewObjectArray(arraySize,stringClass,NULL);
|
||||
}
|
||||
if (modifier == arrayElement
|
||||
|| (isOut && (modifier == none))
|
||||
) {
|
||||
indexInArray = (modifier == arrayElement) ? ind : 0;
|
||||
env->SetObjectArrayElement((jobjectArray)*value, indexInArray, data);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case bc_T_IID:
|
||||
{
|
||||
int indexInArray = 0;
|
||||
jobject data = NULL;
|
||||
if (um) {
|
||||
nsIID iid;
|
||||
um->ReadSimple(&iid,type);
|
||||
data = bcIIDJava::GetObject(&iid);
|
||||
}
|
||||
if ( ! isOut
|
||||
&& (modifier == none) ) {
|
||||
*value = data;
|
||||
} else if (isOut && (modifier == array)) {
|
||||
*value = env->NewObjectArray(1, iidArrayClass, NULL);
|
||||
} else if (isOut
|
||||
|| (modifier == array)) {
|
||||
int arraySize;
|
||||
arraySize = (modifier == array) ? ind : 1;
|
||||
*value = env->NewObjectArray(arraySize,iidClass,NULL);
|
||||
}
|
||||
if (modifier == arrayElement
|
||||
|| (isOut && (modifier == none))
|
||||
) {
|
||||
indexInArray = (modifier == arrayElement) ? ind : 0;
|
||||
env->SetObjectArrayElement((jobjectArray)*value, indexInArray, data);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case bc_T_INTERFACE:
|
||||
{
|
||||
printf("--[c++] bcJavaMarshalToolkit::UnMarshalElement we have an interface\n");
|
||||
int indexInArray = 0;
|
||||
jobject data = NULL;
|
||||
bcOID oid = 0;
|
||||
nsIID iid;
|
||||
nsresult r;
|
||||
jclass clazz = objectClass;
|
||||
if (um) {
|
||||
um->ReadSimple(&oid,type);
|
||||
um->ReadSimple(&iid,bc_T_IID);
|
||||
printf("%d oid\n",(int) oid);
|
||||
NS_WITH_SERVICE(bcJavaStubsAndProxies, javaStubsAndProxies, kJavaStubsAndProxies, &r);
|
||||
if (NS_FAILED(r)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (oid != 0) {
|
||||
javaStubsAndProxies->GetProxy(oid, iid, orb, &data);
|
||||
}
|
||||
javaStubsAndProxies->GetInterface(iid,&clazz);
|
||||
}
|
||||
|
||||
if ( ! isOut
|
||||
&& (modifier == none) ) {
|
||||
*value = data;
|
||||
} else if (isOut && (modifier == array)) { //how to create type[][] ?
|
||||
jobject arrayObject;
|
||||
arrayObject = env->NewObjectArray(1,clazz,NULL);
|
||||
jclass arrayClass = (jclass) env->CallObjectMethod(arrayObject,getClassMID); //nb how to to it better ?
|
||||
*value = env->NewObjectArray(1, arrayClass, NULL);
|
||||
} else if (isOut
|
||||
|| (modifier == array)) {
|
||||
int arraySize;
|
||||
arraySize = (modifier == array) ? ind : 1;
|
||||
*value = env->NewObjectArray(arraySize,clazz,NULL);
|
||||
}
|
||||
if (modifier == arrayElement
|
||||
|| (isOut && (modifier == none))
|
||||
) {
|
||||
indexInArray = (modifier == arrayElement) ? ind : 0;
|
||||
env->SetObjectArrayElement((jobjectArray)*value, indexInArray, data);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case bc_T_ARRAY:
|
||||
{
|
||||
nsXPTType datumType;
|
||||
if(NS_FAILED(interfaceInfo->GetTypeForParam(methodIndex, param, 1,&datumType))) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
bcXPType type = XPTType2bcXPType(datumType.TagPart());
|
||||
if (isOut) {
|
||||
UnMarshalElement(value,ind,NULL,isOut,param,type,allocator,array);
|
||||
}
|
||||
if (um != NULL) {
|
||||
PRUint32 arraySize;
|
||||
um->ReadSimple(&arraySize,bc_T_U32);
|
||||
jobject arrayValue = NULL;
|
||||
UnMarshalElement(&arrayValue,arraySize,NULL,0,param,type,allocator,array);
|
||||
if (isOut) {
|
||||
env->SetObjectArrayElement((jobjectArray)*value,0,arrayValue);
|
||||
} else {
|
||||
*value = arrayValue;
|
||||
}
|
||||
for (PRUint32 i = 0; i < arraySize; i++) {
|
||||
UnMarshalElement(&arrayValue,i,um,0,param,type,allocator,arrayElement);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
default:
|
||||
;
|
||||
}
|
||||
if (env->ExceptionOccurred()) {
|
||||
env->ExceptionDescribe();
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
||||
}
|
||||
|
||||
bcXPType bcJavaMarshalToolkit::XPTType2bcXPType(uint8 type) {
|
||||
switch(type) {
|
||||
case nsXPTType::T_I8 :
|
||||
return bc_T_I8;
|
||||
case nsXPTType::T_U8 :
|
||||
return bc_T_U8;
|
||||
case nsXPTType::T_I16 :
|
||||
return bc_T_I16;
|
||||
case nsXPTType::T_U16 :
|
||||
return bc_T_U16;
|
||||
case nsXPTType::T_I32 :
|
||||
return bc_T_I32;
|
||||
case nsXPTType::T_U32 :
|
||||
return bc_T_U32;
|
||||
case nsXPTType::T_I64 :
|
||||
return bc_T_I64;
|
||||
case nsXPTType::T_U64 :
|
||||
return bc_T_U64;
|
||||
case nsXPTType::T_FLOAT :
|
||||
return bc_T_FLOAT;
|
||||
case nsXPTType::T_DOUBLE :
|
||||
return bc_T_DOUBLE;
|
||||
case nsXPTType::T_BOOL :
|
||||
return bc_T_BOOL;
|
||||
case nsXPTType::T_CHAR :
|
||||
return bc_T_CHAR;
|
||||
case nsXPTType::T_WCHAR :
|
||||
return bc_T_WCHAR;
|
||||
case nsXPTType::T_IID :
|
||||
return bc_T_IID;
|
||||
case nsXPTType::T_CHAR_STR :
|
||||
case nsXPTType::T_PSTRING_SIZE_IS:
|
||||
return bc_T_CHAR_STR;
|
||||
case nsXPTType::T_WCHAR_STR :
|
||||
case nsXPTType::T_PWSTRING_SIZE_IS:
|
||||
return bc_T_WCHAR_STR;
|
||||
case nsXPTType::T_INTERFACE :
|
||||
case nsXPTType::T_INTERFACE_IS :
|
||||
return bc_T_INTERFACE;
|
||||
case nsXPTType::T_ARRAY:
|
||||
return bc_T_ARRAY;
|
||||
default:
|
||||
return bc_T_UNDEFINED;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void bcJavaMarshalToolkit::InitializeStatic() {
|
||||
jclass clazz;
|
||||
if (!(clazz = env->FindClass("java/lang/Object"))
|
||||
|| !(objectClass = (jclass) env->NewGlobalRef(clazz))
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(clazz = env->FindClass("java/lang/Boolean"))
|
||||
|| !(booleanClass = (jclass) env->NewGlobalRef(clazz))
|
||||
|| !(clazz = env->FindClass("[Ljava/lang/Boolean;"))
|
||||
|| !(booleanArrayClass = (jclass) env->NewGlobalRef(clazz))
|
||||
) {
|
||||
DeInitializeStatic();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(clazz = env->FindClass("java/lang/Character"))
|
||||
|| !(charClass = (jclass) env->NewGlobalRef(clazz))
|
||||
|| !(clazz = env->FindClass("[Ljava/lang/Character;"))
|
||||
|| !(charArrayClass = (jclass) env->NewGlobalRef(clazz))
|
||||
) {
|
||||
DeInitializeStatic();
|
||||
return;
|
||||
}
|
||||
if (!(clazz = env->FindClass("java/lang/Byte"))
|
||||
|| !(byteClass = (jclass) env->NewGlobalRef(clazz))
|
||||
|| !(clazz = env->FindClass("[Ljava/lang/Byte;"))
|
||||
|| !(byteArrayClass = (jclass) env->NewGlobalRef(clazz))
|
||||
) {
|
||||
DeInitializeStatic();
|
||||
return;
|
||||
}
|
||||
if (!(clazz = env->FindClass("java/lang/Short"))
|
||||
|| !(shortClass = (jclass) env->NewGlobalRef(clazz))
|
||||
|| !(clazz = env->FindClass("[Ljava/lang/Short;"))
|
||||
|| !(shortArrayClass = (jclass) env->NewGlobalRef(clazz))
|
||||
) {
|
||||
DeInitializeStatic();
|
||||
return;
|
||||
}
|
||||
if (!(clazz = env->FindClass("java/lang/Integer"))
|
||||
|| !(intClass = (jclass) env->NewGlobalRef(clazz))
|
||||
|| !(clazz = env->FindClass("[Ljava/lang/Integer;"))
|
||||
|| !(intArrayClass = (jclass) env->NewGlobalRef(clazz))
|
||||
) {
|
||||
DeInitializeStatic();
|
||||
return;
|
||||
}
|
||||
if (!(clazz = env->FindClass("java/lang/Long"))
|
||||
|| !(longClass = (jclass) env->NewGlobalRef(clazz))
|
||||
|| !(clazz = env->FindClass("[Ljava/lang/Long;"))
|
||||
) {
|
||||
DeInitializeStatic();
|
||||
return;
|
||||
}
|
||||
if (!(clazz = env->FindClass("java/lang/Float"))
|
||||
|| !(floatClass = (jclass) env->NewGlobalRef(clazz))
|
||||
|| !(clazz = env->FindClass("[Ljava/lang/Float;"))
|
||||
|| !(floatArrayClass = (jclass) env->NewGlobalRef(clazz))
|
||||
) {
|
||||
DeInitializeStatic();
|
||||
return;
|
||||
}
|
||||
if (!(clazz = env->FindClass("java/lang/Double"))
|
||||
|| !(doubleClass = (jclass) env->NewGlobalRef(clazz))
|
||||
|| !(clazz = env->FindClass("[Ljava/lang/Double;"))
|
||||
|| !(doubleArrayClass = (jclass) env->NewGlobalRef(clazz))
|
||||
) {
|
||||
DeInitializeStatic();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(clazz = env->FindClass("java/lang/String"))
|
||||
|| !(stringClass = (jclass) env->NewGlobalRef(clazz))
|
||||
|| !(clazz = env->FindClass("[Ljava/lang/String;"))
|
||||
|| !(stringArrayClass = (jclass) env->NewGlobalRef(clazz))
|
||||
) {
|
||||
DeInitializeStatic();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(clazz = env->FindClass("org/mozilla/xpcom/IID"))
|
||||
|| !(iidClass = (jclass) env->NewGlobalRef(clazz))
|
||||
|| !(clazz = env->FindClass("[Lorg/mozilla/xpcom/IID;"))
|
||||
|| !(iidArrayClass = (jclass) env->NewGlobalRef(clazz))
|
||||
) {
|
||||
DeInitializeStatic();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(booleanInitMID = env->GetMethodID(booleanClass,"<init>","(Z)V"))) {
|
||||
DeInitializeStatic();
|
||||
return;
|
||||
}
|
||||
if (!(booleanValueMID = env->GetMethodID(booleanClass,"booleanValue","()Z"))) {
|
||||
DeInitializeStatic();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(charInitMID = env->GetMethodID(charClass,"<init>","(C)V"))) {
|
||||
DeInitializeStatic();
|
||||
return;
|
||||
}
|
||||
if (!(charValueMID = env->GetMethodID(charClass,"charValue","()C"))) {
|
||||
DeInitializeStatic();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(byteInitMID = env->GetMethodID(byteClass,"<init>","(B)V"))) {
|
||||
DeInitializeStatic();
|
||||
return;
|
||||
}
|
||||
if (!(byteValueMID = env->GetMethodID(byteClass,"byteValue","()B"))) {
|
||||
DeInitializeStatic();
|
||||
return;
|
||||
}
|
||||
if (!(shortInitMID = env->GetMethodID(shortClass,"<init>","(S)V"))) {
|
||||
DeInitializeStatic();
|
||||
return;
|
||||
}
|
||||
if (!(shortValueMID = env->GetMethodID(shortClass,"shortValue","()S"))) {
|
||||
DeInitializeStatic();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(intInitMID = env->GetMethodID(intClass,"<init>","(I)V"))) {
|
||||
DeInitializeStatic();
|
||||
return;
|
||||
}
|
||||
if (!(intValueMID = env->GetMethodID(intClass,"intValue","()I"))) {
|
||||
DeInitializeStatic();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(longInitMID = env->GetMethodID(longClass,"<init>","(J)V"))) {
|
||||
DeInitializeStatic();
|
||||
return;
|
||||
}
|
||||
if (!(longValueMID = env->GetMethodID(longClass,"longValue","()J"))) {
|
||||
DeInitializeStatic();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(floatInitMID = env->GetMethodID(floatClass,"<init>","(F)V"))) {
|
||||
DeInitializeStatic();
|
||||
return;
|
||||
}
|
||||
if (!(floatValueMID = env->GetMethodID(floatClass,"floatValue","()F"))) {
|
||||
DeInitializeStatic();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(doubleInitMID = env->GetMethodID(doubleClass,"<init>","(D)V"))) {
|
||||
DeInitializeStatic();
|
||||
return;
|
||||
}
|
||||
if (!(doubleValueMID = env->GetMethodID(doubleClass,"doubleValue","()D"))) {
|
||||
DeInitializeStatic();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(getClassMID = env->GetMethodID(objectClass,"getClass","()Ljava/lang/Class;"))) {
|
||||
DeInitializeStatic();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void bcJavaMarshalToolkit::DeInitializeStatic() { //nb need to do
|
||||
printf("--[c++]void bcJavaMarshalToolkit::DeInitializeStatic() - boomer \n");
|
||||
}
|
||||
|
||||
115
mozilla/java/xpcom/java/src/bcJavaMarshalToolkit.h
Normal file
115
mozilla/java/xpcom/java/src/bcJavaMarshalToolkit.h
Normal file
@@ -0,0 +1,115 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are
|
||||
* Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
|
||||
#ifndef _bcJavaMarshalToolkit_h
|
||||
#define _bcJavaMarshalToolkit_h
|
||||
|
||||
#include "nscore.h"
|
||||
#include "xptcall.h"
|
||||
#include "nsISupports.h"
|
||||
#include "jni.h"
|
||||
#include "bcIMarshaler.h"
|
||||
#include "bcIUnMarshaler.h"
|
||||
#include "bcIORB.h"
|
||||
|
||||
class bcJavaMarshalToolkit {
|
||||
public:
|
||||
bcJavaMarshalToolkit(PRUint16 methodIndex,
|
||||
nsIInterfaceInfo *interfaceInfo, jobjectArray args,
|
||||
JNIEnv *env, int isOnServer, bcIORB *orb) ;
|
||||
virtual ~bcJavaMarshalToolkit();
|
||||
nsresult Marshal(bcIMarshaler *);
|
||||
nsresult UnMarshal(bcIUnMarshaler *);
|
||||
private:
|
||||
|
||||
|
||||
enum ArrayModifier { none, arrayElement, array};
|
||||
enum { unDefined, onServer, onClient } callSide;
|
||||
JNIEnv *env;
|
||||
PRUint16 methodIndex;
|
||||
nsXPTMethodInfo *info;
|
||||
nsIInterfaceInfo * interfaceInfo;
|
||||
bcIORB *orb;
|
||||
jobjectArray args;
|
||||
|
||||
static jclass objectClass;
|
||||
static jclass objectArrayClass;
|
||||
static jclass booleanClass;
|
||||
static jclass booleanArrayClass;
|
||||
static jmethodID booleanInitMID;
|
||||
static jmethodID booleanValueMID;
|
||||
static jclass charClass;
|
||||
static jclass charArrayClass;
|
||||
static jmethodID charInitMID;
|
||||
static jmethodID charValueMID;
|
||||
static jclass byteClass;
|
||||
static jclass byteArrayClass;
|
||||
static jmethodID byteInitMID;
|
||||
static jmethodID byteValueMID;
|
||||
static jclass shortClass;
|
||||
static jclass shortArrayClass;
|
||||
static jmethodID shortInitMID;
|
||||
static jmethodID shortValueMID;
|
||||
static jclass intClass;
|
||||
static jclass intArrayClass;
|
||||
static jmethodID intInitMID;
|
||||
static jmethodID intValueMID;
|
||||
static jclass longClass;
|
||||
static jclass longArrayClass;
|
||||
static jmethodID longInitMID;
|
||||
static jmethodID longValueMID;
|
||||
static jclass floatClass;
|
||||
static jclass floatArrayClass;
|
||||
static jmethodID floatInitMID;
|
||||
static jmethodID floatValueMID;
|
||||
static jclass doubleClass;
|
||||
static jclass doubleArrayClass;
|
||||
static jmethodID doubleInitMID;
|
||||
static jmethodID doubleValueMID;
|
||||
|
||||
static jclass stringClass;
|
||||
static jclass stringArrayClass;
|
||||
|
||||
static jclass iidClass;
|
||||
static jclass iidArrayClass;
|
||||
|
||||
static jmethodID getClassMID;
|
||||
|
||||
void InitializeStatic();
|
||||
void DeInitializeStatic();
|
||||
bcXPType XPTType2bcXPType(uint8 type);
|
||||
// nsresult MarshalElement(bcIMarshaler *m, jobject array, nsXPTParamInfo * param, bcXPType type,
|
||||
// uint8 ind, ArrayModifier modifier = none);
|
||||
|
||||
nsresult
|
||||
MarshalElement(bcIMarshaler *m, jobject value, PRBool isOut, nsXPTParamInfo * param,
|
||||
bcXPType type, uint8 ind, ArrayModifier modifier = none);
|
||||
nsresult
|
||||
UnMarshalElement(jobject *value, uint8 ind, bcIUnMarshaler *um, PRBool isOut , nsXPTParamInfo * param,
|
||||
bcXPType type, bcIAllocator *allocator, ArrayModifier modifier = none);
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
40
mozilla/java/xpcom/java/src/bcJavaProxy.h
Normal file
40
mozilla/java/xpcom/java/src/bcJavaProxy.h
Normal file
@@ -0,0 +1,40 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are
|
||||
* Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
|
||||
#ifndef __bcJavaProxy_h
|
||||
#define __bcJavaProxy_h
|
||||
#include "jni.h"
|
||||
#include "bcDefs.h"
|
||||
#include "bcIORB.h"
|
||||
|
||||
class bcJavaProxy {
|
||||
public:
|
||||
bcJavaProxy(bcOID oid, bcIID * iid, bcIORB *orb);
|
||||
virtual ~bcJavaProxy();
|
||||
jobject GetObject();
|
||||
private:
|
||||
bcIORB *orb;
|
||||
bcOID oid;
|
||||
bcIID iid;
|
||||
|
||||
};
|
||||
#endif
|
||||
116
mozilla/java/xpcom/java/src/bcJavaStub.cpp
Normal file
116
mozilla/java/xpcom/java/src/bcJavaStub.cpp
Normal file
@@ -0,0 +1,116 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are
|
||||
* Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
|
||||
|
||||
#include "nscore.h"
|
||||
#include "xptcall.h"
|
||||
#include "bcJavaStub.h"
|
||||
#include "nsIInterfaceInfo.h"
|
||||
#include "nsIInterfaceInfoManager.h"
|
||||
#include "bcJavaMarshalToolkit.h"
|
||||
#include "bcJavaGlobal.h"
|
||||
#include "bcIIDJava.h"
|
||||
|
||||
jclass bcJavaStub::objectClass = NULL;
|
||||
jclass bcJavaStub::utilitiesClass = NULL;
|
||||
jmethodID bcJavaStub::callMethodByIndexMID = NULL;
|
||||
|
||||
bcJavaStub::bcJavaStub(jobject obj) {
|
||||
printf("--bcJavaStub::bcJavaStub \n");
|
||||
if (!obj) {
|
||||
printf("--bcJavaStub::bcJavaStub obj== 0\n");
|
||||
return;
|
||||
}
|
||||
JNIEnv * env = bcJavaGlobal::GetJNIEnv();
|
||||
object = env->NewGlobalRef(obj);
|
||||
}
|
||||
|
||||
|
||||
bcJavaStub::~bcJavaStub() {
|
||||
bcJavaGlobal::GetJNIEnv()->DeleteGlobalRef(object);
|
||||
}
|
||||
|
||||
void bcJavaStub::Dispatch(bcICall *call) {
|
||||
//sigsend(P_PID, getpid(),SIGINT);
|
||||
JNIEnv * env = bcJavaGlobal::GetJNIEnv();
|
||||
bcIID iid; bcOID oid; bcMID mid;
|
||||
jobjectArray args;
|
||||
call->GetParams(&iid, &oid, &mid);
|
||||
nsIInterfaceInfo *interfaceInfo;
|
||||
nsIInterfaceInfoManager* iimgr;
|
||||
if((iimgr = XPTI_GetInterfaceInfoManager()) != NULL) {
|
||||
if (NS_FAILED(iimgr->GetInfoForIID(&iid, &interfaceInfo))) {
|
||||
return; //nb exception handling
|
||||
}
|
||||
NS_RELEASE(iimgr);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
if (!objectClass) {
|
||||
Init();
|
||||
if (!objectClass) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
nsXPTMethodInfo* info;
|
||||
interfaceInfo->GetMethodInfo(mid,(const nsXPTMethodInfo **)&info);
|
||||
PRUint32 paramCount = info->GetParamCount();
|
||||
args = env->NewObjectArray(paramCount, objectClass,NULL);
|
||||
bcJavaMarshalToolkit * mt = new bcJavaMarshalToolkit(mid, interfaceInfo, args, env,1, call->GetORB());
|
||||
bcIUnMarshaler * um = call->GetUnMarshaler();
|
||||
mt->UnMarshal(um);
|
||||
jobject jiid = bcIIDJava::GetObject(&iid);
|
||||
bcJavaGlobal::GetJNIEnv()->CallStaticObjectMethod(utilitiesClass, callMethodByIndexMID, object, jiid, (jint)mid, args);
|
||||
//nb return value; excepion handling
|
||||
bcIMarshaler * m = call->GetMarshaler();
|
||||
mt->Marshal(m);
|
||||
//nb memory deallocation
|
||||
delete m; delete um; delete mt;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void bcJavaStub::Init() {
|
||||
JNIEnv * env = bcJavaGlobal::GetJNIEnv();
|
||||
objectClass = (jclass)env->NewGlobalRef(env->FindClass("java/lang/Object"));
|
||||
if (env->ExceptionOccurred()) {
|
||||
env->ExceptionDescribe();
|
||||
return;
|
||||
}
|
||||
|
||||
utilitiesClass = (jclass)env->NewGlobalRef(env->FindClass("org/mozilla/xpcom/Utilities"));
|
||||
if (env->ExceptionOccurred()) {
|
||||
env->ExceptionDescribe();
|
||||
return;
|
||||
}
|
||||
callMethodByIndexMID = env->GetStaticMethodID(utilitiesClass,"callMethodByIndex","(Ljava/lang/Object;Lorg/mozilla/xpcom/IID;I[Ljava/lang/Object;)Ljava/lang/Object;");
|
||||
if (env->ExceptionOccurred()) {
|
||||
env->ExceptionDescribe();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
41
mozilla/java/xpcom/java/src/bcJavaStub.h
Normal file
41
mozilla/java/xpcom/java/src/bcJavaStub.h
Normal file
@@ -0,0 +1,41 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are
|
||||
* Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
|
||||
#ifndef __bcJavaStub_h
|
||||
#define __bcJavaStub_h
|
||||
#include "bcIStub.h"
|
||||
#include "jni.h"
|
||||
|
||||
class bcJavaStub : public bcIStub {
|
||||
public:
|
||||
bcJavaStub(jobject obj);
|
||||
virtual ~bcJavaStub();
|
||||
virtual void Dispatch(bcICall *call) ;
|
||||
private:
|
||||
jobject object;
|
||||
static jclass objectClass;
|
||||
static jclass utilitiesClass;
|
||||
static jmethodID callMethodByIndexMID;
|
||||
void Init();
|
||||
};
|
||||
|
||||
#endif
|
||||
175
mozilla/java/xpcom/java/src/bcJavaStubsAndProxies.cpp
Normal file
175
mozilla/java/xpcom/java/src/bcJavaStubsAndProxies.cpp
Normal file
@@ -0,0 +1,175 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are
|
||||
* Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
#include "nsIGenericFactory.h"
|
||||
#include "nsIModule.h"
|
||||
#include "bcJavaStubsAndProxies.h"
|
||||
#include "bcJavaStub.h"
|
||||
#include "bcJavaGlobal.h"
|
||||
#include "bcORB.h"
|
||||
#include "bcIIDJava.h"
|
||||
|
||||
jclass bcJavaStubsAndProxies::componentLoader = 0;
|
||||
jmethodID bcJavaStubsAndProxies::loadComponentID = 0;
|
||||
|
||||
jclass bcJavaStubsAndProxies::proxyFactory = 0;
|
||||
jmethodID bcJavaStubsAndProxies::getProxyID = 0;
|
||||
jmethodID bcJavaStubsAndProxies::getInterfaceID = 0;
|
||||
|
||||
NS_DEFINE_CID(kORBCIID,BC_ORB_CID);
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(bcJavaStubsAndProxies);
|
||||
|
||||
static nsModuleComponentInfo components[] =
|
||||
{
|
||||
{
|
||||
"Black Connect Java stubs and proxies",
|
||||
BC_JAVASTUBSANDPROXIES_CID,
|
||||
BC_JAVASTUBSANDPROXIES_PROGID,
|
||||
bcJavaStubsAndProxiesConstructor
|
||||
}
|
||||
};
|
||||
|
||||
NS_IMPL_NSGETMODULE("BlackConnect Java stubs and proxies",components);
|
||||
|
||||
NS_IMPL_ISUPPORTS(bcJavaStubsAndProxies,NS_GET_IID(bcJavaStubsAndProxies));
|
||||
|
||||
|
||||
bcJavaStubsAndProxies::bcJavaStubsAndProxies() {
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
bcJavaStubsAndProxies::~bcJavaStubsAndProxies() {
|
||||
}
|
||||
|
||||
NS_IMETHODIMP bcJavaStubsAndProxies::GetStub(jobject obj, bcIStub **stub) {
|
||||
if (!stub) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
*stub = new bcJavaStub(obj);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP bcJavaStubsAndProxies::GetProxy(bcOID oid, const nsIID &iid, bcIORB *orb, jobject *proxy) {
|
||||
printf("--[c++] bcJavaStubsAndProxies::GetProxy\n");
|
||||
if (!componentLoader) {
|
||||
Init();
|
||||
}
|
||||
|
||||
JNIEnv * env = bcJavaGlobal::GetJNIEnv();
|
||||
jobject jiid = bcIIDJava::GetObject((nsIID*)&iid);
|
||||
*proxy = env->CallStaticObjectMethod(proxyFactory,getProxyID, (jlong)oid, jiid, (jlong)orb);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP bcJavaStubsAndProxies::GetInterface(const nsIID &iid, jclass *clazz) {
|
||||
printf("--[c++] bcJavaStubsAndProxies::GetInterface\n");
|
||||
if (!componentLoader) {
|
||||
Init();
|
||||
}
|
||||
|
||||
JNIEnv * env = bcJavaGlobal::GetJNIEnv();
|
||||
jobject jiid = bcIIDJava::GetObject((nsIID*)&iid);
|
||||
*clazz = (jclass)env->CallStaticObjectMethod(proxyFactory,getInterfaceID, jiid);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP bcJavaStubsAndProxies::GetOID(jobject object, bcIORB *orb, bcOID *oid) {
|
||||
bcIStub *stub = new bcJavaStub(object);
|
||||
*oid = orb->RegisterStub(stub);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP bcJavaStubsAndProxies::GetOID(char *location, bcOID *oid) {
|
||||
printf("--bcJavaStubsAndProxies::GetOID %s\n",location);
|
||||
JNIEnv * env = bcJavaGlobal::GetJNIEnv();
|
||||
nsresult result;
|
||||
|
||||
if (!componentLoader) {
|
||||
Init();
|
||||
}
|
||||
//location[strlen(location)-5] = 0; //nb dirty hack. location is xyz.jar.info
|
||||
strcpy(location + strlen(location)-4,"comp");
|
||||
jstring jstr = env->NewStringUTF(location);
|
||||
jobject object = env->CallStaticObjectMethod(componentLoader, loadComponentID, jstr);
|
||||
bcIStub *stub = new bcJavaStub(object);
|
||||
NS_WITH_SERVICE(bcORB,_orb,kORBCIID,&result);
|
||||
if (NS_FAILED(result)) {
|
||||
printf("--bcJavaStubsAndProxies::GetOID failed\n");
|
||||
return result;
|
||||
}
|
||||
bcIORB *orb;
|
||||
_orb->GetORB(&orb);
|
||||
*oid = orb->RegisterStub(stub);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void bcJavaStubsAndProxies::Init(void) {
|
||||
printf("--[c++]bcJavaStubsAndProxies::Init\n");
|
||||
JNIEnv * env = bcJavaGlobal::GetJNIEnv();
|
||||
componentLoader = env->FindClass("org/mozilla/xpcom/ComponentLoader");
|
||||
if (env->ExceptionOccurred()) {
|
||||
env->ExceptionDescribe();
|
||||
componentLoader = 0;
|
||||
return;
|
||||
}
|
||||
componentLoader = (jclass)env->NewGlobalRef(componentLoader);
|
||||
if (env->ExceptionOccurred()) {
|
||||
env->ExceptionDescribe();
|
||||
componentLoader = 0;
|
||||
return;
|
||||
}
|
||||
loadComponentID = env->GetStaticMethodID(componentLoader,"loadComponent","(Ljava/lang/String;)Ljava/lang/Object;");
|
||||
if (env->ExceptionOccurred()) {
|
||||
env->ExceptionDescribe();
|
||||
componentLoader = 0;
|
||||
return;
|
||||
}
|
||||
proxyFactory = env->FindClass("org/mozilla/xpcom/ProxyFactory");
|
||||
if (env->ExceptionOccurred()) {
|
||||
env->ExceptionDescribe();
|
||||
componentLoader = 0;
|
||||
return;
|
||||
}
|
||||
proxyFactory = (jclass)env->NewGlobalRef(proxyFactory);
|
||||
if (env->ExceptionOccurred()) {
|
||||
env->ExceptionDescribe();
|
||||
componentLoader = 0;
|
||||
return;
|
||||
}
|
||||
getProxyID = env->GetStaticMethodID(proxyFactory, "getProxy","(JLorg/mozilla/xpcom/IID;J)Ljava/lang/Object;");
|
||||
if (env->ExceptionOccurred()) {
|
||||
env->ExceptionDescribe();
|
||||
componentLoader = 0;
|
||||
return;
|
||||
}
|
||||
getInterfaceID = env->GetStaticMethodID(proxyFactory, "getInterface","(Lorg/mozilla/xpcom/IID;)Ljava/lang/Class;");
|
||||
if (env->ExceptionOccurred()) {
|
||||
env->ExceptionDescribe();
|
||||
componentLoader = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
66
mozilla/java/xpcom/java/src/bcJavaStubsAndProxies.h
Normal file
66
mozilla/java/xpcom/java/src/bcJavaStubsAndProxies.h
Normal file
@@ -0,0 +1,66 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are
|
||||
* Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
#ifndef __bcJavaStubsAndProxies_h
|
||||
#define __bcJavaStubsAndProxies_h
|
||||
#include "nsISupports.h"
|
||||
#include "jni.h"
|
||||
#include "bcDefs.h"
|
||||
#include "bcIStub.h"
|
||||
#include "bcIORB.h"
|
||||
|
||||
/* 58034ea6-1dd2-11b2-9b58-8630abb8af47 */
|
||||
|
||||
#define BC_JAVASTUBSANDPROXIES_IID \
|
||||
{0x58034ea6, 0x1dd2, 0x11b2, \
|
||||
{0x9b, 0x58, 0x86, 0x30, 0xab, 0xb8, 0xaf,0x47}}
|
||||
|
||||
#define BC_JAVASTUBSANDPROXIES_PROGID "component://netscape/blackwood/blackconnect/java-stubs-and-proxies"
|
||||
|
||||
/* 7cadf6e8-1dd2-11b2-9a6e-b1c37844e004 */
|
||||
#define BC_JAVASTUBSANDPROXIES_CID \
|
||||
{0x7cadf6e8, 0x1dd2, 0x11b2, \
|
||||
{0x9a, 0x6e, 0xb1, 0xc3, 0x78,0x44, 0xe0, 0x04}}
|
||||
|
||||
class bcJavaStubsAndProxies : public nsISupports {
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(BC_JAVASTUBSANDPROXIES_IID)
|
||||
NS_IMETHOD GetStub(jobject obj, bcIStub **stub);
|
||||
NS_IMETHOD GetOID(char *location, bcOID *); //load component by location
|
||||
NS_IMETHOD GetOID(jobject object, bcIORB *orb, bcOID *oid);
|
||||
NS_IMETHOD GetProxy(bcOID oid, const nsIID &iid, bcIORB *orb, jobject *proxy);
|
||||
NS_IMETHOD GetInterface(const nsIID &iid, jclass *clazz);
|
||||
bcJavaStubsAndProxies();
|
||||
virtual ~bcJavaStubsAndProxies();
|
||||
protected:
|
||||
void Init(void);
|
||||
static jclass componentLoader;
|
||||
static jmethodID loadComponentID;
|
||||
static jclass proxyFactory;
|
||||
static jmethodID getProxyID;
|
||||
static jmethodID getInterfaceID;
|
||||
};
|
||||
|
||||
#endif /* __bcJavaStubsAndProxies_h */
|
||||
|
||||
|
||||
|
||||
|
||||
54
mozilla/java/xpcom/java/src/makefile.win
Normal file
54
mozilla/java/xpcom/java/src/makefile.win
Normal file
@@ -0,0 +1,54 @@
|
||||
#!nmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Igor Kushnirskiy <idk@eng.sun.com>
|
||||
#
|
||||
|
||||
DEPTH=..\..\..\..
|
||||
|
||||
|
||||
MAKE_OBJ_TYPE = DLL
|
||||
MODULE=bcjavastubs
|
||||
COMPONENT = 1
|
||||
DLLNAME = bcjavastubs
|
||||
DLL=.\$(OBJDIR)\$(DLLNAME).dll
|
||||
|
||||
EXPORTS = \
|
||||
bcJavaStubsAndProxies.h
|
||||
|
||||
OBJS= \
|
||||
.\$(OBJDIR)\bcJavaMarshalToolkit.obj \
|
||||
.\$(OBJDIR)\bcJavaStub.obj \
|
||||
.\$(OBJDIR)\bcJavaGlobal.obj \
|
||||
.\$(OBJDIR)\bcJavaStubsAndProxies.obj \
|
||||
.\$(OBJDIR)\bcIIDJava.obj \
|
||||
.\$(OBJDIR)\org_mozilla_xpcom_Utilities.obj \
|
||||
$(NULL)
|
||||
|
||||
LINCS=-I$(JDKHOME)\include -I$(JDKHOME)\include\win32
|
||||
|
||||
LLIBS=$(LLIBS) $(LIBNSPR) $(DIST)\lib\xpcom.lib $(JDKHOME)\lib\jvm.lib
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
install:: $(DLL)
|
||||
$(MAKE_INSTALL) $(DLL) $(DIST)\bin\components
|
||||
clobber::
|
||||
rm -f $(DIST)\bin\components\$(DLLNAME).dll
|
||||
71
mozilla/java/xpcom/java/src/org_mozilla_xpcom_Utilities.cpp
Normal file
71
mozilla/java/xpcom/java/src/org_mozilla_xpcom_Utilities.cpp
Normal file
@@ -0,0 +1,71 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are
|
||||
* Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
#include "nsISupports.h"
|
||||
#include "org_mozilla_xpcom_Utilities.h"
|
||||
#include "bcIORB.h"
|
||||
#include "bcICall.h"
|
||||
#include "bcDefs.h"
|
||||
#include "xptcall.h"
|
||||
#include "nsIInterfaceInfo.h"
|
||||
#include "nsIInterfaceInfoManager.h"
|
||||
#include "bcJavaMarshalToolkit.h"
|
||||
|
||||
/*
|
||||
* Class: org_mozilla_xpcom_Utilities
|
||||
* Method: callMethodByIndex
|
||||
* Signature: (JILjava/lang/String;J[Ljava/lang/Object;)Ljava/lang/Object;
|
||||
*/
|
||||
|
||||
JNIEXPORT jobject JNICALL Java_org_mozilla_xpcom_Utilities_callMethodByIndex
|
||||
(JNIEnv *env, jclass clazz, jlong _oid, jint mid, jstring jiid, jlong _orb, jobjectArray args) {
|
||||
bcIORB * orb = (bcIORB*) _orb;
|
||||
bcOID oid = (bcOID)_oid;
|
||||
nsIID iid;
|
||||
printf("--[c++] jni Java_org_mozilla_xpcom_Utilities_callMethodByIndex %d\n",(int)mid);
|
||||
const char * str = NULL;
|
||||
str = env->GetStringUTFChars(jiid,NULL);
|
||||
iid.Parse(str);
|
||||
env->ReleaseStringUTFChars(jiid,str);
|
||||
bcICall *call = orb->CreateCall(&iid, &oid, mid);
|
||||
|
||||
/*****/
|
||||
nsIInterfaceInfo *interfaceInfo;
|
||||
nsIInterfaceInfoManager* iimgr;
|
||||
if( (iimgr = XPTI_GetInterfaceInfoManager()) != NULL) {
|
||||
if (NS_FAILED(iimgr->GetInfoForIID(&iid, &interfaceInfo))) {
|
||||
return NULL; //nb exception handling
|
||||
}
|
||||
NS_RELEASE(iimgr);
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
/*****/
|
||||
bcIMarshaler * m = call->GetMarshaler();
|
||||
bcJavaMarshalToolkit * mt = new bcJavaMarshalToolkit((unsigned)mid, interfaceInfo, args, env, 0, orb);
|
||||
mt->Marshal(m);
|
||||
orb->SendReceive(call);
|
||||
bcIUnMarshaler * um = call->GetUnMarshaler();
|
||||
mt->UnMarshal(um);
|
||||
delete m; delete um; delete mt;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
21
mozilla/java/xpcom/java/src/org_mozilla_xpcom_Utilities.h
Normal file
21
mozilla/java/xpcom/java/src/org_mozilla_xpcom_Utilities.h
Normal file
@@ -0,0 +1,21 @@
|
||||
/* DO NOT EDIT THIS FILE - it is machine generated */
|
||||
#include <jni.h>
|
||||
/* Header for class org_mozilla_xpcom_Utilities */
|
||||
|
||||
#ifndef _Included_org_mozilla_xpcom_Utilities
|
||||
#define _Included_org_mozilla_xpcom_Utilities
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/*
|
||||
* Class: org_mozilla_xpcom_Utilities
|
||||
* Method: callMethodByIndex
|
||||
* Signature: (JILjava/lang/String;J[Ljava/lang/Object;)Ljava/lang/Object;
|
||||
*/
|
||||
JNIEXPORT jobject JNICALL Java_org_mozilla_xpcom_Utilities_callMethodByIndex
|
||||
(JNIEnv *, jclass, jlong, jint, jstring, jlong, jobjectArray);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
52
mozilla/java/xpcom/java/test/Makefile.in
Normal file
52
mozilla/java/xpcom/java/test/Makefile.in
Normal file
@@ -0,0 +1,52 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Igor Kushnirskiy <idk@eng.sun.com>
|
||||
#
|
||||
|
||||
|
||||
DEPTH = ../../../..
|
||||
topsrcdir = ../../../..
|
||||
srcdir = .
|
||||
VPATH = .
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = javaSample
|
||||
LIBRARY_NAME = javaSample
|
||||
IS_COMPONENT = 1
|
||||
XPIDL_MODULE = javaSample
|
||||
XPIDLSRCS = bcIJavaSample.idl
|
||||
CPPSRCS = bcJavaSample.cpp
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
bcJavaSample.jar.comp: manifest bcIJavaSample.class bcJavaSample.class
|
||||
$(JDKHOME)/bin/jar cvfm bcJavaSample.jar.comp manifest *.class
|
||||
.java.class:
|
||||
$(JDKHOME)/bin/javac -classpath .:../classes $<
|
||||
install-component: bcJavaSample.jar.comp bcJavaSample.jar.info
|
||||
cp bcJavaSample.jar.comp bcJavaSample.jar.info $(DEPTH)/dist/bin/components/
|
||||
|
||||
clobber-java:
|
||||
rm -f *.class *.jar
|
||||
clobber:: clobber-java
|
||||
clobber_all:: clobber-java
|
||||
install:: install-component
|
||||
|
||||
12
mozilla/java/xpcom/java/test/bcIJavaSample.idl
Normal file
12
mozilla/java/xpcom/java/test/bcIJavaSample.idl
Normal file
@@ -0,0 +1,12 @@
|
||||
#include "nsISupports.idl"
|
||||
|
||||
[scriptable, uuid(ca1e2656-1dd1-11b2-9c4e-f49ea557abde)]
|
||||
interface bcIJavaSample : nsISupports
|
||||
{
|
||||
void test0();
|
||||
void test1(in long l);
|
||||
void test2(in bcIJavaSample o);
|
||||
void test3(in PRUint32 count,[array, size_is(count)] in long valueArray);
|
||||
void test4(in PRUint32 count,[array, size_is(count)] inout string valueArray);
|
||||
|
||||
};
|
||||
19
mozilla/java/xpcom/java/test/bcIJavaSample.java
Normal file
19
mozilla/java/xpcom/java/test/bcIJavaSample.java
Normal file
@@ -0,0 +1,19 @@
|
||||
/**
|
||||
* Interface nsISample
|
||||
*
|
||||
* IID: 0xca1e2656-1dd1-11b2-9c4e-f49ea557abde
|
||||
*/
|
||||
|
||||
import org.mozilla.xpcom.*;
|
||||
|
||||
public interface bcIJavaSample
|
||||
{
|
||||
public static final String BC_IJAVASAMPLE_IID_STRING =
|
||||
"ca1e2656-1dd1-11b2-9c4e-f49ea557abde";
|
||||
void queryInterface(IID iid, Object[] result);
|
||||
void test0();
|
||||
void test1(int l);
|
||||
void test2(bcIJavaSample o);
|
||||
void test3(int count, int[] valueArray);
|
||||
void test4(int count, String[][] valueArray);
|
||||
}
|
||||
151
mozilla/java/xpcom/java/test/bcJavaSample.cpp
Normal file
151
mozilla/java/xpcom/java/test/bcJavaSample.cpp
Normal file
@@ -0,0 +1,151 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are
|
||||
* Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
#include "bcIJavaSample.h"
|
||||
|
||||
#include "nsIGenericFactory.h"
|
||||
#include "nsIModule.h"
|
||||
#include "stdlib.h"
|
||||
|
||||
#define BC_JAVA_SAMPLE_CID \
|
||||
{0x072fa586, 0x1dd2, 0x11b2, \
|
||||
{ 0xb2, 0x3a, 0x81, 0xe8, 0x16, 0x49, 0xe8, 0x8b }}
|
||||
|
||||
#define BC_JAVA_SAMPLE_PROGID "javaSample.cpp"
|
||||
|
||||
|
||||
|
||||
class bcJavaSample : public bcIJavaSample {
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_BCIJAVASAMPLE
|
||||
bcJavaSample();
|
||||
virtual ~bcJavaSample();
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS1(bcJavaSample, bcIJavaSample)
|
||||
|
||||
bcJavaSample::bcJavaSample()
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
/* member initializers and constructor code */
|
||||
}
|
||||
|
||||
bcJavaSample::~bcJavaSample()
|
||||
{
|
||||
/* destructor code */
|
||||
}
|
||||
|
||||
NS_IMETHODIMP bcJavaSample::Test0()
|
||||
{ printf("--[c++] bcJavaSample::Test0() \n");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* void test1 (in long l); */
|
||||
NS_IMETHODIMP bcJavaSample::Test1(PRInt32 l)
|
||||
{
|
||||
printf("--[c++] bcJavaSample.test1 l=%d\n",l);
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* void test2 (in bcIJavaSample o); */
|
||||
NS_IMETHODIMP bcJavaSample::Test2(bcIJavaSample *o)
|
||||
{
|
||||
printf("--[c++] bcJavaSample.test2\n");
|
||||
o->Test0();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
/* void test3 (in PRUint32 count, [array, size_is (count)] in long valueArray); */
|
||||
NS_IMETHODIMP bcJavaSample::Test3(PRUint32 count, PRInt32 *valueArray) {
|
||||
printf("--[c++] bcJavaSample.test3 coutn %d\n",count);
|
||||
for(unsigned int i = 0; i < count; i++) {
|
||||
printf("--[c++] valueArray[%d]=%d\n",i,valueArray[i]);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void test4 (in PRUint32 count, [array, size_is (count)] inout string valueArray); */
|
||||
NS_IMETHODIMP bcJavaSample::Test4(PRUint32 count, char ***valueArray) {
|
||||
printf("--[c++] bcJavaSample.test4 coutn %d\n",count);
|
||||
for(unsigned int i = 0; i < count; i++) {
|
||||
printf("--[c++] valueArray[%d]=%s\n",i,(*valueArray)[i]);
|
||||
}
|
||||
char ** array = (char **)malloc(sizeof(char*)*4);
|
||||
array[0] = "1";
|
||||
array[1] = "2";
|
||||
array[2] = "hello";
|
||||
array[3] = "world";
|
||||
*valueArray = array;
|
||||
return NS_OK;
|
||||
}
|
||||
void test() {
|
||||
printf("--BlackConnect test start\n");
|
||||
nsresult r;
|
||||
bcIJavaSample *test;
|
||||
bcIJavaSample *a = new bcJavaSample();
|
||||
r = nsComponentManager::CreateInstance("bcJavaSample",
|
||||
nsnull,
|
||||
NS_GET_IID(bcIJavaSample),
|
||||
(void**)&test);
|
||||
//sigsend(P_PID, getpid(),SIGINT);
|
||||
//test->Test1(2000);
|
||||
#if 0
|
||||
test->Test1(1000);
|
||||
bcIJavaSample *test1;
|
||||
if (NS_FAILED(r)) {
|
||||
printf("failed to get component. try to restart test\n");
|
||||
} else {
|
||||
test->Test2(a);
|
||||
}
|
||||
test->QueryInterface(NS_GET_IID(bcIJavaSample),(void**)&test1);
|
||||
int intArray[] = {1,2,3};
|
||||
test->Test3(3, intArray);
|
||||
#endif
|
||||
{
|
||||
char ** valueArray = (char **)malloc(sizeof(char*)*4);
|
||||
valueArray[0] = "hi";
|
||||
valueArray[1] = "there";
|
||||
valueArray[2] = "a";
|
||||
valueArray[3] = "b";
|
||||
char *** valueArray2 = &valueArray;
|
||||
test->Test4(4,valueArray2);
|
||||
for (int i = 0; i < 4; i++) {
|
||||
printf("valueArray2[%d]=%s\n",i,(*valueArray2)[i]);
|
||||
}
|
||||
}
|
||||
printf("--BlackConnect test end\n");
|
||||
}
|
||||
|
||||
static int counter = 0; //we do not need to call it on unload time;
|
||||
extern "C" NS_EXPORT nsresult NSGetModule(nsIComponentManager *compMgr,
|
||||
nsIFile *location,
|
||||
nsIModule** result) //I am using it for runnig test *only*
|
||||
{
|
||||
if (counter == 0) {
|
||||
counter ++;
|
||||
printf("--bcJavaSample before test\n");
|
||||
test();
|
||||
printf("--bcJavaSample after test\n");
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
3
mozilla/java/xpcom/java/test/bcJavaSample.jar.info
Normal file
3
mozilla/java/xpcom/java/test/bcJavaSample.jar.info
Normal file
@@ -0,0 +1,3 @@
|
||||
6b701852-1dd2-11b2-91bd-d3ab05f89834
|
||||
bcJavaSample
|
||||
bcJavaSample
|
||||
102
mozilla/java/xpcom/java/test/bcJavaSample.java
Normal file
102
mozilla/java/xpcom/java/test/bcJavaSample.java
Normal file
@@ -0,0 +1,102 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are
|
||||
* Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
import org.mozilla.xpcom.*;
|
||||
import java.lang.reflect.*;
|
||||
public class bcJavaSample implements bcIJavaSample {
|
||||
public bcJavaSample() {
|
||||
System.out.println("--[java]bcJavaSample constructor");
|
||||
}
|
||||
public void queryInterface(IID iid, Object[] result) {
|
||||
System.out.println("--[java]bcJavaSample::queryInterface iid="+iid);
|
||||
if ( iid.equals(nsISupportsIID)
|
||||
|| iid.equals(bcIJavaSampleIID)) {
|
||||
result[0] = this;
|
||||
} else {
|
||||
result = null;
|
||||
}
|
||||
}
|
||||
public void test0() {
|
||||
System.out.println("--[java]bcJavaSample.test0 ");
|
||||
}
|
||||
public void test1(int l) {
|
||||
System.out.println("--[java]bcJavaSample.test1 "+l+"\n");
|
||||
}
|
||||
public void test2(bcIJavaSample o) {
|
||||
System.out.println("--[java]bcJavaSample.test2");
|
||||
System.out.println("--[java]bcJavaSample.test2 :)))) Hi there");
|
||||
if (o != null) {
|
||||
System.out.println("--[java]bcJavaSample.test2 o!= null");
|
||||
o.test0();
|
||||
o.test1(1000);
|
||||
o.test2(this);
|
||||
int[] array={3,2,1};
|
||||
o.test3(3,array);
|
||||
} else {
|
||||
System.out.println("--[java]bcJavaSample.test2 o = null");
|
||||
}
|
||||
}
|
||||
public void test3(int count, int[] valueArray) {
|
||||
System.out.println("--[java]bcJavaSample.test3");
|
||||
System.out.println(valueArray.length);
|
||||
for (int i = 0; i < valueArray.length; i++) {
|
||||
System.out.println("--[java]callMethodByIndex args["+i+"] = "+valueArray[i]);
|
||||
}
|
||||
|
||||
}
|
||||
public void test4(int count, String[][] valueArray) {
|
||||
System.out.println("--[java]bcJavaSample.test4");
|
||||
String[] array = valueArray[0];
|
||||
for (int i = 0; i < array.length; i++) {
|
||||
System.out.println("--[java]callMethodByIndex args["+i+"] = "+array[i]);
|
||||
}
|
||||
String[] returnArray = {"4","3","2","1"};
|
||||
valueArray[0] = returnArray;
|
||||
}
|
||||
static IID bcIJavaSampleIID;
|
||||
static IID nsISupportsIID;
|
||||
static {
|
||||
try {
|
||||
Method[] methods = null;
|
||||
Class bcIJavaSampleClass = Class.forName("bcIJavaSample");
|
||||
Class IIDClass = Class.forName("org.mozilla.xpcom.IID");
|
||||
methods = new Method[100];
|
||||
Class ObjectArrayClass = (new Object[1]).getClass();
|
||||
Class IntArrayClass = (new int[1]).getClass();
|
||||
Class StringArrayArrayClass = (new String[1][1]).getClass();
|
||||
methods[0] = bcIJavaSampleClass.getDeclaredMethod("queryInterface",new Class[]{IIDClass,ObjectArrayClass});
|
||||
methods[3] = bcIJavaSampleClass.getDeclaredMethod("test0",new Class[]{});
|
||||
methods[4] = bcIJavaSampleClass.getDeclaredMethod("test1",new Class[]{Integer.TYPE});
|
||||
methods[5] = bcIJavaSampleClass.getDeclaredMethod("test2",new Class[]{bcIJavaSampleClass});
|
||||
methods[6] = bcIJavaSampleClass.getDeclaredMethod("test3",new Class[]{Integer.TYPE,IntArrayClass});
|
||||
methods[7] = bcIJavaSampleClass.getDeclaredMethod("test4",new Class[]{Integer.TYPE,StringArrayArrayClass});
|
||||
System.out.println(methods[0]+" "+methods[3]+" "+methods[4]+" "+methods[5]+" "+methods[6]+" "+methods[7]);
|
||||
bcIJavaSampleIID = new IID(bcIJavaSample.BC_IJAVASAMPLE_IID_STRING);
|
||||
nsISupportsIID = new IID("00000000-0000-0000-c000-000000000046");
|
||||
ProxyFactory.registerInterfaceForIID(bcIJavaSampleClass,bcIJavaSampleIID);
|
||||
new ProxyClass(bcIJavaSampleIID, methods);
|
||||
//new ProxyClass(nsISupportsIID, methods);
|
||||
} catch (Exception e) {
|
||||
System.out.println(e);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
63
mozilla/java/xpcom/java/test/makefile.win
Normal file
63
mozilla/java/xpcom/java/test/makefile.win
Normal file
@@ -0,0 +1,63 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Igor Kushnirskiy <idk@eng.sun.com>
|
||||
#
|
||||
|
||||
|
||||
DEPTH = ..\..\..\..
|
||||
topsrcdir = ..\..\..\..
|
||||
srcdir = .
|
||||
VPATH = .
|
||||
|
||||
MAKE_OBJ_TYPE=DLL
|
||||
MODULE=javaSample
|
||||
COMPONENT=1
|
||||
DLLNAME=$(MODULE)
|
||||
DLL=.\$(OBJDIR)\$(DLLNAME).dll
|
||||
|
||||
XPIDLSRCS = \
|
||||
.\bcIJavaSample.idl \
|
||||
$(NULL)
|
||||
|
||||
OBJS = .\$(OBJDIR)\bcJavaSample.obj
|
||||
LLIBS=$(LLIBS) $(LIBNSPR) $(DIST)\lib\xpcom.lib
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
bcJavaSample.jar.comp: manifest bcIJavaSample.class bcJavaSample.class
|
||||
$(JDKHOME)\bin\jar cvfm bcJavaSample.jar.comp manifest *.class
|
||||
|
||||
.SUFFIXES: .java .class
|
||||
|
||||
.java.class:
|
||||
$(JDKHOME)\bin\javac -classpath .;..\classes $<
|
||||
|
||||
install-component: bcJavaSample.jar.comp bcJavaSample.jar.info $(DLL)
|
||||
copy bcJavaSample.jar* $(DIST)\bin\components
|
||||
copy $(DLL) $(DIST)\bin\components
|
||||
|
||||
clobber-java:
|
||||
-del *.class *.jar.comp
|
||||
clobber:: clobber-java
|
||||
rm $(DIST)\bin\components\$(DLLNAME).dll
|
||||
rm $(DIST)\bin\components\bcJavaSample.jar.*
|
||||
clobber_all:: clobber-java
|
||||
install:: install-component
|
||||
1
mozilla/java/xpcom/java/test/manifest
Normal file
1
mozilla/java/xpcom/java/test/manifest
Normal file
@@ -0,0 +1 @@
|
||||
Component-Class: bcJavaSample
|
||||
34
mozilla/java/xpcom/makefile.win
Normal file
34
mozilla/java/xpcom/makefile.win
Normal file
@@ -0,0 +1,34 @@
|
||||
#!nmake
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Sun Microsystems,
|
||||
# Inc. Portions created by Sun are
|
||||
# Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Igor Kushnirskiy <idk@eng.sun.com>
|
||||
#
|
||||
|
||||
DEPTH = ..\..
|
||||
|
||||
DIRS= \
|
||||
connect \
|
||||
xpcom \
|
||||
java \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
|
||||
34
mozilla/java/xpcom/old/Makefile.in
Normal file
34
mozilla/java/xpcom/old/Makefile.in
Normal file
@@ -0,0 +1,34 @@
|
||||
#!gmake
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
|
||||
DEPTH = ../..
|
||||
topsrcdir = @top_srcdir@
|
||||
VPATH = @srcdir@
|
||||
srcdir = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
DIRS= classes \
|
||||
src \
|
||||
tools \
|
||||
$(NULL)
|
||||
# test \
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
155
mozilla/java/xpcom/old/README
Normal file
155
mozilla/java/xpcom/old/README
Normal file
@@ -0,0 +1,155 @@
|
||||
Java Bridge to XPCOM
|
||||
====================
|
||||
|
||||
This directory contains the beginnings of the Java Bridge to XPCOM.
|
||||
For now it is disconnected from the main Mozilla build, because as yet
|
||||
it is good for no more than a few demo and test programs, and because
|
||||
Java compilation on Unix and Linux doesn't work quite right (as of
|
||||
Aug 13, 1999).
|
||||
|
||||
The source is divided into four directories
|
||||
|
||||
classes
|
||||
Java source files
|
||||
src
|
||||
Native code (C++/C) for Java classes and stub support
|
||||
test
|
||||
Test code, including a dummy XPCOM component
|
||||
tools
|
||||
Support tools:
|
||||
|
||||
genproxy -- Generates Java source for a proxy class
|
||||
to an XPCOM object. (Eventually will
|
||||
generate bytecodes and interfaces.)
|
||||
|
||||
|
||||
Build
|
||||
-----
|
||||
|
||||
Currently only UNIX/Linux builds are supported (mainly because it's my
|
||||
platform of choice). Windows builds should not be too much more
|
||||
difficult, and
|
||||
|
||||
1. Make sure MOZILLA_FIVE_HOME is set to <mozilla-source-dir>/dist/bin,
|
||||
and that JDKHOME indicates a valid JDK 1.2 installation.
|
||||
|
||||
*IMPORTANT*: remove the jni.h, jni_md.h, and jri.h in mozilla/dist/bin,
|
||||
before compiling native code. Otherwise, the header
|
||||
mismatch will cause crashes in JNI code.
|
||||
|
||||
2. Insure that the following are in your LD_LIBRARY_PATH:
|
||||
|
||||
$MOZILLA_FIVE_HOME
|
||||
$MOZILLA_FIVE_HOME/../lib
|
||||
mozilla/java/xpcom/test (or "." if you run in that directory)
|
||||
mozilla/java/xpcom/src (or "../src" if you run in "test")
|
||||
|
||||
3. In mozilla/java/xpcom, execute
|
||||
|
||||
../../build/autoconf/update-makefile.sh
|
||||
|
||||
if necessary, to generate a Makefile, and then
|
||||
|
||||
gmake JAVAC="javac -g -d $MOZILLA_FIVE_HOME/../classes"
|
||||
|
||||
This is to get around bugs in Java compilation.
|
||||
|
||||
4. Change directories to mozilla/java/xpcom/test
|
||||
|
||||
5. Execute
|
||||
|
||||
gmake -f Makefile.test
|
||||
|
||||
This has the side effect of creating JSISample.xpt in the main
|
||||
Mozilla components directory; all other libraries, executables, and
|
||||
Java class files reside in the test directory.
|
||||
|
||||
|
||||
Tests
|
||||
-----
|
||||
|
||||
Both tests use the JSSample component, whose methods do nothing more
|
||||
than print out the in and out arguments, and perhaps perform a simple
|
||||
operation.
|
||||
|
||||
xptest
|
||||
|
||||
This program takes the name of a JSSample method and a number
|
||||
of "in" parameters (coerced from strings to the expected
|
||||
data types), executes the method, and returns. It is mainly
|
||||
useful to test whether the "xpjava" native functions still
|
||||
work correctly, independently of the JVM.
|
||||
|
||||
Sample invocation:
|
||||
|
||||
./xptest AddTwoInts 1 1
|
||||
|
||||
Output:
|
||||
Starting ...
|
||||
Initializing XPCOM
|
||||
<some debugging messages>
|
||||
Registering Allocator
|
||||
Getting InterfaceInfoManager
|
||||
Registering Sample Factory
|
||||
AddTwoInts:
|
||||
0: type = 2, in
|
||||
1: type = 2, in
|
||||
2: type = 2, out, retval
|
||||
Consuming 1
|
||||
Consuming 1
|
||||
Arguments are:
|
||||
0) 1 : type 2, ptr=(nil)
|
||||
1) 1 : type 2, ptr=(nil)
|
||||
2) 7566446 : type 2, ptr=0x804fae8, data
|
||||
Calling XPTC_InvokeByIndex( 0x80932d0, 23, 3, 0x804fac8)
|
||||
Results are:
|
||||
0) 1 : type 2, ptr=(nil)
|
||||
1) 1 : type 2, ptr=(nil)
|
||||
2) 2 : type 2, ptr=0x804fae8, data
|
||||
|
||||
|
||||
XPCTest.main()
|
||||
|
||||
This is a Java version of xptest. Unlike xptest, each
|
||||
non-String argument to the method must be preceded by a flag
|
||||
indicating its type, out parameters require a "placeholder
|
||||
flag":
|
||||
|
||||
-c: char
|
||||
-b: byte
|
||||
-s: short
|
||||
-i: int
|
||||
-j, -l: long
|
||||
-f: float
|
||||
-d: double
|
||||
-z: boolean
|
||||
-r: placeholder for retval
|
||||
-0: placeholder for out param (equiv. to -r)
|
||||
|
||||
If the "command" argument is a number, XPCTest invokes the
|
||||
XPCOM method with that offset.
|
||||
|
||||
Sample invocation:
|
||||
|
||||
java -native XPCTest AddTwoInts -i 1 -i 1 -r
|
||||
|
||||
Output:
|
||||
|
||||
Initializing XPCOM
|
||||
Registering Allocator
|
||||
Getting InterfaceInfoManager
|
||||
Command: AddTwoInts, arguments: [1, 1, null]
|
||||
Results: [1, 1, 2]
|
||||
|
||||
Notes:
|
||||
|
||||
1. You must run native threads; Mozilla loads the native
|
||||
thread library, and the JVM will panic if it has to
|
||||
load both native and green threads.
|
||||
|
||||
2. Because of the way the JDK links shared libraries,
|
||||
you must have a valid mozilla/dist/bin/component.reg;
|
||||
otherwise, XPCOM will not bootstrap correctly.
|
||||
Note that "apprunner" and "xptest" will create one.
|
||||
Future versions will fix this limitation.
|
||||
|
||||
92
mozilla/java/xpcom/old/TODO
Normal file
92
mozilla/java/xpcom/old/TODO
Normal file
@@ -0,0 +1,92 @@
|
||||
TODO
|
||||
====
|
||||
|
||||
(By no means complete ...)
|
||||
|
||||
Configuration
|
||||
-------------
|
||||
|
||||
-- *GET XPCTest WORKING*. For some reason, the JDK 1.2 JVM on Solaris
|
||||
won't load libxpcom.so correctly, even if it's on LD_LIBRARY_PATH. I
|
||||
have yet to confirm whether this is a problem on Linux or NT.
|
||||
[Done 13 Aug 1999]
|
||||
|
||||
-- Make Java compilation work correctly on Unix/Linux.
|
||||
|
||||
-- Better integration with Mozilla makefile/autoconf system.
|
||||
|
||||
-- Move XPCOM startup code to test programs.
|
||||
|
||||
-- Integrate into Java Plugin and test.
|
||||
|
||||
-- File and function renaming, to prevent conflicts and increase modularity.
|
||||
|
||||
|
||||
Registration and Activation
|
||||
---------------------------
|
||||
|
||||
-- Insure JNI libraries load and unload, even within JNI plugin
|
||||
|
||||
-- Derive proxy class from IID, and vice-versa
|
||||
|
||||
-- Generate static proxies (using genproxy)
|
||||
|
||||
-- Generate and load "on-the-fly" bytecode for proxy classes.
|
||||
|
||||
|
||||
Marshalling
|
||||
-----------
|
||||
|
||||
-- Verify nsID parameters are marshalled correctly.
|
||||
|
||||
-- Unwrap proxies used as "in" parameters.
|
||||
|
||||
-- Wrap "out" XPCOM objects in correct wrapper class. [dep: Proxy Generation]
|
||||
|
||||
-- Build C++ stubs for Java-implemented XPCOM objects. [big task?]
|
||||
|
||||
-- [Future] Allow mapping from native concrete type to Java types
|
||||
|
||||
-- [Future] Efficient handling of attributes and 0- or 1-arg methods.
|
||||
|
||||
-- [Future] Reflection API (if Java's is insufficient)
|
||||
|
||||
|
||||
NSRESULTs
|
||||
---------
|
||||
|
||||
-- Throw exceptions for error codes
|
||||
|
||||
-- Design and implement "success code mechanism", for single-threaded case
|
||||
|
||||
-- Store success codes per thread, and retrieve for current threads.
|
||||
|
||||
|
||||
API
|
||||
---
|
||||
|
||||
-- Write proxy for ns[I]ComponentManager, by hand. (For performance,
|
||||
and because of the overloaded methods and lack of XPT.)
|
||||
|
||||
-- Write proxy for ns[I]ServiceManager, similar to above.
|
||||
|
||||
-- Throw exceptions for unknown or missing proxy classes (and other errors).
|
||||
|
||||
-- Implement XPCOM identity rules
|
||||
|
||||
-- Document (including Javadoc)
|
||||
|
||||
|
||||
Memory Management
|
||||
-----------------
|
||||
|
||||
-- Insure that temporary heap memory (esp. strings and nsIDs) is
|
||||
recycled.
|
||||
|
||||
-- Insure reference-counting rules aren't violated.
|
||||
|
||||
-- Cache previously allocated wrapper objects, to prevent unnecessary
|
||||
allocation.
|
||||
|
||||
-- Thread-safe object release
|
||||
|
||||
50
mozilla/java/xpcom/old/classes/Makefile.in
Normal file
50
mozilla/java/xpcom/old/classes/Makefile.in
Normal file
@@ -0,0 +1,50 @@
|
||||
#!gmake
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
VPATH = @srcdir@
|
||||
srcdir = @srcdir@
|
||||
|
||||
# PENDING(frankm): find out where these should really be defined
|
||||
IGNORE_MANIFEST=1
|
||||
JAVA_OR_NSJVM=1
|
||||
NO_CAFE=1
|
||||
|
||||
# PENDING(frankm): find out how to define this for UNIX/SunOS
|
||||
JAVAC=$(JDKHOME)/bin/javac
|
||||
JAVALIB=$(JDKHOME)/lib
|
||||
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
|
||||
JAR_XPCOM_CLASSES = org/mozilla/xpcom \
|
||||
$(NULL)
|
||||
|
||||
ifdef JAVA_OR_NSJVM
|
||||
JDIRS = $(JAR_XPCOM_CLASSES)
|
||||
endif
|
||||
|
||||
# PENDING(frankm): find out how to define this for UNIX/SunOS
|
||||
JAVAC=$(JDKHOME)/bin/javac
|
||||
JAVALIB=$(JDKHOME)/lib
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Frank
|
||||
* Mitchell. Portions created by Frank Mitchell are
|
||||
* Copyright (C) 1999 Frank Mitchell. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Frank Mitchell (frank.mitchell@sun.com)
|
||||
*/
|
||||
package org.mozilla.xpcom;
|
||||
|
||||
public class ComObject extends Object {
|
||||
// the XPCOM object pointer, stored as a long (for 64 bit compatibility)
|
||||
long objptr;
|
||||
|
||||
// package-private constructors
|
||||
ComObject() {
|
||||
}
|
||||
|
||||
ComObject(long p) {
|
||||
this.objptr = p;
|
||||
XPComUtilities.AddRef(objptr);
|
||||
}
|
||||
|
||||
protected void finalize() throws Throwable {
|
||||
XPComUtilities.Release(objptr);
|
||||
}
|
||||
|
||||
protected void __invokeByIndex(nsID iid, int index, Object[] args) {
|
||||
XPComUtilities.InvokeMethodByIndex(iid, this.objptr, index, args);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Frank
|
||||
* Mitchell. Portions created by Frank Mitchell are
|
||||
* Copyright (C) 1999 Frank Mitchell. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Frank Mitchell (frank.mitchell@sun.com)
|
||||
*/
|
||||
package org.mozilla.xpcom;
|
||||
|
||||
public final class XPCMethod extends Object {
|
||||
// PENDING: symbolic names for type codes
|
||||
|
||||
// PENDING: use an nsID equivalent
|
||||
nsID iid;
|
||||
String methodName;
|
||||
|
||||
// Pointer to XPCOM MethodInfo ptr
|
||||
long infoptr;
|
||||
// Pointer to C++ argument array template
|
||||
long frameptr;
|
||||
// Vtable offset
|
||||
int offset;
|
||||
// Number of parameters
|
||||
int count;
|
||||
|
||||
// PENDING: Add lookup by name
|
||||
// PENDING: Add metadata (in, out, retval, types)
|
||||
public // PENDING: make nonpublic ASAP
|
||||
XPCMethod(String iidString, String methodName)
|
||||
throws XPCOMException {
|
||||
this.iid = new nsID(iidString);
|
||||
this.methodName = methodName;
|
||||
offset = this.init(this.iid, this.methodName);
|
||||
}
|
||||
|
||||
public // PENDING: make nonpublic ASAP
|
||||
XPCMethod(nsID iid, String methodName)
|
||||
throws XPCOMException {
|
||||
this.iid = iid;
|
||||
this.methodName = methodName;
|
||||
offset = this.init(this.iid, methodName);
|
||||
}
|
||||
|
||||
private native int init(nsID iid, String methodName)
|
||||
throws XPCOMException;
|
||||
|
||||
protected void finalize() throws Throwable {
|
||||
infoptr = 0;
|
||||
destroyPeer(frameptr);
|
||||
frameptr = 0;
|
||||
}
|
||||
|
||||
private native void destroyPeer(long ptr) throws XPCOMException;
|
||||
|
||||
public int getNumberOfParameters() {
|
||||
return count;
|
||||
}
|
||||
|
||||
public native int getParameterType(int index)
|
||||
throws IndexOutOfBoundsException, XPCOMException;
|
||||
|
||||
public native int getParameterClass(int index)
|
||||
throws IndexOutOfBoundsException, XPCOMException;
|
||||
|
||||
public native void invoke(ComObject target, Object[] params)
|
||||
throws XPCOMException;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Frank
|
||||
* Mitchell. Portions created by Frank Mitchell are
|
||||
* Copyright (C) 1999 Frank Mitchell. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Frank Mitchell (frank.mitchell@sun.com)
|
||||
*/
|
||||
package org.mozilla.xpcom;
|
||||
|
||||
public class XPCOMException extends RuntimeException {
|
||||
public XPCOMException(String message, int xpcomCode) {
|
||||
super(message + " [nsresult=" + xpcomCode + "]");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Frank
|
||||
* Mitchell. Portions created by Frank Mitchell are
|
||||
* Copyright (C) 1999 Frank Mitchell. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Frank Mitchell (frank.mitchell@sun.com)
|
||||
*/
|
||||
package org.mozilla.xpcom;
|
||||
|
||||
public class XPComUtilities {
|
||||
private static boolean didInit = false;
|
||||
|
||||
static {
|
||||
initXPCOM();
|
||||
}
|
||||
|
||||
static void initXPCOM() {
|
||||
if (didInit) return;
|
||||
|
||||
didInit = true;
|
||||
System.loadLibrary("xpjava");
|
||||
if (!initialize()) {
|
||||
System.out.println("Initialization failed!!");
|
||||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
private static native boolean initialize();
|
||||
|
||||
// public static native nsIComponentManager GetGlobalComponentManager();
|
||||
|
||||
public static native nsISupports CreateInstance(nsID classID,
|
||||
nsISupports aDelegate,
|
||||
nsID interfaceID);
|
||||
|
||||
/*
|
||||
public static native Object CreateInstance(String progID,
|
||||
nsISupports aDelegate,
|
||||
nsID interfaceID);
|
||||
|
||||
public static native void RegisterFactory(nsID classID,
|
||||
String className,
|
||||
String progID,
|
||||
nsIFactory aFactory,
|
||||
boolean replace);
|
||||
*/
|
||||
|
||||
public static native void RegisterComponent(nsID classID,
|
||||
String className,
|
||||
String progID,
|
||||
String libraryName,
|
||||
boolean replace,
|
||||
boolean persist);
|
||||
|
||||
//public static native nsIInterfaceInfoManager GetInterfaceInfoManager();
|
||||
|
||||
static native void AddRef(long ref);
|
||||
static native void Release(long ref);
|
||||
|
||||
static native void InvokeMethodByIndex(nsID iid,
|
||||
long ref,
|
||||
int index,
|
||||
Object[] args);
|
||||
|
||||
// TEMPORARY: remove ASAP
|
||||
public static void InvokeMethodByIndex(nsID iid,
|
||||
ComObject object,
|
||||
int index,
|
||||
Object[] args) {
|
||||
object.__invokeByIndex(iid, index, args);
|
||||
}
|
||||
}
|
||||
82
mozilla/java/xpcom/old/classes/org/mozilla/xpcom/nsID.java
Normal file
82
mozilla/java/xpcom/old/classes/org/mozilla/xpcom/nsID.java
Normal file
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Frank
|
||||
* Mitchell. Portions created by Frank Mitchell are
|
||||
* Copyright (C) 1999 Frank Mitchell. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Frank Mitchell (frank.mitchell@sun.com)
|
||||
*/
|
||||
package org.mozilla.xpcom;
|
||||
|
||||
public final class nsID {
|
||||
// ptr to a C++ nsID
|
||||
long nsidptr;
|
||||
|
||||
static {
|
||||
XPComUtilities.initXPCOM();
|
||||
}
|
||||
|
||||
/** DO NOT USE: only for creating nsIDs in native code */
|
||||
nsID() {
|
||||
nsidptr = 0x0;
|
||||
}
|
||||
|
||||
public nsID(int m0, short m1, short m2,
|
||||
byte m30, byte m31, byte m32, byte m33,
|
||||
byte m34, byte m35, byte m36, byte m37) {
|
||||
// What fun
|
||||
this.NewIDPtr(m0, m1, m2, m30, m31, m32, m33, m34, m35, m36, m37);
|
||||
}
|
||||
|
||||
private native void NewIDPtr(int m0, short m1, short m2,
|
||||
byte m30, byte m31, byte m32, byte m33,
|
||||
byte m34, byte m35, byte m36, byte m37);
|
||||
|
||||
public nsID(String idstring) throws NumberFormatException {
|
||||
this.NewIDPtr(idstring);
|
||||
if (this.nsidptr == 0) {
|
||||
throw new NumberFormatException("Can't convert '" +
|
||||
idstring
|
||||
+ "' to an nsID");
|
||||
}
|
||||
}
|
||||
|
||||
private native void NewIDPtr(String idstring);
|
||||
|
||||
protected native void finalize() throws Throwable;
|
||||
|
||||
public native boolean equals(Object other);
|
||||
|
||||
public native String toString();
|
||||
|
||||
public native int hashCode();
|
||||
|
||||
public static void main(String[] argv) {
|
||||
System.loadLibrary("xpjava");
|
||||
|
||||
nsID iid1 = new nsID("57ecad90-ae1a-11d1-b66c-00805f8a2676");
|
||||
nsID iid2 = new nsID((int)0x57ecad90, (short)0xae1a, (short)0x11d1,
|
||||
(byte)0xb6, (byte)0x6c, (byte)0x00, (byte)0x80,
|
||||
(byte)0x5f, (byte)0x8a, (byte)0x26, (byte)0x76);
|
||||
|
||||
System.out.println(iid1);
|
||||
System.out.println(iid2);
|
||||
|
||||
System.out.println(iid1.equals(iid2));
|
||||
System.out.println(iid1.equals(null));
|
||||
System.out.println(iid1.hashCode());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Frank
|
||||
* Mitchell. Portions created by Frank Mitchell are
|
||||
* Copyright (C) 1999 Frank Mitchell. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Frank Mitchell (frank.mitchell@sun.com)
|
||||
*/
|
||||
/*
|
||||
* ************* DO NOT EDIT THIS FILE ***********
|
||||
*
|
||||
* This file was automatically generated from /home/frankm/mozilla/dist/idl/nsISupports.idl.
|
||||
*/
|
||||
package org.mozilla.xpcom;
|
||||
|
||||
import org.mozilla.xpcom.nsID;
|
||||
|
||||
/**
|
||||
* Interface nsISupports
|
||||
*
|
||||
* IID: 0x00000000-0000-0000-c000-000000000046
|
||||
*/
|
||||
|
||||
public interface nsISupports
|
||||
{
|
||||
public static final String NS_ISUPPORTS_IID_STRING =
|
||||
"00000000-0000-0000-c000-000000000046";
|
||||
|
||||
public static final nsID NS_ISUPPORTS_IID =
|
||||
new nsID(NS_ISUPPORTS_IID_STRING);
|
||||
|
||||
|
||||
/* void QueryInterface (in nsIIDRef uuid, [iid_is (uuid), retval] out nsQIResult result); */
|
||||
public Object QueryInterface(nsID uuid);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* end
|
||||
*/
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Frank
|
||||
* Mitchell. Portions created by Frank Mitchell are
|
||||
* Copyright (C) 1999 Frank Mitchell. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Frank Mitchell (frank.mitchell@sun.com)
|
||||
*/
|
||||
package org.mozilla.xpcom;
|
||||
|
||||
class nsISupports__Proxy extends ComObject implements nsISupports {
|
||||
|
||||
public Object QueryInterface(nsID uuid) {
|
||||
Object[] args = new Object[2];
|
||||
args[0] = uuid;
|
||||
args[1] = null;
|
||||
XPComUtilities.InvokeMethodByIndex(NS_ISUPPORTS_IID, objptr, 0, args);
|
||||
return args[1];
|
||||
}
|
||||
|
||||
// PENDING: should reimplement identity, hash, etc.
|
||||
}
|
||||
66
mozilla/java/xpcom/old/src/Makefile.in
Normal file
66
mozilla/java/xpcom/old/src/Makefile.in
Normal file
@@ -0,0 +1,66 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
|
||||
DEPTH=../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
LIBRARY_NAME = xpjava
|
||||
|
||||
#MODULE = xpcom
|
||||
#XPIDL_MODULE = xpcom_base
|
||||
|
||||
CPPSRCS = \
|
||||
xpjava.cpp \
|
||||
xpj_proxy.cpp \
|
||||
xpj_XPCMethod.cpp \
|
||||
xpj_ComUtilities.cpp \
|
||||
xpj_nsID.cpp \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = \
|
||||
$(NULL)
|
||||
|
||||
# EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
|
||||
|
||||
REQUIRES = xpcom
|
||||
|
||||
# XXX: fix this to substitute correct OS name
|
||||
|
||||
INCLUDES += -I$(JDKHOME)/include \
|
||||
-I$(JDKHOME)/include/solaris \
|
||||
-I$(JDKHOME)/include/linux \
|
||||
$(NULL)
|
||||
|
||||
EXTRA_DSO_LDOPTS += \
|
||||
-L$(topsrcdir)/dist/lib \
|
||||
-lxpcom \
|
||||
-lplc3 \
|
||||
-lplds3 \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
203
mozilla/java/xpcom/old/src/xpj_ComUtilities.cpp
Normal file
203
mozilla/java/xpcom/old/src/xpj_ComUtilities.cpp
Normal file
@@ -0,0 +1,203 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Frank
|
||||
* Mitchell. Portions created by Frank Mitchell are
|
||||
* Copyright (C) 1999 Frank Mitchell. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Frank Mitchell (frank.mitchell@sun.com)
|
||||
*/
|
||||
#include <iostream.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include <jni.h>
|
||||
#include "nscore.h"
|
||||
#include "nsID.h"
|
||||
#include "nsIFactory.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIInterfaceInfo.h"
|
||||
#include "nsIInterfaceInfoManager.h"
|
||||
#include "nsIAllocator.h"
|
||||
|
||||
#include "xpjava.h"
|
||||
|
||||
#ifdef INCLUDE_JNI_HEADER
|
||||
#include "org_mozilla_xpcom_XPComUtilities.h"
|
||||
#endif
|
||||
|
||||
/* ---------- CLASS METHODS ------------ */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_org_mozilla_xpcom_XPComUtilities_initialize(JNIEnv *env, jclass cls)
|
||||
{
|
||||
nsresult res = xpj_InitXPCOM();
|
||||
if (NS_FAILED(res)) return JNI_FALSE;
|
||||
|
||||
return xpjd_InitJavaCaches(env); // XXX: remove; do in dispatch
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: XPComUtilities
|
||||
* Method: CreateInstance
|
||||
* Signature: (LID;LnsISupports;LID;)Ljava/lang/Object;
|
||||
*/
|
||||
JNIEXPORT jobject JNICALL Java_org_mozilla_xpcom_XPComUtilities_CreateInstance
|
||||
(JNIEnv *env, jclass clazz,
|
||||
jobject jcid, jobject jdelegate, jobject jiid)
|
||||
{
|
||||
jobject result;
|
||||
nsISupports *xpcobj = NULL;
|
||||
nsresult res;
|
||||
nsID *classID = ID_GetNative(env, jcid);
|
||||
nsID *interfaceID = ID_GetNative(env, jiid);
|
||||
nsISupports *delegate = NULL;
|
||||
|
||||
if (jdelegate != NULL) {
|
||||
xpjp_QueryInterfaceToXPCOM(env,
|
||||
jdelegate,
|
||||
NS_GET_IID(nsISupports),
|
||||
(void **)&delegate);
|
||||
}
|
||||
|
||||
assert(classID != NULL && interfaceID != NULL);
|
||||
|
||||
// Create Instance
|
||||
//cerr << "Creating Sample Instance" << endl;
|
||||
|
||||
nsIComponentManager *manager;
|
||||
|
||||
res = NS_GetGlobalComponentManager(&manager);
|
||||
|
||||
if (NS_FAILED(res)) {
|
||||
cerr << "Failed to get component manager" << endl;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
res = manager->CreateInstance(*classID,
|
||||
delegate,
|
||||
*interfaceID,
|
||||
(void **) &xpcobj);
|
||||
|
||||
if (NS_FAILED(res)) {
|
||||
cerr << "Failed to create instance" << endl;
|
||||
return NULL;
|
||||
}
|
||||
// cerr << "Wrapping " << sample << " in new ComObject" << endl;
|
||||
|
||||
// Wrap it in an ComObject
|
||||
result = xpjp_QueryInterfaceToJava(env, xpcobj, *interfaceID);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: XPComUtilities
|
||||
* Method: RegisterComponent
|
||||
* Signature: (LID;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZZ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_xpcom_XPComUtilities_RegisterComponent
|
||||
(JNIEnv *env, jclass clazz,
|
||||
jobject cid, jstring className, jstring progID, jstring libraryName,
|
||||
jboolean replace, jboolean persist)
|
||||
{
|
||||
nsresult res;
|
||||
const nsID *aClass = ID_GetNative(env, cid);
|
||||
|
||||
const char *c_className =
|
||||
(const char *)env->GetStringUTFChars(className, NULL);
|
||||
|
||||
const char *c_progID =
|
||||
(const char *)env->GetStringUTFChars(progID, NULL);
|
||||
|
||||
// PENDING: convert from library-independent to library-dependent?
|
||||
const char *c_libraryName =
|
||||
(const char *)env->GetStringUTFChars(libraryName, NULL);
|
||||
|
||||
res = nsComponentManager::RegisterComponent(*aClass,
|
||||
c_className,
|
||||
c_progID,
|
||||
c_libraryName,
|
||||
(PRBool)replace,
|
||||
(PRBool)persist);
|
||||
|
||||
env->ReleaseStringUTFChars(className, c_className);
|
||||
|
||||
env->ReleaseStringUTFChars(progID, c_progID);
|
||||
|
||||
env->ReleaseStringUTFChars(libraryName, c_libraryName);
|
||||
|
||||
if (NS_FAILED(res)) {
|
||||
cerr << "Failed to register factory" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: XPComUtilities
|
||||
* Method: AddRef
|
||||
* Signature: (J)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_xpcom_XPComUtilities_AddRef
|
||||
(JNIEnv *env, jclass cls, jlong ref)
|
||||
{
|
||||
xpjp_SafeAddRefProxyID(ref);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: XPComUtilities
|
||||
* Method: Release
|
||||
* Signature: (J)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_xpcom_XPComUtilities_Release
|
||||
(JNIEnv *env, jclass cls, jlong ref)
|
||||
{
|
||||
xpjp_SafeReleaseProxyID(ref);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: XPComUtilities
|
||||
* Method: InvokeMethodByIndex
|
||||
* Signature: (LID;IJ[Ljava/lang/Object;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_mozilla_xpcom_XPComUtilities_InvokeMethodByIndex(JNIEnv *env,
|
||||
jclass cls,
|
||||
jobject iid,
|
||||
jlong ref,
|
||||
jint index,
|
||||
jobjectArray args) {
|
||||
nsIInterfaceInfo *info = nsnull;
|
||||
nsISupports *target;
|
||||
|
||||
// XXX: check for success
|
||||
xpjd_GetInterfaceInfo(env, iid, &info);
|
||||
|
||||
// XXX: s.b. just |xpjp_UnwrapProxy(env, self);|
|
||||
nsIID *nativeIID = ID_GetNative(env, iid);
|
||||
xpjp_QueryInterfaceForProxyID(ref, *nativeIID, (void**)&target);
|
||||
|
||||
xpjd_InvokeMethod(env, target, info, index, args);
|
||||
|
||||
// XXX: remove when ref not QueryInterface'd
|
||||
xpjp_SafeReleaseProxyID(ref);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
297
mozilla/java/xpcom/old/src/xpj_XPCMethod.cpp
Normal file
297
mozilla/java/xpcom/old/src/xpj_XPCMethod.cpp
Normal file
@@ -0,0 +1,297 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Frank
|
||||
* Mitchell. Portions created by Frank Mitchell are
|
||||
* Copyright (C) 1999 Frank Mitchell. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Frank Mitchell (frank.mitchell@sun.com)
|
||||
*/
|
||||
#include <iostream.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include <jni.h>
|
||||
#include "nscore.h"
|
||||
#include "nsIFactory.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIInterfaceInfo.h"
|
||||
#include "nsIInterfaceInfoManager.h"
|
||||
#include "xptinfo.h"
|
||||
#include "xptcall.h"
|
||||
#include "xpt_struct.h"
|
||||
#include "nsIAllocator.h"
|
||||
|
||||
#include "xpjava.h"
|
||||
|
||||
#ifdef INCLUDE_JNI_HEADER
|
||||
#include "org_mozilla_xpcom_XPCMethod.h"
|
||||
#endif
|
||||
|
||||
static jfieldID XPCMethod_infoptr_ID = NULL;
|
||||
static jfieldID XPCMethod_frameptr_ID = NULL;
|
||||
static jfieldID XPCMethod_offset_ID = NULL;
|
||||
static jfieldID XPCMethod_count_ID = NULL;
|
||||
|
||||
jclass classXPCMethod = NULL;
|
||||
|
||||
#undef USE_PARAM_TEMPLATE
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Because not all platforms convert jlong to "long long"
|
||||
*
|
||||
* NOTE: this code was cut&pasted to other places, with tweaks.
|
||||
* Normally I wouldn't do this, but my reasons are:
|
||||
*
|
||||
* 1. My alternatives were to put it in xpjava.h or xpjava.cpp
|
||||
* I'd like to take stuff *out* of xpjava.h, and putting it
|
||||
* in xpjava.cpp would preclude inlining.
|
||||
*
|
||||
* 2. How we represent methods in Java is an implementation
|
||||
* detail, which may change in the future; this entire class
|
||||
* may disappear in favor of normal Java reflection, or change
|
||||
* drastically. Thus ToPtr/ToJLong is only of interest to those
|
||||
* objects that encode pointers as jlongs, which is kind of a
|
||||
* kludge to begin with.
|
||||
*
|
||||
* -- frankm, 99.09.09
|
||||
*/
|
||||
static inline jlong ToJLong(const void *p) {
|
||||
jlong result;
|
||||
jlong_I2L(result, (int)p);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline void* ToPtr(jlong l) {
|
||||
int result;
|
||||
jlong_L2I(result, l);
|
||||
return (void *)result;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: XPCMethod
|
||||
* Method: init
|
||||
* Signature: (Ljava/lang/String;Ljava/lang/String;)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_org_mozilla_xpcom_XPCMethod_init(JNIEnv *env, jobject self,
|
||||
jobject iid, jstring methodName) {
|
||||
int offset;
|
||||
const nsXPTMethodInfo *mi;
|
||||
nsID *iidPtr = ID_GetNative(env, iid);
|
||||
const char *tmpstr;
|
||||
nsresult res;
|
||||
|
||||
// Get interface info
|
||||
nsIInterfaceInfo *info = nsnull;
|
||||
|
||||
res = (XPTI_GetInterfaceInfoManager())->GetInfoForIID(iidPtr, &info);
|
||||
|
||||
if (NS_FAILED(res)) {
|
||||
cerr << "Failed to find info for " << iidPtr->ToString() << endl;
|
||||
return res;
|
||||
}
|
||||
|
||||
tmpstr = env->GetStringUTFChars(methodName, NULL);
|
||||
res = xpj_GetMethodInfoByName(iidPtr, tmpstr, PR_FALSE, &mi, &offset);
|
||||
if (NS_FAILED(res)) {
|
||||
cerr << "Cannot find method for: " << (char *)tmpstr << endl;
|
||||
return -1;
|
||||
}
|
||||
env->ReleaseStringUTFChars(methodName, tmpstr);
|
||||
|
||||
// Store argptr
|
||||
// PENDING: add iid as an argument
|
||||
|
||||
if (XPCMethod_infoptr_ID == NULL) {
|
||||
classXPCMethod = env->GetObjectClass(self);
|
||||
|
||||
classXPCMethod = (jclass)env->NewGlobalRef(classXPCMethod);
|
||||
if (classXPCMethod == NULL) return -1;
|
||||
|
||||
XPCMethod_infoptr_ID = env->GetFieldID(classXPCMethod,
|
||||
"infoptr",
|
||||
"J");
|
||||
|
||||
if (XPCMethod_infoptr_ID == NULL) {
|
||||
cerr << "Field id for infoptr not found" << endl;
|
||||
return -1;
|
||||
}
|
||||
|
||||
XPCMethod_frameptr_ID = env->GetFieldID(classXPCMethod,
|
||||
"frameptr",
|
||||
"J");
|
||||
|
||||
if (XPCMethod_frameptr_ID == NULL) {
|
||||
cerr << "Field id for frameptr not found" << endl;
|
||||
return -1;
|
||||
}
|
||||
|
||||
XPCMethod_count_ID = env->GetFieldID(classXPCMethod,
|
||||
"count",
|
||||
"I");
|
||||
|
||||
if (XPCMethod_count_ID == NULL) {
|
||||
cerr << "Field id for count not found" << endl;
|
||||
return -1;
|
||||
}
|
||||
|
||||
XPCMethod_offset_ID = env->GetFieldID(classXPCMethod,
|
||||
"offset",
|
||||
"I");
|
||||
|
||||
if (XPCMethod_offset_ID == NULL) {
|
||||
cerr << "Field id for offset not found" << endl;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
env->SetLongField(self,
|
||||
XPCMethod_infoptr_ID,
|
||||
ToJLong(info));
|
||||
|
||||
env->SetIntField(self,
|
||||
XPCMethod_count_ID,
|
||||
(jint)mi->GetParamCount());
|
||||
|
||||
#ifdef USE_PARAM_TEMPLATE
|
||||
// Build parameter array
|
||||
nsXPTCVariant *variantPtr = NULL;
|
||||
xpjd_BuildParamsForOffset(info, offset, 0, &variantPtr);
|
||||
|
||||
env->SetLongField(self,
|
||||
XPCMethod_frameptr_ID,
|
||||
ToJLong(variantPtr));
|
||||
#else
|
||||
env->SetLongField(self,
|
||||
XPCMethod_frameptr_ID,
|
||||
ToJLong(NULL));
|
||||
#endif
|
||||
|
||||
// Return offset
|
||||
return offset;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: XPCMethod
|
||||
* Method: destroyPeer
|
||||
* Signature: (J)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_mozilla_xpcom_XPCMethod_destroyPeer(JNIEnv *env,
|
||||
jobject self, jlong peer) {
|
||||
|
||||
nsXPTCVariant *variantPtr = (nsXPTCVariant *)ToPtr(peer);
|
||||
if (variantPtr != NULL) {
|
||||
nsAllocator::Free(variantPtr);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: XPCMethod
|
||||
* Method: getParameterType
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_mozilla_xpcom_XPCMethod_getParameterType
|
||||
(JNIEnv *env, jobject self, jint index) {
|
||||
|
||||
jint paramcount = env->GetIntField(self, XPCMethod_count_ID);
|
||||
|
||||
if (index >= paramcount || index < 0) {
|
||||
cerr << "Out of range: " << index << endl;
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
jint offset = env->GetIntField(self, XPCMethod_offset_ID);
|
||||
jlong ptrval = env->GetLongField(self, XPCMethod_infoptr_ID);
|
||||
|
||||
const nsXPTMethodInfo *mi;
|
||||
nsIInterfaceInfo *info = (nsIInterfaceInfo *)ToPtr(ptrval);
|
||||
|
||||
info->GetMethodInfo(offset, &mi);
|
||||
return mi->GetParam(index).GetType().TagPart();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: XPCMethod
|
||||
* Method: getParameterClass
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_mozilla_xpcom_XPCMethod_getParameterClass
|
||||
(JNIEnv *env, jobject self, jint index) {
|
||||
cerr << "Unimplemented call" << endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: XPCMethod
|
||||
* Method: invoke
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_xpcom_XPCMethod_invoke
|
||||
(JNIEnv *env, jobject self, jobject target, jobjectArray params) {
|
||||
nsresult res;
|
||||
|
||||
if (XPCMethod_infoptr_ID == NULL) {
|
||||
cerr << "Field id for infoptr not initialized" << endl;
|
||||
return;
|
||||
}
|
||||
|
||||
jint offset = env->GetIntField(self, XPCMethod_offset_ID);
|
||||
|
||||
jlong infoptr = env->GetLongField(self, XPCMethod_infoptr_ID);
|
||||
nsIInterfaceInfo *info =
|
||||
(nsIInterfaceInfo *)ToPtr(infoptr);
|
||||
|
||||
#ifdef USE_PARAM_TEMPLATE
|
||||
jint paramcount = env->GetIntField(self, XPCMethod_count_ID);
|
||||
|
||||
nsXPTCVariant *paramTemplate =
|
||||
(nsXPTCVariant *)ToPtr(env->GetLongField(self, XPCMethod_frameptr_ID));
|
||||
|
||||
nsXPTCVariant variantArray[paramcount];
|
||||
|
||||
memcpy(variantArray, paramTemplate, paramcount * sizeof(nsXPTCVariant));
|
||||
// Fix pointers
|
||||
for (int i = 0; i < paramcount; i++) {
|
||||
nsXPTCVariant *current = &(variantArray[i]);
|
||||
if (current->flags == nsXPTCVariant::PTR_IS_DATA) {
|
||||
current->ptr = ¤t->val;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
nsIID* iid = nsnull;
|
||||
nsISupports *true_target = nsnull;
|
||||
|
||||
// XXX: check for success
|
||||
info->GetIID(&iid);
|
||||
|
||||
// XXX: check for success
|
||||
xpjp_QueryInterfaceToXPCOM(env, target, *iid, (void**)&true_target);
|
||||
|
||||
xpjd_InvokeMethod(env, true_target, info, offset, params);
|
||||
|
||||
xpjp_SafeRelease(true_target);
|
||||
nsAllocator::Free(iid);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
103
mozilla/java/xpcom/old/src/xpj_dispatch.h
Normal file
103
mozilla/java/xpcom/old/src/xpj_dispatch.h
Normal file
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Frank
|
||||
* Mitchell. Portions created by Frank Mitchell are
|
||||
* Copyright (C) 1999 Frank Mitchell. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Frank Mitchell (frank.mitchell@sun.com)
|
||||
*/
|
||||
#include <jni.h>
|
||||
#include "nsISupports.h"
|
||||
#include "xptcall.h"
|
||||
#include "xptinfo.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Initialize caches for often-used Java classes (all in java.lang).
|
||||
* Will return JNI_FALSE if those classes, or their fields
|
||||
* and methods, aren't found.
|
||||
* @deprecated
|
||||
*/
|
||||
/* XXX: should be hidden in first call to xpjd_InvokeMethod */
|
||||
jboolean xpjd_InitJavaCaches(JNIEnv *env);
|
||||
|
||||
/**
|
||||
* Uncaches often-used Java classes (e.g. during unload).
|
||||
*/
|
||||
/* XXX: should be part of general unloading mechanism */
|
||||
void xpjd_FlushJavaCaches(JNIEnv *env);
|
||||
|
||||
/**
|
||||
* Convenience method to get the nsIInterfaceInfo for an
|
||||
* interface denoted by the Java IID object `iid'.
|
||||
* Will return JNI_FALSE if `iid' isn't a org.mozilla.xpcom.nsID
|
||||
* or no info object exists.
|
||||
*/
|
||||
jboolean xpjd_GetInterfaceInfo(JNIEnv *env,
|
||||
jobject iid,
|
||||
nsIInterfaceInfo **info);
|
||||
|
||||
/**
|
||||
* Convenience method to get the nsIInterfaceInfo for an
|
||||
* interface denoted by the C++ struct `iid'.
|
||||
* Will return JNI_FALSE if `iid' isn't a org.mozilla.xpcom.nsID
|
||||
* or no info object exists.
|
||||
*/
|
||||
jboolean xpjd_GetInterfaceInfoNative(REFNSIID iid,
|
||||
nsIInterfaceInfo **info);
|
||||
|
||||
/**
|
||||
* Invoke a method on 'target' indicated by the 'methodIndex'-th
|
||||
* method in `info', with arguments `args'.
|
||||
* Throws a Java exception if `target' can't receive the method,
|
||||
* `methodIndex' is out of bounds, `args' contains too few arguments,
|
||||
* or any of the pointer arguments is NULL.
|
||||
*/
|
||||
void xpjd_InvokeMethod(JNIEnv *env,
|
||||
nsISupports *target,
|
||||
nsIInterfaceInfo *info,
|
||||
jint methodIndex,
|
||||
jobjectArray args);
|
||||
|
||||
#if 0 /* not implemented yet */
|
||||
|
||||
/**
|
||||
* Optimized version of `xpjd_InvokeMethod' to get attributes, or
|
||||
* methods with only one in parameter and no outs or inouts.
|
||||
*/
|
||||
jobject xpjd_GetAttribute(JNIEnv *env,
|
||||
nsISupports *target,
|
||||
nsIInterfaceInfo *info,
|
||||
jint getMethodIndex);
|
||||
|
||||
/**
|
||||
* Optimized version of `xpjd_InvokeMethod' to set attributes, or
|
||||
* methods with only one out parameter and no ins or inouts.
|
||||
*/
|
||||
void xpjd_SetAttribute(JNIEnv *env,
|
||||
nsISupports *target,
|
||||
nsIInterfaceInfo *info,
|
||||
jint setMethodIndex,
|
||||
jobject value);
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
298
mozilla/java/xpcom/old/src/xpj_nsID.cpp
Normal file
298
mozilla/java/xpcom/old/src/xpj_nsID.cpp
Normal file
@@ -0,0 +1,298 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Frank
|
||||
* Mitchell. Portions created by Frank Mitchell are
|
||||
* Copyright (C) 1999 Frank Mitchell. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Frank Mitchell (frank.mitchell@sun.com)
|
||||
*/
|
||||
#include <iostream.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include <jni.h>
|
||||
#include "nscore.h"
|
||||
#include "nsID.h"
|
||||
#include "nsIAllocator.h"
|
||||
|
||||
#include "xpjava.h"
|
||||
|
||||
#ifdef INCLUDE_JNI_HEADER
|
||||
#include "org_mozilla_xpcom_nsID.h"
|
||||
#endif
|
||||
|
||||
#define ID_CLASS_NAME "org/mozilla/xpcom/nsID"
|
||||
#define ID_FIELD_NAME "nsidptr"
|
||||
#define ID_FIELD_TYPE "J"
|
||||
|
||||
/* Because not all platforms convert jlong to "long long"
|
||||
*
|
||||
* NOTE: this code was cut&pasted from xpj_XPCMethod.cpp, with tweaks.
|
||||
* Normally I wouldn't do this, but my reasons are:
|
||||
*
|
||||
* 1. My alternatives were to put it in xpjava.h or xpjava.cpp
|
||||
* I'd like to take stuff *out* of xpjava.h, and putting it
|
||||
* in xpjava.cpp would preclude inlining.
|
||||
*
|
||||
* 2. How we represent nsIDs in Java is an implementation
|
||||
* detail, which may change in the future (e.g. placing the
|
||||
* whole value in the Java obj, not just a pointer to heap
|
||||
* memory). Thus ToPtr/ToJLong is only of interest to those
|
||||
* objects that stuff pointers into jlongs.
|
||||
*
|
||||
* -- frankm, 99.09.09
|
||||
*/
|
||||
static inline jlong ToJLong(const void *p) {
|
||||
jlong result;
|
||||
jlong_I2L(result, (int)p);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline void* ToPtr(jlong l) {
|
||||
int result;
|
||||
jlong_L2I(result, l);
|
||||
return (void *)result;
|
||||
}
|
||||
|
||||
#undef DEBUG_GETSET_ID
|
||||
|
||||
#ifdef DEBUG_GETSET_ID
|
||||
static void GetClassName(char *namebuf, JNIEnv *env, jobject self, int len) {
|
||||
jclass clazz = env->GetObjectClass(self);
|
||||
jclass clazz_clazz = env->GetObjectClass(clazz);
|
||||
jmethodID nameID = env->GetMethodID(clazz_clazz, "getName", "()Ljava/lang/String;");
|
||||
jstring string = (jstring)env->CallObjectMethod(clazz, nameID);
|
||||
|
||||
jsize jstrlen = env->GetStringUTFLength(string);
|
||||
const char *utf = env->GetStringUTFChars(string, NULL);
|
||||
|
||||
if (jstrlen >= len) {
|
||||
jstrlen = len;
|
||||
}
|
||||
strncpy(namebuf, utf, jstrlen);
|
||||
namebuf[jstrlen] = '\0';
|
||||
|
||||
env->ReleaseStringUTFChars(string, utf);
|
||||
}
|
||||
#endif
|
||||
|
||||
/********************** ID **************************/
|
||||
|
||||
jobject ID_NewJavaID(JNIEnv *env, const nsIID* iid) {
|
||||
jclass clazz = env->FindClass(ID_CLASS_NAME);
|
||||
jmethodID initID = env->GetMethodID(clazz, "<init>", "()V");
|
||||
|
||||
jobject result = env->NewObject(clazz, initID);
|
||||
nsID *idptr = (nsID *)nsAllocator::Alloc(sizeof(nsID));
|
||||
|
||||
memcpy(idptr, iid, sizeof(nsID));
|
||||
ID_SetNative(env, result, idptr);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
nsID *ID_GetNative(JNIEnv *env, jobject self) {
|
||||
jclass clazz = env->FindClass(ID_CLASS_NAME);
|
||||
jfieldID nsidptrID = env->GetFieldID(clazz, ID_FIELD_NAME, ID_FIELD_TYPE);
|
||||
|
||||
#ifdef DEBUG_GETSET_ID
|
||||
char classname[128];
|
||||
|
||||
GetClassName(classname, env, self, sizeof(classname));
|
||||
fprintf(stderr, "ID_GetNative: self instanceof %s\n", classname);
|
||||
fflush(stderr);
|
||||
#endif
|
||||
|
||||
assert(env->IsInstanceOf(self, clazz));
|
||||
|
||||
jlong nsidptr = env->GetLongField(self, nsidptrID);
|
||||
|
||||
return (nsID *)ToPtr(nsidptr);
|
||||
}
|
||||
|
||||
void ID_SetNative(JNIEnv *env, jobject self, nsID *id) {
|
||||
jclass clazz = env->FindClass(ID_CLASS_NAME);
|
||||
jfieldID nsidptrID = env->GetFieldID(clazz, ID_FIELD_NAME, ID_FIELD_TYPE);
|
||||
|
||||
#ifdef DEBUG_GETSET_ID
|
||||
char classname[128];
|
||||
|
||||
GetClassName(classname, env, self, sizeof(classname));
|
||||
fprintf(stderr, "ID_SetNative: self instanceof %s\n", classname);
|
||||
fflush(stderr);
|
||||
#endif
|
||||
|
||||
assert(env->IsInstanceOf(self, clazz));
|
||||
|
||||
jlong nsidptr = ToJLong(id);
|
||||
|
||||
env->SetLongField(self, nsidptrID, nsidptr);
|
||||
}
|
||||
|
||||
jboolean ID_IsEqual(JNIEnv *env, jobject self, jobject other) {
|
||||
jboolean result = JNI_FALSE;
|
||||
jclass clazz = env->FindClass(ID_CLASS_NAME);
|
||||
jfieldID nsidptrID = env->GetFieldID(clazz, ID_FIELD_NAME, ID_FIELD_TYPE);
|
||||
|
||||
#ifdef DEBUG_GETSET_ID
|
||||
char classname[128];
|
||||
|
||||
GetClassName(classname, env, self, sizeof(classname));
|
||||
fprintf(stderr, "ID_IsEqual: self instanceof %s\n", classname);
|
||||
|
||||
GetClassName(classname, env, other, sizeof(classname));
|
||||
fprintf(stderr, "ID_IsEqual: other instanceof %s\n", classname);
|
||||
fflush(stderr);
|
||||
#endif
|
||||
|
||||
assert(env->IsInstanceOf(self, clazz));
|
||||
|
||||
if (other != NULL && env->IsInstanceOf(other, clazz)) {
|
||||
nsID *selfid = (nsID *)ToPtr(env->GetLongField(self, nsidptrID));
|
||||
nsID *otherid = (nsID *)ToPtr(env->GetLongField(other, nsidptrID));
|
||||
|
||||
if (selfid != NULL && otherid != NULL) {
|
||||
result = selfid->Equals(*otherid);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Class: ID
|
||||
* Method: NewIDPtr
|
||||
* Signature: (ISSBBBBBBBB)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_xpcom_nsID_NewIDPtr__ISSBBBBBBBB
|
||||
(JNIEnv *env, jobject self, jint m0, jshort m1, jshort m2,
|
||||
jbyte m30, jbyte m31, jbyte m32, jbyte m33,
|
||||
jbyte m34, jbyte m35, jbyte m36, jbyte m37) {
|
||||
|
||||
nsID *idptr = (nsID *)nsAllocator::Alloc(sizeof(nsID));
|
||||
idptr->m0 = m0;
|
||||
idptr->m1 = m1;
|
||||
idptr->m2 = m2;
|
||||
idptr->m3[0] = m30;
|
||||
idptr->m3[1] = m31;
|
||||
idptr->m3[2] = m32;
|
||||
idptr->m3[3] = m33;
|
||||
idptr->m3[4] = m34;
|
||||
idptr->m3[5] = m35;
|
||||
idptr->m3[6] = m36;
|
||||
idptr->m3[7] = m37;
|
||||
|
||||
ID_SetNative(env, self, idptr);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: ID
|
||||
* Method: NewIDPtr
|
||||
* Signature: (Ljava/lang/String;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_xpcom_nsID_NewIDPtr__Ljava_lang_String_2
|
||||
(JNIEnv *env, jobject self, jstring string) {
|
||||
|
||||
nsID *idptr = (nsID *)nsAllocator::Alloc(sizeof(nsID));
|
||||
|
||||
jboolean isCopy;
|
||||
const char *utf = env->GetStringUTFChars(string, &isCopy);
|
||||
char *aIDStr;
|
||||
|
||||
if (isCopy) {
|
||||
aIDStr = (char *)utf;
|
||||
}
|
||||
else {
|
||||
jsize len = env->GetStringUTFLength(string);
|
||||
aIDStr = (char *)nsAllocator::Alloc(len * sizeof(char));
|
||||
strncpy(aIDStr, utf, len);
|
||||
aIDStr[len - 1] = 0;
|
||||
}
|
||||
|
||||
if (!(idptr->Parse(aIDStr))) {
|
||||
nsAllocator::Free(idptr);
|
||||
idptr = NULL;
|
||||
}
|
||||
|
||||
ID_SetNative(env, self, idptr);
|
||||
|
||||
if (!isCopy) {
|
||||
nsAllocator::Free(aIDStr);
|
||||
}
|
||||
|
||||
env->ReleaseStringUTFChars(string, utf);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: ID
|
||||
* Method: finalize
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_xpcom_nsID_finalize(JNIEnv *env, jobject self) {
|
||||
nsID *idptr = ID_GetNative(env, self);
|
||||
|
||||
nsAllocator::Free(idptr);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: ID
|
||||
* Method: equals
|
||||
* Signature: (Ljava/lang/Object;)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_org_mozilla_xpcom_nsID_equals(JNIEnv *env, jobject self, jobject other) {
|
||||
return ID_IsEqual(env, self, other);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: ID
|
||||
* Method: toString
|
||||
* Signature: ()Ljava/lang/String;
|
||||
*/
|
||||
JNIEXPORT jstring JNICALL Java_org_mozilla_xpcom_nsID_toString(JNIEnv *env, jobject self) {
|
||||
|
||||
nsID *idptr = ID_GetNative(env, self);
|
||||
|
||||
char *idstr = idptr->ToString();
|
||||
|
||||
jstring result = env->NewStringUTF(idstr);
|
||||
|
||||
delete [] idstr;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: ID
|
||||
* Method: hashCode
|
||||
* Signature: ()I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_mozilla_xpcom_nsID_hashCode(JNIEnv *env, jobject self) {
|
||||
jint result;
|
||||
|
||||
PRUint32 *intptr = (PRUint32 *)ID_GetNative(env, self);
|
||||
|
||||
result = intptr[0] ^ intptr[1] ^ intptr[2] ^ intptr[3];
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
243
mozilla/java/xpcom/old/src/xpj_proxy.cpp
Normal file
243
mozilla/java/xpcom/old/src/xpj_proxy.cpp
Normal file
@@ -0,0 +1,243 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Frank
|
||||
* Mitchell. Portions created by Frank Mitchell are
|
||||
* Copyright (C) 1999 Frank Mitchell. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Frank Mitchell (frank.mitchell@sun.com)
|
||||
*/
|
||||
#include "xpjava.h"
|
||||
|
||||
#define JAVA_XPCOBJECT_CLASS "org/mozilla/xpcom/ComObject"
|
||||
|
||||
static jclass classComObject = NULL;
|
||||
static jfieldID ComObject_objptr_ID = NULL;
|
||||
|
||||
/* --------- SUPPORT FUNCTIONS ------------- */
|
||||
|
||||
/* Because not all platforms convert jlong to "long long"
|
||||
*
|
||||
* NOTE: this code was cut&pasted from xpj_XPCMethod.cpp, with tweaks.
|
||||
* Normally I wouldn't do this, but my reasons are:
|
||||
*
|
||||
* 1. My alternatives were to put it in xpjava.h or xpjava.cpp
|
||||
* I'd like to take stuff *out* of xpjava.h, and putting it
|
||||
* in xpjava.cpp would preclude inlining.
|
||||
*
|
||||
* 2. How we map proxies to XPCOM objects is an implementation
|
||||
* detail, which may change in the future (e.g. an index
|
||||
* into a proxy table). Thus ToPtr/ToJLong is only of
|
||||
* interest to those objects that stuff pointers into jlongs.
|
||||
*
|
||||
* 3. This allows adaptations to each implementation, for
|
||||
* type safety (e.g. taking and returning nsISupports*).
|
||||
*
|
||||
* -- frankm, 99.09.09
|
||||
*/
|
||||
static inline jlong ToJLong(nsISupports *p) {
|
||||
jlong result;
|
||||
jlong_I2L(result, (int)p);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline nsISupports* ToPtr(jlong l) {
|
||||
int result;
|
||||
jlong_L2I(result, l);
|
||||
return (nsISupports *)result;
|
||||
}
|
||||
|
||||
static inline jboolean xpjp_QueryInterface(nsISupports *object,
|
||||
REFNSIID iid,
|
||||
void **instance) {
|
||||
assert(object != NULL && instance != NULL);
|
||||
|
||||
if (NS_SUCCEEDED(object->QueryInterface(iid, instance))) {
|
||||
return JNI_TRUE;
|
||||
}
|
||||
return JNI_FALSE;
|
||||
}
|
||||
|
||||
static jboolean xpjp_InitJavaCaches(JNIEnv *env) {
|
||||
if (ComObject_objptr_ID == NULL) {
|
||||
classComObject = env->FindClass(JAVA_XPCOBJECT_CLASS);
|
||||
if (classComObject == NULL) return JNI_FALSE;
|
||||
|
||||
classComObject = (jclass)env->NewGlobalRef(classComObject);
|
||||
if (classComObject == NULL) return JNI_FALSE;
|
||||
|
||||
ComObject_objptr_ID = env->GetFieldID(classComObject, "objptr", "J");
|
||||
if (ComObject_objptr_ID == NULL) return JNI_FALSE;
|
||||
}
|
||||
return JNI_TRUE;
|
||||
}
|
||||
|
||||
|
||||
static jclass xpjp_ClassForInterface(JNIEnv *env, REFNSIID iid) {
|
||||
#if 0
|
||||
// Get info
|
||||
jclass result = classComObject; // null?
|
||||
nsIInterfaceInfo *info = nsnull;
|
||||
char *interface_name;
|
||||
char *name_space;
|
||||
char *full_classname;
|
||||
char *ch;
|
||||
nsresult res;
|
||||
|
||||
res = interfaceInfoManager->GetInfoForIID(&iid, &info);
|
||||
|
||||
if (NS_FAILED(res)) {
|
||||
cerr << "Failed to find info for " << iid.ToString() << endl;
|
||||
goto end;
|
||||
}
|
||||
|
||||
// XXX: PENDING: find name_space somehow
|
||||
name_space = "org.mozilla.xpcom";
|
||||
|
||||
res = info->GetName(&interface_name);
|
||||
|
||||
if (NS_FAILED(res)) {
|
||||
cerr << "Failed to find name for " << iid.ToString() << endl;
|
||||
goto end;
|
||||
}
|
||||
|
||||
// Construct class name
|
||||
full_classname =
|
||||
(char*)nsAllocator::Alloc(strlen(interface_name) + strlen(name_space) + 2);
|
||||
|
||||
strcpy(full_classname, name_space);
|
||||
ch = full_classname;
|
||||
while (ch != '\0') {
|
||||
if (*ch == '.') {
|
||||
*ch = '/';
|
||||
}
|
||||
ch++;
|
||||
}
|
||||
strcat(full_classname, "/");
|
||||
strcat(full_classname, interface_name);
|
||||
|
||||
cerr << "Looking for " << full_classname << endl;
|
||||
|
||||
result = env->FindClass(full_classname);
|
||||
// XXX: PENDING: If no such class found, make it
|
||||
|
||||
// XXX: PENDING: Cache result
|
||||
end:
|
||||
// Cleanup
|
||||
nsAllocator::Free(interface_name);
|
||||
nsAllocator::Free(full_classname);
|
||||
//nsAllocator::Free(name_space);
|
||||
|
||||
return result;
|
||||
#else
|
||||
return classComObject;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* --------- PROXY API FUNCTIONS ------------- */
|
||||
|
||||
jobject xpjp_QueryInterfaceToJava(JNIEnv *env,
|
||||
nsISupports *obj,
|
||||
REFNSIID iid) {
|
||||
if (!xpjp_InitJavaCaches(env)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// XXX: Bad implementation; returns a new proxy every time
|
||||
jobject result = 0;
|
||||
jmethodID initID = 0;
|
||||
jclass proxyClass = xpjp_ClassForInterface(env, iid);
|
||||
jobject jiid = ID_NewJavaID(env, &iid);
|
||||
|
||||
assert(proxyClass != 0);
|
||||
|
||||
initID = env->GetMethodID(proxyClass, "<init>", "(J)V");
|
||||
|
||||
if (initID != NULL) {
|
||||
result = env->NewObject(proxyClass, initID, ToJLong(obj), jiid);
|
||||
}
|
||||
else {
|
||||
initID = env->GetMethodID(proxyClass, "<init>", "()V");
|
||||
|
||||
result = env->NewObject(proxyClass, initID);
|
||||
env->SetLongField(result, ComObject_objptr_ID, ToJLong(obj));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
jboolean xpjp_QueryInterfaceToXPCOM(JNIEnv *env,
|
||||
jobject proxy,
|
||||
REFNSIID iid,
|
||||
void **instance) {
|
||||
nsISupports* xpcobj = xpjp_UnwrapProxy(env, proxy);
|
||||
if (xpcobj != NULL) {
|
||||
return xpjp_QueryInterface(xpcobj, iid, instance);
|
||||
}
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
nsISupports* xpjp_UnwrapProxy(JNIEnv *env, jobject proxy) {
|
||||
if (!xpjp_InitJavaCaches(env)) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
return ToPtr(env->GetLongField(proxy, ComObject_objptr_ID));
|
||||
}
|
||||
|
||||
void xpjp_SafeAddRef(nsISupports *object) {
|
||||
/* XXX: NOT "SAFE" */
|
||||
NS_ADDREF(object);
|
||||
}
|
||||
|
||||
void xpjp_SafeRelease(nsISupports *object) {
|
||||
/* XXX: NOT "SAFE" */
|
||||
NS_RELEASE(object);
|
||||
}
|
||||
|
||||
void xpjp_SafeAddRefProxy(JNIEnv *env, jobject proxy) {
|
||||
nsISupports* xpcobj = xpjp_UnwrapProxy(env, proxy);
|
||||
if (xpcobj != NULL) {
|
||||
xpjp_SafeAddRef(xpcobj);
|
||||
}
|
||||
}
|
||||
|
||||
void xpjp_SafeReleaseProxy(JNIEnv *env, jobject proxy) {
|
||||
nsISupports* xpcobj = xpjp_UnwrapProxy(env, proxy);
|
||||
if (xpcobj != NULL) {
|
||||
xpjp_SafeRelease(xpcobj);
|
||||
}
|
||||
}
|
||||
|
||||
/* deprecated */
|
||||
jboolean xpjp_QueryInterfaceForProxyID(jlong ref,
|
||||
REFNSIID iid,
|
||||
void **instance) {
|
||||
nsISupports *xpcobj = ToPtr(ref);
|
||||
|
||||
if (xpcobj != NULL) {
|
||||
return xpjp_QueryInterface(xpcobj, iid, instance);
|
||||
}
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
/* deprecated */
|
||||
void xpjp_SafeReleaseProxyID(jlong ref) {
|
||||
xpjp_SafeRelease(ToPtr(ref));
|
||||
}
|
||||
|
||||
/* deprecated */
|
||||
void xpjp_SafeAddRefProxyID(jlong ref) {
|
||||
xpjp_SafeAddRef(ToPtr(ref));
|
||||
}
|
||||
103
mozilla/java/xpcom/old/src/xpj_proxy.h
Normal file
103
mozilla/java/xpcom/old/src/xpj_proxy.h
Normal file
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Frank
|
||||
* Mitchell. Portions created by Frank Mitchell are
|
||||
* Copyright (C) 1999 Frank Mitchell. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Frank Mitchell (frank.mitchell@sun.com)
|
||||
*/
|
||||
#include <jni.h>
|
||||
#include "nsISupports.h"
|
||||
#include "xptcall.h"
|
||||
#include "xptinfo.h"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Returns a jobject implementing the interface indicated by `iid',
|
||||
* or NULL if `ptr' does not implement that interface.
|
||||
* The function wraps the XPCOM object in a Java proxy, unless it
|
||||
* is itself a proxy to a Java object; in that case, it unwraps the
|
||||
* proxy before testing.
|
||||
* The refcount of `ptr' will be incremented if it is wrapped.
|
||||
*/
|
||||
/* XXX: should we skip actual QueryInterface if not a proxy? */
|
||||
jobject xpjp_QueryInterfaceToJava(JNIEnv *env,
|
||||
nsISupports *ptr,
|
||||
REFNSIID iid);
|
||||
|
||||
/**
|
||||
* Sets `instance' to an instance of the interface indicated by `iid'.
|
||||
* If the Java object is a proxy, the function unwraps it and performs
|
||||
* QueryInterface(); otherwise, it performs QueryInterface() on
|
||||
* `object' and, if that succeeds, wraps it in a C++ proxy.
|
||||
* The refcount of `object' will be incremented if it is unwrapped.
|
||||
*/
|
||||
jboolean xpjp_QueryInterfaceToXPCOM(JNIEnv *env,
|
||||
jobject object,
|
||||
REFNSIID iid,
|
||||
void **instance);
|
||||
|
||||
/**
|
||||
* If `proxy' is a proxy to a nsISupports, returns the
|
||||
* contained pointer and returns true; otherwise, return NULL.
|
||||
* Used mainly for proxy implementation; others should
|
||||
* use QueryInterfaceToXPCOM().
|
||||
* The refcount of the return value is unchanged.
|
||||
*/
|
||||
nsISupports* xpjp_UnwrapProxy(JNIEnv *env, jobject proxy);
|
||||
|
||||
/**
|
||||
* Perform ptr->AddRef() in a thread-safe manner.
|
||||
*/
|
||||
void xpjp_SafeAddRef(nsISupports *ptr);
|
||||
|
||||
/**
|
||||
* Perform ptr->Release() in a thread-safe manner.
|
||||
*/
|
||||
void xpjp_SafeRelease(nsISupports *ptr);
|
||||
|
||||
/**
|
||||
* Perform AddRef() on `proxy''s underlying object in a
|
||||
* thread-safe manner.
|
||||
* Has no effect if proxy is not a proxy to a ref-counted object.
|
||||
*/
|
||||
void xpjp_SafeAddRefProxy(JNIEnv *env, jobject proxy);
|
||||
|
||||
/**
|
||||
* Perform Release() on `proxy''s underlying object in a
|
||||
* thread-safe manner.
|
||||
* Has no effect if proxy is not a proxy to a ref-counted object.
|
||||
*/
|
||||
void xpjp_SafeReleaseProxy(JNIEnv *env, jobject proxy);
|
||||
|
||||
|
||||
/* deprecated API */
|
||||
|
||||
jboolean xpjp_QueryInterfaceForProxyID(jlong ref,
|
||||
REFNSIID iid,
|
||||
void **instance);
|
||||
|
||||
void xpjp_SafeAddRefProxyID(jlong ref);
|
||||
|
||||
void xpjp_SafeReleaseProxyID(jlong ref);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
76
mozilla/java/xpcom/old/src/xpj_utils.h
Normal file
76
mozilla/java/xpcom/old/src/xpj_utils.h
Normal file
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Frank
|
||||
* Mitchell. Portions created by Frank Mitchell are
|
||||
* Copyright (C) 1999 Frank Mitchell. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Frank Mitchell (frank.mitchell@sun.com)
|
||||
*/
|
||||
#include <jni.h>
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "xptinfo.h"
|
||||
|
||||
/*
|
||||
* Macros defined in some, but not all, jni_md.h, for
|
||||
* compilers that don't have 64 bit ints.
|
||||
*/
|
||||
#ifndef jlong_L2I
|
||||
# define jlong_L2I(_i, _l) ((_i) = (_l))
|
||||
# define jlong_I2L(_l, _i) ((_l) = (_i))
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Start up XPCOM
|
||||
* @deprecated
|
||||
*/
|
||||
/* XXX: should move into test directory */
|
||||
nsresult xpj_InitXPCOM();
|
||||
|
||||
/**
|
||||
* Find the method info for method or attribute `methodname'.
|
||||
* If an attribute, do not prefix with "get" or "set"; set
|
||||
* `wantsSetter' to select the getter or setter.
|
||||
* The contents of `indexPtr' are set to the method's index.
|
||||
*/
|
||||
nsresult xpj_GetMethodInfoByName(const nsID *iid,
|
||||
const char *methodname,
|
||||
PRBool wantSetter,
|
||||
const nsXPTMethodInfo **miptr,
|
||||
int *indexPtr);
|
||||
|
||||
/* Defined in xpj_nsID.cpp */
|
||||
|
||||
/** Create a new Java wrapper for `id' */
|
||||
jobject ID_NewJavaID(JNIEnv *env, const nsID* id);
|
||||
|
||||
/** Unwrap an nsID; returns the internal struct, *not a copy* */
|
||||
nsID* ID_GetNative(JNIEnv *env, jobject self);
|
||||
|
||||
/** Copies `id' to a Java wrapper */
|
||||
void ID_SetNative(JNIEnv *env, jobject self, nsID* id);
|
||||
|
||||
/** Compares two Java wrappers for an nsID */
|
||||
jboolean ID_IsEqual(JNIEnv *env, jobject self, jobject other);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
819
mozilla/java/xpcom/old/src/xpjava.cpp
Normal file
819
mozilla/java/xpcom/old/src/xpjava.cpp
Normal file
@@ -0,0 +1,819 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Frank
|
||||
* Mitchell. Portions created by Frank Mitchell are
|
||||
* Copyright (C) 1999 Frank Mitchell. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Frank Mitchell (frank.mitchell@sun.com)
|
||||
*/
|
||||
#include <iostream.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include "nscore.h"
|
||||
#include "nsIFactory.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIInterfaceInfo.h"
|
||||
#include "nsIInterfaceInfoManager.h"
|
||||
#include "xptinfo.h"
|
||||
#include "xptcall.h"
|
||||
#include "xpt_struct.h"
|
||||
#include "nsIAllocator.h"
|
||||
#include "nsSpecialSystemDirectory.h"
|
||||
|
||||
#include "xpjava.h"
|
||||
|
||||
|
||||
#ifdef XP_PC
|
||||
#define XPCOM_DLL "xpcom32.dll"
|
||||
#define SAMPLE_DLL "sampl32.dll"
|
||||
#else
|
||||
#ifdef XP_MAC
|
||||
#define XPCOM_DLL "XPCOM_DLL"
|
||||
#define SAMPLE_DLL "SAMPL_DLL"
|
||||
#else
|
||||
#define XPCOM_DLL "libxpcom.so"
|
||||
#define SAMPLE_DLL "libsample.so"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/* Global references to frequently used classes and objects */
|
||||
static jclass classString;
|
||||
static jclass classByte;
|
||||
static jclass classShort;
|
||||
static jclass classInteger;
|
||||
static jclass classLong;
|
||||
static jclass classFloat;
|
||||
static jclass classDouble;
|
||||
static jclass classBoolean;
|
||||
static jclass classCharacter;
|
||||
|
||||
/* Cached field and method IDs */
|
||||
static jfieldID Byte_value_ID;
|
||||
static jfieldID Short_value_ID;
|
||||
static jfieldID Integer_value_ID;
|
||||
static jfieldID Long_value_ID;
|
||||
static jfieldID Float_value_ID;
|
||||
static jfieldID Double_value_ID;
|
||||
static jfieldID Boolean_value_ID;
|
||||
static jfieldID Character_value_ID;
|
||||
|
||||
static jmethodID Byte_init_ID;
|
||||
static jmethodID Short_init_ID;
|
||||
static jmethodID Integer_init_ID;
|
||||
static jmethodID Long_init_ID;
|
||||
static jmethodID Float_init_ID;
|
||||
static jmethodID Double_init_ID;
|
||||
static jmethodID Boolean_init_ID;
|
||||
static jmethodID Character_init_ID;
|
||||
|
||||
/* Global references to frequently used XPCOM objects */
|
||||
static nsIInterfaceInfoManager *interfaceInfoManager;
|
||||
|
||||
/* Flag to indicate caches filled */
|
||||
static jboolean cache_initialized = JNI_FALSE;
|
||||
|
||||
|
||||
/* ---------- GENERAL API FUNCTIONS ------------ */
|
||||
|
||||
nsresult xpj_InitXPCOM() {
|
||||
nsresult res;
|
||||
|
||||
#ifdef DEBUG_frankm
|
||||
cerr << "Initializing XPCOM" << endl;
|
||||
#endif
|
||||
|
||||
// Autoregistration magic. Boogeda boogeda.
|
||||
res = nsComponentManager::AutoRegister(nsIComponentManager::NS_Startup,
|
||||
nsnull);
|
||||
|
||||
#ifdef DEBUG_frankm
|
||||
cerr << "XPCOM Initialized" << endl;
|
||||
#endif
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
nsresult xpj_GetMethodInfoByName(const nsID *iid,
|
||||
const char *methodname,
|
||||
PRBool wantSetter,
|
||||
const nsXPTMethodInfo **miptr,
|
||||
int *_retval) {
|
||||
nsresult res;
|
||||
|
||||
// Get info
|
||||
nsIInterfaceInfo *info = nsnull;
|
||||
|
||||
res = interfaceInfoManager->GetInfoForIID(iid, &info);
|
||||
|
||||
if (NS_FAILED(res)) {
|
||||
cerr << "Failed to find info for " << iid->ToString() << endl;
|
||||
return res;
|
||||
}
|
||||
|
||||
// Find info for command
|
||||
uint16 methodcount;
|
||||
|
||||
info->GetMethodCount(&methodcount);
|
||||
|
||||
int i;
|
||||
for (i = 0; i < methodcount; i++) {
|
||||
const nsXPTMethodInfo *mi;
|
||||
|
||||
info->GetMethodInfo(i, &mi);
|
||||
// PENDING(frankm): match against name, get/set, *AND* param types
|
||||
if (strcmp(methodname, mi->GetName()) == 0) {
|
||||
PRBool setter = mi->IsSetter();
|
||||
PRBool getter = mi->IsGetter();
|
||||
if ((!getter && !setter)
|
||||
|| (setter && wantSetter)
|
||||
|| (getter && !wantSetter)) {
|
||||
*miptr = mi;
|
||||
*_retval = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (i >= methodcount) {
|
||||
cerr << "Failed to find " << methodname << endl;
|
||||
*miptr = NULL;
|
||||
*_retval = -1;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/* ---------- DISPATCH SUPPORT FUNCTIONS ------------ */
|
||||
|
||||
static
|
||||
int xpjd_BuildParamsForOffset(nsIInterfaceInfo *info,
|
||||
jint offset,
|
||||
jint arraysize,
|
||||
nsXPTCVariant **_retval) {
|
||||
const nsXPTMethodInfo *mi;
|
||||
nsresult res;
|
||||
|
||||
// Find info for command
|
||||
uint16 methodcount;
|
||||
|
||||
info->GetMethodCount(&methodcount);
|
||||
|
||||
if (offset < methodcount) {
|
||||
info->GetMethodInfo(offset, &mi);
|
||||
}
|
||||
else {
|
||||
cerr << "Offset " << offset << " should be < " << methodcount << endl;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (NS_FAILED(res)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Make sure the array is large enough, and alloc more if
|
||||
// necessary.
|
||||
int paramcount = mi->GetParamCount();
|
||||
|
||||
if (paramcount > arraysize || *_retval == NULL) {
|
||||
*_retval = (nsXPTCVariant *)
|
||||
nsAllocator::Alloc(sizeof(nsXPTCVariant) * paramcount);
|
||||
}
|
||||
|
||||
// Set flags, pointers, and types for array elements
|
||||
nsXPTCVariant *current = *_retval;
|
||||
|
||||
for (int i = 0; i < paramcount; i++) {
|
||||
nsXPTParamInfo param = mi->GetParam(i);
|
||||
nsXPTType type = param.GetType();
|
||||
|
||||
current->type = type.TagPart();
|
||||
current->flags = 0;
|
||||
|
||||
if (!param.IsOut()) {
|
||||
current->flags = 0;
|
||||
current->ptr = 0;
|
||||
}
|
||||
else {
|
||||
// PTR_IS_DATA: ptr points to 'real' data in val
|
||||
current->flags = nsXPTCVariant::PTR_IS_DATA;
|
||||
|
||||
if (type.IsPointer()) {
|
||||
current->val.p = NULL;
|
||||
current->ptr = ¤t->val.p;
|
||||
// PENDING: does this routine also alloc memory?
|
||||
// Or do we treat pointers to basic types like "out"
|
||||
// parameters?
|
||||
// What about an out parameter that is a
|
||||
}
|
||||
else {
|
||||
// PENDING: Will this work on all platforms?
|
||||
current->ptr = ¤t->val;
|
||||
}
|
||||
}
|
||||
current++;
|
||||
}
|
||||
return paramcount;
|
||||
}
|
||||
|
||||
static jboolean JObjectToVariant(JNIEnv *env,
|
||||
nsXPTCVariant *current,
|
||||
const jobject elem,
|
||||
REFNSIID iid) {
|
||||
jboolean result = JNI_FALSE;
|
||||
/*
|
||||
* Match:
|
||||
* T_BOOL : Boolean
|
||||
* T_I8: Byte
|
||||
* T_I16: Short
|
||||
* T_I32: Integer
|
||||
* T_I64: Long
|
||||
* -- we may want to support widening casts
|
||||
* T_U<n>: T_I<n> type
|
||||
* T_FLOAT: Float
|
||||
* T_DOUBLE: Double (or Float?)
|
||||
* T_CHAR: Character if value is an ASCII value
|
||||
* T_WCHAR: Character
|
||||
* T_CHAR_STRING: String as UTF-8 chars
|
||||
* T_WCHAR_STRING: String as Unicode chars
|
||||
* T_BSTR: String as UTF-8 chars
|
||||
* T_INTERFACE(_IS): XPCOM pointer for an ComObject, if nsID matches
|
||||
*/
|
||||
|
||||
// Integer code assumes that current->val.i# == current->val.u#
|
||||
// for assignment purposes
|
||||
switch(current->type) {
|
||||
case nsXPTType::T_I8:
|
||||
case nsXPTType::T_U8:
|
||||
if (env->IsInstanceOf(elem, classByte)) {
|
||||
current->val.i8 =
|
||||
env->GetByteField(elem, Byte_value_ID);
|
||||
result = JNI_TRUE;
|
||||
}
|
||||
break;
|
||||
case nsXPTType::T_I16:
|
||||
case nsXPTType::T_U16:
|
||||
if (env->IsInstanceOf(elem, classShort)) {
|
||||
current->val.i16 =
|
||||
env->GetShortField(elem, Short_value_ID);
|
||||
result = JNI_TRUE;
|
||||
}
|
||||
break;
|
||||
case nsXPTType::T_I32:
|
||||
case nsXPTType::T_U32:
|
||||
if (env->IsInstanceOf(elem, classInteger)) {
|
||||
current->val.i32 =
|
||||
env->GetShortField(elem, Integer_value_ID);
|
||||
result = JNI_TRUE;
|
||||
}
|
||||
break;
|
||||
case nsXPTType::T_I64:
|
||||
case nsXPTType::T_U64:
|
||||
if (env->IsInstanceOf(elem, classLong)) {
|
||||
current->val.i64 =
|
||||
env->GetShortField(elem, Long_value_ID);
|
||||
result = JNI_TRUE;
|
||||
}
|
||||
break;
|
||||
case nsXPTType::T_FLOAT:
|
||||
if (env->IsInstanceOf(elem, classFloat)) {
|
||||
current->val.f =
|
||||
env->GetFloatField(elem, Float_value_ID);
|
||||
result = JNI_TRUE;
|
||||
}
|
||||
break;
|
||||
case nsXPTType::T_DOUBLE:
|
||||
if (env->IsInstanceOf(elem, classDouble)) {
|
||||
current->val.d =
|
||||
env->GetDoubleField(elem, Double_value_ID);
|
||||
result = JNI_TRUE;
|
||||
}
|
||||
break;
|
||||
case nsXPTType::T_BOOL:
|
||||
if (env->IsInstanceOf(elem, classBoolean)) {
|
||||
current->val.b =
|
||||
env->GetBooleanField(elem, Boolean_value_ID);
|
||||
result = JNI_TRUE;
|
||||
}
|
||||
break;
|
||||
case nsXPTType::T_CHAR:
|
||||
if (env->IsInstanceOf(elem, classCharacter)) {
|
||||
current->val.c =
|
||||
(char)env->GetCharField(elem, Character_value_ID);
|
||||
result = JNI_TRUE;
|
||||
}
|
||||
break;
|
||||
case nsXPTType::T_WCHAR:
|
||||
if (env->IsInstanceOf(elem, classCharacter)) {
|
||||
current->val.wc =
|
||||
env->GetCharField(elem, Character_value_ID);
|
||||
result = JNI_TRUE;
|
||||
}
|
||||
break;
|
||||
case nsXPTType::T_CHAR_STR:
|
||||
if (env->IsInstanceOf(elem, classString)) {
|
||||
jstring string = (jstring)elem;
|
||||
jsize jstrlen = env->GetStringUTFLength(string);
|
||||
const char *utf = env->GetStringUTFChars(string, NULL);
|
||||
|
||||
// PENDING: copying every time is wasteful, but
|
||||
// we need to release `utf' before invocation loses it.
|
||||
char *tmpstr = new char[jstrlen + 1];
|
||||
strncpy(tmpstr, utf, jstrlen);
|
||||
tmpstr[jstrlen] = '\0';
|
||||
|
||||
current->val.p = tmpstr;
|
||||
current->flags |= nsXPTCVariant::VAL_IS_OWNED;
|
||||
|
||||
env->ReleaseStringUTFChars(string, utf);
|
||||
result = JNI_TRUE;
|
||||
}
|
||||
break;
|
||||
case nsXPTType::T_WCHAR_STR:
|
||||
if (env->IsInstanceOf(elem, classString)) {
|
||||
jstring string = (jstring)elem;
|
||||
jsize jstrlen = env->GetStringLength(string);
|
||||
const jchar *wstr = env->GetStringChars(string, NULL);
|
||||
|
||||
// PENDING: copying every time is wasteful, but
|
||||
// we need to release `wstr' before invocation loses it.
|
||||
PRUnichar *tmpstr = new PRUnichar[jstrlen + 1];
|
||||
memcpy(tmpstr, wstr, jstrlen * sizeof(PRUnichar));
|
||||
tmpstr[jstrlen] = '\0';
|
||||
|
||||
current->val.p = tmpstr;
|
||||
|
||||
env->ReleaseStringChars(string, wstr);
|
||||
result = JNI_TRUE;
|
||||
}
|
||||
break;
|
||||
case nsXPTType::T_VOID:
|
||||
// PENDING: handle void ptrs
|
||||
break;
|
||||
case nsXPTType::T_IID:
|
||||
// PENDING: unwrap the ID
|
||||
break;
|
||||
case nsXPTType::T_INTERFACE:
|
||||
case nsXPTType::T_INTERFACE_IS:
|
||||
if (elem == NULL) {
|
||||
current->val.p = NULL;
|
||||
}
|
||||
else {
|
||||
xpjp_QueryInterfaceToXPCOM(env, elem, iid, &(current->val.p));
|
||||
}
|
||||
current->flags |= nsXPTCVariant::VAL_IS_IFACE;
|
||||
break;
|
||||
case nsXPTType::T_BSTR:
|
||||
// Ignore for now
|
||||
break;
|
||||
}
|
||||
// VAL_IS_OWNED: val.p holds alloc'd ptr that must be freed
|
||||
// VAL_IS_IFACE: val.p holds interface ptr that must be released
|
||||
return result;
|
||||
}
|
||||
|
||||
static nsresult JArrayToVariant(JNIEnv *env,
|
||||
int paramcount,
|
||||
nsXPTCVariant *params,
|
||||
const jobjectArray theJarray) {
|
||||
nsXPTCVariant *current = params;
|
||||
|
||||
for (jsize i = 0; i < paramcount; i++, current++) {
|
||||
jobject elem = env->GetObjectArrayElement(theJarray, i);
|
||||
nsIID iid = NS_GET_IID(nsISupports);
|
||||
// PENDING: get the iid of the object
|
||||
|
||||
if (elem == NULL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (JObjectToVariant(env, current, elem, iid) == JNI_FALSE) {
|
||||
// PENDING: throw an exception
|
||||
cerr << "Argument " << i << " is not of the correct type" << endl;
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
static jobject VariantToJObject(JNIEnv *env, const nsXPTCVariant *current) {
|
||||
jobject result = NULL;
|
||||
|
||||
// Integer code assumes that current->val.i# == current->val.u#
|
||||
// for assignment purposes
|
||||
switch(current->type) {
|
||||
case nsXPTType::T_I8:
|
||||
case nsXPTType::T_U8:
|
||||
result =
|
||||
env->NewObject(classByte,
|
||||
Byte_init_ID,
|
||||
(jbyte)current->val.i16);
|
||||
break;
|
||||
case nsXPTType::T_I16:
|
||||
case nsXPTType::T_U16:
|
||||
result =
|
||||
env->NewObject(classShort,
|
||||
Short_init_ID,
|
||||
(jshort)current->val.i16);
|
||||
break;
|
||||
case nsXPTType::T_I32:
|
||||
case nsXPTType::T_U32:
|
||||
result =
|
||||
env->NewObject(classInteger,
|
||||
Integer_init_ID,
|
||||
(jint)current->val.i32);
|
||||
break;
|
||||
case nsXPTType::T_I64:
|
||||
result =
|
||||
env->NewObject(classLong,
|
||||
Long_init_ID,
|
||||
(jlong)current->val.i64);
|
||||
break;
|
||||
case nsXPTType::T_FLOAT:
|
||||
result =
|
||||
env->NewObject(classFloat,
|
||||
Float_init_ID,
|
||||
(jfloat)current->val.f);
|
||||
break;
|
||||
case nsXPTType::T_DOUBLE:
|
||||
result =
|
||||
env->NewObject(classDouble,
|
||||
Double_init_ID,
|
||||
(jdouble)current->val.d);
|
||||
break;
|
||||
case nsXPTType::T_BOOL:
|
||||
result =
|
||||
env->NewObject(classBoolean,
|
||||
Boolean_init_ID,
|
||||
(jboolean)current->val.b);
|
||||
break;
|
||||
case nsXPTType::T_CHAR:
|
||||
result =
|
||||
env->NewObject(classCharacter,
|
||||
Character_init_ID,
|
||||
(jchar)current->val.c);
|
||||
break;
|
||||
case nsXPTType::T_WCHAR:
|
||||
result =
|
||||
env->NewObject(classCharacter,
|
||||
Character_init_ID,
|
||||
(jchar)current->val.wc);
|
||||
break;
|
||||
case nsXPTType::T_CHAR_STR:
|
||||
if (current->val.p != NULL) {
|
||||
result = env->NewStringUTF((const char *)current->val.p);
|
||||
}
|
||||
break;
|
||||
case nsXPTType::T_WCHAR_STR:
|
||||
if (current->val.p != NULL) {
|
||||
jsize len = 0;
|
||||
const jchar *wstr = (const jchar *)current->val.p;
|
||||
// PENDING: is this right?
|
||||
while (wstr[len] != 0) len++;
|
||||
result = env->NewString(wstr, len);
|
||||
}
|
||||
break;
|
||||
case nsXPTType::T_VOID:
|
||||
// Ignore for now
|
||||
break;
|
||||
case nsXPTType::T_IID:
|
||||
// Ignore for now
|
||||
if (current->val.p != NULL) {
|
||||
result = ID_NewJavaID(env, (const nsID *)current->val.p);
|
||||
}
|
||||
break;
|
||||
case nsXPTType::T_BSTR:
|
||||
// Ignore for now
|
||||
break;
|
||||
case nsXPTType::T_INTERFACE:
|
||||
// Ignore for now
|
||||
break;
|
||||
case nsXPTType::T_INTERFACE_IS:
|
||||
// Ignore for now
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
static nsresult VariantToJArray(JNIEnv *env,
|
||||
jobjectArray theJarray,
|
||||
int paramcount,
|
||||
nsXPTCVariant *params) {
|
||||
nsXPTCVariant *current = params;
|
||||
|
||||
for (jsize i = 0; i < paramcount; i++, current++) {
|
||||
jobject elem = NULL; // env->GetObjectArrayElement(theJarray, i);
|
||||
jboolean isequal = JNI_FALSE;
|
||||
nsXPTCVariant currValue;
|
||||
|
||||
if (!(current->flags & nsXPTCVariant::PTR_IS_DATA)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (elem != NULL) {
|
||||
nsIID iid = NS_GET_IID(nsISupports);
|
||||
// PENDING: get the iid of the object
|
||||
|
||||
memcpy(&currValue, current, sizeof(nsXPTCVariant));
|
||||
if (JObjectToVariant(env, &currValue, elem, iid) != JNI_FALSE) {
|
||||
isequal =
|
||||
(memcmp(&currValue, current, sizeof(nsXPTCVariant)) != 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (isequal) {
|
||||
// PENDING: what about casting to more specific interfaces?
|
||||
continue;
|
||||
}
|
||||
|
||||
elem = VariantToJObject(env, current);
|
||||
|
||||
env->SetObjectArrayElement(theJarray, i, elem);
|
||||
|
||||
if (current->flags & nsXPTCVariant::VAL_IS_IFACE) {
|
||||
xpjp_SafeRelease((nsISupports*)current->val.p);
|
||||
}
|
||||
|
||||
if (current->flags & nsXPTCVariant::VAL_IS_OWNED) {
|
||||
delete [] current->val.p;
|
||||
current->val.p = 0; // for cleanliness sake
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* ---------- DISPATCH API FUNCTIONS ------------ */
|
||||
|
||||
jboolean xpjd_InitJavaCaches(JNIEnv *env) {
|
||||
|
||||
if (cache_initialized) {
|
||||
return JNI_TRUE;
|
||||
}
|
||||
|
||||
// For basic types
|
||||
|
||||
classString = env->FindClass("java/lang/String");
|
||||
if (classString == NULL) return JNI_FALSE;
|
||||
classString = (jclass)env->NewGlobalRef(classString);
|
||||
if (classString == NULL) return JNI_FALSE;
|
||||
|
||||
classByte = env->FindClass("java/lang/Byte");
|
||||
if (classByte == NULL) return JNI_FALSE;
|
||||
classByte = (jclass)env->NewGlobalRef(classByte);
|
||||
if (classByte == NULL) return JNI_FALSE;
|
||||
|
||||
classShort = env->FindClass("java/lang/Short");
|
||||
if (classShort == NULL) return JNI_FALSE;
|
||||
classShort = (jclass)env->NewGlobalRef(classShort);
|
||||
if (classShort == NULL) return JNI_FALSE;
|
||||
|
||||
classInteger = env->FindClass("java/lang/Integer");
|
||||
if (classInteger == NULL) return JNI_FALSE;
|
||||
classInteger = (jclass)env->NewGlobalRef(classInteger);
|
||||
if (classInteger == NULL) return JNI_FALSE;
|
||||
|
||||
classLong = env->FindClass("java/lang/Long");
|
||||
if (classLong == NULL) return JNI_FALSE;
|
||||
classLong = (jclass)env->NewGlobalRef(classLong);
|
||||
if (classLong == NULL) return JNI_FALSE;
|
||||
|
||||
classFloat = env->FindClass("java/lang/Float");
|
||||
if (classFloat == NULL) return JNI_FALSE;
|
||||
classFloat = (jclass)env->NewGlobalRef(classFloat);
|
||||
if (classFloat == NULL) return JNI_FALSE;
|
||||
|
||||
classDouble = env->FindClass("java/lang/Double");
|
||||
if (classDouble == NULL) return JNI_FALSE;
|
||||
classDouble = (jclass)env->NewGlobalRef(classDouble);
|
||||
if (classDouble == NULL) return JNI_FALSE;
|
||||
|
||||
classBoolean = env->FindClass("java/lang/Boolean");
|
||||
if (classBoolean == NULL) return JNI_FALSE;
|
||||
classBoolean = (jclass)env->NewGlobalRef(classBoolean);
|
||||
if (classBoolean == NULL) return JNI_FALSE;
|
||||
|
||||
classCharacter = env->FindClass("java/lang/Character");
|
||||
if (classCharacter == NULL) return JNI_FALSE;
|
||||
classCharacter = (jclass)env->NewGlobalRef(classCharacter);
|
||||
if (classCharacter == NULL) return JNI_FALSE;
|
||||
|
||||
Byte_init_ID = env->GetMethodID(classByte, "<init>", "(B)V");
|
||||
if (Byte_init_ID == NULL) return JNI_FALSE;
|
||||
|
||||
Byte_value_ID = env->GetFieldID(classByte, "value", "B");
|
||||
if (Byte_value_ID == NULL) return JNI_FALSE;
|
||||
|
||||
Short_init_ID = env->GetMethodID(classShort, "<init>", "(S)V");
|
||||
if (Short_init_ID == NULL) return JNI_FALSE;
|
||||
|
||||
Short_value_ID = env->GetFieldID(classShort, "value", "S");
|
||||
if (Short_value_ID == NULL) return JNI_FALSE;
|
||||
|
||||
Integer_init_ID = env->GetMethodID(classInteger, "<init>", "(I)V");
|
||||
if (Integer_init_ID == NULL) return JNI_FALSE;
|
||||
|
||||
Integer_value_ID = env->GetFieldID(classInteger, "value", "I");
|
||||
if (Integer_value_ID == NULL) return JNI_FALSE;
|
||||
|
||||
Long_init_ID = env->GetMethodID(classLong, "<init>", "(J)V");
|
||||
if (Long_init_ID == NULL) return JNI_FALSE;
|
||||
|
||||
Long_value_ID = env->GetFieldID(classLong, "value", "J");
|
||||
if (Long_value_ID == NULL) return JNI_FALSE;
|
||||
|
||||
Float_init_ID = env->GetMethodID(classFloat, "<init>", "(F)V");
|
||||
if (Float_init_ID == NULL) return JNI_FALSE;
|
||||
|
||||
Float_value_ID = env->GetFieldID(classFloat, "value", "F");
|
||||
if (Float_value_ID == NULL) return JNI_FALSE;
|
||||
|
||||
Double_init_ID = env->GetMethodID(classDouble, "<init>", "(D)V");
|
||||
if (Double_init_ID == NULL) return JNI_FALSE;
|
||||
|
||||
Double_value_ID = env->GetFieldID(classDouble, "value", "D");
|
||||
if (Double_value_ID == NULL) return JNI_FALSE;
|
||||
|
||||
Boolean_init_ID = env->GetMethodID(classBoolean, "<init>", "(Z)V");
|
||||
if (Boolean_init_ID == NULL) return JNI_FALSE;
|
||||
|
||||
Boolean_value_ID = env->GetFieldID(classBoolean, "value", "Z");
|
||||
if (Boolean_value_ID == NULL) return JNI_FALSE;
|
||||
|
||||
Character_init_ID = env->GetMethodID(classCharacter, "<init>", "(C)V");
|
||||
if (Integer_init_ID == NULL) return JNI_FALSE;
|
||||
|
||||
Character_value_ID = env->GetFieldID(classCharacter, "value", "C");
|
||||
if (Character_value_ID == NULL) return JNI_FALSE;
|
||||
|
||||
// Get InterfaceInfoManager
|
||||
|
||||
#ifdef DEBUG_frankm
|
||||
cerr << "Getting InterfaceInfoManager" << endl;
|
||||
#endif
|
||||
|
||||
interfaceInfoManager = XPTI_GetInterfaceInfoManager();
|
||||
|
||||
if (!interfaceInfoManager) {
|
||||
// XXX: throw exception or something
|
||||
cerr << "Failed to find InterfaceInfoManager" << endl;
|
||||
return JNI_FALSE;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_frankm
|
||||
cerr << "InterfaceInfoManager found!" << endl;
|
||||
#endif
|
||||
|
||||
cache_initialized = JNI_TRUE;
|
||||
|
||||
return cache_initialized;
|
||||
}
|
||||
|
||||
void xpjd_FlushJavaCaches(JNIEnv *env) {
|
||||
|
||||
cache_initialized = JNI_FALSE;
|
||||
|
||||
// For basic types
|
||||
|
||||
env->DeleteGlobalRef(classString);
|
||||
classString = NULL;
|
||||
|
||||
env->DeleteGlobalRef(classByte);
|
||||
classByte = NULL;
|
||||
|
||||
env->DeleteGlobalRef(classShort);
|
||||
classShort = NULL;
|
||||
|
||||
env->DeleteGlobalRef(classInteger);
|
||||
classInteger = NULL;
|
||||
|
||||
env->DeleteGlobalRef(classLong);
|
||||
classLong = NULL;
|
||||
|
||||
env->DeleteGlobalRef(classFloat);
|
||||
classFloat = NULL;
|
||||
|
||||
env->DeleteGlobalRef(classDouble);
|
||||
classDouble = NULL;
|
||||
|
||||
env->DeleteGlobalRef(classBoolean);
|
||||
classBoolean = NULL;
|
||||
|
||||
env->DeleteGlobalRef(classCharacter);
|
||||
classCharacter = NULL;
|
||||
|
||||
Byte_init_ID = NULL;
|
||||
Byte_value_ID = NULL;
|
||||
Short_init_ID = NULL;
|
||||
Short_value_ID = NULL;
|
||||
Integer_init_ID = NULL;
|
||||
Integer_value_ID = NULL;
|
||||
Long_init_ID = NULL;
|
||||
Long_value_ID = NULL;
|
||||
Float_init_ID = NULL;
|
||||
Float_value_ID = NULL;
|
||||
Double_init_ID = NULL;
|
||||
Double_value_ID = NULL;
|
||||
Boolean_init_ID = NULL;
|
||||
Boolean_value_ID = NULL;
|
||||
Character_init_ID = NULL;
|
||||
Character_value_ID = NULL;
|
||||
}
|
||||
|
||||
jboolean xpjd_GetInterfaceInfo(JNIEnv *env,
|
||||
jobject iid,
|
||||
nsIInterfaceInfo **info) {
|
||||
nsID *nativeIID = ID_GetNative(env, iid);
|
||||
|
||||
return xpjd_GetInterfaceInfoNative(*nativeIID, info);
|
||||
}
|
||||
|
||||
jboolean xpjd_GetInterfaceInfoNative(REFNSIID iid,
|
||||
nsIInterfaceInfo **info) {
|
||||
nsresult res;
|
||||
|
||||
// Get info
|
||||
*info = nsnull;
|
||||
|
||||
res = interfaceInfoManager->GetInfoForIID(&iid, info);
|
||||
|
||||
if (NS_FAILED(res)) {
|
||||
cerr << "Failed to find info for " << iid.ToString() << endl;
|
||||
return JNI_FALSE;
|
||||
}
|
||||
return JNI_TRUE;
|
||||
}
|
||||
|
||||
void xpjd_InvokeMethod(JNIEnv *env,
|
||||
nsISupports *target,
|
||||
nsIInterfaceInfo *info,
|
||||
jint methodIndex,
|
||||
jobjectArray jargs) {
|
||||
|
||||
nsresult res = NS_OK;
|
||||
nsXPTCVariant paramArray[32];
|
||||
nsXPTCVariant *params = paramArray;
|
||||
int nparams = 0;
|
||||
const int capacity = sizeof(paramArray)/sizeof(paramArray[0]);
|
||||
|
||||
// XXX: check info != NULL, target != null, jargs != null, env != null
|
||||
|
||||
// XXX: check bounds of methodIndex
|
||||
|
||||
nparams = xpjd_BuildParamsForOffset(info,
|
||||
methodIndex,
|
||||
capacity,
|
||||
¶ms);
|
||||
if (nparams < 0) {
|
||||
// PENDING: throw an exception
|
||||
cerr << "Couldn't initialize parameter array" << endl;
|
||||
goto finally;
|
||||
}
|
||||
|
||||
res = JArrayToVariant(env, nparams, params, jargs);
|
||||
if (NS_FAILED(res)) {
|
||||
// PENDING: throw an exception
|
||||
cerr << "Array and parameter list mismatch" << endl;
|
||||
goto finally;
|
||||
}
|
||||
|
||||
//xpjp_SafeAddRef(target);
|
||||
|
||||
res = XPTC_InvokeByIndex(target, methodIndex, nparams, params);
|
||||
|
||||
//xpjp_SafeRelease(target);
|
||||
|
||||
if (NS_FAILED(res)) {
|
||||
// PENDING: throw an exception
|
||||
cerr << "Invocation failed, status: " << res << endl;
|
||||
goto finally;
|
||||
}
|
||||
|
||||
res = VariantToJArray(env, jargs, nparams, params);
|
||||
if (NS_FAILED(res)) {
|
||||
// PENDING: throw an exception
|
||||
cerr << "Array and parameter list mismatch" << endl;
|
||||
goto finally;
|
||||
}
|
||||
|
||||
finally:
|
||||
if (params != paramArray) {
|
||||
nsAllocator::Free(params);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
25
mozilla/java/xpcom/old/src/xpjava.h
Normal file
25
mozilla/java/xpcom/old/src/xpjava.h
Normal file
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Frank
|
||||
* Mitchell. Portions created by Frank Mitchell are
|
||||
* Copyright (C) 1999 Frank Mitchell. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Frank Mitchell (frank.mitchell@sun.com)
|
||||
*/
|
||||
|
||||
#include "xpj_dispatch.h"
|
||||
#include "xpj_proxy.h"
|
||||
#include "xpj_utils.h"
|
||||
73
mozilla/java/xpcom/old/test/JSISample.idl
Normal file
73
mozilla/java/xpcom/old/test/JSISample.idl
Normal file
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Frank
|
||||
* Mitchell. Portions created by Frank Mitchell are
|
||||
* Copyright (C) 1999 Frank Mitchell. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Frank Mitchell (frank.mitchell@sun.com)
|
||||
*/
|
||||
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* blah blah blah.
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface JSIComplex;
|
||||
|
||||
[object, uuid(57ecad90-ae1a-11d1-b66c-00805f8a2676)]
|
||||
interface JSISample : nsISupports {
|
||||
|
||||
// basic method
|
||||
void PrintStats();
|
||||
|
||||
// attributes
|
||||
attribute long someInt;
|
||||
attribute boolean someBool;
|
||||
readonly attribute long roInt;
|
||||
attribute double someDouble;
|
||||
attribute string someName;
|
||||
readonly attribute string roString;
|
||||
|
||||
// methods
|
||||
void TakeInt(in long anInt);
|
||||
long GiveInt();
|
||||
long GiveAndTake(inout long anInt);
|
||||
|
||||
string TooManyArgs(in short oneInt,
|
||||
in short twoInt,
|
||||
inout long redInt,
|
||||
out short blueInt,
|
||||
in double orNothing,
|
||||
in long long johnSilver,
|
||||
in boolean algebra);
|
||||
|
||||
string CatStrings(in string str1, in string str2);
|
||||
void AppendString(inout string str1, in string str2);
|
||||
|
||||
JSIComplex NewComplex(in long aReal, in long anImaginary);
|
||||
JSIComplex AddComplex(in JSIComplex complex1, in JSIComplex complex2);
|
||||
void AddInPlace(inout JSIComplex complex1, in JSIComplex complex2);
|
||||
|
||||
long AddTwoInts(in long int1, in long int2);
|
||||
};
|
||||
|
||||
[object, uuid(57ecad91-ae1a-11d1-b66c-00805f8a2676)]
|
||||
interface JSIComplex : nsISupports {
|
||||
// attributes
|
||||
attribute long real;
|
||||
attribute long imaginary;
|
||||
};
|
||||
536
mozilla/java/xpcom/old/test/JSSample.cpp
Normal file
536
mozilla/java/xpcom/old/test/JSSample.cpp
Normal file
@@ -0,0 +1,536 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Frank
|
||||
* Mitchell. Portions created by Frank Mitchell are
|
||||
* Copyright (C) 1999 Frank Mitchell. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Frank Mitchell (frank.mitchell@sun.com)
|
||||
*/
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
#include <iostream.h>
|
||||
#include "pratom.h"
|
||||
#include "nscore.h"
|
||||
#include "nsIFactory.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "JSISample.h"
|
||||
#include "JSSample.h"
|
||||
|
||||
class JSSample: public JSISample {
|
||||
public:
|
||||
// Constructor and Destuctor
|
||||
JSSample();
|
||||
virtual ~JSSample();
|
||||
|
||||
// nsISupports methods
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// JSISample methods
|
||||
NS_DECL_JSISAMPLE
|
||||
|
||||
private:
|
||||
/* attribute long someInt; */
|
||||
PRInt32 someInt_;
|
||||
|
||||
/* attribute boolean someBool; */
|
||||
PRBool someBool_;
|
||||
|
||||
/* readonly attribute long roInt; */
|
||||
PRInt32 roInt_;
|
||||
|
||||
/* attribute double someDouble; */
|
||||
double someDouble_;
|
||||
|
||||
/* attribute string someName; */
|
||||
char *someName_;
|
||||
|
||||
/* readonly attribute string roString; */
|
||||
char *roString_;
|
||||
};
|
||||
|
||||
// Globals, need to check if safe to unload module
|
||||
//static PRInt32 gLockCnt = 0;
|
||||
// static PRInt32 gInstanceCnt = 0;
|
||||
|
||||
static NS_DEFINE_CID(kSampleCID, JS_SAMPLE_CID);
|
||||
|
||||
/*
|
||||
* JSSampleClass Declaration: see JSSample_private.h
|
||||
*/
|
||||
|
||||
/*
|
||||
* JSComplex Declaration
|
||||
*/
|
||||
class JSComplex : public JSIComplex {
|
||||
public:
|
||||
// Constructor and Destuctor
|
||||
JSComplex();
|
||||
JSComplex(int aReal, int aImaginary);
|
||||
virtual ~JSComplex();
|
||||
|
||||
// nsISupports methods
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsISupports methods
|
||||
NS_DECL_JSICOMPLEX
|
||||
|
||||
private:
|
||||
PRInt32 real_;
|
||||
PRInt32 imaginary_;
|
||||
};
|
||||
|
||||
/*
|
||||
* JSSampleFactory Declaration
|
||||
*/
|
||||
|
||||
class JSSampleFactory: public nsIFactory {
|
||||
public:
|
||||
JSSampleFactory();
|
||||
virtual ~JSSampleFactory();
|
||||
|
||||
// nsISupports methods
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIFactory methods
|
||||
NS_IMETHOD CreateInstance(nsISupports *aOuter,
|
||||
const nsIID &aIID,
|
||||
void **aResult);
|
||||
|
||||
NS_IMETHOD LockFactory(PRBool aLock);
|
||||
};
|
||||
|
||||
/*
|
||||
* JSSample Implementation
|
||||
*/
|
||||
|
||||
JSSample::JSSample()
|
||||
{
|
||||
// Zero reference counter
|
||||
NS_INIT_ISUPPORTS();
|
||||
// PR_AtomicIncrement(&gInstanceCnt);
|
||||
}
|
||||
|
||||
JSSample::~JSSample()
|
||||
{
|
||||
// Make sure there are no dangling pointers to us,
|
||||
// debug only
|
||||
NS_ASSERTION(mRefCnt == 0,"Wrong ref count");
|
||||
// PR_AtomicDecrement(&gInstanceCnt);
|
||||
}
|
||||
|
||||
|
||||
// Use the official macros to implement nsISupports
|
||||
NS_IMPL_ISUPPORTS1(JSSample, JSISample)
|
||||
|
||||
|
||||
NS_IMETHODIMP JSSample::PrintStats()
|
||||
{
|
||||
cout << "Stats would go here" << endl;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* attribute boolean someInt; */
|
||||
NS_IMETHODIMP JSSample::GetSomeInt(PRInt32 *aSomeInt) {
|
||||
*aSomeInt = someInt_;
|
||||
cout << "--> JSSample::GetSomeInt() : " << *aSomeInt << endl;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP JSSample::SetSomeInt(PRInt32 aSomeInt) {
|
||||
cout << "--> JSSample::SetSomeInt(" << aSomeInt << ")" << endl;
|
||||
someInt_ = aSomeInt;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* attribute boolean someBool; */
|
||||
NS_IMETHODIMP JSSample::GetSomeBool(PRInt32 *aSomeBool) {
|
||||
*aSomeBool = someBool_;
|
||||
cout << "--> JSSample::GetSomeBool() : " << *aSomeBool << endl;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP JSSample::SetSomeBool(PRInt32 aSomeBool) {
|
||||
cout << "--> JSSample::SetSomeBool(" << aSomeBool << ")" << endl;
|
||||
someBool_ = aSomeBool;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute long roInt; */
|
||||
NS_IMETHODIMP JSSample::GetRoInt(PRInt32 *aRoInt) {
|
||||
*aRoInt = roInt_;
|
||||
cout << "--> JSSample::GetRoInt() : " << *aRoInt << endl;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
/* attribute double someDouble; */
|
||||
NS_IMETHODIMP JSSample::GetSomeDouble(double *aSomeDouble) {
|
||||
*aSomeDouble = someDouble_;
|
||||
cout << "--> JSSample::GetSomeDouble() : " << *aSomeDouble << endl;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP JSSample::SetSomeDouble(double aSomeDouble) {
|
||||
cout << "--> JSSample::SetSomeDouble(" << aSomeDouble << ")" << endl;
|
||||
someDouble_ = aSomeDouble;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
/* attribute string someName; */
|
||||
NS_IMETHODIMP JSSample::GetSomeName(char * *aSomeName) {
|
||||
*aSomeName = new char[strlen(someName_) + 1];
|
||||
strcpy(*aSomeName, someName_);
|
||||
cout << "--> JSSample::GetSomeName() : '" << *aSomeName << '\'' << endl;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP JSSample::SetSomeName(const char * aSomeName) {
|
||||
cout << "--> JSSample::SetSomeName('" << aSomeName << "')" << endl;
|
||||
if (aSomeName != someName_) {
|
||||
delete someName_;
|
||||
someName_ = new char[strlen(aSomeName) + 1];
|
||||
strcpy(someName_, aSomeName);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
/* readonly attribute string roString; */
|
||||
NS_IMETHODIMP JSSample::GetRoString(char * *aRoString) {
|
||||
*aRoString = new char[sizeof("Read Only String") + 1];
|
||||
strcpy(*aRoString, "Read Only String");
|
||||
cout << "--> JSSample::GetRoString() : " << *aRoString << '\'' << endl;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void TakeInt (in long anInt); */
|
||||
NS_IMETHODIMP JSSample::TakeInt(PRInt32 anInt) {
|
||||
cout << "--> JSSample::TakeInt(" << anInt << ")" << endl;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
/* long GiveInt (); */
|
||||
NS_IMETHODIMP JSSample::GiveInt(PRInt32 *_retval) {
|
||||
*_retval = 42;
|
||||
cout << "--> JSSample::GiveInt() : " << *_retval << endl;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* long GiveAndTake (inout long anInt); */
|
||||
NS_IMETHODIMP JSSample::GiveAndTake(PRInt32 *anInt, PRInt32 *_retval) {
|
||||
cout << "--> JSSample::GiveAndTake(" << *anInt << ") => ";
|
||||
*_retval = *anInt;
|
||||
*anInt *= 2;
|
||||
cout << "( " << *anInt << ") : " << *_retval << endl;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* string TooManyArgs (in short oneInt, in short twoInt, inout long redInt, out short blueInt, in double orNothing, in long johnSilver, in boolean algebra); */
|
||||
NS_IMETHODIMP JSSample::TooManyArgs(PRInt16 oneInt,
|
||||
PRInt16 twoInt,
|
||||
PRInt32 *redInt,
|
||||
PRInt16 *blueInt,
|
||||
double orNothing,
|
||||
PRInt64 johnSilver,
|
||||
PRBool algebra,
|
||||
char **_retval) {
|
||||
cout << "--> JSSample::TooManyArgs("
|
||||
<< oneInt << ", "
|
||||
<< twoInt << ", "
|
||||
<< *redInt << ", "
|
||||
<< '-' << ", "
|
||||
<< orNothing << ", "
|
||||
<< johnSilver << ", "
|
||||
<< algebra << ") => ";
|
||||
*redInt = oneInt + twoInt;
|
||||
*blueInt = oneInt - twoInt;
|
||||
this->GetRoString(_retval);
|
||||
cout << "("
|
||||
<< oneInt << ", "
|
||||
<< twoInt << ", "
|
||||
<< *redInt << ", "
|
||||
<< *blueInt << ", "
|
||||
<< orNothing << ", "
|
||||
<< johnSilver << ", "
|
||||
<< algebra
|
||||
<< ") : "
|
||||
<< *_retval << endl;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* string CatStrings (in string str1, in string str2); */
|
||||
NS_IMETHODIMP JSSample::CatStrings(const char *str1, const char *str2, char **_retval) {
|
||||
cout << "--> JSSample::CatStrings(" << str1 << ", " << str2 << ") : ";
|
||||
*_retval = new char[strlen(str1) + strlen(str2) + 1];
|
||||
strcpy(*_retval, str1);
|
||||
strcat(*_retval, str2);
|
||||
cout << '\'' << *_retval << '\'' << endl;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void AppendString (inout string str1, in string str2); */
|
||||
NS_IMETHODIMP JSSample::AppendString(char **str1, const char *str2) {
|
||||
cout << "--> JSSample::AppendString('" << *str1 << "', '" << str2 << "') => ";
|
||||
char* tmp = new char[strlen(*str1) + strlen(str2) + 1];
|
||||
strcpy(tmp, *str1);
|
||||
strcat(tmp, str2);
|
||||
*str1 = tmp; // XXX potential memory leak
|
||||
cout << "('" << *str1 << "')" << endl;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* JSIComplex AddComplex (in JSIComplex complex1, in JSIComplex complex2); */
|
||||
NS_IMETHODIMP JSSample::AddComplex(JSIComplex *complex1, JSIComplex *complex2, JSIComplex **_retval) {
|
||||
cout << "--> JSSample::AddComplex("
|
||||
<< complex1 << ", "
|
||||
<< complex2 << ") : ";
|
||||
|
||||
PRInt32 r1, i1, r2, i2;
|
||||
complex1->GetReal(&r1);
|
||||
complex1->GetImaginary(&i1);
|
||||
complex2->GetReal(&r2);
|
||||
complex2->GetImaginary(&i2);
|
||||
*_retval = new JSComplex(r1 + r2, i1 + i2);
|
||||
|
||||
cout << *_retval << endl;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* JSIComplex NewComplex (in long aReal, in long aImaginary); */
|
||||
NS_IMETHODIMP JSSample::NewComplex(PRInt32 aReal, PRInt32 aImaginary, JSIComplex **_retval) {
|
||||
cout << "--> JSSample::AddComplex("
|
||||
<< aReal << ", "
|
||||
<< aImaginary << ") : ";
|
||||
|
||||
*_retval = new JSComplex(aReal, aImaginary);
|
||||
|
||||
cout << *_retval << endl;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
/* void AddInPlace (inout JSIComplex complex1, in JSIComplex complex2); */
|
||||
NS_IMETHODIMP JSSample::AddInPlace(JSIComplex **complex1, JSIComplex *complex2) {
|
||||
cout << "--> JSSample::AddInPlace('"
|
||||
<< *complex1 << ", "
|
||||
<< complex2 << ") => ";
|
||||
|
||||
PRInt32 r1, i1, r2, i2;
|
||||
(*complex1)->GetReal(&r1);
|
||||
(*complex1)->GetImaginary(&i1);
|
||||
complex2->GetReal(&r2);
|
||||
complex2->GetImaginary(&i2);
|
||||
r1 += r2;
|
||||
i1 += i2;
|
||||
(*complex1)->SetReal(r1);
|
||||
(*complex1)->SetImaginary(i1);
|
||||
cout << "("
|
||||
<< *complex1 << ", "
|
||||
<< complex2 << ")"
|
||||
<< endl;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
/* long AddTwoInts (in long int1, in long int2); */
|
||||
NS_IMETHODIMP JSSample::AddTwoInts(PRInt32 int1,
|
||||
PRInt32 int2,
|
||||
PRInt32 *_retval) {
|
||||
*_retval = int1 + int2;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* JSComplex Implementation
|
||||
*/
|
||||
|
||||
JSComplex::JSComplex()
|
||||
{
|
||||
// Zero reference counter
|
||||
NS_INIT_ISUPPORTS();
|
||||
// PR_AtomicIncrement(&gInstanceCnt);
|
||||
}
|
||||
|
||||
JSComplex::JSComplex(int aReal, int aImaginary) :
|
||||
real_(aReal), imaginary_(aImaginary)
|
||||
{
|
||||
// Zero reference counter
|
||||
NS_INIT_ISUPPORTS();
|
||||
// PR_AtomicIncrement(&gInstanceCnt);
|
||||
}
|
||||
|
||||
JSComplex::~JSComplex()
|
||||
{
|
||||
// Make sure there are no dangling pointers to us,
|
||||
// debug only
|
||||
NS_ASSERTION(mRefCnt == 0,"Wrong ref count");
|
||||
// PR_AtomicDecrement(&gInstanceCnt);
|
||||
}
|
||||
|
||||
|
||||
// Use the official macros to implement nsISupports
|
||||
NS_IMPL_ISUPPORTS1(JSComplex, JSIComplex)
|
||||
|
||||
|
||||
/* attribute long real; */
|
||||
NS_IMETHODIMP JSComplex::GetReal(PRInt32 *aReal) {
|
||||
*aReal = real_;
|
||||
cout << "--> JSComplex::GetReal() : " << *aReal << endl;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP JSComplex::SetReal(PRInt32 aReal) {
|
||||
cout << "--> JSComplex::SetReal(" << aReal << ")" << endl;
|
||||
real_ = aReal;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* attribute long imaginary; */
|
||||
NS_IMETHODIMP JSComplex::GetImaginary(PRInt32 *aImaginary) {
|
||||
*aImaginary = imaginary_;
|
||||
cout << "--> JSComplex::GetImaginary() : " << *aImaginary << ")" << endl;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP JSComplex::SetImaginary(PRInt32 aImaginary) {
|
||||
cout << "--> JSComplex::SetImaginary(" << aImaginary << ")" << endl;
|
||||
imaginary_ = aImaginary;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* JSSampleFactory Implementation
|
||||
*/
|
||||
|
||||
JSSampleFactory::JSSampleFactory()
|
||||
{
|
||||
// Zero reference counter
|
||||
NS_INIT_ISUPPORTS();
|
||||
// PR_AtomicIncrement(&gInstanceCnt);
|
||||
}
|
||||
|
||||
JSSampleFactory::~JSSampleFactory()
|
||||
{
|
||||
// Make sure there are no dangling pointers to us,
|
||||
// debug only
|
||||
NS_ASSERTION(mRefCnt == 0,"Wrong ref count");
|
||||
// PR_AtomicDecrement(&gInstanceCnt);
|
||||
}
|
||||
|
||||
|
||||
// Use the official macros to implement nsISupports
|
||||
NS_IMPL_ISUPPORTS1(JSSampleFactory, nsIFactory)
|
||||
|
||||
|
||||
NS_IMETHODIMP JSSampleFactory::CreateInstance(nsISupports *aOuter,
|
||||
const nsIID &aIID,
|
||||
void **aResult)
|
||||
{
|
||||
if (!aResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
*aResult = nsnull;
|
||||
|
||||
nsISupports* inst = new JSSample();
|
||||
|
||||
if (!inst) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
nsresult res = inst->QueryInterface(aIID, aResult);
|
||||
|
||||
if (NS_FAILED(res)) {
|
||||
// We didn't get the right interface, so clean up
|
||||
delete inst;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP JSSampleFactory::LockFactory(PRBool aLock)
|
||||
{
|
||||
if (aLock) {
|
||||
// PR_AtomicIncrement(&gLockCnt);
|
||||
} else {
|
||||
// PR_AtomicDecrement(&gLockCnt);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
// Exported functions. With these in place we can compile
|
||||
// this module into a dynamically loaded and registered
|
||||
// component.
|
||||
|
||||
extern "C" {
|
||||
NS_EXPORT nsresult NSGetFactory(nsISupports *serviceMgr,
|
||||
const nsCID &aCID,
|
||||
const char *aClassName,
|
||||
const char *aProgID,
|
||||
nsIFactory **aResult) {
|
||||
if (!aResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
*aResult = nsnull;
|
||||
|
||||
nsISupports *inst;
|
||||
|
||||
if (aCID.Equals(kSampleCID)) {
|
||||
// Ok, we know this CID and here is the factory
|
||||
// that can manufacture the objects
|
||||
inst = new JSSampleFactory();
|
||||
} else {
|
||||
return NS_ERROR_NO_INTERFACE;
|
||||
}
|
||||
|
||||
if (!inst) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
nsresult rv = inst->QueryInterface(NS_GET_IID(nsIFactory),
|
||||
(void **) aResult);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
delete inst;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_EXPORT PRBool NSCanUnload(nsISupports* serviceMgr) {
|
||||
return PR_FALSE;
|
||||
// return PRBool(gInstanceCnt == 0 && gLockCnt == 0);
|
||||
}
|
||||
|
||||
NS_EXPORT nsresult NSRegisterSelf(nsISupports* serviceMgr,
|
||||
const char *path) {
|
||||
return nsComponentManager::RegisterComponent(kSampleCID, nsnull, nsnull,
|
||||
path, PR_TRUE, PR_TRUE);
|
||||
}
|
||||
|
||||
NS_EXPORT nsresult NSUnregisterSelf(nsISupports* serviceMgr,
|
||||
const char *path) {
|
||||
return nsComponentManager::UnregisterComponent(kSampleCID, path);
|
||||
}
|
||||
}
|
||||
32
mozilla/java/xpcom/old/test/JSSample.h
Normal file
32
mozilla/java/xpcom/old/test/JSSample.h
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Frank
|
||||
* Mitchell. Portions created by Frank Mitchell are
|
||||
* Copyright (C) 1999 Frank Mitchell. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Frank Mitchell (frank.mitchell@sun.com)
|
||||
*/
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
|
||||
#ifndef JSSample_h__
|
||||
#define JSSample_h__
|
||||
|
||||
// {d3944dd0-ae1a-11d1-b66c-00805f8a2676}
|
||||
#define JS_SAMPLE_CID \
|
||||
{0xd3944dd0, 0xae1a, 0x11d1, \
|
||||
{0xb6, 0x6c, 0x00, 0x80, 0x5f, 0x8a, 0x26, 0x76}}
|
||||
|
||||
#endif /* JSSample_h__ */
|
||||
93
mozilla/java/xpcom/old/test/Makefile.test
Normal file
93
mozilla/java/xpcom/old/test/Makefile.test
Normal file
@@ -0,0 +1,93 @@
|
||||
# Makefile
|
||||
|
||||
MOZILLA=../../..
|
||||
|
||||
CC=gcc
|
||||
CPP=g++
|
||||
|
||||
CFLAGS=-Wall -g -fno-rtti -fno-handle-exceptions -pipe
|
||||
SHLIB_FLAGS=-fpic
|
||||
SHLIB_LDFLAGS=-shared
|
||||
DEFINES=-DXP_UNIX
|
||||
INCLUDE=-I$(MOZILLA)/dist/include -I$(MOZILLA)/xpcom/public -I../src -I$(JDKHOME)/include -I$(JDKHOME)/include/solaris -I$(JDKHOME)/include/linux
|
||||
LIBS=-L$(MOZILLA)/dist/lib -lxptinfo -lxptcmd -lxptcall -lxpt -lxpcom -lplds3 -lplc3 -lnspr3
|
||||
|
||||
COMPDIR=$(MOZILLA)/dist/bin/components
|
||||
|
||||
XPIDL=$(MOZILLA)/dist/bin/xpidl
|
||||
|
||||
GENPROXY=$(MOZILLA)/dist/bin/genproxy
|
||||
|
||||
JAVAC=$(JDKHOME)/bin/javac
|
||||
|
||||
CLASSDIR=$(MOZILLA)/dist/classes
|
||||
|
||||
|
||||
TEST_CLASSES=XPCTest.class
|
||||
|
||||
PROXY_JAR=sample.jar
|
||||
PROXY_DIR=_genproxy
|
||||
|
||||
|
||||
.SUFFIXES: .java .class .cpp .o
|
||||
|
||||
all: sample xptest $(TEST_CLASSES) $(PROXY_JAR)
|
||||
|
||||
#
|
||||
# Build class files.
|
||||
#
|
||||
.java.class:
|
||||
$(JAVAC) -g -d . -classpath $(CLASSDIR):. $<
|
||||
|
||||
|
||||
#
|
||||
# Compile C++.
|
||||
#
|
||||
.cpp.o:
|
||||
$(CPP) $(CFLAGS) $(DEFINES) $(INCLUDE) $(SHLIB_FLAGS) -c $<
|
||||
|
||||
#
|
||||
# Sample XPCOM module.
|
||||
#
|
||||
sample: JSISample.h $(COMPDIR)/libxpjtest.so $(COMPDIR)/xpjtest.xpt
|
||||
|
||||
#
|
||||
# Build sample header & typelib
|
||||
#
|
||||
JSISample.cpp: JSISample.h
|
||||
|
||||
JSISample.h: JSISample.idl
|
||||
$(XPIDL) -w -v -m header -I $(MOZILLA)/dist/idl JSISample.idl
|
||||
|
||||
$(COMPDIR)/xpjtest.xpt: JSISample.idl
|
||||
$(XPIDL) -w -v -m typelib -o $(COMPDIR)/xpjtest -I $(MOZILLA)/dist/idl JSISample.idl
|
||||
|
||||
#
|
||||
# Sample object shared library
|
||||
#
|
||||
libxpjtest.so: JSISample.h JSSample.o
|
||||
$(CPP) $(SHLIB_LDFLAGS) -L$(MOZILLA)/dist/lib -lxpcom -o libxpjtest.so JSSample.o
|
||||
chmod +x libxpjtest.so
|
||||
|
||||
$(COMPDIR)/libxpjtest.so: libxpjtest.so
|
||||
../../../config/nsinstall -R -m 555 libxpjtest.so $(COMPDIR)
|
||||
|
||||
#
|
||||
# C++ test program
|
||||
#
|
||||
xptest: xptest.o
|
||||
$(CPP) -g -Wall -o xptest $(LIBS) xptest.o
|
||||
|
||||
|
||||
#
|
||||
# Java proxies
|
||||
#
|
||||
$(PROXY_JAR): $(GENPROXY) $(COMPDIR)/xpjtest.xpt
|
||||
- mkdir $(PROXY_DIR)
|
||||
$(GENPROXY) -d $(PROXY_DIR) $(COMPDIR)/xpjtest.xpt
|
||||
$(GENPROXY) -i -d $(PROXY_DIR) $(COMPDIR)/xpjtest.xpt
|
||||
$(JAVAC) -g -d $(PROXY_DIR) -classpath $(CLASSDIR):. $(PROXY_DIR)/*.java
|
||||
(cd $(PROXY_DIR); jar cf ../$(PROXY_JAR) org)
|
||||
|
||||
clean:
|
||||
$(RM) -r *.o *.so core xptest $(COMPDIR)/libxpjtest.so $(COMPDIR)/xpjtest.xpt JSISample.h $(TEST_CLASSES) $(PROXY_JAR) $(PROXY_DIR)
|
||||
202
mozilla/java/xpcom/old/test/XPCTest.java
Normal file
202
mozilla/java/xpcom/old/test/XPCTest.java
Normal file
@@ -0,0 +1,202 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Frank
|
||||
* Mitchell. Portions created by Frank Mitchell are
|
||||
* Copyright (C) 1999 Frank Mitchell. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Frank Mitchell (frank.mitchell@sun.com)
|
||||
*/
|
||||
|
||||
import java.util.Vector;
|
||||
import java.lang.reflect.Method;
|
||||
import org.mozilla.xpcom.*;
|
||||
|
||||
public class XPCTest {
|
||||
static ComObject CreateSampleInstance() {
|
||||
nsID kSampleCID =
|
||||
new nsID("d3944dd0-ae1a-11d1-b66c-00805f8a2676");
|
||||
|
||||
nsID kISampleIID =
|
||||
new nsID("57ecad90-ae1a-11d1-b66c-00805f8a2676");
|
||||
|
||||
|
||||
// XXX: convert to nsIComponentManager calls
|
||||
return (ComObject)XPComUtilities.CreateInstance(kSampleCID,
|
||||
null,
|
||||
kISampleIID);
|
||||
}
|
||||
|
||||
public static void main(String[] argv) {
|
||||
String command = "PrintStats";
|
||||
int cmdOffset = -1;
|
||||
boolean useXPCMethod = true;
|
||||
|
||||
try {
|
||||
Object[] params = null;
|
||||
|
||||
// Process arguments
|
||||
if (argv.length == 0) {
|
||||
params = new Object[0];
|
||||
}
|
||||
else {
|
||||
int argi = 0;
|
||||
while (argv[argi].charAt(0) == '-') {
|
||||
switch(argv[argi].charAt(1)) {
|
||||
case 'r':
|
||||
useXPCMethod = false;
|
||||
break;
|
||||
case 'x':
|
||||
useXPCMethod = true;
|
||||
break;
|
||||
}
|
||||
argi++;
|
||||
}
|
||||
|
||||
command = argv[argi++];
|
||||
if (Character.isDigit(command.charAt(0))) {
|
||||
cmdOffset = Integer.parseInt(command);
|
||||
}
|
||||
|
||||
params = paramArray(argv, argi);
|
||||
}
|
||||
|
||||
ComObject sample = CreateSampleInstance();
|
||||
|
||||
// DEBUG
|
||||
System.out.print("Command: "); // DEBUG
|
||||
System.out.print(command); // DEBUG
|
||||
System.out.print(", arguments: "); // DEBUG
|
||||
System.out.println(paramString(params)); // DEBUG
|
||||
|
||||
nsID kISampleIID =
|
||||
new nsID("57ecad90-ae1a-11d1-b66c-00805f8a2676");
|
||||
|
||||
if (cmdOffset >= 0) {
|
||||
XPComUtilities.InvokeMethodByIndex(kISampleIID,
|
||||
sample,
|
||||
cmdOffset,
|
||||
params);
|
||||
}
|
||||
else if (useXPCMethod) {
|
||||
XPCMethod method = new XPCMethod(kISampleIID, command);
|
||||
|
||||
method.invoke(sample, params);
|
||||
}
|
||||
else {
|
||||
Method[] methods = sample.getClass().getMethods();
|
||||
|
||||
for (int i = 0; i < methods.length; i++) {
|
||||
if (methods[i].getName().equals(command)) {
|
||||
Object retval =
|
||||
methods[i].invoke(sample, params);
|
||||
System.out.print("Retval: "); // DEBUG
|
||||
System.out.println(retval); // DEBUG
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get "out" parameters and return value
|
||||
System.out.print("Results: "); // DEBUG
|
||||
System.out.println(paramString(params)); // DEBUG
|
||||
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
static String paramString(Object[] params) {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
buf.append('[');
|
||||
for (int i = 0; i < params.length; i++) {
|
||||
if (i != 0) {
|
||||
buf.append(", ");
|
||||
}
|
||||
buf.append(params[i]);
|
||||
}
|
||||
buf.append(']');
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
static Object[] paramArray(String[] argv) throws NumberFormatException {
|
||||
return paramArray(argv, 0);
|
||||
}
|
||||
|
||||
static Object[] paramArray(String[] argv, int argi)
|
||||
throws NumberFormatException {
|
||||
Vector vector = new Vector(argv.length - argi);
|
||||
|
||||
while (argi < argv.length) {
|
||||
String opt = argv[argi];
|
||||
if (opt.charAt(0) != '-') {
|
||||
vector.addElement(opt);
|
||||
}
|
||||
else {
|
||||
switch (opt.charAt(1)) {
|
||||
case 'c':
|
||||
argi++;
|
||||
vector.addElement(new Character(argv[argi].charAt(0)));
|
||||
break;
|
||||
case 'b':
|
||||
argi++;
|
||||
vector.addElement(Byte.valueOf(argv[argi]));
|
||||
break;
|
||||
case 's':
|
||||
argi++;
|
||||
vector.addElement(Short.valueOf(argv[argi]));
|
||||
break;
|
||||
case 'i':
|
||||
argi++;
|
||||
vector.addElement(Integer.valueOf(argv[argi]));
|
||||
break;
|
||||
case 'j':
|
||||
case 'l':
|
||||
argi++;
|
||||
vector.addElement(Long.valueOf(argv[argi]));
|
||||
break;
|
||||
case 'f':
|
||||
argi++;
|
||||
vector.addElement(Float.valueOf(argv[argi]));
|
||||
break;
|
||||
case 'd':
|
||||
argi++;
|
||||
vector.addElement(Double.valueOf(argv[argi]));
|
||||
break;
|
||||
case 'r':
|
||||
case '0':
|
||||
vector.addElement(null);
|
||||
break;
|
||||
case '@':
|
||||
argi++;
|
||||
vector.addElement(new nsID(argv[argi]));
|
||||
break;
|
||||
case 'z':
|
||||
argi++;
|
||||
vector.addElement(Boolean.valueOf(argv[argi]));
|
||||
break;
|
||||
}
|
||||
}
|
||||
argi++;
|
||||
}
|
||||
|
||||
Object[] result = new Object[vector.size()];
|
||||
for (int i = 0; i < result.length; i++) {
|
||||
result[i] = vector.elementAt(i);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
423
mozilla/java/xpcom/old/test/xptest.cpp
Normal file
423
mozilla/java/xpcom/old/test/xptest.cpp
Normal file
@@ -0,0 +1,423 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Frank
|
||||
* Mitchell. Portions created by Frank Mitchell are
|
||||
* Copyright (C) 1999 Frank Mitchell. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Frank Mitchell (frank.mitchell@sun.com)
|
||||
*/
|
||||
#include <iostream.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include "nscore.h"
|
||||
#include "nsIFactory.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIInterfaceInfo.h"
|
||||
#include "nsIInterfaceInfoManager.h"
|
||||
#include "xptinfo.h"
|
||||
#include "xptcall.h"
|
||||
#include "xpt_struct.h"
|
||||
#include "nsIAllocator.h"
|
||||
#include "JSISample.h"
|
||||
#include "JSSample.h"
|
||||
|
||||
#include "nsSpecialSystemDirectory.h"
|
||||
|
||||
|
||||
static NS_DEFINE_IID(kISampleIID, JSISAMPLE_IID);
|
||||
static NS_DEFINE_CID(kSampleCID, JS_SAMPLE_CID);
|
||||
|
||||
#ifdef XP_PC
|
||||
#define SAMPLE_DLL "xpjtest.dll"
|
||||
#else
|
||||
#ifdef XP_MAC
|
||||
#define SAMPLE_DLL "XPJTEST_DLL"
|
||||
#else
|
||||
#define SAMPLE_DLL "libxpjtest.so"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
static void ParamsFromArgv(nsXPTCVariant *result,
|
||||
const nsXPTMethodInfo *mi,
|
||||
int argi, int argc, char **argv) {
|
||||
uint8 paramcount = mi->GetParamCount();
|
||||
|
||||
memset(result, 0, sizeof(nsXPTCVariant) * paramcount);
|
||||
|
||||
for (int i = 0; i < paramcount; i++) {
|
||||
nsXPTParamInfo param = mi->GetParam(i);
|
||||
|
||||
result[i].ptr = 0;
|
||||
result[i].type = param.GetType().TagPart();
|
||||
result[i].flags = 0;
|
||||
|
||||
if (param.IsIn()) {
|
||||
assert(argi < argc);
|
||||
|
||||
cerr << "Consuming " << argv[argi] << endl;
|
||||
|
||||
switch(result[i].type) {
|
||||
case nsXPTType::T_I8:
|
||||
result[i].val.i8 = atoi(argv[argi]);
|
||||
break;
|
||||
case nsXPTType::T_I16:
|
||||
result[i].val.i16 = atoi(argv[argi]);
|
||||
break;
|
||||
case nsXPTType::T_I32:
|
||||
result[i].val.i32 = atol(argv[argi]);
|
||||
break;
|
||||
case nsXPTType::T_I64:
|
||||
result[i].val.i64 = atol(argv[argi]); //s.b. conversion to long long
|
||||
break;
|
||||
case nsXPTType::T_U8:
|
||||
result[i].val.u8 = atoi(argv[argi]);
|
||||
break;
|
||||
case nsXPTType::T_U16:
|
||||
result[i].val.u16 = atoi(argv[argi]);
|
||||
break;
|
||||
case nsXPTType::T_U32:
|
||||
result[i].val.u32 = atol(argv[argi]);
|
||||
break;
|
||||
case nsXPTType::T_U64:
|
||||
result[i].val.u64 = atol(argv[argi]); //s.b. conversion to long long
|
||||
break;
|
||||
case nsXPTType::T_FLOAT:
|
||||
result[i].val.f = atof(argv[argi]);
|
||||
break;
|
||||
case nsXPTType::T_DOUBLE:
|
||||
result[i].val.d = atof(argv[argi]);
|
||||
break;
|
||||
case nsXPTType::T_BOOL:
|
||||
switch (argv[argi][0]) {
|
||||
case '1':
|
||||
case 't':
|
||||
case 'T':
|
||||
result[i].val.b = 1;
|
||||
break;
|
||||
default:
|
||||
result[i].val.b = 0;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case nsXPTType::T_CHAR:
|
||||
result[i].val.c = argv[argi][0];
|
||||
break;
|
||||
case nsXPTType::T_WCHAR:
|
||||
result[i].val.wc = argv[argi][0]; // PENDING: not wide
|
||||
break;
|
||||
case nsXPTType::T_CHAR_STR:
|
||||
result[i].val.p = argv[argi];
|
||||
// Copying every time would be wasteful
|
||||
if (param.IsOut()) {
|
||||
char *tmpstr = new char[strlen(argv[argi]) + 1];
|
||||
strcpy(tmpstr, argv[argi]);
|
||||
result[i].val.p = tmpstr;
|
||||
result[i].flags |= nsXPTCVariant::VAL_IS_OWNED;
|
||||
}
|
||||
break;
|
||||
case nsXPTType::T_VOID:
|
||||
case nsXPTType::T_IID:
|
||||
case nsXPTType::T_BSTR:
|
||||
case nsXPTType::T_WCHAR_STR:
|
||||
case nsXPTType::T_INTERFACE:
|
||||
case nsXPTType::T_INTERFACE_IS:
|
||||
// Ignore for now
|
||||
break;
|
||||
}
|
||||
// VAL_IS_OWNED: val.p holds alloc'd ptr that must be freed
|
||||
// VAL_IS_IFACE: val.p holds interface ptr that must be released
|
||||
|
||||
argi++;
|
||||
}
|
||||
|
||||
if (param.IsOut()) {
|
||||
// PTR_IS_DATA: ptr points to 'real' data in val
|
||||
result[i].flags |= nsXPTCVariant::PTR_IS_DATA;
|
||||
|
||||
switch(result[i].type) {
|
||||
case nsXPTType::T_I8:
|
||||
result[i].ptr = &result[i].val.i8;
|
||||
break;
|
||||
case nsXPTType::T_I16:
|
||||
result[i].ptr = &result[i].val.i16;
|
||||
break;
|
||||
case nsXPTType::T_I32:
|
||||
result[i].ptr = &result[i].val.i32;
|
||||
break;
|
||||
case nsXPTType::T_I64:
|
||||
result[i].ptr = &result[i].val.i64;
|
||||
break;
|
||||
case nsXPTType::T_U8:
|
||||
result[i].ptr = &result[i].val.u8;
|
||||
break;
|
||||
case nsXPTType::T_U16:
|
||||
result[i].ptr = &result[i].val.u16;
|
||||
break;
|
||||
case nsXPTType::T_U32:
|
||||
result[i].ptr = &result[i].val.u32;
|
||||
break;
|
||||
case nsXPTType::T_U64:
|
||||
result[i].ptr = &result[i].val.u64;
|
||||
break;
|
||||
case nsXPTType::T_FLOAT:
|
||||
result[i].ptr = &result[i].val.f;
|
||||
break;
|
||||
case nsXPTType::T_DOUBLE:
|
||||
result[i].ptr = &result[i].val.d;
|
||||
break;
|
||||
case nsXPTType::T_BOOL:
|
||||
result[i].ptr = &result[i].val.b;
|
||||
break;
|
||||
case nsXPTType::T_CHAR:
|
||||
result[i].ptr = &result[i].val.c;
|
||||
break;
|
||||
case nsXPTType::T_WCHAR:
|
||||
result[i].ptr = &result[i].val.wc;
|
||||
break;
|
||||
default:
|
||||
result[i].ptr = &result[i].val.p;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void xpjd_PrintParams(const nsXPTCVariant params[], int paramcount) {
|
||||
for (int i = 0; i < paramcount; i++) {
|
||||
|
||||
cerr << i << ") ";
|
||||
|
||||
switch(params[i].type) {
|
||||
case nsXPTType::T_I8:
|
||||
cerr << params[i].val.i8;
|
||||
break;
|
||||
case nsXPTType::T_I16:
|
||||
cerr << params[i].val.i16;
|
||||
break;
|
||||
case nsXPTType::T_I32:
|
||||
cerr << params[i].val.i32;
|
||||
break;
|
||||
case nsXPTType::T_I64:
|
||||
cerr << params[i].val.i64;
|
||||
break;
|
||||
case nsXPTType::T_U8:
|
||||
cerr << params[i].val.u8;
|
||||
break;
|
||||
case nsXPTType::T_U16:
|
||||
cerr << params[i].val.u16;
|
||||
break;
|
||||
case nsXPTType::T_U32:
|
||||
cerr << params[i].val.u32;
|
||||
break;
|
||||
case nsXPTType::T_U64:
|
||||
cerr << params[i].val.u64;
|
||||
break;
|
||||
case nsXPTType::T_FLOAT:
|
||||
cerr << params[i].val.f;
|
||||
break;
|
||||
case nsXPTType::T_DOUBLE:
|
||||
cerr << params[i].val.d;
|
||||
break;
|
||||
case nsXPTType::T_BOOL:
|
||||
cerr << (params[i].val.b ? "true" : "false");
|
||||
break;
|
||||
case nsXPTType::T_CHAR:
|
||||
cerr << "'" << params[i].val.c << "'";
|
||||
break;
|
||||
case nsXPTType::T_WCHAR:
|
||||
cerr << "'" << params[i].val.wc << "'";
|
||||
break;
|
||||
case nsXPTType::T_CHAR_STR:
|
||||
cerr << params[i].val.p << ' '
|
||||
<< '"' << (char *)params[i].val.p << '"';
|
||||
break;
|
||||
default:
|
||||
// Ignore for now
|
||||
break;
|
||||
}
|
||||
cerr << " : type " << (int)(params[i].type)
|
||||
<< ", ptr=" << params[i].ptr
|
||||
<< (params[i].IsPtrData() ? ", data" : "")
|
||||
<< (params[i].IsValOwned() ? ", owned" : "")
|
||||
<< (params[i].IsValInterface() ? ", interface" : "")
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static nsresult GetMethodInfoByName(const nsID *iid,
|
||||
const char *methodname,
|
||||
PRBool wantSetter,
|
||||
const nsXPTMethodInfo **miptr,
|
||||
int *_retval) {
|
||||
nsresult res;
|
||||
nsIInterfaceInfoManager *iim;
|
||||
nsIInterfaceInfo *info = nsnull;
|
||||
|
||||
// Get info
|
||||
iim = XPTI_GetInterfaceInfoManager();
|
||||
|
||||
if (!iim) {
|
||||
cerr << "Failed to find InterfaceInfoManager" << endl;
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
res = iim->GetInfoForIID(iid, &info);
|
||||
|
||||
if (NS_FAILED(res)) {
|
||||
cerr << "Failed to find info for " << iid->ToString() << endl;
|
||||
return res;
|
||||
}
|
||||
|
||||
// Find info for command
|
||||
uint16 methodcount;
|
||||
|
||||
info->GetMethodCount(&methodcount);
|
||||
|
||||
int i;
|
||||
for (i = 0; i < methodcount; i++) {
|
||||
const nsXPTMethodInfo *mi;
|
||||
|
||||
info->GetMethodInfo(i, &mi);
|
||||
// PENDING(frankm): match against name, get/set, *AND* param types
|
||||
if (strcmp(methodname, mi->GetName()) == 0) {
|
||||
PRBool setter = mi->IsSetter();
|
||||
PRBool getter = mi->IsGetter();
|
||||
if ((!getter && !setter)
|
||||
|| (setter && wantSetter)
|
||||
|| (getter && !wantSetter)) {
|
||||
*miptr = mi;
|
||||
*_retval = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (i >= methodcount) {
|
||||
cerr << "Failed to find " << methodname << endl;
|
||||
*miptr = NULL;
|
||||
*_retval = -1;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
JSISample *sample;
|
||||
nsresult res;
|
||||
char *commandName;
|
||||
|
||||
cout << "Starting ..." << endl;
|
||||
|
||||
// Get options
|
||||
|
||||
// Get command vector
|
||||
if (argc > 1) {
|
||||
commandName = argv[1];
|
||||
}
|
||||
else {
|
||||
commandName = "PrintStats";
|
||||
}
|
||||
|
||||
// Initialize XPCOM
|
||||
nsComponentManager::AutoRegister(nsIComponentManager::NS_Startup, nsnull);
|
||||
|
||||
// Create Instance
|
||||
res = nsComponentManager::CreateInstance(kSampleCID,
|
||||
nsnull,
|
||||
kISampleIID,
|
||||
(void **) &sample);
|
||||
|
||||
if (NS_FAILED(res)) {
|
||||
cerr << "Failed to create instance" << endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Get info
|
||||
int index;
|
||||
const nsXPTMethodInfo *mi;
|
||||
|
||||
res = GetMethodInfoByName(&kISampleIID, commandName, PR_FALSE,
|
||||
&mi, &index);
|
||||
|
||||
if (NS_FAILED(res)) {
|
||||
cerr << "Failed to find " << commandName << endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint8 paramcount = mi->GetParamCount();
|
||||
|
||||
cerr << mi->GetName()
|
||||
<< ":" << endl;
|
||||
|
||||
for (int i = 0; i < paramcount; i++) {
|
||||
nsXPTParamInfo param = mi->GetParam(i);
|
||||
nsXPTType type = param.GetType();
|
||||
|
||||
cerr << '\t' << i << ": "
|
||||
<< " type = " << (int)type.TagPart()
|
||||
<< (type.IsUniquePointer() ? " UNIQUE" : "")
|
||||
<< (type.IsReference() ? " REF" : "")
|
||||
<< (type.IsPointer() ? " POINTER" : "")
|
||||
<< (param.IsIn() ? ", in" : "")
|
||||
<< (param.IsOut() ? ", out" : "")
|
||||
<< (param.IsRetval() ? ", retval" : "")
|
||||
<< (param.IsShared() ? ", shared" : "")
|
||||
<< endl;
|
||||
}
|
||||
|
||||
// Translate and marshall arguments
|
||||
nsXPTCVariant params[32];
|
||||
|
||||
if (paramcount > (sizeof(params)/sizeof(nsXPTCVariant))) {
|
||||
cerr << "Too Many Params" << endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
ParamsFromArgv(params, mi, 2, argc, argv);
|
||||
|
||||
cerr << "Arguments are: " << endl;
|
||||
|
||||
xpjd_PrintParams(params, paramcount);
|
||||
|
||||
// Invoke command
|
||||
|
||||
cerr << "Calling XPTC_InvokeByIndex( " << sample
|
||||
<< ", " << (int)index
|
||||
<< ", " << (int)paramcount
|
||||
<< ", " << params
|
||||
<< ")" << endl;
|
||||
|
||||
res = XPTC_InvokeByIndex(sample,
|
||||
(PRUint32)index,
|
||||
(PRUint32)paramcount,
|
||||
params);
|
||||
|
||||
// Get result
|
||||
|
||||
cerr << "Results are: " << endl;
|
||||
|
||||
xpjd_PrintParams(params, paramcount);
|
||||
|
||||
// Release Instance
|
||||
NS_RELEASE(sample);
|
||||
|
||||
return 0;
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user