Signature fixes for .NET 1.1
[mono.git] / mcs / class / corlib / System.Runtime.InteropServices / Marshal.cs
1 // System.Runtime.InteropServices.Marshal
2 //
3 // Sean MacIsaac (macisaac@ximian.com)
4 // Paolo Molaro (lupus@ximian.com)
5 // Dietmar Maurer (dietmar@ximian.com)
6 //
7 // (C) 2001-2002 Ximian, Inc.
8
9 using System.Runtime.CompilerServices;
10 using System;
11 using System.Reflection;
12 using System.Threading;
13
14 namespace System.Runtime.InteropServices
15 {
16         public sealed class Marshal
17         {
18                 /* fields */
19                 public static readonly int SystemMaxDBCSCharSize = 2; // don't know what this is
20                 public static readonly int SystemDefaultCharSize = 2;
21                 
22                 private Marshal () {}
23
24                 [MonoTODO]
25                 public static int AddRef (IntPtr pUnk) {
26                         throw new NotImplementedException ();
27                 }
28                 [MonoTODO]
29                 public static IntPtr AllocCoTaskMem (int cb) {
30                         throw new NotImplementedException ();
31                 }
32
33                 [MethodImplAttribute(MethodImplOptions.InternalCall)]
34                 public extern static IntPtr AllocHGlobal (IntPtr cb);
35
36                 public static IntPtr AllocHGlobal (int cb) {
37                         return AllocHGlobal ((IntPtr)cb);
38                 }
39
40                 [MonoTODO]
41                 public static object BindToMoniker (string monikerName) {
42                         throw new NotImplementedException ();
43                 }
44
45                 [MonoTODO]
46                 public static void ChangeWrapperHandleStrength (object otp, bool fIsWeak) {
47                         throw new NotImplementedException ();
48                 }
49
50                 [MethodImplAttribute(MethodImplOptions.InternalCall)]
51                 extern static void copy_to_unmanaged (Array source, int startIndex,
52                                                       IntPtr destination, int length);
53
54                 [MethodImplAttribute(MethodImplOptions.InternalCall)]
55                 extern static void copy_from_unmanaged (IntPtr source, int startIndex,
56                                                         Array destination, int length);
57
58                 public static void Copy (byte[] source, int startIndex, IntPtr destination, int length) {
59                         copy_to_unmanaged (source, startIndex, destination, length);
60                 }
61
62                 public static void Copy (char[] source, int startIndex, IntPtr destination, int length) {
63                         copy_to_unmanaged (source, startIndex, destination, length);
64                 }
65
66                 public static void Copy (short[] source, int startIndex, IntPtr destination, int length) {
67                         copy_to_unmanaged (source, startIndex, destination, length);
68                 }
69
70                 public static void Copy (int[] source, int startIndex, IntPtr destination, int length) {
71                         copy_to_unmanaged (source, startIndex, destination, length);
72                 }
73
74                 public static void Copy (long[] source, int startIndex, IntPtr destination, int length) {
75                         copy_to_unmanaged (source, startIndex, destination, length);
76                 }
77
78                 public static void Copy (float[] source, int startIndex, IntPtr destination, int length) {
79                         copy_to_unmanaged (source, startIndex, destination, length);
80                 }
81
82                 public static void Copy (double[] source, int startIndex, IntPtr destination, int length) {
83                         copy_to_unmanaged (source, startIndex, destination, length);
84                 }
85
86                 public static void Copy (IntPtr source, byte[] destination, int startIndex, int length) {
87                         copy_from_unmanaged (source, startIndex, destination, length);
88                 }
89
90                 public static void Copy (IntPtr source, char[] destination, int startIndex, int length) {
91                         copy_from_unmanaged (source, startIndex, destination, length);
92                 }
93
94                 public static void Copy (IntPtr source, short[] destination, int startIndex, int length) {
95                         copy_from_unmanaged (source, startIndex, destination, length);
96                 }
97
98                 public static void Copy (IntPtr source, int[] destination, int startIndex, int length) {
99                         copy_from_unmanaged (source, startIndex, destination, length);
100                 }
101
102                 public static void Copy (IntPtr source, long[] destination, int startIndex, int length) {
103                         copy_from_unmanaged (source, startIndex, destination, length);
104                 }
105
106                 public static void Copy (IntPtr source, float[] destination, int startIndex, int length) {
107                         copy_from_unmanaged (source, startIndex, destination, length);
108                 }
109
110                 public static void Copy (IntPtr source, double[] destination, int startIndex, int length) {
111                         copy_from_unmanaged (source, startIndex, destination, length);
112                 }
113
114                 [MonoTODO]
115                 public static object CreateWrapperOfType (object o, Type t) {
116                         throw new NotImplementedException ();
117                 }
118
119                 [MethodImplAttribute(MethodImplOptions.InternalCall)]
120                 public extern static void DestroyStructure (IntPtr ptr, Type structuretype);
121
122                 [MonoTODO]
123                 public static void FreeBSTR (IntPtr ptr) {
124                         throw new NotImplementedException ();
125                 }
126
127                 [MonoTODO]
128                 public static void FreeCoTaskMem (IntPtr ptr) {
129                         throw new NotImplementedException ();
130                 }
131
132                 [MethodImplAttribute(MethodImplOptions.InternalCall)]
133                 public extern static void FreeHGlobal (IntPtr hglobal);
134
135                 [MonoTODO]
136                 public static Guid GenerateGuidForType (Type type) {
137                         throw new NotImplementedException ();
138                 }
139
140                 [MonoTODO]
141                 public static string GenerateProgIdForType (Type type) {
142                         throw new NotImplementedException ();
143                 }
144
145                 [MonoTODO]
146                 public static object GetActiveObject (string progID) {
147                         throw new NotImplementedException ();
148                 }
149
150                 [MonoTODO]
151                 public static IntPtr GetComInterfaceForObject (object o, Type T) {
152                         throw new NotImplementedException ();
153                 }
154
155                 [MonoTODO]
156                 public static object GetComObjectData (object obj, object key) {
157                         throw new NotImplementedException ();
158                 }
159
160                 [MonoTODO]
161                 public static int GetComSlotForMethodInfo (MemberInfo m) {
162                         throw new NotImplementedException ();
163                 }
164
165                 [MonoTODO]
166                 public static int GetEndComSlot (Type t) {
167                         throw new NotImplementedException ();
168                 }
169
170                 [MonoTODO]
171                 public static int GetExceptionCode() {
172                         throw new NotImplementedException ();
173                 }
174
175                 [MonoTODO]
176                 public static IntPtr GetExceptionPointers() {
177                         throw new NotImplementedException ();
178                 }
179
180                 [MonoTODO]
181                 public static IntPtr GetHINSTANCE (Module m) {
182                         throw new NotImplementedException ();
183                 }
184
185                 [MonoTODO]
186                 public static int GetHRForException (Exception e) {
187                         throw new NotImplementedException ();
188                 }
189
190                 [MonoTODO]
191                 public static int GetHRForLastWin32Error() {
192                         throw new NotImplementedException ();
193                 }
194
195                 [MonoTODO]
196                 public static IntPtr GetIDispatchForObject (object o) {
197                         throw new NotImplementedException ();
198                 }
199
200                 [MonoTODO]
201                 public static IntPtr GetITypeInfoForType (Type t) {
202                         throw new NotImplementedException ();
203                 }
204
205                 [MonoTODO]
206                 public static IntPtr GetIUnknownForObject (object o) {
207                         throw new NotImplementedException ();
208                 }
209
210                 [MethodImplAttribute(MethodImplOptions.InternalCall)]
211                 public static extern int GetLastWin32Error();
212
213                 [MonoTODO]
214                 public static IntPtr GetManagedThunkForUnmanagedMethodPtr (IntPtr pfnMethodToWrap, IntPtr pbSignature, int cbSignature) {
215                         throw new NotImplementedException ();
216                 }
217
218                 [MonoTODO]
219                 public static MemberInfo GetMethodInfoForComSlot (Type t, int slot, ref ComMemberType memberType) {
220                         throw new NotImplementedException ();
221                 }
222
223                 [MonoTODO]
224                 public static void GetNativeVariantForObject (object obj, IntPtr pDstNativeVariant) {
225                         throw new NotImplementedException ();
226                 }
227
228                 [MonoTODO]
229                 public static object GetObjectForIUnknown (IntPtr pUnk) {
230                         throw new NotImplementedException ();
231                 }
232
233                 [MonoTODO]
234                 public static object GetObjectForNativeVariant (IntPtr pSrcNativeVariant) {
235                         throw new NotImplementedException ();
236                 }
237
238                 [MonoTODO]
239                 public static object[] GetObjectsForNativeVariants (IntPtr aSrcNativeVariant, int cVars) {
240                         throw new NotImplementedException ();
241                 }
242
243                 [MonoTODO]
244                 public static int GetStartComSlot (Type t) {
245                         throw new NotImplementedException ();
246                 }
247
248                 [MonoTODO]
249                 public static Thread GetThreadFromFiberCookie (int cookie) {
250                         throw new NotImplementedException ();
251                 }
252
253                 [MonoTODO]
254                 public static object GetTypedObjectForIUnknown (IntPtr pUnk, Type t) {
255                         throw new NotImplementedException ();
256                 }
257
258                 [MonoTODO]
259                 public static Type GetTypeForITypeInfo (IntPtr piTypeInfo) {
260                         throw new NotImplementedException ();
261                 }
262
263                 [MonoTODO]
264                 public static string GetTypeInfoName (UCOMITypeInfo pTI) {
265                         throw new NotImplementedException ();
266                 }
267
268                 [MonoTODO]
269                 public static Guid GetTypeLibGuid (UCOMITypeLib pTLB) {
270                         throw new NotImplementedException ();
271                 }
272
273                 [MonoTODO]
274                 public static Guid GetTypeLibGuidForAssembly (Assembly asm) {
275                         throw new NotImplementedException ();
276                 }
277
278                 [MonoTODO]
279                 public static int GetTypeLibLcid (UCOMITypeLib pTLB) {
280                         throw new NotImplementedException ();
281                 }
282
283                 [MonoTODO]
284                 public static string GetTypeLibName (UCOMITypeLib pTLB) {
285                         throw new NotImplementedException ();
286                 }
287
288                 [MonoTODO]
289                 public static IntPtr GetUnmanagedThunkForManagedMethodPtr (IntPtr pfnMethodToWrap, IntPtr pbSignature, int cbSignature) {
290                         throw new NotImplementedException ();
291                 }
292
293                 [MonoTODO]
294                 public static bool IsComObject (object o) {
295                         throw new NotImplementedException ();
296                 }
297
298                 [MonoTODO]
299                 public static bool IsTypeVisibleFromCom (Type t) {
300                         throw new NotImplementedException ();
301                 }
302
303                 [MonoTODO]
304                 public static int NumParamBytes (MethodInfo m) {
305                         throw new NotImplementedException ();
306                 }
307
308                 [MethodImplAttribute(MethodImplOptions.InternalCall)]
309                 public extern static IntPtr OffsetOf (Type t, string fieldName);
310
311                 [MethodImplAttribute(MethodImplOptions.InternalCall)]
312                 public extern static void Prelink (MethodInfo m);
313
314                 [MethodImplAttribute(MethodImplOptions.InternalCall)]
315                 public extern static void PrelinkAll (Type c);
316
317                 [MethodImplAttribute(MethodImplOptions.InternalCall)]
318                 public extern static string PtrToStringAnsi (IntPtr ptr);
319                 
320                 [MethodImplAttribute(MethodImplOptions.InternalCall)]
321                 public extern static string PtrToStringAnsi (IntPtr ptr, int len);
322
323                 [MethodImplAttribute(MethodImplOptions.InternalCall)]
324                 public extern static string PtrToStringAuto (IntPtr ptr);
325                 
326                 [MethodImplAttribute(MethodImplOptions.InternalCall)]
327                 public extern static string PtrToStringAuto (IntPtr ptr, int len);
328
329                 [MethodImplAttribute(MethodImplOptions.InternalCall)]
330                 public extern static string PtrToStringUni (IntPtr ptr);
331
332                 [MethodImplAttribute(MethodImplOptions.InternalCall)]
333                 public extern static string PtrToStringUni (IntPtr ptr, int len);
334
335                 [MethodImplAttribute(MethodImplOptions.InternalCall)]
336                 public extern static string PtrToStringBSTR (IntPtr ptr);
337                 
338                 [MethodImplAttribute(MethodImplOptions.InternalCall)]
339                 public extern static void PtrToStructure (IntPtr ptr, object structure);
340
341                 [MethodImplAttribute(MethodImplOptions.InternalCall)]
342                 public extern static object PtrToStructure (IntPtr ptr, Type structureType);
343
344                 [MonoTODO]
345                 public static int QueryInterface (IntPtr pUnk, ref Guid iid, out IntPtr ppv) {
346                         throw new NotImplementedException ();
347                 }
348
349                 public static byte ReadByte (IntPtr ptr) {
350                         return ReadByte (ptr, 0);
351                 }
352
353                 [MethodImplAttribute(MethodImplOptions.InternalCall)]
354                 public extern static byte ReadByte (IntPtr ptr, int ofs);
355
356                 [MonoTODO]
357                 public static byte ReadByte ([In] object ptr, int ofs) {
358                         throw new NotImplementedException ();
359                 }
360
361                 public static short ReadInt16 (IntPtr ptr) {
362                         return ReadInt16 (ptr, 0);
363                 }
364
365                 [MethodImplAttribute(MethodImplOptions.InternalCall)]
366                 public extern static short ReadInt16 (IntPtr ptr, int ofs);
367
368                 [MonoTODO]
369                 public static short ReadInt16 ([In] object ptr, int ofs) {
370                         throw new NotImplementedException ();
371                 }
372
373                 public static int ReadInt32 (IntPtr ptr) {
374                         return ReadInt32 (ptr, 0);
375                 }
376
377                 [MethodImplAttribute(MethodImplOptions.InternalCall)]
378                 public extern static int ReadInt32 (IntPtr ptr, int ofs);
379
380                 [MonoTODO]
381                 public static int ReadInt32 ([In] object ptr, int ofs) {
382                         throw new NotImplementedException ();
383                 }
384
385                 public static long ReadInt64 (IntPtr ptr) {
386                         return ReadInt64 (ptr, 0);
387                 }
388
389                 [MethodImplAttribute(MethodImplOptions.InternalCall)]
390                 public extern static long ReadInt64 (IntPtr ptr, int ofs);
391
392                 [MonoTODO]
393                 public static long ReadInt64(object ptr, int ofs) {
394                         throw new NotImplementedException ();
395                 }
396
397                 public static IntPtr ReadIntPtr (IntPtr ptr) {
398                         return ReadIntPtr (ptr, 0);
399                 }
400                 
401                 [MethodImplAttribute(MethodImplOptions.InternalCall)]
402                 public extern static IntPtr ReadIntPtr (IntPtr ptr, int ofs);
403
404                 [MonoTODO]
405                 public static IntPtr ReadIntPtr(object ptr, int ofs) {
406                         throw new NotImplementedException ();
407                 }
408
409                 [MonoTODO]
410                 public static IntPtr ReAllocCoTaskMem (IntPtr pv, int cb) {
411                         throw new NotImplementedException ();
412                 }
413
414                 [MethodImplAttribute(MethodImplOptions.InternalCall)]
415                 public extern static IntPtr ReAllocHGlobal (IntPtr pv, IntPtr cb);
416
417                 [MonoTODO]
418                 public static int Release (IntPtr pUnk) {
419                         throw new NotImplementedException ();
420                 }
421
422                 [MonoTODO]
423                 public static int ReleaseComObject (object o) {
424                         throw new NotImplementedException ();
425                 }
426
427                 [MonoTODO]
428                 public static void ReleaseThreadCache() {
429                         throw new NotImplementedException ();
430                 }
431
432                 [MonoTODO]
433                 public static bool SetComObjectData (object obj, object key, object data) {
434                         throw new NotImplementedException ();
435                 }
436
437                 public static int SizeOf (object structure) {
438                         return SizeOf (structure.GetType ());
439                 }
440
441                 [MethodImplAttribute(MethodImplOptions.InternalCall)]
442                 public extern static int SizeOf (Type t);
443
444                 [MonoTODO]
445                 public static IntPtr StringToBSTR (string s) {
446                         throw new NotImplementedException ();
447                 }
448
449                 [MonoTODO]
450                 public static IntPtr StringToCoTaskMemAnsi (string s) {
451                         throw new NotImplementedException ();
452                 }
453
454                 [MonoTODO]
455                 public static IntPtr StringToCoTaskMemAuto (string s) {
456                         throw new NotImplementedException ();
457                 }
458
459                 [MonoTODO]
460                 public static IntPtr StringToCoTaskMemUni (string s) {
461                         throw new NotImplementedException ();
462                 }
463
464                 [MethodImplAttribute(MethodImplOptions.InternalCall)]
465                 public extern static IntPtr StringToHGlobalAnsi (string s);
466
467                 [MethodImplAttribute(MethodImplOptions.InternalCall)]
468                 public extern static IntPtr StringToHGlobalAuto (string s);
469
470                 [MethodImplAttribute(MethodImplOptions.InternalCall)]
471                 public extern static IntPtr StringToHGlobalUni (string s);
472
473                 [MethodImplAttribute(MethodImplOptions.InternalCall)]
474                 public extern static void StructureToPtr (object structure, IntPtr ptr, bool fDeleteOld);
475
476                 [MonoTODO]
477                 public static void ThrowExceptionForHR (int errorCode) {
478                         throw new NotImplementedException ();
479                 }
480
481                 [MonoTODO]
482                 public static void ThrowExceptionForHR (int errorCode, IntPtr errorInfo) {
483                         throw new NotImplementedException ();
484                 }
485
486                 [MonoTODO]
487                 public static IntPtr UnsafeAddrOfPinnedArrayElement (Array arr, int index) {
488                         throw new NotImplementedException ();
489                 }
490
491                 public static void WriteByte (IntPtr ptr, byte val) {
492                         WriteByte (ptr, 0, val);
493                 }
494
495                 [MethodImplAttribute(MethodImplOptions.InternalCall)]
496                 public extern static void WriteByte (IntPtr ptr, int ofs, byte val);
497
498                 [MonoTODO]
499                 public static void WriteByte([In,Out] object ptr, int ofs, byte val) {
500                         throw new NotImplementedException ();
501                 }
502
503                 public static void WriteInt16 (IntPtr ptr, short val) {
504                         WriteInt16 (ptr, 0, val);
505                 }
506
507                 [MethodImplAttribute(MethodImplOptions.InternalCall)]
508                 public extern static void WriteInt16 (IntPtr ptr, int ofs, short val);
509
510                 [MonoTODO]
511                 public static void WriteInt16([In,Out] object ptr, int ofs, short val) {
512                         throw new NotImplementedException ();
513                 }
514
515                 public static void WriteInt32 (IntPtr ptr, int val) {
516                         WriteInt32 (ptr, 0, val);
517                 }
518
519                 [MethodImplAttribute(MethodImplOptions.InternalCall)]
520                 public extern static void WriteInt32 (IntPtr ptr, int ofs, int val);
521
522                 [MonoTODO]
523                 public static void WriteInt32([In,Out] object ptr, int ofs, int val) {
524                         throw new NotImplementedException ();
525                 }
526
527                 public static void WriteInt64 (IntPtr ptr, long val) {
528                         WriteInt64 (ptr, 0, val);
529                 }
530
531                 [MethodImplAttribute(MethodImplOptions.InternalCall)]
532                 public extern static void WriteInt64 (IntPtr ptr, int ofs, long val);
533
534                 [MonoTODO]
535                 public static void WriteInt64(object ptr, int ofs, long val) {
536                         throw new NotImplementedException ();
537                 }
538
539                 public static void WriteIntPtr (IntPtr ptr, IntPtr val) {
540                         WriteIntPtr (ptr, 0, val);
541                 }
542
543                 [MethodImplAttribute(MethodImplOptions.InternalCall)]
544                 public extern static void WriteIntPtr (IntPtr ptr, int ofs, IntPtr val);
545
546                 [MonoTODO]
547                 public static void WriteIntPtr(object ptr, int ofs, IntPtr val) {
548                         throw new NotImplementedException ();
549                 }
550
551         }
552 }