Thread: [Waba-commits] CVS: waba/src/palm nmpalm_a.c,NONE,1.1 nmpalm_a.h,NONE,1.1 nmpalm_b.c,NONE,1.1 nmpalm
Status: Abandoned
Brought to you by:
bornet
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: */ |