[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Dotgnu-pnet-commits] CVS: pnet/engine custom.c,NONE,1.1 Makefile.am,1.
From: |
Rhys Weatherley <address@hidden> |
Subject: |
[Dotgnu-pnet-commits] CVS: pnet/engine custom.c,NONE,1.1 Makefile.am,1.53,1.54 cvm.h,1.38,1.39 cvm_conv.c,1.24,1.25 cvm_dasm.c,1.44,1.45 cvmc_setup.c,1.28,1.29 engine.h,1.66,1.67 pinvoke.c,1.17,1.18 |
Date: |
Thu, 30 Jan 2003 21:00:32 -0500 |
Update of /cvsroot/dotgnu-pnet/pnet/engine
In directory subversions:/tmp/cvs-serv19621/engine
Modified Files:
Makefile.am cvm.h cvm_conv.c cvm_dasm.c cvmc_setup.c engine.h
pinvoke.c
Added Files:
custom.c
Log Message:
Put some of the support code in place for custom marshaling (doesn't work yet).
--- NEW FILE ---
/*
* custom.c - Handle custom marshaling operations.
*
* Copyright (C) 2003 Southern Storm Software, Pty Ltd.
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "engine.h"
#ifdef __cplusplus
extern "C" {
#endif
void *_ILObjectToCustom(ILExecThread *thread, ILObject *obj,
const char *customName, int
customNameLen)
{
/* TODO */
return (void *)obj;
}
ILObject *_ILCustomToObject(ILExecThread *thread, void *ptr,
const char *customName,
int customNameLen)
{
/* TODO */
return (ILObject *)ptr;
}
#ifdef __cplusplus
};
#endif
Index: Makefile.am
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/Makefile.am,v
retrieving revision 1.53
retrieving revision 1.54
diff -C2 -r1.53 -r1.54
*** Makefile.am 14 Dec 2002 23:24:39 -0000 1.53
--- Makefile.am 31 Jan 2003 02:00:29 -0000 1.54
***************
*** 7,10 ****
--- 7,11 ----
call.c \
convert.c \
+ custom.c \
cvm_dasm.c \
cvm_lengths.c \
Index: cvm.h
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/cvm.h,v
retrieving revision 1.38
retrieving revision 1.39
diff -C2 -r1.38 -r1.39
*** cvm.h 28 Jan 2003 06:25:01 -0000 1.38
--- cvm.h 31 Jan 2003 02:00:29 -0000 1.39
***************
*** 468,500 ****
#define COP_PREFIX_REFARRAY2ANSI 0x44
#define COP_PREFIX_REFARRAY2UTF8 0x45
/*
* Inline method replacements.
*/
! #define COP_PREFIX_STRING_CONCAT_2 0x46
! #define COP_PREFIX_STRING_CONCAT_3 0x47
! #define COP_PREFIX_STRING_CONCAT_4 0x48
! #define COP_PREFIX_STRING_EQ 0x49
! #define COP_PREFIX_STRING_NE 0x4A
! #define COP_PREFIX_STRING_GET_CHAR 0x4B
! #define COP_PREFIX_TYPE_FROM_HANDLE 0x4C
! #define COP_PREFIX_MONITOR_ENTER 0x4D
! #define COP_PREFIX_MONITOR_EXIT 0x4E
/*
* Binary value fixups.
*/
! #define COP_PREFIX_FIX_I4_I 0x4F
! #define COP_PREFIX_FIX_I4_U 0x50
/*
* Trigger method unrolling.
*/
! #define COP_PREFIX_UNROLL_METHOD 0x51
/*
* Allocate local stack space.
*/
! #define COP_PREFIX_LOCAL_ALLOC 0x52
/*
--- 468,502 ----
#define COP_PREFIX_REFARRAY2ANSI 0x44
#define COP_PREFIX_REFARRAY2UTF8 0x45
+ #define COP_PREFIX_TOCUSTOM 0x46
+ #define COP_PREFIX_FROMCUSTOM 0x47
/*
* Inline method replacements.
*/
! #define COP_PREFIX_STRING_CONCAT_2 0x48
! #define COP_PREFIX_STRING_CONCAT_3 0x49
! #define COP_PREFIX_STRING_CONCAT_4 0x4A
! #define COP_PREFIX_STRING_EQ 0x4B
! #define COP_PREFIX_STRING_NE 0x4C
! #define COP_PREFIX_STRING_GET_CHAR 0x4D
! #define COP_PREFIX_TYPE_FROM_HANDLE 0x4E
! #define COP_PREFIX_MONITOR_ENTER 0x4F
! #define COP_PREFIX_MONITOR_EXIT 0x50
/*
* Binary value fixups.
*/
! #define COP_PREFIX_FIX_I4_I 0x51
! #define COP_PREFIX_FIX_I4_U 0x52
/*
* Trigger method unrolling.
*/
! #define COP_PREFIX_UNROLL_METHOD 0x53
/*
* Allocate local stack space.
*/
! #define COP_PREFIX_LOCAL_ALLOC 0x54
/*
Index: cvm_conv.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/cvm_conv.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -r1.24 -r1.25
*** cvm_conv.c 28 Jan 2003 06:25:01 -0000 1.24
--- cvm_conv.c 31 Jan 2003 02:00:29 -0000 1.25
***************
*** 2126,2129 ****
--- 2126,2199 ----
VMBREAK(COP_PREFIX_REFARRAY2UTF8);
+ /**
+ * <opcode name="tocustom" group="Conversion operators">
+ * <operation>Convert an object reference into a custom native
+ * pointer</operation>
+ *
+ * <format>prefix<fsep/>tocustom<fsep/>len[4]<fsep/>name</format>
+ * <dformat>{tocustom}<fsep/>len<fsep/>name</dformat>
+ *
+ * <form name="tocustom" code="COP_PREFIX_TOCUSTOM"/>
+ *
+ * <before>..., value</before>
+ * <after>..., result</after>
+ *
+ * <description>The <i>value</i> is popped from the stack as
+ * type <code>ptr</code>. The custom marshaler called <i>name</i>
+ * is used to convert <i>value</i> into a native pointer <i>result</i>.
+ * The value <i>len</i> is the length of the <i>name</i>.
+ * </description>
+ *
+ * <notes>This instruction is used to perform custom marshaling
+ * during "PInvoke" operations.</notes>
+ * </opcode>
+ */
+ VMCASE(COP_PREFIX_TOCUSTOM):
+ {
+ /* Convert an object reference into a native pointer */
+ COPY_STATE_TO_THREAD();
+ stacktop[-1].ptrValue = _ILObjectToCustom
+ (thread, (ILObject *)(stacktop[-1].ptrValue),
+ CVMP_ARG_WORD_PTR(const char *), CVMP_ARG_WORD);
+ RESTORE_STATE_FROM_THREAD();
+ MODIFY_PC_AND_STACK(CVMP_LEN_WORD_PTR, 0);
+ }
+ VMBREAK(COP_PREFIX_TOCUSTOM);
+
+ /**
+ * <opcode name="fromcustom" group="Conversion operators">
+ * <operation>Convert a custom native pointer into an object
+ * reference</operation>
+ *
+ * <format>prefix<fsep/>fromcustom<fsep/>len[4]<fsep/>name</format>
+ * <dformat>{fromcustom}<fsep/>len<fsep/>name</dformat>
+ *
+ * <form name="fromcustom" code="COP_PREFIX_FROMCUSTOM"/>
+ *
+ * <before>..., value</before>
+ * <after>..., result</after>
+ *
+ * <description>The <i>value</i> is popped from the stack as
+ * type <code>ptr</code>. The custom marshaler called <i>name</i>
+ * is used to convert <i>value</i> into an object refernce <i>result</i>.
+ * The value <i>len</i> is the length of the <i>name</i>.
+ * </description>
+ *
+ * <notes>This instruction is used to perform custom marshaling
+ * during "PInvoke" operations.</notes>
+ * </opcode>
+ */
+ VMCASE(COP_PREFIX_FROMCUSTOM):
+ {
+ /* Convert a native pointer into an object reference */
+ COPY_STATE_TO_THREAD();
+ stacktop[-1].ptrValue = _ILCustomToObject
+ (thread, stacktop[-1].ptrValue,
+ CVMP_ARG_WORD_PTR(const char *), CVMP_ARG_WORD);
+ RESTORE_STATE_FROM_THREAD();
+ MODIFY_PC_AND_STACK(CVMP_LEN_WORD_PTR, 0);
+ }
+ VMBREAK(COP_PREFIX_FROMCUSTOM);
+
#else /* !IL_CONFIG_PINVOKE */
***************
*** 2132,2135 ****
--- 2202,2207 ----
VMCASE(COP_PREFIX_ANSI2STR):
VMCASE(COP_PREFIX_UTF82STR):
+ VMCASE(COP_PREFIX_STR2UTF16):
+ VMCASE(COP_PREFIX_UTF162STR):
VMCASE(COP_PREFIX_DELEGATE2FNPTR):
VMCASE(COP_PREFIX_ARRAY2PTR):
***************
*** 2141,2144 ****
--- 2213,2224 ----
}
VMBREAK(COP_PREFIX_STR2ANSI);
+
+ VMCASE(COP_PREFIX_TOCUSTOM):
+ VMCASE(COP_PREFIX_FROMCUSTOM):
+ {
+ /* Stub out PInvoke-related CVM opcodes */
+ MODIFY_PC_AND_STACK(CVMP_LEN_WORD_PTR, 0);
+ }
+ VMBREAK(COP_PREFIX_TOCUSTOM);
#endif /* !IL_CONFIG_PINVOKE */
Index: cvm_dasm.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/cvm_dasm.c,v
retrieving revision 1.44
retrieving revision 1.45
diff -C2 -r1.44 -r1.45
*** cvm_dasm.c 28 Jan 2003 06:25:01 -0000 1.44
--- cvm_dasm.c 31 Jan 2003 02:00:29 -0000 1.45
***************
*** 56,59 ****
--- 56,60 ----
#define CVM_OPER_TAIL_CALL 25
#define CVM_OPER_PACK_VARARGS 26
+ #define CVM_OPER_CUSTOM 27
/*
***************
*** 526,529 ****
--- 527,532 ----
{"refarray2ansi", CVM_OPER_NONE},
{"refarray2utf8", CVM_OPER_NONE},
+ {"tocustom", CVM_OPER_CUSTOM},
+ {"fromcustom", CVM_OPER_CUSTOM},
/*
***************
*** 559,564 ****
* Reserved opcodes.
*/
- {"preserved_53", CVM_OPER_NONE},
- {"preserved_54", CVM_OPER_NONE},
{"preserved_55", CVM_OPER_NONE},
{"preserved_56", CVM_OPER_NONE},
--- 562,565 ----
***************
*** 957,960 ****
--- 958,970 ----
(ILType
*)CVMReadPointer(pc + 10), 0);
size = 10 + sizeof(void *);
+ }
+ break;
+
+ case CVM_OPER_CUSTOM:
+ {
+ putc('"', stream);
+ fwrite((void *)CVMReadPointer(pc + 6),
1,
+ (unsigned)(IL_READ_UINT32(pc
+ 2)), stream);
+ putc('"', stream);
}
break;
Index: cvmc_setup.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/cvmc_setup.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -C2 -r1.28 -r1.29
*** cvmc_setup.c 28 Jan 2003 06:25:01 -0000 1.28
--- cvmc_setup.c 31 Jan 2003 02:00:29 -0000 1.29
***************
*** 538,541 ****
--- 538,543 ----
#ifdef IL_CONFIG_PINVOKE
ILUInt32 marshalType;
+ char *customName;
+ int customNameLen;
#endif
***************
*** 571,575 ****
/* Perform PInvoke expansions on the parameter */
if(!isInternal &&
! (marshalType = ILPInvokeGetMarshalType(pinv, method, param))
!= IL_META_MARSHAL_DIRECT)
{
--- 573,578 ----
/* Perform PInvoke expansions on the parameter */
if(!isInternal &&
! (marshalType = ILPInvokeGetMarshalType(pinv, method, param,
!
&customName, &customNameLen))
!= IL_META_MARSHAL_DIRECT)
{
***************
*** 627,630 ****
--- 630,641 ----
}
break;
+
+ case IL_META_MARSHAL_CUSTOM:
+ {
+ CVMP_OUT_WORD_PTR(COP_PREFIX_TOCUSTOM,
+
(ILUInt32)(ILInt32)customNameLen,
+ (void
*)customName);
+ }
+ break;
}
if(offset < 4)
***************
*** 791,794 ****
--- 802,807 ----
ILUInt32 size;
ILUInt32 marshalType;
+ char *customName;
+ int customNameLen;
/* Push the address of the argument array onto the stack */
***************
*** 1012,1016 ****
/* Marshal the PInvoke return value back into a CLR
object */
marshalType = ILPInvokeGetMarshalType
! (ILPInvokeFind(method), method, 0);
switch(marshalType)
{
--- 1025,1029 ----
/* Marshal the PInvoke return value back into a CLR
object */
marshalType = ILPInvokeGetMarshalType
! (ILPInvokeFind(method), method, 0, &customName,
&customNameLen);
switch(marshalType)
{
***************
*** 1030,1033 ****
--- 1043,1054 ----
{
CVMP_OUT_NONE(COP_PREFIX_UTF162STR);
+ }
+ break;
+
+ case IL_META_MARSHAL_CUSTOM:
+ {
+ CVMP_OUT_WORD_PTR(COP_PREFIX_FROMCUSTOM,
+
(ILUInt32)(ILInt32)customNameLen,
+ (void
*)customName);
}
break;
Index: engine.h
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/engine.h,v
retrieving revision 1.66
retrieving revision 1.67
diff -C2 -r1.66 -r1.67
*** engine.h 10 Jan 2003 00:44:11 -0000 1.66
--- engine.h 31 Jan 2003 02:00:29 -0000 1.67
***************
*** 542,545 ****
--- 542,559 ----
#endif /* IL_CONFIG_DEBUG_LINES */
+ /*
+ * Perform custom marshalling to convert an object reference
+ * into a native pointer.
+ */
+ void *_ILObjectToCustom(ILExecThread *thread, ILObject *obj,
+ const char *customName, int
customNameLen);
+
+ /*
+ * Perform custom marshalling to convert a native pointer
+ * into an object reference.
+ */
+ ILObject *_ILCustomToObject(ILExecThread *thread, void *ptr,
+ const char *customName,
int customNameLen);
+
#ifdef __cplusplus
};
Index: pinvoke.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/pinvoke.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -r1.17 -r1.18
*** pinvoke.c 28 Jan 2003 06:25:01 -0000 1.17
--- pinvoke.c 31 Jan 2003 02:00:29 -0000 1.18
***************
*** 456,459 ****
--- 456,461 ----
ILNativeFloat tempFloat;
ILUInt32 marshalType;
+ char *customName;
+ int customNameLen;
char *strValue;
***************
*** 474,478 ****
{
/* Marshal parameters that need special handling */
! marshalType = ILPInvokeGetMarshalType(0, method, param);
if(marshalType != IL_META_MARSHAL_DIRECT)
{
--- 476,481 ----
{
/* Marshal parameters that need special handling */
! marshalType = ILPInvokeGetMarshalType(0, method, param,
!
&customName, &customNameLen);
if(marshalType != IL_META_MARSHAL_DIRECT)
{
***************
*** 546,549 ****
--- 549,568 ----
}
continue;
+
+ case IL_META_MARSHAL_CUSTOM:
+ {
+ /* Marshal a custom value from the
native world */
+ CHECK_SPACE(1);
+ stacktop->ptrValue = _ILCustomToObject
+ (thread, *((void **)(*args)),
+ customName, customNameLen);
+ if(ILExecThreadHasException(thread))
+ {
+ return 1;
+ }
+ ++args;
+ ++stacktop;
+ }
+ continue;
}
}
***************
*** 685,691 ****
ILNativeFloat tempFloat;
ILUInt32 marshalType;
/* Marshal return types that need special handling */
! marshalType = ILPInvokeGetMarshalType(0, method, 0);
if(marshalType != IL_META_MARSHAL_DIRECT)
{
--- 704,713 ----
ILNativeFloat tempFloat;
ILUInt32 marshalType;
+ char *customName;
+ int customNameLen;
/* Marshal return types that need special handling */
! marshalType = ILPInvokeGetMarshalType
! (0, method, 0, &customName, &customNameLen);
if(marshalType != IL_META_MARSHAL_DIRECT)
{
***************
*** 741,744 ****
--- 763,776 ----
*((void **)result) = 0;
}
+ }
+ return;
+
+ case IL_META_MARSHAL_CUSTOM:
+ {
+ /* Marshal a custom value to the native world */
+ *((void **)result) = _ILObjectToCustom
+ (thread, (ILObject
*)(thread->stackTop[-1].ptrValue),
+ customName, customNameLen);
+ --(thread->stackTop);
}
return;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Dotgnu-pnet-commits] CVS: pnet/engine custom.c,NONE,1.1 Makefile.am,1.53,1.54 cvm.h,1.38,1.39 cvm_conv.c,1.24,1.25 cvm_dasm.c,1.44,1.45 cvmc_setup.c,1.28,1.29 engine.h,1.66,1.67 pinvoke.c,1.17,1.18,
Rhys Weatherley <address@hidden> <=