more quaternion work (should be working, haven't come up with tests yet)

This commit is contained in:
Bill Currie 2004-04-08 03:32:14 +00:00
parent 4882005a49
commit fc2413ff72
7 changed files with 33 additions and 7 deletions

View file

@ -649,9 +649,10 @@ PR_Sprintf (progs_t *pr, dstring_t *result, const char *name,
fi = &(*fi)->next;
break;
case 'v':
case 'q':
// vector
{
int i;
int i, count = 3;
int flags = (*fi)->flags;
int precision = (*fi)->precision;
unsigned minWidth = (*fi)->minFieldWidth;
@ -660,7 +661,10 @@ PR_Sprintf (progs_t *pr, dstring_t *result, const char *name,
(*fi)->precision = -1;
(*fi)->minFieldWidth = 0;
for (i = 0; i < 3; i++) {
if (*c == 'q')
count = 4;
for (i = 0; i < count; i++) {
if (i == 0) {
(*fi)->type = 's';
(*fi)->data.string_var = "'";

View file

@ -60,7 +60,7 @@ typedef struct struct_s {
struct_field_t *struct_head;
struct_field_t **struct_tail;
int size;
void *return_addr; // who allocated this
void *return_addr; // who allocated this
} struct_t;
typedef struct enum_s {

View file

@ -172,7 +172,7 @@ build_scope (function_t *f, def_t *func, param_t *params)
if (args) {
while (i < MAX_PARMS) {
def = get_def (&type_vector, 0, f->scope, st_local);
def = get_def (&type_vector, 0, f->scope, st_local);//XXX param
def->used = 1;
i++;
}

View file

@ -240,6 +240,9 @@ WriteProgdefs (const char *filename)
fprintf (f, "\tvec3_t\t%s;\n", d->name);
d = d->def_next->def_next->def_next; // skip the elements
break;
case ev_quat:
fprintf (f, "\tquat_t\t%s;\n", d->name);
break;
case ev_string:
fprintf (f, "\tstring_t\t%s;\n", d->name);
break;

View file

@ -213,7 +213,7 @@ ReuseConstant (expr_t *expr, def_t *def)
type = &type_vector;
break;
case ex_quaternion:
tab = vector_imm_defs;
tab = quaternion_imm_defs;
type = &type_quaternion;
break;
default:

View file

@ -168,8 +168,10 @@ m ([\-+]?)
'{s}*{m}{NUM}{s}+{m}{NUM}{s}+{m}{NUM}{s}+{m}{NUM}{s}*' {
sscanf (yytext, "' %f %f %f %f '",
&yylval.vector_val[0], &yylval.vector_val[1],
&yylval.vector_val[2], &yylval.vector_val[3]);
&yylval.quaternion_val[0],
&yylval.quaternion_val[1],
&yylval.quaternion_val[2],
&yylval.quaternion_val[3]);
return QUATERNION_VAL;
}

View file

@ -99,6 +99,7 @@ type_t type_param;
type_t type_zero;
struct_t *vector_struct;
struct_t *quaterion_struct;
type_t type_floatfield = { ev_field, ".float", NULL, &type_float };
@ -653,12 +654,28 @@ init_types (void)
if (options.traditional)
return;
strct = type_zero.s.strct;
new_struct_field (strct, &type_vector, "vector_val", vis_public);
new_struct_field (strct, &type_quaternion, "quaternion_val", vis_public);
strct = type_param.s.strct;
new_struct_field (strct, &type_quaternion, "quaternion_val", vis_public);
strct = vector_struct = get_struct (0, 1);
init_struct (strct, new_type (), str_struct, 0);
new_struct_field (strct, &type_float, "x", vis_public);
new_struct_field (strct, &type_float, "y", vis_public);
new_struct_field (strct, &type_float, "z", vis_public);
strct = quaterion_struct = get_struct (0, 1);
init_struct (strct, new_type (), str_struct, 0);
new_struct_field (strct, &type_float, "s", vis_public);
new_struct_field (strct, &type_float, "x", vis_public);
new_struct_field (strct, &type_float, "y", vis_public);
new_struct_field (strct, &type_float, "z", vis_public);
strct->size = 1; // evil hack for the vector access
new_struct_field (strct, &type_vector, "v", vis_public);
strct = get_struct (0, 1);
init_struct (strct, new_type (), str_struct, 0);
new_struct_field (strct, &type_string, "sel_id", vis_public);