/[dotgnu-pnet]/pnet/engine/pinvoke.c
ViewVC logotype

Diff of /pnet/engine/pinvoke.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.27 by rweather, Sat Jun 19 10:11:10 2004 UTC revision 1.28 by ktreichel, Tue Aug 23 10:45:52 2005 UTC
# Line 88  static ffi_type ffi_type_typedref = Line 88  static ffi_type ffi_type_typedref =
88  /*  /*
89   * Forward declarations.   * Forward declarations.
90   */   */
91  static ffi_type *TypeToFFI(ILType *type, int isInternal);  static ffi_type *TypeToFFI(ILExecProcess *process, ILType *type, int isInternal);
92    
93  #ifdef IL_CONFIG_PINVOKE  #ifdef IL_CONFIG_PINVOKE
94    
95  static ffi_type *StructToFFI(ILClass *classInfo);  static ffi_type *StructToFFI(ILExecProcess *process, ILClass *classInfo);
96    
97  #if !FFI_NO_STRUCTS  #if !FFI_NO_STRUCTS
98    
# Line 101  static ffi_type *StructToFFI(ILClass *cl Line 101  static ffi_type *StructToFFI(ILClass *cl
101   * about the non-static fields of a class.  Returns zero if   * about the non-static fields of a class.  Returns zero if
102   * out of memory.   * out of memory.
103   */   */
104  static int PopulateStructFFI(ILClass *classInfo, ffi_type **fieldTypes,  static int PopulateStructFFI(ILExecProcess *process, ILClass *classInfo,
105                                                           unsigned *posn)                                                            ffi_type **fieldTypes, unsigned *posn)
106  {  {
107          ILClass *parent;          ILClass *parent;
108          ILField *field;          ILField *field;
# Line 113  static int PopulateStructFFI(ILClass *cl Line 113  static int PopulateStructFFI(ILClass *cl
113          parent = ILClassGetParent(classInfo);          parent = ILClassGetParent(classInfo);
114          if(parent)          if(parent)
115          {          {
116                  if(!PopulateStructFFI(parent, fieldTypes, posn))                  if(!PopulateStructFFI(process, parent, fieldTypes, posn))
117                  {                  {
118                          return 0;                          return 0;
119                  }                  }
# Line 130  static int PopulateStructFFI(ILClass *cl Line 130  static int PopulateStructFFI(ILClass *cl
130                          if(ILType_IsValueType(type))                          if(ILType_IsValueType(type))
131                          {                          {
132                                  /* Process an embedded structure type */                                  /* Process an embedded structure type */
133                                  ffi = StructToFFI(ILType_ToValueType(type));                                  ffi = StructToFFI(process, ILType_ToValueType(type));
134                                  if(!ffi)                                  if(!ffi)
135                                  {                                  {
136                                          return 0;                                          return 0;
# Line 139  static int PopulateStructFFI(ILClass *cl Line 139  static int PopulateStructFFI(ILClass *cl
139                          else                          else
140                          {                          {
141                                  /* Process a non-structure type */                                  /* Process a non-structure type */
142                                  ffi = TypeToFFI(type, 0);                                  ffi = TypeToFFI(process, type, 0);
143                          }                          }
144                          fieldTypes[(*posn)++] = ffi;                          fieldTypes[(*posn)++] = ffi;
145                  }                  }
# Line 155  static int PopulateStructFFI(ILClass *cl Line 155  static int PopulateStructFFI(ILClass *cl
155   * Convert a "struct" class into a "ffi" type descriptor.   * Convert a "struct" class into a "ffi" type descriptor.
156   * Returns zero if out of memory.   * Returns zero if out of memory.
157   */   */
158  static ffi_type *StructToFFI(ILClass *classInfo)  static ffi_type *StructToFFI(ILExecProcess *process, ILClass *classInfo)
159  {  {
160  #if !FFI_NO_STRUCTS  #if !FFI_NO_STRUCTS
161          ILClass *current;          ILClass *current;
# Line 190  static ffi_type *StructToFFI(ILClass *cl Line 190  static ffi_type *StructToFFI(ILClass *cl
190          else          else
191          {          {
192                  /* Use the explicit layout information from "layout.c" */                  /* Use the explicit layout information from "layout.c" */
193                  explicitSize = _ILLayoutClassReturn(classInfo, &explicitAlignment);                  explicitSize = _ILLayoutClassReturn(process, classInfo, &explicitAlignment);
194          }          }
195    
196          /* Allocate space for the struct's type descriptor */          /* Allocate space for the struct's type descriptor */
# Line 213  static ffi_type *StructToFFI(ILClass *cl Line 213  static ffi_type *StructToFFI(ILClass *cl
213          if(!ILClass_IsExplicitLayout(classInfo))          if(!ILClass_IsExplicitLayout(classInfo))
214          {          {
215                  numFields = 0;                  numFields = 0;
216                  if(!PopulateStructFFI(classInfo, fieldTypes, &numFields))                  if(!PopulateStructFFI(process, classInfo, fieldTypes, &numFields))
217                  {                  {
218                          ILFree(descr);                          ILFree(descr);
219                          return 0;                          return 0;
# Line 239  static ffi_type *StructToFFI(ILClass *cl Line 239  static ffi_type *StructToFFI(ILClass *cl
239  /*  /*
240   * Convert an IL type into an "ffi" type descriptor.   * Convert an IL type into an "ffi" type descriptor.
241   */   */
242  static ffi_type *TypeToFFI(ILType *type, int isInternal)  static ffi_type *TypeToFFI(ILExecProcess *process, ILType *type, int isInternal)
243  {  {
244          if(ILType_IsPrimitive(type))          if(ILType_IsPrimitive(type))
245          {          {
# Line 279  static ffi_type *TypeToFFI(ILType *type, Line 279  static ffi_type *TypeToFFI(ILType *type,
279          else if(!isInternal && ILType_IsValueType(type))          else if(!isInternal && ILType_IsValueType(type))
280          {          {
281                  /* Structure that is passed by value to a PInvoke method */                  /* Structure that is passed by value to a PInvoke method */
282                  ffi_type *ffi = StructToFFI(ILClassResolve(ILType_ToValueType(type)));                  ffi_type *ffi = StructToFFI(process, ILClassResolve(ILType_ToValueType(type)));
283                  return (ffi ? ffi : &ffi_type_pointer);                  return (ffi ? ffi : &ffi_type_pointer);
284          }          }
285  #endif  #endif
# Line 290  static ffi_type *TypeToFFI(ILType *type, Line 290  static ffi_type *TypeToFFI(ILType *type,
290          }          }
291  }  }
292    
293  void *_ILMakeCifForMethod(ILMethod *method, int isInternal)  void *_ILMakeCifForMethod(ILExecProcess *process, ILMethod *method, int isInternal)
294  {  {
295          ILType *signature = ILMethod_Signature(method);          ILType *signature = ILMethod_Signature(method);
296          ILType *returnType = ILTypeGetEnumType(ILTypeGetReturn(signature));          ILType *returnType = ILTypeGetEnumType(ILTypeGetReturn(signature));
# Line 333  void *_ILMakeCifForMethod(ILMethod *meth Line 333  void *_ILMakeCifForMethod(ILMethod *meth
333          args = ((ffi_type **)(cif + 1));          args = ((ffi_type **)(cif + 1));
334    
335          /* Convert the return type */          /* Convert the return type */
336          rtype = TypeToFFI(modReturnType, isInternal);          rtype = TypeToFFI(process, modReturnType, isInternal);
337    
338          /* Convert the argument types */          /* Convert the argument types */
339          arg = 0;          arg = 0;
# Line 354  void *_ILMakeCifForMethod(ILMethod *meth Line 354  void *_ILMakeCifForMethod(ILMethod *meth
354          }          }
355          for(param = 1; param <= numParams; ++param)          for(param = 1; param <= numParams; ++param)
356          {          {
357                  args[arg++] = TypeToFFI(ILTypeGetEnumType                  args[arg++] = TypeToFFI(process, ILTypeGetEnumType
358                                                                          (ILTypeGetParam(signature, param)),                                                                          (ILTypeGetParam(signature, param)),
359                                                              isInternal);                                                              isInternal);
360          }          }
# Line 378  void *_ILMakeCifForMethod(ILMethod *meth Line 378  void *_ILMakeCifForMethod(ILMethod *meth
378          return (void *)cif;          return (void *)cif;
379  }  }
380    
381  void *_ILMakeCifForConstructor(ILMethod *method, int isInternal)  void *_ILMakeCifForConstructor(ILExecProcess *process, ILMethod *method, int isInternal)
382  {  {
383          ILType *signature = ILMethod_Signature(method);          ILType *signature = ILMethod_Signature(method);
384          ILUInt32 numArgs;          ILUInt32 numArgs;
# Line 420  void *_ILMakeCifForConstructor(ILMethod Line 420  void *_ILMakeCifForConstructor(ILMethod
420          }          }
421          for(param = 1; param <= numParams; ++param)          for(param = 1; param <= numParams; ++param)
422          {          {
423                  args[arg++] = TypeToFFI(ILTypeGetEnumType                  args[arg++] = TypeToFFI(process, ILTypeGetEnumType
424                                                                          (ILTypeGetParam(signature, param)),                                                                          (ILTypeGetParam(signature, param)),
425                                                              isInternal);                                                              isInternal);
426          }          }
# Line 1032  static void MethodInvoke(ffi_cif *cif, v Line 1032  static void MethodInvoke(ffi_cif *cif, v
1032    
1033  #endif /* FFI_CLOSURES */  #endif /* FFI_CLOSURES */
1034    
1035  void *_ILMakeClosureForDelegate(ILObject *delegate, ILMethod *method)  void *_ILMakeClosureForDelegate(ILExecProcess *process, ILObject *delegate, ILMethod *method)
1036  {  {
1037  #if FFI_CLOSURES  #if FFI_CLOSURES
1038          ILType *signature = ILMethod_Signature(method);          ILType *signature = ILMethod_Signature(method);
# Line 1058  void *_ILMakeClosureForDelegate(ILObject Line 1058  void *_ILMakeClosureForDelegate(ILObject
1058          args = ((ffi_type **)(cif + 1));          args = ((ffi_type **)(cif + 1));
1059    
1060          /* Convert the return type */          /* Convert the return type */
1061          rtype = TypeToFFI(returnType, 0);          rtype = TypeToFFI(process, returnType, 0);
1062    
1063          /* Convert the argument types */          /* Convert the argument types */
1064          arg = 0;          arg = 0;
# Line 1069  void *_ILMakeClosureForDelegate(ILObject Line 1069  void *_ILMakeClosureForDelegate(ILObject
1069          }          }
1070          for(param = 1; param <= numArgs; ++param)          for(param = 1; param <= numArgs; ++param)
1071          {          {
1072                  args[arg++] = TypeToFFI(ILTypeGetEnumType                  args[arg++] = TypeToFFI(process, ILTypeGetEnumType
1073                                                                          (ILTypeGetParam(signature, param)), 0);                                                                          (ILTypeGetParam(signature, param)), 0);
1074          }          }
1075    

Legend:
Removed from v.1.27  
changed lines
  Added in v.1.28

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26