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