00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "testplugin.h"
00021 #include "testobject.h"
00022
00023 #include <kdebug.h>
00024
00025
00026
00027
00028
00029 TestPluginObject::TestPluginObject(const QString& name)
00030 : Kross::Api::Class<TestPluginObject>(name)
00031 {
00032 this->addFunction("internalfunc1",
00033 new Kross::Api::ProxyFunction <
00034 TestPluginObject,
00035 uint (TestPluginObject::*)(uint),
00036 Kross::Api::ProxyValue< Kross::Api::Variant, uint >,
00037 Kross::Api::ProxyValue< Kross::Api::Variant, uint >
00038 > ( this, &TestPluginObject::internalfunc1 )
00039 );
00040
00041 addFunction("func1", &TestPluginObject::func1);
00042 addFunction("func2", &TestPluginObject::func2,
00043 Kross::Api::ArgumentList()
00044 << Kross::Api::Argument("Kross::Api::Variant::String")
00045 << Kross::Api::Argument("Kross::Api::Variant::String") );
00046 addFunction("func3", &TestPluginObject::func3,
00047 Kross::Api::ArgumentList()
00048 << Kross::Api::Argument("Kross::Api::Variant::String")
00049 << Kross::Api::Argument("Kross::Api::Variant::String") );
00050 addFunction("func4", &TestPluginObject::func4,
00051 Kross::Api::ArgumentList()
00052 << Kross::Api::Argument("Kross::Api::Variant::String")
00053 << Kross::Api::Argument("Kross::Api::Variant::String")
00054 << Kross::Api::Argument("Kross::Api::Variant::String") );
00055 addFunction("func5", &TestPluginObject::func5,
00056 Kross::Api::ArgumentList()
00057 << Kross::Api::Argument("Kross::Api::Variant::String")
00058 << Kross::Api::Argument("Kross::Api::Variant::String")
00059 << Kross::Api::Argument("Kross::Api::Variant::String") );
00060 addFunction("func6", &TestPluginObject::func6,
00061 Kross::Api::ArgumentList()
00062 << Kross::Api::Argument("Kross::Api::List") );
00063 addFunction("func7", &TestPluginObject::func7,
00064 Kross::Api::ArgumentList()
00065 << Kross::Api::Argument("Kross::Api::List")
00066 << Kross::Api::Argument("Kross::Api::Variant") );
00067 addFunction("func8", &TestPluginObject::func8,
00068 Kross::Api::ArgumentList()
00069 << Kross::Api::Argument("Kross::Api::Variant")
00070 << Kross::Api::Argument("Kross::Api::Variant") );
00071 addFunction("func9", &TestPluginObject::func9,
00072 Kross::Api::ArgumentList()
00073 << Kross::Api::Argument("Kross::Api::Variant")
00074 << Kross::Api::Argument("Kross::Api::Variant") );
00075
00076 }
00077
00078 TestPluginObject::~TestPluginObject()
00079 {
00080 }
00081
00082 const QString TestPluginObject::getClassName() const
00083 {
00084 return "TestPluginObject";
00085 }
00086
00087 uint TestPluginObject::internalfunc1(uint i)
00088 {
00089 kdDebug() << "CALLED => TestPluginObject::internalfunc1" << endl;
00090 return i;
00091 }
00092
00093 Kross::Api::Object::Ptr TestPluginObject::func1(Kross::Api::List::Ptr )
00094 {
00095
00096 return 0;
00097 }
00098
00099 Kross::Api::Object::Ptr TestPluginObject::func2(Kross::Api::List::Ptr )
00100 {
00101
00102 return new Kross::Api::Variant("func2returnvalue");
00103 }
00104
00105 Kross::Api::Object::Ptr TestPluginObject::func3(Kross::Api::List::Ptr )
00106 {
00107
00108 return new Kross::Api::Variant("func3returnvalue");
00109 }
00110
00111 Kross::Api::Object::Ptr TestPluginObject::func4(Kross::Api::List::Ptr )
00112 {
00113
00114 return new Kross::Api::Variant("func4returnvalue");
00115 }
00116
00117 Kross::Api::Object::Ptr TestPluginObject::func5(Kross::Api::List::Ptr )
00118 {
00119
00120 return new Kross::Api::Variant("func5returnvalue");
00121 }
00122
00123 Kross::Api::Object::Ptr TestPluginObject::func6(Kross::Api::List::Ptr args)
00124 {
00125 Kross::Api::List* list = Kross::Api::Object::fromObject< Kross::Api::List >( args->item(0) );
00126 return list->item(0);
00127 }
00128
00129 Kross::Api::Object::Ptr TestPluginObject::func7(Kross::Api::List::Ptr args)
00130 {
00131 return args->item(0);
00132 }
00133
00134 Kross::Api::Object::Ptr TestPluginObject::func8(Kross::Api::List::Ptr args)
00135 {
00136 return args->item(0);
00137 }
00138
00139 Kross::Api::Object::Ptr TestPluginObject::func9(Kross::Api::List::Ptr args)
00140 {
00141 return args->item(0);
00142 }
00143
00144
00145
00146
00147
00148 TestPluginModule::TestPluginModule(const QString& name)
00149 : Kross::Api::Module(name)
00150 , m_testobject( new TestObject() )
00151
00152 {
00153 addChild( new TestPluginObject("testpluginobject1") );
00154
00155
00156 Kross::Api::Event<TestObject> *testobjectclass =
00157 new Kross::Api::Event<TestObject>("testpluginobject2", this);
00158 addChild(testobjectclass);
00159
00160 testobjectclass->addFunction("func1",
00161 new Kross::Api::ProxyFunction <
00162 TestObject,
00163 uint (TestObject::*)(uint),
00164 Kross::Api::ProxyValue< Kross::Api::Variant, uint >,
00165 Kross::Api::ProxyValue< Kross::Api::Variant, uint >
00166 > ( m_testobject, &TestObject::func1 )
00167 );
00168 testobjectclass->addFunction("func2",
00169 new Kross::Api::ProxyFunction <
00170 TestObject,
00171 void (TestObject::*)(QString, int),
00172 Kross::Api::ProxyValue< Kross::Api::Variant, void >,
00173 Kross::Api::ProxyValue< Kross::Api::Variant, QString >,
00174 Kross::Api::ProxyValue< Kross::Api::Variant, int >
00175 > ( m_testobject, &TestObject::func2 )
00176 );
00177 testobjectclass->addFunction("func3",
00178 new Kross::Api::ProxyFunction<
00179 TestObject,
00180 QString (TestObject::*)(QString, int),
00181 Kross::Api::ProxyValue< Kross::Api::Variant, QString >,
00182 Kross::Api::ProxyValue< Kross::Api::Variant, QString >,
00183 Kross::Api::ProxyValue< Kross::Api::Variant, int >
00184 > ( m_testobject, &TestObject::func3) );
00185 testobjectclass->addFunction("func4",
00186 new Kross::Api::ProxyFunction<
00187 TestObject,
00188 const QString& (TestObject::*)(const QString&, int) const,
00189 Kross::Api::ProxyValue< Kross::Api::Variant, const QString& >,
00190 Kross::Api::ProxyValue< Kross::Api::Variant, const QString& >,
00191 Kross::Api::ProxyValue< Kross::Api::Variant, int >
00192 > ( m_testobject, &TestObject::func4) );
00193 }
00194
00195 TestPluginModule::~TestPluginModule()
00196 {
00197 delete m_testobject;
00198 }
00199
00200 const QString TestPluginModule::getClassName() const
00201 {
00202 return "TestPluginModule";
00203 }
00204