예제 #1
0
static int
_pattern_delete(lua_State *L) {
	struct pbc_pattern * pat = (struct pbc_pattern *)lua_touserdata(L,1);
	pbc_pattern_delete(pat);
	
	return 0;
}
예제 #2
0
파일: pattern.c 프로젝트: zhangjinde/z
int
main()
{
	struct pbc_slice slice;
	read_file("addressbook.pb", &slice);
	if (slice.buffer == NULL)
		return 1;
	struct pbc_env * env = pbc_new();
	pbc_register(env, &slice);

	free(slice.buffer);

	pat = pbc_pattern_new(env, "tutorial.Person" , 
		"name %s id %d email %s phone %a test %a",
		offsetof(struct person, name) , 
		offsetof(struct person, id) ,
		offsetof(struct person, email) ,
		offsetof(struct person, phone) ,
		offsetof(struct person, test));

	pat_phone = pbc_pattern_new(env, "tutorial.Person.PhoneNumber",
		"number %s type %d",
		offsetof(struct person_phone, number),
		offsetof(struct person_phone, type));


	char buffer[4096];
	struct pbc_slice message = { buffer, sizeof(buffer) };

	test_pattern_pack(env, &message);

	dump((uint8_t*)message.buffer, message.len);

	test_pattern_unpack(env, &message);

	pbc_pattern_delete(pat);
	pbc_pattern_delete(pat_phone);

	pbc_delete(env);

	return 0;
}
예제 #3
0
파일: pbc-lua.c 프로젝트: adroitly/boom
static int
_clear_gcobj(lua_State *L) {
	struct gcobj * obj = (struct gcobj *)lua_touserdata(L,1);
	int i;
	for (i=0;i<obj->size_pat;i++) {
		pbc_pattern_delete(obj->pat[i]);
	}
	for (i=0;i<obj->size_msg;i++) {
		pbc_rmessage_delete(obj->msg[i]);
	}
	free(obj->pat);
	free(obj->msg);
	obj->pat = NULL;
	obj->msg = NULL;
	pbc_delete(obj->env);
	obj->env = NULL;

	return 0;
}