#include <qcstring.h>
#include <qimage.h>
#include <qpainter.h>
#include <qpalette.h>
#include <qpixmap.h>
#include <qfont.h>
#include <kjs/object.h>
#include <kjsembed/global.h>
#include <kjsembed/jsobjectproxy.h>
#include <kjsembed/jsopaqueproxy.h>
#include <kjsembed/jsbinding.h>
#include <>
#include "_imp.h"
/**
* Namespace containing the KJSEmbed library.
*/
namespace KJSEmbed {
Imp::Imp( KJS::ExecState *exec, int mid, bool constructor )
: JSProxyImp(exec), id(mid), cons(constructor)
{
}
Imp::~Imp()
{
}
/**
* Adds bindings for static methods and enum constants to the specified Object.
*/
void Imp::addStaticBindings( KJS::ExecState *exec, KJS::Object &object )
{
JSProxy::MethodTable methods[] = {
_
Method_
{ , "" },
{ 0, 0 }
};
int idx = 0;
TQCString lastName;
while( methods[idx].name ) {
if ( lastName != methods[idx].name ) {
Imp *meth = new Imp( exec, methods[idx].id );
object.put( exec , methods[idx].name, KJS::Object(meth) );
lastName = methods[idx].name;
}
++idx;
}
//
// Define the enum constants
//
struct EnumValue {
const char *id;
int val;
};
EnumValue enums[] = {
// enum
{ "", :: },
{ 0, 0 }
};
int enumidx = 0;
while( enums[enumidx].id ) {
object.put( exec, enums[enumidx].id, KJS::Number(enums[enumidx].val), KJS::ReadOnly );
++enumidx;
}
}
/**
* Adds bindings for instance methods to the specified Object.
*/
void Imp::addBindings( KJS::ExecState *exec, KJS::Object &object )
{
JSProxy::MethodTable methods[] = {
_
Method_
{ , "" },
{ 0, 0 }
};
int idx = 0;
TQCString lastName;
while( methods[idx].name ) {
if ( lastName != methods[idx].name ) {
Imp *meth = new Imp( exec, methods[idx].id );
object.put( exec , methods[idx].name, KJS::Object(meth) );
lastName = methods[idx].name;
}
++idx;
}
}
/**
* Extract a pointer from an Object.
*/
*Imp::to( KJS::Object &self )
{
JSObjectProxy *ob = JSProxy::toObjectProxy( self.imp() );
if ( ob ) {
TQObject *obj = ob->object();
if ( obj )
return dynamic_cast< *>( obj );
}
JSOpaqueProxy *op = JSProxy::toOpaqueProxy( self.imp() );
if ( !op )
return 0;
if ( op->typeName() != "" )
return 0;
return ( *)( op->toVoidStar() );
}
/**
* Select and invoke the correct constructor.
*/
KJS::Object Imp::construct( KJS::ExecState *exec, const KJS::List &args )
{
switch( id ) {
_
Constructor_
case :
return ( exec, args );
break;
default:
break;
}
TQString msg = i18n("Cons has no constructor with id '%1'").arg(id);
KJS::Object err = KJS::Error::create( exec, KJS::ReferenceError, msg.utf8() );
exec->setException( err );
return err;
}
_
Constructor_
KJS::Object Imp::( KJS::ExecState *exec, const KJS::List &args )
{
#if 0 // This constructor has been disabled by the XSL template
TQString arg = extractTQString(exec, args, );
TQString arg = extractTQString(exec, args, );
TQString arg = extractTQString(exec, args, );
const TQCString arg = (args.size() >= ) ? args[].toString(exec).ascii() : 0;
const char *arg = (args.size() >= ) ? args[].toString(exec).ascii() : 0;
int arg = extractInt(exec, args, );
uint arg = extractUInt(exec, args, );
double arg = extractDouble(exec, args, );
bool arg = extractBool(exec, args, );
TQFont arg = extractTQFont(exec, args, );
TQPalette arg = extractTQPalette(exec, args, );
TQStringList arg = extractTQStringList(exec, args, );
TQStrList arg = extractTQStrList(exec, args, );
TQPoint arg = extractTQPoint(exec, args, );
TQRect arg = extractTQRect(exec, args, );
TQSize arg = extractTQSize(exec, args, );
TQPixmap arg = extractTQPixmap(exec, args, );
TQImage arg = extractTQImage(exec, args, );
TQColor arg = extractTQColor(exec, args, );
TQDate arg = extractTQDate(exec, args, );
TQTime arg = extractTQTime(exec, args, );
TQDateTime arg = extractTQDateTime(exec, args, );
TQt::WFlags arg; // TODO (hack for TQCanvasView)
// Unsupported parameter
return KJS::Object();
arg; // Dummy
// We should now create an instance of the object
*ret = new (
arg,
);
#endif // This constructor has been disabled by the XSL template
}
KJS::Value Imp::call( KJS::ExecState *exec, KJS::Object &self, const KJS::List &args )
{
instance = Imp::to( self );
switch( id ) {
_
Method_
case :
return ( exec, self, args );
break;
default:
break;
}
TQString msg = i18n( "Imp has no method with id '%1'" ).arg( id );
KJS::Object err = KJS::Error::create( exec, KJS::ReferenceError, msg.utf8() );
exec->setException( err );
return err;
}
Imp::_
KJS::Value ( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
{
TQString arg = extractTQString(exec, args, );
TQString arg = extractTQString(exec, args, );
TQString arg = extractTQString(exec, args, );
const TQCString arg = (args.size() >= ) ? args[].toString(exec).ascii() : 0;
const char *arg = (args.size() >= ) ? args[].toString(exec).ascii() : 0;
int arg = extractInt(exec, args, );
uint arg = extractUInt(exec, args, );
double arg = extractDouble(exec, args, );
bool arg = extractBool(exec, args, );
TQFont arg = extractTQFont(exec, args, );
TQPalette arg = extractTQPalette(exec, args, );
TQStringList arg = extractTQStringList(exec, args, );
TQStrList arg = extractTQStrList(exec, args, );
TQPoint arg = extractTQPoint(exec, args, );
TQRect arg = extractTQRect(exec, args, );
TQSize arg = extractTQSize(exec, args, );
TQPixmap arg = extractTQPixmap(exec, args, );
TQImage arg = extractTQImage(exec, args, );
TQColor arg = extractTQColor(exec, args, );
TQDate arg = extractTQDate(exec, args, );
TQTime arg = extractTQTime(exec, args, );
TQDateTime arg = extractTQDateTime(exec, args, );
TQComboBox::Policy arg; // TODO (hack for combo box)
TQFrame::Shape arg; // TODO (hack for frame)
TQFrame::Shadow arg; // TODO (hack for frame)
FILE *arg; // TODO (hack for qfile)
TQFile::Offset arg; // TODO (hack for qfile)
TQFile::EncoderFn arg; // TODO (hack for qfile)
TQFile::DecoderFn arg; // TODO (hack for qfile)
TQCanvasSprite::FrameAnimationType arg; // TODO (hack for TQCanvasSprite)
TQt::WFlags arg; // TODO (hack for TQCanvasView)
TQByteArray arg; // TODO (hack for qfile)
TQPointArray arg; // TODO (hack for qcanvas)
TQPainter arg; // TODO (hack for qcanvas)
TQPainter arg; // TODO (hack for qcanvas)
TQWMatrix arg; // TODO (hack for qcanvasview)
// Unsupported parameter
return KJS::Value();
arg; // Dummy
bool ret;
ret = instance->(
arg, );
return KJS::Boolean( ret );
int ret;
ret = instance->(
arg, );
return KJS::Number( ret );
uint ret;
ret = instance->(
arg, );
return KJS::Number( ret );
double ret;
ret = instance->(
arg, );
return KJS::Number( ret );
TQString ret;
ret = instance->(
arg, );
return KJS::String( ret );
const char *ret;
ret = instance->(
arg, );
return KJS::String( ret );
ret;
ret = instance->(
arg, );
return convertToValue( exec, ret );
TQStringList ret;
ret = instance->(
arg, );
return convertToValue( exec, ret );
instance->(
arg, );
return KJS::Value(); // Returns void
instance->(
arg, );
return KJS::Value(); // Returns ''
}
} // namespace KJSEmbed