* src/native/jni.cpp: [OPENJDK] Implemented jni_GetDirectBufferCapacity.
[cacao.git] / src / vm / suck.cpp
index 01415a5368a900b6209d59129d7e28074ad4fb49..ef43e92ff114f11e17c22fb075bc3a0bcaf2a335 100644 (file)
 
 #include "arch.h"
 
-#include "mm/memory.h"
+#include "mm/memory.hpp"
 
 #include "threads/mutex.hpp"
 
-#include "toolbox/list.h"
-#include "toolbox/logging.h"
-#include "toolbox/util.h"
+#include "toolbox/list.hpp"
+#include "toolbox/logging.hpp"
 
 #include "vm/exceptions.hpp"
 #include "vm/loader.hpp"
 #include "vm/properties.hpp"
 #include "vm/suck.hpp"
 #include "vm/vm.hpp"
-#include "vm/zip.h"
-
-
-/* global variables ***********************************************************/
-
-list_t *list_classpath_entries;
-
-
-/* suck_init *******************************************************************
-
-   Initializes the suck subsystem like initializing the classpath
-   entries list.
-
-*******************************************************************************/
-
-bool suck_init(void)
-{
-       TRACESUBSYSTEMINITIALIZATION("suck_init");
-
-       list_classpath_entries = list_create(OFFSET(list_classpath_entry, linkage));
-
-       /* everything's ok */
-
-       return true;
-}
+#include "vm/zip.hpp"
 
 
 /* scandir_filter **************************************************************
@@ -98,13 +73,10 @@ static int scandir_filter(const struct dirent *a)
 }
 
 
-/* suck_add ********************************************************************
-
-   Adds a classpath to the global classpath entries list.
-
-*******************************************************************************/
-
-void suck_add(char *classpath)
+/**
+ * Adds a classpath to the global classpath entries list.
+ */
+void SuckClasspath::add(char *classpath)
 {
        list_classpath_entry *lce;
        char                 *start;
@@ -142,7 +114,7 @@ void suck_add(char *classpath)
                        cwdlen = 0;
 
                        if (*start != '/') {                      /* XXX fix me for win32 */
-                               cwd = _Jv_getcwd();
+                               cwd = os::getcwd();
                                cwdlen = strlen(cwd) + strlen("/");
                        }
 
@@ -205,7 +177,7 @@ void suck_add(char *classpath)
                        /* add current classpath entry, if no error */
 
                        if (lce != NULL)
-                               list_add_last(list_classpath_entries, lce);
+                               push_back(lce);
                }
 
                /* goto next classpath entry, skip ':' delimiter */
@@ -218,14 +190,11 @@ void suck_add(char *classpath)
 }
 
 
-/* suck_add_from_property ******************************************************
-
-   Adds a classpath form a property entry to the global classpath
-   entries list.
-
-*******************************************************************************/
-
-void suck_add_from_property(const char *key)
+/**
+ * Adds a classpath form a property entry to the global classpath
+ * entries list.
+ */
+void SuckClasspath::add_from_property(const char *key)
 {
        const char     *value;
        const char     *start;
@@ -237,8 +206,8 @@ void suck_add_from_property(const char *key)
        s4              namlen;
        char           *p;
 
-       /* get the property value */
-       Properties properties = VM::get_current()->get_properties();
+       // Get the property value.
+       Properties& properties = VM::get_current()->get_properties();
        value = properties.get(key);
 
        if (value == NULL)
@@ -391,21 +360,12 @@ u4 suck_u4(classbuffer *cb)
 
 u8 suck_u8(classbuffer *cb)
 {
-#if U8_AVAILABLE == 1
        u8 a;
 
        a = SUCK_BE_U8(cb->pos);
        cb->pos += 8;
 
        return a;
-#else
-       u8 v;
-
-       v.high = suck_u4(cb);
-       v.low = suck_u4(cb);
-
-       return v;
-#endif
 }
 
 
@@ -524,10 +484,14 @@ classbuffer *suck_start(classinfo *c)
        utf_copy(filename, c->name);
        strcat(filename, ".class");
 
+       // Get current list of classpath entries.
+       SuckClasspath& suckclasspath = VM::get_current()->get_suckclasspath();
+
        /* walk through all classpath entries */
 
-       for (lce = (list_classpath_entry*) list_first(list_classpath_entries); lce != NULL && cb == NULL;
-                lce = (list_classpath_entry*) list_next(list_classpath_entries, lce)) {
+       for (SuckClasspath::iterator it = suckclasspath.begin(); it != suckclasspath.end() && cb == NULL; it++) {
+               lce = *it;
+
 #if defined(ENABLE_ZLIB)
                if (lce->type == CLASSPATH_ARCHIVE) {