hsss 0.1.15 → 0.1.20
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 +5 -5
- data/exe/hsss +3 -0
- data/lib/hsss.rb +67 -23
- data/lib/hsss/version.rb +1 -1
- metadata +6 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d82312d9d40fe7749258fe1e917963eca868efe1f21a5867b24531c988d9f423
|
4
|
+
data.tar.gz: ef2849d3bd39335bd3e1b19a10b61ca1c613230570db7b7a7792d0154d39943d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fe53ce199038e44561d0f6dab8e00472618b879a94089d9333b369c4229047870e43139abbe9f53ba2ccd44333255e39370f6f4ea52d96de2e542644dc090475
|
7
|
+
data.tar.gz: 82aa9124e4bc30bd1b42de06715a89ae6af7344afeaf9be5e96d559116875d76c69412434b2d62e68e7ca7a5fb4d41d170b684ed78bf76350282b1b26b319875
|
data/exe/hsss
CHANGED
@@ -18,6 +18,9 @@ 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("--header-guard [LUA_SCRIPTS_H]", "header guard string"){|v|opt[:header_guard]=v}
|
23
|
+
opts.on("--data-only", "just the data"){opt[:data_only]=true}
|
21
24
|
opts.on("--prefix [#{Hsss::DEFAULT_PREFIX}]", "Prefix default names with this"){|v| opt[:prefix]=v}
|
22
25
|
end
|
23
26
|
arg.banner=<<EOS
|
data/lib/hsss.rb
CHANGED
@@ -39,9 +39,13 @@ 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
|
+
@static=opt[:no_static] ? "" : "static "
|
43
|
+
@header_only = opt[:header_only]
|
44
|
+
@data_only = opt[:data_only]
|
43
45
|
@include_count = !opt[:skip_count]
|
44
46
|
@include_iter_macro = !opt[:skip_each]
|
47
|
+
@header_guard = opt[:header_guard] || "LUA_SCRIPTS_H"
|
48
|
+
@header_guard = false if @header_guard.length == 0
|
45
49
|
@include_hash = !!hashes_struct
|
46
50
|
|
47
51
|
(Array === files ? files : [ files ]).each do |f|
|
@@ -122,7 +126,7 @@ module Hsss
|
|
122
126
|
|
123
127
|
EOS
|
124
128
|
@struct_fmt= <<-EOS.gsub(/^ {8}/, '')
|
125
|
-
#{
|
129
|
+
#{@static}#{struct_name} %s = {
|
126
130
|
%s
|
127
131
|
};
|
128
132
|
|
@@ -139,28 +143,41 @@ module Hsss
|
|
139
143
|
|
140
144
|
def to_s
|
141
145
|
out = ""
|
146
|
+
if @header_only
|
142
147
|
out << sprintf(@head, @struct.join("\n"))
|
143
|
-
|
144
|
-
out <<
|
145
|
-
out <<
|
146
|
-
out <<
|
148
|
+
out << "#{@static}#{struct_name} #{hashes_struct};\n" if hashes_struct
|
149
|
+
out << "#{@static}#{struct_name} #{names_struct};\n" if names_struct
|
150
|
+
out << "#{@static}#{struct_name} #{scripts_struct};\n" if scripts_struct
|
151
|
+
out << "const int #{@count_name};\n" if @include_count
|
152
|
+
out << iter_macro
|
147
153
|
else
|
148
|
-
out
|
154
|
+
out = ""
|
155
|
+
out << sprintf(@head, @struct.join("\n")) unless @data_only
|
156
|
+
if @scripts.count > 0
|
157
|
+
out << sprintf(@struct_fmt, hashes_struct, @hashed_table.map{|v|" \"#{v}\""}.join(",\n")) if hashes_struct
|
158
|
+
out << sprintf(@struct_fmt, names_struct, @name_table.map{|v|" \"#{v}\","}.join("\n")) if names_struct
|
159
|
+
out << sprintf(@struct_fmt, scripts_struct, @script_table.join(",\n\n")) if scripts_struct
|
160
|
+
else
|
161
|
+
out << "//no scrpts\n"
|
162
|
+
end
|
163
|
+
out << "const int #{@count_name}=#{@scripts.count};\n" if @include_count
|
164
|
+
out << iter_macro
|
149
165
|
end
|
150
166
|
|
151
|
-
out
|
152
|
-
|
167
|
+
out
|
168
|
+
end
|
169
|
+
|
170
|
+
def iter_macro
|
153
171
|
if @include_iter_macro
|
154
172
|
macro = []
|
155
173
|
macro << "#define #{iter_macro_name}(script_src, script_name, script_hash) \\"
|
156
174
|
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
|
-
|
175
|
+
macro.join("\n")
|
176
|
+
else
|
177
|
+
""
|
158
178
|
end
|
159
|
-
|
160
|
-
out
|
161
179
|
end
|
162
180
|
|
163
|
-
|
164
181
|
end
|
165
182
|
|
166
183
|
|
@@ -170,7 +187,7 @@ module Hsss
|
|
170
187
|
|
171
188
|
def initialize(files, opt={})
|
172
189
|
super
|
173
|
-
@
|
190
|
+
@headf= <<-EOS.gsub(/^ {8}/, '')
|
174
191
|
// don't edit this please, it was auto-generated by hsss
|
175
192
|
// https://github.com/slact/hsss
|
176
193
|
|
@@ -182,8 +199,11 @@ module Hsss
|
|
182
199
|
typedef struct {
|
183
200
|
%s
|
184
201
|
} #{struct_name};
|
202
|
+
EOS
|
203
|
+
@cout= <<-EOS.gsub(/^ {8}/, '')
|
204
|
+
#{@headf}
|
185
205
|
|
186
|
-
#{
|
206
|
+
#{@static}#{struct_name} #{scripts_struct} = {
|
187
207
|
%s
|
188
208
|
};
|
189
209
|
|
@@ -198,26 +218,50 @@ module Hsss
|
|
198
218
|
cquote(script, " ")
|
199
219
|
end
|
200
220
|
def to_s
|
221
|
+
out = ""
|
222
|
+
|
201
223
|
if @scripts.count > 0
|
202
224
|
scrapts=[]
|
203
225
|
for i in 0...@scripts.count do
|
204
226
|
scrapts<< " {\"#{@name_table[i]}\", #{@include_hash ? "\"#{@hashed_table[i]}\"," : ""}\n#{@script_table[i]}}"
|
205
227
|
end
|
206
|
-
out=sprintf @cout, @struct.join("\n"), scrapts.join(",\n\n")
|
207
228
|
else
|
208
|
-
|
229
|
+
scripties = nil
|
209
230
|
end
|
210
|
-
|
211
|
-
|
212
|
-
|
231
|
+
if @header_only
|
232
|
+
if @header_guard
|
233
|
+
out << "#ifndef #{@header_guard}\n"
|
234
|
+
out << "#define #{@header_guard}\n"
|
235
|
+
end
|
236
|
+
out << sprintf(@headf, @struct.join("\n"))
|
237
|
+
out << "extern #{@static}#{struct_name} #{scripts_struct};\n"
|
238
|
+
out << "extern const int #{@count_name};\n" if @include_count
|
239
|
+
out << iter_macro
|
240
|
+
if @header_guard
|
241
|
+
out << "\n#endif //#{@header_guard}\n"
|
242
|
+
end
|
243
|
+
elsif @data_only
|
244
|
+
out << "#{@static}#{struct_name} #{scripts_struct} = {\n"
|
245
|
+
out << "#{scrapts.join(",\n\n")}\n"
|
246
|
+
out << "};\n"
|
247
|
+
out << "const int #{@count_name}=#{@scripts.count};\n" if @include_count
|
248
|
+
else
|
249
|
+
out << sprintf(@cout, (@struct || []).join("\n"), (scrapts || []).join(",\n\n"))
|
250
|
+
out << "const int #{@count_name}=#{@scripts.count};\n" if @include_count
|
251
|
+
out << iter_macro
|
252
|
+
end
|
253
|
+
out
|
254
|
+
end
|
255
|
+
|
256
|
+
def iter_macro
|
213
257
|
if @include_iter_macro
|
214
258
|
macro = []
|
215
259
|
macro << "#define #{iter_macro_name}(script) \\"
|
216
260
|
macro << "for((script)=(#{row_struct_name} *)&#{scripts_struct}; (script) < (#{row_struct_name} *)(&#{scripts_struct} + 1); (script)++) "
|
217
|
-
|
261
|
+
macro.join("\n")
|
262
|
+
else
|
263
|
+
""
|
218
264
|
end
|
219
|
-
|
220
|
-
out
|
221
265
|
end
|
222
266
|
|
223
267
|
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.20
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Leo P.
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-06-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -78,7 +78,7 @@ licenses:
|
|
78
78
|
- MIT
|
79
79
|
metadata:
|
80
80
|
allowed_push_host: https://rubygems.org
|
81
|
-
post_install_message:
|
81
|
+
post_install_message:
|
82
82
|
rdoc_options: []
|
83
83
|
require_paths:
|
84
84
|
- lib
|
@@ -93,9 +93,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
93
93
|
- !ruby/object:Gem::Version
|
94
94
|
version: '0'
|
95
95
|
requirements: []
|
96
|
-
|
97
|
-
|
98
|
-
signing_key:
|
96
|
+
rubygems_version: 3.1.3
|
97
|
+
signing_key:
|
99
98
|
specification_version: 4
|
100
99
|
summary: Hash-Safe Script Splinterer
|
101
100
|
test_files: []
|