* configure.ac (OPT_CXXFLAGS): New variable.
(ARCH_CFLAGS): Renamed to ARCH_FLAGS.
(OS_FLAGS): New variable.
(CC_FLAGS, CXX_FLAGS): Likewise.
* m4/threads.m4 (ENABLE_THREADS): Set OS_FLAGS instead of ARCH_CFLAGS.
* src/cacao/Makefile.am (nodist_EXTRA_libjvm_la_SOURCES): Added to
force C++ linking.
* src/cacaoh/dummy.c (instruction_call_site): Added.
(icmd_table): Likewise.
(package_add): Renamed to Package_add.
[HAVE___THREAD] (thread_current): Added.
[!HAVE___THREAD) (thread_current_key): Likewise.
* src/cacaoh/headers.c (printmethod): Print _this instead of this, as
it's a C++ keyword.
* src/mm/boehm-gc/configure.ac: Don't use CACAO's CFLAGS anymore.
* src/mm/memory.h [__cplusplus]: Added define.
* src/native/jni.h [__cplusplus] (_Jv_JNIEnv): Likewise.
[__cplusplus] (_Jv_JavaVM): Likewise.
* src/native/vm/openjdk/jvm.c (vm/package.h): Removed.
(vm/package.hpp): Added.
(JVM_GetSystemPackage): Renamed package_find to Package_find.
* src/toolbox/list.h [__cplusplus]: Added define.
* src/vm/Makefile.am (libvm_la_SOURCES): Removed package.[ch], added
package.{cpp,hpp}.
* src/vm/vm.c (vm/package.h): Removed.
(vm/package.hpp): Added.
(vm_create): Renamed package_init to Package_initialize.
* src/vmcore/loader.c (vm/package.h): Removed.
(vm/package.hpp): Added.
(load_class_bootstrap): Renamed package_add to Package_add.
* src/vm/package.c,
src/vm/package.h: Moved from C...
* src/vm/package.cpp,
src/vm/package.hpp: ...to C++.
AC_PREFIX_DEFAULT(/usr/local/cacao)
-dnl set optimization and debugging for all architectures and systems
+dnl Set optimization and debugging for all architectures and systems.
if test x"$CFLAGS" = "x"; then
OPT_CFLAGS="-O0 -g"
else
OPT_CFLAGS=$CFLAGS
fi
+if test x"$CXXFLAGS" = "x"; then
+ OPT_CXXFLAGS="-O0 -g"
+else
+ OPT_CXXFLAGS=$CXXFLAGS
+fi
+
dnl system type
case "$host_cpu" in
alpha | alphaev56 | alphapca56 )
ARCH_DIR="alpha"
- ARCH_CFLAGS="-mieee -D__ALPHA__"
+ ARCH_FLAGS="-mieee -D__ALPHA__"
JAVA_ARCH="alpha"
;;
arm | armv4 | armv4tl | armv5b | armv5l )
ARCH_DIR="arm"
- ARCH_CFLAGS="-D__ARM__"
+ ARCH_FLAGS="-D__ARM__"
JAVA_ARCH="arm"
;;
hppa2.0 )
ARCH_DIR="parisc"
- ARCH_CFLAGS="-D__PARISC__"
+ ARCH_FLAGS="-D__PARISC__"
JAVA_ARCH="hppa"
;;
i386 | i486 | i586 | i686 )
ARCH_DIR="i386"
- ARCH_CFLAGS="-D__I386__"
+ ARCH_FLAGS="-D__I386__"
JAVA_ARCH="i386"
;;
m68k )
ARCH_DIR="m68k"
- ARCH_CFLAGS="-D__M68K__"
+ ARCH_FLAGS="-D__M68K__"
JAVA_ARCH="m68k"
;;
mips | mipsel )
ARCH_DIR="mips"
- ARCH_CFLAGS="-D__MIPS__"
+ ARCH_FLAGS="-D__MIPS__"
dnl Is this correct for mipsel?
JAVA_ARCH="mips"
;;
powerpc )
ARCH_DIR="powerpc"
- ARCH_CFLAGS="-D__POWERPC__"
+ ARCH_FLAGS="-D__POWERPC__"
JAVA_ARCH="ppc"
;;
powerpc64 )
ARCH_DIR="powerpc64"
- ARCH_CFLAGS="-D__POWERPC64__"
+ ARCH_FLAGS="-D__POWERPC64__"
JAVA_ARCH="ppc64"
;;
s390 )
ARCH_DIR="s390"
- ARCH_CFLAGS="-D__S390__"
+ ARCH_FLAGS="-D__S390__"
JAVA_ARCH="s390"
;;
sparc | sparc64 )
ARCH_DIR="sparc64"
- ARCH_CFLAGS="-mcpu=v9 -m64 -D__SPARC_64__"
+ ARCH_FLAGS="-mcpu=v9 -m64 -D__SPARC_64__"
dnl Is this correct for 64-bits?
JAVA_ARCH="sparc"
;;
x86_64 )
ARCH_DIR="x86_64"
- ARCH_CFLAGS="-D__X86_64__"
+ ARCH_FLAGS="-m64 -D__X86_64__"
JAVA_ARCH="amd64"
;;
xdspcore )
ARCH_DIR="xdspcore"
ENABLE_STATICVM="yes"
- ARCH_CFLAGS="-D__XDSPCORE__"
+ ARCH_FLAGS="-D__XDSPCORE__"
USE_SCHEDULER="1"
;;
case "$host_os" in
*cygwin* )
OS_DIR="cygwin"
- INTRP_CFLAGS="$ARCH_CFLAGS -D__WINDOWS__ -D__CYGWIN__ -Wall -Wno-long-long"
- ARCH_CFLAGS="$ARCH_CFLAGS -D__WINDOWS__ -D__CYGWIN__ -std=c99 -pedantic -Wall -Wno-long-long"
+ OS_FLAGS="-D__WINDOWS__ -D__CYGWIN__"
+ CC_FLAGS="-std=c99 -pedantic -Wall -Wno-long-long"
+ CXX_FLAGS="-std=c++98 -pedantic -Wall -Wno-long-long"
+ INTRP_CFLAGS="-Wall -Wno-long-long $ARCH_FLAGS $OS_FLAGS"
;;
*darwin* )
OS_DIR="darwin"
- INTRP_CFLAGS="$ARCH_CFLAGS -D__DARWIN__ -Wall -Wno-long-long"
- ARCH_CFLAGS="$ARCH_CFLAGS -D__DARWIN__ -std=c99 -pedantic -Wall -Wno-long-long"
+ OS_FLAGS="-D__DARWIN__"
+ CC_FLAGS="-std=c99 -pedantic -Wall -Wno-long-long"
+ CXX_FLAGS="-std=c++98 -pedantic -Wall -Wno-long-long"
+ INTRP_CFLAGS="-Wall -Wno-long-long $ARCH_FLAGS $OS_FLAGS"
;;
dnl Must be BEFORE *freebsd*.
*kfreebsd*-gnu)
OS_DIR="freebsd"
- INTRP_CFLAGS="$ARCH_CFLAGS -D__FREEBSD__ -Wall -Wno-long-long -D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE"
- ARCH_CFLAGS="$ARCH_CFLAGS -D__FREEBSD__ -std=c99 -pedantic -Wall -Wno-long-long -D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE"
+ OS_FLAGS="-D__FREEBSD__ -D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE"
+ CC_FLAGS="-std=c99 -pedantic -Wall -Wno-long-long"
+ CXX_FLAGS="-std=c++98 -pedantic -Wall -Wno-long-long"
+ INTRP_CFLAGS="-Wall -Wno-long-long $ARCH_FLAGS $OS_FLAGS"
;;
*freebsd* )
OS_DIR="freebsd"
- INTRP_CFLAGS="$ARCH_CFLAGS -D__FREEBSD__ -Wall -Wno-long-long -D_XOPEN_SOURCE_EXTENDED"
- ARCH_CFLAGS="$ARCH_CFLAGS -D__FREEBSD__ -std=c99 -pedantic -Wall -Wno-long-long -D_XOPEN_SOURCE_EXTENDED"
+ OS_FLAGS="-D__FREEBSD__ -D_XOPEN_SOURCE_EXTENDED"
+ CC_FLAGS="-std=c99 -pedantic -Wall -Wno-long-long"
+ CXX_FLAGS="-std=c++98 -pedantic -Wall -Wno-long-long"
+ INTRP_CFLAGS="-Wall -Wno-long-long $ARCH_FLAGS $OS_FLAGS"
;;
*irix* )
OS_DIR="irix"
- INTRP_CFLAGS="$ARCH_CFLAGS -D__IRIX__"
- ARCH_CFLAGS="$ARCH_CFLAGS -D__IRIX__"
+ OS_FLAGS="-D__IRIX__"
+ CC_FLAGS=""
+ CXX_FLAGS=""
+ INTRP_CFLAGS="$ARCH_FLAGS $OS_FLAGS"
;;
dnl Must be BEFORE *linux*.
*uclinux | *elf )
OS_DIR="uclinux"
- INTRP_CFLAGS="$ARCH_CFLAGS -D__LINUX__ -Wall -Wno-long-long -D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE"
- ARCH_CFLAGS="$ARCH_CFLAGS -D__LINUX__ -std=c99 -pedantic -Wall -Wno-long-long -D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE"
+ OS_FLAGS="-D__LINUX__ -D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE"
+ CC_FLAGS="-std=c99 -pedantic -Wall -Wno-long-long"
+ CXX_FLAGS="-std=c++98 -pedantic -Wall -Wno-long-long"
+ INTRP_CFLAGS="-Wall -Wno-long-long $ARCH_FLAGS $OS_FLAGS"
;;
*linux* | *Linux* )
OS_DIR="linux"
- INTRP_CFLAGS="$ARCH_CFLAGS -D__LINUX__ -Wall -Wno-long-long -D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE"
- ARCH_CFLAGS="$ARCH_CFLAGS -D__LINUX__ -std=c99 -pedantic -Wall -Wno-long-long -D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE"
+ OS_FLAGS="-D__LINUX__ -D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE"
+ CC_FLAGS="-std=c99 -pedantic -Wall -Wno-long-long"
+ CXX_FLAGS="-std=c++98 -pedantic -Wall -Wno-long-long"
+ INTRP_CFLAGS="-Wall -Wno-long-long $ARCH_FLAGS $OS_FLAGS"
;;
*netbsd* )
OS_DIR="netbsd"
- INTRP_CFLAGS="$ARCH_CFLAGS -D__NETBSD__ -Wall -Wno-long-long -D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE"
- ARCH_CFLAGS="$ARCH_CFLAGS -D__NETBSD__ -std=c99 -pedantic -Wall -Wno-long-long -D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE"
+ OS_FLAGS="-D__NETBSD__ -D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE"
+ CC_FLAGS="-std=c99 -pedantic -Wall -Wno-long-long"
+ CXX_FLAGS="-std=c++98 -pedantic -Wall -Wno-long-long"
+ INTRP_CFLAGS="-Wall -Wno-long-long $ARCH_FLAGS $OS_FLAGS"
;;
*solaris* )
dnl On solaris the architecture defines 'sparc', 'sun', 'unix' are
dnl not set when cpp is called with -std=c99, therefore we add them
dnl here.
- INTRP_CFLAGS="$ARCH_CFLAGS -D__SOLARIS__ -Wall -Wno-long-long -D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=600 -D__EXTENSIONS__ -D_BSD_SOURCE -Dsparc -Dsun -Dunix"
- ARCH_CFLAGS="$ARCH_CFLAGS -D__SOLARIS__ -std=c99 -pedantic -Wall -Wno-long-long -D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=600 -D__EXTENSIONS__ -D_BSD_SOURCE -Dsparc -Dsun -Dunix"
+ OS_FLAGS="-D__SOLARIS__ -D_POSIX_C_SOURCE=200112L -D__EXTENSIONS__ -D_BSD_SOURCE"
+ CC_FLAGS="-std=c99 -pedantic -Wall -Wno-long-long -D_XOPEN_SOURCE=600"
+ CXX_FLAGS="-std=c++98 -pedantic -Wall -Wno-long-long"
+ INTRP_CFLAGS="-Wall -Wno-long-long $ARCH_FLAGS $OS_FLAGS"
;;
* )
dnl temporary set the CFLAGS for configure tests (e.g. inline keyword)
dnl we set it properly at the end of this file
-CFLAGS="$ARCH_CFLAGS $OPT_CFLAGS"
+CFLAGS="$OPT_CFLAGS $ARCH_FLAGS $OS_FLAGS $CC_FLAGS"
+CXXFLAGS="$OPT_CXXFLAGS $ARCH_FLAGS $OS_FLAGS $CXX_FLAGS"
dnl set interpreter flags
AC_SUBST(INTRP_CFLAGS)
dnl Checks for programs.
AC_PROG_CC
+AC_PROG_CXX
AM_PROG_AS
AC_PROG_LD
AC_PROG_LD_GNU
dnl define some stuff required for --fullversion
AC_DEFINE_UNQUOTED(VERSION_CONFIGURE_ARGS, "$ac_configure_args", [configure arguments])
AC_DEFINE_UNQUOTED(VERSION_CC, "$CC", [CC used])
-AC_DEFINE_UNQUOTED(VERSION_CFLAGS, "$OPT_CFLAGS $ARCH_CFLAGS $CPPFLAGS", [CFLAGS used])
+AC_DEFINE_UNQUOTED(VERSION_CXX, "$CXX", [CXX used])
+AC_DEFINE_UNQUOTED(VERSION_CFLAGS, "$OPT_CFLAGS $ARCH_CFLAGS $CC_FLAGS $CPPFLAGS", [CFLAGS used])
+AC_DEFINE_UNQUOTED(VERSION_CXXFLAGS, "$OPT_CXXFLAGS $ARCH_CXXFLAGS $CXX_FLAGS $CPPFLAGS", [CXXFLAGS used])
-dnl finally pass CFLAGS to Makefiles via AM_CFLAGS
+dnl Finally pass flags to Makefiles.
CFLAGS="$OPT_CFLAGS"
-AM_CFLAGS=$ARCH_CFLAGS
+CXXFLAGS="$OPT_CXXFLAGS"
+
+AM_CFLAGS="$CC_FLAGS $ARCH_FLAGS $OS_FLAGS"
+AM_CXXFLAGS="$CXX_FLAGS $ARCH_FLAGS $OS_FLAGS"
AM_CPPFLAGS="$CPPFLAGS"
+
AC_SUBST(AM_CFLAGS)
+AC_SUBST(AM_CXXFLAGS)
AC_SUBST(AM_CPPFLAGS)
)
-dnl now configure subpackages with OPT_CFLAGS and ARCH_CFLAGS
-export OPT_CFLAGS
-export ARCH_CFLAGS
dnl We only build the shared library objects but we use it as
-dnl noinst_LTLIBRARIES
+dnl noinst_LTLIBRARIES.
ac_configure_args="$ac_configure_args --disable-static"
AC_CONFIG_SUBDIRS(src/mm/boehm-gc)
AC_DEFINE([ENABLE_THREADS], 1, [enable threads])
AC_CHECK_LIB(pthread, main)
- ARCH_CFLAGS="$ARCH_CFLAGS -D_REENTRANT"
+ OS_FLAGS="$OS_FLAGS -D_REENTRANT"
- dnl we changed ARCH_CFLAGS, set CFLAGS again
- CFLAGS="$ARCH_CFLAGS $OPT_CFLAGS"
+ dnl We changed OS_FLAGS, set CFLAGS again.
+ CFLAGS="$OPT_CFLAGS $ARCH_FLAGS $OS_FLAGS $CC_FLAGS"
+ CXXFLAGS="$OPT_CXXFLAGS $ARCH_FLAGS $OS_FLAGS $CXX_FLAGS"
dnl tell boehm to support threads as well
ac_configure_args="$ac_configure_args --enable-boehm-threads=posix"
libjvm_la_SOURCES =
+# Dummy C++ source to cause C++ linking.
+# http://www.gnu.org/software/automake/manual/automake.html#Libtool-Convenience-Libraries
+nodist_EXTRA_libjvm_la_SOURCES = \
+ dummy.cxx
+
libjvm_la_LIBADD = \
$(top_builddir)/src/fdlibm/libfdlibm.la \
$(top_builddir)/src/mm/libmm.la \
}
+/* instruction ****************************************************************/
+
+methoddesc *instruction_call_site(const instruction *iptr)
+{
+ return NULL;
+}
+
+
/* jit ************************************************************************/
+icmdtable_entry_t icmd_table[256] = {};
+
void jit_invalidate_code(methodinfo *m)
{
vm_abort("jit_invalidate_code");
/* package ********************************************************************/
-/* void package_add(java_handle_t *packagename) */
-void package_add(utf *packagename)
+/* void Package_add(java_handle_t *packagename) */
+void Package_add(utf *packagename)
{
/* Do nothing. */
}
/* threads ********************************************************************/
+#if defined(HAVE___THREAD)
+__thread threadobject *thread_current;
+#else
+#include <pthread.h>
+pthread_key_t thread_current_key;
+#endif
+
intptr_t threads_get_current_tid(void)
{
return 0;
if (!(m->flags & ACC_STATIC)) {
fprintf(file, ", struct ");
printID(m->clazz->name);
- fprintf(file, "* this");
+ fprintf(file, "* _this");
} else {
fprintf(file, ", jclass clazz");
AM_PROG_CC_C_O
AC_PROG_CXX
-dnl temporary set the CFLAGS for configure tests (e.g. inline keyword)
-dnl we set it properly later in this file
-CFLAGS="$ARCH_CFLAGS $OPT_CFLAGS"
-AC_C_INLINE
-
AM_PROG_AS
## FIXME: really needed? (AC_LIBTOOL already provides this)
AC_CHECK_TOOL(AR, ar)
*) AC_MSG_RESULT(no) ;;
esac
-dnl We need to override the top-level CFLAGS. This is how we do it.
-dnl MY_CFLAGS="$CFLAGS"
-dnl AC_SUBST(MY_CFLAGS)
-
-dnl pass CFLAGS to Makefiles via AM_CFLAGS
-CFLAGS=$OPT_CFLAGS
-AM_CFLAGS=$ARCH_CFLAGS
-AC_SUBST(AM_CFLAGS)
-
dnl Include defines that have become de facto standard.
dnl ALL_INTERIOR_POINTERS can be overridden in startup code.
AC_DEFINE([NO_EXECUTE_PERMISSION], 1, [no exceute permission])
#ifndef _MEMORY_H
#define _MEMORY_H
-
#include "config.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#include <string.h>
#include "vm/types.h"
bool memory_start_thread(void);
#endif
+#ifdef __cplusplus
+}
+#endif
+
#endif /* _MEMORY_H */
/* _Jv_JNIEnv *****************************************************************/
+#ifndef __cplusplus
+
+// FIXME The __cplusplus define is just a quick workaround and needs
+// to be fixed properly.
+
typedef struct _Jv_JNIEnv _Jv_JNIEnv;
struct _Jv_JNIEnv {
const struct JNINativeInterface_ *env; /* This MUST be the first entry */
};
+#endif
+
/* _Jv_JavaVM *****************************************************************/
+#ifndef __cplusplus
+
+// FIXME The __cplusplus define is just a quick workaround and needs
+// to be fixed properly.
+
typedef struct _Jv_JavaVM _Jv_JavaVM;
struct _Jv_JavaVM {
s8 java_lang_management_ThreadMXBean_TotalStartedThreadCount;
};
+#endif
+
/* CACAO related stuff ********************************************************/
#include "vm/exceptions.h"
#include "vm/global.h"
#include "vm/initialize.h"
-#include "vm/package.h"
+#include "vm/package.hpp"
#include "vm/primitive.h"
#include "vm/properties.h"
#include "vm/resolve.h"
TRACEJVMCALLS(("JVM_GetSystemPackage(env=%p, name=%p)", env, name));
-/* s = package_find(name); */
+/* s = Package_find(name); */
u = javastring_toutf((java_handle_t *) name, false);
- result = package_find(u);
+ result = Package_find(u);
if (result != NULL)
s = javastring_new(result);
#include "config.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#include <stdint.h>
#include "vm/global.h"
void *list_next(list_t *l, void *element);
void *list_prev(list_t *l, void *element);
+#ifdef __cplusplus
+}
+#endif
+
#endif /* _LIST_H */
## src/vm/Makefile.am
##
-## Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel,
-## C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
-## E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
-## J. Wenninger, Institut f. Computersprachen - TU Wien
+## Copyright (C) 1996-2005, 2006, 2007, 2008
+## CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
##
## This file is part of CACAO.
##
## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
## 02110-1301, USA.
-## Process this file with automake to produce Makefile.in
AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/src/vm/jit/$(ARCH_DIR) -I$(top_srcdir)/src/vm/jit/$(ARCH_DIR)/$(OS_DIR) -I$(top_builddir)/src -I$(top_srcdir)/contrib/vmlog -I$(top_srcdir)/src/native
initialize.c \
initialize.h \
jit_interface.h \
- package.c \
- package.h \
+ package.cpp \
+ package.hpp \
primitive.c \
primitive.h \
properties.c \
+++ /dev/null
-/* src/vm/package.c - Java boot-package functions
-
- Copyright (C) 2007, 2008
- CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
-
- This file is part of CACAO.
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2, or (at
- your option) any later version.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- 02110-1301, USA.
-
-*/
-
-
-#include "config.h"
-
-#include <stdint.h>
-
-#include "toolbox/list.h"
-
-#include "mm/memory.h"
-
-#include "native/jni.h"
-
-#include "native/include/java_lang_String.h"
-
-#include "vm/package.h"
-#include "vm/stringlocal.h"
-
-#include "vmcore/options.h"
-#include "vmcore/utf8.h"
-
-
-/* internal property structure ************************************************/
-
-typedef struct list_package_entry_t list_package_entry_t;
-
-struct list_package_entry_t {
-/* java_string_t *packagename; */
- utf *packagename;
- listnode_t linkage;
-};
-
-
-/* global variables ***********************************************************/
-
-static list_t *list_package = NULL;
-
-
-/* package_init ****************************************************************
-
- Initialize the package list.
-
-*******************************************************************************/
-
-void package_init(void)
-{
- TRACESUBSYSTEMINITIALIZATION("package_init");
-
- /* create the properties list */
-
- list_package = list_create(OFFSET(list_package_entry_t, linkage));
-}
-
-
-/* package_add *****************************************************************
-
- Add a package to the boot-package list.
-
- IN:
- packagename....package name as Java string
-
-*******************************************************************************/
-
-/* void package_add(java_handle_t *packagename) */
-void package_add(utf *packagename)
-{
-/* java_string_t *s; */
- list_package_entry_t *lpe;
-
- /* Intern the Java string to get a unique address. */
-
-/* s = javastring_intern(packagename); */
-
- /* Check if the package is already stored. */
-
- if (package_find(packagename) != NULL)
- return;
-
- /* Add the package. */
-
-#if !defined(NDEBUG)
- if (opt_DebugPackage) {
- log_start();
- log_print("[package_add: packagename=");
- utf_display_printable_ascii(packagename);
- log_print("]");
- log_finish();
- }
-#endif
-
- lpe = NEW(list_package_entry_t);
-
- lpe->packagename = packagename;
-
- list_add_last(list_package, lpe);
-}
-
-
-/* package_find ****************************************************************
-
- Find a package in the list.
-
- IN:
- packagename....package name as Java string
-
- OUT:
- package name as Java string
-
-*******************************************************************************/
-
-/* java_handle_t *package_find(java_handle_t *packagename) */
-utf *package_find(utf *packagename)
-{
-/* java_string_t *s; */
- list_t *l;
- list_package_entry_t *lpe;
-
- /* Intern the Java string to get a unique address. */
-
-/* s = javastring_intern(packagename); */
-
- /* For convenience. */
-
- l = list_package;
-
- for (lpe = list_first(l); lpe != NULL; lpe = list_next(l, lpe)) {
-/* if (lpe->packagename == s) */
- if (lpe->packagename == packagename)
- return lpe->packagename;
- }
-
- return NULL;
-}
-
-
-/*
- * These are local overrides for various environment variables in Emacs.
- * Please do not remove this and leave it at the end of the file, where
- * Emacs will automagically detect them.
- * ---------------------------------------------------------------------
- * Local variables:
- * mode: c
- * indent-tabs-mode: t
- * c-basic-offset: 4
- * tab-width: 4
- * End:
- * vim:noexpandtab:sw=4:ts=4:
- */
--- /dev/null
+/* src/vm/package.cpp - Java boot-package functions
+
+ Copyright (C) 2007, 2008
+ CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+
+ This file is part of CACAO.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2, or (at
+ your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA.
+
+*/
+
+
+#include "config.h"
+
+#include <stdint.h>
+
+#include "toolbox/list.h"
+
+#include "mm/memory.h"
+
+#include "native/jni.h"
+
+#include "native/include/java_lang_String.h"
+
+#include "vm/package.hpp"
+#include "vm/stringlocal.h"
+
+#include "vmcore/options.h"
+#include "vmcore/utf8.h"
+
+
+/* internal property structure ************************************************/
+
+typedef struct list_package_entry_t list_package_entry_t;
+
+struct list_package_entry_t {
+/* java_string_t *packagename; */
+ utf *packagename;
+ listnode_t linkage;
+};
+
+
+/* global variables ***********************************************************/
+
+static list_t *list_package = NULL;
+
+
+/**
+ * Initialize the package list.
+ */
+void Package::initialize(void)
+{
+ TRACESUBSYSTEMINITIALIZATION("package_init");
+
+ /* create the properties list */
+
+ list_package = list_create(OFFSET(list_package_entry_t, linkage));
+}
+
+
+/**
+ * Add a package to the boot-package list.
+ *
+ * @param packagename Package name as Java string.
+ */
+/* void package_add(java_handle_t *packagename) */
+void Package::add(utf *packagename)
+{
+/* java_string_t *s; */
+ list_package_entry_t *lpe;
+
+ /* Intern the Java string to get a unique address. */
+
+/* s = javastring_intern(packagename); */
+
+ /* Check if the package is already stored. */
+
+ if (Package::find(packagename) != NULL)
+ return;
+
+ /* Add the package. */
+
+#if !defined(NDEBUG)
+ if (opt_DebugPackage) {
+ log_start();
+ log_print("[package_add: packagename=");
+ utf_display_printable_ascii(packagename);
+ log_print("]");
+ log_finish();
+ }
+#endif
+
+ lpe = NEW(list_package_entry_t);
+
+ lpe->packagename = packagename;
+
+ list_add_last(list_package, lpe);
+}
+
+
+/**
+ * Find a package in the list.
+ *
+ * @param packagename Package name as Java string.
+ *
+ * @return Package name as Java string.
+ */
+/* java_handle_t *package_find(java_handle_t *packagename) */
+utf* Package::find(utf *packagename)
+{
+/* java_string_t *s; */
+ list_t *l;
+ list_package_entry_t *lpe;
+
+ /* Intern the Java string to get a unique address. */
+
+/* s = javastring_intern(packagename); */
+
+ /* For convenience. */
+
+ l = list_package;
+
+ for (lpe = (list_package_entry_t*) list_first(l); lpe != NULL; lpe = (list_package_entry_t*) list_next(l, lpe)) {
+/* if (lpe->packagename == s) */
+ if (lpe->packagename == packagename)
+ return lpe->packagename;
+ }
+
+ return NULL;
+}
+
+
+/* Legacy C interface *********************************************************/
+
+extern "C" {
+
+void Package_initialize(void) { Package::initialize(); }
+void Package_add(utf* packagename) { Package::add(packagename); }
+utf* Package_find(utf *packagename) { return Package::find(packagename); }
+
+}
+
+
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of the file, where
+ * Emacs will automagically detect them.
+ * ---------------------------------------------------------------------
+ * Local variables:
+ * mode: c++
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ * vim:noexpandtab:sw=4:ts=4:
+ */
+++ /dev/null
-/* src/vm/package.c - Java boot-package functions
-
- Copyright (C) 2007 R. Grafl, A. Krall, C. Kruegel,
- C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
- E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
- J. Wenninger, Institut f. Computersprachen - TU Wien
-
- This file is part of CACAO.
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2, or (at
- your option) any later version.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- 02110-1301, USA.
-
-*/
-
-
-#ifndef _VM_PACKAGE_H
-#define _VM_PACKAGE_H
-
-#include "config.h"
-
-#include <stdint.h>
-
-#include "native/jni.h"
-
-#include "vm/global.h"
-
-
-/* function prototypes ********************************************************/
-
-void package_init(void);
-
-/* void package_add(java_handle_t *packagename); */
-void package_add(utf *packagename);
-/* java_handle_t *package_find(java_handle_t *packagename); */
-utf *package_find(utf *packagename);
-
-#endif /* _VM_PACKAGE_H */
-
-
-/*
- * These are local overrides for various environment variables in Emacs.
- * Please do not remove this and leave it at the end of the file, where
- * Emacs will automagically detect them.
- * ---------------------------------------------------------------------
- * Local variables:
- * mode: c
- * indent-tabs-mode: t
- * c-basic-offset: 4
- * tab-width: 4
- * End:
- * vim:noexpandtab:sw=4:ts=4:
- */
--- /dev/null
+/* src/vm/package.hpp - Java boot-package functions
+
+ Copyright (C) 2007, 2008
+ CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+
+ This file is part of CACAO.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2, or (at
+ your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA.
+
+*/
+
+
+#ifndef _VM_PACKAGE_HPP
+#define _VM_PACKAGE_HPP
+
+#include "config.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdint.h>
+
+#include "native/jni.h"
+
+#include "vm/global.h"
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#ifdef __cplusplus
+
+/**
+ *
+ */
+class Package {
+public:
+ static void initialize();
+ /* static void add(java_handle_t *packagename); */
+ static void add(utf *packagename);
+ /* static java_handle_t* find(java_handle_t *packagename); */
+ static utf* find(utf *packagename);
+};
+
+#else
+
+/* Legacy C interface *********************************************************/
+
+typedef struct Package Package;
+
+void Package_initialize();
+void Package_add(utf* packagename);
+utf* Package_find(utf* packagename);
+
+#endif
+
+#endif /* _VM_PACKAGE_HPP */
+
+
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of the file, where
+ * Emacs will automagically detect them.
+ * ---------------------------------------------------------------------
+ * Local variables:
+ * mode: c++
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ * vim:noexpandtab:sw=4:ts=4:
+ */
#include "vm/finalizer.h"
#include "vm/global.h"
#include "vm/initialize.h"
-#include "vm/package.h"
+#include "vm/package.hpp"
#include "vm/primitive.h"
#include "vm/properties.h"
#include "vm/signallocal.h"
/* BEFORE: loader_preinit */
- package_init();
+ Package_initialize();
/* AFTER: utf8_init, classcache_init */
#include "vm/builtin.h"
#include "vm/exceptions.h"
#include "vm/global.h"
-#include "vm/package.h"
+#include "vm/package.hpp"
#include "vm/primitive.h"
#include "vm/resolve.h"
#include "vm/stringlocal.h"
else {
/* Add the package name to the boot packages. */
- package_add(c->packagename);
+ Package_add(c->packagename);
}
r = res;