repos
/
smoke
/ annotate_shade
summary
|
shortlog
|
log
|
tree
|
commit
|
commitdiff
|
headdiff
|
annotate
|
headblob
|
headfilediff
|
filehistory
normal
|
plain
|
shade
|
zebra
No need to construct a SmokeBinding per Smoke module.
Annotate for file src/libsmoke/smokebinding.cpp
2010-01-10 tobias
1
#include "smokebinding.h"
2009-04-05 tobias
2
15:36:29 '
3
#include <QtGlobal>
2009-08-02 tobias
4
#include <QDebug>
2009-04-05 tobias
5
15:36:29 '
6
namespace cl_smoke
'
7
{
'
8
2010-02-18 tobias
9
/** @class NoDispatchBinding
19:57:00 '
10
* @brief The Smoke binding for classes we need no dispatching.
'
11
* This saves some overhead, since it does not call into Lisp.
'
12
* Idea stolen from CommonQt ;)
'
13
*
'
14
* Dispatches for non extended classes (not of class CXX:CLASS) are between
'
15
* 20% - 40% (for qt.examples:colliding-mice - qt.examples:class-browser). (18 February 2010)
2009-04-05 tobias
16
*/
15:36:29 '
17
2010-02-18 tobias
18
/** @typedef NoDispatchBinding::destructed
2009-04-05 tobias
19
* Callback when a Smoke object is destructed.
15:36:29 '
20
*
2009-08-02 tobias
21
* @param class_index Index of the object's class.
2009-06-22 tobias
22
* @param object pointer to the object
2009-04-05 tobias
23
*/
15:36:29 '
24
2010-02-18 tobias
25
/** Constructor.
19:57:00 '
26
* @param destruct destruct callback
'
27
*/
2010-02-19 tobias
28
NoDispatchBinding::NoDispatchBinding(destructed destruct)
21:10:24 '
29
: SmokeBinding(NULL),
2010-02-18 tobias
30
destruct(destruct)
19:57:00 '
31
{
'
32
Q_ASSERT(destruct);
'
33
}
'
34
'
35
/** Invoked when a Smoke object is destructed. */
'
36
void
'
37
NoDispatchBinding::deleted(Smoke::Index, void *object)
'
38
{
'
39
destruct(object);
'
40
}
'
41
'
42
/** Invoked when a Smoke method gets called. */
'
43
bool
'
44
NoDispatchBinding::callMethod(Smoke::Index method, void* object,
'
45
Smoke::Stack stack, bool abstract)
'
46
{
'
47
Q_ASSERT(!abstract);
'
48
return false;
'
49
}
'
50
'
51
/**
'
52
* @todo Returning a const char* would be better
'
53
*/
'
54
char*
'
55
NoDispatchBinding::className(Smoke::Index classId)
'
56
{
2010-02-19 tobias
57
qFatal("className() Not implemented");
2010-02-18 tobias
58
}
19:57:00 '
59
'
60
/** @function NoDispatchBinding::get_smoke()
'
61
* Gets the Smoke instance associated with the binding.
'
62
* @return a pointer to the Smoke instance
'
63
*/
'
64
'
65
/** @class Binding
'
66
* @brief The Smoke binding.
'
67
*/
2009-04-05 tobias
68
15:36:29 '
69
/** @typedef Binding::dispatch_method
'
70
* Callback when a Smoke method gets called.
'
71
*
'
72
* @param binding Smoke binding of @a object
'
73
* @param method index of the method
'
74
* @param object the object for which the method is called
'
75
* @param args the arguments to the method
'
76
* @param abstract @c true when the method is abstract and @c false otherwise
'
77
*
'
78
* @return @c true when the method call was handled and @c false
2009-06-22 tobias
79
* when the default method shall be invoked.
2009-04-05 tobias
80
*/
15:36:29 '
81
'
82
/** Constructor.
'
83
* @param destruct destruct callback
'
84
* @param dispatch method dispatch callback
'
85
*/
2010-02-19 tobias
86
Binding::Binding(destructed destruct, dispatch_method dispatch)
21:10:24 '
87
: NoDispatchBinding(destruct),
2009-04-05 tobias
88
dispatch(dispatch)
15:36:29 '
89
{
'
90
Q_ASSERT(dispatch);
'
91
}
'
92
'
93
2009-06-03 tobias
94
/** Invoked when a Smoke method gets called. */
2009-04-05 tobias
95
bool
15:36:29 '
96
Binding::callMethod(Smoke::Index method, void* object,
'
97
Smoke::Stack stack, bool abstract)
'
98
{
2010-02-19 tobias
99
int ret = dispatch(method, object, stack, abstract);
2009-06-03 tobias
100
Q_ASSERT( !abstract || ret );
21:55:26 '
101
'
102
return ret;
2009-04-05 tobias
103
}
15:36:29 '
104
'
105
} // namespace cl_smoke