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 #-------------------------------------------------------------------------
23 from egl.common import *
24 from khr_util.format import indentLines, commandParams, commandArgs
25 import khr_util.registry
26 from itertools import chain
29 from itertools import imap
33 def virtualMemberDecl (command):
34 return "virtual %s\t%s\t(%s) const\t= 0;" % (
36 getFunctionMemberName(command.name),
37 commandParams(command))
39 def concreteMemberDecl (command):
40 return "%s\t%s\t(%s) const;" % (
42 getFunctionMemberName(command.name),
43 commandParams(command))
45 def memberImpl (command):
47 {returnType} FuncPtrLibrary::{memberName} ({paramDecls}) const
49 {maybeReturn}m_egl.{memberName}({arguments});
51 return template.format(
52 returnType = command.type,
53 mangledName = getFunctionMemberName(command.name),
54 paramDecls = commandParams(command),
55 maybeReturn = "return " if command.type != 'void' else "",
56 memberName = getFunctionMemberName(command.name),
57 arguments = commandArgs(command))
59 def initFunctionEntry (command):
60 return "dst->%s\t= (%sFunc)\tloader->get(\"%s\");" % (
61 getFunctionMemberName(command.name),
65 def getExtOnlyIface (registry, api, extensions):
66 spec = khr_util.registry.InterfaceSpec()
68 for extension in registry.extensions:
69 if not khr_util.registry.getExtensionName(extension) in extensions:
72 if not khr_util.registry.extensionSupports(extension, api):
75 spec.addExtension(extension, api)
77 return khr_util.registry.createInterface(registry, spec, api)
79 def commandLibraryEntry (command):
80 return "\t{ \"%s\",\t(deFunctionPtr)%s }," % (command.name, command.name)
82 def genStaticLibrary (registry):
83 genCommandLists(registry, commandLibraryEntry,
84 check = lambda api, version: api == 'egl' and version in set(["1.4", "1.5"]),
85 directory = EGL_WRAPPER_DIR,
86 filePattern = "eglwStaticLibrary%s.inl",
90 defaultIface = getDefaultInterface()
91 noExtIface = getInterface(registry, 'egl', VERSION)
92 extOnlyIface = getExtOnlyIface(registry, 'egl', EXTENSIONS)
94 genCommandList(defaultIface, virtualMemberDecl, EGL_WRAPPER_DIR, "eglwLibrary.inl", True)
95 genCommandList(defaultIface, concreteMemberDecl, EGL_WRAPPER_DIR, "eglwFuncPtrLibraryDecl.inl", True)
96 genCommandList(defaultIface, memberImpl, EGL_WRAPPER_DIR, "eglwFuncPtrLibraryImpl.inl")
98 genCommandList(noExtIface, initFunctionEntry, EGL_WRAPPER_DIR, "eglwInitCore.inl", True)
99 genCommandList(extOnlyIface, initFunctionEntry, EGL_WRAPPER_DIR, "eglwInitExtensions.inl", True)
101 genStaticLibrary(registry)