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 );
}
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 );
}
예제 #3
0
void KstBindLegend::addBindings(KJS::ExecState *exec, KJS::Object& obj) {
  int start = KstBindBorderedViewObject::methodCount();
  for (int i = 0; legendBindings[i].name != 0L; ++i) {
    KJS::Object o = KJS::Object(new KstBindLegend(i + start + 1));
    obj.put(exec, legendBindings[i].name, o, KJS::Function);
  }
}
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);
}
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;
}
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);
  }
}
예제 #7
0
void KstBindCurve::addBindings(KJS::ExecState *exec, KJS::Object& obj) {
  int start = KstBindDataObject::methodCount();
  for (int i = 0; curveBindings[i].name != 0L; ++i) {
    KJS::Object o = KJS::Object(new KstBindCurve(i + start + 1));
    obj.put(exec, curveBindings[i].name, o, KJS::Function);
  }
}
    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 ) );
        }
    }
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 );

}
예제 #10
0
void KstJS::createBindings() {
  _jsPart->factory()->addType("KstJSUIBuilder");
  _jsPart->factory()->addType("KActionCollection");
  if (_merge) {
    _jsPart->addObject(_merge, _merge->name());
  }

  KJS::ExecState *exec = _jsPart->globalExec();
  KJS::Object globalObj = _jsPart->globalObject();

  new KstBindPoint(exec, &globalObj);
  new KstBindSize(exec, &globalObj);

  new KstBindVector(exec, &globalObj);
  new KstBindScalar(exec, &globalObj);
  new KstBindString(exec, &globalObj);
  new KstBindDataSource(exec, &globalObj);
  new KstBindDataVector(exec, &globalObj);
  new KstBindMatrix(exec, &globalObj);
  new KstBindDataMatrix(exec, &globalObj);
  new KstBindVectorView(exec, &globalObj);

  new KstBindBinnedMap(exec, &globalObj);
  new KstBindCSD(exec, &globalObj);
  new KstBindCrossPowerSpectrum(exec, &globalObj);
  new KstBindEquation(exec, &globalObj);
  new KstBindPlugin(exec, &globalObj);
  new KstBindPowerSpectrum(exec, &globalObj);
  new KstBindHistogram(exec, &globalObj);

  new KstBindCurve(exec, &globalObj);
  new KstBindImage(exec, &globalObj);

  new KstBindGroup(exec, &globalObj);
  new KstBindPlot(exec, &globalObj);
  new KstBindLine(exec, &globalObj);
  new KstBindLabel(exec, &globalObj);
  new KstBindLegend(exec, &globalObj);
  new KstBindBox(exec, &globalObj);
  new KstBindEllipse(exec, &globalObj);
  new KstBindPicture(exec, &globalObj);
  new KstBindArrow(exec, &globalObj);

  new KstBindWindow(exec, &globalObj);
  new KstBindDebug(exec, &globalObj);
  new KstBindKst(exec, &globalObj, this);

  new KstBindFile(exec, &globalObj);
  new KstBindELOG(exec, &globalObj);

  globalObj.put(exec, "loadScript", KJS::Object(new LoadScript(this)));

  createRegistry();
}
    void JSObjectProxy::addBindingsEnum( KJS::ExecState *exec, KJS::Object &object ) {
        QMetaObject * mo = obj->metaObject();
        QStrList enumList = mo->enumeratorNames( true );

        for ( QStrListIterator iter( enumList ); iter.current(); ++iter ) {

            const QMetaEnum *me = mo->enumerator( iter.current(), true );
            for ( uint i = 0 ; i < me->count ; i++ ) {
                QCString key( ( me->items ) [ i ].key );
                int val = ( me->items ) [ i ].value;
                object.put( exec, key.data(), KJS::Number( val ), KJS::ReadOnly );
            }
        }
    }
예제 #12
0
static void JsDebugExtension(ExecState *exec, KParts::ReadOnlyPart *part, 
	const KURL &, const QString &, KJS::Object &hostobj )
{
    if ( !part->inherits( "KHTMLPart" ) )
	return;

    if ( !s_debug )
    {
	s_debug = new JsDebug;
	s_debug->ref();
    }

    hostobj.put(exec, "DebugOut", Object(s_debug));
}
예제 #13
0
void QFrameImp::addBindings( KJS::ExecState *exec, KJS::Object &object )
{
    //
    // Define the enum constants
    //
    struct EnumValue {
	const char *id;
	int val;
    };

    EnumValue enums[] = {

        // enum Shape
        { "NoFrame", QFrame::NoFrame },
        { "Box", QFrame::Box },
        { "Panel", QFrame::Panel },
        { "WinPanel", QFrame::WinPanel },
        { "HLine", QFrame::HLine },
        { "VLine", QFrame::VLine },
        { "StyledPanel", QFrame::StyledPanel },
        { "PopupPanel", QFrame::PopupPanel },
        { "MenuBarPanel", QFrame::MenuBarPanel },
        { "ToolBarPanel", QFrame::ToolBarPanel },
        { "LineEditPanel", QFrame::LineEditPanel },
        { "TabWidgetPanel", QFrame::TabWidgetPanel },
        { "GroupBoxPanel", QFrame::GroupBoxPanel },
        { "MShape", QFrame::MShape },
        // enum Shadow
        { "Plain", QFrame::Plain },
        { "Raised", QFrame::Raised },
        { "Sunken", QFrame::Sunken },
        { "MShadow", QFrame::MShadow },
	{ 0, 0 }
    };

    int enumidx = 0;
    do {
        object.put( exec, enums[enumidx].id, KJS::Number(enums[enumidx].val), KJS::ReadOnly );
        ++enumidx;
    } while( enums[enumidx].id );

}
    void JSObjectProxy::addBindings( KJS::ExecState *exec, KJS::Object &object ) {
        kdDebug( 80001 ) << "JSObjectProxy::addBindings() " << ( obj->name() ? obj->name() : "dunno" )
        << ", class " << obj->className() << endl;

        if ( policy->hasCapability( JSSecurityPolicy::CapabilityGetProperties | JSSecurityPolicy::CapabilitySetProperties ) ) {
            object.put( exec, "properties", KJS::Object( new JSObjectProxyImp( exec, JSObjectProxyImp::MethodProps, this ) ) );
        }

        if ( policy->hasCapability( JSSecurityPolicy::CapabilityTree ) ) {
            JSObjectProxyImp::addBindingsTree( exec, object, this );
            JSObjectProxyImp::addBindingsDOM( exec, object, this );
        }

        if ( policy->hasCapability( JSSecurityPolicy::CapabilitySlots ) ) {
            addBindingsSlots( exec, object );
            JSObjectProxyImp::addBindingsConnect( exec, object, this );
        }

        addBindingsClass( exec, object );
    }
예제 #15
0
void QDirImp::addBindings( KJS::ExecState *exec, KJS::Object &object )
{
    JSProxy::MethodTable methods[] = {

    { Method_setPath_7, "setPath" },

    { Method_path_8, "path" },

    { Method_absPath_9, "absPath" },

    { Method_canonicalPath_10, "canonicalPath" },

    { Method_dirName_11, "dirName" },

    { Method_filePath_12, "filePath" },

    { Method_absFilePath_13, "absFilePath" },

    { Method_cd_14, "cd" },

    { Method_cdUp_15, "cdUp" },

    { Method_nameFilter_16, "nameFilter" },

    { Method_setNameFilter_17, "setNameFilter" },

    { Method_filter_18, "filter" },

    { Method_setFilter_19, "setFilter" },

    { Method_sorting_20, "sorting" },

    { Method_setSorting_21, "setSorting" },

    { Method_matchAllDirs_22, "matchAllDirs" },

    { Method_setMatchAllDirs_23, "setMatchAllDirs" },

    { Method_count_24, "count" },

    { Method_encodedEntryList_26, "encodedEntryList" },

    { Method_encodedEntryList_27, "encodedEntryList" },

    { Method_entryList_28, "entryList" },

    { Method_entryList_29, "entryList" },

    { Method_entryInfoList_30, "entryInfoList" },

    { Method_entryInfoList_31, "entryInfoList" },

    { Method_mkdir_32, "mkdir" },

    { Method_rmdir_33, "rmdir" },

    { Method_isReadable_34, "isReadable" },

    { Method_exists_35, "exists" },

    { Method_isRoot_36, "isRoot" },

    { Method_isRelative_37, "isRelative" },

    { Method_convertToAbs_38, "convertToAbs" },

    { Method_remove_41, "remove" },

    { Method_rename_42, "rename" },

    { Method_exists_43, "exists" },

    { Method_refresh_44, "refresh" },

    { Method_convertSeparators_45, "convertSeparators" },

    { Method_drives_46, "drives" },

    { Method_separator_47, "separator" },

    { Method_setCurrent_48, "setCurrent" },

    { Method_current_49, "current" },

    { Method_home_50, "home" },

    { Method_root_51, "root" },

    { Method_currentDirPath_52, "currentDirPath" },

    { Method_homeDirPath_53, "homeDirPath" },

    { Method_rootDirPath_54, "rootDirPath" },

    { Method_match_55, "match" },

    { Method_match_56, "match" },

    { Method_cleanDirPath_57, "cleanDirPath" },

    { Method_isRelativePath_58, "isRelativePath" },

	{ 0, 0 }
    };

    int idx = 0;
    do {
        QDirImp *meth = new QDirImp( 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 FilterSpec
        { "Dirs", QDir::Dirs },
        { "Files", QDir::Files },
        { "Drives", QDir::Drives },
        { "NoSymLinks", QDir::NoSymLinks },
        { "All", QDir::All },
        { "TypeMask", QDir::TypeMask },
        { "Readable", QDir::Readable },
        { "Writable", QDir::Writable },
        { "Executable", QDir::Executable },
        { "RWEMask", QDir::RWEMask },
        { "Modified", QDir::Modified },
        { "Hidden", QDir::Hidden },
        { "System", QDir::System },
        { "AccessMask", QDir::AccessMask },
        { "DefaultFilter", QDir::DefaultFilter },
        // enum SortSpec
        { "Name", QDir::Name },
        { "Time", QDir::Time },
        { "Size", QDir::Size },
        { "Unsorted", QDir::Unsorted },
        { "SortByMask", QDir::SortByMask },
        { "DirsFirst", QDir::DirsFirst },
        { "Reversed", QDir::Reversed },
        { "IgnoreCase", QDir::IgnoreCase },
        { "DefaultSort", QDir::DefaultSort },
	{ 0, 0 }
    };

    int enumidx = 0;
    do {
        object.put( exec, enums[enumidx].id, KJS::Number(enums[enumidx].val), KJS::ReadOnly );
        ++enumidx;
    } while( enums[enumidx].id );

}
예제 #16
0
void KstBindPoint::addBindings(KJS::ExecState *exec, KJS::Object& obj) {
  for (int i = 0; pointBindings[i].name != 0L; ++i) {
    KJS::Object o = KJS::Object(new KstBindPoint(i + 1));
    obj.put(exec, pointBindings[i].name, o, KJS::Function);
  }
}
void KstBindTimeInterpretation::addBindings(KJS::ExecState *exec, KJS::Object& obj) {
  for (int i = 0; timeInterpretationBindings[i].name != 0L; ++i) {
    KJS::Object o = KJS::Object(new KstBindTimeInterpretation(i + 1));
    obj.put(exec, timeInterpretationBindings[i].name, o, KJS::Function);
  }
}