[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[cinvoke-svn] r63 - in trunk/cinvoke: bindings/java bindings/java/org/ci
From: |
will |
Subject: |
[cinvoke-svn] r63 - in trunk/cinvoke: bindings/java bindings/java/org/cinvoke lib lib/arch test |
Date: |
1 Jul 2006 00:31:31 -0400 |
Author: will
Date: 2006-07-01 00:31:31 -0400 (Sat, 01 Jul 2006)
New Revision: 63
Modified:
trunk/cinvoke/bindings/java/Makefile
trunk/cinvoke/bindings/java/org/cinvoke/CInvoke.java
trunk/cinvoke/bindings/java/org_cinvoke_CInvoke.cpp
trunk/cinvoke/bindings/java/org_cinvoke_CInvoke.h
trunk/cinvoke/lib/arch/cl_x86_win.h
trunk/cinvoke/lib/arch/empty_empty_empty.h
trunk/cinvoke/lib/arch/gcc_x64_unix.h
trunk/cinvoke/lib/arch/gcc_x86_unix.h
trunk/cinvoke/lib/cinvoke-arch.h
trunk/cinvoke/lib/cinvoke.c
trunk/cinvoke/lib/cinvoke.h
trunk/cinvoke/test/lib.c
trunk/cinvoke/test/runtests.c
Log:
implemented some native java methods, some general api/build fixes
Modified: trunk/cinvoke/bindings/java/Makefile
===================================================================
--- trunk/cinvoke/bindings/java/Makefile 2006-07-01 03:04:41 UTC (rev 62)
+++ trunk/cinvoke/bindings/java/Makefile 2006-07-01 04:31:31 UTC (rev 63)
@@ -7,10 +7,10 @@
OBJS = $(SRCS:.cpp=.o)
$(TARGET): $(OBJS)
- gcc -shared -o $(TARGET) $(OBJS)
+ g++ -shared -o $(TARGET) $(OBJS) -lcinvoke
.cpp.o:
- gcc -Wall -Werror -c $<
+ g++ -Wall -Werror -c $<
header:
javah org.cinvoke.CInvoke
Modified: trunk/cinvoke/bindings/java/org/cinvoke/CInvoke.java
===================================================================
--- trunk/cinvoke/bindings/java/org/cinvoke/CInvoke.java 2006-07-01
03:04:41 UTC (rev 62)
+++ trunk/cinvoke/bindings/java/org/cinvoke/CInvoke.java 2006-07-01
04:31:31 UTC (rev 63)
@@ -6,36 +6,37 @@
}
private static native long createContext();
- private static native void deleteContext(long ctx);
+ private static native String getError(long ctx);
+ private static native int deleteContext(long ctx);
private static native long createLibrary(long ctx, String path);
private static native long loadEPLibrary(long ctx, long lib,
String path);
- private static native void deleteLibrary(long ctx, long lib);
+ private static native int deleteLibrary(long ctx, long lib);
private static native long createFunction(long ctx, int cc, String
retfmt,
String paramfmt);
private static native Object invokeFunction(long ctx, long func, long
ep,
Object[] params);
- private static native void deleteFunction(long ctx, long func);
+ private static native int deleteFunction(long ctx, long func);
private static native long createStruct(long ctx);
- private static native void addValueMemberStruct(long ctx, long strct,
+ private static native int addValueMemberStruct(long ctx, long strct,
String name, int type);
- private static native void addStructMemberStruct(long ctx, long strct,
+ private static native int addStructMemberStruct(long ctx, long strct,
String name, long type);
private static native long alloc(int sz);
private static native void free(long m);
private static native void writeValue(long m, Object val);
private static native Object readValue(long m, int type);
- private static native void setMemberValueStruct(long ctx, long strct,
+ private static native int setMemberValueStruct(long ctx, long strct,
long m, String name, Object val);
private static native Object getMemberValueStruct(long ctx, long strct,
- long m, String name);
- private static native void finishStruct(long ctx, long strct);
+ long m, String name, int type);
+ private static native int finishStruct(long ctx, long strct);
private static native int sizeStruct(long ctx, long strct);
- private static native void deleteStruct(long ctx, long strct);
+ private static native int deleteStruct(long ctx, long strct);
private static native long createCallback(long ctx, long func,
CBThunk cbcls);
private static native long getEPCallback(long ctx, long cb);
- private static native void deleteCallback(long ctx, long cb);
+ private static native int deleteCallback(long ctx, long cb);
private class CBThunk {
public CBThunk() {
Modified: trunk/cinvoke/bindings/java/org_cinvoke_CInvoke.cpp
===================================================================
--- trunk/cinvoke/bindings/java/org_cinvoke_CInvoke.cpp 2006-07-01 03:04:41 UTC
(rev 62)
+++ trunk/cinvoke/bindings/java/org_cinvoke_CInvoke.cpp 2006-07-01 04:31:31 UTC
(rev 63)
@@ -1,107 +1,181 @@
#include <stdio.h>
+#include <stdlib.h>
+#include <cinvoke.h>
#include "org_cinvoke_CInvoke.h"
JNIEXPORT jlong JNICALL Java_org_cinvoke_CInvoke_createContext(
JNIEnv *env, jclass) {
- // XXX
- return 0;
+ return (jlong)cinv_context_create();
}
-JNIEXPORT void JNICALL Java_org_cinvoke_CInvoke_deleteContext(
- JNIEnv *env, jclass, jlong) {
- // XXX
+JNIEXPORT jstring JNICALL Java_org_cinvoke_CInvoke_getError(
+ JNIEnv *env, jclass, jlong c) {
+ CInvContext *ctx = (CInvContext *)c;
+ return env->NewStringUTF(cinv_context_geterrormsg(ctx));
}
+JNIEXPORT jint JNICALL Java_org_cinvoke_CInvoke_deleteContext(
+ JNIEnv *env, jclass, jlong c) {
+ CInvContext *ctx = (CInvContext *)c;
+ return cinv_context_delete(ctx);
+}
JNIEXPORT jlong JNICALL Java_org_cinvoke_CInvoke_createLibrary(
- JNIEnv *env, jclass, jlong, jstring) {
- // XXX
- return 0;
+ JNIEnv *env, jclass, jlong c, jstring libname) {
+ CInvContext *ctx = (CInvContext *)c;
+ const char *chrs = env->GetStringUTFChars(libname, NULL);
+ if (chrs == NULL) return 0;
+
+ jlong ret = (jlong)cinv_library_create(ctx, chrs);
+
+ env->ReleaseStringUTFChars(libname, chrs);
+ return ret;
}
JNIEXPORT jlong JNICALL Java_org_cinvoke_CInvoke_loadEPLibrary(
- JNIEnv *env, jclass, jlong, jlong, jstring) {
- // XXX
- return 0;
+ JNIEnv *env, jclass, jlong c, jlong l, jstring name) {
+ CInvContext *ctx = (CInvContext *)c;
+ CInvLibrary *lib = (CInvLibrary *)l;
+ const char *chrs = env->GetStringUTFChars(name, NULL);
+ if (chrs == NULL) return 0;
+
+ jlong ret = (jlong)cinv_library_load_entrypoint(ctx, lib, chrs);
+
+ env->ReleaseStringUTFChars(name, chrs);
+ return ret;
}
-JNIEXPORT void JNICALL Java_org_cinvoke_CInvoke_deleteLibrary(
- JNIEnv *env, jclass, jlong, jlong) {
- // XXX
+JNIEXPORT jint JNICALL Java_org_cinvoke_CInvoke_deleteLibrary(
+ JNIEnv *env, jclass, jlong c, jlong l) {
+ CInvContext *ctx = (CInvContext *)c;
+ CInvLibrary *lib = (CInvLibrary *)l;
+
+ return cinv_library_delete(ctx, lib);
}
JNIEXPORT jlong JNICALL Java_org_cinvoke_CInvoke_createFunction(
- JNIEnv *env, jclass, jlong, jint, jstring, jstring) {
- // XXX
- return 0;
+ JNIEnv *env, jclass, jlong c, jint cc, jstring retfmt, jstring parmfmt)
{
+ CInvContext *ctx = (CInvContext *)c;
+ const char *parmchrs = env->GetStringUTFChars(parmfmt, NULL);
+ if (parmchrs == NULL) return 0;
+ const char *retchrs = env->GetStringUTFChars(retfmt, NULL);
+ if (retchrs == NULL) return 0;
+
+ jlong ret = (jlong)cinv_function_create(ctx, (cinv_callconv_t)cc,
+ retchrs, parmchrs);
+
+ env->ReleaseStringUTFChars(parmfmt, parmchrs);
+ env->ReleaseStringUTFChars(retfmt, retchrs);
+ return ret;
}
JNIEXPORT jobject JNICALL Java_org_cinvoke_CInvoke_invokeFunction(
- JNIEnv *env, jclass, jlong, jlong, jlong, jobjectArray) {
+ JNIEnv *env, jclass, jlong c, jlong f, jlong e, jobjectArray params) {
// XXX
return NULL;
}
-JNIEXPORT void JNICALL Java_org_cinvoke_CInvoke_deleteFunction(
- JNIEnv *env, jclass, jlong, jlong) {
- // XXX
+JNIEXPORT jint JNICALL Java_org_cinvoke_CInvoke_deleteFunction(
+ JNIEnv *env, jclass, jlong c, jlong f) {
+ CInvContext *ctx = (CInvContext *)c;
+ CInvFunction *func = (CInvFunction *)f;
+
+ return cinv_function_delete(ctx, func);
}
JNIEXPORT jlong JNICALL Java_org_cinvoke_CInvoke_createStruct(
- JNIEnv *env, jclass, jlong) {
- // XXX
- return 0;
+ JNIEnv *env, jclass, jlong c) {
+ CInvContext *ctx = (CInvContext *)c;
+
+ return (jlong)cinv_structure_create(ctx);
}
-JNIEXPORT void JNICALL Java_org_cinvoke_CInvoke_addValueMemberStruct(
- JNIEnv *env, jclass, jlong, jlong, jstring, jint) {
- // XXX
+JNIEXPORT jint JNICALL Java_org_cinvoke_CInvoke_addValueMemberStruct(
+ JNIEnv *env, jclass, jlong c, jlong s, jstring name, jint type) {
+ CInvContext *ctx = (CInvContext *)c;
+ CInvStructure *st = (CInvStructure *)s;
+ const char *chrs = env->GetStringUTFChars(name, NULL);
+ if (chrs == NULL) return 0;
+
+ jint ret = cinv_structure_addmember_value(ctx, st, chrs,
(cinv_type_t)type);
+
+ env->ReleaseStringUTFChars(name, chrs);
+ return ret;
}
-JNIEXPORT void JNICALL Java_org_cinvoke_CInvoke_addStructMemberStruct(
- JNIEnv *env, jclass, jlong, jlong, jstring, jlong) {
- // XXX
+JNIEXPORT jint JNICALL Java_org_cinvoke_CInvoke_addStructMemberStruct(
+ JNIEnv *env, jclass, jlong c, jlong s, jstring name, jlong t) {
+ CInvContext *ctx = (CInvContext *)c;
+ CInvStructure *st = (CInvStructure *)s;
+ CInvStructure *type = (CInvStructure *)t;
+ const char *chrs = env->GetStringUTFChars(name, NULL);
+ if (chrs == NULL) return 0;
+
+ jint ret = cinv_structure_addmember_struct(ctx, st, chrs, type);
+
+ env->ReleaseStringUTFChars(name, chrs);
+ return ret;
}
JNIEXPORT jlong JNICALL Java_org_cinvoke_CInvoke_alloc(
- JNIEnv *env, jclass, jint) {
- // XXX
- return 0;
+ JNIEnv *env, jclass, jint sz) {
+ return (jlong)malloc(sz);
}
JNIEXPORT void JNICALL Java_org_cinvoke_CInvoke_free(
- JNIEnv *env, jclass, jlong) {
- // XXX
+ JNIEnv *env, jclass, jlong p) {
+ void *ptr = (void *)p;
+ free(ptr);
}
JNIEXPORT void JNICALL Java_org_cinvoke_CInvoke_writeValue(
- JNIEnv *env, jclass, jlong, jobject) {
+ JNIEnv *env, jclass, jlong p, jobject val) {
// XXX
}
JNIEXPORT jobject JNICALL Java_org_cinvoke_CInvoke_readValue(
- JNIEnv *env, jclass, jlong, jint) {
+ JNIEnv *env, jclass, jlong p, jint type) {
// XXX
return NULL;
}
-JNIEXPORT void JNICALL Java_org_cinvoke_CInvoke_setMemberValueStruct(
- JNIEnv *env, jclass, jlong, jlong, jlong, jstring, jobject) {
+JNIEXPORT jint JNICALL Java_org_cinvoke_CInvoke_setMemberValueStruct(
+ JNIEnv *env, jclass, jlong c, jlong s, jlong i, jstring name, jobject
val) {
// XXX
+ return 0;
}
JNIEXPORT jobject JNICALL Java_org_cinvoke_CInvoke_getMemberValueStruct(
- JNIEnv *env, jclass, jlong, jlong, jlong, jstring) {
+ JNIEnv *env, jclass, jlong c, jlong s, jlong i, jstring name, jint
type) {
// XXX
return NULL;
}
-JNIEXPORT void JNICALL Java_org_cinvoke_CInvoke_finishStruct(
- JNIEnv *env, jclass, jlong, jlong) {
- // XXX
+JNIEXPORT jint JNICALL Java_org_cinvoke_CInvoke_finishStruct(
+ JNIEnv *env, jclass, jlong c, jlong s) {
+ CInvContext *ctx = (CInvContext *)c;
+ CInvStructure *st = (CInvStructure *)s;
+
+ return cinv_structure_finish(ctx, st);
}
JNIEXPORT jint JNICALL Java_org_cinvoke_CInvoke_sizeStruct(
- JNIEnv *env, jclass, jlong, jlong) {
- // XXX
- return 0;
+ JNIEnv *env, jclass, jlong c, jlong s) {
+ CInvContext *ctx = (CInvContext *)c;
+ CInvStructure *st = (CInvStructure *)s;
+
+ int ret;
+ if (!cinv_structure_getsize(ctx, st, &ret))
+ return -1;
+ return ret;
}
-JNIEXPORT void JNICALL Java_org_cinvoke_CInvoke_deleteStruct(
- JNIEnv *env, jclass, jlong, jlong) {
- // XXX
+JNIEXPORT jint JNICALL Java_org_cinvoke_CInvoke_deleteStruct(
+ JNIEnv *env, jclass, jlong c, jlong s) {
+ CInvContext *ctx = (CInvContext *)c;
+ CInvStructure *st = (CInvStructure *)s;
+
+ return cinv_structure_delete(ctx, st);
}
JNIEXPORT jlong JNICALL Java_org_cinvoke_CInvoke_createCallback(
- JNIEnv *env, jclass, jlong, jlong, jobject) {
+ JNIEnv *env, jclass, jlong c, jlong f, jobject cbthunk) {
+ //CInvContext *ctx = (CInvContext *)c;
+ //CInvFunction *func = (CInvFunction *)f;
+
// XXX
return 0;
}
JNIEXPORT jlong JNICALL Java_org_cinvoke_CInvoke_getEPCallback(
- JNIEnv *env, jclass, jlong, jlong) {
- // XXX
- return 0;
+ JNIEnv *env, jclass, jlong c, jlong b) {
+ CInvContext *ctx = (CInvContext *)c;
+ CInvCallback *cb = (CInvCallback *)b;
+
+ return (jlong)cinv_callback_getentrypoint(ctx, cb);
}
-JNIEXPORT void JNICALL Java_org_cinvoke_CInvoke_deleteCallback(
- JNIEnv *env, jclass, jlong, jlong) {
- // XXX
+JNIEXPORT jint JNICALL Java_org_cinvoke_CInvoke_deleteCallback(
+ JNIEnv *env, jclass, jlong c, jlong b) {
+ CInvContext *ctx = (CInvContext *)c;
+ CInvCallback *cb = (CInvCallback *)b;
+
+ return cinv_callback_delete(ctx, cb);
}
Modified: trunk/cinvoke/bindings/java/org_cinvoke_CInvoke.h
===================================================================
--- trunk/cinvoke/bindings/java/org_cinvoke_CInvoke.h 2006-07-01 03:04:41 UTC
(rev 62)
+++ trunk/cinvoke/bindings/java/org_cinvoke_CInvoke.h 2006-07-01 04:31:31 UTC
(rev 63)
@@ -11,28 +11,29 @@
#endif
JNIEXPORT jlong JNICALL Java_org_cinvoke_CInvoke_createContext (JNIEnv *env,
jclass);
-JNIEXPORT void JNICALL Java_org_cinvoke_CInvoke_deleteContext (JNIEnv *env,
jclass, jlong);
+JNIEXPORT jstring JNICALL Java_org_cinvoke_CInvoke_getError (JNIEnv *env,
jclass, jlong);
+JNIEXPORT jint JNICALL Java_org_cinvoke_CInvoke_deleteContext (JNIEnv *env,
jclass, jlong);
JNIEXPORT jlong JNICALL Java_org_cinvoke_CInvoke_createLibrary (JNIEnv *env,
jclass, jlong, jstring);
JNIEXPORT jlong JNICALL Java_org_cinvoke_CInvoke_loadEPLibrary (JNIEnv *env,
jclass, jlong, jlong, jstring);
-JNIEXPORT void JNICALL Java_org_cinvoke_CInvoke_deleteLibrary (JNIEnv *env,
jclass, jlong, jlong);
+JNIEXPORT jint JNICALL Java_org_cinvoke_CInvoke_deleteLibrary (JNIEnv *env,
jclass, jlong, jlong);
JNIEXPORT jlong JNICALL Java_org_cinvoke_CInvoke_createFunction (JNIEnv *env,
jclass, jlong, jint, jstring, jstring);
JNIEXPORT jobject JNICALL Java_org_cinvoke_CInvoke_invokeFunction (JNIEnv
*env, jclass, jlong, jlong, jlong, jobjectArray);
-JNIEXPORT void JNICALL Java_org_cinvoke_CInvoke_deleteFunction (JNIEnv *env,
jclass, jlong, jlong);
+JNIEXPORT jint JNICALL Java_org_cinvoke_CInvoke_deleteFunction (JNIEnv *env,
jclass, jlong, jlong);
JNIEXPORT jlong JNICALL Java_org_cinvoke_CInvoke_createStruct (JNIEnv *env,
jclass, jlong);
-JNIEXPORT void JNICALL Java_org_cinvoke_CInvoke_addValueMemberStruct (JNIEnv
*env, jclass, jlong, jlong, jstring, jint);
-JNIEXPORT void JNICALL Java_org_cinvoke_CInvoke_addStructMemberStruct (JNIEnv
*env, jclass, jlong, jlong, jstring, jlong);
+JNIEXPORT jint JNICALL Java_org_cinvoke_CInvoke_addValueMemberStruct (JNIEnv
*env, jclass, jlong, jlong, jstring, jint);
+JNIEXPORT jint JNICALL Java_org_cinvoke_CInvoke_addStructMemberStruct (JNIEnv
*env, jclass, jlong, jlong, jstring, jlong);
JNIEXPORT jlong JNICALL Java_org_cinvoke_CInvoke_alloc (JNIEnv *env, jclass,
jint);
JNIEXPORT void JNICALL Java_org_cinvoke_CInvoke_free (JNIEnv *env, jclass,
jlong);
JNIEXPORT void JNICALL Java_org_cinvoke_CInvoke_writeValue (JNIEnv *env,
jclass, jlong, jobject);
JNIEXPORT jobject JNICALL Java_org_cinvoke_CInvoke_readValue (JNIEnv *env,
jclass, jlong, jint);
-JNIEXPORT void JNICALL Java_org_cinvoke_CInvoke_setMemberValueStruct (JNIEnv
*env, jclass, jlong, jlong, jlong, jstring, jobject);
+JNIEXPORT jint JNICALL Java_org_cinvoke_CInvoke_setMemberValueStruct (JNIEnv
*env, jclass, jlong, jlong, jlong, jstring, jobject);
JNIEXPORT jobject JNICALL Java_org_cinvoke_CInvoke_getMemberValueStruct
(JNIEnv *env, jclass, jlong, jlong, jlong, jstring);
-JNIEXPORT void JNICALL Java_org_cinvoke_CInvoke_finishStruct (JNIEnv *env,
jclass, jlong, jlong);
+JNIEXPORT jint JNICALL Java_org_cinvoke_CInvoke_finishStruct (JNIEnv *env,
jclass, jlong, jlong);
JNIEXPORT jint JNICALL Java_org_cinvoke_CInvoke_sizeStruct (JNIEnv *env,
jclass, jlong, jlong);
-JNIEXPORT void JNICALL Java_org_cinvoke_CInvoke_deleteStruct (JNIEnv *env,
jclass, jlong, jlong);
+JNIEXPORT jint JNICALL Java_org_cinvoke_CInvoke_deleteStruct (JNIEnv *env,
jclass, jlong, jlong);
JNIEXPORT jlong JNICALL Java_org_cinvoke_CInvoke_createCallback (JNIEnv *env,
jclass, jlong, jlong, jobject);
JNIEXPORT jlong JNICALL Java_org_cinvoke_CInvoke_getEPCallback (JNIEnv *env,
jclass, jlong, jlong);
-JNIEXPORT void JNICALL Java_org_cinvoke_CInvoke_deleteCallback (JNIEnv *env,
jclass, jlong, jlong);
+JNIEXPORT jint JNICALL Java_org_cinvoke_CInvoke_deleteCallback (JNIEnv *env,
jclass, jlong, jlong);
#ifdef __cplusplus
}
Modified: trunk/cinvoke/lib/arch/cl_x86_win.h
===================================================================
--- trunk/cinvoke/lib/arch/cl_x86_win.h 2006-07-01 03:04:41 UTC (rev 62)
+++ trunk/cinvoke/lib/arch/cl_x86_win.h 2006-07-01 04:31:31 UTC (rev 63)
@@ -59,7 +59,7 @@
// setting this to stdcall makes the win32 api work, but user-compiled
// dlls break; you can't win
-#define CINV_CC_DEFAULT CINV_CC_CDECL
+#define CINV_ARCH_CC_DEFAULT CINV_CC_CDECL
#define CINV_T_2BYTE CINV_T_SHORT
#define CINV_T_4BYTE CINV_T_INT
#define CINV_T_8BYTE CINV_T_EXTRALONG
Modified: trunk/cinvoke/lib/arch/empty_empty_empty.h
===================================================================
--- trunk/cinvoke/lib/arch/empty_empty_empty.h 2006-07-01 03:04:41 UTC (rev 62)
+++ trunk/cinvoke/lib/arch/empty_empty_empty.h 2006-07-01 04:31:31 UTC (rev 63)
@@ -82,9 +82,9 @@
#define CINV_E_INVAL (EINVAL)
// TODO: this sets the default calling convention. most
-// archs only have one, so just add it to the cinv_cc_t enum
-// and use that.
-#define CINV_CC_DEFAULT CINV_CC_CDECL
+// archs only have one, so you can either add a new one to
+// the cinv_callconv_t enumeration, or just use "cdecl"
+#define CINV_ARCH_CC_DEFAULT CINV_CC_CDECL
// TODO: set these similarly to the cinv_int*_t types above
#define CINV_T_2BYTE CINV_T_SHORT
Modified: trunk/cinvoke/lib/arch/gcc_x64_unix.h
===================================================================
--- trunk/cinvoke/lib/arch/gcc_x64_unix.h 2006-07-01 03:04:41 UTC (rev 62)
+++ trunk/cinvoke/lib/arch/gcc_x64_unix.h 2006-07-01 04:31:31 UTC (rev 63)
@@ -66,7 +66,7 @@
#define CINV_NOMEM_NEEDSFREE 1
#define CINV_E_INVAL ((cinv_int32_t)EINVAL)
-#define CINV_CC_DEFAULT CINV_CC_CDECL
+#define CINV_ARCH_CC_DEFAULT CINV_CC_CDECL
#define CINV_T_2BYTE CINV_T_SHORT
#define CINV_T_4BYTE CINV_T_INT
#define CINV_T_8BYTE CINV_T_EXTRALONG
Modified: trunk/cinvoke/lib/arch/gcc_x86_unix.h
===================================================================
--- trunk/cinvoke/lib/arch/gcc_x86_unix.h 2006-07-01 03:04:41 UTC (rev 62)
+++ trunk/cinvoke/lib/arch/gcc_x86_unix.h 2006-07-01 04:31:31 UTC (rev 63)
@@ -52,7 +52,7 @@
#define CINV_NOMEM_NEEDSFREE 1
#define CINV_E_INVAL ((cinv_int32_t)EINVAL)
-#define CINV_CC_DEFAULT CINV_CC_CDECL
+#define CINV_ARCH_CC_DEFAULT CINV_CC_CDECL
#define CINV_T_2BYTE CINV_T_SHORT
#define CINV_T_4BYTE CINV_T_INT
#define CINV_T_8BYTE CINV_T_EXTRALONG
Modified: trunk/cinvoke/lib/cinvoke-arch.h
===================================================================
--- trunk/cinvoke/lib/cinvoke-arch.h 2006-07-01 03:04:41 UTC (rev 62)
+++ trunk/cinvoke/lib/cinvoke-arch.h 2006-07-01 04:31:31 UTC (rev 63)
@@ -28,7 +28,7 @@
#ifndef _ARCH_H
#define _ARCH_H
-#ifdef __CPLUSPLUS
+#ifdef __cplusplus
extern "C" {
#endif
@@ -62,9 +62,10 @@
/** Indicates the calling convention being used for a function.
*/
typedef enum _cinv_callconv_t {
- CINV_CC_CDECL = 0, /**< The cdecl calling convention, the most common
convention on x86. */
- CINV_CC_STDCALL, /**< The stdcall calling convention, the default
convention for the Windows API. */
- CINV_CC_FASTCALL /**< Yet another, rarely used, Windows calling
convention */
+ CINV_CC_DEFAULT = 0,
+ CINV_CC_CDECL = 1, /**< The cdecl calling convention, the most common
convention on x86. */
+ CINV_CC_STDCALL = 2, /**< The stdcall calling convention, the default
convention for the Windows API. */
+ CINV_CC_FASTCALL = 3 /**< Yet another, rarely used, Windows calling
convention */
} cinv_callconv_t;
#ifdef ARCH_GCC_X86_UNIX
@@ -141,7 +142,7 @@
void arch_size_ptr(int *stacksize_out, int *structsize_out,
int *stackalign_out, int *structalign_out);
-#ifdef __CPLUSPLUS
+#ifdef __cplusplus
}
#endif
Modified: trunk/cinvoke/lib/cinvoke.c
===================================================================
--- trunk/cinvoke/lib/cinvoke.c 2006-07-01 03:04:41 UTC (rev 62)
+++ trunk/cinvoke/lib/cinvoke.c 2006-07-01 04:31:31 UTC (rev 63)
@@ -220,6 +220,8 @@
return NULL;
}
+ if (callingconvention == CINV_CC_DEFAULT)
+ callingconvention = CINV_ARCH_CC_DEFAULT;
function->callconv = callingconvention;
function->stacksize = 0;
Modified: trunk/cinvoke/lib/cinvoke.h
===================================================================
--- trunk/cinvoke/lib/cinvoke.h 2006-07-01 03:04:41 UTC (rev 62)
+++ trunk/cinvoke/lib/cinvoke.h 2006-07-01 04:31:31 UTC (rev 63)
@@ -30,7 +30,7 @@
#include "cinvoke-arch.h"
-#ifdef __CPLUSPLUS
+#ifdef __cplusplus
extern "C" {
#endif
@@ -408,7 +408,7 @@
CInvCallback *callback);
///////////////////
///////////////////
-#ifdef __CPLUSPLUS
+#ifdef __cplusplus
}
#endif
Modified: trunk/cinvoke/test/lib.c
===================================================================
--- trunk/cinvoke/test/lib.c 2006-07-01 03:04:41 UTC (rev 62)
+++ trunk/cinvoke/test/lib.c 2006-07-01 04:31:31 UTC (rev 63)
@@ -79,6 +79,6 @@
return 0.7f;
}
DLLEXPORT void test11(int (CDECL *f)(int, int, long, long, int, int,
-int, long)) {
- printf("test9: %d (want 1)\n", f(1, 2, 3, 4, 5, 6, 0x77777777,
0x8888888888888888));
+int, long long)) {
+ printf("test9: %d (want 1)\n", f(1, 2, 3, 4, 5, 6, 0x77777777,
0x88888888888888LL));
}
Modified: trunk/cinvoke/test/runtests.c
===================================================================
--- trunk/cinvoke/test/runtests.c 2006-07-01 03:04:41 UTC (rev 62)
+++ trunk/cinvoke/test/runtests.c 2006-07-01 04:31:31 UTC (rev 63)
@@ -321,8 +321,8 @@
void cbfunc2(CInvFunction *f, void *parameters[], void *returnout,
void *userdata) {
printf("userdata=%p (want 0xBB)\n", userdata);
- printf("args=%d %d %ld %ld %d %d %x %lx"
- " (want 1 2 3 4 5 6 77777777 8888888888888888)\n",
+ printf("args=%d %d %ld %ld %d %d %x %llx"
+ " (want 1 2 3 4 5 6 77777777 88888888888888)\n",
*(int *)parameters[0],
*(int *)parameters[1],
*(long *)parameters[2],
@@ -330,7 +330,7 @@
*(int *)parameters[4],
*(int *)parameters[5],
*(int *)parameters[6],
- *(long *)parameters[7]);
+ *(long long *)parameters[7]);
*(int *)returnout = 1;
}
@@ -338,7 +338,7 @@
int test11(CInvContext *ctx, CInvLibrary *lib, void *ep,
CInvFunction *f) {
CInvFunction *proto = cinv_function_create(ctx, CINV_CC_DEFAULT, "i",
- "iilliiil");
+ "iilliiie");
CInvCallback *cb = cinv_callback_create(ctx, proto, (void *)0xBB,
cbfunc2);
void *e = cinv_callback_getentrypoint(ctx, cb);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [cinvoke-svn] r63 - in trunk/cinvoke: bindings/java bindings/java/org/cinvoke lib lib/arch test,
will <=