当前位置: 首页>>代码示例>>C++>>正文


C++ kjs::Object类代码示例

本文整理汇总了C++中kjs::Object的典型用法代码示例。如果您正苦于以下问题:C++ Object类的具体用法?C++ Object怎么用?C++ Object使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Object类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: putValue

void KJSEmbedPart::putValue( const QString & valueName, const KJS::Value & value )
{
  KJS::ExecState *exec = js->globalExec();
  KJS::Identifier id = KJS::Identifier( KJS::UString(valueName.latin1() ));
  KJS::Object obj = js->globalObject();
  obj.put(exec, id, value);
}
开发者ID:Kst-plot,项目名称:kst-subversion-archive,代码行数:7,代码来源:kjsembedpart.cpp

示例2: addBindings

void TextStreamImp::addBindings( KJS::ExecState *exec, KJS::Object &parent )
{
    kdDebug() << "TextStreamImp::addBindings()" << endl;

    JSOpaqueProxy *op = JSProxy::toOpaqueProxy( parent.imp() );
    if ( !op ) {
	kdWarning() << "TextStreamImp::addBindings() failed, not a JSOpaqueProxy" << endl;
	return;
    }

    QTextStream *ts = op->toTextStream();
    if ( !ts ) {
	kdWarning() << "TextStreamImp::addBindings() failed, type is " << op->typeName() << endl;
	return;
    }

    JSProxy::MethodTable methods[] = { 
	{ MethodIsReadable, "isReadable" },
	{ MethodIsWritable, "isWritable" },
	{ MethodPrint, "print" },
	{ MethodPrintLn, "println" },
	{ MethodReadLine, "readLine" },
	{ MethodFlush, "flush" },
	{ 0, 0 }
    };

    int idx = 0;
    do {
	TextStreamImp *tsi = new TextStreamImp( exec, idx, ts );
	parent.put( exec , methods[idx].name, KJS::Object(tsi) );
	++idx;
    } while( methods[idx].id );
}
开发者ID:Kst-plot,项目名称:kst-subversion-archive,代码行数:33,代码来源:textstream_imp.cpp

示例3: callMethod

KJS::Value KJSEmbedPart::callMethod( const QString & methodName, const KJS::List & args ) const
{
  KJS::ExecState *exec = js->globalExec();
  KJS::Identifier id = KJS::Identifier( KJS::UString(methodName.latin1() ));
  KJS::Object obj = js->globalObject();
  KJS::Object fun = obj.get(exec, id ).toObject( exec );
  KJS::Value retValue;
  if ( !fun.implementsCall() )
  {
  	// We need to create an exception here...
  }
  else
        retValue = fun.call(exec, obj, args);
	kdDebug( 80001 ) << "Returned type is: " << retValue.type() << endl;  
	if( exec->hadException() )
	{
		kdWarning( 80001 ) << "Got error: " << exec->exception().toString(exec).qstring() << endl;
		return exec->exception();
	}
	else
	{
		if( retValue.type() == 1 && retValue.type() == 0)
		{
			kdDebug( 80001 ) << "Got void return type. " << endl;
			return KJS::Null();
		}
	}
  return retValue;
}
开发者ID:Kst-plot,项目名称:kst-subversion-archive,代码行数:29,代码来源:kjsembedpart.cpp

示例4: getValue

KJS::Value KJSEmbedPart::getValue( const QString & valueName ) const
{
  KJS::ExecState *exec = js->globalExec();
  KJS::Identifier id = KJS::Identifier( KJS::UString(valueName.latin1() ));
  KJS::Object obj = js->globalObject();
  return obj.get(exec, id );
}
开发者ID:Kst-plot,项目名称:kst-subversion-archive,代码行数:7,代码来源:kjsembedpart.cpp

示例5: addBindingsClass

    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;
        }
    }
开发者ID:Kst-plot,项目名称:kst-subversion-archive,代码行数:28,代码来源:jsobjectproxy.cpp

示例6: startElement

bool SaxHandler::startElement( const QString &ns, const QString &ln, const QString &qn,
			       const QXmlAttributes &attrs )
{
    if ( !jshandler.isValid() ) {
	error = ErrorNoHandler;
	return false;
    }

    KJS::Identifier funName("startElement");
    if ( !jshandler.hasProperty(exec, funName) )
	return QXmlDefaultHandler::startElement( ns, ln, qn, attrs );

    KJS::Object fun = jshandler.get(exec, funName).toObject( exec );
    if ( !fun.implementsCall() ) {
	error = ErrorNotCallable;
	return false;
    }

    KJS::List args;
    args.append( KJS::String(ns) );
    args.append( KJS::String(ln) );
    args.append( KJS::String(qn) );
    // TODO: XmlAttributes not yet supported

    KJS::Value ret = fun.call( exec, jshandler, args );
    return ret.toBoolean( exec );
}
开发者ID:Kst-plot,项目名称:kst-subversion-archive,代码行数:27,代码来源:saxhandler.cpp

示例7: hasMethod

bool KJSEmbedPart::hasMethod( const QString & methodName )
{
  KJS::ExecState *exec = js->globalExec();
  KJS::Identifier id = KJS::Identifier( KJS::UString(methodName.latin1() ));
  KJS::Object obj = js->globalObject();
  KJS::Object fun = obj.get(exec, id ).toObject( exec );
  return fun.implementsCall();
}
开发者ID:Kst-plot,项目名称:kst-subversion-archive,代码行数:8,代码来源:kjsembedpart.cpp

示例8: KFileItemImp

void KJSEmbed::Bindings::KFileItemImp::addBindings( KJS::ExecState * exec, KJS::Object & object )
{

	JSOpaqueProxy *op = JSProxy::toOpaqueProxy( object.imp() );
	if ( !op ) 
	{
		kdWarning() << "KFileItemImp::addBindings() failed, not a JSOpaqueProxy" << endl;
		return;
	}
	
	if ( op->typeName() != "KFileItem" ) 
	{
		kdWarning() << "KFileItemImp::addBindings() failed, type is " << op->typeName() <<
	endl;
		return;
	}
	
	JSProxy::MethodTable methods[] = {
		{ Methodrefresh, "refresh"},
		{ MethodrefreshMimeType, "refreshMimeType"},
		{ Methodurl, "url"},
		{ MethodsetUrl, "setUrl"},
		{ MethodsetName, "setName"},
		{ MethodpermissionsString, "permissionsString"},
		{ Methoduser, "user"},
		{ Methodgroup, "group"},
		{ MethodisLink, "isLink"},
		{ MethodisDir, "isDir"},
		{ MethodisFile, "isFile"},
		{ MethodisReadable, "isReadable"},
		{ MethodlinkDest, "linkDest"},
		{ MethodtimeString, "timeString"}, 
		{ MethodisLocalFile, "isLocalFile"},
		{ Methodtext, "text"},
		{ Methodname, "name"}, 
		{ MethodmimeType, "mimeType"},
		{ MethodisMimeTypeKnown, "isMimeTypeKnown"},
		{ MethodmimeComment, "mimeComment"},
		{ MethodiconName, "iconName"},
		{ Methodpixmap, "pixmap"},
		{ Methodoverlays, "overlays"},
		{ MethodgetStatusBarInfo, "getStatusBarInfo"},
		{ MethodgetToolTipText, "getToolTipText"}, 
		{ Methodrun, "run"},
		{ 0, 0 }
	};
	
	int idx = 0;
	do {
		KFileItemImp *meth = new KFileItemImp( exec, methods[idx].id );
		object.put( exec , methods[idx].name, KJS::Object(meth) );
		++idx;
	} while( methods[idx].id );

}
开发者ID:Kst-plot,项目名称:kst-subversion-archive,代码行数:55,代码来源:kfileitemloader.cpp

示例9: scopeWalker

static KJS::Object scopeWalker( KJS::ExecState *exec, const KJS::Object &root, const QString &objectString )
{
  KJS::Object returnObject = root;
  QStringList objects = QStringList::split(".", objectString);
  for( uint idx = 0; idx < objects.count(); ++idx)
  {
    KJS::Identifier id = KJS::Identifier( KJS::UString( objects[idx] ));
    KJS::Value newObject = returnObject.get(exec, id );
    if( newObject.isValid() )
    	returnObject = newObject.toObject(exec);
  }
  return returnObject;
}
开发者ID:Kst-plot,项目名称:kst-subversion-archive,代码行数:13,代码来源:kjsembedpart.cpp

示例10: addBindings

void MyCustomObjectImp::addBindings( KJS::ExecState *exec, KJS::Object &object ) {

    kdDebug() << "MyCustomObjectImp::addBindings()" << endl;
    JSOpaqueProxy *op = JSProxy::toOpaqueProxy( object.imp() );
    if ( !op ) {
        kdWarning() << "MyCustomObjectImp::addBindings() failed, not a JSOpaqueProxy" << endl;
        return;
    }

    if ( op->typeName() != "MyCustomObject" ) {
	kdWarning() << "MyCustomObjectImp::addBindings() failed, type is " << op->typeName() << endl;
	return;
    }

    JSProxy::MethodTable methods[] = {
	{ Methodmode, "mode"},
	{ MethodsetMode, "setMode"},
	{ Methodthing,  "thing"},
	{ MethodsetThing, "setThing"},
	{ 0, 0 }
    };

    int idx = 0;
    do {
        MyCustomObjectImp *meth = new MyCustomObjectImp( 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[] = {
	// MyCustomObject::mode
	{ "On", 0 },
	{ "Off", 1 },
	{ 0, 0 }
    };

    int enumidx = 0;
    do {
        object.put( exec, enums[enumidx].id, KJS::Number(enums[enumidx].val), KJS::ReadOnly );
        ++enumidx;
    } while( enums[enumidx].id );
}
开发者ID:Kst-plot,项目名称:kst-subversion-archive,代码行数:50,代码来源:customobject_plugin.cpp

示例11: addObject

KJS::Object KJSEmbedPart::addObject( QObject *obj, KJS::Object &parent, const char *name )
{
    KJS::Object jsobj = bind( obj );
    parent.put( js->globalExec(), name ? name : obj->name(), jsobj );

    return jsobj;
}
开发者ID:Kst-plot,项目名称:kst-subversion-archive,代码行数:7,代码来源:kjsembedpart.cpp

示例12: addBindings

void KstBindEllipse::addBindings(KJS::ExecState *exec, KJS::Object& obj) {
  int start = KstBindViewObject::methodCount();
  for (int i = 0; ellipseBindings[i].name != 0L; ++i) {
    KJS::Object o = KJS::Object(new KstBindEllipse(i + start + 1));
    obj.put(exec, ellipseBindings[i].name, o, KJS::Function);
  }
}
开发者ID:Kst-plot,项目名称:kst-subversion-archive,代码行数:7,代码来源:bind_ellipse.cpp

示例13: call

  KJS::Value Point::call( KJS::ExecState *exec, KJS::Object &self, const KJS::List &args ) {
    if( !JSProxy::checkType(self, JSProxy::ValueProxy, "QPoint") ) return KJS::Value();
    JSValueProxy *vp = JSProxy::toValueProxy( self.imp() );
    KJS::Value retValue = KJS::Value();
    QPoint val = vp->toVariant().toPoint();

    switch ( mid ) { 
      case Methodx:
	retValue = KJS::Number(val.x());
       break;
      case MethodsetX:
	val.setX(extractInt(exec,args,0));
	break;
      case  Methody:
	retValue = KJS::Number(val.y());
	break;
      case  MethodsetY:
	val.setY(extractInt(exec,args,0));
	break;
      case  MethodmanhattanLength:
	retValue = KJS::Number(val.manhattanLength());
	break;
      default:
	QString msg = i18n( "Point has no method %1" ).arg(mid);
  return throwError(exec, msg);
	break;
    }

    vp->setValue(val);
    return retValue;
  }
开发者ID:Kst-plot,项目名称:kst-subversion-archive,代码行数:31,代码来源:point_imp.cpp

示例14: addSlotBinding

    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 ) );
        }
    }
开发者ID:Kst-plot,项目名称:kst-subversion-archive,代码行数:47,代码来源:jsobjectproxy.cpp

示例15: initScript

DOM::EventListener *KJSProxyImpl::createHTMLEventHandler(QString sourceUrl, QString code)
{
#ifdef KJS_DEBUGGER
  if (KJSDebugWin::instance())
    KJSDebugWin::instance()->setNextSourceInfo(sourceUrl,m_handlerLineno);
#else
  Q_UNUSED(sourceUrl);
#endif

  initScript();
  //KJS::Constructor constr(KJS::Global::current().get("Function").imp());
  KJS::Object constr = m_script->builtinFunction();
  KJS::List args;
  args.append(KJS::String("event"));
  args.append(KJS::String(code));
  Object handlerFunc = constr.construct(m_script->globalExec(), args); // ### is globalExec ok ?

  return KJS::Window::retrieveWindow(m_part)->getJSEventListener(handlerFunc,true);
}
开发者ID:crutchwalkfactory,项目名称:motocakerteam,代码行数:19,代码来源:kjs_proxy.cpp


注:本文中的kjs::Object类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。