/** * \brief Returns the value of a boolean field of this entity. * \param key Key of the field to get. It must exist and be a boolean. * \return The boolean value. */ bool EntityData::get_boolean(const std::string& key) const { const auto& it = fields.find(key); Debug::check_assertion(it != fields.end(), "No such entity field in " + get_type_name() + ": '" + key + "'"); Debug::check_assertion(it->second.value_type == EntityFieldType::BOOLEAN, "Field '" + key + "' is not a boolean"); return it->second.int_value != 0; }
std::string get_type_name_parameter(GType gtype, GTypeIsAPointerFunc is_a_pointer_func) { std::string strTypeName = get_type_name(gtype, is_a_pointer_func); // All signal parameters that are registered as GTK_TYPE_STRING are actually const gchar*. if (strTypeName == "gchar*") strTypeName = "const-gchar*"; return strTypeName; }
/** * \brief Sets the value of a boolean field of this entity. * \param key Key of the field to set. It must exist and be a boolean. * \param value The boolean value. */ void EntityData::set_boolean(const std::string& key, bool value) { const auto& it = fields.find(key); Debug::check_assertion(it != fields.end(), "No such entity field in " + get_type_name() + ": '" + key + "'"); Debug::check_assertion(it->second.value_type == EntityFieldType::BOOLEAN, "Field '" + key + "' is not an boolean"); it->second.int_value = value ? 1 : 0; }
/** * \brief Sets the value of a string field of this entity. * \param key Key of the field to set. It must exist and be a string. * \param value The string value. */ void EntityData::set_string(const std::string& key, const std::string& value) { const auto& it = fields.find(key); Debug::check_assertion(it != fields.end(), "No such entity field in " + get_type_name() + ": '" + key + "'"); Debug::check_assertion(it->second.value_type == EntityFieldType::STRING, "Field '" + key + "' is not a string"); it->second.string_value = value; }
/** * \brief Returns the value of an integer field of this entity. * \param key Key of the field to get. It must exist and be an integer. * \return The integer value. */ int EntityData::get_integer(const std::string& key) const { const auto& it = fields.find(key); Debug::check_assertion(it != fields.end(), "No such entity field in " + get_type_name() + ": '" + key + "'"); Debug::check_assertion(it->second.value_type == EntityFieldType::INTEGER, "Field '" + key + "' is not a string"); return it->second.int_value; }
const char* QoreValue::getTypeName() const { switch (type) { case QV_Bool: return QoreBoolNode::getStaticTypeName(); case QV_Int: return QoreBigIntNode::getStaticTypeName(); case QV_Float: return QoreFloatNode::getStaticTypeName(); case QV_Node: return get_type_name(v.n); default: assert(false); // no break } return 0; }
void print_tree(ParseNode* root, int level) { int i; for(i = 0; i < level; ++i) printf(" "); if(root == 0) { printf("NULL\n"); return; } printf("%s", get_type_name(root->type_)); switch(root->type_) { case T_BOOL: if (root->value_ == 1) printf(" : TRUE\n"); else if (root->value_ == 0) printf(" : FALSE\n"); else printf(" : UNKNOWN\n"); break; case T_BINARY: printf(" : \\x"); for(i = 0; i < root->value_; ++i) { printf("%02x", (unsigned char)root->str_value_[i]); } printf("\n"); break; case T_INT: case T_FLOAT: case T_DOUBLE: case T_DECIMAL: case T_STRING: case T_DATE: case T_HINT: case T_IDENT: printf(" : %s\n", root->str_value_); break; case T_FUN_SYS: printf(" : %s\n", root->str_value_); break; default: printf("\n"); break; } for(i = 0; i < root->num_child_; ++i) { if (root->children_[i]) print_tree(root->children_[i], level+1); } }
bool TmsiAmplifier::_refreshInfo(int type) { int counter = 0; while (counter++ < 20) { send_request(type); if (br < 0 || tms_chk_msg(msg, br) != 0) fprintf(stderr, "Error while receiving message (%d)", br); else if (update_info(type)) return true; } fprintf(stderr, "Could not receive proper %s!!\n",get_type_name(type)); return false; }
void Object::get_signal_list(List<MethodInfo> *p_signals ) const { ObjectTypeDB::get_signal_list(get_type_name(),p_signals); //find maybe usersignals? const StringName *S=NULL; while((S=signal_map.next(S))) { if (signal_map[*S].user.name!="") { //user signal p_signals->push_back(signal_map[*S].user); } } }
int wpl_value_array::finalize_expression (wpl_expression_state *exp_state, wpl_value *last_value) { /* TODO Set array by discard chain? */ if ((get_flags() & wpl_value_do_finalize) && !set_strong (last_value)) { cerr << "While setting final result of type " << get_type_name() << " to array of type " << last_value->get_type_name() << ":\n"; throw runtime_error("Incompatible types"); } return WPL_OP_OK; }
void debug_cnt(const_object c) { printf("--DEBUGCNT-----------\n"); printf("> my_type: %s\n", get_type_name(c.my_type)); printf("> index: %d\n", c.index); printf("> value_i: %d\n", c.value_i); printf("> value_f: %f\n", c.value_f); printf("> value_c: %c\n", c.value_c); printf("> value_s: %s\n", c.value_s); printf("> value_b: %d\n", c.value_b); printf("-------------\n"); return; }
std::string use_function::get_name() const { switch( function_type ) { case USE_FUNCTION_CPP: return item_action_generator::generator().get_action_name( get_type_name() ); case USE_FUNCTION_ACTOR_PTR: return item_action_generator::generator().get_action_name( get_actor_ptr() ); case USE_FUNCTION_LUA: return "Lua"; case USE_FUNCTION_NONE: return "None"; default: debugmsg( "Tried to get type name of a badly typed iuse_function." ); return errstring; } }
void debug_var(var_object v) { printf("--DEBUGVAR-----------\n"); printf("> my_type: %s\n", get_type_name(v.my_type)); printf("> my_label: %s\n", v.my_label); printf("> index: %d\n", v.index); printf("> value_i: %d\n", v.value_i); printf("> value_f: %f\n", v.value_f); printf("> value_c: %c\n", v.value_c); printf("> value_s: %s\n", v.value_s); printf("> value_b: %d\n", v.value_b); printf("-------------\n"); return; }
std::ostream & operator << (std::ostream & out, const Stats & stats) { out << stats.filename << std::endl; unsigned int bad = 0; for (auto it = stats.reads.begin(); it != stats.reads.end(); ++it) { out << "\t" << get_type_name(it->first) << "\t" << it->second << std::endl; if (it->first != ReadType::ok) { bad += it->second; } } out << "\t" << "fraction " << (double)(stats.complete - bad)/stats.complete << std::endl; if (stats.pe) { out << "\t" << "se\t" << stats.se << std::endl; out << "\t" << "pe\t" << stats.pe << std::endl; } return out; }
/*Return a pointer to the internal error message, might be NULL. Caller should not release it.*/ const char* mono_error_get_message (MonoError *oerror) { MonoErrorInternal *error = (MonoErrorInternal*)oerror; if (error->error_code == MONO_ERROR_NONE) return NULL; if (error->full_message_with_fields) return error->full_message_with_fields; error->full_message_with_fields = g_strdup_printf ("%s assembly:%s type:%s member:%s", error->full_message, get_assembly_name (error), get_type_name (error), error->member_name ? error->member_name : "<none>"); return error->full_message_with_fields ? error->full_message_with_fields : error->full_message; }
static void *print_out_pointer(const char *prefix, void *p, GC_get_type_name_proc get_type_name, GC_print_tagged_value_proc print_tagged_value, int *_kind) { trace_page_t *page; const char *what; page = pagemap_find_page(GC_instance->page_maps, p); if (!page || (trace_page_type(page) == TRACE_PAGE_BAD)) { GCPRINT(GCOUTF, "%s%s %p\n", prefix, trace_source_kind(*_kind), p); return NULL; } p = trace_pointer_start(page, p); if ((trace_page_type(page) == TRACE_PAGE_TAGGED) || (trace_page_type(page) == TRACE_PAGE_PAIR)) { Type_Tag tag; tag = *(Type_Tag *)p; if ((tag >= 0) && get_type_name && get_type_name(tag)) { print_tagged_value(prefix, p, 0, 1000, "\n"); } else { GCPRINT(GCOUTF, "%s<#%d> %p\n", prefix, tag, p); } what = NULL; } else if (trace_page_type(page) == TRACE_PAGE_ARRAY) { what = "ARRAY"; } else if (trace_page_type(page) == TRACE_PAGE_ATOMIC) { what = "ATOMIC"; } else if (trace_page_type(page) == TRACE_PAGE_MALLOCFREE) { what = "MALLOCED"; } else { what = "?!?"; } if (what) { GCPRINT(GCOUTF, "%s%s%s %p\n", prefix, what, (trace_page_is_big(page) ? "b" : ""), p); } return trace_backpointer(page, p, _kind); }
void Object::call_multilevel(const StringName& p_method,const Variant** p_args,int p_argcount) { if (p_method==CoreStringNames::get_singleton()->_free) { #ifdef DEBUG_ENABLED if (cast_to<Reference>()) { ERR_EXPLAIN("Can't 'free' a reference."); ERR_FAIL(); return; } if (_lock_index.get()>1) { ERR_EXPLAIN("Object is locked and can't be freed."); ERR_FAIL(); return; } #endif //must be here, must be before everything, memdelete(this); return; } //Variant ret; OBJ_DEBUG_LOCK Variant::CallError error; if (script_instance) { script_instance->call_multilevel(p_method,p_args,p_argcount); //_test_call_error(p_method,error); } MethodBind *method=ObjectTypeDB::get_method(get_type_name(),p_method); if (method) { method->call(this,p_args,p_argcount,error); _test_call_error(p_method,error); } }
int print_rr_info(void *rr_info) { char tmp_addr[INET_ADDRSTRLEN]; RR_INFO *rr_info_p; assert(rr_info); rr_info_p = rr_info; printf("%s\t%s\t%s\t%d\t%s\n", rr_info_p->name, get_class_name(rr_info_p->rr_class), get_type_name(rr_info_p->type), rr_info_p->ttl, inet_ntop(AF_INET, &rr_info_p->data.ip4, tmp_addr, INET_ADDRSTRLEN) ); return RET_OK; }
bool Object::is_connected(const StringName& p_signal, Object *p_to_object, const StringName& p_to_method) const { ERR_FAIL_NULL_V(p_to_object,false); const Signal *s = signal_map.getptr(p_signal); if (!s) { bool signal_is_valid = ObjectTypeDB::has_signal(get_type_name(),p_signal); if (signal_is_valid) return false; ERR_EXPLAIN("Nonexistent signal: "+p_signal); ERR_FAIL_COND_V(!s,false); } Signal::Target target(p_to_object->get_instance_ID(),p_to_method); return s->slot_map.has(target); //const Map<Signal::Target,Signal::Slot>::Element *E = s->slot_map.find(target); //return (E!=NULL); }
Variant::Type Object::get_static_property_type(const StringName& p_property, bool *r_valid) const { bool valid; Variant::Type t = ObjectTypeDB::get_property_type(get_type_name(),p_property,&valid); if (valid) { if (r_valid) *r_valid=true; return t; } if (get_script_instance()) { return get_script_instance()->get_property_type(p_property,r_valid); } if (r_valid) *r_valid=false; return Variant::NIL; }
bool Object::has_method(const StringName& p_method) const { if (p_method==CoreStringNames::get_singleton()->_free) { return true; } if (script_instance && script_instance->has_method(p_method)) { return true; } MethodBind *method=ObjectTypeDB::get_method(get_type_name(),p_method); if (method) { return true; } return false; }
void ModelObject::validate_outputs() const { if (!get_has_dependencies()) return; IMP_IF_CHECK(USAGE_AND_INTERNAL) { IMP_CHECK_OBJECT(this); ModelObjectsTemp ret = do_get_outputs(); std::sort(ret.begin(), ret.end()); ret.erase(std::unique(ret.begin(), ret.end()), ret.end()); ModelObjectsTemp saved = get_model()->get_dependency_graph_outputs(this); std::sort(saved.begin(), saved.end()); ModelObjectsTemp intersection; std::set_intersection(saved.begin(), saved.end(), ret.begin(), ret.end(), std::back_inserter(intersection)); IMP_USAGE_CHECK( intersection.size() == ret.size(), "Dependencies changed without invalidating dependencies." << " Make sure you call set_has_dependencies(false) any " << "time the list of dependencies changed. Object is " << get_name() << " of type " << get_type_name()); } }
void print_tree(Node* p) { if(p==NULL)return; if(p->line==-1)return; depth++; for(int i=0;i<depth;i++) printf(" "); printf("%s",get_type_name(p->type)); if(p->type>_FLOAT) printf(" (%d)",p->line); else if(p->type==_ID || p->type==_TYPE) printf(": %s",p->name); else if(p->type==_INT) printf(": %d",p->value_i); else if(p->type==_FLOAT) printf(": %f",p->value_f); printf("\n"); for(int i=0;i<p->child_count;i++) print_tree(p->child[i]); depth--; }
static void add_new_files (gpointer key, gpointer value, gpointer data) { glibtop_open_files_entry *openfiles = static_cast<glibtop_open_files_entry*>(value); GtkTreeModel *model = static_cast<GtkTreeModel*>(data); GtkTreeIter row; char *object; switch(openfiles->type) { case GLIBTOP_FILE_TYPE_FILE: object = g_strdup(openfiles->info.file.name); break; case GLIBTOP_FILE_TYPE_INET6SOCKET: case GLIBTOP_FILE_TYPE_INETSOCKET: object = friendlier_hostname(openfiles->info.sock.dest_host, openfiles->info.sock.dest_port); break; case GLIBTOP_FILE_TYPE_LOCALSOCKET: object = g_strdup(openfiles->info.localsock.name); break; default: object = g_strdup(""); } gtk_list_store_insert (GTK_LIST_STORE (model), &row, 0); gtk_list_store_set (GTK_LIST_STORE (model), &row, COL_FD, openfiles->fd, COL_TYPE, get_type_name(static_cast<glibtop_file_type>(openfiles->type)), COL_OBJECT, object, COL_OPENFILE_STRUCT, g_memdup(openfiles, sizeof(*openfiles)), -1); g_free(object); }
ExprPtr IoBlock::call(ArgList args, std::size_t num_args) { if (!empty()) { char const* errorPoint = "before eval"; IoMessage* m; try { m = new_message(io_target, "IoBlock"); errorPoint = "while adding args"; for (int i = 0; i < num_args; ++i) add_arg(m, args[i]); errorPoint = "on activate"; IoObject* io_obj = activate(m); errorPoint = "create IoObjectExpr"; TypeIndex from_type = FromIoTypeInfo::create_index(get_type_name(io_obj)); if (type_system->has_type(from_type)) return create_expr(io_obj, from_type); else return Term<IoObject*>::create(io_obj); } catch (Iocaste::ScriptException const& exc) { // TODO: assoc addn'l info w/exp. throw; } // TODO: Create LikeMagic exception object. catch (std::exception const& e) { throw Iocaste::IoStateError(io_block, std::string() + "Error in IoBlock " + errorPoint + ": " + e.what(), m); } } else { throw std::logic_error("Tried to eval an empty block."); } }
Error Object::connect(const StringName& p_signal, Object *p_to_object, const StringName& p_to_method,const Vector<Variant>& p_binds,uint32_t p_flags) { ERR_FAIL_NULL_V(p_to_object,ERR_INVALID_PARAMETER); Signal *s = signal_map.getptr(p_signal); if (!s) { bool signal_is_valid = ObjectTypeDB::has_signal(get_type_name(),p_signal); //check in script if (!signal_is_valid && !script.is_null() && Ref<Script>(script)->has_script_signal(p_signal)) signal_is_valid=true; if (!signal_is_valid) { ERR_EXPLAIN("In Object of type '"+String(get_type())+"': Attempt to connect nonexistent signal '"+p_signal+"' to method '"+p_to_object->get_type()+"."+p_to_method+"'"); ERR_FAIL_COND_V(!signal_is_valid,ERR_INVALID_PARAMETER); } signal_map[p_signal]=Signal(); s=&signal_map[p_signal]; } Signal::Target target(p_to_object->get_instance_ID(),p_to_method); if (s->slot_map.has(target)) { ERR_EXPLAIN("Signal '"+p_signal+"'' already connected to given method '"+p_to_method+"' in that object."); ERR_FAIL_COND_V(s->slot_map.has(target),ERR_INVALID_PARAMETER); } Signal::Slot slot; Connection conn; conn.source=this; conn.target=p_to_object; conn.method=p_to_method; conn.signal=p_signal; conn.flags=p_flags; conn.binds=p_binds; slot.conn=conn; slot.cE=p_to_object->connections.push_back(conn); s->slot_map[target]=slot; return OK; }
inline std::string demangle(const std::type_info& id) { std::string realname = get_type_name(id); const static std::array<std::string, 2> removals = {{ "struct ", "class " }}; const static std::array<std::string, 2> replacements = {{ "::", "_" }}; for(std::size_t r = 0; r < removals.size(); ++r) { auto found = realname.find(removals[r]); while(found != std::string::npos) { realname.erase(found, removals[r].size()); found = realname.find(removals[r]); } } for(std::size_t r = 0; r < replacements.size(); r+=2) { auto found = realname.find(replacements[r]); while(found != std::string::npos) { realname.replace(found, replacements[r].size(), replacements[r + 1]); found = realname.find(replacements[r], found); } } return realname; }
static runall_result invoke_test_main() { runall_result result; try { // Make sure the DMF doesn't use exit() set_require_device_behavior(false /*exit_on_no_device*/); result = test_main(); } catch(amptest_skip e) { Log(LogType::Warning) << e.what() << std::endl; result = runall_skip; } catch(amptest_cascade_failure e) { Log(LogType::Error) << e.what() << std::endl; result = runall_cascade_fail; } catch(amptest_failure e) { Log(LogType::Error) << e.what() << std::endl; result = runall_fail; } catch(const amptest_exception& e) { Log(LogType::Error) << "test_main() threw unhandled " << get_type_name(e) << " exception: " << e.what() << std::endl; result = runall_fail; } Log() << "test_main(): Returned " << result << std::endl; return result; }
void GstPropertiesModule::append_property(const std::shared_ptr<GValueBase>& value_base, const std::string &prop_name) { auto e = std::dynamic_pointer_cast<ElementModel>(controller->get_selected_object()); if (!e) return; auto klass = controller->get_klass(e->get_type_name()); if (!klass) return; auto prop = klass.get().get_property(prop_name); if (!prop) return; Gtk::Box *hbox = new Gtk::Box (Gtk::ORIENTATION_HORIZONTAL, 0); hbox->set_data("property-name", g_strdup (prop_name.c_str()), g_free); Gtk::Label *lbl = Gtk::manage(new Gtk::Label(prop_name)); lbl->set_tooltip_text(prop->get_blurb()); Gtk::Button *btn = Gtk::manage(new Gtk::Button("Refresh")); btn->signal_clicked().connect([this, prop_name] {request_selected_element_property(prop_name);}); hbox->pack_start(*lbl, false, false); auto value_widget = value_base->get_widget(); value_base->set_sensitive(prop.get().get_flags() & G_PARAM_WRITABLE); hbox->pack_start(*value_widget, true, true); hbox->pack_start(*btn, false, false); properties_box->pack_start(*hbox); hbox->show_all(); }
static void list_drives (GList *drives, int indent) { GList *volumes, *l; int c, i; GDrive *drive; char *name; char **ids; GIcon *icon; char *type_name; const gchar *sort_key; for (c = 0, l = drives; l != NULL; l = l->next, c++) { drive = (GDrive *) l->data; name = g_drive_get_name (drive); g_print ("%*sDrive(%d): %s\n", indent, "", c, name); g_free (name); type_name = get_type_name (drive); g_print ("%*sType: %s\n", indent+2, "", type_name); g_free (type_name); if (extra_detail) { GEnumValue *enum_value; gpointer klass; ids = g_drive_enumerate_identifiers (drive); if (ids && ids[0] != NULL) { g_print ("%*sids:\n", indent+2, ""); for (i = 0; ids[i] != NULL; i++) { char *id = g_drive_get_identifier (drive, ids[i]); g_print ("%*s %s: '%s'\n", indent+2, "", ids[i], id); g_free (id); } } g_strfreev (ids); icon = g_drive_get_icon (drive); if (icon) { if (G_IS_THEMED_ICON (icon)) show_themed_icon_names (G_THEMED_ICON (icon), indent + 2); g_object_unref (icon); } g_print ("%*sis_media_removable=%d\n", indent + 2, "", g_drive_is_media_removable (drive)); g_print ("%*shas_media=%d\n", indent + 2, "", g_drive_has_media (drive)); g_print ("%*sis_media_check_automatic=%d\n", indent + 2, "", g_drive_is_media_check_automatic (drive)); g_print ("%*scan_poll_for_media=%d\n", indent + 2, "", g_drive_can_poll_for_media (drive)); g_print ("%*scan_eject=%d\n", indent + 2, "", g_drive_can_eject (drive)); g_print ("%*scan_start=%d\n", indent + 2, "", g_drive_can_start (drive)); g_print ("%*scan_stop=%d\n", indent + 2, "", g_drive_can_stop (drive)); enum_value = NULL; klass = g_type_class_ref (G_TYPE_DRIVE_START_STOP_TYPE); if (klass != NULL) { enum_value = g_enum_get_value (klass, g_drive_get_start_stop_type (drive)); g_print ("%*sstart_stop_type=%s\n", indent + 2, "", enum_value != NULL ? enum_value->value_nick : "UNKNOWN"); g_type_class_unref (klass); } sort_key = g_drive_get_sort_key (drive); if (sort_key != NULL) g_print ("%*ssort_key=%s\n", indent + 2, "", sort_key); } volumes = g_drive_get_volumes (drive); list_volumes (volumes, indent + 2, FALSE); g_list_foreach (volumes, (GFunc)g_object_unref, NULL); g_list_free (volumes); } }