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

Kross

  • Kross
  • Object
Public Types | Public Member Functions | List of all members
Kross::Object Class Reference

#include <object.h>

Inheritance diagram for Kross::Object:
Inheritance graph
[legend]

Public Types

typedef KSharedPtr< Object > Ptr
 

Public Member Functions

 Object ()
 
 Object (const Object &other)
 
virtual ~Object ()
 
virtual QVariant callMethod (const QString &name, const QVariantList &args=QVariantList())
 
virtual QStringList methodNames ()
 
virtual void virtual_hook (int id, void *ptr)
 
- Public Member Functions inherited from QSharedData
 QSharedData ()
 
 QSharedData (const QSharedData &other)
 
- Public Member Functions inherited from Kross::ErrorInterface
 ErrorInterface ()
 
void clearError ()
 
long errorLineNo () const
 
const QString errorMessage () const
 
const QString errorTrace () const
 
bool hadError () const
 
void setError (const QString &errormessage, const QString &tracemessage=QString(), long lineno=-1)
 
void setError (ErrorInterface *error)
 

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.

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
nameEach call has a name that says what should be called.
argsThe optional list of arguments passed to the call.
Returns
The call-result as QVariant.

Reimplemented in Kross::EcmaObject.

Definition at line 49 of file object.cpp.

QStringList Object::methodNames ( )
virtual

Return a list of supported callable objects.

Returns
List of supported calls.

Reimplemented in Kross::EcmaObject.

Definition at line 56 of file object.cpp.

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

used virtual hook to easier the job to keep binary compatibility.

Definition at line 61 of file object.cpp.


The documentation for this class was generated from the following files:
  • object.h
  • object.cpp
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:24:44 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

Kross

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

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal