waba-commits Mailing List for Waba Virtual Machine
Status: Abandoned
Brought to you by:
bornet
You can subscribe to this list here.
| 2001 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(34) |
Sep
(34) |
Oct
(86) |
Nov
(31) |
Dec
(71) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2002 |
Jan
(105) |
Feb
(23) |
Mar
(1) |
Apr
(6) |
May
(4) |
Jun
(1) |
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2003 |
Jan
(14) |
Feb
(1) |
Mar
(10) |
Apr
(60) |
May
(82) |
Jun
(22) |
Jul
(2) |
Aug
(39) |
Sep
|
Oct
(32) |
Nov
|
Dec
|
| 2004 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(117) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(13) |
|
From: Manfred R. <mr...@us...> - 2004-12-21 00:43:50
|
Update of /cvsroot/waba/waba/src/win32 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11096 Added Files: main.c Log Message: Moved main entry point method to main.c --- NEW FILE: main.c --- /* * $Id: main.c,v 1.1 2004/12/21 00:43:41 mriem Exp $ * * Copyright (c) 2004 Waba @ Sourceforge. All Rights Reserved */ #include "waba.h" // -------------------------------------------------------------------------- // // Shared code // // -------------------------------------------------------------------------- // -------------------------------------------------------------------------- // // Win32 Console mode // // -------------------------------------------------------------------------- #if defined(_CONSOLE) /* * Show the usage information. */ void usage() { printf( "Waba (TM) Virtual Machine Version 2.0\n" "Copyright (c) 2004, Waba @ Sourceforge.\n" "Copyright (c) 1998, Wabasoft.\n" "All rights reserved.\n" "\n" "Usage: waba [options] class\n" "\n" "See documentation for more information\n" ); } /* * Main method to the program. */ int main(int argc, char* argv[]) { usage(); } #endif // -------------------------------------------------------------------------- // // Win32 GUI mode // // -------------------------------------------------------------------------- #if defined(_WINDOWS) void usage() { MessageBox( NULL, TEXT( "Waba (TM) Virtual Machine Version 2.0\n" "Copyright (c) 2004, Waba @ Sourceforge.\n" "Copyright (c) 1998, Wabasoft.\n" "All rights reserved.\n" "\n" "Usage: waba [options] class\n" "\n" "See documentation for more information" ), TEXT( "Usage"), MB_ICONEXCLAMATION ); exit( 0 ); } #endif |
|
From: Manfred R. <mr...@us...> - 2004-12-20 23:44:28
|
Update of /cvsroot/waba/waba In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29165 Modified Files: build.xml Log Message: Cleanup on build file Index: build.xml =================================================================== RCS file: /cvsroot/waba/waba/build.xml,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** build.xml 10 Jul 2004 14:21:53 -0000 1.10 --- build.xml 20 Dec 2004 23:44:18 -0000 1.11 *************** *** 25,36 **** <property name="package.lib" value="lib"/> <property name="package.src" value="src"/> ! ! <property name="build.root" value="build"/> ! <property name="build.bin" value="${build.root}/bin"/> ! <property name="build.doc" value="${build.root}/doc"/> ! <property name="build.lib" value="${build.root}/lib"/> ! <property name="build.src" value="${build.root}/src"/> ! <property name="build.obj" value="${build.root}/obj"/> ! <property name="build.pkz" value="java.awt.*, java.io.*, java.lang.*, --- 25,29 ---- <property name="package.lib" value="lib"/> <property name="package.src" value="src"/> ! <property name="package.pkz" value="java.awt.*, java.io.*, java.lang.*, *************** *** 51,58 **** <target name="api" depends="prepare" description="Generates the API documentation"> ! <mkdir dir="${build.doc}/api"/> ! <javadoc packagenames="${build.pkz}" ! sourcepath="${build.src}/share/classes" ! destdir="${build.doc}/api" author="true" bottom="Copyright © ${dist.year} Waba @ Sourceforge"> --- 44,51 ---- <target name="api" depends="prepare" description="Generates the API documentation"> ! <mkdir dir="${package.doc}/api"/> ! <javadoc packagenames="${package.pkz}" ! sourcepath="${package.src}/share/classes" ! destdir="${package.doc}/api" author="true" bottom="Copyright © ${dist.year} Waba @ Sourceforge"> *************** *** 64,75 **** depends="init" description="* Cleans the build directories"> - <delete dir="${build.root}"/> </target> <target name="compile" depends="prepare" description="Compiles the source code"> ! <mkdir dir="${build.obj}/share/classes"/> ! <javac srcdir="${build.src}/share/classes" ! destdir="${build.obj}/share/classes" deprecation="on"> <classpath refid="classpath"/> --- 57,66 ---- depends="init" description="* Cleans the build directories"> </target> <target name="compile" depends="prepare" description="Compiles the source code"> ! <javac srcdir="${package.src}/share/classes" ! destdir="${package.src}/share/classes" deprecation="on"> <classpath refid="classpath"/> *************** *** 80,84 **** <target name="jar" depends="compile" description="Generates the jar package"> ! <jar jarfile="${build.lib}/java-lang.jar"> <manifest> <attribute name="Implementation-Title" value="java.lang"/> --- 71,75 ---- <target name="jar" depends="compile" description="Generates the jar package"> ! <jar jarfile="${package.lib}/java-lang.jar"> <manifest> <attribute name="Implementation-Title" value="java.lang"/> *************** *** 91,97 **** <attribute name="Specification-Website" value="http://java.sun.com/"/> </manifest> ! <fileset dir="${build.obj}/share/classes" includes="java/lang/**"/> </jar> ! <jar jarfile="${build.lib}/java-io.jar"> <manifest> <attribute name="Implementation-Title" value="java.io"/> --- 82,88 ---- <attribute name="Specification-Website" value="http://java.sun.com/"/> </manifest> ! <fileset dir="${package.src}/share/classes" includes="java/lang/**/*.class"/> </jar> ! <jar jarfile="${package.lib}/java-io.jar"> <manifest> <attribute name="Implementation-Title" value="java.io"/> *************** *** 104,110 **** <attribute name="Specification-Website" value="http://java.sun.com/"/> </manifest> ! <fileset dir="${build.obj}/share/classes" includes="java/io/**"/> </jar> ! <jar jarfile="${build.lib}/java-awt.jar"> <manifest> <attribute name="Implementation-Title" value="java.awt"/> --- 95,127 ---- <attribute name="Specification-Website" value="http://java.sun.com/"/> </manifest> ! <fileset dir="${package.src}/share/classes" includes="java/io/**/*.class"/> </jar> ! <jar jarfile="${package.lib}/java-awt-event.jar"> ! <manifest> ! <attribute name="Implementation-Title" value="java.awt.event"/> ! <attribute name="Implementation-Version" value="${dist.version}"/> ! <attribute name="Implementation-Vendor" value="Waba @ Sourceforge"/> ! <attribute name="Implementation-Website" value="http://waba.sourceforge.net/"/> ! <attribute name="Specification-Title" value="java.awt.event.* packages"/> ! <attribute name="Specification-Version" value="${dist.major}"/> ! <attribute name="Specification-Vendor" value="Sun Microsystems"/> ! <attribute name="Specification-Website" value="http://java.sun.com/"/> ! </manifest> ! <fileset dir="${package.src}/share/classes" includes="java/awt/event/**/*.class"/> ! </jar> ! <jar jarfile="${package.lib}/java-awt-image.jar"> ! <manifest> ! <attribute name="Implementation-Title" value="java.awt.image"/> ! <attribute name="Implementation-Version" value="${dist.version}"/> ! <attribute name="Implementation-Vendor" value="Waba @ Sourceforge"/> ! <attribute name="Implementation-Website" value="http://waba.sourceforge.net/"/> ! <attribute name="Specification-Title" value="java.awt.image.* packages"/> ! <attribute name="Specification-Version" value="${dist.major}"/> ! <attribute name="Specification-Vendor" value="Sun Microsystems"/> ! <attribute name="Specification-Website" value="http://java.sun.com/"/> ! </manifest> ! <fileset dir="${package.src}/share/classes" includes="java/awt/image/**/*.class"/> ! </jar> ! <jar jarfile="${package.lib}/java-awt.jar"> <manifest> <attribute name="Implementation-Title" value="java.awt"/> *************** *** 117,123 **** <attribute name="Specification-Website" value="http://java.sun.com/"/> </manifest> ! <fileset dir="${build.obj}/share/classes" includes="java/awt/**"/> </jar> ! <jar jarfile="${build.lib}/javax-accessiblity.jar"> <manifest> <attribute name="Implementation-Title" value="javax.accessiblity"/> --- 134,140 ---- <attribute name="Specification-Website" value="http://java.sun.com/"/> </manifest> ! <fileset dir="${package.src}/share/classes" includes="java/awt/**/*.class"/> </jar> ! <jar jarfile="${package.lib}/javax-accessiblity.jar"> <manifest> <attribute name="Implementation-Title" value="javax.accessiblity"/> *************** *** 130,134 **** <attribute name="Specification-Website" value="http://java.sun.com/"/> </manifest> ! <fileset dir="${build.obj}/share/classes" includes="javax/accessibility/**"/> </jar> </target> --- 147,151 ---- <attribute name="Specification-Website" value="http://java.sun.com/"/> </manifest> ! <fileset dir="${package.src}/share/classes" includes="javax/accessibility/**/*.class"/> </jar> </target> *************** *** 136,157 **** <target name="prepare" depends="init" description="Setting up required directories"> - <mkdir dir="${build.root}"/> - <mkdir dir="${build.bin}"/> - <mkdir dir="${build.doc}"/> - <mkdir dir="${build.lib}"/> - <mkdir dir="${build.src}"/> - <mkdir dir="${build.obj}"/> - <copy todir="${build.bin}"> - <fileset dir="${package.bin}"/> - </copy> - <copy todir="${build.doc}"> - <fileset dir="${package.doc}"/> - </copy> - <copy todir="${build.lib}"> - <fileset dir="${package.lib}"/> - </copy> - <copy todir="${build.src}"> - <fileset dir="${package.src}"/> - </copy> </target> --- 153,156 ---- *************** *** 169,173 **** <mkdir dir="${dist.root}/bin/${dist.name}-${dist.version}"/> <copy todir="${dist.root}/bin/${dist.name}-${dist.version}"> ! <fileset dir="${build.root}" excludes="**/IGNORE,**/.nbattrs"/> </copy> <delete dir="${dist.root}/bin/${dist.name}-${dist.version}/obj"/> --- 168,172 ---- <mkdir dir="${dist.root}/bin/${dist.name}-${dist.version}"/> <copy todir="${dist.root}/bin/${dist.name}-${dist.version}"> ! <fileset dir="${package.root}" excludes="**/IGNORE,**/.nbattrs"/> </copy> <delete dir="${dist.root}/bin/${dist.name}-${dist.version}/obj"/> |
|
From: Manfred R. <mr...@us...> - 2004-12-20 23:40:43
|
Update of /cvsroot/waba/waba/src/share/c In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28219/c Removed Files: config.h constants.h debug.h error.c error.h exception.h memory.c memory.h native.c native.h opcodes.h thread.h types.h waba.c waba.h Log Message: Removed GENERIC files, use one of the existing ports as template instead. --- config.h DELETED --- --- constants.h DELETED --- --- debug.h DELETED --- --- error.c DELETED --- --- error.h DELETED --- --- exception.h DELETED --- --- memory.c DELETED --- --- memory.h DELETED --- --- native.c DELETED --- --- native.h DELETED --- --- opcodes.h DELETED --- --- thread.h DELETED --- --- types.h DELETED --- --- waba.c DELETED --- --- waba.h DELETED --- |
|
From: Manfred R. <mr...@us...> - 2004-12-20 23:39:10
|
Update of /cvsroot/waba/waba/src/palm In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27774 Added Files: nmpalm_a.c nmpalm_a.h nmpalm_b.c nmpalm_b.h nmpalm_c.c nmpalm_c.h Log Message: Added to new location --- NEW FILE: nmpalm_a.c --- /* $Id: nmpalm_a.c,v 1.1 2004/12/20 23:38:57 mriem Exp $ Copyright (C) 1998, 1999, 2000 Wabasoft 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 of the License, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* all the needed include */ #include "../waba.h" #ifndef FASTANDBIG uint32 getUInt32(uchar *b) { return (uint32)( (uint32)((b)[0])<<24 | (uint32)((b)[1])<<16 | (uint32)((b)[2])<<8 | (uint32)((b)[3]) ); } uint16 getUInt16(uchar *b) { return (uint16)(((b)[0]<<8)|(b)[1]); } int32 getInt32(uchar *b) { return (int32)( (uint32)((b)[0])<<24 | (uint32)((b)[1])<<16 | (uint32)((b)[2])<<8 | (uint32)((b)[3]) ); } int16 getInt16(uchar *b) { return (int16)(((b)[0]<<8)|(b)[1]); } #endif #ifdef WITH_64BITS // get one 64 float value from buf and return it float64 getFloat64bits(uchar *buf) { float64HiLo fhl; fhl.ul.lo = getInt32( buf ); fhl.ul.hi = getInt32( buf + 4 ); return fhl.value; } // get one 64 float value from buf and return it int64 getInt64bits(uchar *buf) { int64HiLo ihl; ihl.ul.lo = getInt32( buf ); ihl.ul.hi = getInt32( buf + 4 ); return ihl.value; } #endif /* WITH_64BITS */ float32 getFloat32(uchar *buf) { uint32 i; float32 f; // we need to make sure we're aligned before casting i = ((uint32)buf[0] << 24) | ((uint32)buf[1] << 16) | ((uint32)buf[2] << 8) | (uint32)buf[3]; f = *((float32 *)&i); return f; } // // x portability functions // void* xmalloc(uint32 size) { VoidHand memH; uchar* ptr; // we stick the handle in the first bytes and then return a pointer // inside the memory block. Then when we free it, we can get the // memory handle back to unlock and free it without having to track it. memH = MemHandleNew(sizeof(VoidHand) + size); if(!memH) return NULL; ptr = MemHandleLock(memH); *((VoidHand*)ptr) = memH; ptr += sizeof(VoidHand); return ptr; } void xfree(void *p) { VoidHand memH; uchar* ptr; ptr = (uchar *)p - sizeof(VoidHand); memH = *((VoidHand *)ptr); MemHandleUnlock(memH); MemHandleFree(memH); } --- NEW FILE: nmpalm_a.h --- /* $Id: nmpalm_a.h,v 1.1 2004/12/20 23:38:57 mriem Exp $ */ #ifndef __NMPALM_A_H__ #define __NMPALM_A_H__ #define A_SECTION __attribute__ ((section ("a"))) /* Copyright (C) 1998, 1999, 2000 Wabasoft 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 of the License, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <PalmOS.h> #include <PalmCompatibility.h> #include <SysEvtMgr.h> #include <SerialMgr.h> #include <NetMgr.h> #include <FloatMgr.h> #include <DLServer.h> #define FREE_ON_EXIT 1 #define SECURE_CLASS_HEAP 1 #ifdef SECURE_CLASS_HEAP #define LOCK_CLASS_HEAP MemSemaphoreReserve(1); #define UNLOCK_CLASS_HEAP MemSemaphoreRelease(1); #else #define LOCK_CLASS_HEAP ; #define UNLOCK_CLASS_HEAP ; #endif #define uchar unsigned char #define int32 long #define uint32 unsigned long #define float32 float #define int16 short #define uint16 unsigned short #ifndef TRUE #define TRUE 1 #define FALSE 0 #endif #ifdef WITH_64BITS // - int64 is a signed 64 bit value #define int64 long long // - uint64 is an unsigned 64 bit value #define uint64 unsigned long long // - float64 is a signed 64 bit floating point value #define float64 double // --- define a struct for double and long support in two Var ... // ... the hi/lo decomposition typedef struct { uint32 lo; uint32 hi; } HiLoDoubleOrLong; //... for the double typedef union { float64 value; HiLoDoubleOrLong ul; } float64HiLo; //... for the long typedef union { int64 value; HiLoDoubleOrLong ul; } int64HiLo; #endif /* WITH_64BITS */ // // type converters // #undef FASTANDBIG #ifdef FASTANDBIG #define getUInt32(b) (uint32)( (uint32)((b)[0])<<24 | (uint32)((b)[1])<<16 | (uint32)((b)[2])<<8 | (uint32)((b)[3]) ) #define getUInt16(b) (uint16)(((b)[0]<<8)|(b)[1]) #define getInt32(b) (int32)( (uint32)((b)[0])<<24 | (uint32)((b)[1])<<16 | (uint32)((b)[2])<<8 | (uint32)((b)[3]) ) #define getInt16(b) (int16)(((b)[0]<<8)|(b)[1]) #else uint32 getUInt32(uchar *b) A_SECTION; uint16 getUInt16(uchar *b) A_SECTION; int32 getInt32(uchar *b) A_SECTION; int16 getInt16(uchar *b) A_SECTION; #endif #ifdef WITH_64BITS // get one 64 float value from buf and return it float64 getFloat64bits(uchar *buf); // get one 64 float value from buf and return it int64 getInt64bits(uchar *buf); #endif /* WITH_64BITS */ float32 getFloat32(uchar *buf) A_SECTION; // // x portability functions // #define xstrncmp(s1, s2, n) StrNCompare(s1, s2, n) #define xstrncpy(dst, src, n) StrNCopy(dst, src, (ULong)n) #define xstrlen(s) StrLen(s) #define xstrcat(dst, src) StrCat(dst, src) #define xmemmove(dst, src, size) MemMove(dst, src, size) #define xmemzero(mem, len) MemSet(mem, len, (Byte)0) void* xmalloc(uint32 size) A_SECTION; void xfree(void *p) A_SECTION; #endif /* __NMPALM_A_H__ */ /* Local Variables: c-file-style: "smartdata" End: */ --- NEW FILE: nmpalm_b.c --- /* $Id: nmpalm_b.c,v 1.1 2004/12/20 23:38:57 mriem Exp $ Copyright (C) 1998, 1999, 2000 Wabasoft 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 of the License, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* all the needed include */ #include "../waba.h" [...1401 lines suppressed...] threadProcessIndex = 0; }//End of if(threadListCurrentSize > 0) #endif }//End of if(vmStatus.errNum == 0) else handleErrorWinEvent(&event); //*** Isao's Multithread implementation END *** }//End of while(1) stopApp(mainWinObj); if(globalNetState == NET_IS_OPEN) NetLibClose(globalSocketLibRefNum, false); return 0; } --- NEW FILE: nmpalm_b.h --- /* $Id: nmpalm_b.h,v 1.1 2004/12/20 23:38:57 mriem Exp $ */ #ifndef __NMPALM_B_H__ #define __NMPALM_B_H__ #define B_SECTION __attribute__ ((section ("b"))) /* Copyright (C) 1998, 1999, 2000 Wabasoft 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 of the License, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <PalmOS.h> #include <Chars.h> // globals // PlamOS Version 2.0 or later is supported. // Note that you should use < or >= in these comparisons, // in nearly every case, because 3.0.1 should be treated the same way as 3.0. // If you say "if vers <= 3.0" you'd often do the wrong thing. #define wabaMinVersion sysMakeROMVersion(2,0,0,sysROMStageRelease,0) #define palmOS_Version3p0 sysMakeROMVersion(3,0,0,sysROMStageRelease,0) #define palmOS_Version3p1 sysMakeROMVersion(3,1,0,sysROMStageRelease,0) #define palmOS_Version3p3 sysMakeROMVersion(3,3,0,sysROMStageRelease,0) #define palmOS_Version3p5 sysMakeROMVersion(3,5,0,sysROMStageRelease,0) #define NET_NOT_READY_FOR_OPEN 0 #define NET_READY_FOR_OPEN 1 #define NET_IS_OPEN 2 #define NET_OPEN_FAILED 3 extern WObject globalMainWin; extern int32 globalTimerInterval; extern int32 globalTimerStart; extern int classDbCount; extern DmOpenRef* classDbList; extern ULong appCreatorId; extern Word globalSocketLibRefNum; extern int globalNetState; extern DWord palmOS_ROM_Version; #ifdef QUICKBIND extern int32 postEventMethodMapNum; extern int32 onTimerTickMethodMapNum; #endif /*** Isao F. Yamashita 1218/2000 ***/ extern UInt32 globalScreenDepth; #ifdef WITH_THREAD //*** Isao's Multithread implementation START *** // Thread variables - Isao F. Yamashita 07/25/2000 #define THREAD_LIST_MAX_SIZE 8 typedef struct { WClass* tClass; WObject tObject; WObject syncObject; WClassMethod* syncMethod; int32 runMethodMapNum; int32 syncMethodMapNum; uint32 sleepCountSet; uint32 sleepCountNow; uchar isSleepCountAlreadySet; uchar isWaiting; } WThread; extern WThread wThreadList[THREAD_LIST_MAX_SIZE]; extern uint32 threadListCurrentSize; extern uint32 threadProcessIndex; extern uint32 threadSynchMethodIndex; int InitThread(uint32 stacksize) B_SECTION; //*** This "_onThreadStart()" method is called from "start()" method. Var ThreadStart(Var stack[]) B_SECTION; //*** This "_onThreadStop()" method is called from "stop()" method. Var ThreadStop(Var stack[]) B_SECTION; //*** This "_onThreadSleep()" method is called from "sleep()" method. Var ThreadSleep(Var stack[]) B_SECTION; //*** This "_onThreadWait()" method is called from "wait()" method. Var ThreadWaitForSignal(Var stack[]) B_SECTION; Var ThreadSignalAll(Var stack[]) B_SECTION; //*** Isao's Multithread implementation END *** //*** This "ThreadCurrentThread()" method is called from "curentThread()" method. Var ThreadCurrentThread(Var stack[]) B_SECTION; #define THERE_IS_SOME_THREADS (threadListCurrentSize > 0) void tickThread(void); int registerAsSyncronized(WClassMethod* method); void exitFromSyncronized(WClassMethod* method); int enterMonitor(WObject obj); int exitMonitor(WObject obj); #endif /* WITH_THREAD */ Long millisToTicks(int32 millis) B_SECTION; int32 getTimeStamp() B_SECTION; void postStopEvent() B_SECTION; void drawErrorWin() B_SECTION; void drawMainWin() B_SECTION; void timerCheck() B_SECTION; void handleErrorWinEvent(EventPtr eventP) B_SECTION; void handleMainWinEvent(EventPtr eventP) B_SECTION; Long calcEventTimeout() B_SECTION; int isostrncmp(uchar *s1, uchar *s2, uint16 n) B_SECTION; uchar* lockWarpRec(char* path, uint16 pathLen, uint32* size) B_SECTION; void unlockWarpRec(uchar *ptr, uint16 pathLen) B_SECTION; uchar* nativeLoadClass(UtfString className, uint32* size) B_SECTION; #ifdef SECURE_CLASS_HEAP extern DmOpenRef classHeapDmRef; extern VoidHand classHeapRecH; extern VoidPtr classHeapRecP; void delClassHeapDb(); #endif /* SECURE_CLASS_HEAP */ WObject startApp(int runApp); void stopApp(WObject mainWinObj); DWord PilotMain(Word cmd, Ptr cmdPBP, Word launchFlags); #endif /* __NMPALM_B_H__ */ /* Local Variables: c-file-style: "smartdata" End: */ --- NEW FILE: nmpalm_c.c --- /* $Id: nmpalm_c.c,v 1.1 2004/12/20 23:38:57 mriem Exp $ Copyright (C) 1998, 1999, 2000 Wabasoft 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 of the License, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ // NOTE: General rule for native functions.. don't hold a pointer across any // call that could garbage collect. For example, this isn't good: [...3873 lines suppressed...] Var PalmOsPrefSetPalmOsPref(Var stack[]) { Var v; WObject prefArray; UInt32 screenDepth; uchar* prefDataPtr; v.intValue = 0; prefArray = stack[1].obj; prefDataPtr = (uchar*)WOBJ_arrayStart(prefArray); screenDepth = (UInt32)prefDataPtr[0]; PrefSetAppPreferences('WABA', 0, 2, &screenDepth, sizeof(UInt32), false); return v; } --- NEW FILE: nmpalm_c.h --- /* $Id: nmpalm_c.h,v 1.1 2004/12/20 23:38:57 mriem Exp $ */ #ifndef __NMPALM_C_H__ #define __NMPALM_C_H__ #define C_SECTION __attribute__ ((section ("c"))) /* Copyright (C) 1998, 1999, 2000 Wabasoft 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 of the License, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ // NOTE: General rule for native functions.. don't hold a pointer across any // call that could garbage collect. For example, this isn't good: // // ptr = WOBJ_arrayStart(array) // ... // string = createString(..) // ptr[0] // // since the createString() could GC, the ptr inside of array could be invalid // after the call since a GC would move memory around. Instead, use: // // ptr = WOBJ_arrayStart(array) // ... // string = createString(..) // ... // ptr = WOBJ_arrayStart(array) // ptr[0] // // to recompute the pointer after the possible GC // NOTE: If you subclass a class with an object destroy function, you must // explicity call your superclasses object destroy function. #include <SerialMgrOld.h> #include <FileStream.h> #include <Bitmap.h> void GraphicsDestroy(WObject obj) C_SECTION; void ImageDestroy(WObject obj) C_SECTION; void CatalogDestroy(WObject obj) C_SECTION; void SocketDestroy(WObject obj) C_SECTION; void SerialPortDestroy(WObject obj) C_SECTION; Var ImageCreate(Var stack[]) C_SECTION; extern ClassHook classHooks[]; #define FUNC(f) extern Var f (Var stack[]) C_SECTION /* some generic functions */ FUNC(Return0Func); FUNC(ReturnNeg1Func); /* all the native functions */ /* FUNC(VmPrintLn); FUNC(VmPrint); */ #define VmPrint Return0Func #define VmPrintLn Return0Func FUNC(VmExec); FUNC(VmGetTimeStamp); FUNC(copyArray); FUNC(VmExit); FUNC(VmSleep); FUNC(VmSetDeviceAutoOff); FUNC(VmGetUserName); FUNC(VmGetPlatform); FUNC(VmIsColor); /* FUNC(FileGetLength); FUNC(FileCreateDir); FUNC(FileReadBytes); FUNC(FileRename); FUNC(FileCreate); FUNC(FileWriteBytes); FUNC(FileListDir); FUNC(FileSeekWaba); FUNC(FileIsDir); FUNC(FileCloseWaba); FUNC(FileIsOpen); FUNC(FileDeleteWaba); FUNC(FileExists); */ #define FileGetLength Return0Func #define FileCreateDir Return0Func #define FileReadBytes ReturnNeg1Func #define FileCreate Return0Func #define FileWriteBytes ReturnNeg1Func #define FileListDir Return0Func #define FileIsDir Return0Func #define FileCloseWaba Return0Func #define FileDeleteWaba Return0Func #define FileExists Return0Func #define FileIsOpen Return0Func #define FileSeekWaba Return0Func #define FileRename Return0Func FUNC(ImageCreate); FUNC(ImageFree); FUNC(ImageSetPixels); FUNC(ImageUseImagePalette); FUNC(ImageLoad); FUNC(SoundBeep); FUNC(SoundTone); FUNC(TimeCreate); FUNC(SocketCreate); FUNC(SocketRead); FUNC(SocketWrite); FUNC(SocketSetReadTimeout); FUNC(SocketClose); FUNC(SocketIsOpen); FUNC(WindowCreate); #if WITH_CATALOG FUNC(CatalogListCatalogs); FUNC(CatalogAddRecord); FUNC(CatalogSkipBytes); FUNC(CatalogCreate); FUNC(CatalogRead); FUNC(CatalogDeleteRecord); FUNC(CatalogSetRecordPos); FUNC(CatalogGetRecordSize); FUNC(CatalogResizeRecord); FUNC(CatalogWrite); FUNC(CatalogGetRecordCount); FUNC(CatalogClose); FUNC(CatalogIsOpen); FUNC(CatalogDelete); #endif FUNC(GraphicsCopyRect); FUNC(GraphicsClearClip); FUNC(GraphicsSetFont); FUNC(GraphicsSetDrawOp); FUNC(GraphicsSetClip); FUNC(GraphicsSetBackColor); FUNC(GraphicsSetColor); FUNC(GraphicsGetClip); FUNC(GraphicsFillRect); FUNC(GraphicsDrawLine); FUNC(GraphicsTranslate); FUNC(GraphicsDrawDots); FUNC(GraphicsDrawChars); FUNC(GraphicsCreate); FUNC(GraphicsDrawCursor); FUNC(GraphicsSetClip); /* FUNC(GraphicsFree); */ #define GraphicsFree Return0Func FUNC(GraphicsSetForeColor); FUNC(GraphicsSetTextColor); FUNC(GraphicsFillPolygon); FUNC(GraphicsDrawString); FUNC(ConvertStringToInt); FUNC(ConvertFloatToIntBitwise); FUNC(ConvertCharToString); FUNC(ConvertIntToFloatBitwise); FUNC(ConvertFloatToString); FUNC(ConvertDoubleToString); FUNC(ConvertIntToString); FUNC(ConvertLongToString); FUNC(ConvertBooleanToString); /* FUNC(SoundClipPlay); */ #define SoundClipPlay Return0Func #define VmPrint Return0Func FUNC(PalmOsPrefSetPalmOsPref); FUNC(PalmOsPrefGetPalmOsPref); FUNC(MainWinCreate); FUNC(MainWinExit); FUNC(MainWinSetTimerInterval); FUNC(SerialPortReadCheck); FUNC(SerialPortRead); FUNC(SerialPortWrite); FUNC(SerialPortSetReadTimeout); FUNC(SerialPortClose); FUNC(SerialPortSetFlowControl); FUNC(SerialPortIsOpen); FUNC(SerialPortCreate); FUNC(FontMetricsGetStringWidth); FUNC(FontMetricsGetCharWidth); FUNC(FontMetricsCreate); FUNC(FontMetricsGetCharArrayWidth); #endif /* __NMPALM_C_H__ */ /* Local Variables: c-file-style: "smartdata" End: */ |
|
From: Manfred R. <mr...@us...> - 2004-12-20 23:38:27
|
Update of /cvsroot/waba/waba/src/palm/c In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27534/c Removed Files: nmpalm_a.c nmpalm_a.h nmpalm_b.c nmpalm_b.h nmpalm_c.c nmpalm_c.h Log Message: Removed old location --- nmpalm_a.c DELETED --- --- nmpalm_a.h DELETED --- --- nmpalm_b.c DELETED --- --- nmpalm_b.h DELETED --- --- nmpalm_c.c DELETED --- --- nmpalm_c.h DELETED --- |
|
From: Manfred R. <mr...@us...> - 2004-12-20 23:37:41
|
Update of /cvsroot/waba/waba/src/linux In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27256 Added Files: debug.c debug.h gdk-pixbuf-xlibrgb.c gdk-pixbuf-xlibrgb.h jar.c jar.h jar2host.h nm_linux_a.c nm_linux_a.h nm_linux_b.c nm_linux_b.h nm_linux_c.c nm_linux_c.h ui_gtk.c ui_gtk.h ui_none.c ui_none.h ui_pgui.c ui_pgui.h ui_x.c ui_x.h Log Message: Added to correct location --- NEW FILE: debug.c --- /* $Id: debug.c,v 1.1 2004/12/20 23:37:32 mriem Exp $ */ #include "../waba.h" #ifdef DEBUG char* UTF2CSTR(UtfString *utf) { typedef char buf[255]; static buf utf_buf[16]; static int ix = 0; char *b; ix++; ix&=15; b = &utf_buf[ix][0]; xstrncpy(b, utf->str, utf->len); b[utf->len]=0; return b; } #else /* !DEBUG */ /* * static void _dummy_(char* d, ...) {} */ #endif --- NEW FILE: debug.h --- /* $Id: debug.h,v 1.1 2004/12/20 23:37:32 mriem Exp $ */ #ifndef __WABA_DEBUG_H #define __WABA_DEBUG_H #ifdef DEBUG #define DPUTS puts #define DPRINTF printf char* UTF2CSTR(UtfString *utf); #else /* !DEBUG */ static void _dummy_(char* d, ...){}; # define DPUTS _dummy_ # define DPRINTF _dummy_ # define UTF2CSTR(utf) "" #endif #endif /* WABA_DEBUG_H */ --- NEW FILE: gdk-pixbuf-xlibrgb.c --- /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- * * The contents of this file are subject to the Mozilla Public License * Version 1.1 (the "MPL"); you may not use this file except in * compliance with the MPL. You may obtain a copy of the MPL at * http://www.mozilla.org/MPL/ * * Software distributed under the MPL is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the MPL * for the specific language governing rights and limitations under the * MPL. * * Alternatively, the contents of this file may be used under the * terms of the GNU Library General Public License (the "LGPL"), in * which case the provisions of 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 the LGPL and not to allow others to use * your version of this file under the MPL, indicate your decision by * deleting the provisions above and replace them with the notice and [...3691 lines suppressed...] return image_info->display; return NULL; } /** * xlib_rgb_get_screen: * * Queries the screen that XlibRGB is using. * * Return value: An X screen. **/ Screen * xlib_rgb_get_screen (void) { if (image_info) return image_info->screen; return NULL; } --- NEW FILE: gdk-pixbuf-xlibrgb.h --- /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- * * The contents of this file are subject to the Mozilla Public License * Version 1.1 (the "MPL"); you may not use this file except in * compliance with the MPL. You may obtain a copy of the MPL at * http://www.mozilla.org/MPL/ * * Software distributed under the MPL is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the MPL * for the specific language governing rights and limitations under the * MPL. * * Alternatively, the contents of this file may be used under the * terms of the GNU Library General Public License (the "LGPL"), in * which case the provisions of 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 the LGPL and not to allow others to use * your version of this file under the MPL, indicate your decision by * deleting the provisions above and replace them with the notice and * other provisions required by the LGPL. If you do not delete the * provisions above, a recipient may use your version of this file * under either the MPL or the LGPL. */ /* * This code is derived from GdkRgb. * For more information on GdkRgb, see http://www.levien.com/gdkrgb/ * Raph Levien <ra...@ac...> */ /* Ported by Christopher Blizzard to Xlib. With permission from the * original authors of this file, the contents of this file are also * redistributable under the terms of the Mozilla Public license. For * information about the Mozilla Public License, please see the * license information at http://www.mozilla.org/MPL/ */ /* This code is copyright the following authors: * Raph Levien <ra...@ac...> * Manish Singh <ma...@gt...> * Tim Janik <ti...@gt...> * Peter Mattis <pe...@xc...> * Spencer Kimball <sp...@xc...> * Josh MacDonald <jm...@xc...> * Christopher Blizzard <bli...@re...> * Owen Taylor <ot...@re...> * Shawn T. Amundson <amu...@gt...> */ #ifndef __XLIB_RGB_H__ #define __XLIB_RGB_H__ #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ #include <X11/Xlib.h> #include <X11/Xutil.h> #include <X11/Xos.h> #include <X11/Intrinsic.h> #include <glib.h> typedef struct _XlibRgbCmap XlibRgbCmap; struct _XlibRgbCmap { unsigned int colors[256]; unsigned char lut[256]; /* for 8-bit modes */ }; void xlib_rgb_init (Display *display, Screen *screen); void xlib_rgb_init_with_depth (Display *display, Screen *screen, int prefDepth); unsigned long xlib_rgb_xpixel_from_rgb (guint32 rgb); void xlib_rgb_gc_set_foreground (GC gc, guint32 rgb); void xlib_rgb_gc_set_background (GC gc, guint32 rgb); typedef enum { XLIB_RGB_DITHER_NONE, XLIB_RGB_DITHER_NORMAL, XLIB_RGB_DITHER_MAX } XlibRgbDither; void xlib_draw_rgb_image (Drawable drawable, GC gc, int x, int y, int width, int height, XlibRgbDither dith, unsigned char *rgb_buf, int rowstride); void xlib_draw_rgb_image_dithalign (Drawable drawable, GC gc, int x, int y, int width, int height, XlibRgbDither dith, unsigned char *rgb_buf, int rowstride, int xdith, int ydith); void xlib_draw_rgb_32_image (Drawable drawable, GC gc, int x, int y, int width, int height, XlibRgbDither dith, unsigned char *buf, int rowstride); void xlib_draw_gray_image (Drawable drawable, GC gc, int x, int y, int width, int height, XlibRgbDither dith, unsigned char *buf, int rowstride); XlibRgbCmap * xlib_rgb_cmap_new (guint32 *colors, int n_colors); void xlib_rgb_cmap_free (XlibRgbCmap *cmap); void xlib_draw_indexed_image (Drawable drawable, GC gc, int x, int y, int width, int height, XlibRgbDither dith, unsigned char *buf, int rowstride, XlibRgbCmap *cmap); /* Below are some functions which are primarily useful for debugging and experimentation. */ Bool xlib_rgb_ditherable (void); void xlib_rgb_set_verbose (Bool verbose); /* experimental colormap stuff */ void xlib_rgb_set_install (Bool install); void xlib_rgb_set_min_colors (int min_colors); Colormap xlib_rgb_get_cmap (void); Visual * xlib_rgb_get_visual (void); XVisualInfo * xlib_rgb_get_visual_info (void); int xlib_rgb_get_depth (void); Display * xlib_rgb_get_display (void); Screen * xlib_rgb_get_screen (void); #ifdef __cplusplus } #endif /* __cplusplus */ #endif /* __XLIB_RGB_H__ */ --- NEW FILE: jar.c --- /* $Id: jar.c,v 1.1 2004/12/20 23:37:32 mriem Exp $ Copyright (C) 2000, 2001 Chirag Kantharia 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 of the License, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include <stdio.h> #include <stdlib.h> #include <string.h> #include <zlib.h> #include "jar.h" #include "jar2host.h" /* provide swap or not depending of the endianess of the host */ #define err_exit(msg) { perror(msg); exit(-1); } unsigned char * getClassFrmOffset(FILE *, struct CentralDirRecord *, int *); unsigned char * loadClassFrmJar(char * jar, char * classname, int * size) { FILE * fp; unsigned char * class; char * classfilename; int classfilename_len; volatile int ret, i, len; #ifdef _DEBUG unsigned int tmp4; #endif struct EndCentralDirRecord endrec; class = NULL; len = strlen(classname); if(!(classfilename = malloc(len + 7))) err_exit("malloc"); strncpy(classfilename, classname, len); strncpy(classfilename + len, ".class", 6); classfilename[len + 6] = '\0'; classfilename_len = len + 6; if (!(fp = fopen(jar, "r"))) err_exit("fopen"); ret = fseek(fp, -22, SEEK_END); if (ret != 0) err_exit("fseek"); #ifdef _DEBUG ret = fread(&tmp4, sizeof(unsigned int), 1, fp); if (ret != 1) err_exit("fread"); tmp4 = jar2host_l( tmp4 ); if (tmp4 != END_OF_CENTRAL_DIR_SIGNATURE) err_exit("end of central dir signature"); fseek(fp, -sizeof(unsigned int), SEEK_CUR); #endif ret = fread(&endrec, sizeof(struct EndCentralDirRecord), 1, fp); if (ret != 1) err_exit("fread"); /* convert from jar to host the readed informations */ endrec.sig = jar2host_l( endrec.sig ); endrec.this_disk_num = jar2host_s( endrec.this_disk_num ); endrec.start_disk_num_with_cdr = jar2host_s( endrec.start_disk_num_with_cdr ); endrec.this_disk_nentries = jar2host_s( endrec.this_disk_nentries ); endrec.nentries = jar2host_s( endrec.nentries ); endrec.cd_size = jar2host_l( endrec.cd_size ); endrec.cd_offset = jar2host_l( endrec.cd_offset ); endrec.zip_file_comment_len = jar2host_s( endrec.zip_file_comment_len ); #ifdef _DEBUG printf("sig = %p\n", (int *)endrec.sig); printf("nentries = %d\n", endrec.nentries); printf("cd_size = %d\n", endrec.cd_size); printf("cd_offset = %d\n", endrec.cd_offset); printf("zip_file_comment_len = %d\n", endrec.zip_file_comment_len); if (endrec.zip_file_comment_len > 0) { char * comment; if (!(comment = malloc(endrec.zip_file_comment_len + 1))) err_exit("malloc"); ret = fread(comment, 1, endrec.zip_file_comment_len, fp); if (ret != endrec.zip_file_comment_len) err_exit("fread"); comment[endrec.zip_file_comment_len] = '\0'; printf("zip_file_comment = %s\n", comment); free(comment); } #else if (endrec.zip_file_comment_len > 0) fseek(fp, endrec.zip_file_comment_len, SEEK_CUR); #endif ret = fseek(fp, endrec.cd_offset, SEEK_SET); if (ret != 0) err_exit("fseek"); for(i = 0; i < endrec.nentries; i++) { struct CentralDirRecord cdr; char * filename; char * extra_field; char * file_comment; ret = fread(&cdr, sizeof(struct CentralDirRecord), 1, fp); if (ret != 1) err_exit("fread"); /* convert from jar to host the readed informations */ cdr.sig = jar2host_l( cdr.sig ); cdr.version_created = jar2host_s( cdr.version_created ); cdr.version_req = jar2host_s( cdr.version_req ); cdr.flag = jar2host_s( cdr.flag ); cdr.compression_method = jar2host_s( cdr.compression_method ); cdr.mtime = jar2host_s( cdr.mtime ); cdr.mdate = jar2host_s( cdr.mdate ); cdr.crc = jar2host_l( cdr.crc ); cdr.csize = jar2host_l( cdr.csize ); cdr.ucsize = jar2host_l( cdr.ucsize ); cdr.fnlen = jar2host_s( cdr.fnlen ); cdr.eflen = jar2host_s( cdr.eflen ); cdr.fcommentlen = jar2host_s( cdr.fcommentlen ); cdr.disknum = jar2host_s( cdr.disknum ); cdr.ifattr = jar2host_s( cdr.ifattr ); cdr.efattr = jar2host_l( cdr.efattr ); cdr.lhoff = jar2host_l( cdr.lhoff ); if (cdr.fnlen > 0) { if (!(filename = malloc(cdr.fnlen + 1))) err_exit("malloc"); ret = fread(filename, 1, cdr.fnlen, fp); if (ret != cdr.fnlen) err_exit("fread"); filename[cdr.fnlen] = '\0'; } #ifdef _DEBUG if (cdr.eflen > 0) { if (!(extra_field = malloc(cdr.eflen + 1))) err_exit("malloc"); ret = fread(extra_field, 1, cdr.eflen, fp); if (ret != cdr.eflen) err_exit("fread"); extra_field[cdr.eflen] = '\0'; printf("extra_field = %s\n", extra_field); free(extra_field); } #else if (cdr.eflen > 0) fseek(fp, cdr.eflen, SEEK_CUR); #endif #ifdef _DEBUG if (cdr.fcommentlen > 0) { if (!(file_comment = malloc(cdr.fcommentlen + 1))) err_exit("malloc"); ret = fread(file_comment, 1, cdr.fcommentlen, fp); if (ret != cdr.fcommentlen) err_exit("fread"); file_comment[cdr.fcommentlen] = '\0'; printf("file_comment: %s\n", file_comment); free(file_comment); } #else if (cdr.fcommentlen > 0) fseek(fp, cdr.fcommentlen, SEEK_CUR); #endif if (strncmp(classfilename, filename, classfilename_len) == 0) { int real_size; class = getClassFrmOffset(fp, &cdr, &real_size); *size = real_size; break; } } fclose(fp); free(classfilename); return class; } unsigned char * getClassFrmOffset(FILE * jarfile, struct CentralDirRecord * cdr, int * rsize) { struct LocalFileHeader lfh; Bytef * next_in, * next_out; z_stream z; int ret; int _csize, _ucsize; ret = fseek(jarfile, cdr->lhoff, SEEK_SET); if (ret != 0) err_exit("fseek"); ret = fread(&lfh, sizeof(struct LocalFileHeader), 1, jarfile); if (ret != 1) err_exit("fread"); /* convert from jar to host the readed informations */ lfh.sig = jar2host_l( lfh.sig ); lfh.version_req = jar2host_s( lfh.version_req ); lfh.flag = jar2host_s( lfh.flag ); lfh.compression_method = jar2host_s( lfh.compression_method ); lfh.mtime = jar2host_s( lfh.mtime ); lfh.mdate = jar2host_s( lfh.mdate ); lfh.crc = jar2host_l( lfh.crc ); lfh.csize = jar2host_l( lfh.csize ); lfh.ucsize = jar2host_l( lfh.ucsize ); lfh.fnlen = jar2host_s( lfh.fnlen ); lfh.eflen = jar2host_s( lfh.eflen ); #ifdef _DEBUG // printf("offset = %d\n", offset); #endif #ifdef _DEBUG printf("compression_method = %d\n", lfh.compression_method); #endif #ifdef _DEBUG { char * filename; if (!(filename = malloc(lfh.fnlen + 1))) err_exit("malloc"); ret = fread(filename, lfh.fnlen, 1, jarfile); if (ret != 1) err_exit("fread"); filename[lfh.fnlen] = '\0'; printf("filename = %s\n", filename); free(filename); } #else fseek(jarfile, lfh.fnlen, SEEK_CUR); #endif _csize = (lfh.csize == 0) ? cdr->csize : lfh.csize; _ucsize = (lfh.ucsize == 0) ? cdr->ucsize : lfh.ucsize; if (!(next_in = malloc(_csize))) err_exit("malloc"); ret = fread(next_in, 1, _csize, jarfile); if (ret != _csize) err_exit("fread"); #ifdef _DEBUG printf("compressed data size = %x\n", _csize); printf("uncompressed data size = %x\n", _ucsize); #endif if (lfh.flag & HAS_DATA_DESCRIPTOR) { struct DataDescriptorRecord ddr; ret = fread(&ddr, sizeof(struct DataDescriptorRecord), 1, jarfile); if (ret != 1) err_exit("fread"); /* convert from jar to host the readed informations */ ddr.sig = jar2host_l( ddr.sig ); ddr.crc = jar2host_l( ddr.crc ); ddr.csize = jar2host_l( ddr.csize ); ddr.ucsize = jar2host_l( ddr.ucsize ); #ifdef _DEBUG if (ddr.sig != EXTENDED_LOCAL_FILE_HEADER_SIGNATURE) err_exit("data descriptor signature!"); #endif _csize = ddr.csize; _ucsize = ddr.ucsize; } *rsize = _ucsize; switch(lfh.compression_method) { case 0: next_out = next_in; break; case 8: if (!(next_out = malloc(_ucsize))) err_exit("malloc"); z.next_in = next_in; z.avail_in = _csize; z.next_out = next_out; z.avail_out = _ucsize; z.zalloc = (alloc_func)Z_NULL; z.zfree = (free_func)Z_NULL; z.opaque = Z_NULL; ret = inflateInit2(&z, -MAX_WBITS); if (ret != Z_OK) err_exit("inflateInit2"); while (z.total_in < _csize) { ret = inflate(&z, Z_SYNC_FLUSH); if (ret == Z_STREAM_END) break; if (z.msg) err_exit(z.msg); } ret = inflateEnd(&z); if (ret != Z_OK) err_exit("inflateEnd"); break; } return (unsigned char *)next_out; } --- NEW FILE: jar.h --- /* $Id: jar.h,v 1.1 2004/12/20 23:37:32 mriem Exp $ Copyright (C) 2000, 2001 Chirag Kantharia 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 of the License, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __JAR_H_ #define __JAR_H_ #define LOCAL_FILE_HEADER_SIGNATURE 0x04034b50 #define EXTENDED_LOCAL_FILE_HEADER_SIGNATURE 0x08074b50 #define CENTRAL_FILE_HEADER_SIGNATURE 0x02014b50 #define END_OF_CENTRAL_DIR_SIGNATURE 0x06054b50 #define HAS_DATA_DESCRIPTOR 0x8 struct LocalFileHeader { int sig; /* 0x04034b50 */ short version_req; short flag; short compression_method; short mtime; short mdate; int crc; unsigned int csize; unsigned int ucsize; unsigned short fnlen; unsigned short eflen; } __attribute__ ((packed)); struct CentralDirRecord { int sig; /* 0x02014b50 */ short version_created; short version_req; short flag; short compression_method; short mtime; short mdate; int crc; unsigned int csize; unsigned int ucsize; unsigned short fnlen; unsigned short eflen; unsigned short fcommentlen; unsigned short disknum; short ifattr; int efattr; unsigned int lhoff; } __attribute__ ((packed)); struct EndCentralDirRecord { int sig; /* 0x06054b50 */ unsigned short this_disk_num; unsigned short start_disk_num_with_cdr; unsigned short this_disk_nentries; unsigned short nentries; unsigned int cd_size; unsigned int cd_offset; unsigned short zip_file_comment_len; } __attribute__ ((packed)); struct DataDescriptorRecord { int sig; /* 0x08074b50 */ int crc; int csize; int ucsize; } __attribute__ ((packed)); extern unsigned char * loadClassFrmJar(char * jar, char * classname, int * size); #endif /* #ifndef __JAR_H_ */ --- NEW FILE: jar2host.h --- /* $Id: jar2host.h,v 1.1 2004/12/20 23:37:32 mriem Exp $ * * jar2host.h - definition of jar2host functions * * Copyright (C) 2001 SMARTDATA * * 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 * of the License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * Contributors: * * * */ #ifndef __JAR2HOST_H__ #define __JAR2HOST_H__ #ifdef WORDS_BIGENDIAN /* as the jar files are little endian by default, we must swap */ # define jar2host_l(x) ((__u32)( \ (((__u32)(x) & (__u32)0x000000ffUL) << 24) | \ (((__u32)(x) & (__u32)0x0000ff00UL) << 8) | \ (((__u32)(x) & (__u32)0x00ff0000UL) >> 8) | \ (((__u32)(x) & (__u32)0xff000000UL) >> 24) )) # define jar2host_s(x) ((__u16)( \ (((__u16)(x) & (__u16)0x00ffU) << 8) | \ (((__u16)(x) & (__u16)0xff00U) >> 8) )) #else /* no swap, because we are little endian, same as the jar files */ # define jar2host_l(x) ((unsigned int)(x)) # define jar2host_s(x) ((unsigned short)(x)) #endif /* WORDS_BIGENDIAN */ #endif /* Local Variables: c-file-style: "smartdata" End: */ --- NEW FILE: nm_linux_a.c --- /* $Id: nm_linux_a.c,v 1.1 2004/12/20 23:37:32 mriem Exp $ Copyright (C) 1998, 1999, 2000 Wabasoft 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 of the License, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* Copyright (C) 2000, 2001 SMARTDATA, http://www.smartdata.ch/ More help for porting is include in the file nmport_a.c. Please read it before porting or modify this port. Linux port. =========== */ typedef unsigned long uint32; /* all the needed include */ #include "../waba.h" #ifndef LINUX # error You must define the LINUX symbol as gcc parameter (-DLINUX=1) #endif #ifndef FASTANDBIG uint32 getUInt32(uchar *b) { return (uint32)( (uint32)((b)[0])<<24 | (uint32)((b)[1])<<16 | (uint32)((b)[2])<<8 | (uint32)((b)[3]) ); } uint16 getUInt16(uchar *b) { return (uint16)(((b)[0]<<8)|(b)[1]); } int32 getInt32(uchar *b) { return (int32)( (uint32)((b)[0])<<24 | (uint32)((b)[1])<<16 | (uint32)((b)[2])<<8 | (uint32)((b)[3]) ); } int16 getInt16(uchar *b) { return (int16)(((b)[0]<<8)|(b)[1]); } #endif /* ifndef FASTANDBIG */ #ifdef WITH_64BITS // get one 64 float value from buf and return it float64 getFloat64bits(uchar *buf) { float64HiLo fhl; fhl.ul.lo = getInt32( buf ); fhl.ul.hi = getInt32( buf + 4 ); return fhl.value; } // get one 64 float value from buf and return it int64 getInt64bits(uchar *buf) { int64HiLo ihl; ihl.ul.lo = getInt32( buf ); ihl.ul.hi = getInt32( buf + 4 ); return ihl.value; } #endif /* WITH_64BITS */ float32 getFloat32(uchar *buf) { uint32 i; float32 f; // we need to make sure we're aligned before casting i = ((uint32)buf[0] << 24) | ((uint32)buf[1] << 16) | ((uint32)buf[2] << 8 ) | (uint32)buf[3]; f = *((float32 *)&i); return f; } /* Local Variables: c-file-style: "smartdata" End: */ --- NEW FILE: nm_linux_a.h --- /* $Id: nm_linux_a.h,v 1.1 2004/12/20 23:37:32 mriem Exp $ */ #ifndef __NM_LINUX_A_H__ #define __NM_LINUX_A_H__ /* Copyright (C) 1998, 1999, 2000 Wabasoft 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 of the License, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* Copyright (C) 2000, 2001 SMARTDATA, http://www.smartdata.ch/ More help for porting is include in the file nmport_a.c. Please read it before porting or modify this port. Linux port. =========== */ /* all the needed include */ #include <stdlib.h> #include <string.h> #ifndef LINUX # error You must define the LINUX symbol as gcc parameter (-DLINUX=1) #endif #define FREE_ON_EXIT 1 #undef SECURE_CLASS_HEAP //#define SECURE_CLASS_HEAP 1 #ifdef SECURE_CLASS_HEAP # define LOCK_CLASS_HEAP MemSemaphoreReserve(1); # define UNLOCK_CLASS_HEAP MemSemaphoreRelease(1); #else # define LOCK_CLASS_HEAP ; # define UNLOCK_CLASS_HEAP ; #endif /******************************************************************************** TYPE DEFINITIONS ********************************************************************************/ /* for the types, we use the GLib library of the GTK project. See http://www.gtk.org for more informations */ #ifdef USE_GLIB /* use glib for types */ #include <glib.h> #else /* we don't use glib, so we need to define g... types */ #define guchar unsigned char #define gint32 int #define guint32 unsigned int #define gfloat float #define gint16 short #define guint16 unsigned short #define gint int #define guint unsigned int #define gchar char #ifdef WITH_64BITS #define gint64 long long #define guint64 unsigned long long #define gdouble double #endif /* WITH_64BITS */ #define TRUE 1 #define FALSE 0 #endif /* ifdef USE_GLIB ... else ... */ // - uchar is an 8 bit unsigned value #define uchar guchar // - int32 is a signed 32 bit value #define int32 gint32 // - uint32 is an unsigned 32 bit value #define uint32 guint32 // - float32 is a signed 32 bit floating point value #define float32 gfloat // - int16 is a signed 16 bit value #define int16 gint16 // - uint16 is an unsigned 16 bit value #define uint16 guint16 #ifdef WITH_64BITS // - int64 is a signed 64 bit value #define int64 gint64 // - uint64 is an unsigned 64 bit value #define uint64 guint64 // - float64 is a signed 64 bit floating point value #define float64 gdouble // --- define a struct for double and long support in two Var ... // ... the hi/lo decomposition typedef struct { uint32 lo; uint32 hi; } HiLoDoubleOrLong; //... for the double typedef union { float64 value; HiLoDoubleOrLong ul; } float64HiLo; //... for the long typedef union { int64 value; HiLoDoubleOrLong ul; } int64HiLo; #endif /* WITH_64BITS */ /******************************************************************************** TYPE CONVERTERS ********************************************************************************/ #ifdef FASTANDBIG # define getUInt32(b) (uint32)( (uint32)((b)[0])<<24 | \ (uint32)((b)[1])<<16 | \ (uint32)((b)[2])<<8 | (uint32)((b)[3]) ) # define getUInt16(b) (uint16)( ((b)[0]<<8)|(b)[1] ) # define getInt32(b) (int32) ( (uint32)((b)[0])<<24 | \ (uint32)((b)[1])<<16 | \ (uint32)((b)[2])<<8 | (uint32)((b)[3]) ) # define getInt16(b) (int16) ( ((b)[0]<<8)|(b)[1] ) #else uint32 getUInt32(uchar *b); uint16 getUInt16(uchar *b); int32 getInt32(uchar *b); int16 getInt16(uchar *b); #endif /* ifdef FASTANDBIG */ #ifdef WITH_64BITS // get one 64 float value from buf and return it float64 getFloat64bits(uchar *buf); // get one 64 float value from buf and return it int64 getInt64bits(uchar *buf); #endif /* WITH_64BITS */ float32 getFloat32(uchar *buf); /******************************************************************************** "STRING" FUNCTIONS ********************************************************************************/ #define xstrncmp(s1, s2, n) strncmp(s1, s2, n) #define xstrncpy(dst, src, n) strncpy(dst, src, n) #define xstrlen(s) strlen(s) #define xstrcat(dst, src) strcat(dst, src) #define xmemmove(dst, src, size) memmove(dst, src, size) #define xmemzero(mem, len) memset(mem, 0, len ) /******************************************************************************** DYNAMIC ALLOCATION FUNCTIONS ********************************************************************************/ #define xmalloc(size) malloc(size) #define xfree(p) free(p) /******************** TO REMOVE *********************/ #include <stdio.h> /******************************************************************** * Elementary data types ********************************************************************/ // Fixed size data types typedef char SByte; // 8 bits #ifndef __TYPES__ // (Already defined in CW11) typedef unsigned char Byte; #endif typedef short SWord; // 16 bits typedef unsigned short Word; typedef long SDWord; // 32 bits typedef unsigned long DWord; // Logical data types #ifndef __TYPES__ // (Already defined in CW11) typedef unsigned char Boolean; #endif typedef char Char; // Used for character strings typedef unsigned char UChar; typedef short Short; // >= Byte typedef unsigned short UShort; typedef short Int; // >= Word (use short so MPW and CW agree) typedef unsigned short UInt; typedef long Long; // >= DWord typedef unsigned long ULong; typedef short Err; typedef DWord LocalID; // local (card relative) chunk ID /************************************************************ * Pointer Types *************************************************************/ typedef void* VoidPtr; typedef VoidPtr* VoidHand; // Fixed size data types typedef SByte* SBytePtr; #ifndef __TYPES__ // (Already defined in CW11) typedef Byte* BytePtr; #endif typedef SWord* SWordPtr; typedef Word* WordPtr; typedef SDWord* SDWordPtr; typedef DWord* DWordPtr; // Logical data types typedef Boolean* BooleanPtr; typedef Char* CharPtr; typedef UChar* UCharPtr; typedef Short* ShortPtr; typedef UShort* UShortPtr; typedef Int* IntPtr; typedef UInt* UIntPtr; typedef Long* LongPtr; typedef ULong* ULongPtr; // Include the following typedefs if types.h wasn't read. #ifndef __TYPES__ // Generic Pointer types used by Memory Manager // We have to define Ptr as char* because that's what the Mac includes do. typedef char* Ptr; // global pointer typedef Ptr* Handle; // global handle // Function types typedef Long (*ProcPtr)(); #endif /* __TYPES__ */ /************************************************************ * Common constants *************************************************************/ #ifndef NULL # define NULL 0 #endif // NULL // Include the following typedefs if types.h wasn't read. #ifndef __TYPES__ #ifdef __MWERKS__ #if !__option(bool) #ifndef true #define true 1 #endif #ifndef false #define false 0 #endif #endif #else enum {false, true}; #endif #endif /* __TYPES__ */ #endif /* __NM_LINUX_A_H__ */ /* Local Variables: c-file-style: "smartdata" End: */ --- NEW FILE: nm_linux_b.c --- /* $Id: nm_linux_b.c,v 1.1 2004/12/20 23:37:32 mriem Exp $ Copyright (C) 1998, 1999, 2000 Wabasoft 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 of the License, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* Copyright (C) 2000, 2001 SMARTDATA, http://www.smartdata.ch/ [...1489 lines suppressed...] globalNetState = NET_READY_FOR_OPEN; if (!isApplication) { ui_MainLoop(); } stopApp(mainWinObj); if (globalNetState == NET_IS_OPEN) ; // TODO: NetLibClose(globalSocketLibRefNum, false); ui_exit(0); } /* Local Variables: c-file-style: "smartdata" End: */ --- NEW FILE: nm_linux_b.h --- /* $Id: nm_linux_b.h,v 1.1 2004/12/20 23:37:32 mriem Exp $ */ #ifndef __NM_LINUX_B_H__ #define __NM_LINUX_B_H__ /* Copyright (C) 1998, 1999, 2000 Wabasoft 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 of the License, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* Copyright (C) 2000, 2001 SMARTDATA, http://www.smartdata.ch/ More help for porting is include in the file nmport_b.c. Please read it before porting or modify this port. Linux port. =========== */ /* which GUI to use ? At this time, only GUI_GTK and GUI_PGUI is implemented */ #if defined(GUI_X) # include "ui_x.h" #elif defined(GUI_GTK) # include "ui_gtk.h" #elif defined(GUI_PGUI) # include "ui_pgui.h" #elif defined(GUI_NONE) # include "ui_none.h" #else # error you must define GUI_... to choose a GUI system #endif /* globals */ #define NET_NOT_READY_FOR_OPEN 0 #define NET_READY_FOR_OPEN 1 #define NET_IS_OPEN 2 #define NET_OPEN_FAILED 3 /**************** which are needed ? */ extern WObject globalMainWin; /* extern int32 globalTimerInterval; extern int32 globalTimerStart; extern int classDbCount; extern ULong appCreatorId; extern Word globalSocketLibRefNum; extern int globalNetState; #ifdef QUICKBIND extern int32 postEventMethodMapNum; extern int32 onTimerTickMethodMapNum; #endif */ /*************************************/ /* the size/properties of the MainWindow */ extern int32 hwr_bpp; extern int32 hwr_width; extern int32 hwr_height; extern int isApplication; #define HELPER #define PUBLIC #define WARN_NA(s) printf("### Warning: not implmented: %s\n", #s) #define MEM_CACHING 0 #define MAX_CLASSPATHS 20 static int numClassPaths = -1; static char *classPaths[MAX_CLASSPATHS]; static char *classpath = 0; static int is_ui_inited = 0; HELPER void * ui_init(); uchar *readFileIntoMemory( char *path, int nullTerminate, uint32 *size ); #ifdef WITH_THREAD //*** Isao's Multithread implementation START *** typedef struct { //Use either "syncObj" or "syncMethod", //Not both at the same time. WObject syncObj; WClassMethod* syncMethod; } WSync; typedef struct { WObject signalObj; } WSignal; typedef struct _queue { struct _queue *next; struct _queue *prev; } Queue; typedef struct { Queue queue; /* 'Queue' must be first to use type cast trick. */ WClass* tClass; WObject tObject; WSync wSyncObj; WSignal wSignal; int32 runMethodMapNum; uint32 sleepCountSet; uint32 sleepCountNow; uchar isSleepCountAlreadySet; uchar isWaiting; } WThread; // Thread variables - Isao F. Yamashita 07/25/2000 #define THREAD_LIST_MAX_SIZE 8 extern int InitThread(uint32 stacksize); //*** This "_onThreadStart()" method is called from "start()" method. extern Var ThreadStart(Var stack[]); //*** This "_onThreadStop()" method is called from "stop()" method. extern Var ThreadStop(Var stack[]); //*** This "_onThreadSleep()" method is called from "sleep()" method. extern Var ThreadSleep(Var stack[]); //*** This "_onThreadWait()" method is called from "wait()" method. extern Var ThreadWaitForSignal(Var stack[]); extern Var ThreadSignalAll(Var stack[]); //*** Isao's Multithread implementation END *** //*** This "ThreadCurrentThread()" method is called from "curentThread()" method. extern Var ThreadCurrentThread(Var stack[]); #define THERE_IS_SOME_THREADS (threadListCurrentSize > 0) void tickThread(void); int registerAsSyncronized(WClassMethod* method); void exitFromSyncronized(WClassMethod* method); int enterMonitor(WObject obj); int exitMonitor(WObject obj); #endif /* WITH_THREAD */ /* get/set the properties of the main window */ #endif /* __NM_LINUX_B_H__ */ /* Local Variables: c-file-style: "smartdata" End: */ --- NEW FILE: nm_linux_c.c --- /* $Id: nm_linux_c.c,v 1.1 2004/12/20 23:37:32 mriem Exp $ Copyright (C) 1998, 1999, 2000 Wabasoft 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 of the License, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* Copyright (C) 2000, 2001 SMARTDATA, http://www.smartdata.ch/ [...4551 lines suppressed...] /* * Registry destructor */ void RegistryDestroy (WObject registry) { char * fileName; InternalRegistryClose (registry); fileName = (char *) WOBJ_RegistryFileName (registry); free (fileName); } #endif /* #ifdef BEE_BIOS #else */ /* Local Variables: c-file-style: "smartdata" End: */ --- NEW FILE: nm_linux_c.h --- /* $Id: nm_linux_c.h,v 1.1 2004/12/20 23:37:32 mriem Exp $ */ #ifndef __NM_LINUX_C_H__ #define __NM_LINUX_C_H__ /* Copyright (C) 1998, 1999, 2000 Wabasoft 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 of the License, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* Copyright (C) 2000, 2001 SMARTDATA, http://www.smartdata.ch/ More help for porting is include in the file nmport_c.c. Please read it before porting or modify this port. Linux port. =========== */ /* default font parameters */ #define DEFAULT_FONT "helvetica" #define DEFAULT_FONT_SIZE 10 /* usefull for some implementation, like Solaris */ #ifndef INADDR_NONE #define INADDR_NONE ((unsigned long) -1) #endif void WindowDestroy(WObject obj); void MainWinDestroy(WObject obj); void GraphicsDestroy(WObject obj); void ImageDestroy(WObject obj); #if WITH_CATALOG_CLASS void CatalogDestroy(WObject obj); #endif void FileDestroy(WObject obj); void SocketDestroy(WObject obj); void SerialPortDestroy(WObject obj); void RegistryDestroy(WObject obj); void EditDestroy(WObject obj); /* to have a explanation of the following structure, see the the file nmport_c.c and my small explanation of how to access class variable below */ extern ClassHook classHooks[]; #define FUNC(f) extern Var f (Var stack[]) /* all the native functions */ FUNC(VmPrintLn); FUNC(VmPrint); FUNC(VmExec); FUNC(VmGetTimeStamp); FUNC(copyArray); FUNC(VmExit); FUNC(VmSleep); FUNC(VmSetDeviceAutoOff); FUNC(VmGetUserName); FUNC(VmGetPlatform); FUNC(VmIsColor); FUNC(FileGetLength); FUNC(FileCreateDir); FUNC(FileReadBytes); FUNC(FileRename); FUNC(FileCreate); FUNC(FileWriteBytes); FUNC(FileListDir); FUNC(FileSeekWaba); FUNC(FileIsDir); FUNC(FileCloseWaba); FUNC(FileIsOpen); FUNC(FileDeleteWaba); FUNC(FileExists); FUNC(ImageCreate); FUNC(ImageFree); FUNC(ImageSetPixels); FUNC(ImageUseImagePalette); FUNC(ImageLoad); FUNC(SoundBeep); FUNC(SoundTone); FUNC(TimeCreate); FUNC(SocketCreate); FUNC(SocketRead); FUNC(SocketWrite); FUNC(SocketSetReadTimeout); FUNC(SocketClose); FUNC(SocketIsOpen); FUNC(WindowCreate); #ifdef WITH_CATALOG_CLASS FUNC(CatalogListCatalogs); FUNC(CatalogAddRecord); FUNC(CatalogSkipBytes); FUNC(CatalogCreate); FUNC(CatalogRead); FUNC(CatalogDeleteRecord); FUNC(CatalogSetRecordPos); FUNC(CatalogGetRecordSize); FUNC(CatalogResizeRecord); FUNC(CatalogWrite); FUNC(CatalogGetRecordCount); FUNC(CatalogClose); FUNC(CatalogIsOpen); FUNC(CatalogDelete); #endif FUNC(GraphicsCopyRect); FUNC(GraphicsClearClip); FUNC(GraphicsSetFont); FUNC(GraphicsSetDrawOp); FUNC(GraphicsSetClip); FUNC(GraphicsSetBackColor); FUNC(GraphicsSetColor); FUNC(GraphicsGetClip); FUNC(GraphicsFillRect); FUNC(GraphicsDrawLine); FUNC(GraphicsTranslate); FUNC(GraphicsDrawDots); FUNC(GraphicsDrawChars); FUNC(GraphicsCreate); FUNC(GraphicsDrawCursor); FUNC(GraphicsSetClip); FUNC(GraphicsFree); FUNC(GraphicsSetForeColor); FUNC(GraphicsSetTextColor); FUNC(GraphicsFillPolygon); FUNC(GraphicsDrawString); FUNC(ConvertStringToInt); FUNC(ConvertFloatToIntBitwise); FUNC(ConvertCharToString); FUNC(ConvertIntToFloatBitwise); FUNC(ConvertFloatToString); FUNC(ConvertDoubleToString); FUNC(ConvertIntToString); FUNC(ConvertLongToString); FUNC(ConvertBooleanToString); FUNC(SoundClipPlay); FUNC(PalmOsPrefSetPalmOsPref); FUNC(PalmOsPrefGetPalmOsPref); FUNC(MainWinCreate); FUNC(MainWinExit); FUNC(MainWinSetTimerInterval); FUNC(SerialPortReadCheck); FUNC(SerialPortRead); FUNC(SerialPortWrite); FUNC(SerialPortSetReadTimeout); FUNC(SerialPortClose); FUNC(SerialPortSetFlowControl); FUNC(SerialPortIsOpen); FUNC(SerialPortCreate); #ifdef WITH_SMARTDATA_CLASSES FUNC(EditCreate); FUNC(EditGetText); FUNC(EditSetText); FUNC(EditDraw); FUNC(EditFocusIn); FUNC(EditFocusOut); FUNC(EditKeyPress); FUNC(EditPenDown); FUNC(EditPenDrag); FUNC(EditEvent); FUNC(EditPaint); #endif /* #ifdef WITH_SMARTDATA_CLASSES */ FUNC(FontMetricsGetStringWidth); FUNC(FontMetricsGetCharWidth); FUNC(FontMetricsCreate); FUNC(FontMetricsGetCharArrayWidth); FUNC(RegistryCreate); FUNC(RegistryReadBytes); FUNC(RegistryWriteBytes); FUNC(RegistrySkipBytes); FUNC(RegistryClose); FUNC(RegistryDelete); FUNC(RegistrySpaceAvailable); /************************************************************************* class waba/fx/Rect *************************************************************************/ // var[0] = Class // var[1] = int x // var[2] = int y // var[3] = int width // var[4] = int height #define WOBJ_RectX(o) (objectPtr(o))[1].intValue #define WOBJ_RectY(o) (objectPtr(o))[2].intValue #define WOBJ_RectWidth(o) (objectPtr(o))[3].intValue #define WOBJ_RectHeight(o) (objectPtr(o))[4].intValue /************************************************************************* class waba/ui/Control *************************************************************************/ // var[0] = Class // var[1] = int x // var[2] = int y // var[3] = int width // var[4] = int height #define WOBJ_ControlX(o) (objectPtr(o))[1].intValue #define WOBJ_ControlY(o) (objectPtr(o))[2].intValue #define WOBJ_ControlWidth(o) (objectPtr(o))[3].intValue #define WOBJ_ControlHeight(o) (objectPtr(o))[4].intValue /************************************************************************* class waba/ui/Window *************************************************************************/ // var[0] = Class // var[n] = ...other locals... // var[n + 1] = hook var - a pointer to the MainWindow // var[n + 2] = hook var - boolean if the Window allready a pixmap or not // // since Window inherits from other classes, we need to calculate the // right base offset to start with when reading/writing to variables extern int _winHookOffset; #define WOBJ_WindowMain(o) (objectPtr(o))[_winHookOffset + 0].refValue #define WOBJ_WindowHookVars 1 /* number of hook var for Window */ /************************************************************************* class waba/ui/MainWindow *************************************************************************/ // var[0] = Class // var[n] = ...other locals... // var[n + 1] = hook var - // extern int _mainWinHookOffset; #define WOBJ_MainWinTimer(o) (objectPtr(o))[_mainWinHookOffset + 0].intValue #define WOBJ_MainWinHookVars 1 /* number of hook var for MainWindow */ /************************************************************************* class waba/fx/Image *************************************************************************/ // var[0] = Class // var[1] = width // var[2] = height // var[3] = hook var - pointer to the pixmap image #define WOBJ_ImageWidth(o) (objectPtr(o))[1].intValue #define WOBJ_ImageHeight(o) (objectPtr(o))[2].intValue #define WOBJ_ImagePixmap(o) (objectPtr(o))[3].refValue /************************************************************************* class waba/io/Socket *************************************************************************/ // var[0] = Class // var[1] = hook var - Socket Id (int32) // var[2] = timeout delay in milliseconds // // NOTE: The SOCKET type is an unsigned 32 bit quantity - this most closely // matches the object type #define WOBJ_SocketFD(o) (objectPtr(o))[1].intValue #define WOBJ_SocketTimeout(o) (objectPtr(o))[2].intValue #ifdef WITH_SMARTDATA_CLASSES /************************************************************************* class ch/smartdata/ui/Edit *************************************************************************/ // var[0] = Class // ... = other local variables // var[n + 0] = Timer blinkTimer // var[n + 1] = Graphics drawg // var[n + 2] = hook var - char * chars // var[n + 3] = hook var - unsigned char * charWidths // var[n + 4] = hook var - ui_FontType * font // var[n + 5] = hook var - int totalCharWidth // var[n + 6] = hook var - int xOffset // var[n + 7] = hook var - int hasFocus // var[n + 8] = hook var - int redraw // var[n + 9] = hook var - int insertPoint // since Edit inherits from other classes, we need to calculate the // right base offset to start with when reading/writing to variables extern int _editHookOffset; #define WOBJ_EditBlinkTimer(o) (objectPtr(o))[_editHookOffset + 0].obj #define WOBJ_EditDrawG(o) (objectPtr(o))[_editHookOffset + 1].obj #define WOBJ_EditFont(o) (objectPtr(o))[_editHookOffset + 2].obj #define WOBJ_EditChars(o) (objectPtr(o))[_editHookOffset + 3].refValue #define WOBJ_EditCharWidths(o) (objectPtr(o))[_editHookOffset + 4].refValue #define WOBJ_EditTotalCharWidth(o) (objectPtr(o))[_editHookOffset + 5].intValue #define WOBJ_EditXOffset(o) (objectPtr(o))[_editHookOffset + 6].intValue #define WOBJ_EditHasFocus(o) (objectPtr(o))[_editHookOffset + 7].intValue #define WOBJ_EditRedraw(o) (objectPtr(o))[_editHookOffset + 8].intValue #define WOBJ_EditInsertPos(o) (objectPtr(o))[_editHookOffset + 9].intValue #define WOBJ_EditHookVars 10 /* number of hook var for Edit */ #endif /* #ifdef WITH_SMARTDATA_CLASSES */ /************************************************************************* class waba/fx/Font *************************************************************************/ // var[0] = Class // var[1] = String name // var[2] = int style // var[3] = int size // #define WOBJ_FontName(o) (objectPtr(o))[1].obj #define WOBJ_FontStyle(o) (objectPtr(o))[2].intValue #define WOBJ_FontSize(o) (objectPtr(o))[3].intValue #define Font_PLAIN 0 #define Font_BOLD 1 /************************************************************************* class waba/fx/FontMetrics *************************************************************************/ // var[0] = Class // var[1] = Font // var[2] = Surface // var[3] = int ascent // var[4] = int descent // var[5] = int leading #define WOBJ_FontMetricsFont(o) (objectPtr(o))[1].obj #define WOBJ_FontMetricsSurface(o) (objectPtr(o))[2].obj #define WOBJ_FontMetricsAscent(o) (objectPtr(o))[3].intValue #define WOBJ_FontMetricsDescent(o) (objectPtr(o))[4].intValue #define WOBJ_FontMetricsLeading(o) (objectPtr(o))[5].intValue /* what type of width we can compute */ #define FM_STRINGWIDTH 1 #define FM_CHARARRAYWIDTH 2 #define FM_CHARWIDTH 3 /************************************************************************* class waba/fx/Graphics *************************************************************************/ // var[0] = Class // var[1] = Surface // var[2] = hook var - isValid flag // var[3] = hook var - pointer to the main window, NULL if it's an Image // var[4] = hook var - pointer to the Pixmap if it's an Image, NULL otherwise // var[5] = hook var - pointer to the drawing pixmap where all draw are made // var[6] = hook var - pointer to the used font // var[7] = hook var - the start x of the clip region // var[8] = hook var - the start y of the clip region // var[9] = hook var - the width of the clip region // var[10] = hook var - the height of the clip region // var[11] = hook var - the operation used for the draw (AND/OR/XOR...) // var[12] = hook var - the value of the red color used for the draw // var[13] = hook var - the value of the green color used for the draw // var[14] = hook var - the value of the blue color used for the draw // var[15] = hook var - the X used for translation // var[16] = hook var - the Y used for translation #define WOBJ_GraphicsSurface(o) (objectPtr(o))[1].obj #define WOBJ_GraphicsIsValid(o) (objectPtr(o))[2].intValue #define WOBJ_GraphicsWindowMain(o) (objectPtr(o))[3].refValue #define WOBJ_GraphicsPixmap(o) (objectPtr(o))[4].refValue #define WOBJ_GraphicsDrawingPixmap(o) (objectPtr(o))[5].refValue #define WOBJ_GraphicsFont(o) (objectPtr(o))[6].refValue #define WOBJ_GraphicsClipRegionX(o) (objectPtr(o))[7].intValue #define WOBJ_GraphicsClipRegionY(o) (objectPtr(o))[8].intValue #define WOBJ_GraphicsClipRegionW(o) (objectPtr(o))[9].intValue #define WOBJ_GraphicsClipRegionH(o) (objectPtr(o))[10].intValue #define WOBJ_GraphicsDrawOp(o) (objectPtr(o))[11].intValue #define WOBJ_GraphicsRED(o) (objectPtr(o))[12].intValue #define WOBJ_GraphicsGREEN(o) (objectPtr(o))[13].intValue #define WOBJ_GraphicsBLUE(o) (objectPtr(o))[14].intValue #define WOBJ_GraphicsTransX(o) (objectPtr(o))[15].intValue #define WOBJ_GraphicsTransY(o) (objectPtr(o))[16].intValue /* how we can draw */ #define DRAW_OVER 1 #define DRAW_AND 2 #define DRAW_OR 3 #define DRAW_XOR 4 /* some constants giving the existing type of drawing */ #define GR_FILLRECT 0 #define GR_DRAWLINE 1 #define GR_FILLPOLY 2 #define GR_DRAWCHARS 3 #define GR_DRAWSTRING 4 #define GR_DOTS 5 #define GR_COPYRECT 6 #define GR_DRAWCURSOR 7 /* existing surface type */ #define SURF_UNKNOWN 0 #define SURF_WINDOW 1 #define SURF_IMAGE 2 /************************************************************************* class waba/fx/SoundClip *************************************************************************/ // var[0] = Class // var[1] = path // var[2] = loaded #define WOBJ_SoundClipPath(o) (objectPtr(o))[1].obj #define WOBJ_SoundClipLoaded(o) (objectPtr(o))[2].intValue #ifdef WITH_CATALOG_CLASS /************************************************************************* class waba/io/Catalog As linux has no catalog, this is not implemented at this time *************************************************************************/ // var[0] = Class // var[1] = hook var - database handle (null if no open db) // var[2] = hook var - database oid // var[3] = hook var - current record position // var[4] = hook var - current record oid // var[5] = hook var - current record memory pointer // var[6] = hook var - current record memory allocation pointer // var[7] = hook var - length of current record // var[8] = hook var - current offset in record // var[9] = hook var - 1 if record has been modified, 0 otherwise #define WOBJ_CatalogHandle(o) (objectPtr(o))[1].refValue #define WOBJ_CatalogOID(o) (objectPtr(o))[2].refValue #define WOBJ_CatalogCurRecPos(o) (objectPtr(o))[3].intValue #define WOBJ_CatalogCurRecOid(o) (objectPtr(o))[4].refValue #define WOBJ_CatalogCurRecPtr(o) (objectPtr(o))[5].refValue #define WOBJ_CatalogCurRecAllocPtr(o) (objectPtr(o))[6].refValue #define WOBJ_CatalogCurRecLen(o) (objectPtr(o))[7].intValue #define WOBJ_CatalogCurRecOffset(o) (objectPtr(o))[8].intValue #define WOBJ_CatalogCurRecModified(o) (objectPtr(o))[9].intValue #define Catalog_READ_ONLY 1 #define Catalog_WRITE_ONLY 2 #define Catalog_READ_WRITE 3 #define Catalog_CREATE 4 #define Catalog_CEDBTYPE 4141 #endif //WITH_CATALOG_CLASS /************************************************************************* class waba/io/File *************************************************************************/ // var[0] = Class // var[1] = String name // var[2] = int mode // var[3] = hook var - file handle #define WOBJ_FileName(o) (objectPtr(o))[1].obj #define WOBJ_FileMode(o) (objectPtr(o))[2].intValue #define WOBJ_FileHandle(o) (objectPtr(o))[3].refValue #define File_DONT_OPEN 0 #define File_READ_ONLY 1 #define File_WRITE_ONLY 2 #define File_READ_WRITE 3 #define File_CREATE 4 /* some file operation */ #define FILE_CREATE_DIR 1 #define FILE_IS_DIR 2 #define FILE_DELETE 3 #define FILE_RENAME 4 #define FILE_EXISTS 5 /************************************************************************* class waba/io/SerialPort *************************************************************************/ // var[0] = Class // var[1] = hook var - Handle #define WOBJ_SerialPortHandle(o) (objectPtr(o))[1].refValue /************************************************************************* class waba/sys/Time *************************************************************************/ // var[0] = Class // var[1] = int year // var[2] = int month // var[3] = int day // var[4] = int hour // var[5] = int minute // var[6] = int second // var[7] = int millis #define WOBJ_TimeYear(o) (objectPtr(o))[1].intValue #define WOBJ_TimeMonth(o) (objectPtr(o))[2].intValue #define WOBJ_TimeDay(o) (objectPtr(o))[3].intValue #define WOBJ_TimeHour(o) (objectPtr(o))[4].intValue #define WOBJ_TimeMinute(o) (objectPtr(o))[5].intValue #define WOBJ_TimeSecond(o) (objectPtr(o))[6].intValue #define WOBJ_TimeMillis(o) (objectPtr(o))[7].intValue /************************************************************************* class waba/io/Registry *************************************************************************/ #ifdef BEE_BIOS // var [0] = Class // var [1] = unsigned char * memory buffer // var [2] = int position into memory buffer // var [3] = int current size of memory buffer // var [4] = int flag indicating that the buffer has been modified // var [5] = char * environment variable name #define WOBJ_RegistryBuffer(o) (objectPtr(o))[1].refValue #define WOBJ_RegistryBufferPos(o) (objectPtr(o))[2].intValue #define WOBJ_RegistryBufferSize(o) (objectPtr(o))[3].intValue #define WOBJ_RegistryBufferDirty(o) (objectPtr(o))[4].intValue #define WOBJ_RegistryVarName(o) (objectPtr(o))[5].refValue #else /* #ifdef BEE_BIOS */ // var[0] = Class // var[1] = char * file name // var[2] = int file descriptor #define WOBJ_RegistryFileName(o) (objectPtr(o))[1].refValue #define WOBJ_RegistryFile(o) (objectPtr(o))[2].intValue #endif /* #ifdef BEE_BIOS #else */ /************************************************************************* functions implemented in ui_xxx.c *************************************************************************/ /* general */ void ui_MainLoop(); int ui_IsColor(); /* timeout related */ void ui_TimeoutSet( WObject win, gint nbOfMillisecond ); /* for the fonts */ ui_FontType *ui_FontCreate( WObject font ); void ui_FontDelete( ui_FontType *theFont ); gint ui_TextWidth( char *theText, ui_FontType *theFont ); gint ui_CharWidth( char theChar, ui_FontType *theFont ); int ui_FontHeight( ui_FontType *theFont ); void ui_FontSetProperties( ui_FontType *theFont, WObject fontMetrics ); gint ui_FontGetYOffset( ui_FontType *theFont ); /* for the draw */ ui_PixmapType *ui_createDrawingPixmap( ui_MainWindowType *mw, ui_Rectangle rect ); void ui_deleteDrawingPixmap( ui_PixmapType *thePixmap ); ui_GraphicsContextType *ui_createGC( WObject gr ); void ui_deleteGC( ui_GraphicsContextType *theGC ); void ui_setTheDrawFunction( ui_GraphicsContextType *theGC, gint32 drawOp ); void ui_ClipTo( ui_GraphicsContextType *theGC, ui_Rectangle rect ); void ui_SetColor( ui_GraphicsContextType *theGC, gint red, gint green, gint blue ); void ui_DrawPixel( ui_PixmapType *drawingPixmap, ui_GraphicsContextType *theGC, gint x, gint y ); void ui_DrawLine( ui_PixmapType *drawingPixmap, ui_GraphicsContextType *theGC, gint x1, gint y1, gint x2, gint y2 ); void ui_DrawText( ui_PixmapType *drawingPixmap, ui_GraphicsContextType *theGC, gint x, gint y, char *theText, ui_FontType *theFont ); void ui_DrawFilledRect( ui_PixmapType *drawingPixmap, ui_GraphicsContextType *theGC, gint x, gint y, gint w, gint h ); void ui_DrawFilledPoly( ui_PixmapType *drawingPixmap, ui_GraphicsContextType *theGC, gint *x, gint *y, gint nbPoints, gint transX, gint transY ); void ui_GraphicsRepaint( WObject graphics, ui_PixmapType *drawingPixmap, ui_GraphicsContextType *gc ); /* image related */ ui_GraphicsContextType *ui_createGCFromPixmap( ui_PixmapType *thePixmap, gint32 width, gint32 height ); ui_PixmapType *ui_NewPixmap( gint w, gint h ); void ui_DeletePixmap( ui_PixmapType *thePixmap ); void ui_DrawRGBImage( ui_PixmapType *thePixmap, ui_GraphicsContextType *theGC, gint x, gint y, gint w, gint h, uchar *rgbbuf ); void ui_DrawPixmap( ui_PixmapType *dstPixmap, ui_GraphicsContextType *theGC, ui_PixmapType *srcPixmap, gint x, gint y, gint dstX, gint dstY, gint w, gint h ); /* for translating the key code to a waba key code */ int32 ui_TranslateKey( Word chr ); #endif /* __NM_LINUX_A_H__ */ /* Local Variables: c-file-style: "smartdata" End: */ --- NEW FILE: ui_gtk.c --- /* $Id: ui_gtk.c,v 1.1 2004/12/20 23:37:32 mriem Exp $ Copyright (C) 2000, 2001 SMARTDATA, http://www.smartdata.ch/ 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 of the License, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* GTK Port. See http://www.gtk.org/ for more informations */ #include "../waba.h" #ifdef WITH_THREAD /* as it seem gtk_main_iteration_do() don't return TRUE when we call gtk_main_quit(), */ /* we use a global variable to finish the program... Bad, but... */ gint isFinish; #endif g_error sucess = {ERRT_NONE,NULL}; g_error mkerror(unsigned char type, char *msg) { g_error e = {type,msg}; return e; } g_error prerror(g_error e) { if (e.type == ERRT_NONE) return sucess; if (!e.msg) e.msg = "?"; printf("*** ERROR ("); switch (e.type) { case ERRT_MEMORY: printf("MEMORY"); break; case ER... [truncated message content] |
|
From: Manfred R. <mr...@us...> - 2004-12-20 23:35:44
|
Update of /cvsroot/waba/waba/src/linux/c In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26967/c Removed Files: debug.c debug.h gdk-pixbuf-xlibrgb.c gdk-pixbuf-xlibrgb.h jar.c jar.h jar2host.h nm_linux_a.c nm_linux_a.h nm_linux_b.c nm_linux_b.h nm_linux_c.c nm_linux_c.h ui_gtk.c ui_gtk.h ui_none.c ui_none.h ui_pgui.c ui_pgui.h ui_x.c ui_x.h Log Message: Removed old location --- debug.c DELETED --- --- debug.h DELETED --- --- gdk-pixbuf-xlibrgb.c DELETED --- --- gdk-pixbuf-xlibrgb.h DELETED --- --- jar.c DELETED --- --- jar.h DELETED --- --- jar2host.h DELETED --- --- nm_linux_a.c DELETED --- --- nm_linux_a.h DELETED --- --- nm_linux_b.c DELETED --- --- nm_linux_b.h DELETED --- --- nm_linux_c.c DELETED --- --- nm_linux_c.h DELETED --- --- ui_gtk.c DELETED --- --- ui_gtk.h DELETED --- --- ui_none.c DELETED --- --- ui_none.h DELETED --- --- ui_pgui.c DELETED --- --- ui_pgui.h DELETED --- --- ui_x.c DELETED --- --- ui_x.h DELETED --- |
|
From: Manfred R. <mr...@us...> - 2004-12-20 23:24:59
|
Update of /cvsroot/waba/waba/src/win32 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24332 Added Files: config.h constants.h debug.h error.c error.h exception.h memory.c memory.h native.c native.h nmwin32_a.c nmwin32_a.h nmwin32_b.c nmwin32_b.h nmwin32_c.c nmwin32_c.h opcodes.h thread.h types.h waba.c waba.h Log Message: Added at correct location --- NEW FILE: config.h --- /* * $Id: config.h,v 1.1 2004/12/20 23:24:50 mriem Exp $ * * Copyright (c) 2001, 2002, 2003, Waba @ Sourceforge. * Copyright (c) 1998, 1999, 2000, Wabasoft. * All Rights Reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * ---------------------------------------------------------------------------- * * Defines all the configuration for the VM * * ---------------------------------------------------------------------------- */ #ifndef __CONFIG_H__ #define __CONFIG_H__ /* * Which OS */ // #define PALMOS 1 // #define WINCE 1 // #define WIN32 1 /* * Memory options */ #define QUICKBIND 1 #define SANITYCHECK 1 #define SECURE_CLASS_HEAP 1 #define SMALLMEM 1 /* * With classic Waba support */ #define WITH_WABA 1 #define WITH_CATALOG 1 #define WITH_CATALOG_CLASS 1 #define WITH_DOUBLE_BUFFER 1 #define WITH_FILE_CLASS 1 #define WITH_FONTMETRICS_CLASS 1 #define WITH_GRAPHICS_CLASS 1 #define WITH_GUI_CLASS 1 #define WITH_SERIALPORT_CLASS 1 #define WITH_SOCKET_CLASS 1 #define WITH_SOUNDCLIP_CLASS 1 /* * With Waba extension support */ // #define WITH_SMARTDATA_CLASSES 1 /* * With thread support */ #define WITH_THREAD 1 #define WITH_THREAD_NATIVE 1 /* * With 64 bits support */ #define WITH_64BITS 1 #endif --- NEW FILE: constants.h --- /* * $Id: constants.h,v 1.1 2004/12/20 23:24:50 mriem Exp $ * * Copyright (c) 2001, 2002, 2003, Waba @ Sourceforge. * Copyright (c) 1998, 1999, 2000, Wabasoft. * All Rights Reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef __CONSTANTS_H__ #define __CONSTANTS_H__ /* * Waba classic key constants. */ #define WABA_KEY_PAGE_UP 75000 #define WABA_KEY_PAGE_DOWN 75001 #define WABA_KEY_HOME 75002 #define WABA_KEY_END 75003 #define WABA_KEY_UP 75004 #define WABA_KEY_DOWN 75005 #define WABA_KEY_LEFT 75006 #define WABA_KEY_RIGHT 75007 #define WABA_KEY_INSERT 75008 #define WABA_KEY_ENTER 75009 #define WABA_KEY_TAB 75010 #define WABA_KEY_BACKSPACE 75011 #define WABA_KEY_ESCAPE 75012 #define WABA_KEY_DELETE 75013 #define WABA_KEY_MENU 75014 #define WABA_KEY_COMMAND 75015 /* * Waba classic event constants. */ #define WABA_EVENT_KEY_PRESS 100 #define WABA_EVENT_PEN_DOWN 200 #define WABA_EVENT_PEN_MOVE 201 #define WABA_EVENT_PEN_UP 202 #define WABA_EVENT_PEN_DRAG 203 #endif --- NEW FILE: debug.h --- /* * $Id: debug.h,v 1.1 2004/12/20 23:24:50 mriem Exp $ * * Copyright (c) 2001, 2002, 2003, Waba @ Sourceforge. * Copyright (c) 1998, 1999, 2000, Wabasoft. * All Rights Reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * ---------------------------------------------------------------------------- * * Defines support for debugging. * * ---------------------------------------------------------------------------- */ #ifndef __DEBUG_H__ #define __DEBUG_H__ #ifdef DEBUG_OPCODE #define OP_MAX_OP 202 static char * _OP_name [] = { "OP_nop", "OP_aconst_null", "OP_iconst_m1", "OP_iconst_0", "OP_iconst_1", "OP_iconst_2", "OP_iconst_3", "OP_iconst_4", "OP_iconst_5", "OP_lconst_0", "OP_lconst_1", "OP_fconst_0", "OP_fconst_1", "OP_fconst_2", "OP_dconst_0", "OP_dconst_1", "OP_bipush", "OP_sipush", "OP_ldc", "OP_ldc_w", "OP_ldc2_w", "OP_iload", "OP_lload", "OP_fload", "OP_dload", "OP_aload", "OP_iload_0", "OP_iload_1", "OP_iload_2", "OP_iload_3", "OP_lload_0", "OP_lload_1", "OP_lload_2", "OP_lload_3", "OP_fload_0", "OP_fload_1", "OP_fload_2", "OP_fload_3", "OP_dload_0", "OP_dload_1", "OP_dload_2", "OP_dload_3", "OP_aload_0", "OP_aload_1", "OP_aload_2", "OP_aload_3", "OP_iaload", "OP_laload", "OP_faload", "OP_daload", "OP_aaload", "OP_baload", "OP_caload", "OP_saload", "OP_istore", "OP_lstore", "OP_fstore", "OP_dstore", "OP_astore", "OP_istore_0", "OP_istore_1", "OP_istore_2", "OP_istore_3", "OP_lstore_0", "OP_lstore_1", "OP_lstore_2", "OP_lstore_3", "OP_fstore_0", "OP_fstore_1", "OP_fstore_2", "OP_fstore_3", "OP_dstore_0", "OP_dstore_1", "OP_dstore_2", "OP_dstore_3", "OP_astore_0", "OP_astore_1", "OP_astore_2", "OP_astore_3", "OP_iastore", "OP_lastore", "OP_fastore", "OP_dastore", "OP_aastore", "OP_bastore", "OP_castore", "OP_sastore", "OP_pop", "OP_pop2", "OP_dup", "OP_dup_x1", "OP_dup_x2", "OP_dup2", "OP_dup2_x1", "OP_dup2_x2", "OP_swap", "OP_iadd", "OP_ladd", "OP_fadd", "OP_dadd", "OP_isub", "OP_lsub", "OP_fsub", "OP_dsub", "OP_imul", "OP_lmul", "OP_fmul", "OP_dmul", "OP_idiv", "OP_ldiv", "OP_fdiv", "OP_ddiv", "OP_irem", "OP_lrem", "OP_frem", "OP_drem", "OP_ineg", "OP_lneg", "OP_fneg", "OP_dneg", "OP_ishl", "OP_lshl", "OP_ishr", "OP_lshr", "OP_iushr", "OP_lushr", "OP_iand", "OP_land", "OP_ior", "OP_lor", "OP_ixor", "OP_lxor", "OP_iinc", "OP_i2l", "OP_i2f", "OP_i2d", "OP_l2i", "OP_l2f", "OP_l2d", "OP_f2i", "OP_f2l", "OP_f2d", "OP_d2i", "OP_d2l", "OP_d2f", "OP_i2b", "OP_i2c", "OP_i2s", "OP_lcmp", "OP_fcmpl", "OP_fcmpg", "OP_dcmpl", "OP_dcmpg", "OP_ifeq", "OP_ifne", "OP_iflt", "OP_ifge", "OP_ifgt", "OP_ifle", "OP_if_icmpeq", "OP_if_icmpne", "OP_if_icmplt", "OP_if_icmpge", "OP_if_icmpgt", "OP_if_icmple", "OP_if_acmpeq", "OP_if_acmpne", "OP_goto", "OP_jsr", "OP_ret", "OP_tableswitch", "OP_lookupswitch", "OP_ireturn", "OP_lreturn", "OP_freturn", "OP_dreturn", "OP_areturn", "OP_return", "OP_getstatic", "OP_putstatic", "OP_getfield", "OP_putfield", "OP_invokevirtual", "OP_invokespecial", "OP_invokestatic", "OP_invokeinterface", "OP_new", "OP_newarray", "OP_anewarray", "OP_arraylength", "OP_athrow", "OP_checkcast", "OP_instanceof", "OP_monitorenter", "OP_monitorexit", "OP_wide", "OP_multianewarray", "OP_ifnull", "OP_ifnonnull", "OP_goto_w", "OP_jsr_w", "OP_breakpoint" }; #endif #endif --- NEW FILE: error.c --- /* * $Id: error.c,v 1.1 2004/12/20 23:24:50 mriem Exp $ * * Copyright (c) 2001, 2002, 2003, Waba @ Sourceforge. * Copyright (c) 1998, 1999, 2000, Wabasoft. * All Rights Reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * ---------------------------------------------------------------------------- * * Implements support for errors. * * ---------------------------------------------------------------------------- */ #include "waba.h" #include "error.h" void VmError( uint16 errNum, WClass *iclass, UtfString *desc1, UtfString *desc2 ) { WClass *wclass; WClassMethod *method; UtfString className, iclassName, methodName, methodDesc; // NOTE: Don't overwrite an existing error since it may be the // root cause of this error. if (vmStatus.errNum != 0) return; vmStatus.errNum = errNum; // get current class and method off stack if (vmStackPtr > 0) { wclass = (WClass *)vmStack[vmStackPtr - 1].refValue; method = (WClassMethod *)vmStack[vmStackPtr - 2].refValue; } else { wclass = 0; method = 0; } // output class and method name if (wclass) { className = getUtfString(wclass, wclass->classNameIndex); printToBuf(vmStatus.className, 40, &className, NULL); } if (method) { methodName = getUtfString(wclass, METH_nameIndex(method)); methodDesc = getUtfString(wclass, METH_descIndex(method)); printToBuf(vmStatus.methodName, 40, &methodName, &methodDesc); } // output additional error arguments (target class, desc, etc.) if (iclass) { iclassName = getUtfString(iclass, iclass->classNameIndex); printToBuf(vmStatus.arg1, 40, &iclassName, NULL); } printToBuf(vmStatus.arg2, 40, desc1, desc2); #ifdef WIN32 #ifndef WINCE dumpStackTrace(); #endif #endif } void VmQuickError(uint16 errNum) { VmError( errNum, NULL, NULL, NULL ); } --- NEW FILE: error.h --- /* * $Id: error.h,v 1.1 2004/12/20 23:24:50 mriem Exp $ * * Copyright (c) 2001, 2002, 2003, Waba @ Sourceforge. * Copyright (c) 1998, 1999, 2000, Wabasoft. * All Rights Reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * ---------------------------------------------------------------------------- * * Defines support for errors. * * ---------------------------------------------------------------------------- */ #ifndef __ERROR_H__ #define __ERROR_H__ /* * Error messages */ static char *errorMessages[] = { "sanity", "incompatible device", "can't access waba classes", "can't access app classes", "can't allocate memory", "out of class memory", "out of object memory", "native stack overflow", "native stack underflow", "stack overflow", "bad class", "bad opcode", "can't find class", "can't find method", "can't find field", "null object access", "null array access", "index out of range", "divide by zero", "bad class cast", "class too large" }; /* * Fatal errors */ #define ERR_SanityCheckFailed 1 #define ERR_IncompatibleDevice 2 #define ERR_CantAccessCoreClasses 3 #define ERR_CantAccessAppClasses 4 #define ERR_CantAllocateMemory 5 #define ERR_OutOfClassMem 6 #define ERR_OutOfObjectMem 7 #define ERR_NativeStackOverflow 8 #define ERR_NativeStackUnderflow 9 #define ERR_StackOverflow 10 /* * Program errors */ #define ERR_BadClass 11 #define ERR_BadOpcode 12 #define ERR_CantFindClass 13 #define ERR_CantFindMethod 14 #define ERR_CantFindField 15 #define ERR_NullObjectAccess 16 #define ERR_NullArrayAccess 17 #define ERR_IndexOutOfRange 18 #define ERR_DivideByZero 19 #define ERR_ClassCastException 20 #define ERR_ClassTooLarge 21 /* * Function prototypes * ------------------- * * NOTE: the function prototypes should be enabled here once we have finished * cleaning up interdepencies. * * void VmError( uint16 errNum, * WClass *iclass, * UtfString *desc1, * UtfString *desc2); * * void VmQuickError( uint16 errNum ); */ #endif --- NEW FILE: exception.h --- /* * $Id: exception.h,v 1.1 2004/12/20 23:24:50 mriem Exp $ * * Copyright (c) 2001, 2002, 2003, Waba @ Sourceforge. * Copyright (c) 1998, 1999, 2000, Wabasoft. * All Rights Reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * ---------------------------------------------------------------------------- * * Defines the exception support in the VM. * * ---------------------------------------------------------------------------- */ #ifndef __EXCEPTION_H__ #define __EXCEPTION_H__ #endif --- NEW FILE: memory.c --- /* * $Id: memory.c,v 1.1 2004/12/20 23:24:50 mriem Exp $ * * Copyright (c) 2001, 2002, 2003, Waba @ Sourceforge. * Copyright (c) 1998, 1999, 2000, Wabasoft. * All Rights Reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * ---------------------------------------------------------------------------- * * Memory Management * ----------------- * * Here's the garbage collector. I implemented the mark and sweep below after * testing out a few different ones and reading: * * Garbage Collection, Algorithms for Automatic Dynamic Memory Management * by Richard Jones and Rafael Lins * * which is an excellent book. Also, this collector has gone through a lot of * testing. It runs when the system is completely out of memory which can * happen at any time ... for example during class loading. * * To test it out, tests were run where 1000's of random objects were loaded, * constructed and random methods called on them over some period of days. * This found a couple subtle bugs that were fixed like when the garbage * collector ran in the middle of array allocation and moved pointers around * from under the array allocator code ( those have all been fixed ). * * The heap is comprised of Hos objects (an array) that grows from the * "right" of object memory and objects that take up the space on on the * "left" side. The Hos array keeps track of where the objects are on the * left. * * The Hos structure (strange, but aptly named) is used to keep track of * handles (pointers to memory locations), order (order of handles with * respect to memory) and temporary items (used during the scan phase). * * The 3 items in the Hos structure do not relate to each other. They are * each a part of 3 conceptually distinct arrays that grow from the right of * the heap while the objects grow from the left. So, when the Hos array is * indexed, it is always negative (first element is 0, next is -1, next * is -2, etc). * * ---------------------------------------------------------------------------- */ #include "waba.h" #include "memory.h" /* * The heap with objects. */ static ObjectHeap heap; #define VALID_OBJ(o) (o > FIRST_OBJ && o <= FIRST_OBJ + heap.numHandles) // mark bits in the handle order array since it is not used during // the mark object process (its used in the sweep phase) #define MARK(o) heap.hos[- (int32)(o - FIRST_OBJ - 1)].order |= 0x80000000 #define IS_MARKED(o) (heap.hos[- (int32)(o - FIRST_OBJ - 1)].order & 0x80000000) /* * NOTE: There are no waba methods that are called when objects are destroyed. * This is because if a method was called, the object would be on its * way to being GC'd and if we set another object (or static field) to * reference it, after the GC, the reference would be stale. */ void sweep() { WObject obj; WClass *wclass; uint32 i, h, objSize, prevObjectSize, numUsedHandles; uchar *src, *dst; prevObjectSize = heap.objectSize; heap.objectSize = 0; // move all the marks over into the scan array so we don't have // to do lots of bit shifting for (i = 0; i < heap.numHandles; i++) { if (heap.hos[- (int32)i].order & 0x80000000) { heap.hos[- (int32)i].order &= 0x7FFFFFFF; // clear mark bit heap.hos[- (int32)i].temp = 1; } else { heap.hos[- (int32)i].temp = 0; } } numUsedHandles = 0; for (i = 0; i < heap.numHandles; i++) { // we need to scan in memory order so we can compact things without // copying objects over each other h = heap.hos[- (int32)i].order; obj = h + FIRST_OBJ + 1; if (!heap.hos[- (int32)h].temp) { // handle is free - dereference object if (objectPtr(obj) != NULL) { wclass = WOBJ_class(obj); // for non-arrays, call objDestroy if present if (wclass != NULL && wclass->objDestroyFunc) wclass->objDestroyFunc(obj); heap.hos[- (int32)h].ptr = NULL; } continue; } wclass = WOBJ_class(obj); if (wclass == NULL) objSize = arraySize(WOBJ_arrayType(obj), WOBJ_arrayLen(obj)); else objSize = WCLASS_objectSize(wclass); // copy object to new heap src = (uchar *)heap.hos[- (int32)h].ptr; dst = &heap.mem[heap.objectSize]; if (src != dst) // NOTE: overlapping regions need to copy correctly xmemmove(dst, src, objSize); heap.hos[- (int32)h].ptr = (Var *)dst; heap.hos[- (int32)numUsedHandles].order = h; heap.objectSize += objSize; numUsedHandles++; } heap.numFreeHandles = heap.numHandles - numUsedHandles; for (i = 0; i < heap.numHandles; i++) if (!heap.hos[- (int32)i].temp) { // add free handle to free section of order array heap.hos[- (int32)numUsedHandles].order = i; numUsedHandles++; } // zero out the part of the heap that is now junk xmemzero(&heap.mem[heap.objectSize], prevObjectSize - heap.objectSize); } /* * NOTE: this method is only for printing the status of memory and can be * removed. Also note, there is no such thing as the "amount of free * memory" because of garbage collection. */ uint32 getUnusedMem() { return heap.memSize - (heap.objectSize + (heap.numHandles * sizeof(Hos))); } int initObjectHeap(uint32 heapSize) { // NOTE: we must intiailize all the variables since after // a freeObjectHeap() we get called again heap.numHandles = 0; heap.numFreeHandles = 0; heap.memSize = heapSize; #if FIXED_OBJECT_HEAP_SIZE > 0 // align to 4 byte boundry for correct alignment of the Hos array heap.memSize = sizeof(objectHeapArea); // allocate and zero out memory region heap.mem = &objectHeapArea[0]; #else // align to 4 byte boundry for correct alignment of the Hos array heap.memSize = (heap.memSize + 3) & ~3; // allocate and zero out memory region heap.mem = (uchar *)xmalloc(heap.memSize); if (heap.mem == NULL) return -1; #endif xmemzero(heap.mem, heap.memSize); heap.hos = (Hos *)(&heap.mem[heap.memSize - sizeof(Hos)]); heap.objectSize = 0; return 0; } void freeObjectHeap() { #ifdef FREE_ON_EXIT { WObject obj; uint32 h; WClass *wclass; // call any native object destroy methods to free system resources for (h = 0; h < heap.numHandles; h++) { obj = h + FIRST_OBJ + 1; if (objectPtr(obj) != NULL) { wclass = WOBJ_class(obj); if (wclass != NULL && wclass->objDestroyFunc) wclass->objDestroyFunc(obj); } } } #endif #if FIXED_OBJECT_HEAP_SIZE <= 0 if (heap.mem) xfree(heap.mem); #endif } // mark this object and all the objects this object refers to and all // objects those objects refer to, etc. void markObject(WObject obj) { WClass *wclass; WObject *arrayStart, o; uint32 i, len, type, numScan; if (!VALID_OBJ(obj) || objectPtr(obj) == NULL || IS_MARKED(obj)) return; MARK(obj); numScan = 0; markinterior: wclass = WOBJ_class(obj); if (wclass == NULL) { // array - see if it contains object references type = WOBJ_arrayType(obj); if (type == 1 || type == 2) { // for an array of arrays or object array arrayStart = (WObject *)WOBJ_arrayStart(obj); len = WOBJ_arrayLen(obj); for (i = 0; i < len; i++) { o = arrayStart[i]; if (VALID_OBJ(o) && objectPtr(o) != NULL && !IS_MARKED(o)) { MARK(o); heap.hos[- (int32)numScan].temp = o; numScan++; } } } } else { // object len = wclass->numVars; for (i = 0; i < len; i++) { o = WOBJ_var(obj, i).obj; if (VALID_OBJ(o) && objectPtr(o) != NULL && !IS_MARKED(o)) { MARK(o); heap.hos[- (int32)numScan].temp = o; numScan++; } } } if (numScan > 0) { // Note: we use goto since we want to avoid recursion here // since structures like linked links could create deep // stack calls --numScan; obj = heap.hos[- (int32)numScan].temp; goto markinterior; } } // NOTE: size passed must be 4 byte aligned (see arraySize()) WObject allocObject(int32 size) { uint32 i, sizeReq, hosSize; if (size <= 0) return 0; sizeReq = size; if (!heap.numFreeHandles) sizeReq += sizeof(Hos); hosSize = heap.numHandles * sizeof(Hos); if (sizeReq + hosSize + heap.objectSize > heap.memSize) { gc(); // heap.objectSize changed or we are out of memory if (sizeReq + hosSize + heap.objectSize > heap.memSize) { VmQuickError(ERR_OutOfObjectMem); return 0; } } if (heap.numFreeHandles) { i = heap.hos[- (int32)(heap.numHandles - heap.numFreeHandles)].order; heap.numFreeHandles--; } else { // no free handles, get a new one i = heap.numHandles; heap.hos[- (int32)i].order = i; heap.numHandles++; } heap.hos[- (int32)i].ptr = (Var *)&heap.mem[heap.objectSize]; heap.objectSize += size; return FIRST_OBJ + i + 1; } // NOTE: we made this function a #define and it showed no real performance // gain over having it a function on either PalmOS or Windows when // optimization was turned on. Var *objectPtr(WObject obj) { return heap.hos[- (int32)(obj - FIRST_OBJ - 1)].ptr; } void gc() { WClass *wclass; WObject obj; uint32 i, j; // mark objects on vm stack for (i = 0; i < vmStackPtr; i++) if (VALID_OBJ(vmStack[i].obj)) markObject(vmStack[i].obj); // mark objects on native stack for (i = 0; i < nmStackPtr; i++) if (VALID_OBJ(nmStack[i])) markObject(nmStack[i]); // mark all static class objects for (i = 0; i < CLASS_HASH_SIZE; i++) { wclass = classHashList[i]; while (wclass != NULL) { for (j = 0; j < wclass->numFields; j++) { WClassField *field; field = &wclass->fields[j]; if (!FIELD_isStatic(field)) continue; obj = field->var.staticVar.obj; if (VALID_OBJ(obj)) markObject(obj); } wclass = wclass->nextClass; } } sweep(); #ifdef DEBUGMEMSIZE debugMemSize(); #endif } --- NEW FILE: memory.h --- /* * $Id: memory.h,v 1.1 2004/12/20 23:24:50 mriem Exp $ * * Copyright (c) 2001, 2002, 2003, Waba @ Sourceforge. * Copyright (c) 1998, 1999, 2000, Wabasoft. * All Rights Reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * ---------------------------------------------------------------------------- * * Defines support for memory management. * * ---------------------------------------------------------------------------- */ #ifndef __MEMORY_H__ #define __MEMORY_H__ #define FIRST_OBJ 2244 typedef struct { Var *ptr; uint32 order; uint32 temp; } Hos; /* * NOTE: The total amount of memory used up at any given time in the heap is: * objectSize + ( numHandles * sizeof( Hos ) ) */ typedef struct { Hos *hos; /* handle, order and scan arrays (interlaced) */ uint32 numHandles; /* */ uint32 numFreeHandles; /* */ uchar *mem; /* */ uint32 memSize; /* total size of memory (including free) */ uint32 objectSize; /* size of all objects in heap */ } ObjectHeap; #endif --- NEW FILE: native.c --- /* * $Id: native.c,v 1.1 2004/12/20 23:24:50 mriem Exp $ * * Copyright (c) 2001, 2002, 2003, Waba @ Sourceforge. * Copyright (c) 1998, 1999, 2000, Wabasoft. * All Rights Reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "waba.h" #include "native.h" --- NEW FILE: native.h --- /* * $Id: native.h,v 1.1 2004/12/20 23:24:50 mriem Exp $ * * Copyright (c) 2001, 2002, 2003, Waba @ Sourceforge. * Copyright (c) 1998, 1999, 2000, Wabasoft. * All Rights Reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef __NATIVE_H__ #define __NATIVE_H__ #endif --- NEW FILE: nmwin32_a.c --- /* $Id: nmwin32_a.c,v 1.1 2004/12/20 23:24:50 mriem Exp $ Copyright (C) 1998, 1999, 2000 Wabasoft 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 of the License, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* all the needed include */ #include "../waba.h" // // type converters // #ifdef WITH_64BITS // get one 64 float value from buf and return it float64 getFloat64bits(uchar *buf) { float64HiLo fhl; fhl.ul.lo = getInt32( buf ); fhl.ul.hi = getInt32( buf + 4 ); return fhl.value; } // get one 64 float value from buf and return it int64 getInt64bits(uchar *buf) { int64HiLo ihl; ihl.ul.lo = getInt32( buf ); ihl.ul.hi = getInt32( buf + 4 ); return ihl.value; } #endif /* WITH_64BITS */ float32 getFloat32(uchar *buf) { uint32 i; float32 f; // we need to make sure we're aligned before casting i = ((uint32)buf[0] << 24) | ((uint32)buf[1] << 16) | ((uint32)buf[2] << 8) | (uint32)buf[3]; f = *((float32 *)&i); return f; } --- NEW FILE: nmwin32_a.h --- /* * $Id: nmwin32_a.h,v 1.1 2004/12/20 23:24:50 mriem Exp $ * * Copyright (c) 2001, 2002, 2003, Waba @ Sourceforge. * Copyright (c) 1998, 1999, 2000, Wabasoft. * All Rights Reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef __NMWIN32_A_H__ #define __NMWIN32_A_H__ #include <tchar.h> #include <windows.h> #include <stdlib.h> #ifndef WINCE #include <stdio.h> #include <fcntl.h> #include <conio.h> #endif #ifdef WINCE #include <winsock.h> #include <winnetwk.h> #endif #undef FREE_ON_EXIT #undef SECURE_CLASS_HEAP #define LOCK_CLASS_HEAP #define UNLOCK_CLASS_HEAP #define uchar unsigned char #define int32 int #define uint32 unsigned int #define float32 float #define int16 short #define uint16 unsigned short #ifdef WITH_64BITS // - int64 is a signed 64 bit value #define int64 __int64 //INT64 //long long // - uint64 is an unsigned 64 bit value #define uint64 unsigned __int64 //UINT64 //unsigned long long // - float64 is a signed 64 bit floating point value #define float64 double // --- define a struct for double and long support in two Var ... // ... the hi/lo decomposition typedef struct { uint32 lo; uint32 hi; } HiLoDoubleOrLong; //... for the double typedef union { float64 value; HiLoDoubleOrLong ul; } float64HiLo; //... for the long typedef union { int64 value; HiLoDoubleOrLong ul; } int64HiLo; #endif /* WITH_64BITS */ #define cprintf printf // // type converters // #define getUInt32(b) (uint32)( (uint32)((b)[0])<<24 | (uint32)((b)[1])<<16 | (uint32)((b)[2])<<8 | (uint32)((b)[3]) ) #define getUInt16(b) (uint16)(((b)[0]<<8)|(b)[1]) #define getInt32(b) (int32)( (uint32)((b)[0])<<24 | (uint32)((b)[1])<<16 | (uint32)((b)[2])<<8 | (uint32)((b)[3]) ) #define getInt16(b) (int16)(((b)[0]<<8)|(b)[1]) #ifdef WITH_64BITS // get one 64 float value from buf and return it float64 getFloat64bits(uchar *buf); // get one 64 float value from buf and return it int64 getInt64bits(uchar *buf); #endif /* WITH_64BITS */ float32 getFloat32(uchar *buf); // // x portability functions // // NOTE: The str, mem and malloc routines aren't documented in the reference // manuals for CE, however, the methods do exist in the CE library and have // prototypes, etc. #define xstrncmp(s1, s2, n) strncmp(s1, s2, n) #define xstrncpy(dst, src, n) strncpy(dst, src, n) #define xstrlen(s) strlen(s) #define xstrcat(dst, src) strcat(dst, src) #define xmemmove(dst, src, size) memmove(dst, src, size) #define xmemzero(mem, len) memset(mem, 0, len) #define xmalloc(size) malloc(size); #define xfree(ptr) free(ptr) #endif /* __NMWIN32_A_H__ */ --- NEW FILE: nmwin32_b.c --- /* $Id: nmwin32_b.c,v 1.1 2004/12/20 23:24:50 mriem Exp $ Copyright (C) 1998, 1999, 2000 Wabasoft 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 of the License, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* all the needed include */ #include "../waba.h" [...1705 lines suppressed...] FILE *fp; AllocConsole(); GetConsoleScreenBufferInfo( GetStdHandle( STD_OUTPUT_HANDLE ), &coninfo ); coninfo.dwSize.Y = 500; SetConsoleScreenBufferSize( GetStdHandle( STD_OUTPUT_HANDLE ), coninfo.dwSize ); lStdHandle = (long) GetStdHandle( STD_OUTPUT_HANDLE ); hConHandle = _open_osfhandle( lStdHandle, _O_TEXT ); fp = _fdopen( hConHandle, "w" ); *stdout = *fp; setvbuf( stdout, NULL, _IONBF, 0 ); #endif } --- NEW FILE: nmwin32_b.h --- /* $Id: nmwin32_b.h,v 1.1 2004/12/20 23:24:50 mriem Exp $ */ #ifndef __NMWIN32_B_H__ #define __NMWIN32_B_H__ /* Copyright (C) 1998, 1999, 2000 Wabasoft 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 of the License, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ static int g_mainWinWidth = 0; static int g_mainWinHeight = 0; static DWORD g_startTime = 0; static DWORD g_messageTime = 0; static HINSTANCE g_hInstance; static TCHAR *pszWndClassName = TEXT("WabaWndClass"); #define WARP_CORE_PATH "\\Program Files\\waba\\waba.wrp" #define MAX_CLASSPATHS 20 static int numClassPaths = -1; static char *classPaths[MAX_CLASSPATHS]; typedef struct { HANDLE fileH; HANDLE mapH; int viewIsMapped; uchar *ptr; } MemFile; #define MAX_MEM_FILES 16 static MemFile memFiles[MAX_MEM_FILES]; static uint32 numMemFiles = 0; static int memFileNotSupported = 0; static int win32WSAStarted = 0; #ifdef QUICKBIND static int32 postPaintMethodMapNum = -1; static int32 postEventMethodMapNum = -1; static int32 onTimerTickMethodMapNum = -1; #endif int asciiToUnicode(char *src, TCHAR *dst, int max); WObject createStringFromUnicode(TCHAR *s, uint32 len); uchar *loadFromMem(char *path, uint32 pathLen, uint32 *size); uchar *readFileIntoMemory(char *path, int nullTerminate, uint32 *size); int32 getTimeStamp(); void dumpStackTrace(); uchar *nativeLoadClass(UtfString className, uint32 *size); #ifdef WITH_THREAD //*** Monaka's Multithread implemantasion //*** based on Isao's Multithread implementation #define THREAD_LIST_MAX_SIZE 8 typedef struct _queue { struct _queue *next; struct _queue *prev; } Queue; typedef struct { //Use either "syncObj" or "syncMethod", //Not both at the same time. WObject syncObj; WClassMethod* syncMethod; #ifdef WITH_THREAD_NATIVE CRITICAL_SECTION syncLock; #endif } WSync; typedef struct { WObject signalObj; #ifdef WITH_THREAD_NATIVE HANDLE signalHandle; #endif } WSignal; //This trick is necessary for Win32 native threads. typedef struct { WClass* vclass; WClassMethod* method; Var params[7]; uint32 paramSize; } WVmParam; typedef struct { Queue queue; /* 'Queue' must be first to use type cast trick. */ WClass* tClass; WObject tObject; //Since I don't know how to override: //"java.Object.wait()", //"java.Object.notify()", and //"java.Object.notifyAll()" //witout getting a JDK 1.2.2 compiler error, //I have coded so that "Thread" class handles the synchronization. //Someone who can handle this, any help wl be appreciated. WSync wSyncObj; WSignal wSignal; int32 runMethodMapNum; uint32 sleepCountSet; uint32 sleepCountNow; uchar isSleepCountAlreadySet; uchar isWaiting; //This trick is necessary for Win32 native threads. #ifdef WITH_THREAD_NATIVE WVmParam wParams; HANDLE wThreadHandle; DWORD wThreadID; #endif } WThread; extern int InitThread(uint32 stack_size); //*** This "ThreadStart()" method is called from "start()" method. extern Var ThreadStart(Var stack[]); //*** This "ThreadStop()" method is called from "stop()" method. extern Var ThreadStop(Var stack[]); void ThreadDestroy(WObject targetObj); //*** This "ThreadSleep()" method is called from "sleep()" method. extern Var ThreadSleep(Var stack[]); //*** This "ThreadWaitForSignal()" method is called from "waitForSignal()" method. extern Var ThreadWaitForSignal(Var stack[]); extern Var ThreadSignalAll(Var stack[]); //*** Isao's Multithread implementation END *** //*** This "ThreadCurrentThread()" method is called from "curentThread()" method. extern Var ThreadCurrentThread(Var stack[]); void tickThread(void); int registerAsSyncronized(WClassMethod* method); void exitFromSyncronized(WClassMethod* method); int enterMonitor(WObject obj); int exitMonitor(WObject obj); #ifdef WITH_DOUBLE_BUFFER void setMainWinObj(WObject winObj); WObject getMainWinObj(void); WObject theMainWinObj; #endif #endif /* WITH_THREAD */ #endif /* __NMWIN32_B_H__ */ --- NEW FILE: nmwin32_c.c --- /* $Id: nmwin32_c.c,v 1.1 2004/12/20 23:24:50 mriem Exp $ Copyright (C) 1998, 1999, 2000 Wabasoft 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 of the License, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ // NOTE: General rule for native functions.. don't hold a pointer across any // call that could garbage collect. For example, this is bad: [...3881 lines suppressed...] NULL); WriteFile(hCout, str.str, str.len, &cbWritten, NULL); CloseHandle(hCout); return v; } #ifdef WIN32 Var SystemInit( Var stack[] ) { Var v; printf( "SystemInit\n" ); v.obj = 0; return v; } #endif --- NEW FILE: nmwin32_c.h --- /* $Id: nmwin32_c.h,v 1.1 2004/12/20 23:24:50 mriem Exp $ */ #ifndef __NMWIN32_C_H__ #define __NMWIN32_C_H__ /* Copyright (C) 1998, 1999, 2000 Wabasoft 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 of the License, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifdef WITH_DOUBLE_BUFFER HBITMAP hMainScrBitmap; HBITMAP hOffScrBitmap; HDC hMainScrDC; HDC hOffScrDC; HWND hMainWnd; int mainWinWidth, mainWinHeight; HDC createOffScreenBuffer(WObject winObj); void deleteOffScreenBuffer(void); void paint(void); #endif //*** Isao's internationalization stuff START *** //static HFONT createWin32Font(WObject font, HDC hDC); static HFONT createWin32Font(WObject font); //*** Isao's internationalization stuff END *** static void WindowDestroy(WObject obj); static void MainWinDestroy(WObject obj); static void GraphicsDestroy(WObject obj); static void ImageDestroy(WObject obj); #if WITH_CATALOG static void CatalogDestroy(WObject obj); #endif static void FileDestroy(WObject obj); static void SocketDestroy(WObject obj); static void SerialPortDestroy(WObject obj); extern ClassHook classHooks[]; #define FUNC(f) extern Var f (Var stack[]) /* some generic functions */ FUNC(Return0Func); FUNC(ReturnNeg1Func); /* all the native functions */ FUNC(VmPrintLn); FUNC(VmPrint); FUNC(VmExec); FUNC(VmGetTimeStamp); FUNC(copyArray); FUNC(VmExit); FUNC(VmSleep); FUNC(VmSetDeviceAutoOff); FUNC(VmGetUserName); FUNC(VmGetPlatform); FUNC(VmIsColor); FUNC(FileGetLength); FUNC(FileCreateDir); FUNC(FileReadBytes); FUNC(FileRename); FUNC(FileCreate); FUNC(FileWriteBytes); FUNC(FileListDir); FUNC(FileSeekWaba); FUNC(FileIsDir); FUNC(FileCloseWaba); FUNC(FileIsOpen); FUNC(FileDeleteWaba); FUNC(FileExists); FUNC(ImageCreate); FUNC(ImageFree); FUNC(ImageSetPixels); FUNC(ImageUseImagePalette); FUNC(ImageLoad); FUNC(SoundBeep); FUNC(SoundTone); FUNC(TimeCreate); FUNC(SocketCreate); FUNC(SocketRead); FUNC(SocketWrite); FUNC(SocketSetReadTimeout); FUNC(SocketClose); FUNC(SocketIsOpen); FUNC(WindowCreate); #if WITH_CATALOG FUNC(CatalogListCatalogs); FUNC(CatalogAddRecord); FUNC(CatalogSkipBytes); FUNC(CatalogCreate); FUNC(CatalogRead); FUNC(CatalogDeleteRecord); FUNC(CatalogSetRecordPos); FUNC(CatalogGetRecordSize); FUNC(CatalogResizeRecord); FUNC(CatalogWrite); FUNC(CatalogGetRecordCount); FUNC(CatalogClose); FUNC(CatalogIsOpen); FUNC(CatalogDelete); #endif //WITH_CATALOG FUNC(GraphicsCopyRect); FUNC(GraphicsClearClip); FUNC(GraphicsSetFont); FUNC(GraphicsSetDrawOp); FUNC(GraphicsSetClip); FUNC(GraphicsSetBackColor); FUNC(GraphicsSetColor); FUNC(GraphicsGetClip); FUNC(GraphicsFillRect); FUNC(GraphicsDrawLine); FUNC(GraphicsTranslate); FUNC(GraphicsDrawDots); FUNC(GraphicsDrawChars); FUNC(GraphicsCreate); FUNC(GraphicsDrawCursor); FUNC(GraphicsSetClip); FUNC(GraphicsFree); FUNC(GraphicsSetForeColor); FUNC(GraphicsSetTextColor); FUNC(GraphicsFillPolygon); FUNC(GraphicsDrawString); FUNC(ConvertStringToInt); FUNC(ConvertFloatToIntBitwise); FUNC(ConvertCharToString); FUNC(ConvertIntToFloatBitwise); FUNC(ConvertFloatToString); FUNC(ConvertDoubleToString); FUNC(ConvertIntToString); FUNC(ConvertLongToString); FUNC(ConvertBooleanToString); FUNC(SoundClipPlay); FUNC(PalmOsPrefSetPalmOsPref); FUNC(PalmOsPrefGetPalmOsPref); FUNC(MainWinCreate); FUNC(MainWinExit); FUNC(MainWinSetTimerInterval); #ifdef WITH_DOUBLE_BUFFER FUNC(MainWinPaint); #endif FUNC(SerialPortReadCheck); FUNC(SerialPortRead); FUNC(SerialPortWrite); FUNC(SerialPortSetReadTimeout); FUNC(SerialPortClose); FUNC(SerialPortSetFlowControl); FUNC(SerialPortIsOpen); FUNC(SerialPortCreate); FUNC(FontMetricsGetStringWidth); FUNC(FontMetricsGetCharWidth); FUNC(FontMetricsCreate); FUNC(FontMetricsGetCharArrayWidth); /* * Begin of J2ME compliant code. */ #ifdef WIN32 FUNC(SystemInit); #endif #endif /* __NMWIN32_C_H__ */ --- NEW FILE: opcodes.h --- /* * $Id: opcodes.h,v 1.1 2004/12/20 23:24:50 mriem Exp $ * * Copyright (c) 2001, 2002, 2003, Waba @ Sourceforge. * Copyright (c) 1998, 1999, 2000, Wabasoft. * All Rights Reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * ---------------------------------------------------------------------------- * * Defines all the opcodes known by the JVM. * * ---------------------------------------------------------------------------- */ #ifndef __OPCODES_H__ #define __OPCODES_H__ #define OP_nop 0 #define OP_aconst_null 1 #define OP_iconst_m1 2 #define OP_iconst_0 3 #define OP_iconst_1 4 #define OP_iconst_2 5 #define OP_iconst_3 6 #define OP_iconst_4 7 #define OP_iconst_5 8 #define OP_lconst_0 9 #define OP_lconst_1 10 #define OP_fconst_0 11 #define OP_fconst_1 12 #define OP_fconst_2 13 #define OP_dconst_0 14 #define OP_dconst_1 15 #define OP_bipush 16 #define OP_sipush 17 #define OP_ldc 18 #define OP_ldc_w 19 #define OP_ldc2_w 20 #define OP_iload 21 #define OP_lload 22 #define OP_fload 23 #define OP_dload 24 #define OP_aload 25 #define OP_iload_0 26 #define OP_iload_1 27 #define OP_iload_2 28 #define OP_iload_3 29 #define OP_lload_0 30 #define OP_lload_1 31 #define OP_lload_2 32 #define OP_lload_3 33 #define OP_fload_0 34 #define OP_fload_1 35 #define OP_fload_2 36 #define OP_fload_3 37 #define OP_dload_0 38 #define OP_dload_1 39 #define OP_dload_2 40 #define OP_dload_3 41 #define OP_aload_0 42 #define OP_aload_1 43 #define OP_aload_2 44 #define OP_aload_3 45 #define OP_iaload 46 #define OP_laload 47 #define OP_faload 48 #define OP_daload 49 #define OP_aaload 50 #define OP_baload 51 #define OP_caload 52 #define OP_saload 53 #define OP_istore 54 #define OP_lstore 55 #define OP_fstore 56 #define OP_dstore 57 #define OP_astore 58 #define OP_istore_0 59 #define OP_istore_1 60 #define OP_istore_2 61 #define OP_istore_3 62 #define OP_lstore_0 63 #define OP_lstore_1 64 #define OP_lstore_2 65 #define OP_lstore_3 66 #define OP_fstore_0 67 #define OP_fstore_1 68 #define OP_fstore_2 69 #define OP_fstore_3 70 #define OP_dstore_0 71 #define OP_dstore_1 72 #define OP_dstore_2 73 #define OP_dstore_3 74 #define OP_astore_0 75 #define OP_astore_1 76 #define OP_astore_2 77 #define OP_astore_3 78 #define OP_iastore 79 #define OP_lastore 80 #define OP_fastore 81 #define OP_dastore 82 #define OP_aastore 83 #define OP_bastore 84 #define OP_castore 85 #define OP_sastore 86 #define OP_pop 87 #define OP_pop2 88 #define OP_dup 89 #define OP_dup_x1 90 #define OP_dup_x2 91 #define OP_dup2 92 #define OP_dup2_x1 93 #define OP_dup2_x2 94 #define OP_swap 95 #define OP_iadd 96 #define OP_ladd 97 #define OP_fadd 98 #define OP_dadd 99 #define OP_isub 100 #define OP_lsub 101 #define OP_fsub 102 #define OP_dsub 103 #define OP_imul 104 #define OP_lmul 105 #define OP_fmul 106 #define OP_dmul 107 #define OP_idiv 108 #define OP_ldiv 109 #define OP_fdiv 110 #define OP_ddiv 111 #define OP_irem 112 #define OP_lrem 113 #define OP_frem 114 #define OP_drem 115 #define OP_ineg 116 #define OP_lneg 117 #define OP_fneg 118 #define OP_dneg 119 #define OP_ishl 120 #define OP_lshl 121 #define OP_ishr 122 #define OP_lshr 123 #define OP_iushr 124 #define OP_lushr 125 #define OP_iand 126 #define OP_land 127 #define OP_ior 128 #define OP_lor 129 #define OP_ixor 130 #define OP_lxor 131 #define OP_iinc 132 #define OP_i2l 133 #define OP_i2f 134 #define OP_i2d 135 #define OP_l2i 136 #define OP_l2f 137 #define OP_l2d 138 #define OP_f2i 139 #define OP_f2l 140 #define OP_f2d 141 #define OP_d2i 142 #define OP_d2l 143 #define OP_d2f 144 #define OP_i2b 145 #define OP_i2c 146 #define OP_i2s 147 #define OP_lcmp 148 #define OP_fcmpl 149 #define OP_fcmpg 150 #define OP_dcmpl 151 #define OP_dcmpg 152 #define OP_ifeq 153 #define OP_ifne 154 #define OP_iflt 155 #define OP_ifge 156 #define OP_ifgt 157 #define OP_ifle 158 #define OP_if_icmpeq 159 #define OP_if_icmpne 160 #define OP_if_icmplt 161 #define OP_if_icmpge 162 #define OP_if_icmpgt 163 #define OP_if_icmple 164 #define OP_if_acmpeq 165 #define OP_if_acmpne 166 #define OP_goto 167 #define OP_jsr 168 #define OP_ret 169 #define OP_tableswitch 170 #define OP_lookupswitch 171 #define OP_ireturn 172 #define OP_lreturn 173 #define OP_freturn 174 #define OP_dreturn 175 #define OP_areturn 176 #define OP_return 177 #define OP_getstatic 178 #define OP_putstatic 179 #define OP_getfield 180 #define OP_putfield 181 #define OP_invokevirtual 182 #define OP_invokespecial 183 #define OP_invokestatic 184 #define OP_invokeinterface 185 #define OP_new 187 #define OP_newarray 188 #define OP_anewarray 189 #define OP_arraylength 190 #define OP_athrow 191 #define OP_checkcast 192 #define OP_instanceof 193 #define OP_monitorenter 194 #define OP_monitorexit 195 #define OP_wide 196 #define OP_multianewarray 197 #define OP_ifnull 198 #define OP_ifnonnull 199 #define OP_goto_w 200 #define OP_jsr_w 201 #define OP_breakpoint 202 #endif --- NEW FILE: thread.h --- /* * $Id: thread.h,v 1.1 2004/12/20 23:24:50 mriem Exp $ * * Copyright (c) 2001, 2002, 2003, Waba @ Sourceforge. * Copyright (c) 1998, 1999, 2000, Wabasoft. * All Rights Reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * ---------------------------------------------------------------------------- * * Defines support for threads. * * ---------------------------------------------------------------------------- */ #ifndef __THREAD_H__ #define __THREAD_H__ #endif --- NEW FILE: types.h --- /* * $Id: types.h,v 1.1 2004/12/20 23:24:50 mriem Exp $ * * Copyright (c) 2001, 2002, 2003, Waba @ Sourceforge. * Copyright (c) 1998, 1999, 2000, Wabasoft. * All Rights Reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * ---------------------------------------------------------------------------- * * Defines the basic types used in the VM. * * ---------------------------------------------------------------------------- */ #ifndef __TYPES_H__ #define __TYPES_H__ #if defined(DOS) #include "dos/nmdos_a.h" #elif defined(LINUX) #include "linux/nm_linux_a.h" #elif defined(PALMOS) #include "palm/nmpalm_a.h" #elif defined(TOPPERS) #include "toppers/nmtoppers_a.h" #elif defined(WIN32) #include "nmwin32_a.h" #elif defined(WINCE) #include "win32/nmwin32_a.h" #endif #endif --- NEW FILE: waba.c --- /* * $Id: waba.c,v 1.1 2004/12/20 23:24:50 mriem Exp $ * * Copyright (c) 2001, 2002, 2003, Waba @ Sourceforge. * Copyright (C) 1998, 1999, 2000, Wabasoft. * All Rights Reserved. * * --------------------------------------------------------------------------- * * 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 of the * License, 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. * [...5445 lines suppressed...] stack++; } else if (pushReturnedValue == 2) { stack[0] = returnedValue; stack[1] = returnedValue2; stack += 2; } var = (Var *)vmStack[--vmStackPtr].refValue; pc = vmStack[--vmStackPtr].pc; wclass = (WClass *)vmStack[vmStackPtr - 1].refValue; method = (WClassMethod *)vmStack[vmStackPtr - 2].refValue; goto step; } /* * --END */ --- NEW FILE: waba.h --- /* * $Id: waba.h,v 1.1 2004/12/20 23:24:50 mriem Exp $ * * Copyright (c) 2001, 2002, 2003, Waba @ Sourceforge. * Copyright (c) 1998, 1999, 2000, Wabasoft. * All Rights Reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * -------------------------------------------------------------------------- * * "True words are not beautiful, beautiful words are not true. * The good are not argumentative, the argumentative are not good. * Knowers do not generalize, generalists do not know. * Sages do not accumulate anything but give everything to others, * having more the more they give. * The Way of heaven helps and does not harm. * The Way for humans is to act without contention." * * - Lao-tzu, Tao Te Ching circa 500 B.C. * * -------------------------------------------------------------------------- */ #ifndef __WABA_H__ #define __WABA_H__ #include "config.h" #include "types.h" #include "debug.h" #include "error.h" #include "exception.h" #include "opcodes.h" #include "constants.h" #include "thread.h" // // TYPES AND METHODS // // Access flags #define ACCESS_PUBLIC 0x0001 #define ACCESS_PRIVATE 0x0002 #define ACCESS_PROTECTED 0x0004 #define ACCESS_STATIC 0x0008 #define ACCESS_FINAL 0x0010 #define ACCESS_SYNCHRONIZED 0x0020 #define ACCESS_VOLATILE 0x0040 #define ACCESS_TRANSIENT 0x0080 #define ACCESS_NATIVE 0x0100 #define ACCESS_INTERFACE 0x0200 #define ACCESS_ABSTRACT 0x0400 // Constant Pool tags #define CONSTANT_Utf8 1 #define CONSTANT_Integer 3 #define CONSTANT_Float 4 #define CONSTANT_Long 5 #define CONSTANT_Double 6 #define CONSTANT_Class 7 #define CONSTANT_String 8 #define CONSTANT_Fieldref ... [truncated message content] |
|
From: Manfred R. <mr...@us...> - 2004-12-20 23:23:58
|
Update of /cvsroot/waba/waba/src/win32/c In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24101/c Removed Files: config.h constants.h debug.h error.c error.h exception.h memory.c memory.h native.c native.h nmwin32_a.c nmwin32_a.h nmwin32_b.c nmwin32_b.h nmwin32_c.c nmwin32_c.h opcodes.h thread.h types.h waba.c waba.h Log Message: Removed wrongly placed files --- config.h DELETED --- --- constants.h DELETED --- --- debug.h DELETED --- --- error.c DELETED --- --- error.h DELETED --- --- exception.h DELETED --- --- memory.c DELETED --- --- memory.h DELETED --- --- native.c DELETED --- --- native.h DELETED --- --- nmwin32_a.c DELETED --- --- nmwin32_a.h DELETED --- --- nmwin32_b.c DELETED --- --- nmwin32_b.h DELETED --- --- nmwin32_c.c DELETED --- --- nmwin32_c.h DELETED --- --- opcodes.h DELETED --- --- thread.h DELETED --- --- types.h DELETED --- --- waba.c DELETED --- --- waba.h DELETED --- |
|
From: Manfred R. <mr...@us...> - 2004-12-20 23:21:29
|
Update of /cvsroot/waba/waba/src/port/c In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23656 Removed Files: nmport_a.c nmport_a.h nmport_b.c nmport_b.h nmport_c.c nmport_c.h Log Message: Removed generic port files --- nmport_a.c DELETED --- --- nmport_a.h DELETED --- --- nmport_b.c DELETED --- --- nmport_b.h DELETED --- --- nmport_c.c DELETED --- --- nmport_c.h DELETED --- |
|
From: Manfred R. <mr...@us...> - 2004-12-11 17:39:30
|
Update of /cvsroot/waba/waba/src/share/classes/waba/samples/helloworld In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15215/waba/samples/helloworld Added Files: HelloWorld.java HelloWorldAWT.form HelloWorldAWT.java HelloWorldApplet.java Log Message: Added some rudimentary samples --- NEW FILE: HelloWorld.java --- /* * $Id: HelloWorld.java,v 1.1 2004/12/11 17:39:21 mriem Exp $ * * Copyright (c) 2004 Waba @ Sourceforge. All Rights Reserved. */ package waba.samples.helloworld; /** * A simple Hello World application. <p> * * @author Manfred N. Riem (mr...@us...) * @version $Revision: 1.1 $ */ public class HelloWorld { /** * Main method. * * @param arguments the command line arguments */ public static void main(String[] arguments) { System.out.println("Hello World"); System.exit(0); } } --- NEW FILE: HelloWorldAWT.form --- <?xml version="1.0" encoding="UTF-8" ?> <Form version="1.0" type="org.netbeans.modules.form.forminfo.FrameFormInfo"> <SyntheticProperties> <SyntheticProperty name="formSizePolicy" type="int" value="1"/> </SyntheticProperties> <Events> <EventHandler event="windowClosing" listener="java.awt.event.WindowListener" parameters="java.awt.event.WindowEvent" handler="exitForm"/> </Events> <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> </Form> --- NEW FILE: HelloWorldAWT.java --- /* * $Id: HelloWorldAWT.java,v 1.1 2004/12/11 17:39:21 mriem Exp $ * * Copyright (c) 2004 Waba @ Sourceforge. All Rights Reserved */ package waba.samples.helloworld; /** * A Hello World application in AWT. <p> * * @author Manfred N. Riem (mr...@us...) * @version $Revision: 1.1 $ */ public class HelloWorldAWT extends java.awt.Frame { /** * Constructor. <p> */ public HelloWorldAWT() { initComponents(); } /** * Initializes the components. <p> */ private void initComponents() {//GEN-BEGIN:initComponents addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent evt) { exitForm(evt); } }); pack(); }//GEN-END:initComponents /** * Exit the Application */ private void exitForm(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_exitForm System.exit(0); }//GEN-LAST:event_exitForm /** * @param arguments the command line arguments */ public static void main(String args[]) { new HelloWorldAWT().show(); } // Variables declaration - do not modify//GEN-BEGIN:variables // End of variables declaration//GEN-END:variables } --- NEW FILE: HelloWorldApplet.java --- /* * $Id: HelloWorldApplet.java,v 1.1 2004/12/11 17:39:21 mriem Exp $ * * Copyright (c) 2004 Waba @ Sourceforge. All Rights Reserved. */ package waba.samples.helloworld; /** * @author Manfred N. Riem (mr...@us...) * @version $Revision: 1.1 $ */ public class HelloWorldApplet extends java.applet.Applet { /** * Initializes the applet. <p> */ public void init() { } } |
|
From: Manfred R. <mr...@us...> - 2004-12-11 17:38:57
|
Update of /cvsroot/waba/waba/src/share/classes/waba/samples/helloworld In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15053/helloworld Log Message: Directory /cvsroot/waba/waba/src/share/classes/waba/samples/helloworld added to the repository |
|
From: Manfred R. <mr...@us...> - 2004-12-11 17:38:51
|
Update of /cvsroot/waba/waba/src/share/classes/waba/samples In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15022/samples Log Message: Directory /cvsroot/waba/waba/src/share/classes/waba/samples added to the repository |
|
From: Manfred R. <mr...@us...> - 2004-07-10 19:01:26
|
Update of /cvsroot/waba/waba/src/win32/c In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12274 Added Files: config.h constants.h debug.h error.c error.h exception.h memory.c memory.h native.c native.h opcodes.h thread.h types.h waba.h waba.c Log Message: Copied shared code to win32\c directory to sort out the details and cleanup on code. --- NEW FILE: config.h --- /* * $Id: config.h,v 1.1 2004/07/10 19:01:14 mriem Exp $ * * Copyright (c) 2001, 2002, 2003, Waba @ Sourceforge. * Copyright (c) 1998, 1999, 2000, Wabasoft. * All Rights Reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * ---------------------------------------------------------------------------- * * Defines all the configuration for the VM * * ---------------------------------------------------------------------------- */ #ifndef __CONFIG_H__ #define __CONFIG_H__ /* * Which OS */ // #define PALMOS 1 // #define WINCE 1 // #define WIN32 1 /* * Memory options */ #define QUICKBIND 1 #define SANITYCHECK 1 #define SECURE_CLASS_HEAP 1 #define SMALLMEM 1 /* * With classic Waba support */ #define WITH_WABA 1 #define WITH_CATALOG 1 #define WITH_CATALOG_CLASS 1 #define WITH_DOUBLE_BUFFER 1 #define WITH_FILE_CLASS 1 #define WITH_FONTMETRICS_CLASS 1 #define WITH_GRAPHICS_CLASS 1 #define WITH_GUI_CLASS 1 #define WITH_SERIALPORT_CLASS 1 #define WITH_SOCKET_CLASS 1 #define WITH_SOUNDCLIP_CLASS 1 /* * With Waba extension support */ // #define WITH_SMARTDATA_CLASSES 1 /* * With thread support */ #define WITH_THREAD 1 #define WITH_THREAD_NATIVE 1 /* * With 64 bits support */ #define WITH_64BITS 1 #endif --- NEW FILE: constants.h --- /* * $Id: constants.h,v 1.1 2004/07/10 19:01:14 mriem Exp $ * * Copyright (c) 2001, 2002, 2003, Waba @ Sourceforge. * Copyright (c) 1998, 1999, 2000, Wabasoft. * All Rights Reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef __CONSTANTS_H__ #define __CONSTANTS_H__ /* * Waba classic key constants. */ #define WABA_KEY_PAGE_UP 75000 #define WABA_KEY_PAGE_DOWN 75001 #define WABA_KEY_HOME 75002 #define WABA_KEY_END 75003 #define WABA_KEY_UP 75004 #define WABA_KEY_DOWN 75005 #define WABA_KEY_LEFT 75006 #define WABA_KEY_RIGHT 75007 #define WABA_KEY_INSERT 75008 #define WABA_KEY_ENTER 75009 #define WABA_KEY_TAB 75010 #define WABA_KEY_BACKSPACE 75011 #define WABA_KEY_ESCAPE 75012 #define WABA_KEY_DELETE 75013 #define WABA_KEY_MENU 75014 #define WABA_KEY_COMMAND 75015 /* * Waba classic event constants. */ #define WABA_EVENT_KEY_PRESS 100 #define WABA_EVENT_PEN_DOWN 200 #define WABA_EVENT_PEN_MOVE 201 #define WABA_EVENT_PEN_UP 202 #define WABA_EVENT_PEN_DRAG 203 #endif --- NEW FILE: debug.h --- /* * $Id: debug.h,v 1.1 2004/07/10 19:01:14 mriem Exp $ * * Copyright (c) 2001, 2002, 2003, Waba @ Sourceforge. * Copyright (c) 1998, 1999, 2000, Wabasoft. * All Rights Reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * ---------------------------------------------------------------------------- * * Defines support for debugging. * * ---------------------------------------------------------------------------- */ #ifndef __DEBUG_H__ #define __DEBUG_H__ #ifdef DEBUG_OPCODE #define OP_MAX_OP 202 static char * _OP_name [] = { "OP_nop", "OP_aconst_null", "OP_iconst_m1", "OP_iconst_0", "OP_iconst_1", "OP_iconst_2", "OP_iconst_3", "OP_iconst_4", "OP_iconst_5", "OP_lconst_0", "OP_lconst_1", "OP_fconst_0", "OP_fconst_1", "OP_fconst_2", "OP_dconst_0", "OP_dconst_1", "OP_bipush", "OP_sipush", "OP_ldc", "OP_ldc_w", "OP_ldc2_w", "OP_iload", "OP_lload", "OP_fload", "OP_dload", "OP_aload", "OP_iload_0", "OP_iload_1", "OP_iload_2", "OP_iload_3", "OP_lload_0", "OP_lload_1", "OP_lload_2", "OP_lload_3", "OP_fload_0", "OP_fload_1", "OP_fload_2", "OP_fload_3", "OP_dload_0", "OP_dload_1", "OP_dload_2", "OP_dload_3", "OP_aload_0", "OP_aload_1", "OP_aload_2", "OP_aload_3", "OP_iaload", "OP_laload", "OP_faload", "OP_daload", "OP_aaload", "OP_baload", "OP_caload", "OP_saload", "OP_istore", "OP_lstore", "OP_fstore", "OP_dstore", "OP_astore", "OP_istore_0", "OP_istore_1", "OP_istore_2", "OP_istore_3", "OP_lstore_0", "OP_lstore_1", "OP_lstore_2", "OP_lstore_3", "OP_fstore_0", "OP_fstore_1", "OP_fstore_2", "OP_fstore_3", "OP_dstore_0", "OP_dstore_1", "OP_dstore_2", "OP_dstore_3", "OP_astore_0", "OP_astore_1", "OP_astore_2", "OP_astore_3", "OP_iastore", "OP_lastore", "OP_fastore", "OP_dastore", "OP_aastore", "OP_bastore", "OP_castore", "OP_sastore", "OP_pop", "OP_pop2", "OP_dup", "OP_dup_x1", "OP_dup_x2", "OP_dup2", "OP_dup2_x1", "OP_dup2_x2", "OP_swap", "OP_iadd", "OP_ladd", "OP_fadd", "OP_dadd", "OP_isub", "OP_lsub", "OP_fsub", "OP_dsub", "OP_imul", "OP_lmul", "OP_fmul", "OP_dmul", "OP_idiv", "OP_ldiv", "OP_fdiv", "OP_ddiv", "OP_irem", "OP_lrem", "OP_frem", "OP_drem", "OP_ineg", "OP_lneg", "OP_fneg", "OP_dneg", "OP_ishl", "OP_lshl", "OP_ishr", "OP_lshr", "OP_iushr", "OP_lushr", "OP_iand", "OP_land", "OP_ior", "OP_lor", "OP_ixor", "OP_lxor", "OP_iinc", "OP_i2l", "OP_i2f", "OP_i2d", "OP_l2i", "OP_l2f", "OP_l2d", "OP_f2i", "OP_f2l", "OP_f2d", "OP_d2i", "OP_d2l", "OP_d2f", "OP_i2b", "OP_i2c", "OP_i2s", "OP_lcmp", "OP_fcmpl", "OP_fcmpg", "OP_dcmpl", "OP_dcmpg", "OP_ifeq", "OP_ifne", "OP_iflt", "OP_ifge", "OP_ifgt", "OP_ifle", "OP_if_icmpeq", "OP_if_icmpne", "OP_if_icmplt", "OP_if_icmpge", "OP_if_icmpgt", "OP_if_icmple", "OP_if_acmpeq", "OP_if_acmpne", "OP_goto", "OP_jsr", "OP_ret", "OP_tableswitch", "OP_lookupswitch", "OP_ireturn", "OP_lreturn", "OP_freturn", "OP_dreturn", "OP_areturn", "OP_return", "OP_getstatic", "OP_putstatic", "OP_getfield", "OP_putfield", "OP_invokevirtual", "OP_invokespecial", "OP_invokestatic", "OP_invokeinterface", "OP_new", "OP_newarray", "OP_anewarray", "OP_arraylength", "OP_athrow", "OP_checkcast", "OP_instanceof", "OP_monitorenter", "OP_monitorexit", "OP_wide", "OP_multianewarray", "OP_ifnull", "OP_ifnonnull", "OP_goto_w", "OP_jsr_w", "OP_breakpoint" }; #endif #endif --- NEW FILE: error.c --- /* * $Id: error.c,v 1.1 2004/07/10 19:01:14 mriem Exp $ * * Copyright (c) 2001, 2002, 2003, Waba @ Sourceforge. * Copyright (c) 1998, 1999, 2000, Wabasoft. * All Rights Reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * ---------------------------------------------------------------------------- * * Implements support for errors. * * ---------------------------------------------------------------------------- */ #include "waba.h" #include "error.h" void VmError( uint16 errNum, WClass *iclass, UtfString *desc1, UtfString *desc2 ) { WClass *wclass; WClassMethod *method; UtfString className, iclassName, methodName, methodDesc; // NOTE: Don't overwrite an existing error since it may be the // root cause of this error. if (vmStatus.errNum != 0) return; vmStatus.errNum = errNum; // get current class and method off stack if (vmStackPtr > 0) { wclass = (WClass *)vmStack[vmStackPtr - 1].refValue; method = (WClassMethod *)vmStack[vmStackPtr - 2].refValue; } else { wclass = 0; method = 0; } // output class and method name if (wclass) { className = getUtfString(wclass, wclass->classNameIndex); printToBuf(vmStatus.className, 40, &className, NULL); } if (method) { methodName = getUtfString(wclass, METH_nameIndex(method)); methodDesc = getUtfString(wclass, METH_descIndex(method)); printToBuf(vmStatus.methodName, 40, &methodName, &methodDesc); } // output additional error arguments (target class, desc, etc.) if (iclass) { iclassName = getUtfString(iclass, iclass->classNameIndex); printToBuf(vmStatus.arg1, 40, &iclassName, NULL); } printToBuf(vmStatus.arg2, 40, desc1, desc2); #ifdef WIN32 #ifndef WINCE dumpStackTrace(); #endif #endif } void VmQuickError(uint16 errNum) { VmError( errNum, NULL, NULL, NULL ); } --- NEW FILE: error.h --- /* * $Id: error.h,v 1.1 2004/07/10 19:01:14 mriem Exp $ * * Copyright (c) 2001, 2002, 2003, Waba @ Sourceforge. * Copyright (c) 1998, 1999, 2000, Wabasoft. * All Rights Reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * ---------------------------------------------------------------------------- * * Defines support for errors. * * ---------------------------------------------------------------------------- */ #ifndef __ERROR_H__ #define __ERROR_H__ /* * Error messages */ static char *errorMessages[] = { "sanity", "incompatible device", "can't access waba classes", "can't access app classes", "can't allocate memory", "out of class memory", "out of object memory", "native stack overflow", "native stack underflow", "stack overflow", "bad class", "bad opcode", "can't find class", "can't find method", "can't find field", "null object access", "null array access", "index out of range", "divide by zero", "bad class cast", "class too large" }; /* * Fatal errors */ #define ERR_SanityCheckFailed 1 #define ERR_IncompatibleDevice 2 #define ERR_CantAccessCoreClasses 3 #define ERR_CantAccessAppClasses 4 #define ERR_CantAllocateMemory 5 #define ERR_OutOfClassMem 6 #define ERR_OutOfObjectMem 7 #define ERR_NativeStackOverflow 8 #define ERR_NativeStackUnderflow 9 #define ERR_StackOverflow 10 /* * Program errors */ #define ERR_BadClass 11 #define ERR_BadOpcode 12 #define ERR_CantFindClass 13 #define ERR_CantFindMethod 14 #define ERR_CantFindField 15 #define ERR_NullObjectAccess 16 #define ERR_NullArrayAccess 17 #define ERR_IndexOutOfRange 18 #define ERR_DivideByZero 19 #define ERR_ClassCastException 20 #define ERR_ClassTooLarge 21 /* * Function prototypes * ------------------- * * NOTE: the function prototypes should be enabled here once we have finished * cleaning up interdepencies. * * void VmError( uint16 errNum, * WClass *iclass, * UtfString *desc1, * UtfString *desc2); * * void VmQuickError( uint16 errNum ); */ #endif --- NEW FILE: exception.h --- /* * $Id: exception.h,v 1.1 2004/07/10 19:01:14 mriem Exp $ * * Copyright (c) 2001, 2002, 2003, Waba @ Sourceforge. * Copyright (c) 1998, 1999, 2000, Wabasoft. * All Rights Reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * ---------------------------------------------------------------------------- * * Defines the exception support in the VM. * * ---------------------------------------------------------------------------- */ #ifndef __EXCEPTION_H__ #define __EXCEPTION_H__ #endif --- NEW FILE: memory.c --- /* * $Id: memory.c,v 1.1 2004/07/10 19:01:14 mriem Exp $ * * Copyright (c) 2001, 2002, 2003, Waba @ Sourceforge. * Copyright (c) 1998, 1999, 2000, Wabasoft. * All Rights Reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * ---------------------------------------------------------------------------- * * Memory Management * ----------------- * * Here's the garbage collector. I implemented the mark and sweep below after * testing out a few different ones and reading: * * Garbage Collection, Algorithms for Automatic Dynamic Memory Management * by Richard Jones and Rafael Lins * * which is an excellent book. Also, this collector has gone through a lot of * testing. It runs when the system is completely out of memory which can * happen at any time ... for example during class loading. * * To test it out, tests were run where 1000's of random objects were loaded, * constructed and random methods called on them over some period of days. * This found a couple subtle bugs that were fixed like when the garbage * collector ran in the middle of array allocation and moved pointers around * from under the array allocator code ( those have all been fixed ). * * The heap is comprised of Hos objects (an array) that grows from the * "right" of object memory and objects that take up the space on on the * "left" side. The Hos array keeps track of where the objects are on the * left. * * The Hos structure (strange, but aptly named) is used to keep track of * handles (pointers to memory locations), order (order of handles with * respect to memory) and temporary items (used during the scan phase). * * The 3 items in the Hos structure do not relate to each other. They are * each a part of 3 conceptually distinct arrays that grow from the right of * the heap while the objects grow from the left. So, when the Hos array is * indexed, it is always negative (first element is 0, next is -1, next * is -2, etc). * * ---------------------------------------------------------------------------- */ #include "waba.h" #include "memory.h" /* * The heap with objects. */ static ObjectHeap heap; #define VALID_OBJ(o) (o > FIRST_OBJ && o <= FIRST_OBJ + heap.numHandles) // mark bits in the handle order array since it is not used during // the mark object process (its used in the sweep phase) #define MARK(o) heap.hos[- (int32)(o - FIRST_OBJ - 1)].order |= 0x80000000 #define IS_MARKED(o) (heap.hos[- (int32)(o - FIRST_OBJ - 1)].order & 0x80000000) /* * NOTE: There are no waba methods that are called when objects are destroyed. * This is because if a method was called, the object would be on its * way to being GC'd and if we set another object (or static field) to * reference it, after the GC, the reference would be stale. */ void sweep() { WObject obj; WClass *wclass; uint32 i, h, objSize, prevObjectSize, numUsedHandles; uchar *src, *dst; prevObjectSize = heap.objectSize; heap.objectSize = 0; // move all the marks over into the scan array so we don't have // to do lots of bit shifting for (i = 0; i < heap.numHandles; i++) { if (heap.hos[- (int32)i].order & 0x80000000) { heap.hos[- (int32)i].order &= 0x7FFFFFFF; // clear mark bit heap.hos[- (int32)i].temp = 1; } else { heap.hos[- (int32)i].temp = 0; } } numUsedHandles = 0; for (i = 0; i < heap.numHandles; i++) { // we need to scan in memory order so we can compact things without // copying objects over each other h = heap.hos[- (int32)i].order; obj = h + FIRST_OBJ + 1; if (!heap.hos[- (int32)h].temp) { // handle is free - dereference object if (objectPtr(obj) != NULL) { wclass = WOBJ_class(obj); // for non-arrays, call objDestroy if present if (wclass != NULL && wclass->objDestroyFunc) wclass->objDestroyFunc(obj); heap.hos[- (int32)h].ptr = NULL; } continue; } wclass = WOBJ_class(obj); if (wclass == NULL) objSize = arraySize(WOBJ_arrayType(obj), WOBJ_arrayLen(obj)); else objSize = WCLASS_objectSize(wclass); // copy object to new heap src = (uchar *)heap.hos[- (int32)h].ptr; dst = &heap.mem[heap.objectSize]; if (src != dst) // NOTE: overlapping regions need to copy correctly xmemmove(dst, src, objSize); heap.hos[- (int32)h].ptr = (Var *)dst; heap.hos[- (int32)numUsedHandles].order = h; heap.objectSize += objSize; numUsedHandles++; } heap.numFreeHandles = heap.numHandles - numUsedHandles; for (i = 0; i < heap.numHandles; i++) if (!heap.hos[- (int32)i].temp) { // add free handle to free section of order array heap.hos[- (int32)numUsedHandles].order = i; numUsedHandles++; } // zero out the part of the heap that is now junk xmemzero(&heap.mem[heap.objectSize], prevObjectSize - heap.objectSize); } /* * NOTE: this method is only for printing the status of memory and can be * removed. Also note, there is no such thing as the "amount of free * memory" because of garbage collection. */ uint32 getUnusedMem() { return heap.memSize - (heap.objectSize + (heap.numHandles * sizeof(Hos))); } int initObjectHeap(uint32 heapSize) { // NOTE: we must intiailize all the variables since after // a freeObjectHeap() we get called again heap.numHandles = 0; heap.numFreeHandles = 0; heap.memSize = heapSize; #if FIXED_OBJECT_HEAP_SIZE > 0 // align to 4 byte boundry for correct alignment of the Hos array heap.memSize = sizeof(objectHeapArea); // allocate and zero out memory region heap.mem = &objectHeapArea[0]; #else // align to 4 byte boundry for correct alignment of the Hos array heap.memSize = (heap.memSize + 3) & ~3; // allocate and zero out memory region heap.mem = (uchar *)xmalloc(heap.memSize); if (heap.mem == NULL) return -1; #endif xmemzero(heap.mem, heap.memSize); heap.hos = (Hos *)(&heap.mem[heap.memSize - sizeof(Hos)]); heap.objectSize = 0; return 0; } void freeObjectHeap() { #ifdef FREE_ON_EXIT { WObject obj; uint32 h; WClass *wclass; // call any native object destroy methods to free system resources for (h = 0; h < heap.numHandles; h++) { obj = h + FIRST_OBJ + 1; if (objectPtr(obj) != NULL) { wclass = WOBJ_class(obj); if (wclass != NULL && wclass->objDestroyFunc) wclass->objDestroyFunc(obj); } } } #endif #if FIXED_OBJECT_HEAP_SIZE <= 0 if (heap.mem) xfree(heap.mem); #endif } // mark this object and all the objects this object refers to and all // objects those objects refer to, etc. void markObject(WObject obj) { WClass *wclass; WObject *arrayStart, o; uint32 i, len, type, numScan; if (!VALID_OBJ(obj) || objectPtr(obj) == NULL || IS_MARKED(obj)) return; MARK(obj); numScan = 0; markinterior: wclass = WOBJ_class(obj); if (wclass == NULL) { // array - see if it contains object references type = WOBJ_arrayType(obj); if (type == 1 || type == 2) { // for an array of arrays or object array arrayStart = (WObject *)WOBJ_arrayStart(obj); len = WOBJ_arrayLen(obj); for (i = 0; i < len; i++) { o = arrayStart[i]; if (VALID_OBJ(o) && objectPtr(o) != NULL && !IS_MARKED(o)) { MARK(o); heap.hos[- (int32)numScan].temp = o; numScan++; } } } } else { // object len = wclass->numVars; for (i = 0; i < len; i++) { o = WOBJ_var(obj, i).obj; if (VALID_OBJ(o) && objectPtr(o) != NULL && !IS_MARKED(o)) { MARK(o); heap.hos[- (int32)numScan].temp = o; numScan++; } } } if (numScan > 0) { // Note: we use goto since we want to avoid recursion here // since structures like linked links could create deep // stack calls --numScan; obj = heap.hos[- (int32)numScan].temp; goto markinterior; } } // NOTE: size passed must be 4 byte aligned (see arraySize()) WObject allocObject(int32 size) { uint32 i, sizeReq, hosSize; if (size <= 0) return 0; sizeReq = size; if (!heap.numFreeHandles) sizeReq += sizeof(Hos); hosSize = heap.numHandles * sizeof(Hos); if (sizeReq + hosSize + heap.objectSize > heap.memSize) { gc(); // heap.objectSize changed or we are out of memory if (sizeReq + hosSize + heap.objectSize > heap.memSize) { VmQuickError(ERR_OutOfObjectMem); return 0; } } if (heap.numFreeHandles) { i = heap.hos[- (int32)(heap.numHandles - heap.numFreeHandles)].order; heap.numFreeHandles--; } else { // no free handles, get a new one i = heap.numHandles; heap.hos[- (int32)i].order = i; heap.numHandles++; } heap.hos[- (int32)i].ptr = (Var *)&heap.mem[heap.objectSize]; heap.objectSize += size; return FIRST_OBJ + i + 1; } // NOTE: we made this function a #define and it showed no real performance // gain over having it a function on either PalmOS or Windows when // optimization was turned on. Var *objectPtr(WObject obj) { return heap.hos[- (int32)(obj - FIRST_OBJ - 1)].ptr; } void gc() { WClass *wclass; WObject obj; uint32 i, j; // mark objects on vm stack for (i = 0; i < vmStackPtr; i++) if (VALID_OBJ(vmStack[i].obj)) markObject(vmStack[i].obj); // mark objects on native stack for (i = 0; i < nmStackPtr; i++) if (VALID_OBJ(nmStack[i])) markObject(nmStack[i]); // mark all static class objects for (i = 0; i < CLASS_HASH_SIZE; i++) { wclass = classHashList[i]; while (wclass != NULL) { for (j = 0; j < wclass->numFields; j++) { WClassField *field; field = &wclass->fields[j]; if (!FIELD_isStatic(field)) continue; obj = field->var.staticVar.obj; if (VALID_OBJ(obj)) markObject(obj); } wclass = wclass->nextClass; } } sweep(); #ifdef DEBUGMEMSIZE debugMemSize(); #endif } --- NEW FILE: memory.h --- /* * $Id: memory.h,v 1.1 2004/07/10 19:01:14 mriem Exp $ * * Copyright (c) 2001, 2002, 2003, Waba @ Sourceforge. * Copyright (c) 1998, 1999, 2000, Wabasoft. * All Rights Reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * ---------------------------------------------------------------------------- * * Defines support for memory management. * * ---------------------------------------------------------------------------- */ #ifndef __MEMORY_H__ #define __MEMORY_H__ #define FIRST_OBJ 2244 typedef struct { Var *ptr; uint32 order; uint32 temp; } Hos; /* * NOTE: The total amount of memory used up at any given time in the heap is: * objectSize + ( numHandles * sizeof( Hos ) ) */ typedef struct { Hos *hos; /* handle, order and scan arrays (interlaced) */ uint32 numHandles; /* */ uint32 numFreeHandles; /* */ uchar *mem; /* */ uint32 memSize; /* total size of memory (including free) */ uint32 objectSize; /* size of all objects in heap */ } ObjectHeap; #endif --- NEW FILE: native.c --- /* * $Id: native.c,v 1.1 2004/07/10 19:01:15 mriem Exp $ * * Copyright (c) 2001, 2002, 2003, Waba @ Sourceforge. * Copyright (c) 1998, 1999, 2000, Wabasoft. * All Rights Reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "waba.h" #include "native.h" --- NEW FILE: native.h --- /* * $Id: native.h,v 1.1 2004/07/10 19:01:15 mriem Exp $ * * Copyright (c) 2001, 2002, 2003, Waba @ Sourceforge. * Copyright (c) 1998, 1999, 2000, Wabasoft. * All Rights Reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef __NATIVE_H__ #define __NATIVE_H__ #endif --- NEW FILE: opcodes.h --- /* * $Id: opcodes.h,v 1.1 2004/07/10 19:01:15 mriem Exp $ * * Copyright (c) 2001, 2002, 2003, Waba @ Sourceforge. * Copyright (c) 1998, 1999, 2000, Wabasoft. * All Rights Reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * ---------------------------------------------------------------------------- * * Defines all the opcodes known by the JVM. * * ---------------------------------------------------------------------------- */ #ifndef __OPCODES_H__ #define __OPCODES_H__ #define OP_nop 0 #define OP_aconst_null 1 #define OP_iconst_m1 2 #define OP_iconst_0 3 #define OP_iconst_1 4 #define OP_iconst_2 5 #define OP_iconst_3 6 #define OP_iconst_4 7 #define OP_iconst_5 8 #define OP_lconst_0 9 #define OP_lconst_1 10 #define OP_fconst_0 11 #define OP_fconst_1 12 #define OP_fconst_2 13 #define OP_dconst_0 14 #define OP_dconst_1 15 #define OP_bipush 16 #define OP_sipush 17 #define OP_ldc 18 #define OP_ldc_w 19 #define OP_ldc2_w 20 #define OP_iload 21 #define OP_lload 22 #define OP_fload 23 #define OP_dload 24 #define OP_aload 25 #define OP_iload_0 26 #define OP_iload_1 27 #define OP_iload_2 28 #define OP_iload_3 29 #define OP_lload_0 30 #define OP_lload_1 31 #define OP_lload_2 32 #define OP_lload_3 33 #define OP_fload_0 34 #define OP_fload_1 35 #define OP_fload_2 36 #define OP_fload_3 37 #define OP_dload_0 38 #define OP_dload_1 39 #define OP_dload_2 40 #define OP_dload_3 41 #define OP_aload_0 42 #define OP_aload_1 43 #define OP_aload_2 44 #define OP_aload_3 45 #define OP_iaload 46 #define OP_laload 47 #define OP_faload 48 #define OP_daload 49 #define OP_aaload 50 #define OP_baload 51 #define OP_caload 52 #define OP_saload 53 #define OP_istore 54 #define OP_lstore 55 #define OP_fstore 56 #define OP_dstore 57 #define OP_astore 58 #define OP_istore_0 59 #define OP_istore_1 60 #define OP_istore_2 61 #define OP_istore_3 62 #define OP_lstore_0 63 #define OP_lstore_1 64 #define OP_lstore_2 65 #define OP_lstore_3 66 #define OP_fstore_0 67 #define OP_fstore_1 68 #define OP_fstore_2 69 #define OP_fstore_3 70 #define OP_dstore_0 71 #define OP_dstore_1 72 #define OP_dstore_2 73 #define OP_dstore_3 74 #define OP_astore_0 75 #define OP_astore_1 76 #define OP_astore_2 77 #define OP_astore_3 78 #define OP_iastore 79 #define OP_lastore 80 #define OP_fastore 81 #define OP_dastore 82 #define OP_aastore 83 #define OP_bastore 84 #define OP_castore 85 #define OP_sastore 86 #define OP_pop 87 #define OP_pop2 88 #define OP_dup 89 #define OP_dup_x1 90 #define OP_dup_x2 91 #define OP_dup2 92 #define OP_dup2_x1 93 #define OP_dup2_x2 94 #define OP_swap 95 #define OP_iadd 96 #define OP_ladd 97 #define OP_fadd 98 #define OP_dadd 99 #define OP_isub 100 #define OP_lsub 101 #define OP_fsub 102 #define OP_dsub 103 #define OP_imul 104 #define OP_lmul 105 #define OP_fmul 106 #define OP_dmul 107 #define OP_idiv 108 #define OP_ldiv 109 #define OP_fdiv 110 #define OP_ddiv 111 #define OP_irem 112 #define OP_lrem 113 #define OP_frem 114 #define OP_drem 115 #define OP_ineg 116 #define OP_lneg 117 #define OP_fneg 118 #define OP_dneg 119 #define OP_ishl 120 #define OP_lshl 121 #define OP_ishr 122 #define OP_lshr 123 #define OP_iushr 124 #define OP_lushr 125 #define OP_iand 126 #define OP_land 127 #define OP_ior 128 #define OP_lor 129 #define OP_ixor 130 #define OP_lxor 131 #define OP_iinc 132 #define OP_i2l 133 #define OP_i2f 134 #define OP_i2d 135 #define OP_l2i 136 #define OP_l2f 137 #define OP_l2d 138 #define OP_f2i 139 #define OP_f2l 140 #define OP_f2d 141 #define OP_d2i 142 #define OP_d2l 143 #define OP_d2f 144 #define OP_i2b 145 #define OP_i2c 146 #define OP_i2s 147 #define OP_lcmp 148 #define OP_fcmpl 149 #define OP_fcmpg 150 #define OP_dcmpl 151 #define OP_dcmpg 152 #define OP_ifeq 153 #define OP_ifne 154 #define OP_iflt 155 #define OP_ifge 156 #define OP_ifgt 157 #define OP_ifle 158 #define OP_if_icmpeq 159 #define OP_if_icmpne 160 #define OP_if_icmplt 161 #define OP_if_icmpge 162 #define OP_if_icmpgt 163 #define OP_if_icmple 164 #define OP_if_acmpeq 165 #define OP_if_acmpne 166 #define OP_goto 167 #define OP_jsr 168 #define OP_ret 169 #define OP_tableswitch 170 #define OP_lookupswitch 171 #define OP_ireturn 172 #define OP_lreturn 173 #define OP_freturn 174 #define OP_dreturn 175 #define OP_areturn 176 #define OP_return 177 #define OP_getstatic 178 #define OP_putstatic 179 #define OP_getfield 180 #define OP_putfield 181 #define OP_invokevirtual 182 #define OP_invokespecial 183 #define OP_invokestatic 184 #define OP_invokeinterface 185 #define OP_new 187 #define OP_newarray 188 #define OP_anewarray 189 #define OP_arraylength 190 #define OP_athrow 191 #define OP_checkcast 192 #define OP_instanceof 193 #define OP_monitorenter 194 #define OP_monitorexit 195 #define OP_wide 196 #define OP_multianewarray 197 #define OP_ifnull 198 #define OP_ifnonnull 199 #define OP_goto_w 200 #define OP_jsr_w 201 #define OP_breakpoint 202 #endif --- NEW FILE: thread.h --- /* * $Id: thread.h,v 1.1 2004/07/10 19:01:15 mriem Exp $ * * Copyright (c) 2001, 2002, 2003, Waba @ Sourceforge. * Copyright (c) 1998, 1999, 2000, Wabasoft. * All Rights Reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * ---------------------------------------------------------------------------- * * Defines support for threads. * * ---------------------------------------------------------------------------- */ #ifndef __THREAD_H__ #define __THREAD_H__ #endif --- NEW FILE: types.h --- /* * $Id: types.h,v 1.1 2004/07/10 19:01:15 mriem Exp $ * * Copyright (c) 2001, 2002, 2003, Waba @ Sourceforge. * Copyright (c) 1998, 1999, 2000, Wabasoft. * All Rights Reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * ---------------------------------------------------------------------------- * * Defines the basic types used in the VM. * * ---------------------------------------------------------------------------- */ #ifndef __TYPES_H__ #define __TYPES_H__ #if defined(DOS) #include "dos/nmdos_a.h" #elif defined(LINUX) #include "linux/nm_linux_a.h" #elif defined(PALMOS) #include "palm/nmpalm_a.h" #elif defined(TOPPERS) #include "toppers/nmtoppers_a.h" #elif defined(WIN32) #include "nmwin32_a.h" #elif defined(WINCE) #include "win32/nmwin32_a.h" #endif #endif --- NEW FILE: waba.h --- /* * $Id: waba.h,v 1.1 2004/07/10 19:01:15 mriem Exp $ * * Copyright (c) 2001, 2002, 2003, Waba @ Sourceforge. * Copyright (c) 1998, 1999, 2000, Wabasoft. * All Rights Reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * -------------------------------------------------------------------------- * * "True words are not beautiful, beautiful words are not true. * The good are not argumentative, the argumentative are not good. * Knowers do not generalize, generalists do not know. * Sages do not accumulate anything but give everything to others, * having more the more they give. * The Way of heaven helps and does not harm. * The Way for humans is to act without contention." * * - Lao-tzu, Tao Te Ching circa 500 B.C. * * -------------------------------------------------------------------------- */ #ifndef __WABA_H__ #define __WABA_H__ #include "config.h" #include "types.h" #include "debug.h" #include "error.h" #include "exception.h" #include "opcodes.h" #include "constants.h" #include "thread.h" // // TYPES AND METHODS // // Access flags #define ACCESS_PUBLIC 0x0001 #define ACCESS_PRIVATE 0x0002 #define ACCESS_PROTECTED 0x0004 #define ACCESS_STATIC 0x0008 #define ACCESS_FINAL 0x0010 #define ACCESS_SYNCHRONIZED 0x0020 #define ACCESS_VOLATILE 0x0040 #define ACCESS_TRANSIENT 0x0080 #define ACCESS_NATIVE 0x0100 #define ACCESS_INTERFACE 0x0200 #define ACCESS_ABSTRACT 0x0400 // Constant Pool tags #define CONSTANT_Utf8 1 #define CONSTANT_Integer 3 #define CONSTANT_Float 4 #define CONSTANT_Long 5 #define CONSTANT_Double 6 #define CONSTANT_Class 7 #define CONSTANT_String 8 #define CONSTANT_Fieldref 9 #define CONSTANT_Methodref 10 #define CONSTANT_InterfaceMethodref 11 #define CONSTANT_NameAndType 12 // flags for stringToUtf() #define STU_NULL_TERMINATE 1 #define STU_USE_STATIC 2 // // types and accessors // typedef uint32 WObject; typedef union { int32 intValue; float32 floatValue; void *classRef; uchar *pc; void *refValue; WObject obj; #ifdef WITH_64BITS // long/double support : comming from SuperWaba 2.0beta1 guich@200 // stored in two consecutive Var Lo first, Hi then int32 int64ValueHalf; int32 float64ValueHalf; #endif /* WITH_64BITS */ } Var; typedef Var (*NativeFunc)(Var stack[]); typedef void (*ObjDestroyFunc)(WObject obj); // // more types and accessors // #define WOBJ_class(o) (objectPtr(o))[0].classRef #define WOBJ_var(o, idx) (objectPtr(o))[idx + 1] // NOTE: These get various values in objects at defined offsets. // If the variables in the base classes change, these offsets will // need to be recomputed. For example, the first (StringCharArray) // get the character array var offset in a String object. #define WOBJ_StringCharArrayObj(o) (objectPtr(o))[1].obj #define WOBJ_StringBufferStrings(o) (objectPtr(o))[1].obj #define WOBJ_StringBufferCount(o) (objectPtr(o))[2].intValue #define WOBJ_arrayType(o) (objectPtr(o))[1].intValue #define WOBJ_arrayLen(o) (objectPtr(o))[2].intValue #define WOBJ_arrayStart(o) (&(objectPtr(o)[3])) // for faster access #define WOBJ_arrayTypeP(objPtr) (objPtr)[1].intValue #define WOBJ_arrayLenP(objPtr) (objPtr)[2].intValue #define WOBJ_arrayStartP(objPtr) (&(objPtr[3])) typedef struct UtfStringStruct { char *str; uint32 len; } UtfString; typedef union { // FieldVar is either a reference to a static class variable (staticVar) // or an offset of a local variable within an object (varOffset) Var staticVar; uint32 varOffset; // computed var offset in object } FieldVar; typedef struct WClassFieldStruct { uchar *header; FieldVar var; #ifdef WITH_64BITS FieldVar var2; // guich@200 - one more int32 to hold 64 bit values #endif /* WITH_64BITS */ } WClassField; #define FIELD_accessFlags(f) getUInt16(f->header) #define FIELD_nameIndex(f) getUInt16(&f->header[2]) #define FIELD_descIndex(f) getUInt16(&f->header[4]) #define FIELD_isStatic(f) ((FIELD_accessFlags(f) & ACCESS_STATIC) > 0) typedef union { // Code is either pointer to bytecode or pointer to native function // NOTE: If accessFlags(method) & ACCESS_NATIVE then nativeFunc // is set, otherwise codeAttr is set. Native methods don't have // maxStack, maxLocals so it is OK to merge the codeAttr w/nativeFunc. uchar *codeAttr; NativeFunc nativeFunc; } Code; typedef struct { uint16 count; uchar *table; } ExceptionTable; typedef struct WClassMethodStruct { uchar *header; Code code; ExceptionTable exception_table; /* If the method has no exception, value is NULL */ uint16 numParams:14; uint16 returnsValue:1; uint16 isInit:1; } WClassMethod; #define METH_accessFlags(m) getUInt16(m->header) #define METH_nameIndex(m) getUInt16(&m->header[2]) #define METH_descIndex(m) getUInt16(&m->header[4]) #define METH_maxStack(m) getUInt16(&m->code.codeAttr[6]) #define METH_maxLocals(m) getUInt16(&m->code.codeAttr[8]) #define METH_codeCount(m) getUInt32(&m->code.codeAttr[10]) #define METH_code(m) &m->code.codeAttr[14] #define CONS_offset(wc, idx) wc->constantOffsets[idx - 1] #define CONS_ptr(wc, idx) (wc->byteRep + CONS_offset(wc, idx)) #define CONS_tag(wc, idx) CONS_ptr(wc, idx)[0] #define CONS_utfLen(wc, idx) getUInt16(&CONS_ptr(wc, idx)[1]) #define CONS_utfStr(wc, idx) &CONS_ptr(wc, idx)[3] #define CONS_integer(wc, idx) getInt32(&CONS_ptr(wc, idx)[1]) #define CONS_float(wc, idx) getFloat32(&CONS_ptr(wc, idx)[1]) #define CONS_stringIndex(wc, idx) getUInt16(&CONS_ptr(wc, idx)[1]) #define CONS_classIndex(wc, idx) getUInt16(&CONS_ptr(wc, idx)[1]) #define CONS_nameAndTypeIndex(wc, idx) getUInt16(&CONS_ptr(wc, idx)[3]) #define CONS_nameIndex(wc, idx) getUInt16(&CONS_ptr(wc, idx)[1]) #define CONS_typeIndex(wc, idx) getUInt16(&CONS_ptr(wc, idx)[3]) #ifdef WITH_64BITS /* guich@200: added to handle 64bit numbers */ #define CONS_double(wc, idx) getFloat64bits(&CONS_ptr(wc, idx)[1]) #define CONS_long(wc, idx) getInt64bits(&CONS_ptr(wc, idx)[1]) /* end guich@200 modification */ #endif /* WITH_64BITS */ // The VM keeps an array of constant offsets for each constant in a class // in the runtime class structure (see WClassStruct). For each constant, // the offset is an offset from the start of the bytes defining the class. // Depdending on whether SMALLMEM is defined, the offset is either a 16 or // 32 bit quantity. So, if SMALLMEM is defined, the maximum offset is 2^16. // However, we also keep a bit in the constant to determine whether the // constant is an offset that is "bound" or not. So, the maximum value of // an offset if SMALLMEM is defined (the small memory model) is 32767. // // This means under the small memory model, the biggest class constant // pool we can have is 32K. Under the large memory model (SMALLMEM not // defined) the maximum class constant pool size that we could have is // 2^31 bytes. Using SMALLMEM can save quite a bit of memory since // constant pools tend to be large. // // When a constant offset is "bound", instead of the offset being // an offset into the constant pool, it is (with the exception of methods) // a pointer offset from the start of the class heap to the actual data // the constant refers to. // // For example, when a field constant is bound, it contains an offset // from the start of the class heap to the actual WClassField * structure // for the field. For class offsets, it is an offset to the WClass * // structure. For method offsets, the offset is a virtual method number // and class index. Only class, field and methods can be bound. // // A bound offset will only be bound if the offset of the actual structure // in the class heap is within the range that can fit in the offset. For // example, in a small memory model, if a WClassField * structure exists // beyond 32K from the start of the class heap, its offset can't be bound. // If that happens, the offset simply won't be bound and will retain // an offset into the constant pool (known now as an "adaptive bind"). // // Binding of constants (adaptive quickbind) will only be performed if // QUICKBIND is defined. When an offset is bound, it's CONS_boundBit // will be set to 1. #ifdef SMALLMEM typedef uint16 ConsOffset; #define MAX_consOffset 0x7FFF #define CONS_boundBit 0x8000 #define CONS_boundOffsetMask 0x7FFF // 1 bit for bound bit, 7 bits for method, 8 bits for class index #define MAX_boundMethodNum 127 #define MAX_boundClassIndex 255 #define CONS_boundMethodShift 8 #define CONS_boundClassMask 0xFF; #else typedef uint32 ConsOffset; #define MAX_consOffset 0x7FFFFFFF #define CONS_boundBit 0x80000000 #define CONS_boundOffsetMask 0x7FFFFFFF // 1 bit for bound bit, 15 bits for method, 16 bits for class index #define MAX_boundMethodNum 32767 #define MAX_boundClassIndex 65535 #define CONS_boundMethodShift 16 #define CONS_boundClassMask 0xFFFF; #endif #ifdef QUICKBIND typedef struct { uint16 classNum:6; uint16 methodNum:10; } VMapValue; #define MAX_superClassNum 63 #define MAX_methodNum 1023 typedef struct { VMapValue *mapValues; // maps virtual method number to class, virtual method index uint16 mapSize; // size of map = number of inherited methods uint16 numVirtualMethods; // number of new virtual methods in the class uint16 numOverriddenMethods; // number of overridden methods in the class } VirtualMethodMap; // search types for getMethodMapNum() #define SEARCH_METHOD_ALL 0 #define SEARCH_METHOD_INHERITED 1 #define SEARCH_METHOD_THISCLASS 2 // keep this a prime number for best distribution #define OVERRIDE_HASH_SIZE 127 #endif /* QUICKBIND */ // NOTE: In the following structure, a constant offset can either be // bound (by having boundBit set) in which case it is an offset into // the classHeap directly or unbound in which case it is an offset into // the byteRep of the class typedef struct WClassStruct { struct WClassStruct **superClasses; // array of this classes superclasses uint16 numSuperClasses; uint16 classNameIndex; uchar *byteRep; // pointer to class representation in memory (bytes) uchar *attrib2; // pointer to area after constant pool (accessFlags) uint16 numConstants; ConsOffset *constantOffsets; uint16 numFields; WClassField *fields; uint16 numMethods; WClassMethod *methods; #ifdef QUICKBIND VirtualMethodMap vMethodMap; #endif uint16 numVars; // computed number of object variables ObjDestroyFunc objDestroyFunc; struct WClassStruct *nextClass; // next class in hash table linked list } WClass; #define WCLASS_accessFlags(wc) getUInt16(wc->attrib2) #define WCLASS_thisClass(wc) getUInt16(&wc->attrib2[2]) #define WCLASS_superClass(wc) getUInt16(&wc->attrib2[4]) #define WCLASS_numInterfaces(wc) getUInt16(&wc->attrib2[6]) #define WCLASS_interfaceIndex(wc, idx) getUInt16(&wc->attrib2[8 + (idx * 2)]) #define WCLASS_objectSize(wc) ((wc->numVars + 1) * sizeof(Var)) #define WCLASS_isInterface(wc) ((WCLASS_accessFlags(wc) & ACCESS_INTERFACE) > 0) typedef struct { uint16 errNum; char className[40]; char methodName[40]; char arg1[40]; char arg2[40]; } ErrorStatus; // // private function prototypes // #ifdef WITH_THREAD_NATIVE CRITICAL_SECTION vmThreadLock; CRITICAL_SECTION nmThreadLock; Var* getVmStack(void); WObject* getNmStack(void); uint32 getVmStackSizeInBytes(void); uint32 getNmStackSizeInBytes(void); #endif void VmInit(uint32 vmStackSizeInBytes, uint32 nmStackSizeInBytes, uint32 classHeapSize, uint32 objectHeapSize); WObject VmStartApp(char *className); int VmStartApplication(char *className, int argc, char** argv); //SD void VmStopApp(WObject mainWinObj); void VmFree(); WClass *findLoadedClass(UtfString className); WClass *getClass(UtfString className); uchar *nativeLoadClass(UtfString className, uint32 *size); void freeClass(WClass *wclass); uchar *loadClassConstant(WClass *wclass, uint16 idx, uchar *p); uchar *loadClassField(WClass *wclass, WClassField *field, uchar *p); Var constantToVar(WClass *wclass, uint16 idx); uchar *loadClassMethod(WClass *wclass, WClassMethod *method, uchar *p); #ifdef QUICKBIND int createVirtualMethodMap(WClass *wclass); #endif UtfString createUtfString(char *buf); UtfString getUtfString(WClass *wclass, uint16 idx); WObject createObject(WClass *wclass); int32 arrayTypeSize(int32 type); int32 arraySize(int32 type, int32 len); WObject createArrayObject(int32 type, int32 len); uint16 arrayType(char c); WObject createMultiArray(int32 ndim, char *desc, Var *sizes); WObject createStringFromUtf(UtfString s); WObject createString(char *buf); UtfString stringToUtf(WObject str, int flags); int arrayRangeCheck(WObject array, int32 start, int32 count); Var copyArray(Var stack[]); WClassField *getField(WClass *wclass, UtfString name, UtfString desc); WClass *getClassByIndex(WClass *wclass, uint16 classIndex); #ifdef QUICKBIND int compareMethodNameDesc(WClass *wclass, uint16 mapNum, UtfString name, UtfString desc); int32 getMethodMapNum(WClass *wclass, UtfString name, UtfString desc, int searchType); WClassMethod *getMethodByMapNum(WClass *wclass, WClass **vclass, uint16 mapNum); #endif WClassMethod *getMethod(WClass *wclass, UtfString name, UtfString desc, WClass **vclass); int32 countMethodParams(UtfString desc); int compatible(WClass *wclass, WClass *target); int compatibleArray(WObject obj, UtfString arrayName); uint32 getUnusedMem(); int initObjectHeap(uint32 heapSize); void freeObjectHeap(); void markObject(WObject obj); void sweep(); void gc(); WObject allocObject(int32 size); Var *objectPtr(WObject obj); int pushObject(WObject obj); WObject popObject(); NativeFunc getNativeMethod(WClass *wclass, UtfString methodName, UtfString methodDesc); void setClassHooks(WClass *wclass); #ifdef WITH_THREAD_NATIVE DWORD WINAPI executeMethod(void* passedWParams); #else void executeMethod( WClass *wclass, WClassMethod *method, Var params[], uint32 numParams); #endif unsigned char * loadClassFrmJar(char * jar, char * classname, int * size); uint32 ucsToUc(uint16* ucsStr, uint16* ucStr, uint32 ucsStrSize); #ifdef WITH_64BITS // guich@200 - transforms 2 consecutive vars in one long // the first var stores the lower 32 bits and // the 2nd var stores the upper 32 bits of the double int64 vars2int64(Var *v); // guich@200 - transforms 2 consecutive vars in one double; // the first var stores the lower 32 bits and // the 2nd var stores the upper 32 bits of the double float64 vars2double(Var *v); #endif /* WITH_64BITS */ // // global vars // /* Main qualified class name */ char * mainClassName; #ifdef USE_VIRTUAL_KBD /* Flag indicating whether to open the virtual keyboard upon startup */ extern int withVirtualKeyboard; #endif /* USE_VIRTUAL_KBD */ extern int vmInitialized; extern int isApplication; // virtual machine stack extern Var *vmStack; extern uint32 vmStackSize; // in Var units extern uint32 vmStackPtr; // native method stack extern WObject *nmStack; extern uint32 nmStackSize; // in WObject units extern uint32 nmStackPtr; // keep these prime numbers for best distribution #ifdef SMALLMEM #define CLASS_HASH_SIZE 63 #else #define CLASS_HASH_SIZE 255 #endif // class heap extern uchar *classHeap; extern uint32 classHeapSize; extern uint32 classHeapUsed; extern WClass *classHashList[CLASS_HASH_SIZE]; // error status extern ErrorStatus vmStatus; // pointer to String class (for performance) extern WClass *stringClass; // // Native Methods and Hooks // typedef struct { char *className; ObjDestroyFunc destroyFunc; uint16 varsNeeded; } ClassHook; typedef struct { uint32 hash; NativeFunc func; } NativeMethod; #if defined(PALMOS) #include "palm/nmpalm_b.h" #include "palm/nmpalm_c.h" #elif defined(WIN32) #include "nmwin32_b.h" #include "nmwin32_c.h" #elif defined(WINCE) #include "win32/nmwin32_b.h" #include "win32/nmwin32_c.h" #elif defined(LINUX) #include "linux/nm_linux_b.h" #include "linux/nm_linux_c.h" #include "linux/debug.h" #elif defined(TOPPERS) #include "toppers/nmtoppers_b.h" #include "toppers/nmtoppers_c.h" #elif defined(DOS) #include "dos/nmdos_b.h" #include "dos/nmdos_c.h" #endif #endif --- NEW FILE: waba.c --- /* * $Id: waba.c,v 1.1 2004/07/10 19:01:15 mriem Exp $ * * Copyright (c) 2001, 2002, 2003, Waba @ Sourceforge. * Copyright (C) 1998, 1999, 2000, Wabasoft. * All Rights Reserved. * * --------------------------------------------------------------------------- * * 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 of the * License, 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. * [...5445 lines suppressed...] stack++; } else if (pushReturnedValue == 2) { stack[0] = returnedValue; stack[1] = returnedValue2; stack += 2; } var = (Var *)vmStack[--vmStackPtr].refValue; pc = vmStack[--vmStackPtr].pc; wclass = (WClass *)vmStack[vmStackPtr - 1].refValue; method = (WClassMethod *)vmStack[vmStackPtr - 2].refValue; goto step; } /* * --END */ |
|
From: Manfred R. <mr...@us...> - 2004-07-10 17:57:58
|
Update of /cvsroot/waba/waba/vm/win32 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1823/vm/win32 Removed Files: Makefile nmwin32_a.c nmwin32_a.h nmwin32_b.c nmwin32_b.h nmwin32_c.c nmwin32_c.h Log Message: Removed old source as they have moved to new location --- Makefile DELETED --- --- nmwin32_a.c DELETED --- --- nmwin32_a.h DELETED --- --- nmwin32_b.c DELETED --- --- nmwin32_b.h DELETED --- --- nmwin32_c.c DELETED --- --- nmwin32_c.h DELETED --- |
|
From: Manfred R. <mr...@us...> - 2004-07-10 17:57:58
|
Update of /cvsroot/waba/waba/vm/port In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1823/vm/port Removed Files: Makefile.am nmport_a.c nmport_a.h nmport_b.c nmport_b.h nmport_c.c nmport_c.h Log Message: Removed old source as they have moved to new location --- Makefile.am DELETED --- --- nmport_a.c DELETED --- --- nmport_a.h DELETED --- --- nmport_b.c DELETED --- --- nmport_b.h DELETED --- --- nmport_c.c DELETED --- --- nmport_c.h DELETED --- |
|
From: Manfred R. <mr...@us...> - 2004-07-10 17:57:57
|
Update of /cvsroot/waba/waba/vm/palm In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1823/vm/palm Removed Files: Makefile.am nmpalm_a.c nmpalm_a.h nmpalm_b.c nmpalm_b.h nmpalm_c.c nmpalm_c.h waba.def Log Message: Removed old source as they have moved to new location --- Makefile.am DELETED --- --- nmpalm_a.c DELETED --- --- nmpalm_a.h DELETED --- --- nmpalm_b.c DELETED --- --- nmpalm_b.h DELETED --- --- nmpalm_c.c DELETED --- --- nmpalm_c.h DELETED --- --- waba.def DELETED --- |
Update of /cvsroot/waba/waba/vm/linux In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1823/vm/linux Removed Files: Makefile.am debug.c debug.h gdk-pixbuf-xlibrgb.c gdk-pixbuf-xlibrgb.h jar.c jar.h jar2host.h nm_linux_a.c nm_linux_a.h nm_linux_b.c nm_linux_b.h nm_linux_c.c nm_linux_c.h ui_gtk.c ui_gtk.h ui_none.c ui_none.h ui_pgui.c ui_pgui.h ui_x.c ui_x.h Log Message: Removed old source as they have moved to new location --- Makefile.am DELETED --- --- debug.c DELETED --- --- debug.h DELETED --- --- gdk-pixbuf-xlibrgb.c DELETED --- --- gdk-pixbuf-xlibrgb.h DELETED --- --- jar.c DELETED --- --- jar.h DELETED --- --- jar2host.h DELETED --- --- nm_linux_a.c DELETED --- --- nm_linux_a.h DELETED --- --- nm_linux_b.c DELETED --- --- nm_linux_b.h DELETED --- --- nm_linux_c.c DELETED --- --- nm_linux_c.h DELETED --- --- ui_gtk.c DELETED --- --- ui_gtk.h DELETED --- --- ui_none.c DELETED --- --- ui_none.h DELETED --- --- ui_pgui.c DELETED --- --- ui_pgui.h DELETED --- --- ui_x.c DELETED --- --- ui_x.h DELETED --- |
|
From: Manfred R. <mr...@us...> - 2004-07-10 17:57:56
|
Update of /cvsroot/waba/waba/vm In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1823/vm Removed Files: .cvsignore Makefile.am config.h constants.h debug.h error.c error.h exception.h memory.c memory.h native.c native.h opcodes.h thread.h types.h waba.c waba.h Log Message: Removed old source as they have moved to new location --- .cvsignore DELETED --- --- Makefile.am DELETED --- --- config.h DELETED --- --- constants.h DELETED --- --- debug.h DELETED --- --- error.c DELETED --- --- error.h DELETED --- --- exception.h DELETED --- --- memory.c DELETED --- --- memory.h DELETED --- --- native.c DELETED --- --- native.h DELETED --- --- opcodes.h DELETED --- --- thread.h DELETED --- --- types.h DELETED --- --- waba.c DELETED --- --- waba.h DELETED --- |
|
From: Manfred R. <mr...@us...> - 2004-07-10 15:30:53
|
Update of /cvsroot/waba/waba/src/win32/c In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10313/src/win32/c Added Files: nmwin32_a.c nmwin32_a.h nmwin32_b.c nmwin32_b.h nmwin32_c.c nmwin32_c.h Log Message: Moved sources to new location --- NEW FILE: nmwin32_a.c --- /* $Id: nmwin32_a.c,v 1.1 2004/07/10 15:30:42 mriem Exp $ Copyright (C) 1998, 1999, 2000 Wabasoft 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 of the License, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* all the needed include */ #include "../waba.h" // // type converters // #ifdef WITH_64BITS // get one 64 float value from buf and return it float64 getFloat64bits(uchar *buf) { float64HiLo fhl; fhl.ul.lo = getInt32( buf ); fhl.ul.hi = getInt32( buf + 4 ); return fhl.value; } // get one 64 float value from buf and return it int64 getInt64bits(uchar *buf) { int64HiLo ihl; ihl.ul.lo = getInt32( buf ); ihl.ul.hi = getInt32( buf + 4 ); return ihl.value; } #endif /* WITH_64BITS */ float32 getFloat32(uchar *buf) { uint32 i; float32 f; // we need to make sure we're aligned before casting i = ((uint32)buf[0] << 24) | ((uint32)buf[1] << 16) | ((uint32)buf[2] << 8) | (uint32)buf[3]; f = *((float32 *)&i); return f; } --- NEW FILE: nmwin32_a.h --- /* * $Id: nmwin32_a.h,v 1.1 2004/07/10 15:30:42 mriem Exp $ * * Copyright (c) 2001, 2002, 2003, Waba @ Sourceforge. * Copyright (c) 1998, 1999, 2000, Wabasoft. * All Rights Reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef __NMWIN32_A_H__ #define __NMWIN32_A_H__ #include <tchar.h> #include <windows.h> #include <stdlib.h> #ifndef WINCE #include <stdio.h> #include <fcntl.h> #include <conio.h> #endif #ifdef WINCE #include <winsock.h> #include <winnetwk.h> #endif #undef FREE_ON_EXIT #undef SECURE_CLASS_HEAP #define LOCK_CLASS_HEAP #define UNLOCK_CLASS_HEAP #define uchar unsigned char #define int32 int #define uint32 unsigned int #define float32 float #define int16 short #define uint16 unsigned short #ifdef WITH_64BITS // - int64 is a signed 64 bit value #define int64 __int64 //INT64 //long long // - uint64 is an unsigned 64 bit value #define uint64 unsigned __int64 //UINT64 //unsigned long long // - float64 is a signed 64 bit floating point value #define float64 double // --- define a struct for double and long support in two Var ... // ... the hi/lo decomposition typedef struct { uint32 lo; uint32 hi; } HiLoDoubleOrLong; //... for the double typedef union { float64 value; HiLoDoubleOrLong ul; } float64HiLo; //... for the long typedef union { int64 value; HiLoDoubleOrLong ul; } int64HiLo; #endif /* WITH_64BITS */ #define cprintf printf // // type converters // #define getUInt32(b) (uint32)( (uint32)((b)[0])<<24 | (uint32)((b)[1])<<16 | (uint32)((b)[2])<<8 | (uint32)((b)[3]) ) #define getUInt16(b) (uint16)(((b)[0]<<8)|(b)[1]) #define getInt32(b) (int32)( (uint32)((b)[0])<<24 | (uint32)((b)[1])<<16 | (uint32)((b)[2])<<8 | (uint32)((b)[3]) ) #define getInt16(b) (int16)(((b)[0]<<8)|(b)[1]) #ifdef WITH_64BITS // get one 64 float value from buf and return it float64 getFloat64bits(uchar *buf); // get one 64 float value from buf and return it int64 getInt64bits(uchar *buf); #endif /* WITH_64BITS */ float32 getFloat32(uchar *buf); // // x portability functions // // NOTE: The str, mem and malloc routines aren't documented in the reference // manuals for CE, however, the methods do exist in the CE library and have // prototypes, etc. #define xstrncmp(s1, s2, n) strncmp(s1, s2, n) #define xstrncpy(dst, src, n) strncpy(dst, src, n) #define xstrlen(s) strlen(s) #define xstrcat(dst, src) strcat(dst, src) #define xmemmove(dst, src, size) memmove(dst, src, size) #define xmemzero(mem, len) memset(mem, 0, len) #define xmalloc(size) malloc(size); #define xfree(ptr) free(ptr) #endif /* __NMWIN32_A_H__ */ --- NEW FILE: nmwin32_b.c --- /* $Id: nmwin32_b.c,v 1.1 2004/07/10 15:30:42 mriem Exp $ Copyright (C) 1998, 1999, 2000 Wabasoft 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 of the License, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* all the needed include */ #include "../waba.h" [...1705 lines suppressed...] FILE *fp; AllocConsole(); GetConsoleScreenBufferInfo( GetStdHandle( STD_OUTPUT_HANDLE ), &coninfo ); coninfo.dwSize.Y = 500; SetConsoleScreenBufferSize( GetStdHandle( STD_OUTPUT_HANDLE ), coninfo.dwSize ); lStdHandle = (long) GetStdHandle( STD_OUTPUT_HANDLE ); hConHandle = _open_osfhandle( lStdHandle, _O_TEXT ); fp = _fdopen( hConHandle, "w" ); *stdout = *fp; setvbuf( stdout, NULL, _IONBF, 0 ); #endif } --- NEW FILE: nmwin32_b.h --- /* $Id: nmwin32_b.h,v 1.1 2004/07/10 15:30:42 mriem Exp $ */ #ifndef __NMWIN32_B_H__ #define __NMWIN32_B_H__ /* Copyright (C) 1998, 1999, 2000 Wabasoft 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 of the License, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ static int g_mainWinWidth = 0; static int g_mainWinHeight = 0; static DWORD g_startTime = 0; static DWORD g_messageTime = 0; static HINSTANCE g_hInstance; static TCHAR *pszWndClassName = TEXT("WabaWndClass"); #define WARP_CORE_PATH "\\Program Files\\waba\\waba.wrp" #define MAX_CLASSPATHS 20 static int numClassPaths = -1; static char *classPaths[MAX_CLASSPATHS]; typedef struct { HANDLE fileH; HANDLE mapH; int viewIsMapped; uchar *ptr; } MemFile; #define MAX_MEM_FILES 16 static MemFile memFiles[MAX_MEM_FILES]; static uint32 numMemFiles = 0; static int memFileNotSupported = 0; static int win32WSAStarted = 0; #ifdef QUICKBIND static int32 postPaintMethodMapNum = -1; static int32 postEventMethodMapNum = -1; static int32 onTimerTickMethodMapNum = -1; #endif int asciiToUnicode(char *src, TCHAR *dst, int max); WObject createStringFromUnicode(TCHAR *s, uint32 len); uchar *loadFromMem(char *path, uint32 pathLen, uint32 *size); uchar *readFileIntoMemory(char *path, int nullTerminate, uint32 *size); int32 getTimeStamp(); void dumpStackTrace(); uchar *nativeLoadClass(UtfString className, uint32 *size); #ifdef WITH_THREAD //*** Monaka's Multithread implemantasion //*** based on Isao's Multithread implementation #define THREAD_LIST_MAX_SIZE 8 typedef struct _queue { struct _queue *next; struct _queue *prev; } Queue; typedef struct { //Use either "syncObj" or "syncMethod", //Not both at the same time. WObject syncObj; WClassMethod* syncMethod; #ifdef WITH_THREAD_NATIVE CRITICAL_SECTION syncLock; #endif } WSync; typedef struct { WObject signalObj; #ifdef WITH_THREAD_NATIVE HANDLE signalHandle; #endif } WSignal; //This trick is necessary for Win32 native threads. typedef struct { WClass* vclass; WClassMethod* method; Var params[7]; uint32 paramSize; } WVmParam; typedef struct { Queue queue; /* 'Queue' must be first to use type cast trick. */ WClass* tClass; WObject tObject; //Since I don't know how to override: //"java.Object.wait()", //"java.Object.notify()", and //"java.Object.notifyAll()" //witout getting a JDK 1.2.2 compiler error, //I have coded so that "Thread" class handles the synchronization. //Someone who can handle this, any help wl be appreciated. WSync wSyncObj; WSignal wSignal; int32 runMethodMapNum; uint32 sleepCountSet; uint32 sleepCountNow; uchar isSleepCountAlreadySet; uchar isWaiting; //This trick is necessary for Win32 native threads. #ifdef WITH_THREAD_NATIVE WVmParam wParams; HANDLE wThreadHandle; DWORD wThreadID; #endif } WThread; extern int InitThread(uint32 stack_size); //*** This "ThreadStart()" method is called from "start()" method. extern Var ThreadStart(Var stack[]); //*** This "ThreadStop()" method is called from "stop()" method. extern Var ThreadStop(Var stack[]); void ThreadDestroy(WObject targetObj); //*** This "ThreadSleep()" method is called from "sleep()" method. extern Var ThreadSleep(Var stack[]); //*** This "ThreadWaitForSignal()" method is called from "waitForSignal()" method. extern Var ThreadWaitForSignal(Var stack[]); extern Var ThreadSignalAll(Var stack[]); //*** Isao's Multithread implementation END *** //*** This "ThreadCurrentThread()" method is called from "curentThread()" method. extern Var ThreadCurrentThread(Var stack[]); void tickThread(void); int registerAsSyncronized(WClassMethod* method); void exitFromSyncronized(WClassMethod* method); int enterMonitor(WObject obj); int exitMonitor(WObject obj); #ifdef WITH_DOUBLE_BUFFER void setMainWinObj(WObject winObj); WObject getMainWinObj(void); WObject theMainWinObj; #endif #endif /* WITH_THREAD */ #endif /* __NMWIN32_B_H__ */ --- NEW FILE: nmwin32_c.c --- /* $Id: nmwin32_c.c,v 1.1 2004/07/10 15:30:42 mriem Exp $ Copyright (C) 1998, 1999, 2000 Wabasoft 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 of the License, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ // NOTE: General rule for native functions.. don't hold a pointer across any // call that could garbage collect. For example, this is bad: [...3881 lines suppressed...] NULL); WriteFile(hCout, str.str, str.len, &cbWritten, NULL); CloseHandle(hCout); return v; } #ifdef WIN32 Var SystemInit( Var stack[] ) { Var v; printf( "SystemInit\n" ); v.obj = 0; return v; } #endif --- NEW FILE: nmwin32_c.h --- /* $Id: nmwin32_c.h,v 1.1 2004/07/10 15:30:42 mriem Exp $ */ #ifndef __NMWIN32_C_H__ #define __NMWIN32_C_H__ /* Copyright (C) 1998, 1999, 2000 Wabasoft 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 of the License, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifdef WITH_DOUBLE_BUFFER HBITMAP hMainScrBitmap; HBITMAP hOffScrBitmap; HDC hMainScrDC; HDC hOffScrDC; HWND hMainWnd; int mainWinWidth, mainWinHeight; HDC createOffScreenBuffer(WObject winObj); void deleteOffScreenBuffer(void); void paint(void); #endif //*** Isao's internationalization stuff START *** //static HFONT createWin32Font(WObject font, HDC hDC); static HFONT createWin32Font(WObject font); //*** Isao's internationalization stuff END *** static void WindowDestroy(WObject obj); static void MainWinDestroy(WObject obj); static void GraphicsDestroy(WObject obj); static void ImageDestroy(WObject obj); #if WITH_CATALOG static void CatalogDestroy(WObject obj); #endif static void FileDestroy(WObject obj); static void SocketDestroy(WObject obj); static void SerialPortDestroy(WObject obj); extern ClassHook classHooks[]; #define FUNC(f) extern Var f (Var stack[]) /* some generic functions */ FUNC(Return0Func); FUNC(ReturnNeg1Func); /* all the native functions */ FUNC(VmPrintLn); FUNC(VmPrint); FUNC(VmExec); FUNC(VmGetTimeStamp); FUNC(copyArray); FUNC(VmExit); FUNC(VmSleep); FUNC(VmSetDeviceAutoOff); FUNC(VmGetUserName); FUNC(VmGetPlatform); FUNC(VmIsColor); FUNC(FileGetLength); FUNC(FileCreateDir); FUNC(FileReadBytes); FUNC(FileRename); FUNC(FileCreate); FUNC(FileWriteBytes); FUNC(FileListDir); FUNC(FileSeekWaba); FUNC(FileIsDir); FUNC(FileCloseWaba); FUNC(FileIsOpen); FUNC(FileDeleteWaba); FUNC(FileExists); FUNC(ImageCreate); FUNC(ImageFree); FUNC(ImageSetPixels); FUNC(ImageUseImagePalette); FUNC(ImageLoad); FUNC(SoundBeep); FUNC(SoundTone); FUNC(TimeCreate); FUNC(SocketCreate); FUNC(SocketRead); FUNC(SocketWrite); FUNC(SocketSetReadTimeout); FUNC(SocketClose); FUNC(SocketIsOpen); FUNC(WindowCreate); #if WITH_CATALOG FUNC(CatalogListCatalogs); FUNC(CatalogAddRecord); FUNC(CatalogSkipBytes); FUNC(CatalogCreate); FUNC(CatalogRead); FUNC(CatalogDeleteRecord); FUNC(CatalogSetRecordPos); FUNC(CatalogGetRecordSize); FUNC(CatalogResizeRecord); FUNC(CatalogWrite); FUNC(CatalogGetRecordCount); FUNC(CatalogClose); FUNC(CatalogIsOpen); FUNC(CatalogDelete); #endif //WITH_CATALOG FUNC(GraphicsCopyRect); FUNC(GraphicsClearClip); FUNC(GraphicsSetFont); FUNC(GraphicsSetDrawOp); FUNC(GraphicsSetClip); FUNC(GraphicsSetBackColor); FUNC(GraphicsSetColor); FUNC(GraphicsGetClip); FUNC(GraphicsFillRect); FUNC(GraphicsDrawLine); FUNC(GraphicsTranslate); FUNC(GraphicsDrawDots); FUNC(GraphicsDrawChars); FUNC(GraphicsCreate); FUNC(GraphicsDrawCursor); FUNC(GraphicsSetClip); FUNC(GraphicsFree); FUNC(GraphicsSetForeColor); FUNC(GraphicsSetTextColor); FUNC(GraphicsFillPolygon); FUNC(GraphicsDrawString); FUNC(ConvertStringToInt); FUNC(ConvertFloatToIntBitwise); FUNC(ConvertCharToString); FUNC(ConvertIntToFloatBitwise); FUNC(ConvertFloatToString); FUNC(ConvertDoubleToString); FUNC(ConvertIntToString); FUNC(ConvertLongToString); FUNC(ConvertBooleanToString); FUNC(SoundClipPlay); FUNC(PalmOsPrefSetPalmOsPref); FUNC(PalmOsPrefGetPalmOsPref); FUNC(MainWinCreate); FUNC(MainWinExit); FUNC(MainWinSetTimerInterval); #ifdef WITH_DOUBLE_BUFFER FUNC(MainWinPaint); #endif FUNC(SerialPortReadCheck); FUNC(SerialPortRead); FUNC(SerialPortWrite); FUNC(SerialPortSetReadTimeout); FUNC(SerialPortClose); FUNC(SerialPortSetFlowControl); FUNC(SerialPortIsOpen); FUNC(SerialPortCreate); FUNC(FontMetricsGetStringWidth); FUNC(FontMetricsGetCharWidth); FUNC(FontMetricsCreate); FUNC(FontMetricsGetCharArrayWidth); /* * Begin of J2ME compliant code. */ #ifdef WIN32 FUNC(SystemInit); #endif #endif /* __NMWIN32_C_H__ */ |
|
From: Manfred R. <mr...@us...> - 2004-07-10 15:30:52
|
Update of /cvsroot/waba/waba/src/share/c In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10313/src/share/c Added Files: config.h constants.h debug.h error.c error.h exception.h memory.c memory.h native.c native.h opcodes.h thread.h types.h waba.c waba.h Log Message: Moved sources to new location --- NEW FILE: config.h --- /* * $Id: config.h,v 1.1 2004/07/10 15:30:41 mriem Exp $ * * Copyright (c) 2001, 2002, 2003, Waba @ Sourceforge. * Copyright (c) 1998, 1999, 2000, Wabasoft. * All Rights Reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * ---------------------------------------------------------------------------- * * Defines all the configuration for the VM * * ---------------------------------------------------------------------------- */ #ifndef __CONFIG_H__ #define __CONFIG_H__ /* * Which OS */ // #define PALMOS 1 // #define WINCE 1 // #define WIN32 1 /* * Memory options */ #define QUICKBIND 1 #define SANITYCHECK 1 #define SECURE_CLASS_HEAP 1 #define SMALLMEM 1 /* * With classic Waba support */ #define WITH_WABA 1 #define WITH_CATALOG 1 #define WITH_CATALOG_CLASS 1 #define WITH_DOUBLE_BUFFER 1 #define WITH_FILE_CLASS 1 #define WITH_FONTMETRICS_CLASS 1 #define WITH_GRAPHICS_CLASS 1 #define WITH_GUI_CLASS 1 #define WITH_SERIALPORT_CLASS 1 #define WITH_SOCKET_CLASS 1 #define WITH_SOUNDCLIP_CLASS 1 /* * With Waba extension support */ // #define WITH_SMARTDATA_CLASSES 1 /* * With thread support */ #define WITH_THREAD 1 #define WITH_THREAD_NATIVE 1 /* * With 64 bits support */ #define WITH_64BITS 1 #endif --- NEW FILE: constants.h --- /* * $Id: constants.h,v 1.1 2004/07/10 15:30:41 mriem Exp $ * * Copyright (c) 2001, 2002, 2003, Waba @ Sourceforge. * Copyright (c) 1998, 1999, 2000, Wabasoft. * All Rights Reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef __CONSTANTS_H__ #define __CONSTANTS_H__ /* * Waba classic key constants. */ #define WABA_KEY_PAGE_UP 75000 #define WABA_KEY_PAGE_DOWN 75001 #define WABA_KEY_HOME 75002 #define WABA_KEY_END 75003 #define WABA_KEY_UP 75004 #define WABA_KEY_DOWN 75005 #define WABA_KEY_LEFT 75006 #define WABA_KEY_RIGHT 75007 #define WABA_KEY_INSERT 75008 #define WABA_KEY_ENTER 75009 #define WABA_KEY_TAB 75010 #define WABA_KEY_BACKSPACE 75011 #define WABA_KEY_ESCAPE 75012 #define WABA_KEY_DELETE 75013 #define WABA_KEY_MENU 75014 #define WABA_KEY_COMMAND 75015 /* * Waba classic event constants. */ #define WABA_EVENT_KEY_PRESS 100 #define WABA_EVENT_PEN_DOWN 200 #define WABA_EVENT_PEN_MOVE 201 #define WABA_EVENT_PEN_UP 202 #define WABA_EVENT_PEN_DRAG 203 #endif --- NEW FILE: debug.h --- /* * $Id: debug.h,v 1.1 2004/07/10 15:30:41 mriem Exp $ * * Copyright (c) 2001, 2002, 2003, Waba @ Sourceforge. * Copyright (c) 1998, 1999, 2000, Wabasoft. * All Rights Reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * ---------------------------------------------------------------------------- * * Defines support for debugging. * * ---------------------------------------------------------------------------- */ #ifndef __DEBUG_H__ #define __DEBUG_H__ #ifdef DEBUG_OPCODE #define OP_MAX_OP 202 static char * _OP_name [] = { "OP_nop", "OP_aconst_null", "OP_iconst_m1", "OP_iconst_0", "OP_iconst_1", "OP_iconst_2", "OP_iconst_3", "OP_iconst_4", "OP_iconst_5", "OP_lconst_0", "OP_lconst_1", "OP_fconst_0", "OP_fconst_1", "OP_fconst_2", "OP_dconst_0", "OP_dconst_1", "OP_bipush", "OP_sipush", "OP_ldc", "OP_ldc_w", "OP_ldc2_w", "OP_iload", "OP_lload", "OP_fload", "OP_dload", "OP_aload", "OP_iload_0", "OP_iload_1", "OP_iload_2", "OP_iload_3", "OP_lload_0", "OP_lload_1", "OP_lload_2", "OP_lload_3", "OP_fload_0", "OP_fload_1", "OP_fload_2", "OP_fload_3", "OP_dload_0", "OP_dload_1", "OP_dload_2", "OP_dload_3", "OP_aload_0", "OP_aload_1", "OP_aload_2", "OP_aload_3", "OP_iaload", "OP_laload", "OP_faload", "OP_daload", "OP_aaload", "OP_baload", "OP_caload", "OP_saload", "OP_istore", "OP_lstore", "OP_fstore", "OP_dstore", "OP_astore", "OP_istore_0", "OP_istore_1", "OP_istore_2", "OP_istore_3", "OP_lstore_0", "OP_lstore_1", "OP_lstore_2", "OP_lstore_3", "OP_fstore_0", "OP_fstore_1", "OP_fstore_2", "OP_fstore_3", "OP_dstore_0", "OP_dstore_1", "OP_dstore_2", "OP_dstore_3", "OP_astore_0", "OP_astore_1", "OP_astore_2", "OP_astore_3", "OP_iastore", "OP_lastore", "OP_fastore", "OP_dastore", "OP_aastore", "OP_bastore", "OP_castore", "OP_sastore", "OP_pop", "OP_pop2", "OP_dup", "OP_dup_x1", "OP_dup_x2", "OP_dup2", "OP_dup2_x1", "OP_dup2_x2", "OP_swap", "OP_iadd", "OP_ladd", "OP_fadd", "OP_dadd", "OP_isub", "OP_lsub", "OP_fsub", "OP_dsub", "OP_imul", "OP_lmul", "OP_fmul", "OP_dmul", "OP_idiv", "OP_ldiv", "OP_fdiv", "OP_ddiv", "OP_irem", "OP_lrem", "OP_frem", "OP_drem", "OP_ineg", "OP_lneg", "OP_fneg", "OP_dneg", "OP_ishl", "OP_lshl", "OP_ishr", "OP_lshr", "OP_iushr", "OP_lushr", "OP_iand", "OP_land", "OP_ior", "OP_lor", "OP_ixor", "OP_lxor", "OP_iinc", "OP_i2l", "OP_i2f", "OP_i2d", "OP_l2i", "OP_l2f", "OP_l2d", "OP_f2i", "OP_f2l", "OP_f2d", "OP_d2i", "OP_d2l", "OP_d2f", "OP_i2b", "OP_i2c", "OP_i2s", "OP_lcmp", "OP_fcmpl", "OP_fcmpg", "OP_dcmpl", "OP_dcmpg", "OP_ifeq", "OP_ifne", "OP_iflt", "OP_ifge", "OP_ifgt", "OP_ifle", "OP_if_icmpeq", "OP_if_icmpne", "OP_if_icmplt", "OP_if_icmpge", "OP_if_icmpgt", "OP_if_icmple", "OP_if_acmpeq", "OP_if_acmpne", "OP_goto", "OP_jsr", "OP_ret", "OP_tableswitch", "OP_lookupswitch", "OP_ireturn", "OP_lreturn", "OP_freturn", "OP_dreturn", "OP_areturn", "OP_return", "OP_getstatic", "OP_putstatic", "OP_getfield", "OP_putfield", "OP_invokevirtual", "OP_invokespecial", "OP_invokestatic", "OP_invokeinterface", "OP_new", "OP_newarray", "OP_anewarray", "OP_arraylength", "OP_athrow", "OP_checkcast", "OP_instanceof", "OP_monitorenter", "OP_monitorexit", "OP_wide", "OP_multianewarray", "OP_ifnull", "OP_ifnonnull", "OP_goto_w", "OP_jsr_w", "OP_breakpoint" }; #endif #endif --- NEW FILE: error.c --- /* * $Id: error.c,v 1.1 2004/07/10 15:30:41 mriem Exp $ * * Copyright (c) 2001, 2002, 2003, Waba @ Sourceforge. * Copyright (c) 1998, 1999, 2000, Wabasoft. * All Rights Reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * ---------------------------------------------------------------------------- * * Implements support for errors. * * ---------------------------------------------------------------------------- */ #include "waba.h" #include "error.h" void VmError( uint16 errNum, WClass *iclass, UtfString *desc1, UtfString *desc2 ) { WClass *wclass; WClassMethod *method; UtfString className, iclassName, methodName, methodDesc; // NOTE: Don't overwrite an existing error since it may be the // root cause of this error. if (vmStatus.errNum != 0) return; vmStatus.errNum = errNum; // get current class and method off stack if (vmStackPtr > 0) { wclass = (WClass *)vmStack[vmStackPtr - 1].refValue; method = (WClassMethod *)vmStack[vmStackPtr - 2].refValue; } else { wclass = 0; method = 0; } // output class and method name if (wclass) { className = getUtfString(wclass, wclass->classNameIndex); printToBuf(vmStatus.className, 40, &className, NULL); } if (method) { methodName = getUtfString(wclass, METH_nameIndex(method)); methodDesc = getUtfString(wclass, METH_descIndex(method)); printToBuf(vmStatus.methodName, 40, &methodName, &methodDesc); } // output additional error arguments (target class, desc, etc.) if (iclass) { iclassName = getUtfString(iclass, iclass->classNameIndex); printToBuf(vmStatus.arg1, 40, &iclassName, NULL); } printToBuf(vmStatus.arg2, 40, desc1, desc2); #ifdef WIN32 #ifndef WINCE dumpStackTrace(); #endif #endif } void VmQuickError(uint16 errNum) { VmError( errNum, NULL, NULL, NULL ); } --- NEW FILE: error.h --- /* * $Id: error.h,v 1.1 2004/07/10 15:30:41 mriem Exp $ * * Copyright (c) 2001, 2002, 2003, Waba @ Sourceforge. * Copyright (c) 1998, 1999, 2000, Wabasoft. * All Rights Reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * ---------------------------------------------------------------------------- * * Defines support for errors. * * ---------------------------------------------------------------------------- */ #ifndef __ERROR_H__ #define __ERROR_H__ /* * Error messages */ static char *errorMessages[] = { "sanity", "incompatible device", "can't access waba classes", "can't access app classes", "can't allocate memory", "out of class memory", "out of object memory", "native stack overflow", "native stack underflow", "stack overflow", "bad class", "bad opcode", "can't find class", "can't find method", "can't find field", "null object access", "null array access", "index out of range", "divide by zero", "bad class cast", "class too large" }; /* * Fatal errors */ #define ERR_SanityCheckFailed 1 #define ERR_IncompatibleDevice 2 #define ERR_CantAccessCoreClasses 3 #define ERR_CantAccessAppClasses 4 #define ERR_CantAllocateMemory 5 #define ERR_OutOfClassMem 6 #define ERR_OutOfObjectMem 7 #define ERR_NativeStackOverflow 8 #define ERR_NativeStackUnderflow 9 #define ERR_StackOverflow 10 /* * Program errors */ #define ERR_BadClass 11 #define ERR_BadOpcode 12 #define ERR_CantFindClass 13 #define ERR_CantFindMethod 14 #define ERR_CantFindField 15 #define ERR_NullObjectAccess 16 #define ERR_NullArrayAccess 17 #define ERR_IndexOutOfRange 18 #define ERR_DivideByZero 19 #define ERR_ClassCastException 20 #define ERR_ClassTooLarge 21 /* * Function prototypes * ------------------- * * NOTE: the function prototypes should be enabled here once we have finished * cleaning up interdepencies. * * void VmError( uint16 errNum, * WClass *iclass, * UtfString *desc1, * UtfString *desc2); * * void VmQuickError( uint16 errNum ); */ #endif --- NEW FILE: exception.h --- /* * $Id: exception.h,v 1.1 2004/07/10 15:30:41 mriem Exp $ * * Copyright (c) 2001, 2002, 2003, Waba @ Sourceforge. * Copyright (c) 1998, 1999, 2000, Wabasoft. * All Rights Reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * ---------------------------------------------------------------------------- * * Defines the exception support in the VM. * * ---------------------------------------------------------------------------- */ #ifndef __EXCEPTION_H__ #define __EXCEPTION_H__ #endif --- NEW FILE: memory.c --- /* * $Id: memory.c,v 1.1 2004/07/10 15:30:41 mriem Exp $ * * Copyright (c) 2001, 2002, 2003, Waba @ Sourceforge. * Copyright (c) 1998, 1999, 2000, Wabasoft. * All Rights Reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * ---------------------------------------------------------------------------- * * Memory Management * ----------------- * * Here's the garbage collector. I implemented the mark and sweep below after * testing out a few different ones and reading: * * Garbage Collection, Algorithms for Automatic Dynamic Memory Management * by Richard Jones and Rafael Lins * * which is an excellent book. Also, this collector has gone through a lot of * testing. It runs when the system is completely out of memory which can * happen at any time ... for example during class loading. * * To test it out, tests were run where 1000's of random objects were loaded, * constructed and random methods called on them over some period of days. * This found a couple subtle bugs that were fixed like when the garbage * collector ran in the middle of array allocation and moved pointers around * from under the array allocator code ( those have all been fixed ). * * The heap is comprised of Hos objects (an array) that grows from the * "right" of object memory and objects that take up the space on on the * "left" side. The Hos array keeps track of where the objects are on the * left. * * The Hos structure (strange, but aptly named) is used to keep track of * handles (pointers to memory locations), order (order of handles with * respect to memory) and temporary items (used during the scan phase). * * The 3 items in the Hos structure do not relate to each other. They are * each a part of 3 conceptually distinct arrays that grow from the right of * the heap while the objects grow from the left. So, when the Hos array is * indexed, it is always negative (first element is 0, next is -1, next * is -2, etc). * * ---------------------------------------------------------------------------- */ #include "waba.h" #include "memory.h" /* * The heap with objects. */ static ObjectHeap heap; #define VALID_OBJ(o) (o > FIRST_OBJ && o <= FIRST_OBJ + heap.numHandles) // mark bits in the handle order array since it is not used during // the mark object process (its used in the sweep phase) #define MARK(o) heap.hos[- (int32)(o - FIRST_OBJ - 1)].order |= 0x80000000 #define IS_MARKED(o) (heap.hos[- (int32)(o - FIRST_OBJ - 1)].order & 0x80000000) /* * NOTE: There are no waba methods that are called when objects are destroyed. * This is because if a method was called, the object would be on its * way to being GC'd and if we set another object (or static field) to * reference it, after the GC, the reference would be stale. */ void sweep() { WObject obj; WClass *wclass; uint32 i, h, objSize, prevObjectSize, numUsedHandles; uchar *src, *dst; prevObjectSize = heap.objectSize; heap.objectSize = 0; // move all the marks over into the scan array so we don't have // to do lots of bit shifting for (i = 0; i < heap.numHandles; i++) { if (heap.hos[- (int32)i].order & 0x80000000) { heap.hos[- (int32)i].order &= 0x7FFFFFFF; // clear mark bit heap.hos[- (int32)i].temp = 1; } else { heap.hos[- (int32)i].temp = 0; } } numUsedHandles = 0; for (i = 0; i < heap.numHandles; i++) { // we need to scan in memory order so we can compact things without // copying objects over each other h = heap.hos[- (int32)i].order; obj = h + FIRST_OBJ + 1; if (!heap.hos[- (int32)h].temp) { // handle is free - dereference object if (objectPtr(obj) != NULL) { wclass = WOBJ_class(obj); // for non-arrays, call objDestroy if present if (wclass != NULL && wclass->objDestroyFunc) wclass->objDestroyFunc(obj); heap.hos[- (int32)h].ptr = NULL; } continue; } wclass = WOBJ_class(obj); if (wclass == NULL) objSize = arraySize(WOBJ_arrayType(obj), WOBJ_arrayLen(obj)); else objSize = WCLASS_objectSize(wclass); // copy object to new heap src = (uchar *)heap.hos[- (int32)h].ptr; dst = &heap.mem[heap.objectSize]; if (src != dst) // NOTE: overlapping regions need to copy correctly xmemmove(dst, src, objSize); heap.hos[- (int32)h].ptr = (Var *)dst; heap.hos[- (int32)numUsedHandles].order = h; heap.objectSize += objSize; numUsedHandles++; } heap.numFreeHandles = heap.numHandles - numUsedHandles; for (i = 0; i < heap.numHandles; i++) if (!heap.hos[- (int32)i].temp) { // add free handle to free section of order array heap.hos[- (int32)numUsedHandles].order = i; numUsedHandles++; } // zero out the part of the heap that is now junk xmemzero(&heap.mem[heap.objectSize], prevObjectSize - heap.objectSize); } /* * NOTE: this method is only for printing the status of memory and can be * removed. Also note, there is no such thing as the "amount of free * memory" because of garbage collection. */ uint32 getUnusedMem() { return heap.memSize - (heap.objectSize + (heap.numHandles * sizeof(Hos))); } int initObjectHeap(uint32 heapSize) { // NOTE: we must intiailize all the variables since after // a freeObjectHeap() we get called again heap.numHandles = 0; heap.numFreeHandles = 0; heap.memSize = heapSize; #if FIXED_OBJECT_HEAP_SIZE > 0 // align to 4 byte boundry for correct alignment of the Hos array heap.memSize = sizeof(objectHeapArea); // allocate and zero out memory region heap.mem = &objectHeapArea[0]; #else // align to 4 byte boundry for correct alignment of the Hos array heap.memSize = (heap.memSize + 3) & ~3; // allocate and zero out memory region heap.mem = (uchar *)xmalloc(heap.memSize); if (heap.mem == NULL) return -1; #endif xmemzero(heap.mem, heap.memSize); heap.hos = (Hos *)(&heap.mem[heap.memSize - sizeof(Hos)]); heap.objectSize = 0; return 0; } void freeObjectHeap() { #ifdef FREE_ON_EXIT { WObject obj; uint32 h; WClass *wclass; // call any native object destroy methods to free system resources for (h = 0; h < heap.numHandles; h++) { obj = h + FIRST_OBJ + 1; if (objectPtr(obj) != NULL) { wclass = WOBJ_class(obj); if (wclass != NULL && wclass->objDestroyFunc) wclass->objDestroyFunc(obj); } } } #endif #if FIXED_OBJECT_HEAP_SIZE <= 0 if (heap.mem) xfree(heap.mem); #endif } // mark this object and all the objects this object refers to and all // objects those objects refer to, etc. void markObject(WObject obj) { WClass *wclass; WObject *arrayStart, o; uint32 i, len, type, numScan; if (!VALID_OBJ(obj) || objectPtr(obj) == NULL || IS_MARKED(obj)) return; MARK(obj); numScan = 0; markinterior: wclass = WOBJ_class(obj); if (wclass == NULL) { // array - see if it contains object references type = WOBJ_arrayType(obj); if (type == 1 || type == 2) { // for an array of arrays or object array arrayStart = (WObject *)WOBJ_arrayStart(obj); len = WOBJ_arrayLen(obj); for (i = 0; i < len; i++) { o = arrayStart[i]; if (VALID_OBJ(o) && objectPtr(o) != NULL && !IS_MARKED(o)) { MARK(o); heap.hos[- (int32)numScan].temp = o; numScan++; } } } } else { // object len = wclass->numVars; for (i = 0; i < len; i++) { o = WOBJ_var(obj, i).obj; if (VALID_OBJ(o) && objectPtr(o) != NULL && !IS_MARKED(o)) { MARK(o); heap.hos[- (int32)numScan].temp = o; numScan++; } } } if (numScan > 0) { // Note: we use goto since we want to avoid recursion here // since structures like linked links could create deep // stack calls --numScan; obj = heap.hos[- (int32)numScan].temp; goto markinterior; } } // NOTE: size passed must be 4 byte aligned (see arraySize()) WObject allocObject(int32 size) { uint32 i, sizeReq, hosSize; if (size <= 0) return 0; sizeReq = size; if (!heap.numFreeHandles) sizeReq += sizeof(Hos); hosSize = heap.numHandles * sizeof(Hos); if (sizeReq + hosSize + heap.objectSize > heap.memSize) { gc(); // heap.objectSize changed or we are out of memory if (sizeReq + hosSize + heap.objectSize > heap.memSize) { VmQuickError(ERR_OutOfObjectMem); return 0; } } if (heap.numFreeHandles) { i = heap.hos[- (int32)(heap.numHandles - heap.numFreeHandles)].order; heap.numFreeHandles--; } else { // no free handles, get a new one i = heap.numHandles; heap.hos[- (int32)i].order = i; heap.numHandles++; } heap.hos[- (int32)i].ptr = (Var *)&heap.mem[heap.objectSize]; heap.objectSize += size; return FIRST_OBJ + i + 1; } // NOTE: we made this function a #define and it showed no real performance // gain over having it a function on either PalmOS or Windows when // optimization was turned on. Var *objectPtr(WObject obj) { return heap.hos[- (int32)(obj - FIRST_OBJ - 1)].ptr; } void gc() { WClass *wclass; WObject obj; uint32 i, j; // mark objects on vm stack for (i = 0; i < vmStackPtr; i++) if (VALID_OBJ(vmStack[i].obj)) markObject(vmStack[i].obj); // mark objects on native stack for (i = 0; i < nmStackPtr; i++) if (VALID_OBJ(nmStack[i])) markObject(nmStack[i]); // mark all static class objects for (i = 0; i < CLASS_HASH_SIZE; i++) { wclass = classHashList[i]; while (wclass != NULL) { for (j = 0; j < wclass->numFields; j++) { WClassField *field; field = &wclass->fields[j]; if (!FIELD_isStatic(field)) continue; obj = field->var.staticVar.obj; if (VALID_OBJ(obj)) markObject(obj); } wclass = wclass->nextClass; } } sweep(); #ifdef DEBUGMEMSIZE debugMemSize(); #endif } --- NEW FILE: memory.h --- /* * $Id: memory.h,v 1.1 2004/07/10 15:30:41 mriem Exp $ * * Copyright (c) 2001, 2002, 2003, Waba @ Sourceforge. * Copyright (c) 1998, 1999, 2000, Wabasoft. * All Rights Reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * ---------------------------------------------------------------------------- * * Defines support for memory management. * * ---------------------------------------------------------------------------- */ #ifndef __MEMORY_H__ #define __MEMORY_H__ #define FIRST_OBJ 2244 typedef struct { Var *ptr; uint32 order; uint32 temp; } Hos; /* * NOTE: The total amount of memory used up at any given time in the heap is: * objectSize + ( numHandles * sizeof( Hos ) ) */ typedef struct { Hos *hos; /* handle, order and scan arrays (interlaced) */ uint32 numHandles; /* */ uint32 numFreeHandles; /* */ uchar *mem; /* */ uint32 memSize; /* total size of memory (including free) */ uint32 objectSize; /* size of all objects in heap */ } ObjectHeap; #endif --- NEW FILE: native.c --- /* * $Id: native.c,v 1.1 2004/07/10 15:30:41 mriem Exp $ * * Copyright (c) 2001, 2002, 2003, Waba @ Sourceforge. * Copyright (c) 1998, 1999, 2000, Wabasoft. * All Rights Reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "waba.h" #include "native.h" --- NEW FILE: native.h --- /* * $Id: native.h,v 1.1 2004/07/10 15:30:41 mriem Exp $ * * Copyright (c) 2001, 2002, 2003, Waba @ Sourceforge. * Copyright (c) 1998, 1999, 2000, Wabasoft. * All Rights Reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef __NATIVE_H__ #define __NATIVE_H__ #endif --- NEW FILE: opcodes.h --- /* * $Id: opcodes.h,v 1.1 2004/07/10 15:30:41 mriem Exp $ * * Copyright (c) 2001, 2002, 2003, Waba @ Sourceforge. * Copyright (c) 1998, 1999, 2000, Wabasoft. * All Rights Reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * ---------------------------------------------------------------------------- * * Defines all the opcodes known by the JVM. * * ---------------------------------------------------------------------------- */ #ifndef __OPCODES_H__ #define __OPCODES_H__ #define OP_nop 0 #define OP_aconst_null 1 #define OP_iconst_m1 2 #define OP_iconst_0 3 #define OP_iconst_1 4 #define OP_iconst_2 5 #define OP_iconst_3 6 #define OP_iconst_4 7 #define OP_iconst_5 8 #define OP_lconst_0 9 #define OP_lconst_1 10 #define OP_fconst_0 11 #define OP_fconst_1 12 #define OP_fconst_2 13 #define OP_dconst_0 14 #define OP_dconst_1 15 #define OP_bipush 16 #define OP_sipush 17 #define OP_ldc 18 #define OP_ldc_w 19 #define OP_ldc2_w 20 #define OP_iload 21 #define OP_lload 22 #define OP_fload 23 #define OP_dload 24 #define OP_aload 25 #define OP_iload_0 26 #define OP_iload_1 27 #define OP_iload_2 28 #define OP_iload_3 29 #define OP_lload_0 30 #define OP_lload_1 31 #define OP_lload_2 32 #define OP_lload_3 33 #define OP_fload_0 34 #define OP_fload_1 35 #define OP_fload_2 36 #define OP_fload_3 37 #define OP_dload_0 38 #define OP_dload_1 39 #define OP_dload_2 40 #define OP_dload_3 41 #define OP_aload_0 42 #define OP_aload_1 43 #define OP_aload_2 44 #define OP_aload_3 45 #define OP_iaload 46 #define OP_laload 47 #define OP_faload 48 #define OP_daload 49 #define OP_aaload 50 #define OP_baload 51 #define OP_caload 52 #define OP_saload 53 #define OP_istore 54 #define OP_lstore 55 #define OP_fstore 56 #define OP_dstore 57 #define OP_astore 58 #define OP_istore_0 59 #define OP_istore_1 60 #define OP_istore_2 61 #define OP_istore_3 62 #define OP_lstore_0 63 #define OP_lstore_1 64 #define OP_lstore_2 65 #define OP_lstore_3 66 #define OP_fstore_0 67 #define OP_fstore_1 68 #define OP_fstore_2 69 #define OP_fstore_3 70 #define OP_dstore_0 71 #define OP_dstore_1 72 #define OP_dstore_2 73 #define OP_dstore_3 74 #define OP_astore_0 75 #define OP_astore_1 76 #define OP_astore_2 77 #define OP_astore_3 78 #define OP_iastore 79 #define OP_lastore 80 #define OP_fastore 81 #define OP_dastore 82 #define OP_aastore 83 #define OP_bastore 84 #define OP_castore 85 #define OP_sastore 86 #define OP_pop 87 #define OP_pop2 88 #define OP_dup 89 #define OP_dup_x1 90 #define OP_dup_x2 91 #define OP_dup2 92 #define OP_dup2_x1 93 #define OP_dup2_x2 94 #define OP_swap 95 #define OP_iadd 96 #define OP_ladd 97 #define OP_fadd 98 #define OP_dadd 99 #define OP_isub 100 #define OP_lsub 101 #define OP_fsub 102 #define OP_dsub 103 #define OP_imul 104 #define OP_lmul 105 #define OP_fmul 106 #define OP_dmul 107 #define OP_idiv 108 #define OP_ldiv 109 #define OP_fdiv 110 #define OP_ddiv 111 #define OP_irem 112 #define OP_lrem 113 #define OP_frem 114 #define OP_drem 115 #define OP_ineg 116 #define OP_lneg 117 #define OP_fneg 118 #define OP_dneg 119 #define OP_ishl 120 #define OP_lshl 121 #define OP_ishr 122 #define OP_lshr 123 #define OP_iushr 124 #define OP_lushr 125 #define OP_iand 126 #define OP_land 127 #define OP_ior 128 #define OP_lor 129 #define OP_ixor 130 #define OP_lxor 131 #define OP_iinc 132 #define OP_i2l 133 #define OP_i2f 134 #define OP_i2d 135 #define OP_l2i 136 #define OP_l2f 137 #define OP_l2d 138 #define OP_f2i 139 #define OP_f2l 140 #define OP_f2d 141 #define OP_d2i 142 #define OP_d2l 143 #define OP_d2f 144 #define OP_i2b 145 #define OP_i2c 146 #define OP_i2s 147 #define OP_lcmp 148 #define OP_fcmpl 149 #define OP_fcmpg 150 #define OP_dcmpl 151 #define OP_dcmpg 152 #define OP_ifeq 153 #define OP_ifne 154 #define OP_iflt 155 #define OP_ifge 156 #define OP_ifgt 157 #define OP_ifle 158 #define OP_if_icmpeq 159 #define OP_if_icmpne 160 #define OP_if_icmplt 161 #define OP_if_icmpge 162 #define OP_if_icmpgt 163 #define OP_if_icmple 164 #define OP_if_acmpeq 165 #define OP_if_acmpne 166 #define OP_goto 167 #define OP_jsr 168 #define OP_ret 169 #define OP_tableswitch 170 #define OP_lookupswitch 171 #define OP_ireturn 172 #define OP_lreturn 173 #define OP_freturn 174 #define OP_dreturn 175 #define OP_areturn 176 #define OP_return 177 #define OP_getstatic 178 #define OP_putstatic 179 #define OP_getfield 180 #define OP_putfield 181 #define OP_invokevirtual 182 #define OP_invokespecial 183 #define OP_invokestatic 184 #define OP_invokeinterface 185 #define OP_new 187 #define OP_newarray 188 #define OP_anewarray 189 #define OP_arraylength 190 #define OP_athrow 191 #define OP_checkcast 192 #define OP_instanceof 193 #define OP_monitorenter 194 #define OP_monitorexit 195 #define OP_wide 196 #define OP_multianewarray 197 #define OP_ifnull 198 #define OP_ifnonnull 199 #define OP_goto_w 200 #define OP_jsr_w 201 #define OP_breakpoint 202 #endif --- NEW FILE: thread.h --- /* * $Id: thread.h,v 1.1 2004/07/10 15:30:41 mriem Exp $ * * Copyright (c) 2001, 2002, 2003, Waba @ Sourceforge. * Copyright (c) 1998, 1999, 2000, Wabasoft. * All Rights Reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * ---------------------------------------------------------------------------- * * Defines support for threads. * * ---------------------------------------------------------------------------- */ #ifndef __THREAD_H__ #define __THREAD_H__ #endif --- NEW FILE: types.h --- /* * $Id: types.h,v 1.1 2004/07/10 15:30:41 mriem Exp $ * * Copyright (c) 2001, 2002, 2003, Waba @ Sourceforge. * Copyright (c) 1998, 1999, 2000, Wabasoft. * All Rights Reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * ---------------------------------------------------------------------------- * * Defines the basic types used in the VM. * * ---------------------------------------------------------------------------- */ #ifndef __TYPES_H__ #define __TYPES_H__ #if defined(DOS) #include "dos/nmdos_a.h" #elif defined(LINUX) #include "linux/nm_linux_a.h" #elif defined(PALMOS) #include "palm/nmpalm_a.h" #elif defined(TOPPERS) #include "toppers/nmtoppers_a.h" #elif defined(WIN32) #include "nmwin32_a.h" #elif defined(WINCE) #include "win32/nmwin32_a.h" #endif #endif --- NEW FILE: waba.c --- /* * $Id: waba.c,v 1.1 2004/07/10 15:30:41 mriem Exp $ * * Copyright (c) 2001, 2002, 2003, Waba @ Sourceforge. * Copyright (C) 1998, 1999, 2000, Wabasoft. * All Rights Reserved. * * --------------------------------------------------------------------------- * * 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 of the * License, 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. * [...5445 lines suppressed...] stack++; } else if (pushReturnedValue == 2) { stack[0] = returnedValue; stack[1] = returnedValue2; stack += 2; } var = (Var *)vmStack[--vmStackPtr].refValue; pc = vmStack[--vmStackPtr].pc; wclass = (WClass *)vmStack[vmStackPtr - 1].refValue; method = (WClassMethod *)vmStack[vmStackPtr - 2].refValue; goto step; } /* * --END */ --- NEW FILE: waba.h --- /* * $Id: waba.h,v 1.1 2004/07/10 15:30:41 mriem Exp $ * * Copyright (c) 2001, 2002, 2003, Waba @ Sourceforge. * Copyright (c) 1998, 1999, 2000, Wabasoft. * All Rights Reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * -------------------------------------------------------------------------- * * "True words are not beautiful, beautiful words are not true. * The good are not argumentative, the argumentative are not good. * Knowers do not generalize, generalists do not know. * Sages do not accumulate anything but give everything to others, * having more the more they give. * The Way of heaven helps and does not harm. * The Way for humans is to act without contention." * * - Lao-tzu, Tao Te Ching circa 500 B.C. * * -------------------------------------------------------------------------- */ #ifndef __WABA_H__ #define __WABA_H__ #include "config.h" #include "types.h" #include "debug.h" #include "error.h" #include "exception.h" #include "opcodes.h" #include "constants.h" #include "thread.h" // // TYPES AND METHODS // // Access flags #define ACCESS_PUBLIC 0x0001 #define ACCESS_PRIVATE 0x0002 #define ACCESS_PROTECTED 0x0004 #define ACCESS_STATIC 0x0008 #define ACCESS_FINAL 0x0010 #define ACCESS_SYNCHRONIZED 0x0020 #define ACCESS_VOLATILE 0x0040 #define ACCESS_TRANSIENT 0x0080 #define ACCESS_NATIVE 0x0100 #define ACCESS_INTERFACE 0x0200 #define ACCESS_ABSTRACT 0x0400 // Constant Pool tags #define CONSTANT_Utf8 1 #define CONSTANT_Integer 3 #define CONSTANT_Float 4 #define CONSTANT_Long 5 #define CONSTANT_Double 6 #define CONSTANT_Class 7 #define CONSTANT_String 8 #define CONSTANT_Fieldref 9 #define CONSTANT_Methodref 10 #define CONSTANT_InterfaceMethodref 11 #define CONSTANT_NameAndType 12 // flags for stringToUtf() #define STU_NULL_TERMINATE 1 #define STU_USE_STATIC 2 // // types and accessors // typedef uint32 WObject; typedef union { int32 intValue; float32 floatValue; void *classRef; uchar *pc; void *refValue; WObject obj; #ifdef WITH_64BITS // long/double support : comming from SuperWaba 2.0beta1 guich@200 // stored in two consecutive Var Lo first, Hi then int32 int64ValueHalf; int32 float64ValueHalf; #endif /* WITH_64BITS */ } Var; typedef Var (*NativeFunc)(Var stack[]); typedef void (*ObjDestroyFunc)(WObject obj); // // more types and accessors // #define WOBJ_class(o) (objectPtr(o))[0].classRef #define WOBJ_var(o, idx) (objectPtr(o))[idx + 1] // NOTE: These get various values in objects at defined offsets. // If the variables in the base classes change, these offsets will // need to be recomputed. For example, the first (StringCharArray) // get the character array var offset in a String object. #define WOBJ_StringCharArrayObj(o) (objectPtr(o))[1].obj #define WOBJ_StringBufferStrings(o) (objectPtr(o))[1].obj #define WOBJ_StringBufferCount(o) (objectPtr(o))[2].intValue #define WOBJ_arrayType(o) (objectPtr(o))[1].intValue #define WOBJ_arrayLen(o) (objectPtr(o))[2].intValue #define WOBJ_arrayStart(o) (&(objectPtr(o)[3])) // for faster access #define WOBJ_arrayTypeP(objPtr) (objPtr)[1].intValue #define WOBJ_arrayLenP(objPtr) (objPtr)[2].intValue #define WOBJ_arrayStartP(objPtr) (&(objPtr[3])) typedef struct UtfStringStruct { char *str; uint32 len; } UtfString; typedef union { // FieldVar is either a reference to a static class variable (staticVar) // or an offset of a local variable within an object (varOffset) Var staticVar; uint32 varOffset; // computed var offset in object } FieldVar; typedef struct WClassFieldStruct { uchar *header; FieldVar var; #ifdef WITH_64BITS FieldVar var2; // guich@200 - one more int32 to hold 64 bit values #endif /* WITH_64BITS */ } WClassField; #define FIELD_accessFlags(f) getUInt16(f->header) #define FIELD_nameIndex(f) getUInt16(&f->header[2]) #define FIELD_descIndex(f) getUInt16(&f->header[4]) #define FIELD_isStatic(f) ((FIELD_accessFlags(f) & ACCESS_STATIC) > 0) typedef union { // Code is either pointer to bytecode or pointer to native function // NOTE: If accessFlags(method) & ACCESS_NATIVE then nativeFunc // is set, otherwise codeAttr is set. Native methods don't have // maxStack, maxLocals so it is OK to merge the codeAttr w/nativeFunc. uchar *codeAttr; NativeFunc nativeFunc; } Code; typedef struct { uint16 count; uchar *table; } ExceptionTable; typedef struct WClassMethodStruct { uchar *header; Code code; ExceptionTable exception_table; /* If the method has no exception, value is NULL */ uint16 numParams:14; uint16 returnsValue:1; uint16 isInit:1; } WClassMethod; #define METH_accessFlags(m) getUInt16(m->header) #define METH_nameIndex(m) getUInt16(&m->header[2]) #define METH_descIndex(m) getUInt16(&m->header[4]) #define METH_maxStack(m) getUInt16(&m->code.codeAttr[6]) #define METH_maxLocals(m) getUInt16(&m->code.codeAttr[8]) #define METH_codeCount(m) getUInt32(&m->code.codeAttr[10]) #define METH_code(m) &m->code.codeAttr[14] #define CONS_offset(wc, idx) wc->constantOffsets[idx - 1] #define CONS_ptr(wc, idx) (wc->byteRep + CONS_offset(wc, idx)) #define CONS_tag(wc, idx) CONS_ptr(wc, idx)[0] #define CONS_utfLen(wc, idx) getUInt16(&CONS_ptr(wc, idx)[1]) #define CONS_utfStr(wc, idx) &CONS_ptr(wc, idx)[3] #define CONS_integer(wc, idx) getInt32(&CONS_ptr(wc, idx)[1]) #define CONS_float(wc, idx) getFloat32(&CONS_ptr(wc, idx)[1]) #define CONS_stringIndex(wc, idx) getUInt16(&CONS_ptr(wc, idx)[1]) #define CONS_classIndex(wc, idx) getUInt16(&CONS_ptr(wc, idx)[1]) #define CONS_nameAndTypeIndex(wc, idx) getUInt16(&CONS_ptr(wc, idx)[3]) #define CONS_nameIndex(wc, idx) getUInt16(&CONS_ptr(wc, idx)[1]) #define CONS_typeIndex(wc, idx) getUInt16(&CONS_ptr(wc, idx)[3]) #ifdef WITH_64BITS /* guich@200: added to handle 64bit numbers */ #define CONS_double(wc, idx) getFloat64bits(&CONS_ptr(wc, idx)[1]) #define CONS_long(wc, idx) getInt64bits(&CONS_ptr(wc, idx)[1]) /* end guich@200 modification */ #endif /* WITH_64BITS */ // The VM keeps an array of constant offsets for each constant in a class // in the runtime class structure (see WClassStruct). For each constant, // the offset is an offset from the start of the bytes defining the class. // Depdending on whether SMALLMEM is defined, the offset is either a 16 or // 32 bit quantity. So, if SMALLMEM is defined, the maximum offset is 2^16. // However, we also keep a bit in the constant to determine whether the // constant is an offset that is "bound" or not. So, the maximum value of // an offset if SMALLMEM is defined (the small memory model) is 32767. // // This means under the small memory model, the biggest class constant // pool we can have is 32K. Under the large memory model (SMALLMEM not // defined) the maximum class constant pool size that we could have is // 2^31 bytes. Using SMALLMEM can save quite a bit of memory since // constant pools tend to be large. // // When a constant offset is "bound", instead of the offset being // an offset into the constant pool, it is (with the exception of methods) // a pointer offset from the start of the class heap to the actual data // the constant refers to. // // For example, when a field constant is bound, it contains an offset // from the start of the class heap to the actual WClassField * structure // for the field. For class offsets, it is an offset to the WClass * // structure. For method offsets, the offset is a virtual method number // and class index. Only class, field and methods can be bound. // // A bound offset will only be bound if the offset of the actual structure // in the class heap is within the range that can fit in the offset. For // example, in a small memory model, if a WClassField * structure exists // beyond 32K from the start of the class heap, its offset can't be bound. // If that happens, the offset simply won't be bound and will retain // an offset into the constant pool (known now as an "adaptive bind"). // // Binding of constants (adaptive quickbind) will only be performed if // QUICKBIND is defined. When an offset is bound, it's CONS_boundBit // will be set to 1. #ifdef SMALLMEM typedef uint16 ConsOffset; #define MAX_consOffset 0x7FFF #define CONS_boundBit 0x8000 #define CONS_boundOffsetMask 0x7FFF // 1 bit for bound bit, 7 bits for method, 8 bits for class index #define MAX_boundMethodNum 127 #define MAX_boundClassIndex 255 #define CONS_boundMethodShift 8 #define CONS_boundClassMask 0xFF; #else typedef uint32 ConsOffset; #define MAX_consOffset 0x7FFFFFFF #define CONS_boundBit 0x80000000 #define CONS_boundOffsetMask 0x7FFFFFFF // 1 bit for bound bit, 15 bits for method, 16 bits for class index #define MAX_boundMethodNum 32767 #define MAX_boundClassIndex 65535 #define CONS_boundMethodShift 16 #define CONS_boundClassMask 0xFFFF; #endif #ifdef QUICKBIND typedef struct { uint16 classNum:6; uint16 methodNum:10; } VMapValue; #define MAX_superClassNum 63 #define MAX_methodNum 1023 typedef struct { VMapValue *mapValues; // maps virtual method number to class, virtual method index uint16 mapSize; // size of map = number of inherited methods uint16 numVirtualMethods; // number of new virtual methods in the class uint16 numOverriddenMethods; // number of overridden methods in the class } VirtualMethodMap; // search types for getMethodMapNum() #define SEARCH_METHOD_ALL 0 #define SEARCH_METHOD_INHERITED 1 #define SEARCH_METHOD_THISCLASS 2 // keep this a prime number for best distribution #define OVERRIDE_HASH_SIZE 127 #endif /* QUICKBIND */ // NOTE: In the following structure, a constant offset can either be // bound (by having boundBit set) in which case it is an offset into // the classHeap directly or unbound in which case it is an offset into // the byteRep of the class typedef struct WClassStruct { struct WClassStruct **superClasses; // array of this classes superclasses uint16 numSuperClasses; uint16 classNameIndex; uchar *byteRep; // pointer to class representation in memory (bytes) uchar *attrib2; // pointer to area after constant pool (accessFlags) uint16 numConstants; ConsOffset *constantOffsets; uint16 numFields; WClassField *fields; uint16 numMethods; WClassMethod *methods; #ifdef QUICKBIND VirtualMethodMap vMethodMap; #endif uint16 numVars; // computed number of object variables ObjDestroyFunc objDestroyFunc; struct WClassStruct *nextClass; // next class in hash table linked list } WClass; #define WCLASS_accessFlags(wc) getUInt16(wc->attrib2) #define WCLASS_thisClass(wc) getUInt16(&wc->attrib2[2]) #define WCLASS_superClass(wc) getUInt16(&wc->attrib2[4]) #define WCLASS_numInterfaces(wc) getUInt16(&wc->attrib2[6]) #define WCLASS_interfaceIndex(wc, idx) getUInt16(&wc->attrib2[8 + (idx * 2)]) #define WCLASS_objectSize(wc) ((wc->numVars + 1) * sizeof(Var)) #define WCLASS_isInterface(wc) ((WCLASS_accessFlags(wc) & ACCESS_INTERFACE) > 0) typedef struct { uint16 errNum; char className[40]; char methodName[40]; char arg1[40]; char arg2[40]; } ErrorStatus; // // private function prototypes // #ifdef WITH_THREAD_NATIVE CRITICAL_SECTION vmThreadLock; CRITICAL_SECTION nmThreadLock; Var* getVmStack(void); WObject* getNmStack(void); uint32 getVmStackSizeInBytes(void); uint32 getNmStackSizeInBytes(void); #endif void VmInit(uint32 vmStackSizeInBytes, uint32 nmStackSizeInBytes, uint32 classHeapSize, uint32 objectHeapSize); WObject VmStartApp(char *className); int VmStartApplication(char *className, int argc, char** argv); //SD void VmStopApp(WObject mainWinObj); void VmFree(); WClass *findLoadedClass(UtfString className); WClass *getClass(UtfString className); uchar *nativeLoadClass(UtfString className, uint32 *size); void freeClass(WClass *wclass); uchar *loadClassConstant(WClass *wclass, uint16 idx, uchar *p); uchar *loadClassField(WClass *wclass, WClassField *field, uchar *p); Var constantToVar(WClass *wclass, uint16 idx); uchar *loadClassMethod(WClass *wclass, WClassMethod *method, uchar *p); #ifdef QUICKBIND int createVirtualMethodMap(WClass *wclass); #endif UtfString createUtfString(char *buf); UtfString getUtfString(WClass *wclass, uint16 idx); WObject createObject(WClass *wclass); int32 arrayTypeSize(int32 type); int32 arraySize(int32 type, int32 len); WObject createArrayObject(int32 type, int32 len); uint16 arrayType(char c); WObject createMultiArray(int32 ndim, char *desc, Var *sizes); WObject createStringFromUtf(UtfString s); WObject createString(char *buf); UtfString stringToUtf(WObject str, int flags); int arrayRangeCheck(WObject array, int32 start, int32 count); Var copyArray(Var stack[]); WClassField *getField(WClass *wclass, UtfString name, UtfString desc); WClass *getClassByIndex(WClass *wclass, uint16 classIndex); #ifdef QUICKBIND int compareMethodNameDesc(WClass *wclass, uint16 mapNum, UtfString name, UtfString desc); int32 getMethodMapNum(WClass *wclass, UtfString name, UtfString desc, int searchType); WClassMethod *getMethodByMapNum(WClass *wclass, WClass **vclass, uint16 mapNum); #endif WClassMethod *getMethod(WClass *wclass, UtfString name, UtfString desc, WClass **vclass); int32 countMethodParams(UtfString desc); int compatible(WClass *wclass, WClass *target); int compatibleArray(WObject obj, UtfString arrayName); uint32 getUnusedMem(); int initObjectHeap(uint32 heapSize); void freeObjectHeap(); void markObject(WObject obj); void sweep(); void gc(); WObject allocObject(int32 size); Var *objectPtr(WObject obj); int pushObject(WObject obj); WObject popObject(); NativeFunc getNativeMethod(WClass *wclass, UtfString methodName, UtfString methodDesc); void setClassHooks(WClass *wclass); #ifdef WITH_THREAD_NATIVE DWORD WINAPI executeMethod(void* passedWParams); #else void executeMethod( WClass *wclass, WClassMethod *method, Var params[], uint32 numParams); #endif unsigned char * loadClassFrmJar(char * jar, char * classname, int * size); uint32 ucsToUc(uint16* ucsStr, uint16* ucStr, uint32 ucsStrSize); #ifdef WITH_64BITS // guich@200 - transforms 2 consecutive vars in one long // the first var stores the lower 32 bits and // the 2nd var stores the upper 32 bits of the double int64 vars2int64(Var *v); // guich@200 - transforms 2 consecutive vars in one double; // the first var stores the lower 32 bits and // the 2nd var stores the upper 32 bits of the double float64 vars2double(Var *v); #endif /* WITH_64BITS */ // // global vars // /* Main qualified class name */ char * mainClassName; #ifdef USE_VIRTUAL_KBD /* Flag indicating whether to open the virtual keyboard upon startup */ extern int withVirtualKeyboard; #endif /* USE_VIRTUAL_KBD */ extern int vmInitialized; extern int isApplication; // virtual machine stack extern Var *vmStack; extern uint32 vmStackSize; // in Var units extern uint32 vmStackPtr; // native method stack extern WObject *nmStack; extern uint32 nmStackSize; // in WObject units extern uint32 nmStackPtr; // keep these prime numbers for best distribution #ifdef SMALLMEM #define CLASS_HASH_SIZE 63 #else #define CLASS_HASH_SIZE 255 #endif // class heap extern uchar *classHeap; extern uint32 classHeapSize; extern uint32 classHeapUsed; extern WClass *classHashList[CLASS_HASH_SIZE]; // error status extern ErrorStatus vmStatus; // pointer to String class (for performance) extern WClass *stringClass; // // Native Methods and Hooks // typedef struct { char *className; ObjDestroyFunc destroyFunc; uint16 varsNeeded; } ClassHook; typedef struct { uint32 hash; NativeFunc func; } NativeMethod; #if defined(PALMOS) #include "palm/nmpalm_b.h" #include "palm/nmpalm_c.h" #elif defined(WIN32) #include "win32/nmwin32_b.h" #include "win32/nmwin32_c.h" #elif defined(WINCE) #include "win32/nmwin32_b.h" #include "win32/nmwin32_c.h" #elif defined(LINUX) #include "linux/nm_linux_b.h" #include "linux/nm_linux_c.h" #include "linux/debug.h" #elif defined(TOPPERS) #include "toppers/nmtoppers_b.h" #include "toppers/nmtoppers_c.h" #elif defined(DOS) #include "dos/nmdos_b.h" #include "dos/nmdos_c.h" #endif #endif |
|
From: Manfred R. <mr...@us...> - 2004-07-10 15:30:51
|
Update of /cvsroot/waba/waba/src/port/c In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10313/src/port/c Added Files: nmport_a.c nmport_a.h nmport_b.c nmport_b.h nmport_c.c nmport_c.h Log Message: Moved sources to new location --- NEW FILE: nmport_a.c --- /* $Id: nmport_a.c,v 1.1 2004/07/10 15:30:41 mriem Exp $ Copyright (C) 1998, 1999, 2000 Wabasoft 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 of the License, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* This file is modified by Monaka (mo...@mo...) */ /* This file is the starting point when porting the WabaVM to a new platform. To port the WabaVM, you need to fill in platform dependent code in 3 files: - nm<platform>_a.c - nm<platform>_b.c - nm<platform>_c.c The nm stands for 'native methods'. The 3 files contain: - code to deal with platform-specific type sizes and byte order - code to allocate a few blocks of memory - code to load a class from memory or disk - the main application loop - native functions This file contains the code to deal with platform-specific types and allocation of blocks of memory. To port the VM, read though the comments and look for the 'WHEN PORTING' comments and fill in what you need to. You'll probably want to take a look at waba.c as you go along to see where the code is used. A WabaVM is comprised of the 3 native function files and the VM code itself contained in waba.c */ // WHEN PORTING: define FREE_ON_EXIT if you want all object destructors // to be called when the program exits. Under OS's that release system // resources automatically, you don't need to do this. On OS's that don't // automatically release system resources (images, memory, etc.) that // native functions may allocate, you should set this to 1 so when // the waba program exits, all native method object destructors get called // to clean things up #define FREE_ON_EXIT 1 // WHEN PORTING: You need to define the basic types of uchar, int32, etc. // for the platform being ported to as follows: // // - uchar is an 8 bit unsigned value // - int32 is a signed 32 bit value // - uint32 is an unsigned 32 bit value // - float32 is a signed 32 bit floating point value // - int16 is a signed 16 bit value // - uint16 is an unsigned 16 bit value // // below is an example from PalmOS /* all the needed include */ #include "../waba.h" // // type converters // #ifdef WITH_64BITS // get one 64 float value from buf and return it float64 getFloat64bits(uchar *buf) { float64HiLo fhl; fhl.ul.lo = getInt32( buf ); fhl.ul.hi = getInt32( buf + 4 ); return fhl.value; } // get one 64 float value from buf and return it int64 getInt64bits(uchar *buf) { int64HiLo ihl; ihl.ul.lo = getInt32( buf ); ihl.ul.hi = getInt32( buf + 4 ); return ihl.value; } #endif /* WITH_64BITS */ float32 getFloat32(uchar *buf) { uint32 i; float32 f; // we need to make sure we're aligned before casting i = ((uint32)buf[0] << 24) | ((uint32)buf[1] << 16) | ((uint32)buf[2] << 8) | (uint32)buf[3]; f = *((float32 *)&i); return f; } --- NEW FILE: nmport_a.h --- /* $Id: nmport_a.h,v 1.1 2004/07/10 15:30:41 mriem Exp $ Copyright (C) 1998, 1999, 2000 Wabasoft 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 of the License, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* This file is modified by Monaka (mo...@mo...) */ #undef FREE_ON_EXIT #undef SECURE_CLASS_HEAP #define LOCK_CLASS_HEAP #define UNLOCK_CLASS_HEAP #define uchar unsigned char #define int32 long #define uint32 unsigned long #define float32 float #define int16 short #define uint16 unsigned short #ifdef WITH_64BITS // - int64 is a signed 64 bit value #define int64 long long // - uint64 is an unsigned 64 bit value #define uint64 unsigned long long // - float64 is a signed 64 bit floating point value #define float64 double // --- define a struct for double and long support in two Var ... // ... the hi/lo decomposition typedef struct { uint32 lo; uint32 hi; } HiLoDoubleOrLong; //... for the double typedef union { float64 value; HiLoDoubleOrLong ul; } float64HiLo; //... for the long typedef union { int64 value; HiLoDoubleOrLong ul; } int64HiLo; #endif /* WITH_64BITS */ // WHEN PORTING: You need to define functions that convert a string // of 2 or 4 bytes in network byte order to a 16 or 32 bit value as follows: // // getUInt32() - converts 4 bytes to a unsigned 32 bit integer // getUInt16() - converts 2 bytes to a unsigned 16 bit integer // getInt32() - converts 4 bytes to a signed 32 bit integer // getInt16() - converts 2 bytes to a signed 16 bit integer // // Here is an example from PalmOS, you can make these functions instead of // a macro if you want the executable to be smaller #define getUInt32(b) (uint32)( (uint32)((b)[0])<<24 | (uint32)((b)[1])<<16 | (uint32)((b)[2])<<8 | (uint32)((b)[3]) ) #define getUInt16(b) (uint16)(((b)[0]<<8)|(b)[1]) #define getInt32(b) (int32)( (uint32)((b)[0])<<24 | (uint32)((b)[1])<<16 | (uint32)((b)[2])<<8 | (uint32)((b)[3]) ) #define getInt16(b) (int16)(((b)[0]<<8)|(b)[1]) #ifdef WITH_64BITS // WHEN PORTING: You need to define functions that convert a string // of 8 bytes in network byte order to a 64 bit value as follows: // get one 8byte float value from buf and return it float64 getFloat64bits(uchar *buf); // get one 8byte int value from buf and return it int64 getInt64bits(uchar *buf); #endif /* WITH_64BITS */ // WHEN PORTING: You need to define a function that converts 4 bytes in // network byte order to a 32 bit floating point value // // Here is an example from PalmOS: static float32 getFloat32(uchar *buf) { uint32 i; float32 f; // we need to make sure we're aligned before casting i = ((uint32)buf[0] << 24) | ((uint32)buf[1] << 16) | ((uint32)buf[2] << 8) | (uint32)buf[3]; f = *((float32 *)&i); return f; } // WHEN PORTING: You need to define the following functions: // // xstrncmp(s1, s2, n) - compares 2 strings n bytes up to a 0 terminator // xstrncpy(s1, s2, n) - copies 2 strings n bytes up to a 0 terminator // xstrlen(s) - returns the length of a string // xstrcat(dst, src) - concats one string to another // xmemmove(dst, src, size) - copies size bytes from src to dst // xmemzero(mem, len) - zeros out len bytes at location mem // // You could find the native functions that map to the above functions // or (easier) just use the ones below. In any case, its probably best // to use the ones below first and then you switch out after things // are running in case the machines functions don't do exactly what // is expected. static int xstrncmp(char *s1, char *s2, uint32 n) { uint32 i; for (i = 0; i < n; i++) if (s1[i] != s2[i]) return 1; return 0; } static void xstrncpy(char *dst, char *src, uint32 n) { uint32 i; for (i = 0; i < n; i++) dst[i] = src[i]; } static uint32 xstrlen(char *s) { uint32 len; len = 0; while (*s != 0) { len++; s++; } return len; } static void xstrcat(char *dst, char *src) { while (*dst != 0) dst++; while (*src != 0) *dst++ = *src++; *dst = 0; } static void xmemmove(uchar *dst, uchar *src, uint32 size) { uint32 i; for (i = 0; i < size; i++) dst[i] = src[i]; } static void xmemzero(uchar *mem, uint32 len) { uint32 i; for (i = 0; i < len; i++) mem[i] = 0; } // WHEN PORTING: You need to define a function that allocates a block // of memory and a function that frees a block of memory. The WabaVM // allocates 4 blocks of memory when it starts up and these methods // are only used to allocate and free those 4 blocks of memory. When // the VM is running, it does not call these functions. So, if you have // a processor without any heap management, it should be rather easy // to get the VM running. Just allocate 4 blocks of memory for it and // return pointers to them below. You don't need a heap based malloc() // implementation or anything to run with the WabaVM. The VM does its // own memory management within the 4 blocks. // // The two functions you need to implement are: // // xmalloc(size) - allocates size bytes of memory and returns a pointer // xfree(ptr) - frees the memory allocated previously // // On platforms that have malloc() and free, we can simply use them as // follows: #define xmalloc(size) malloc(size); #define xfree(ptr) free(ptr) // WHEN PORTING: That's it for the types and memory allocation, the next // step is to implement the class loader and native functions in the // nm<platform>_b.c and nm<platform>_c.c files --- NEW FILE: nmport_b.c --- /* $Id: nmport_b.c,v 1.1 2004/07/10 15:30:41 mriem Exp $ Copyright (C) 1998, 1999, 2000 Wabasoft 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 of the License, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* If you're looking here, you've probably already looked at (or worked on) the nm<platform>_a.c file. This file is the second step in porting the VM. In it, you need to place the main application loop and class loader. If you get through this, you'll have a basic VM running and from there you can implement the native functions so you can actually see something on the screen. The WabaVM, like other applications, needs some type of main application loop where the OS sends it key clicks, mouse presses, etc. The VM also needs to load classes from memory or disk or wherever. Different platforms have different main application loops. For example, under Win32, a program has a WinMain() function. Under PalmOS, applications have a PilotMain() function. You'll want to implement a main application loop for the platform you are porting to. Then, when things start up (initialization), you need to: - parse the launch command and then call VmInit() - call VmStartApp passing the class name of the program's main window You'll also need to figure out how programs will launch the VM. The VM is normally passed parameters telling it what class heap, class name, etc. to use. It's usually another program that does this but you could do it by building a waba launcher that draws a tray of icons and when you click one, it runs the WabaVM with various parameters as an example of something different. Whatever you do for this is platform-specific. Just before the program exits, you'll should call VmStopApp(mainWinObj); That's it for initialization and exit, then you need to do some work to hook up key presses, mouse presses, etc. to the VM. When a key is pressed, you'll want to invoke the main window's onEvent() method. Here's an example of how to do that: mainWinObj = globalMainWin; if (!mainWinObj) return; vclass = WOBJ_class(mainWinObj); // get runtime class method = getMethod(vclass, createUtfString("_postEvent"), createUtfString("(IIIIII)V"), &vclass); if (method != NULL) { params[0].obj = mainWinObj; params[1].intValue = type; // type params[2].intValue = key; // key params[3].intValue = 0; // x params[4].intValue = 0; // y params[5].intValue = 0; // modifiers params[6].intValue = 0; // timeStamp executeMethod(vclass, method, params, 7); } This gets the runtime class of the main window object, gets a reference to the _postEvent method, fills in an array of parameters to pass and then calls executeMethod() to execute the method. There is also a quickbind version of this which is quicker than the above. You can look at nmpalm_b.c or nmwin32_b.c to get an idea how that works (look for the #ifdef QUICKBIND) but you should start without using the quickbind method. You'll want to hook up mouse or pen click, key presses, calls from the OS to repaint the window (which should call the main window's _doPaint routine). Overall, you need to make sure the following main window functions get called: _onTimerTick() _postEvent() for key presses and mouse/pen clicks and moves You'll need to map special keys (escape, etc.) if the device has them to suitable numbers for waba. To do this, you can see how the other native implementations do key mapping (a big switch statement). The _onTimerTick() one can be tricky for devices that don't have a built in timer (like PalmOS). When using one of those devices, copy the code from the nmpalm_b.c to deal with timers. Basically, this consists of getting the current time and looking for an event up until the time the next timer period expires. The VM only needs a single timer, the waba core classes have the code to support multiple timers even though the underlying system only supports a single one. The last code you need to implement is: nativeLoadClass() This is the function that load a class from memory, disk or whatever. It looks like this: static uchar *nativeLoadClass(UtfString className, uint32 *size) and it is passed a class name (not zero terminated, the UtfString contains the len in: className.len and it returns a pointer to the class in memory after it is loaded and fills in the *size variable with the size of the class in bytes. The classes loaded are classes that are compiled by a java compiler or other compiler that can generate code in the subset of java bytecode that waba supports. */ /* all the needed include */ #include "../waba.h" #ifdef WITH_THREAD /* PORT: If you wanna use thread, you need to define function follows * so that they are required by waba.c */ //*** This method is called from "start()" method. Var ThreadStart(Var stack[]) { } //*** This method is called from "stop()" method. Var ThreadStop(Var stack[]) { } //*** This method is called from "sleep()" method. Var ThreadSleep(Var stack[]) { } //*** This method is called from "wait()" method. Var ThreadWaitForSignal(Var stack[]) { } Var ThreadSignalAll(Var stack[]) { } //*** This "ThreadCurrentThread()" method is called from "curentThread()" method. Var ThreadCurrentThread(Var stack[]) { Var v; v.obj = 0; return v; } void tickThread(void) { } int registerAsSyncronized(WClassMethod* method) { } void exitFromSyncronized(WClassMethod* method) { } int enterMonitor(WObject obj) { } int exitMonitor(WObject obj) { } #endif --- NEW FILE: nmport_b.h --- /* $Id: nmport_b.h,v 1.1 2004/07/10 15:30:41 mriem Exp $ */ #ifdef WITH_THREAD /* PORT: the required functions by waba.c are follows. */ //*** Isao's Multithread implementation START *** //*** This "_onThreadStart()" method is called from "start()" method. Var ThreadStart(Var stack[]); //*** This "_onThreadStop()" method is called from "stop()" method. Var ThreadStop(Var stack[]); //*** This "_onThreadSleep()" method is called from "sleep()" method. Var ThreadSleep(Var stack[]); //*** This "_onThreadWait()" method is called from "wait()" method. Var ThreadWaitForSignal(Var stack[]); Var ThreadSignalAll(Var stack[]); //*** Isao's Multithread implementation END *** //*** This "ThreadCurrentThread()" method is called from "curentThread()" method. extern Var ThreadCurrentThread(Var stack[]); void tickThread(void); int registerAsSyncronized(WClassMethod* method); void exitFromSyncronized(WClassMethod* method); int enterMonitor(WObject obj); int exitMonitor(WObject obj); #endif /* WITH_THREAD */ --- NEW FILE: nmport_c.c --- /* $Id: nmport_c.c,v 1.1 2004/07/10 15:30:41 mriem Exp $ Copyright (C) 1998, 1999, 2000 Wabasoft 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 of the License, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* This file is modified by Monaka (mon...@mo...) */ #ifdef COMMENT [...992 lines suppressed...] v.obj = 0; return v; } static Var VmSetDeviceAutoOff(Var stack[]) { Var v; v.obj = 0; return v; } static Var VmGetUserName(Var stack[]) { Var v; v.obj = 0; return v; } --- NEW FILE: nmport_c.h --- /* $Id: nmport_c.h,v 1.1 2004/07/10 15:30:41 mriem Exp $ */ #ifndef __NMPORT_C_H__ #define __NMPORT_C_H__ /* Copyright (C) 1998, 1999, 2000 Wabasoft 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 of the License, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ static void WindowDestroy(WObject obj); static void MainWinDestroy(WObject obj); static void GraphicsDestroy(WObject obj); static void ImageDestroy(WObject obj); #if WITH_CATALOG_CLASS static void CatalogDestroy(WObject obj); #endif static void FileDestroy(WObject obj); static void SocketDestroy(WObject obj); static void SerialPortDestroy(WObject obj); extern ClassHook classHooks[]; #define FUNC(f) extern Var f (Var stack[]) /* some generic functions */ FUNC(Return0Func); FUNC(ReturnNeg1Func); /* all the native functions */ #define VmPrint Return0Func #define VmPrintLn Return0Func FUNC(VmExec); FUNC(VmGetTimeStamp); FUNC(copyArray); FUNC(VmExit); FUNC(VmSleep); FUNC(VmSetDeviceAutoOff); FUNC(VmGetUserName); FUNC(VmGetPlatform); FUNC(VmIsColor); FUNC(FileGetLength); FUNC(FileCreateDir); FUNC(FileReadBytes); FUNC(FileRename); FUNC(FileCreate); FUNC(FileWriteBytes); FUNC(FileListDir); FUNC(FileSeekWaba); FUNC(FileIsDir); FUNC(FileCloseWaba); FUNC(FileIsOpen); FUNC(FileDeleteWaba); FUNC(FileExists); FUNC(ImageCreate); FUNC(ImageFree); FUNC(ImageSetPixels); FUNC(ImageUseImagePalette); FUNC(ImageLoad); FUNC(SoundBeep); FUNC(SoundTone); FUNC(TimeCreate); FUNC(SocketCreate); FUNC(SocketRead); FUNC(SocketWrite); FUNC(SocketSetReadTimeout); FUNC(SocketClose); FUNC(SocketIsOpen); FUNC(WindowCreate); #if WITH_CATALOG_CLASS FUNC(CatalogListCatalogs); FUNC(CatalogAddRecord); FUNC(CatalogSkipBytes); FUNC(CatalogCreate); FUNC(CatalogRead); FUNC(CatalogDeleteRecord); FUNC(CatalogSetRecordPos); FUNC(CatalogGetRecordSize); FUNC(CatalogResizeRecord); FUNC(CatalogWrite); FUNC(CatalogGetRecordCount); FUNC(CatalogClose); FUNC(CatalogIsOpen); FUNC(CatalogDelete); #endif //WITH_CATALOG_CLASS FUNC(GraphicsCopyRect); FUNC(GraphicsClearClip); FUNC(GraphicsSetFont); FUNC(GraphicsSetDrawOp); FUNC(GraphicsSetClip); FUNC(GraphicsSetBackColor); FUNC(GraphicsSetColor); FUNC(GraphicsGetClip); FUNC(GraphicsFillRect); FUNC(GraphicsDrawLine); FUNC(GraphicsTranslate); FUNC(GraphicsDrawDots); FUNC(GraphicsDrawChars); FUNC(GraphicsCreate); FUNC(GraphicsDrawCursor); FUNC(GraphicsSetClip); FUNC(GraphicsFree); FUNC(GraphicsSetForeColor); FUNC(GraphicsSetTextColor); FUNC(GraphicsFillPolygon); FUNC(GraphicsDrawString); FUNC(ConvertStringToInt); FUNC(ConvertFloatToIntBitwise); FUNC(ConvertCharToString); FUNC(ConvertIntToFloatBitwise); FUNC(ConvertFloatToString); #if WITH_64BITS FUNC(ConvertDoubleToString); #endif FUNC(ConvertIntToString); #if WITH_64BITS FUNC(ConvertLongToString); #endif FUNC(ConvertBooleanToString); FUNC(SoundClipPlay); FUNC(PalmOsPrefSetPalmOsPref); FUNC(PalmOsPrefGetPalmOsPref); FUNC(MainWinCreate); FUNC(MainWinExit); FUNC(MainWinSetTimerInterval); FUNC(SerialPortReadCheck); FUNC(SerialPortRead); FUNC(SerialPortWrite); FUNC(SerialPortSetReadTimeout); FUNC(SerialPortClose); FUNC(SerialPortSetFlowControl); FUNC(SerialPortIsOpen); FUNC(SerialPortCreate); FUNC(FontMetricsGetStringWidth); FUNC(FontMetricsGetCharWidth); FUNC(FontMetricsCreate); FUNC(FontMetricsGetCharArrayWidth); #endif /* __NMPORT_C_H__ */ |
|
From: Manfred R. <mr...@us...> - 2004-07-10 15:30:51
|
Update of /cvsroot/waba/waba/src/palm/c In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10313/src/palm/c Added Files: nmpalm_a.c nmpalm_a.h nmpalm_b.c nmpalm_b.h nmpalm_c.c nmpalm_c.h Log Message: Moved sources to new location --- NEW FILE: nmpalm_a.c --- /* $Id: nmpalm_a.c,v 1.1 2004/07/10 15:30:40 mriem Exp $ Copyright (C) 1998, 1999, 2000 Wabasoft 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 of the License, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* all the needed include */ #include "../waba.h" #ifndef FASTANDBIG uint32 getUInt32(uchar *b) { return (uint32)( (uint32)((b)[0])<<24 | (uint32)((b)[1])<<16 | (uint32)((b)[2])<<8 | (uint32)((b)[3]) ); } uint16 getUInt16(uchar *b) { return (uint16)(((b)[0]<<8)|(b)[1]); } int32 getInt32(uchar *b) { return (int32)( (uint32)((b)[0])<<24 | (uint32)((b)[1])<<16 | (uint32)((b)[2])<<8 | (uint32)((b)[3]) ); } int16 getInt16(uchar *b) { return (int16)(((b)[0]<<8)|(b)[1]); } #endif #ifdef WITH_64BITS // get one 64 float value from buf and return it float64 getFloat64bits(uchar *buf) { float64HiLo fhl; fhl.ul.lo = getInt32( buf ); fhl.ul.hi = getInt32( buf + 4 ); return fhl.value; } // get one 64 float value from buf and return it int64 getInt64bits(uchar *buf) { int64HiLo ihl; ihl.ul.lo = getInt32( buf ); ihl.ul.hi = getInt32( buf + 4 ); return ihl.value; } #endif /* WITH_64BITS */ float32 getFloat32(uchar *buf) { uint32 i; float32 f; // we need to make sure we're aligned before casting i = ((uint32)buf[0] << 24) | ((uint32)buf[1] << 16) | ((uint32)buf[2] << 8) | (uint32)buf[3]; f = *((float32 *)&i); return f; } // // x portability functions // void* xmalloc(uint32 size) { VoidHand memH; uchar* ptr; // we stick the handle in the first bytes and then return a pointer // inside the memory block. Then when we free it, we can get the // memory handle back to unlock and free it without having to track it. memH = MemHandleNew(sizeof(VoidHand) + size); if(!memH) return NULL; ptr = MemHandleLock(memH); *((VoidHand*)ptr) = memH; ptr += sizeof(VoidHand); return ptr; } void xfree(void *p) { VoidHand memH; uchar* ptr; ptr = (uchar *)p - sizeof(VoidHand); memH = *((VoidHand *)ptr); MemHandleUnlock(memH); MemHandleFree(memH); } --- NEW FILE: nmpalm_a.h --- /* $Id: nmpalm_a.h,v 1.1 2004/07/10 15:30:40 mriem Exp $ */ #ifndef __NMPALM_A_H__ #define __NMPALM_A_H__ #define A_SECTION __attribute__ ((section ("a"))) /* Copyright (C) 1998, 1999, 2000 Wabasoft 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 of the License, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <PalmOS.h> #include <PalmCompatibility.h> #include <SysEvtMgr.h> #include <SerialMgr.h> #include <NetMgr.h> #include <FloatMgr.h> #include <DLServer.h> #define FREE_ON_EXIT 1 #define SECURE_CLASS_HEAP 1 #ifdef SECURE_CLASS_HEAP #define LOCK_CLASS_HEAP MemSemaphoreReserve(1); #define UNLOCK_CLASS_HEAP MemSemaphoreRelease(1); #else #define LOCK_CLASS_HEAP ; #define UNLOCK_CLASS_HEAP ; #endif #define uchar unsigned char #define int32 long #define uint32 unsigned long #define float32 float #define int16 short #define uint16 unsigned short #ifndef TRUE #define TRUE 1 #define FALSE 0 #endif #ifdef WITH_64BITS // - int64 is a signed 64 bit value #define int64 long long // - uint64 is an unsigned 64 bit value #define uint64 unsigned long long // - float64 is a signed 64 bit floating point value #define float64 double // --- define a struct for double and long support in two Var ... // ... the hi/lo decomposition typedef struct { uint32 lo; uint32 hi; } HiLoDoubleOrLong; //... for the double typedef union { float64 value; HiLoDoubleOrLong ul; } float64HiLo; //... for the long typedef union { int64 value; HiLoDoubleOrLong ul; } int64HiLo; #endif /* WITH_64BITS */ // // type converters // #undef FASTANDBIG #ifdef FASTANDBIG #define getUInt32(b) (uint32)( (uint32)((b)[0])<<24 | (uint32)((b)[1])<<16 | (uint32)((b)[2])<<8 | (uint32)((b)[3]) ) #define getUInt16(b) (uint16)(((b)[0]<<8)|(b)[1]) #define getInt32(b) (int32)( (uint32)((b)[0])<<24 | (uint32)((b)[1])<<16 | (uint32)((b)[2])<<8 | (uint32)((b)[3]) ) #define getInt16(b) (int16)(((b)[0]<<8)|(b)[1]) #else uint32 getUInt32(uchar *b) A_SECTION; uint16 getUInt16(uchar *b) A_SECTION; int32 getInt32(uchar *b) A_SECTION; int16 getInt16(uchar *b) A_SECTION; #endif #ifdef WITH_64BITS // get one 64 float value from buf and return it float64 getFloat64bits(uchar *buf); // get one 64 float value from buf and return it int64 getInt64bits(uchar *buf); #endif /* WITH_64BITS */ float32 getFloat32(uchar *buf) A_SECTION; // // x portability functions // #define xstrncmp(s1, s2, n) StrNCompare(s1, s2, n) #define xstrncpy(dst, src, n) StrNCopy(dst, src, (ULong)n) #define xstrlen(s) StrLen(s) #define xstrcat(dst, src) StrCat(dst, src) #define xmemmove(dst, src, size) MemMove(dst, src, size) #define xmemzero(mem, len) MemSet(mem, len, (Byte)0) void* xmalloc(uint32 size) A_SECTION; void xfree(void *p) A_SECTION; #endif /* __NMPALM_A_H__ */ /* Local Variables: c-file-style: "smartdata" End: */ --- NEW FILE: nmpalm_b.c --- /* $Id: nmpalm_b.c,v 1.1 2004/07/10 15:30:40 mriem Exp $ Copyright (C) 1998, 1999, 2000 Wabasoft 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 of the License, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* all the needed include */ #include "../waba.h" [...1401 lines suppressed...] threadProcessIndex = 0; }//End of if(threadListCurrentSize > 0) #endif }//End of if(vmStatus.errNum == 0) else handleErrorWinEvent(&event); //*** Isao's Multithread implementation END *** }//End of while(1) stopApp(mainWinObj); if(globalNetState == NET_IS_OPEN) NetLibClose(globalSocketLibRefNum, false); return 0; } --- NEW FILE: nmpalm_b.h --- /* $Id: nmpalm_b.h,v 1.1 2004/07/10 15:30:40 mriem Exp $ */ #ifndef __NMPALM_B_H__ #define __NMPALM_B_H__ #define B_SECTION __attribute__ ((section ("b"))) /* Copyright (C) 1998, 1999, 2000 Wabasoft 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 of the License, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <PalmOS.h> #include <Chars.h> // globals // PlamOS Version 2.0 or later is supported. // Note that you should use < or >= in these comparisons, // in nearly every case, because 3.0.1 should be treated the same way as 3.0. // If you say "if vers <= 3.0" you'd often do the wrong thing. #define wabaMinVersion sysMakeROMVersion(2,0,0,sysROMStageRelease,0) #define palmOS_Version3p0 sysMakeROMVersion(3,0,0,sysROMStageRelease,0) #define palmOS_Version3p1 sysMakeROMVersion(3,1,0,sysROMStageRelease,0) #define palmOS_Version3p3 sysMakeROMVersion(3,3,0,sysROMStageRelease,0) #define palmOS_Version3p5 sysMakeROMVersion(3,5,0,sysROMStageRelease,0) #define NET_NOT_READY_FOR_OPEN 0 #define NET_READY_FOR_OPEN 1 #define NET_IS_OPEN 2 #define NET_OPEN_FAILED 3 extern WObject globalMainWin; extern int32 globalTimerInterval; extern int32 globalTimerStart; extern int classDbCount; extern DmOpenRef* classDbList; extern ULong appCreatorId; extern Word globalSocketLibRefNum; extern int globalNetState; extern DWord palmOS_ROM_Version; #ifdef QUICKBIND extern int32 postEventMethodMapNum; extern int32 onTimerTickMethodMapNum; #endif /*** Isao F. Yamashita 1218/2000 ***/ extern UInt32 globalScreenDepth; #ifdef WITH_THREAD //*** Isao's Multithread implementation START *** // Thread variables - Isao F. Yamashita 07/25/2000 #define THREAD_LIST_MAX_SIZE 8 typedef struct { WClass* tClass; WObject tObject; WObject syncObject; WClassMethod* syncMethod; int32 runMethodMapNum; int32 syncMethodMapNum; uint32 sleepCountSet; uint32 sleepCountNow; uchar isSleepCountAlreadySet; uchar isWaiting; } WThread; extern WThread wThreadList[THREAD_LIST_MAX_SIZE]; extern uint32 threadListCurrentSize; extern uint32 threadProcessIndex; extern uint32 threadSynchMethodIndex; int InitThread(uint32 stacksize) B_SECTION; //*** This "_onThreadStart()" method is called from "start()" method. Var ThreadStart(Var stack[]) B_SECTION; //*** This "_onThreadStop()" method is called from "stop()" method. Var ThreadStop(Var stack[]) B_SECTION; //*** This "_onThreadSleep()" method is called from "sleep()" method. Var ThreadSleep(Var stack[]) B_SECTION; //*** This "_onThreadWait()" method is called from "wait()" method. Var ThreadWaitForSignal(Var stack[]) B_SECTION; Var ThreadSignalAll(Var stack[]) B_SECTION; //*** Isao's Multithread implementation END *** //*** This "ThreadCurrentThread()" method is called from "curentThread()" method. Var ThreadCurrentThread(Var stack[]) B_SECTION; #define THERE_IS_SOME_THREADS (threadListCurrentSize > 0) void tickThread(void); int registerAsSyncronized(WClassMethod* method); void exitFromSyncronized(WClassMethod* method); int enterMonitor(WObject obj); int exitMonitor(WObject obj); #endif /* WITH_THREAD */ Long millisToTicks(int32 millis) B_SECTION; int32 getTimeStamp() B_SECTION; void postStopEvent() B_SECTION; void drawErrorWin() B_SECTION; void drawMainWin() B_SECTION; void timerCheck() B_SECTION; void handleErrorWinEvent(EventPtr eventP) B_SECTION; void handleMainWinEvent(EventPtr eventP) B_SECTION; Long calcEventTimeout() B_SECTION; int isostrncmp(uchar *s1, uchar *s2, uint16 n) B_SECTION; uchar* lockWarpRec(char* path, uint16 pathLen, uint32* size) B_SECTION; void unlockWarpRec(uchar *ptr, uint16 pathLen) B_SECTION; uchar* nativeLoadClass(UtfString className, uint32* size) B_SECTION; #ifdef SECURE_CLASS_HEAP extern DmOpenRef classHeapDmRef; extern VoidHand classHeapRecH; extern VoidPtr classHeapRecP; void delClassHeapDb(); #endif /* SECURE_CLASS_HEAP */ WObject startApp(int runApp); void stopApp(WObject mainWinObj); DWord PilotMain(Word cmd, Ptr cmdPBP, Word launchFlags); #endif /* __NMPALM_B_H__ */ /* Local Variables: c-file-style: "smartdata" End: */ --- NEW FILE: nmpalm_c.c --- /* $Id: nmpalm_c.c,v 1.1 2004/07/10 15:30:40 mriem Exp $ Copyright (C) 1998, 1999, 2000 Wabasoft 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 of the License, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ // NOTE: General rule for native functions.. don't hold a pointer across any // call that could garbage collect. For example, this isn't good: [...3873 lines suppressed...] Var PalmOsPrefSetPalmOsPref(Var stack[]) { Var v; WObject prefArray; UInt32 screenDepth; uchar* prefDataPtr; v.intValue = 0; prefArray = stack[1].obj; prefDataPtr = (uchar*)WOBJ_arrayStart(prefArray); screenDepth = (UInt32)prefDataPtr[0]; PrefSetAppPreferences('WABA', 0, 2, &screenDepth, sizeof(UInt32), false); return v; } --- NEW FILE: nmpalm_c.h --- /* $Id: nmpalm_c.h,v 1.1 2004/07/10 15:30:40 mriem Exp $ */ #ifndef __NMPALM_C_H__ #define __NMPALM_C_H__ #define C_SECTION __attribute__ ((section ("c"))) /* Copyright (C) 1998, 1999, 2000 Wabasoft 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 of the License, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ // NOTE: General rule for native functions.. don't hold a pointer across any // call that could garbage collect. For example, this isn't good: // // ptr = WOBJ_arrayStart(array) // ... // string = createString(..) // ptr[0] // // since the createString() could GC, the ptr inside of array could be invalid // after the call since a GC would move memory around. Instead, use: // // ptr = WOBJ_arrayStart(array) // ... // string = createString(..) // ... // ptr = WOBJ_arrayStart(array) // ptr[0] // // to recompute the pointer after the possible GC // NOTE: If you subclass a class with an object destroy function, you must // explicity call your superclasses object destroy function. #include <SerialMgrOld.h> #include <FileStream.h> #include <Bitmap.h> void GraphicsDestroy(WObject obj) C_SECTION; void ImageDestroy(WObject obj) C_SECTION; void CatalogDestroy(WObject obj) C_SECTION; void SocketDestroy(WObject obj) C_SECTION; void SerialPortDestroy(WObject obj) C_SECTION; Var ImageCreate(Var stack[]) C_SECTION; extern ClassHook classHooks[]; #define FUNC(f) extern Var f (Var stack[]) C_SECTION /* some generic functions */ FUNC(Return0Func); FUNC(ReturnNeg1Func); /* all the native functions */ /* FUNC(VmPrintLn); FUNC(VmPrint); */ #define VmPrint Return0Func #define VmPrintLn Return0Func FUNC(VmExec); FUNC(VmGetTimeStamp); FUNC(copyArray); FUNC(VmExit); FUNC(VmSleep); FUNC(VmSetDeviceAutoOff); FUNC(VmGetUserName); FUNC(VmGetPlatform); FUNC(VmIsColor); /* FUNC(FileGetLength); FUNC(FileCreateDir); FUNC(FileReadBytes); FUNC(FileRename); FUNC(FileCreate); FUNC(FileWriteBytes); FUNC(FileListDir); FUNC(FileSeekWaba); FUNC(FileIsDir); FUNC(FileCloseWaba); FUNC(FileIsOpen); FUNC(FileDeleteWaba); FUNC(FileExists); */ #define FileGetLength Return0Func #define FileCreateDir Return0Func #define FileReadBytes ReturnNeg1Func #define FileCreate Return0Func #define FileWriteBytes ReturnNeg1Func #define FileListDir Return0Func #define FileIsDir Return0Func #define FileCloseWaba Return0Func #define FileDeleteWaba Return0Func #define FileExists Return0Func #define FileIsOpen Return0Func #define FileSeekWaba Return0Func #define FileRename Return0Func FUNC(ImageCreate); FUNC(ImageFree); FUNC(ImageSetPixels); FUNC(ImageUseImagePalette); FUNC(ImageLoad); FUNC(SoundBeep); FUNC(SoundTone); FUNC(TimeCreate); FUNC(SocketCreate); FUNC(SocketRead); FUNC(SocketWrite); FUNC(SocketSetReadTimeout); FUNC(SocketClose); FUNC(SocketIsOpen); FUNC(WindowCreate); #if WITH_CATALOG FUNC(CatalogListCatalogs); FUNC(CatalogAddRecord); FUNC(CatalogSkipBytes); FUNC(CatalogCreate); FUNC(CatalogRead); FUNC(CatalogDeleteRecord); FUNC(CatalogSetRecordPos); FUNC(CatalogGetRecordSize); FUNC(CatalogResizeRecord); FUNC(CatalogWrite); FUNC(CatalogGetRecordCount); FUNC(CatalogClose); FUNC(CatalogIsOpen); FUNC(CatalogDelete); #endif FUNC(GraphicsCopyRect); FUNC(GraphicsClearClip); FUNC(GraphicsSetFont); FUNC(GraphicsSetDrawOp); FUNC(GraphicsSetClip); FUNC(GraphicsSetBackColor); FUNC(GraphicsSetColor); FUNC(GraphicsGetClip); FUNC(GraphicsFillRect); FUNC(GraphicsDrawLine); FUNC(GraphicsTranslate); FUNC(GraphicsDrawDots); FUNC(GraphicsDrawChars); FUNC(GraphicsCreate); FUNC(GraphicsDrawCursor); FUNC(GraphicsSetClip); /* FUNC(GraphicsFree); */ #define GraphicsFree Return0Func FUNC(GraphicsSetForeColor); FUNC(GraphicsSetTextColor); FUNC(GraphicsFillPolygon); FUNC(GraphicsDrawString); FUNC(ConvertStringToInt); FUNC(ConvertFloatToIntBitwise); FUNC(ConvertCharToString); FUNC(ConvertIntToFloatBitwise); FUNC(ConvertFloatToString); FUNC(ConvertDoubleToString); FUNC(ConvertIntToString); FUNC(ConvertLongToString); FUNC(ConvertBooleanToString); /* FUNC(SoundClipPlay); */ #define SoundClipPlay Return0Func #define VmPrint Return0Func FUNC(PalmOsPrefSetPalmOsPref); FUNC(PalmOsPrefGetPalmOsPref); FUNC(MainWinCreate); FUNC(MainWinExit); FUNC(MainWinSetTimerInterval); FUNC(SerialPortReadCheck); FUNC(SerialPortRead); FUNC(SerialPortWrite); FUNC(SerialPortSetReadTimeout); FUNC(SerialPortClose); FUNC(SerialPortSetFlowControl); FUNC(SerialPortIsOpen); FUNC(SerialPortCreate); FUNC(FontMetricsGetStringWidth); FUNC(FontMetricsGetCharWidth); FUNC(FontMetricsCreate); FUNC(FontMetricsGetCharArrayWidth); #endif /* __NMPALM_C_H__ */ /* Local Variables: c-file-style: "smartdata" End: */ |
|
From: Manfred R. <mr...@us...> - 2004-07-10 15:30:50
|
Update of /cvsroot/waba/waba/src/linux/c In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10313/src/linux/c Added Files: debug.c debug.h gdk-pixbuf-xlibrgb.c gdk-pixbuf-xlibrgb.h jar.c jar.h jar2host.h nm_linux_a.c nm_linux_a.h nm_linux_b.c nm_linux_b.h nm_linux_c.c nm_linux_c.h ui_gtk.c ui_gtk.h ui_none.c ui_none.h ui_pgui.c ui_pgui.h ui_x.c ui_x.h Log Message: Moved sources to new location --- NEW FILE: debug.c --- /* $Id: debug.c,v 1.1 2004/07/10 15:30:40 mriem Exp $ */ #include "../waba.h" #ifdef DEBUG char* UTF2CSTR(UtfString *utf) { typedef char buf[255]; static buf utf_buf[16]; static int ix = 0; char *b; ix++; ix&=15; b = &utf_buf[ix][0]; xstrncpy(b, utf->str, utf->len); b[utf->len]=0; return b; } #else /* !DEBUG */ /* * static void _dummy_(char* d, ...) {} */ #endif --- NEW FILE: debug.h --- /* $Id: debug.h,v 1.1 2004/07/10 15:30:40 mriem Exp $ */ #ifndef __WABA_DEBUG_H #define __WABA_DEBUG_H #ifdef DEBUG #define DPUTS puts #define DPRINTF printf char* UTF2CSTR(UtfString *utf); #else /* !DEBUG */ static void _dummy_(char* d, ...){}; # define DPUTS _dummy_ # define DPRINTF _dummy_ # define UTF2CSTR(utf) "" #endif #endif /* WABA_DEBUG_H */ --- NEW FILE: gdk-pixbuf-xlibrgb.c --- /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- * * The contents of this file are subject to the Mozilla Public License * Version 1.1 (the "MPL"); you may not use this file except in * compliance with the MPL. You may obtain a copy of the MPL at * http://www.mozilla.org/MPL/ * * Software distributed under the MPL is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the MPL * for the specific language governing rights and limitations under the * MPL. * * Alternatively, the contents of this file may be used under the * terms of the GNU Library General Public License (the "LGPL"), in * which case the provisions of 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 the LGPL and not to allow others to use * your version of this file under the MPL, indicate your decision by * deleting the provisions above and replace them with the notice and [...3691 lines suppressed...] return image_info->display; return NULL; } /** * xlib_rgb_get_screen: * * Queries the screen that XlibRGB is using. * * Return value: An X screen. **/ Screen * xlib_rgb_get_screen (void) { if (image_info) return image_info->screen; return NULL; } --- NEW FILE: gdk-pixbuf-xlibrgb.h --- /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- * * The contents of this file are subject to the Mozilla Public License * Version 1.1 (the "MPL"); you may not use this file except in * compliance with the MPL. You may obtain a copy of the MPL at * http://www.mozilla.org/MPL/ * * Software distributed under the MPL is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the MPL * for the specific language governing rights and limitations under the * MPL. * * Alternatively, the contents of this file may be used under the * terms of the GNU Library General Public License (the "LGPL"), in * which case the provisions of 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 the LGPL and not to allow others to use * your version of this file under the MPL, indicate your decision by * deleting the provisions above and replace them with the notice and * other provisions required by the LGPL. If you do not delete the * provisions above, a recipient may use your version of this file * under either the MPL or the LGPL. */ /* * This code is derived from GdkRgb. * For more information on GdkRgb, see http://www.levien.com/gdkrgb/ * Raph Levien <ra...@ac...> */ /* Ported by Christopher Blizzard to Xlib. With permission from the * original authors of this file, the contents of this file are also * redistributable under the terms of the Mozilla Public license. For * information about the Mozilla Public License, please see the * license information at http://www.mozilla.org/MPL/ */ /* This code is copyright the following authors: * Raph Levien <ra...@ac...> * Manish Singh <ma...@gt...> * Tim Janik <ti...@gt...> * Peter Mattis <pe...@xc...> * Spencer Kimball <sp...@xc...> * Josh MacDonald <jm...@xc...> * Christopher Blizzard <bli...@re...> * Owen Taylor <ot...@re...> * Shawn T. Amundson <amu...@gt...> */ #ifndef __XLIB_RGB_H__ #define __XLIB_RGB_H__ #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ #include <X11/Xlib.h> #include <X11/Xutil.h> #include <X11/Xos.h> #include <X11/Intrinsic.h> #include <glib.h> typedef struct _XlibRgbCmap XlibRgbCmap; struct _XlibRgbCmap { unsigned int colors[256]; unsigned char lut[256]; /* for 8-bit modes */ }; void xlib_rgb_init (Display *display, Screen *screen); void xlib_rgb_init_with_depth (Display *display, Screen *screen, int prefDepth); unsigned long xlib_rgb_xpixel_from_rgb (guint32 rgb); void xlib_rgb_gc_set_foreground (GC gc, guint32 rgb); void xlib_rgb_gc_set_background (GC gc, guint32 rgb); typedef enum { XLIB_RGB_DITHER_NONE, XLIB_RGB_DITHER_NORMAL, XLIB_RGB_DITHER_MAX } XlibRgbDither; void xlib_draw_rgb_image (Drawable drawable, GC gc, int x, int y, int width, int height, XlibRgbDither dith, unsigned char *rgb_buf, int rowstride); void xlib_draw_rgb_image_dithalign (Drawable drawable, GC gc, int x, int y, int width, int height, XlibRgbDither dith, unsigned char *rgb_buf, int rowstride, int xdith, int ydith); void xlib_draw_rgb_32_image (Drawable drawable, GC gc, int x, int y, int width, int height, XlibRgbDither dith, unsigned char *buf, int rowstride); void xlib_draw_gray_image (Drawable drawable, GC gc, int x, int y, int width, int height, XlibRgbDither dith, unsigned char *buf, int rowstride); XlibRgbCmap * xlib_rgb_cmap_new (guint32 *colors, int n_colors); void xlib_rgb_cmap_free (XlibRgbCmap *cmap); void xlib_draw_indexed_image (Drawable drawable, GC gc, int x, int y, int width, int height, XlibRgbDither dith, unsigned char *buf, int rowstride, XlibRgbCmap *cmap); /* Below are some functions which are primarily useful for debugging and experimentation. */ Bool xlib_rgb_ditherable (void); void xlib_rgb_set_verbose (Bool verbose); /* experimental colormap stuff */ void xlib_rgb_set_install (Bool install); void xlib_rgb_set_min_colors (int min_colors); Colormap xlib_rgb_get_cmap (void); Visual * xlib_rgb_get_visual (void); XVisualInfo * xlib_rgb_get_visual_info (void); int xlib_rgb_get_depth (void); Display * xlib_rgb_get_display (void); Screen * xlib_rgb_get_screen (void); #ifdef __cplusplus } #endif /* __cplusplus */ #endif /* __XLIB_RGB_H__ */ --- NEW FILE: jar.c --- /* $Id: jar.c,v 1.1 2004/07/10 15:30:40 mriem Exp $ Copyright (C) 2000, 2001 Chirag Kantharia 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 of the License, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include <stdio.h> #include <stdlib.h> #include <string.h> #include <zlib.h> #include "jar.h" #include "jar2host.h" /* provide swap or not depending of the endianess of the host */ #define err_exit(msg) { perror(msg); exit(-1); } unsigned char * getClassFrmOffset(FILE *, struct CentralDirRecord *, int *); unsigned char * loadClassFrmJar(char * jar, char * classname, int * size) { FILE * fp; unsigned char * class; char * classfilename; int classfilename_len; volatile int ret, i, len; #ifdef _DEBUG unsigned int tmp4; #endif struct EndCentralDirRecord endrec; class = NULL; len = strlen(classname); if(!(classfilename = malloc(len + 7))) err_exit("malloc"); strncpy(classfilename, classname, len); strncpy(classfilename + len, ".class", 6); classfilename[len + 6] = '\0'; classfilename_len = len + 6; if (!(fp = fopen(jar, "r"))) err_exit("fopen"); ret = fseek(fp, -22, SEEK_END); if (ret != 0) err_exit("fseek"); #ifdef _DEBUG ret = fread(&tmp4, sizeof(unsigned int), 1, fp); if (ret != 1) err_exit("fread"); tmp4 = jar2host_l( tmp4 ); if (tmp4 != END_OF_CENTRAL_DIR_SIGNATURE) err_exit("end of central dir signature"); fseek(fp, -sizeof(unsigned int), SEEK_CUR); #endif ret = fread(&endrec, sizeof(struct EndCentralDirRecord), 1, fp); if (ret != 1) err_exit("fread"); /* convert from jar to host the readed informations */ endrec.sig = jar2host_l( endrec.sig ); endrec.this_disk_num = jar2host_s( endrec.this_disk_num ); endrec.start_disk_num_with_cdr = jar2host_s( endrec.start_disk_num_with_cdr ); endrec.this_disk_nentries = jar2host_s( endrec.this_disk_nentries ); endrec.nentries = jar2host_s( endrec.nentries ); endrec.cd_size = jar2host_l( endrec.cd_size ); endrec.cd_offset = jar2host_l( endrec.cd_offset ); endrec.zip_file_comment_len = jar2host_s( endrec.zip_file_comment_len ); #ifdef _DEBUG printf("sig = %p\n", (int *)endrec.sig); printf("nentries = %d\n", endrec.nentries); printf("cd_size = %d\n", endrec.cd_size); printf("cd_offset = %d\n", endrec.cd_offset); printf("zip_file_comment_len = %d\n", endrec.zip_file_comment_len); if (endrec.zip_file_comment_len > 0) { char * comment; if (!(comment = malloc(endrec.zip_file_comment_len + 1))) err_exit("malloc"); ret = fread(comment, 1, endrec.zip_file_comment_len, fp); if (ret != endrec.zip_file_comment_len) err_exit("fread"); comment[endrec.zip_file_comment_len] = '\0'; printf("zip_file_comment = %s\n", comment); free(comment); } #else if (endrec.zip_file_comment_len > 0) fseek(fp, endrec.zip_file_comment_len, SEEK_CUR); #endif ret = fseek(fp, endrec.cd_offset, SEEK_SET); if (ret != 0) err_exit("fseek"); for(i = 0; i < endrec.nentries; i++) { struct CentralDirRecord cdr; char * filename; char * extra_field; char * file_comment; ret = fread(&cdr, sizeof(struct CentralDirRecord), 1, fp); if (ret != 1) err_exit("fread"); /* convert from jar to host the readed informations */ cdr.sig = jar2host_l( cdr.sig ); cdr.version_created = jar2host_s( cdr.version_created ); cdr.version_req = jar2host_s( cdr.version_req ); cdr.flag = jar2host_s( cdr.flag ); cdr.compression_method = jar2host_s( cdr.compression_method ); cdr.mtime = jar2host_s( cdr.mtime ); cdr.mdate = jar2host_s( cdr.mdate ); cdr.crc = jar2host_l( cdr.crc ); cdr.csize = jar2host_l( cdr.csize ); cdr.ucsize = jar2host_l( cdr.ucsize ); cdr.fnlen = jar2host_s( cdr.fnlen ); cdr.eflen = jar2host_s( cdr.eflen ); cdr.fcommentlen = jar2host_s( cdr.fcommentlen ); cdr.disknum = jar2host_s( cdr.disknum ); cdr.ifattr = jar2host_s( cdr.ifattr ); cdr.efattr = jar2host_l( cdr.efattr ); cdr.lhoff = jar2host_l( cdr.lhoff ); if (cdr.fnlen > 0) { if (!(filename = malloc(cdr.fnlen + 1))) err_exit("malloc"); ret = fread(filename, 1, cdr.fnlen, fp); if (ret != cdr.fnlen) err_exit("fread"); filename[cdr.fnlen] = '\0'; } #ifdef _DEBUG if (cdr.eflen > 0) { if (!(extra_field = malloc(cdr.eflen + 1))) err_exit("malloc"); ret = fread(extra_field, 1, cdr.eflen, fp); if (ret != cdr.eflen) err_exit("fread"); extra_field[cdr.eflen] = '\0'; printf("extra_field = %s\n", extra_field); free(extra_field); } #else if (cdr.eflen > 0) fseek(fp, cdr.eflen, SEEK_CUR); #endif #ifdef _DEBUG if (cdr.fcommentlen > 0) { if (!(file_comment = malloc(cdr.fcommentlen + 1))) err_exit("malloc"); ret = fread(file_comment, 1, cdr.fcommentlen, fp); if (ret != cdr.fcommentlen) err_exit("fread"); file_comment[cdr.fcommentlen] = '\0'; printf("file_comment: %s\n", file_comment); free(file_comment); } #else if (cdr.fcommentlen > 0) fseek(fp, cdr.fcommentlen, SEEK_CUR); #endif if (strncmp(classfilename, filename, classfilename_len) == 0) { int real_size; class = getClassFrmOffset(fp, &cdr, &real_size); *size = real_size; break; } } fclose(fp); free(classfilename); return class; } unsigned char * getClassFrmOffset(FILE * jarfile, struct CentralDirRecord * cdr, int * rsize) { struct LocalFileHeader lfh; Bytef * next_in, * next_out; z_stream z; int ret; int _csize, _ucsize; ret = fseek(jarfile, cdr->lhoff, SEEK_SET); if (ret != 0) err_exit("fseek"); ret = fread(&lfh, sizeof(struct LocalFileHeader), 1, jarfile); if (ret != 1) err_exit("fread"); /* convert from jar to host the readed informations */ lfh.sig = jar2host_l( lfh.sig ); lfh.version_req = jar2host_s( lfh.version_req ); lfh.flag = jar2host_s( lfh.flag ); lfh.compression_method = jar2host_s( lfh.compression_method ); lfh.mtime = jar2host_s( lfh.mtime ); lfh.mdate = jar2host_s( lfh.mdate ); lfh.crc = jar2host_l( lfh.crc ); lfh.csize = jar2host_l( lfh.csize ); lfh.ucsize = jar2host_l( lfh.ucsize ); lfh.fnlen = jar2host_s( lfh.fnlen ); lfh.eflen = jar2host_s( lfh.eflen ); #ifdef _DEBUG // printf("offset = %d\n", offset); #endif #ifdef _DEBUG printf("compression_method = %d\n", lfh.compression_method); #endif #ifdef _DEBUG { char * filename; if (!(filename = malloc(lfh.fnlen + 1))) err_exit("malloc"); ret = fread(filename, lfh.fnlen, 1, jarfile); if (ret != 1) err_exit("fread"); filename[lfh.fnlen] = '\0'; printf("filename = %s\n", filename); free(filename); } #else fseek(jarfile, lfh.fnlen, SEEK_CUR); #endif _csize = (lfh.csize == 0) ? cdr->csize : lfh.csize; _ucsize = (lfh.ucsize == 0) ? cdr->ucsize : lfh.ucsize; if (!(next_in = malloc(_csize))) err_exit("malloc"); ret = fread(next_in, 1, _csize, jarfile); if (ret != _csize) err_exit("fread"); #ifdef _DEBUG printf("compressed data size = %x\n", _csize); printf("uncompressed data size = %x\n", _ucsize); #endif if (lfh.flag & HAS_DATA_DESCRIPTOR) { struct DataDescriptorRecord ddr; ret = fread(&ddr, sizeof(struct DataDescriptorRecord), 1, jarfile); if (ret != 1) err_exit("fread"); /* convert from jar to host the readed informations */ ddr.sig = jar2host_l( ddr.sig ); ddr.crc = jar2host_l( ddr.crc ); ddr.csize = jar2host_l( ddr.csize ); ddr.ucsize = jar2host_l( ddr.ucsize ); #ifdef _DEBUG if (ddr.sig != EXTENDED_LOCAL_FILE_HEADER_SIGNATURE) err_exit("data descriptor signature!"); #endif _csize = ddr.csize; _ucsize = ddr.ucsize; } *rsize = _ucsize; switch(lfh.compression_method) { case 0: next_out = next_in; break; case 8: if (!(next_out = malloc(_ucsize))) err_exit("malloc"); z.next_in = next_in; z.avail_in = _csize; z.next_out = next_out; z.avail_out = _ucsize; z.zalloc = (alloc_func)Z_NULL; z.zfree = (free_func)Z_NULL; z.opaque = Z_NULL; ret = inflateInit2(&z, -MAX_WBITS); if (ret != Z_OK) err_exit("inflateInit2"); while (z.total_in < _csize) { ret = inflate(&z, Z_SYNC_FLUSH); if (ret == Z_STREAM_END) break; if (z.msg) err_exit(z.msg); } ret = inflateEnd(&z); if (ret != Z_OK) err_exit("inflateEnd"); break; } return (unsigned char *)next_out; } --- NEW FILE: jar.h --- /* $Id: jar.h,v 1.1 2004/07/10 15:30:40 mriem Exp $ Copyright (C) 2000, 2001 Chirag Kantharia 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 of the License, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __JAR_H_ #define __JAR_H_ #define LOCAL_FILE_HEADER_SIGNATURE 0x04034b50 #define EXTENDED_LOCAL_FILE_HEADER_SIGNATURE 0x08074b50 #define CENTRAL_FILE_HEADER_SIGNATURE 0x02014b50 #define END_OF_CENTRAL_DIR_SIGNATURE 0x06054b50 #define HAS_DATA_DESCRIPTOR 0x8 struct LocalFileHeader { int sig; /* 0x04034b50 */ short version_req; short flag; short compression_method; short mtime; short mdate; int crc; unsigned int csize; unsigned int ucsize; unsigned short fnlen; unsigned short eflen; } __attribute__ ((packed)); struct CentralDirRecord { int sig; /* 0x02014b50 */ short version_created; short version_req; short flag; short compression_method; short mtime; short mdate; int crc; unsigned int csize; unsigned int ucsize; unsigned short fnlen; unsigned short eflen; unsigned short fcommentlen; unsigned short disknum; short ifattr; int efattr; unsigned int lhoff; } __attribute__ ((packed)); struct EndCentralDirRecord { int sig; /* 0x06054b50 */ unsigned short this_disk_num; unsigned short start_disk_num_with_cdr; unsigned short this_disk_nentries; unsigned short nentries; unsigned int cd_size; unsigned int cd_offset; unsigned short zip_file_comment_len; } __attribute__ ((packed)); struct DataDescriptorRecord { int sig; /* 0x08074b50 */ int crc; int csize; int ucsize; } __attribute__ ((packed)); extern unsigned char * loadClassFrmJar(char * jar, char * classname, int * size); #endif /* #ifndef __JAR_H_ */ --- NEW FILE: jar2host.h --- /* $Id: jar2host.h,v 1.1 2004/07/10 15:30:40 mriem Exp $ * * jar2host.h - definition of jar2host functions * * Copyright (C) 2001 SMARTDATA * * 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 * of the License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * Contributors: * * * */ #ifndef __JAR2HOST_H__ #define __JAR2HOST_H__ #ifdef WORDS_BIGENDIAN /* as the jar files are little endian by default, we must swap */ # define jar2host_l(x) ((__u32)( \ (((__u32)(x) & (__u32)0x000000ffUL) << 24) | \ (((__u32)(x) & (__u32)0x0000ff00UL) << 8) | \ (((__u32)(x) & (__u32)0x00ff0000UL) >> 8) | \ (((__u32)(x) & (__u32)0xff000000UL) >> 24) )) # define jar2host_s(x) ((__u16)( \ (((__u16)(x) & (__u16)0x00ffU) << 8) | \ (((__u16)(x) & (__u16)0xff00U) >> 8) )) #else /* no swap, because we are little endian, same as the jar files */ # define jar2host_l(x) ((unsigned int)(x)) # define jar2host_s(x) ((unsigned short)(x)) #endif /* WORDS_BIGENDIAN */ #endif /* Local Variables: c-file-style: "smartdata" End: */ --- NEW FILE: nm_linux_a.c --- /* $Id: nm_linux_a.c,v 1.1 2004/07/10 15:30:40 mriem Exp $ Copyright (C) 1998, 1999, 2000 Wabasoft 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 of the License, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* Copyright (C) 2000, 2001 SMARTDATA, http://www.smartdata.ch/ More help for porting is include in the file nmport_a.c. Please read it before porting or modify this port. Linux port. =========== */ typedef unsigned long uint32; /* all the needed include */ #include "../waba.h" #ifndef LINUX # error You must define the LINUX symbol as gcc parameter (-DLINUX=1) #endif #ifndef FASTANDBIG uint32 getUInt32(uchar *b) { return (uint32)( (uint32)((b)[0])<<24 | (uint32)((b)[1])<<16 | (uint32)((b)[2])<<8 | (uint32)((b)[3]) ); } uint16 getUInt16(uchar *b) { return (uint16)(((b)[0]<<8)|(b)[1]); } int32 getInt32(uchar *b) { return (int32)( (uint32)((b)[0])<<24 | (uint32)((b)[1])<<16 | (uint32)((b)[2])<<8 | (uint32)((b)[3]) ); } int16 getInt16(uchar *b) { return (int16)(((b)[0]<<8)|(b)[1]); } #endif /* ifndef FASTANDBIG */ #ifdef WITH_64BITS // get one 64 float value from buf and return it float64 getFloat64bits(uchar *buf) { float64HiLo fhl; fhl.ul.lo = getInt32( buf ); fhl.ul.hi = getInt32( buf + 4 ); return fhl.value; } // get one 64 float value from buf and return it int64 getInt64bits(uchar *buf) { int64HiLo ihl; ihl.ul.lo = getInt32( buf ); ihl.ul.hi = getInt32( buf + 4 ); return ihl.value; } #endif /* WITH_64BITS */ float32 getFloat32(uchar *buf) { uint32 i; float32 f; // we need to make sure we're aligned before casting i = ((uint32)buf[0] << 24) | ((uint32)buf[1] << 16) | ((uint32)buf[2] << 8 ) | (uint32)buf[3]; f = *((float32 *)&i); return f; } /* Local Variables: c-file-style: "smartdata" End: */ --- NEW FILE: nm_linux_a.h --- /* $Id: nm_linux_a.h,v 1.1 2004/07/10 15:30:40 mriem Exp $ */ #ifndef __NM_LINUX_A_H__ #define __NM_LINUX_A_H__ /* Copyright (C) 1998, 1999, 2000 Wabasoft 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 of the License, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* Copyright (C) 2000, 2001 SMARTDATA, http://www.smartdata.ch/ More help for porting is include in the file nmport_a.c. Please read it before porting or modify this port. Linux port. =========== */ /* all the needed include */ #include <stdlib.h> #include <string.h> #ifndef LINUX # error You must define the LINUX symbol as gcc parameter (-DLINUX=1) #endif #define FREE_ON_EXIT 1 #undef SECURE_CLASS_HEAP //#define SECURE_CLASS_HEAP 1 #ifdef SECURE_CLASS_HEAP # define LOCK_CLASS_HEAP MemSemaphoreReserve(1); # define UNLOCK_CLASS_HEAP MemSemaphoreRelease(1); #else # define LOCK_CLASS_HEAP ; # define UNLOCK_CLASS_HEAP ; #endif /******************************************************************************** TYPE DEFINITIONS ********************************************************************************/ /* for the types, we use the GLib library of the GTK project. See http://www.gtk.org for more informations */ #ifdef USE_GLIB /* use glib for types */ #include <glib.h> #else /* we don't use glib, so we need to define g... types */ #define guchar unsigned char #define gint32 int #define guint32 unsigned int #define gfloat float #define gint16 short #define guint16 unsigned short #define gint int #define guint unsigned int #define gchar char #ifdef WITH_64BITS #define gint64 long long #define guint64 unsigned long long #define gdouble double #endif /* WITH_64BITS */ #define TRUE 1 #define FALSE 0 #endif /* ifdef USE_GLIB ... else ... */ // - uchar is an 8 bit unsigned value #define uchar guchar // - int32 is a signed 32 bit value #define int32 gint32 // - uint32 is an unsigned 32 bit value #define uint32 guint32 // - float32 is a signed 32 bit floating point value #define float32 gfloat // - int16 is a signed 16 bit value #define int16 gint16 // - uint16 is an unsigned 16 bit value #define uint16 guint16 #ifdef WITH_64BITS // - int64 is a signed 64 bit value #define int64 gint64 // - uint64 is an unsigned 64 bit value #define uint64 guint64 // - float64 is a signed 64 bit floating point value #define float64 gdouble // --- define a struct for double and long support in two Var ... // ... the hi/lo decomposition typedef struct { uint32 lo; uint32 hi; } HiLoDoubleOrLong; //... for the double typedef union { float64 value; HiLoDoubleOrLong ul; } float64HiLo; //... for the long typedef union { int64 value; HiLoDoubleOrLong ul; } int64HiLo; #endif /* WITH_64BITS */ /******************************************************************************** TYPE CONVERTERS ********************************************************************************/ #ifdef FASTANDBIG # define getUInt32(b) (uint32)( (uint32)((b)[0])<<24 | \ (uint32)((b)[1])<<16 | \ (uint32)((b)[2])<<8 | (uint32)((b)[3]) ) # define getUInt16(b) (uint16)( ((b)[0]<<8)|(b)[1] ) # define getInt32(b) (int32) ( (uint32)((b)[0])<<24 | \ (uint32)((b)[1])<<16 | \ (uint32)((b)[2])<<8 | (uint32)((b)[3]) ) # define getInt16(b) (int16) ( ((b)[0]<<8)|(b)[1] ) #else uint32 getUInt32(uchar *b); uint16 getUInt16(uchar *b); int32 getInt32(uchar *b); int16 getInt16(uchar *b); #endif /* ifdef FASTANDBIG */ #ifdef WITH_64BITS // get one 64 float value from buf and return it float64 getFloat64bits(uchar *buf); // get one 64 float value from buf and return it int64 getInt64bits(uchar *buf); #endif /* WITH_64BITS */ float32 getFloat32(uchar *buf); /******************************************************************************** "STRING" FUNCTIONS ********************************************************************************/ #define xstrncmp(s1, s2, n) strncmp(s1, s2, n) #define xstrncpy(dst, src, n) strncpy(dst, src, n) #define xstrlen(s) strlen(s) #define xstrcat(dst, src) strcat(dst, src) #define xmemmove(dst, src, size) memmove(dst, src, size) #define xmemzero(mem, len) memset(mem, 0, len ) /******************************************************************************** DYNAMIC ALLOCATION FUNCTIONS ********************************************************************************/ #define xmalloc(size) malloc(size) #define xfree(p) free(p) /******************** TO REMOVE *********************/ #include <stdio.h> /******************************************************************** * Elementary data types ********************************************************************/ // Fixed size data types typedef char SByte; // 8 bits #ifndef __TYPES__ // (Already defined in CW11) typedef unsigned char Byte; #endif typedef short SWord; // 16 bits typedef unsigned short Word; typedef long SDWord; // 32 bits typedef unsigned long DWord; // Logical data types #ifndef __TYPES__ // (Already defined in CW11) typedef unsigned char Boolean; #endif typedef char Char; // Used for character strings typedef unsigned char UChar; typedef short Short; // >= Byte typedef unsigned short UShort; typedef short Int; // >= Word (use short so MPW and CW agree) typedef unsigned short UInt; typedef long Long; // >= DWord typedef unsigned long ULong; typedef short Err; typedef DWord LocalID; // local (card relative) chunk ID /************************************************************ * Pointer Types *************************************************************/ typedef void* VoidPtr; typedef VoidPtr* VoidHand; // Fixed size data types typedef SByte* SBytePtr; #ifndef __TYPES__ // (Already defined in CW11) typedef Byte* BytePtr; #endif typedef SWord* SWordPtr; typedef Word* WordPtr; typedef SDWord* SDWordPtr; typedef DWord* DWordPtr; // Logical data types typedef Boolean* BooleanPtr; typedef Char* CharPtr; typedef UChar* UCharPtr; typedef Short* ShortPtr; typedef UShort* UShortPtr; typedef Int* IntPtr; typedef UInt* UIntPtr; typedef Long* LongPtr; typedef ULong* ULongPtr; // Include the following typedefs if types.h wasn't read. #ifndef __TYPES__ // Generic Pointer types used by Memory Manager // We have to define Ptr as char* because that's what the Mac includes do. typedef char* Ptr; // global pointer typedef Ptr* Handle; // global handle // Function types typedef Long (*ProcPtr)(); #endif /* __TYPES__ */ /************************************************************ * Common constants *************************************************************/ #ifndef NULL # define NULL 0 #endif // NULL // Include the following typedefs if types.h wasn't read. #ifndef __TYPES__ #ifdef __MWERKS__ #if !__option(bool) #ifndef true #define true 1 #endif #ifndef false #define false 0 #endif #endif #else enum {false, true}; #endif #endif /* __TYPES__ */ #endif /* __NM_LINUX_A_H__ */ /* Local Variables: c-file-style: "smartdata" End: */ --- NEW FILE: nm_linux_b.c --- /* $Id: nm_linux_b.c,v 1.1 2004/07/10 15:30:40 mriem Exp $ Copyright (C) 1998, 1999, 2000 Wabasoft 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 of the License, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* Copyright (C) 2000, 2001 SMARTDATA, http://www.smartdata.ch/ [...1489 lines suppressed...] globalNetState = NET_READY_FOR_OPEN; if (!isApplication) { ui_MainLoop(); } stopApp(mainWinObj); if (globalNetState == NET_IS_OPEN) ; // TODO: NetLibClose(globalSocketLibRefNum, false); ui_exit(0); } /* Local Variables: c-file-style: "smartdata" End: */ --- NEW FILE: nm_linux_b.h --- /* $Id: nm_linux_b.h,v 1.1 2004/07/10 15:30:40 mriem Exp $ */ #ifndef __NM_LINUX_B_H__ #define __NM_LINUX_B_H__ /* Copyright (C) 1998, 1999, 2000 Wabasoft 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 of the License, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* Copyright (C) 2000, 2001 SMARTDATA, http://www.smartdata.ch/ More help for porting is include in the file nmport_b.c. Please read it before porting or modify this port. Linux port. =========== */ /* which GUI to use ? At this time, only GUI_GTK and GUI_PGUI is implemented */ #if defined(GUI_X) # include "ui_x.h" #elif defined(GUI_GTK) # include "ui_gtk.h" #elif defined(GUI_PGUI) # include "ui_pgui.h" #elif defined(GUI_NONE) # include "ui_none.h" #else # error you must define GUI_... to choose a GUI system #endif /* globals */ #define NET_NOT_READY_FOR_OPEN 0 #define NET_READY_FOR_OPEN 1 #define NET_IS_OPEN 2 #define NET_OPEN_FAILED 3 /**************** which are needed ? */ extern WObject globalMainWin; /* extern int32 globalTimerInterval; extern int32 globalTimerStart; extern int classDbCount; extern ULong appCreatorId; extern Word globalSocketLibRefNum; extern int globalNetState; #ifdef QUICKBIND extern int32 postEventMethodMapNum; extern int32 onTimerTickMethodMapNum; #endif */ /*************************************/ /* the size/properties of the MainWindow */ extern int32 hwr_bpp; extern int32 hwr_width; extern int32 hwr_height; extern int isApplication; #define HELPER #define PUBLIC #define WARN_NA(s) printf("### Warning: not implmented: %s\n", #s) #define MEM_CACHING 0 #define MAX_CLASSPATHS 20 static int numClassPaths = -1; static char *classPaths[MAX_CLASSPATHS]; static char *classpath = 0; static int is_ui_inited = 0; HELPER void * ui_init(); uchar *readFileIntoMemory( char *path, int nullTerminate, uint32 *size ); #ifdef WITH_THREAD //*** Isao's Multithread implementation START *** typedef struct { //Use either "syncObj" or "syncMethod", //Not both at the same time. WObject syncObj; WClassMethod* syncMethod; } WSync; typedef struct { WObject signalObj; } WSignal; typedef struct _queue { struct _queue *next; struct _queue *prev; } Queue; typedef struct { Queue queue; /* 'Queue' must be first to use type cast trick. */ WClass* tClass; WObject tObject; WSync wSyncObj; WSignal wSignal; int32 runMethodMapNum; uint32 sleepCountSet; uint32 sleepCountNow; uchar isSleepCountAlreadySet; uchar isWaiting; } WThread; // Thread variables - Isao F. Yamashita 07/25/2000 #define THREAD_LIST_MAX_SIZE 8 extern int InitThread(uint32 stacksize); //*** This "_onThreadStart()" method is called from "start()" method. extern Var ThreadStart(Var stack[]); //*** This "_onThreadStop()" method is called from "stop()" method. extern Var ThreadStop(Var stack[]); //*** This "_onThreadSleep()" method is called from "sleep()" method. extern Var ThreadSleep(Var stack[]); //*** This "_onThreadWait()" method is called from "wait()" method. extern Var ThreadWaitForSignal(Var stack[]); extern Var ThreadSignalAll(Var stack[]); //*** Isao's Multithread implementation END *** //*** This "ThreadCurrentThread()" method is called from "curentThread()" method. extern Var ThreadCurrentThread(Var stack[]); #define THERE_IS_SOME_THREADS (threadListCurrentSize > 0) void tickThread(void); int registerAsSyncronized(WClassMethod* method); void exitFromSyncronized(WClassMethod* method); int enterMonitor(WObject obj); int exitMonitor(WObject obj); #endif /* WITH_THREAD */ /* get/set the properties of the main window */ #endif /* __NM_LINUX_B_H__ */ /* Local Variables: c-file-style: "smartdata" End: */ --- NEW FILE: nm_linux_c.c --- /* $Id: nm_linux_c.c,v 1.1 2004/07/10 15:30:40 mriem Exp $ Copyright (C) 1998, 1999, 2000 Wabasoft 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 of the License, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* Copyright (C) 2000, 2001 SMARTDATA, http://www.smartdata.ch/ [...4551 lines suppressed...] /* * Registry destructor */ void RegistryDestroy (WObject registry) { char * fileName; InternalRegistryClose (registry); fileName = (char *) WOBJ_RegistryFileName (registry); free (fileName); } #endif /* #ifdef BEE_BIOS #else */ /* Local Variables: c-file-style: "smartdata" End: */ --- NEW FILE: nm_linux_c.h --- /* $Id: nm_linux_c.h,v 1.1 2004/07/10 15:30:40 mriem Exp $ */ #ifndef __NM_LINUX_C_H__ #define __NM_LINUX_C_H__ /* Copyright (C) 1998, 1999, 2000 Wabasoft 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 of the License, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* Copyright (C) 2000, 2001 SMARTDATA, http://www.smartdata.ch/ More help for porting is include in the file nmport_c.c. Please read it before porting or modify this port. Linux port. =========== */ /* default font parameters */ #define DEFAULT_FONT "helvetica" #define DEFAULT_FONT_SIZE 10 /* usefull for some implementation, like Solaris */ #ifndef INADDR_NONE #define INADDR_NONE ((unsigned long) -1) #endif void WindowDestroy(WObject obj); void MainWinDestroy(WObject obj); void GraphicsDestroy(WObject obj); void ImageDestroy(WObject obj); #if WITH_CATALOG_CLASS void CatalogDestroy(WObject obj); #endif void FileDestroy(WObject obj); void SocketDestroy(WObject obj); void SerialPortDestroy(WObject obj); void RegistryDestroy(WObject obj); void EditDestroy(WObject obj); /* to have a explanation of the following structure, see the the file nmport_c.c and my small explanation of how to access class variable below */ extern ClassHook classHooks[]; #define FUNC(f) extern Var f (Var stack[]) /* all the native functions */ FUNC(VmPrintLn); FUNC(VmPrint); FUNC(VmExec); FUNC(VmGetTimeStamp); FUNC(copyArray); FUNC(VmExit); FUNC(VmSleep); FUNC(VmSetDeviceAutoOff); FUNC(VmGetUserName); FUNC(VmGetPlatform); FUNC(VmIsColor); FUNC(FileGetLength); FUNC(FileCreateDir); FUNC(FileReadBytes); FUNC(FileRename); FUNC(FileCreate); FUNC(FileWriteBytes); FUNC(FileListDir); FUNC(FileSeekWaba); FUNC(FileIsDir); FUNC(FileCloseWaba); FUNC(FileIsOpen); FUNC(FileDeleteWaba); FUNC(FileExists); FUNC(ImageCreate); FUNC(ImageFree); FUNC(ImageSetPixels); FUNC(ImageUseImagePalette); FUNC(ImageLoad); FUNC(SoundBeep); FUNC(SoundTone); FUNC(TimeCreate); FUNC(SocketCreate); FUNC(SocketRead); FUNC(SocketWrite); FUNC(SocketSetReadTimeout); FUNC(SocketClose); FUNC(SocketIsOpen); FUNC(WindowCreate); #ifdef WITH_CATALOG_CLASS FUNC(CatalogListCatalogs); FUNC(CatalogAddRecord); FUNC(CatalogSkipBytes); FUNC(CatalogCreate); FUNC(CatalogRead); FUNC(CatalogDeleteRecord); FUNC(CatalogSetRecordPos); FUNC(CatalogGetRecordSize); FUNC(CatalogResizeRecord); FUNC(CatalogWrite); FUNC(CatalogGetRecordCount); FUNC(CatalogClose); FUNC(CatalogIsOpen); FUNC(CatalogDelete); #endif FUNC(GraphicsCopyRect); FUNC(GraphicsClearClip); FUNC(GraphicsSetFont); FUNC(GraphicsSetDrawOp); FUNC(GraphicsSetClip); FUNC(GraphicsSetBackColor); FUNC(GraphicsSetColor); FUNC(GraphicsGetClip); FUNC(GraphicsFillRect); FUNC(GraphicsDrawLine); FUNC(GraphicsTranslate); FUNC(GraphicsDrawDots); FUNC(GraphicsDrawChars); FUNC(GraphicsCreate); FUNC(GraphicsDrawCursor); FUNC(GraphicsSetClip); FUNC(GraphicsFree); FUNC(GraphicsSetForeColor); FUNC(GraphicsSetTextColor); FUNC(GraphicsFillPolygon); FUNC(GraphicsDrawString); FUNC(ConvertStringToInt); FUNC(ConvertFloatToIntBitwise); FUNC(ConvertCharToString); FUNC(ConvertIntToFloatBitwise); FUNC(ConvertFloatToString); FUNC(ConvertDoubleToString); FUNC(ConvertIntToString); FUNC(ConvertLongToString); FUNC(ConvertBooleanToString); FUNC(SoundClipPlay); FUNC(PalmOsPrefSetPalmOsPref); FUNC(PalmOsPrefGetPalmOsPref); FUNC(MainWinCreate); FUNC(MainWinExit); FUNC(MainWinSetTimerInterval); FUNC(SerialPortReadCheck); FUNC(SerialPortRead); FUNC(SerialPortWrite); FUNC(SerialPortSetReadTimeout); FUNC(SerialPortClose); FUNC(SerialPortSetFlowControl); FUNC(SerialPortIsOpen); FUNC(SerialPortCreate); #ifdef WITH_SMARTDATA_CLASSES FUNC(EditCreate); FUNC(EditGetText); FUNC(EditSetText); FUNC(EditDraw); FUNC(EditFocusIn); FUNC(EditFocusOut); FUNC(EditKeyPress); FUNC(EditPenDown); FUNC(EditPenDrag); FUNC(EditEvent); FUNC(EditPaint); #endif /* #ifdef WITH_SMARTDATA_CLASSES */ FUNC(FontMetricsGetStringWidth); FUNC(FontMetricsGetCharWidth); FUNC(FontMetricsCreate); FUNC(FontMetricsGetCharArrayWidth); FUNC(RegistryCreate); FUNC(RegistryReadBytes); FUNC(RegistryWriteBytes); FUNC(RegistrySkipBytes); FUNC(RegistryClose); FUNC(RegistryDelete); FUNC(RegistrySpaceAvailable); /************************************************************************* class waba/fx/Rect *************************************************************************/ // var[0] = Class // var[1] = int x // var[2] = int y // var[3] = int width // var[4] = int height #define WOBJ_RectX(o) (objectPtr(o))[1].intValue #define WOBJ_RectY(o) (objectPtr(o))[2].intValue #define WOBJ_RectWidth(o) (objectPtr(o))[3].intValue #define WOBJ_RectHeight(o) (objectPtr(o))[4].intValue /************************************************************************* class waba/ui/Control *************************************************************************/ // var[0] = Class // var[1] = int x // var[2] = int y // var[3] = int width // var[4] = int height #define WOBJ_ControlX(o) (objectPtr(o))[1].intValue #define WOBJ_ControlY(o) (objectPtr(o))[2].intValue #define WOBJ_ControlWidth(o) (objectPtr(o))[3].intValue #define WOBJ_ControlHeight(o) (objectPtr(o))[4].intValue /************************************************************************* class waba/ui/Window *************************************************************************/ // var[0] = Class // var[n] = ...other locals... // var[n + 1] = hook var - a pointer to the MainWindow // var[n + 2] = hook var - boolean if the Window allready a pixmap or not // // since Window inherits from other classes, we need to calculate the // right base offset to start with when reading/writing to variables extern int _winHookOffset; #define WOBJ_WindowMain(o) (objectPtr(o))[_winHookOffset + 0].refValue #define WOBJ_WindowHookVars 1 /* number of hook var for Window */ /************************************************************************* class waba/ui/MainWindow *************************************************************************/ // var[0] = Class // var[n] = ...other locals... // var[n + 1] = hook var - // extern int _mainWinHookOffset; #define WOBJ_MainWinTimer(o) (objectPtr(o))[_mainWinHookOffset + 0].intValue #define WOBJ_MainWinHookVars 1 /* number of hook var for MainWindow */ /************************************************************************* class waba/fx/Image *************************************************************************/ // var[0] = Class // var[1] = width // var[2] = height // var[3] = hook var - pointer to the pixmap image #define WOBJ_ImageWidth(o) (objectPtr(o))[1].intValue #define WOBJ_ImageHeight(o) (objectPtr(o))[2].intValue #define WOBJ_ImagePixmap(o) (objectPtr(o))[3].refValue /************************************************************************* class waba/io/Socket *************************************************************************/ // var[0] = Class // var[1] = hook var - Socket Id (int32) // var[2] = timeout delay in milliseconds // // NOTE: The SOCKET type is an unsigned 32 bit quantity - this most closely // matches the object type #define WOBJ_SocketFD(o) (objectPtr(o))[1].intValue #define WOBJ_SocketTimeout(o) (objectPtr(o))[2].intValue #ifdef WITH_SMARTDATA_CLASSES /************************************************************************* class ch/smartdata/ui/Edit *************************************************************************/ // var[0] = Class // ... = other local variables // var[n + 0] = Timer blinkTimer // var[n + 1] = Graphics drawg // var[n + 2] = hook var - char * chars // var[n + 3] = hook var - unsigned char * charWidths // var[n + 4] = hook var - ui_FontType * font // var[n + 5] = hook var - int totalCharWidth // var[n + 6] = hook var - int xOffset // var[n + 7] = hook var - int hasFocus // var[n + 8] = hook var - int redraw // var[n + 9] = hook var - int insertPoint // since Edit inherits from other classes, we need to calculate the // right base offset to start with when reading/writing to variables extern int _editHookOffset; #define WOBJ_EditBlinkTimer(o) (objectPtr(o))[_editHookOffset + 0].obj #define WOBJ_EditDrawG(o) (objectPtr(o))[_editHookOffset + 1].obj #define WOBJ_EditFont(o) (objectPtr(o))[_editHookOffset + 2].obj #define WOBJ_EditChars(o) (objectPtr(o))[_editHookOffset + 3].refValue #define WOBJ_EditCharWidths(o) (objectPtr(o))[_editHookOffset + 4].refValue #define WOBJ_EditTotalCharWidth(o) (objectPtr(o))[_editHookOffset + 5].intValue #define WOBJ_EditXOffset(o) (objectPtr(o))[_editHookOffset + 6].intValue #define WOBJ_EditHasFocus(o) (objectPtr(o))[_editHookOffset + 7].intValue #define WOBJ_EditRedraw(o) (objectPtr(o))[_editHookOffset + 8].intValue #define WOBJ_EditInsertPos(o) (objectPtr(o))[_editHookOffset + 9].intValue #define WOBJ_EditHookVars 10 /* number of hook var for Edit */ #endif /* #ifdef WITH_SMARTDATA_CLASSES */ /************************************************************************* class waba/fx/Font *************************************************************************/ // var[0] = Class // var[1] = String name // var[2] = int style // var[3] = int size // #define WOBJ_FontName(o) (objectPtr(o))[1].obj #define WOBJ_FontStyle(o) (objectPtr(o))[2].intValue #define WOBJ_FontSize(o) (objectPtr(o))[3].intValue #define Font_PLAIN 0 #define Font_BOLD 1 /************************************************************************* class waba/fx/FontMetrics *************************************************************************/ // var[0] = Class // var[1] = Font // var[2] = Surface // var[3] = int ascent // var[4] = int descent // var[5] = int leading #define WOBJ_FontMetricsFont(o) (objectPtr(o))[1].obj #define WOBJ_FontMetricsSurface(o) (objectPtr(o))[2].obj #define WOBJ_FontMetricsAscent(o) (objectPtr(o))[3].intValue #define WOBJ_FontMetricsDescent(o) (objectPtr(o))[4].intValue #define WOBJ_FontMetricsLeading(o) (objectPtr(o))[5].intValue /* what type of width we can compute */ #define FM_STRINGWIDTH 1 #define FM_CHARARRAYWIDTH 2 #define FM_CHARWIDTH 3 /************************************************************************* class waba/fx/Graphics *************************************************************************/ // var[0] = Class // var[1] = Surface // var[2] = hook var - isValid flag // var[3] = hook var - pointer to the main window, NULL if it's an Image // var[4] = hook var - pointer to the Pixmap if it's an Image, NULL otherwise // var[5] = hook var - pointer to the drawing pixmap where all draw are made // var[6] = hook var - pointer to the used font // var[7] = hook var - the start x of the clip region // var[8] = hook var - the start y of the clip region // var[9] = hook var - the width of the clip region // var[10] = hook var - the height of the clip region // var[11] = hook var - the operation used for the draw (AND/OR/XOR...) // var[12] = hook var - the value of the red color used for the draw // var[13] = hook var - the value of the green color used for the draw // var[14] = hook var - the value of the blue color used for the draw // var[15] = hook var - the X used for translation // var[16] = hook var - the Y used for translation #define WOBJ_GraphicsSurface(o) (objectPtr(o))[1].obj #define WOBJ_GraphicsIsValid(o) (objectPtr(o))[2].intValue #define WOBJ_GraphicsWindowMain(o) (objectPtr(o))[3].refValue #define WOBJ_GraphicsPixmap(o) (objectPtr(o))[4].refValue #define WOBJ_GraphicsDrawingPixmap(o) (objectPtr(o))[5].refValue #define WOBJ_GraphicsFont(o) (objectPtr(o))[6].refValue #define WOBJ_GraphicsClipRegionX(o) (objectPtr(o))[7].intValue #define WOBJ_GraphicsClipRegionY(o) (objectPtr(o))[8].intValue #define WOBJ_GraphicsClipRegionW(o) (objectPtr(o))[9].intValue #define WOBJ_GraphicsClipRegionH(o) (objectPtr(o))[10].intValue #define WOBJ_GraphicsDrawOp(o) (objectPtr(o))[11].intValue #define WOBJ_GraphicsRED(o) (objectPtr(o))[12].intValue #define WOBJ_GraphicsGREEN(o) (objectPtr(o))[13].intValue #define WOBJ_GraphicsBLUE(o) (objectPtr(o))[14].intValue #define WOBJ_GraphicsTransX(o) (objectPtr(o))[15].intValue #define WOBJ_GraphicsTransY(o) (objectPtr(o))[16].intValue /* how we can draw */ #define DRAW_OVER 1 #define DRAW_AND 2 #define DRAW_OR 3 #define DRAW_XOR 4 /* some constants giving the existing type of drawing */ #define GR_FILLRECT 0 #define GR_DRAWLINE 1 #define GR_FILLPOLY 2 #define GR_DRAWCHARS 3 #define GR_DRAWSTRING 4 #define GR_DOTS 5 #define GR_COPYRECT 6 #define GR_DRAWCURSOR 7 /* existing surface type */ #define SURF_UNKNOWN 0 #define SURF_WINDOW 1 #define SURF_IMAGE 2 /************************************************************************* class waba/fx/SoundClip *************************************************************************/ // var[0] = Class // var[1] = path // var[2] = loaded #define WOBJ_SoundClipPath(o) (objectPtr(o))[1].obj #define WOBJ_SoundClipLoaded(o) (objectPtr(o))[2].intValue #ifdef WITH_CATALOG_CLASS /************************************************************************* class waba/io/Catalog As linux has no catalog, this is not implemented at this time *************************************************************************/ // var[0] = Class // var[1] = hook var - database handle (null if no open db) // var[2] = hook var - database oid // var[3] = hook var - current record position // var[4] = hook var - current record oid // var[5] = hook var - current record memory pointer // var[6] = hook var - current record memory allocation pointer // var[7] = hook var - length of current record // var[8] = hook var - current offset in record // var[9] = hook var - 1 if record has been modified, 0 otherwise #define WOBJ_CatalogHandle(o) (objectPtr(o))[1].refValue #define WOBJ_CatalogOID(o) (objectPtr(o))[2].refValue #define WOBJ_CatalogCurRecPos(o) (objectPtr(o))[3].intValue #define WOBJ_CatalogCurRecOid(o) (objectPtr(o))[4].refValue #define WOBJ_CatalogCurRecPtr(o) (objectPtr(o))[5].refValue #define WOBJ_CatalogCurRecAllocPtr(o) (objectPtr(o))[6].refValue #define WOBJ_CatalogCurRecLen(o) (objectPtr(o))[7].intValue #define WOBJ_CatalogCurRecOffset(o) (objectPtr(o))[8].intValue #define WOBJ_CatalogCurRecModified(o) (objectPtr(o))[9].intValue #define Catalog_READ_ONLY 1 #define Catalog_WRITE_ONLY 2 #define Catalog_READ_WRITE 3 #define Catalog_CREATE 4 #define Catalog_CEDBTYPE 4141 #endif //WITH_CATALOG_CLASS /************************************************************************* class waba/io/File *************************************************************************/ // var[0] = Class // var[1] = String name // var[2] = int mode // var[3] = hook var - file handle #define WOBJ_FileName(o) (objectPtr(o))[1].obj #define WOBJ_FileMode(o) (objectPtr(o))[2].intValue #define WOBJ_FileHandle(o) (objectPtr(o))[3].refValue #define File_DONT_OPEN 0 #define File_READ_ONLY 1 #define File_WRITE_ONLY 2 #define File_READ_WRITE 3 #define File_CREATE 4 /* some file operation */ #define FILE_CREATE_DIR 1 #define FILE_IS_DIR 2 #define FILE_DELETE 3 #define FILE_RENAME 4 #define FILE_EXISTS 5 /************************************************************************* class waba/io/SerialPort *************************************************************************/ // var[0] = Class // var[1] = hook var - Handle #define WOBJ_SerialPortHandle(o) (objectPtr(o))[1].refValue /************************************************************************* class waba/sys/Time *************************************************************************/ // var[0] = Class // var[1] = int year // var[2] = int month // var[3] = int day // var[4] = int hour // var[5] = int minute // var[6] = int second // var[7] = int millis #define WOBJ_TimeYear(o) (objectPtr(o))[1].intValue #define WOBJ_TimeMonth(o) (objectPtr(o))[2].intValue #define WOBJ_TimeDay(o) (objectPtr(o))[3].intValue #define WOBJ_TimeHour(o) (objectPtr(o))[4].intValue #define WOBJ_TimeMinute(o) (objectPtr(o))[5].intValue #define WOBJ_TimeSecond(o) (objectPtr(o))[6].intValue #define WOBJ_TimeMillis(o) (objectPtr(o))[7].intValue /************************************************************************* class waba/io/Registry *************************************************************************/ #ifdef BEE_BIOS // var [0] = Class // var [1] = unsigned char * memory buffer // var [2] = int position into memory buffer // var [3] = int current size of memory buffer // var [4] = int flag indicating that the buffer has been modified // var [5] = char * environment variable name #define WOBJ_RegistryBuffer(o) (objectPtr(o))[1].refValue #define WOBJ_RegistryBufferPos(o) (objectPtr(o))[2].intValue #define WOBJ_RegistryBufferSize(o) (objectPtr(o))[3].intValue #define WOBJ_RegistryBufferDirty(o) (objectPtr(o))[4].intValue #define WOBJ_RegistryVarName(o) (objectPtr(o))[5].refValue #else /* #ifdef BEE_BIOS */ // var[0] = Class // var[1] = char * file name // var[2] = int file descriptor #define WOBJ_RegistryFileName(o) (objectPtr(o))[1].refValue #define WOBJ_RegistryFile(o) (objectPtr(o))[2].intValue #endif /* #ifdef BEE_BIOS #else */ /************************************************************************* functions implemented in ui_xxx.c *************************************************************************/ /* general */ void ui_MainLoop(); int ui_IsColor(); /* timeout related */ void ui_TimeoutSet( WObject win, gint nbOfMillisecond ); /* for the fonts */ ui_FontType *ui_FontCreate( WObject font ); void ui_FontDelete( ui_FontType *theFont ); gint ui_TextWidth( char *theText, ui_FontType *theFont ); gint ui_CharWidth( char theChar, ui_FontType *theFont ); int ui_FontHeight( ui_FontType *theFont ); void ui_FontSetProperties( ui_FontType *theFont, WObject fontMetrics ); gint ui_FontGetYOffset( ui_FontType *theFont ); /* for the draw */ ui_PixmapType *ui_createDrawingPixmap( ui_MainWindowType *mw, ui_Rectangle rect ); void ui_deleteDrawingPixmap( ui_PixmapType *thePixmap ); ui_GraphicsContextType *ui_createGC( WObject gr ); void ui_deleteGC( ui_GraphicsContextType *theGC ); void ui_setTheDrawFunction( ui_GraphicsContextType *theGC, gint32 drawOp ); void ui_ClipTo( ui_GraphicsContextType *theGC, ui_Rectangle rect ); void ui_SetColor( ui_GraphicsContextType *theGC, gint red, gint green, gint blue ); void ui_DrawPixel( ui_PixmapType *drawingPixmap, ui_GraphicsContextType *theGC, gint x, gint y ); void ui_DrawLine( ui_PixmapType *drawingPixmap, ui_GraphicsContextType *theGC, gint x1, gint y1, gint x2, gint y2 ); void ui_DrawText( ui_PixmapType *drawingPixmap, ui_GraphicsContextType *theGC, gint x, gint y, char *theText, ui_FontType *theFont ); void ui_DrawFilledRect( ui_PixmapType *drawingPixmap, ui_GraphicsContextType *theGC, gint x, gint y, gint w, gint h ); void ui_DrawFilledPoly( ui_PixmapType *drawingPixmap, ui_GraphicsContextType *theGC, gint *x, gint *y, gint nbPoints, gint transX, gint transY ); void ui_GraphicsRepaint( WObject graphics, ui_PixmapType *drawingPixmap, ui_GraphicsContextType *gc ); /* image related */ ui_GraphicsContextType *ui_createGCFromPixmap( ui_PixmapType *thePixmap, gint32 width, gint32 height ); ui_PixmapType *ui_NewPixmap( gint w, gint h ); void ui_DeletePixmap( ui_PixmapType *thePixmap ); void ui_DrawRGBImage( ui_PixmapType *thePixmap, ui_GraphicsContextType *theGC, gint x, gint y, gint w, gint h, uchar *rgbbuf ); void ui_DrawPixmap( ui_PixmapType *dstPixmap, ui_GraphicsContextType *theGC, ui_PixmapType *srcPixmap, gint x, gint y, gint dstX, gint dstY, gint w, gint h ); /* for translating the key code to a waba key code */ int32 ui_TranslateKey( Word chr ); #endif /* __NM_LINUX_A_H__ */ /* Local Variables: c-file-style: "smartdata" End: */ --- NEW FILE: ui_gtk.c --- /* $Id: ui_gtk.c,v 1.1 2004/07/10 15:30:40 mriem Exp $ Copyright (C) 2000, 2001 SMARTDATA, http://www.smartdata.ch/ 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 of the License, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* GTK Port. See http://www.gtk.org/ for more informations */ #include "../waba.h" #ifdef WITH_THREAD /* as it seem gtk_main_iteration_do() don't return TRUE when we call gtk_main_quit(), */ /* we use a global variable to finish the program... Bad, but... */ gint isFinish; #endif g_error sucess = {ERRT_NONE,NULL}; g_error mkerror(unsigned char type, char *msg) { g_error e = {type,msg}; return e; } g_error prerror(g_error e) { if (e.type == ERRT_NONE) return sucess; if (!e.msg) e.msg = "?"; printf("*** ERROR ("); switch (e.type) { case ERRT_MEMORY: printf("MEMORY"); br... [truncated message content] |
|
From: Manfred R. <mr...@us...> - 2004-07-10 15:29:42
|
Update of /cvsroot/waba/waba/src/share/c In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10109/c Log Message: Directory /cvsroot/waba/waba/src/share/c added to the repository |