kjs Library API Documentation

KJS::InternalFunctionImp Class Reference

Base class for all function objects. More...

#include <function.h>

Inheritance diagram for KJS::InternalFunctionImp:

KJS::ObjectImp KJS::ValueImp KJS::ArrayObjectImp KJS::ArrayProtoFuncImp KJS::BooleanObjectImp KJS::BooleanProtoFuncImp KJS::DateObjectFuncImp KJS::DateObjectImp KJS::DateProtoFuncImp KJS::ErrorObjectImp KJS::ErrorProtoFuncImp KJS::FunctionImp KJS::FunctionObjectImp KJS::FunctionProtoFuncImp KJS::FunctionPrototypeImp KJS::GlobalFuncImp KJS::MathFuncImp KJS::NativeErrorImp KJS::NumberObjectImp KJS::NumberProtoFuncImp KJS::ObjectObjectImp KJS::ObjectProtoFuncImp KJS::RegExpObjectImp KJS::RegExpProtoFuncImp KJS::StringObjectFuncImp KJS::StringObjectImp KJS::StringProtoFuncImp List of all members.

Public Member Functions

 InternalFunctionImp (FunctionPrototypeImp *funcProto)
 InternalFunctionImp (ExecState *exec)
bool implementsHasInstance () const
Boolean hasInstance (ExecState *exec, const Value &value)
virtual const ClassInfoclassInfo () const
Identifier name () const
void setName (Identifier _ident)

Static Public Attributes

static const ClassInfo info = {"Function", 0, 0, 0}

Protected Attributes

Identifier ident

Detailed Description

Base class for all function objects.

It implements the hasInstance method (for instanceof, which only applies to function objects) and allows to give the function a name, used in toString().

Constructors and prototypes of internal objects (implemented in C++) directly inherit from this. FunctionImp also does, for functions implemented in JS.

Definition at line 41 of file function.h.


Constructor & Destructor Documentation

InternalFunctionImp::InternalFunctionImp FunctionPrototypeImp funcProto  ) 
 

Constructor.

For C++-implemented functions, funcProto is usually static_cast<FunctionPrototypeImp*>(exec->interpreter()->builtinFunctionPrototype().imp())

Definition at line 967 of file internal.cpp.


Member Function Documentation

Boolean InternalFunctionImp::hasInstance ExecState exec,
const Value value
[virtual]
 

Implementation of the [[HasInstance]] internal property.

See also:
Object::hasInstance()

Reimplemented from KJS::ObjectImp.

Definition at line 982 of file internal.cpp.

References KJS::Error::create(), KJS::Object::dynamicCast(), KJS::ObjectImp::get(), KJS::Object::imp(), KJS::Value::imp(), KJS::Object::prototype(), KJS::prototypePropertyName, KJS::ExecState::setException(), and KJS::Value::type().

virtual const ClassInfo* KJS::InternalFunctionImp::classInfo  )  const [inline, virtual]
 

A pointer to a ClassInfo struct for this class.

This provides a basic facility for run-time type information, and can be used to check an object's class an inheritance (see inherits()). This should always return a statically declared pointer, or 0 to indicate that there is no class information.

This is primarily useful if you have application-defined classes that you wish to check against for casting purposes.

For example, to specify the class info for classes FooImp and BarImp, where FooImp inherits from BarImp, you would add the following in your class declarations:

   class BarImp : public ObjectImp {
     virtual const ClassInfo *classInfo() const { return &info; }
     static const ClassInfo info;
     // ...
   };

   class FooImp : public ObjectImp {
     virtual const ClassInfo *classInfo() const { return &info; }
     static const ClassInfo info;
     // ...
   };

And in your source file:

   const ClassInfo BarImp::info = {0, 0, 0}; // no parent class
   const ClassInfo FooImp::info = {&BarImp::info, 0, 0};

See also:
inherits()

Reimplemented from KJS::ObjectImp.

Reimplemented in KJS::NativeErrorImp, KJS::FunctionImp, KJS::DeclaredFunctionImp, and KJS::NumberObjectImp.

Definition at line 53 of file function.h.

void KJS::InternalFunctionImp::setName Identifier  _ident  )  [inline]
 

You might want to use the helper function ObjectImp::setFunctionName for this.

Definition at line 57 of file function.h.


The documentation for this class was generated from the following files:
KDE Logo
This file is part of the documentation for kjs Library Version 3.4.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Tue Nov 1 10:32:48 2005 by doxygen 1.4.3 written by Dimitri van Heesch, © 1997-2003