opengl-registry 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/.travis.yml +6 -0
- data/.yardopts +7 -0
- data/CHANGELOG.md +4 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +21 -0
- data/README.md +85 -0
- data/Rakefile +3 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/opengl/registry.rb +318 -0
- data/lib/opengl/registry/argument.rb +60 -0
- data/lib/opengl/registry/enum.rb +64 -0
- data/lib/opengl/registry/extension.rb +23 -0
- data/lib/opengl/registry/feature.rb +48 -0
- data/lib/opengl/registry/feature_group.rb +38 -0
- data/lib/opengl/registry/feature_provider.rb +45 -0
- data/lib/opengl/registry/function.rb +86 -0
- data/lib/opengl/registry/group.rb +62 -0
- data/lib/opengl/registry/native_type.rb +59 -0
- data/lib/opengl/registry/token.rb +29 -0
- data/lib/opengl/registry/version.rb +10 -0
- data/lib/opengl/registry/words.rb +39 -0
- data/lib/opengl/spec.rb +176 -0
- data/opengl-registry.gemspec +37 -0
- metadata +103 -0
@@ -0,0 +1,29 @@
|
|
1
|
+
module GL
|
2
|
+
class Registry
|
3
|
+
|
4
|
+
##
|
5
|
+
# @abstract Base class for OpenGL registry defined items.
|
6
|
+
class Token
|
7
|
+
|
8
|
+
##
|
9
|
+
# @return [String?] an arbitrary comment associated with this object.
|
10
|
+
attr_reader :comment
|
11
|
+
|
12
|
+
##
|
13
|
+
# Creates a new instance of the {Token} class.
|
14
|
+
#
|
15
|
+
# @param node [Ox::Element] The XML element defining the instance.
|
16
|
+
def initialize(node)
|
17
|
+
raise ArgumentError, 'item node cannot be nil' unless node
|
18
|
+
|
19
|
+
@comment = node[Words::COMMENT]
|
20
|
+
end
|
21
|
+
|
22
|
+
##
|
23
|
+
# @return [String] the string representation of this object.
|
24
|
+
def to_s
|
25
|
+
@name || super
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module GL
|
4
|
+
|
5
|
+
class Registry
|
6
|
+
|
7
|
+
##
|
8
|
+
# Strongly-typed values for common XML element/attribute names.
|
9
|
+
module Words
|
10
|
+
|
11
|
+
ENUM = 'enum'
|
12
|
+
COMMAND = 'command'
|
13
|
+
REGISTRY = 'registry'
|
14
|
+
COMMENT = 'comment'
|
15
|
+
NAMESPACE = 'namespace'
|
16
|
+
GROUP = 'group'
|
17
|
+
NAME = 'name'
|
18
|
+
RANGE_START = 'start'
|
19
|
+
RANGE_END = 'end'
|
20
|
+
API = 'api'
|
21
|
+
ALIAS = 'alias'
|
22
|
+
TYPE = 'type'
|
23
|
+
VENDOR = 'vendor'
|
24
|
+
VALUE = 'value'
|
25
|
+
PROTO = 'proto'
|
26
|
+
PTYPE = 'ptype'
|
27
|
+
PARAM = 'param'
|
28
|
+
GLX = 'glx'
|
29
|
+
VECTOR_EQUIVALENT = 'vecequiv'
|
30
|
+
LENGTH = 'len'
|
31
|
+
NUMBER = 'number'
|
32
|
+
PROFILE = 'profile'
|
33
|
+
SUPPORTED = 'supported'
|
34
|
+
U_LONG = 'u'
|
35
|
+
U_LONG_LONG = 'ull'
|
36
|
+
BITMASK = 'bitmask'
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/lib/opengl/spec.rb
ADDED
@@ -0,0 +1,176 @@
|
|
1
|
+
module GL
|
2
|
+
|
3
|
+
##
|
4
|
+
# Describes a specific subset of the OpenGL registry, targeting an API, version, profile, etc.
|
5
|
+
#
|
6
|
+
# Automatically filters all results bu the specified criteria, only returning results that are
|
7
|
+
# used in the specification.
|
8
|
+
class Spec
|
9
|
+
|
10
|
+
##
|
11
|
+
# @return [Registry] the registry instance the specification uses for reference.
|
12
|
+
attr_accessor :registry
|
13
|
+
|
14
|
+
##
|
15
|
+
# @return [Symbol] the OpenGL API name.
|
16
|
+
attr_reader :api
|
17
|
+
|
18
|
+
##
|
19
|
+
# @return [String] the OpenGL version number for the specification.
|
20
|
+
attr_reader :version
|
21
|
+
|
22
|
+
##
|
23
|
+
# @return [Symbol] the OpenGL profile name for the specification.
|
24
|
+
attr_reader :profile
|
25
|
+
|
26
|
+
##
|
27
|
+
# @return [Array<String>] an array of extension names.
|
28
|
+
attr_reader :extensions
|
29
|
+
|
30
|
+
##
|
31
|
+
# Creates a new instance of the {Spec} class.
|
32
|
+
#
|
33
|
+
# @param registry [Registry] An registry instance to use for definition referencing.
|
34
|
+
# @param api [Symbol,String] The OpenGL API name.
|
35
|
+
# @param version [String,Float] The OpenGL version number for the specification.
|
36
|
+
# @param profile [Symbol,String] The OpenGL profile name for the specification.
|
37
|
+
# @param extensions [Array<String>] Names of extensions name to include definitions for.
|
38
|
+
def initialize(registry, api, version, profile, *extensions)
|
39
|
+
@registry = registry
|
40
|
+
@api = api.to_sym
|
41
|
+
@profile = profile.to_sym
|
42
|
+
@version = Float(version).to_s
|
43
|
+
@extensions = extensions&.uniq || []
|
44
|
+
end
|
45
|
+
|
46
|
+
##
|
47
|
+
# Retrieves a complete list of all OpenGL types that this specification must have defined. Any type not included
|
48
|
+
# here does not need to be mapped.
|
49
|
+
#
|
50
|
+
# @param groups [Boolean] `true` to include group (enumeration) names, otherwise `false`
|
51
|
+
#
|
52
|
+
# @return [Array<Symbol>] a collection of OpenGL types.
|
53
|
+
# @note The values are re-calculated each time this method is invoked, so consider caching the result if reusing.
|
54
|
+
def types(groups = false)
|
55
|
+
|
56
|
+
values = {}
|
57
|
+
functions.each do |func|
|
58
|
+
|
59
|
+
values[func.type.base] = true
|
60
|
+
values[func.type.group] = true if groups && func.type.group
|
61
|
+
|
62
|
+
func.arguments.each do |arg|
|
63
|
+
values[arg.type.base] = true
|
64
|
+
values[arg.type.group] = true if groups && arg.type.group
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
#noinspection RubyYardReturnMatch
|
69
|
+
values.keys.map(&:to_sym)
|
70
|
+
end
|
71
|
+
|
72
|
+
##
|
73
|
+
# Retrieves a complete list of all OpenGL functions that this specification defines.
|
74
|
+
#
|
75
|
+
# @return [Array<Registry::Function>] a collection of {Registry::Function} instances.
|
76
|
+
# @note The values are re-calculated each time this method is invoked, so consider caching the result if reusing.
|
77
|
+
def functions
|
78
|
+
items(:function, @registry.functions)
|
79
|
+
end
|
80
|
+
|
81
|
+
##
|
82
|
+
# Retrieves a complete list of all OpenGL enumeration values that this specification defines.
|
83
|
+
#
|
84
|
+
# @return [Array<Registry::Enum>] a collection of {Registry::Enum} instances.
|
85
|
+
# @note The values are re-calculated each time this method is invoked, so consider caching the result if reusing.
|
86
|
+
def enums
|
87
|
+
items(:enum, @registry.enums)
|
88
|
+
end
|
89
|
+
|
90
|
+
##
|
91
|
+
# Retrieves a complete list of all OpenGL group names that this specification uses.
|
92
|
+
#
|
93
|
+
# @return [Array<String>] a collection of group (enumeration) names.
|
94
|
+
# @note The values are re-calculated each time this method is invoked, so consider caching the result if reusing.
|
95
|
+
def used_groups
|
96
|
+
|
97
|
+
names = {}
|
98
|
+
functions.each do |func|
|
99
|
+
|
100
|
+
names[func.type.group] = true if func.type.group
|
101
|
+
func.arguments.each do |arg|
|
102
|
+
group = arg.type.group
|
103
|
+
next unless group
|
104
|
+
|
105
|
+
names[group] = true
|
106
|
+
end
|
107
|
+
end
|
108
|
+
names.keys
|
109
|
+
end
|
110
|
+
|
111
|
+
##
|
112
|
+
# @return [String] the string representation of this object.
|
113
|
+
def to_s
|
114
|
+
if profile != :none
|
115
|
+
return "Open#{@api.to_s.upcase} #{@version} (#{@profile} profile)"
|
116
|
+
end
|
117
|
+
"Open#{@api.to_s.upcase} #{@version}"
|
118
|
+
end
|
119
|
+
|
120
|
+
private
|
121
|
+
|
122
|
+
def items(type, definitions)
|
123
|
+
raise 'registry is nil' unless @registry
|
124
|
+
|
125
|
+
values = []
|
126
|
+
|
127
|
+
# Enumerate through each feature group
|
128
|
+
@registry.features.each do |group|
|
129
|
+
|
130
|
+
# Skip unless this group implements the specified API and version
|
131
|
+
next if group.api != @api
|
132
|
+
next if group.version > @version
|
133
|
+
|
134
|
+
# Enumerator through item this group implements
|
135
|
+
group.additions.each do |feature|
|
136
|
+
# Skip if this is not the specified type of not within the profile
|
137
|
+
next if feature.type != type
|
138
|
+
next unless feature.profile == :none || feature.profile == @profile
|
139
|
+
|
140
|
+
# Add the definition this feature represents
|
141
|
+
values << definitions.find { |item| item.name == feature.name }
|
142
|
+
end
|
143
|
+
|
144
|
+
# Enumerate through any "removed item" for this group
|
145
|
+
group.removals.each do |feature|
|
146
|
+
# Skip if this is not the specified type of not within the profile
|
147
|
+
next unless feature.type == type
|
148
|
+
next unless feature.profile == :none || feature.profile == @profile
|
149
|
+
|
150
|
+
# Remove the definition this feature represents
|
151
|
+
values.delete_if { |item| item.name == feature.name }
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
# Enumerate through each extension
|
156
|
+
@extensions.each do |name|
|
157
|
+
# Find the extension definition, skipping unless supported by the API
|
158
|
+
ext = @registry.extensions.find { |e| e.name == name }
|
159
|
+
next unless ext && ext.supported.include?(@api)
|
160
|
+
|
161
|
+
# Enumerate through each feature this extension implements
|
162
|
+
ext.additions.each do |feature|
|
163
|
+
# Skip if this is not the specified type of not within the profile
|
164
|
+
next if feature.type != type
|
165
|
+
next unless feature.profile == :none || feature.profile == @profile
|
166
|
+
|
167
|
+
# Add the definition this feature represents
|
168
|
+
values << definitions.find { |item| item.name == feature.name }
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
# Return results
|
173
|
+
values
|
174
|
+
end
|
175
|
+
end
|
176
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'lib/opengl/registry/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'opengl-registry'
|
7
|
+
spec.version = GL::Registry::VERSION
|
8
|
+
spec.authors = ['ForeverZer0']
|
9
|
+
spec.email = ['efreed09@gmail.com']
|
10
|
+
|
11
|
+
spec.summary = 'OpenGL Registry parser for generating API specifications'
|
12
|
+
spec.description = <<-EOS
|
13
|
+
Parses the Khronos OpenGL registry into a standardized and user-friendly data structure that can be walked through,
|
14
|
+
providing an essential need for tools that generate code to create an OpenGL wrapper/bindings, for any language. Given
|
15
|
+
an API name, version, and profile, is capable of filtering and grouping data structures that cover that specific
|
16
|
+
subset of definitions, using a typical Ruby object-oriented approach.
|
17
|
+
EOS
|
18
|
+
spec.homepage = 'https://github.com/ForeverZer0/opengl-registry'
|
19
|
+
spec.license = 'MIT'
|
20
|
+
spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
|
21
|
+
|
22
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
23
|
+
spec.metadata['source_code_uri'] = 'https://github.com/ForeverZer0/opengl-registry'
|
24
|
+
spec.metadata['changelog_uri'] = 'https://github.com/ForeverZer0/opengl-registry/CHANGELOG.md'
|
25
|
+
|
26
|
+
# Specify which files should be added to the gem when it is released.
|
27
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
28
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
29
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
30
|
+
end
|
31
|
+
spec.bindir = 'exe'
|
32
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
33
|
+
spec.require_paths = ['lib']
|
34
|
+
|
35
|
+
spec.add_development_dependency 'rake', '~> 12.0'
|
36
|
+
spec.add_runtime_dependency 'ox', '~> 2.13'
|
37
|
+
end
|
metadata
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: opengl-registry
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- ForeverZer0
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-05-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '12.0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '12.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: ox
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.13'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.13'
|
41
|
+
description: |2
|
42
|
+
Parses the Khronos OpenGL registry into a standardized and user-friendly data structure that can be walked through,
|
43
|
+
providing an essential need for tools that generate code to create an OpenGL wrapper/bindings, for any language. Given
|
44
|
+
an API name, version, and profile, is capable of filtering and grouping data structures that cover that specific
|
45
|
+
subset of definitions, using a typical Ruby object-oriented approach.
|
46
|
+
email:
|
47
|
+
- efreed09@gmail.com
|
48
|
+
executables: []
|
49
|
+
extensions: []
|
50
|
+
extra_rdoc_files: []
|
51
|
+
files:
|
52
|
+
- ".gitignore"
|
53
|
+
- ".travis.yml"
|
54
|
+
- ".yardopts"
|
55
|
+
- CHANGELOG.md
|
56
|
+
- Gemfile
|
57
|
+
- LICENSE.txt
|
58
|
+
- README.md
|
59
|
+
- Rakefile
|
60
|
+
- bin/console
|
61
|
+
- bin/setup
|
62
|
+
- lib/opengl/registry.rb
|
63
|
+
- lib/opengl/registry/argument.rb
|
64
|
+
- lib/opengl/registry/enum.rb
|
65
|
+
- lib/opengl/registry/extension.rb
|
66
|
+
- lib/opengl/registry/feature.rb
|
67
|
+
- lib/opengl/registry/feature_group.rb
|
68
|
+
- lib/opengl/registry/feature_provider.rb
|
69
|
+
- lib/opengl/registry/function.rb
|
70
|
+
- lib/opengl/registry/group.rb
|
71
|
+
- lib/opengl/registry/native_type.rb
|
72
|
+
- lib/opengl/registry/token.rb
|
73
|
+
- lib/opengl/registry/version.rb
|
74
|
+
- lib/opengl/registry/words.rb
|
75
|
+
- lib/opengl/spec.rb
|
76
|
+
- opengl-registry.gemspec
|
77
|
+
homepage: https://github.com/ForeverZer0/opengl-registry
|
78
|
+
licenses:
|
79
|
+
- MIT
|
80
|
+
metadata:
|
81
|
+
homepage_uri: https://github.com/ForeverZer0/opengl-registry
|
82
|
+
source_code_uri: https://github.com/ForeverZer0/opengl-registry
|
83
|
+
changelog_uri: https://github.com/ForeverZer0/opengl-registry/CHANGELOG.md
|
84
|
+
post_install_message:
|
85
|
+
rdoc_options: []
|
86
|
+
require_paths:
|
87
|
+
- lib
|
88
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: 2.3.0
|
93
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
requirements: []
|
99
|
+
rubygems_version: 3.1.2
|
100
|
+
signing_key:
|
101
|
+
specification_version: 4
|
102
|
+
summary: OpenGL Registry parser for generating API specifications
|
103
|
+
test_files: []
|