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

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

template<class PROXYFUNC, typename RETURNTYPE>
struct ProxyFunctionCaller

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 TQString& 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 TQString 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 TQString getClassName() const { return "MyClass"; }
private:
uint myfunc(const TQCString&, MyClass* myotherclass) {
// This method will be published to the scripting backend. So, scripting
// code is able to call this method.
}
}
virtual const TQString getClassName() const
Return the class name.
Definition callable.cpp:42
From Event inherited template-class to represent class-structures.
Definition class.h:44
Variant value to wrap a TQVariant into a Kross::Api::Value to enable primitive types like strings or ...
Definition variant.h:39
The common Kross API used as common codebase.
Definition callable.h:33
The Kross scripting bridge to embed scripting functionality into an application.
Definition callable.h:33

Definition at line 102 of file proxy.h.

Constructor & Destructor Documentation

◆ ProxyFunction()

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
instanceThe objectinstance to which the method belongs to.
methodThe method-pointer.

Definition at line 156 of file proxy.h.

Member Function Documentation

◆ call()

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)
inlinevirtual

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

Parameters
argsThe 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 168 of file proxy.h.

◆ ProxyFunctionCaller

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>
template<class PROXYFUNC, typename RETURNTYPE>
friend struct ProxyFunctionCaller
friend

Definition at line 105 of file proxy.h.


The documentation for this class was generated from the following file: