repos
/
smoke
/ annotate_shade
summary
|
shortlog
|
log
|
tree
|
commit
|
commitdiff
|
headdiff
|
annotate
|
headblob
|
headfilediff
|
filehistory
normal
|
plain
|
shade
|
zebra
Fix class-map image loading and use the new static smoke methods.
Annotate for file src/libsmoke/smoke.cpp
2009-04-17 tobias
1
#include "cl_smoke.h"
2010-01-10 tobias
2
#include "smokebinding.h"
2009-04-05 tobias
3
15:36:29 '
4
#include <smoke.h>
'
5
#include <QtGlobal>
'
6
'
7
/** @file
2009-04-17 tobias
8
* @brief C wrapper the Smoke bindings.
2009-04-05 tobias
9
*/
15:36:29 '
10
'
11
using namespace cl_smoke;
'
12
'
13
extern "C" {
'
14
2010-02-19 tobias
15
/** Returns the Smoke module of a Smoke binding.
21:10:24 '
16
* @related cl_smoke::Binding
'
17
* @param binding the Binding
'
18
*
'
19
* @return the Smoke module
'
20
*/
'
21
CL_SMOKE_EXPORT void*
'
22
cl_smoke_get_smoke(smoke_binding binding)
'
23
{
2010-02-18 tobias
24
return get_smoke_binding(binding)->get_smoke();
2010-02-19 tobias
25
}
21:10:24 '
26
2009-04-05 tobias
27
/** Creates a new Smoke binding.
15:36:29 '
28
* The binding is allocated on the heap an can be freed with smoke_destruct().
'
29
* @related cl_smoke::Binding
'
30
* @param smoke pointer to a Smoke module instance
'
31
* @param destruct callback for object destruction
'
32
* @param dispatch method dispatch callback
'
33
*
'
34
* @return a pointer to a new Smoke binding.
'
35
*/
2009-05-11 tobias
36
CL_SMOKE_EXPORT smoke_binding
2010-02-18 tobias
37
cl_smoke_init(void* smoke, void* destruct, void* dispatch)
2009-04-05 tobias
38
{
2010-02-18 tobias
39
return new Binding(static_cast<Smoke*>(smoke),
19:57:00 '
40
reinterpret_cast<Binding::destructed>(destruct),
'
41
reinterpret_cast<Binding::dispatch_method>(dispatch));
2009-04-05 tobias
42
}
15:36:29 '
43
2010-02-18 tobias
44
/** Deletes the smoke binding.
19:57:00 '
45
* @related cl_smoke::Binding
2009-04-05 tobias
46
*/
2009-05-11 tobias
47
CL_SMOKE_EXPORT void
2010-02-18 tobias
48
cl_smoke_destruct(smoke_binding binding)
2009-04-05 tobias
49
{
2010-02-18 tobias
50
delete get_smoke_binding(binding)->get_smoke();
19:57:00 '
51
delete get_smoke_binding(binding);
2009-04-05 tobias
52
}
15:36:29 '
53
2010-02-18 tobias
54
/** Gets a Smoke modules name.
2009-04-05 tobias
55
* @param smoke the Smoke module
15:36:29 '
56
*
'
57
* @return the module name
'
58
*/
2009-05-11 tobias
59
CL_SMOKE_EXPORT const char*
2010-01-10 tobias
60
cl_smoke_get_module_name(void* smoke)
2009-04-05 tobias
61
{
15:36:29 '
62
return get_smoke(smoke)->moduleName();
'
63
}
'
64
2009-06-22 tobias
65
12:18:08 '
66
/** Returns the pointer to the array @a array of @a smoke.
'
67
* @param smoke the Smoke module
'
68
* @param array the array type
'
69
*
'
70
* @return a pointer to the array
'
71
*/
'
72
CL_SMOKE_EXPORT void*
'
73
cl_smoke_array(void* smoke, cl_smoke_module_array array)
'
74
{
'
75
switch (array)
'
76
{
'
77
case classes:
'
78
return get_smoke(smoke)->classes;
'
79
case methods:
'
80
return get_smoke(smoke)->methods;
'
81
case method_maps:
'
82
return get_smoke(smoke)->methodMaps;
'
83
case method_names:
'
84
return get_smoke(smoke)->methodNames;
'
85
case types:
'
86
return get_smoke(smoke)->types;
'
87
case inheritance_list:
'
88
return get_smoke(smoke)->inheritanceList;
'
89
case argument_list:
'
90
return get_smoke(smoke)->argumentList;
'
91
case ambiguous_method_list:
'
92
return get_smoke(smoke)->ambiguousMethodList;
'
93
}
'
94
qFatal("cl_smoke_array(): Unknown smoke_array %d", array);
'
95
}
'
96
'
97
/** Returns the size of the array @a array of @a smoke.
'
98
* The size if inclusive the bound.
'
99
* @param smoke the Smoke module
'
100
* @param array the array type
'
101
*
'
102
* @return the size
'
103
*/
'
104
CL_SMOKE_EXPORT Smoke::Index
'
105
cl_smoke_array_size(void* smoke, cl_smoke_module_array array)
'
106
{
'
107
switch (array)
'
108
{
'
109
case classes:
'
110
return get_smoke(smoke)->numClasses;
'
111
case methods:
'
112
return get_smoke(smoke)->numMethods;
'
113
case method_maps:
'
114
return get_smoke(smoke)->numMethodMaps;
'
115
case method_names:
'
116
return get_smoke(smoke)->numMethodNames;
'
117
case types:
'
118
return get_smoke(smoke)->numTypes;
'
119
case inheritance_list:
'
120
case argument_list:
'
121
case ambiguous_method_list:
'
122
qFatal("cl_smoke_array_size(): size of %d not known.", array);
'
123
}
'
124
qFatal("cl_smoke_array_size(): Unknown smoke_array %d.", array);
'
125
}
'
126
2009-04-05 tobias
127
///////////////////////////
15:36:29 '
128
/// Class
'
129
///////////////////////////
'
130
'
131
/** Finds a class.
'
132
* @param c pointer to write the result to
'
133
* @param name the name of the class
'
134
*/
2009-05-11 tobias
135
CL_SMOKE_EXPORT void
2010-01-17 tobias
136
cl_smoke_find_class(Smoke::ModuleIndex* c, const char* name)
2009-04-05 tobias
137
{
2010-01-17 tobias
138
*c = Smoke::findClass(name);
2009-04-05 tobias
139
}
15:36:29 '
140
'
141
/** Gets the class ID for a Smoke module.
'
142
* @param smoke the Smoke module
'
143
* @param name the class name
'
144
*
'
145
* @return the class ID in the supplied Smoke module
'
146
*/
2009-05-11 tobias
147
CL_SMOKE_EXPORT Smoke::Index
2010-01-10 tobias
148
cl_smoke_class_id(void* smoke, const char* name)
2009-04-05 tobias
149
{
15:36:29 '
150
Smoke::ModuleIndex m = get_smoke(smoke)->idClass(name, true);
'
151
Q_ASSERT(m.smoke == smoke);
'
152
'
153
return m.index;
'
154
}
'
155
'
156
/** Gets a class
'
157
* @param smoke the smoke binding
'
158
* @param class_index the index of the class
'
159
*
'
160
* @return A pointer to the class into the array of class structs
'
161
*/
2009-05-11 tobias
162
CL_SMOKE_EXPORT const struct Smoke::Class*
2010-01-10 tobias
163
cl_smoke_get_class(void* smoke, Smoke::Index class_index)
2009-04-05 tobias
164
{
2009-06-22 tobias
165
Q_ASSERT(class_index >= 0 && class_index <= get_smoke(smoke)->numClasses);
2009-04-05 tobias
166
return &get_smoke(smoke)->classes[class_index];
15:36:29 '
167
}
'
168
'
169
/** Determines werter a class is from a base class.
'
170
* @param smoke the Smoke module of @a class_index
'
171
* @param class_index the class index
'
172
* @param smoke_base the Smoke module of the base class @a base_index
'
173
* @param base_index the index of the base class
'
174
*
'
175
* @return Returns 0 when the class is not derived from the base class and nonzero value otherwise.
'
176
*/
2009-05-11 tobias
177
CL_SMOKE_EXPORT int
2010-01-10 tobias
178
cl_smoke_is_derived_from(void* smoke, Smoke::Index class_index, void* smoke_base,
08:49:36 '
179
Smoke::Index base_index)
2009-04-05 tobias
180
{
2010-02-03 tobias
181
Q_ASSERT(!smoke_get_class(smoke, class_index)->external);
16:20:56 '
182
Q_ASSERT(!smoke_get_class(smoke_base, base_index)->external);
2009-04-05 tobias
183
2010-01-17 tobias
184
return Smoke::isDerivedFrom(get_smoke(smoke), class_index,
2010-01-10 tobias
185
get_smoke(smoke_base), base_index);
2009-04-05 tobias
186
}
15:36:29 '
187
'
188
//////////////////////////////
'
189
/// Method
'
190
//////////////////////////////
'
191
'
192
/** Finds a method of a class.
'
193
* @param m pointer to write the result to
2010-02-19 tobias
194
* @param smoke the smoke binding
2009-04-05 tobias
195
* @param class_index index of the class
15:36:29 '
196
* @param method_name method name
'
197
*/
2009-05-11 tobias
198
CL_SMOKE_EXPORT void
2010-01-10 tobias
199
cl_smoke_find_method(Smoke::ModuleIndex* m, void* smoke,
2009-04-05 tobias
200
Smoke::Index class_index, const char* method_name)
15:36:29 '
201
{
2010-02-18 tobias
202
*m = get_smoke(smoke)->findMethod(get_smoke(smoke)->className(class_index),
19:57:00 '
203
method_name);
2009-04-05 tobias
204
if(m->index > 0)
2009-06-22 tobias
205
m->index = m->smoke->methodMaps[m->index].method;
2009-04-05 tobias
206
}
15:36:29 '
207
'
208
///////////////////////////
'
209
/// Type
'
210
//////////////////////////
'
211
'
212
/** Gets the index of a type.
'
213
* @param smoke the Smoke module
'
214
* @param name the types name
'
215
*
'
216
* @return the index of the type
'
217
*/
2009-05-11 tobias
218
CL_SMOKE_EXPORT Smoke::Index
2010-01-10 tobias
219
cl_smoke_find_type(void* smoke, const char* name)
2009-04-05 tobias
220
{
15:36:29 '
221
return get_smoke(smoke)->idType(name);
'
222
}
'
223
'
224
/** Casts an object.
'
225
* @param smoke the Smoke module
2010-02-18 tobias
226
* @param object the objec
2009-04-05 tobias
227
* @param from the class index of @a object
15:36:29 '
228
* @param to the class index to cast to
'
229
*
'
230
* @return the casted object
'
231
*/
2009-05-11 tobias
232
CL_SMOKE_EXPORT void*
2010-01-10 tobias
233
cl_smoke_cast(void* smoke, void* object, Smoke::Index from, Smoke::Index to)
2009-04-05 tobias
234
{
2009-06-22 tobias
235
Q_ASSERT(from > 0 && from <= get_smoke(smoke)->numClasses);
12:18:08 '
236
Q_ASSERT(to > 0 && to <= get_smoke(smoke)->numClasses);
2009-04-05 tobias
237
15:36:29 '
238
return get_smoke(smoke)->cast(object, from, to);
'
239
}
'
240
'
241
} // extern "C"