Esempio n. 1
0
void gui_getFileSelectionBoxPseudoResources(const Widget widget, Var* dvStruct)
{

	int dirListItemCount, fileListItemCount;
	Var *dirListItems, *fileListItems;

#if DEBUG
	fprintf(stderr, "DEBUG: gui_getFileSelectionBoxPseudoResources(%ld, %ld)\n", widget, dvStruct);
#endif

	XtVaGetValues(widget, "dirListItemCount", &dirListItemCount, NULL);
	if (dirListItemCount == 0) {
		dirListItems = newText(0, NULL);
	} else {
		dirListItems = gui_getXmStringTableCount(widget, "dirListItems", 0, dirListItemCount);
	}
	add_struct(dvStruct, "dirListItems", dirListItems);

	XtVaGetValues(widget, "fileListItemCount", &fileListItemCount, NULL);
	if (fileListItemCount == 0) {
		fileListItems = newText(0, NULL);
	} else {
		fileListItems = gui_getXmStringTableCount(widget, "fileListItems", 0, fileListItemCount);
	}
	add_struct(dvStruct, "fileListItems", fileListItems);
}
Esempio n. 2
0
/*create a structure and add it into the struct list
 *structure defined by structspecifier node in syntax tree*/
struct struct_descriptor*
create_structure(struct tree_node* structspecifier_node){

	assert(structspecifier_node -> unit_code == StructSpecifier);
	struct tree_node* opttag_node = structspecifier_node -> child -> sibling;
	char* struct_name;
	if(structspecifier_node -> child -> sibling -> child != NULL){	//OptTag !-> empty
		struct_name = opttag_node -> child -> unit_value; //ID node has a value
		/*check struct name repeat*/
		if((find_struct(struct_table_head, struct_name) != NULL) ||
			(find_var(var_table_head, struct_name) != NULL)){
			printf("Error type 16 at line %d: Struct name redefine\n", structspecifier_node -> lineno);
			semantic_error_flag = true;
			return NULL;
		}
	}
	else
		struct_name = "";	//empty struct name
	
	struct tree_node* deflist_node = opttag_node -> sibling -> sibling;
		
	struct struct_descriptor* new_struct_descriptor = create_struct_descriptor(struct_name);
	new_struct_descriptor -> member_num = init_member_list(new_struct_descriptor -> member_list_head, deflist_node);
	add_struct(struct_table_head, new_struct_descriptor);
	return new_struct_descriptor;
}
Esempio n. 3
0
		DefaultLayout()
		{
			add_base(get_structlayout<CPipeDataSBase>());
			add_simple(_T("a1"),&CPipeDataS::m_a1);
			add_simple(_T("a2"),&CPipeDataS::m_a2);
			add_simple(_T("b"),&CPipeDataS::m_b);
			add_simple(_T("String"),&CPipeDataS::m_str);
			add_vector(_T("Vec"),&CPipeDataS::m_vec,get_primitivelayout<long>());
			add_struct(_T("Struct"),&CPipeDataS::m_struct,get_structlayout<CPipeDataSBase>());
		}
Esempio n. 4
0
static size_t get_return_struct(code_system *system, type *return_type) {
  if (is_void(return_type)) {
    return 0;
  }

  size_t count = system->struct_count;
  code_struct *return_struct;

  for (size_t i = 0; i < count; i++) {
    return_struct = get_code_struct(system, i);
    if (return_struct->field_count != 1) {
      continue;
    }

    code_field *first_field = &return_struct->fields[0];
    type *first = first_field->field_type;

    if (first->type != T_BLOCKREF || !first->blocktype ||
        !first->blocktype->next || first->blocktype->next->next) {
      continue;
    }

    type *second = first->blocktype->next->argument_type;
    first = first->blocktype->argument_type;

    if (first->type == T_OBJECT && first->struct_index == i &&
        equivalent_type(return_type, second)) {
      return i;
    }
  }

  return_struct = add_struct(system);
  return_struct->field_count = 1;
  return_struct->fields = xmalloc(sizeof(code_field));
  return_struct->fields[0].field_type = new_type(T_BLOCKREF);

  argument *blocktype = xmalloc(sizeof(*blocktype));
  blocktype->symbol_name = NULL;
  blocktype->argument_type = get_object_type(count);
  return_struct->fields[0].field_type->blocktype = blocktype;

  blocktype->next = xmalloc(sizeof(argument));
  blocktype = blocktype->next;
  blocktype->symbol_name = NULL;
  blocktype->argument_type = copy_type(return_type);
  blocktype->next = NULL;

  return count;
}
Esempio n. 5
0
void gui_getSelectionBoxPseudoResources(const Widget widget, Var* dvStruct)
{

	int listItemCount;
	Var* listItems;

#if DEBUG
	fprintf(stderr, "DEBUG: gui_getSelectionBoxPseudoResources(%ld, %ld)\n", widget, dvStruct);
#endif

	XtVaGetValues(widget, "listItemCount", &listItemCount, NULL);
	if (listItemCount == 0) {
		listItems = newText(0, NULL);
	} else {
		listItems = gui_getXmStringTableCount(widget, "listItems", 0, listItemCount);
	}
	add_struct(dvStruct, "listItems", listItems);

	return;
}
Esempio n. 6
0
static int convert_include(const char *filename)
{
	/* read include file, skip structs with a '#' before it.
	 * store all data in temporal arrays.
	 */
	int filelen, count, overslaan, slen, type, name, strct;
	short *structpoin, *sp;
	char *maindata, *mainend, *md, *md1;
	
	md = maindata = read_file_data(filename, &filelen);
	if (filelen == -1) {
		fprintf(stderr, "Can't read file %s\n", filename);
		return 1;
	}

	filelen = preprocess_include(maindata, filelen);
	mainend = maindata + filelen - 1;

	/* we look for '{' and then back to 'struct' */
	count = 0;
	overslaan = 0;
	while (count < filelen) {
		
		/* code for skipping a struct: two hashes on 2 lines. (preprocess added a space) */
		if (md[0] == '#' && md[1] == ' ' && md[2] == '#') {
			overslaan = 1;
		}
		
		if (md[0] == '{') {
			md[0] = 0;
			if (overslaan) {
				overslaan = 0;
			}
			else {
				if (md[-1] == ' ') md[-1] = 0;
				md1 = md - 2;
				while (*md1 != 32) md1--;       /* to beginning of word */
				md1++;
				
				/* we've got a struct name when... */
				if (strncmp(md1 - 7, "struct", 6) == 0) {

					strct = add_type(md1, 0);
					if (strct == -1) {
						fprintf(stderr, "File '%s' contains struct we cant parse \"%s\"\n", filename, md1);
						return 1;
					}

					structpoin = add_struct(strct);
					sp = structpoin + 2;

					if (debugSDNA > 1) printf("\t|\t|-- detected struct %s\n", types[strct]);

					/* first lets make it all nice strings */
					md1 = md + 1;
					while (*md1 != '}') {
						if (md1 > mainend) break;
						
						if (*md1 == ',' || *md1 == ' ') *md1 = 0;
						md1++;
					}
					
					/* read types and names until first character that is not '}' */
					md1 = md + 1;
					while (*md1 != '}') {
						if (md1 > mainend) break;
						
						/* skip when it says 'struct' or 'unsigned' or 'const' */
						if (*md1) {
							if (strncmp(md1, "struct", 6) == 0) md1 += 7;
							if (strncmp(md1, "unsigned", 8) == 0) md1 += 9;
							if (strncmp(md1, "const", 5) == 0) md1 += 6;
							
							/* we've got a type! */
							type = add_type(md1, 0);
							if (type == -1) {
								fprintf(stderr, "File '%s' contains struct we can't parse \"%s\"\n", filename, md1);
								return 1;
							}

							if (debugSDNA > 1) printf("\t|\t|\tfound type %s (", md1);

							md1 += strlen(md1);

							
							/* read until ';' */
							while (*md1 != ';') {
								if (md1 > mainend) break;
								
								if (*md1) {
									/* We've got a name. slen needs
									 * correction for function
									 * pointers! */
									slen = (int) strlen(md1);
									if (md1[slen - 1] == ';') {
										md1[slen - 1] = 0;


										name = add_name(md1);
										slen += additional_slen_offset;
										sp[0] = type;
										sp[1] = name;

										if ((debugSDNA > 1) && (names[name] != NULL)) printf("%s |", names[name]);

										structpoin[1]++;
										sp += 2;
																					
										md1 += slen;
										break;
									}
									

									name = add_name(md1);
									slen += additional_slen_offset;

									sp[0] = type;
									sp[1] = name;
									if ((debugSDNA > 1) && (names[name] != NULL)) printf("%s ||", names[name]);

									structpoin[1]++;
									sp += 2;
									
									md1 += slen;
								}
								md1++;
							}

							if (debugSDNA > 1) printf(")\n");

						}
						md1++;
					}
				}
			}
		}
		count++;
		md++;
	}
	
	MEM_freeN(maindata);

	return 0;
}
Esempio n. 7
0
Var* ff_boxfilter(vfuncptr func, Var* arg)
{
	Var* v = NULL;
	Var *rcount, *rmean, *rs, *rn, *rsigma;
	Var* a;
	int x         = 0;
	int y         = 0;
	int z         = 0;
	int size      = 0;
	double ignore = FLT_MIN;
	int verbose   = 0;

	Alist alist[8];
	alist[0]      = make_alist("obj", ID_VAL, NULL, &v);
	alist[1]      = make_alist("x", DV_INT32, NULL, &x);
	alist[2]      = make_alist("y", DV_INT32, NULL, &y);
	alist[3]      = make_alist("z", DV_INT32, NULL, &z);
	alist[4]      = make_alist("size", DV_INT32, NULL, &size);
	alist[5]      = make_alist("ignore", DV_DOUBLE, NULL, &ignore);
	alist[6]      = make_alist("verbose", DV_INT32, NULL, &verbose);
	alist[7].name = NULL;

	if (parse_args(func, arg, alist) == 0) return (NULL);
	if (v == NULL) {
		parse_error("%s(): No object specified\n", func->name);
		return (NULL);
	}
	if (x && y && size) {
		parse_error("%s(): Specify either size or (x, y, z), not both", func->name);
		return (NULL);
	}
	if (x == 0) x    = 1;
	if (y == 0) y    = 1;
	if (z == 0) z    = 1;
	if (size != 0) x = y = size;

	if (x == 0 || y == 0) {
		parse_error("%s(): No x or y specified", func->name);
		return (NULL);
	}

	init_sums(v, x, y, z, &rn, &rs, &rcount, &rmean, &rsigma, ignore);

	if (verbose) {
		a = new_struct(0);
		add_struct(a, "count", rcount);
		add_struct(a, "mean", rmean);
		add_struct(a, "sigma", rsigma);
		add_struct(a, "n", rn);
		add_struct(a, "s", rs);
		return (a);
	} else {
		mem_claim(rcount);
		free_var(rcount);
		mem_claim(rn);
		free_var(rn);
		mem_claim(rs);
		free_var(rs);
		return (rmean);
	}
}