d3d10core: COM cleanup for the ID3D10SamplerState iface.
[wine] / dlls / msvcp90 / msvcp90.h
1 /*
2  * Copyright 2010 Piotr Caban for CodeWeavers
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17  */
18
19 #include "stdlib.h"
20 #include "windef.h"
21
22 typedef unsigned char MSVCP_bool;
23 typedef int MSVCP_long;
24 typedef SIZE_T MSVCP_size_t;
25
26 void __cdecl _invalid_parameter(const wchar_t*, const wchar_t*,
27         const wchar_t*, unsigned int, uintptr_t);
28
29 extern void* (__cdecl *MSVCRT_operator_new)(MSVCP_size_t);
30 extern void (__cdecl *MSVCRT_operator_delete)(void*);
31
32 /* Copied from dlls/msvcrt/cpp.c */
33 #ifdef __i386__  /* thiscall functions are i386-specific */
34
35 #define THISCALL(func) __thiscall_ ## func
36 #define THISCALL_NAME(func) __ASM_NAME("__thiscall_" #func)
37 #define __thiscall __stdcall
38 #define DEFINE_THISCALL_WRAPPER(func,args) \
39     extern void THISCALL(func)(void); \
40     __ASM_GLOBAL_FUNC(__thiscall_ ## func, \
41                       "popl %eax\n\t" \
42                       "pushl %ecx\n\t" \
43                       "pushl %eax\n\t" \
44                       "jmp " __ASM_NAME(#func) __ASM_STDCALL(args) )
45 #else /* __i386__ */
46
47 #define THISCALL(func) func
48 #define THISCALL_NAME(func) __ASM_NAME(#func)
49 #define __thiscall __cdecl
50 #define DEFINE_THISCALL_WRAPPER(func,args) /* nothing */
51
52 #endif /* __i386__ */
53
54 #ifdef _WIN64
55
56 #define __ASM_VTABLE(name,funcs) \
57     __asm__(".data\n" \
58             "\t.align 8\n" \
59             "\t.quad " __ASM_NAME(#name "_rtti") "\n" \
60             "\t.globl " __ASM_NAME("MSVCP_" #name "_vtable") "\n" \
61             __ASM_NAME("MSVCP_" #name "_vtable") ":\n" \
62             "\t.quad " THISCALL_NAME(MSVCP_ ## name ## _vector_dtor) "\n" \
63             funcs "\n\t.text");
64
65 #else
66
67 #define __ASM_VTABLE(name,funcs) \
68     __asm__(".data\n" \
69             "\t.align 4\n" \
70             "\t.long " __ASM_NAME(#name "_rtti") "\n" \
71             "\t.globl " __ASM_NAME("MSVCP_" #name "_vtable") "\n" \
72             __ASM_NAME("MSVCP_" #name "_vtable") ":\n" \
73             "\t.long " THISCALL_NAME(MSVCP_ ## name ## _vector_dtor) "\n" \
74             funcs "\n\t.text");
75
76 #endif /* _WIN64 */
77
78 /* exception object */
79 typedef void (*vtable_ptr)(void);
80 typedef struct __exception
81 {
82     const vtable_ptr *vtable;
83     char             *name;    /* Name of this exception, always a new copy for each object */
84     int               do_free; /* Whether to free 'name' in our dtor */
85 } exception;
86
87 /* Internal: throws selected exception */
88 typedef enum __exception_type {
89     EXCEPTION,
90     EXCEPTION_BAD_ALLOC,
91     EXCEPTION_LOGIC_ERROR,
92     EXCEPTION_LENGTH_ERROR,
93     EXCEPTION_OUT_OF_RANGE,
94     EXCEPTION_INVALID_ARGUMENT
95 } exception_type;
96 void throw_exception(exception_type, const char *);
97 void set_exception_vtable(void);
98
99 /* rtti */
100 typedef struct __type_info
101 {
102     const vtable_ptr *vtable;
103     char              *name;        /* Unmangled name, allocated lazily */
104     char               mangled[64]; /* Variable length, but we declare it large enough for static RTTI */
105 } type_info;
106
107 /* offsets for computing the this pointer */
108 typedef struct
109 {
110     int         this_offset;   /* offset of base class this pointer from start of object */
111     int         vbase_descr;   /* offset of virtual base class descriptor */
112     int         vbase_offset;  /* offset of this pointer offset in virtual base class descriptor */
113 } this_ptr_offsets;
114
115 typedef struct _rtti_base_descriptor
116 {
117     const type_info *type_descriptor;
118     int num_base_classes;
119     this_ptr_offsets offsets;    /* offsets for computing the this pointer */
120     unsigned int attributes;
121 } rtti_base_descriptor;
122
123 typedef struct _rtti_base_array
124 {
125     const rtti_base_descriptor *bases[3]; /* First element is the class itself */
126 } rtti_base_array;
127
128 typedef struct _rtti_object_hierarchy
129 {
130     unsigned int signature;
131     unsigned int attributes;
132     int array_len; /* Size of the array pointed to by 'base_classes' */
133     const rtti_base_array *base_classes;
134 } rtti_object_hierarchy;
135
136 typedef struct _rtti_object_locator
137 {
138     unsigned int signature;
139     int base_class_offset;
140     unsigned int flags;
141     const type_info *type_descriptor;
142     const rtti_object_hierarchy *type_hierarchy;
143 } rtti_object_locator;
144
145 /* basic_string<char, char_traits<char>, allocator<char>> */
146 #define BUF_SIZE_CHAR 16
147 typedef struct _basic_string_char
148 {
149     void *allocator;
150     union {
151         char buf[BUF_SIZE_CHAR];
152         char *ptr;
153     } data;
154     MSVCP_size_t size;
155     MSVCP_size_t res;
156 } basic_string_char;
157
158 basic_string_char* __stdcall MSVCP_basic_string_char_ctor_cstr(basic_string_char*, const char*);
159 basic_string_char* __stdcall MSVCP_basic_string_char_copy_ctor(basic_string_char*, const basic_string_char*);
160 void __stdcall MSVCP_basic_string_char_dtor(basic_string_char*);
161 const char* __stdcall MSVCP_basic_string_char_c_str(basic_string_char*);
162
163 #define BUF_SIZE_WCHAR 8
164 typedef struct _basic_string_wchar
165 {
166     void *allocator;
167     union {
168         wchar_t buf[BUF_SIZE_WCHAR];
169         wchar_t *ptr;
170     } data;
171     MSVCP_size_t size;
172     MSVCP_size_t res;
173 } basic_string_wchar;
174
175 char* __stdcall MSVCP_allocator_char_allocate(void*, MSVCP_size_t);
176 void __stdcall MSVCP_allocator_char_deallocate(void*, char*, MSVCP_size_t);
177 wchar_t* __stdcall MSVCP_allocator_wchar_allocate(void*, MSVCP_size_t);
178 void __stdcall MSVCP_allocator_wchar_deallocate(void*, wchar_t*, MSVCP_size_t);
179
180 /* class locale */
181 typedef struct
182 {
183     /*_Lockimp*/void *ptr;
184 } locale;