예제 #1
0
 external_relation * external_relation::complement(func_decl* p) const {
     ast_manager& m = m_rel.get_manager();
     family_id fid = get_plugin().get_family_id();
     expr_ref res(m);
     expr* rel = m_rel;
     func_decl_ref fn(m.mk_func_decl(fid, OP_RA_COMPLEMENT,0,0, 1, &rel), m);
     get_plugin().reduce(fn, 1, &rel, res);
     return alloc(external_relation, get_plugin(), get_signature(), res);
 }
예제 #2
0
 external_relation * external_relation::clone() const {
     ast_manager& m = m_rel.get_manager();
     family_id fid = get_plugin().get_family_id();
     expr* rel = m_rel.get();
     expr_ref res(m.mk_fresh_const("T", m.get_sort(rel)), m);
     expr* rel_out = res.get();
     func_decl_ref fn(m.mk_func_decl(fid, OP_RA_CLONE,0,0, 1, &rel), m);
     get_plugin().reduce_assign(fn, 1, &rel, 1, &rel_out);
     return alloc(external_relation, get_plugin(), get_signature(), res);
 }
예제 #3
0
 bool external_relation::empty() const {
     ast_manager& m = m_rel.get_manager();
     expr* r = m_rel.get();
     expr_ref res(m);
     if (!m_is_empty_fn.get()) {
         family_id fid = get_plugin().get_family_id();
         const_cast<func_decl_ref&>(m_is_empty_fn) = m.mk_func_decl(fid, OP_RA_IS_EMPTY, 0, 0, 1, &r);
     }
     get_plugin().reduce(m_is_empty_fn, 1, &r, res);
     return m.is_true(res);
 }
예제 #4
0
void ItemList::init_actions()
{
    PasspotPlugin *plugin = dynamic_cast<PasspotPlugin*>(get_plugin().pointer());
    assert(NULL != plugin);

    // add article
    _new_action = new QAction(plugin->load_icon("passpot/add_item"), tr("添加(&A)"), this);
    _new_action->setStatusTip(tr("添加新记录"));
    _new_action->setToolTip(tr("添加新记录"));
    connect(_new_action, SIGNAL(triggered()), this, SLOT(add_item()));

    _edit_action = new QAction(plugin->load_icon("passpot/edit_item"), tr("编辑(&E)"), this);
    _edit_action->setStatusTip(tr("编辑当前记录"));
    _edit_action->setToolTip(tr("编辑当前记录"));
    connect(_edit_action, SIGNAL(triggered()), this, SLOT(edit_item()));

    _move_to_trash_action = new QAction(plugin->load_icon("passpot/move_to_trash"), tr("移动到回收站(&T)"), this);
    _move_to_trash_action->setStatusTip(tr("将当前记录移动到回收站"));
    _move_to_trash_action->setToolTip(tr("将当前记录移动到回收站"));
    connect(_move_to_trash_action, SIGNAL(triggered()), this, SLOT(move_to_trash()));

    // delete article
    _delete_action = new QAction(plugin->load_icon("passpot/delete"), tr("删除(&D)"), this);
    _delete_action->setStatusTip(tr("永久删除当前记录"));
    _delete_action->setToolTip(tr("永久删除当前记录"));
    connect(_delete_action, SIGNAL(triggered()), this, SLOT(delete_item()));
}
예제 #5
0
void ItemList::tick_clipboard()
{
    PasspotPlugin *plugin = dynamic_cast<PasspotPlugin*>(get_plugin().pointer());
    assert(NULL != plugin);
    QClipboard *board = QApplication::clipboard();
    assert(NULL != board);

    const bool clipboard_changed = (_clipboard_hash != hash(board->text()));
    --_clipboard_countdown;
    if (!clipboard_changed && _clipboard_countdown > 0)
    {
        QString msg = _clipboard_status + QString(tr(" %1秒")).arg(_clipboard_countdown);
        plugin->show_status(msg, _clipboard_countdown * 1000);
        return;
    }

    if (clipboard_changed)
    {
        plugin->show_status(tr("剪贴板已经被覆盖"), 5000);
    }
    else
    {
        board->setText(QString());
        plugin->show_status(tr("剪贴板已经被清空"), 5000);
    }
    _clipboard_hash = 0;
    _clipboard_countdown = 0;
    _clipboard_status.clear();
    if (NULL != _clipboard_timer)
        _clipboard_timer->stop();
}
예제 #6
0
 udoc_relation * udoc_relation::clone() const {
     udoc_relation* result = udoc_plugin::get(get_plugin().mk_empty(get_signature()));
     for (unsigned i = 0; i < m_elems.size(); ++i) {
         result->m_elems.push_back(dm.allocate(m_elems[i]));
     }
     return result;
 }
예제 #7
0
파일: conf.c 프로젝트: donington/cwiid
int conf_plugin_button(struct conf *conf, const char *name, const char *button,
                       __u16 action)
{
	struct plugin *plugin;
	int i;
	unsigned char button_found = 0;

	if ((plugin = get_plugin(conf, name)) == NULL) {
		return -1;
	}

	for (i=0; i < plugin->info->button_count; i++) {
		if (!strcmp(plugin->info->button_info[i].name, button)) {
			button_found = 1;
			break;
		}
	}

	if (!button_found) {
		wminput_err("Invalid plugin button: %s.%s", name, button);
		return -1;
	}
	else {
		plugin->bmap[i].active = 1;
		plugin->bmap[i].action = action;
	}

	return 0;
}
예제 #8
0
void BIK_execute_tree(struct Scene *scene, Object *ob, bPoseChannel *pchan, float ctime) 
{
	IKPlugin *plugin = get_plugin(ob->pose);

	if (plugin && plugin->execute_tree_func)
		plugin->execute_tree_func(scene, ob, pchan, ctime);
}
예제 #9
0
void BIK_initialize_tree(Scene *scene, Object *ob, float ctime) 
{
	IKPlugin *plugin = get_plugin(ob->pose);

	if (plugin && plugin->initialize_tree_func)
		plugin->initialize_tree_func(scene, ob, ctime);
}
예제 #10
0
void BIK_test_constraint(struct Object *ob, struct bConstraint *cons)
{
	IKPlugin *plugin = get_plugin(ob->pose);

	if (plugin && plugin->test_constraint)
		plugin->test_constraint(ob, cons);
}
예제 #11
0
void BIK_update_param(struct bPose *pose)
{
	IKPlugin *plugin = get_plugin(pose);

	if (plugin && plugin->update_param)
		plugin->update_param(pose);
}
예제 #12
0
void BIK_clear_cache(struct bPose *pose)
{
	IKPlugin *plugin = get_plugin(pose);

	if (plugin && plugin->clear_cache)
		plugin->clear_cache(pose);
}
예제 #13
0
void BIK_clear_data(struct bPose *pose)
{
	IKPlugin *plugin = get_plugin(pose);

	if (plugin && plugin->remove_armature_func)
		plugin->remove_armature_func(pose);
}
예제 #14
0
void BIK_release_tree(struct Scene *scene, Object *ob, float ctime) 
{
	IKPlugin *plugin = get_plugin(ob->pose);

	if (plugin && plugin->release_tree_func)
		plugin->release_tree_func(scene, ob, ctime);
}
예제 #15
0
void DirectoryTree::init_actions()
{
    PkmPlugin *plugin = dynamic_cast<PkmPlugin*>(get_plugin().pointer());
    assert(NULL != plugin);

    // rename directory
    _rename_action = new QAction(plugin->load_icon("pkm/rename"), tr("重命名(&R)"), this);
    _rename_action->setStatusTip(tr("重命名当前目录"));
    _rename_action->setToolTip(tr("重命名当前目录"));
    connect(_rename_action, SIGNAL(triggered()), this, SLOT(rename_directory()));

    // add brother
    _add_brother_action = new QAction(plugin->load_icon("pkm/add_brother"), tr("添加兄弟节点(&A)"), this);
    _add_brother_action->setStatusTip(tr("为当前目录添加一个兄弟节点"));
    _add_brother_action->setToolTip(tr("为当前目录添加一个兄弟节点"));
    connect(_add_brother_action, SIGNAL(triggered()), this, SLOT(add_brother()));

    // add child
    _add_child_action = new QAction(plugin->load_icon("pkm/add_child"), tr("添加子节点(&A)"), this);
    _add_child_action->setStatusTip(tr("为当前目录添加一个子节点"));
    _add_child_action->setToolTip(tr("为当前目录添加一个子节点"));
    connect(_add_child_action, SIGNAL(triggered()), this, SLOT(add_child()));

    // delete
    _delete_action = new QAction(plugin->load_icon("pkm/delete"), tr("删除(&D)"), this);
    _delete_action->setStatusTip(tr("删除当前目录"));
    _delete_action->setToolTip(tr("删除当前目录"));
    connect(_delete_action, SIGNAL(triggered()), this, SLOT(delete_directory()));

    // import
    _import_action = new QAction(plugin->load_icon("pkm/import_files"), tr("导入"), this);
    _import_action->setStatusTip(tr("导入本地文件"));
    _import_action->setToolTip(tr("导入本地文件"));
    connect(_import_action, SIGNAL(triggered()), this, SLOT(import_from_files()));
}
예제 #16
0
파일: conf.c 프로젝트: donington/cwiid
int conf_plugin_axis(struct conf *conf, const char *name, const char *axis,
                     __u16 axis_type, __u16 action, char flags)
{
	struct plugin *plugin;
	int i;
	unsigned char axis_found = 0;
	unsigned char mismatch = 0;

	if ((plugin = get_plugin(conf, name)) == NULL) {
		return -1;
	}

	for (i=0; i < plugin->info->axis_count; i++) {
		if (!strcmp(plugin->info->axis_info[i].name, axis)) {
			axis_found = 1;
			break;
		}
	}

	if (!axis_found) {
		wminput_err("Invalid plugin axis: %s.%s", name, axis);
		return -1;
	}

	switch (axis_type) {
	case CONF_ABS:
		if (!(plugin->info->axis_info[i].type & WMPLUGIN_ABS)) {
			mismatch = 1;
		}
		break;
	case CONF_REL:
		if (!(plugin->info->axis_info[i].type & WMPLUGIN_REL)) {
			mismatch = 1;
		}
		break;
	}
	if (mismatch) {
		wminput_err("Warning: axis type mismatch - %s.%s", name, axis);
	}

	plugin->amap[i].active = 1;
	plugin->amap[i].axis_type = axis_type;
	plugin->amap[i].action = action;
	plugin->amap[i].flags = flags;

	if (axis_type == EV_ABS) {
		if (!(conf->dev.absmax[action] == -1) ||
		  !(conf->dev.absmin[action] == -1)) {
			wminput_err("Warning: duplicate absolute axis assignment");
		}

		conf->dev.absmax[action] = plugin->info->axis_info[i].max;
		conf->dev.absmin[action] = plugin->info->axis_info[i].min;
		conf->dev.absfuzz[action] = plugin->info->axis_info[i].fuzz;
		conf->dev.absflat[action] = plugin->info->axis_info[i].flat;
	}

	return 0;
}
예제 #17
0
 void relation_base::reset() {
     ast_manager & m = get_plugin().get_ast_manager();
     app_ref bottom_ref(m.mk_false(), m);
     scoped_ptr<relation_mutator_fn> reset_fn = get_manager().mk_filter_interpreted_fn(*this, bottom_ref);
     if(!reset_fn) {
         NOT_IMPLEMENTED_YET();
     }
     (*reset_fn)(*this);
 }
예제 #18
0
 void external_relation::mk_accessor(decl_kind k, func_decl_ref& fn, const relation_fact& f, bool destructive, expr_ref& res) const {
     ast_manager& m = m_rel.get_manager();
     family_id fid = get_plugin().get_family_id();
     ptr_vector<expr> args;
     args.push_back(m_rel);
     for (unsigned i = 0; i < f.size(); ++i) {
         args.push_back(f[i]);
     }
     if (!fn.get()) {
        fn = m.mk_func_decl(fid, k, 0, 0, args.size(), args.c_ptr());
     }        
     if (destructive) {
         get_plugin().reduce_assign(fn, args.size(), args.c_ptr(), 1, args.c_ptr());
         res = m_rel;
     }
     else {
         get_plugin().reduce(fn, args.size(), args.c_ptr(), res);
     }
 }
예제 #19
0
 expr_ref udoc_relation::to_formula(doc const& d) const {
     ast_manager& m = get_plugin().get_ast_manager();
     expr_ref result(m);
     expr_ref_vector conjs(m);
     conjs.push_back(to_formula(d.pos()));
     for (unsigned i = 0; i < d.neg().size(); ++i) {
         conjs.push_back(m.mk_not(to_formula(d.neg()[i])));
     }
     result = mk_and(m, conjs.size(), conjs.c_ptr());
     return result;
 }
예제 #20
0
void DirectoryTree::on_item_activated(const QModelIndex& index)
{
    if (!index.isValid())
        return;

    DirectoryItem *p = static_cast<DirectoryItem*>(index.internalPointer());
    assert(NULL != p);

    PkmPlugin *plugin = dynamic_cast<PkmPlugin*>(get_plugin().pointer());
    assert(NULL != plugin);
    plugin->directory_activated(p->get_id(), p->get_name());
}
예제 #21
0
 void unite_with_data(const relation_fact & f) {
     if (empty()) {
         assign_data(f);
         return;
     }
     unsigned n=get_signature().size();
     SASSERT(f.size()==n);
     for (unsigned i=0; i<n; i++) {
         SASSERT(!is_undefined(i));
         m_data[i] = get_plugin().mk_union(m_data[i], f[i]);
     }
 }
예제 #22
0
파일: plugins.c 프로젝트: ikrabbe/nyx
plugin_repository_t *
discover_plugins(const char *directory, hash_t *config)
{
    plugin_repository_t *repo = NULL;

    if (directory == NULL || *directory == '\0')
        return NULL;

    log_debug("Searching plugin directory '%s'", directory);

    DIR *dir = opendir(directory);
    if (dir)
    {
        repo = plugin_repository_new(config);

        struct dirent *entry = NULL;
        while ((entry = readdir(dir)) != NULL)
        {
            const char *plugin_name = get_plugin(entry->d_name);
            if (!plugin_name)
                continue;

            log_debug("Found plugin '%s'", plugin_name);

            plugin_t *plugin = init_plugin(directory, plugin_name, repo->manager);

            /* plugin initialization failed */
            if (plugin == NULL)
            {
                log_warn("Failed to load plugin '%s'", plugin_name);
                free((void *)plugin_name);
            }
            else
            {
                list_add(repo->plugins, plugin);
                log_info("Successfully loaded plugin '%s'", plugin_name);
            }
        }

        closedir(dir);

        /* we can immediately release the whole plugin repository
         * in case we could not initialize at least one plugin */
        if (list_size(repo->plugins) < 1)
        {
            plugin_repository_destroy(repo);
            repo = NULL;
        }
    }

    return repo;
}
예제 #23
0
ArticleToolTip::ArticleToolTip()
    : QWidget(NULL, Qt::ToolTip)
{
    PkmPlugin *plugin = dynamic_cast<PkmPlugin*>(get_plugin().pointer());
    _db = plugin->get_data_source()->get_db();

    _ui.setupUi(this);

    // 进一步设置
    setPalette(QToolTip::palette());
    setWindowOpacity(style()->styleHint(QStyle::SH_ToolTipLabel_Opacity, 0, this) / 255.0);
    layout()->setMargin(style()->pixelMetric(QStyle::PM_ToolTipLabelFrameWidth, 0, this));
}
예제 #24
0
void ArticleToolTip::hyperlink_act(const QString &s)
{
    rc_ptr<Bundle> info = _db->get_article_info(_article_id);
    if (info.is_null())
        return;

    if (s == "locatePath")
    {
        PkmPlugin *plugin = dynamic_cast<PkmPlugin*>(get_plugin().pointer());
        const int did = info->get_value<int>("DirectoryId");
        plugin->locate_directory(did);
    }
}
예제 #25
0
 doc* udoc_relation::fact2doc(const relation_fact & f) const {
     doc* d = dm.allocate0();
     for (unsigned i = 0; i < f.size(); ++i) {
         unsigned bv_size;
         rational val;
         VERIFY(get_plugin().is_numeral(f[i], val, bv_size));
         SASSERT(bv_size == column_num_bits(i));
         unsigned lo = column_idx(i);
         unsigned hi = column_idx(i + 1);
         dm.tbvm().set(d->pos(),val, hi-1, lo);
     }
     return d;
 }
예제 #26
0
 void sieve_relation::to_formula(expr_ref& fml) const {
     ast_manager& m = fml.get_manager();
     expr_ref_vector s(m);
     expr_ref tmp(m);
     relation_signature const& sig = get_inner().get_signature();
     unsigned sz = sig.size();
     for (unsigned i = sz ; i > 0; ) {
         --i;
         unsigned idx = m_inner2sig[i];
         s.push_back(m.mk_var(idx, sig[i]));
     }
     get_inner().to_formula(tmp);
     get_plugin().get_context().get_var_subst()(tmp, sz, s.c_ptr(), fml);
 }
예제 #27
0
파일: dl_base.cpp 프로젝트: Jornason/z3
    table_base * table_base::clone() const {
        table_base * res = get_plugin().mk_empty(get_signature());

        iterator it = begin();
        iterator iend = end();

        table_fact row;

        for(; it!=iend; ++it) {
            it->get_fact(row);
            res->add_new_fact(row);
        }
        return res;
    }
예제 #28
0
bool_t playlist_save (int list, const char * filename)
{
    AUDDBG ("Saving playlist %s.\n", filename);

    PluginHandle * plugin = get_plugin (filename, TRUE);
    if (! plugin)
        return FALSE;

    PlaylistPlugin * pp = plugin_get_header (plugin);
    g_return_val_if_fail (pp && PLUGIN_HAS_FUNC (pp, load), FALSE);

    bool_t fast = get_bool (NULL, "metadata_on_play");

    VFSFile * file = vfs_fopen (filename, "w");
    if (! file)
        return FALSE;

    char * title = playlist_get_title (list);

    int entries = playlist_entry_count (list);
    Index * filenames = index_new ();
    index_allocate (filenames, entries);
    Index * tuples = index_new ();
    index_allocate (tuples, entries);

    for (int i = 0; i < entries; i ++)
    {
        index_append (filenames, playlist_entry_get_filename (list, i));
        index_append (tuples, playlist_entry_get_tuple (list, i, fast));
    }

    bool_t success = pp->save (filename, file, title, filenames, tuples);

    vfs_fclose (file);
    str_unref (title);

    for (int i = 0; i < entries; i ++)
    {
        str_unref (index_get (filenames, i));
        Tuple * tuple = index_get (tuples, i);
        if (tuple)
            tuple_unref (tuple);
    }

    index_free (filenames);
    index_free (tuples);

    return success;
}
예제 #29
0
 expr_ref udoc_relation::to_formula(tbv const& t) const {
     udoc_plugin& p = get_plugin();
     ast_manager& m = p.get_ast_manager();
     expr_ref result(m);
     expr_ref_vector conjs(m);
     for (unsigned i = 0; i < get_num_cols(); ++i) {
         var_ref v(m);
         v = m.mk_var(i, get_signature()[i]);
         unsigned lo = column_idx(i);
         unsigned hi = column_idx(i+1);
         rational r(0);
         unsigned lo1 = lo;
         bool is_x = true;
         for (unsigned j = lo; j < hi; ++j) {
             switch(t[j]) {
             case BIT_0:
                 if (is_x) is_x = false, lo1 = j, r.reset();
                 break;
             case BIT_1:
                 if (is_x) is_x = false, lo1 = j, r.reset();
                 r += rational::power_of_two(j - lo1);
                 break;
             case BIT_x:
                 if (!is_x) {
                     SASSERT(p.bv.is_bv_sort(get_signature()[i]));
                     conjs.push_back(m.mk_eq(p.bv.mk_extract(j-1-lo,lo1-lo,v),
                                             p.bv.mk_numeral(r,j-lo1)));
                 }
                 is_x = true;
                 break;
             default:
                 UNREACHABLE();
             }
         }
         if (!is_x) {
             expr_ref num(m);
             if (lo1 == lo) {
                 num = p.mk_numeral(r, get_signature()[i]);
                 conjs.push_back(m.mk_eq(v, num));
             }
             else {
                 num = p.bv.mk_numeral(r, hi-lo1);
                 conjs.push_back(m.mk_eq(p.bv.mk_extract(hi-1-lo,lo1-lo,v), num));
             }
         }
     }
     result = mk_and(m, conjs.size(), conjs.c_ptr());
     return result;
 }
예제 #30
0
void DirectoryTree::import_from_files()
{
    QModelIndexList ids = selectionModel()->selectedIndexes();
    if (ids.size() == 0)
        return;
    QModelIndex index = ids.at(0);
    if (!index.isValid())
        return;

    // 弹出对话框
    QStringList files = QFileDialog::getOpenFileNames(this,
        tr("打开文件"),
        QString::fromLocal8Bit(_last_visited_dir.data(), _last_visited_dir.length()),
        "Text file (*.txt)");
    const size_t size = files.size();
    if (size == 0)
        return;

    DirectoryTreeModel *m = dynamic_cast<DirectoryTreeModel*>(model());
    assert(NULL != m);
    for (size_t i = 0; i < size; ++i)
    {
        const QString& file = files.at(i);

        // get title
        string dir, name;
        Path::split(file.toLocal8Bit(), &dir, &name);
        if (!ends_with(name.c_str(), ".txt") && !ends_with(name.c_str(), ".TXT"))
            continue;
        string title;
        Path::split_ext(name.c_str(), &title, NULL);
        _last_visited_dir = dir;

        // get content
        QString all = read_text_file(file);
        all = convert_txt_to_html(all);

        // insert to db
        m->insert_article(index, QString::fromLocal8Bit(title.data(), title.length()),
                          MIME_PKM_RICHTEXT, all);
    }

    // 发送通知
    DirectoryItem *p = static_cast<DirectoryItem*>(index.internalPointer());
    assert(NULL != p);
    PkmPlugin *plugin = dynamic_cast<PkmPlugin*>(get_plugin().pointer());
    plugin->directory_activated(p->get_id(), p->get_name());
}