KJSEmbed::StaticConstructor

Search for usage in LXR

#include <static_binding.h>

Inherits InternalFunctionImp.

Public Member Functions

 StaticConstructor (KJS::ExecState *exec, const Constructor *constructor)
 
void addStaticMethods (KJS::ExecState *exec, const Method *methods)
 
KJS::JSValuecallAsFunction (KJS::ExecState *exec, KJS::JSObject *, const KJS::List &args) override
 
KJS::JSObject * construct (KJS::ExecState *exec, const KJS::List &args) override
 
KJS::JSValuedefaultValue (KJS::ExecState *exec, KJS::JSType hint) const override
 
bool implementsConstruct () const override
 
void setDefaultValue (KJS::JSValue *value)
 

Static Public Member Functions

static KJS::JSObject * add (KJS::ExecState *exec, KJS::JSObject *object, const Constructor *constructor)
 
static KJS::JSObject * bind (KJS::ExecState *exec, const QString &className, PointerBase &objPtr)
 
static KJS::JSObject * construct (KJS::ExecState *exec, KJS::JSObject *parent, const KJS::UString &className, const KJS::List &args=KJS::List())
 
static const Constructor * constructor (const KJS::UString &className)
 
static const Methodmethods (const KJS::UString &className)
 

Protected Attributes

const Constructor * m_constructor
 

Detailed Description

A special method that will create other objects.

If you want to have your binding to be able to create instances of itself it must have at least one of these objects published at the global scope.

Definition at line 70 of file static_binding.h.

Constructor & Destructor Documentation

◆ StaticConstructor()

StaticConstructor::StaticConstructor ( KJS::ExecState exec,
const Constructor *  constructor 
)

Create a new constructor.

Definition at line 68 of file static_binding.cpp.

Member Function Documentation

◆ add()

KJS::JSObject * StaticConstructor::add ( KJS::ExecState exec,
KJS::JSObject *  object,
const Constructor *  constructor 
)
static

Add the constructor to an object.

This is usually the global scope.

Definition at line 94 of file static_binding.cpp.

◆ addStaticMethods()

void KJSEmbed::StaticConstructor::addStaticMethods ( KJS::ExecState exec,
const Method methods 
)

Add static methods to the object.

KJS::JSObject *ctor = StaticConstructor::add( exec, parent, TestPointer::constructor() ); // Ctor
ctor.addStaticMethods( exec, TestPointer::staticMethods() );

◆ construct() [1/2]

KJS::JSObject * StaticConstructor::construct ( KJS::ExecState exec,
const KJS::List args 
)
override

Calls the callback that will in turn create a new instance of this object with the arguments passed in with args.

Definition at line 77 of file static_binding.cpp.

◆ construct() [2/2]

KJS::JSObject * StaticConstructor::construct ( KJS::ExecState exec,
KJS::JSObject *  parent,
const KJS::UString className,
const KJS::List args = KJS::List() 
)
static

This method is used to construct a KJS value from C++.

KJS::List args;
args.append("test");
KJS::Value myType = KJSEmbed::construct(exec, "MyType", args);

is equivalent to the following javascript

var myType = new MyType("test");

Definition at line 136 of file static_binding.cpp.


The documentation for this class was generated from the following files:
void append(JSValue *val)
static KJS::JSObject * add(KJS::ExecState *exec, KJS::JSObject *object, const Constructor *constructor)
Add the constructor to an object.
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Wed Nov 29 2023 04:01:06 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.