Example #1
0
File: main.c Project: mattjakob/s3d
Poly *prim_polys(Prim *s, Poly *p)
{
  int i;
  Poly *l = plist_alloc(3, p->n);
  for (i = 0; i < p->n; i++) {
    PL(l)->v[i] = SL(l)->v[i] = prim_point(s, p->v[i].x, p->v[i].y);
    NL(l)->v[i] = prim_normal(s, p->v[i].x, p->v[i].y);
  }
  return l;
}
Example #2
0
File: main.c Project: mattjakob/s3d
Poly *prim_polys(Prim *s, Poly *p)
{
  int i;
  Poly *l = plist_alloc(7, p->n);

  for (i = 0; i < p->n; i++) {
    PL(l)->v[i] = SL(l)->v[i] = prim_point(s, p->v[i].x, p->v[i].y);
    NL(l)->v[i] = prim_normal(s, p->v[i].x, p->v[i].y);
    TL(l)->v[i] = prim_texc(s, p->v[i].x, p->v[i].y);
    DUL(l)->v[i] = v3_unit(prim_du(s, p->v[i].x, p->v[i].y));
    DVL(l)->v[i] = v3_unit(prim_dv(s, p->v[i].x, p->v[i].y));
  }
  return l;
}
Example #3
0
File: tree.c Project: c0cky/pcc-3
PARAM_LIST build_Param(DN dn, TYPE initialType, PARAM_LIST pl)
{
	if(dn == NULL)
	{
		error("no id in declaration");
		return NULL;
	}
	TYPE type = initialType;
	PARAM_LIST pl1 = plist_alloc();
	while(dn != NULL)
	{
		switch(dn->tag) {
			case ARRAY:
				type = ty_build_array(type, TRUE, dn->u.array_dim.dim);
				break;
			case PTR:
				type = ty_build_ptr(type, NO_QUAL);
				break;
			case FUNC:
				// this will have to be fixed
				type = ty_build_func(type, PROTOTYPE, dn->u.param_list.pl);
				break;
			case REF:
				pl1->is_ref = TRUE;
				break;
			case ID: 
				pl1->id = dn->u.st_id.i;
				pl1->type = type;
				pl1->sc = NO_SC;
				pl1->err = FALSE;

				break;
			default:
				bug("where's the tag? in Param\"stdr_dump\"");
		}
	
		dn = dn->n_node;
	}
	
	return pl1;
}
Example #4
0
static bool
decode_proplist(void *port, PropList **plist, int *szalloc,
                const char *buf, int *index) {
    int type, size;
    long item_type;
    bool succeess = false;
    PropList *list_head = (*plist = plist_alloc(port, szalloc));
    if (DECODED(ei_get_type(buf, index, &type, &size))) {
        int list_arity = 0;
        if (DECODED(ei_decode_list_header(buf, index, &list_arity))) {
            ASSERT(size == list_arity);
            if (list_arity < 1) {
                succeess = false;
            } else {
                for (int i = 0; i < list_arity; i++) {
                    if (!DECODED(ei_decode_tuple_header(buf, index, &size))) {
                        return false;
                    }
                    if ((list_head->next = plist_alloc(port, szalloc)) != NULL) {
                        *plist = (list_head = list_head->next);
                        list_head->type = EDBC_OCI_DRV_TYPE_UNASSIGNED;
                        char *pkey = safe_driver_alloc(port, sizeof(char) * MAXATOMLEN);
                        
                        if (!DECODED(ei_decode_atom(buf, index, pkey))) {
                            return false;
                        } 
                        
                        list_head->name = pkey;
                        
                        if (!DECODED(ei_decode_long(buf, index, &item_type))) {
                            return false;
                        }
                        list_head->type = item_type;
                        
                        switch (item_type) {
                        case EDBC_OCI_DRV_TYPE_STRING: {
                            if(!DECODED(ei_get_type(buf, index, &type, &size))) {
                                return false;
                            }
                            ASSERT(type == ERL_STRING_EXT);
                            TextBuffer *ptxt = zalloc(port, sizeof(TextBuffer));
                            char *pval = safe_driver_alloc(port, sizeof(char) * ptxt->size);

                            ptxt->size = size + 1;
                            ptxt->data = pval;
                            list_head->value.buffer = ptxt;
                            if (!DECODED(ei_decode_string(buf, index, pval))) {
                                return false;
                            }
                            break;
                        }
                        case EDBC_OCI_DRV_TYPE_LONG: {
                            long num;
                            if (!DECODED(ei_decode_long(buf, index, &num))) {
                                return false;
                            }
                            list_head->value.number = num;
                            break;
                        }
                        default:
                            // make error?
                            break;
                        }
                    }
                }
            }
        }
    }
    return false;
};