Esempio n. 1
0
static char *parse_shader(lua_State *L, int text_idx, int uniform_text_idx)
{
	struct declaration *d;
	char *text;
	int sz;
	int rc;
	g_decls = NULL;
	const char *temp = lua_tostring(L, text_idx);
	sz = strlen(temp);
	text = malloc(sz + 2);
	strcpy(text, temp);
	text[sz + 1] = 0;
	glsl_scan_buffer(text, sz + 2);
	rc = glslparse();
	if (rc) {
		free(text);
		return NULL;
	}
	d = g_decls;
	while (d) {
		process_declaration(L, uniform_text_idx, d);
		d = d->next;
	}
	meta_scan_buffer(text, sz + 2);
	int filtered_sz = 0;
	while(metalex()) {
		filtered_sz += strlen(metalval);
	}
	metalex_destroy();

	char *out_text = malloc(filtered_sz + 1);
	char *c = out_text;
	meta_scan_buffer(text, sz + 2);
	while(metalex()) {
		int s = strlen(metalval);
		memcpy(c, metalval, s);
		c += s;
	}
	*c = 0;
	metalex_destroy();
	free(text);
	return out_text;
}
Esempio n. 2
0
void process_extern (TYPE t) {
	shouldSetExtern = 1;
	process_declaration (t);
	shouldSetExtern = 0;
}