Defines.h

Go to the documentation of this file.
00001 #ifndef JAVA_LANG_DEFINES_H
00002 #define JAVA_LANG_DEFINES_H 1
00003 
00004 // Window 32bits ILP = 32/32/32, Linux 32bits ILP = 32/32/32
00005 // Window 64bits ILP = 32/32/64, Linux 64bits ILP = 32/64/64
00006 
00007 typedef void* jvoid; // Make sure all handle use jvoid instead of jint
00008 typedef bool jboolean;
00009 typedef char jbyte;
00010 typedef unsigned char jubyte;
00011 typedef short jshort;
00012 typedef unsigned short jushort;
00013 typedef unsigned short jchar;
00014 typedef int jint;
00015 typedef unsigned int juint;
00016 typedef float jfloat;
00017 typedef double jdouble;
00018 
00019 #define MACRO_EXPAND_IMPL(X,Y) X##Y
00020 #define MACRO_EXPAND(X,Y) MACRO_EXPAND_IMPL(X,Y)
00021 #define CONCAT(X,Y) MACRO_EXPAND(X,Y)
00022 #define CSTR(X) ((const jbyte*)X)
00023 
00024 #define nilCString CSTR("")
00025 #define nilString String(nilCString)
00026 
00027 #define REGISTER_MEMBERS public: virtual jvoid getThis() const { return (jvoid)this;} virtual const Class& getClass() const { return theClass();} static const Class& theClass()
00028 #define REG_THE_CLASS(P,T,X,A) const Class& T::theClass() { static const Class *singular = Global::class_init(#T, __caster< T,P >::cast, X::copier, X::constructor, &P::theClass(), false, A); return *singular;}
00029 #define REGISTER_CLASS(P,T) REG_THE_CLASS(P,T,__concrete_operator< T >, false)
00030 #define REGISTER_ABSTRACT_CLASS(P,T) REG_THE_CLASS(P,T,__abstract_operator< T >, true)
00031 #define ADD_INTERFACE(X,Y) static jboolean CONCAT(status_,__LINE__) = Global::class_interface(X::theClass(), Y::theClass(), __caster< X,Y >::cast)
00032 
00033 #define assignable(D,S) (D::theClass().isAssignableFrom(S::theClass()))
00034 #define instanceof(I,C) (C::theClass().isInstance(I))
00035 #define castof(I,C) (*(C*)Global::class_cast(C::theClass(), I))
00036 #define leafof(I,C) (*(C*)(I).getThis())
00037 
00038 #include <limits.h>
00039 
00040 #if defined(_WIN64) || (__WORDSIZE == 64)
00041 #  define J64OS
00042 #  define P2I(p) ((jint)(jlong)(jvoid)p)
00043 #else
00044 #  define J32OS
00045 #  define P2I(p) ((jint)(jvoid)p)
00046 #endif
00047 
00048 #if defined(WIN32) || defined(UNDER_CE)
00049 
00050 typedef __int64 jlong;
00051 typedef unsigned __int64 julong;
00052 #define JLONG(T) ((jlong)T##L)
00053 #define DLL_IMPORT __declspec(dllimport)
00054 #define DLL_EXPORT __declspec(dllexport)
00055 #define WIN32_LEAN_AND_MEAN
00056 #pragma warning(disable:4251)
00057 #pragma comment(linker, "\"/manifestdependency:type='Win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")
00058 
00059 #if defined UNICODE
00060 #  define tchar jchar
00061 #  define TBUF(s) ((s).toWCString())
00062 #  define TCSTR(s) ((const jchar*)L##s)
00063 #else
00064 #  define tchar jbyte
00065 #  define TBUF(s) ((s).toCString())
00066 #  define TCSTR(s) CSTR(s)
00067 #endif
00068 #define TSTR(s) ((LPTSTR)(tchar*)(s))
00069 
00070 #else
00071 
00072 // Unix sizeof(wchar_t) == 4 which is not compatible with Win32 
00073 // So do not use wchar at all
00074 
00075 #include <stdint.h>
00076 typedef int64_t  jlong;
00077 typedef uint64_t julong;
00078 #define JLONG(T) ((jlong)T##LL)
00079 #define DLL_IMPORT
00080 #define DLL_EXPORT
00081 
00082 #endif
00083 
00084 #if defined(_USRDLL)
00085 #  if defined(JAVA_LANG_DLL_EXPORTS)
00086 #    define JAVA_LANG_SPEC DLL_EXPORT
00087 #  else
00088 #    define JAVA_LANG_SPEC DLL_IMPORT
00089 #  endif
00090 #  if defined(JAVA_UTIL_DLL_EXPORTS)
00091 #    define JAVA_UTIL_SPEC DLL_EXPORT
00092 #  else
00093 #    define JAVA_UTIL_SPEC DLL_IMPORT
00094 #  endif
00095 #  if defined(JAVA_IO_DLL_EXPORTS)
00096 #    define JAVA_IO_SPEC DLL_EXPORT
00097 #  else
00098 #    define JAVA_IO_SPEC DLL_IMPORT
00099 #  endif
00100 #else
00101 #    define JAVA_LANG_SPEC
00102 #    define JAVA_UTIL_SPEC
00103 #    define JAVA_IO_SPEC
00104 #endif
00105 
00106 namespace java {
00107   namespace lang {
00108 
00109     class Object;
00110     class Class;
00111     class String;
00112     class ObjectRef;
00113     typedef Object* jobject;
00114 
00115     typedef jvoid(*CastFunc)(jvoid);
00116     typedef ObjectRef(*InitFunc)();
00117     typedef ObjectRef(*CopyFunc)(const Object&);
00118 
00119     class JAVA_LANG_SPEC Global { // collection of system global free functions
00120     public:
00121       static CopyFunc class_copier(const Object& src);
00122       static const Class* class_init(const String& name, CastFunc _caster, CopyFunc _copier, InitFunc _constructor,
00123         const Class* parent = 0, jboolean primitive = true, jboolean abstract = false);
00124       static jboolean class_interface(const Class& c, const Class& i, CastFunc castFunc);
00125      static jvoid class_cast(const Class& c, const Object& src);
00126    };
00127 
00128   } // namespace lang
00129 } // namespace java
00130 
00131 #endif /* JAVA_LANG_DEFINES_H */

Generated on Fri May 16 11:54:43 2008 for CrossPlatformJavaLikeC++API by  doxygen 1.5.3