[Waba-commits] CVS: waba/src/win32/c nmwin32_a.c,NONE,1.1 nmwin32_a.h,NONE,1.1 nmwin32_b.c,NONE,1.1
Status: Abandoned
Brought to you by:
bornet
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__ */ |