Esempio n. 1
0
name_pointer
#line 339 "./cwebdir/comm-w2c.ch"

add_section_name P5C(name_pointer,par,int,c,char*,first,char*,last,
int,ispref)
#line 863 "./cwebdir/common.w"
{
name_pointer p= name_ptr;
char*s= first_chunk(p);
int name_len= last-first+ispref;
if(s+name_len> byte_mem_end)overflow("byte memory");
if(name_ptr+1>=name_dir_end)overflow("name");
(++name_ptr)->byte_start= byte_ptr= s+name_len;
if(ispref){
*(byte_ptr-1)= ' ';
name_len--;
name_ptr->link= name_dir;
(++name_ptr)->byte_start= byte_ptr;
}
set_prefix_length(p,name_len);
strncpy(s,first,name_len);
p->llink= NULL;
p->rlink= NULL;
init_node(p);
return par==NULL?(root= p):c==less?(par->llink= p):(par->rlink= p);
}
Esempio n. 2
0
int section_name_cmp P3C(char**,pfirst,int,len,name_pointer,r)
#line 1025 "./cwebdir/common.w"
{
char*first= *pfirst;
name_pointer q= r+1;
char*ss,*s= first_chunk(r);
int c;
int ispref;
while(1){
ss= (r+1)->byte_start-1;
if(*ss==' '&&ss>=r->byte_start)ispref= 1,q= q->link;
else ispref= 0,ss++,q= name_dir;
switch(c= web_strcmp(first,len,s,ss-s)){
case equal:if(q==name_dir)
if(ispref){
*pfirst= first+(ss-s);
return extension;
}else return equal;
else return(q->byte_start==(q+1)->byte_start)?equal:prefix;
case extension:
if(!ispref)return bad_extension;
first+= ss-s;
if(q!=name_dir){len-= ss-s;s= q->byte_start;r= q;continue;}
*pfirst= first;return extension;
default:return c;
}
}
}
Esempio n. 3
0
void
#line 307 "./cwebdir/comm-w2c.ch"
 print_prefix_name P1C(name_pointer,p)
#line 808 "./cwebdir/common.w"
{
char*s= first_chunk(p);
int l= prefix_length(p);
term_write(s,l);
if(s+l<(p+1)->byte_start)term_write("...",3);
}
Esempio n. 4
0
blob encode_omdl(const model& mdl
	, const allocator& file_alloc
	, const allocator& temp_alloc)
{
	const auto& info = mdl.info();

	uint32_t nslots = info.num_slots;
	const auto subsets_bytes = info.num_subsets * (uint32_t)sizeof(subset_t);
	const auto indices_bytes = info.num_indices * (uint32_t)sizeof(uint16_t);
	const auto vertices_bytes = info.num_vertices * layout_size(info.layout);

	const auto bytes = sizeof(file_header) 
		+ sizeof(file_chunk) + sizeof(info_t) 
		+ sizeof(file_chunk) + subsets_bytes
		+ sizeof(file_chunk) + indices_bytes
		+ sizeof(file_chunk) * nslots + vertices_bytes;

	auto mem = file_alloc.scoped_allocate(bytes, "encoded model");
	auto hdr = (file_header*)mem;

	hdr->fourcc = omdl_signature;
	hdr->num_chunks = 4;
	hdr->compression = compression_type::none; // not yet implemented, though here's where it gets done
	hdr->reserved = 0;
	hdr->version_hash = 0; // not yet implemented

	auto chk = hdr->first_chunk();
	chk->fourcc = omdl_info_signature;
	chk->chunk_bytes = sizeof(info_t);
	chk->uncompressed_bytes = chk->chunk_bytes;
	memcpy(chk->data<info_t>(), &info, sizeof(info_t));

	chk = chk->next();
	chk->fourcc = omdl_subsets_signature;
	chk->chunk_bytes = subsets_bytes;
	chk->uncompressed_bytes = chk->chunk_bytes;
	memcpy(chk->data<subset_t>(), mdl.subsets(), chk->chunk_bytes);

	chk = chk->next();
	chk->fourcc = omdl_indices_signature;
	chk->chunk_bytes = indices_bytes;
	chk->uncompressed_bytes = chk->chunk_bytes;
	memcpy(chk->data<uint16_t>(), mdl.indices(), chk->chunk_bytes);

	for (uint32_t slot = 0; slot < nslots; slot++)
	{
		chk = chk->next();
		chk->fourcc = omdl_vertex_slot_signature;
		chk->chunk_bytes = vertices_bytes;
		chk->uncompressed_bytes = chk->chunk_bytes;
		memcpy(chk->data<void>(), mdl.vertices(slot), chk->chunk_bytes);
	}

	return mem;
}
Esempio n. 5
0
void
#line 288 "./cwebdir/comm-w2c.ch"
 print_section_name P1C(name_pointer,p)
#line 768 "./cwebdir/common.w"
{
char*ss,*s= first_chunk(p);
name_pointer q= p+1;
while(p!=name_dir){
ss= (p+1)->byte_start-1;
if(*ss==' '&&ss>=s){
term_write(s,ss-s);p= q->link;q= p;
}else{
term_write(s,ss+1-s);p= name_dir;q= NULL;
}
s= p->byte_start;
}
if(q)term_write("...",3);
}
Esempio n. 6
0
void
#line 298 "./cwebdir/comm-w2c.ch"
 sprint_section_name P2C(char*,dest,name_pointer,p)
#line 788 "./cwebdir/common.w"
{
char*ss,*s= first_chunk(p);
name_pointer q= p+1;
while(p!=name_dir){
ss= (p+1)->byte_start-1;
if(*ss==' '&&ss>=s){
p= q->link;q= p;
}else{
ss++;p= name_dir;
}
strncpy(dest,s,ss-s),dest+= ss-s;
s= p->byte_start;
}
*dest= '\0';
}
Esempio n. 7
0
name_pointer
#line 363 "./cwebdir/comm-w2c.ch"

section_lookup P3C(char*,first,char*,last,int,ispref)
#line 917 "./cwebdir/common.w"
{
int c= 0;
name_pointer p= root;
name_pointer q= NULL;
name_pointer r= NULL;
name_pointer par= NULL;

int name_len= last-first+1;
/*52:*/
#line 936 "./cwebdir/common.w"

while(p){
c= web_strcmp(first,name_len,first_chunk(p),prefix_length(p));
if(c==less||c==greater){
if(r==NULL)
par= p;
p= (c==less?p->llink:p->rlink);
}else{
if(r!=NULL){
printf("\n! Ambiguous prefix: matches <");

print_prefix_name(p);
printf(">\n and <");
print_prefix_name(r);
err_print(">");
return name_dir;
}
r= p;
p= p->llink;
q= r->rlink;
}
if(p==NULL)
p= q,q= NULL;
}

/*:52*/
#line 926 "./cwebdir/common.w"
;
/*53:*/
#line 961 "./cwebdir/common.w"

if(r==NULL)
return add_section_name(par,c,first,last+1,ispref);

/*:53*/
#line 927 "./cwebdir/common.w"
;
/*54:*/
#line 969 "./cwebdir/common.w"

switch(section_name_cmp(&first,name_len,r)){

case prefix:
if(!ispref){
printf("\n! New name is a prefix of <");

print_section_name(r);
err_print(">");
}
else if(name_len<prefix_length(r))set_prefix_length(r,name_len);

case equal:return r;
case extension:if(!ispref||first<=last)
extend_section_name(r,first,last+1,ispref);
return r;
case bad_extension:
printf("\n! New name extends <");

print_section_name(r);
err_print(">");
return r;
default:
printf("\n! Section name incompatible with <");

print_prefix_name(r);
printf(">,\n which abbreviates <");
print_section_name(r);
err_print(">");
return r;
}

/*:54*/
#line 928 "./cwebdir/common.w"
;
}