示例#1
0
static void
set_msg_one(struct pbc_pattern * FIELD_T, struct pbc_env *p, struct file_t *file, const char *name, int start, int sz , pbc_array queue) {
	int i;
	for (i=0;i<sz;i++) {
		pbc_var _field;
		_pbcA_index(file->message_field, start+i, _field);
		struct field_t field;

		int ret = pbc_pattern_unpack(FIELD_T, _field->m.buffer, _field->m.len, &field);
		if (ret != 0) {
			continue;
		}
		struct _field f;
		f.id = field.id;
		f.name = field.name->s.str;
		f.type = field.type;
		f.label = field.label;
		f.type_name.n = field.type_name->s.str;
		set_default(&f, &field);

		_pbcP_push_message(p,name, &f , queue);

		// don't need to close pattern since no array
	}
	_pbcP_init_message(p, name);
}
示例#2
0
文件: register.c 项目: SimonRen/pbc
static void
_register_extension(struct pbc_env *p, struct _stringpool *pool , const char * prefix, int prefix_sz, struct pbc_rmessage * msg, pbc_array queue) {
	int extension_count = pbc_rmessage_size(msg , "extension");
	if (extension_count <= 0) 
		return;
	int i;

	const char * last = NULL;

	for (i=0;i<extension_count;i++) {
		struct pbc_rmessage * extension = pbc_rmessage_message(msg, "extension", i);
		int field_name_sz = 0;
		struct _field f;
		const char * field_name = pbc_rmessage_string(extension , "name" , 0, &field_name_sz);
		f.name =  _concat_name(pool, prefix, prefix_sz, field_name, field_name_sz, NULL);

		_register_field(extension, &f , pool);

		const char * extendee = pbc_rmessage_string(extension , "extendee" , 0, NULL);

		_pbcP_push_message(p, extendee + 1 , &f , queue);

		if (last == NULL) {
			last = extendee;
		} else if (strcmp(extendee,last) != 0) {
			_pbcP_init_message(p, last+1);
			last = extendee;
		} 
	}
	_pbcP_init_message(p, last+1);
}
示例#3
0
文件: register.c 项目: SimonRen/pbc
static void
_register_message(struct pbc_env *p, struct _stringpool *pool, struct pbc_rmessage * message_type, const char *prefix, int prefix_sz, pbc_array queue) {
	int name_sz;
	const char * name = pbc_rmessage_string(message_type, "name", 0 , &name_sz);
	int sz = 0;
	const char *temp = _concat_name(pool, prefix , prefix_sz , name , name_sz, &sz);

	int field_count = pbc_rmessage_size(message_type, "field");
	int i;
	for (i=0;i<field_count;i++) {
		struct pbc_rmessage * field = pbc_rmessage_message(message_type, "field" , i);
		struct _field f;
		int field_name_sz;
		const char * field_name = pbc_rmessage_string(field, "name", 0 , &field_name_sz);
		f.name = _pbcS_build(pool,field_name,field_name_sz);

		_register_field(field, &f , pool);

		_pbcP_push_message(p, temp , &f , queue);
	}

	_pbcP_init_message(p, temp);

	_register_extension(p, pool, temp, sz,message_type, queue);

	// nested enum

	int enum_count = pbc_rmessage_size(message_type, "enum_type");

	for (i=0;i<enum_count;i++) {
		struct pbc_rmessage * enum_type = pbc_rmessage_message(message_type, "enum_type", i);
		_register_enum(p, pool, enum_type, temp, sz);
	}
	
	// nested type
	int message_count = pbc_rmessage_size(message_type, "nested_type");
	for (i=0;i<message_count;i++) {
		struct pbc_rmessage * nested_type = pbc_rmessage_message(message_type, "nested_type", i);
		_register_message(p, pool, nested_type, temp, sz, queue);
	}
}