#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 ) {
QObject *obj = ob->object();
if ( obj )
return dynamic_cast<QComboBox *>( 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;
}
QString 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 )
{
QString arg = (args.size() >= ) ? args[].toString(exec).qstring() : QString::null;
QString arg = (args.size() >= ) ? args[].toString(exec).qstring() : QString::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;
QFont arg; // TODO
QPalette arg; // TODO
QStringList arg = extractQStringList(exec, args, );
QStrList arg;
if ( args.size() >= ) {
// TODO: populate the list
}
QRect arg = extractQRect(exec, args, );
QSize arg = extractQSize(exec, args, );
QPixmap arg = extractQPixmap(exec, args, );
QColor arg = extractQColor(exec, args, );
QDate arg = extractQDate(exec, args, );
QTime arg = extractQTime(exec, args, );
QDateTime arg = extractQDateTime(exec, args, );
QComboBox::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 );
QString ret;
ret = instance->(
arg, );
return KJS::String( ret );
const char *ret;
ret = instance->(
arg, );
return KJS::String( ret );
QStringList 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: