# $Id$
-CFLAGS = -Igensrc -ggdb
-CXXFLAGS = -Igensrc -ggdb
+CFLAGS = -Igensrc -ggdb -Wall -Wextra -Werror
+CXXFLAGS = -Igensrc -ggdb -Wall -Wextra -Werror
PACKAGES_gldbg = mspcore mspstrings mspio mspfs
CXXFLAGS_gldbg = $(shell pkg-config --cflags $(PACKAGES_gldbg))
intptr, int, %i
sizeiptr, int, %i
handle, int, %i
-int64, longlong, %lli
-uint64, longlong, %llu
+int64, long long, %lli
+uint64, long long, %llu
half, short, %#x
float, float, %g
clampf, float, %g
int32_t, int, %i
long, long, %li
unsigned long, long, %lu
-int64_t, longlong, %lli
+int64_t, long long, %lli
sizei, int, %i
float, float, %g
unsigned int *, pointer, %p
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include "enums.h"
#include "tmpalloc.h"
#include <string.h>
#include "functions.h"
#include "gldecoder.h"
+#include "tmpalloc.h"
static unsigned read_short(short *, const char *);
static unsigned read_int(int *, const char *);
int gldecoder_decode(GlDecoder *dec, const char *data, unsigned len)
{
unsigned pos = 0;
- int pktlen;
+ unsigned pktlen;
unsigned short func;
int ret;
if(len<sizeof(int)+sizeof(short))
return -1;
- pos += read_int(&pktlen, data);
+ pos += read_int((int *)&pktlen, data);
if(len<pktlen)
return -1;
- pos += read_short(&func, data+pos);
+ pos += read_short((short *)&func, data+pos);
if(dec)
{
if(func&0x8000)
return sizeof(long);
}
-static unsigned read_ulong(unsigned long *v, const char *data)
-{
- *v = *(unsigned long *)data;
- return sizeof(unsigned long);
-}
-
-static unsigned read_longlong(long long *v, const char *data)
+static unsigned read_long_long(long long *v, const char *data)
{
*v = *(long long *)data;
return sizeof(long long);
return sizeof(double);
}
-static unsigned read_pointer(void **v, const char *data)
+typedef void *pointer;
+
+static unsigned read_pointer(pointer *v, const char *data)
{
*v = *(void **)data;
return sizeof(void *);
return pos+vlen;
}
-static unsigned read_string(const unsigned char **v, const char *data)
+typedef const char *string;
+
+static unsigned read_string(string *v, const char *data)
{
return read_data((const void **)v, data);
}
-static unsigned read_string_array(const unsigned char ***v, const char *data)
+static unsigned read_string_array(string **v, const char *data)
{
int count;
unsigned pos = 0;
int i;
pos += read_int(&count, data);
- *v = (const unsigned char **)tmpalloc(count*sizeof(const unsigned char *));
+ *v = (string *)tmpalloc(count*sizeof(string));
for(i=0; i<count; ++i)
pos += read_string(*v+i, data+pos);
return pos;
{
unsigned pos = 0;
GLenum code;
- pos += read_int(&code, data);
+ pos += read_int((int *)&code, data);
if(dec->gldError)
dec->gldError(dec->user_data, code);
return pos;
# $Id$
-wl('static unsigned decode_%s(GlDecoder *dec, const char *data)', func.name)
+wl('static unsigned decode_%s(GlDecoder *dec, const char *data __attribute__((unused)))', func.name)
wl('{')
wl(' unsigned pos = 0;')
if ret.ctype!="void":
for p in params:
wl(' %s p_%s;', p.ctype, p.name)
if ret.ctype!="void":
- wl(' pos += read_%s(&ret, data+pos);', ret.io[0])
+ wl(' pos += read_%s((%s *)&ret, data+pos);', ret.io[0].replace(' ', '_'), ret.io[0])
for p in params:
if p.kind=="value":
- wl(' pos += read_%s(&p_%s, data+pos);', p.io[0], p.name)
+ wl(' pos += read_%s((%s *)&p_%s, data+pos);', p.io[0].replace(' ', '_'), p.io[0], p.name)
elif p.kind=="array" and p.io and p.io[0]=="string":
wl(' pos += read_string_array(&p_%s, data+pos);', p.name)
elif p.csize:
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+#include <ctype.h>
#include "arraysize.h"
#include "enums.h"
#include "glprint.h"
if p.io:
w('{%s}', p.io[1])
else:
- w('<ref:%s>', p.type)
+ w('<ref:%s %%p>', p.type)
elif p.kind=="array":
w('%%s')
first = False
elif p.kind=="reference":
if p.io:
w(', *%s', p.name)
+ else:
+ w(', %s', p.name)
elif p.kind=="array":
if not p.csize:
w(', print_data(%s, 0)', p.name)
write_bytes((char *)&v, sizeof(long));
}
-static inline void write_ulong(unsigned long v)
-{
- write_bytes((char *)&v, sizeof(unsigned long));
-}
-
-static inline void write_longlong(long long v)
+static inline void write_long_long(long long v)
{
write_bytes((char *)&v, sizeof(long long));
}
write_int(0);
}
-static inline void write_string(const unsigned char *s)
+static inline void write_string(const char *s)
{
write_data(s, strlen(s)+1);
}
-static inline void write_string_array(const unsigned char **sa, unsigned size)
+static inline void write_string_array(const char **sa, unsigned size)
{
unsigned i;
- size /= sizeof(const unsigned char *);
+ size /= sizeof(const char *);
write_int(size);
for(i=0; i<size; ++i)
write_string(sa[i]);
wl('orig(%s);', ", ".join([p.name for p in params]))
wl(' begin_packet(FUNC_%s);', func.name.upper())
if ret.ctype!='void':
- wl(' write_%s(ret);', ret.io[0])
+ wl(' write_%s(ret);', ret.io[0].replace(' ', '_'))
for p in params:
if p.kind=="value":
- wl(' write_%s(%s);', p.io[0], p.name)
+ wl(' write_%s(%s);', p.io[0].replace(' ', '_'), p.name)
elif p.kind=="array" and p.io and p.io[0]=="string":
wl(' write_string_array(%s, %s);', p.name, p.csize)
elif p.csize: