lib

Kross::Api::ProxyFunction< INSTANCE, METHOD, RETURNOBJ, ARG1OBJ, ARG2OBJ, ARG3OBJ, ARG4OBJ > Class Template Reference

#include <proxy.h>

Inheritance diagram for Kross::Api::ProxyFunction< INSTANCE, METHOD, RETURNOBJ, ARG1OBJ, ARG2OBJ, ARG3OBJ, ARG4OBJ >:

Kross::Api::Function

List of all members.


Detailed Description

template<class INSTANCE, typename METHOD, class RETURNOBJ, class ARG1OBJ = Kross::Api::Object, class ARG2OBJ = Kross::Api::Object, class ARG3OBJ = Kross::Api::Object, class ARG4OBJ = Kross::Api::Object>
class Kross::Api::ProxyFunction< INSTANCE, METHOD, RETURNOBJ, ARG1OBJ, ARG2OBJ, ARG3OBJ, ARG4OBJ >

The ProxyFunction template-class is used to publish any C/C++ method (not only slots) of a struct or class instance as a a Function to Kross.

With this class we don't need to have a method-wrapper for each single function what a) should reduce the code needed for wrappers and b) is more typesafe cause the connection to the C/C++ method is done on compiletime.

Example how a ProxyFunction may got used;

 #include "../api/class.h"
 #include "../api/proxy.h"
 // The class which should be published.
 class MyClass : public Kross::Api::Class<MyClass> {
     public:
         MyClass(const QString& name) : Kross::Api::Class<MyClass>(name) {
             // publish the function myfunc, so that scripting-code is able
             // to call that method.
             this->addProxyFunction <
                 Kross::Api::Variant, // the uint returnvalue is handled with Variant.
                 Kross::Api::Variant, // the QString argument is handled with Variant too.
                 MyClass // the MyClass* is handled implicit by our class.
             > ( "myfuncname", // the name the function should be published as.
                 this, // pointer to the class-instance which has the method.
                 &TestPluginObject::myfunc ); // pointer to the method itself.
         }
         virtual ~MyClass() {}
         virtual const QString getClassName() const { return "MyClass"; }
     private:
         uint myfunc(const QCString&, MyClass* myotherclass) {
             // This method will be published to the scripting backend. So, scripting
             // code is able to call this method.
         }
 }

Definition at line 103 of file proxy.h.


Public Member Functions

 ProxyFunction (INSTANCE *instance, const METHOD &method, ARG1OBJ *defarg1=0, ARG2OBJ *defarg2=0, ARG3OBJ *defarg3=0, ARG4OBJ *defarg4=0)
Object::Ptr call (List::Ptr args)

Friends

struct ProxyFunctionCaller

Constructor & Destructor Documentation

template<class INSTANCE, typename METHOD, class RETURNOBJ, class ARG1OBJ = Kross::Api::Object, class ARG2OBJ = Kross::Api::Object, class ARG3OBJ = Kross::Api::Object, class ARG4OBJ = Kross::Api::Object>
Kross::Api::ProxyFunction< INSTANCE, METHOD, RETURNOBJ, ARG1OBJ, ARG2OBJ, ARG3OBJ, ARG4OBJ >::ProxyFunction ( INSTANCE *  instance,
const METHOD &  method,
ARG1OBJ *  defarg1 = 0,
ARG2OBJ *  defarg2 = 0,
ARG3OBJ *  defarg3 = 0,
ARG4OBJ *  defarg4 = 0 
) [inline]

Constructor.

Parameters:
instance The objectinstance to which the method belongs to.
method The method-pointer.

Definition at line 157 of file proxy.h.


Member Function Documentation

template<class INSTANCE, typename METHOD, class RETURNOBJ, class ARG1OBJ = Kross::Api::Object, class ARG2OBJ = Kross::Api::Object, class ARG3OBJ = Kross::Api::Object, class ARG4OBJ = Kross::Api::Object>
Object::Ptr Kross::Api::ProxyFunction< INSTANCE, METHOD, RETURNOBJ, ARG1OBJ, ARG2OBJ, ARG3OBJ, ARG4OBJ >::call ( List::Ptr  args  )  [inline, virtual]

This method got called if the wrapped method should be executed.

Parameters:
args The optional list of arguments passed to the execution-call.
Returns:
The returnvalue of the functioncall. It will be NULL if the functioncall doesn't provide us a returnvalue (e.g. if the function has void as returnvalue).

Implements Kross::Api::Function.

Definition at line 169 of file proxy.h.


The documentation for this class was generated from the following file:
KDE Home | KDE Accessibility Home | Description of Access Keys