Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Chambers <joncham@gmail.com>2007-04-24 16:13:23 +0400
committerJonathan Chambers <joncham@gmail.com>2007-04-24 16:13:23 +0400
commite8d592a899172a0f3801b18e7e14c82da6bdffb8 (patch)
tree710047dc1f59e4db97d3d2fab517903fec8c2191 /mcs/class/CustomMarshalers
parent08369769d59b4ae8df8b2ba2ec231e3ecbcd6ea2 (diff)
2007-04-24 Jonathan Chambers <joncham@gmail.com>
* EnumeratorToEnumVariantMarshaler.cs: Implement. svn path=/trunk/mcs/; revision=76183
Diffstat (limited to 'mcs/class/CustomMarshalers')
-rw-r--r--mcs/class/CustomMarshalers/System.Runtime.InteropServices.CustomMarshalers/ChangeLog3
-rw-r--r--mcs/class/CustomMarshalers/System.Runtime.InteropServices.CustomMarshalers/EnumeratorToEnumVariantMarshaler.cs96
2 files changed, 76 insertions, 23 deletions
diff --git a/mcs/class/CustomMarshalers/System.Runtime.InteropServices.CustomMarshalers/ChangeLog b/mcs/class/CustomMarshalers/System.Runtime.InteropServices.CustomMarshalers/ChangeLog
new file mode 100644
index 00000000000..94c59637c55
--- /dev/null
+++ b/mcs/class/CustomMarshalers/System.Runtime.InteropServices.CustomMarshalers/ChangeLog
@@ -0,0 +1,3 @@
+2007-04-24 Jonathan Chambers <joncham@gmail.com>
+
+ * EnumeratorToEnumVariantMarshaler.cs: Implement.
diff --git a/mcs/class/CustomMarshalers/System.Runtime.InteropServices.CustomMarshalers/EnumeratorToEnumVariantMarshaler.cs b/mcs/class/CustomMarshalers/System.Runtime.InteropServices.CustomMarshalers/EnumeratorToEnumVariantMarshaler.cs
index 514eed5ea0d..54f8bcb9915 100644
--- a/mcs/class/CustomMarshalers/System.Runtime.InteropServices.CustomMarshalers/EnumeratorToEnumVariantMarshaler.cs
+++ b/mcs/class/CustomMarshalers/System.Runtime.InteropServices.CustomMarshalers/EnumeratorToEnumVariantMarshaler.cs
@@ -3,8 +3,10 @@
//
// Authors:
// Martin Willemoes Hansen (mwh@sysrq.dk)
+// Jonathan Chambers (joncham@gmail.com)
//
// (C) 2003 Martin Willemoes Hansen
+// (C) 2007 Jonathan Chambers
//
//
@@ -28,43 +30,91 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
+using System;
+using System.Collections;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
namespace System.Runtime.InteropServices.CustomMarshalers
{
- public class EnumeratorToEnumVariantMarshaler : ICustomMarshaler {
- [MonoTODO]
- public void CleanUpManagedData (object pManagedObj)
- {
- throw new NotImplementedException();
+ public class EnumeratorToEnumVariantMarshaler : ICustomMarshaler
+ {
+ static EnumeratorToEnumVariantMarshaler instance;
+ public void CleanUpManagedData (object pManagedObj) {
+ throw new NotImplementedException ();
}
- [MonoTODO]
- public void CleanUpNativeData (IntPtr pNativeData)
- {
- throw new NotImplementedException();
+ public void CleanUpNativeData (IntPtr pNativeData) {
+ Marshal.Release (pNativeData);
}
- [MonoTODO]
- public static ICustomMarshaler GetInstance (string pstrCookie)
- {
- throw new NotImplementedException();
+ public static ICustomMarshaler GetInstance (string pstrCookie) {
+ if (instance == null)
+ instance = new EnumeratorToEnumVariantMarshaler ();
+ return instance;
}
- [MonoTODO]
- public int GetNativeDataSize()
- {
- throw new NotImplementedException();
+ public int GetNativeDataSize () {
+ throw new NotImplementedException ();
+ }
+
+ public IntPtr MarshalManagedToNative (object pManagedObj) {
+ throw new NotImplementedException ();
}
- [MonoTODO]
- public IntPtr MarshalManagedToNative (object pManagedObj)
+ public object MarshalNativeToManaged (IntPtr pNativeData) {
+ IEnumVARIANT ienumvariant = (IEnumVARIANT)Marshal.GetObjectForIUnknown (pNativeData);
+ VARIANTEnumerator e = new VARIANTEnumerator (ienumvariant);
+ return e;
+ }
+
+ [ComImport]
+ [Guid ("00020404-0000-0000-C000-000000000046")]
+ [InterfaceType (ComInterfaceType.InterfaceIsIUnknown)]
+ interface IEnumVARIANT
{
- throw new NotImplementedException();
+ [MethodImpl (MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
+ void Next (int celt, [MarshalAs (UnmanagedType.Struct)]out object rgvar, out uint pceltFetched);
+ [MethodImpl (MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
+ void Skip (uint celt);
+ [MethodImpl (MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
+ void Reset ();
+ [return: MarshalAs (UnmanagedType.Interface)]
+ [MethodImpl (MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
+ IEnumVARIANT Clone ();
+
}
- [MonoTODO]
- public object MarshalNativeToManaged (IntPtr pNativeData)
+ class VARIANTEnumerator : IEnumerator
{
- throw new NotImplementedException();
+ IEnumVARIANT com_enum;
+ object current;
+ public VARIANTEnumerator (IEnumVARIANT com_enum) {
+ this.com_enum = com_enum;
+ }
+ #region IEnumerator Members
+
+ public object Current {
+ get {
+ return current;
+ }
+ }
+
+ public bool MoveNext () {
+ object val;
+ uint fetched = 0;
+ com_enum.Next (1, out val, out fetched);
+ if (fetched == 0)
+ return false;
+ current = val;
+ return true;
+ }
+
+ public void Reset () {
+ com_enum.Reset ();
+ }
+
+ #endregion
}
}
}