hsss 0.1.15 → 0.1.16
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 +4 -4
- data/exe/hsss +2 -0
- data/lib/hsss.rb +57 -23
- data/lib/hsss/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e93d5f3037e8065f5edc447e9b2e36134d52327b
|
4
|
+
data.tar.gz: 265f5c4624f809b0981fa07dbbe979c12ef55a17
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 07ec0641c7713ab755c9ae1cd6d1f8cc0a6d65fa6be94a4ef0006dc33732b7e3dbca749d998b5202700310785f6f7406e763cbd320d3416e76bd1dcc22fd411f
|
7
|
+
data.tar.gz: e0f865e15b12e450466139141abe8dcb37bce535146310621680fffe561c46a94e1eba04538a6c575b9aea2e6a0a9935cffe8d88db118f75a315cbe22fe5a136
|
data/exe/hsss
CHANGED
@@ -18,6 +18,8 @@ arg=OptionParser.new do |opts|
|
|
18
18
|
opts.on("--no-each", "Omit the iterator macro"){opt[:skip_each]=true}
|
19
19
|
opts.on("--no-parse", "Skip using luac to check script syntax"){opt[:no_luac]=true}
|
20
20
|
opts.on("--no-static", "Don't make variables static (file-scoped)"){opt[:no_static]=true}
|
21
|
+
opts.on("--header-only", "just the header"){opt[:header_only]=true}
|
22
|
+
opts.on("--data-only", "just the data"){opt[:data_only]=true}
|
21
23
|
opts.on("--prefix [#{Hsss::DEFAULT_PREFIX}]", "Prefix default names with this"){|v| opt[:prefix]=v}
|
22
24
|
end
|
23
25
|
arg.banner=<<EOS
|
data/lib/hsss.rb
CHANGED
@@ -39,7 +39,8 @@ module Hsss
|
|
39
39
|
names.each do |var, default|
|
40
40
|
send "#{var}=", opt[var]!=false ? opt[var] || cased_prefix(opt[:prefix], default) : false
|
41
41
|
end
|
42
|
-
|
42
|
+
@header_only = opt[:header_only]
|
43
|
+
@data_only = opt[:data_only]
|
43
44
|
@include_count = !opt[:skip_count]
|
44
45
|
@include_iter_macro = !opt[:skip_each]
|
45
46
|
@include_hash = !!hashes_struct
|
@@ -111,6 +112,7 @@ module Hsss
|
|
111
112
|
class CSplit < COutput
|
112
113
|
|
113
114
|
def initialize(files, opt={})
|
115
|
+
@static=opt[:no_static] ? "" : "static "
|
114
116
|
super
|
115
117
|
@head= <<-EOS.gsub(/^ {8}/, '')
|
116
118
|
// don't edit this please, it was auto-generated by hsss
|
@@ -122,7 +124,7 @@ module Hsss
|
|
122
124
|
|
123
125
|
EOS
|
124
126
|
@struct_fmt= <<-EOS.gsub(/^ {8}/, '')
|
125
|
-
#{
|
127
|
+
#{@static}#{struct_name} %s = {
|
126
128
|
%s
|
127
129
|
};
|
128
130
|
|
@@ -139,28 +141,41 @@ module Hsss
|
|
139
141
|
|
140
142
|
def to_s
|
141
143
|
out = ""
|
144
|
+
if @header_only
|
142
145
|
out << sprintf(@head, @struct.join("\n"))
|
143
|
-
|
144
|
-
out <<
|
145
|
-
out <<
|
146
|
-
out <<
|
146
|
+
out << "#{@static}#{struct_name} #{hashes_struct};\n" if hashes_struct
|
147
|
+
out << "#{@static}#{struct_name} #{names_struct};\n" if names_struct
|
148
|
+
out << "#{@static}#{struct_name} #{scripts_struct};\n" if scripts_struct
|
149
|
+
out << "const int #{@count_name};\n" if @include_count
|
150
|
+
out << iter_macro
|
147
151
|
else
|
148
|
-
out
|
152
|
+
out = ""
|
153
|
+
out << sprintf(@head, @struct.join("\n")) unless @data_only
|
154
|
+
if @scripts.count > 0
|
155
|
+
out << sprintf(@struct_fmt, hashes_struct, @hashed_table.map{|v|" \"#{v}\""}.join(",\n")) if hashes_struct
|
156
|
+
out << sprintf(@struct_fmt, names_struct, @name_table.map{|v|" \"#{v}\","}.join("\n")) if names_struct
|
157
|
+
out << sprintf(@struct_fmt, scripts_struct, @script_table.join(",\n\n")) if scripts_struct
|
158
|
+
else
|
159
|
+
out << "//no scrpts\n"
|
160
|
+
end
|
161
|
+
out << "const int #{@count_name}=#{@scripts.count};\n" if @include_count
|
162
|
+
out << iter_macro
|
149
163
|
end
|
150
164
|
|
151
|
-
out
|
152
|
-
|
165
|
+
out
|
166
|
+
end
|
167
|
+
|
168
|
+
def iter_macro
|
153
169
|
if @include_iter_macro
|
154
170
|
macro = []
|
155
171
|
macro << "#define #{iter_macro_name}(script_src, script_name, script_hash) \\"
|
156
172
|
macro << "for((script_src)=(char **)&#{scripts_struct}, (script_hash)=(char **)&#{hashes_struct}, (script_name)=(char **)&#{names_struct}; (script_src) < (char **)(&#{scripts_struct} + 1); (script_src)++, (script_hash)++, (script_name)++) "
|
157
|
-
|
173
|
+
macro.join("\n")
|
174
|
+
else
|
175
|
+
""
|
158
176
|
end
|
159
|
-
|
160
|
-
out
|
161
177
|
end
|
162
178
|
|
163
|
-
|
164
179
|
end
|
165
180
|
|
166
181
|
|
@@ -170,7 +185,7 @@ module Hsss
|
|
170
185
|
|
171
186
|
def initialize(files, opt={})
|
172
187
|
super
|
173
|
-
@
|
188
|
+
@headf= <<-EOS.gsub(/^ {8}/, '')
|
174
189
|
// don't edit this please, it was auto-generated by hsss
|
175
190
|
// https://github.com/slact/hsss
|
176
191
|
|
@@ -182,8 +197,11 @@ module Hsss
|
|
182
197
|
typedef struct {
|
183
198
|
%s
|
184
199
|
} #{struct_name};
|
200
|
+
EOS
|
201
|
+
@cout= <<-EOS.gsub(/^ {8}/, '')
|
202
|
+
#{@headf}
|
185
203
|
|
186
|
-
#{
|
204
|
+
#{@static}#{struct_name} #{scripts_struct} = {
|
187
205
|
%s
|
188
206
|
};
|
189
207
|
|
@@ -198,26 +216,42 @@ module Hsss
|
|
198
216
|
cquote(script, " ")
|
199
217
|
end
|
200
218
|
def to_s
|
219
|
+
out = ""
|
220
|
+
|
201
221
|
if @scripts.count > 0
|
202
222
|
scrapts=[]
|
203
223
|
for i in 0...@scripts.count do
|
204
224
|
scrapts<< " {\"#{@name_table[i]}\", #{@include_hash ? "\"#{@hashed_table[i]}\"," : ""}\n#{@script_table[i]}}"
|
205
225
|
end
|
206
|
-
out=sprintf @cout, @struct.join("\n"), scrapts.join(",\n\n")
|
207
226
|
else
|
208
|
-
|
227
|
+
scripties = nil
|
209
228
|
end
|
210
|
-
|
211
|
-
|
212
|
-
|
229
|
+
if @header_only
|
230
|
+
out << sprintf(@headf, @struct.join("\n"))
|
231
|
+
out << "const int #{@count_name};\n" if @include_count
|
232
|
+
out << iter_macro
|
233
|
+
elsif @data_only
|
234
|
+
out << "#{@static}#{struct_name} #{scripts_struct} = {\n"
|
235
|
+
out << "#{scrapts.join(",\n\n")}\n"
|
236
|
+
out << "};\n"
|
237
|
+
out << "const int #{@count_name}=#{@scripts.count};\n" if @include_count
|
238
|
+
else
|
239
|
+
out << sprintf(@cout, (@struct || []).join("\n"), (scrapts || []).join(",\n\n"))
|
240
|
+
out << "const int #{@count_name}=#{@scripts.count};\n" if @include_count
|
241
|
+
out << iter_macro
|
242
|
+
end
|
243
|
+
out
|
244
|
+
end
|
245
|
+
|
246
|
+
def iter_macro
|
213
247
|
if @include_iter_macro
|
214
248
|
macro = []
|
215
249
|
macro << "#define #{iter_macro_name}(script) \\"
|
216
250
|
macro << "for((script)=(#{row_struct_name} *)&#{scripts_struct}; (script) < (#{row_struct_name} *)(&#{scripts_struct} + 1); (script)++) "
|
217
|
-
|
251
|
+
macro.join("\n")
|
252
|
+
else
|
253
|
+
""
|
218
254
|
end
|
219
|
-
|
220
|
-
out
|
221
255
|
end
|
222
256
|
|
223
257
|
def failed?
|
data/lib/hsss/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hsss
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Leo P.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-05-
|
11
|
+
date: 2017-05-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|