From: Mikko Rasa Date: Wed, 28 Oct 2009 07:48:50 +0000 (+0000) Subject: Allow tagging funtions for handcoding in templates X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=7c57338619688bc07f394ad82f75471aefbecc59;p=gldbg.git Allow tagging funtions for handcoding in templates Send glGetError and glXGetProcAddress calls Various string handling fixes A couple other bugfixes --- diff --git a/genwrap.py b/genwrap.py index ec23985..e614ab7 100755 --- a/genwrap.py +++ b/genwrap.py @@ -138,8 +138,6 @@ class Function: self.csize = "%d*sizeof(%s)"%(self.size, self.base_ctype) elif self.size.startswith("COMPSIZE("): self.csize = self.func.compsize(self.size[9:-1], self.base_ctype) - elif self.size=="" and (self.type=="charARB" or self.type=="Char"): - self.csize = "strlen" else: s = self.func.get_param(self.size.split('*')[0]) if (s.type=="SizeI" or s.type.endswith("Int32") or s.type.startswith("BufferSize")) and s.kind=="value": @@ -197,7 +195,7 @@ class Function: sys.stderr.write("Compsize '%s' for function '%s' failed: Parameter '%s' has unknown type '%s'\n"%(size, self.name, param.name, param.type)) return if not have_type: - res += "*sizeof(%s)"%param.ctype + res += "*sizeof(%s)"%btype return res def finalize(self): @@ -211,6 +209,7 @@ class Function: class Template: def __init__(self, fn): self.sections = [] + self.handcode = [] literal = True text = "" @@ -221,6 +220,10 @@ class Template: text = "" text += line[1:]+"\n" literal = True + elif line[0]=='!': + parts = line[1:].split() + if parts[0]=="handcode": + self.handcode.append(parts[1]) else: if literal and text: self.add_section(text, literal) @@ -248,6 +251,8 @@ class Template: print sect else: for func in functions: + if func.name in self.handcode: + continue globals = { "w": self.write, "wl": self.writeln, diff --git a/gl.files b/gl.files index d6631d8..8be2a33 100644 --- a/gl.files +++ b/gl.files @@ -4,4 +4,3 @@ spec gl.spec prefix gl ignore category VERSION_3_2 ignore category ARB_sync -ignore function glGetError diff --git a/gl.tm b/gl.tm index fb4f851..bc05d5f 100644 --- a/gl.tm +++ b/gl.tm @@ -10,7 +10,7 @@ BlendingFactorDest,*,*, GLenum,*,* BlendingFactorSrc,*,*, GLenum,*,* Boolean,*,*, GLboolean,*,* BooleanPointer,*,*, GLboolean*,*,* -Char,*,*, GLchar,*,* +Char,*,array, GLchar *,*,value CharPointer,*,*, GLchar*,*,* CheckedFloat32,*,*, GLfloat,*,* CheckedInt32,*,*, GLint,*,* @@ -290,7 +290,7 @@ Int64,*,*, GLint64,*,* UInt64,*,*, GLuint64,*,* # Object handle & data pointers handleARB,*,*, GLhandleARB,*,* -charARB,*,*, GLcharARB,*,* +charARB,*,array, GLcharARB *,*,value charPointerARB,*,*, GLcharARB*,*,* sync,*,*, GLsync,*,*, # EXT_timer_query diff --git a/glx.files b/glx.files index 3d7d138..bfac81e 100644 --- a/glx.files +++ b/glx.files @@ -9,5 +9,3 @@ ignore category SGIX_dmbuffer ignore category SGIX_hyperpipe ignore category NV_video_output ignore category NV_video_capture -ignore function glXGetProcAddress -ignore function glXGetProcAddressARB diff --git a/glx.io b/glx.io index 7322c3a..e30ff09 100644 --- a/glx.io +++ b/glx.io @@ -9,6 +9,7 @@ sizei, int, %i float, float, %g unsigned int *, pointer, %p char *, string, \"%s\" +ubyte *, string, \"%s\" Bool, int, %i Display *, pointer, %p XVisualInfo *, pointer, %p @@ -25,3 +26,4 @@ GLXDrawable, long, %#lx GLXPbuffer, long, %#lx GLXWindow, long, %#lx GLXPixmap, long, %#lx +__GLXextFuncPtr, pointer, %p diff --git a/glx.tm b/glx.tm index 7ba7c61..0a865bd 100644 --- a/glx.tm +++ b/glx.tm @@ -30,7 +30,7 @@ GLenum,*,*, GLenum,*,* GLfunction,*,*, GLfunction,*,* GLint,*,*, GLint,*,* GLsizei,*,*, GLsizei,*,* -GLubyte,*,*, GLubyte,*,* +GLubyte,*,reference, GLubyte *,*,value GLuint,*,*, GLuint,*,* Pixmap,*,*, Pixmap,*,* Status,*,*, Status,*,* diff --git a/source/glprint.c b/source/glprint.c index fbf6e0e..ec8d47e 100644 --- a/source/glprint.c +++ b/source/glprint.c @@ -40,6 +40,8 @@ GlDecoder *glprint_new(char *buffer, unsigned bufsize) init_print(dec); dec->gldError = print_gldError; + + return dec; } char *glprint_get_buffer(GlDecoder *dec) diff --git a/source/glwrap.c b/source/glwrap.c index 0a22c3c..0673b5a 100644 --- a/source/glwrap.c +++ b/source/glwrap.c @@ -262,13 +262,21 @@ GLenum APIENTRY glGetError() { GLenum ret = cur_error; cur_error = GL_NO_ERROR; + begin_packet(FUNC_GLGETERROR); + write_int(ret); + send_packet(); return ret; } void (*glXGetProcAddress(const GLubyte *procname))(void) { void *handle = dlopen(NULL, RTLD_LAZY); - return dlsym(handle, (const char *)procname); + void (*ret)() = dlsym(handle, (const char *)procname); + begin_packet(FUNC_GLXGETPROCADDRESS); + write_pointer(ret); + write_string(procname); + send_packet(); + return ret; } void (*glXGetProcAddressARB(const GLubyte *))(void) __attribute__((alias("glXGetProcAddress"))); diff --git a/source/glwrap.funcs.t b/source/glwrap.funcs.t index a58a1c5..59bdb47 100644 --- a/source/glwrap.funcs.t +++ b/source/glwrap.funcs.t @@ -1,4 +1,7 @@ # $Id$ +!handcode glGetError +!handcode glXGetProcAddress +!handcode glXGetProcAddressARB wl('%s APIENTRY %s(%s)', ret.ctype, func.name, ", ".join([p.ctype+" "+p.name for p in params])) wl('{') wl(' static %s (*orig)(%s);', ret.ctype, ", ".join([p.ctype for p in params]))