1 # -*- coding: utf-8 -*-
3 #-------------------------------------------------------------------------
4 # drawElements Quality Program utilities
5 # --------------------------------------
7 # Copyright 2015 The Android Open Source Project
9 # Licensed under the Apache License, Version 2.0 (the "License");
10 # you may not use this file except in compliance with the License.
11 # You may obtain a copy of the License at
13 # http://www.apache.org/licenses/LICENSE-2.0
15 # Unless required by applicable law or agreed to in writing, software
16 # distributed under the License is distributed on an "AS IS" BASIS,
17 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 # See the License for the specific language governing permissions and
19 # limitations under the License.
21 #-------------------------------------------------------------------------
24 from khr_util.format import indentLines, commandParams, commandArgs
25 import khr_util.registry
26 from itertools import imap, chain
28 def virtualMemberDecl (command):
29 return "virtual %s\t%s\t(%s) const\t= 0;" % (
31 getFunctionMemberName(command.name),
32 commandParams(command))
34 def concreteMemberDecl (command):
35 return "%s\t%s\t(%s) const;" % (
37 getFunctionMemberName(command.name),
38 commandParams(command))
40 def memberImpl (command):
42 {returnType} FuncPtrLibrary::{memberName} ({paramDecls}) const
44 {maybeReturn}m_egl.{memberName}({arguments});
46 return template.format(
47 returnType = command.type,
48 mangledName = getFunctionMemberName(command.name),
49 paramDecls = commandParams(command),
50 maybeReturn = "return " if command.type != 'void' else "",
51 memberName = getFunctionMemberName(command.name),
52 arguments = commandArgs(command))
54 def initFunctionEntry (command):
55 return "dst->%s\t= (%sFunc)\tloader->get(\"%s\");" % (
56 getFunctionMemberName(command.name),
60 def getExtOnlyIface (registry, api, extensions):
61 spec = khr_util.registry.InterfaceSpec()
63 for extension in registry.extensions:
64 if not khr_util.registry.getExtensionName(extension) in extensions:
67 if not khr_util.registry.extensionSupports(extension, api):
70 spec.addExtension(extension, api)
72 return khr_util.registry.createInterface(registry, spec, api)
74 def commandLibraryEntry (command):
75 return "\t{ \"%s\",\t(deFunctionPtr)%s }," % (command.name, command.name)
77 def genStaticLibrary (registry):
78 genCommandLists(registry, commandLibraryEntry,
79 check = lambda api, version: api == 'egl' and version in set(["1.4", "1.5"]),
80 directory = EGL_WRAPPER_DIR,
81 filePattern = "eglwStaticLibrary%s.inl",
85 defaultIface = getDefaultInterface()
86 noExtIface = getInterface(registry, 'egl', VERSION)
87 extOnlyIface = getExtOnlyIface(registry, 'egl', EXTENSIONS)
89 genCommandList(defaultIface, virtualMemberDecl, EGL_WRAPPER_DIR, "eglwLibrary.inl", True)
90 genCommandList(defaultIface, concreteMemberDecl, EGL_WRAPPER_DIR, "eglwFuncPtrLibraryDecl.inl", True)
91 genCommandList(defaultIface, memberImpl, EGL_WRAPPER_DIR, "eglwFuncPtrLibraryImpl.inl")
93 genCommandList(noExtIface, initFunctionEntry, EGL_WRAPPER_DIR, "eglwInitCore.inl", True)
94 genCommandList(extOnlyIface, initFunctionEntry, EGL_WRAPPER_DIR, "eglwInitExtensions.inl", True)
96 genStaticLibrary(registry)