#include <qpalette.h>
#include <qpixmap.h>
#include <qfont.h>
#include <klocale.h>
#include <kjs/object.h>
#include <kdebug.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 id )
: JSProxyImp(exec), mid(id)
{
}
Imp::~Imp()
{
}
void Imp::addBindings( KJS::ExecState *exec, KJS::Object &object )
{
JSProxy::MethodTable methods[] = {
_
Method_
{ , "" },
{ 0, 0 }
};
int idx = 0;
do {
Imp *meth = new Imp( exec, methods[idx].id );
object.put( exec , methods[idx].name, KJS::Object(meth) );
++idx;
} while( methods[idx].id );
//
// Define the enum constants
//
struct EnumValue {
const char *id;
int val;
};
EnumValue enums[] = {
// enum
{ "", :: },
{ 0, 0 }
};
int enumidx = 0;
do {
object.put( exec, enums[enumidx].id, KJS::Number(enums[enumidx].val), KJS::ReadOnly );
++enumidx;
} while( enums[enumidx].id );
}
*Imp::to( KJS::Object &self )
{
JSObjectProxy *ob = JSProxy::toObjectProxy( self.imp() );
if ( ob ) {
TQObject *obj = ob->object();
if ( obj )
return dynamic_cast<TQComboBox *>( obj );
}
JSOpaqueProxy *op = JSProxy::toOpaqueProxy( self.imp() );
if ( !op )
return 0;
if ( op->typeName() != "" )
return 0;
return ( *)( op->toVoidStar() );
}
KJS::Value Imp::call( KJS::ExecState *exec, KJS::Object &self, const KJS::List &args )
{
instance = Imp::to( self );
switch( mid ) {
_
Method_
case :
return ( exec, self, args );
break;
default:
break;
}
TQString msg = i18n( "Imp has no method with id '%1'" ).arg( mid );
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 = (args.size() >= ) ? args[].toString(exec).qstring() : TQString::null;
TQString arg = (args.size() >= ) ? args[].toString(exec).qstring() : TQString::null;
const char *arg = (args.size() >= ) ? args[].toString(exec).ascii() : 0;
int arg = (args.size() >= ) ? args[].toInteger(exec) : -1;
uint arg = (args.size() >= ) ? args[].toInteger(exec) : -1;
double arg = (args.size() >= ) ? args[].toInteger(exec) : -1;
bool arg = (args.size() >= ) ? args[].toBoolean(exec) : false;
TQFont arg; // TODO
TQPalette arg; // TODO
TQStringList arg = extractTQStringList(exec, args, );
TQStrList arg;
if ( args.size() >= ) {
// TODO: populate the list
}
TQRect arg = extractTQRect(exec, args, );
TQSize arg = extractTQSize(exec, args, );
TQPixmap arg = extractTQPixmap(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)
// 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 );
TQStringList ret;
ret = instance->(
arg, );
return convertToValue( exec, ret );
instance->(
arg, );
return KJS::Value(); // Returns void
instance->(
arg, );
return KJS::Value(); // Returns ''
}
} // namespace KJSEmbed
// Local Variables:
// c-basic-offset: 4
// End: