home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 39 / IOPROG_39.ISO / SOFT / sdkjava40.exe / data1.cab / fg_Include / Include / native.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-05-04  |  29.8 KB  |  718 lines

  1. /*++
  2.  
  3. Copyright (c) 1995-1999  Microsoft Corporation.  All rights reserved.
  4.  
  5. Module Name:
  6.  
  7.     native.h
  8.  
  9. Abstract:
  10.  
  11.     Public header for facilities provided by msjava.dll.
  12.  
  13. --*/
  14.  
  15. #ifndef _NATIVE_
  16. #define _NATIVE_
  17.  
  18. #ifndef JAVAVMAPI
  19. #if !defined(_MSJAVA_)
  20. #define JAVAVMAPI DECLSPEC_IMPORT
  21. #else
  22. #define JAVAVMAPI
  23. #endif
  24. #endif
  25.  
  26. #pragma warning(disable:4115)
  27. #pragma warning(disable:4510)
  28. #pragma warning(disable:4512)
  29. #pragma warning(disable:4610)
  30.  
  31. #ifdef __cplusplus
  32. extern "C" {
  33. #endif
  34.  
  35. //----------------------------------------------------------------------------
  36. // Since handles have gone away, this is no op. The unhands() in this file
  37. // a redundant but useful for clarity.
  38. // Note: You can not just unhand an array to get at it's data, you must now
  39. // use unhand(x)->body.
  40. //----------------------------------------------------------------------------
  41. #define unhand(phobj) (phobj)
  42.  
  43. //----------------------------------------------------------------------------
  44. //----------------------------------------------------------------------------
  45. #define JAVAPKG    "java/lang/"
  46.  
  47. //----------------------------------------------------------------------------
  48. // Standard Java declarations for built in types.
  49. //----------------------------------------------------------------------------
  50. typedef unsigned short unicode;
  51. typedef long int32_t;
  52. typedef __int64 int64_t;
  53. typedef int BOOL;
  54. typedef void *PVOID;
  55. typedef unsigned long DWORD;
  56. #ifndef _SIZE_T_DEFINED
  57. #define _SIZE_T_DEFINED
  58. typedef unsigned int size_t;
  59. #endif
  60. #ifndef VOID
  61. #define VOID void
  62. #endif
  63. #ifndef _BOOL_T_DEFINED
  64. #define _BOOL_T_DEFINED
  65. typedef BOOL bool_t;
  66. #endif
  67.  
  68. #if !defined(_MSJAVA_)
  69. typedef struct OBJECT {
  70.     const PVOID MSReserved;
  71. } OBJECT;
  72. #endif
  73.  
  74. typedef OBJECT Classjava_lang_Object;
  75. typedef OBJECT Hjava_lang_Object;
  76. typedef OBJECT ClassObject;
  77. typedef Hjava_lang_Object JHandle;
  78. typedef Hjava_lang_Object HObject;
  79.  
  80. //----------------------------------------------------------------------------
  81. // All RNI DLLs should export the following function to let the VM determine
  82. // if the DLL is compatible with it.
  83. //----------------------------------------------------------------------------
  84.  
  85. DWORD __declspec(dllexport) __cdecl RNIGetCompatibleVersion();
  86.  
  87. #ifndef RNIVER
  88. #define RNIMAJORVER         2
  89. #define RNIMINORVER         0
  90. #define RNIVER              ((((DWORD) RNIMAJORVER) << 16) + (DWORD) RNIMINORVER)
  91. #endif
  92.  
  93. //----------------------------------------------------------------------------
  94. // Use to get the length of an array an HObject.
  95. //----------------------------------------------------------------------------
  96. #define obj_length(hobj) (((ArrayOfSomething*)unhand(hobj))->length)
  97.  
  98. //----------------------------------------------------------------------------
  99. // Thread entry/exit functions.
  100. // These functions should wrap any calls into the virtual machine.
  101. //----------------------------------------------------------------------------
  102. typedef struct {
  103.     DWORD   reserved[6];
  104. } ThreadEntryFrame;
  105.  
  106. JAVAVMAPI BOOL __cdecl PrepareThreadForJava(PVOID pThreadEntryFrame);
  107. JAVAVMAPI BOOL __cdecl PrepareThreadForJavaEx(PVOID pThreadEntryFrame, DWORD
  108.     dwFlags);
  109. JAVAVMAPI VOID __cdecl UnprepareThreadForJava(PVOID pThreadEntryFrame);
  110.  
  111. // Don't install the standard Microsoft SecurityManager.  Useful if an
  112. // application wants the process not to have an active SecurityManager or if it
  113. // plans on installing its own SecurityManager.  If this or another thread
  114. // has already called PrepareThreadForJava without specifying this flag, then
  115. // this flag will be ignored-- the current SecurityManager (possibly null) is
  116. // used.
  117. #define PTFJ_DONTINSTALLSTANDARDSECURITY    0x00000001
  118.  
  119. //----------------------------------------------------------------------------
  120. // Garbage Collection.
  121. //----------------------------------------------------------------------------
  122. typedef struct {
  123.     DWORD    reserved[6];
  124. } GCFrame;
  125.  
  126. JAVAVMAPI void    __cdecl GCFramePush(PVOID pGCFrame, PVOID pObjects, DWORD
  127.     cbObjectStructSize);
  128. JAVAVMAPI void    __cdecl GCFramePop(PVOID pGCFrame);
  129.  
  130. // 'Weak' ptrs
  131. JAVAVMAPI HObject** __cdecl GCGetPtr(HObject *phobj);
  132. JAVAVMAPI void    __cdecl GCFreePtr(HObject **pphobj);
  133.  
  134. #define GCGetWeakPtr    GCGetPtr
  135. #define GCFreeWeakPtr   GCFreePtr
  136.  
  137. // 'Strong' ptrs
  138. JAVAVMAPI HObject** __cdecl GCNewHandle(HObject *phobj);
  139. JAVAVMAPI void __cdecl GCFreeHandle(HObject **pphobj);
  140.  
  141. // 'Internal reserved pinned ptrs
  142. JAVAVMAPI HObject** __cdecl GCNewPinnedHandle(HObject *phobj);
  143. JAVAVMAPI void __cdecl GCFreePinnedHandle(HObject **pphobj);
  144.  
  145. // GC write barrier support
  146.  
  147. JAVAVMAPI void __cdecl GCSetObjectReferenceForObject (HObject* const * location, HObject* phobj);
  148. JAVAVMAPI void __cdecl GCSetObjectReferenceForHandle (HObject** handle, HObject* phobj);
  149.  
  150. JAVAVMAPI int     __cdecl GCEnable();
  151. JAVAVMAPI int     __cdecl GCDisable();
  152. JAVAVMAPI int     __cdecl GCDisableCount();
  153. JAVAVMAPI int     __cdecl GCEnableCompletely();
  154. JAVAVMAPI void    __cdecl GCDisableMultiple(int cDisable);
  155.  
  156. //----------------------------------------------------------------------------
  157. // "Built-in" object structures...
  158. // These include helper macro's to get at array data.
  159. //----------------------------------------------------------------------------
  160.  
  161. #include <pshpack4.h>
  162.  
  163. typedef struct Classjava_lang_String Classjava_lang_String;
  164. #define Hjava_lang_String Classjava_lang_String
  165. typedef Hjava_lang_String HString;
  166.  
  167. typedef struct ClassArrayOfByte
  168. {
  169.     const int32_t MSReserved;
  170.     const unsigned long length;
  171.     char body[1];
  172. } ClassArrayOfByte;
  173. #define HArrayOfByte ClassArrayOfByte
  174. #define ArrayOfByte ClassArrayOfByte
  175.  
  176. typedef struct ClassArrayOfBoolean
  177. {
  178.     const int32_t MSReserved;
  179.     const unsigned long length;
  180.     char body[1];           // all entries must be 0 (FALSE) or 1 (TRUE)
  181. } ClassArrayOfBoolean;
  182. #define HArrayOfBoolean ClassArrayOfBoolean
  183. #define ArrayOfBoolean ClassArrayOfBoolean
  184.  
  185. typedef struct ClassArrayOfChar
  186. {
  187.     const int32_t MSReserved;
  188.     const unsigned long length;
  189.     unsigned short body[1];
  190. } ClassArrayOfChar;
  191. #define HArrayOfChar ClassArrayOfChar
  192. #define ArrayOfChar ClassArrayOfChar
  193.  
  194. typedef struct ClassArrayOfShort
  195. {
  196.     const int32_t MSReserved;
  197.     const unsigned long length;
  198.     short body[1];
  199. } ClassArrayOfShort;
  200. #define HArrayOfShort ClassArrayOfShort
  201. #define ArrayOfShort ClassArrayOfShort
  202.  
  203. typedef struct ClassArrayOfInt
  204. {
  205.     const int32_t MSReserved;
  206.     const unsigned long length;
  207.     long body[1];
  208. } ClassArrayOfInt;
  209. #define HArrayOfInt ClassArrayOfInt
  210. #define ArrayOfInt ClassArrayOfInt
  211.  
  212. typedef struct ClassArrayOfLong
  213. {
  214.     const int32_t MSReserved;
  215.     const unsigned long length;
  216.     __int64 body[1];
  217. } ClassArrayOfLong;
  218. #define HArrayOfLong ClassArrayOfLong
  219. #define ArrayOfLong ClassArrayOfLong
  220.  
  221. typedef struct ClassArrayOfFloat
  222. {
  223.     const int32_t MSReserved;
  224.     const unsigned long length;
  225.     float body[1];
  226. } ClassArrayOfFloat;
  227. #define HArrayOfFloat ClassArrayOfFloat
  228. #define ArrayOfFloat ClassArrayOfFloat
  229.  
  230. typedef struct ClassArrayOfDouble
  231. {
  232.     const int32_t MSReserved;
  233.     const unsigned long length;
  234.     double body[1];
  235. } ClassArrayOfDouble;
  236. #define HArrayOfDouble ClassArrayOfDouble
  237. #define ArrayOfDouble ClassArrayOfDouble
  238.  
  239. typedef struct ClassArrayOfObject
  240. {
  241.     const int32_t MSReserved;
  242.     const unsigned long length;
  243.     HObject * const body[1];
  244. } ClassArrayOfObject;
  245. #define HArrayOfObject ClassArrayOfObject
  246. #define ArrayOfObject ClassArrayOfObject
  247.  
  248. typedef struct ClassArrayOfString
  249. {
  250.     const int32_t MSReserved;
  251.     const unsigned long length;
  252.     HString * const (body[1]);
  253. } ClassArrayOfString;
  254. #define HArrayOfString ClassArrayOfString
  255. #define ArrayOfString ClassArrayOfString
  256.  
  257. typedef struct ClassArrayOfArray
  258. {
  259.     const int32_t MSReserved;
  260.     const unsigned long length;
  261.     JHandle * const (body[1]);
  262. } ClassArrayOfArray;
  263. #define HArrayOfArray ClassArrayOfArray
  264. #define ArrayOfArray ClassArrayOfArray
  265.  
  266. typedef struct
  267. {
  268.     const int32_t MSReserved;
  269.     const unsigned long length;
  270. } ArrayOfSomething;
  271.  
  272. #include <poppack.h>
  273.  
  274. //----------------------------------------------------------------------------
  275. // We automatically track the execution environment so there's no EE() call
  276. // needed anymore, just pass NULL if an API needs one.
  277. //----------------------------------------------------------------------------
  278. #define EE() ((struct execenv *)NULL)
  279. typedef void ExecEnv;
  280.  
  281. //----------------------------------------------------------------------------
  282. // Exception handling stuff...
  283. //----------------------------------------------------------------------------
  284. JAVAVMAPI void __cdecl SignalError(struct execenv *ee, const char *ename, const char *DetailMessage);
  285. JAVAVMAPI void __cdecl SignalErrorPrintf( const char *ename, const char *pszFormat, ...);
  286.  
  287. JAVAVMAPI bool_t __cdecl exceptionOccurred(ExecEnv *ee);
  288. JAVAVMAPI void __cdecl exceptionDescribe(ExecEnv *ee);
  289. JAVAVMAPI void __cdecl exceptionClear(ExecEnv *ee);
  290. JAVAVMAPI void __cdecl exceptionSet( ExecEnv *ee, HObject *phThrowable );
  291.  
  292. JAVAVMAPI HObject * __cdecl getPendingException(ExecEnv *ee);
  293.  
  294. //----------------------------------------------------------------------------
  295. // Standard exec functions...
  296. //----------------------------------------------------------------------------
  297. #if !defined(_MSJAVA_)
  298. typedef PVOID ClassClass;
  299. #endif
  300.  
  301. JAVAVMAPI HObject* __cdecl execute_java_constructor(ExecEnv *ee, const char
  302.         *classname, ClassClass *cb, const char *signature, ...);
  303. JAVAVMAPI HObject* __cdecl execute_java_constructorV(ExecEnv *ee, const char
  304.         *classname, ClassClass *cb, const char *signature, va_list args);
  305.  
  306. JAVAVMAPI HObject* __cdecl execute_java_constructor_method(struct methodblock
  307.     *mb, ...);
  308. JAVAVMAPI HObject* __cdecl execute_java_constructor_methodV(struct methodblock
  309.     *mb, va_list args);
  310.  
  311. #ifndef execute_java_dynamic_method
  312. JAVAVMAPI long __cdecl execute_java_dynamic_method(ExecEnv *ee, HObject *obj,
  313.         const char *method_name, const char *signature, ...);
  314. #endif
  315. JAVAVMAPI int64_t __cdecl execute_java_dynamic_method64(ExecEnv *ee, HObject
  316.         *obj, const char *method_name, const char *signature, ...);
  317. JAVAVMAPI int64_t __cdecl execute_java_dynamic_methodV(ExecEnv *ee, HObject *obj,
  318.         const char *method_name, const char *signature, va_list args);
  319.  
  320. #ifndef execute_java_interface_method
  321. JAVAVMAPI long __cdecl execute_java_interface_method(ExecEnv *ee, HObject *pobj,
  322.         ClassClass *j_interface, const char *method_name, const char *signature,
  323.         ...);
  324. #endif
  325. JAVAVMAPI int64_t __cdecl execute_java_interface_method64(ExecEnv *ee, HObject
  326.         *pobj, ClassClass *j_interface, const char *method_name, const char
  327.         *signature, ...);
  328. JAVAVMAPI int64_t __cdecl execute_java_interface_methodV(ExecEnv *ee, HObject
  329.         *pobj, ClassClass *j_interface, const char *method_name, const char
  330.         *signature, va_list args);
  331.  
  332. #ifndef execute_java_static_method
  333. JAVAVMAPI long __cdecl execute_java_static_method(ExecEnv *ee, ClassClass *cb,
  334.         const char *method_name, const char *signature, ...);
  335. #endif
  336. JAVAVMAPI int64_t __cdecl execute_java_static_method64(ExecEnv *ee, ClassClass
  337.         *cb, const char *method_name, const char *signature, ...);
  338. JAVAVMAPI int64_t __cdecl execute_java_static_methodV(ExecEnv *ee, ClassClass
  339.         *cb, const char *method_name, const char *signature, va_list args);
  340.  
  341. //----------------------------------------------------------------------------
  342. // NB The resolve flag is ignored, classes found with this api will always
  343. // be resolved.
  344. //----------------------------------------------------------------------------
  345. JAVAVMAPI ClassClass* __cdecl FindClass(ExecEnv *ee, char *classname, bool_t
  346.         resolve);
  347.  
  348. //----------------------------------------------------------------------------
  349. // FindClassEx
  350. //
  351. // Similar to FindClass, but can take some flags that control how the class
  352. // load operation works.
  353. //
  354. // The valid flags are:
  355. //
  356. //   FINDCLASSEX_NOINIT
  357. //      If the class is a system class, will prevent the classes static
  358. //      initializer from running.
  359. //
  360. //   FINDCLASSEX_IGNORECASE
  361. //      Will perform a case-insensitive validation of the class name, as
  362. //      opposed to the case-sensitive validation that normally occurs.
  363. //
  364. //   FINDCLASSEX_SYSTEMONLY
  365. //       Will only look for the named class as a system class.
  366. //
  367. //----------------------------------------------------------------------------
  368.  
  369. #define FINDCLASSEX_NOINIT      0x0001
  370. #define FINDCLASSEX_IGNORECASE  0x0002
  371. #define FINDCLASSEX_SYSTEMONLY  0x0004
  372.  
  373. JAVAVMAPI ClassClass* __cdecl FindClassEx(const char *pszClassName,DWORD dwFlags);
  374.  
  375. //----------------------------------------------------------------------------
  376. // FindClassFromClass
  377. //
  378. // Similar to FindClassEx, but takes a ClassClass that supplies the ClassLoader
  379. // context to use to
  380. //----------------------------------------------------------------------------
  381.  
  382. JAVAVMAPI ClassClass* __cdecl FindClassFromClass(const char *pszClassName,
  383.     DWORD dwFlags, ClassClass *pContextClass);
  384.  
  385. //----------------------------------------------------------------------------
  386. // Helper function that returns a methodblock.
  387. //----------------------------------------------------------------------------
  388. JAVAVMAPI struct methodblock* __cdecl get_methodblock(HObject *pjobj, const char
  389.         *method_name, char *signature);
  390.  
  391. //----------------------------------------------------------------------------
  392. // If you pass in a methodblock from get_methodblock the method name and
  393. // sig are ignored and so it's faster than a regular execute.
  394. //----------------------------------------------------------------------------
  395. #ifndef do_execute_java_method
  396. JAVAVMAPI long __cdecl do_execute_java_method(ExecEnv *ee, void *obj, const char
  397.         *method_name, const char *signature, struct methodblock *mb,
  398.         bool_t isStaticCall, ...);
  399. #endif
  400. JAVAVMAPI int64_t __cdecl do_execute_java_method64(ExecEnv *ee, void *obj, const
  401.         char *method_name, const char *signature, struct methodblock *mb,
  402.         bool_t isStaticCall, ...);
  403. JAVAVMAPI int64_t __cdecl do_execute_java_methodV(ExecEnv *ee, void *obj, const
  404.         char *method_name, const char *signature, struct methodblock *mb,
  405.         bool_t isStaticCall, va_list args);
  406.  
  407. //----------------------------------------------------------------------------
  408. // isInstanceOf
  409. //
  410. // Returns true if the specified object can be cast to the named class
  411. // type.
  412. //----------------------------------------------------------------------------
  413.  
  414. JAVAVMAPI BOOL __cdecl isInstanceOf(JHandle *phobj, const char *classname);
  415.  
  416. //----------------------------------------------------------------------------
  417. // is_instance_of
  418. //
  419. // Returns true if the specified object can be cast to the specified
  420. // class type.
  421. //----------------------------------------------------------------------------
  422.  
  423. JAVAVMAPI BOOL __cdecl is_instance_of(JHandle *phobj,ClassClass *dcb,ExecEnv *ee);
  424.  
  425. //----------------------------------------------------------------------------
  426. // is_subclass_of
  427. //
  428. // Returns true if the class (cb) is a subclass of the specified class(dcb).
  429. //----------------------------------------------------------------------------
  430.  
  431. JAVAVMAPI BOOL __cdecl is_subclass_of(ClassClass *cb, ClassClass *dcb, ExecEnv *ee);
  432.  
  433. //----------------------------------------------------------------------------
  434. // ImplementsInterface
  435. //
  436. // Returns true if the class (cb) implements the specified interface (icb).
  437. //----------------------------------------------------------------------------
  438.  
  439. JAVAVMAPI BOOL __cdecl ImplementsInterface(ClassClass *cb,ClassClass *icb,ExecEnv *ee);
  440.  
  441. //----------------------------------------------------------------------------
  442. #define T_TMASK    034
  443. #define T_LMASK 003
  444. #define T_MKTYPE( t, l )  ( ( (t)&T_TMASK ) | ( (l)&T_LMASK) )
  445.  
  446. #define T_CLASS        2
  447. #define T_FLOATING    4    
  448. #define T_CHAR        5
  449. #define T_INTEGER    010
  450. #define T_BOOLEAN    4
  451.  
  452. #define T_FLOAT     T_MKTYPE(T_FLOATING,2)
  453. #define T_DOUBLE    T_MKTYPE(T_FLOATING,3)
  454. #define T_BYTE        T_MKTYPE(T_INTEGER,0)
  455. #define T_SHORT        T_MKTYPE(T_INTEGER,1)
  456. #define T_INT        T_MKTYPE(T_INTEGER,2)
  457. #define T_LONG        T_MKTYPE(T_INTEGER,3)
  458.  
  459. //----------------------------------------------------------------------------
  460. // Create an array of primitive types only (int, long etc).
  461. //----------------------------------------------------------------------------
  462. JAVAVMAPI HObject* __cdecl ArrayAlloc(int type, int cItems);
  463.  
  464. //----------------------------------------------------------------------------
  465. // Create an array of objects.
  466. //----------------------------------------------------------------------------
  467. JAVAVMAPI HObject* __cdecl ClassArrayAlloc(int type, int cItems, const char *szSig);
  468.  
  469. //----------------------------------------------------------------------------
  470. // Create an array of objects.
  471. // If type is T_CLASS, cb must be valid.
  472. //----------------------------------------------------------------------------
  473. JAVAVMAPI HObject* __cdecl ClassArrayAlloc2(int type, int cItems, ClassClass *cb);
  474.  
  475. //----------------------------------------------------------------------------
  476. // Copy an array ala System.arrayCopy()
  477. //----------------------------------------------------------------------------
  478. JAVAVMAPI void __cdecl ArrayCopy(HObject *srch, long src_pos, HObject *dsth,
  479.         long dst_pos, long length);
  480.  
  481. //----------------------------------------------------------------------------
  482. // Create and return a new array of bytes initialized from the C string.
  483. //----------------------------------------------------------------------------
  484.  
  485. JAVAVMAPI HArrayOfByte* __cdecl MakeByteString(const char *str, long len);
  486.  
  487. //----------------------------------------------------------------------------
  488. // Create and return a new Java String object, initialized from the C string.
  489. //----------------------------------------------------------------------------
  490.  
  491. JAVAVMAPI Hjava_lang_String* __cdecl makeJavaString(const char *str, int len);
  492. JAVAVMAPI Hjava_lang_String* __cdecl makeJavaStringW(const unicode *pszwSrc, int cch);
  493.  
  494. //----------------------------------------------------------------------------
  495. // Create and return a new Java String object, initialized from a null
  496. // terminated, UTF8 formatted, C string.
  497. //----------------------------------------------------------------------------
  498. JAVAVMAPI Hjava_lang_String* __cdecl makeJavaStringFromUtf8(const char *pszUtf8);
  499.  
  500. //----------------------------------------------------------------------------
  501. // Get the characters of the String object into a C string buffer.
  502. // No allocation occurs. Assumes that len is the size of the buffer.
  503. // The C string's address is returned.
  504. //----------------------------------------------------------------------------
  505. JAVAVMAPI char* __cdecl javaString2CString(Hjava_lang_String *s, char *buf, int buflen);
  506.  
  507. //----------------------------------------------------------------------------
  508. // Return the length of the String object.
  509. //----------------------------------------------------------------------------
  510.  
  511. JAVAVMAPI int __cdecl javaStringLength(Hjava_lang_String *s);
  512. JAVAVMAPI int __cdecl javaStringLengthAsCString(Hjava_lang_String *s);
  513.  
  514. //----------------------------------------------------------------------------
  515. // Return temporary ptr to first char of the String object.
  516. // May change when gc happens.
  517. //----------------------------------------------------------------------------
  518. JAVAVMAPI unicode * __cdecl javaStringStart (HString *string);
  519.  
  520. //----------------------------------------------------------------------------
  521. // Note: The int passed to these API's must be an object ptr.
  522. //----------------------------------------------------------------------------
  523. #define obj_monitor(handlep) ((int) handlep)
  524. JAVAVMAPI void __cdecl monitorEnter(unsigned int);
  525. JAVAVMAPI void __cdecl monitorExit(unsigned int);
  526. JAVAVMAPI void __cdecl monitorNotify(unsigned int);
  527. JAVAVMAPI void __cdecl monitorNotifyAll(unsigned int);
  528. JAVAVMAPI void __cdecl monitorWait(unsigned int, int64_t millis);
  529.  
  530. #define ObjectMonitorEnter(obj)         monitorEnter((int)obj)
  531. #define ObjectMonitorExit(obj)          monitorExit((int)obj)
  532. #define ObjectMonitorNotify(obj)        monitorNotify((int)obj)
  533. #define ObjectMonitorNotifyAll(obj)     monitorNotifyAll((int)obj)
  534. #define ObjectMonitorWait(obj,millis)   monitorWait((int)obj,millis)
  535.  
  536. //----------------------------------------------------------------------------
  537. // String helpers...
  538. //----------------------------------------------------------------------------
  539. JAVAVMAPI int __cdecl jio_snprintf(char *str, size_t count, const char *fmt, ...);
  540. JAVAVMAPI int __cdecl jio_vsnprintf(char *str, size_t count, const char *fmt,
  541.     va_list args);
  542.  
  543. //----------------------------------------------------------------------------
  544. // Methods to get information about the caller of a native method.
  545. //----------------------------------------------------------------------------
  546.  
  547. JAVAVMAPI ClassClass * __cdecl GetNativeMethodCallersClass();
  548. JAVAVMAPI struct methodblock* __cdecl GetNativeMethodCallersMethodInfo();
  549.  
  550. //----------------------------------------------------------------------------
  551. // Methods to get information about the native method.
  552. //----------------------------------------------------------------------------
  553.  
  554. JAVAVMAPI ClassClass * __cdecl GetNativeMethodsClass();
  555. JAVAVMAPI struct methodblock* __cdecl GetNativeMethodsMethodInfo();
  556.  
  557. //----------------------------------------------------------------------------
  558. // Member attributes, as appear in Java class file.
  559. //----------------------------------------------------------------------------
  560.  
  561. #define ACC_PUBLIC      0x0001
  562. #define ACC_PRIVATE     0x0002
  563. #define ACC_PROTECTED   0x0004
  564. #define ACC_STATIC      0x0008
  565. #define ACC_FINAL       0x0010
  566. #define ACC_SYNCH       0x0020
  567. #define ACC_SUPER       0x0020
  568. #define ACC_THREADSAFE  0x0040
  569. #define ACC_VOLATILE    0x0040
  570. #define ACC_TRANSIENT   0x0080
  571. #define ACC_NATIVE      0x0100
  572. #define ACC_INTERFACE   0x0200
  573. #define ACC_ABSTRACT    0x0400
  574.  
  575. //----------------------------------------------------------------------------
  576. // Class information
  577. //----------------------------------------------------------------------------
  578.  
  579. // Total number of fields in the class, including supers
  580. JAVAVMAPI unsigned __cdecl            Class_GetFieldCount(ClassClass *cls);
  581. JAVAVMAPI struct fieldblock * __cdecl Class_GetField(ClassClass *cls, const char *name);
  582. JAVAVMAPI struct fieldblock * __cdecl Class_GetFieldByIndex(ClassClass *cls, unsigned index);
  583. // Total number of methods, including supers.
  584. JAVAVMAPI unsigned __cdecl            Class_GetMethodCount(ClassClass *cls);
  585. JAVAVMAPI struct methodblock* __cdecl Class_GetMethod(ClassClass *cls, const char *name, const char *signature);
  586. JAVAVMAPI struct methodblock* __cdecl Class_GetMethodByIndex(ClassClass *cls, unsigned index);
  587. JAVAVMAPI ClassClass * __cdecl        Class_GetSuper(ClassClass *cls);
  588. JAVAVMAPI const char * __cdecl        Class_GetName(ClassClass *cls);
  589. JAVAVMAPI unsigned __cdecl            Class_GetInterfaceCount(ClassClass *cls);
  590. JAVAVMAPI ClassClass * __cdecl        Class_GetInterface(ClassClass *cls, unsigned index);
  591. // Returns combination of ACC_* constants.
  592. JAVAVMAPI int __cdecl                 Class_GetAttributes(ClassClass *cls);
  593. JAVAVMAPI unsigned __cdecl            Class_GetConstantPoolCount(ClassClass *cls);
  594.  
  595. // Copies a constant pool item.  'size' is the size of 'pbuf' in bytes.
  596. // 'ptype' is filled in on output with the type of the item.  pbuf may be NULL
  597. // to obtain only the size/type.  Returns the number of bytes copied/needed or
  598. // -1 if failed.  For utf8 items, the buffer size is *not* the number of
  599. // characters, and the copied string will be null-terminated; size includes the
  600. // null-terminator.  For ClassRef, FieldRef, etc., the buffer is filled in with
  601. // a struct ptr.
  602. //
  603. // CP type          Buffer contents
  604. // CP_Utf8          null-terminated string
  605. // CP_Unicode       (error)
  606. // CP_Integer       long
  607. // CP_Float         float
  608. // CP_Long          __int64
  609. // CP_Double        double
  610. // CP_Class         ClassClass*
  611. // CP_String        HObject*
  612. // CP_FieldRef      fieldblock*
  613. // CP_MethodRef     methodblock*
  614. // CP_IntfMethod    methodblock*
  615. // CP_NameAndType   (error)
  616. //
  617. // Values for 'flags' parameter:
  618. // If the constant pool item has not yet been used, force its referent to be
  619. // loaded/looked up.  With this flag set, the method may cause GC.
  620. #define COPYCPITEM_RESOLVE_REFERENCES 1
  621.  
  622. JAVAVMAPI int __cdecl                 Class_CopyConstantPoolItem(ClassClass *cls, unsigned index, BYTE *pbuf, int size, DWORD flags, BYTE *ptype);
  623.  
  624. //----------------------------------------------------------------------------
  625. // Field/method information
  626. //----------------------------------------------------------------------------
  627.  
  628. JAVAVMAPI const char * __cdecl  Member_GetName(PVOID member);
  629. JAVAVMAPI const char * __cdecl  Member_GetSignature(PVOID member);
  630. // class of the field/method is implemented in.
  631. JAVAVMAPI ClassClass * __cdecl  Member_GetClass(PVOID member);
  632. // Returns combination of ACC_* constants.
  633. JAVAVMAPI int __cdecl           Member_GetAttributes(PVOID member);
  634.  
  635. // For non-static fields, Offset of field in object.  See also Field_Get/SetValue.
  636. JAVAVMAPI unsigned __cdecl      Field_GetOffset(struct fieldblock * field);
  637. // Ptr to static value
  638. JAVAVMAPI PVOID __cdecl         Field_GetStaticPtr(struct fieldblock * field);
  639.  
  640. //----------------------------------------------------------------------------
  641. // Object accessors
  642. //----------------------------------------------------------------------------
  643. JAVAVMAPI ClassClass * __cdecl  Object_GetClass(HObject *obj);
  644.  
  645. JAVAVMAPI __int32 __cdecl       Field_GetValue(HObject *obj, struct fieldblock * field);
  646. JAVAVMAPI __int64 __cdecl       Field_GetValue64(HObject *obj, struct fieldblock * field);
  647. JAVAVMAPI float __cdecl         Field_GetFloat(HObject *obj, struct fieldblock * field);
  648. JAVAVMAPI double __cdecl        Field_GetDouble(HObject *obj, struct fieldblock * field);
  649. JAVAVMAPI void __cdecl          Field_SetValue(HObject *obj, struct fieldblock * field, __int32 value);
  650. JAVAVMAPI void __cdecl          Field_SetValue64(HObject *obj, struct fieldblock * field, __int64 value);
  651. JAVAVMAPI void __cdecl          Field_SetFloat(HObject *obj, struct fieldblock * field, float value);
  652. JAVAVMAPI void __cdecl          Field_SetDouble(HObject *obj, struct fieldblock * field, double value);
  653.  
  654. #define Field_GetBoolean(obj,field)     ((bool_t)       Field_GetValue(obj,field))
  655. #define Field_GetByte(obj,field)        ((signed char)  Field_GetValue(obj,field))
  656. #define Field_GetChar(obj,field)        ((unicode)      Field_GetValue(obj,field))
  657. #define Field_GetShort(obj,field)       ((short)        Field_GetValue(obj,field))
  658. #define Field_GetInt(obj,field)                         Field_GetValue(obj,field)
  659. #define Field_GetLong(obj,field)                        Field_GetValue64(obj,field)
  660. #define Field_GetObject(obj,field)      ((HObject*)     Field_GetValue(obj,field))
  661. #define Field_GetFloat(obj,field)                       Field_GetFloat(obj,field)
  662. #define Field_GetDouble(obj,field)                      Field_GetDouble(obj,field)
  663.  
  664. #define Field_SetBoolean(obj,field,value)               Field_SetValue(obj,field,(bool_t)(value))
  665. #define Field_SetByte(obj,field,value)                  Field_SetValue(obj,field,(signed char)(value))
  666. #define Field_SetChar(obj,field,value)                  Field_SetValue(obj,field,(unicode)(value))
  667. #define Field_SetShort(obj,field,value)                 Field_SetValue(obj,field,(short)(value))
  668. #define Field_SetInt(obj,field,value)                   Field_SetValue(obj,field,value)
  669. #define Field_SetLong(obj,field,value)                  Field_SetValue64(obj,field,value)
  670. #define Field_SetObject(obj,field,value)                Field_SetValue(obj,field,(__int32)(value))
  671. #define Field_SetFloat(obj,field,value)                 Field_SetFloat(obj,field,value)
  672. #define Field_SetDouble(obj,field,value)                Field_SetDouble(obj,field,value)
  673.  
  674. //----------------------------------------------------------------------------
  675. // java.lang.Class<->ClassClass conversions
  676. //----------------------------------------------------------------------------
  677.  
  678. JAVAVMAPI ClassClass* __cdecl ClassObjectToClassClass(HObject *obj);
  679. JAVAVMAPI HObject* __cdecl ClassClassToClassObject(ClassClass *cls);
  680.  
  681. //----------------------------------------------------------------------------
  682. // Thread information
  683. //----------------------------------------------------------------------------
  684.  
  685. JAVAVMAPI BOOL __cdecl Thread_IsInterrupted(BOOL fResetInterruptFlag);
  686.  
  687. //----------------------------------------------------------------------------
  688. // class path modification
  689. //----------------------------------------------------------------------------
  690.  
  691. // add path to the VM's internal class path.
  692. // if fAppend is true, path is appended to the class path, else it is prepended.
  693. JAVAVMAPI BOOL __cdecl AddPathClassSource( const char *path, BOOL fAppend );
  694.  
  695. // notify the VM of a WIN32 resource containing class files.  this resource must
  696. //  be in the format created by JExeGen.
  697. // when classes are being loaded, the resource will be searched for classes
  698. //  as if it were a directory on the classpath.
  699. JAVAVMAPI BOOL __cdecl AddModuleResourceClassSource( HMODULE hMod, DWORD dwResID );
  700.  
  701. //----------------------------------------------------------------------------
  702. // Miscellaneous APIs
  703. //----------------------------------------------------------------------------
  704.  
  705. // Returns the same result as defined by java/lang/System.currentTimeMillis().
  706. JAVAVMAPI __int64 __cdecl GetCurrentJavaTimeMillis();
  707.  
  708. #ifdef __cplusplus
  709. }
  710. #endif
  711.  
  712. #pragma warning(default:4115)
  713. #pragma warning(default:4510)
  714. #pragma warning(default:4512)
  715. #pragma warning(default:4610)
  716.  
  717. #endif
  718.