This commit was manufactured by cvs2svn to create tag

'xpc_20010327_pre_trunk_merge_TAG'.

git-svn-id: svn://10.0.0.236/tags/xpc_20010327_pre_trunk_merge_TAG@90539 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
(no author) 2001-03-27 14:35:08 +00:00
parent b7f662d833
commit 4acb8ac1e9
41 changed files with 128 additions and 3581 deletions

View File

@ -1,486 +0,0 @@
# 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): Stephen Lamm
# Build the Mozilla client.
#
# This needs CVSROOT set to work, e.g.,
# setenv CVSROOT :pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot
# or
# setenv CVSROOT :pserver:username%somedomain.org@cvs.mozilla.org:/cvsroot
#
# To checkout and build a tree,
# 1. cvs co mozilla/client.mk
# 2. cd mozilla
# 3. gmake -f client.mk
#
# Other targets (gmake -f client.mk [targets...]),
# checkout
# build
# clean (realclean is now the same as clean)
# distclean
#
# See http://www.mozilla.org/build/unix.html 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 (default: SeaMonkeyAll)
# 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_BRANCH - Branch tag (Depricated. Use MOZ_CO_TAG below.)
#
#######################################################################
# Checkout Tags
#
# For branches, uncomment the MOZ_CO_TAG line with the proper tag,
# and commit this file on that tag.
#MOZ_CO_TAG = <tag>
NSPR_CO_TAG = NSPRPUB_CLIENT_BRANCH
PSM_CO_TAG = #We will now build PSM from the tip instead of a branch.
NSS_CO_TAG = NSS_CLIENT_TAG
LDAPCSDK_CO_TAG = LDAPCSDK_40_BRANCH
GFX2_CO_TAG =
IMGLIB2_CO_TAG =
BUILD_MODULES = all
#######################################################################
# Defines
#
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%//%/%')
# 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
CVSCO = $(strip cvs $(CVS_FLAGS) co $(CVS_CO_FLAGS))
CVSCO_LOGFILE := $(ROOTDIR)/cvsco.log
CVSCO_LOGFILE := $(shell echo $(CVSCO_LOGFILE) | sed s%//%/%)
ifdef MOZ_CO_TAG
CVS_CO_FLAGS := -r $(MOZ_CO_TAG)
endif
####################################
# Load mozconfig Options
# See build pages, http://www.mozilla.org/build/unix.html,
# 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
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
# 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
# This option is depricated. The best way to have client.mk pull a tag
# is to set MOZ_CO_TAG (see above) and commit that change on the tag.
ifdef MOZ_CO_BRANCH
CVS_CO_FLAGS := -r $(MOZ_CO_BRANCH)
endif
# MOZ_CO_FLAGS - Anything that we should use on all checkouts
ifeq "$(origin MOZ_CO_FLAGS)" "undefined"
CVS_CO_FLAGS := $(CVS_CO_FLAGS) -P
else
CVS_CO_FLAGS := $(CVS_CO_FLAGS) $(MOZ_CO_FLAGS)
endif
ifdef MOZ_CO_DATE
CVS_CO_DATE_FLAGS := -D "$(MOZ_CO_DATE)"
endif
ifeq "$(origin MOZ_MAKE_FLAGS)" "undefined"
MOZ_MAKE_ENV :=
else
MOZ_MAKE_ENV := MAKE="$(MAKE) $(MOZ_MAKE_FLAGS)"
endif
ifdef MOZ_OBJDIR
OBJDIR := $(MOZ_OBJDIR)
MOZ_MAKE := $(MOZ_MAKE_ENV) $(MAKE) -C $(OBJDIR)
else
OBJDIR := $(TOPSRCDIR)
MOZ_MAKE := $(MOZ_MAKE_ENV) $(MAKE)
endif
####################################
# CVS defines for PSM
#
PSM_CO_MODULE= mozilla/security/psm mozilla/security/manager mozilla/security/Makefile.in
PSM_CO_FLAGS := -P -A
ifdef PSM_CO_TAG
PSM_CO_FLAGS := $(PSM_CO_FLAGS) -r $(PSM_CO_TAG)
endif
CVSCO_PSM = cvs $(CVS_FLAGS) co $(PSM_CO_FLAGS) $(CVS_CO_DATE_FLAGS) $(PSM_CO_MODULE)
####################################
# CVS defines for NSS
#
NSS_CO_MODULE= mozilla/security/nss mozilla/security/coreconf
NSS_CO_FLAGS := -P
ifdef NSS_CO_TAG
NSS_CO_FLAGS := $(NSS_CO_FLAGS) -r $(NSS_CO_TAG)
endif
CVSCO_NSS = cvs $(CVS_FLAGS) co $(NSS_CO_FLAGS) $(CVS_CO_DATE_FLAGS) $(NSS_CO_MODULE)
####################################
# CVS defines for NSPR
#
NSPR_CO_MODULE = mozilla/nsprpub
NSPR_CO_FLAGS := -P
ifdef NSPR_CO_TAG
NSPR_CO_FLAGS := $(NSPR_CO_FLAGS) -r $(NSPR_CO_TAG)
endif
CVSCO_NSPR = cvs $(CVS_FLAGS) co $(NSPR_CO_FLAGS) $(CVS_CO_DATE_FLAGS) $(NSPR_CO_MODULE)
####################################
# CVS defines for the C LDAP SDK
#
LDAPCSDK_CO_MODULE = mozilla/directory/c-sdk
LDAPCSDK_CO_FLAGS := -P
ifdef LDAPCSDK_CO_TAG
LDAPCSDK_CO_FLAGS := $(LDAPCSDK_CO_FLAGS) -r $(LDAPCSDK_CO_TAG)
endif
CVSCO_LDAPCSDK = cvs $(CVS_FLAGS) co $(LDAPCSDK_CO_FLAGS) $(CVS_CO_DATE_FLAGS) $(LDAPCSDK_CO_MODULE)
####################################
# CVS defines for gfx2
#
GFX2_CO_MODULE = mozilla/gfx2
GFX2_CO_FLAGS := -P
ifdef GFX2_CO_TAG
GFX2_CO_FLAGS := $(GFX2_CO_FLAGS) -r $(GFX2_CO_TAG)
endif
CVSCO_GFX2 = cvs $(CVS_FLAGS) co $(GFX2_CO_FLAGS) $(CVS_CO_DATE_FLAGS) $(GFX2_CO_MODULE)
####################################
# CVS defines for new image library
#
IMGLIB2_CO_MODULE = mozilla/modules/libpr0n
IMGLIB2_CO_FLAGS := -P
ifdef IMGLIB2_CO_TAG
IMGLIB2_CO_FLAGS := $(IMGLIB2_CO_FLAGS) -r $(IMGLIB2_CO_TAG)
endif
CVSCO_IMGLIB2 = cvs $(CVS_FLAGS) co $(IMGLIB2_CO_FLAGS) $(CVS_CO_DATE_FLAGS) $(IMGLIB2_CO_MODULE)
####################################
# CVS defines for standalone modules
#
ifneq ($(BUILD_MODULES),all)
MOZ_CO_MODULE := $(filter-out $(NSPRPUB_DIR) security directory/c-sdk, $(BUILD_MODULE_CVS))
MOZ_CO_MODULE += allmakefiles.sh client.mk aclocal.m4 configure configure.in
MOZ_CO_MODULE += Makefile.in
MOZ_CO_MODULE := $(addprefix mozilla/, $(MOZ_CO_MODULE))
NOSUBDIRS_MODULE := $(addprefix mozilla/, $(BUILD_MODULE_CVS_NS))
ifneq ($(NOSUBDIRS_MODULE),)
CVSCO_NOSUBDIRS := $(CVSCO) -l $(CVS_CO_DATE_FLAGS) $(NOSUBDIRS_MODULE)
endif
ifeq (,$(filter $(NSPRPUB_DIR), $(BUILD_MODULE_CVS)))
CVSCO_NSPR :=
endif
ifeq (,$(filter security security/manager, $(BUILD_MODULE_CVS)))
CVSCO_PSM :=
CVSCO_NSS :=
endif
ifeq (,$(filter directory/c-sdk, $(BUILD_MODULE_CVS)))
CVSCO_LDAPCSDK :=
endif
ifeq (,$(filter gfx2, $(BUILD_MODULE_CVS)))
CVSCO_GFX2 :=
endif
ifeq (,$(filter modules/libpr0n, $(BUILD_MODULE_CVS)))
CVSCO_IMGLIB2 :=
endif
else
# Do not pull PSM/NSS by default
CVSCO_PSM :=
CVSCO_NSS :=
endif
####################################
# CVS defines for SeaMonkey
#
ifeq ($(MOZ_CO_MODULE),)
MOZ_CO_MODULE := SeaMonkeyAll
endif
CVSCO_SEAMONKEY := $(CVSCO) $(CVS_CO_DATE_FLAGS) $(MOZ_CO_MODULE)
#######################################################################
# Rules
#
# Print out any options loaded from mozconfig.
all build checkout clean depend distclean export 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 depend build
endif
# Windows equivalents
pull_all: checkout
build_all: build
clobber clobber_all: clean
pull_and_build_all: checkout depend build
# 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
@echo "checkout start: "`date` | tee $(CVSCO_LOGFILE)
@echo '$(CVSCO) mozilla/client.mk mozilla/build/unix/modules.mk'; \
cd $(ROOTDIR); \
$(CVSCO) mozilla/client.mk mozilla/build/unix/modules.mk && \
$(MAKE) -f mozilla/client.mk real_checkout
real_checkout:
# @: Start the checkout. Split the output to the tty and a log file. \
# : If it fails, touch an error file because "tee" hides the error.
@failed=.cvs-failed.tmp; rm -f $$failed*; \
cvs_co() { echo "$$@" ; \
("$$@" || touch $$failed) 2>&1 | tee -a $(CVSCO_LOGFILE) && \
if test -f $$failed; then false; else true; fi; }; \
cvs_co $(CVSCO_NSPR) && \
cvs_co $(CVSCO_PSM) && \
cvs_co $(CVSCO_NSS) && \
cvs_co $(CVSCO_LDAPCSDK) && \
cvs_co $(CVSCO_GFX2) && \
cvs_co $(CVSCO_IMGLIB2) && \
cvs_co $(CVSCO_SEAMONKEY) && \
cvs_co $(CVSCO_NOSUBDIRS)
@echo "checkout finish: "`date` | tee -a $(CVSCO_LOGFILE)
# @: 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
####################################
# Web configure
WEBCONFIG_FILE := $(HOME)/.mozconfig
MOZCONFIG2CONFIGURATOR := build/autoconf/mozconfig2configurator
webconfig:
@cd $(TOPSRCDIR); \
url=`$(MOZCONFIG2CONFIGURATOR) $(TOPSRCDIR)`; \
echo Running netscape with the following url: ;\
echo ;\
echo $$url ;\
netscape -remote "openURL($$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
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 \
$(TOPSRCDIR)/build/autoconf/gtk.m4 \
$(TOPSRCDIR)/build/autoconf/altoptions.m4 \
$(NULL)
$(TOPSRCDIR)/configure: $(TOPSRCDIR)/configure.in $(EXTRA_CONFIG_DEPS)
@echo Generating $@ using autoconf
cd $(TOPSRCDIR); $(AUTOCONF)
endif
CONFIG_STATUS_DEPS_L10N := $(wildcard $(TOPSRCDIR)/l10n/makefiles.all)
CONFIG_STATUS_DEPS := \
$(TOPSRCDIR)/configure \
$(TOPSRCDIR)/allmakefiles.sh \
$(TOPSRCDIR)/.mozconfig.mk \
$(wildcard $(TOPSRCDIR)/nsprpub/configure) \
$(wildcard $(TOPSRCDIR)/directory/c-sdk/ldap/configure) \
$(wildcard $(TOPSRCDIR)/mailnews/makefiles) \
$(CONFIG_STATUS_DEPS_L10N) \
$(wildcard $(TOPSRCDIR)/themes/makefiles) \
$(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
$(OBJDIR)/Makefile $(OBJDIR)/config.status: $(CONFIG_STATUS_DEPS)
@if test ! -d $(OBJDIR); then $(MKDIR) $(OBJDIR); else true; fi
@echo cd $(OBJDIR);
@echo $(CONFIGURE)
@cd $(OBJDIR) && $(CONFIGURE_ENV_ARGS) $(CONFIGURE) \
|| ( echo "*** Fix above errors and then restart with\
\"$(MAKE) -f client.mk build\"" && exit 1 )
@touch $(OBJDIR)/Makefile
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) $@;
####################################
# Build it
build:: $(OBJDIR)/Makefile $(OBJDIR)/config.status
$(MOZ_MAKE) export && $(MOZ_MAKE) install
####################################
# Other targets
# Pass these target onto the real build system
install export clean realclean distclean:: $(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
.PHONY: checkout real_checkout depend build export install clean realclean distclean cleansrcdir pull_all build_all clobber clobber_all pull_and_build_all everything

View File

@ -1,55 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* 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 oqr
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Mozilla Communicator client code, released
* March 31, 1998.
*
* 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):
* Robert Ginda <rginda@netscape.com>
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
#include "nsISupports.idl"
[scriptable, uuid(8792d77e-1dd2-11b2-ac7f-9bc9be4f2916)]
interface mozIJSSubScriptLoader : nsISupports
{
/**
* This method should only be called from JS!
* In JS, the signature looks like:
* rv loadSubScript (url [, obj]);
* @param url the url if the sub-script, it MUST be either a file:,
* resource:, or chrome: url, and MUST be local.
* @param obj an optional object to evaluate the script onto, it
* defaults to the global object of the caller.
* @retval rv the value returned by the sub-script
*/
void loadSubScript (in wstring url);
};

View File

@ -1,331 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* 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 oqr
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Mozilla Communicator client code, released
* March 31, 1998.
*
* 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):
* Robert Ginda <rginda@netscape.com>
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
#if !defined(XPCONNECT_STANDALONE) && !defined(NO_SUBSCRIPT_LOADER)
#include "mozJSSubScriptLoader.h"
#include "nsIServiceManager.h"
#include "nsIXPConnect.h"
#include "nsIURI.h"
#include "nsIIOService.h"
#include "nsIChannel.h"
#include "nsIInputStream.h"
#include "jsapi.h"
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
/* load() error msgs, XXX localize? */
#define LOAD_ERROR_NOSERVICE "Error creating IO Service."
#define LOAD_ERROR_NOCHANNEL "Error creating channel (invalid URL scheme?)"
#define LOAD_ERROR_NOSTREAM "Error opening input stream (invalid filename?)"
#define LOAD_ERROR_NOCONTENT "ContentLength not available (not a local URL?)"
#define LOAD_ERROR_BADREAD "File Read Error."
#define LOAD_ERROR_READUNDERFLOW "File Read Error (underflow.)"
/* turn ALL JS Runtime errors into exceptions */
JS_STATIC_DLL_CALLBACK(void)
ExceptionalErrorReporter (JSContext *cx, const char *message,
JSErrorReport *report)
{
JSObject *ex;
JSString *jstr;
JSBool ok;
if (report && JSREPORT_IS_EXCEPTION (report->flags))
/* if it's already an exception, our job is done. */
return;
ex = JS_NewObject (cx, nsnull, nsnull, nsnull);
/* create a jsobject to throw */
if (!ex)
goto panic;
/* decorate the exception */
if (message)
{
jstr = JS_NewStringCopyZ (cx, message);
if (!jstr)
goto panic;
ok = JS_DefineProperty (cx, ex, "message", STRING_TO_JSVAL(jstr),
nsnull, nsnull, JSPROP_ENUMERATE);
if (!ok)
goto panic;
}
if (report)
{
jstr = JS_NewStringCopyZ (cx, report->filename);
if (!jstr)
goto panic;
ok = JS_DefineProperty (cx, ex, "fileName", STRING_TO_JSVAL(jstr),
nsnull, nsnull, JSPROP_ENUMERATE);
if (!ok)
goto panic;
ok = JS_DefineProperty (cx, ex, "lineNumber",
INT_TO_JSVAL(NS_STATIC_CAST(uintN,
report->lineno)),
nsnull, nsnull, JSPROP_ENUMERATE);
if (!ok)
goto panic;
}
JS_SetPendingException (cx, OBJECT_TO_JSVAL(ex));
return;
panic:
#ifdef DEBUG
fprintf (stderr,
"mozJSSubScriptLoader: Error occurred while reporting error :/\n")
#endif
;
}
mozJSSubScriptLoader::mozJSSubScriptLoader() : mSystemPrincipal(nsnull)
{
NS_INIT_ISUPPORTS();
}
mozJSSubScriptLoader::~mozJSSubScriptLoader()
{
/* empty */
}
NS_IMPL_THREADSAFE_ISUPPORTS1(mozJSSubScriptLoader, mozIJSSubScriptLoader)
NS_IMETHODIMP /* args and return value are delt with using XPConnect and JSAPI */
mozJSSubScriptLoader::LoadSubScript (const PRUnichar */*url*/
/* [, JSObject *target_obj] */)
{
/*
* Loads a local url and evals it into the current cx
* Synchronous (an async version would be cool too.)
* url: The url to load. Must be local so that it can be loaded
* synchronously.
* target_obj: Optional object to eval the script onto (defaults to context
* global)
* returns: Whatever jsval the script pointed to by the url returns.
* Should ONLY (O N L Y !) be called from JavaScript code.
*/
/* gotta define most of this stuff up here because of all the gotos,
* defined the rest up here to be consistent */
nsresult rv;
JSBool ok;
/* get JS things from the CallContext */
nsCOMPtr<nsIXPConnect> xpc = do_GetService(nsIXPConnect::GetCID());
if (!xpc) return NS_ERROR_FAILURE;
nsCOMPtr<nsIXPCNativeCallContext> cc;
rv = xpc->GetCurrentNativeCallContext(getter_AddRefs(cc));
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
JSContext *cx;
rv = cc->GetJSContext (&cx);
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
PRUint32 argc;
rv = cc->GetArgc (&argc);
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
jsval *argv;
rv = cc->GetArgvPtr (&argv);
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
jsval *rval;
rv = cc->GetRetValPtr (&rval);
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
/* set mJSPrincipals if it's not here already */
if (!mSystemPrincipal)
{
nsCOMPtr<nsIScriptSecurityManager> secman =
do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID);
if (!secman)
return rv;
rv = secman->GetSystemPrincipal(getter_AddRefs(mSystemPrincipal));
if (NS_FAILED(rv) || !mSystemPrincipal)
return rv;
}
char *url;
JSObject *target_obj = nsnull;
ok = JS_ConvertArguments (cx, argc, argv, "s / o", &url, &target_obj);
if (!ok)
{
cc->SetExceptionWasThrown (JS_TRUE);
/* let the exception raised by JS_ConvertArguments show through */
return NS_OK;
}
if (!target_obj)
{
/* if the user didn't provide an object to eval onto, find the global
* object by walking the parent chain of the calling object */
#ifdef DEBUG_rginda
JSObject *got_glob = JS_GetGlobalObject (cx);
fprintf (stderr, "JS_GetGlobalObject says glob is %p.\n", got_glob);
target_obj = JS_GetPrototype (cx, got_glob);
fprintf (stderr, "That glob's prototype is %p.\n", target_obj);
target_obj = JS_GetParent (cx, got_glob);
fprintf (stderr, "That glob's parent is %p.\n", target_obj);
#endif
nsCOMPtr<nsIXPConnectWrappedNative> wn;
rv = cc->GetCalleeWrapper (getter_AddRefs(wn));
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
rv = wn->GetJSObject (&target_obj);
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
#ifdef DEBUG_rginda
fprintf (stderr, "Parent chain: %p", target_obj);
#endif
JSObject *maybe_glob = JS_GetParent (cx, target_obj);
while (maybe_glob != nsnull)
{
#ifdef DEBUG_rginda
fprintf (stderr, ", %p", maybe_glob);
#endif
target_obj = maybe_glob;
maybe_glob = JS_GetParent (cx, maybe_glob);
}
#ifdef DEBUG_rginda
fprintf (stderr, "\n");
#endif
}
/* load up the url. From here on, failures are reflected as ``custom''
* js exceptions */
PRInt32 len = -1;
PRUint32 readcount;
char *buf = nsnull;
JSString *errmsg;
JSErrorReporter er;
JSPrincipals *jsPrincipals;
nsCOMPtr<nsIChannel> chan;
nsCOMPtr<nsIInputStream> instream;
nsCOMPtr<nsIIOService> serv = do_GetService(kIOServiceCID);
if (!serv)
{
errmsg = JS_NewStringCopyZ (cx, LOAD_ERROR_NOSERVICE);
goto return_exception;
}
rv = serv->NewChannel(url, NS_STATIC_CAST(nsIURI *, nsnull),
getter_AddRefs(chan));
if (NS_FAILED(rv))
{
errmsg = JS_NewStringCopyZ (cx, LOAD_ERROR_NOCHANNEL);
goto return_exception;
}
rv = chan->Open (getter_AddRefs(instream));
if (NS_FAILED(rv))
{
errmsg = JS_NewStringCopyZ (cx, LOAD_ERROR_NOSTREAM);
goto return_exception;
}
rv = chan->GetContentLength (&len);
if (NS_FAILED(rv))
{
errmsg = JS_NewStringCopyZ (cx, LOAD_ERROR_NOCONTENT);
goto return_exception;
}
buf = new char[len + 1];
if (!buf)
return NS_ERROR_OUT_OF_MEMORY;
rv = instream->Read (buf, len, &readcount);
if (NS_FAILED(rv))
{
errmsg = JS_NewStringCopyZ (cx, LOAD_ERROR_BADREAD);
goto return_exception;
}
if (NS_STATIC_CAST(PRUint32, len) != readcount)
{
errmsg = JS_NewStringCopyZ (cx, LOAD_ERROR_READUNDERFLOW);
goto return_exception;
}
/* we can't hold onto jsPrincipals as a module var because the
* JSPRINCIPALS_DROP macro takes a JSContext, which we won't have in the
* destructor */
rv = mSystemPrincipal->GetJSPrincipals(&jsPrincipals);
if (NS_FAILED(rv) || !jsPrincipals)
return rv;
/* set our own error reporter so we can report any bad things as catchable
* exceptions, including the source/line number */
er = JS_SetErrorReporter (cx, ExceptionalErrorReporter);
ok = JS_EvaluateScriptForPrincipals (cx, target_obj, jsPrincipals,
buf, len, url, 1, rval);
/* repent for our evil deeds */
JS_SetErrorReporter (cx, er);
cc->SetExceptionWasThrown (!ok);
cc->SetReturnValueWasSet (ok);
delete[] buf;
return NS_OK;
return_exception:
if (buf)
delete[] buf;
JS_SetPendingException (cx, STRING_TO_JSVAL(errmsg));
cc->SetExceptionWasThrown (JS_TRUE);
return NS_OK;
}
#endif /* NO_SUBSCRIPT_LOADER */

View File

@ -1,61 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* 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 oqr
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Mozilla Communicator client code, released
* March 31, 1998.
*
* 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):
* Robert Ginda <rginda@netscape.com>
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
#include "nsCOMPtr.h"
#include "mozIJSSubScriptLoader.h"
#include "nsIScriptSecurityManager.h"
#define MOZ_JSSUBSCRIPTLOADER_CID \
{ /* 829814d6-1dd2-11b2-8e08-82fa0a339b00 */ \
0x929814d6, \
0x1dd2, \
0x11b2, \
{0x8e, 0x08, 0x82, 0xfa, 0x0a, 0x33, 0x9b, 0x00} \
}
class mozJSSubScriptLoader : public mozIJSSubScriptLoader
{
public:
mozJSSubScriptLoader();
virtual ~mozJSSubScriptLoader();
// all the interface method declarations...
NS_DECL_ISUPPORTS
NS_DECL_MOZIJSSUBSCRIPTLOADER
private:
nsCOMPtr<nsIPrincipal> mSystemPrincipal;
};

View File

@ -1,300 +0,0 @@
/* -*- Mode: C++; tab-width: 8; 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 oqr
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Mozilla Communicator client code, released
* March 31, 1998.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Mike Shaver <shaver@mozilla.org>
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
/*
* Infrastructure for sharing DOMString data with JSStrings.
*
* Importing an nsAReadableString into JS:
* If possible (GetSharedBufferHandle works) use the external string support in
* JS to create a JSString that points to the readable's buffer. We keep a
* reference to the buffer handle until the JSString is finalized.
*
* Exporting a JSString as an nsAReadable:
* Wrap the JSString with a root-holding XPCJSReadableStringWrapper, which roots
* the string and exposes its buffer via the nsAReadableString interface, as
* well as providing refcounting support.
*/
#include "xpcprivate.h"
#include "nscore.h"
/*
* We require that STRING_TO_JSVAL(s) != (jsval)s, for tracking rootedness.
* When we colonize Mars and change JSVAL_STRING, we'll need to update this
* code.
*/
#if JSVAL_STRING == 0
#error "JSVAL_STRING has zero value -- need to fix root management!"
#endif
XPCReadableJSStringWrapper::~XPCReadableJSStringWrapper()
{
if (mBufferHandle)
{
if (mHandleIsShared)
{
mBufferHandle->ReleaseReference();
}
else
{
delete mBufferHandle;
}
}
}
const nsSharedBufferHandle<PRUnichar>*
XPCReadableJSStringWrapper::BufferHandle(JSBool shared) const
{
XPCReadableJSStringWrapper * mutable_this =
NS_CONST_CAST(XPCReadableJSStringWrapper *, this);
if (!mBufferHandle)
{
mutable_this->mBufferHandle =
new WrapperBufferHandle(mutable_this, mStr);
}
if (shared && !mHandleIsShared)
{
mutable_this->mBufferHandle->AcquireReference();
mutable_this->mBufferHandle->mAllocator.RootString();
mutable_this->mHandleIsShared = JS_TRUE;
}
return mBufferHandle;
}
void
XPCReadableJSStringWrapper::WrapperBufferHandle::Allocator::
Deallocate(PRUnichar *) const
{
if (JSVAL_IS_STRING(mStr))
{
// unroot
JSRuntime *rt;
nsCOMPtr<nsIJSRuntimeService> rtsvc =
nsJSRuntimeServiceImpl::GetSingleton();
if (rtsvc && NS_SUCCEEDED(rtsvc->GetRuntime(&rt)))
{
JS_RemoveRootRT(rt,
NS_CONST_CAST(void **,
NS_REINTERPRET_CAST(void * const *,
&mStr)));
Allocator *mutable_this = NS_CONST_CAST(Allocator *, this);
// store untagged to indicate that we're not rooted
mutable_this->mStr = NS_REINTERPRET_CAST(jsval,
JSVAL_TO_STRING(mStr));
}
else
{
NS_ERROR("Unable to unroot mStr! Prepare for leak or crash!");
}
}
}
JSBool
XPCReadableJSStringWrapper::WrapperBufferHandle::Allocator::RootString()
{
JSRuntime *rt;
nsCOMPtr<nsIJSRuntimeService> rtsvc =
nsJSRuntimeServiceImpl::GetSingleton();
JSBool ok = rtsvc &&
NS_SUCCEEDED(rtsvc->GetRuntime(&rt)) &&
JS_AddNamedRootRT(rt,
NS_CONST_CAST(void **,
NS_REINTERPRET_CAST(void * const *,
&mStr)),
"WrapperBufferHandle.mAllocator.mStr");
if (ok)
{
// Indicate that we've rooted the string by storing it as a
// string-tagged jsval
mStr = STRING_TO_JSVAL(NS_REINTERPRET_CAST(JSString *, mStr));
}
return ok;
}
// structure for entry in the DOMStringTable
struct SharedStringEntry : public JSDHashEntryHdr {
void *key;
const nsSharedBufferHandle<PRUnichar> *handle;
};
// table to match JSStrings to their handles at finalization time
static JSDHashTable DOMStringTable;
static intN DOMStringFinalizerIndex = -1;
// unref the appropriate handle when the matching string is finalized
JS_STATIC_DLL_CALLBACK(void)
FinalizeDOMString(JSContext *cx, JSString *str)
{
NS_ASSERTION(DOMStringFinalizerIndex != -1,
"XPCConvert: DOM string finalizer called uninitialized!");
SharedStringEntry *entry =
NS_STATIC_CAST(SharedStringEntry *,
JS_DHashTableOperate(&DOMStringTable, str,
JS_DHASH_LOOKUP));
// entry might be empty if we ran out of memory adding it to the hash
if (JS_DHASH_ENTRY_IS_BUSY(entry))
{
entry->handle->ReleaseReference();
(void) JS_DHashTableOperate(&DOMStringTable, str, JS_DHASH_REMOVE);
}
}
// initialize the aforementioned hash table and register our external finalizer
static JSBool
InitializeDOMStringFinalizer()
{
if (!JS_DHashTableInit(&DOMStringTable, JS_DHashGetStubOps(), NULL,
sizeof(SharedStringEntry), JS_DHASH_MIN_SIZE))
{
return JS_FALSE;
}
DOMStringFinalizerIndex =
JS_AddExternalStringFinalizer(FinalizeDOMString);
if (DOMStringFinalizerIndex == -1)
{
JS_DHashTableFinish(&DOMStringTable);
return JS_FALSE;
}
return JS_TRUE;
}
// cleanup enumerator for the DOMStringTable
JS_STATIC_DLL_CALLBACK(JSDHashOperator)
ReleaseHandleAndRemove(JSDHashTable *table, JSDHashEntryHdr *hdr,
uint32 number, void *arg)
{
SharedStringEntry *entry = NS_STATIC_CAST(SharedStringEntry *, hdr);
entry->handle->ReleaseReference();
return JS_DHASH_REMOVE;
}
// clean up the finalizer infrastructure, releasing all outstanding handles
// static
void
XPCStringConvert::ShutdownDOMStringFinalizer()
{
if (DOMStringFinalizerIndex == -1)
{
return;
}
// enumerate and release
(void)JS_DHashTableEnumerate(&DOMStringTable, ReleaseHandleAndRemove, NULL);
JS_DHashTableFinish(&DOMStringTable);
DOMStringFinalizerIndex =
JS_RemoveExternalStringFinalizer(FinalizeDOMString);
DOMStringFinalizerIndex = -1;
}
// convert a readable to a JSString, sharing if possible and copying otherwise
// static
JSString *
XPCStringConvert::ReadableToJSString(JSContext *cx,
const nsAReadableString &readable)
{
const nsSharedBufferHandle<PRUnichar> *handle;
handle = readable.GetSharedBufferHandle();
JSString *str;
if (!handle || NS_REINTERPRET_CAST(int, handle) == 1)
{
// blech, have to copy.
PRUint32 length = readable.Length();
jschar *chars = NS_REINTERPRET_CAST(jschar *,
JS_malloc(cx, (length + 1) *
sizeof(jschar)));
if (!chars)
return NULL;
if (length && !CopyUnicodeTo(readable, 0,
NS_REINTERPRET_CAST(PRUnichar *, chars),
length))
{
JS_free(cx, chars);
return NULL;
}
chars[length] = 0;
str = JS_NewUCString(cx, chars, length);
if (!str)
JS_free(cx, chars);
return str;
}
if (DOMStringFinalizerIndex == -1 && !InitializeDOMStringFinalizer())
return NULL;
str = JS_NewExternalString(cx,
NS_CONST_CAST(jschar *,
NS_REINTERPRET_CAST(const jschar *,
handle->DataStart())),
handle->DataLength(),
DOMStringFinalizerIndex);
if (!str)
return NULL;
SharedStringEntry *entry =
NS_STATIC_CAST(SharedStringEntry *,
JS_DHashTableOperate(&DOMStringTable, str,
JS_DHASH_ADD));
if (!entry)
return NULL; // str will be cleaned up by GC
entry->handle = handle;
entry->key = str;
handle->AcquireReference();
return str;
}
// static
XPCReadableJSStringWrapper *
XPCStringConvert::JSStringToReadable(JSString *str)
{
return new XPCReadableJSStringWrapper(str);
}

View File

@ -1,124 +0,0 @@
/* -*- Mode: C++; tab-width: 8; 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 oqr
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Mozilla Communicator client code, released
* March 31, 1998.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Mike Shaver <shaver@mozilla.org>
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
#include "nsISupports.h"
#include "nsString.h"
#include "xpctest_domstring.h"
#include "xpctest_private.h"
class xpcTestDOMString : public nsIXPCTestDOMString {
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIXPCTESTDOMSTRING
xpcTestDOMString();
virtual ~xpcTestDOMString();
private:
const nsSharedBufferHandle<PRUnichar> *mHandle;
};
NS_IMPL_ISUPPORTS1(xpcTestDOMString, nsIXPCTestDOMString);
xpcTestDOMString::xpcTestDOMString()
: mHandle(0)
{
NS_INIT_REFCNT();
NS_ADDREF_THIS();
}
xpcTestDOMString::~xpcTestDOMString()
{
if (mHandle)
mHandle->ReleaseReference();
}
NS_IMETHODIMP
xpcTestDOMString::HereHaveADOMString(const nsAReadableString &str)
{
const nsSharedBufferHandle<PRUnichar> *handle;
handle = str.GetSharedBufferHandle();
if (!handle || int(handle) == 1)
return NS_ERROR_INVALID_ARG;
if (mHandle)
mHandle->ReleaseReference();
mHandle = handle;
mHandle->AcquireReference();
return NS_OK;
}
NS_IMETHODIMP
xpcTestDOMString::DontKeepThisOne(const nsAReadableString &str)
{
nsCString c; c.AssignWithConversion(str);
fprintf(stderr, "xpcTestDOMString::DontKeepThisOne: \"%s\"\n", c.get());
return NS_OK;
}
NS_IMETHODIMP
xpcTestDOMString::GiveDOMStringTo(nsIXPCTestDOMString *recv)
{
NS_NAMED_LITERAL_STRING(myString, "A DOM String, Just For You");
return recv->HereHaveADOMString(myString);
}
NS_IMETHODIMP
xpcTestDOMString::PassDOMStringThroughTo(const nsAReadableString &str,
nsIXPCTestDOMString *recv)
{
return recv->HereHaveADOMString(str);
}
NS_IMETHODIMP
xpctest::ConstructXPCTestDOMString(nsISupports *aOuter, REFNSIID aIID,
void **aResult)
{
nsresult rv;
NS_ASSERTION(!aOuter, "no aggregation");
xpcTestDOMString *obj = new xpcTestDOMString();
if (obj)
{
rv = obj->QueryInterface(aIID, aResult);
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to find correct interface");
NS_RELEASE(obj);
}
else
{
*aResult = nsnull;
rv = NS_ERROR_OUT_OF_MEMORY;
}
return rv;
}

View File

@ -1,54 +0,0 @@
/* -*- Mode: IDL; tab-width: 8; 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 oqr
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Mozilla Communicator client code, released
* March 31, 1998.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Mike Shaver <shaver@mozilla.org>
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
#include "nsISupports.idl"
/**
* Interface for testing the DOMString-conversion infrastructure.
*/
[scriptable, uuid(646d0b6b-6872-43b9-aa73-3c6b89ac3080)]
interface nsIXPCTestDOMString : nsISupports {
// Implementation should ask for the shared buffer interface and hold
// a refcount to it.
void hereHaveADOMString(in DOMString str);
// don't hold onto this one
void dontKeepThisOne(in DOMString str);
void giveDOMStringTo(in nsIXPCTestDOMString recv);
void passDOMStringThroughTo(in DOMString str, in nsIXPCTestDOMString recv);
};

View File

@ -1,31 +0,0 @@
#
# 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) 2000 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
#
MODULES_LIBREG_SRC_LCSRCS = \
reg.c \
VerReg.c \
vr_stubs.c \
$(NULL)
MODULES_LIBREG_SRC_CSRCS := $(addprefix $(topsrcdir)/modules/libreg/src/, $(MODULES_LIBREG_SRC_LCSRCS))

View File

@ -1,58 +0,0 @@
#
# 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):
# Samir Gehani <sgehani@netscape.com>
#
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@:@srcdir@/../src/
include $(DEPTH)/config/autoconf.mk
include $(srcdir)/../src/objs.mk
MODULE = libreg
LIBRARY_NAME = mozregsa_s
CSRCS = $(MODULES_LIBREG_SRC_LCSRCS)
OBJS = $(addprefix S_,$(CSRCS:.c=.$(OBJ_SUFFIX)))
override NO_SHARED_LIB=1
override NO_STATIC_LIB=
MDDEPDIR := $(MDDEPDIR)_S
GARBAGE_DIRS += .deps
include $(topsrcdir)/config/rules.mk
DEFINES += -DSTANDALONE_REGISTRY
# Make sure that these custom rules stay in sync with rules.mk
S_%.$(OBJ_SUFFIX): $(srcdir)/../src/%.c
$(REPORT_BUILD)
ifeq ($(MOZ_OS2_TOOLS), VACPP)
$(ELOG) $(CC) -Fo$@ -c $(COMPILE_CFLAGS) $<
else
$(ELOG) $(CC) -o $@ -c $(COMPILE_CFLAGS) $<
endif

View File

@ -1,5 +1,4 @@
#! gmake
#
# The contents of this file are subject to the Netscape Public License
# Version 1.1 (the "NPL"); you may not use this file except in

View File

@ -79,14 +79,14 @@ ifeq ($(OS_ARCH), HP-UX)
endif
ifeq ($(MOZ_OS2_TOOLS),EMX)
XCFLAGS = $(OS_EXE_CFLAGS)
XCFLAGS = $(OS_CFLAGS)
ifeq ($(MOZ_OS2_EMX_OBJECTFORMAT),OMF)
XLDOPTS = -Zlinker /PM:VIO
endif
endif
ifeq ($(MOZ_OS2_TOOLS),PGCC)
XCFLAGS = $(OS_EXE_CFLAGS)
XCFLAGS = $(OS_CFLAGS)
XLDOPTS = -Zlinker /PM:VIO
endif

View File

@ -52,16 +52,23 @@ ifeq ($(OBJECT_FMT),ELF)
DLL_SUFFIX = so
else
DLL_SUFFIX = so.1.0
# XXX work around a bug in the a.out ld(1).
OS_LIBS =
endif
DSO_CFLAGS = -fPIC -DPIC
DSO_LDFLAGS =
DSO_LDOPTS = -x -shared
ifdef LIBRUNPATH
DSO_LDOPTS += -R$(LIBRUNPATH)
DSO_LDOPTS = -shared
ifeq ($(OBJECT_FMT),ELF)
DSO_LDOPTS +=-Wl,-soname,lib$(LIBRARY_NAME)$(LIBRARY_VERSION).$(DLL_SUFFIX)
endif
MKSHLIB = $(LD) $(DSO_LDOPTS)
ifdef LIBRUNPATH
#DSO_LDOPTS += -R$(LIBRUNPATH)
DSO_LDOPTS += -Wl,-R$(LIBRUNPATH)
endif
#MKSHLIB = $(LD) $(DSO_LDOPTS)
MKSHLIB = $(CC) $(DSO_LDOPTS)
G++INCLUDES = -I/usr/include/g++

View File

@ -48,8 +48,9 @@ NSINSTALL = @NSINSTALL@
FILTER = @FILTER@
IMPLIB = @IMPLIB@
OS_CFLAGS = @CFLAGS@ $(DSO_CFLAGS)
OS_CXXFLAGS = @CXXFLAGS@ $(DSO_CFLAGS)
OS_CPPFLAGS = @CPPFLAGS@
OS_CFLAGS = $(OS_CPPFLAGS) @CFLAGS@ $(DSO_CFLAGS)
OS_CXXFLAGS = $(OS_CPPFLAGS) @CXXFLAGS@ $(DSO_CFLAGS)
OS_LIBS = @OS_LIBS@
OS_LDFLAGS = @LDFLAGS@
OS_DLLFLAGS = @OS_DLLFLAGS@

View File

@ -3106,6 +3106,7 @@ EOF
PR_MD_ASFILES=os_Irix.s
MKSHLIB='$(LD) $(DSO_LDOPTS) -rdata_shared -shared -soname $(notdir $@) -o $@'
#DSO_LDOPTS='-elf -shared -all'
STRIP="$STRIP -f"
if test -n "$USE_64"; then
MDCPUCFG_H=_irix64.cfg
else
@ -3238,6 +3239,7 @@ EOF
MKSHLIB='$(LD) $(DSO_LDOPTS) -soname $(notdir $@) -o $@'
DSO_CFLAGS=-fPIC
DSO_LDOPTS=-shared
OS_LIBS="$OS_LIBS -lc"
case "${target_cpu}" in
alpha)
cat >> confdefs.h <<\EOF
@ -3635,6 +3637,8 @@ EOF
CXXFLAGS="$CXXFLAGS -ansi -Wall -pipe"
DLL_SUFFIX=so.1.0
DSO_CFLAGS=-fPIC
MDCPUCFG_H=_openbsd.cfg
PR_MD_CSRCS=openbsd.c
case "$OS_TEST" in
alpha|mips|pmax)
DSO_LDOPTS=-shared ;;
@ -4077,14 +4081,17 @@ EOF
LD='$(CC)'
IMPLIB='emximp -o'
FILTER='emxexp'
OS_DLLFLAGS='$(DSO_LDOPTS) -o $@'
_OPTIMIZE_FLAGS=-O3
_DEBUG_FLAGS=-g
if test -n "$MOZ_DEBUG"; then
DLLFLAGS='-g'
EXEFLAGS='-g $(OMF_FLAG) -Zmtd -L$(DIST)/lib -o $@'
DSO_LDOPTS='-g -Zomf -Zdll -Zmt -Zcrtdll -Zlinker /NOO'
else
DLLFLAGS=
EXEFLAGS='-Zmtd -o $@'
DSO_LDOPTS='-Zomf -Zdll -Zmt -Zcrtdll -Zlinker /NOO'
fi
;;
*-os2_vacpp)
@ -4147,12 +4154,12 @@ fi
if test -z "$SKIP_LIBRARY_CHECKS"; then
echo $ac_n "checking for dlopen""... $ac_c" 1>&6
echo "configure:4151: checking for dlopen" >&5
echo "configure:4158: checking for dlopen" >&5
if eval "test \"`echo '$''{'ac_cv_func_dlopen'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 4156 "configure"
#line 4163 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char dlopen(); below. */
@ -4175,7 +4182,7 @@ dlopen();
; return 0; }
EOF
if { (eval echo configure:4179: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:4186: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_dlopen=yes"
else
@ -4194,7 +4201,7 @@ else
echo "$ac_t""no" 1>&6
echo $ac_n "checking for dlopen in -ldl""... $ac_c" 1>&6
echo "configure:4198: checking for dlopen in -ldl" >&5
echo "configure:4205: checking for dlopen in -ldl" >&5
ac_lib_var=`echo dl'_'dlopen | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@ -4202,7 +4209,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-ldl $LIBS"
cat > conftest.$ac_ext <<EOF
#line 4206 "configure"
#line 4213 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@ -4213,7 +4220,7 @@ int main() {
dlopen()
; return 0; }
EOF
if { (eval echo configure:4217: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:4224: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@ -4240,7 +4247,7 @@ fi
echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
echo "configure:4244: checking how to run the C preprocessor" >&5
echo "configure:4251: checking how to run the C preprocessor" >&5
# On Suns, sometimes $CPP names a directory.
if test -n "$CPP" && test -d "$CPP"; then
CPP=
@ -4255,13 +4262,13 @@ else
# On the NeXT, cc -E runs the code through the compiler's parser,
# not just through cpp.
cat > conftest.$ac_ext <<EOF
#line 4259 "configure"
#line 4266 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:4265: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:4272: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
:
@ -4272,13 +4279,13 @@ else
rm -rf conftest*
CPP="${CC-cc} -E -traditional-cpp"
cat > conftest.$ac_ext <<EOF
#line 4276 "configure"
#line 4283 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:4282: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:4289: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
:
@ -4289,13 +4296,13 @@ else
rm -rf conftest*
CPP="${CC-cc} -nologo -E"
cat > conftest.$ac_ext <<EOF
#line 4293 "configure"
#line 4300 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:4299: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:4306: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
:
@ -4321,13 +4328,13 @@ echo "$ac_t""$CPP" 1>&6
if test $ac_cv_prog_gcc = yes; then
echo $ac_n "checking whether ${CC-cc} needs -traditional""... $ac_c" 1>&6
echo "configure:4325: checking whether ${CC-cc} needs -traditional" >&5
echo "configure:4332: checking whether ${CC-cc} needs -traditional" >&5
if eval "test \"`echo '$''{'ac_cv_prog_gcc_traditional'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
ac_pattern="Autoconf.*'x'"
cat > conftest.$ac_ext <<EOF
#line 4331 "configure"
#line 4338 "configure"
#include "confdefs.h"
#include <sgtty.h>
Autoconf TIOCGETP
@ -4345,7 +4352,7 @@ rm -f conftest*
if test $ac_cv_prog_gcc_traditional = no; then
cat > conftest.$ac_ext <<EOF
#line 4349 "configure"
#line 4356 "configure"
#include "confdefs.h"
#include <termio.h>
Autoconf TCGETA
@ -4369,12 +4376,12 @@ fi
for ac_func in lchown strerror
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
echo "configure:4373: checking for $ac_func" >&5
echo "configure:4380: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 4378 "configure"
#line 4385 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@ -4397,7 +4404,7 @@ $ac_func();
; return 0; }
EOF
if { (eval echo configure:4401: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:4408: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@ -4428,7 +4435,7 @@ done
echo $ac_n "checking for pthread_create in -lpthreads""... $ac_c" 1>&6
echo "configure:4432: checking for pthread_create in -lpthreads" >&5
echo "configure:4439: checking for pthread_create in -lpthreads" >&5
echo "
#include <pthread.h>
void *foo(void *v) { int a = 1; }
@ -4450,7 +4457,7 @@ echo "
echo "$ac_t""no" 1>&6
echo $ac_n "checking for pthread_create in -lpthread""... $ac_c" 1>&6
echo "configure:4454: checking for pthread_create in -lpthread" >&5
echo "configure:4461: checking for pthread_create in -lpthread" >&5
echo "
#include <pthread.h>
void *foo(void *v) { int a = 1; }
@ -4472,7 +4479,7 @@ echo "
echo "$ac_t""no" 1>&6
echo $ac_n "checking for pthread_create in -lc_r""... $ac_c" 1>&6
echo "configure:4476: checking for pthread_create in -lc_r" >&5
echo "configure:4483: checking for pthread_create in -lc_r" >&5
echo "
#include <pthread.h>
void *foo(void *v) { int a = 1; }
@ -4494,7 +4501,7 @@ echo "
echo "$ac_t""no" 1>&6
echo $ac_n "checking for pthread_create in -lc""... $ac_c" 1>&6
echo "configure:4498: checking for pthread_create in -lc" >&5
echo "configure:4505: checking for pthread_create in -lc" >&5
echo "
#include <pthread.h>
void *foo(void *v) { int a = 1; }
@ -4644,7 +4651,7 @@ if test -n "$USE_PTHREADS"; then
rm -f conftest*
ac_cv_have_dash_pthread=no
echo $ac_n "checking whether ${CC-cc} accepts -pthread""... $ac_c" 1>&6
echo "configure:4648: checking whether ${CC-cc} accepts -pthread" >&5
echo "configure:4655: checking whether ${CC-cc} accepts -pthread" >&5
echo 'int main() { return 0; }' | cat > conftest.c
${CC-cc} -pthread -o conftest conftest.c > conftest.out 2>&1
if test $? -eq 0; then
@ -4660,7 +4667,7 @@ echo "configure:4648: checking whether ${CC-cc} accepts -pthread" >&5
ac_cv_have_dash_pthreads=no
if test "$ac_cv_have_dash_pthread" = "no"; then
echo $ac_n "checking whether ${CC-cc} accepts -pthreads""... $ac_c" 1>&6
echo "configure:4664: checking whether ${CC-cc} accepts -pthreads" >&5
echo "configure:4671: checking whether ${CC-cc} accepts -pthreads" >&5
echo 'int main() { return 0; }' | cat > conftest.c
${CC-cc} -pthreads -o conftest conftest.c > conftest.out 2>&1
if test $? -eq 0; then
@ -4910,6 +4917,7 @@ fi
MAKEFILES="

View File

@ -789,6 +789,7 @@ case "$target" in
PR_MD_ASFILES=os_Irix.s
MKSHLIB='$(LD) $(DSO_LDOPTS) -rdata_shared -shared -soname $(notdir $@) -o $@'
#DSO_LDOPTS='-elf -shared -all'
STRIP="$STRIP -f"
if test -n "$USE_64"; then
MDCPUCFG_H=_irix64.cfg
else
@ -885,6 +886,7 @@ case "$target" in
MKSHLIB='$(LD) $(DSO_LDOPTS) -soname $(notdir $@) -o $@'
DSO_CFLAGS=-fPIC
DSO_LDOPTS=-shared
OS_LIBS="$OS_LIBS -lc"
case "${target_cpu}" in
alpha)
AC_DEFINE(_ALPHA_)
@ -1147,6 +1149,8 @@ mips-sony-newsos*)
CXXFLAGS="$CXXFLAGS -ansi -Wall -pipe"
DLL_SUFFIX=so.1.0
DSO_CFLAGS=-fPIC
MDCPUCFG_H=_openbsd.cfg
PR_MD_CSRCS=openbsd.c
case "$OS_TEST" in
alpha|mips|pmax)
DSO_LDOPTS=-shared ;;
@ -1412,14 +1416,17 @@ mips-sony-newsos*)
LD='$(CC)'
IMPLIB='emximp -o'
FILTER='emxexp'
OS_DLLFLAGS='$(DSO_LDOPTS) -o $@'
_OPTIMIZE_FLAGS=-O3
_DEBUG_FLAGS=-g
if test -n "$MOZ_DEBUG"; then
DLLFLAGS='-g'
EXEFLAGS='-g $(OMF_FLAG) -Zmtd -L$(DIST)/lib -o $@'
DSO_LDOPTS='-g -Zomf -Zdll -Zmt -Zcrtdll -Zlinker /NOO'
else
DLLFLAGS=
EXEFLAGS='-Zmtd -o $@'
DSO_LDOPTS='-Zomf -Zdll -Zmt -Zcrtdll -Zlinker /NOO'
fi
;;
*-os2_vacpp)
@ -1828,6 +1835,7 @@ AC_SUBST(CC)
AC_SUBST(CXX)
AC_SUBST(CFLAGS)
AC_SUBST(CXXFLAGS)
AC_SUBST(CPPFLAGS)
AC_SUBST(HOST_CC)
AC_SUBST(HOST_CFLAGS)
AC_SUBST(LDFLAGS)

View File

@ -54,15 +54,15 @@ all:: build_all
# Furthermore, shmsdos doesn't support '&&' so there's a chance the
# 'cd' could fail and configure would be run in the wrong dir
#
$(MOZ_OBJDIR)/config.status: check_old configure configure.in
$(MOZ_OBJDIR)/config.status: configure configure.in
@$(MAKE_OBJDIR)
cd $(MOZ_OBJDIR)/ ; \
sh $(NSPR_CONFIGURE)
build_all: $(MOZ_OBJDIR)/config.status
build_all: $(MOZ_OBJDIR)/config.status check_old
gmake -C $(MOZ_OBJDIR)
clobber_all: $(MOZ_OBJDIR)/config.status
clobber_all: $(MOZ_OBJDIR)/config.status check_old
gmake -C $(MOZ_OBJDIR) clobber_all
distclean: check_old

View File

@ -1,105 +0,0 @@
#
# The contents of this file are subject to the Netscape Public License
# Version 1.1 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
#
#
# An NMAKE file to set up and adjust NSPR20's build system for
# Client build. Client build should invoke NMAKE on this file
# instead of invoking gmake directly.
#
DEPTH = ..
include <$(DEPTH)\config\config.mak>
#
# Backslashes are escape characters to gmake, so flip all backslashes
# in $(MOZ_TOOLS) to forward slashes and pass that to gmake.
#
GMAKE = $(MOZ_TOOLS)\bin\gmake.exe
GMAKE_FLAGS = MOZ_TOOLS_FLIPPED=$(MOZ_TOOLS:\=/) PR_CLIENT_BUILD=1 PR_CLIENT_BUILD_WINDOWS=1
#
# The Client's debug build uses MSVC's debug runtime library (/MDd).
#
!ifdef MOZ_DEBUG
!else
GMAKE_FLAGS = $(GMAKE_FLAGS) BUILD_OPT=1
!endif
!if "$(MOZ_BITS)" == "16"
GMAKE_FLAGS = $(GMAKE_FLAGS) OS_TARGET=WIN16
!else
GMAKE_FLAGS = $(GMAKE_FLAGS) OS_TARGET=WIN95
!ifdef MOZ_DEBUG
!ifdef MOZ_NO_DEBUG_RTL
!IF "$(CPU)" == "ALPHA"
PR_OBJDIR = WIN954.0ALPHA_DBG.OBJ
!else
PR_OBJDIR = WIN954.0_DBG.OBJ
!endif
!else
GMAKE_FLAGS = $(GMAKE_FLAGS) USE_DEBUG_RTL=1
!IF "$(CPU)" == "ALPHA"
PR_OBJDIR = WIN954.0ALPHA_DBG.OBJD
!else
PR_OBJDIR = WIN954.0_DBG.OBJD
!endif
!endif
!else
!IF "$(CPU)" == "ALPHA"
PR_OBJDIR = WIN954.0ALPHA_OPT.OBJ
!else
PR_OBJDIR = WIN954.0_OPT.OBJ
!endif
!endif
!endif
#
# The rules. Simply invoke gmake with the same target.
# The default target is 'all'. For Win16, set up the
# environment to use the Watcom compiler, Watcom headers,
# and Watcom libs.
#
all:: export libs install
export libs install clobber clobber_all clean depend::
!if "$(MOZ_BITS)" == "16"
set PATH=%WATCPATH%
set INCLUDE=%WATC_INC%
set LIB=%WATC_LIB%
!endif
$(GMAKE) $(GMAKE_FLAGS) $@
!if "$(MOZ_BITS)" == "16"
set PATH=%MSVCPATH%
set INCLUDE=%MSVC_INC%
set LIB=%MSVC_LIB%
!endif
!if "$(MOZ_BITS)" != "16"
export::
$(MAKE_INSTALL) $(XPDIST)\$(PR_OBJDIR)\include\*.h $(DIST)\include
$(MAKE_INSTALL) $(XPDIST)\$(PR_OBJDIR)\include\obsolete\*.h $(DIST)\include\obsolete
$(MAKE_INSTALL) $(XPDIST)\$(PR_OBJDIR)\include\private\*.h $(DIST)\include\private
$(MAKE_INSTALL) $(XPDIST)\$(PR_OBJDIR)\lib\*.lib $(DIST)\lib
$(MAKE_INSTALL) $(XPDIST)\$(PR_OBJDIR)\lib\*.dll $(DIST)\bin
!endif

View File

@ -103,6 +103,7 @@ struct _MDFileDesc {
_MDSocketCallerInfo misc;
_MDSocketCallerInfo read;
_MDSocketCallerInfo write;
_MDSocketCallerInfo poll;
};
/*

View File

@ -43,11 +43,6 @@
#define sock_errno() errno
#define soclose close
#define sock_init()
#include <sys/builtin.h>
#include <sys/smutex.h>
static _smutex _md_shm_lock = 0;
#endif
/*

View File

@ -292,6 +292,7 @@ static pascal void NotifierRoutine(void * contextPtr, OTEventCode code, OTResul
_MDFileDesc * md = &(secret->md);
EndpointRef endpoint = (EndpointRef)secret->md.osfd;
PRThread * thread = NULL;
PRThread * pollThread = md->poll.thread;
OSStatus err;
OTResult resultOT;
TDiscon discon;
@ -452,7 +453,11 @@ static pascal void NotifierRoutine(void * contextPtr, OTEventCode code, OTResul
return;
}
WakeUpNotifiedThread(thread, result);
if (pollThread)
WakeUpNotifiedThread(pollThread, kOTNoError);
if (thread && (thread != pollThread))
WakeUpNotifiedThread(thread, result);
}
@ -1658,8 +1663,13 @@ PRInt32 _MD_writev(PRFileDesc *fd, const struct PRIOVec *iov, PRInt32 iov_size,
static PRBool GetState(PRFileDesc *fd, PRBool *readReady, PRBool *writeReady, PRBool *exceptReady)
{
OTResult resultOT;
*readReady = fd->secret->md.readReady;
// hack to emulate BSD sockets; say that a socket that has disconnected
// is still readable.
size_t availableData = 1;
if (!fd->secret->md.orderlyDisconnect)
OTCountDataBytes((EndpointRef)fd->secret->md.osfd, &availableData);
*readReady = fd->secret->md.readReady && (availableData > 0);
*exceptReady = fd->secret->md.exceptReady;
resultOT = OTGetEndpointState((EndpointRef)fd->secret->md.osfd);
@ -1680,14 +1690,11 @@ PRInt32 _MD_poll(PRPollDesc *pds, PRIntn npds, PRIntervalTime timeout)
{
PRInt32 ready = 0;
PRPollDesc *pd, *epd;
PRIntervalTime sleepTime, timein;
PRThread *thread = _PR_MD_CURRENT_THREAD();
PRIntervalTime timein;
sleepTime = PR_MillisecondsToInterval(5UL);
if (PR_INTERVAL_NO_TIMEOUT != timeout)
{
if (sleepTime > timeout) sleepTime = timeout;
timein = PR_IntervalNow();
}
do
{
@ -1724,6 +1731,8 @@ PRInt32 _MD_poll(PRPollDesc *pds, PRIntn npds, PRIntervalTime timeout)
PR_ASSERT(NULL != bottomFD);
if ((NULL != bottomFD) && (_PR_FILEDESC_OPEN == bottomFD->secret->state))
{
bottomFD->secret->md.poll.thread = thread;
if (GetState(bottomFD, &readReady, &writeReady, &exceptReady))
{
if (readReady)
@ -1757,7 +1766,10 @@ PRInt32 _MD_poll(PRPollDesc *pds, PRIntn npds, PRIntervalTime timeout)
if (ready > 0) return ready;
(void) PR_Sleep(sleepTime);
thread->io_pending = PR_TRUE;
thread->io_fd = NULL;
thread->md.osErrCode = noErr;
WaitOnThisThread(thread, timeout);
} while ((timeout == PR_INTERVAL_NO_TIMEOUT) ||
(((PRIntervalTime)(PR_IntervalNow() - timein)) < timeout));

View File

@ -219,7 +219,7 @@ static void md_PostNotifyToCvar(_MDCVar *cvar, _MDLock *lock,
* 0 when it succeeds.
*
*/
PR_IMPLEMENT(PRInt32)
PRInt32
_PR_MD_NEW_CV(_MDCVar *cv)
{
cv->magic = _MD_MAGIC_CV;
@ -230,7 +230,7 @@ _PR_MD_NEW_CV(_MDCVar *cv)
return 0;
}
PR_IMPLEMENT(void) _PR_MD_FREE_CV(_MDCVar *cv)
void _PR_MD_FREE_CV(_MDCVar *cv)
{
cv->magic = (PRUint32)-1;
return;
@ -239,7 +239,7 @@ PR_IMPLEMENT(void) _PR_MD_FREE_CV(_MDCVar *cv)
/*
* _PR_MD_WAIT_CV() -- Wait on condition variable
*/
PR_IMPLEMENT(void)
void
_PR_MD_WAIT_CV(_MDCVar *cv, _MDLock *lock, PRIntervalTime timeout )
{
PRThread *thred = _PR_MD_CURRENT_THREAD();
@ -306,21 +306,21 @@ _PR_MD_WAIT_CV(_MDCVar *cv, _MDLock *lock, PRIntervalTime timeout )
return;
} /* --- end _PR_MD_WAIT_CV() --- */
PR_IMPLEMENT(void)
void
_PR_MD_NOTIFY_CV(_MDCVar *cv, _MDLock *lock)
{
md_PostNotifyToCvar(cv, lock, PR_FALSE);
return;
}
PR_IMPLEMENT(void)
void
_PR_MD_NOTIFYALL_CV(_MDCVar *cv, _MDLock *lock)
{
md_PostNotifyToCvar(cv, lock, PR_TRUE);
return;
}
PR_IMPLEMENT(void)
void
_PR_MD_UNLOCK(_MDLock *lock)
{
if (0 != lock->notified.length) {

View File

@ -29,7 +29,7 @@ PRInt32 _os2_highMask = 0;
PR_IMPLEMENT(void)
void
_PR_MD_INTERVAL_INIT()
{
if (DosTmrQueryFreq(&_os2_ticksPerSec) == NO_ERROR)
@ -46,7 +46,7 @@ _PR_MD_INTERVAL_INIT()
PR_ASSERT(_os2_ticksPerSec > PR_INTERVAL_MIN && _os2_ticksPerSec < PR_INTERVAL_MAX);
}
PR_IMPLEMENT(PRIntervalTime)
PRIntervalTime
_PR_MD_GET_INTERVAL()
{
QWORD count;
@ -69,7 +69,7 @@ _PR_MD_GET_INTERVAL()
}
}
PR_IMPLEMENT(PRIntervalTime)
PRIntervalTime
_PR_MD_INTERVAL_PER_SEC()
{
if(_os2_ticksPerSec != -1)

View File

@ -473,7 +473,7 @@ PRStatus _MD_OS2GetHostName(char *name, PRUint32 namelen)
return PR_FAILURE;
}
PR_IMPLEMENT(void)
void
_PR_MD_WAKEUP_CPUS( void )
{
return;

View File

@ -24,7 +24,7 @@
#include "primpl.h"
PR_IMPLEMENT(void)
void
_PR_MD_NEW_SEM(_MDSemaphore *md, PRUintn value)
{
int rv;
@ -36,7 +36,7 @@ _PR_MD_NEW_SEM(_MDSemaphore *md, PRUintn value)
PR_ASSERT(rv == NO_ERROR);
}
PR_IMPLEMENT(void)
void
_PR_MD_DESTROY_SEM(_MDSemaphore *md)
{
int rv;
@ -45,7 +45,7 @@ _PR_MD_DESTROY_SEM(_MDSemaphore *md)
}
PR_IMPLEMENT(PRStatus)
PRStatus
_PR_MD_TIMED_WAIT_SEM(_MDSemaphore *md, PRIntervalTime ticks)
{
int rv;
@ -57,13 +57,13 @@ _PR_MD_TIMED_WAIT_SEM(_MDSemaphore *md, PRIntervalTime ticks)
return PR_FAILURE;
}
PR_IMPLEMENT(PRStatus)
PRStatus
_PR_MD_WAIT_SEM(_MDSemaphore *md)
{
return _PR_MD_TIMED_WAIT_SEM(md, PR_INTERVAL_NO_TIMEOUT);
}
PR_IMPLEMENT(void)
void
_PR_MD_POST_SEM(_MDSemaphore *md)
{
int rv;

View File

@ -36,7 +36,7 @@ _NSPR_TLS* pThreadLocalStorage = 0;
_PRInterruptTable _pr_interruptTable[] = { { 0 } };
APIRET (* APIENTRY QueryThreadContext)(TID, ULONG, PCONTEXTRECORD);
PR_IMPLEMENT(void)
void
_PR_MD_ENSURE_TLS(void)
{
if(!pThreadLocalStorage)
@ -50,7 +50,7 @@ _PR_MD_ENSURE_TLS(void)
}
}
PR_IMPLEMENT(void)
void
_PR_MD_EARLY_INIT()
{
HMODULE hmod;
@ -77,7 +77,7 @@ _pr_SetThreadMDHandle(PRThread *thread)
}
PR_IMPLEMENT(PRStatus)
PRStatus
_PR_MD_INIT_THREAD(PRThread *thread)
{
#ifdef XP_OS2_EMX
@ -98,7 +98,7 @@ _PR_MD_INIT_THREAD(PRThread *thread)
return (thread->md.blocked_sema.sem != 0) ? PR_SUCCESS : PR_FAILURE;
}
PR_IMPLEMENT(PRStatus)
PRStatus
_PR_MD_CREATE_THREAD(PRThread *thread,
void (*start)(void *),
PRThreadPriority priority,
@ -119,14 +119,14 @@ _PR_MD_CREATE_THREAD(PRThread *thread,
return PR_SUCCESS;
}
PR_IMPLEMENT(void)
void
_PR_MD_YIELD(void)
{
/* Isn't there some problem with DosSleep(0) on OS/2? */
DosSleep(0);
}
PR_IMPLEMENT(void)
void
_PR_MD_SET_PRIORITY(_MDThread *thread, PRThreadPriority newPri)
{
int nativePri;
@ -159,7 +159,7 @@ _PR_MD_SET_PRIORITY(_MDThread *thread, PRThreadPriority newPri)
return;
}
PR_IMPLEMENT(void)
void
_PR_MD_CLEAN_THREAD(PRThread *thread)
{
if (&thread->md.blocked_sema) {
@ -172,7 +172,7 @@ _PR_MD_CLEAN_THREAD(PRThread *thread)
}
}
PR_IMPLEMENT(void)
void
_PR_MD_EXIT_THREAD(PRThread *thread)
{
_PR_MD_DESTROY_SEM(&thread->md.blocked_sema);
@ -200,7 +200,7 @@ _PR_MD_EXIT_THREAD(PRThread *thread)
}
PR_IMPLEMENT(void)
void
_PR_MD_EXIT(PRIntn status)
{
_exit(status);
@ -240,19 +240,19 @@ _PR_MD_GETTHREADAFFINITYMASK(PRThread *thread, PRUint32 *mask)
}
#endif /* HAVE_THREAD_AFFINITY */
PR_IMPLEMENT(void)
void
_PR_MD_SUSPEND_CPU(_PRCPU *cpu)
{
_PR_MD_SUSPEND_THREAD(cpu->thread);
}
PR_IMPLEMENT(void)
void
_PR_MD_RESUME_CPU(_PRCPU *cpu)
{
_PR_MD_RESUME_THREAD(cpu->thread);
}
PR_IMPLEMENT(void)
void
_PR_MD_SUSPEND_THREAD(PRThread *thread)
{
if (_PR_IS_NATIVE_THREAD(thread)) {
@ -266,7 +266,7 @@ _PR_MD_SUSPEND_THREAD(PRThread *thread)
}
}
PR_IMPLEMENT(void)
void
_PR_MD_RESUME_THREAD(PRThread *thread)
{
if (_PR_IS_NATIVE_THREAD(thread)) {

View File

@ -43,7 +43,7 @@ endif
TARGETS = $(OBJS)
INCLUDES = -I$(includedir) -I$(topsrcdir)/pr/include -I$(topsrcdir)/pr/include/private
INCLUDES = -I$(includedir) -I$(includedir)/boehm -I$(topsrcdir)/pr/include -I$(topsrcdir)/pr/include/private
DEFINES += -D_NSPR_BUILD_

View File

@ -806,11 +806,27 @@ void _PR_InitThreads(
#endif
#if defined(_PR_DCETHREADS) || defined(_POSIX_THREAD_PRIORITY_SCHEDULING)
#if defined(FREEBSD)
{
pthread_attr_t attr;
int policy;
/* get the min and max priorities of the default policy */
pthread_attr_init(&attr);
pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED);
pthread_attr_getschedpolicy(&attr, &policy);
pt_book.minPrio = sched_get_priority_min(policy);
PR_ASSERT(-1 != pt_book.minPrio);
pt_book.maxPrio = sched_get_priority_max(policy);
PR_ASSERT(-1 != pt_book.maxPrio);
pthread_attr_destroy(&attr);
}
#else
/*
** These might be function evaluations
*/
pt_book.minPrio = PT_PRIO_MIN;
pt_book.maxPrio = PT_PRIO_MAX;
#endif
#endif
PR_ASSERT(NULL == pt_book.ml);

View File

@ -1,262 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<title>nsIClassInfo Overview</title>
<meta name="author" content="Mike Shaver">
<meta name="description" content="General Overview of nsIClassInfo infrastructure">
<style type="text/css">
a:link, a:visited { text-decoration: none; }
</style>
</head>
<body bgcolor="#ffffff" link="#0000ee" vlink="#551a8b" alink="#0000ee">
<h2><code>nsIClassInfo</code> Overview</h2>
Mike Shaver &lt;<a href="mailto:shaver@mozilla.org">shaver@mozilla.org</a>
&gt;<br>
&nbsp;&nbsp; &nbsp; Last Modified: March 12, 2001<br>
<hr align="Left" width="100%" size="2">
<h3>Table of Contents</h3>
<ul>
<li><a href="#What_is_nsIClassInfo">What is <code>nsIClassInfo</code>?</a></li>
<li><a href="#How_do_I_use_it">How do I use it?</a><a href="#What_is_nsIClassInfo"></a></li>
<li><a href="#Doesnt_that_break_the_COM">Doesn't that break the COM <code>
QueryInterface</code> rules?</a><a href="#Doesnt_that_break_the_COM"></a></li>
<li><a href="#What_are_the_language_helpers_for">What are the "language
helpers" for?</a><br>
</li>
<li><a href="#That_sounds_useful_How_do_I_make_it">That sounds useful.
How do I make that work with my code?</a></li>
<ul>
<li>I'm writing C++ code, and</li>
<ul>
<li><a href="#Im_writing_C_code_and_I_use_the">I use the generic factory
and <code>nsModuleComponentInfo</code></a></li>
<li><a href="#Im_writing_C_code_and_I_use_a_custom">I use a custom factory
or a singleton service object</a><br>
</li>
</ul>
</ul>
<ul>
<li><a href="#Im_writing_JS_code">I'm writing JS code.</a></li>
</ul>
<li><a href="#Whats_interface_flattening">What's "interface flattening"?</a><br>
</li>
</ul>
<hr align="Left" width="100%" size="2">
<h4><a name="What_is_nsIClassInfo"></a>What is <code>nsIClassInfo</code>?</h4>
<p><a href="http://lxr.mozilla.org/mozilla/source/xpcom/components/nsIClassInfo.idl#38"><code>
nsIClassInfo</code></a> is an interface that provides information
about a specific implementation class, to wit:</p>
<ul>
<li> a contract ID and class ID through which it may be instantiated;</li>
<li>the language of implementation (C++, JavaScript, etc.);</li>
<li> a list of the interfaces implemented by the class;</li>
<li>flags indicating whether or not the class is threadsafe or a singleton;
and</li>
<li>helper objects in support of various language bindings.</li>
</ul>
<h4><a name="How_do_I_use_it"></a>How do I use it?</h4>
<p> To get the <code>nsIClassInfo</code> object for the implementation behind
a given interface, simply <code>QueryInterface</code> for the nsIClassInfo
interface:</p>
<blockquote>C++:<br>
<code>nsCOMPtr&lt;nsIClassInfo&gt; info = do_QueryInterface(ifacePtr);</code><br>
<br>
JavaScript:<br>
<code>var info = ifacePtr.QueryInterface(Components.interfaces.nsIClassInfo);</code></blockquote>
<p>It's important to note that this will usually return a <i>singleton</i>
object: there often exists only one nsIClassInfo implementation for
all implementations of a given class. This is very important, because it
means that you can't <code>QueryInterface</code> back to the original object,
no matter how hard you try.</p>
<h4><a name="Doesnt_that_break_the_COM"></a>Doesn't that break the COM
<code>QueryInterface</code> rules?</h4>
<p>Quite. As discussed in <a href="http://bugzilla.mozilla.org/show_bug.cgi?id=67699">
bug 67699</a>, though, it's a reasonable concession to make in order
to avoid an additional vtbl entry on every class that wants to export <code>
nsIClassInfo</code> data.<br>
</p>
<h4><a name="What_are_the_language_helpers_for"></a>What are the "language
helpers" for?</h4>
<p>The language helpers are basically hooks for alternate language bindings
to use for providing language-specific wrapping and manipulation behaviour,
without adding code to every wrapped object.&nbsp; In <a href="http://bugzilla.mozilla.org/show_bug.cgi?id=67699">
bug 67669</a>, jband tells us what XPConnect does with the language helpers:</p>
<blockquote>
<p>When wrapping an object xpconnect QIs the object for its classinfo
(say 'foo'). If it has seen that foo classinfo pointer before then it knows
that this object is a foo and it can reuse all the info is knows about foo
objects. If it has never seen foo it will gather info (such as the JS helper)
and remember that for future wrappings of foo objects.</p>
<p> Assuming that the foo helper tells xpconnect to not bother QI'ing
each foo instance for a per instance helper (or if the instances don't respond
to QI for the helper) then the same foo helper is used on all calls from
JS relating to the foo instances. </p>
<p>What you may be missing is that methods on the helper (nsIXPCScriptable
in the xpconnect case) *all* receive a pointer to the instance wrapper when
called. I.e. the helper methods have an explicit 'self' param. This allows
the helper to customize its response for each method call without requiring
a helper per instance.</p>
</blockquote>
See <a href="http://bugzilla.mozilla.org/show_bug.cgi?id=67699">bug 67699</a>
for more interesting discussion about pluggable language helpers and decoupling
them from specific wrapped classes.
<p></p>
<h4><a name="That_sounds_useful_How_do_I_make_it"></a>That sounds useful.
How do I make it work with my code?</h4>
<p>Why, yes, it <i>is</i> useful. To provide <code>nsIClassInfo</code>
data for your class, you need to ensure that it returns an <code>nsIClassInfo</code>
-implementing object when it is <code>QueryInterface</code>d for <code>
nsIClassInfo</code> . Simple enough, but it can be even simpler through
the use of a handful of helper macros/functions. Choose your own adventure:</p>
<h4><a name="Im_writing_C_code_and_I_use_the"></a>I'm writing C++ code,
and I use the generic factory and <code>nsModuleComponentInfo</code>.</h4>
<p>First, make sure that your class has the <code>nsIClassInfo</code>
helpers, by changing the <code>NS_IMPL_ISUPPORTS</code> line:</p>
<blockquote><code>NS_IMPL_ISUPPORTS2(nsSampleImpl, nsISample, nsIOther)</code><br>
</blockquote>
<p>becomes</p>
<blockquote><code>NS_IMPL_ISUPPORTS2_CI(nsSampleImpl, nsISample, nsIOther)</code><br>
</blockquote>
<p>This will provide an implementation of a helper function, named
<code>nsSampleImpl_GetInterfacesHelper</code>, which handles the processing
of <code>nsIClassInfo::getInterfaces</code>.</p>
<p>Next, in your module code, use <code>NS_DECL_CLASSINFO</code> to
provide the rest of the per-class infrastructure (a global pointer into
which to stash the <code>nsIClassInfo</code> object, and an extern declaration
of the interfaces-helper, in case it's defined in another file):</p>
<blockquote><code>NS_DECL_CLASSINFO(nsSampleImpl)</code><br>
</blockquote>
<p>You'll need one of these lines for each <code>nsIClassInfo</code>
-supporting class represented in your <code>nsModuleComponentInfo</code>
array.</p>
<p>Lastly, fill in the appropriate members of <code>nsModuleComponentInfo</code>
to wire everything up:</p>
<blockquote><code>static nsModuleComponentInfo components[] =</code><br>
<code>{</code><br>
<code> &nbsp; {<br>
&nbsp; &nbsp; "Sample Component", NS_SAMPLE_CID, NS_SAMPLE_CONTRACTID,
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br>
&nbsp; &nbsp; nsSampleImplConstructor,</code><br>
<code> &nbsp; &nbsp; nsSampleRegistrationProc,</code><br>
<code> &nbsp; &nbsp; nsSampleUnregistrationProc,</code><br>
<code> &nbsp; &nbsp; nsnull /* no factory destructor */,</code><br>
<code><font color="#ff0000"> &nbsp; &nbsp; NS_CI_INTERFACE_GETTER_NAME(nsSampleImpl),&nbsp;
/* interface getter */</font></code><br>
<code> &nbsp; &nbsp; nsnull /* no language helper */,</code><br>
<code><font color="#ff0000"> &nbsp; &nbsp; &amp;NS_CLASSINFO_NAME(nsSampleImpl),&nbsp;
/* global class-info pointer */</font></code><br>
<code> &nbsp; &nbsp; 0 /* no class flags */<br>
&nbsp; }</code><br>
<code>};</code><br>
</blockquote>
<p>If you want to add a callback which provides language-helper
objects, replace the last <code>nsnull</code> with your callback. See the
<a href="http://lxr.mozilla.org/mozilla/source/xpcom/components/nsIClassInfo.idl"><code>
nsIClassInfo</code> IDL file</a> for details on language helpers and
other esoterica.</p>
<p><b><i>Note</i></b>: the details of these macros may change
slightly over the next week or so, as we refine a system for using table-driven
QI and sharing data between QI and the class-info calls.<br>
</p>
<h4><a name="Im_writing_C_code_and_I_use_a_custom"></a>I'm writing
C++ code, and I use a custom factory or a singleton service object.</h4>
<p>You need some utility macros, don't ya?&nbsp; We're working
on it.&nbsp; (You should really use the generic factory and module, though.&nbsp;
See <a href="http://lxr.mozilla.org/seamonkey/source/intl/uconv/src/nsUConvModule.cpp">
nsUConvModule.cpp</a> for an example of how to use <code>nsModuleComponentInfo</code>
and the generic modules even when you have highly-custom registration
requirements.)</p>
<h4><a name="Im_writing_JS_code"></a>I'm writing JS code.</h4>
You poor thing. You suffer without even a GenericModule helper. We're
<a href="http://bugzilla.mozilla.org/show_bug.cgi?id=71689">working on
that</a>, too.
<h4><a name="Whats_interface_flattening"></a>What's "interface
flattening"?</h4>
<p></p>
<p> Interface flattening is a way to present multiple interfaces
of the same object to a language binding, without requiring explicit <code>
QueryInterface</code> calls.&nbsp; Consider the following interfaces and
an object <code>obj</code> that implements both of them:</p>
<blockquote>
<p><code>interface nsIFoo : nsISupports {<br>
&nbsp; &nbsp; void fooMeth(in string message);<br>
};</code></p>
<p><code>interface nsIBar : nsISupports {<br>
&nbsp; &nbsp; void barMeth(in PRUint32 meaning);<br>
};</code></p>
</blockquote>
<p>You could use the following code to call both fooMeth and
barMeth without any QueryInterface:<br>
</p>
<blockquote><code>obj.fooMeth("welcome to foo");<br>
obj.barMeth(42);</code></blockquote>
<p>Pretty, no?&nbsp; Pretty, yes. </p>
<p>There are also intricacies related to conflicting method
names and the difference between interface sets that are part of a contract's
promise and those which are simply artifacts of the implementation, but they're
beyond the scope of this overview.<br>
<br>
</p>
</body>
</html>

View File

@ -1,46 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* 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) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Darin Fisher <darin@netscape.com> (original author)
*/
#include "nsIInputStream.idl"
interface nsIOutputStream;
/**
* A nsIInputStreamTee is a wrapper for an input stream, that when read
* reads the specified amount of data from its |source| and copies that
* data to its |sink|. |sink| must be a blocking output stream.
*/
[scriptable, uuid(44e8b2c8-1ecb-4a63-8b23-3e3500c34f32)]
interface nsIInputStreamTee : nsIInputStream
{
void init(in nsIInputStream source,
in nsIOutputStream sink);
};
%{C++
// factory method
extern NS_COM nsresult
NS_NewInputStreamTee(nsIInputStream **tee, // read from this input stream
nsIInputStream *source,
nsIOutputStream *sink);
%}

View File

@ -1,193 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* 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) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Darin Fisher <darin@netscape.com> (original author)
*/
#include "nsIInputStreamTee.h"
#include "nsIInputStream.h"
#include "nsIOutputStream.h"
#include "nsCOMPtr.h"
class nsInputStreamTee : public nsIInputStreamTee
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIINPUTSTREAM
NS_DECL_NSIINPUTSTREAMTEE
nsInputStreamTee();
virtual ~nsInputStreamTee();
private:
nsresult TeeSegment(const char *buf, PRUint32 count);
static NS_METHOD WriteSegmentFun(nsIInputStream *, void *, const char *,
PRUint32, PRUint32, PRUint32 *);
private:
nsCOMPtr<nsIInputStream> mSource;
nsCOMPtr<nsIOutputStream> mSink;
nsWriteSegmentFun mWriter; // for implementing ReadSegments
void *mClosure; // for implementing ReadSegments
};
nsInputStreamTee::nsInputStreamTee()
{
NS_INIT_ISUPPORTS();
}
nsInputStreamTee::~nsInputStreamTee()
{
}
nsresult
nsInputStreamTee::TeeSegment(const char *buf, PRUint32 count)
{
nsresult rv = NS_OK;
PRUint32 bytesWritten = 0;
while (count) {
rv = mSink->Write(buf + bytesWritten, count, &bytesWritten);
if (NS_FAILED(rv)) break;
NS_ASSERTION(bytesWritten <= count, "wrote too much");
count -= bytesWritten;
}
return rv;
}
NS_METHOD
nsInputStreamTee::WriteSegmentFun(nsIInputStream *in, void *closure, const char *fromSegment,
PRUint32 offset, PRUint32 count, PRUint32 *writeCount)
{
nsInputStreamTee *tee = NS_REINTERPRET_CAST(nsInputStreamTee *, closure);
nsresult rv = tee->mWriter(in, tee->mClosure, fromSegment, offset, count, writeCount);
if (NS_FAILED(rv) || (writeCount == 0))
return rv;
return tee->TeeSegment(fromSegment, *writeCount);
}
NS_IMPL_ISUPPORTS2(nsInputStreamTee,
nsIInputStreamTee,
nsIInputStream)
NS_IMETHODIMP
nsInputStreamTee::Close()
{
NS_ENSURE_TRUE(mSource, NS_ERROR_NOT_INITIALIZED);
nsresult rv = mSource->Close();
mSource = 0;
mSink = 0;
return rv;
}
NS_IMETHODIMP
nsInputStreamTee::Available(PRUint32 *avail)
{
NS_ENSURE_TRUE(mSource, NS_ERROR_NOT_INITIALIZED);
return mSource->Available(avail);
}
NS_IMETHODIMP
nsInputStreamTee::Read(char *buf, PRUint32 count, PRUint32 *bytesRead)
{
NS_ENSURE_TRUE(mSource, NS_ERROR_NOT_INITIALIZED);
NS_ENSURE_TRUE(mSink, NS_ERROR_NOT_INITIALIZED);
nsresult rv = mSource->Read(buf, count, bytesRead);
if (NS_FAILED(rv) || (*bytesRead == 0))
return rv;
return TeeSegment(buf, *bytesRead);
}
NS_IMETHODIMP
nsInputStreamTee::ReadSegments(nsWriteSegmentFun writer,
void *closure,
PRUint32 count,
PRUint32 *bytesRead)
{
NS_ENSURE_TRUE(mSource, NS_ERROR_NOT_INITIALIZED);
NS_ENSURE_TRUE(mSink, NS_ERROR_NOT_INITIALIZED);
mWriter = writer;
mClosure = closure;
return mSource->ReadSegments(WriteSegmentFun, this, count, bytesRead);
}
NS_IMETHODIMP
nsInputStreamTee::GetNonBlocking(PRBool *result)
{
NS_ENSURE_TRUE(mSource, NS_ERROR_NOT_INITIALIZED);
return mSource->GetNonBlocking(result);
}
NS_IMETHODIMP
nsInputStreamTee::GetObserver(nsIInputStreamObserver **obs)
{
NS_ENSURE_TRUE(mSource, NS_ERROR_NOT_INITIALIZED);
return mSource->GetObserver(obs);
}
NS_IMETHODIMP
nsInputStreamTee::SetObserver(nsIInputStreamObserver *obs)
{
NS_ENSURE_TRUE(mSource, NS_ERROR_NOT_INITIALIZED);
return mSource->SetObserver(obs);
}
nsresult
nsInputStreamTee::Init(nsIInputStream *source, nsIOutputStream *sink)
{
NS_ENSURE_TRUE(source, NS_ERROR_NOT_INITIALIZED);
NS_ENSURE_TRUE(sink, NS_ERROR_NOT_INITIALIZED);
PRBool nonBlocking = PR_FALSE;
nsresult rv = sink->GetNonBlocking(&nonBlocking);
if (NS_FAILED(rv))
return rv;
if (nonBlocking) {
NS_NOTREACHED("Can only tee data to a blocking output stream");
return NS_ERROR_NOT_IMPLEMENTED;
}
mSource = source;
mSink = sink;
return NS_OK;
}
// factory method
NS_COM nsresult
NS_NewInputStreamTee(nsIInputStream **result,
nsIInputStream *source,
nsIOutputStream *sink)
{
nsCOMPtr<nsIInputStreamTee> tee;
NS_NEWXPCOM(tee, nsInputStreamTee);
if (!tee)
return NS_ERROR_OUT_OF_MEMORY;
nsresult rv = tee->Init(source, sink);
if (NS_SUCCEEDED(rv))
NS_ADDREF(*result = tee);
return rv;
}

View File

@ -1,198 +0,0 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* 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):
*/
/* Platform specific code to invoke XPCOM methods on native objects */
#include "xptcprivate.h"
// Remember that these 'words' are 32bit DWORDS
static PRUint32
invoke_count_words(PRUint32 paramCount, nsXPTCVariant* s)
{
PRUint32 result = 0;
for(PRUint32 i = 0; i < paramCount; i++, s++)
{
if(s->IsPtrData())
{
result++;
continue;
}
switch(s->type)
{
case nsXPTType::T_I8 :
case nsXPTType::T_I16 :
case nsXPTType::T_I32 :
result++;
break;
case nsXPTType::T_I64 :
result+=2;
break;
case nsXPTType::T_U8 :
case nsXPTType::T_U16 :
case nsXPTType::T_U32 :
result++;
break;
case nsXPTType::T_U64 :
result+=2;
break;
case nsXPTType::T_FLOAT :
result++;
break;
case nsXPTType::T_DOUBLE :
result+=2;
break;
case nsXPTType::T_BOOL :
case nsXPTType::T_CHAR :
case nsXPTType::T_WCHAR :
result++;
break;
default:
// all the others are plain pointer types
result++;
break;
}
}
return result;
}
static void
invoke_copy_to_stack(PRUint32* d, PRUint32 paramCount, nsXPTCVariant* s)
{
for(PRUint32 i = 0; i < paramCount; i++, d++, s++)
{
if(s->IsPtrData())
{
*((void**)d) = s->ptr;
continue;
}
switch(s->type)
{
case nsXPTType::T_I8 : *((PRInt8*) d) = s->val.i8; break;
case nsXPTType::T_I16 : *((PRInt16*) d) = s->val.i16; break;
case nsXPTType::T_I32 : *((PRInt32*) d) = s->val.i32; break;
case nsXPTType::T_I64 : *((PRInt64*) d) = s->val.i64; d++; break;
case nsXPTType::T_U8 : *((PRUint8*) d) = s->val.u8; break;
case nsXPTType::T_U16 : *((PRUint16*)d) = s->val.u16; break;
case nsXPTType::T_U32 : *((PRUint32*)d) = s->val.u32; break;
case nsXPTType::T_U64 : *((PRUint64*)d) = s->val.u64; d++; break;
case nsXPTType::T_FLOAT : *((float*) d) = s->val.f; break;
case nsXPTType::T_DOUBLE : *((double*) d) = s->val.d; d++; break;
case nsXPTType::T_BOOL : *((PRBool*) d) = s->val.b; break;
case nsXPTType::T_CHAR : *((char*) d) = s->val.c; break;
case nsXPTType::T_WCHAR : *((wchar_t*) d) = s->val.wc; break;
default:
// all the others are plain pointer types
*((void**)d) = s->val.p;
break;
}
}
}
extern "C"
struct my_params_struct {
nsISupports* that;
PRUint32 Index;
PRUint32 Count;
nsXPTCVariant* params;
PRUint32 fn_count;
PRUint32 fn_copy;
};
XPTC_PUBLIC_API(nsresult)
XPTC_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
PRUint32 paramCount, nsXPTCVariant* params)
{
PRUint32 result;
struct my_params_struct my_params;
my_params.that = that;
my_params.Index = methodIndex;
my_params.Count = paramCount;
my_params.params = params;
my_params.fn_copy = (PRUint32) &invoke_copy_to_stack;
my_params.fn_count = (PRUint32) &invoke_count_words;
/* This is to call a given method of class that.
* The parameters are in params, the number is in paramCount.
* The routine will issue calls to count the number of words
* required for argument passing and to copy the arguments to
* the stack.
* Since APCS passes the first 3 params in r1-r3, we need to
* load the first three words from the stack and correct the stack
* pointer (sp) in the appropriate way. This means:
*
* 1.) more than 3 arguments: load r1-r3, correct sp and remember No.
* of bytes left on the stack in r4
*
* 2.) <= 2 args: load r1-r3 (we won't be causing a stack overflow I hope),
* restore sp as if nothing had happened and set the marker r4 to zero.
*
* Afterwards sp will be restored using the value in r4 (which is not a temporary register
* and will be preserved by the function/method called according to APCS [ARM Procedure
* Calling Standard]).
*
* !!! IMPORTANT !!!
* This routine makes assumptions about the vtable layout of the c++ compiler. It's implemented
* for arm-linux GNU g++ >= 2.8.1 (including egcs and gcc-2.95.[1-3])!
*
*/
__asm__ __volatile__(
"ldr r1, [%1, #12] \n\t" /* prepare to call invoke_count_words */
"ldr ip, [%1, #16] \n\t" /* r0=paramCount, r1=params */
"ldr r0, [%1, #8] \n\t"
"mov lr, pc \n\t" /* call it... */
"mov pc, ip \n\t"
"mov r4, r0, lsl #2 \n\t" /* This is the amount of bytes needed. */
"sub sp, sp, r4 \n\t" /* use stack space for the args... */
"mov r0, sp \n\t" /* prepare a pointer an the stack */
"ldr r1, [%1, #8] \n\t" /* =paramCount */
"ldr r2, [%1, #12] \n\t" /* =params */
"ldr ip, [%1, #20] \n\t" /* =invoke_copy_to_stack */
"mov lr, pc \n\t" /* copy args to the stack like the */
"mov pc, ip \n\t" /* compiler would. */
"ldr r0, [%1] \n\t" /* =that */
"ldr r1, [r0, #0] \n\t" /* get that->vtable offset */
"ldr r2, [%1, #4] \n\t"
"add r2, r1, r2, lsl #3\n\t" /* a vtable_entry(x)=8 + (8 bytes * x) */
"add r2, r2, #8 \n\t" /* with this compilers */
"ldr r3, [r2] \n\t" /* get virtual offset from vtable */
"mov r3, r3, lsl #16 \n\t"
"add r0, r0, r3, asr #16\n\t"
"ldr ip, [r2, #4] \n\t" /* get method address from vtable */
"cmp r4, #12 \n\t" /* more than 3 arguments??? */
"ldmgtia sp!, {r1, r2, r3}\n\t" /* yes: load arguments for r1-r3 */
"subgt r4, r4, #12 \n\t" /* and correct the stack pointer */
"ldmleia sp, {r1, r2, r3}\n\t" /* no: load r1-r3 from stack */
"addle sp, sp, r4 \n\t" /* and restore stack pointer */
"movle r4, #0 \n\t" /* a mark for restoring sp */
"mov lr, pc \n\t" /* call mathod */
"mov pc, ip \n\t"
"add sp, sp, r4 \n\t" /* restore stack pointer */
"mov %0, r0 \n\t" /* the result... */
: "=r" (result)
: "r" (&my_params)
: "r0", "r1", "r2", "r3", "r4", "ip", "lr"
);
return result;
}

View File

@ -1,114 +0,0 @@
# -*- Mode: Asm -*-
#
# 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):
# Franz.Sirl-kernel@lauterbach.com (Franz Sirl)
# beard@netscape.com (Patrick Beard)
# waterson@netscape.com (Chris Waterson)
#
.set r0,0; .set sp,1; .set RTOC,2; .set r3,3; .set r4,4
.set r5,5; .set r6,6; .set r7,7; .set r8,8; .set r9,9
.set r10,10; .set r11,11; .set r12,12; .set r13,13; .set r14,14
.set r15,15; .set r16,16; .set r17,17; .set r18,18; .set r19,19
.set r20,20; .set r21,21; .set r22,22; .set r23,23; .set r24,24
.set r25,25; .set r26,26; .set r27,27; .set r28,28; .set r29,29
.set r30,30; .set r31,31
.set f0,0; .set f1,1; .set f2,2; .set f3,3; .set f4,4
.set f5,5; .set f6,6; .set f7,7; .set f8,8; .set f9,9
.set f10,10; .set f11,11; .set f12,12; .set f13,13; .set f14,14
.set f15,15; .set f16,16; .set f17,17; .set f18,18; .set f19,19
.set f20,20; .set f21,21; .set f22,22; .set f23,23; .set f24,24
.set f25,25; .set f26,26; .set f27,27; .set f28,28; .set f29,29
.set f30,30; .set f31,31
.section ".text"
.align 2
.globl XPTC_InvokeByIndex
.type XPTC_InvokeByIndex,@function
#
# XPTC_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
# PRUint32 paramCount, nsXPTCVariant* params)
#
XPTC_InvokeByIndex:
stwu sp,-32(sp) # setup standard stack frame
mflr r0 # save LR
stw r3,8(sp) # r3 <= that
stw r4,12(sp) # r4 <= methodIndex
stw r30,16(sp)
stw r31,20(sp)
stw r0,36(sp) # store LR backchain
mr r31,sp
rlwinm r10,r5,3,0,27 # r10 = (ParamCount * 2 * 4) & ~0x0f
addi r0,r10,96 # reserve stack for GPR and FPR register save area r0 = r10 + 96
lwz r9,0(sp) # r9 = backchain
neg r0,r0
stwux r9,sp,r0 # reserve stack sapce and save SP backchain
addi r3,sp,8 # r3 <= args
mr r4,r5 # r4 <= paramCount
mr r5,r6 # r5 <= params
add r6,r3,r10 # r6 <= gpregs ( == args + r10 )
mr r30,r6 # store in r30 for use later...
addi r7,r6,32 # r7 <= fpregs ( == gpregs + 32 )
bl invoke_copy_to_stack@local # (args, paramCount, params, gpregs, fpregs)
lfd f1,32(r30) # load FP registers with method parameters
lfd f2,40(r30)
lfd f3,48(r30)
lfd f4,56(r30)
lfd f5,64(r30)
lfd f6,72(r30)
lfd f7,80(r30)
lfd f8,88(r30)
lwz r3,8(r31) # r3 <= that
lwz r4,12(r31) # r4 <= methodIndex
lwz r5,0(r3) # r5 <= vtable ( == *that )
slwi r4,r4,3 # convert to offset ( *= 8 )
addi r4,r4,8 # skip first two vtable entries
add r4,r4,r5
lhz r0,0(r4) # virtual base offset
extsh r0,r0
add r3,r3,r0
lwz r0,4(r4) # r0 <= methodpointer ( == vtable + offset )
lwz r4,4(r30) # load GP regs with method parameters
lwz r5,8(r30)
lwz r6,12(r30)
lwz r7,16(r30)
lwz r8,20(r30)
lwz r9,24(r30)
lwz r10,28(r30)
mtlr r0 # copy methodpointer to LR
blrl # call method
lwz r30,16(r31) # restore r30 & r31
lwz r31,20(r31)
lwz r11,0(sp) # clean up the stack
lwz r0,4(r11)
mtlr r0
mr sp,r11
blr

View File

@ -1,121 +0,0 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* 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): Chris Torek (torek@bsdi.com), Kurt Lidl (lidl@pix.net)
*/
/* Platform specific code to invoke XPCOM methods on native objects */
.global XPTC_InvokeByIndex
/*
XPTC_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
PRUint32 paramCount, nsXPTCVariant* params);
*/
XPTC_InvokeByIndex:
/* regular C/C++ stack frame -- see <machine/frame.h> */
save %sp, -96, %sp
/*
* invoke_count_words(paramCount, params) apparently tells us
* how many "32-bit words" are involved in passing the given
* parameters to the target function.
*/
mov %i2, %o0
call invoke_count_words ! invoke_count_words(paramCount, params)
mov %i3, %o1
/*
* ??? Torek wonders: does invoke_count_words always force its
* return value to be even? If not, we would have to adjust
* the return value ... should make it a multiple of 8 anyway,
* for efficiency (32 byte cache lines); will do that here thus:
*
* We already have room (in our callee's "argument dump" area,
* sp->fr_argd) for six parameters, and we are going to use
* five of those (fr_argd[1] through fr_argd[5]) in a moment.
* This space is followed by fr_argx[1], room for a seventh.
* Thus, if invoke_count_words returns a value between 0 and 6
* inclusive, we do not need any stack adjustment. For values
* from 7 through (7+8) we want to make room for another 8
* parameters, and so on. Thus, we want to calculate:
*
* n_extra_words = (wordcount + 1) & ~7
*
* and then make room for that many more 32-bit words. (Normally
* it would be ((w+7)&~7; we just subtract off the room-for-6 we
* already have.)
*/
inc %o0
andn %o0, 7, %o0
sll %o0, 2, %o0 ! convert to bytes
sub %sp, %o0, %sp ! and make room for arguments
/*
* Copy all the arguments to the stack, starting at the argument
* dump area at [%sp + 68], even though the first six arguments
* go in the six %o registers. We will just load up those
* arguments after the copy is done. The first argument to
* any C++ member function is always the "this" parameter so
* we actually start with what will go in %o1, at [%sp + 72].
*/
add %sp, 72, %o0 ! invoke_copy_to_stack(addr,
mov %i2, %o1 ! paramCount,
call invoke_copy_to_stack
mov %i3, %o2 ! params);
/*
* This is the only really tricky (compiler-dependent) part
* (everything else here relies only on the V8 SPARC calling
* conventions). "methodIndex" (%i1) is an index into a C++
* vtable. The word at "*that" points to the vtable, but for
* some reason, the first function (index=0) is at vtable[2*4],
* the second (index 1) at vtable[3*4], the third at vtable[4*4],
* and so on. Thus, we want, in effect:
*
* that->vTable[index + 2]
*/
ld [%i0], %l0 ! vTable = *that
add %i1, 2, %l1
sll %l1, 2, %l1
ld [%l0 + %l1], %l0 ! fn = vTable[index + 2]
/*
* Now load up the various function parameters. We do not know,
* nor really care, how many there are -- we just load five words
* from the stack (there are always at least five such words to
* load, even if some of them are junk) into %o1 through %o5,
* and set %o0 = %i0, to pass "that" to the target member function
* as its C++ "this" parameter.
*
* If there are more than five parameters, any extras go on our
* stack starting at sp->fr_argx ([%sp + 92]), which is of course
* where we have just copied them.
*/
ld [%sp + 72], %o1
ld [%sp + 76], %o2
ld [%sp + 80], %o3
ld [%sp + 84], %o4
ld [%sp + 88], %o5
call %l0 ! fn(that, %o1, %o2, %o3, %o4, %o5)
mov %i0, %o0
! return whatever fn() returned
ret
restore %o0, 0, %o0

View File

@ -1,71 +0,0 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* 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):
*/
/* Platform specific code to invoke XPCOM methods on native objects */
.global XPTC_InvokeByIndex
/*
XPTC_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
PRUint32 paramCount, nsXPTCVariant* params);
*/
XPTC_InvokeByIndex:
save %sp,-(64 + 16),%sp ! room for the register window and
! struct pointer, rounded up to 0 % 16
mov %i2,%o0 ! paramCount
call invoke_count_words ! returns the required stack size in %o0
mov %i3,%o1 ! params
sll %o0,2,%l0 ! number of bytes
sub %sp,%l0,%sp ! create the additional stack space
mov %sp,%o0 ! pointer for copied args
add %o0,72,%o0 ! step past the register window, the
! struct result pointer and the 'this' slot
mov %i2,%o1 ! paramCount
call invoke_copy_to_stack
mov %i3,%o2 ! params
!
! calculate the target address from the vtable
!
add %i1,1,%i1 ! vTable is zero-based, index is 1 based (?)
ld [%i0],%l1 ! *that --> vTable
sll %i1,3,%i1
add %i1,%l1,%l1 ! vTable[index * 8], l1 now points to vTable entry
lduh [%l1],%l0 ! this adjustor
sll %l0,16,%l0 ! sign extend to 32 bits
sra %l0,16,%l0
add %l0,%i0,%i0 ! adjust this
ld [%l1 + 4],%l0 ! target address
.L5: ld [%sp + 88],%o5
.L4: ld [%sp + 84],%o4
.L3: ld [%sp + 80],%o3
.L2: ld [%sp + 76],%o2
.L1: ld [%sp + 72],%o1
.L0:
jmpl %l0,%o7 ! call the routine
! always have a 'this', from the incoming 'that'
mov %i0,%o0
mov %o0,%i0 ! propogate return value
ret
restore

View File

@ -1,132 +0,0 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* 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):
* Franz.Sirl-kernel@lauterbach.com (Franz Sirl)
* beard@netscape.com (Patrick Beard)
* waterson@netscape.com (Chris Waterson)
*/
// Platform specific code to invoke XPCOM methods on native objects
// The purpose of XPTC_InvokeByIndex() is to map a platform
// indepenpent call to the platform ABI. To do that,
// XPTC_InvokeByIndex() has to determine the method to call via vtable
// access. The parameters for the method are read from the
// nsXPTCVariant* and prepared for th native ABI. For the Linux/PPC
// ABI this means that the first 8 integral and floating point
// parameters are passed in registers.
#include "xptcprivate.h"
// 8 integral parameters are passed in registers
#define GPR_COUNT 8
// 8 floating point parameters are passed in registers, floats are
// promoted to doubles when passed in registers
#define FPR_COUNT 8
extern "C" PRUint32
invoke_count_words(PRUint32 paramCount, nsXPTCVariant* s)
{
return PRUint32(((paramCount * 2) + 3) & ~3);
}
extern "C" void
invoke_copy_to_stack(PRUint32* d,
PRUint32 paramCount,
nsXPTCVariant* s,
PRUint32* gpregs,
double* fpregs)
{
PRUint32 gpr = 1; // skip one GP reg for 'that'
PRUint32 fpr = 0;
PRUint32 tempu32;
PRUint64 tempu64;
for(uint32 i = 0; i < paramCount; i++, s++) {
if(s->IsPtrData())
tempu32 = (PRUint32) s->ptr;
else {
switch(s->type) {
case nsXPTType::T_FLOAT: break;
case nsXPTType::T_DOUBLE: break;
case nsXPTType::T_I8: tempu32 = s->val.i8; break;
case nsXPTType::T_I16: tempu32 = s->val.i16; break;
case nsXPTType::T_I32: tempu32 = s->val.i32; break;
case nsXPTType::T_I64: tempu64 = s->val.i64; break;
case nsXPTType::T_U8: tempu32 = s->val.u8; break;
case nsXPTType::T_U16: tempu32 = s->val.u16; break;
case nsXPTType::T_U32: tempu32 = s->val.u32; break;
case nsXPTType::T_U64: tempu64 = s->val.u64; break;
case nsXPTType::T_BOOL: tempu32 = s->val.b; break;
case nsXPTType::T_CHAR: tempu32 = s->val.c; break;
case nsXPTType::T_WCHAR: tempu32 = s->val.wc; break;
default: tempu32 = (PRUint32) s->val.p; break;
}
}
if (!s->IsPtrData() && s->type == nsXPTType::T_DOUBLE) {
if (fpr < FPR_COUNT)
fpregs[fpr++] = s->val.d;
else {
if ((PRUint32) d & 4) d++; // doubles are 8-byte aligned on stack
*((double*) d) = s->val.d;
d += 2;
if (gpr < GPR_COUNT)
gpr += 2;
}
}
else if (!s->IsPtrData() && s->type == nsXPTType::T_FLOAT) {
if (fpr < FPR_COUNT)
fpregs[fpr++] = s->val.f; // if passed in registers, floats are promoted to doubles
else {
*((float*) d) = s->val.f;
d += 1;
if (gpr < GPR_COUNT)
gpr += 1;
}
}
else if (!s->IsPtrData() && (s->type == nsXPTType::T_I64
|| s->type == nsXPTType::T_U64)) {
if ((gpr + 1) < GPR_COUNT) {
if (gpr & 1) gpr++; // longlongs are aligned in odd/even register pairs, eg. r5/r6
*((PRUint64*) &gpregs[gpr]) = tempu64;
gpr += 2;
}
else {
if ((PRUint32) d & 4) d++; // longlongs are 8-byte aligned on stack
*((PRUint64*) d) = tempu64;
d += 2;
}
}
else {
if (gpr < GPR_COUNT)
gpregs[gpr++] = tempu32;
else
*d++ = tempu32;
}
}
}
extern "C"
XPTC_PUBLIC_API(nsresult)
XPTC_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
PRUint32 paramCount, nsXPTCVariant* params);

View File

@ -1,141 +0,0 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* 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):
*/
/* Platform specific code to invoke XPCOM methods on native objects */
#include "xptcprivate.h"
/* solaris defines __sparc for workshop compilers and
linux defines __sparc__ */
#if !defined(__sparc) && !defined(__sparc__)
#error "This code is for Sparc only"
#endif
typedef unsigned nsXPCVariant;
extern "C" PRUint32
invoke_count_words(PRUint32 paramCount, nsXPTCVariant* s)
{
PRUint32 result = 0;
for(PRUint32 i = 0; i < paramCount; i++, s++)
{
if(s->IsPtrData())
{
result++;
continue;
}
switch(s->type)
{
case nsXPTType::T_I8 :
case nsXPTType::T_I16 :
case nsXPTType::T_I32 :
result++;
break;
case nsXPTType::T_I64 :
result+=2;
break;
case nsXPTType::T_U8 :
case nsXPTType::T_U16 :
case nsXPTType::T_U32 :
result++;
break;
case nsXPTType::T_U64 :
result+=2;
break;
case nsXPTType::T_FLOAT :
result++;
break;
case nsXPTType::T_DOUBLE :
result+=2;
break;
case nsXPTType::T_BOOL :
case nsXPTType::T_CHAR :
case nsXPTType::T_WCHAR :
result++;
break;
default:
// all the others are plain pointer types
result++;
break;
}
}
// nuts, I know there's a cooler way of doing this, but it's late
// now and it'll probably come to me in the morning.
if (result & 0x3) result += 4 - (result & 0x3); // ensure q-word alignment
return result;
}
extern "C" PRUint32
invoke_copy_to_stack(PRUint32* d, PRUint32 paramCount, nsXPTCVariant* s)
{
/*
We need to copy the parameters for this function to locals and use them
from there since the parameters occupy the same stack space as the stack
we're trying to populate.
*/
uint32 *l_d = d;
nsXPTCVariant *l_s = s;
uint32 l_paramCount = paramCount;
uint32 regCount = 0; // return the number of registers to load from the stack
typedef struct {
uint32 hi;
uint32 lo;
} DU; // have to move 64 bit entities as 32 bit halves since
// stack slots are not guaranteed 16 byte aligned
for(uint32 i = 0; i < l_paramCount; i++, l_d++, l_s++)
{
if (regCount < 5) regCount++;
if(l_s->IsPtrData())
{
*((void**)l_d) = l_s->ptr;
continue;
}
switch(l_s->type)
{
case nsXPTType::T_I8 : *((int32*) l_d) = l_s->val.i8; break;
case nsXPTType::T_I16 : *((int32*) l_d) = l_s->val.i16; break;
case nsXPTType::T_I32 : *((int32*) l_d) = l_s->val.i32; break;
case nsXPTType::T_I64 :
case nsXPTType::T_U64 :
case nsXPTType::T_DOUBLE : *((uint32*) l_d++) = ((DU *)l_s)->hi;
if (regCount < 5) regCount++;
*((uint32*) l_d) = ((DU *)l_s)->lo;
break;
case nsXPTType::T_U8 : *((uint32*) l_d) = l_s->val.u8; break;
case nsXPTType::T_U16 : *((uint32*) l_d) = l_s->val.u16; break;
case nsXPTType::T_U32 : *((uint32*) l_d) = l_s->val.u32; break;
case nsXPTType::T_FLOAT : *((float*) l_d) = l_s->val.f; break;
case nsXPTType::T_BOOL : *((PRBool*) l_d) = l_s->val.b; break;
case nsXPTType::T_CHAR : *((uint32*) l_d) = l_s->val.c; break;
case nsXPTType::T_WCHAR : *((int32*)l_d) = l_s->val.wc; break;
default:
// all the others are plain pointer types
*((void**)l_d) = l_s->val.p;
break;
}
}
return regCount;
}

View File

@ -1,130 +0,0 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* 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):
*/
/* Implement shared vtbl methods. */
#include "xptcprivate.h"
nsresult
PrepareAndDispatch(nsXPTCStubBase* self, uint32 methodIndex, PRUint32* args)
{
#define PARAM_BUFFER_COUNT 16
nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
nsXPTCMiniVariant* dispatchParams = NULL;
nsIInterfaceInfo* iface_info = NULL;
const nsXPTMethodInfo* info;
PRUint8 paramCount;
PRUint8 i;
nsresult result = NS_ERROR_FAILURE;
NS_ASSERTION(self,"no self");
self->GetInterfaceInfo(&iface_info);
NS_ASSERTION(iface_info,"no interface info");
iface_info->GetMethodInfo(PRUint16(methodIndex), &info);
NS_ASSERTION(info,"no interface info");
paramCount = info->GetParamCount();
// setup variant array pointer
if(paramCount > PARAM_BUFFER_COUNT)
dispatchParams = new nsXPTCMiniVariant[paramCount];
else
dispatchParams = paramBuffer;
NS_ASSERTION(dispatchParams,"no place for params");
PRUint32* ap = args;
for(i = 0; i < paramCount; i++, ap++)
{
const nsXPTParamInfo& param = info->GetParam(i);
const nsXPTType& type = param.GetType();
nsXPTCMiniVariant* dp = &dispatchParams[i];
if(param.IsOut() || !type.IsArithmetic())
{
dp->val.p = (void*) *ap;
continue;
}
// else
switch(type)
{
case nsXPTType::T_I8 : dp->val.i8 = *((PRInt8*) ap); break;
case nsXPTType::T_I16 : dp->val.i16 = *((PRInt16*) ap); break;
case nsXPTType::T_I32 : dp->val.i32 = *((PRInt32*) ap); break;
case nsXPTType::T_I64 : dp->val.i64 = *((PRInt64*) ap); ap++; break;
case nsXPTType::T_U8 : dp->val.u8 = *((PRUint8*) ap); break;
case nsXPTType::T_U16 : dp->val.u16 = *((PRUint16*)ap); break;
case nsXPTType::T_U32 : dp->val.u32 = *((PRUint32*)ap); break;
case nsXPTType::T_U64 : dp->val.u64 = *((PRUint64*)ap); ap++; break;
case nsXPTType::T_FLOAT : dp->val.f = *((float*) ap); break;
case nsXPTType::T_DOUBLE : dp->val.d = *((double*) ap); ap++; break;
case nsXPTType::T_BOOL : dp->val.b = *((PRBool*) ap); break;
case nsXPTType::T_CHAR : dp->val.c = *((char*) ap); break;
case nsXPTType::T_WCHAR : dp->val.wc = *((wchar_t*) ap); break;
default:
NS_ASSERTION(0, "bad type");
break;
}
}
result = self->CallMethod((PRUint16)methodIndex, info, dispatchParams);
NS_RELEASE(iface_info);
if(dispatchParams != paramBuffer)
delete [] dispatchParams;
return result;
}
/*
* These stubs move just move the values passed in registers onto the stack,
* so they are contiguous with values passed on the stack, and then calls
* PrepareAndDispatch() to do the dirty work.
*/
#define STUB_ENTRY(n) \
__asm__( \
".global _Stub"#n"__14nsXPTCStubBase\n\t" \
"_Stub"#n"__14nsXPTCStubBase:\n\t" \
"stmfd sp!, {r1, r2, r3} \n\t" \
"mov ip, sp \n\t" \
"stmfd sp!, {fp, ip, lr, pc} \n\t" \
"sub fp, ip, #4 \n\t" \
"mov r1, #"#n" \n\t" /* = methodIndex */ \
"add r2, sp, #16 \n\t" \
"bl _PrepareAndDispatch__FP14nsXPTCStubBaseUiPUi \n\t" \
"ldmea fp, {fp, sp, lr} \n\t" \
"add sp, sp, #12 \n\t" \
"mov pc, lr \n\t" \
);
#define SENTINEL_ENTRY(n) \
nsresult nsXPTCStubBase::Sentinel##n() \
{ \
NS_ASSERTION(0,"nsXPTCStubBase::Sentinel called"); \
return NS_ERROR_NOT_IMPLEMENTED; \
}
#include "xptcstubsdef.inc"

View File

@ -1,89 +0,0 @@
# -*- Mode: Asm -*-
#
# 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):
# Franz.Sirl-kernel@lauterbach.com (Franz Sirl)
# beard@netscape.com (Patrick Beard)
# waterson@netscape.com (Chris Waterson)
#
.set r0,0; .set sp,1; .set RTOC,2; .set r3,3; .set r4,4
.set r5,5; .set r6,6; .set r7,7; .set r8,8; .set r9,9
.set r10,10; .set r11,11; .set r12,12; .set r13,13; .set r14,14
.set r15,15; .set r16,16; .set r17,17; .set r18,18; .set r19,19
.set r20,20; .set r21,21; .set r22,22; .set r23,23; .set r24,24
.set r25,25; .set r26,26; .set r27,27; .set r28,28; .set r29,29
.set r30,30; .set r31,31
.set f0,0; .set f1,1; .set f2,2; .set f3,3; .set f4,4
.set f5,5; .set f6,6; .set f7,7; .set f8,8; .set f9,9
.set f10,10; .set f11,11; .set f12,12; .set f13,13; .set f14,14
.set f15,15; .set f16,16; .set f17,17; .set f18,18; .set f19,19
.set f20,20; .set f21,21; .set f22,22; .set f23,23; .set f24,24
.set f25,25; .set f26,26; .set f27,27; .set f28,28; .set f29,29
.set f30,30; .set f31,31
.section ".text"
.align 2
.globl SharedStub
.type SharedStub,@function
SharedStub:
stwu sp,-112(sp) # room for
# linkage (8),
# gprData (32),
# fprData (64),
# stack alignment(8)
mflr r0
stw r0,116(sp) # save LR backchain
stw r4,12(sp) # save GP registers
stw r5,16(sp) # (n.b. that we don't save r3
stw r6,20(sp) # because PrepareAndDispatch() is savvy)
stw r7,24(sp)
stw r8,28(sp)
stw r9,32(sp)
stw r10,36(sp)
stfd f1,40(sp) # save FP registers
stfd f2,48(sp)
stfd f3,56(sp)
stfd f4,64(sp)
stfd f5,72(sp)
stfd f6,80(sp)
stfd f7,88(sp)
stfd f8,96(sp)
# r3 has the 'self' pointer already
mr r4,r11 # r4 <= methodIndex selector, passed
# via r11 in the nsXPTCStubBase::StubXX() call
addi r5,sp,120 # r5 <= pointer to callers args area,
# beyond r3-r10/f1-f8 mapped range
addi r6,sp,8 # r6 <= gprData
addi r7,sp,40 # r7 <= fprData
bl PrepareAndDispatch@local # Go!
lwz r0,116(sp) # restore LR
mtlr r0
la sp,112(sp) # clean up the stack
blr

View File

@ -1,65 +0,0 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* 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):
*/
.global SharedStub
/*
in the frame for the function that called SharedStub are the
rest of the parameters we need
*/
SharedStub:
! we don't create a new frame yet, but work within the frame of the calling
! function to give ourselves the other parameters we want
mov %o0, %o1 ! shuffle the index up to 2nd place
mov %i0, %o0 ! the original 'this'
add %fp, 72, %o2 ! previous stack top adjusted to the first argument slot (beyond 'this')
! save off the original incoming parameters that arrived in
! registers, the ABI guarantees the space for us to do this
st %i1, [%fp + 72]
st %i2, [%fp + 76]
st %i3, [%fp + 80]
st %i4, [%fp + 84]
st %i5, [%fp + 88]
! now we can build our own stack frame
save %sp,-(64 + 32),%sp ! room for the register window and
! struct pointer, rounded up to 0 % 32
! our function now appears to have been called
! as SharedStub(nsISupports* that, PRUint32 index, PRUint32* args)
! so we can just copy these through
mov %i0, %o0
mov %i1, %o1
mov %i2, %o2
call PrepareAndDispatch
nop
mov %o0,%i0 ! propogate return value
b .LL1
nop
.LL1:
ret
restore
.size SharedStub, .-SharedStub
.type SharedStub, #function

View File

@ -1,202 +0,0 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* 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):
* Franz.Sirl-kernel@lauterbach.com (Franz Sirl)
* beard@netscape.com (Patrick Beard)
* waterson@netscape.com (Chris Waterson)
*/
// Implement shared vtbl methods.
#include "xptcprivate.h"
// The Linux/PPC ABI (aka PPC/SYSV ABI) passes the first 8 integral
// parameters and the first 8 floating point parameters in registers
// (r3-r10 and f1-f8), no stack space is allocated for these by the
// caller. The rest of the parameters are passed in the callers stack
// area. The stack pointer has to retain 16-byte alignment, longlongs
// and doubles are aligned on 8-byte boundaries.
#define PARAM_BUFFER_COUNT 16
#define GPR_COUNT 8
#define FPR_COUNT 8
// PrepareAndDispatch() is called by SharedStub() and calls the actual method.
//
// - 'args[]' contains the arguments passed on stack
// - 'gprData[]' contains the arguments passed in integer registers
// - 'fprData[]' contains the arguments passed in floating point registers
//
// The parameters are mapped into an array of type 'nsXPTCMiniVariant'
// and then the method gets called.
extern "C" nsresult
PrepareAndDispatch(nsXPTCStubBase* self,
PRUint32 methodIndex,
PRUint32* args,
PRUint32 *gprData,
double *fprData)
{
nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
nsXPTCMiniVariant* dispatchParams = NULL;
nsIInterfaceInfo* iface_info = NULL;
const nsXPTMethodInfo* info;
PRUint32 paramCount;
PRUint32 i;
nsresult result = NS_ERROR_FAILURE;
NS_ASSERTION(self,"no self");
self->GetInterfaceInfo(&iface_info);
NS_ASSERTION(iface_info,"no interface info");
if (! iface_info)
return NS_ERROR_UNEXPECTED;
iface_info->GetMethodInfo(PRUint16(methodIndex), &info);
NS_ASSERTION(info,"no method info");
if (! info)
return NS_ERROR_UNEXPECTED;
paramCount = info->GetParamCount();
// setup variant array pointer
if(paramCount > PARAM_BUFFER_COUNT)
dispatchParams = new nsXPTCMiniVariant[paramCount];
else
dispatchParams = paramBuffer;
NS_ASSERTION(dispatchParams,"no place for params");
if (! dispatchParams)
return NS_ERROR_OUT_OF_MEMORY;
PRUint32* ap = args;
PRUint32 gpr = 1; // skip one GPR register
PRUint32 fpr = 0;
PRUint32 tempu32;
PRUint64 tempu64;
for(i = 0; i < paramCount; i++) {
const nsXPTParamInfo& param = info->GetParam(i);
const nsXPTType& type = param.GetType();
nsXPTCMiniVariant* dp = &dispatchParams[i];
if (!param.IsOut() && type == nsXPTType::T_DOUBLE) {
if (fpr < FPR_COUNT)
dp->val.d = fprData[fpr++];
else {
if ((PRUint32) ap & 4) ap++; // doubles are 8-byte aligned on stack
dp->val.d = *(double*) ap;
ap += 2;
if (gpr < GPR_COUNT)
gpr += 2;
}
continue;
}
else if (!param.IsOut() && type == nsXPTType::T_FLOAT) {
if (fpr < FPR_COUNT)
dp->val.f = (float) fprData[fpr++]; // in registers floats are passed as doubles
else {
dp->val.f = *(float*) ap;
ap += 1;
if (gpr < GPR_COUNT)
gpr += 1;
}
continue;
}
else if (!param.IsOut() && (type == nsXPTType::T_I64
|| type == nsXPTType::T_U64)) {
if (gpr & 1) gpr++; // longlongs are aligned in odd/even register pairs, eg. r5/r6
if ((gpr + 1) < GPR_COUNT) {
tempu64 = *(PRUint64*) &gprData[gpr];
gpr += 2;
}
else {
if ((PRUint32) ap & 4) ap++; // longlongs are 8-byte aligned on stack
tempu64 = *(PRUint64*) ap;
ap += 2;
}
}
else {
if (gpr < GPR_COUNT)
tempu32 = gprData[gpr++];
else
tempu32 = *ap++;
}
if(param.IsOut() || !type.IsArithmetic()) {
dp->val.p = (void*) tempu32;
continue;
}
switch(type) {
case nsXPTType::T_I8: dp->val.i8 = (PRInt8) tempu32; break;
case nsXPTType::T_I16: dp->val.i16 = (PRInt16) tempu32; break;
case nsXPTType::T_I32: dp->val.i32 = (PRInt32) tempu32; break;
case nsXPTType::T_I64: dp->val.i64 = (PRInt64) tempu64; break;
case nsXPTType::T_U8: dp->val.u8 = (PRUint8) tempu32; break;
case nsXPTType::T_U16: dp->val.u16 = (PRUint16) tempu32; break;
case nsXPTType::T_U32: dp->val.u32 = (PRUint32) tempu32; break;
case nsXPTType::T_U64: dp->val.u64 = (PRUint64) tempu64; break;
case nsXPTType::T_BOOL: dp->val.b = (PRBool) tempu32; break;
case nsXPTType::T_CHAR: dp->val.c = (char) tempu32; break;
case nsXPTType::T_WCHAR: dp->val.wc = (wchar_t) tempu32; break;
default:
NS_ASSERTION(0, "bad type");
break;
}
}
result = self->CallMethod((PRUint16) methodIndex, info, dispatchParams);
NS_RELEASE(iface_info);
if (dispatchParams != paramBuffer)
delete [] dispatchParams;
return result;
}
// Load r11 with the constant 'n' and branch to SharedStub().
//
// XXX Yes, it's ugly that we're relying on gcc's name-mangling here;
// however, it's quick, dirty, and'll break when the ABI changes on
// us, which is what we want ;-).
#define STUB_ENTRY(n) \
__asm__ ( \
".section \".text\" \n\t" \
".align 2 \n\t" \
".globl Stub"#n"__14nsXPTCStubBase \n\t" \
".type Stub"#n"__14nsXPTCStubBase,@function \n\n" \
\
"Stub"#n"__14nsXPTCStubBase: \n\t" \
"li 11,"#n" \n\t" \
"b SharedStub@local \n" \
);
#define SENTINEL_ENTRY(n) \
nsresult nsXPTCStubBase::Sentinel##n() \
{ \
NS_ASSERTION(0,"nsXPTCStubBase::Sentinel called"); \
return NS_ERROR_NOT_IMPLEMENTED; \
}
#include "xptcstubsdef.inc"

View File

@ -1,131 +0,0 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* 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):
*/
/* Implement shared vtbl methods. */
#include "xptcprivate.h"
#if defined(sparc) || defined(__sparc__)
extern "C" nsresult
PrepareAndDispatch(nsXPTCStubBase* self, uint32 methodIndex, uint32* args)
{
typedef struct {
uint32 hi;
uint32 lo;
} DU; // have to move 64 bit entities as 32 bit halves since
// stack slots are not guaranteed 16 byte aligned
#define PARAM_BUFFER_COUNT 16
nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
nsXPTCMiniVariant* dispatchParams = NULL;
nsIInterfaceInfo* iface_info = NULL;
const nsXPTMethodInfo* info;
PRUint8 paramCount;
PRUint8 i;
nsresult result = NS_ERROR_FAILURE;
NS_ASSERTION(self,"no self");
self->GetInterfaceInfo(&iface_info);
NS_ASSERTION(iface_info,"no interface info");
iface_info->GetMethodInfo(PRUint16(methodIndex), &info);
NS_ASSERTION(info,"no interface info");
paramCount = info->GetParamCount();
// setup variant array pointer
if(paramCount > PARAM_BUFFER_COUNT)
dispatchParams = new nsXPTCMiniVariant[paramCount];
else
dispatchParams = paramBuffer;
NS_ASSERTION(dispatchParams,"no place for params");
PRUint32* ap = args;
for(i = 0; i < paramCount; i++, ap++)
{
const nsXPTParamInfo& param = info->GetParam(i);
const nsXPTType& type = param.GetType();
nsXPTCMiniVariant* dp = &dispatchParams[i];
if(param.IsOut() || !type.IsArithmetic())
{
dp->val.p = (void*) *ap;
continue;
}
// else
switch(type)
{
case nsXPTType::T_I8 : dp->val.i8 = *((PRInt32*) ap); break;
case nsXPTType::T_I16 : dp->val.i16 = *((PRInt32*) ap); break;
case nsXPTType::T_I32 : dp->val.i32 = *((PRInt32*) ap); break;
case nsXPTType::T_DOUBLE :
case nsXPTType::T_U64 :
case nsXPTType::T_I64 : ((DU *)dp)->hi = ((DU *)ap)->hi;
((DU *)dp)->lo = ((DU *)ap)->lo;
ap++;
break;
case nsXPTType::T_U8 : dp->val.u8 = *((PRUint32*) ap); break;
case nsXPTType::T_U16 : dp->val.u16 = *((PRUint32*)ap); break;
case nsXPTType::T_U32 : dp->val.u32 = *((PRUint32*)ap); break;
case nsXPTType::T_FLOAT : dp->val.f = *((float*) ap); break;
case nsXPTType::T_BOOL : dp->val.b = *((PRBool*) ap); break;
case nsXPTType::T_CHAR : dp->val.c = *((PRUint32*) ap); break;
case nsXPTType::T_WCHAR : dp->val.wc = *((PRInt32*) ap); break;
default:
NS_ASSERTION(0, "bad type");
break;
}
}
result = self->CallMethod((PRUint16)methodIndex, info, dispatchParams);
NS_RELEASE(iface_info);
if(dispatchParams != paramBuffer)
delete [] dispatchParams;
return result;
}
extern "C" int SharedStub(int, int*);
#define STUB_ENTRY(n) \
nsresult nsXPTCStubBase::Stub##n() \
{ \
int dummy; /* defeat tail-call optimization */ \
return SharedStub(n, &dummy); \
}
#define SENTINEL_ENTRY(n) \
nsresult nsXPTCStubBase::Sentinel##n() \
{ \
NS_ASSERTION(0,"nsXPTCStubBase::Sentinel called"); \
return NS_ERROR_NOT_IMPLEMENTED; \
}
#include "xptcstubsdef.inc"
#endif /* sparc || __sparc__ */