blob: 91bad62b28d0c4102c897f6b95ade8ed43894a0b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" />
<xsl:template match="/doxygen/compounddef">
<xsl:variable name="clazz" select="compoundname" />
<xsl:variable name="consmeth" select="sectiondef/memberdef[@kind='function' and @prot='public']" />
#include <klocale.h>
#include <kjs/object.h>
#include <<xsl:value-of select="includes" />>
#include "<xsl:value-of select="substring-before(includes,'.h')"/>_imp.h"
/**
* Namespace containing the KJSEmbed library.
*/
namespace KJSEmbed {
<!-- Select and invoke the correct constructor. -->
KJS::Object <xsl:value-of select="$clazz" />Cons::construct( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
{
switch( id ) {
<xsl:for-each select="$consmeth">
<xsl:choose>
<xsl:when test="name = $clazz">
<xsl:variable name="cons_name"><xsl:value-of select="name" />_<xsl:value-of select="position()" /></xsl:variable>
<xsl:variable name="cons_id">Constructor_<xsl:value-of select="$cons_name" /></xsl:variable>
case <xsl:value-of select="$cons_id" />:
return <xsl:value-of select="$cons_name" />( exec, obj, args );
break;
</xsl:when>
</xsl:choose>
</xsl:for-each>
default:
break;
}
TQString msg = i18n("<xsl:value-of select="$clazz" />Cons has no constructor with id '%1'").arg(id);
KJS::Object err = KJS::Error::create( exec, KJS::ReferenceError, msg.utf8() );
exec->setException( err );
return err;
}
<!-- Implementations of the constructors. -->
<xsl:for-each select="$consmeth">
<xsl:choose>
<xsl:when test="name = $clazz">
<xsl:variable name="cons_name"><xsl:value-of select="name" />_<xsl:value-of select="position()" /></xsl:variable>
<xsl:variable name="cons_id">Constructor_<xsl:value-of select="$cons_name" /></xsl:variable>
KJS::Object <xsl:value-of select="$clazz" />Cons::<xsl:value-of select="$cons_name" />( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
{
<xsl:for-each select="param/type">
<xsl:choose>
<xsl:when test=". = 'TQString'">
TQString arg<xsl:value-of select="position()-1" /> = (args.size() >= <xsl:value-of select="position()" />) ? args[<xsl:value-of select="position()-1" />].toString(exec).qstring() : TQString::null;
</xsl:when>
<xsl:when test=". = 'const TQString &'">
TQString arg<xsl:value-of select="position()-1" /> = (args.size() >= <xsl:value-of select="position()" />) ? args[<xsl:value-of select="position()-1" />].toString(exec).qstring() : TQString::null;
</xsl:when>
<xsl:when test=". = 'const char *'">
const char *arg<xsl:value-of select="position()-1" /> = (args.size() >= <xsl:value-of select="position()" />) ? args[<xsl:value-of select="position()-1" />].toString(exec).ascii() : 0;
</xsl:when>
<xsl:when test=". = 'int'">
int arg<xsl:value-of select="position()-1" /> = (args.size() >= <xsl:value-of select="position()" />) ? args[<xsl:value-of select="position()-1" />].toInteger(exec) : -1;
</xsl:when>
<xsl:when test=". = 'uint'">
uint arg<xsl:value-of select="position()-1" /> = (args.size() >= <xsl:value-of select="position()" />) ? args[<xsl:value-of select="position()-1" />].toInteger(exec) : -1;
</xsl:when>
<xsl:when test=". = 'double'">
double arg<xsl:value-of select="position()-1" /> = (args.size() >= <xsl:value-of select="position()" />) ? args[<xsl:value-of select="position()-1" />].toInteger(exec) : -1;
</xsl:when>
<xsl:when test=". = 'bool'">
bool arg<xsl:value-of select="position()-1" /> = (args.size() >= <xsl:value-of select="position()" />) ? args[<xsl:value-of select="position()-1" />].toBoolean(exec) : false;
</xsl:when>
<xsl:when test=". = 'const TQStringList &'">
TQStringList arg<xsl:value-of select="position()-1" />;
if ( args.size() >= <xsl:value-of select="position()" /> ) {
// TODO: populate the list
}
</xsl:when>
<xsl:otherwise>
// Unsupported parameter <xsl:value-of select="." />
return KJS::Value();
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
}
</xsl:when>
</xsl:choose>
</xsl:for-each>
} // namespace KJSEmbed
// Local Variables:
// c-basic-offset: 4
// End:
</xsl:template>
</xsl:stylesheet>
|