Adding include and import handling to api language
include merges symbol tables into the current api file, import processes
an api file and makes it's symbols available.
Change-Id: I195bfcc144b67f8c00022321002d198fdba16247
diff --git a/api/api.go b/api/api.go
new file mode 100644
index 0000000..b6df1b1
--- /dev/null
+++ b/api/api.go
@@ -0,0 +1,149 @@
+// Copyright (C) 2014 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+// Package api holds the main interface to the api language libraries.
+// It provides functions for going from api files to abstract syntax trees and
+// processed semantic trees.
+package api
+
+import (
+ "fmt"
+ "io/ioutil"
+ "path/filepath"
+ "sort"
+
+ "android.googlesource.com/platform/tools/gpu/api/ast"
+ "android.googlesource.com/platform/tools/gpu/api/parser"
+ "android.googlesource.com/platform/tools/gpu/api/resolver"
+ "android.googlesource.com/platform/tools/gpu/api/semantic"
+ "android.googlesource.com/platform/tools/gpu/parse"
+)
+
+// Processor holds the state when resolving multiple api files.
+type Processor struct {
+ Parsed map[string]*ast.API
+ Resolved map[string]*semantic.API
+}
+
+// DefaultProcessor is the Processor used in the package level functions.
+// Most applications will not need multiple instances of a Processor, and can
+// just use this one.
+var DefaultProcessor Processor
+
+// Parse parses the api file with the DefaultProcessor.
+// See Processor.Parse for details.
+func Parse(apiname string) (*ast.API, parse.ErrorList) {
+ return DefaultProcessor.Parse(apiname)
+}
+
+// Parse returns an ast that represents the supplied filename.
+// It if the file has already been parsed, the cached ast will be returned,
+// otherwise it invokes parser.Parse on the content of the supplied file name.
+func (p *Processor) Parse(path string) (*ast.API, parse.ErrorList) {
+ if api, ok := p.Parsed[path]; ok {
+ return api, nil
+ }
+ info, err := ioutil.ReadFile(path)
+ if err != nil {
+ return nil, parse.ErrorList{parse.Error{Message: err.Error()}}
+ }
+ return parser.Parse(string(info))
+}
+
+// Resolve resolves the api file with the DefaultProcessor.
+// See Processor.Resolve for details.
+func Resolve(apiname string, mappings resolver.ASTToSemantic) (*semantic.API, parse.ErrorList) {
+ return DefaultProcessor.Resolve(apiname, mappings)
+}
+
+// Resolve returns a semantic.API that represents the supplied api file name.
+// If the file has already been resolved, the cached semantic tree is returned,
+// otherwise the file and all dependant files are parsed using Processor.Parse.
+// Recursive calls are made to Resolve for all named imports, and then finally
+// the ast and all included ast's are handed to resolver.Resolve to do semantic
+// processing.
+func (p *Processor) Resolve(apiname string, mappings resolver.ASTToSemantic) (*semantic.API, parse.ErrorList) {
+ absname, err := filepath.Abs(apiname)
+ if err != nil {
+ return nil, parse.ErrorList{parse.Error{Message: err.Error()}}
+ }
+ if api, ok := p.Resolved[absname]; ok {
+ return api, nil
+ }
+ // Parse all the includes
+ wd, name := filepath.Split(absname)
+ includes := map[string]*ast.API{}
+ errs := p.include(includes, wd, name)
+ if len(errs) > 0 {
+ return nil, errs
+ }
+ // Build a sorted list of includes
+ names := make(sort.StringSlice, 0, len(includes))
+ for name := range includes {
+ names = append(names, name)
+ }
+ names.Sort()
+ list := make([]*ast.API, len(names))
+ for i, name := range names {
+ list[i] = includes[name]
+ }
+ // Resolve all the imports
+ imports := map[string]*semantic.API{}
+ for _, api := range list {
+ for _, i := range api.Imports {
+ if i.Name == nil {
+ // unnamed imports have already been included
+ continue
+ }
+ if _, seen := imports[i.Name.Value]; seen {
+ return nil, parse.ErrorList{parse.Error{
+ Message: fmt.Sprintf("Duplicate import %s", i.Name.Value)},
+ }
+ }
+ api, errs := Resolve(i.Path.Value, mappings)
+ if len(errs) > 0 {
+ return nil, errs
+ }
+ imports[i.Name.Value] = api
+ }
+ }
+ // Now resolve the api set as a single unit
+ return resolver.Resolve(list, imports, mappings)
+}
+
+func (p *Processor) include(includes map[string]*ast.API, wd string, apiname string) parse.ErrorList {
+ absname, err := filepath.Abs(filepath.Join(wd, apiname))
+ if err != nil {
+ return parse.ErrorList{parse.Error{Message: err.Error()}}
+ }
+ if _, seen := includes[absname]; seen {
+ return nil
+ }
+ api, errs := p.Parse(absname)
+ if len(errs) > 0 {
+ return errs
+ }
+ includes[absname] = api
+ for _, i := range api.Imports {
+ if i.Name != nil {
+ // named imports don't get merged
+ continue
+ }
+ errs := p.include(includes, wd, i.Path.Value)
+ if len(errs) > 0 {
+ return errs
+ }
+ }
+ return nil
+}
diff --git a/api/apic/main.go b/api/apic/main.go
index 3bedd87..476641c 100644
--- a/api/apic/main.go
+++ b/api/apic/main.go
@@ -18,7 +18,6 @@
"flag"
"android.googlesource.com/platform/tools/gpu/api/apic/commands"
- _ "android.googlesource.com/platform/tools/gpu/api/apic/reflow"
_ "android.googlesource.com/platform/tools/gpu/api/apic/template"
_ "android.googlesource.com/platform/tools/gpu/api/apic/validate"
)
diff --git a/api/apic/reflow/README.md b/api/apic/reflow/README.md
deleted file mode 100644
index 53e2f5d..0000000
--- a/api/apic/reflow/README.md
+++ /dev/null
@@ -1,6 +0,0 @@
-# reflow
---
- import "android.googlesource.com/platform/tools/gpu/api/apic/reflow"
-
-
-## Usage
diff --git a/api/apic/reflow/reflow.go b/api/apic/reflow/reflow.go
deleted file mode 100644
index 88a2c6a..0000000
--- a/api/apic/reflow/reflow.go
+++ /dev/null
@@ -1,66 +0,0 @@
-// Copyright (C) 2015 The Android Open Source Project
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package reflow
-
-import (
- "bufio"
- "flag"
- "io/ioutil"
- "os"
-
- "android.googlesource.com/platform/tools/gpu/api/apic/commands"
- "android.googlesource.com/platform/tools/gpu/api/parser"
- "android.googlesource.com/platform/tools/gpu/api/resolver"
-)
-
-var (
- command = &commands.Command{
- Name: "reflow",
- ShortHelp: "Reflows an api file for smart formatting",
- }
-)
-
-func init() {
- command.Run = doReflow
- commands.Register(command)
-}
-
-func doReflow(flags flag.FlagSet) {
- args := flags.Args()
- if len(args) < 1 {
- commands.Usage("Missing api file\n")
- }
- for _, apiName := range args {
- info, err := ioutil.ReadFile(apiName)
- commands.MaybeError(apiName, err)
- commands.Logf("Compiling api file %q\n", apiName)
- parsed, errs := parser.Parse(string(info[:]))
- commands.CheckErrors(apiName, errs)
- compiled, errs, _ := resolver.Resolve(parsed)
- commands.CheckErrors(apiName, errs)
- commands.Logf("Reflowing api %s\n", apiName)
-
- commands.Logf("Writing output to %q\n", apiName)
- w, err := os.Create(apiName)
- commands.MaybeError(apiName, err)
- out := bufio.NewWriter(w)
- err = compiled.AST.CST.WriteTo(out)
- commands.MaybeError(apiName, err)
- err = out.Flush()
- commands.MaybeError(apiName, err)
- err = w.Close()
- commands.MaybeError(apiName, err)
- }
-}
diff --git a/api/apic/template/template.go b/api/apic/template/template.go
index 801c284..f912c9d 100644
--- a/api/apic/template/template.go
+++ b/api/apic/template/template.go
@@ -24,8 +24,8 @@
"path/filepath"
"text/template"
+ "android.googlesource.com/platform/tools/gpu/api"
"android.googlesource.com/platform/tools/gpu/api/apic/commands"
- "android.googlesource.com/platform/tools/gpu/api/parser"
"android.googlesource.com/platform/tools/gpu/api/resolver"
"android.googlesource.com/platform/tools/gpu/tools/copyright"
)
@@ -152,12 +152,10 @@
mainTemplate := args[1]
commands.Logf("Reading api file %q\n", apiName)
inputDep(apiName)
- info, err := ioutil.ReadFile(apiName)
- commands.MaybeError(apiName, err)
+
commands.Logf("Compiling api file %q\n", apiName)
- parsed, errs := parser.Parse(string(info[:]))
- commands.CheckErrors(apiName, errs)
- compiled, errs, _ := resolver.Resolve(parsed)
+ mappings := resolver.ASTToSemantic{}
+ compiled, errs := api.Resolve(apiName, mappings)
commands.CheckErrors(apiName, errs)
f := NewFunctions(apiName, compiled, ioutil.ReadFile, nil)
commands.MaybeError(mainTemplate, f.Include(mainTemplate))
diff --git a/api/apic/validate/no_unreachables_test.go b/api/apic/validate/no_unreachables_test.go
index 0328c24..7455061 100644
--- a/api/apic/validate/no_unreachables_test.go
+++ b/api/apic/validate/no_unreachables_test.go
@@ -17,6 +17,7 @@
import (
"testing"
+ "android.googlesource.com/platform/tools/gpu/api/ast"
"android.googlesource.com/platform/tools/gpu/api/parser"
"android.googlesource.com/platform/tools/gpu/api/resolver"
"android.googlesource.com/platform/tools/gpu/api/semantic"
@@ -31,7 +32,7 @@
return nil
}
- compiled, errs, _ := resolver.Resolve(parsed)
+ compiled, errs := resolver.Resolve([]*ast.API{parsed}, nil, resolver.ASTToSemantic{})
for _, err := range errs {
t.Error(err.Error())
}
diff --git a/api/apic/validate/validate.go b/api/apic/validate/validate.go
index f4d65d9..7d6254a 100644
--- a/api/apic/validate/validate.go
+++ b/api/apic/validate/validate.go
@@ -21,11 +21,10 @@
import (
"flag"
"fmt"
- "io/ioutil"
"os"
+ "android.googlesource.com/platform/tools/gpu/api"
"android.googlesource.com/platform/tools/gpu/api/apic/commands"
- "android.googlesource.com/platform/tools/gpu/api/parser"
"android.googlesource.com/platform/tools/gpu/api/resolver"
"android.googlesource.com/platform/tools/gpu/api/semantic"
"android.googlesource.com/platform/tools/gpu/parse"
@@ -48,15 +47,11 @@
if len(args) < 1 {
commands.Usage("Missing api file\n")
}
+ mappings := resolver.ASTToSemantic{}
for _, apiName := range args {
- info, err := ioutil.ReadFile(apiName)
- commands.MaybeError(apiName, err)
+ compiled, errs := api.Resolve(apiName, mappings)
+ commands.CheckErrors(apiName, errs)
commands.Logf("Validating api file %q\n", apiName)
- parsed, errs := parser.Parse(string(info[:]))
- commands.CheckErrors(apiName, errs)
- compiled, errs, _ := resolver.Resolve(parsed)
- commands.CheckErrors(apiName, errs)
-
errors := Validate(apiName, compiled)
for _, err := range errors {
fmt.Fprintf(os.Stderr, "%s\n", err.Error())
diff --git a/api/ast/api.go b/api/ast/api.go
index 11af7b9..68adc7a 100644
--- a/api/ast/api.go
+++ b/api/ast/api.go
@@ -22,6 +22,7 @@
// It holds the set of top level AST nodes, grouped by type.
type API struct {
CST *parse.Branch // underlying parse structure for this node
+ Imports []*Import // api files imported with the "import" keyword
Macros []*Function // functions declared with the "macro" keyword
Externs []*Function // functions declared with the "extern" keyword
Commands []*Function // functions declared with the "cmd" keyword
@@ -32,7 +33,7 @@
Fields []*Field // variables declared at the global scope
}
-// Annotation is the AST node that represents «@name(arguments) constructs»
+// Annotation is the AST node that represents «@name(arguments)» constructs
type Annotation struct {
CST *parse.Branch // underlying parse structure for this node
Name *Identifier // the name part (between the @ and the brackets)
@@ -46,3 +47,11 @@
// Invalid is used when an error was encountered in the parsing, but we want to
// keep going. If there are no errors, this will never be in the tree.
type Invalid struct{}
+
+// Import is the AST node that represents «import name "path"» constructs
+type Import struct {
+ CST *parse.Branch // underlying parse structure for this node
+ Annotations Annotations // the annotations applied to the import
+ Name *Identifier // the name to import an api file as
+ Path *String // the relative path to the api file
+}
diff --git a/api/ast/identifier.go b/api/ast/identifier.go
index db996d6..cf70da7 100644
--- a/api/ast/identifier.go
+++ b/api/ast/identifier.go
@@ -41,6 +41,7 @@
KeywordFalse = "false"
KeywordFor = "for"
KeywordIf = "if"
+ KeywordImport = "import"
KeywordIn = "in"
KeywordInout = "inout"
KeywordLength = "len"
diff --git a/api/parser/api.go b/api/parser/api.go
index 1d56778..5c4311b 100644
--- a/api/parser/api.go
+++ b/api/parser/api.go
@@ -19,15 +19,18 @@
"android.googlesource.com/platform/tools/gpu/parse"
)
-// { macro | extern | enum | alias | pseudonym | class | command | field }
+// { import | macro | extern | enum | alias | pseudonym | class | command | field }
func requireAPI(p *parse.Parser, cst *parse.Branch) *ast.API {
api := &ast.API{}
api.CST = cst
+
annotations := &ast.Annotations{}
p.ParseBranch(cst, func(p *parse.Parser, cst *parse.Branch) {
for !p.IsEOF() {
parseAnnotations(annotations, p, cst)
- if m := macro(p, cst, annotations); m != nil {
+ if i := import_(p, cst, annotations); i != nil {
+ api.Imports = append(api.Imports, i)
+ } else if m := macro(p, cst, annotations); m != nil {
api.Macros = append(api.Macros, m)
} else if e := extern(p, cst, annotations); e != nil {
api.Externs = append(api.Externs, e)
@@ -81,3 +84,19 @@
*src = (*src)[0:0]
*dst = l
}
+
+// { annotation } 'import' [ identifier ] '"' path '""'
+func import_(p *parse.Parser, cst *parse.Branch, a *ast.Annotations) *ast.Import {
+ if !peekKeyword(ast.KeywordImport, p) {
+ return nil
+ }
+ i := &ast.Import{}
+ consumeAnnotations(&i.Annotations, a)
+ p.ParseBranch(cst, func(p *parse.Parser, cst *parse.Branch) {
+ i.CST = cst
+ requireKeyword(ast.KeywordImport, p, cst)
+ i.Name = identifier(p, cst)
+ i.Path = requireString(p, cst)
+ })
+ return i
+}
diff --git a/api/parser/expression.go b/api/parser/expression.go
index a57d54c..c3d50a3 100644
--- a/api/parser/expression.go
+++ b/api/parser/expression.go
@@ -127,17 +127,8 @@
if l := keyword(ast.KeywordFalse, p, cst); l != nil {
return &ast.Bool{CST: l, Value: false}
}
- if p.Rune(ast.Quote) {
- n := &ast.String{}
- p.ParseLeaf(cst, func(p *parse.Parser, l *parse.Leaf) {
- n.CST = l
- p.SeekRune(ast.Quote)
- p.Rune(ast.Quote)
- l.SetToken(p.Consume())
- v := l.Token().String()
- n.Value = v[1 : len(v)-1]
- })
- return n
+ if s := string_(p, cst); s != nil {
+ return s
}
if peekOperator(ast.OpUnknown, p) {
n := &ast.Unknown{}
@@ -153,6 +144,31 @@
return nil
}
+// '"' string '"'
+func string_(p *parse.Parser, cst *parse.Branch) *ast.String {
+ if !p.Rune(ast.Quote) {
+ return nil
+ }
+ n := &ast.String{}
+ p.ParseLeaf(cst, func(p *parse.Parser, l *parse.Leaf) {
+ n.CST = l
+ p.SeekRune(ast.Quote)
+ p.Rune(ast.Quote)
+ l.SetToken(p.Consume())
+ v := l.Token().String()
+ n.Value = v[1 : len(v)-1]
+ })
+ return n
+}
+
+func requireString(p *parse.Parser, cst *parse.Branch) *ast.String {
+ s := string_(p, cst)
+ if s == nil {
+ p.Expected("string")
+ }
+ return s
+}
+
// standard numeric formats
func number(p *parse.Parser, cst *parse.Branch) *ast.Number {
_ = p.Rune('+') || p.Rune('-') // optional sign
diff --git a/api/parser/parser.go b/api/parser/parser.go
index 82d1a26..f769a22 100644
--- a/api/parser/parser.go
+++ b/api/parser/parser.go
@@ -26,7 +26,7 @@
// If the string is not syntactically valid, it will also return the
// errors encountered. If errors are returned, the ast returned will be
// the incomplete tree so far, and may not be structurally valid.
-func Parse(data string) (*ast.API, []parse.Error) {
+func Parse(data string) (*ast.API, parse.ErrorList) {
var api *ast.API
parser := func(p *parse.Parser, cst *parse.Branch) {
api = requireAPI(p, cst)
diff --git a/api/resolver/api.go b/api/resolver/api.go
index 4dec6eb..b66a29e 100644
--- a/api/resolver/api.go
+++ b/api/resolver/api.go
@@ -21,90 +21,88 @@
"android.googlesource.com/platform/tools/gpu/api/semantic"
)
-func api(ctx *context, out *semantic.API) {
- in := out.AST
- macros := []*macroStub{}
- ctx.with(semantic.VoidType, func() {
- // Build and register the high level semantic objects
- out.Enums = make([]*semantic.Enum, len(in.Enums))
- for i, e := range in.Enums {
- out.Enums[i] = &semantic.Enum{AST: e, Name: e.Name.Value}
- ctx.addType(out.Enums[i])
+func apiNames(ctx *context, in *ast.API) {
+ // Build and register the high level semantic objects
+ for _, e := range in.Enums {
+ n := &semantic.Enum{AST: e, Name: e.Name.Value}
+ ctx.api.Enums = append(ctx.api.Enums, n)
+ ctx.addType(n)
+ }
+ for _, c := range in.Classes {
+ n := &semantic.Class{AST: c, Name: c.Name.Value, Members: semantic.Members{}}
+ ctx.api.Classes = append(ctx.api.Classes, n)
+ ctx.addType(n)
+ }
+ for _, p := range in.Pseudonyms {
+ n := &semantic.Pseudonym{AST: p, Name: p.Name.Value, Members: semantic.Members{}}
+ ctx.api.Pseudonyms = append(ctx.api.Pseudonyms, n)
+ ctx.addType(n)
+ }
+ for _, m := range in.Macros {
+ stub := ¯oStub{}
+ ctx.macros = append(ctx.macros, stub)
+ stub.function = &semantic.Function{AST: m, Name: m.Name.Value}
+ ctx.add(stub.function.Name, stub)
+ }
+ for _, e := range in.Externs {
+ n := &semantic.Function{AST: e, Name: e.Name.Value}
+ ctx.api.Externs = append(ctx.api.Externs, n)
+ ctx.api.Members[n.Name] = n
+ }
+ for _, m := range in.Commands {
+ f := &semantic.Function{AST: m, Name: m.Name.Value}
+ if !m.Parameters[0].This {
+ ctx.api.Functions = append(ctx.api.Functions, f)
+ ctx.api.Members[f.Name] = f
+ } else {
+ ctx.api.Methods = append(ctx.api.Methods, f)
}
- out.Classes = make([]*semantic.Class, len(in.Classes))
- for i, c := range in.Classes {
- out.Classes[i] = &semantic.Class{AST: c, Name: c.Name.Value, Members: semantic.Members{}}
- ctx.addType(out.Classes[i])
- }
- out.Pseudonyms = make([]*semantic.Pseudonym, len(in.Pseudonyms))
- for i, p := range in.Pseudonyms {
- out.Pseudonyms[i] = &semantic.Pseudonym{AST: p, Name: p.Name.Value, Members: semantic.Members{}}
- ctx.addType(out.Pseudonyms[i])
- }
- macros = make([]*macroStub, len(in.Macros))
- for i, m := range in.Macros {
- stub := ¯oStub{}
- macros[i] = stub
- stub.function = &semantic.Function{AST: m, Name: m.Name.Value}
- ctx.add(stub.function.Name, stub)
- }
- out.Externs = make([]*semantic.Function, len(in.Externs))
- for i, e := range in.Externs {
- out.Externs[i] = &semantic.Function{AST: e, Name: e.Name.Value}
- out.Members[out.Externs[i].Name] = out.Externs[i]
- }
- for _, m := range in.Commands {
- if !m.Parameters[0].This {
- f := &semantic.Function{AST: m, Name: m.Name.Value}
- out.Functions = append(out.Functions, f)
- out.Members[f.Name] = f
- }
- }
- out.Globals = make([]*semantic.Global, len(in.Fields))
- for i, f := range in.Fields {
- out.Globals[i] = &semantic.Global{AST: f, Name: f.Name.Value}
- out.Members[out.Globals[i].Name] = out.Globals[i]
- }
- for name, member := range out.Members {
- ctx.add(name, member)
- }
- // Add all the alias remaps
- for _, a := range in.Aliases {
- ctx.addType(&Alias{AST: a, Name: a.Name.Value})
- }
- // Now resolve all the references
- for _, e := range out.Enums {
- enum(ctx, e)
- }
- for _, g := range out.Globals {
- global(ctx, g)
- }
- for _, p := range out.Pseudonyms {
- pseudonym(ctx, p)
- }
- for _, m := range macros {
- functionSignature(ctx, m.function)
- m.scope = ctx.scope
- }
- for _, e := range out.Externs {
- functionSignature(ctx, e)
- functionBody(ctx, nil, e)
- }
- for _, c := range out.Classes {
- class(ctx, c)
- }
- for _, f := range out.Functions {
- functionSignature(ctx, f)
- functionBody(ctx, nil, f)
- }
- for _, m := range in.Commands {
- if m.Parameters[0].This {
- method(ctx, m)
- }
- }
- })
- sort.Sort(arraysByName(out.Arrays))
- sort.Sort(mapsByName(out.Maps))
+ }
+ for _, f := range in.Fields {
+ n := &semantic.Global{AST: f, Name: f.Name.Value}
+ ctx.api.Globals = append(ctx.api.Globals, n)
+ ctx.api.Members[n.Name] = n
+ }
+ // Add all the alias remaps
+ for _, a := range in.Aliases {
+ ctx.addType(&Alias{AST: a, Name: a.Name.Value})
+ }
+}
+
+func resolve(ctx *context) {
+ for name, member := range ctx.api.Members {
+ ctx.add(name, member)
+ }
+ // Now resolve all the references
+ for _, e := range ctx.api.Enums {
+ enum(ctx, e)
+ }
+ for _, g := range ctx.api.Globals {
+ global(ctx, g)
+ }
+ for _, p := range ctx.api.Pseudonyms {
+ pseudonym(ctx, p)
+ }
+ for _, m := range ctx.macros {
+ functionSignature(ctx, m.function)
+ m.scope = ctx.scope
+ }
+ for _, e := range ctx.api.Externs {
+ functionSignature(ctx, e)
+ functionBody(ctx, nil, e)
+ }
+ for _, c := range ctx.api.Classes {
+ class(ctx, c)
+ }
+ for _, f := range ctx.api.Functions {
+ functionSignature(ctx, f)
+ functionBody(ctx, nil, f)
+ }
+ for _, m := range ctx.api.Methods {
+ method(ctx, m)
+ }
+ sort.Sort(arraysByName(ctx.api.Arrays))
+ sort.Sort(mapsByName(ctx.api.Maps))
}
func annotations(ctx *context, in ast.Annotations) semantic.Annotations {
diff --git a/api/resolver/context.go b/api/resolver/context.go
index bd42c32..bb67b8f 100644
--- a/api/resolver/context.go
+++ b/api/resolver/context.go
@@ -27,6 +27,7 @@
errors parse.ErrorList
api *semantic.API
types map[string]semantic.Type
+ macros []*macroStub
scope *scope
nextId uint64
mappings ASTToSemantic
diff --git a/api/resolver/function.go b/api/resolver/function.go
index b5d97e6..6749c5b 100644
--- a/api/resolver/function.go
+++ b/api/resolver/function.go
@@ -104,14 +104,13 @@
ctx.mappings[in] = out
}
-func method(ctx *context, in *ast.Function) {
- out := &semantic.Function{AST: in, Name: in.Name.Value}
+func method(ctx *context, out *semantic.Function) {
functionSignature(ctx, out)
t := out.This.Type
switch t := t.(type) {
case *semantic.Pointer:
if class, ok := t.To.(*semantic.Class); !ok {
- ctx.errorf(in, "expected this as a reference to a class, got %s[%T]", typename(t.To), t.To)
+ ctx.errorf(out.AST, "expected this as a reference to a class, got %s[%T]", typename(t.To), t.To)
} else {
class.Methods = append(class.Methods, out)
class.Members[out.Name] = out
@@ -126,9 +125,9 @@
t.Members[out.Name] = out
functionBody(ctx, t, out)
default:
- ctx.errorf(in, "invalid type for this , got %s[%T]", typename(t), t)
+ ctx.errorf(out.AST, "invalid type for this , got %s[%T]", typename(t), t)
}
- ctx.mappings[in] = out
+ ctx.mappings[out.AST] = out
}
func getSignature(ctx *context, at ast.Node, r semantic.Type, args []semantic.Type) *semantic.Signature {
diff --git a/api/resolver/resolve.go b/api/resolver/resolve.go
index 9922242..f96c0ba 100644
--- a/api/resolver/resolve.go
+++ b/api/resolver/resolve.go
@@ -26,21 +26,20 @@
// ASTToSemantic is a relational map of AST nodes to semantic nodes.
type ASTToSemantic map[ast.Node]semantic.Node
-// Resolve takes a valid ast as produced by the parser and converts it to the
+// Resolve takes valid asts as produced by the parser and converts them to the
// semantic graph form.
-// If the ast is not fully valid (ie there were parse errors) then the results
-// are undefined, and may include null pointer access.
+// If the asts are not fully valid (ie there were parse errors) then the results
+// are undefined.
// If there are semantic problems with the ast, Resolve will return the set of
// errors it finds, and the returned graph may be incomplete/invalid.
-func Resolve(compiled *ast.API) (*semantic.API, parse.ErrorList, ASTToSemantic) {
+func Resolve(includes []*ast.API, imports map[string]*semantic.API, mappings ASTToSemantic) (*semantic.API, parse.ErrorList) {
ctx := &context{
api: &semantic.API{
- AST: compiled,
Members: semantic.Members{},
},
types: map[string]semantic.Type{},
scope: &scope{entries: map[string][]semantic.Node{}},
- mappings: make(ASTToSemantic),
+ mappings: mappings,
}
func() {
defer func() {
@@ -49,11 +48,19 @@
panic(err)
}
}()
+ for name, i := range imports {
+ ctx.api.Members[name] = i
+ }
// Register all the built in symbols
for _, t := range semantic.BuiltinTypes {
ctx.addType(t)
}
- api(ctx, ctx.api)
+ ctx.with(semantic.VoidType, func() {
+ for _, api := range includes {
+ apiNames(ctx, api)
+ }
+ resolve(ctx)
+ })
}()
- return ctx.api, ctx.errors, ctx.mappings
+ return ctx.api, ctx.errors
}
diff --git a/api/semantic/api.go b/api/semantic/api.go
index aad4fff..89c1b77 100644
--- a/api/semantic/api.go
+++ b/api/semantic/api.go
@@ -20,12 +20,12 @@
// API is the root of the ASG, and holds a fully resolved api.
type API struct {
- AST *ast.API // the underlying syntax node this was built from
Enums []*Enum // the set of enums
Classes []*Class // the set of classes
Pseudonyms []*Pseudonym // the set of pseudo types
Externs []*Function // the external function references
Functions []*Function // the global functions
+ Methods []*Function // the method functions
Globals []*Global // the global variables
Arrays []*Array // the array types used
StaticArrays []*StaticArray // the fixed size array types used
diff --git a/gfxapi/gles/glenum.api b/gfxapi/gles/glenum.api
new file mode 100644
index 0000000..8920080
--- /dev/null
+++ b/gfxapi/gles/glenum.api
@@ -0,0 +1,728 @@
+// Copyright (C) 2015 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+// GLES 1 constants can be found in:
+// http://www.khronos.org/registry/gles/api/GLES/gl.h
+
+// GLES 2 constants can be found in:
+// http://www.khronos.org/registry/gles/api/GLES2/gl2.h
+
+enum DrawMode {
+ GL_LINE_LOOP = 0x0002,
+ GL_LINE_STRIP = 0x0003,
+ GL_LINES = 0x0001,
+ GL_POINTS = 0x0000,
+ GL_TRIANGLE_FAN = 0x0006,
+ GL_TRIANGLE_STRIP = 0x0005,
+ GL_TRIANGLES = 0x0004,
+}
+
+enum IndicesType {
+ GL_UNSIGNED_BYTE = 0x1401,
+ GL_UNSIGNED_SHORT = 0x1403,
+ GL_UNSIGNED_INT = 0x1405,
+}
+
+enum TextureTarget_GLES_1_1 {
+ GL_TEXTURE_2D = 0x0DE1,
+}
+
+enum TextureTarget_GLES_2_0 {
+ GL_TEXTURE_CUBE_MAP = 0x8513,
+}
+
+enum TextureTarget_OES_EGL_image_external {
+ GL_TEXTURE_EXTERNAL_OES = 0x8D65,
+}
+
+enum TextureTarget
+ : TextureTarget_GLES_1_1
+ , TextureTarget_GLES_2_0
+ , TextureTarget_OES_EGL_image_external {}
+
+enum CubeMapImageTarget {
+ GL_TEXTURE_CUBE_MAP_NEGATIVE_X = 0x8516,
+ GL_TEXTURE_CUBE_MAP_NEGATIVE_Y = 0x8518,
+ GL_TEXTURE_CUBE_MAP_NEGATIVE_Z = 0x851A,
+ GL_TEXTURE_CUBE_MAP_POSITIVE_X = 0x8515,
+ GL_TEXTURE_CUBE_MAP_POSITIVE_Y = 0x8517,
+ GL_TEXTURE_CUBE_MAP_POSITIVE_Z = 0x8519,
+}
+
+enum Texture2DImageTarget {
+ GL_TEXTURE_2D = 0x0DE1,
+}
+
+enum TextureImageTarget : CubeMapImageTarget, Texture2DImageTarget {}
+
+enum BaseTexelFormat {
+ GL_ALPHA = 0x1906,
+ GL_RGB = 0x1907,
+ GL_RGBA = 0x1908,
+}
+
+enum TexelFormat_GLES_1_1 : BaseTexelFormat {
+ GL_LUMINANCE = 0x1909,
+ GL_LUMINANCE_ALPHA = 0x190A,
+}
+
+enum TexelFormat_GLES_3_0 {
+ GL_RED = 0x1903,
+ GL_RED_INTEGER = 0x8D94,
+ GL_RG = 0x8227,
+ GL_RG_INTEGER = 0x8228,
+ GL_RGB_INTEGER = 0x8D98,
+ GL_RGBA_INTEGER = 0x8D99,
+ GL_DEPTH_COMPONENT = 0x1902,
+ GL_DEPTH_COMPONENT16 = 0x81A5,
+ GL_DEPTH_STENCIL = 0x84F9,
+ GL_DEPTH24_STENCIL8 = 0x88F0,
+}
+
+enum TexelFormat : TexelFormat_GLES_1_1, TexelFormat_GLES_3_0 {}
+
+enum RenderbufferFormat {
+ GL_RGBA4 = 0x8056,
+ GL_RGB5_A1 = 0x8057,
+ GL_RGB565 = 0x8D62,
+ GL_RGBA8 = 0x8058,
+ GL_DEPTH_COMPONENT16 = 0x81A5,
+ GL_STENCIL_INDEX8 = 0x8D48,
+}
+
+// http://www.khronos.org/registry/specs/ARB/half_float_vertex.txt
+enum Type_ARB_half_float_vertex {
+ GL_ARB_half_float_vertex = 0x140B,
+}
+
+// http://www.khronos.org/registry/gles/extensions/OES/OES_vertex_half_float.txt
+enum Type_OES_vertex_half_float {
+ GL_HALF_FLOAT_OES = 0x8D61,
+}
+
+// http://www.khronos.org/registry/gles/extensions/OES/OES_compressed_ETC1_RGB8_texture.txt
+enum CompressedTexelFormat_OES_compressed_ETC1_RGB8_texture {
+ GL_ETC1_RGB8_OES = 0x8D64,
+}
+
+enum CompressedTexelFormat_AMD_compressed_ATC_texture {
+ GL_ATC_RGB_AMD = 0x8C92,
+ GL_ATC_RGBA_EXPLICIT_ALPHA_AMD = 0x8C93,
+ GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD = 0x87EE,
+}
+
+enum CompressedTexelFormat
+ : CompressedTexelFormat_OES_compressed_ETC1_RGB8_texture
+ , CompressedTexelFormat_AMD_compressed_ATC_texture {}
+
+enum ImageTexelFormat : TexelFormat, CompressedTexelFormat {}
+
+enum TexelType {
+ GL_UNSIGNED_BYTE = 0x1401,
+ GL_UNSIGNED_SHORT = 0x1403,
+ GL_UNSIGNED_INT = 0x1405,
+ GL_FLOAT = 0x1406,
+ GL_UNSIGNED_SHORT_4_4_4_4 = 0x8033,
+ GL_UNSIGNED_SHORT_5_5_5_1 = 0x8034,
+ GL_UNSIGNED_SHORT_5_6_5 = 0x8363,
+ GL_UNSIGNED_INT_24_8 = 0x84FA,
+}
+
+enum FramebufferAttachment {
+ GL_COLOR_ATTACHMENT0 = 0x8CE0,
+ GL_DEPTH_ATTACHMENT = 0x8D00,
+ GL_STENCIL_ATTACHMENT = 0x8D20,
+}
+
+enum FramebufferAttachmentType {
+ GL_NONE = 0x0000,
+ GL_RENDERBUFFER = 0x8D41,
+ GL_TEXTURE = 0x1702,
+}
+
+enum FramebufferTarget_GLES_2_0 {
+ GL_FRAMEBUFFER = 0x8D40,
+}
+
+enum FramebufferTarget_GLES_3_1 {
+ GL_READ_FRAMEBUFFER = 0x8CA8,
+ GL_DRAW_FRAMEBUFFER = 0x8CA9,
+}
+
+enum FramebufferTarget : FramebufferTarget_GLES_2_0, FramebufferTarget_GLES_3_1 {}
+
+enum FramebufferAttachmentParameter {
+ GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE = 0x8CD0,
+ GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME = 0x8CD1,
+ GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL = 0x8CD2,
+ GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE = 0x8CD3,
+}
+
+enum FramebufferStatus {
+ GL_FRAMEBUFFER_COMPLETE = 0x8CD5,
+ GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT = 0x8CD6,
+ GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT = 0x8CD7,
+ GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS = 0x8CD9,
+ GL_FRAMEBUFFER_UNSUPPORTED = 0x8CDD,
+}
+
+enum RenderbufferTarget {
+ GL_RENDERBUFFER = 0x8D41,
+}
+
+enum RenderbufferParameter {
+ GL_RENDERBUFFER_WIDTH = 0x8D42,
+ GL_RENDERBUFFER_HEIGHT = 0x8D43,
+ GL_RENDERBUFFER_INTERNAL_FORMAT = 0x8D44,
+ GL_RENDERBUFFER_RED_SIZE = 0x8D50,
+ GL_RENDERBUFFER_GREEN_SIZE = 0x8D51,
+ GL_RENDERBUFFER_BLUE_SIZE = 0x8D52,
+ GL_RENDERBUFFER_ALPHA_SIZE = 0x8D53,
+ GL_RENDERBUFFER_DEPTH_SIZE = 0x8D54,
+ GL_RENDERBUFFER_STENCIL_SIZE = 0x8D55,
+}
+
+enum BufferParameter {
+ GL_BUFFER_SIZE = 0x8764,
+ GL_BUFFER_USAGE = 0x8765,
+}
+
+enum TextureUnit {
+ GL_TEXTURE0 = 0x84C0,
+ GL_TEXTURE1 = 0x84C1,
+ GL_TEXTURE2 = 0x84C2,
+ GL_TEXTURE3 = 0x84C3,
+ GL_TEXTURE4 = 0x84C4,
+ GL_TEXTURE5 = 0x84C5,
+ GL_TEXTURE6 = 0x84C6,
+ GL_TEXTURE7 = 0x84C7,
+ GL_TEXTURE8 = 0x84C8,
+ GL_TEXTURE9 = 0x84C9,
+ GL_TEXTURE10 = 0x84CA,
+ GL_TEXTURE11 = 0x84CB,
+ GL_TEXTURE12 = 0x84CC,
+ GL_TEXTURE13 = 0x84CD,
+ GL_TEXTURE14 = 0x84CE,
+ GL_TEXTURE15 = 0x84CF,
+ GL_TEXTURE16 = 0x84D0,
+ GL_TEXTURE17 = 0x84D1,
+ GL_TEXTURE18 = 0x84D2,
+ GL_TEXTURE19 = 0x84D3,
+ GL_TEXTURE20 = 0x84D4,
+ GL_TEXTURE21 = 0x84D5,
+ GL_TEXTURE22 = 0x84D6,
+ GL_TEXTURE23 = 0x84D7,
+ GL_TEXTURE24 = 0x84D8,
+ GL_TEXTURE25 = 0x84D9,
+ GL_TEXTURE26 = 0x84DA,
+ GL_TEXTURE27 = 0x84DB,
+ GL_TEXTURE28 = 0x84DC,
+ GL_TEXTURE29 = 0x84DD,
+ GL_TEXTURE30 = 0x84DE,
+ GL_TEXTURE31 = 0x84DF,
+}
+
+enum BufferUsage {
+ GL_DYNAMIC_DRAW = 0x88E8,
+ GL_STATIC_DRAW = 0x88E4,
+ GL_STREAM_DRAW = 0x88E0,
+}
+
+enum ShaderType {
+ GL_VERTEX_SHADER = 0x8B31,
+ GL_FRAGMENT_SHADER = 0x8B30,
+}
+
+enum StateVariable_GLES_2_0 {
+ GL_ACTIVE_TEXTURE = 0x84E0,
+ GL_ALIASED_LINE_WIDTH_RANGE = 0x846E,
+ GL_ALIASED_POINT_SIZE_RANGE = 0x846D,
+ GL_ALPHA_BITS = 0x0D55,
+ GL_ARRAY_BUFFER_BINDING = 0x8894,
+ GL_BLEND = 0x0BE2,
+ GL_BLEND_COLOR = 0x8005,
+ GL_BLEND_DST_ALPHA = 0x80CA,
+ GL_BLEND_DST_RGB = 0x80C8,
+ GL_BLEND_EQUATION_ALPHA = 0x883D,
+ GL_BLEND_EQUATION_RGB = 0x8009,
+ GL_BLEND_SRC_ALPHA = 0x80CB,
+ GL_BLEND_SRC_RGB = 0x80C9,
+ GL_BLUE_BITS = 0x0D54,
+ GL_COLOR_CLEAR_VALUE = 0x0C22,
+ GL_COLOR_WRITEMASK = 0x0C23,
+ GL_COMPRESSED_TEXTURE_FORMATS = 0x86A3,
+ GL_CULL_FACE = 0x0B44,
+ GL_CULL_FACE_MODE = 0x0B45,
+ GL_CURRENT_PROGRAM = 0x8B8D,
+ GL_DEPTH_BITS = 0x0D56,
+ GL_DEPTH_CLEAR_VALUE = 0x0B73,
+ GL_DEPTH_FUNC = 0x0B74,
+ GL_DEPTH_RANGE = 0x0B70,
+ GL_DEPTH_TEST = 0x0B71,
+ GL_DEPTH_WRITEMASK = 0x0B72,
+ GL_DITHER = 0x0BD0,
+ GL_ELEMENT_ARRAY_BUFFER_BINDING = 0x8895,
+ GL_FRAMEBUFFER_BINDING = 0x8CA6,
+ GL_FRONT_FACE = 0x0B46,
+ GL_GENERATE_MIPMAP_HINT = 0x8192,
+ GL_GREEN_BITS = 0x0D53,
+ GL_IMPLEMENTATION_COLOR_READ_FORMAT = 0x8B9B,
+ GL_IMPLEMENTATION_COLOR_READ_TYPE = 0x8B9A,
+ GL_LINE_WIDTH = 0x0B21,
+ GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS = 0x8B4D,
+ GL_MAX_CUBE_MAP_TEXTURE_SIZE = 0x851C,
+ GL_MAX_FRAGMENT_UNIFORM_VECTORS = 0x8DFD,
+ GL_MAX_RENDERBUFFER_SIZE = 0x84E8,
+ GL_MAX_TEXTURE_IMAGE_UNITS = 0x8872,
+ GL_MAX_TEXTURE_SIZE = 0x0D33,
+ GL_MAX_VARYING_VECTORS = 0x8DFC,
+ GL_MAX_VERTEX_ATTRIBS = 0x8869,
+ GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS = 0x8B4C,
+ GL_MAX_VERTEX_UNIFORM_VECTORS = 0x8DFB,
+ GL_MAX_VIEWPORT_DIMS = 0x0D3A,
+ GL_NUM_COMPRESSED_TEXTURE_FORMATS = 0x86A2,
+ GL_NUM_SHADER_BINARY_FORMATS = 0x8DF9,
+ GL_PACK_ALIGNMENT = 0x0D05,
+ GL_POLYGON_OFFSET_FACTOR = 0x8038,
+ GL_POLYGON_OFFSET_FILL = 0x8037,
+ GL_POLYGON_OFFSET_UNITS = 0x2A00,
+ GL_RED_BITS = 0x0D52,
+ GL_RENDERBUFFER_BINDING = 0x8CA7,
+ GL_SAMPLE_ALPHA_TO_COVERAGE = 0x809E,
+ GL_SAMPLE_BUFFERS = 0x80A8,
+ GL_SAMPLE_COVERAGE = 0x80A0,
+ GL_SAMPLE_COVERAGE_INVERT = 0x80AB,
+ GL_SAMPLE_COVERAGE_VALUE = 0x80AA,
+ GL_SAMPLES = 0x80A9,
+ GL_SCISSOR_BOX = 0x0C10,
+ GL_SCISSOR_TEST = 0x0C11,
+ GL_SHADER_BINARY_FORMATS = 0x8DF8,
+ GL_SHADER_COMPILER = 0x8DFA,
+ GL_STENCIL_BACK_FAIL = 0x8801,
+ GL_STENCIL_BACK_FUNC = 0x8800,
+ GL_STENCIL_BACK_PASS_DEPTH_FAIL = 0x8802,
+ GL_STENCIL_BACK_PASS_DEPTH_PASS = 0x8803,
+ GL_STENCIL_BACK_REF = 0x8CA3,
+ GL_STENCIL_BACK_VALUE_MASK = 0x8CA4,
+ GL_STENCIL_BACK_WRITEMASK = 0x8CA5,
+ GL_STENCIL_BITS = 0x0D57,
+ GL_STENCIL_CLEAR_VALUE = 0x0B91,
+ GL_STENCIL_FAIL = 0x0B94,
+ GL_STENCIL_FUNC = 0x0B92,
+ GL_STENCIL_PASS_DEPTH_FAIL = 0x0B95,
+ GL_STENCIL_PASS_DEPTH_PASS = 0x0B96,
+ GL_STENCIL_REF = 0x0B97,
+ GL_STENCIL_TEST = 0x0B90,
+ GL_STENCIL_VALUE_MASK = 0x0B93,
+ GL_STENCIL_WRITEMASK = 0x0B98,
+ GL_SUBPIXEL_BITS = 0x0D50,
+ GL_TEXTURE_BINDING_2D = 0x8069,
+ GL_TEXTURE_BINDING_CUBE_MAP = 0x8514,
+ GL_UNPACK_ALIGNMENT = 0x0CF5,
+ GL_VIEWPORT = 0x0BA2,
+}
+
+enum StateVariable_GLES_3_1 {
+ // GL_DRAW_FRAMEBUFFER_BINDING = 0x8CA6, // Same as GL_FRAMEBUFFER_BINDING
+ GL_READ_FRAMEBUFFER_BINDING = 0x8CAA,
+}
+
+enum StateVariable_EXT_texture_filter_anisotropic {
+ GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT = 0x84FF,
+}
+
+enum StateVariable_EXT_disjoint_timer_query {
+ GL_GPU_DISJOINT_EXT = 0x8FBB,
+}
+
+enum StateVariable
+ : StateVariable_GLES_2_0
+ , StateVariable_GLES_3_1
+ , StateVariable_EXT_texture_filter_anisotropic
+ , StateVariable_EXT_disjoint_timer_query {}
+
+enum FaceMode {
+ GL_FRONT = 0x0404,
+ GL_BACK = 0x0405,
+ GL_FRONT_AND_BACK = 0x0408,
+}
+
+enum ArrayType_GLES_1_1 {
+ GL_VERTEX_ARRAY = 0x8074,
+ GL_NORMAL_ARRAY = 0x8075,
+ GL_COLOR_ARRAY = 0x8076,
+ GL_TEXTURE_COORD_ARRAY = 0x8078,
+}
+
+enum ArrayType_OES_point_size_array {
+ GL_POINT_SIZE_ARRAY_OES = 0x8B9C,
+}
+
+enum ArrayType : ArrayType_GLES_1_1, ArrayType_OES_point_size_array {}
+
+enum Capability : ArrayType {
+ GL_BLEND = 0x0BE2,
+ GL_CULL_FACE = 0x0B44,
+ GL_DEPTH_TEST = 0x0B71,
+ GL_DITHER = 0x0BD0,
+ GL_POLYGON_OFFSET_FILL = 0x8037,
+ GL_SAMPLE_ALPHA_TO_COVERAGE = 0x809E,
+ GL_SAMPLE_COVERAGE = 0x80A0,
+ GL_SCISSOR_TEST = 0x0C11,
+ GL_STENCIL_TEST = 0x0B90,
+}
+
+enum StringConstant {
+ GL_EXTENSIONS = 0x1F03,
+ GL_RENDERER = 0x1F01,
+ GL_VENDOR = 0x1F00,
+ GL_VERSION = 0x1F02,
+}
+
+enum VertexAttribType : Type_OES_vertex_half_float
+ , Type_ARB_half_float_vertex {
+ GL_BYTE = 0x1400,
+ GL_FIXED = 0x140C,
+ GL_FLOAT = 0x1406,
+ GL_SHORT = 0x1402,
+ GL_UNSIGNED_BYTE = 0x1401,
+ GL_UNSIGNED_SHORT = 0x1403,
+}
+
+enum ShaderAttribType {
+ GL_FLOAT = 0x1406,
+ GL_FLOAT_VEC2 = 0x8B50,
+ GL_FLOAT_VEC3 = 0x8B51,
+ GL_FLOAT_VEC4 = 0x8B52,
+ GL_FLOAT_MAT2 = 0x8B5A,
+ GL_FLOAT_MAT3 = 0x8B5B,
+ GL_FLOAT_MAT4 = 0x8B5C,
+}
+
+enum ShaderUniformType {
+ GL_FLOAT = 0x1406,
+ GL_FLOAT_VEC2 = 0x8B50,
+ GL_FLOAT_VEC3 = 0x8B51,
+ GL_FLOAT_VEC4 = 0x8B52,
+ GL_INT = 0x1404,
+ GL_INT_VEC2 = 0x8B53,
+ GL_INT_VEC3 = 0x8B54,
+ GL_INT_VEC4 = 0x8B55,
+ GL_BOOL = 0x8B56,
+ GL_BOOL_VEC2 = 0x8B57,
+ GL_BOOL_VEC3 = 0x8B58,
+ GL_BOOL_VEC4 = 0x8B59,
+ GL_FLOAT_MAT2 = 0x8B5A,
+ GL_FLOAT_MAT3 = 0x8B5B,
+ GL_FLOAT_MAT4 = 0x8B5C,
+ GL_SAMPLER_2D = 0x8B5E,
+ GL_SAMPLER_CUBE = 0x8B60,
+}
+
+enum Error {
+ GL_NO_ERROR = 0x0,
+ GL_INVALID_ENUM = 0x0500,
+ GL_INVALID_VALUE = 0x0501,
+ GL_INVALID_OPERATION = 0x0502,
+ GL_INVALID_FRAMEBUFFER_OPERATION = 0x0506,
+ GL_OUT_OF_MEMORY = 0x0505,
+}
+
+enum HintTarget {
+ GL_GENERATE_MIPMAP_HINT = 0x8192,
+}
+
+enum HintMode {
+ GL_DONT_CARE = 0x1100,
+ GL_FASTEST = 0x1101,
+ GL_NICEST = 0x1102,
+}
+
+enum DiscardFramebufferAttachment {
+ GL_COLOR_EXT = 0x1800,
+ GL_DEPTH_EXT = 0x1801,
+ GL_STENCIL_EXT = 0x1802,
+}
+
+enum ProgramParameter {
+ GL_DELETE_STATUS = 0x8B80,
+ GL_LINK_STATUS = 0x8B82,
+ GL_VALIDATE_STATUS = 0x8B83,
+ GL_INFO_LOG_LENGTH = 0x8B84,
+ GL_ATTACHED_SHADERS = 0x8B85,
+ GL_ACTIVE_ATTRIBUTES = 0x8B89,
+ GL_ACTIVE_ATTRIBUTE_MAX_LENGTH = 0x8B8A,
+ GL_ACTIVE_UNIFORMS = 0x8B86,
+ GL_ACTIVE_UNIFORM_MAX_LENGTH = 0x8B87,
+}
+
+enum ShaderParameter {
+ GL_SHADER_TYPE = 0x8B4F,
+ GL_DELETE_STATUS = 0x8B80,
+ GL_COMPILE_STATUS = 0x8B81,
+ GL_INFO_LOG_LENGTH = 0x8B84,
+ GL_SHADER_SOURCE_LENGTH = 0x8B88,
+}
+
+enum PixelStoreParameter {
+ GL_PACK_ALIGNMENT = 0x0D05,
+ GL_UNPACK_ALIGNMENT = 0x0CF5,
+}
+
+enum TextureParameter_FilterMode {
+ GL_TEXTURE_MIN_FILTER = 0x2801,
+ GL_TEXTURE_MAG_FILTER = 0x2800,
+}
+
+enum TextureParameter_WrapMode {
+ GL_TEXTURE_WRAP_S = 0x2802,
+ GL_TEXTURE_WRAP_T = 0x2803,
+}
+
+enum TextureParameter_EXT_texture_filter_anisotropic {
+ GL_TEXTURE_MAX_ANISOTROPY_EXT = 0x84FE,
+}
+
+enum TextureParameter_SwizzleMode {
+ GL_TEXTURE_SWIZZLE_R = 0x8E42,
+ GL_TEXTURE_SWIZZLE_G = 0x8E43,
+ GL_TEXTURE_SWIZZLE_B = 0x8E44,
+ GL_TEXTURE_SWIZZLE_A = 0x8E45,
+}
+
+enum TextureParameter
+ : TextureParameter_FilterMode
+ , TextureParameter_WrapMode
+ , TextureParameter_SwizzleMode
+ , TextureParameter_EXT_texture_filter_anisotropic {}
+
+enum TextureFilterMode {
+ GL_NEAREST = 0x2600,
+ GL_LINEAR = 0x2601,
+ GL_NEAREST_MIPMAP_NEAREST = 0x2700,
+ GL_LINEAR_MIPMAP_NEAREST = 0x2701,
+ GL_NEAREST_MIPMAP_LINEAR = 0x2702,
+ GL_LINEAR_MIPMAP_LINEAR = 0x2703,
+}
+
+enum TextureWrapMode {
+ GL_CLAMP_TO_EDGE = 0x812F,
+ GL_MIRRORED_REPEAT = 0x8370,
+ GL_REPEAT = 0x2901,
+}
+
+enum TexelComponent {
+ GL_RED = 0x1903,
+ GL_GREEN = 0x1904,
+ GL_BLUE = 0x1905,
+ GL_ALPHA = 0x1906,
+}
+
+enum BlendFactor {
+ GL_ZERO = 0x0000,
+ GL_ONE = 0x0001,
+ GL_SRC_COLOR = 0x0300,
+ GL_ONE_MINUS_SRC_COLOR = 0x0301,
+ GL_DST_COLOR = 0x0306,
+ GL_ONE_MINUS_DST_COLOR = 0x0307,
+ GL_SRC_ALPHA = 0x0302,
+ GL_ONE_MINUS_SRC_ALPHA = 0x0303,
+ GL_DST_ALPHA = 0x0304,
+ GL_ONE_MINUS_DST_ALPHA = 0x0305,
+ GL_CONSTANT_COLOR = 0x8001,
+ GL_ONE_MINUS_CONSTANT_COLOR = 0x8002,
+ GL_CONSTANT_ALPHA = 0x8003,
+ GL_ONE_MINUS_CONSTANT_ALPHA = 0x8004,
+ GL_SRC_ALPHA_SATURATE = 0x0308,
+}
+
+enum PrecisionType {
+ GL_LOW_FLOAT = 0x8DF0,
+ GL_MEDIUM_FLOAT = 0x8DF1,
+ GL_HIGH_FLOAT = 0x8DF2,
+ GL_LOW_INT = 0x8DF3,
+ GL_MEDIUM_INT = 0x8DF4,
+ GL_HIGH_INT = 0x8DF5,
+}
+
+enum TestFunction {
+ GL_NEVER = 0x0200,
+ GL_LESS = 0x0201,
+ GL_EQUAL = 0x0202,
+ GL_LEQUAL = 0x0203,
+ GL_GREATER = 0x0204,
+ GL_NOTEQUAL = 0x0205,
+ GL_GEQUAL = 0x0206,
+ GL_ALWAYS = 0x0207,
+}
+
+enum StencilAction {
+ GL_KEEP = 0x1E00,
+ GL_ZERO = 0x0000,
+ GL_REPLACE = 0x1E01,
+ GL_INCR = 0x1E02,
+ GL_INCR_WRAP = 0x8507,
+ GL_DECR = 0x1E03,
+ GL_DECR_WRAP = 0x8508,
+ GL_INVERT = 0x150A,
+}
+
+enum FaceOrientation {
+ GL_CW = 0x0900,
+ GL_CCW = 0x0901,
+}
+
+enum BlendEquation {
+ GL_FUNC_ADD = 0x8006,
+ GL_FUNC_SUBTRACT = 0x800A,
+ GL_FUNC_REVERSE_SUBTRACT = 0x800B,
+}
+
+// GLES 3
+enum BufferTarget {
+ GL_ARRAY_BUFFER = 0x8892,
+ GL_COPY_READ_BUFFER = 0x8F36,
+ GL_COPY_WRITE_BUFFER = 0x8F37,
+ GL_ELEMENT_ARRAY_BUFFER = 0x8893,
+ GL_PIXEL_PACK_BUFFER = 0x88EB,
+ GL_PIXEL_UNPACK_BUFFER = 0x88EC,
+ GL_TRANSFORM_FEEDBACK_BUFFER = 0x8C8E,
+ GL_UNIFORM_BUFFER = 0x8A11,
+}
+
+enum ImageTargetTexture_OES_EGL_image {
+ GL_TEXTURE_2D = 0x0DE1,
+}
+
+enum ImageTargetTexture_OES_EGL_image_external {
+ GL_TEXTURE_EXTERNAL_OES = 0x8D65,
+}
+
+enum ImageTargetTexture
+ : ImageTargetTexture_OES_EGL_image
+ , ImageTargetTexture_OES_EGL_image_external {}
+
+enum ImageTargetRenderbufferStorage {
+ GL_RENDERBUFFER_OES = 0x8D41,
+}
+
+enum ResetStatus {
+ GL_NO_ERROR = 0x0000,
+ GL_GUILTY_CONTEXT_RESET_EXT = 0x8253,
+ GL_INNOCENT_CONTEXT_RESET_EXT = 0x8254,
+ GL_UNKNOWN_CONTEXT_RESET_EXT = 0x8255,
+}
+
+enum TextureKind {
+ UNDEFINED = 0,
+ TEXTURE2D = 1,
+ CUBEMAP = 2,
+}
+
+enum QueryParameter_GLES_3 {
+ GL_CURRENT_QUERY = 0x8865,
+}
+
+enum QueryParameter_EXT_disjoint_timer_query {
+ GL_QUERY_COUNTER_BITS_EXT = 0x8864,
+ // GL_CURRENT_QUERY_EXT = 0x8865, // Same as GL_CURRENT_QUERY
+}
+
+enum QueryParameter
+ : QueryParameter_GLES_3
+ , QueryParameter_EXT_disjoint_timer_query {}
+
+enum QueryObjectParameter_GLES_3 {
+ GL_QUERY_RESULT = 0x8866,
+ GL_QUERY_RESULT_AVAILABLE = 0x8867,
+}
+
+enum QueryObjectParameter_EXT_disjoint_timer_query {
+ // GL_QUERY_RESULT_EXT = 0x8866, // Same as GL_QUERY_RESULT
+ // GL_QUERY_RESULT_AVAILABLE_EXT = 0x8867, // Same as GL_QUERY_RESULT_AVAILABLE
+}
+
+enum QueryObjectParameter
+ : QueryObjectParameter_GLES_3
+ , QueryObjectParameter_EXT_disjoint_timer_query {}
+
+enum QueryTarget_GLES_3 {
+ GL_ANY_SAMPLES_PASSED = 0x8C2F,
+ GL_ANY_SAMPLES_PASSED_CONSERVATIVE = 0x8D6A,
+ GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN = 0x8C88,
+}
+
+enum QueryTarget_EXT_disjoint_timer_query {
+ GL_TIME_ELAPSED_EXT = 0x88BF,
+ GL_TIMESTAMP_EXT = 0x8E28,
+}
+
+enum QueryTarget
+ : QueryTarget_GLES_3
+ , QueryTarget_EXT_disjoint_timer_query {}
+
+/////////////////////////////////////////////////////////////////
+// Bitfields
+/////////////////////////////////////////////////////////////////
+
+bitfield TilePreserveMaskQCOM {
+ GL_COLOR_BUFFER_BIT0_QCOM = 0x00000001,
+ GL_COLOR_BUFFER_BIT1_QCOM = 0x00000002,
+ GL_COLOR_BUFFER_BIT2_QCOM = 0x00000004,
+ GL_COLOR_BUFFER_BIT3_QCOM = 0x00000008,
+ GL_COLOR_BUFFER_BIT4_QCOM = 0x00000010,
+ GL_COLOR_BUFFER_BIT5_QCOM = 0x00000020,
+ GL_COLOR_BUFFER_BIT6_QCOM = 0x00000040,
+ GL_COLOR_BUFFER_BIT7_QCOM = 0x00000080,
+ GL_DEPTH_BUFFER_BIT0_QCOM = 0x00000100,
+ GL_DEPTH_BUFFER_BIT1_QCOM = 0x00000200,
+ GL_DEPTH_BUFFER_BIT2_QCOM = 0x00000400,
+ GL_DEPTH_BUFFER_BIT3_QCOM = 0x00000800,
+ GL_DEPTH_BUFFER_BIT4_QCOM = 0x00001000,
+ GL_DEPTH_BUFFER_BIT5_QCOM = 0x00002000,
+ GL_DEPTH_BUFFER_BIT6_QCOM = 0x00004000,
+ GL_DEPTH_BUFFER_BIT7_QCOM = 0x00008000,
+ GL_STENCIL_BUFFER_BIT0_QCOM = 0x00010000,
+ GL_STENCIL_BUFFER_BIT1_QCOM = 0x00020000,
+ GL_STENCIL_BUFFER_BIT2_QCOM = 0x00040000,
+ GL_STENCIL_BUFFER_BIT3_QCOM = 0x00080000,
+ GL_STENCIL_BUFFER_BIT4_QCOM = 0x00100000,
+ GL_STENCIL_BUFFER_BIT5_QCOM = 0x00200000,
+ GL_STENCIL_BUFFER_BIT6_QCOM = 0x00400000,
+ GL_STENCIL_BUFFER_BIT7_QCOM = 0x00800000,
+ GL_MULTISAMPLE_BUFFER_BIT0_QCOM = 0x01000000,
+ GL_MULTISAMPLE_BUFFER_BIT1_QCOM = 0x02000000,
+ GL_MULTISAMPLE_BUFFER_BIT2_QCOM = 0x04000000,
+ GL_MULTISAMPLE_BUFFER_BIT3_QCOM = 0x08000000,
+ GL_MULTISAMPLE_BUFFER_BIT4_QCOM = 0x10000000,
+ GL_MULTISAMPLE_BUFFER_BIT5_QCOM = 0x20000000,
+ GL_MULTISAMPLE_BUFFER_BIT6_QCOM = 0x40000000,
+ GL_MULTISAMPLE_BUFFER_BIT7_QCOM = 0x80000000,
+}
+
+bitfield ClearMask {
+ GL_COLOR_BUFFER_BIT = 0x00004000,
+ GL_DEPTH_BUFFER_BIT = 0x00000100,
+ GL_STENCIL_BUFFER_BIT = 0x00000400,
+}
+
+// GLES 3
+bitfield MapBufferRangeAccess {
+ GL_MAP_READ_BIT = 0x0001,
+ GL_MAP_WRITE_BIT = 0x0002,
+ GL_MAP_INVALIDATE_RANGE_BIT = 0x0004,
+ GL_MAP_INVALIDATE_BUFFER_BIT = 0x0008,
+ GL_MAP_FLUSH_EXPLICIT_BIT = 0x0010,
+ GL_MAP_UNSYNCHRONIZED_BIT = 0x0020,
+}
diff --git a/gfxapi/gles/gles.api b/gfxapi/gles/gles.api
index 93bfbb2..ab9482f 100644
--- a/gfxapi/gles/gles.api
+++ b/gfxapi/gles/gles.api
@@ -12,11 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-// GLES 1 constants can be found in:
-// http://www.khronos.org/registry/gles/api/GLES/gl.h
-
-// GLES 2 constants can be found in:
-// http://www.khronos.org/registry/gles/api/GLES2/gl2.h
+import "glenum.api"
alias void[] pointer
alias buffer<u8> memory
@@ -165,718 +161,6 @@
}
*/
-/////////////////////////////////////////////////////////////////
-// Enums
-/////////////////////////////////////////////////////////////////
-enum DrawMode {
- GL_LINE_LOOP = 0x0002,
- GL_LINE_STRIP = 0x0003,
- GL_LINES = 0x0001,
- GL_POINTS = 0x0000,
- GL_TRIANGLE_FAN = 0x0006,
- GL_TRIANGLE_STRIP = 0x0005,
- GL_TRIANGLES = 0x0004,
-}
-
-enum IndicesType {
- GL_UNSIGNED_BYTE = 0x1401,
- GL_UNSIGNED_SHORT = 0x1403,
- GL_UNSIGNED_INT = 0x1405,
-}
-
-enum TextureTarget_GLES_1_1 {
- GL_TEXTURE_2D = 0x0DE1,
-}
-
-enum TextureTarget_GLES_2_0 {
- GL_TEXTURE_CUBE_MAP = 0x8513,
-}
-
-enum TextureTarget_OES_EGL_image_external {
- GL_TEXTURE_EXTERNAL_OES = 0x8D65,
-}
-
-enum TextureTarget
- : TextureTarget_GLES_1_1
- , TextureTarget_GLES_2_0
- , TextureTarget_OES_EGL_image_external {}
-
-enum CubeMapImageTarget {
- GL_TEXTURE_CUBE_MAP_NEGATIVE_X = 0x8516,
- GL_TEXTURE_CUBE_MAP_NEGATIVE_Y = 0x8518,
- GL_TEXTURE_CUBE_MAP_NEGATIVE_Z = 0x851A,
- GL_TEXTURE_CUBE_MAP_POSITIVE_X = 0x8515,
- GL_TEXTURE_CUBE_MAP_POSITIVE_Y = 0x8517,
- GL_TEXTURE_CUBE_MAP_POSITIVE_Z = 0x8519,
-}
-
-enum Texture2DImageTarget {
- GL_TEXTURE_2D = 0x0DE1,
-}
-
-enum TextureImageTarget : CubeMapImageTarget, Texture2DImageTarget {}
-
-enum BaseTexelFormat {
- GL_ALPHA = 0x1906,
- GL_RGB = 0x1907,
- GL_RGBA = 0x1908,
-}
-
-enum TexelFormat_GLES_1_1 : BaseTexelFormat {
- GL_LUMINANCE = 0x1909,
- GL_LUMINANCE_ALPHA = 0x190A,
-}
-
-enum TexelFormat_GLES_3_0 {
- GL_RED = 0x1903,
- GL_RED_INTEGER = 0x8D94,
- GL_RG = 0x8227,
- GL_RG_INTEGER = 0x8228,
- GL_RGB_INTEGER = 0x8D98,
- GL_RGBA_INTEGER = 0x8D99,
- GL_DEPTH_COMPONENT = 0x1902,
- GL_DEPTH_COMPONENT16 = 0x81A5,
- GL_DEPTH_STENCIL = 0x84F9,
- GL_DEPTH24_STENCIL8 = 0x88F0,
-}
-
-enum TexelFormat : TexelFormat_GLES_1_1, TexelFormat_GLES_3_0 {}
-
-enum RenderbufferFormat {
- GL_RGBA4 = 0x8056,
- GL_RGB5_A1 = 0x8057,
- GL_RGB565 = 0x8D62,
- GL_RGBA8 = 0x8058,
- GL_DEPTH_COMPONENT16 = 0x81A5,
- GL_STENCIL_INDEX8 = 0x8D48,
-}
-
-// http://www.khronos.org/registry/specs/ARB/half_float_vertex.txt
-enum Type_ARB_half_float_vertex {
- GL_ARB_half_float_vertex = 0x140B,
-}
-
-// http://www.khronos.org/registry/gles/extensions/OES/OES_vertex_half_float.txt
-enum Type_OES_vertex_half_float {
- GL_HALF_FLOAT_OES = 0x8D61,
-}
-
-// http://www.khronos.org/registry/gles/extensions/OES/OES_compressed_ETC1_RGB8_texture.txt
-enum CompressedTexelFormat_OES_compressed_ETC1_RGB8_texture {
- GL_ETC1_RGB8_OES = 0x8D64,
-}
-
-enum CompressedTexelFormat_AMD_compressed_ATC_texture {
- GL_ATC_RGB_AMD = 0x8C92,
- GL_ATC_RGBA_EXPLICIT_ALPHA_AMD = 0x8C93,
- GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD = 0x87EE,
-}
-
-enum CompressedTexelFormat
- : CompressedTexelFormat_OES_compressed_ETC1_RGB8_texture
- , CompressedTexelFormat_AMD_compressed_ATC_texture {}
-
-enum ImageTexelFormat : TexelFormat, CompressedTexelFormat {}
-
-enum TexelType {
- GL_UNSIGNED_BYTE = 0x1401,
- GL_UNSIGNED_SHORT = 0x1403,
- GL_UNSIGNED_INT = 0x1405,
- GL_FLOAT = 0x1406,
- GL_UNSIGNED_SHORT_4_4_4_4 = 0x8033,
- GL_UNSIGNED_SHORT_5_5_5_1 = 0x8034,
- GL_UNSIGNED_SHORT_5_6_5 = 0x8363,
- GL_UNSIGNED_INT_24_8 = 0x84FA,
-}
-
-enum FramebufferAttachment {
- GL_COLOR_ATTACHMENT0 = 0x8CE0,
- GL_DEPTH_ATTACHMENT = 0x8D00,
- GL_STENCIL_ATTACHMENT = 0x8D20,
-}
-
-enum FramebufferAttachmentType {
- GL_NONE = 0x0000,
- GL_RENDERBUFFER = 0x8D41,
- GL_TEXTURE = 0x1702,
-}
-
-enum FramebufferTarget_GLES_2_0 {
- GL_FRAMEBUFFER = 0x8D40,
-}
-
-enum FramebufferTarget_GLES_3_1 {
- GL_READ_FRAMEBUFFER = 0x8CA8,
- GL_DRAW_FRAMEBUFFER = 0x8CA9,
-}
-
-enum FramebufferTarget : FramebufferTarget_GLES_2_0, FramebufferTarget_GLES_3_1 {}
-
-enum FramebufferAttachmentParameter {
- GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE = 0x8CD0,
- GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME = 0x8CD1,
- GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL = 0x8CD2,
- GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE = 0x8CD3,
-}
-
-enum FramebufferStatus {
- GL_FRAMEBUFFER_COMPLETE = 0x8CD5,
- GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT = 0x8CD6,
- GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT = 0x8CD7,
- GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS = 0x8CD9,
- GL_FRAMEBUFFER_UNSUPPORTED = 0x8CDD,
-}
-
-enum RenderbufferTarget {
- GL_RENDERBUFFER = 0x8D41,
-}
-
-enum RenderbufferParameter {
- GL_RENDERBUFFER_WIDTH = 0x8D42,
- GL_RENDERBUFFER_HEIGHT = 0x8D43,
- GL_RENDERBUFFER_INTERNAL_FORMAT = 0x8D44,
- GL_RENDERBUFFER_RED_SIZE = 0x8D50,
- GL_RENDERBUFFER_GREEN_SIZE = 0x8D51,
- GL_RENDERBUFFER_BLUE_SIZE = 0x8D52,
- GL_RENDERBUFFER_ALPHA_SIZE = 0x8D53,
- GL_RENDERBUFFER_DEPTH_SIZE = 0x8D54,
- GL_RENDERBUFFER_STENCIL_SIZE = 0x8D55,
-}
-
-enum BufferParameter {
- GL_BUFFER_SIZE = 0x8764,
- GL_BUFFER_USAGE = 0x8765,
-}
-
-enum TextureUnit {
- GL_TEXTURE0 = 0x84C0,
- GL_TEXTURE1 = 0x84C1,
- GL_TEXTURE2 = 0x84C2,
- GL_TEXTURE3 = 0x84C3,
- GL_TEXTURE4 = 0x84C4,
- GL_TEXTURE5 = 0x84C5,
- GL_TEXTURE6 = 0x84C6,
- GL_TEXTURE7 = 0x84C7,
- GL_TEXTURE8 = 0x84C8,
- GL_TEXTURE9 = 0x84C9,
- GL_TEXTURE10 = 0x84CA,
- GL_TEXTURE11 = 0x84CB,
- GL_TEXTURE12 = 0x84CC,
- GL_TEXTURE13 = 0x84CD,
- GL_TEXTURE14 = 0x84CE,
- GL_TEXTURE15 = 0x84CF,
- GL_TEXTURE16 = 0x84D0,
- GL_TEXTURE17 = 0x84D1,
- GL_TEXTURE18 = 0x84D2,
- GL_TEXTURE19 = 0x84D3,
- GL_TEXTURE20 = 0x84D4,
- GL_TEXTURE21 = 0x84D5,
- GL_TEXTURE22 = 0x84D6,
- GL_TEXTURE23 = 0x84D7,
- GL_TEXTURE24 = 0x84D8,
- GL_TEXTURE25 = 0x84D9,
- GL_TEXTURE26 = 0x84DA,
- GL_TEXTURE27 = 0x84DB,
- GL_TEXTURE28 = 0x84DC,
- GL_TEXTURE29 = 0x84DD,
- GL_TEXTURE30 = 0x84DE,
- GL_TEXTURE31 = 0x84DF,
-}
-
-enum BufferUsage {
- GL_DYNAMIC_DRAW = 0x88E8,
- GL_STATIC_DRAW = 0x88E4,
- GL_STREAM_DRAW = 0x88E0,
-}
-
-enum ShaderType {
- GL_VERTEX_SHADER = 0x8B31,
- GL_FRAGMENT_SHADER = 0x8B30,
-}
-
-enum StateVariable_GLES_2_0 {
- GL_ACTIVE_TEXTURE = 0x84E0,
- GL_ALIASED_LINE_WIDTH_RANGE = 0x846E,
- GL_ALIASED_POINT_SIZE_RANGE = 0x846D,
- GL_ALPHA_BITS = 0x0D55,
- GL_ARRAY_BUFFER_BINDING = 0x8894,
- GL_BLEND = 0x0BE2,
- GL_BLEND_COLOR = 0x8005,
- GL_BLEND_DST_ALPHA = 0x80CA,
- GL_BLEND_DST_RGB = 0x80C8,
- GL_BLEND_EQUATION_ALPHA = 0x883D,
- GL_BLEND_EQUATION_RGB = 0x8009,
- GL_BLEND_SRC_ALPHA = 0x80CB,
- GL_BLEND_SRC_RGB = 0x80C9,
- GL_BLUE_BITS = 0x0D54,
- GL_COLOR_CLEAR_VALUE = 0x0C22,
- GL_COLOR_WRITEMASK = 0x0C23,
- GL_COMPRESSED_TEXTURE_FORMATS = 0x86A3,
- GL_CULL_FACE = 0x0B44,
- GL_CULL_FACE_MODE = 0x0B45,
- GL_CURRENT_PROGRAM = 0x8B8D,
- GL_DEPTH_BITS = 0x0D56,
- GL_DEPTH_CLEAR_VALUE = 0x0B73,
- GL_DEPTH_FUNC = 0x0B74,
- GL_DEPTH_RANGE = 0x0B70,
- GL_DEPTH_TEST = 0x0B71,
- GL_DEPTH_WRITEMASK = 0x0B72,
- GL_DITHER = 0x0BD0,
- GL_ELEMENT_ARRAY_BUFFER_BINDING = 0x8895,
- GL_FRAMEBUFFER_BINDING = 0x8CA6,
- GL_FRONT_FACE = 0x0B46,
- GL_GENERATE_MIPMAP_HINT = 0x8192,
- GL_GREEN_BITS = 0x0D53,
- GL_IMPLEMENTATION_COLOR_READ_FORMAT = 0x8B9B,
- GL_IMPLEMENTATION_COLOR_READ_TYPE = 0x8B9A,
- GL_LINE_WIDTH = 0x0B21,
- GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS = 0x8B4D,
- GL_MAX_CUBE_MAP_TEXTURE_SIZE = 0x851C,
- GL_MAX_FRAGMENT_UNIFORM_VECTORS = 0x8DFD,
- GL_MAX_RENDERBUFFER_SIZE = 0x84E8,
- GL_MAX_TEXTURE_IMAGE_UNITS = 0x8872,
- GL_MAX_TEXTURE_SIZE = 0x0D33,
- GL_MAX_VARYING_VECTORS = 0x8DFC,
- GL_MAX_VERTEX_ATTRIBS = 0x8869,
- GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS = 0x8B4C,
- GL_MAX_VERTEX_UNIFORM_VECTORS = 0x8DFB,
- GL_MAX_VIEWPORT_DIMS = 0x0D3A,
- GL_NUM_COMPRESSED_TEXTURE_FORMATS = 0x86A2,
- GL_NUM_SHADER_BINARY_FORMATS = 0x8DF9,
- GL_PACK_ALIGNMENT = 0x0D05,
- GL_POLYGON_OFFSET_FACTOR = 0x8038,
- GL_POLYGON_OFFSET_FILL = 0x8037,
- GL_POLYGON_OFFSET_UNITS = 0x2A00,
- GL_RED_BITS = 0x0D52,
- GL_RENDERBUFFER_BINDING = 0x8CA7,
- GL_SAMPLE_ALPHA_TO_COVERAGE = 0x809E,
- GL_SAMPLE_BUFFERS = 0x80A8,
- GL_SAMPLE_COVERAGE = 0x80A0,
- GL_SAMPLE_COVERAGE_INVERT = 0x80AB,
- GL_SAMPLE_COVERAGE_VALUE = 0x80AA,
- GL_SAMPLES = 0x80A9,
- GL_SCISSOR_BOX = 0x0C10,
- GL_SCISSOR_TEST = 0x0C11,
- GL_SHADER_BINARY_FORMATS = 0x8DF8,
- GL_SHADER_COMPILER = 0x8DFA,
- GL_STENCIL_BACK_FAIL = 0x8801,
- GL_STENCIL_BACK_FUNC = 0x8800,
- GL_STENCIL_BACK_PASS_DEPTH_FAIL = 0x8802,
- GL_STENCIL_BACK_PASS_DEPTH_PASS = 0x8803,
- GL_STENCIL_BACK_REF = 0x8CA3,
- GL_STENCIL_BACK_VALUE_MASK = 0x8CA4,
- GL_STENCIL_BACK_WRITEMASK = 0x8CA5,
- GL_STENCIL_BITS = 0x0D57,
- GL_STENCIL_CLEAR_VALUE = 0x0B91,
- GL_STENCIL_FAIL = 0x0B94,
- GL_STENCIL_FUNC = 0x0B92,
- GL_STENCIL_PASS_DEPTH_FAIL = 0x0B95,
- GL_STENCIL_PASS_DEPTH_PASS = 0x0B96,
- GL_STENCIL_REF = 0x0B97,
- GL_STENCIL_TEST = 0x0B90,
- GL_STENCIL_VALUE_MASK = 0x0B93,
- GL_STENCIL_WRITEMASK = 0x0B98,
- GL_SUBPIXEL_BITS = 0x0D50,
- GL_TEXTURE_BINDING_2D = 0x8069,
- GL_TEXTURE_BINDING_CUBE_MAP = 0x8514,
- GL_UNPACK_ALIGNMENT = 0x0CF5,
- GL_VIEWPORT = 0x0BA2,
-}
-
-enum StateVariable_GLES_3_1 {
- // GL_DRAW_FRAMEBUFFER_BINDING = 0x8CA6, // Same as GL_FRAMEBUFFER_BINDING
- GL_READ_FRAMEBUFFER_BINDING = 0x8CAA,
-}
-
-enum StateVariable_EXT_texture_filter_anisotropic {
- GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT = 0x84FF,
-}
-
-enum StateVariable_EXT_disjoint_timer_query {
- GL_GPU_DISJOINT_EXT = 0x8FBB,
-}
-
-enum StateVariable
- : StateVariable_GLES_2_0
- , StateVariable_GLES_3_1
- , StateVariable_EXT_texture_filter_anisotropic
- , StateVariable_EXT_disjoint_timer_query {}
-
-enum FaceMode {
- GL_FRONT = 0x0404,
- GL_BACK = 0x0405,
- GL_FRONT_AND_BACK = 0x0408,
-}
-
-enum ArrayType_GLES_1_1 {
- GL_VERTEX_ARRAY = 0x8074,
- GL_NORMAL_ARRAY = 0x8075,
- GL_COLOR_ARRAY = 0x8076,
- GL_TEXTURE_COORD_ARRAY = 0x8078,
-}
-
-enum ArrayType_OES_point_size_array {
- GL_POINT_SIZE_ARRAY_OES = 0x8B9C,
-}
-
-enum ArrayType : ArrayType_GLES_1_1, ArrayType_OES_point_size_array {}
-
-enum Capability : ArrayType {
- GL_BLEND = 0x0BE2,
- GL_CULL_FACE = 0x0B44,
- GL_DEPTH_TEST = 0x0B71,
- GL_DITHER = 0x0BD0,
- GL_POLYGON_OFFSET_FILL = 0x8037,
- GL_SAMPLE_ALPHA_TO_COVERAGE = 0x809E,
- GL_SAMPLE_COVERAGE = 0x80A0,
- GL_SCISSOR_TEST = 0x0C11,
- GL_STENCIL_TEST = 0x0B90,
-}
-
-enum StringConstant {
- GL_EXTENSIONS = 0x1F03,
- GL_RENDERER = 0x1F01,
- GL_VENDOR = 0x1F00,
- GL_VERSION = 0x1F02,
-}
-
-enum VertexAttribType : Type_OES_vertex_half_float
- , Type_ARB_half_float_vertex {
- GL_BYTE = 0x1400,
- GL_FIXED = 0x140C,
- GL_FLOAT = 0x1406,
- GL_SHORT = 0x1402,
- GL_UNSIGNED_BYTE = 0x1401,
- GL_UNSIGNED_SHORT = 0x1403,
-}
-
-enum ShaderAttribType {
- GL_FLOAT = 0x1406,
- GL_FLOAT_VEC2 = 0x8B50,
- GL_FLOAT_VEC3 = 0x8B51,
- GL_FLOAT_VEC4 = 0x8B52,
- GL_FLOAT_MAT2 = 0x8B5A,
- GL_FLOAT_MAT3 = 0x8B5B,
- GL_FLOAT_MAT4 = 0x8B5C,
-}
-
-enum ShaderUniformType {
- GL_FLOAT = 0x1406,
- GL_FLOAT_VEC2 = 0x8B50,
- GL_FLOAT_VEC3 = 0x8B51,
- GL_FLOAT_VEC4 = 0x8B52,
- GL_INT = 0x1404,
- GL_INT_VEC2 = 0x8B53,
- GL_INT_VEC3 = 0x8B54,
- GL_INT_VEC4 = 0x8B55,
- GL_BOOL = 0x8B56,
- GL_BOOL_VEC2 = 0x8B57,
- GL_BOOL_VEC3 = 0x8B58,
- GL_BOOL_VEC4 = 0x8B59,
- GL_FLOAT_MAT2 = 0x8B5A,
- GL_FLOAT_MAT3 = 0x8B5B,
- GL_FLOAT_MAT4 = 0x8B5C,
- GL_SAMPLER_2D = 0x8B5E,
- GL_SAMPLER_CUBE = 0x8B60,
-}
-
-enum Error {
- GL_NO_ERROR = 0x0,
- GL_INVALID_ENUM = 0x0500,
- GL_INVALID_VALUE = 0x0501,
- GL_INVALID_OPERATION = 0x0502,
- GL_INVALID_FRAMEBUFFER_OPERATION = 0x0506,
- GL_OUT_OF_MEMORY = 0x0505,
-}
-
-enum HintTarget {
- GL_GENERATE_MIPMAP_HINT = 0x8192,
-}
-
-enum HintMode {
- GL_DONT_CARE = 0x1100,
- GL_FASTEST = 0x1101,
- GL_NICEST = 0x1102,
-}
-
-enum DiscardFramebufferAttachment {
- GL_COLOR_EXT = 0x1800,
- GL_DEPTH_EXT = 0x1801,
- GL_STENCIL_EXT = 0x1802,
-}
-
-enum ProgramParameter {
- GL_DELETE_STATUS = 0x8B80,
- GL_LINK_STATUS = 0x8B82,
- GL_VALIDATE_STATUS = 0x8B83,
- GL_INFO_LOG_LENGTH = 0x8B84,
- GL_ATTACHED_SHADERS = 0x8B85,
- GL_ACTIVE_ATTRIBUTES = 0x8B89,
- GL_ACTIVE_ATTRIBUTE_MAX_LENGTH = 0x8B8A,
- GL_ACTIVE_UNIFORMS = 0x8B86,
- GL_ACTIVE_UNIFORM_MAX_LENGTH = 0x8B87,
-}
-
-enum ShaderParameter {
- GL_SHADER_TYPE = 0x8B4F,
- GL_DELETE_STATUS = 0x8B80,
- GL_COMPILE_STATUS = 0x8B81,
- GL_INFO_LOG_LENGTH = 0x8B84,
- GL_SHADER_SOURCE_LENGTH = 0x8B88,
-}
-
-enum PixelStoreParameter {
- GL_PACK_ALIGNMENT = 0x0D05,
- GL_UNPACK_ALIGNMENT = 0x0CF5,
-}
-
-enum TextureParameter_FilterMode {
- GL_TEXTURE_MIN_FILTER = 0x2801,
- GL_TEXTURE_MAG_FILTER = 0x2800,
-}
-
-enum TextureParameter_WrapMode {
- GL_TEXTURE_WRAP_S = 0x2802,
- GL_TEXTURE_WRAP_T = 0x2803,
-}
-
-enum TextureParameter_EXT_texture_filter_anisotropic {
- GL_TEXTURE_MAX_ANISOTROPY_EXT = 0x84FE,
-}
-
-enum TextureParameter_SwizzleMode {
- GL_TEXTURE_SWIZZLE_R = 0x8E42,
- GL_TEXTURE_SWIZZLE_G = 0x8E43,
- GL_TEXTURE_SWIZZLE_B = 0x8E44,
- GL_TEXTURE_SWIZZLE_A = 0x8E45,
-}
-
-enum TextureParameter
- : TextureParameter_FilterMode
- , TextureParameter_WrapMode
- , TextureParameter_SwizzleMode
- , TextureParameter_EXT_texture_filter_anisotropic {}
-
-enum TextureFilterMode {
- GL_NEAREST = 0x2600,
- GL_LINEAR = 0x2601,
- GL_NEAREST_MIPMAP_NEAREST = 0x2700,
- GL_LINEAR_MIPMAP_NEAREST = 0x2701,
- GL_NEAREST_MIPMAP_LINEAR = 0x2702,
- GL_LINEAR_MIPMAP_LINEAR = 0x2703,
-}
-
-enum TextureWrapMode {
- GL_CLAMP_TO_EDGE = 0x812F,
- GL_MIRRORED_REPEAT = 0x8370,
- GL_REPEAT = 0x2901,
-}
-
-enum TexelComponent {
- GL_RED = 0x1903,
- GL_GREEN = 0x1904,
- GL_BLUE = 0x1905,
- GL_ALPHA = 0x1906,
-}
-
-enum BlendFactor {
- GL_ZERO = 0x0000,
- GL_ONE = 0x0001,
- GL_SRC_COLOR = 0x0300,
- GL_ONE_MINUS_SRC_COLOR = 0x0301,
- GL_DST_COLOR = 0x0306,
- GL_ONE_MINUS_DST_COLOR = 0x0307,
- GL_SRC_ALPHA = 0x0302,
- GL_ONE_MINUS_SRC_ALPHA = 0x0303,
- GL_DST_ALPHA = 0x0304,
- GL_ONE_MINUS_DST_ALPHA = 0x0305,
- GL_CONSTANT_COLOR = 0x8001,
- GL_ONE_MINUS_CONSTANT_COLOR = 0x8002,
- GL_CONSTANT_ALPHA = 0x8003,
- GL_ONE_MINUS_CONSTANT_ALPHA = 0x8004,
- GL_SRC_ALPHA_SATURATE = 0x0308,
-}
-
-enum PrecisionType {
- GL_LOW_FLOAT = 0x8DF0,
- GL_MEDIUM_FLOAT = 0x8DF1,
- GL_HIGH_FLOAT = 0x8DF2,
- GL_LOW_INT = 0x8DF3,
- GL_MEDIUM_INT = 0x8DF4,
- GL_HIGH_INT = 0x8DF5,
-}
-
-enum TestFunction {
- GL_NEVER = 0x0200,
- GL_LESS = 0x0201,
- GL_EQUAL = 0x0202,
- GL_LEQUAL = 0x0203,
- GL_GREATER = 0x0204,
- GL_NOTEQUAL = 0x0205,
- GL_GEQUAL = 0x0206,
- GL_ALWAYS = 0x0207,
-}
-
-enum StencilAction {
- GL_KEEP = 0x1E00,
- GL_ZERO = 0x0000,
- GL_REPLACE = 0x1E01,
- GL_INCR = 0x1E02,
- GL_INCR_WRAP = 0x8507,
- GL_DECR = 0x1E03,
- GL_DECR_WRAP = 0x8508,
- GL_INVERT = 0x150A,
-}
-
-enum FaceOrientation {
- GL_CW = 0x0900,
- GL_CCW = 0x0901,
-}
-
-enum BlendEquation {
- GL_FUNC_ADD = 0x8006,
- GL_FUNC_SUBTRACT = 0x800A,
- GL_FUNC_REVERSE_SUBTRACT = 0x800B,
-}
-
-// GLES 3
-enum BufferTarget {
- GL_ARRAY_BUFFER = 0x8892,
- GL_COPY_READ_BUFFER = 0x8F36,
- GL_COPY_WRITE_BUFFER = 0x8F37,
- GL_ELEMENT_ARRAY_BUFFER = 0x8893,
- GL_PIXEL_PACK_BUFFER = 0x88EB,
- GL_PIXEL_UNPACK_BUFFER = 0x88EC,
- GL_TRANSFORM_FEEDBACK_BUFFER = 0x8C8E,
- GL_UNIFORM_BUFFER = 0x8A11,
-}
-
-enum ImageTargetTexture_OES_EGL_image {
- GL_TEXTURE_2D = 0x0DE1,
-}
-
-enum ImageTargetTexture_OES_EGL_image_external {
- GL_TEXTURE_EXTERNAL_OES = 0x8D65,
-}
-
-enum ImageTargetTexture
- : ImageTargetTexture_OES_EGL_image
- , ImageTargetTexture_OES_EGL_image_external {}
-
-enum ImageTargetRenderbufferStorage {
- GL_RENDERBUFFER_OES = 0x8D41,
-}
-
-enum ResetStatus {
- GL_NO_ERROR = 0x0000,
- GL_GUILTY_CONTEXT_RESET_EXT = 0x8253,
- GL_INNOCENT_CONTEXT_RESET_EXT = 0x8254,
- GL_UNKNOWN_CONTEXT_RESET_EXT = 0x8255,
-}
-
-enum TextureKind {
- UNDEFINED = 0,
- TEXTURE2D = 1,
- CUBEMAP = 2,
-}
-
-enum QueryParameter_GLES_3 {
- GL_CURRENT_QUERY = 0x8865,
-}
-
-enum QueryParameter_EXT_disjoint_timer_query {
- GL_QUERY_COUNTER_BITS_EXT = 0x8864,
- // GL_CURRENT_QUERY_EXT = 0x8865, // Same as GL_CURRENT_QUERY
-}
-
-enum QueryParameter
- : QueryParameter_GLES_3
- , QueryParameter_EXT_disjoint_timer_query {}
-
-enum QueryObjectParameter_GLES_3 {
- GL_QUERY_RESULT = 0x8866,
- GL_QUERY_RESULT_AVAILABLE = 0x8867,
-}
-
-enum QueryObjectParameter_EXT_disjoint_timer_query {
- // GL_QUERY_RESULT_EXT = 0x8866, // Same as GL_QUERY_RESULT
- // GL_QUERY_RESULT_AVAILABLE_EXT = 0x8867, // Same as GL_QUERY_RESULT_AVAILABLE
-}
-
-enum QueryObjectParameter
- : QueryObjectParameter_GLES_3
- , QueryObjectParameter_EXT_disjoint_timer_query {}
-
-enum QueryTarget_GLES_3 {
- GL_ANY_SAMPLES_PASSED = 0x8C2F,
- GL_ANY_SAMPLES_PASSED_CONSERVATIVE = 0x8D6A,
- GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN = 0x8C88,
-}
-
-enum QueryTarget_EXT_disjoint_timer_query {
- GL_TIME_ELAPSED_EXT = 0x88BF,
- GL_TIMESTAMP_EXT = 0x8E28,
-}
-
-enum QueryTarget
- : QueryTarget_GLES_3
- , QueryTarget_EXT_disjoint_timer_query {}
-
-/////////////////////////////////////////////////////////////////
-// Bitfields
-/////////////////////////////////////////////////////////////////
-
-bitfield TilePreserveMaskQCOM {
- GL_COLOR_BUFFER_BIT0_QCOM = 0x00000001,
- GL_COLOR_BUFFER_BIT1_QCOM = 0x00000002,
- GL_COLOR_BUFFER_BIT2_QCOM = 0x00000004,
- GL_COLOR_BUFFER_BIT3_QCOM = 0x00000008,
- GL_COLOR_BUFFER_BIT4_QCOM = 0x00000010,
- GL_COLOR_BUFFER_BIT5_QCOM = 0x00000020,
- GL_COLOR_BUFFER_BIT6_QCOM = 0x00000040,
- GL_COLOR_BUFFER_BIT7_QCOM = 0x00000080,
- GL_DEPTH_BUFFER_BIT0_QCOM = 0x00000100,
- GL_DEPTH_BUFFER_BIT1_QCOM = 0x00000200,
- GL_DEPTH_BUFFER_BIT2_QCOM = 0x00000400,
- GL_DEPTH_BUFFER_BIT3_QCOM = 0x00000800,
- GL_DEPTH_BUFFER_BIT4_QCOM = 0x00001000,
- GL_DEPTH_BUFFER_BIT5_QCOM = 0x00002000,
- GL_DEPTH_BUFFER_BIT6_QCOM = 0x00004000,
- GL_DEPTH_BUFFER_BIT7_QCOM = 0x00008000,
- GL_STENCIL_BUFFER_BIT0_QCOM = 0x00010000,
- GL_STENCIL_BUFFER_BIT1_QCOM = 0x00020000,
- GL_STENCIL_BUFFER_BIT2_QCOM = 0x00040000,
- GL_STENCIL_BUFFER_BIT3_QCOM = 0x00080000,
- GL_STENCIL_BUFFER_BIT4_QCOM = 0x00100000,
- GL_STENCIL_BUFFER_BIT5_QCOM = 0x00200000,
- GL_STENCIL_BUFFER_BIT6_QCOM = 0x00400000,
- GL_STENCIL_BUFFER_BIT7_QCOM = 0x00800000,
- GL_MULTISAMPLE_BUFFER_BIT0_QCOM = 0x01000000,
- GL_MULTISAMPLE_BUFFER_BIT1_QCOM = 0x02000000,
- GL_MULTISAMPLE_BUFFER_BIT2_QCOM = 0x04000000,
- GL_MULTISAMPLE_BUFFER_BIT3_QCOM = 0x08000000,
- GL_MULTISAMPLE_BUFFER_BIT4_QCOM = 0x10000000,
- GL_MULTISAMPLE_BUFFER_BIT5_QCOM = 0x20000000,
- GL_MULTISAMPLE_BUFFER_BIT6_QCOM = 0x40000000,
- GL_MULTISAMPLE_BUFFER_BIT7_QCOM = 0x80000000,
-}
-
-bitfield ClearMask {
- GL_COLOR_BUFFER_BIT = 0x00004000,
- GL_DEPTH_BUFFER_BIT = 0x00000100,
- GL_STENCIL_BUFFER_BIT = 0x00000400,
-}
-
-// GLES 3
-bitfield MapBufferRangeAccess {
- GL_MAP_READ_BIT = 0x0001,
- GL_MAP_WRITE_BIT = 0x0002,
- GL_MAP_INVALIDATE_RANGE_BIT = 0x0004,
- GL_MAP_INVALIDATE_BUFFER_BIT = 0x0008,
- GL_MAP_FLUSH_EXPLICIT_BIT = 0x0010,
- GL_MAP_UNSYNCHRONIZED_BIT = 0x0020,
-}
-
@internal
class Color {
f32 Red
diff --git a/parse/error.go b/parse/error.go
index 7dffeff..4c7f861 100644
--- a/parse/error.go
+++ b/parse/error.go
@@ -41,6 +41,13 @@
// ErrorList is a convenience type for managing lists of errors.
type ErrorList []Error
+func (errs ErrorList) Error() string {
+ if len(errs) == 0 {
+ return ""
+ }
+ return fmt.Sprintf("%d errors, first error was: %v", len(errs), errs[0])
+}
+
func (err Error) Error() string {
return err.Message
}
diff --git a/rpc/rpcapi/main.go b/rpc/rpcapi/main.go
index 4ed5c51..21ef07d 100644
--- a/rpc/rpcapi/main.go
+++ b/rpc/rpcapi/main.go
@@ -19,12 +19,11 @@
import (
"flag"
"fmt"
- "io/ioutil"
"os"
"strings"
+ "android.googlesource.com/platform/tools/gpu/api"
"android.googlesource.com/platform/tools/gpu/api/apic/commands"
- "android.googlesource.com/platform/tools/gpu/api/parser"
"android.googlesource.com/platform/tools/gpu/api/resolver"
"android.googlesource.com/platform/tools/gpu/rpc/generate"
)
@@ -54,17 +53,10 @@
c[0].Flags.Set("dir", *dir)
}
apiName := flag.Args()[0]
- info, err := ioutil.ReadFile(apiName)
- if err != nil {
- return err
- }
- parsed, errs := parser.Parse(string(info[:]))
- if err != nil {
- return err
- }
- compiled, errs, _ := resolver.Resolve(parsed)
+ mappings := resolver.ASTToSemantic{}
+ compiled, errs := api.Resolve(apiName, mappings)
if len(errs) > 0 {
- return errs[0]
+ return errs
}
f := generate.Init(apiName, compiled)
if len(errs) > 0 {