update dev300-m58
[ooovba.git] / cli_ure / source / mono_bridge / binaryuno.cs
blobb9d46fbc5e185ee48e2ad03cd73a576b44b2bcbd
1 /*************************************************************************
3 * $RCSfile: $
5 * $Revision: $
7 * last change: $Author: $ $Date: $
9 * The Contents of this file are made available subject to the terms of
10 * either of the following licenses
12 * - GNU Lesser General Public License Version 2.1
13 * - Sun Industry Standards Source License Version 1.1
15 * Sun Microsystems Inc., October, 2000
17 * GNU Lesser General Public License Version 2.1
18 * =============================================
19 * Copyright 2000 by Sun Microsystems, Inc.
20 * 901 San Antonio Road, Palo Alto, CA 94303, USA
22 * This library is free software; you can redistribute it and/or
23 * modify it under the terms of the GNU Lesser General Public
24 * License version 2.1, as published by the Free Software Foundation.
26 * This library is distributed in the hope that it will be useful,
27 * but WITHOUT ANY WARRANTY; without even the implied warranty of
28 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
29 * Lesser General Public License for more details.
31 * You should have received a copy of the GNU Lesser General Public
32 * License along with this library; if not, write to the Free Software
33 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
34 * MA 02111-1307 USA
37 * Sun Industry Standards Source License Version 1.1
38 * =================================================
39 * The contents of this file are subject to the Sun Industry Standards
40 * Source License Version 1.1 (the "License"); You may not use this file
41 * except in compliance with the License. You may obtain a copy of the
42 * License at http://www.openoffice.org/license.html.
44 * Software provided under this License is provided on an "AS IS" basis,
45 * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
46 * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
47 * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
48 * See the License for the specific provisions governing your rights and
49 * obligations concerning the Software.
51 * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
53 * Copyright: 2000 by Sun Microsystems, Inc.
55 * All Rights Reserved.
57 * Contributor(s): _______________________________________
60 ************************************************************************/
62 namespace uno.Binary {
64 using System;
65 using System.Runtime.InteropServices;
66 using uno.Typelib;
67 using uno.rtl;
69 [ StructLayout(LayoutKind.Sequential) ]
70 public unsafe struct Any
72 /** type of value
74 public uno.Typelib.TypeDescriptionReference *pType;
76 /** pointer to value; this may point to pReserved and thus the uno_Any is not anytime
77 mem-copyable! You may have to correct the pData pointer to pReserved. Otherwise you need
78 not, because the data is stored in heap space.
80 public void *pData;
81 /** reserved space for storing value
83 public void *pReserved;
85 [ DllImport("uno_cppu", EntryPoint="uno_any_construct") ]
86 public static unsafe extern void Construct(/* Any */ void *dest,
87 void *source,
88 /* uno.Typelib.TypeDescriptionReference */ void *type,
89 void *acquireFunction);
91 [ DllImport("uno_cppu", EntryPoint="uno_any_destruct") ]
92 public static unsafe extern void Destroy(/* Any */ void *value, void *releaseFunction);
95 // FIXME wrap this nicely
96 public struct Interface
98 [ DllImport("cli_uno", EntryPoint="cli_uno_interface_acquire") ]
99 public static extern void Acquire(IntPtr unoInterface);
101 [ DllImport("cli_uno", EntryPoint="cli_uno_interface_release") ]
102 public static extern void Release(IntPtr unoInterface);
104 [ DllImport("cli_uno", EntryPoint="cli_uno_interface_dispatch") ]
105 public static unsafe extern void Dispatch(IntPtr unoInterface,
106 /* uno.Typelib.TypeDescription */ void *memberTD,
107 void *result,
108 void **args,
109 uno.Binary.Any **exception);
112 // FIXME and this
113 public class Environment
115 [ DllImport("cli_uno", EntryPoint="cli_uno_environment_getObjectIdentifier") ]
116 public static unsafe extern void GetObjectIdentifier(IntPtr unoEnvironment,
117 UString** oid,
118 IntPtr unoInterface);
120 [ DllImport("cli_uno", EntryPoint="cli_uno_environment_registerInterface") ]
121 public static unsafe extern void RegisterInterface(
122 IntPtr unoEnvironment,
123 ref IntPtr ppInterface,
124 /* UString */ void* oid,
125 /* InterfaceTypeDescription */ void *td);
127 [ DllImport("cli_uno", EntryPoint="cli_uno_environment_getRegisteredInterface") ]
128 public static unsafe extern void GetRegisteredInterface(
129 IntPtr unoEnvironment,
130 ref IntPtr ppInterface,
131 /* UString */ void* oid,
132 /* InterfaceTypeDescription */ void *td);
135 public struct Data
137 [ DllImport("uno_cppu", EntryPoint="uno_type_destructData") ]
138 public static unsafe extern void Destroy(void *data,
139 /* uno.Typelib.TypeDescription */ void *td,
140 // FIXME is this okay? release is a function pointer
141 void *release);
144 public unsafe struct SequencePtr
146 int *sal_Sequence;
148 // sal_Int32 nRefCount;
149 // sal_Int32 nElements;
150 // char elements[1];
152 /** element count<br>
154 /** elements array<br>
157 /** reference count of sequence<br>
159 private unsafe int nRefCount
161 get { return *(sal_Sequence); }
162 set { *(sal_Sequence) = value; }
165 public unsafe int nElements
167 get { return *(sal_Sequence + 1); }
168 set { *(sal_Sequence + 1) = value; }
171 public unsafe IntPtr elementsPtr
173 get { return new IntPtr((void *)(sal_Sequence + 2)); }
176 private unsafe SequencePtr(void *mem)
178 sal_Sequence = (int*)mem;
181 private const int HEADER_SIZE = 8; // FIXME alignment
183 public static SequencePtr Allocate(int length, int elementSize)
185 void *rtlPtr = uno.rtl.Mem.Allocate(HEADER_SIZE + (length * elementSize));
186 SequencePtr seqPtr = new SequencePtr(rtlPtr);
187 seqPtr.nRefCount = 1;
188 seqPtr.nElements = length;
189 return seqPtr;