void JSObjectProxy::addBindingsClass( KJS::ExecState *exec, KJS::Object & /*object*/ ) { KJS::Identifier clazzid; QObject *o = obj; Bindings::BindingObject *bo = dynamic_cast<Bindings::BindingObject *>( o ); if ( bo ) { clazzid = KJS::Identifier( bo->jsClassName() ? bo->jsClassName() : obj->className() ); } else { clazzid = KJS::Identifier( obj->className() ); } KJS::Object global = js->globalObject(); if ( global.hasProperty( exec, clazzid ) ) { kdDebug( 80001 ) << "addBindingsClass() " << clazzid.qstring() << " already known" << endl; KJS::Object clazz = global.get( exec, clazzid ).toObject( exec ); Bindings::JSFactoryImp *imp = dynamic_cast<Bindings::JSFactoryImp *>( clazz.imp() ); if ( !imp ) { kdWarning() << "addBindingsClass() Class was not created by normal means" << endl; return ; } kdDebug( 80001 ) << "addBindingsClass() Adding enums" << endl; imp->setDefaultValue( js->builtinObject().construct( exec, KJS::List() ) ); addBindingsEnum( exec, clazz ); } else { kdWarning() << "addBindingsClass() " << clazzid.qstring() << " not known" << endl; } }
KJS::List KJSEmbedPart::constructorList() const { KJS::List items; KJS::Object obj = js->globalObject(); KJS::ExecState *exec = js->globalExec(); KJS::ReferenceList l = obj.propList( exec ); KJS::ReferenceListIterator propIt = l.begin(); while ( propIt != l.end() ) { KJS::Identifier name = propIt->getPropertyName( exec ); if ( obj.hasProperty( exec, name ) ) { KJS::Value v = obj.get( exec, name ); KJS::Object vobj = v.toObject( exec ); if ( vobj.implementsConstruct() ) items.append( KJS::String( name.ustring() ) ); } propIt++; } return items; }
void JSObjectProxy::addSlotBinding( const QCString &name, KJS::ExecState *exec, KJS::Object &object ) { // Lookup and bind slot QMetaObject * mo = obj->metaObject(); int slotid = mo->findSlot( name.data(), true ); if ( slotid == -1 ) return ; const QMetaData *md = mo->slot( slotid, true ); if ( md->access != QMetaData::Public ) return ; // Find signature int id = Bindings::JSSlotUtils::findSignature( name ); // kdDebug( 80001 )<<"JSObjectProxy::addSlotBinding()::slot:"<<name<<" id:"<<id<<endl; if ( id < 0 ) return ; QCString jsname = name; jsname.detach(); jsname.replace( QRegExp( "\\([^\\)]*\\)" ), "" ); // Find the return type, we only care if it is a pointer type const QUMethod *m = md->method; const char *retclass = 0; QCString ptr( "ptr" ); if ( m->count && ( m->parameters->inOut == QUParameter::Out ) && ( ptr == m->parameters->type->desc() ) ) { retclass = ( const char * ) m->parameters->typeExtra; // kdDebug(80001) << "Return type is a pointer, type " << retclass << endl; } // Create the Imp JSObjectProxyImp *imp = new JSObjectProxyImp( exec, JSObjectProxyImp::MethodSlot, retclass ? retclass : "", id, name, this ); if ( !object.hasProperty( exec, KJS::Identifier( jsname ) ) ) { // The identifier is unused object.put( exec, KJS::Identifier( jsname.data() ), KJS::Object( imp ) ); } else { // The identifier has already been used QString s( name ); QCString cs = QString( "%1%2" ).arg( jsname ).arg( s.contains( ',' ) + 1 ).ascii(); //kdDebug(80001) << "Method " << jsname << " exists, using " << cs << " for " << s << endl; object.put( exec, KJS::Identifier( cs.data() ), KJS::Object( imp ) ); } }