void buckets_hashmasks_update(node_t *node, hash_t hashmask, int level) { assert(node); assert(level == 0 || level == 1); // verify that the hash provided actually describes a bucket. assert((hashmask & _mask) == hashmask); if (level == 0) { _buckets[hashmask]->primary_node = node; logger(LOG_DEBUG, "Setting HASHMASK: Primary [%#llx] = '%s'", hashmask, node_name(node) ); } else if (level == 1) { _buckets[hashmask]->secondary_node = node; logger(LOG_DEBUG, "Setting HASHMASK: Secondary [%#llx] = '%s'", hashmask, node_name(node) ); } else { assert(0); } }
/** * Try to make the new node into a parent of the tree-node n. The problem * here is that we must include any siblings of n in r if they fit. * @param n the node above which to add the parent * @param r the new unattached node */ static void dom_make_parent( dom *d, node *n, node *r ) { node *parent = node_parent(n); node *prev = node_prec_sibling( n ); if ( parent==NULL ) printf("parent is NULL\n"); //fprintf( stderr,"n: %s %d:%d; r %s %d:%d\n",node_name(n),node_offset(n), // node_end(n),node_name(r),node_offset(r),node_end(r)); //node_debug_check_siblings( node_first_child(parent) ); while ( n != NULL && !node_follows(r,n) ) { node *next = node_next_sibling(n); if ( dom_nests(d,node_name(n),node_name(r)) ) { if ( range_encloses_node(n,r) || range_equals_node(n,r) ) { node_detach_sibling( n, prev ); node_add_child( r, n ); if ( node_overlaps_on_right(parent,r) ) { node_split( r, node_end(parent) ); node *r2 = node_next_sibling( r ); node_detach_sibling( r, NULL ); dom_store_range( d, node_to_range(r2) ); node_dispose( r2 ); } } else if ( node_overlaps_on_left(n,r) ) { node_split( n, node_end(r) ); node_detach_sibling( n, prev ); node_add_child( r, n ); break; } else break; } else { // split off the rest of r and and push it back // Q: what happens to r?? node *r2; node_split( r, node_offset(n) ); r2 = node_next_sibling( r ); node_detach_sibling( r, NULL ); dom_store_range( d, node_to_range(r2) ); //queue_push( d->q, node_to_range(r2) ); node_dispose( r2 ); break; } n = next; if ( n != NULL ) prev = node_prec_sibling( n ); } // make n's original parent the parent of r node_add_child( parent, r ); // node_debug_check_siblings( node_first_child(parent) ); }
/** * Handle the case where node and range are equal * @param d the dom in question * @param n the tree-node already there * @param r the interloper barging in */ static void dom_node_equals( dom *d, node *n, node *r ) { if ( dom_mostly_nests(d,node_name(r),node_name(n)) ) dom_make_child( d, n, r ); else if ( dom_nests(d,node_name(n),node_name(r)) ) dom_make_parent( d, n, r ); else dom_drop_notify( d, r, n ); }
/** * Handle the case where the node is properly inside the range * @param d the dom in question * @param n the node we are comparing the range to * @param r the (ex-)range in question */ static void dom_node_inside_range( dom *d, node *n, node *r ) { if ( dom_nests(d,node_name(n),node_name(r)) ) dom_make_parent( d, n, r ); else if ( dom_nests(d,node_name(r),node_name(n)) ) dom_breakup_range( d, n, r ); else // neither fits inside the other dom_drop_notify(d, r, n ); }
static void write_edge(FILE *fp, const NSegment *from, const NSegment *to) { assert(fp != NULL); assert(from != NULL); assert(to != NULL); fprintf(fp, "%s", node_name(from)); fprintf(fp, " -> "); fprintf(fp, "%s", node_name(to)); fprintf(fp, ";\n"); }
static void write_node_aux(FILE *fp, const NSegment *node, const char *label, const char *color, const char *shape, const char *style, const char *fillcolor, unsigned num) { assert(node != NULL); assert(fp != NULL); fprintf(fp, "%s", node_name(node)); if (label) { fprintf(fp, "[label=\"%s\"]", label); } if (color) { fprintf(fp, "[color=\"%s\"]", color); } if (shape) { fprintf(fp, "[shape=\"%s\"]", shape); } if (style) { fprintf(fp, "[style=\"%s\"]", style); } if (fillcolor) { fprintf(fp, "[fillcolor=\"%s\"]", fillcolor); } if (num != 0) { fprintf(fp, "[peripheries=%u]", num); } }
static bool emit_mapping(node *mapping, void *context) { log_trace(component, "emitting mapping"); yaml_emitter_t *emitter = (yaml_emitter_t *)context; yaml_event_t event; log_trace(component, "mapping start"); uint8_t *name = node_name(mapping); yaml_char_t *tag = NULL == name ? (yaml_char_t *)YAML_DEFAULT_MAPPING_TAG : (yaml_char_t *)name; yaml_mapping_start_event_initialize(&event, NULL, tag, NULL == name, YAML_BLOCK_MAPPING_STYLE); if (!yaml_emitter_emit(emitter, &event)) return false; if(!mapping_iterate(mapping, emit_mapping_item, context)) { return false; } log_trace(component, "mapping end"); yaml_mapping_end_event_initialize(&event); if (!yaml_emitter_emit(emitter, &event)) return false; return true; }
static bool emit_sequence(node *sequence, void *context) { log_trace(component, "emitting seqence"); yaml_emitter_t *emitter = (yaml_emitter_t *)context; yaml_event_t event; log_trace(component, "seqence start"); uint8_t *name = node_name(sequence); yaml_char_t *tag = NULL == name ? (yaml_char_t *)YAML_DEFAULT_SEQUENCE_TAG : (yaml_char_t *)name; yaml_sequence_start_event_initialize(&event, NULL, tag, NULL == name, YAML_BLOCK_SEQUENCE_STYLE); if (!yaml_emitter_emit(emitter, &event)) return false; if(!sequence_iterate(sequence, emit_sequence_item, context)) { return false; } log_trace(component, "seqence end"); yaml_sequence_end_event_initialize(&event); if (!yaml_emitter_emit(emitter, &event)) return false; return true; }
void node_name (node* n, FILE* out) { node* curr = n; char buf[10]; fprintf(out, "{ rank=same;\n"); do { sprintf(buf, "node%05d", ++counter); curr->name = (char*) malloc(sizeof(char)*10); strcpy(curr->name, buf); fprintf(out, "%s [label=\"%d\", shape=%s];\n", curr->name, curr->key, curr->marked ? "box" : "oval"); curr = curr->left_sibling; } while (curr != n); fprintf(out, "}\n"); curr = n; do { if (curr->child) node_name(curr->child, out); curr = curr->left_sibling; } while (curr != n); }
Expr* subst(Expr* e, const Subst& sub) { switch (e->kind) { case id_expr: return e; case unit_term: return e; case true_term: return e; case false_term: return e; case if_term: return subst_ternary_term(as<If>(e), sub); case int_term: return e; case and_term: return subst_binary_term(as<And>(e), sub); case or_term: return subst_binary_term(as<Or>(e), sub); case equals_term: return subst_binary_term(as<Equals>(e), sub); case less_term: return subst_binary_term(as<Less>(e), sub); case not_term: return subst_unary_term(as<Not>(e), sub); case succ_term: return subst_unary_term(as<Succ>(e), sub); case pred_term: return subst_unary_term(as<Pred>(e), sub); case iszero_term: return subst_unary_term(as<Iszero>(e), sub); case var_term: return subst_var(as<Var>(e), sub); case abs_term: return subst_binary_term(as<Abs>(e), sub); case app_term: return subst_binary_term(as<App>(e), sub); case ref_term: return subst_ref(as<Ref>(e), sub); case mem_term: return subst_mem(as<Mem>(e), sub); case kind_type: return e; case unit_type: return e; case bool_type: return e; case nat_type: return e; case arrow_type: return e; case record_term: return e; default: break; } lang_unreachable(format("substitution into unkown term '{}'", node_name(e))); }
// Save the named term t in the current scope. Expr* declare(Expr* t) { if (Var* v = as<Var>(t)) return declare(v->name(), v); if (Def* d = as<Def>(t)) return declare(d->name(), d); lang_unreachable(format("cannot declare expression '{}'", node_name(t))); }
int main(int argc, char** argv) { std::string node_name("obstacle_detector"); ros::init(argc, argv, node_name.c_str()); ros::NodeHandle node_handle; ObstacleDetector obstacle_detector(node_name, node_handle); ros::spin(); return 0; }
mol_device_node_t * prom_find_dev_by_path( const char *path ) { char *s, *s2, *str, *orgstr; mol_device_node_t *dn, *dn2; str = orgstr = strdup( path ); dn = prom_get_root(); while( (s=strsep( &str, "/" )) && dn ) { if( !strlen(s) ) continue; /* strip ':flags' from path */ s2 = s; strsep(&s2,":"); dn2 = dn; for( dn=dn->child ; dn ; dn=dn->sibling ) if( !strcasecmp((char *) node_name(dn), (char *) s) ) break; if( dn ) continue; /* support @N:flags addressing using unit_string. * A unit string '*' matches anything (hack). */ if( !(s2=strsep(&s, "@")) ) continue; for( dn=dn2->child; dn ; dn=dn->sibling ) { if( !dn->unit_string ) continue; /* handle the /parent/node@2 case */ if( strlen(s2) && strcasecmp( (char *)node_name(dn), (char *)s2) ) continue; if( *dn->unit_string == '*' ) break; if( strtoul(s,NULL,16) == strtoul(dn->unit_string,NULL,16) ) break; } } free( orgstr ); return dn; }
/** * Check a single tree-node, recursively */ static int dom_check_node( node *n ) { int res = 1; int start = node_offset(n); int end = node_end(n); node *c = node_first_child(n); node *prev = NULL; while ( c != NULL ) { node *next = node_next_sibling( c ); if ( node_offset(c)<start ) { warning("dom: invalid offset %d < parent start %d\n",node_offset(c), start); return 0; } else if ( node_end(c)>end ) { warning("dom: invalid end %d (%s) > parent end %d (%s)\n", node_end(c), node_name(c), end, node_name(n) ); return 0; } else if ( prev != NULL && node_end(prev)>node_offset(c) ) { warning("dom: prev node ending %d encroaches on child node at %d\n", node_end(prev), node_offset(c)); return 0; } else if ( next != NULL && node_end(c)>node_offset(next) ) { warning("dom: next node starting %d encroaches on child node ending at %d\n", node_offset(next), node_end(c)); return 0; } else res = dom_check_node( c ); prev = c; c = node_next_sibling( c ); } return res; }
END_TEST START_TEST (null_node) { reset_errno(); assert_null(node_name(NULL)); assert_errno(EINVAL); reset_errno(); assert_node_size(NULL, 0); assert_errno(EINVAL); }
/** * Handle overlap on the right of a tree-node * @param d the dom in question * @param n the node to test against * @param r the rogue who overlaps on the right */ static void dom_range_overlaps_right( dom *d, node *n, node *r ) { if ( dom_mostly_nests(d,node_name(n),node_name(r)) ) { node_split( n, node_offset(r) ); dom_add_node( d, node_next_sibling(n), r ); } else if ( dom_mostly_nests(d,node_name(r),node_name(n)) ) { node *r2; node_split( r, node_end(n) ); r2 = node_next_sibling(r); node_detach_sibling( r, NULL ); dom_store_range( d, node_to_range(r2) ); //queue_push( d->q, node_to_range(r2) ); node_dispose( r2 ); dom_add_node( d, n, r ); } else dom_drop_notify( d, r, n ); }
/** * If a range is inside a node's child call dom_range_inside_node again * @param dom the dom object * @param n the node already in the tree and possibly with child * @param r the range inside n but also maybe inside n's child * @return 1 if this was the case */ int dom_range_inside_node_child( dom *d, node *n, node *r ) { node *child = node_first_child(n); while ( child != NULL ) { if ( node_encloses_range(child,r) ) { dom_range_inside_node(d,child,r); return 1; } else if ( range_equals_node(child,r) && !dom_nests(d,node_name(r),node_name(n)) && dom_nests(d,node_name(r),node_name(child)) ) { dom_range_inside_node(d,child,r); return 1; } child = node_next_sibling(child); } return 0; }
static void hashmasks_dump(void) { hash_t i; assert(_buckets); stat_dumpstr("HASHMASKS"); for (i=0; i<=_mask; i++) { assert(_buckets[i]); const char *name_primary = "Local"; const char *name_secondary = "None"; if (_buckets[i]->primary_node) { name_primary = node_name(_buckets[i]->primary_node); } if (_buckets[i]->secondary_node) { name_secondary = node_name(_buckets[i]->secondary_node); } stat_dumpstr(" Hashmask:%#llx, Primary:'%s', Secondary:'%s'", i, name_primary ? name_primary : "", name_secondary ? name_secondary : ""); } stat_dumpstr(NULL); }
void buckets_clear_transferring(bucket_t *bucket) { assert(bucket); assert(_bucket_transfer == bucket); _bucket_transfer = NULL; assert(bucket->transfer_client); assert(bucket->transfer_client->node); logger(LOG_DEBUG, "Finished transferring to client ('%s') of bucket %#llx.", node_name(bucket->transfer_client->node), bucket->hashmask); bucket->transfer_client = NULL; }
void out_switch_detail(ibnd_node_t * node, char *sw_prefix) { char *nodename = NULL; nodename = remap_node_name(node_name_map, node->guid, node->nodedesc); fprintf(f, "%sSwitch\t%d %s\t\t# \"%s\" %s port 0 lid %d lmc %d", sw_prefix ? sw_prefix : "", node->numports, node_name(node), nodename, node->smaenhsp0 ? "enhanced" : "base", node->smalid, node->smalmc); free(nodename); }
void buckets_set_transferring(bucket_t *bucket, client_t *client) { assert(bucket); assert(client); assert(client->node); assert(bucket->transfer_client == NULL); logger(LOG_DEBUG, "Setting transfer client ('%s') to bucket %#llx.", node_name(client->node), bucket->hashmask); bucket->transfer_client = client; assert(_bucket_transfer == NULL); _bucket_transfer = bucket; }
static mol_device_node_t * irq_parent( mol_device_node_t *dn ) { mol_device_node_t *dn2; int par; if( !prom_get_int_property(dn, "interrupt-parent", &par) ) { if( !(dn2=prom_phandle_to_dn(par)) ) printm("Bogus interrupt-parent (%s)\n", node_name(dn) ); return dn2; } return dn->parent; }
bool ResourceWrapper::ParseXML(rapidxml::xml_node<> *node) { Assert(node); while(node && node->name()) { std::string node_name (node->name()); auto type = types_.find(node_name); if(type == types_.end()) { Warn("Unwrapped field seen in XML '%s'", node_name.c_str()); } else { if(!node->value()) { Warn("Node '%s' has an empty value", node_name.c_str()); } else { std::string value = node->value(); switch(type->second) { case BoolType: { auto data = bools_.find(node_name); if(value == "true") *data->second = true; else if(value == "false") *data->second = false; break; } case FloatType: { auto data = floats_.find(node_name); *data->second = (float)atof(value.c_str()); break; } case VectorType: { auto data = floats_.find(node_name); *data->second = (float)atof(value.c_str()); break; } } } } } }
void out_ca_port(ibnd_port_t * port, int group, char *out_prefix) { char *str = NULL; char *rem_nodename = NULL; uint32_t iwidth = mad_get_field(port->info, 0, IB_PORT_LINK_WIDTH_ACTIVE_F); uint32_t ispeed = mad_get_field(port->info, 0, IB_PORT_LINK_SPEED_ACTIVE_F); uint32_t fdr10 = mad_get_field(port->ext_info, 0, IB_MLNX_EXT_PORT_LINK_SPEED_ACTIVE_F); uint32_t cap_mask, espeed; fprintf(f, "%s[%d]", out_prefix ? out_prefix : "", port->portnum); if (port->node->type != IB_NODE_SWITCH) fprintf(f, "(%" PRIx64 ") ", port->guid); fprintf(f, "\t%s[%d]", node_name(port->remoteport->node), port->remoteport->portnum); str = out_ext_port(port->remoteport, group); if (str) fprintf(f, "%s", str); if (port->remoteport->node->type != IB_NODE_SWITCH) fprintf(f, " (%" PRIx64 ") ", port->remoteport->guid); rem_nodename = remap_node_name(node_name_map, port->remoteport->node->guid, port->remoteport->node->nodedesc); cap_mask = mad_get_field(port->info, 0, IB_PORT_CAPMASK_F); if (cap_mask & CL_NTOH32(IB_PORT_CAP_HAS_EXT_SPEEDS)) espeed = mad_get_field(port->info, 0, IB_PORT_LINK_SPEED_EXT_ACTIVE_F); else espeed = 0; fprintf(f, "\t\t# lid %d lmc %d \"%s\" lid %d %s%s", port->base_lid, port->lmc, rem_nodename, port->remoteport->node->type == IB_NODE_SWITCH ? port->remoteport->node->smalid : port->remoteport->base_lid, dump_linkwidth_compat(iwidth), (ispeed != 4 && !espeed) ? dump_linkspeed_compat(ispeed) : dump_linkspeedext_compat(espeed, ispeed, fdr10)); if (full_info) fprintf(f, " s=%d w=%d", ispeed, iwidth); fprintf(f, "\n"); free(rem_nodename); }
/** * Write to the console details of the dropped node * @param d the dom in question * @param r the node we are dropping * @param n the parent node */ static void dom_drop_notify( dom *d, node *r, node *n ) { warning("dom: dropping %s at %d:%d - %s and %s incompatible\n", node_name(r),node_offset(r), node_end(r),node_html_name(r),node_html_name(n)); attribute *id = node_get_attribute( r, "id" ); if ( id != NULL ) { char *value = attribute_get_value( id ); if ( value[strlen(value)-1]=='b' ) printf( "aha! dropping id %s\n",value ); } node_dispose( r ); }
tgt_node_t * tgt_node_alloc(char *name, xml_val_type_t type, void *value) { tgt_node_t *d = node_alloc(); int value_len = 0; char *value_str = NULL; if (d == NULL) return (NULL); switch (type) { case String: if (value) value_len = strlen((char *)value) + 1; break; case Int: value_len = sizeof (int) * 2 + 3; break; case Uint64: value_len = sizeof (uint64_t) * 2 + 3; break; } if (value_len && (value_str = (char *)calloc(sizeof (char), value_len)) == NULL) return (NULL); if (node_name(d, (xmlChar *)name) == False) { free(value_str); return (NULL); } if (value_str) { switch (type) { case String: (void) snprintf(value_str, value_len, "%s", (char *)value); break; case Int: (void) snprintf(value_str, value_len, "%d", *(int *)value); break; case Uint64: (void) snprintf(value_str, value_len, "0x%llx", *(uint64_t *)value); break; } } (void) node_value(d, (xmlChar *)value_str, True); free(value_str); return (d); }
mol_device_node_t * prom_find_devices( const char *name ) { mol_device_node_t *head, **prevp, *np; prevp = &head; for( np=oftree.allnext; np ; np=np->allnext ) { if( !strcasecmp( (char *)node_name(np), (char *)name) ) { *prevp = np; prevp = &np->next; } } *prevp = 0; return head; }
static int get_icells( mol_device_node_t *dn ) { mol_device_node_t *dn2 = dn; int val; dn = irq_parent(dn); for( ; dn ; dn=irq_parent(dn) ) if( !prom_get_int_property(dn, "#interrupt-cells", &val) ) { //printm("get_icells: %d\n", val ); return val; } printm("irq_cell_size failed (%s)\n", node_name(dn2) ); return 1; }
int treeNodeCalcPos(Ihandle* h, int *x, int *y, int *text_x) { int err; TtreePtr tree=(TtreePtr)tree_data(h); Node node = (Node)tree_root(tree); float posy = IupGetFloat(h, IUP_POSY); float dy = IupGetFloat(h, IUP_DY); float posx = IupGetFloat(h, IUP_POSX); float dx = IupGetFloat(h, IUP_DX); CdActivate(tree,err); *y = (int)((1.0 + posy/dy)*(YmaxCanvas(tree)-TREE_TOP_MARGIN)); while(node != tree_selected(tree)) { if( node_visible(node) == YES ) *y -= NODE_Y; node = node_next(node); if (node == NULL) return 0; } *y -= NODE_Y; *x = (int)(TREE_LEFT_MARGIN - (XmaxCanvas(tree)-NODE_X)*posx/dx) + NODE_X * node_depth(node); /* if node has a text associated to it... */ *text_x = 0; if(node_name(node)) { /* Calculates its dimensions */ iupdrvStringSize(tree->self, node_name(node), text_x, NULL); } return 1; }
/*------------------------------------------------------------------------- * (function: make_not_gate) * Just make a not gate *-----------------------------------------------------------------------*/ nnode_t *make_not_gate(nnode_t *node, short mark) { nnode_t *logic_node; logic_node = allocate_nnode(); logic_node->traverse_visited = mark; logic_node->type = LOGICAL_NOT; logic_node->name = node_name(logic_node, node->name); logic_node->related_ast_node = node->related_ast_node; allocate_more_input_pins(logic_node, 1); allocate_more_output_pins(logic_node, 1); return logic_node; }