зеркало из https://github.com/mozilla/gecko-dev.git
Merge m-i to m-c.
This commit is contained in:
Коммит
b5a2c9c036
|
@ -4,7 +4,6 @@ dnl The contents of this file are under the Public Domain.
|
|||
dnl
|
||||
|
||||
builtin(include, build/autoconf/glib.m4)dnl
|
||||
builtin(include, build/autoconf/libIDL.m4)dnl
|
||||
builtin(include, build/autoconf/nspr.m4)dnl
|
||||
builtin(include, build/autoconf/nss.m4)dnl
|
||||
builtin(include, build/autoconf/pkg.m4)dnl
|
||||
|
|
|
@ -4177,6 +4177,11 @@
|
|||
aMenuitem.removeAttribute("busy");
|
||||
}
|
||||
|
||||
if (aTab.hasAttribute("pending"))
|
||||
aMenuitem.setAttribute("pending", aTab.getAttribute("pending"));
|
||||
else
|
||||
aMenuitem.removeAttribute("pending");
|
||||
|
||||
if (aTab.selected)
|
||||
aMenuitem.setAttribute("selected", "true");
|
||||
else
|
||||
|
|
|
@ -2825,6 +2825,7 @@ SessionStoreService.prototype = {
|
|||
// a tab gets closed before it's been properly restored
|
||||
browser.__SS_data = tabData;
|
||||
browser.__SS_restoreState = TAB_STATE_NEEDS_RESTORE;
|
||||
tab.setAttribute("pending", "true");
|
||||
|
||||
// Make sure that set/getTabValue will set/read the correct data by
|
||||
// wiping out any current value in tab.__SS_extdata.
|
||||
|
@ -3007,6 +3008,7 @@ SessionStoreService.prototype = {
|
|||
|
||||
// Set this tab's state to restoring
|
||||
browser.__SS_restoreState = TAB_STATE_RESTORING;
|
||||
aTab.removeAttribute("pending");
|
||||
|
||||
// Remove the history listener, since we no longer need it once we start restoring
|
||||
this._removeSHistoryListener(aTab);
|
||||
|
|
|
@ -152,6 +152,7 @@ _BROWSER_TEST_FILES = \
|
|||
browser_645428.js \
|
||||
browser_659591.js \
|
||||
browser_662812.js \
|
||||
browser_682507.js \
|
||||
$(NULL)
|
||||
|
||||
ifneq ($(OS_ARCH),Darwin)
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
function test() {
|
||||
Services.prefs.setBoolPref("browser.sessionstore.restore_on_demand", true);
|
||||
gBrowser.addTab("about:mozilla");
|
||||
|
||||
ss.setTabState(gBrowser.tabs[1], ss.getTabState(gBrowser.tabs[1]));
|
||||
ok(gBrowser.tabs[1].hasAttribute("pending"), "second tab should have 'pending' attribute");
|
||||
|
||||
gBrowser.selectedTab = gBrowser.tabs[1];
|
||||
ok(!gBrowser.tabs[1].hasAttribute("pending"), "second tab should have not 'pending' attribute");
|
||||
|
||||
gBrowser.removeTab(gBrowser.tabs[1]);
|
||||
Services.prefs.clearUserPref("browser.sessionstore.restore_on_demand");
|
||||
}
|
|
@ -1,194 +0,0 @@
|
|||
# Configure paths for LIBIDL
|
||||
|
||||
dnl AM_PATH_LIBIDL([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, MODULES]]]])
|
||||
dnl Test for LIBIDL, and define LIBIDL_CFLAGS and LIBIDL_LIBS
|
||||
dnl
|
||||
AC_DEFUN([AM_PATH_LIBIDL],
|
||||
[dnl
|
||||
dnl Get the cflags and libraries from the libIDL-config script
|
||||
dnl
|
||||
AC_ARG_WITH(libIDL-prefix,[ --with-libIDL-prefix=PFX
|
||||
Prefix where libIDL is installed (optional)],
|
||||
libIDL_config_prefix="$withval", libIDL_config_prefix="")
|
||||
AC_ARG_WITH(libIDL-exec-prefix,[ --with-libIDL-exec-prefix=PFX
|
||||
Exec prefix where libIDL is installed (optional)],
|
||||
libIDL_config_exec_prefix="$withval", libIDL_config_exec_prefix="")
|
||||
AC_ARG_ENABLE(libIDLtest, [ --disable-libIDLtest Do not try to compile and run a test libIDL program],
|
||||
, enable_libIDLtest=yes)
|
||||
|
||||
if test x$libIDL_config_exec_prefix != x ; then
|
||||
libIDL_config_args="$libIDL_config_args --exec-prefix=$libIDL_config_exec_prefix"
|
||||
if test x${HOST_LIBIDL_CONFIG+set} != xset ; then
|
||||
HOST_LIBIDL_CONFIG=$libIDL_config_exec_prefix/bin/libIDL-config
|
||||
fi
|
||||
fi
|
||||
if test x$libIDL_config_prefix != x ; then
|
||||
libIDL_config_args="$libIDL_config_args --prefix=$libIDL_config_prefix"
|
||||
if test x${HOST_LIBIDL_CONFIG+set} != xset ; then
|
||||
HOST_LIBIDL_CONFIG=$libIDL_config_prefix/bin/libIDL-config
|
||||
fi
|
||||
fi
|
||||
|
||||
AM_PATH_GLIB(1.2.0)
|
||||
|
||||
dnl Force a version check to keep upgraded versions from being overridden by the cached value.
|
||||
unset ac_cv_path_LIBIDL_CONFIG
|
||||
|
||||
AC_PATH_PROG(HOST_LIBIDL_CONFIG, libIDL-config, no)
|
||||
min_libIDL_version=ifelse([$1], ,0.6.0,$1)
|
||||
AC_MSG_CHECKING(for libIDL - version >= $min_libIDL_version)
|
||||
no_libIDL=""
|
||||
if test "$HOST_LIBIDL_CONFIG" = "no" ; then
|
||||
no_libIDL=yes
|
||||
else
|
||||
HOST_LIBIDL_CFLAGS=`$HOST_LIBIDL_CONFIG $libIDL_config_args --cflags`
|
||||
HOST_LIBIDL_LIBS=`$HOST_LIBIDL_CONFIG $libIDL_config_args --libs`
|
||||
libIDL_config_major_version=`$HOST_LIBIDL_CONFIG $libIDL_config_args --version | \
|
||||
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
|
||||
libIDL_config_minor_version=`$HOST_LIBIDL_CONFIG $libIDL_config_args --version | \
|
||||
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
|
||||
libIDL_config_micro_version=`$HOST_LIBIDL_CONFIG $libIDL_config_args --version | \
|
||||
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
|
||||
if test "x$enable_libIDLtest" = "xyes" ; then
|
||||
ac_save_CFLAGS="$CFLAGS"
|
||||
ac_save_LIBS="$LIBS"
|
||||
CFLAGS="$CFLAGS $HOST_LIBIDL_CFLAGS"
|
||||
LIBS="$HOST_LIBIDL_LIBS $LIBS"
|
||||
dnl
|
||||
dnl Now check if the installed LIBIDL is sufficiently new.
|
||||
dnl
|
||||
rm -f conf.libIDLtest
|
||||
AC_TRY_RUN([
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <libIDL/IDL.h>
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
int major, minor, micro;
|
||||
int libIDL_major_version;
|
||||
int libIDL_minor_version;
|
||||
int libIDL_micro_version;
|
||||
char *tmp_version;
|
||||
|
||||
system ("touch conf.libIDLtest");
|
||||
|
||||
/* HP/UX 9 (%@#!) writes to sscanf strings */
|
||||
tmp_version = g_strdup ("$min_libIDL_version");
|
||||
if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) {
|
||||
printf("%s, bad version string\n", "$min_libIDL_version");
|
||||
exit(1);
|
||||
}
|
||||
tmp_version = g_strdup (IDL_get_libver_string ());
|
||||
if (sscanf(tmp_version, "%d.%d.%d",
|
||||
&libIDL_major_version,
|
||||
&libIDL_minor_version,
|
||||
&libIDL_micro_version) != 3) {
|
||||
printf("%s, bad version string\n", tmp_version);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if ((libIDL_major_version != $libIDL_config_major_version) ||
|
||||
(libIDL_minor_version != $libIDL_config_minor_version) ||
|
||||
(libIDL_micro_version != $libIDL_config_micro_version))
|
||||
{
|
||||
printf("\n*** 'libIDL-config --version' returned %d.%d.%d, but libIDL (%d.%d.%d)\n",
|
||||
$libIDL_config_major_version, $libIDL_config_minor_version, $libIDL_config_micro_version,
|
||||
libIDL_major_version, libIDL_minor_version, libIDL_micro_version);
|
||||
printf ("*** was found! If libIDL-config was correct, then it is best\n");
|
||||
printf ("*** to remove the old version of LIBIDL. You may also be able to fix the error\n");
|
||||
printf("*** by modifying your LD_LIBRARY_PATH environment variable, or by editing\n");
|
||||
printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n");
|
||||
printf("*** required on your system.\n");
|
||||
printf("*** If libIDL-config was wrong, set the environment variable LIBIDL_CONFIG\n");
|
||||
printf("*** to point to the correct copy of libIDL-config, and remove the file config.cache\n");
|
||||
printf("*** before re-running configure\n");
|
||||
}
|
||||
else if ((libIDL_major_version != LIBIDL_MAJOR_VERSION) ||
|
||||
(libIDL_minor_version != LIBIDL_MINOR_VERSION) ||
|
||||
(libIDL_micro_version != LIBIDL_MICRO_VERSION))
|
||||
{
|
||||
printf("\n*** libIDL header files (version %d.%d.%d) do not match\n",
|
||||
LIBIDL_MAJOR_VERSION, LIBIDL_MINOR_VERSION, LIBIDL_MICRO_VERSION);
|
||||
printf("*** library (version %d.%d.%d)\n",
|
||||
libIDL_major_version, libIDL_minor_version, libIDL_micro_version);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((libIDL_major_version > major) ||
|
||||
((libIDL_major_version == major) && (libIDL_minor_version > minor)) ||
|
||||
((libIDL_major_version == major) && (libIDL_minor_version == minor) && (libIDL_micro_version >= micro)))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("\n*** An old version of libIDL (%d.%d.%d) was found.\n",
|
||||
libIDL_major_version, libIDL_minor_version, libIDL_micro_version);
|
||||
printf("*** You need at least libIDL version %d.%d.%d.\n",
|
||||
major, minor, micro);
|
||||
printf("***\n");
|
||||
printf("*** If you have already installed a sufficiently new version, this error\n");
|
||||
printf("*** probably means that the wrong copy of the libIDL-config shell script is\n");
|
||||
printf("*** being found. The easiest way to fix this is to remove the old version\n");
|
||||
printf("*** of libIDL, but you can also set the LIBIDL_CONFIG environment to point to the\n");
|
||||
printf("*** correct copy of libIDL-config. (In this case, you will have to\n");
|
||||
printf("*** modify your LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf\n");
|
||||
printf("*** so that the correct libraries are found at run-time))\n");
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
],, no_libIDL=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
|
||||
CFLAGS="$ac_save_CFLAGS"
|
||||
LIBS="$ac_save_LIBS"
|
||||
fi
|
||||
fi
|
||||
if test "x$no_libIDL" = x ; then
|
||||
AC_MSG_RESULT(yes)
|
||||
ifelse([$2], , :, [$2])
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
if test "$HOST_LIBIDL_CONFIG" = "no" ; then
|
||||
echo "*** The libIDL-config script installed by libIDL could not be found"
|
||||
echo "*** If libIDL was installed in PREFIX, make sure PREFIX/bin is in"
|
||||
echo "*** your path, or set the LIBIDL_CONFIG environment variable to the"
|
||||
echo "*** full path to libIDL-config."
|
||||
else
|
||||
if test -f conf.libIDLtest ; then
|
||||
:
|
||||
else
|
||||
echo "*** Could not run libIDL test program, checking why..."
|
||||
CFLAGS="$CFLAGS $HOST_LIBIDL_CFLAGS"
|
||||
LIBS="$LIBS $HOST_LIBIDL_LIBS"
|
||||
AC_TRY_LINK([
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <libIDL/IDL.h>
|
||||
], [ return IDL_get_libver_string ? 1 : 0; ],
|
||||
[ echo "*** The test program compiled, but did not run. This usually means"
|
||||
echo "*** that the run-time linker is not finding libIDL or finding the wrong"
|
||||
echo "*** version of LIBIDL. If it is not finding libIDL, you'll need to set your"
|
||||
echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
|
||||
echo "*** to the installed location Also, make sure you have run ldconfig if that"
|
||||
echo "*** is required on your system"
|
||||
echo "***"
|
||||
echo "*** If you have an old version installed, it is best to remove it, although"
|
||||
echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" ],
|
||||
[ echo "*** The test program failed to compile or link. See the file config.log for the"
|
||||
echo "*** exact error that occurred. This usually means libIDL was incorrectly installed"
|
||||
echo "*** or that you have moved libIDL since it was installed. In the latter case, you"
|
||||
echo "*** may want to edit the libIDL-config script: $LIBIDL_CONFIG" ])
|
||||
CFLAGS="$ac_save_CFLAGS"
|
||||
LIBS="$ac_save_LIBS"
|
||||
fi
|
||||
fi
|
||||
HOST_LIBIDL_CFLAGS=""
|
||||
HOST_LIBIDL_LIBS=""
|
||||
ifelse([$3], , :, [$3])
|
||||
fi
|
||||
AC_SUBST(HOST_LIBIDL_CFLAGS)
|
||||
AC_SUBST(HOST_LIBIDL_LIBS)
|
||||
rm -f conf.libIDLtest
|
||||
])
|
|
@ -400,10 +400,6 @@ HOST_LD = @HOST_LD@
|
|||
HOST_RANLIB = @HOST_RANLIB@
|
||||
HOST_BIN_SUFFIX = @HOST_BIN_SUFFIX@
|
||||
|
||||
HOST_LIBIDL_CONFIG = @HOST_LIBIDL_CONFIG@
|
||||
HOST_LIBIDL_CFLAGS = @HOST_LIBIDL_CFLAGS@
|
||||
HOST_LIBIDL_LIBS = @HOST_LIBIDL_LIBS@
|
||||
|
||||
HOST_OS_ARCH = @HOST_OS_ARCH@
|
||||
host_cpu = @host_cpu@
|
||||
host_vendor = @host_vendor@
|
||||
|
@ -578,9 +574,6 @@ MOZ_ALSA_LIBS = @MOZ_ALSA_LIBS@
|
|||
GLIB_CFLAGS = @GLIB_CFLAGS@
|
||||
GLIB_LIBS = @GLIB_LIBS@
|
||||
GLIB_GMODULE_LIBS = @GLIB_GMODULE_LIBS@
|
||||
LIBIDL_CFLAGS = @LIBIDL_CFLAGS@
|
||||
LIBIDL_LIBS = @LIBIDL_LIBS@
|
||||
STATIC_LIBIDL = @STATIC_LIBIDL@
|
||||
|
||||
MOZ_NATIVE_MAKEDEPEND = @SYSTEM_MAKEDEPEND@
|
||||
|
||||
|
|
|
@ -308,7 +308,6 @@ hlink.h
|
|||
ia64/sys/inline.h
|
||||
Icons.h
|
||||
iconv.h
|
||||
IDL.h
|
||||
ieeefp.h
|
||||
ifaddrs.h
|
||||
image.h
|
||||
|
@ -404,7 +403,6 @@ libgnomevfs/gnome-vfs-mime-handlers.h
|
|||
libgnomevfs/gnome-vfs-mime-utils.h
|
||||
libgnomevfs/gnome-vfs-ops.h
|
||||
libgnomevfs/gnome-vfs-standard-callbacks.h
|
||||
libIDL/IDL.h
|
||||
lib$routines.h
|
||||
libnotify/notify.h
|
||||
limits
|
||||
|
|
208
configure.in
208
configure.in
|
@ -116,7 +116,6 @@ NSS_VERSION=3
|
|||
dnl Set the minimum version of toolkit libs used by mozilla
|
||||
dnl ========================================================
|
||||
GLIB_VERSION=1.2.0
|
||||
LIBIDL_VERSION=0.6.3
|
||||
PERL_VERSION=5.006
|
||||
PYTHON_VERSION=2.5
|
||||
CAIRO_VERSION=1.10
|
||||
|
@ -7831,207 +7830,8 @@ dnl =
|
|||
dnl ========================================================
|
||||
MOZ_ARG_HEADER(Standalone module options (Not for building Mozilla))
|
||||
|
||||
dnl Check for GLib and libIDL.
|
||||
dnl Check for GLib.
|
||||
dnl ========================================================
|
||||
SKIP_IDL_CHECK="no"
|
||||
|
||||
if test -z "$COMPILE_ENVIRONMENT"; then
|
||||
SKIP_IDL_CHECK="yes"
|
||||
fi
|
||||
|
||||
dnl = Allow users to disable libIDL checking for standalone modules
|
||||
MOZ_ARG_WITHOUT_BOOL(libIDL,
|
||||
[ --without-libIDL Skip check for libIDL (standalone modules only)],
|
||||
SKIP_IDL_CHECK="yes")
|
||||
|
||||
if test -z "$CROSS_COMPILE"; then
|
||||
if test -z "$HOST_LIBIDL_CONFIG"; then
|
||||
HOST_LIBIDL_CONFIG="$LIBIDL_CONFIG"
|
||||
fi
|
||||
if test -z "$HOST_LIBIDL_PREFIX"; then
|
||||
HOST_LIBIDL_PREFIX="$LIBIDL_PREFIX"
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "$SKIP_IDL_CHECK" = "no"
|
||||
then
|
||||
_LIBIDL_FOUND=
|
||||
case "$host" in
|
||||
*-mingw*)
|
||||
if test -n "$GLIB_PREFIX"; then
|
||||
_GLIB_PREFIX_DIR=`cd $GLIB_PREFIX && pwd -W`
|
||||
if test "$?" = "0"; then
|
||||
if test `echo ${PATH}: | grep -ic "$_GLIB_PREFIX_DIR/bin:"` = 0; then
|
||||
AC_MSG_ERROR([GLIB_PREFIX must be in your \$PATH.])
|
||||
fi
|
||||
else
|
||||
AC_MSG_ERROR([GLIB_PREFIX is set but "${GLIB_PREFIX}" is not a directory.])
|
||||
fi
|
||||
else
|
||||
_GLIB_PREFIX_DIR=$MOZ_TOOLS_DIR
|
||||
fi
|
||||
if test ! -f "${_GLIB_PREFIX_DIR}/include/glib.h"; then
|
||||
AC_MSG_ERROR([Cannot find $_GLIB_PREFIX_DIR/include/glib.h .])
|
||||
fi
|
||||
GLIB_CFLAGS="-I${_GLIB_PREFIX_DIR}/include"
|
||||
if test -f "${_GLIB_PREFIX_DIR}/lib/glib-1.2_s.lib"; then
|
||||
GLIB_LIBS="${_GLIB_PREFIX_DIR}/lib/glib-1.2_s.lib"
|
||||
elif test -f "${_GLIB_PREFIX_DIR}/lib/glib-1.2.lib"; then
|
||||
GLIB_LIBS="${_GLIB_PREFIX_DIR}/lib/glib-1.2.lib"
|
||||
else
|
||||
AC_MSG_ERROR([Cannot find $_GLIB_PREFIX_DIR/lib/glib-1.2.lib or $_GLIB_PREFIX_DIR/lib/glib-1.2_s.lib])
|
||||
fi
|
||||
|
||||
if test -n "$HOST_LIBIDL_PREFIX"; then
|
||||
_LIBIDL_PREFIX_DIR=`cd $HOST_LIBIDL_PREFIX && pwd -W`
|
||||
if test "$?" = "0"; then
|
||||
if test `echo ${PATH}: | grep -ic "$_LIBIDL_PREFIX_DIR/bin:"` = 0; then
|
||||
AC_MSG_ERROR([LIBIDL_PREFIX must be in your \$PATH.])
|
||||
fi
|
||||
else
|
||||
AC_MSG_ERROR([LIBIDL_PREFIX is set but "${LIBIDL_PREFIX}" is not a directory.])
|
||||
fi
|
||||
else
|
||||
_LIBIDL_PREFIX_DIR=$MOZ_TOOLS_DIR
|
||||
fi
|
||||
if test ! -f "${_LIBIDL_PREFIX_DIR}/include/libIDL/IDL.h"; then
|
||||
AC_MSG_ERROR([Cannot find $_LIBIDL_PREFIX_DIR/include/libIDL/IDL.h .])
|
||||
fi
|
||||
HOST_LIBIDL_CFLAGS="-I${_LIBIDL_PREFIX_DIR}/include ${GLIB_CFLAGS}"
|
||||
if test -f "${_LIBIDL_PREFIX_DIR}/lib/libidl-0.6_s.lib"; then
|
||||
HOST_LIBIDL_LIBS="${_LIBIDL_PREFIX_DIR}/lib/libidl-0.6_s.lib"
|
||||
STATIC_LIBIDL=1
|
||||
elif test -f "${_LIBIDL_PREFIX_DIR}/lib/libidl-0.6.lib"; then
|
||||
HOST_LIBIDL_LIBS="${_LIBIDL_PREFIX_DIR}/lib/libidl-0.6.lib"
|
||||
else
|
||||
AC_MSG_ERROR([Cannot find $_LIBIDL_PREFIX_DIR/lib/libidl-0.6.lib or $_LIBIDL_PREFIX_DIR/lib/libidl-0.6_s.lib])
|
||||
fi
|
||||
HOST_LIBIDL_LIBS="${HOST_LIBIDL_LIBS} ${GLIB_LIBS}"
|
||||
_LIBIDL_FOUND=1
|
||||
;;
|
||||
esac
|
||||
|
||||
if test -z "$_LIBIDL_FOUND"; then
|
||||
if test "$MACOS_SDK_DIR"; then
|
||||
dnl xpidl, and therefore libIDL, is only needed on the build host.
|
||||
dnl Don't build it against the SDK, as that causes problems.
|
||||
_MACSAVE_CFLAGS="$CFLAGS"
|
||||
_MACSAVE_LIBS="$LIBS"
|
||||
_MACSAVE_LDFLAGS="$LDFLAGS"
|
||||
_MACSAVE_NEXT_ROOT="$NEXT_ROOT"
|
||||
changequote(,)
|
||||
CFLAGS=`echo $CFLAGS|sed -E -e "s%((-I|-isystem )${MACOS_SDK_DIR}/usr/(include|lib/gcc)[^ ]*)|-F${MACOS_SDK_DIR}(/System)?/Library/Frameworks[^ ]*|-nostdinc[^ ]*|-isysroot ${MACOS_SDK_DIR}%%g"`
|
||||
LIBS=`echo $LIBS|sed -e "s?-L${MACOS_SDK_DIR}/usr/lib[^ ]*??g"`
|
||||
LDFLAGS=`echo $LDFLAGS|sed -e "s?-Wl,-syslibroot,${MACOS_SDK_DIR}??g"`
|
||||
changequote([,])
|
||||
unset NEXT_ROOT
|
||||
fi
|
||||
|
||||
PKG_CHECK_MODULES(HOST_LIBIDL, libIDL-2.0 >= 0.8.0 glib-2.0 gobject-2.0, _LIBIDL_FOUND=1,_LIBIDL_FOUND=)
|
||||
fi
|
||||
|
||||
dnl if no gtk/libIDL1 or gtk2/libIDL2 combination was found, fall back
|
||||
dnl to either libIDL1 or libIDL2.
|
||||
if test -z "$_LIBIDL_FOUND"; then
|
||||
AM_PATH_LIBIDL($LIBIDL_VERSION,_LIBIDL_FOUND=1)
|
||||
if test -z "$_LIBIDL_FOUND"; then
|
||||
PKG_CHECK_MODULES(HOST_LIBIDL, libIDL-2.0 >= 0.8.0,_LIBIDL_FOUND=1)
|
||||
fi
|
||||
fi
|
||||
dnl
|
||||
dnl If we don't have a libIDL config program & not cross-compiling,
|
||||
dnl look for orbit-config instead.
|
||||
dnl
|
||||
if test -z "$_LIBIDL_FOUND" -a -z "$CROSS_COMPILE"; then
|
||||
MOZ_PATH_PROGS(ORBIT_CONFIG, $ORBIT_CONFIG orbit-config)
|
||||
if test -n "$ORBIT_CONFIG"; then
|
||||
AC_MSG_CHECKING([for ORBit libIDL usability])
|
||||
_ORBIT_CFLAGS=`${ORBIT_CONFIG} client --cflags`
|
||||
_ORBIT_LIBS=`${ORBIT_CONFIG} client --libs`
|
||||
_ORBIT_INC_PATH=`${PERL} -e '{ for $f (@ARGV) { print "$f " if ($f =~ m/^-I/); } }' -- ${_ORBIT_CFLAGS}`
|
||||
_ORBIT_LIB_PATH=`${PERL} -e '{ for $f (@ARGV) { print "$f " if ($f =~ m/^-L/); } }' -- ${_ORBIT_LIBS}`
|
||||
HOST_LIBIDL_CFLAGS="$_ORBIT_INC_PATH"
|
||||
HOST_LIBIDL_LIBS="$_ORBIT_LIB_PATH -lIDL -lglib"
|
||||
HOST_LIBIDL_CONFIG=
|
||||
_SAVE_CFLAGS="$CFLAGS"
|
||||
_SAVE_LIBS="$LIBS"
|
||||
CFLAGS="$HOST_LIBIDL_CFLAGS $CFLAGS"
|
||||
LIBS="$HOST_LIBIDL_LIBS $LIBS"
|
||||
AC_TRY_RUN([
|
||||
#include <stdlib.h>
|
||||
#include <libIDL/IDL.h>
|
||||
int main() {
|
||||
char *s;
|
||||
s=strdup(IDL_get_libver_string());
|
||||
if(s==NULL) {
|
||||
exit(1);
|
||||
}
|
||||
exit(0);
|
||||
}
|
||||
], [_LIBIDL_FOUND=1
|
||||
result="yes"],
|
||||
[HOST_LIBIDL_CFLAGS=
|
||||
HOST_LIBIDL_LIBS=
|
||||
result="no"],
|
||||
[_LIBIDL_FOUND=1
|
||||
result="maybe"] )
|
||||
AC_MSG_RESULT($result)
|
||||
CFLAGS="$_SAVE_CFLAGS"
|
||||
LIBS="$_SAVE_LIBS"
|
||||
fi
|
||||
fi
|
||||
if test -z "$_LIBIDL_FOUND"; then
|
||||
AC_MSG_ERROR([libIDL not found.
|
||||
libIDL $LIBIDL_VERSION or higher is required.])
|
||||
fi
|
||||
if test "$MACOS_SDK_DIR"; then
|
||||
CFLAGS="$_MACSAVE_CFLAGS"
|
||||
LIBS="$_MACSAVE_LIBS"
|
||||
LDFLAGS="$_MACSAVE_LDFLAGS"
|
||||
if test -n "$_MACSAVE_NEXT_ROOT" ; then
|
||||
export NEXT_ROOT="$_MACSAVE_NEXT_ROOT"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if test -n "$CROSS_COMPILE"; then
|
||||
case "$target" in
|
||||
*-mingw*)
|
||||
if test -n "$GLIB_PREFIX"; then
|
||||
GLIB_CFLAGS="-I${GLIB_PREFIX}/include"
|
||||
if test -f "${GLIB_PREFIX}/lib/glib-1.2_s.lib"; then
|
||||
GLIB_LIBS="${GLIB_PREFIX}/lib/glib-1.2_s.lib"
|
||||
elif test -f "${GLIB_PREFIX}/lib/glib-1.2.lib"; then
|
||||
GLIB_LIBS="${GLIB_PREFIX}/lib/glib-1.2.lib"
|
||||
else
|
||||
AC_MSG_ERROR([Cannot find $GLIB_PREFIX/lib/glib-1.2.lib or $GLIB_PREFIX/lib/glib-1.2_s.lib])
|
||||
fi
|
||||
fi
|
||||
|
||||
if test -n "$LIBIDL_PREFIX"; then
|
||||
LIBIDL_CFLAGS="-I${LIBIDL_PREFIX}/include ${GLIB_CFLAGS}"
|
||||
if test -f "${LIBIDL_PREFIX}/lib/libIDL-0.6_s.lib"; then
|
||||
LIBIDL_LIBS="${LIBIDL_PREFIX}/lib/libIDL-0.6_s.lib"
|
||||
STATIC_LIBIDL=1
|
||||
elif test -f "${LIBIDL_PREFIX}/lib/libIDL-0.6.lib"; then
|
||||
LIBIDL_LIBS="${LIBIDL_PREFIX}/lib/libIDL-0.6.lib"
|
||||
else
|
||||
AC_MSG_ERROR([Cannot find $LIBIDL_PREFIX/lib/libIDL-0.6.lib or $LIBIDL_PREFIX/lib/libIDL-0.6_s.lib])
|
||||
fi
|
||||
fi
|
||||
LIBIDL_LIBS="${LIBIDL_LIBS} ${GLIB_LIBS}"
|
||||
;;
|
||||
*)
|
||||
if test -n "LIBIDL_CONFIG" -a "LIBIDL_CONFIG" != "no"; then
|
||||
LIBIDL_CFLAGS=`${LIBIDL_CONFIG} --cflags`
|
||||
LIBIDL_LIBS=`${LIBIDL_CONFIG} --libs`
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
else
|
||||
LIBIDL_CFLAGS="$HOST_LIBIDL_CFLAGS"
|
||||
LIBIDL_LIBS="$HOST_LIBIDL_LIBS"
|
||||
fi
|
||||
|
||||
if test -z "$SKIP_PATH_CHECKS"; then
|
||||
if test -z "${GLIB_CFLAGS}" -o -z "${GLIB_LIBS}" ; then
|
||||
|
@ -8050,15 +7850,9 @@ if test -z "${GLIB_GMODULE_LIBS}" \
|
|||
GLIB_GMODULE_LIBS=`$GLIB_CONFIG gmodule --libs`
|
||||
fi
|
||||
|
||||
AC_SUBST(LIBIDL_CFLAGS)
|
||||
AC_SUBST(LIBIDL_LIBS)
|
||||
AC_SUBST(STATIC_LIBIDL)
|
||||
AC_SUBST(GLIB_CFLAGS)
|
||||
AC_SUBST(GLIB_LIBS)
|
||||
AC_SUBST(GLIB_GMODULE_LIBS)
|
||||
AC_SUBST(HOST_LIBIDL_CONFIG)
|
||||
AC_SUBST(HOST_LIBIDL_CFLAGS)
|
||||
AC_SUBST(HOST_LIBIDL_LIBS)
|
||||
|
||||
dnl ========================================================
|
||||
dnl Check for cairo
|
||||
|
|
|
@ -71,3 +71,11 @@ DEPRECATED_OPERATION(IsSupported)
|
|||
DEPRECATED_OPERATION(IsEqualNode)
|
||||
DEPRECATED_OPERATION(TextContent)
|
||||
DEPRECATED_OPERATION(EnablePrivilege)
|
||||
DEPRECATED_OPERATION(IsSameNode)
|
||||
DEPRECATED_OPERATION(ReplaceWholeText)
|
||||
DEPRECATED_OPERATION(GlobalStorage)
|
||||
DEPRECATED_OPERATION(XmlEncoding)
|
||||
DEPRECATED_OPERATION(XmlVersion)
|
||||
DEPRECATED_OPERATION(InputEncoding)
|
||||
DEPRECATED_OPERATION(XmlStandalone)
|
||||
DEPRECATED_OPERATION(IsElementContentWhitespace)
|
||||
|
|
|
@ -1579,7 +1579,7 @@ public:
|
|||
void WarnOnceAbout(DeprecatedOperations aOperation);
|
||||
|
||||
private:
|
||||
PRUint32 mWarnedAbout;
|
||||
PRUint64 mWarnedAbout;
|
||||
|
||||
protected:
|
||||
~nsIDocument()
|
||||
|
|
|
@ -569,7 +569,7 @@ nsContentIterator::GetDeepFirstChild(nsINode *aRoot,
|
|||
}
|
||||
|
||||
nsINode *n = aRoot;
|
||||
nsINode *nChild = n->GetChildAt(0);
|
||||
nsINode *nChild = n->GetFirstChild();
|
||||
|
||||
while (nChild)
|
||||
{
|
||||
|
@ -579,7 +579,7 @@ nsContentIterator::GetDeepFirstChild(nsINode *aRoot,
|
|||
aIndexes->AppendElement(0);
|
||||
}
|
||||
n = nChild;
|
||||
nChild = n->GetChildAt(0);
|
||||
nChild = n->GetFirstChild();
|
||||
}
|
||||
|
||||
return n;
|
||||
|
@ -747,7 +747,7 @@ nsContentIterator::NextNode(nsINode *aNode, nsTArray<PRInt32> *aIndexes)
|
|||
// if it has children then next node is first child
|
||||
if (NodeHasChildren(n))
|
||||
{
|
||||
nsINode *nFirstChild = n->GetChildAt(0);
|
||||
nsINode *nFirstChild = n->GetFirstChild();
|
||||
|
||||
// update cache
|
||||
if (aIndexes)
|
||||
|
@ -889,7 +889,8 @@ nsContentIterator::PrevNode(nsINode *aNode, nsTArray<PRInt32> *aIndexes)
|
|||
// if it has children then prev node is last child
|
||||
if (numChildren)
|
||||
{
|
||||
nsINode *nLastChild = n->GetChildAt(--numChildren);
|
||||
nsINode *nLastChild = n->GetLastChild();
|
||||
numChildren--;
|
||||
|
||||
// update cache
|
||||
if (aIndexes)
|
||||
|
@ -1300,7 +1301,7 @@ nsresult nsContentSubtreeIterator::Init(nsIDOMRange* aRange)
|
|||
// short circuit when start node == end node
|
||||
if (startParent == endParent)
|
||||
{
|
||||
nsINode* nChild = nStartP->GetChildAt(0);
|
||||
nsINode* nChild = nStartP->GetFirstChild();
|
||||
|
||||
if (!nChild) // no children, must be a text node or empty container
|
||||
{
|
||||
|
@ -1490,7 +1491,7 @@ nsContentSubtreeIterator::Next()
|
|||
{
|
||||
// as long as we are finding ancestors of the endpoint of the range,
|
||||
// dive down into their children
|
||||
nextNode = nextNode->GetChildAt(0);
|
||||
nextNode = nextNode->GetFirstChild();
|
||||
NS_ASSERTION(nextNode, "Iterator error, expected a child node!");
|
||||
|
||||
// should be impossible to get a null pointer. If we went all the way
|
||||
|
|
|
@ -3782,9 +3782,9 @@ nsContentUtils::SetNodeTextContent(nsIContent* aContent,
|
|||
|
||||
static void AppendNodeTextContentsRecurse(nsINode* aNode, nsAString& aResult)
|
||||
{
|
||||
nsIContent* child;
|
||||
PRUint32 i;
|
||||
for (i = 0; (child = aNode->GetChildAt(i)); ++i) {
|
||||
for (nsIContent* child = aNode->GetFirstChild();
|
||||
child;
|
||||
child = child->GetNextSibling()) {
|
||||
if (child->IsElement()) {
|
||||
AppendNodeTextContentsRecurse(child, aResult);
|
||||
}
|
||||
|
@ -3806,9 +3806,9 @@ nsContentUtils::AppendNodeTextContent(nsINode* aNode, PRBool aDeep,
|
|||
AppendNodeTextContentsRecurse(aNode, aResult);
|
||||
}
|
||||
else {
|
||||
nsIContent* child;
|
||||
PRUint32 i;
|
||||
for (i = 0; (child = aNode->GetChildAt(i)); ++i) {
|
||||
for (nsIContent* child = aNode->GetFirstChild();
|
||||
child;
|
||||
child = child->GetNextSibling()) {
|
||||
if (child->IsNodeOfType(nsINode::eTEXT)) {
|
||||
child->AppendTextTo(aResult);
|
||||
}
|
||||
|
@ -3819,9 +3819,9 @@ nsContentUtils::AppendNodeTextContent(nsINode* aNode, PRBool aDeep,
|
|||
PRBool
|
||||
nsContentUtils::HasNonEmptyTextContent(nsINode* aNode)
|
||||
{
|
||||
nsIContent* child;
|
||||
PRUint32 i;
|
||||
for (i = 0; (child = aNode->GetChildAt(i)); ++i) {
|
||||
for (nsIContent* child = aNode->GetFirstChild();
|
||||
child;
|
||||
child = child->GetNextSibling()) {
|
||||
if (child->IsNodeOfType(nsINode::eTEXT) &&
|
||||
child->TextLength() > 0) {
|
||||
return PR_TRUE;
|
||||
|
|
|
@ -660,6 +660,11 @@ nsDOMAttribute::SetTextContent(const nsAString& aTextContent)
|
|||
NS_IMETHODIMP
|
||||
nsDOMAttribute::IsSameNode(nsIDOMNode *other, PRBool *aResult)
|
||||
{
|
||||
nsIDocument* document = GetOwnerDoc();
|
||||
if (document) {
|
||||
document->WarnOnceAbout(nsIDocument::eIsSameNode);
|
||||
}
|
||||
|
||||
*aResult = other == this;
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -4933,12 +4933,11 @@ GetElementByAttribute(nsIContent* aContent, nsIAtom* aAttrName,
|
|||
return CallQueryInterface(aContent, aResult);
|
||||
}
|
||||
|
||||
PRUint32 childCount = aContent->GetChildCount();
|
||||
for (nsIContent* child = aContent->GetFirstChild();
|
||||
child;
|
||||
child = child->GetNextSibling()) {
|
||||
|
||||
for (PRUint32 i = 0; i < childCount; ++i) {
|
||||
nsIContent *current = aContent->GetChildAt(i);
|
||||
|
||||
GetElementByAttribute(current, aAttrName, aAttrValue, aUniversalMatch,
|
||||
GetElementByAttribute(child, aAttrName, aAttrValue, aUniversalMatch,
|
||||
aResult);
|
||||
|
||||
if (*aResult)
|
||||
|
@ -5115,10 +5114,11 @@ nsIDocument::GetHtmlChildElement(nsIAtom* aTag)
|
|||
|
||||
// Look for the element with aTag inside html. This needs to run
|
||||
// forwards to find the first such element.
|
||||
for (PRUint32 i = 0; i < html->GetChildCount(); ++i) {
|
||||
nsIContent* result = html->GetChildAt(i);
|
||||
if (result->Tag() == aTag && result->IsHTML())
|
||||
return result->AsElement();
|
||||
for (nsIContent* child = html->GetFirstChild();
|
||||
child;
|
||||
child = child->GetNextSibling()) {
|
||||
if (child->IsHTML(aTag))
|
||||
return child->AsElement();
|
||||
}
|
||||
return nsnull;
|
||||
}
|
||||
|
@ -5826,6 +5826,7 @@ nsDocument::SetTextContent(const nsAString & aTextContent)
|
|||
NS_IMETHODIMP
|
||||
nsDocument::IsSameNode(nsIDOMNode *other, PRBool *aResult)
|
||||
{
|
||||
WarnOnceAbout(eIsSameNode);
|
||||
*aResult = other == this;
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -5877,6 +5878,7 @@ nsDocument::Contains(nsIDOMNode* aOther, PRBool* aReturn)
|
|||
NS_IMETHODIMP
|
||||
nsDocument::GetInputEncoding(nsAString& aInputEncoding)
|
||||
{
|
||||
WarnOnceAbout(eInputEncoding);
|
||||
if (mHaveInputEncoding) {
|
||||
return GetCharacterSet(aInputEncoding);
|
||||
}
|
||||
|
@ -5888,6 +5890,7 @@ nsDocument::GetInputEncoding(nsAString& aInputEncoding)
|
|||
NS_IMETHODIMP
|
||||
nsDocument::GetXmlEncoding(nsAString& aXmlEncoding)
|
||||
{
|
||||
WarnOnceAbout(eXmlEncoding);
|
||||
if (!IsHTML() &&
|
||||
mXMLDeclarationBits & XML_DECLARATION_BITS_DECLARATION_EXISTS &&
|
||||
mXMLDeclarationBits & XML_DECLARATION_BITS_ENCODING_EXISTS) {
|
||||
|
@ -5904,6 +5907,7 @@ nsDocument::GetXmlEncoding(nsAString& aXmlEncoding)
|
|||
NS_IMETHODIMP
|
||||
nsDocument::GetXmlStandalone(PRBool *aXmlStandalone)
|
||||
{
|
||||
WarnOnceAbout(eXmlStandalone);
|
||||
*aXmlStandalone =
|
||||
!IsHTML() &&
|
||||
mXMLDeclarationBits & XML_DECLARATION_BITS_DECLARATION_EXISTS &&
|
||||
|
@ -5929,6 +5933,7 @@ nsDocument::GetMozSyntheticDocument(PRBool *aSyntheticDocument)
|
|||
NS_IMETHODIMP
|
||||
nsDocument::GetXmlVersion(nsAString& aXmlVersion)
|
||||
{
|
||||
WarnOnceAbout(eXmlVersion);
|
||||
if (IsHTML()) {
|
||||
SetDOMStringToNull(aXmlVersion);
|
||||
return NS_OK;
|
||||
|
@ -6013,7 +6018,7 @@ BlastSubtreeToPieces(nsINode *aNode)
|
|||
|
||||
count = aNode->GetChildCount();
|
||||
for (i = 0; i < count; ++i) {
|
||||
BlastSubtreeToPieces(aNode->GetChildAt(0));
|
||||
BlastSubtreeToPieces(aNode->GetFirstChild());
|
||||
#ifdef DEBUG
|
||||
nsresult rv =
|
||||
#endif
|
||||
|
@ -8156,7 +8161,7 @@ static const char* kWarnings[] = {
|
|||
void
|
||||
nsIDocument::WarnOnceAbout(DeprecatedOperations aOperation)
|
||||
{
|
||||
PR_STATIC_ASSERT(eDeprecatedOperationCount <= 32);
|
||||
PR_STATIC_ASSERT(eDeprecatedOperationCount <= 64);
|
||||
if (mWarnedAbout & (1 << aOperation)) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -846,6 +846,8 @@ nsGenericDOMDataNode::ReplaceWholeText(const nsAString& aContent,
|
|||
{
|
||||
*aResult = nsnull;
|
||||
|
||||
GetOwnerDoc()->WarnOnceAbout(nsIDocument::eReplaceWholeText);
|
||||
|
||||
// Handle parent-less nodes
|
||||
nsCOMPtr<nsIContent> parent = GetParent();
|
||||
if (!parent) {
|
||||
|
|
|
@ -334,6 +334,7 @@ protected:
|
|||
|
||||
nsresult GetIsElementContentWhitespace(PRBool *aReturn)
|
||||
{
|
||||
GetOwnerDoc()->WarnOnceAbout(nsIDocument::eIsElementContentWhitespace);
|
||||
*aReturn = TextIsOnlyWhitespace();
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -458,7 +458,7 @@ nsINode::GetChildNodes(nsIDOMNodeList** aChildNodes)
|
|||
nsresult
|
||||
nsINode::GetFirstChild(nsIDOMNode** aNode)
|
||||
{
|
||||
nsIContent* child = GetChildAt(0);
|
||||
nsIContent* child = GetFirstChild();
|
||||
if (child) {
|
||||
return CallQueryInterface(child, aNode);
|
||||
}
|
||||
|
@ -2875,9 +2875,9 @@ BindNodesInInsertPoints(nsXBLBinding* aBinding, nsIContent* aInsertParent,
|
|||
nsCOMPtr<nsIContent> insertRoot =
|
||||
inserts->ElementAt(i)->GetDefaultContent();
|
||||
if (insertRoot) {
|
||||
PRUint32 j;
|
||||
for (j = 0; j < insertRoot->GetChildCount(); ++j) {
|
||||
nsCOMPtr<nsIContent> child = insertRoot->GetChildAt(j);
|
||||
for (nsCOMPtr<nsIContent> child = insertRoot->GetFirstChild();
|
||||
child;
|
||||
child = child->GetNextSibling()) {
|
||||
rv = child->BindToTree(aDocument, aInsertParent,
|
||||
aBinding->GetBoundElement(), allowScripts);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
@ -3009,9 +3009,9 @@ nsGenericElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
|||
if (contBinding) {
|
||||
nsCOMPtr<nsIContent> anonRoot = contBinding->GetAnonymousContent();
|
||||
PRBool allowScripts = contBinding->AllowScripts();
|
||||
PRUint32 i;
|
||||
for (i = 0; i < anonRoot->GetChildCount(); ++i) {
|
||||
nsCOMPtr<nsIContent> child = anonRoot->GetChildAt(i);
|
||||
for (nsCOMPtr<nsIContent> child = anonRoot->GetFirstChild();
|
||||
child;
|
||||
child = child->GetNextSibling()) {
|
||||
rv = child->BindToTree(aDocument, this, this, allowScripts);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
@ -3941,11 +3941,10 @@ PRBool IsAllowedAsChild(nsIContent* aNewChild, nsINode* aParent,
|
|||
}
|
||||
|
||||
PRBool sawElement = PR_FALSE;
|
||||
PRUint32 count = aNewChild->GetChildCount();
|
||||
for (PRUint32 index = 0; index < count; ++index) {
|
||||
nsIContent* childContent = aNewChild->GetChildAt(index);
|
||||
NS_ASSERTION(childContent, "Something went wrong");
|
||||
if (childContent->IsElement()) {
|
||||
for (nsIContent* child = aNewChild->GetFirstChild();
|
||||
child;
|
||||
child = child->GetNextSibling()) {
|
||||
if (child->IsElement()) {
|
||||
if (sawElement) {
|
||||
// Can't put two elements into a document
|
||||
return PR_FALSE;
|
||||
|
@ -3954,7 +3953,7 @@ PRBool IsAllowedAsChild(nsIContent* aNewChild, nsINode* aParent,
|
|||
}
|
||||
// If we can put this content at the the right place, we might be ok;
|
||||
// if not, we bail out.
|
||||
if (!IsAllowedAsChild(childContent, aParent, aIsReplace, aRefChild)) {
|
||||
if (!IsAllowedAsChild(child, aParent, aIsReplace, aRefChild)) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -4128,8 +4127,9 @@ nsINode::ReplaceOrInsertBefore(PRBool aReplace, nsINode* aNewChild,
|
|||
// mutations to the fragment while we're inserting.
|
||||
nsAutoTArray<nsCOMPtr<nsIContent>, 50> fragChildren;
|
||||
fragChildren.SetCapacity(count);
|
||||
for (PRUint32 i = 0; i < count; i++) {
|
||||
nsIContent* child = newContent->GetChildAt(i);
|
||||
for (nsIContent* child = newContent->GetFirstChild();
|
||||
child;
|
||||
child = child->GetNextSibling()) {
|
||||
NS_ASSERTION(child->GetCurrentDoc() == nsnull,
|
||||
"How did we get a child with a current doc?");
|
||||
fragChildren.AppendElement(child);
|
||||
|
@ -4210,6 +4210,10 @@ nsINode::IsEqualNode(nsIDOMNode* aOther, PRBool* aReturn)
|
|||
nsresult
|
||||
nsINode::IsSameNode(nsIDOMNode* aOther, PRBool* aReturn)
|
||||
{
|
||||
nsIDocument* owner = GetOwnerDoc();
|
||||
if (owner) {
|
||||
owner->WarnOnceAbout(nsIDocument::eIsSameNode);
|
||||
}
|
||||
nsCOMPtr<nsINode> other = do_QueryInterface(aOther);
|
||||
*aReturn = other == this;
|
||||
return NS_OK;
|
||||
|
@ -5000,13 +5004,12 @@ nsGenericElement::List(FILE* out, PRInt32 aIndent,
|
|||
fprintf(out, " primaryframe=%p", static_cast<void*>(GetPrimaryFrame()));
|
||||
fprintf(out, " refcount=%d<", mRefCnt.get());
|
||||
|
||||
PRUint32 i, length = GetChildCount();
|
||||
if (length > 0) {
|
||||
nsIContent* child = GetFirstChild();
|
||||
if (child) {
|
||||
fputs("\n", out);
|
||||
|
||||
for (i = 0; i < length; ++i) {
|
||||
nsIContent *kid = GetChildAt(i);
|
||||
kid->List(out, aIndent + 1);
|
||||
|
||||
for (; child; child = child->GetNextSibling()) {
|
||||
child->List(out, aIndent + 1);
|
||||
}
|
||||
|
||||
for (indent = aIndent; --indent >= 0; ) fputs(" ", out);
|
||||
|
@ -5027,12 +5030,13 @@ nsGenericElement::List(FILE* out, PRInt32 aIndent,
|
|||
getter_AddRefs(anonymousChildren));
|
||||
|
||||
if (anonymousChildren) {
|
||||
PRUint32 length;
|
||||
anonymousChildren->GetLength(&length);
|
||||
if (length > 0) {
|
||||
for (indent = aIndent; --indent >= 0; ) fputs(" ", out);
|
||||
fputs("anonymous-children<\n", out);
|
||||
|
||||
for (i = 0; i < length; ++i) {
|
||||
for (PRUint32 i = 0; i < length; ++i) {
|
||||
nsCOMPtr<nsIDOMNode> node;
|
||||
anonymousChildren->Item(i, getter_AddRefs(node));
|
||||
nsCOMPtr<nsIContent> child = do_QueryInterface(node);
|
||||
|
@ -5050,13 +5054,14 @@ nsGenericElement::List(FILE* out, PRInt32 aIndent,
|
|||
getter_AddRefs(contentList));
|
||||
|
||||
NS_ASSERTION(contentList != nsnull, "oops, binding manager lied");
|
||||
|
||||
|
||||
PRUint32 length;
|
||||
contentList->GetLength(&length);
|
||||
if (length > 0) {
|
||||
for (indent = aIndent; --indent >= 0; ) fputs(" ", out);
|
||||
fputs("content-list<\n", out);
|
||||
|
||||
for (i = 0; i < length; ++i) {
|
||||
for (PRUint32 i = 0; i < length; ++i) {
|
||||
nsCOMPtr<nsIDOMNode> node;
|
||||
contentList->Item(i, getter_AddRefs(node));
|
||||
nsCOMPtr<nsIContent> child = do_QueryInterface(node);
|
||||
|
@ -5087,11 +5092,11 @@ nsGenericElement::DumpContent(FILE* out, PRInt32 aIndent,
|
|||
|
||||
if(aIndent) fputs("\n", out);
|
||||
|
||||
PRInt32 index, kids = GetChildCount();
|
||||
for (index = 0; index < kids; index++) {
|
||||
nsIContent *kid = GetChildAt(index);
|
||||
for (nsIContent* child = GetFirstChild();
|
||||
child;
|
||||
child = child->GetNextSibling()) {
|
||||
PRInt32 indent = aIndent ? aIndent + 1 : 0;
|
||||
kid->DumpContent(out, indent, aDumpAll);
|
||||
child->DumpContent(out, indent, aDumpAll);
|
||||
}
|
||||
for (indent = aIndent; --indent >= 0; ) fputs(" ", out);
|
||||
fputs("</", out);
|
||||
|
|
|
@ -659,10 +659,11 @@ nsNodeUtils::CloneAndAdopt(nsINode *aNode, PRBool aClone, PRBool aDeep,
|
|||
// XXX End of workaround for broken attribute nodes.
|
||||
else if (aDeep || aNode->IsNodeOfType(nsINode::eATTRIBUTE)) {
|
||||
// aNode's children.
|
||||
PRUint32 i, length = aNode->GetChildCount();
|
||||
for (i = 0; i < length; ++i) {
|
||||
for (nsIContent* cloneChild = aNode->GetFirstChild();
|
||||
cloneChild;
|
||||
cloneChild = cloneChild->GetNextSibling()) {
|
||||
nsCOMPtr<nsINode> child;
|
||||
rv = CloneAndAdopt(aNode->GetChildAt(i), aClone, PR_TRUE, nodeInfoManager,
|
||||
rv = CloneAndAdopt(cloneChild, aClone, PR_TRUE, nodeInfoManager,
|
||||
aCx, aNewScope, aNodesWithProperties, clone,
|
||||
getter_AddRefs(child));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
|
|
@ -1926,13 +1926,10 @@ nsObjectLoadingContent::GetPluginSupportState(nsIContent* aContent,
|
|||
PRBool hasAlternateContent = PR_FALSE;
|
||||
|
||||
// Search for a child <param> with a pluginurl name
|
||||
PRUint32 count = aContent->GetChildCount();
|
||||
for (PRUint32 i = 0; i < count; ++i) {
|
||||
nsIContent* child = aContent->GetChildAt(i);
|
||||
NS_ASSERTION(child, "GetChildCount lied!");
|
||||
|
||||
if (child->IsHTML() &&
|
||||
child->Tag() == nsGkAtoms::param) {
|
||||
for (nsIContent* child = aContent->GetFirstChild();
|
||||
child;
|
||||
child = child->GetNextSibling()) {
|
||||
if (child->IsHTML(nsGkAtoms::param)) {
|
||||
if (child->AttrValueIs(kNameSpaceID_None, nsGkAtoms::name,
|
||||
NS_LITERAL_STRING("pluginurl"), eIgnoreCase)) {
|
||||
return GetPluginDisabledState(aContentType);
|
||||
|
|
|
@ -498,11 +498,10 @@ nsXHTMLContentSerializer::AfterElementStart(nsIContent * aContent,
|
|||
// If there are, they will be modified to use the correct charset.
|
||||
// If there aren't, we'll insert one here.
|
||||
PRBool hasMeta = PR_FALSE;
|
||||
PRUint32 i, childCount = aContent->GetChildCount();
|
||||
for (i = 0; i < childCount; ++i) {
|
||||
nsIContent* child = aContent->GetChildAt(i);
|
||||
if (child->IsHTML() &&
|
||||
child->Tag() == nsGkAtoms::meta &&
|
||||
for (nsIContent* child = aContent->GetFirstChild();
|
||||
child;
|
||||
child = child->GetNextSibling()) {
|
||||
if (child->IsHTML(nsGkAtoms::meta) &&
|
||||
child->HasAttr(kNameSpaceID_None, nsGkAtoms::content)) {
|
||||
nsAutoString header;
|
||||
child->GetAttr(kNameSpaceID_None, nsGkAtoms::httpEquiv, header);
|
||||
|
@ -1019,12 +1018,10 @@ nsXHTMLContentSerializer::IsFirstChildOfOL(nsIContent* aElement)
|
|||
PRBool
|
||||
nsXHTMLContentSerializer::HasNoChildren(nsIContent * aContent) {
|
||||
|
||||
PRUint32 i, childCount = aContent->GetChildCount();
|
||||
|
||||
for (i = 0; i < childCount; ++i) {
|
||||
|
||||
nsIContent* child = aContent->GetChildAt(i);
|
||||
|
||||
for (nsIContent* child = aContent->GetFirstChild();
|
||||
child;
|
||||
child = child->GetNextSibling()) {
|
||||
|
||||
if (!child->IsNodeOfType(nsINode::eTEXT))
|
||||
return PR_FALSE;
|
||||
|
||||
|
|
|
@ -219,6 +219,7 @@ _TEST_FILES1 = \
|
|||
file_XHR_fail1.txt^headers^ \
|
||||
file_XHR_binary1.bin \
|
||||
file_XHR_binary1.bin^headers^ \
|
||||
file_XHR_binary2.bin \
|
||||
test_bug428847.html \
|
||||
file_bug428847-1.xhtml \
|
||||
file_bug428847-2.xhtml \
|
||||
|
|
Двоичный файл не отображается.
|
@ -178,7 +178,7 @@ checkResponseAccessThrows(xhr); // Check twice to ensure that we still throw
|
|||
// test response (responseType='blob')
|
||||
var onloadCount = 0;
|
||||
function checkOnloadCount() {
|
||||
if (++onloadCount >= 2) SimpleTest.finish();
|
||||
if (++onloadCount >= 3) SimpleTest.finish();
|
||||
};
|
||||
|
||||
// with a simple text file
|
||||
|
@ -203,7 +203,8 @@ fr.onload = function() {
|
|||
fr.readAsBinaryString(b);
|
||||
|
||||
// with a binary file
|
||||
xhr = new XMLHttpRequest();
|
||||
(function(){
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.onreadystatechange = function() {
|
||||
switch (xhr.readyState) {
|
||||
case 2:
|
||||
|
@ -228,6 +229,37 @@ xhr.onreadystatechange = function() {
|
|||
};
|
||||
xhr.open("GET", 'file_XHR_binary1.bin', true);
|
||||
xhr.send(null);
|
||||
})();
|
||||
|
||||
(function(){
|
||||
// with a larger binary file
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.onreadystatechange = function() {
|
||||
if (xhr.readyState == 4) {
|
||||
b = xhr.response;
|
||||
ok(b != null, "should have a non-null blob");
|
||||
is(b.size, 65536, "wrong blob size");
|
||||
|
||||
var fr = new FileReader();
|
||||
fr.onload = function() {
|
||||
var u8 = new Uint8Array(fr.result);
|
||||
for (var i = 0; i < 65536; i++) {
|
||||
if (u8[i] !== (i & 255)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
is(i, 65536, "wrong value at offset " + i);
|
||||
checkOnloadCount();
|
||||
};
|
||||
xhr = null; // kill the XHR object
|
||||
SpecialPowers.gc();
|
||||
fr.readAsArrayBuffer(b);
|
||||
}
|
||||
};
|
||||
xhr.open("GET", 'file_XHR_binary2.bin', true);
|
||||
xhr.responseType = 'blob';
|
||||
xhr.send(null);
|
||||
})();
|
||||
|
||||
var client = new XMLHttpRequest();
|
||||
client.onreadystatechange = function() {
|
||||
|
|
|
@ -3661,14 +3661,10 @@ nsGenericHTMLElement::SyncEditorsOnSubtree(nsIContent* content)
|
|||
}
|
||||
|
||||
/* Sync all children */
|
||||
PRUint32 childCount = content->GetChildCount();
|
||||
for (PRUint32 i = 0; i < childCount; ++i) {
|
||||
nsIContent* childContent = content->GetChildAt(i);
|
||||
NS_ASSERTION(childContent,
|
||||
"DOM mutated unexpectedly while syncing editors!");
|
||||
if (childContent) {
|
||||
SyncEditorsOnSubtree(childContent);
|
||||
}
|
||||
for (nsIContent* child = content->GetFirstChild();
|
||||
child;
|
||||
child = child->GetNextSibling()) {
|
||||
SyncEditorsOnSubtree(child);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -603,13 +603,10 @@ NS_IMETHODIMP nsHTMLMediaElement::Load()
|
|||
|
||||
static PRBool HasSourceChildren(nsIContent *aElement)
|
||||
{
|
||||
PRUint32 count = aElement->GetChildCount();
|
||||
for (PRUint32 i = 0; i < count; ++i) {
|
||||
nsIContent* child = aElement->GetChildAt(i);
|
||||
NS_ASSERTION(child, "GetChildCount lied!");
|
||||
if (child &&
|
||||
child->Tag() == nsGkAtoms::source &&
|
||||
child->IsHTML())
|
||||
for (nsIContent* child = aElement->GetFirstChild();
|
||||
child;
|
||||
child = child->GetNextSibling()) {
|
||||
if (child->IsHTML(nsGkAtoms::source))
|
||||
{
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
@ -2528,9 +2525,7 @@ nsIContent* nsHTMLMediaElement::GetNextSource()
|
|||
nsIContent* child = GetChildAt(startOffset);
|
||||
|
||||
// If child is a <source> element, it is the next candidate.
|
||||
if (child &&
|
||||
child->Tag() == nsGkAtoms::source &&
|
||||
child->IsHTML())
|
||||
if (child && child->IsHTML(nsGkAtoms::source))
|
||||
{
|
||||
mSourceLoadCandidate = child;
|
||||
return child;
|
||||
|
|
|
@ -391,9 +391,10 @@ nsHTMLSelectElement::InsertOptionsIntoListRecurse(nsIContent* aOptions,
|
|||
if (aOptions->IsHTML(nsGkAtoms::optgroup)) {
|
||||
mOptGroupCount++;
|
||||
|
||||
PRUint32 numChildren = aOptions->GetChildCount();
|
||||
for (PRUint32 i = 0; i < numChildren; ++i) {
|
||||
nsresult rv = InsertOptionsIntoListRecurse(aOptions->GetChildAt(i),
|
||||
for (nsIContent* child = aOptions->GetFirstChild();
|
||||
child;
|
||||
child = child->GetNextSibling()) {
|
||||
nsresult rv = InsertOptionsIntoListRecurse(child,
|
||||
aInsertIndex, aDepth+1);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
@ -435,9 +436,11 @@ nsHTMLSelectElement::RemoveOptionsFromListRecurse(nsIContent* aOptions,
|
|||
if (mOptGroupCount && aOptions->IsHTML(nsGkAtoms::optgroup)) {
|
||||
mOptGroupCount--;
|
||||
|
||||
PRUint32 numChildren = aOptions->GetChildCount();
|
||||
for (PRUint32 i = 0; i < numChildren; ++i) {
|
||||
nsresult rv = RemoveOptionsFromListRecurse(aOptions->GetChildAt(i),
|
||||
for (nsIContent* child = aOptions->GetFirstChild();
|
||||
child;
|
||||
child = child->GetNextSibling()) {
|
||||
|
||||
nsresult rv = RemoveOptionsFromListRecurse(child,
|
||||
aRemoveIndex,
|
||||
aNumRemoved,
|
||||
aDepth + 1);
|
||||
|
|
|
@ -410,12 +410,11 @@ nsHTMLTableElement::SetCaption(nsIDOMHTMLTableCaptionElement* aValue)
|
|||
already_AddRefed<nsIDOMHTMLTableSectionElement>
|
||||
nsHTMLTableElement::GetSection(nsIAtom *aTag)
|
||||
{
|
||||
PRUint32 childCount = GetChildCount();
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLTableSectionElement> section;
|
||||
|
||||
for (PRUint32 i = 0; i < childCount; ++i) {
|
||||
nsIContent *child = GetChildAt(i);
|
||||
for (nsIContent* child = nsINode::GetFirstChild();
|
||||
child;
|
||||
child = child->GetNextSibling()) {
|
||||
|
||||
section = do_QueryInterface(child);
|
||||
|
||||
|
@ -767,9 +766,9 @@ nsHTMLTableElement::InsertRow(PRInt32 aIndex, nsIDOMHTMLElement** aValue)
|
|||
nsCOMPtr<nsIDOMNode> rowGroup;
|
||||
|
||||
PRInt32 namespaceID = mNodeInfo->NamespaceID();
|
||||
PRUint32 childCount = GetChildCount();
|
||||
for (PRUint32 i = 0; i < childCount; ++i) {
|
||||
nsIContent* child = GetChildAt(i);
|
||||
for (nsIContent* child = nsINode::GetFirstChild();
|
||||
child;
|
||||
child = child->GetNextSibling()) {
|
||||
nsINodeInfo *childInfo = child->NodeInfo();
|
||||
nsIAtom *localName = childInfo->NameAtom();
|
||||
if (childInfo->NamespaceID() == namespaceID &&
|
||||
|
|
|
@ -531,7 +531,7 @@ nsTextInputSelectionImpl::CompleteMove(PRBool aForward, PRBool aExtend)
|
|||
|
||||
if (offset > 0)
|
||||
{
|
||||
nsIContent *child = parentDIV->GetChildAt(offset - 1);
|
||||
nsIContent *child = parentDIV->GetLastChild();
|
||||
|
||||
if (child->Tag() == nsGkAtoms::br)
|
||||
{
|
||||
|
@ -1753,7 +1753,7 @@ nsTextEditorState::SetValue(const nsAString& aValue, PRBool aUserInput)
|
|||
// Grab the current value directly from the text node to make sure that we
|
||||
// deal with stale data correctly.
|
||||
NS_ASSERTION(mRootNode, "We should have a root node here");
|
||||
nsIContent *textContent = mRootNode->GetChildAt(0);
|
||||
nsIContent *textContent = mRootNode->GetFirstChild();
|
||||
nsCOMPtr<nsIDOMCharacterData> textNode = do_QueryInterface(textContent);
|
||||
if (textNode) {
|
||||
textNode->GetData(currentValue);
|
||||
|
@ -1978,8 +1978,8 @@ nsTextEditorState::UpdatePlaceholderText(PRBool aNotify)
|
|||
nsCOMPtr<nsIContent> content = do_QueryInterface(mTextCtrlElement);
|
||||
content->GetAttr(kNameSpaceID_None, nsGkAtoms::placeholder, placeholderValue);
|
||||
nsContentUtils::RemoveNewlines(placeholderValue);
|
||||
NS_ASSERTION(mPlaceholderDiv->GetChildAt(0), "placeholder div has no child");
|
||||
mPlaceholderDiv->GetChildAt(0)->SetText(placeholderValue, aNotify);
|
||||
NS_ASSERTION(mPlaceholderDiv->GetFirstChild(), "placeholder div has no child");
|
||||
mPlaceholderDiv->GetFirstChild()->SetText(placeholderValue, aNotify);
|
||||
ValueWasChanged(aNotify);
|
||||
}
|
||||
|
||||
|
|
|
@ -2700,9 +2700,9 @@ static void
|
|||
NotifyEditableStateChange(nsINode *aNode, nsIDocument *aDocument,
|
||||
PRBool aEditable)
|
||||
{
|
||||
PRUint32 i, n = aNode->GetChildCount();
|
||||
for (i = 0; i < n; ++i) {
|
||||
nsIContent *child = aNode->GetChildAt(i);
|
||||
for (nsIContent* child = aNode->GetFirstChild();
|
||||
child;
|
||||
child = child->GetNextSibling()) {
|
||||
if (child->HasFlag(NODE_IS_EDITABLE) != aEditable &&
|
||||
child->IsElement()) {
|
||||
child->AsElement()->UpdateState(true);
|
||||
|
|
|
@ -157,9 +157,9 @@ SVGMotionSMILAnimationFunction::GetCalcMode() const
|
|||
static nsSVGMpathElement*
|
||||
GetFirstMpathChild(nsIContent* aElem)
|
||||
{
|
||||
PRUint32 childCount = aElem->GetChildCount();
|
||||
for (PRUint32 i = 0; i < childCount; ++i) {
|
||||
nsIContent* child = aElem->GetChildAt(i);
|
||||
for (nsIContent* child = aElem->GetFirstChild();
|
||||
child;
|
||||
child = child->GetNextSibling()) {
|
||||
if (child->Tag() == nsGkAtoms::mpath &&
|
||||
child->GetNameSpaceID() == kNameSpaceID_SVG) {
|
||||
return static_cast<nsSVGMpathElement*>(child);
|
||||
|
|
|
@ -1826,10 +1826,12 @@ nsSVGFEComponentTransferElement::Filter(nsSVGFilterInstance *instance,
|
|||
for (int i=0; i<256; i++)
|
||||
tableR[i] = tableG[i] = tableB[i] = tableA[i] = i;
|
||||
PRUint8* tables[] = { tableR, tableG, tableB, tableA };
|
||||
PRUint32 count = GetChildCount();
|
||||
for (PRUint32 k = 0; k < count; k++) {
|
||||
for (nsIContent* childContent = nsINode::GetFirstChild();
|
||||
childContent;
|
||||
childContent = childContent->GetNextSibling()) {
|
||||
|
||||
nsRefPtr<nsSVGComponentTransferFunctionElement> child;
|
||||
CallQueryInterface(GetChildAt(k),
|
||||
CallQueryInterface(childContent,
|
||||
(nsSVGComponentTransferFunctionElement**)getter_AddRefs(child));
|
||||
if (child) {
|
||||
child->GenerateLookupTable(tables[child->GetChannel()]);
|
||||
|
@ -2377,9 +2379,9 @@ nsSVGFEMergeElement::Filter(nsSVGFilterInstance *instance,
|
|||
void
|
||||
nsSVGFEMergeElement::GetSourceImageNames(nsTArray<nsSVGStringInfo>& aSources)
|
||||
{
|
||||
PRUint32 count = GetChildCount();
|
||||
for (PRUint32 i = 0; i < count; i++) {
|
||||
nsIContent* child = GetChildAt(i);
|
||||
for (nsIContent* child = nsINode::GetFirstChild();
|
||||
child;
|
||||
child = child->GetNextSibling()) {
|
||||
nsRefPtr<nsSVGFEMergeNodeElement> node;
|
||||
CallQueryInterface(child, (nsSVGFEMergeNodeElement**)getter_AddRefs(node));
|
||||
if (node) {
|
||||
|
@ -4868,10 +4870,10 @@ nsSVGFELightingElement::Filter(nsSVGFilterInstance *instance,
|
|||
|
||||
nscolor lightColor = style->GetStyleSVGReset()->mLightingColor;
|
||||
|
||||
// find specified light
|
||||
PRUint32 count = GetChildCount();
|
||||
for (PRUint32 k = 0; k < count; k++) {
|
||||
nsCOMPtr<nsIContent> child = GetChildAt(k);
|
||||
// find specified light
|
||||
for (nsCOMPtr<nsIContent> child = nsINode::GetFirstChild();
|
||||
child;
|
||||
child = child->GetNextSibling()) {
|
||||
distantLight = do_QueryInterface(child);
|
||||
pointLight = do_QueryInterface(child);
|
||||
spotLight = do_QueryInterface(child);
|
||||
|
|
|
@ -167,13 +167,12 @@ nsSVGSwitchElement::FindActiveChild() const
|
|||
const nsAdoptingString& acceptLangs =
|
||||
Preferences::GetLocalizedString("intl.accept_languages");
|
||||
|
||||
PRUint32 count = GetChildCount();
|
||||
|
||||
if (allowReorder && !acceptLangs.IsEmpty()) {
|
||||
PRInt32 bestLanguagePreferenceRank = -1;
|
||||
nsIContent *bestChild = nsnull;
|
||||
for (PRUint32 i = 0; i < count; i++) {
|
||||
nsIContent *child = GetChildAt(i);
|
||||
for (nsIContent* child = nsINode::GetFirstChild();
|
||||
child;
|
||||
child = child->GetNextSibling()) {
|
||||
if (nsSVGFeatures::PassesConditionalProcessingTests(
|
||||
child, nsSVGFeatures::kIgnoreSystemLanguage)) {
|
||||
nsAutoString value;
|
||||
|
@ -204,8 +203,9 @@ nsSVGSwitchElement::FindActiveChild() const
|
|||
return bestChild;
|
||||
}
|
||||
|
||||
for (PRUint32 i = 0; i < count; i++) {
|
||||
nsIContent *child = GetChildAt(i);
|
||||
for (nsIContent* child = nsINode::GetFirstChild();
|
||||
child;
|
||||
child = child->GetNextSibling()) {
|
||||
if (nsSVGFeatures::PassesConditionalProcessingTests(child, &acceptLangs)) {
|
||||
return child;
|
||||
}
|
||||
|
|
|
@ -366,7 +366,7 @@ nsSVGUseElement::CreateAnonymousContent()
|
|||
// move the children over
|
||||
PRUint32 num = newcontent->GetChildCount();
|
||||
for (i = 0; i < num; i++) {
|
||||
nsCOMPtr<nsIContent> child = newcontent->GetChildAt(0);
|
||||
nsCOMPtr<nsIContent> child = newcontent->GetFirstChild();
|
||||
newcontent->RemoveChildAt(0, PR_FALSE);
|
||||
svgNode->InsertChildAt(child, i, PR_TRUE);
|
||||
}
|
||||
|
|
|
@ -349,10 +349,9 @@ nsXBLBinding::InstallAnonymousContent(nsIContent* aAnonParent, nsIContent* aElem
|
|||
PRBool allowScripts = AllowScripts();
|
||||
|
||||
nsAutoScriptBlocker scriptBlocker;
|
||||
|
||||
PRUint32 childCount = aAnonParent->GetChildCount();
|
||||
for (PRUint32 i = 0; i < childCount; i++) {
|
||||
nsIContent *child = aAnonParent->GetChildAt(i);
|
||||
for (nsIContent* child = aAnonParent->GetFirstChild();
|
||||
child;
|
||||
child = child->GetNextSibling()) {
|
||||
child->UnbindFromTree();
|
||||
nsresult rv =
|
||||
child->BindToTree(doc, aElement, mBoundElement, allowScripts);
|
||||
|
@ -387,9 +386,9 @@ nsXBLBinding::UninstallAnonymousContent(nsIDocument* aDocument,
|
|||
nsCOMPtr<nsIXULDocument> xuldoc =
|
||||
do_QueryInterface(aDocument);
|
||||
#endif
|
||||
PRUint32 childCount = aAnonParent->GetChildCount();
|
||||
for (PRUint32 i = 0; i < childCount; ++i) {
|
||||
nsIContent* child = aAnonParent->GetChildAt(i);
|
||||
for (nsIContent* child = aAnonParent->GetFirstChild();
|
||||
child;
|
||||
child = child->GetNextSibling()) {
|
||||
child->UnbindFromTree();
|
||||
#ifdef MOZ_XUL
|
||||
if (xuldoc) {
|
||||
|
@ -576,11 +575,11 @@ RealizeDefaultContent(nsISupports* aKey,
|
|||
|
||||
// Now make sure the kids of the clone are added to the insertion point as
|
||||
// children.
|
||||
PRUint32 cloneKidCount = clonedContent->GetChildCount();
|
||||
for (PRUint32 k = 0; k < cloneKidCount; k++) {
|
||||
nsIContent *cloneChild = clonedContent->GetChildAt(k);
|
||||
bm->SetInsertionParent(cloneChild, insParent);
|
||||
currPoint->AddChild(cloneChild);
|
||||
for (nsIContent* child = clonedContent->GetFirstChild();
|
||||
child;
|
||||
child = child->GetNextSibling()) {
|
||||
bm->SetInsertionParent(child, insParent);
|
||||
currPoint->AddChild(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1178,11 +1177,10 @@ nsXBLBinding::ChangeDocument(nsIDocument* aOldDocument, nsIDocument* aNewDocumen
|
|||
// Make sure that henceforth we don't claim that mBoundElement's children
|
||||
// have insertion parents in the old document.
|
||||
nsBindingManager* bindingManager = aOldDocument->BindingManager();
|
||||
for (PRUint32 i = mBoundElement->GetChildCount(); i > 0; --i) {
|
||||
NS_ASSERTION(mBoundElement->GetChildAt(i-1),
|
||||
"Must have child at i for 0 <= i < GetChildCount()!");
|
||||
bindingManager->SetInsertionParent(mBoundElement->GetChildAt(i-1),
|
||||
nsnull);
|
||||
for (nsIContent* child = mBoundElement->GetLastChild();
|
||||
child;
|
||||
child = child->GetPreviousSibling()) {
|
||||
bindingManager->SetInsertionParent(child, nsnull);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -814,10 +814,9 @@ nsXBLPrototypeBinding::ImplementsInterface(REFNSIID aIID) const
|
|||
nsIContent*
|
||||
nsXBLPrototypeBinding::GetImmediateChild(nsIAtom* aTag)
|
||||
{
|
||||
PRUint32 childCount = mBinding->GetChildCount();
|
||||
|
||||
for (PRUint32 i = 0; i < childCount; i++) {
|
||||
nsIContent* child = mBinding->GetChildAt(i);
|
||||
for (nsIContent* child = mBinding->GetFirstChild();
|
||||
child;
|
||||
child = child->GetNextSibling()) {
|
||||
if (child->NodeInfo()->Equals(aTag, kNameSpaceID_XBL)) {
|
||||
return child;
|
||||
}
|
||||
|
@ -1180,9 +1179,10 @@ nsXBLPrototypeBinding::ConstructAttributeTable(nsIContent* aElement)
|
|||
}
|
||||
|
||||
// Recur into our children.
|
||||
PRUint32 childCount = aElement->GetChildCount();
|
||||
for (PRUint32 i = 0; i < childCount; i++) {
|
||||
ConstructAttributeTable(aElement->GetChildAt(i));
|
||||
for (nsIContent* child = aElement->GetFirstChild();
|
||||
child;
|
||||
child = child->GetNextSibling()) {
|
||||
ConstructAttributeTable(child);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1362,10 +1362,9 @@ nsXBLPrototypeBinding::GetNestedChildren(nsIAtom* aTag, PRInt32 aNamespace,
|
|||
nsIContent* aContent,
|
||||
nsCOMArray<nsIContent> & aList)
|
||||
{
|
||||
PRUint32 childCount = aContent->GetChildCount();
|
||||
|
||||
for (PRUint32 i = 0; i < childCount; i++) {
|
||||
nsIContent *child = aContent->GetChildAt(i);
|
||||
for (nsIContent* child = aContent->GetFirstChild();
|
||||
child;
|
||||
child = child->GetNextSibling()) {
|
||||
|
||||
if (child->NodeInfo()->Equals(aTag, aNamespace)) {
|
||||
aList.AppendObject(child);
|
||||
|
|
|
@ -211,8 +211,9 @@ BuildHandlerChain(nsIContent* aContent, nsXBLPrototypeHandler** aResult)
|
|||
// Since we chain each handler onto the next handler,
|
||||
// we'll enumerate them here in reverse so that when we
|
||||
// walk the chain they'll come out in the original order
|
||||
for (PRUint32 j = aContent->GetChildCount(); j--; ) {
|
||||
nsIContent *key = aContent->GetChildAt(j);
|
||||
for (nsIContent* key = aContent->GetLastChild();
|
||||
key;
|
||||
key = key->GetPreviousSibling()) {
|
||||
|
||||
if (key->NodeInfo()->Equals(nsGkAtoms::key, kNameSpaceID_XUL)) {
|
||||
// Check whether the key element has empty value at key/char attribute.
|
||||
|
|
|
@ -306,9 +306,9 @@ nsXMLContentSink::DidBuildModel(PRBool aTerminated)
|
|||
mIsDocumentObserver = PR_FALSE;
|
||||
|
||||
// Check for xslt-param and xslt-param-namespace PIs
|
||||
PRUint32 i;
|
||||
nsIContent* child;
|
||||
for (i = 0; (child = mDocument->GetChildAt(i)); ++i) {
|
||||
for (nsIContent* child = mDocument->GetFirstChild();
|
||||
child;
|
||||
child = child->GetNextSibling()) {
|
||||
if (child->IsNodeOfType(nsINode::ePROCESSING_INSTRUCTION)) {
|
||||
nsCOMPtr<nsIDOMProcessingInstruction> pi = do_QueryInterface(child);
|
||||
CheckXSLTParamPI(pi, mXSLTProcessor, mDocument);
|
||||
|
|
|
@ -209,7 +209,7 @@ txXPathTreeWalker::moveToFirstChild()
|
|||
NS_ASSERTION(mCurrentIndex != kUnknownIndex || mDescendants.IsEmpty(),
|
||||
"Index should be known if parents index are");
|
||||
|
||||
nsIContent* child = mPosition.mNode->GetChildAt(0);
|
||||
nsIContent* child = mPosition.mNode->GetFirstChild();
|
||||
if (!child) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
@ -242,7 +242,7 @@ txXPathTreeWalker::moveToLastChild()
|
|||
if (!total) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
mPosition.mNode = mPosition.mNode->GetChildAt(total - 1);
|
||||
mPosition.mNode = mPosition.mNode->GetLastChild();
|
||||
|
||||
if (mCurrentIndex != kUnknownIndex &&
|
||||
!mDescendants.AppendValue(mCurrentIndex)) {
|
||||
|
|
|
@ -604,14 +604,12 @@ handleNode(nsINode* aNode, txStylesheetCompiler* aCompiler)
|
|||
// explicitly destroy the attrs here since we no longer need it
|
||||
atts = nsnull;
|
||||
|
||||
PRUint32 childCount = element->GetChildCount();
|
||||
if (childCount > 0) {
|
||||
PRUint32 counter = 0;
|
||||
nsIContent *child;
|
||||
while ((child = element->GetChildAt(counter++))) {
|
||||
rv = handleNode(child, aCompiler);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
for (nsIContent* child = element->GetFirstChild();
|
||||
child;
|
||||
child = child->GetNextSibling()) {
|
||||
|
||||
rv = handleNode(child, aCompiler);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
rv = aCompiler->endElement();
|
||||
|
@ -624,11 +622,10 @@ handleNode(nsINode* aNode, txStylesheetCompiler* aCompiler)
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
else if (aNode->IsNodeOfType(nsINode::eDOCUMENT)) {
|
||||
nsIDocument* document = static_cast<nsIDocument*>(aNode);
|
||||
|
||||
PRUint32 counter = 0;
|
||||
nsIContent *child;
|
||||
while ((child = document->GetChildAt(counter++))) {
|
||||
for (nsIContent* child = aNode->GetFirstChild();
|
||||
child;
|
||||
child = child->GetNextSibling()) {
|
||||
|
||||
rv = handleNode(child, aCompiler);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
|
|
@ -316,21 +316,19 @@ nsXULPopupListener::ClosePopup()
|
|||
}
|
||||
} // ClosePopup
|
||||
|
||||
static void
|
||||
GetImmediateChild(nsIContent* aContent, nsIAtom *aTag, nsIContent** aResult)
|
||||
static already_AddRefed<nsIContent>
|
||||
GetImmediateChild(nsIContent* aContent, nsIAtom *aTag)
|
||||
{
|
||||
*aResult = nsnull;
|
||||
PRInt32 childCount = aContent->GetChildCount();
|
||||
for (PRInt32 i = 0; i < childCount; i++) {
|
||||
nsIContent *child = aContent->GetChildAt(i);
|
||||
for (nsIContent* child = aContent->GetFirstChild();
|
||||
child;
|
||||
child = child->GetNextSibling()) {
|
||||
if (child->Tag() == aTag) {
|
||||
*aResult = child;
|
||||
NS_ADDREF(*aResult);
|
||||
return;
|
||||
NS_ADDREF(child);
|
||||
return child;
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -384,9 +382,7 @@ nsXULPopupListener::LaunchPopup(nsIDOMEvent* aEvent, nsIContent* aTargetContent)
|
|||
nsCOMPtr<nsIDOMElement> popupElement;
|
||||
|
||||
if (identifier.EqualsLiteral("_child")) {
|
||||
nsCOMPtr<nsIContent> popup;
|
||||
|
||||
GetImmediateChild(content, nsGkAtoms::menupopup, getter_AddRefs(popup));
|
||||
nsCOMPtr<nsIContent> popup = GetImmediateChild(content, nsGkAtoms::menupopup);
|
||||
if (popup)
|
||||
popupElement = do_QueryInterface(popup);
|
||||
else {
|
||||
|
|
|
@ -930,14 +930,14 @@ nsXULDocument::ExecuteOnBroadcastHandlerFor(nsIContent* aBroadcaster,
|
|||
// execute the handler.
|
||||
|
||||
nsCOMPtr<nsIContent> listener = do_QueryInterface(aListener);
|
||||
PRUint32 count = listener->GetChildCount();
|
||||
for (PRUint32 i = 0; i < count; ++i) {
|
||||
for (nsIContent* child = listener->GetFirstChild();
|
||||
child;
|
||||
child = child->GetNextSibling()) {
|
||||
|
||||
// Look for an <observes> element beneath the listener. This
|
||||
// ought to have an |element| attribute that refers to
|
||||
// aBroadcaster, and an |attribute| element that tells us what
|
||||
// attriubtes we're listening for.
|
||||
nsIContent *child = listener->GetChildAt(i);
|
||||
|
||||
if (!child->NodeInfo()->Equals(nsGkAtoms::observes, kNameSpaceID_XUL))
|
||||
continue;
|
||||
|
||||
|
@ -1764,10 +1764,11 @@ nsXULDocument::AddSubtreeToDocument(nsIContent* aContent)
|
|||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Recurse to children
|
||||
PRUint32 count = aElement->GetChildCount();
|
||||
for (nsIContent* child = aElement->GetLastChild();
|
||||
child;
|
||||
child = child->GetPreviousSibling()) {
|
||||
|
||||
while (count-- > 0) {
|
||||
rv = AddSubtreeToDocument(aElement->GetChildAt(count));
|
||||
rv = AddSubtreeToDocument(child);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
}
|
||||
|
@ -1798,10 +1799,11 @@ nsXULDocument::RemoveSubtreeFromDocument(nsIContent* aContent)
|
|||
}
|
||||
|
||||
// 1. Remove any children from the document.
|
||||
PRUint32 count = aElement->GetChildCount();
|
||||
for (nsIContent* child = aElement->GetLastChild();
|
||||
child;
|
||||
child = child->GetPreviousSibling()) {
|
||||
|
||||
while (count-- > 0) {
|
||||
rv = RemoveSubtreeFromDocument(aElement->GetChildAt(count));
|
||||
rv = RemoveSubtreeFromDocument(child);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
}
|
||||
|
@ -4077,7 +4079,7 @@ nsXULDocument::OverlayForwardReference::Merge(nsIContent* aTargetNode,
|
|||
nsCOMPtr<nsIContent> currContent;
|
||||
|
||||
for (i = 0; i < childCount; ++i) {
|
||||
currContent = aOverlayNode->GetChildAt(0);
|
||||
currContent = aOverlayNode->GetFirstChild();
|
||||
|
||||
nsIAtom *idAtom = currContent->GetID();
|
||||
|
||||
|
|
|
@ -59,13 +59,12 @@ nsContentSupportMap::Remove(nsIContent* aElement)
|
|||
{
|
||||
if (!mMap.ops)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
PL_DHashTableOperate(&mMap, aElement, PL_DHASH_REMOVE);
|
||||
|
||||
PRUint32 count = aElement->GetChildCount();
|
||||
for (PRUint32 i = 0; i < count; ++i) {
|
||||
Remove(aElement->GetChildAt(i));
|
||||
}
|
||||
|
||||
nsIContent* child = aElement;
|
||||
do {
|
||||
PL_DHashTableOperate(&mMap, child, PL_DHASH_REMOVE);
|
||||
child = child->GetNextNode(aElement);
|
||||
} while(child);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -81,9 +81,10 @@ public:
|
|||
Remove(nsIContent* aContent) {
|
||||
PL_DHashTableOperate(&mTable, aContent, PL_DHASH_REMOVE);
|
||||
|
||||
PRUint32 count = aContent->GetChildCount();
|
||||
for (PRUint32 i = 0; i < count; ++i) {
|
||||
Remove(aContent->GetChildAt(i));
|
||||
for (nsIContent* child = aContent->GetFirstChild();
|
||||
child;
|
||||
child = child->GetNextSibling()) {
|
||||
Remove(child);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -498,10 +498,9 @@ nsXULContentBuilder::BuildContentFromTemplate(nsIContent *aTemplateNode,
|
|||
|
||||
// Iterate through all of the template children, constructing
|
||||
// "real" content model nodes for each "template" child.
|
||||
PRUint32 count = aTemplateNode->GetChildCount();
|
||||
|
||||
for (PRUint32 kid = 0; kid < count; kid++) {
|
||||
nsIContent *tmplKid = aTemplateNode->GetChildAt(kid);
|
||||
for (nsIContent* tmplKid = aTemplateNode->GetFirstChild();
|
||||
tmplKid;
|
||||
tmplKid = tmplKid->GetNextSibling()) {
|
||||
|
||||
PRInt32 nameSpaceID = tmplKid->GetNameSpaceID();
|
||||
|
||||
|
@ -1935,8 +1934,10 @@ nsXULContentBuilder::InsertSortedNode(nsIContent* aContainer,
|
|||
staticCount = 0;
|
||||
} else {
|
||||
// compute the "static" XUL element count
|
||||
for (PRUint32 childLoop = 0; childLoop < numChildren; ++childLoop) {
|
||||
child = aContainer->GetChildAt(childLoop);
|
||||
for (nsIContent* child = aContainer->GetFirstChild();
|
||||
child;
|
||||
child = child->GetNextSibling()) {
|
||||
|
||||
if (nsContentUtils::HasNonEmptyAttr(child, kNameSpaceID_None,
|
||||
nsGkAtoms::_template))
|
||||
break;
|
||||
|
|
|
@ -201,13 +201,12 @@ nsXULContentUtils::FindChildByTag(nsIContent* aElement,
|
|||
nsIAtom* aTag,
|
||||
nsIContent** aResult)
|
||||
{
|
||||
PRUint32 count = aElement->GetChildCount();
|
||||
for (nsIContent* child = aElement->GetFirstChild();
|
||||
child;
|
||||
child = child->GetNextSibling()) {
|
||||
|
||||
for (PRUint32 i = 0; i < count; ++i) {
|
||||
nsIContent *kid = aElement->GetChildAt(i);
|
||||
|
||||
if (kid->NodeInfo()->Equals(aTag, aNameSpaceID)) {
|
||||
NS_ADDREF(*aResult = kid);
|
||||
if (child->NodeInfo()->Equals(aTag, aNameSpaceID)) {
|
||||
NS_ADDREF(*aResult = child);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -109,11 +109,9 @@ XULSortServiceImpl::SetSortColumnHints(nsIContent *content,
|
|||
{
|
||||
// set sort info on current column. This ensures that the
|
||||
// column header sort indicator is updated properly.
|
||||
PRUint32 numChildren = content->GetChildCount();
|
||||
|
||||
for (PRUint32 childIndex = 0; childIndex < numChildren; ++childIndex) {
|
||||
nsIContent *child = content->GetChildAt(childIndex);
|
||||
|
||||
for (nsIContent* child = content->GetFirstChild();
|
||||
child;
|
||||
child = child->GetNextSibling()) {
|
||||
if (child->IsXUL()) {
|
||||
nsIAtom *tag = child->Tag();
|
||||
|
||||
|
@ -177,11 +175,10 @@ XULSortServiceImpl::GetItemsToSort(nsIContent *aContainer,
|
|||
|
||||
aContainer = treechildren;
|
||||
}
|
||||
|
||||
PRUint32 count = aContainer->GetChildCount();
|
||||
for (PRUint32 c = 0; c < count; c++) {
|
||||
nsIContent *child = aContainer->GetChildAt(c);
|
||||
|
||||
|
||||
for (nsIContent* child = aContainer->GetFirstChild();
|
||||
child;
|
||||
child = child->GetNextSibling()) {
|
||||
contentSortInfo* cinfo = aSortItems.AppendElement();
|
||||
if (!cinfo)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
@ -199,9 +196,9 @@ XULSortServiceImpl::GetTemplateItemsToSort(nsIContent* aContainer,
|
|||
nsSortState* aSortState,
|
||||
nsTArray<contentSortInfo>& aSortItems)
|
||||
{
|
||||
PRUint32 numChildren = aContainer->GetChildCount();
|
||||
for (PRUint32 childIndex = 0; childIndex < numChildren; childIndex++) {
|
||||
nsIContent *child = aContainer->GetChildAt(childIndex);
|
||||
for (nsIContent* child = aContainer->GetFirstChild();
|
||||
child;
|
||||
child = child->GetNextSibling()) {
|
||||
|
||||
nsCOMPtr<nsIDOMElement> childnode = do_QueryInterface(child);
|
||||
|
||||
|
@ -347,9 +344,9 @@ XULSortServiceImpl::SortContainer(nsIContent *aContainer, nsSortState* aSortStat
|
|||
nsGkAtoms::_true, eCaseMatters))
|
||||
continue;
|
||||
|
||||
PRUint32 numChildren = child->GetChildCount();
|
||||
for (PRUint32 gcindex = 0; gcindex < numChildren; gcindex++) {
|
||||
nsIContent *grandchild = child->GetChildAt(gcindex);
|
||||
for (nsIContent* grandchild = child->GetFirstChild();
|
||||
grandchild;
|
||||
grandchild = grandchild->GetNextSibling()) {
|
||||
nsINodeInfo *ni = grandchild->NodeInfo();
|
||||
nsIAtom *localName = ni->NameAtom();
|
||||
if (ni->NamespaceID() == kNameSpaceID_XUL &&
|
||||
|
|
|
@ -1699,10 +1699,9 @@ nsXULTemplateBuilder::GetTemplateRoot(nsIContent** aResult)
|
|||
{
|
||||
// If root node has no template attribute, then look for a child
|
||||
// node which is a template tag
|
||||
PRUint32 count = mRoot->GetChildCount();
|
||||
|
||||
for (PRUint32 i = 0; i < count; ++i) {
|
||||
nsIContent *child = mRoot->GetChildAt(i);
|
||||
for (nsIContent* child = mRoot->GetFirstChild();
|
||||
child;
|
||||
child = child->GetNextSibling()) {
|
||||
|
||||
if (IsTemplateElement(child)) {
|
||||
NS_ADDREF(*aResult = child);
|
||||
|
@ -1856,10 +1855,10 @@ nsXULTemplateBuilder::CompileTemplate(nsIContent* aTemplate,
|
|||
PRBool isQuerySetMode = PR_FALSE;
|
||||
PRBool hasQuerySet = PR_FALSE, hasRule = PR_FALSE, hasQuery = PR_FALSE;
|
||||
|
||||
PRUint32 count = aTemplate->GetChildCount();
|
||||
for (nsIContent* rulenode = aTemplate->GetFirstChild();
|
||||
rulenode;
|
||||
rulenode = rulenode->GetNextSibling()) {
|
||||
|
||||
for (PRUint32 i = 0; i < count; i++) {
|
||||
nsIContent *rulenode = aTemplate->GetChildAt(i);
|
||||
nsINodeInfo *ni = rulenode->NodeInfo();
|
||||
|
||||
// don't allow more queries than can be supported
|
||||
|
@ -2243,12 +2242,11 @@ nsXULTemplateBuilder::CompileConditions(nsTemplateRule* aRule,
|
|||
aRule->SetTag(tagatom);
|
||||
}
|
||||
|
||||
PRUint32 count = aCondition->GetChildCount();
|
||||
|
||||
nsTemplateCondition* currentCondition = nsnull;
|
||||
|
||||
for (PRUint32 i = 0; i < count; i++) {
|
||||
nsIContent *node = aCondition->GetChildAt(i);
|
||||
for (nsIContent* node = aCondition->GetFirstChild();
|
||||
node;
|
||||
node = node->GetNextSibling()) {
|
||||
|
||||
if (node->NodeInfo()->Equals(nsGkAtoms::where, kNameSpaceID_XUL)) {
|
||||
nsresult rv = CompileWhereCondition(aRule, node, ¤tCondition);
|
||||
|
@ -2366,10 +2364,9 @@ nsXULTemplateBuilder::CompileBindings(nsTemplateRule* aRule, nsIContent* aBindin
|
|||
// Add an extended rule's bindings.
|
||||
nsresult rv;
|
||||
|
||||
PRUint32 count = aBindings->GetChildCount();
|
||||
|
||||
for (PRUint32 i = 0; i < count; ++i) {
|
||||
nsIContent *binding = aBindings->GetChildAt(i);
|
||||
for (nsIContent* binding = aBindings->GetFirstChild();
|
||||
binding;
|
||||
binding = binding->GetNextSibling()) {
|
||||
|
||||
if (binding->NodeInfo()->Equals(nsGkAtoms::binding,
|
||||
kNameSpaceID_XUL)) {
|
||||
|
@ -2481,10 +2478,11 @@ nsXULTemplateBuilder::AddSimpleRuleBindings(nsTemplateRule* aRule,
|
|||
}
|
||||
|
||||
// Push kids onto the stack, and search them next.
|
||||
count = element->GetChildCount();
|
||||
for (nsIContent* child = element->GetLastChild();
|
||||
child;
|
||||
child = child->GetPreviousSibling()) {
|
||||
|
||||
while (count-- > 0) {
|
||||
if (elements.AppendElement(element->GetChildAt(count)) == nsnull)
|
||||
if (!elements.AppendElement(child))
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1273,14 +1273,13 @@ nsXULTemplateQueryProcessorRDF::CompileExtendedQuery(nsRDFQuery* aQuery,
|
|||
|
||||
TestNode* prevnode = idnode;
|
||||
|
||||
PRUint32 count = aConditions->GetChildCount();
|
||||
|
||||
for (PRUint32 i = 0; i < count; ++i) {
|
||||
nsIContent *condition = aConditions->GetChildAt(i);
|
||||
for (nsIContent* condition = aConditions->GetFirstChild();
|
||||
condition;
|
||||
condition = condition->GetNextSibling()) {
|
||||
|
||||
// the <content> condition should always be the first child
|
||||
if (condition->Tag() == nsGkAtoms::content) {
|
||||
if (i) {
|
||||
if (condition != aConditions->GetFirstChild()) {
|
||||
nsXULContentUtils::LogTemplateError(ERROR_TEMPLATE_CONTENT_NOT_FIRST);
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -328,10 +328,9 @@ nsXULTemplateQueryProcessorStorage::CompileQuery(nsIXULTemplateBuilder* aBuilder
|
|||
}
|
||||
|
||||
PRUint32 parameterCount = 0;
|
||||
PRUint32 count = queryContent->GetChildCount();
|
||||
|
||||
for (PRUint32 i = 0; i < count; ++i) {
|
||||
nsIContent *child = queryContent->GetChildAt(i);
|
||||
for (nsIContent* child = queryContent->GetFirstChild();
|
||||
child;
|
||||
child = child->GetNextSibling()) {
|
||||
|
||||
if (child->NodeInfo()->Equals(nsGkAtoms::param, kNameSpaceID_XUL)) {
|
||||
nsAutoString value;
|
||||
|
|
|
@ -305,9 +305,10 @@ nsXULTemplateQueryProcessorXML::CompileQuery(nsIXULTemplateBuilder* aBuilder,
|
|||
new nsXMLQuery(this, aMemberVariable, compiledexpr);
|
||||
NS_ENSURE_TRUE(query, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
PRUint32 count = content->GetChildCount();
|
||||
for (PRUint32 i = 0; i < count; ++i) {
|
||||
nsIContent *condition = content->GetChildAt(i);
|
||||
for (nsIContent* condition = content->GetFirstChild();
|
||||
condition;
|
||||
condition = condition->GetNextSibling()) {
|
||||
|
||||
if (condition->NodeInfo()->Equals(nsGkAtoms::assign,
|
||||
kNameSpaceID_XUL)) {
|
||||
nsAutoString var;
|
||||
|
|
|
@ -96,9 +96,10 @@ nsXULTemplateResultXML::GetIsEmpty(PRBool* aIsEmpty)
|
|||
// a node is considered empty if it has no elements as children
|
||||
nsCOMPtr<nsIContent> content = do_QueryInterface(mNode);
|
||||
if (content) {
|
||||
PRUint32 count = content->GetChildCount();
|
||||
for (PRUint32 c = 0; c < count; c++) {
|
||||
if (content->GetChildAt(c)->IsElement()) {
|
||||
for (nsIContent* child = content->GetFirstChild();
|
||||
child;
|
||||
child = child->GetNextSibling()) {
|
||||
if (child->IsElement()) {
|
||||
*aIsEmpty = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -1362,10 +1362,10 @@ nsXULTreeBuilder::EnsureSortVariables()
|
|||
|
||||
if (!treecols)
|
||||
return NS_OK;
|
||||
|
||||
PRUint32 count = treecols->GetChildCount();
|
||||
for (PRUint32 i = 0; i < count; ++i) {
|
||||
nsIContent *child = treecols->GetChildAt(i);
|
||||
|
||||
for (nsIContent* child = treecols->GetFirstChild();
|
||||
child;
|
||||
child = child->GetNextSibling()) {
|
||||
|
||||
if (child->NodeInfo()->Equals(nsGkAtoms::treecol,
|
||||
kNameSpaceID_XUL)) {
|
||||
|
@ -1501,11 +1501,11 @@ nsXULTreeBuilder::GetTemplateActionCellFor(PRInt32 aRow,
|
|||
aCol->GetAtom(getter_AddRefs(colAtom));
|
||||
aCol->GetIndex(&colIndex);
|
||||
|
||||
PRUint32 count = row->GetChildCount();
|
||||
PRUint32 j = 0;
|
||||
for (PRUint32 i = 0; i < count; ++i) {
|
||||
nsIContent *child = row->GetChildAt(i);
|
||||
|
||||
for (nsIContent* child = row->GetFirstChild();
|
||||
child;
|
||||
child = child->GetNextSibling()) {
|
||||
|
||||
if (child->NodeInfo()->Equals(nsGkAtoms::treecell,
|
||||
kNameSpaceID_XUL)) {
|
||||
if (colAtom &&
|
||||
|
|
|
@ -8159,6 +8159,11 @@ nsGlobalWindow::GetGlobalStorage(nsIDOMStorageList ** aGlobalStorage)
|
|||
{
|
||||
NS_ENSURE_ARG_POINTER(aGlobalStorage);
|
||||
|
||||
nsCOMPtr<nsIDocument> document = do_QueryInterface(GetExtantDocument());
|
||||
if (document) {
|
||||
document->WarnOnceAbout(nsIDocument::eGlobalStorage);
|
||||
}
|
||||
|
||||
if (!Preferences::GetBool(kStorageEnabled)) {
|
||||
*aGlobalStorage = nsnull;
|
||||
return NS_OK;
|
||||
|
|
|
@ -111,3 +111,11 @@ EnablePrivilegeWarning=Use of enablePrivilege is deprecated. Please use code th
|
|||
nsIJSONDecodeDeprecatedWarning=nsIJSON.decode is deprecated. Please use JSON.parse instead.
|
||||
nsIJSONEncodeDeprecatedWarning=nsIJSON.encode is deprecated. Please use JSON.stringify instead.
|
||||
nsIDOMWindowInternalWarning=Use of nsIDOMWindowInternal is deprecated. Use nsIDOMWindow instead.
|
||||
IsSameNodeWarning=Use of isSameNode is deprecated. Please use A == B to test for equality instead.
|
||||
ReplaceWholeTextWarning=Use of replaceWholeText is deprecated. Please call normalize() on the parent and set the data attribute, or use textContent instead.
|
||||
XmlEncodingWarning=Use of xmlEncoding is deprecated.
|
||||
XmlVersionWarning=Use of xmlVersion is deprecated.
|
||||
InputEncodingWarning=Use of inputEncoding is deprecated.
|
||||
XmlStandaloneWarning=Use of xmlStandalone is deprecated.
|
||||
IsElementContentWhitespaceWarning=Use of isElementContentWhitespaceWarning is deprecated.
|
||||
GlobalStorageWarning=Use of globalStorage is deprecated. Please use localStorage instead.
|
||||
|
|
|
@ -48,4 +48,4 @@ struct THEBES_API gfxPointH3D : public mozilla::gfx::BasePoint4D<float, gfxPoint
|
|||
gfxPointH3D(float aX, float aY, float aZ, float aW) : Super(aX, aY, aZ, aW) {}
|
||||
};
|
||||
|
||||
#endif /* GFX_POINTH3D_H */
|
||||
#endif /* GFX_POINTH3D_H */
|
||||
|
|
|
@ -308,7 +308,6 @@ hlink.h
|
|||
ia64/sys/inline.h
|
||||
Icons.h
|
||||
iconv.h
|
||||
IDL.h
|
||||
ieeefp.h
|
||||
ifaddrs.h
|
||||
image.h
|
||||
|
@ -404,7 +403,6 @@ libgnomevfs/gnome-vfs-mime-handlers.h
|
|||
libgnomevfs/gnome-vfs-mime-utils.h
|
||||
libgnomevfs/gnome-vfs-ops.h
|
||||
libgnomevfs/gnome-vfs-standard-callbacks.h
|
||||
libIDL/IDL.h
|
||||
lib$routines.h
|
||||
libnotify/notify.h
|
||||
limits
|
||||
|
|
|
@ -416,7 +416,7 @@ struct Registers {
|
|||
|
||||
/* Get a register which is not live before a FASTCALL. */
|
||||
static inline RegisterID tempCallReg() {
|
||||
Registers regs(AvailRegs);
|
||||
Registers regs(TempRegs);
|
||||
regs.takeReg(Registers::ArgReg0);
|
||||
regs.takeReg(Registers::ArgReg1);
|
||||
return regs.takeAnyReg().reg();
|
||||
|
|
|
@ -817,12 +817,6 @@ customMethodCalls = {
|
|||
'thisType': 'nsINode',
|
||||
'canFail': False
|
||||
},
|
||||
'nsIDOMNode_IsSameNode': {
|
||||
'thisType': 'nsINode',
|
||||
'arg0Type': 'nsINode',
|
||||
'code': ' PRBool result = self == arg0;',
|
||||
'canFail': False
|
||||
},
|
||||
'nsIDOMNode_LookupPrefix': {
|
||||
'thisType': 'nsINode',
|
||||
'canFail': False
|
||||
|
|
|
@ -256,11 +256,23 @@ function OnRefTestLoad()
|
|||
|
||||
function InitAndStartRefTests()
|
||||
{
|
||||
/* set the gLoadTimeout */
|
||||
/* These prefs are optional, so we don't need to spit an error to the log */
|
||||
try {
|
||||
var prefs = Components.classes["@mozilla.org/preferences-service;1"].
|
||||
getService(Components.interfaces.nsIPrefBranch2);
|
||||
} catch(e) {
|
||||
gDumpLog("REFTEST TEST-UNEXPECTED-FAIL | | EXCEPTION: " + e + "\n");
|
||||
}
|
||||
|
||||
/* set the gLoadTimeout */
|
||||
try {
|
||||
gLoadTimeout = prefs.getIntPref("reftest.timeout");
|
||||
} catch(e) {
|
||||
gLoadTimeout = 5 * 60 * 1000; //5 minutes as per bug 479518
|
||||
}
|
||||
|
||||
/* Get the logfile for android tests */
|
||||
try {
|
||||
logFile = prefs.getCharPref("reftest.logFile");
|
||||
if (logFile) {
|
||||
try {
|
||||
|
@ -273,13 +285,19 @@ function InitAndStartRefTests()
|
|||
gDumpLog = dump;
|
||||
}
|
||||
}
|
||||
} catch(e) {}
|
||||
|
||||
try {
|
||||
gRemote = prefs.getBoolPref("reftest.remote");
|
||||
gIgnoreWindowSize = prefs.getBoolPref("reftest.ignoreWindowSize");
|
||||
}
|
||||
catch(e) {
|
||||
gLoadTimeout = 5 * 60 * 1000; //5 minutes as per bug 479518
|
||||
} catch(e) {
|
||||
gRemote = false;
|
||||
}
|
||||
|
||||
try {
|
||||
gIgnoreWindowSize = prefs.getBoolPref("reftest.ignoreWindowSize");
|
||||
} catch(e) {
|
||||
gIgnoreWindowSize = false;
|
||||
}
|
||||
|
||||
/* Support for running a chunk (subset) of tests. In separate try as this is optional */
|
||||
try {
|
||||
|
|
|
@ -312,7 +312,7 @@
|
|||
</xul:label>
|
||||
</xul:vbox>
|
||||
<xul:hbox anonid="input-container" class="setting-input">
|
||||
<children includes="button"/>
|
||||
<children includes="button|menulist"/>
|
||||
</xul:hbox>
|
||||
</content>
|
||||
</binding>
|
||||
|
|
|
@ -4,6 +4,15 @@
|
|||
<setting pref="extensions.inlinesettings1.boolint" type="boolint" on="1" off="2" title="BoolInt"/>
|
||||
<setting pref="extensions.inlinesettings1.integer" type="integer" title="Integer"/>
|
||||
<setting pref="extensions.inlinesettings1.string" type="string" title="String"/>
|
||||
<setting type="control" title="Menulist">
|
||||
<menulist sizetopopup="always" oncommand="window._testValue = this.value;">
|
||||
<menupopup>
|
||||
<menuitem label="Alpha" value="1" />
|
||||
<menuitem label="Bravo" value="2" />
|
||||
<menuitem label="Charlie" value="3" />
|
||||
</menupopup>
|
||||
</menulist>
|
||||
</setting>
|
||||
<setting pref="extensions.inlinesettings1.color" type="color" title="Color"/>
|
||||
<setting pref="extensions.inlinesettings1.file" type="file" title="File"/>
|
||||
<setting pref="extensions.inlinesettings1.directory" type="directory" title="Directory"/>
|
||||
|
|
|
@ -8,7 +8,7 @@ var gManagerWindow;
|
|||
var gCategoryUtilities;
|
||||
var gProvider;
|
||||
|
||||
const SETTINGS_ROWS = 7;
|
||||
const SETTINGS_ROWS = 8;
|
||||
|
||||
var observer = {
|
||||
lastData: null,
|
||||
|
@ -191,8 +191,17 @@ add_test(function() {
|
|||
is(Services.prefs.getCharPref("extensions.inlinesettings1.string"), "bar", "String pref should have been updated");
|
||||
|
||||
ok(!settings[4].hasAttribute("first-row"), "Not the first row");
|
||||
var input = settings[4].firstElementChild;
|
||||
is(input.value, "1", "Menulist should have initial value");
|
||||
input.focus();
|
||||
EventUtils.synthesizeKey("b", {}, gManagerWindow);
|
||||
is(input.value, "2", "Menulist should have updated value");
|
||||
is(gManagerWindow._testValue, "2", "Menulist oncommand handler should've updated the test value");
|
||||
delete gManagerWindow._testValue;
|
||||
|
||||
ok(!settings[5].hasAttribute("first-row"), "Not the first row");
|
||||
Services.prefs.setCharPref("extensions.inlinesettings1.color", "#FF0000");
|
||||
input = gManagerWindow.document.getAnonymousElementByAttribute(settings[4], "anonid", "input");
|
||||
input = gManagerWindow.document.getAnonymousElementByAttribute(settings[5], "anonid", "input");
|
||||
is(input.color, "#FF0000", "Color picker should have initial value");
|
||||
input.focus();
|
||||
EventUtils.synthesizeKey("VK_RIGHT", {}, gManagerWindow);
|
||||
|
@ -205,9 +214,9 @@ add_test(function() {
|
|||
try {
|
||||
mockFilePickerFactory.register();
|
||||
|
||||
ok(!settings[5].hasAttribute("first-row"), "Not the first row");
|
||||
var button = gManagerWindow.document.getAnonymousElementByAttribute(settings[5], "anonid", "button");
|
||||
input = gManagerWindow.document.getAnonymousElementByAttribute(settings[5], "anonid", "input");
|
||||
ok(!settings[6].hasAttribute("first-row"), "Not the first row");
|
||||
var button = gManagerWindow.document.getAnonymousElementByAttribute(settings[6], "anonid", "button");
|
||||
input = gManagerWindow.document.getAnonymousElementByAttribute(settings[6], "anonid", "input");
|
||||
is(input.value, "", "Label value should be empty");
|
||||
|
||||
var profD = Services.dirsvc.get("ProfD", Ci.nsIFile);
|
||||
|
@ -227,9 +236,9 @@ add_test(function() {
|
|||
is(input.value, profD.path, "Label value should not have changed");
|
||||
is(Services.prefs.getCharPref("extensions.inlinesettings1.file"), profD.path, "File pref should not have changed");
|
||||
|
||||
ok(!settings[6].hasAttribute("first-row"), "Not the first row");
|
||||
button = gManagerWindow.document.getAnonymousElementByAttribute(settings[6], "anonid", "button");
|
||||
input = gManagerWindow.document.getAnonymousElementByAttribute(settings[6], "anonid", "input");
|
||||
ok(!settings[7].hasAttribute("first-row"), "Not the first row");
|
||||
button = gManagerWindow.document.getAnonymousElementByAttribute(settings[7], "anonid", "button");
|
||||
input = gManagerWindow.document.getAnonymousElementByAttribute(settings[7], "anonid", "input");
|
||||
is(input.value, "", "Label value should be empty");
|
||||
|
||||
_returnFile = profD;
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
Wed Dec 2 14:35:41 EST 1998
|
||||
|
||||
xpidl depends on Andrew Veliath and Elliot Lee's libIDL, a part of the
|
||||
GNOME ORBit C ORB. We currently require libIDL >= 0.6.3, which in turn
|
||||
requires glib >= 1.2.0.
|
||||
|
||||
libIDL builds for Linux and Win32 can be found, along with source
|
||||
tarballs, at http://www.rpi.edu/~veliaa/libIDL/, and Win32 users will
|
||||
need glib 1.2 and glib 1.2-dev from
|
||||
http://user.sgic.fi/~tml/gimp/win32/. Source and Linux RPMs are also
|
||||
available from ftp://ftp.mozilla.org/pub/mozilla/libraries, and Win32
|
||||
binaries are included in the wintools.zip file at
|
||||
ftp://ftp.mozilla.org/pub/mozilla/source/wintools.zip. A Mac project
|
||||
is in progress, and should be appearing shortly.
|
||||
|
||||
glib tarballs and RPMs for Linux can be found through http://www.gtk.org.
|
|
@ -1,293 +0,0 @@
|
|||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
* Main xpidl program entry point.
|
||||
*/
|
||||
|
||||
#include "xpidl.h"
|
||||
|
||||
static ModeData modes[] = {
|
||||
{"header", "Generate C++ header", "h", xpidl_header_dispatch},
|
||||
{"typelib", "Generate XPConnect typelib", "xpt", xpidl_typelib_dispatch},
|
||||
{"doc", "Generate HTML documentation", "html", xpidl_doc_dispatch},
|
||||
{"java", "Generate Java interface", "java", xpidl_java_dispatch},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
static ModeData *
|
||||
FindMode(char *mode)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; modes[i].mode; i++) {
|
||||
if (!strcmp(modes[i].mode, mode))
|
||||
return &modes[i];
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gboolean enable_debug = FALSE;
|
||||
gboolean enable_warnings = FALSE;
|
||||
gboolean verbose_mode = FALSE;
|
||||
gboolean emit_typelib_annotations = FALSE;
|
||||
gboolean explicit_output_filename = FALSE;
|
||||
FILE *deps = NULL;
|
||||
|
||||
/* The following globals are explained in xpt_struct.h */
|
||||
PRUint8 major_version = XPT_MAJOR_VERSION;
|
||||
PRUint8 minor_version = XPT_MINOR_VERSION;
|
||||
|
||||
static char xpidl_usage_str[] =
|
||||
"Usage: %s -m mode [-w] [-v] [-t version number] [-d filename.pp]\n"
|
||||
" [-I path] [-o basename | -e filename.ext] filename.idl\n"
|
||||
" -a emit annotations to typelib\n"
|
||||
" -w turn on warnings (recommended)\n"
|
||||
" -v verbose mode (NYI)\n"
|
||||
" -t create a typelib of a specific version number\n"
|
||||
" -I add entry to start of include path for ``#include \"nsIThing.idl\"''\n"
|
||||
" -o use basename (e.g. ``/tmp/nsIThing'') for output\n"
|
||||
" -e use explicit output filename\n"
|
||||
" -d write dependencies (requires -e)\n"
|
||||
" -m specify output mode:\n";
|
||||
|
||||
static void
|
||||
xpidl_usage(int argc, char *argv[])
|
||||
{
|
||||
int i;
|
||||
fprintf(stderr, xpidl_usage_str, argv[0]);
|
||||
for (i = 0; modes[i].mode; i++) {
|
||||
fprintf(stderr, " %-12s %-30s (.%s)\n", modes[i].mode,
|
||||
modes[i].modeInfo, modes[i].suffix);
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int i;
|
||||
IncludePathEntry *inc, *inc_head, **inc_tail;
|
||||
char *file_basename = NULL;
|
||||
ModeData *mode = NULL;
|
||||
gboolean create_old_typelib = FALSE;
|
||||
|
||||
/* turn this on for extra checking of our code */
|
||||
/* IDL_check_cast_enable(TRUE); */
|
||||
|
||||
inc_head = xpidl_malloc(sizeof *inc);
|
||||
inc_head->directory = ".";
|
||||
inc_head->next = NULL;
|
||||
inc_tail = &inc_head->next;
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (argv[i][0] != '-')
|
||||
break;
|
||||
switch (argv[i][1]) {
|
||||
case '-':
|
||||
argc++; /* pretend we didn't see this */
|
||||
/* fall through */
|
||||
case 0: /* - is a legal input filename (stdin) */
|
||||
goto done_options;
|
||||
case 'a':
|
||||
emit_typelib_annotations = TRUE;
|
||||
break;
|
||||
case 'w':
|
||||
enable_warnings = TRUE;
|
||||
break;
|
||||
case 'v':
|
||||
verbose_mode = TRUE;
|
||||
break;
|
||||
case 't':
|
||||
{
|
||||
/* Parse for "-t version number" and store it into global boolean
|
||||
* and string variables.
|
||||
*/
|
||||
const gchar* typelib_version_string = NULL;
|
||||
|
||||
/*
|
||||
* If -t is the last argument on the command line, we have a problem
|
||||
*/
|
||||
|
||||
if (i + 1 == argc) {
|
||||
fprintf(stderr, "ERROR: missing version number after -t\n");
|
||||
xpidl_usage(argc, argv);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Do not allow more than one "-t" definition */
|
||||
if (create_old_typelib) {
|
||||
fprintf(stderr,
|
||||
"ERROR: -t argument used twice. "
|
||||
"Cannot specify more than one version\n");
|
||||
xpidl_usage(argc, argv);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Assume that the argument after "-t" is the version number string
|
||||
* and search for it in our internal list of acceptable version
|
||||
* numbers.
|
||||
*/
|
||||
switch (XPT_ParseVersionString(argv[++i], &major_version,
|
||||
&minor_version)) {
|
||||
case XPT_VERSION_CURRENT:
|
||||
break;
|
||||
case XPT_VERSION_OLD:
|
||||
create_old_typelib = TRUE;
|
||||
break;
|
||||
case XPT_VERSION_UNSUPPORTED:
|
||||
fprintf(stderr, "ERROR: version \"%s\" not supported.\n",
|
||||
argv[i]);
|
||||
xpidl_usage(argc, argv);
|
||||
return 1;
|
||||
case XPT_VERSION_UNKNOWN:
|
||||
default:
|
||||
fprintf(stderr, "ERROR: version \"%s\" not recognised.\n",
|
||||
argv[i]);
|
||||
xpidl_usage(argc, argv);
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'I':
|
||||
if (argv[i][2] == '\0' && i == argc) {
|
||||
fputs("ERROR: missing path after -I\n", stderr);
|
||||
xpidl_usage(argc, argv);
|
||||
return 1;
|
||||
}
|
||||
inc = xpidl_malloc(sizeof *inc);
|
||||
if (argv[i][2] == '\0') {
|
||||
/* is it the -I foo form? */
|
||||
inc->directory = argv[++i];
|
||||
} else {
|
||||
/* must be the -Ifoo form. Don't preincrement i. */
|
||||
inc->directory = argv[i] + 2;
|
||||
}
|
||||
#ifdef DEBUG_shaver_includes
|
||||
fprintf(stderr, "adding %s to include path\n", inc->directory);
|
||||
#endif
|
||||
inc->next = NULL;
|
||||
*inc_tail = inc;
|
||||
inc_tail = &inc->next;
|
||||
break;
|
||||
case 'o':
|
||||
if (i == argc) {
|
||||
fprintf(stderr, "ERROR: missing basename after -o\n");
|
||||
xpidl_usage(argc, argv);
|
||||
return 1;
|
||||
}
|
||||
file_basename = argv[++i];
|
||||
explicit_output_filename = FALSE;
|
||||
break;
|
||||
case 'e':
|
||||
if (i == argc) {
|
||||
fprintf(stderr, "ERROR: missing basename after -e\n");
|
||||
xpidl_usage(argc, argv);
|
||||
return 1;
|
||||
}
|
||||
file_basename = argv[++i];
|
||||
explicit_output_filename = TRUE;
|
||||
break;
|
||||
case 'd':
|
||||
if (!explicit_output_filename) {
|
||||
fprintf(stderr, "ERROR: -d requires -e\n");
|
||||
xpidl_usage(argc, argv);
|
||||
return 1;
|
||||
}
|
||||
if (i == argc) {
|
||||
fprintf(stderr, "ERROR: missing filename after -d\n");
|
||||
xpidl_usage(argc, argv);
|
||||
return 1;
|
||||
}
|
||||
deps = fopen(argv[++i], "w");
|
||||
if (deps)
|
||||
fprintf(deps, "%s:", file_basename);
|
||||
break;
|
||||
case 'm':
|
||||
if (i + 1 == argc) {
|
||||
fprintf(stderr, "ERROR: missing modename after -m\n");
|
||||
xpidl_usage(argc, argv);
|
||||
return 1;
|
||||
}
|
||||
if (mode) {
|
||||
fprintf(stderr,
|
||||
"ERROR: must specify exactly one mode "
|
||||
"(first \"%s\", now \"%s\")\n", mode->mode,
|
||||
argv[i + 1]);
|
||||
xpidl_usage(argc, argv);
|
||||
return 1;
|
||||
}
|
||||
mode = FindMode(argv[++i]);
|
||||
if (!mode) {
|
||||
fprintf(stderr, "ERROR: unknown mode \"%s\"\n", argv[i]);
|
||||
xpidl_usage(argc, argv);
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "unknown option %s\n", argv[i]);
|
||||
xpidl_usage(argc, argv);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
done_options:
|
||||
if (!mode) {
|
||||
fprintf(stderr, "ERROR: must specify output mode\n");
|
||||
xpidl_usage(argc, argv);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Don't try to process multiple files, given that we don't handle -o
|
||||
* multiply.
|
||||
*/
|
||||
if (i < argc) {
|
||||
i = xpidl_process_idl(argv[i], inc_head, file_basename, mode);
|
||||
} else {
|
||||
if (argc > i + 1) {
|
||||
fprintf(stderr, "ERROR: extra arguments after input file\n");
|
||||
} else {
|
||||
fprintf(stderr, "ERROR: no file to process\n");
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (deps) {
|
||||
fprintf(deps, "\n");
|
||||
fclose(deps);
|
||||
}
|
||||
|
||||
return !i;
|
||||
}
|
|
@ -1,275 +0,0 @@
|
|||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
* Intramodule declarations.
|
||||
*/
|
||||
|
||||
#ifndef __xpidl_h
|
||||
#define __xpidl_h
|
||||
|
||||
#include <errno.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <glib.h>
|
||||
#include <string.h> /* After glib.h to avoid warnings about shadowing 'index'. */
|
||||
|
||||
#include <libIDL/IDL.h>
|
||||
|
||||
#include <xpt_struct.h>
|
||||
|
||||
/*
|
||||
* IDL_tree_warning bombs on libIDL version 6.5, and I don't want to not write
|
||||
* warnings... so I define a versioned one here. Thanks to Mike Shaver for the
|
||||
* this solution, which allows us to pass through varargs calls.
|
||||
*/
|
||||
#if !(LIBIDL_MAJOR_VERSION == 0 && LIBIDL_MINOR_VERSION == 6 && \
|
||||
LIBIDL_MICRO_VERSION == 5) && !defined(DEBUG_shaver)
|
||||
/*
|
||||
* This turns a varargs call to XPIDL_WARNING directly into a varargs
|
||||
* call to IDL_tree_warning or xpidl_tree_warning as appropriate. The
|
||||
* only tricky bit is that you must call XPIDL_WARNING with extra
|
||||
* parens, e.g. XPIDL_WARNING((foo, bar, "sil"))
|
||||
*
|
||||
* Probably best removed when we leave 6.5. */
|
||||
#define XPIDL_WARNING(x) IDL_tree_warning x
|
||||
#else
|
||||
extern void xpidl_tree_warning(IDL_tree p, int level, const char *fmt, ...);
|
||||
#define XPIDL_WARNING(x) xpidl_tree_warning x
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Internal operation flags.
|
||||
*/
|
||||
extern gboolean enable_debug;
|
||||
extern gboolean enable_warnings;
|
||||
extern gboolean verbose_mode;
|
||||
extern gboolean emit_typelib_annotations;
|
||||
extern gboolean explicit_output_filename;
|
||||
extern FILE *deps;
|
||||
|
||||
extern PRUint8 major_version;
|
||||
extern PRUint8 minor_version;
|
||||
|
||||
typedef struct TreeState TreeState;
|
||||
|
||||
/*
|
||||
* A function to handle an IDL_tree type.
|
||||
*/
|
||||
typedef gboolean (*nodeHandler)(TreeState *);
|
||||
|
||||
/*
|
||||
* Struct containing functions to define the behavior of a given output mode.
|
||||
*/
|
||||
typedef struct backend {
|
||||
nodeHandler *dispatch_table; /* nodeHandlers table, indexed by node type. */
|
||||
nodeHandler emit_prolog; /* called at beginning of output generation. */
|
||||
nodeHandler emit_epilog; /* called at end. */
|
||||
} backend;
|
||||
|
||||
/* Function that produces a struct of output-generation functions */
|
||||
typedef backend *(*backendFactory)();
|
||||
|
||||
extern backend *xpidl_header_dispatch(void);
|
||||
extern backend *xpidl_typelib_dispatch(void);
|
||||
extern backend *xpidl_doc_dispatch(void);
|
||||
extern backend *xpidl_java_dispatch(void);
|
||||
|
||||
typedef struct ModeData {
|
||||
char *mode;
|
||||
char *modeInfo;
|
||||
char *suffix;
|
||||
backendFactory factory;
|
||||
} ModeData;
|
||||
|
||||
typedef struct IncludePathEntry {
|
||||
char *directory;
|
||||
struct IncludePathEntry *next;
|
||||
} IncludePathEntry;
|
||||
|
||||
struct TreeState {
|
||||
FILE *file;
|
||||
char *filename;
|
||||
/* Maybe supplied by -o. Not related to (g_)basename from string.h or glib */
|
||||
char *basename;
|
||||
IDL_ns ns;
|
||||
IDL_tree tree;
|
||||
GSList *base_includes;
|
||||
nodeHandler *dispatch;
|
||||
void *priv; /* mode-private data */
|
||||
};
|
||||
|
||||
struct java_priv_data {
|
||||
GHashTable *typedefTable;
|
||||
GHashTable *keywords;
|
||||
char *filename;
|
||||
GHashTable *nonIDLIfaces;
|
||||
};
|
||||
|
||||
/*
|
||||
* Process an IDL file, generating InterfaceInfo, documentation and headers as
|
||||
* appropriate.
|
||||
*/
|
||||
int
|
||||
xpidl_process_idl(char *filename, IncludePathEntry *include_path,
|
||||
char *file_basename, ModeData *mode);
|
||||
|
||||
/*
|
||||
* Iterate over an IDLN_LIST -- why is this not part of libIDL?
|
||||
*/
|
||||
void
|
||||
xpidl_list_foreach(IDL_tree p, IDL_tree_func foreach, gpointer user_data);
|
||||
|
||||
/*
|
||||
* Wrapper whines to stderr then exits after null return from malloc or strdup.
|
||||
*/
|
||||
void *
|
||||
xpidl_malloc(size_t nbytes);
|
||||
|
||||
char *
|
||||
xpidl_strdup(const char *s);
|
||||
|
||||
/*
|
||||
* Return a pointer to the start of the base filename of path
|
||||
*/
|
||||
const char *
|
||||
xpidl_basename(const char * path);
|
||||
|
||||
/*
|
||||
* Process an XPIDL node and its kids, if any.
|
||||
*/
|
||||
gboolean
|
||||
xpidl_process_node(TreeState *state);
|
||||
|
||||
/*
|
||||
* Write a newline folllowed by an indented, one-line comment containing IDL
|
||||
* source decompiled from state->tree.
|
||||
*/
|
||||
void
|
||||
xpidl_write_comment(TreeState *state, int indent);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Functions for parsing and printing UUIDs.
|
||||
*/
|
||||
|
||||
/*
|
||||
* How large should the buffer supplied to xpidl_sprint_IID be?
|
||||
*/
|
||||
#define UUID_LENGTH 37
|
||||
|
||||
/*
|
||||
* Print an iid to into a supplied buffer; the buffer should be at least
|
||||
* UUID_LENGTH bytes.
|
||||
*/
|
||||
gboolean
|
||||
xpidl_sprint_iid(nsID *iid, char iidbuf[]);
|
||||
|
||||
/*
|
||||
* Parse a uuid string into an nsID struct. We cannot link against libxpcom,
|
||||
* so we re-implement nsID::Parse here.
|
||||
*/
|
||||
gboolean
|
||||
xpidl_parse_iid(nsID *id, const char *str);
|
||||
|
||||
|
||||
/* Try to common a little node-handling stuff. */
|
||||
|
||||
/* is this node from an aggregate type (interface)? */
|
||||
#define UP_IS_AGGREGATE(node) \
|
||||
(IDL_NODE_UP(node) && \
|
||||
(IDL_NODE_TYPE(IDL_NODE_UP(node)) == IDLN_INTERFACE || \
|
||||
IDL_NODE_TYPE(IDL_NODE_UP(node)) == IDLN_FORWARD_DCL))
|
||||
|
||||
#define UP_IS_NATIVE(node) \
|
||||
(IDL_NODE_UP(node) && \
|
||||
IDL_NODE_TYPE(IDL_NODE_UP(node)) == IDLN_NATIVE)
|
||||
|
||||
#define DIPPER_TYPE(node) \
|
||||
(NULL != IDL_tree_property_get(node, "domstring") || \
|
||||
NULL != IDL_tree_property_get(node, "utf8string") || \
|
||||
NULL != IDL_tree_property_get(node, "cstring") || \
|
||||
NULL != IDL_tree_property_get(node, "astring"))
|
||||
|
||||
/*
|
||||
* Find the underlying type of an identifier typedef. Returns NULL
|
||||
* (and doesn't complain) on failure.
|
||||
*/
|
||||
IDL_tree /* IDL_TYPE_DCL */
|
||||
find_underlying_type(IDL_tree typedef_ident);
|
||||
|
||||
/*
|
||||
* Check that const declarations match their stated sign and are of the
|
||||
* appropriate types.
|
||||
*/
|
||||
gboolean
|
||||
verify_const_declaration(IDL_tree const_tree);
|
||||
|
||||
/*
|
||||
* Check that scriptable attributes in scriptable interfaces actually are.
|
||||
*/
|
||||
gboolean
|
||||
verify_attribute_declaration(IDL_tree method_tree);
|
||||
|
||||
/*
|
||||
* Perform various validation checks on methods.
|
||||
*/
|
||||
gboolean
|
||||
verify_method_declaration(IDL_tree method_tree);
|
||||
|
||||
/*
|
||||
* Verifies the interface declaration
|
||||
*/
|
||||
gboolean
|
||||
verify_interface_declaration(IDL_tree method_tree);
|
||||
|
||||
/*
|
||||
* Verify that a native declaration has an associated C++ expression, i.e. that
|
||||
* it's of the form native <idl-name>(<c++-name>)
|
||||
*/
|
||||
gboolean
|
||||
check_native(TreeState *state);
|
||||
|
||||
void
|
||||
printlist(FILE *outfile, GSList *slist);
|
||||
|
||||
gboolean
|
||||
is_method_scriptable(IDL_tree method_tree, IDL_tree ident);
|
||||
|
||||
#endif /* __xpidl_h */
|
|
@ -1,312 +0,0 @@
|
|||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "xpidl.h"
|
||||
|
||||
/*
|
||||
* Generates documentation from javadoc-style comments in XPIDL files.
|
||||
*/
|
||||
|
||||
static gboolean
|
||||
doc_prolog(TreeState *state)
|
||||
{
|
||||
fprintf(state->file, "<html>\n");
|
||||
fprintf(state->file, "<head>\n");
|
||||
|
||||
fprintf(state->file,
|
||||
"<!-- this file is generated from %s.idl -->\n",
|
||||
state->basename);
|
||||
fprintf(state->file, "<title>documentation for %s.idl interfaces</title>\n",
|
||||
state->basename);
|
||||
fprintf(state->file, "</head>\n\n");
|
||||
fprintf(state->file, "<body>\n");
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
doc_epilog(TreeState *state)
|
||||
{
|
||||
fprintf(state->file, "</body>\n");
|
||||
fprintf(state->file, "</html>\n");
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
static gboolean
|
||||
doc_list(TreeState *state)
|
||||
{
|
||||
IDL_tree iter;
|
||||
for (iter = state->tree; iter; iter = IDL_LIST(iter).next) {
|
||||
state->tree = IDL_LIST(iter).data;
|
||||
if (!xpidl_process_node(state))
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
print_list(FILE *outfile, IDL_tree list)
|
||||
{
|
||||
if (list == NULL)
|
||||
return TRUE;
|
||||
|
||||
fprintf(outfile, "<ul>\n");
|
||||
while (list != NULL) {
|
||||
fprintf(outfile, " <li>%s\n",
|
||||
IDL_IDENT(IDL_LIST(list).data).str);
|
||||
list = IDL_LIST(list).next;
|
||||
}
|
||||
fprintf(outfile, "</ul>\n");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
doc_interface(TreeState *state)
|
||||
{
|
||||
IDL_tree iface = state->tree;
|
||||
IDL_tree iter;
|
||||
IDL_tree orig;
|
||||
char *classname = IDL_IDENT(IDL_INTERFACE(iface).ident).str;
|
||||
GSList *doc_comments = IDL_IDENT(IDL_INTERFACE(iface).ident).comments;
|
||||
|
||||
fprintf(state->file, "interface %s<br>\n", classname);
|
||||
|
||||
/* Much more could happen at this step. */
|
||||
/*
|
||||
* If parsing doc comments, you might need to take some care with line
|
||||
* endings, as the xpidl frontend will return comments containing of /r,
|
||||
* /n, /r/n depending on the platform. It's best to leave out platform
|
||||
* #defines and just treat them all as equivalent.
|
||||
*/
|
||||
if (doc_comments != NULL) {
|
||||
fprintf(state->file, "doc comments:<br>\n");
|
||||
fprintf(state->file, "<pre>\n");
|
||||
printlist(state->file, doc_comments);
|
||||
fprintf(state->file, "</pre>\n");
|
||||
fprintf(state->file, "<br>\n");
|
||||
}
|
||||
|
||||
/* inherits from */
|
||||
/*
|
||||
* Note that we accept multiple inheritance here (for e.g. gnome idl)
|
||||
* even though the header backend (specific to mozilla idl) rejects it.
|
||||
*/
|
||||
if ((iter = IDL_INTERFACE(iface).inheritance_spec)) {
|
||||
fprintf(state->file, "%s inherits from:<br>\n", classname);
|
||||
print_list(state->file, iter);
|
||||
fprintf(state->file, "<br>\n");
|
||||
}
|
||||
|
||||
/*
|
||||
* Call xpidl_process_node to recur through list of declarations in
|
||||
* interface body; another option would be to explicitly iterate through
|
||||
* the list. xpidl_process_node currently requires twiddling the state to
|
||||
* get the right node; I'll fix that soon to just take the node. Makes it
|
||||
* easier to follow what's going on, I think...
|
||||
*/
|
||||
orig = state->tree;
|
||||
state->tree = IDL_INTERFACE(iface).body;
|
||||
if (state->tree && !xpidl_process_node(state))
|
||||
return FALSE;
|
||||
state->tree = orig;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Copied from xpidl_header.c. You'll probably want to change it; if you can
|
||||
* use it verbatim or abstract it, we could move it to xpidl_util.c and share
|
||||
* it from there.
|
||||
*/
|
||||
static gboolean
|
||||
write_type(IDL_tree type_tree, FILE *outfile)
|
||||
{
|
||||
if (!type_tree) {
|
||||
fputs("void", outfile);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
switch (IDL_NODE_TYPE(type_tree)) {
|
||||
case IDLN_TYPE_INTEGER: {
|
||||
gboolean sign = IDL_TYPE_INTEGER(type_tree).f_signed;
|
||||
switch (IDL_TYPE_INTEGER(type_tree).f_type) {
|
||||
case IDL_INTEGER_TYPE_SHORT:
|
||||
fputs(sign ? "PRInt16" : "PRUint16", outfile);
|
||||
break;
|
||||
case IDL_INTEGER_TYPE_LONG:
|
||||
fputs(sign ? "PRInt32" : "PRUint32", outfile);
|
||||
break;
|
||||
case IDL_INTEGER_TYPE_LONGLONG:
|
||||
fputs(sign ? "PRInt64" : "PRUint64", outfile);
|
||||
break;
|
||||
default:
|
||||
g_error("Unknown integer type %d\n",
|
||||
IDL_TYPE_INTEGER(type_tree).f_type);
|
||||
return FALSE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case IDLN_TYPE_CHAR:
|
||||
fputs("char", outfile);
|
||||
break;
|
||||
case IDLN_TYPE_WIDE_CHAR:
|
||||
fputs("PRUnichar", outfile); /* wchar_t? */
|
||||
break;
|
||||
case IDLN_TYPE_WIDE_STRING:
|
||||
fputs("PRUnichar *", outfile);
|
||||
break;
|
||||
case IDLN_TYPE_STRING:
|
||||
fputs("char *", outfile);
|
||||
break;
|
||||
case IDLN_TYPE_BOOLEAN:
|
||||
fputs("PRBool", outfile);
|
||||
break;
|
||||
case IDLN_TYPE_OCTET:
|
||||
fputs("PRUint8", outfile);
|
||||
break;
|
||||
case IDLN_TYPE_FLOAT:
|
||||
switch (IDL_TYPE_FLOAT(type_tree).f_type) {
|
||||
case IDL_FLOAT_TYPE_FLOAT:
|
||||
fputs("float", outfile);
|
||||
break;
|
||||
case IDL_FLOAT_TYPE_DOUBLE:
|
||||
fputs("double", outfile);
|
||||
break;
|
||||
/* XXX 'long double' just ignored, or what? */
|
||||
default:
|
||||
fprintf(outfile, "unknown_type_%d", IDL_NODE_TYPE(type_tree));
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case IDLN_IDENT:
|
||||
if (UP_IS_NATIVE(type_tree)) {
|
||||
fputs(IDL_NATIVE(IDL_NODE_UP(type_tree)).user_type, outfile);
|
||||
if (IDL_tree_property_get(type_tree, "ptr")) {
|
||||
fputs(" *", outfile);
|
||||
} else if (IDL_tree_property_get(type_tree, "ref")) {
|
||||
fputs(" &", outfile);
|
||||
}
|
||||
} else {
|
||||
fputs(IDL_IDENT(type_tree).str, outfile);
|
||||
}
|
||||
if (UP_IS_AGGREGATE(type_tree))
|
||||
fputs(" *", outfile);
|
||||
break;
|
||||
default:
|
||||
fprintf(outfile, "unknown_type_%d", IDL_NODE_TYPE(type_tree));
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* handle ATTR_DCL (attribute declaration) nodes */
|
||||
static gboolean
|
||||
doc_attribute_declaration(TreeState *state)
|
||||
{
|
||||
IDL_tree attr = state->tree;
|
||||
|
||||
if (!verify_attribute_declaration(attr))
|
||||
return FALSE;
|
||||
/*
|
||||
* Attribute idents can also take doc comments. They're ignored here;
|
||||
* should they be?
|
||||
*/
|
||||
|
||||
if (IDL_ATTR_DCL(attr).f_readonly)
|
||||
fprintf(state->file, "readonly ");
|
||||
|
||||
fprintf(state->file, "attribute ");
|
||||
|
||||
if (!write_type(IDL_ATTR_DCL(attr).param_type_spec, state->file))
|
||||
return FALSE;
|
||||
|
||||
fprintf(state->file, "\n");
|
||||
print_list(state->file, IDL_ATTR_DCL(attr).simple_declarations);
|
||||
fprintf(state->file, "<br>\n");
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* handle OP_DCL (method declaration) nodes */
|
||||
static gboolean
|
||||
doc_method_declaration(TreeState *state)
|
||||
{
|
||||
/*
|
||||
* Doc comment for attributes also applies here.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Look at 'write_method_signature' in xpidl_header.c for an example of how
|
||||
* to navigate parse trees for methods. For here, I just print the method
|
||||
* name.
|
||||
*/
|
||||
|
||||
fprintf(state->file,
|
||||
"method %s<br>\n",
|
||||
IDL_IDENT(IDL_OP_DCL(state->tree).ident).str);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
backend *
|
||||
xpidl_doc_dispatch(void)
|
||||
{
|
||||
static backend result;
|
||||
static nodeHandler table[IDLN_LAST];
|
||||
static gboolean initialized = FALSE;
|
||||
|
||||
result.emit_prolog = doc_prolog;
|
||||
result.emit_epilog = doc_epilog;
|
||||
|
||||
if (!initialized) {
|
||||
/* Initialize non-NULL elements */
|
||||
|
||||
/* I just handle a few... many still to be filled in! */
|
||||
|
||||
table[IDLN_LIST] = doc_list;
|
||||
table[IDLN_INTERFACE] = doc_interface;
|
||||
table[IDLN_ATTR_DCL] = doc_attribute_declaration;
|
||||
table[IDLN_OP_DCL] = doc_method_declaration;
|
||||
|
||||
initialized = TRUE;
|
||||
}
|
||||
|
||||
result.dispatch_table = table;
|
||||
return &result;
|
||||
}
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,801 +0,0 @@
|
|||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Michael Ang <mang@subcarrier.org>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
* Common IDL-processing code.
|
||||
*/
|
||||
|
||||
#include "xpidl.h"
|
||||
#include <limits.h>
|
||||
|
||||
static gboolean parsed_empty_file;
|
||||
|
||||
/*
|
||||
* The bulk of the generation happens here.
|
||||
*/
|
||||
gboolean
|
||||
xpidl_process_node(TreeState *state)
|
||||
{
|
||||
gint type;
|
||||
nodeHandler *dispatch, handler;
|
||||
|
||||
XPT_ASSERT(state->tree);
|
||||
type = IDL_NODE_TYPE(state->tree);
|
||||
|
||||
if ((dispatch = state->dispatch) && (handler = dispatch[type]))
|
||||
return handler(state);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static int
|
||||
msg_callback(int level, int num, int line, const char *file,
|
||||
const char *message)
|
||||
{
|
||||
char *warning_message;
|
||||
|
||||
/*
|
||||
* Egregious hack to permit empty files.
|
||||
* XXX libIDL needs an API to detect this case robustly.
|
||||
*/
|
||||
if (0 == strcmp(message, "File empty after optimization")) {
|
||||
parsed_empty_file = TRUE;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!file)
|
||||
file = "<unknown file>";
|
||||
warning_message = g_strdup_printf("%s:%d: %s\n", file, line, message);
|
||||
|
||||
fputs(warning_message, stderr);
|
||||
|
||||
g_free(warning_message);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* To keep track of the state associated with a given input file. The 'next'
|
||||
* field lets us maintain a stack of input files.
|
||||
*/
|
||||
typedef struct input_data {
|
||||
char *filename; /* where did I come from? */
|
||||
unsigned int lineno; /* last lineno processed */
|
||||
char *buf; /* contents of file */
|
||||
char *point; /* next char to feed to libIDL */
|
||||
char *max; /* 1 past last char in buf */
|
||||
struct input_data *next; /* file from which we were included */
|
||||
} input_data;
|
||||
|
||||
/*
|
||||
* Passed to us by libIDL. Holds global information and the current stack of
|
||||
* include files.
|
||||
*/
|
||||
typedef struct input_callback_state {
|
||||
struct input_data *input_stack; /* linked list of input_data */
|
||||
GHashTable *already_included; /* to prevent redundant includes */
|
||||
IncludePathEntry *include_path; /* search path for included files */
|
||||
GSList *base_includes; /* to accumulate #includes from *first* file;
|
||||
* for passing thru TreeState to
|
||||
* xpidl_header backend. */
|
||||
} input_callback_state;
|
||||
|
||||
static FILE *
|
||||
fopen_from_includes(char **filename, const char *mode,
|
||||
IncludePathEntry *include_path)
|
||||
{
|
||||
IncludePathEntry *current_path = include_path;
|
||||
char *pathname;
|
||||
FILE *inputfile;
|
||||
if (!strcmp(*filename, "-"))
|
||||
return stdin;
|
||||
|
||||
if ((*filename)[0] != '/') {
|
||||
while (current_path) {
|
||||
pathname = g_strdup_printf("%s" G_DIR_SEPARATOR_S "%s",
|
||||
current_path->directory, *filename);
|
||||
if (!pathname)
|
||||
return NULL;
|
||||
inputfile = fopen(pathname, mode);
|
||||
if (inputfile) {
|
||||
free(*filename);
|
||||
*filename = xpidl_strdup(pathname);
|
||||
g_free(pathname);
|
||||
return inputfile;
|
||||
}
|
||||
g_free(pathname);
|
||||
current_path = current_path->next;
|
||||
}
|
||||
} else {
|
||||
inputfile = fopen(*filename, mode);
|
||||
if (inputfile)
|
||||
return inputfile;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static input_data *
|
||||
new_input_data(char **filename, IncludePathEntry *include_path)
|
||||
{
|
||||
input_data *new_data;
|
||||
FILE *inputfile;
|
||||
char *buffer = NULL;
|
||||
size_t offset = 0;
|
||||
size_t buffer_size;
|
||||
|
||||
#if defined(XP_OS2) || defined(XP_WIN32)
|
||||
/*
|
||||
* if filename is fully qualified (starts with driver letter), then
|
||||
* just call fopen(); else, go with fopen_from_includes()
|
||||
*/
|
||||
if( (*filename)[1] == ':' )
|
||||
inputfile = fopen(*filename, "r");
|
||||
else
|
||||
inputfile = fopen_from_includes(filename, "r", include_path);
|
||||
#else
|
||||
inputfile = fopen_from_includes(filename, "r", include_path);
|
||||
#endif
|
||||
|
||||
if (!inputfile)
|
||||
return NULL;
|
||||
/*
|
||||
* Rather than try to keep track of many different varieties of state
|
||||
* around the boundaries of a circular buffer, we just read in the entire
|
||||
* file.
|
||||
*
|
||||
* We iteratively grow the buffer here; an alternative would be to use
|
||||
* stat to find the exact buffer size we need, as xpt_dump does.
|
||||
*/
|
||||
for (buffer_size = 8191; ; buffer_size *= 2) {
|
||||
size_t just_read;
|
||||
buffer = realloc(buffer, buffer_size + 1); /* +1 for trailing nul */
|
||||
just_read = fread(buffer + offset, 1, buffer_size - offset, inputfile);
|
||||
if (ferror(inputfile))
|
||||
return NULL;
|
||||
|
||||
if (just_read < buffer_size - offset || just_read == 0) {
|
||||
/* Done reading. */
|
||||
offset += just_read;
|
||||
break;
|
||||
}
|
||||
offset += just_read;
|
||||
}
|
||||
|
||||
fclose(inputfile);
|
||||
|
||||
new_data = xpidl_malloc(sizeof (struct input_data));
|
||||
new_data->point = new_data->buf = buffer;
|
||||
new_data->max = buffer + offset;
|
||||
*new_data->max = '\0';
|
||||
new_data->filename = *filename;
|
||||
/* libIDL expects the line number to be that of the *next* line */
|
||||
new_data->lineno = 2;
|
||||
new_data->next = NULL;
|
||||
|
||||
if (deps)
|
||||
fprintf(deps, " \\\n\t%s", *filename);
|
||||
|
||||
return new_data;
|
||||
}
|
||||
|
||||
/* process pending raw section */
|
||||
static int
|
||||
NextIsRaw(input_data *data, char **startp, int *lenp)
|
||||
{
|
||||
char *end, *start;
|
||||
|
||||
/*
|
||||
* XXXmccabe still needed: an in_raw flag to handle the case where we're in
|
||||
* a raw block, but haven't managed to copy it all to xpidl. This will
|
||||
* happen when we have a raw block larger than
|
||||
* IDL_input_data->fill.max_size (currently 8192.)
|
||||
*/
|
||||
if (!(data->point[0] == '%' && data->point[1] == '{'))
|
||||
return 0;
|
||||
|
||||
start = *startp = data->point;
|
||||
|
||||
end = NULL;
|
||||
while (start < data->max && (end = strstr(start, "%}"))) {
|
||||
if (end[-1] == '\r' ||
|
||||
end[-1] == '\n')
|
||||
break;
|
||||
start = end + 1;
|
||||
}
|
||||
|
||||
if (end && start < data->max) {
|
||||
*lenp = end - data->point + 2;
|
||||
return 1;
|
||||
} else {
|
||||
const char *filename;
|
||||
int lineno;
|
||||
|
||||
IDL_file_get(&filename, &lineno);
|
||||
msg_callback(IDL_ERROR, 0, lineno, filename,
|
||||
"unterminated %{ block");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/* process pending comment */
|
||||
static int
|
||||
NextIsComment(input_data *data, char **startp, int *lenp)
|
||||
{
|
||||
char *end;
|
||||
|
||||
if (!(data->point[0] == '/' && data->point[1] == '*'))
|
||||
return 0;
|
||||
|
||||
end = strstr(data->point, "*/");
|
||||
*lenp = 0;
|
||||
if (end) {
|
||||
int skippedLines = 0;
|
||||
char *tempPoint;
|
||||
|
||||
/* get current lineno */
|
||||
IDL_file_get(NULL,(int *)&data->lineno);
|
||||
|
||||
/* get line count */
|
||||
for (tempPoint = data->point; tempPoint < end; tempPoint++) {
|
||||
if (*tempPoint == '\n')
|
||||
skippedLines++;
|
||||
}
|
||||
|
||||
data->lineno += skippedLines;
|
||||
IDL_file_set(data->filename, (int)data->lineno);
|
||||
|
||||
*startp = end + 2;
|
||||
|
||||
/* If it's a ** comment, tell libIDL about it. */
|
||||
if (data->point[2] == '*') {
|
||||
/* hack termination. +2 to get past '*' '/' */
|
||||
char t = *(end + 2);
|
||||
*(end + 2) = '\0';
|
||||
IDL_queue_new_ident_comment(data->point);
|
||||
*(end + 2) = t;
|
||||
}
|
||||
|
||||
data->point = *startp; /* XXXmccabe move this out of function? */
|
||||
return 1;
|
||||
} else {
|
||||
const char *filename;
|
||||
int lineno;
|
||||
|
||||
IDL_file_get(&filename, &lineno);
|
||||
msg_callback(IDL_ERROR, 0, lineno, filename,
|
||||
"unterminated comment");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
NextIsInclude(input_callback_state *callback_state, char **startp,
|
||||
int *lenp)
|
||||
{
|
||||
input_data *data = callback_state->input_stack;
|
||||
input_data *new_data;
|
||||
char *filename, *end;
|
||||
const char *scratch;
|
||||
|
||||
/* process the #include that we're in now */
|
||||
if (strncmp(data->point, "#include \"", 10)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
filename = data->point + 10; /* skip #include " */
|
||||
XPT_ASSERT(filename < data->max);
|
||||
end = filename;
|
||||
while (end < data->max) {
|
||||
if (*end == '\"' || *end == '\n' || *end == '\r')
|
||||
break;
|
||||
end++;
|
||||
}
|
||||
|
||||
if (*end != '\"') {
|
||||
/*
|
||||
* Didn't find end of include file. Scan 'til next whitespace to find
|
||||
* some reasonable approximation of the filename, and use it to report
|
||||
* an error.
|
||||
*/
|
||||
|
||||
end = filename;
|
||||
while (end < data->max) {
|
||||
if (*end == ' ' || *end == '\n' || *end == '\r' || *end == '\t')
|
||||
break;
|
||||
end++;
|
||||
}
|
||||
*end = '\0';
|
||||
|
||||
/* make sure we have accurate line info */
|
||||
IDL_file_get(&scratch, (int *)&data->lineno);
|
||||
fprintf(stderr,
|
||||
"%s:%d: didn't find end of quoted include name \"%s\n",
|
||||
scratch, data->lineno, filename);
|
||||
return -1;
|
||||
}
|
||||
|
||||
*end = '\0';
|
||||
*startp = end + 1;
|
||||
|
||||
if (data->next == NULL) {
|
||||
/*
|
||||
* If we're in the initial file, add this filename to the list
|
||||
* of filenames to be turned into #include "filename.h"
|
||||
* directives in xpidl_header.c. We do it here rather than in the
|
||||
* block below so it still gets added to the list even if it's
|
||||
* already been recursively included from some other file.
|
||||
*/
|
||||
char *filename_cp = xpidl_strdup(filename);
|
||||
|
||||
/* note that g_slist_append accepts and likes null as list-start. */
|
||||
callback_state->base_includes =
|
||||
g_slist_append(callback_state->base_includes, filename_cp);
|
||||
}
|
||||
|
||||
/* store offset for when we pop, or if we skip this one */
|
||||
data->point = *startp;
|
||||
|
||||
if (!g_hash_table_lookup(callback_state->already_included, filename)) {
|
||||
filename = xpidl_strdup(filename);
|
||||
g_hash_table_insert(callback_state->already_included,
|
||||
filename, (void *)TRUE);
|
||||
filename = xpidl_strdup(filename);
|
||||
new_data = new_input_data(&filename, callback_state->include_path);
|
||||
if (!new_data) {
|
||||
char *error_message;
|
||||
IDL_file_get(&scratch, (int *)&data->lineno);
|
||||
error_message =
|
||||
g_strdup_printf("can't open included file %s for reading\n",
|
||||
filename);
|
||||
msg_callback(IDL_ERROR, 0,
|
||||
data->lineno, scratch, error_message);
|
||||
g_free(error_message);
|
||||
free(filename);
|
||||
return -1;
|
||||
}
|
||||
|
||||
new_data->next = data;
|
||||
/* tell libIDL to exclude this IDL from the toplevel tree */
|
||||
IDL_inhibit_push();
|
||||
IDL_file_get(&scratch, (int *)&data->lineno);
|
||||
callback_state->input_stack = new_data;
|
||||
IDL_file_set(new_data->filename, (int)new_data->lineno);
|
||||
}
|
||||
|
||||
*lenp = 0; /* this is magic, see the comment below */
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
FindSpecial(input_data *data, char **startp, int *lenp)
|
||||
{
|
||||
char *point = data->point;
|
||||
|
||||
/* magic sequences are:
|
||||
* "%{" raw block
|
||||
* "/\*" comment
|
||||
* "#include \"" include
|
||||
* The first and last want a newline [\r\n] before, or the start of the
|
||||
* file.
|
||||
*/
|
||||
|
||||
#define LINE_START(data, point) (point == data->buf || \
|
||||
(point > data->point && \
|
||||
(point[-1] == '\r' || point[-1] == '\n')))
|
||||
|
||||
while (point < data->max) {
|
||||
if (point[0] == '/' && point[1] == '*')
|
||||
break;
|
||||
if (LINE_START(data, point)) {
|
||||
if (point[0] == '%' && point[1] == '{')
|
||||
break;
|
||||
if (point[0] == '#' && !strncmp(point + 1, "include \"", 9))
|
||||
break;
|
||||
}
|
||||
point++;
|
||||
}
|
||||
|
||||
#undef LINE_START
|
||||
|
||||
*startp = data->point;
|
||||
*lenp = point - data->point;
|
||||
}
|
||||
|
||||
/* set this with a debugger to see exactly what libIDL sees */
|
||||
static FILE *tracefile;
|
||||
|
||||
static int
|
||||
input_callback(IDL_input_reason reason, union IDL_input_data *cb_data,
|
||||
gpointer user_data)
|
||||
{
|
||||
input_callback_state *callback_state = user_data;
|
||||
input_data *data = callback_state->input_stack;
|
||||
input_data *new_data = NULL;
|
||||
unsigned int len, copy;
|
||||
int rv;
|
||||
char *start, *filename;
|
||||
|
||||
switch(reason) {
|
||||
case IDL_INPUT_REASON_INIT:
|
||||
filename = xpidl_strdup(cb_data->init.filename);
|
||||
if (data == NULL || data->next == NULL) {
|
||||
/*
|
||||
* This is the first file being processed. As it's the target
|
||||
* file, we only look for it in the first entry in the include
|
||||
* path, which we assume to be the current directory.
|
||||
*/
|
||||
|
||||
/* XXXmccabe proper assumption? Do we handle files in other
|
||||
directories? */
|
||||
|
||||
IncludePathEntry first_entry;
|
||||
|
||||
first_entry.directory = callback_state->include_path->directory;
|
||||
first_entry.next = NULL;
|
||||
|
||||
new_data = new_input_data(&filename, &first_entry);
|
||||
} else {
|
||||
new_data = new_input_data(&filename, callback_state->include_path);
|
||||
}
|
||||
|
||||
if (!new_data) {
|
||||
free(filename);
|
||||
return -1;
|
||||
}
|
||||
|
||||
IDL_file_set(new_data->filename, (int)new_data->lineno);
|
||||
callback_state->input_stack = new_data;
|
||||
return 0;
|
||||
|
||||
case IDL_INPUT_REASON_FILL:
|
||||
start = NULL;
|
||||
len = 0;
|
||||
|
||||
while (data->point >= data->max) {
|
||||
if (!data->next)
|
||||
return 0;
|
||||
|
||||
/* Current file is done; revert to including file */
|
||||
callback_state->input_stack = data->next;
|
||||
free(data->filename);
|
||||
free(data->buf);
|
||||
free(data);
|
||||
data = callback_state->input_stack;
|
||||
|
||||
IDL_file_set(data->filename, (int)data->lineno);
|
||||
IDL_inhibit_pop();
|
||||
}
|
||||
|
||||
/*
|
||||
* Now we scan for sequences which require special attention:
|
||||
* \n#include begins an include statement
|
||||
* \n%{ begins a raw-source block
|
||||
* /\* begins a comment
|
||||
*
|
||||
* We used to be fancier here, so make sure that we sent the most
|
||||
* data possible at any given time. To that end, we skipped over
|
||||
* \n%{ raw \n%} blocks and then _continued_ the search for special
|
||||
* sequences like \n#include or /\* comments .
|
||||
*
|
||||
* It was really ugly, though -- liberal use of goto! lots of implicit
|
||||
* state! what fun! -- so now we just do this:
|
||||
*
|
||||
* if (special at start) {
|
||||
* process that special -
|
||||
* - raw: send it to libIDL, and don't look inside for specials
|
||||
* - comments: adjust point and start over
|
||||
* - includes: push new input_data struct for included file, and
|
||||
* start over
|
||||
* } else {
|
||||
* scan for next special
|
||||
* send data up to that special to libIDL
|
||||
* }
|
||||
*
|
||||
* If len is set to zero, it is a sentinel value indicating we a comment
|
||||
* or include was found, and parsing should start over.
|
||||
*
|
||||
* XXX const string foo = "/\*" will just screw us horribly.
|
||||
* Hm but. We could treat strings as we treat raw blocks, eh?
|
||||
*/
|
||||
|
||||
/*
|
||||
* Order is important, so that you can have /\* comments and
|
||||
* #includes within raw sections, and so that you can comment out
|
||||
* #includes.
|
||||
*/
|
||||
rv = NextIsRaw(data, &start, (int *)&len);
|
||||
if (rv == -1) return -1;
|
||||
if (!rv) {
|
||||
/*
|
||||
* When NextIsComment succeeds, it returns a 0 len (requesting a
|
||||
* restart) and adjusts data->point to pick up after the comment.
|
||||
*/
|
||||
rv = NextIsComment(data, &start, (int *)&len);
|
||||
if (rv == -1) return -1;
|
||||
if (!rv) {
|
||||
/*
|
||||
* NextIsInclude might push a new input_data struct; if so, it
|
||||
* will return a 0 len, letting the callback pick up the new
|
||||
* file the next time around.
|
||||
*/
|
||||
rv = NextIsInclude(callback_state, &start, (int *)&len);
|
||||
if (rv == -1) return -1;
|
||||
if (!rv)
|
||||
FindSpecial(data, &start, (int *)&len);
|
||||
}
|
||||
}
|
||||
|
||||
if (len == 0) {
|
||||
/*
|
||||
* len == 0 is a sentinel value that means we found a comment or
|
||||
* include. If we found a comment, point has been adjusted to
|
||||
* point past the comment. If we found an include, a new input_data
|
||||
* has been pushed. In both cases, calling the input_callback again
|
||||
* will pick up the new state.
|
||||
*/
|
||||
return input_callback(reason, cb_data, user_data);
|
||||
}
|
||||
|
||||
copy = MIN(len, (unsigned int) cb_data->fill.max_size);
|
||||
memcpy(cb_data->fill.buffer, start, copy);
|
||||
data->point = start + copy;
|
||||
|
||||
if (tracefile)
|
||||
fwrite(cb_data->fill.buffer, copy, 1, tracefile);
|
||||
|
||||
return copy;
|
||||
|
||||
case IDL_INPUT_REASON_ABORT:
|
||||
case IDL_INPUT_REASON_FINISH:
|
||||
while (data != NULL) {
|
||||
input_data *next;
|
||||
|
||||
next = data->next;
|
||||
free(data->filename);
|
||||
free(data->buf);
|
||||
free(data);
|
||||
data = next;
|
||||
}
|
||||
return 0;
|
||||
|
||||
default:
|
||||
g_error("unknown input reason %d!", reason);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
free_ghash_key(gpointer key, gpointer value, gpointer user_data)
|
||||
{
|
||||
/* We're only storing TRUE in the value... */
|
||||
free(key);
|
||||
}
|
||||
|
||||
static void
|
||||
free_gslist_data(gpointer data, gpointer user_data)
|
||||
{
|
||||
free(data);
|
||||
}
|
||||
|
||||
/* Pick up unlink. */
|
||||
#ifdef XP_UNIX
|
||||
#include <unistd.h>
|
||||
#elif XP_WIN
|
||||
/* We get it from stdio.h. */
|
||||
#define unlink _unlink
|
||||
#endif
|
||||
|
||||
int
|
||||
xpidl_process_idl(char *filename, IncludePathEntry *include_path,
|
||||
char *file_basename, ModeData *mode)
|
||||
{
|
||||
char *tmp, *outname, *real_outname = NULL;
|
||||
IDL_tree top;
|
||||
TreeState state;
|
||||
int rv;
|
||||
input_callback_state callback_state;
|
||||
gboolean ok = TRUE;
|
||||
backend *emitter;
|
||||
|
||||
callback_state.input_stack = NULL;
|
||||
callback_state.base_includes = NULL;
|
||||
callback_state.include_path = include_path;
|
||||
callback_state.already_included = g_hash_table_new(g_str_hash, g_str_equal);
|
||||
|
||||
if (!callback_state.already_included) {
|
||||
fprintf(stderr, "failed to create hashtable. out of memory?\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
state.basename = xpidl_strdup(filename);
|
||||
|
||||
/* if basename has an .extension, truncate it. */
|
||||
tmp = strrchr(state.basename, '.');
|
||||
if (tmp)
|
||||
*tmp = '\0';
|
||||
|
||||
if (!file_basename)
|
||||
outname = xpidl_strdup(state.basename);
|
||||
else
|
||||
outname = xpidl_strdup(file_basename);
|
||||
|
||||
/* so we don't include it again! */
|
||||
g_hash_table_insert(callback_state.already_included,
|
||||
xpidl_strdup(filename), (void *)TRUE);
|
||||
|
||||
parsed_empty_file = FALSE;
|
||||
|
||||
rv = IDL_parse_filename_with_input(filename, input_callback, &callback_state,
|
||||
msg_callback, &top,
|
||||
&state.ns,
|
||||
IDLF_IGNORE_FORWARDS |
|
||||
IDLF_XPIDL,
|
||||
enable_warnings ? IDL_WARNING1 :
|
||||
IDL_ERROR);
|
||||
if (parsed_empty_file) {
|
||||
/*
|
||||
* If we've detected (via hack in msg_callback) that libIDL returned
|
||||
* failure because it found a file with no IDL, set the parse tree to
|
||||
* null and proceed. Allowing this is useful to permit .idl files that
|
||||
* collect #includes.
|
||||
*/
|
||||
top = NULL;
|
||||
state.ns = NULL;
|
||||
} else if (rv != IDL_SUCCESS) {
|
||||
if (rv == -1) {
|
||||
g_warning("Parse of %s failed: %s", filename, g_strerror(errno));
|
||||
} else {
|
||||
g_warning("Parse of %s failed", filename);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
state.basename = xpidl_strdup(filename);
|
||||
tmp = strrchr(state.basename, '.');
|
||||
if (tmp)
|
||||
*tmp = '\0';
|
||||
|
||||
/* so xpidl_header.c can use it to generate a list of #include directives */
|
||||
state.base_includes = callback_state.base_includes;
|
||||
|
||||
emitter = mode->factory();
|
||||
state.dispatch = emitter->dispatch_table;
|
||||
|
||||
if (strcmp(outname, "-")) {
|
||||
const char *fopen_mode;
|
||||
const char *out_basename;
|
||||
|
||||
/* explicit_output_filename can't be true without a filename */
|
||||
if (explicit_output_filename) {
|
||||
real_outname = g_strdup(outname);
|
||||
} else {
|
||||
#if defined(XP_UNIX) || defined(XP_WIN) || defined(XP_OS2)
|
||||
if (!file_basename) {
|
||||
out_basename = xpidl_basename(outname);
|
||||
} else {
|
||||
out_basename = outname;
|
||||
}
|
||||
#else
|
||||
out_basename = outname;
|
||||
#endif
|
||||
real_outname = g_strdup_printf("%s.%s", out_basename, mode->suffix);
|
||||
}
|
||||
|
||||
/* don't create/open file here for Java */
|
||||
if (strcmp(mode->mode, "java") == 0) {
|
||||
state.filename = real_outname;
|
||||
} else {
|
||||
/* Use binary write for typelib mode */
|
||||
fopen_mode = (strcmp(mode->mode, "typelib")) ? "w" : "wb";
|
||||
state.file = fopen(real_outname, fopen_mode);
|
||||
if (!state.file) {
|
||||
perror("error opening output file");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
state.file = stdout;
|
||||
}
|
||||
state.tree = top;
|
||||
|
||||
if (emitter->emit_prolog)
|
||||
emitter->emit_prolog(&state);
|
||||
if (state.tree) /* Only if we have a tree to process. */
|
||||
ok = xpidl_process_node(&state);
|
||||
if (emitter->emit_epilog)
|
||||
emitter->emit_epilog(&state);
|
||||
|
||||
if (strcmp(mode->mode, "java") != 0) {
|
||||
if (state.file != stdout)
|
||||
fclose(state.file);
|
||||
}
|
||||
|
||||
free(state.basename);
|
||||
free(outname);
|
||||
g_hash_table_foreach(callback_state.already_included, free_ghash_key, NULL);
|
||||
g_hash_table_destroy(callback_state.already_included);
|
||||
g_slist_foreach(callback_state.base_includes, free_gslist_data, NULL);
|
||||
|
||||
if (state.ns)
|
||||
IDL_ns_free(state.ns);
|
||||
if (top)
|
||||
IDL_tree_free(top);
|
||||
|
||||
if (strcmp(mode->mode, "java") != 0) {
|
||||
if (real_outname != NULL) {
|
||||
/*
|
||||
* Delete partial output file on failure. (Mac does this in the
|
||||
* plugin driver code, if the compiler returns failure.)
|
||||
*/
|
||||
#if defined(XP_UNIX) || defined(XP_WIN)
|
||||
if (!ok)
|
||||
unlink(real_outname);
|
||||
#endif
|
||||
g_free(real_outname);
|
||||
}
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
/*
|
||||
* Our own version of IDL_tree_warning, which we use when IDL_tree_warning
|
||||
* would crash on us.
|
||||
*/
|
||||
void
|
||||
xpidl_tree_warning(IDL_tree p, int level, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
char *msg, *file;
|
||||
int lineno;
|
||||
|
||||
/* XXX need to check against __IDL_max_msg_level, no accessor */
|
||||
va_start(ap, fmt);
|
||||
msg = g_strdup_vprintf(fmt, ap);
|
||||
|
||||
if (p) {
|
||||
file = p->_file;
|
||||
lineno = p->_line;
|
||||
} else {
|
||||
file = NULL;
|
||||
lineno = 0;
|
||||
}
|
||||
|
||||
/* call our message callback, like IDL_tree_warning would */
|
||||
msg_callback(level, 0, lineno, file, msg);
|
||||
g_free(msg);
|
||||
va_end(ap);
|
||||
}
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,958 +0,0 @@
|
|||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
* Utility functions called by various backends.
|
||||
*/
|
||||
|
||||
#include "xpidl.h"
|
||||
|
||||
#ifdef XP_WIN
|
||||
#define strdup _strdup
|
||||
#endif
|
||||
|
||||
/* XXXbe static */ char OOM[] = "ERROR: out of memory\n";
|
||||
|
||||
void *
|
||||
xpidl_malloc(size_t nbytes)
|
||||
{
|
||||
void *p = malloc(nbytes);
|
||||
if (!p) {
|
||||
fputs(OOM, stderr);
|
||||
exit(1);
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
char *
|
||||
xpidl_strdup(const char *s)
|
||||
{
|
||||
char *ns = strdup(s);
|
||||
if (!ns) {
|
||||
fputs(OOM, stderr);
|
||||
exit(1);
|
||||
}
|
||||
return ns;
|
||||
}
|
||||
|
||||
void
|
||||
xpidl_write_comment(TreeState *state, int indent)
|
||||
{
|
||||
fprintf(state->file, "%*s/* ", indent, "");
|
||||
IDL_tree_to_IDL(state->tree, state->ns, state->file,
|
||||
IDLF_OUTPUT_NO_NEWLINES |
|
||||
IDLF_OUTPUT_NO_QUALIFY_IDENTS |
|
||||
IDLF_OUTPUT_PROPERTIES);
|
||||
fputs(" */\n", state->file);
|
||||
}
|
||||
|
||||
/*
|
||||
* Print an iid to into a supplied buffer; the buffer should be at least
|
||||
* UUID_LENGTH bytes.
|
||||
*/
|
||||
gboolean
|
||||
xpidl_sprint_iid(nsID *id, char iidbuf[])
|
||||
{
|
||||
int printed;
|
||||
|
||||
printed = sprintf(iidbuf,
|
||||
"%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
|
||||
(PRUint32) id->m0, (PRUint32) id->m1,(PRUint32) id->m2,
|
||||
(PRUint32) id->m3[0], (PRUint32) id->m3[1],
|
||||
(PRUint32) id->m3[2], (PRUint32) id->m3[3],
|
||||
(PRUint32) id->m3[4], (PRUint32) id->m3[5],
|
||||
(PRUint32) id->m3[6], (PRUint32) id->m3[7]);
|
||||
|
||||
#ifdef SPRINTF_RETURNS_STRING
|
||||
return (printed && strlen((char *)printed) == 36);
|
||||
#else
|
||||
return (printed == 36);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* We only parse the {}-less format. */
|
||||
static const char nsIDFmt2[] =
|
||||
"%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x";
|
||||
|
||||
/*
|
||||
* Parse a uuid string into an nsID struct. We cannot link against libxpcom,
|
||||
* so we re-implement nsID::Parse here.
|
||||
*/
|
||||
gboolean
|
||||
xpidl_parse_iid(nsID *id, const char *str)
|
||||
{
|
||||
PRInt32 count = 0;
|
||||
PRUint32 n0, n1, n2;
|
||||
PRUint32 n3[8];
|
||||
PRUint32 i;
|
||||
|
||||
XPT_ASSERT(str != NULL);
|
||||
|
||||
if (strlen(str) != 36) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_shaver_iid
|
||||
fprintf(stderr, "parsing iid %s\n", str);
|
||||
#endif
|
||||
|
||||
count = sscanf(str, nsIDFmt2,
|
||||
&n0, &n1, &n2,
|
||||
&n3[0],&n3[1],&n3[2],&n3[3],
|
||||
&n3[4],&n3[5],&n3[6],&n3[7]);
|
||||
|
||||
id->m0 = n0;
|
||||
id->m1 = (PRUint16) n1;
|
||||
id->m2 = (PRUint16) n2;
|
||||
for (i = 0; i < 8; i++) {
|
||||
id->m3[i] = (PRUint8) n3[i];
|
||||
}
|
||||
|
||||
#ifdef DEBUG_shaver_iid
|
||||
if (count == 11) {
|
||||
fprintf(stderr, "IID parsed to ");
|
||||
print_IID(id, stderr);
|
||||
fputs("\n", stderr);
|
||||
}
|
||||
#endif
|
||||
return (gboolean)(count == 11);
|
||||
}
|
||||
|
||||
gboolean
|
||||
verify_const_declaration(IDL_tree const_tree) {
|
||||
struct _IDL_CONST_DCL *dcl = &IDL_CONST_DCL(const_tree);
|
||||
const char *name = IDL_IDENT(dcl->ident).str;
|
||||
IDL_tree real_type;
|
||||
|
||||
/* const -> list -> interface */
|
||||
if (!IDL_NODE_UP(IDL_NODE_UP(const_tree)) ||
|
||||
IDL_NODE_TYPE(IDL_NODE_UP(IDL_NODE_UP(const_tree)))
|
||||
!= IDLN_INTERFACE) {
|
||||
IDL_tree_error(const_tree,
|
||||
"const declaration \'%s\' outside interface",
|
||||
name);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Could be a typedef; try to map it to the real type. */
|
||||
real_type = find_underlying_type(dcl->const_type);
|
||||
real_type = real_type ? real_type : dcl->const_type;
|
||||
if (IDL_NODE_TYPE(real_type) == IDLN_TYPE_INTEGER &&
|
||||
(IDL_TYPE_INTEGER(real_type).f_type == IDL_INTEGER_TYPE_SHORT ||
|
||||
IDL_TYPE_INTEGER(real_type).f_type == IDL_INTEGER_TYPE_LONG))
|
||||
{
|
||||
if (!IDL_TYPE_INTEGER(real_type).f_signed &&
|
||||
IDL_INTEGER(dcl->const_exp).value < 0)
|
||||
{
|
||||
#ifndef G_HAVE_GINT64
|
||||
/*
|
||||
* For platforms without longlong support turned on we can get
|
||||
* confused by the high bit of the long value and think that it
|
||||
* represents a negative value in an unsigned declaration.
|
||||
* In that case we don't know if it is the programmer who is
|
||||
* confused or the compiler. So we issue a warning instead of
|
||||
* an error.
|
||||
*/
|
||||
if (IDL_TYPE_INTEGER(real_type).f_type == IDL_INTEGER_TYPE_LONG)
|
||||
{
|
||||
XPIDL_WARNING((const_tree, IDL_WARNING1,
|
||||
"unsigned const declaration \'%s\' "
|
||||
"initialized with (possibly) negative constant",
|
||||
name));
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
IDL_tree_error(const_tree,
|
||||
"unsigned const declaration \'%s\' initialized with "
|
||||
"negative constant",
|
||||
name);
|
||||
return FALSE;
|
||||
}
|
||||
} else {
|
||||
IDL_tree_error(const_tree,
|
||||
"const declaration \'%s\' must be of type short or long",
|
||||
name);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* This method consolidates error checking needed when coercing the XPIDL compiler
|
||||
* via the -t flag to generate output for a specific version of XPConnect.
|
||||
*/
|
||||
static gboolean
|
||||
verify_type_fits_version(IDL_tree in_tree, IDL_tree error_tree)
|
||||
{
|
||||
if (major_version == 1 && minor_version == 1)
|
||||
{
|
||||
/* XPIDL Version 1.1 checks */
|
||||
|
||||
/* utf8string, cstring, and astring types are not supported */
|
||||
if (IDL_tree_property_get(in_tree, "utf8string") != NULL ||
|
||||
IDL_tree_property_get(in_tree, "cstring") != NULL ||
|
||||
IDL_tree_property_get(in_tree, "astring") != NULL)
|
||||
{
|
||||
IDL_tree_error(error_tree,
|
||||
"Cannot use [utf8string], [cstring] and [astring] "
|
||||
"types when generating version 1.1 typelibs\n");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
IsNot_AlphaUpper(char letter)
|
||||
{
|
||||
return letter < 'A' || letter > 'Z';
|
||||
}
|
||||
|
||||
static gboolean
|
||||
IsNot_AlphaLower(char letter)
|
||||
{
|
||||
return letter < 'a' || letter > 'z';
|
||||
}
|
||||
|
||||
static gboolean
|
||||
matches_IFoo(const char* substring)
|
||||
{
|
||||
if (substring[0] != 'I')
|
||||
return FALSE;
|
||||
if (IsNot_AlphaUpper(substring[1]))
|
||||
return FALSE;
|
||||
if (IsNot_AlphaLower(substring[2]))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
matches_nsIFoo(const char* attribute_name)
|
||||
{
|
||||
if (IsNot_AlphaLower(attribute_name[0]))
|
||||
return FALSE;
|
||||
if (IsNot_AlphaLower(attribute_name[1]))
|
||||
return FALSE;
|
||||
if (matches_IFoo(attribute_name + 2))
|
||||
return TRUE;
|
||||
if (IsNot_AlphaLower(attribute_name[2]))
|
||||
return FALSE;
|
||||
return matches_IFoo(attribute_name + 3);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns TRUE if the method is probably scriptable, FALSE otherwise.
|
||||
* The first parameter may also be an attr_tree parameter, since these two are
|
||||
* the same with respect to discovering the interface node.
|
||||
*/
|
||||
gboolean
|
||||
is_method_scriptable(IDL_tree method_tree, IDL_tree ident)
|
||||
{
|
||||
IDL_tree iface;
|
||||
gboolean scriptable_interface;
|
||||
|
||||
/*
|
||||
* Look up the tree to find the interface. If we can't find the interface,
|
||||
* then the caller is being called on an incorrect tree. If we find it, we
|
||||
* see if it's [scriptable] and duly note it.
|
||||
*/
|
||||
if (IDL_NODE_UP(method_tree) && IDL_NODE_UP(IDL_NODE_UP(method_tree)) &&
|
||||
IDL_NODE_TYPE(iface = IDL_NODE_UP(IDL_NODE_UP(method_tree)))
|
||||
== IDLN_INTERFACE)
|
||||
{
|
||||
scriptable_interface =
|
||||
(IDL_tree_property_get(IDL_INTERFACE(iface).ident, "scriptable")
|
||||
!= NULL);
|
||||
} else {
|
||||
IDL_tree_error(method_tree,
|
||||
"is_method_scriptable called on a non-interface?");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* If the interface isn't scriptable, the method sure can't be... */
|
||||
if (!scriptable_interface)
|
||||
return FALSE;
|
||||
|
||||
/* [notxpcom] implies [noscript] */
|
||||
if (IDL_tree_property_get(ident, "notxpcom") != NULL)
|
||||
return FALSE;
|
||||
|
||||
/* [noscript] methods obviously aren't scriptable */
|
||||
if (IDL_tree_property_get(ident, "noscript") != NULL)
|
||||
return FALSE;
|
||||
|
||||
/* The interface is scriptable, so therefore the method is, if the
|
||||
* interfaces are accessible. That's good enough for this method.
|
||||
*/
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
verify_attribute_declaration(IDL_tree attr_tree)
|
||||
{
|
||||
IDL_tree iface;
|
||||
IDL_tree ident;
|
||||
IDL_tree attr_type;
|
||||
|
||||
/* We don't support attributes named IID, conflicts with static GetIID
|
||||
* member. The conflict is due to certain compilers (VC++) choosing a
|
||||
* different vtable order, placing GetIID at the beginning regardless
|
||||
* of its placement
|
||||
*/
|
||||
if (strcmp(
|
||||
IDL_IDENT(
|
||||
IDL_LIST(IDL_ATTR_DCL(attr_tree).simple_declarations).data).str,
|
||||
"IID") == 0) {
|
||||
IDL_tree_error(attr_tree,
|
||||
"Attributes named IID not supported, causes vtable "
|
||||
"ordering problems");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Grab the first of the list of idents and hope that it'll
|
||||
* say scriptable or no.
|
||||
*/
|
||||
ident = IDL_LIST(IDL_ATTR_DCL(attr_tree).simple_declarations).data;
|
||||
|
||||
/*
|
||||
* If the interface isn't scriptable, or the attribute is marked noscript,
|
||||
* there's no need to check. This also verifies that we've been called on
|
||||
* an interface.
|
||||
*/
|
||||
if (!is_method_scriptable(attr_tree, ident))
|
||||
return TRUE;
|
||||
|
||||
if (IDL_tree_property_get(ident, "nostdcall") != NULL) {
|
||||
IDL_tree_error(attr_tree,
|
||||
"[nostdcall] attribute must not be scriptable");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
* If it should be scriptable, check that the type is non-native. nsid,
|
||||
* domstring, utf8string, cstring, astring are exempted.
|
||||
*/
|
||||
attr_type = IDL_ATTR_DCL(attr_tree).param_type_spec;
|
||||
|
||||
if (attr_type != NULL)
|
||||
{
|
||||
if (UP_IS_NATIVE(attr_type) &&
|
||||
IDL_tree_property_get(attr_type, "nsid") == NULL &&
|
||||
IDL_tree_property_get(attr_type, "domstring") == NULL &&
|
||||
IDL_tree_property_get(attr_type, "utf8string") == NULL &&
|
||||
IDL_tree_property_get(attr_type, "cstring") == NULL &&
|
||||
IDL_tree_property_get(attr_type, "astring") == NULL &&
|
||||
IDL_tree_property_get(attr_type, "jsval") == NULL)
|
||||
{
|
||||
IDL_tree_error(attr_tree,
|
||||
"attributes in [scriptable] interfaces that are "
|
||||
"non-scriptable because they refer to native "
|
||||
"types must be marked [noscript]\n");
|
||||
return FALSE;
|
||||
}
|
||||
/*
|
||||
* We currently don't support properties of type nsid that aren't
|
||||
* pointers or references, unless they are marked [notxpcom} and
|
||||
* must be read-only
|
||||
*/
|
||||
|
||||
if ((IDL_tree_property_get(ident, "notxpcom") == NULL || !(IDL_ATTR_DCL(attr_tree).f_readonly)) &&
|
||||
IDL_tree_property_get(attr_type,"nsid") != NULL &&
|
||||
IDL_tree_property_get(attr_type,"ptr") == NULL &&
|
||||
IDL_tree_property_get(attr_type,"ref") == NULL)
|
||||
{
|
||||
IDL_tree_error(attr_tree,
|
||||
"Feature not currently supported: "
|
||||
"attributes with a type of nsid must be marked "
|
||||
"either [ptr] or [ref], or "
|
||||
"else must be marked [notxpcom] "
|
||||
"and must be read-only\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
* canIGoHomeNow is a bad name for an attribute.
|
||||
* /^[a-z]{2,3}I[A-Z][a-z]/ => bad, reserved for
|
||||
* interface flattening.
|
||||
*/
|
||||
if (matches_nsIFoo(IDL_IDENT(IDL_LIST(IDL_ATTR_DCL(attr_tree).
|
||||
simple_declarations).data).str)) {
|
||||
XPIDL_WARNING((attr_tree, IDL_WARNING1,
|
||||
"Naming an attribute nsIFoo causes "
|
||||
"problems for interface flattening"));
|
||||
}
|
||||
|
||||
/*
|
||||
* Run additional error checks on the attribute type if targetting an
|
||||
* older version of XPConnect.
|
||||
*/
|
||||
|
||||
if (!verify_type_fits_version(attr_type, attr_tree))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (IDL_LIST(IDL_ATTR_DCL(attr_tree).simple_declarations).next != NULL)
|
||||
{
|
||||
IDL_tree_error(attr_tree,
|
||||
"multiple attributes in a single declaration is not supported\n");
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Find the underlying type of an identifier typedef.
|
||||
*
|
||||
* All the needed tree-walking seems pretty shaky; isn't there something in
|
||||
* libIDL to automate this?
|
||||
*/
|
||||
IDL_tree /* IDL_TYPE_DCL */
|
||||
find_underlying_type(IDL_tree typedef_ident)
|
||||
{
|
||||
IDL_tree up;
|
||||
|
||||
if (typedef_ident == NULL || IDL_NODE_TYPE(typedef_ident) != IDLN_IDENT)
|
||||
return NULL;
|
||||
|
||||
up = IDL_NODE_UP(typedef_ident);
|
||||
if (up == NULL || IDL_NODE_TYPE(up) != IDLN_LIST)
|
||||
return NULL;
|
||||
up = IDL_NODE_UP(up);
|
||||
if (up == NULL || IDL_NODE_TYPE(up) != IDLN_TYPE_DCL)
|
||||
return NULL;
|
||||
|
||||
return IDL_TYPE_DCL(up).type_spec;
|
||||
}
|
||||
|
||||
static IDL_tree /* IDL_PARAM_DCL */
|
||||
find_named_parameter(IDL_tree method_tree, const char *param_name)
|
||||
{
|
||||
IDL_tree iter;
|
||||
for (iter = IDL_OP_DCL(method_tree).parameter_dcls; iter;
|
||||
iter = IDL_LIST(iter).next)
|
||||
{
|
||||
IDL_tree param = IDL_LIST(iter).data;
|
||||
IDL_tree simple_decl = IDL_PARAM_DCL(param).simple_declarator;
|
||||
const char *current_name = IDL_IDENT(simple_decl).str;
|
||||
if (strcmp(current_name, param_name) == 0)
|
||||
return param;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
typedef enum ParamAttrType {
|
||||
IID_IS,
|
||||
LENGTH_IS,
|
||||
SIZE_IS
|
||||
} ParamAttrType;
|
||||
|
||||
/*
|
||||
* Check that parameters referred to by attributes such as size_is exist and
|
||||
* refer to parameters of the appropriate type.
|
||||
*/
|
||||
static gboolean
|
||||
check_param_attribute(IDL_tree method_tree, IDL_tree param,
|
||||
ParamAttrType whattocheck)
|
||||
{
|
||||
const char *method_name = IDL_IDENT(IDL_OP_DCL(method_tree).ident).str;
|
||||
const char *referred_name = NULL;
|
||||
IDL_tree param_type = IDL_PARAM_DCL(param).param_type_spec;
|
||||
IDL_tree simple_decl = IDL_PARAM_DCL(param).simple_declarator;
|
||||
const char *param_name = IDL_IDENT(simple_decl).str;
|
||||
const char *attr_name;
|
||||
const char *needed_type;
|
||||
|
||||
if (whattocheck == IID_IS) {
|
||||
attr_name = "iid_is";
|
||||
needed_type = "IID";
|
||||
} else if (whattocheck == LENGTH_IS) {
|
||||
attr_name = "length_is";
|
||||
needed_type = "unsigned long (or PRUint32)";
|
||||
} else if (whattocheck == SIZE_IS) {
|
||||
attr_name = "size_is";
|
||||
needed_type = "unsigned long (or PRUint32)";
|
||||
} else {
|
||||
XPT_ASSERT("asked to check an unknown attribute type!");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
referred_name = IDL_tree_property_get(simple_decl, attr_name);
|
||||
if (referred_name != NULL) {
|
||||
IDL_tree referred_param = find_named_parameter(method_tree,
|
||||
referred_name);
|
||||
IDL_tree referred_param_type;
|
||||
if (referred_param == NULL) {
|
||||
IDL_tree_error(method_tree,
|
||||
"attribute [%s(%s)] refers to missing "
|
||||
"parameter \"%s\"",
|
||||
attr_name, referred_name, referred_name);
|
||||
return FALSE;
|
||||
}
|
||||
if (referred_param == param) {
|
||||
IDL_tree_error(method_tree,
|
||||
"attribute [%s(%s)] refers to its own parameter",
|
||||
attr_name, referred_name);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
referred_param_type = IDL_PARAM_DCL(referred_param).param_type_spec;
|
||||
if (whattocheck == IID_IS) {
|
||||
/* require IID type */
|
||||
if (IDL_tree_property_get(referred_param_type, "nsid") == NULL) {
|
||||
IDL_tree_error(method_tree,
|
||||
"target \"%s\" of [%s(%s)] attribute "
|
||||
"must be of %s type",
|
||||
referred_name, attr_name, referred_name,
|
||||
needed_type);
|
||||
return FALSE;
|
||||
}
|
||||
} else if (whattocheck == LENGTH_IS || whattocheck == SIZE_IS) {
|
||||
/* require PRUint32 type */
|
||||
IDL_tree real_type;
|
||||
|
||||
/* Could be a typedef; try to map it to the real type. */
|
||||
real_type = find_underlying_type(referred_param_type);
|
||||
real_type = real_type ? real_type : referred_param_type;
|
||||
|
||||
if (IDL_NODE_TYPE(real_type) != IDLN_TYPE_INTEGER ||
|
||||
IDL_TYPE_INTEGER(real_type).f_signed != FALSE ||
|
||||
IDL_TYPE_INTEGER(real_type).f_type != IDL_INTEGER_TYPE_LONG)
|
||||
{
|
||||
IDL_tree_error(method_tree,
|
||||
"target \"%s\" of [%s(%s)] attribute "
|
||||
"must be of %s type",
|
||||
referred_name, attr_name, referred_name,
|
||||
needed_type);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Common method verification code, called by *op_dcl in the various backends.
|
||||
*/
|
||||
gboolean
|
||||
verify_method_declaration(IDL_tree method_tree)
|
||||
{
|
||||
struct _IDL_OP_DCL *op = &IDL_OP_DCL(method_tree);
|
||||
IDL_tree iface;
|
||||
IDL_tree iter;
|
||||
gboolean notxpcom;
|
||||
gboolean scriptable_method;
|
||||
gboolean seen_retval = FALSE;
|
||||
gboolean hasoptional = PR_FALSE;
|
||||
const char *method_name = IDL_IDENT(IDL_OP_DCL(method_tree).ident).str;
|
||||
|
||||
/* We don't support attributes named IID, conflicts with static GetIID
|
||||
* member. The conflict is due to certain compilers (VC++) choosing a
|
||||
* different vtable order, placing GetIID at the beginning regardless
|
||||
* of its placement
|
||||
*/
|
||||
if (strcmp(method_name, "GetIID") == 0) {
|
||||
IDL_tree_error(method_tree,
|
||||
"Methods named GetIID not supported, causes vtable "
|
||||
"ordering problems");
|
||||
return FALSE;
|
||||
}
|
||||
if (op->f_varargs) {
|
||||
/* We don't currently support varargs. */
|
||||
IDL_tree_error(method_tree, "varargs are not currently supported");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Decide if we are a scriptable method, or if we were are notxpcom.
|
||||
* In doing so, we also verify that we've been called on an interface.
|
||||
*/
|
||||
scriptable_method = is_method_scriptable(method_tree, op->ident);
|
||||
notxpcom = IDL_tree_property_get(op->ident, "notxpcom") != NULL;
|
||||
|
||||
/* Loop through the parameters and check. */
|
||||
for (iter = op->parameter_dcls; iter; iter = IDL_LIST(iter).next) {
|
||||
IDL_tree param = IDL_LIST(iter).data;
|
||||
IDL_tree param_type =
|
||||
IDL_PARAM_DCL(param).param_type_spec;
|
||||
IDL_tree simple_decl =
|
||||
IDL_PARAM_DCL(param).simple_declarator;
|
||||
const char *param_name = IDL_IDENT(simple_decl).str;
|
||||
|
||||
/*
|
||||
* Reject this method if it should be scriptable and some parameter is
|
||||
* native that isn't marked with either nsid, domstring, utf8string,
|
||||
* cstring, astring or iid_is.
|
||||
*/
|
||||
if (scriptable_method &&
|
||||
UP_IS_NATIVE(param_type) &&
|
||||
IDL_tree_property_get(param_type, "nsid") == NULL &&
|
||||
IDL_tree_property_get(simple_decl, "iid_is") == NULL &&
|
||||
IDL_tree_property_get(param_type, "domstring") == NULL &&
|
||||
IDL_tree_property_get(param_type, "utf8string") == NULL &&
|
||||
IDL_tree_property_get(param_type, "cstring") == NULL &&
|
||||
IDL_tree_property_get(param_type, "astring") == NULL &&
|
||||
IDL_tree_property_get(param_type, "jsval") == NULL)
|
||||
{
|
||||
IDL_tree_error(method_tree,
|
||||
"methods in [scriptable] interfaces that are "
|
||||
"non-scriptable because they refer to native "
|
||||
"types (parameter \"%s\") must be marked "
|
||||
"[noscript]", param_name);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
* nsid's parameters that aren't ptr's or ref's are not currently
|
||||
* supported in xpcom or non-xpcom (marked with [notxpcom]) methods
|
||||
* as input parameters
|
||||
*/
|
||||
if (!(notxpcom && IDL_PARAM_DCL(param).attr != IDL_PARAM_IN) &&
|
||||
IDL_tree_property_get(param_type, "nsid") != NULL &&
|
||||
IDL_tree_property_get(param_type, "ptr") == NULL &&
|
||||
IDL_tree_property_get(param_type, "ref") == NULL)
|
||||
{
|
||||
IDL_tree_error(method_tree,
|
||||
"Feature currently not supported: "
|
||||
"parameter \"%s\" is of type nsid and "
|
||||
"must be marked either [ptr] or [ref] "
|
||||
"or method \"%s\" must be marked [notxpcom] "
|
||||
"and must not be an input parameter",
|
||||
param_name,
|
||||
method_name);
|
||||
return FALSE;
|
||||
}
|
||||
/*
|
||||
* Sanity checks on return values.
|
||||
*/
|
||||
if (IDL_tree_property_get(simple_decl, "retval") != NULL) {
|
||||
if (IDL_LIST(iter).next != NULL) {
|
||||
IDL_tree_error(method_tree,
|
||||
"only the last parameter can be marked [retval]");
|
||||
return FALSE;
|
||||
}
|
||||
if (op->op_type_spec) {
|
||||
IDL_tree_error(method_tree,
|
||||
"can't have [retval] with non-void return type");
|
||||
return FALSE;
|
||||
}
|
||||
/* In case XPConnect relaxes the retval-is-last restriction. */
|
||||
if (seen_retval) {
|
||||
IDL_tree_error(method_tree,
|
||||
"can't have more than one [retval] parameter");
|
||||
return FALSE;
|
||||
}
|
||||
seen_retval = TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Confirm that [shared] attributes are only used with string, wstring,
|
||||
* or native (but not nsid, domstring, utf8string, cstring or astring)
|
||||
* and can't be used with [array].
|
||||
*/
|
||||
if (IDL_tree_property_get(simple_decl, "shared") != NULL) {
|
||||
IDL_tree real_type;
|
||||
real_type = find_underlying_type(param_type);
|
||||
real_type = real_type ? real_type : param_type;
|
||||
|
||||
if (IDL_tree_property_get(simple_decl, "array") != NULL) {
|
||||
IDL_tree_error(method_tree,
|
||||
"[shared] parameter \"%s\" cannot "
|
||||
"be of array type", param_name);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!(IDL_NODE_TYPE(real_type) == IDLN_TYPE_STRING ||
|
||||
IDL_NODE_TYPE(real_type) == IDLN_TYPE_WIDE_STRING ||
|
||||
(UP_IS_NATIVE(real_type) &&
|
||||
!IDL_tree_property_get(real_type, "nsid") &&
|
||||
!IDL_tree_property_get(real_type, "domstring") &&
|
||||
!IDL_tree_property_get(real_type, "utf8string") &&
|
||||
!IDL_tree_property_get(real_type, "cstring") &&
|
||||
!IDL_tree_property_get(real_type, "astring") &&
|
||||
!IDL_tree_property_get(real_type, "jsval"))))
|
||||
{
|
||||
IDL_tree_error(method_tree,
|
||||
"[shared] parameter \"%s\" must be of type "
|
||||
"string, wstring or native", param_name);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* confirm that once an optional argument is used, all remaining
|
||||
* arguments are marked as optional or retval.
|
||||
*/
|
||||
if (IDL_tree_property_get(simple_decl, "optional") != NULL) {
|
||||
hasoptional = PR_TRUE;
|
||||
}
|
||||
else if (hasoptional && IDL_tree_property_get(simple_decl, "retval") == NULL) {
|
||||
IDL_tree_error(method_tree,
|
||||
"non-optional non-retval parameter used after one marked [optional]");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
* inout is not allowed with "domstring", "UTF8String", "CString"
|
||||
* and "AString" types
|
||||
*/
|
||||
if (IDL_PARAM_DCL(param).attr == IDL_PARAM_INOUT &&
|
||||
UP_IS_NATIVE(param_type) &&
|
||||
(IDL_tree_property_get(param_type, "domstring") != NULL ||
|
||||
IDL_tree_property_get(param_type, "utf8string") != NULL ||
|
||||
IDL_tree_property_get(param_type, "cstring") != NULL ||
|
||||
IDL_tree_property_get(param_type, "astring") != NULL )) {
|
||||
IDL_tree_error(method_tree,
|
||||
"[domstring], [utf8string], [cstring], [astring] "
|
||||
"types cannot be used as inout parameters");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* arrays of domstring, utf8string, cstring, astring types not allowed
|
||||
*/
|
||||
if (IDL_tree_property_get(simple_decl, "array") != NULL &&
|
||||
UP_IS_NATIVE(param_type) &&
|
||||
(IDL_tree_property_get(param_type, "domstring") != NULL ||
|
||||
IDL_tree_property_get(param_type, "utf8string") != NULL ||
|
||||
IDL_tree_property_get(param_type, "cstring") != NULL ||
|
||||
IDL_tree_property_get(param_type, "astring") != NULL)) {
|
||||
IDL_tree_error(method_tree,
|
||||
"[domstring], [utf8string], [cstring], [astring] "
|
||||
"types cannot be used in array parameters");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!check_param_attribute(method_tree, param, IID_IS) ||
|
||||
!check_param_attribute(method_tree, param, LENGTH_IS) ||
|
||||
!check_param_attribute(method_tree, param, SIZE_IS))
|
||||
return FALSE;
|
||||
|
||||
/*
|
||||
* Run additional error checks on the parameter type if targetting an
|
||||
* older version of XPConnect.
|
||||
*/
|
||||
|
||||
if (!verify_type_fits_version(param_type, method_tree))
|
||||
return FALSE;
|
||||
|
||||
}
|
||||
|
||||
if (IDL_tree_property_get(op->ident, "optional_argc") != NULL &&
|
||||
!hasoptional) {
|
||||
IDL_tree_error(method_tree,
|
||||
"[optional_argc] method must contain [optional] "
|
||||
"arguments");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (IDL_tree_property_get(op->ident, "nostdcall") != NULL &&
|
||||
scriptable_method) {
|
||||
IDL_tree_error(method_tree,
|
||||
"[nostdcall] method must not be scriptable");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* XXX q: can return type be nsid? */
|
||||
/* Native return type? */
|
||||
if (scriptable_method &&
|
||||
op->op_type_spec != NULL && UP_IS_NATIVE(op->op_type_spec) &&
|
||||
IDL_tree_property_get(op->op_type_spec, "nsid") == NULL &&
|
||||
IDL_tree_property_get(op->op_type_spec, "domstring") == NULL &&
|
||||
IDL_tree_property_get(op->op_type_spec, "utf8string") == NULL &&
|
||||
IDL_tree_property_get(op->op_type_spec, "cstring") == NULL &&
|
||||
IDL_tree_property_get(op->op_type_spec, "astring") == NULL &&
|
||||
IDL_tree_property_get(op->op_type_spec, "jsval") == NULL)
|
||||
{
|
||||
IDL_tree_error(method_tree,
|
||||
"methods in [scriptable] interfaces that are "
|
||||
"non-scriptable because they return native "
|
||||
"types must be marked [noscript]");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* nsid's parameters that aren't ptr's or ref's are not currently
|
||||
* supported in xpcom
|
||||
*/
|
||||
if (!notxpcom &&
|
||||
op->op_type_spec != NULL &&
|
||||
IDL_tree_property_get(op->op_type_spec, "nsid") != NULL &&
|
||||
IDL_tree_property_get(op->op_type_spec, "ptr") == NULL &&
|
||||
IDL_tree_property_get(op->op_type_spec, "ref") == NULL)
|
||||
{
|
||||
IDL_tree_error(method_tree,
|
||||
"Feature currently not supported: "
|
||||
"return value is of type nsid and "
|
||||
"must be marked either [ptr] or [ref], "
|
||||
"or else method \"%s\" must be marked [notxpcom] ",
|
||||
method_name);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Run additional error checks on the return type if targetting an
|
||||
* older version of XPConnect.
|
||||
*/
|
||||
|
||||
if (op->op_type_spec != NULL &&
|
||||
!verify_type_fits_version(op->op_type_spec, method_tree))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Verify that a native declaration has an associated C++ expression, i.e. that
|
||||
* it's of the form native <idl-name>(<c++-name>)
|
||||
*/
|
||||
gboolean
|
||||
check_native(TreeState *state)
|
||||
{
|
||||
char *native_name;
|
||||
/* require that native declarations give a native type */
|
||||
if (IDL_NATIVE(state->tree).user_type)
|
||||
return TRUE;
|
||||
native_name = IDL_IDENT(IDL_NATIVE(state->tree).ident).str;
|
||||
IDL_tree_error(state->tree,
|
||||
"``native %s;'' needs C++ type: ``native %s(<C++ type>);''",
|
||||
native_name, native_name);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Print a GSList as char strings to a file.
|
||||
*/
|
||||
void
|
||||
printlist(FILE *outfile, GSList *slist)
|
||||
{
|
||||
guint i;
|
||||
guint len = g_slist_length(slist);
|
||||
|
||||
for(i = 0; i < len; i++) {
|
||||
fprintf(outfile,
|
||||
"%s\n", (char *)g_slist_nth_data(slist, i));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
xpidl_list_foreach(IDL_tree p, IDL_tree_func foreach, gpointer user_data)
|
||||
{
|
||||
IDL_tree_func_data tfd;
|
||||
|
||||
while (p) {
|
||||
struct _IDL_LIST *list = &IDL_LIST(p);
|
||||
tfd.tree = list->data;
|
||||
if (!foreach(&tfd, user_data))
|
||||
return;
|
||||
p = list->next;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Verify that the interface declaration is correct
|
||||
*/
|
||||
gboolean
|
||||
verify_interface_declaration(IDL_tree interface_tree)
|
||||
{
|
||||
gboolean scriptable =
|
||||
IDL_tree_property_get(IDL_INTERFACE(interface_tree).ident,
|
||||
"scriptable") != NULL;
|
||||
gboolean builtinclass =
|
||||
IDL_tree_property_get(IDL_INTERFACE(interface_tree).ident,
|
||||
"builtinclass") != NULL;
|
||||
|
||||
IDL_tree iter;
|
||||
/*
|
||||
* If we have the scriptable attribute then make sure all of our direct
|
||||
* parents have it as well.
|
||||
* NOTE: We don't recurse since all interfaces will come through here
|
||||
*/
|
||||
if (scriptable || !builtinclass) {
|
||||
for (iter = IDL_INTERFACE(interface_tree).inheritance_spec; iter;
|
||||
iter = IDL_LIST(iter).next) {
|
||||
if (scriptable &&
|
||||
IDL_tree_property_get(
|
||||
IDL_INTERFACE(iter).ident, "scriptable") == 0) {
|
||||
XPIDL_WARNING((interface_tree,IDL_WARNING1,
|
||||
"%s is scriptable but inherits from the non-scriptable interface %s\n",
|
||||
IDL_IDENT(IDL_INTERFACE(interface_tree).ident).str,
|
||||
IDL_IDENT(IDL_INTERFACE(iter).ident).str));
|
||||
}
|
||||
if (!builtinclass &&
|
||||
IDL_tree_property_get(
|
||||
IDL_INTERFACE(iter).ident, "builtinclass")) {
|
||||
IDL_tree_error(interface_tree,
|
||||
"%s is not [builtinclass] but extends "
|
||||
"[builtinclass] interface %s",
|
||||
IDL_IDENT(IDL_INTERFACE(interface_tree).ident).str,
|
||||
IDL_IDENT(IDL_INTERFACE(iter).ident).str);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return a pointer to the start of the base filename of path
|
||||
*/
|
||||
const char *
|
||||
xpidl_basename(const char * path)
|
||||
{
|
||||
const char * result = g_basename(path);
|
||||
/*
|
||||
*If this is windows then we'll handle either / or \ as a separator
|
||||
* g_basename only handles \ for windows
|
||||
*/
|
||||
#if defined(XP_WIN32)
|
||||
const char * slash = strrchr(path, '/');
|
||||
/* If we found a slash and its after the current default OS separator */
|
||||
if (slash != NULL && (slash > result))
|
||||
result = slash + 1;
|
||||
#endif
|
||||
return result;
|
||||
}
|
Загрузка…
Ссылка в новой задаче