• Skip to content
  • Skip to link menu
KDE 4.1 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

Kross

Kross::Object

Kross::Object Class Reference

#include <object.h>

Inheritance diagram for Kross::Object:

Inheritance graph
[legend]

List of all members.


Detailed Description

The class Object does provide us scripting objects like class instances to the C++ world.

This class implementates reference counting for shared objects. So, no need to take care of freeing objects.

Sample that does use the Object functionality to pass a Javascript classinstance to C++ code which then calls a method the classinstance provides.

 class MyObject : public QObject
 {
     public Q_SLOTS:
         QVariant myFunction(Kross::Object::Ptr obj) {
             QVariantList args;
             return obj->callMethod("myMethod", args);
         }
 };
 function MyClass(result) {
     this.myMethod = function() {
         return result;
     }
 }
 var myclass = new MyClass("my string");
 var r = MyObject.myFunction(myclass);
 print(r); // prints "my string"

Since:
4.1

Definition at line 69 of file object.h.


Public Types

typedef KSharedPtr< Object > Ptr

Public Member Functions

virtual QVariant callMethod (const QString &name, const QVariantList &args=QVariantList())
virtual QStringList methodNames ()
 Object (const Object &other)
 Object ()
virtual void virtual_hook (int id, void *ptr)
virtual ~Object ()

Member Typedef Documentation

typedef KSharedPtr<Object> Kross::Object::Ptr

Shared pointer to implement reference-counting.

Definition at line 76 of file object.h.


Constructor & Destructor Documentation

Object::Object (  )  [explicit]

Default constructor.

Definition at line 29 of file object.cpp.

Object::Object ( const Object &  other  ) 

Copy constructor.

Definition at line 36 of file object.cpp.

Object::~Object (  )  [virtual]

Destructor.

Definition at line 44 of file object.cpp.


Member Function Documentation

QVariant Object::callMethod ( const QString &  name,
const QVariantList &  args = QVariantList() 
) [virtual]

Pass a call to the object and evaluated it.

Parameters:
name Each call has a name that says what should be called.
args The optional list of arguments passed to the call.
Returns:
The call-result as QVariant.

Definition at line 49 of file object.cpp.

QStringList Object::methodNames (  )  [virtual]

Return a list of supported callable objects.

Returns:
List of supported calls.

Definition at line 56 of file object.cpp.

void Object::virtual_hook ( int  id,
void *  ptr 
) [virtual]

Definition at line 61 of file object.cpp.


The documentation for this class was generated from the following files:
  • object.h
  • object.cpp

Kross

Skip menu "Kross"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • KIO
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • Kross
  • KUtils
  • Nepomuk
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal