コード例 #1
0
#endif

"""

print """
struct name_address {
  const char *name;
  CR_PROC address;
};

PROC WINAPI wglGetProcAddress_prox( LPCSTR name );

static struct name_address functions[] = {
"""

keys = apiutil.GetAllFunctions(sys.argv[1] + "/APIspec.txt")
for func_name in keys:
    if "Chromium" == apiutil.Category(func_name):
        continue
    if "VBox" == apiutil.Category(func_name):
        continue
    if func_name == "BoundsInfoCR":
        continue
    if "GL_chromium" == apiutil.Category(func_name):
        pass  #continue

    wrap = apiutil.GetCategoryWrapper(func_name)
    name = "gl" + func_name
    address = "cr_gl" + func_name
    if wrap:
        print '#ifdef CR_%s' % wrap
コード例 #2
0
print """
/* DO NOT EDIT - THIS FILE GENERATED BY THE getprocaddress.py SCRIPT */
#include "chromium.h"
#include "cr_string.h"
#include "cr_version.h"
#include "stub.h"


#ifdef WINDOWS
#pragma warning( disable: 4055 )
#endif

"""

# Extern-like declarations
keys = apiutil.GetAllFunctions("../glapi_parser/APIspec.txt")
for func_name in keys:
    if "Chromium" == apiutil.Category(func_name):
        continue
    if func_name == "BoundsInfoCR":
        continue
    if "GL_chromium" == apiutil.Category(func_name):
        pass  #continue

    return_type = apiutil.ReturnType(func_name)
    params = apiutil.Parameters(func_name)

    print "%s cr_gl%s( %s );" % (return_type, func_name,
                                 apiutil.MakeDeclarationString(params))

print """
コード例 #3
0
def GenerateEntrypoints():

    #apiutil.CopyrightC()

    # Get sorted list of dispatched functions.
    # The order is very important - it must match cr_opcodes.h
    # and spu_dispatch_table.h
    print '%include "iprt/asmdefs.mac"'
    print ""
    print "%ifdef RT_ARCH_AMD64"
    print "extern glim"
    print "%else ; X86"
    print "extern glim"
    print "%endif"
    print ""

    keys = apiutil.GetDispatchedFunctions(sys.argv[1] + "/APIspec.txt")

    for index in range(len(keys)):
        func_name = keys[index]
        if apiutil.Category(func_name) == "Chromium":
            continue
        if apiutil.Category(func_name) == "VBox":
            continue

        print "BEGINPROC_EXPORTED gl%s" % func_name
        print "%ifdef RT_ARCH_AMD64"
        print "\tmov \trax, qword glim+%d" % (8 * index)
        print "\tjmp \t[rax]"
        print "%else ; X86"
        print "\tmov \teax, dword glim+%d" % (4 * index)
        print "\tjmp \t[eax]"
        print "%endif"
        print "ENDPROC gl%s" % func_name
        print ""

    print ';'
    print '; Aliases'
    print ';'

    # Now loop over all the functions and take care of any aliases
    allkeys = apiutil.GetAllFunctions(sys.argv[1] + "/APIspec.txt")
    for func_name in allkeys:
        if "omit" in apiutil.ChromiumProps(func_name):
            continue

        if func_name in keys:
            # we already processed this function earlier
            continue

        # alias is the function we're aliasing
        alias = apiutil.Alias(func_name)
        if alias:
            # this dict lookup should never fail (raise an exception)!
            index = keys.index(alias)
            print "BEGINPROC_EXPORTED gl%s" % func_name
            print "%ifdef RT_ARCH_AMD64"
            print "\tmov \trax, qword glim+%d" % (8 * index)
            print "\tjmp \t[rax]"
            print "%else ; X86"
            print "\tmov \teax, dword glim+%d" % (4 * index)
            print "\tjmp \t[eax]"
            print "%endif"
            print "ENDPROC gl%s" % func_name
            print ""

    print ';'
    print '; No-op stubs'
    print ';'

    # Now generate no-op stub functions
    for func_name in allkeys:
        if "stub" in apiutil.ChromiumProps(func_name):
            print "BEGINPROC_EXPORTED gl%s" % func_name
            print "\tleave"
            print "\tret"
            print "ENDPROC gl%s" % func_name
            print ""
コード例 #4
0
def GenerateEntrypoints(hacks=[]):
    """Emit code for all the OpenGL/Chromium entrypoints.
    hacks is an optional list of functions which are special cased.
    """

    apiutil.CopyrightC()

    print('#define GL_GLEXT_PROTOTYPES')
    print('#include <stdio.h>')
    print('#include <stdlib.h>')
    print('#include <GL/gl.h>')
    print('#include "chromium.h"')
    print('#include "stub.h"')
    print('#include "dri_glx.h"')
    print('')
    print('#ifdef __GNUC__')
    print('# if (__GNUC__ << 16) + __GNUC_MINOR__ >= 0x40002')
    print('#  pragma GCC diagnostic ignored "-Wunused-parameter"')
    print('# endif')
    print('#endif')

    # Get sorted list of dispatched functions.
    # The order is very important - it must match cr_opcodes.h
    # and spu_dispatch_table.h
    keys = apiutil.GetDispatchedFunctions(sys.argv[1] + "/APIspec.txt")

    for index in range(len(keys)):
        func_name = keys[index]
        if apiutil.Category(func_name) == "Chromium":
            # this function is defined in stub.c
            continue

        return_type = apiutil.ReturnType(func_name)
        params = apiutil.Parameters(func_name)

        if func_name in hacks:
            print("/* hacked entrypoint: %s */" % func_name)
            if func_name == "TexImage3D":
                # Pretty common: internalformat is GLenum, not GLint
                print(
                    "void glTexImage3D( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels )"
                )
                print("{")
                print(
                    "\tglim.TexImage3D( target, level, (GLint) internalformat, width, height, depth, border, format, type, pixels );"
                )
                print("}")
            elif func_name == "TexImage2D":
                # Pretty common: internalformat is GLenum, not GLint
                print(
                    "void glTexImage2D( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels )"
                )
                print("{")
                print(
                    "\tglim.TexImage2D( target, level, (GLint) internalformat, width, height, border, format, type, pixels );"
                )
                print("}")
            elif func_name == "TexImage1D":
                # Pretty common: internalformat is GLenum, not GLint
                print(
                    "void glTexImage1D( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels )"
                )
                print("{")
                print(
                    "\tglim.TexImage1D( target, level, (GLint) internalformat, width, border, format, type, pixels );"
                )
                print("}")
            elif func_name == "EdgeFlagPointer":
                # second arg is GLboolean instead of GLvoid
                print(
                    "void glEdgeFlagPointer( GLsizei stride, const GLboolean *pointer )"
                )
                print("{")
                print("\tglim.EdgeFlagPointer( stride, pointer );")
                print("}")
            elif func_name == "ProgramParameters4fvNV":
                print(
                    "void glProgramParameters4fvNV( GLenum target, GLuint index, GLuint num, const GLfloat *params )"
                )
                print("{")
                print(
                    "\tglim.ProgramParameters4fvNV( target, index, num, params );"
                )
                print("}")
            elif func_name == "MultiDrawElementsEXT":
                print(
                    "void glMultiDrawElementsEXT(GLenum mode, GLsizei *count, GLenum type, const GLvoid **indices, GLsizei primcount)"
                )
                print("{")
                print(
                    "\tglim.MultiDrawElementsEXT(mode, count,type, indices, primcount);"
                )
                print("}")
            elif func_name == "ProgramParameters4dvNV":
                print(
                    "void glProgramParameters4dvNV( GLenum target, GLuint index, GLuint num, const GLdouble *params )"
                )
                print("{")
                print(
                    "\tglim.ProgramParameters4dvNV( target, index, num, params );"
                )
                print("}")
        else:
            # the usual path
            print("%s VBOXGLTAG(gl%s)(%s);" %
                  (return_type, func_name,
                   apiutil.MakeDeclarationString(params)))
            print("")
            print("%s VBOXGLTAG(gl%s)(%s)" %
                  (return_type, func_name,
                   apiutil.MakeDeclarationString(params)))
            print("{")
            print("\t", end="")
            if return_type != "void":
                print("return ", end=" ")
            print("glim.%s(%s);" % (func_name, apiutil.MakeCallString(params)))
            print("}")
            print("")

    print('/*')
    print('* Aliases')
    print('*/')

    # Now loop over all the functions and take care of any aliases
    allkeys = apiutil.GetAllFunctions(sys.argv[1] + "/APIspec.txt")
    for func_name in allkeys:
        if "omit" in apiutil.ChromiumProps(func_name):
            continue

        if func_name in keys:
            # we already processed this function earlier
            continue

        # alias is the function we're aliasing
        alias = apiutil.Alias(func_name)
        if alias:
            if func_name in hacks:
                print("/* hacked entrypoint: %s */" % func_name)
                if func_name == "MultiDrawArrays":
                    print(
                        "void glMultiDrawArrays( GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount )"
                    )
                    print("{")
                    print(
                        "\tglim.MultiDrawArraysEXT( mode, (GLint*)first, (GLsizei*)count, primcount );"
                    )
                    print("}")
                elif func_name == "BufferData":
                    print(
                        "void glBufferData(GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage)"
                    )
                    print("{")
                    print("\tglim.BufferDataARB(target, size, data, usage);")
                    print("}")
                elif func_name == "BufferSubData":
                    print(
                        "void glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data)"
                    )
                    print("{")
                    print(
                        "\tglim.BufferSubDataARB(target, offset, size, data);")
                    print("}")
                elif func_name == "GetBufferSubData":
                    print(
                        "void glGetBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data)"
                    )
                    print("{")
                    print(
                        "\tglim.GetBufferSubDataARB(target, offset, size, data);"
                    )
                    print("}")
            else:
                return_type = apiutil.ReturnType(func_name)
                params = apiutil.Parameters(func_name)
                print("%s VBOXGLTAG(gl%s)(%s);" %
                      (return_type, func_name,
                       apiutil.MakeDeclarationString(params)))
                print("")
                print("%s VBOXGLTAG(gl%s)(%s)" %
                      (return_type, func_name,
                       apiutil.MakeDeclarationString(params)))
                print("{")
                print("\t", end="")
                if return_type != "void":
                    print("return ", end=" ")
                print("glim.%s(%s);" % (alias, apiutil.MakeCallString(params)))
                print("}")
                print("")

    print('/*')
    print('* No-op stubs')
    print('*/')

    # Now generate no-op stub functions
    for func_name in allkeys:
        if "stub" in apiutil.ChromiumProps(func_name):
            return_type = apiutil.ReturnType(func_name)
            params = apiutil.Parameters(func_name)

            print("%s VBOXGLTAG(gl%s)(%s);" %
                  (return_type, func_name,
                   apiutil.MakeDeclarationString(params)))
            print("")
            print("%s VBOXGLTAG(gl%s)(%s)" %
                  (return_type, func_name,
                   apiutil.MakeDeclarationString(params)))
            print("{")
            if return_type != "void":
                print("return (%s) 0" % return_type)
            print("}")
            print("")
コード例 #5
0
ファイル: windows_exports.py プロジェクト: aspirefhaha/vbox50
def GenerateEntrypoints():

    apiutil.CopyrightC()

    print '#include "chromium.h"'
    print '#include "stub.h"'
    print ''
    print '#define NAKED __declspec(naked)'
    print '#define UNUSED(x) ((void)(x))'
    print ''

    # Get sorted list of dispatched functions.
    # The order is very important - it must match cr_opcodes.h
    # and spu_dispatch_table.h
    keys = apiutil.GetDispatchedFunctions(sys.argv[1] + "/APIspec.txt")

    for index in range(len(keys)):
        func_name = keys[index]
        if apiutil.Category(func_name) == "Chromium":
            continue
        if apiutil.Category(func_name) == "VBox":
            continue

        return_type = apiutil.ReturnType(func_name)
        params = apiutil.Parameters(func_name)

        print "NAKED %s cr_gl%s( %s )" % (
            return_type, func_name, apiutil.MakeDeclarationString(params))
        print "{"
        print "\t__asm jmp [glim.%s]" % func_name
        for (name, type, vecSize) in params:
            print "\tUNUSED( %s );" % name
        print "}"
        print ""

    print '/*'
    print '* Aliases'
    print '*/'

    # Now loop over all the functions and take care of any aliases
    allkeys = apiutil.GetAllFunctions(sys.argv[1] + "/APIspec.txt")
    for func_name in allkeys:
        if "omit" in apiutil.ChromiumProps(func_name):
            continue

        if func_name in keys:
            # we already processed this function earlier
            continue

        # alias is the function we're aliasing
        alias = apiutil.Alias(func_name)
        if alias:
            return_type = apiutil.ReturnType(func_name)
            params = apiutil.Parameters(func_name)
            print "NAKED %s cr_gl%s( %s )" % (
                return_type, func_name, apiutil.MakeDeclarationString(params))
            print "{"
            print "\t__asm jmp [glim.%s]" % alias
            for (name, type, vecSize) in params:
                print "\tUNUSED( %s );" % name
            print "}"
            print ""

    print '/*'
    print '* No-op stubs'
    print '*/'

    # Now generate no-op stub functions
    for func_name in allkeys:
        if "stub" in apiutil.ChromiumProps(func_name):
            return_type = apiutil.ReturnType(func_name)
            params = apiutil.Parameters(func_name)
            print "NAKED %s cr_gl%s( %s )" % (
                return_type, func_name, apiutil.MakeDeclarationString(params))
            print "{"
            if return_type != "void":
                print "return (%s) 0" % return_type
            print "}"
            print ""
コード例 #6
0
ファイル: Linux_i386_exports.py プロジェクト: pomeloos/VMGL-1
def GenerateEntrypoints():

	apiutil.CopyrightC()

	# Get sorted list of dispatched functions.
	# The order is very important - it must match cr_opcodes.h
	# and spu_dispatch_table.h
	keys = apiutil.GetDispatchedFunctions("../glapi_parser/APIspec.txt")

	for index in range(len(keys)):
		func_name = keys[index]
		if apiutil.Category(func_name) == "Chromium":
			continue

		print "\t.align 4"
		print ".globl gl%s" % func_name
		print "\t.type gl%s,@function" % func_name
		print "gl%s:" % func_name
		print "\tmovl glim+%d, %%eax" % (4*index)
		print "\tjmp *%eax"
		print ""


	print '/*'
	print '* Aliases'
	print '*/'

	# Now loop over all the functions and take care of any aliases
	allkeys = apiutil.GetAllFunctions("../glapi_parser/APIspec.txt")
	for func_name in allkeys:
		if "omit" in apiutil.ChromiumProps(func_name):
			continue

		if func_name in keys:
			# we already processed this function earlier
			continue

		# alias is the function we're aliasing
		alias = apiutil.Alias(func_name)
		if alias:
			# this dict lookup should never fail (raise an exception)!
			index = keys.index(alias)
			print "\t.align 4"
			print ".globl gl%s" % func_name
			print "\t.type gl%s,@function" % func_name
			print "gl%s:" % func_name
			print "\tmovl glim+%d, %%eax" % (4*index)
			print "\tjmp *%eax"
			print ""


	print '/*'
	print '* No-op stubs'
	print '*/'

	# Now generate no-op stub functions
	for func_name in allkeys:
		if "stub" in apiutil.ChromiumProps(func_name):
			print "\t.align 4"
			print ".globl gl%s" % func_name
			print "\t.type gl%s,@function" % func_name
			print "gl%s:" % func_name
			print "\tleave"
			print "\tret"
			print ""