/****************************************************************************** Copyright by Telelogic AB 2002. This Program is owned by Telelogic and is protected by national copyright laws and international copyright treaties. Telelogic grants you the right to use this Program on one computer or in one local computer network at any one time. Under this License you may only modify the source code for the purpose of adapting it to your environment. You must reproduce and include any copyright and trademark notices on all copies of the source code. You may not use, copy, merge, modify or transfer the Program except as provided in this License. Telelogic does not warrant that the Program will meet your requirements or that the operation of the Program will be uninterrupted and error free. You are solely responsible that the selection of the Program and the modification of the source code will achieve your intended results and that the results are actually obtained. ******************************************************************************/ /************************** cast ****************************** * SDL Charstring <-> C/C++ char* conversion operators, * * replaces cstring2cstar and cstar2cstring in ctypes package * **************************************************************/ NEWTYPE CharConvert /*#NOTYPE*/ OPERATORS cast /*#NAME '__cast_cstring2pchar'*/ : Charstring -> ptr_char; /*#OP (B)*/ /* NOT in Cmicro */ cast /*#NAME '__cast_pchar2cstring'*/ : ptr_char -> Charstring; /*#OP (B)*/ /* NOT in Cmicro */ ENDNEWTYPE CharConvert; /*#CODE #HEADING #ifndef XSCT_CMICRO extern #(ptr_char) __cast_cstring2pchar XPP((SDL_Charstring)); extern SDL_Charstring __cast_pchar2cstring XPP((#(ptr_char))); #endif #BODY #ifndef XSCT_CMICRO extern #(ptr_char) __cast_cstring2pchar( SDL_Charstring C) { #(ptr_char) Result; int i; if (C == (SDL_Charstring)0) i = 0; else i = strlen(C)-1; Result = (#(ptr_char))XALLOC(i+1, (tSDLTypeInfo *)&ySDL_#(ptr_char)); if (i > 0) memcpy(Result, C+1, i); Result[i] = '\0'; if (C != 0 && C[0] == 'T') xFree_SDL_Charstring((void**)&C); return Result; } extern SDL_Charstring __cast_pchar2cstring( #(ptr_char) C) { SDL_Charstring Result; int i = 0; if (C != 0) i = strlen(C); Result = (SDL_Charstring) XALLOC(i+2, (tSDLTypeInfo *)&ySDL_SDL_Charstring); if (i > 0) memcpy(Result+1,C,i); Result[0] = 'T'; Result[i+1] = '\0'; return Result; } #endif */