Pārlūkot izejas kodu

obsolete

tags/unichrome-last-xinerama
Brian Paul pirms 21 gadiem
vecāks
revīzija
4e120c9718

+ 0
- 8931
src/mesa/glapi/APIspec
Failā izmaiņas netiks attēlotas, jo tās ir par lielu
Parādīt failu


+ 0
- 147
src/mesa/glapi/apiparser.py Parādīt failu

@@ -1,147 +0,0 @@
#!/usr/bin/env python

# $Id: apiparser.py,v 1.2 2003/08/19 01:06:24 brianp Exp $

# Mesa 3-D graphics library
# Version: 4.1
#
# Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


# These helper functions are used by the other Mesa Python scripts.
# The main function is ProcessSpecFile(spedFile, function) which parses
# the named spec file and calls function() for each entry in the spec file.


import string


# Given parallel arrays of types and names, make a C-style parameter string
def MakeArgList(typeList, nameList):
result = ''
i = 1
n = len(typeList)
for typ in typeList:
result = result + typ + ' ' + nameList[i - 1]
if i < n:
result = result + ', '
i = i + 1
#endfor
if result == '':
result = 'void'
#endif
return result
#enddef


prevCatagory = ''

#
# Example callback function for ProcessSpecFile()
#
def PrintRecord(name, returnType, argTypeList, argNameList, alias, offset):
argList = MakeArgList(argTypeList, argNameList)
if category != prevCategory or prevCategory == '':
print '\n/* %s */' % category
prevCategory = category
#endif
print '%s gl%s(%s); /* %d */' % (returnType, name, argList, offset)
#endfor


#
# Process the api spec file
#
def ProcessSpecFile(specFile, userFunc):

NO_OFFSET = -2
# init some vars
prevCategory = ''
funcName = ''
returnType = ''
argTypeList = [ ]
argNameList = [ ]
maxOffset = 0
table = { }
offset = -1
alias = ''

f = open(specFile)
for line in f.readlines():

# split line into tokens
tokens = string.split(line)

if len(tokens) > 0 and line[0] != '#':

if tokens[0] == 'name':
if funcName != '':
# Verify entry has offset or alias
pnts = 0
if offset == NO_OFFSET:
pnts = pnts + 1
if offset >= 0:
pnts = pnts + 1
if alias != '':
pnts = pnts + 1
if pnts != 1:
print 'XXXXXXXXXX bad entry for %s' % funcName
# process the function now
userFunc (funcName, returnType, argTypeList, argNameList, alias, offset)
# reset the lists
argTypeList = [ ]
argNameList = [ ]
returnType = ''
offset = -1
alias = ''

funcName = tokens[1]

elif tokens[0] == 'return':
returnType = string.join(tokens[1:], ' ')
elif tokens[0] == 'param':
argNameList.append(tokens[1])
argTypeList.append(string.join(tokens[2:], ' '))

elif tokens[0] == 'category':
category = tokens[1]

elif tokens[0] == 'offset':
if tokens[1] == '?':
offset = NO_OFFSET
else:
offset = int(tokens[1])
if offset > maxOffset:
maxOffset = offset
# else:
# print 'Unassigned offset for %s' % funcName

elif tokens[0] == 'alias':
alias = tokens[1]

else:
print 'Invalid token %s after function %s' % (tokens[0], funcName)
#endif
#endif
#endfor
#enddef

+ 0
- 284
src/mesa/glapi/glapitemp.py Parādīt failu

@@ -1,284 +0,0 @@
#!/usr/bin/env python

# $Id: glapitemp.py,v 1.7 2004/10/02 22:47:48 brianp Exp $

# Mesa 3-D graphics library
# Version: 4.1
#
# Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


# Generate the glapitemp.h file.
#
# Usage:
# gloffsets.py >glapitemp.h
#
# Dependencies:
# The apispec file must be in the current directory.


import string
import apiparser;


def PrintHead():
print """
/* DO NOT EDIT! This file is generated by the glapitemp.py script. */

/*
* This file is a template which generates the OpenGL API entry point
* functions. It should be included by a .c file which first defines
* the following macros:
* KEYWORD1 - usually nothing, but might be __declspec(dllexport) on Win32
* KEYWORD2 - usually nothing, but might be __stdcall on Win32
* NAME(n) - builds the final function name (usually add "gl" prefix)
* DISPATCH(func, args, msg) - code to do dispatch of named function.
* msg is a printf-style debug message.
* RETURN_DISPATCH(func, args, msg) - code to do dispatch with a return value
*
* Here's an example which generates the usual OpenGL functions:
* #define KEYWORD1
* #define KEYWORD2
* #define NAME(func) gl##func
* #define DISPATCH(func, args, msg) \\
* struct _glapi_table *dispatch = CurrentDispatch; \\
* (*dispatch->func) args
* #define RETURN DISPATCH(func, args, msg) \\
* struct _glapi_table *dispatch = CurrentDispatch; \\
* return (*dispatch->func) args
*
*/


#if defined( NAME )
#ifndef KEYWORD1
#define KEYWORD1
#endif

#ifndef KEYWORD2
#define KEYWORD2
#endif

#ifndef DISPATCH
#error DISPATCH must be defined
#endif

#ifndef RETURN_DISPATCH
#error RETURN_DISPATCH must be defined
#endif

"""

#enddef


def PrintTail():
print"""
#undef KEYWORD1
#undef KEYWORD2
#undef NAME
#undef DISPATCH
#undef RETURN_DISPATCH
#undef DISPATCH_TABLE_NAME
#undef UNUSED_TABLE_NAME
#undef TABLE_ENTRY
"""
#endif


def MakeParamList(nameList):
n = len(nameList)
i = 1
result = ''
for name in nameList:
result = result + name
if i < n:
result = result + ', '
i = i + 1
return result
#enddef


def Contains(haystack, needle):
if string.find(haystack, needle) >= 0:
return 1
else:
return 0
#enddef

def MakePrintfString(funcName, argTypeList, argNameList):
result = '(F, "gl%s(' % (funcName)

n = len(argTypeList)
i = 1
isPointer = {}
floatv = {}
for argType in argTypeList:
isPointer[i] = 0
floatv[i] = 0
if argType == 'GLenum':
result = result + '0x%x'
elif argType in ['GLfloat', 'GLdouble', 'GLclampf', 'GLclampd']:
result = result + '%f'
elif argType in ['GLbyte', 'GLubyte', 'GLshort', 'GLushort', 'GLint', 'GLuint', 'GLboolean', 'GLsizei']:
result = result + '%d'
else:
result = result + '%p'
isPointer[i] = 1
if argType[0:13] == 'const GLfloat' or argType[0:14] == 'const GLdouble':
if Contains(funcName, '2fv') or Contains(funcName, '2dv'):
result = result + ' /* %g, %g */'
floatv[i] = 2
elif Contains(funcName, '3fv') or Contains(funcName, '3dv'):
result = result + ' /* %g, %g, %g */'
floatv[i] = 3
elif Contains(funcName, '4fv') or Contains(funcName, '4dv'):
result = result + ' /* %g, %g, %g, %g */'
floatv[i] = 4
#endif
if i < n:
result = result + ', '
i = i + 1
#endfor

result = result + ');\\n"'

n = len(argNameList)
i = 1
if n > 0:
result = result + ', '
for pname in argNameList:
if isPointer[i]:
result = result + '(const void *) '
result = result + pname
if floatv[i] == 2:
result = result + ', ' + pname + '[0], ' + pname + '[1]'
elif floatv[i] == 3:
result = result + ', ' + pname + '[0], ' + pname + '[1], ' + pname + '[2]'
elif floatv[i] == 4:
result = result + ', ' + pname + '[0], ' + pname + '[1], ' + pname + '[2], ' + pname + '[3]'
if i < n:
result = result + ', '
i = i + 1
result = result + ')'
return result
#enddef


records = []
emittedFuncs = {}
aliasedFuncs = []

def FindOffset(funcName):
for (name, alias, offset) in records:
if name == funcName:
return offset
#endif
#endfor
return -1
#enddef

def EmitFunction(name, returnType, argTypeList, argNameList, alias, offset):
argList = apiparser.MakeArgList(argTypeList, argNameList)
parms = MakeParamList(argNameList)
printString = MakePrintfString(name, argTypeList, argNameList)
if alias == '':
dispatchName = name
else:
dispatchName = alias
if offset < 0:
offset = FindOffset(dispatchName)
if offset >= 0:
print 'KEYWORD1 %s KEYWORD2 NAME(%s)(%s)' % (returnType, name, argList)
print '{'
if returnType == 'void':
print ' DISPATCH(%s, (%s), %s);' % (dispatchName, parms, printString)
else:
print ' RETURN_DISPATCH(%s, (%s), %s);' % (dispatchName, parms, printString)
print '}'
print ''
records.append((name, dispatchName, offset))
if not emittedFuncs.has_key(offset):
emittedFuncs[offset] = name
else:
aliasedFuncs.append(name)
else:
print '/* No dispatch for %s() */' % (name)
#endif


def PrintInitDispatch():
print """
#endif /* defined( NAME ) */

/*
* This is how a dispatch table can be initialized with all the functions
* we generated above.
*/
#ifdef DISPATCH_TABLE_NAME

#ifndef TABLE_ENTRY
#error TABLE_ENTRY must be defined
#endif

void *DISPATCH_TABLE_NAME[] = {"""
keys = emittedFuncs.keys()
keys.sort()
for k in keys:
print ' TABLE_ENTRY(%s),' % (emittedFuncs[k])

print ' /* A whole bunch of no-op functions. These might be called'
print ' * when someone tries to call a dynamically-registered'
print ' * extension function without a current rendering context.'
print ' */'
for i in range(1, 100):
print ' TABLE_ENTRY(Unused),'

print '};'
print '#endif /* DISPATCH_TABLE_NAME */'
print ''
#enddef



def PrintAliasedTable():
print """
/*
* This is just used to silence compiler warnings.
* We list the functions which aren't otherwise used.
*/
#ifdef UNUSED_TABLE_NAME
void *UNUSED_TABLE_NAME[] = {"""
for alias in aliasedFuncs:
print ' TABLE_ENTRY(%s),' % (alias)
#endfor
print '};'
print '#endif /*UNUSED_TABLE_NAME*/'
print ''
#enddef



PrintHead()
apiparser.ProcessSpecFile("APIspec", EmitFunction)
PrintInitDispatch()
PrintAliasedTable()
PrintTail()

+ 0
- 85
src/mesa/glapi/gloffsets.py Parādīt failu

@@ -1,85 +0,0 @@
#!/usr/bin/env python

# $Id: gloffsets.py,v 1.5 2001/11/18 22:42:57 brianp Exp $

# Mesa 3-D graphics library
# Version: 4.1
#
# Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


# Generate the glapioffsets.h file.
#
# Usage:
# gloffsets.py >glapioffsets.h
#
# Dependencies:
# The apispec file must be in the current directory.



import apiparser;


def PrintHead():
print '/* DO NOT EDIT - This file generated automatically by gloffsets.py script */'
print '#ifndef _GLAPI_OFFSETS_H_'
print '#define _GLAPI_OFFSETS_H_'
print ''
return
#enddef


def PrintTail():
print ''
print '#endif'
#enddef


records = {}

def AddOffset(name, returnType, argTypeList, argNameList, alias, offset):
argList = apiparser.MakeArgList(argTypeList, argNameList)
if offset >= 0 and not records.has_key(offset):
records[offset] = name
#print '#define _gloffset_%s %d' % (name, offset)
#enddef


def PrintRecords():
keys = records.keys()
keys.sort()
prevk = -1
for k in keys:
if k != prevk + 1:
#print 'Missing offset %d' % (prevk)
pass
prevk = int(k)
name = records[k]
print '#define _gloffset_%s %d' % (name, k)
#endef




PrintHead()
apiparser.ProcessSpecFile("APIspec", AddOffset)
PrintRecords()
PrintTail()

+ 0
- 89
src/mesa/glapi/glprocs.py Parādīt failu

@@ -1,89 +0,0 @@
#!/usr/bin/env python

# $Id: glprocs.py,v 1.1 2001/11/18 22:42:57 brianp Exp $

# Mesa 3-D graphics library
# Version: 4.1
#
# Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


# Generate the glprocs.h file.
#
# Usage:
# gloffsets.py >glprocs.h
#
# Dependencies:
# The apispec file must be in the current directory.



import apiparser
import string


def PrintHead():
print '/* DO NOT EDIT - This file generated automatically by glprocs.py script */'
print ''
print '/* This file is only included by glapi.c and is used for'
print ' * the GetProcAddress() function'
print ' */'
print ''
print 'static struct name_address_offset static_functions[] = {'
return
#enddef


def PrintTail():
print ' { NULL, NULL } /* end of list marker */'
print '};'
#enddef


records = []

def FindOffset(funcName):
for (name, alias, offset) in records:
if name == funcName:
return offset
#endif
#endfor
return -1
#enddef


def EmitEntry(name, returnType, argTypeList, argNameList, alias, offset):
if alias == '':
dispatchName = name
else:
dispatchName = alias
if offset < 0:
offset = FindOffset(dispatchName)
if offset >= 0 and string.find(name, "unused") == -1:
print ' { "gl%s", (GLvoid *) gl%s, _gloffset_%s },' % (name, name, dispatchName)
# save this info in case we need to look up an alias later
records.append((name, dispatchName, offset))

#enddef


PrintHead()
apiparser.ProcessSpecFile("APIspec", EmitEntry)
PrintTail()

+ 0
- 134
src/mesa/glapi/glsparcasm.py Parādīt failu

@@ -1,134 +0,0 @@
#!/usr/bin/env python

# Mesa 3-D graphics library
# Version: 5.1
#
# Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


# Generate the src/SPARC/glapi_sparc.S file.
#
# Usage:
# gloffsets.py >glapi_sparc.S
#
# Dependencies:
# The apispec file must be in the current directory.


import apiparser;


def PrintHead():
print '/* DO NOT EDIT - This file generated automatically with glsparcasm.py script */'
print '#include "glapioffsets.h"'
print ''
print '/* The _glapi_Dispatch symbol addresses get relocated into the'
print ' * sethi/or instruction sequences below at library init time.'
print ' */'
print ''
print ''
print '.text'
print '.align 32'
print '.globl __glapi_sparc_icache_flush'
print '__glapi_sparc_icache_flush: /* %o0 = insn_addr */'
print '\tflush\t%o0'
print '\tretl'
print '\tnop'
print ''
print '.data'
print '.align 64'
print ''
print '.globl _mesa_sparc_glapi_begin'
print '.type _mesa_sparc_glapi_begin,#function'
print '_mesa_sparc_glapi_begin:'
return
#endif

def PrintTail():
print '\t nop'
print ''
print '.globl _mesa_sparc_glapi_end'
print '.type _mesa_sparc_glapi_end,#function'
print '_mesa_sparc_glapi_end:'
print ''
#endif



records = []

def FindOffset(funcName):
for (name, alias, offset) in records:
if name == funcName:
return offset
#endif
#endfor
return -1
#enddef

def EmitFunction(name, returnType, argTypeList, argNameList, alias, offset):
argList = apiparser.MakeArgList(argTypeList, argNameList)
if alias != '':
dispatchName = alias
else:
dispatchName = name
#endif
if offset < 0:
# try to find offset from alias name
assert dispatchName != ''
offset = FindOffset(dispatchName)
if offset == -1:
#print 'Cannot dispatch %s' % name
return
#endif
#endif

# save this info in case we need to look up an alias later
records.append((name, dispatchName, offset))

# print the assembly code
print ''
print '.globl gl%s' % (name)
print '.type gl%s,#function' % (name)
print 'gl%s:' % (name)
print '#if defined(__sparc_v9__) && !defined(__linux__)'
print '\tsethi\t%hi(0x00000000), %g2'
print '\tsethi\t%hi(0x00000000), %g1'
print '\tor\t%g2, %lo(0x00000000), %g2'
print '\tor\t%g1, %lo(0x00000000), %g1'
print '\tsllx\t%g2, 32, %g2'
print '\tldx\t[%g1 + %g2], %g1'
print "\tsethi\t%%hi(8 * _gloffset_%s), %%g2" % (dispatchName)
print "\tor\t%%g2, %%lo(8 * _gloffset_%s), %%g2" % (dispatchName)
print '\tldx\t[%g1 + %g2], %g3'
print '#else'
print '\tsethi\t%hi(0x00000000), %g1'
print '\tld\t[%g1 + %lo(0x00000000)], %g1'
print "\tld\t[%%g1 + (4 * _gloffset_%s)], %%g3" % (dispatchName)
print '#endif'
print '\tjmpl\t%g3, %g0'
print '\tnop'
#enddef


PrintHead()
apiparser.ProcessSpecFile("APIspec", EmitFunction)
PrintTail()

+ 0
- 89
src/mesa/glapi/gltable.py Parādīt failu

@@ -1,89 +0,0 @@
#!/usr/bin/env python


# Mesa 3-D graphics library
# Version: 5.1
#
# Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


# Generate the glapitable.h file.
#
# Usage:
# python gloffsets.py >glapitable.h
#
# Dependencies:
# The apispec file must be in the current directory.


import apiparser;


def PrintHead():
print '/* DO NOT EDIT - This file generated automatically with gltable.py script */'
print '#ifndef _GLAPI_TABLE_H_'
print '#define _GLAPI_TABLE_H_'
print ''
print '#ifndef GLAPIENTRYP'
print '#define GLAPIENTRYP'
print '#endif'
print ''
print 'struct _glapi_table'
print '{'
return
#endif


def PrintTail():
print '};'
print ''
print '#endif'
#endif


records = {}

def DoRecord(name, returnType, argTypeList, argNameList, alias, offset):
argList = apiparser.MakeArgList(argTypeList, argNameList)
if offset >= 0 and not records.has_key(offset):
records[offset] = (name, returnType, argList)
#print '#define _gloffset_%s %d' % (name, offset)
#endif


def PrintRecords():
keys = records.keys()
keys.sort()
prevk = -1
for k in keys:
if k != prevk + 1:
#print 'Missing offset %d' % (prevk)
pass
prevk = int(k)
(name, returnType, argList) = records[k]
print ' %s (GLAPIENTRYP %s)(%s); /* %d */' % (returnType, name, argList, k)
#endef


PrintHead()
apiparser.ProcessSpecFile("APIspec", DoRecord)
PrintRecords()
PrintTail()


+ 0
- 136
src/mesa/glapi/glx86asm.py Parādīt failu

@@ -1,136 +0,0 @@
#!/usr/bin/env python


# Mesa 3-D graphics library
# Version: 4.1
#
# Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


# Generate the src/X86/glapi_x86.S file.
#
# Usage:
# gloffsets.py >glapi_x86.S
#
# Dependencies:
# The apispec file must be in the current directory.


import apiparser


def PrintHead():
print '/* DO NOT EDIT - This file generated automatically with glx86asm.py script */'
print '#include "assyntax.h"'
print '#include "glapioffsets.h"'
print ''
print '#ifndef __WIN32__'
print ''
print '#if defined(STDCALL_API)'
print '#define GL_PREFIX(n,n2) GLNAME(CONCAT(gl,n2))'
print '#elif defined(USE_MGL_NAMESPACE)'
print '#define GL_PREFIX(n,n2) GLNAME(CONCAT(mgl,n))'
print '#else'
print '#define GL_PREFIX(n,n2) GLNAME(CONCAT(gl,n))'
print '#endif'
print ''
print '#define GL_OFFSET(x) CODEPTR(REGOFF(4 * x, EAX))'
print ''
print '#if defined(GNU_ASSEMBLER) && !defined(__DJGPP__) && !defined(__MINGW32__)'
print '#define GLOBL_FN(x) GLOBL x ; .type x,@function'
print '#else'
print '#define GLOBL_FN(x) GLOBL x'
print '#endif'
print ''
print 'SEG_TEXT'
print ''
print 'EXTERN GLNAME(_glapi_Dispatch)'
print ''
return
#enddef


def PrintTail():
print ''
print '#endif /* __WIN32__ */'
#enddef



records = []

def FindOffset(funcName):
for (name, alias, offset) in records:
if name == funcName:
return offset
#endif
#endfor
return -1
#enddef

# Find the size of the arguments on the stack for _stdcall name mangling
def FindStackSize(typeList):
result = 0
for typ in typeList:
if typ == 'GLdouble' or typ == 'GLclampd':
result += 8;
else:
result += 4;
#endif
#endfor
return result
#enddef

def EmitFunction(name, returnType, argTypeList, argNameList, alias, offset):
argList = apiparser.MakeArgList(argTypeList, argNameList)
if alias != '':
dispatchName = alias
else:
dispatchName = name
#endif
if offset < 0:
# try to find offset from alias name
assert dispatchName != ''
offset = FindOffset(dispatchName)
if offset == -1:
#print 'Cannot dispatch %s' % name
return
#endif
#endif

# save this info in case we need to look up an alias later
records.append((name, dispatchName, offset))

# Find the argument stack size for _stdcall name mangling
stackSize = FindStackSize(argTypeList)

# print the assembly code
print 'ALIGNTEXT16'
print "GLOBL_FN(GL_PREFIX(%s,%s@%s))" % (name, name, stackSize)
print "GL_PREFIX(%s,%s@%s):" % (name, name, stackSize)
print '\tMOV_L(CONTENT(GLNAME(_glapi_Dispatch)), EAX)'
print "\tJMP(GL_OFFSET(_gloffset_%s))" % (dispatchName)
print ''
#enddef

PrintHead()
apiparser.ProcessSpecFile("APIspec", EmitFunction)
PrintTail()

Notiek ielāde…
Atcelt
Saglabāt