hsss 0.1.14 → 0.1.19
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/exe/hsss +3 -0
- data/lib/hsss.rb +69 -26
- 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: 96bbfca29172fb609c9de7699b81e89c02e0b7539e63a5632f963e2202940031
|
4
|
+
data.tar.gz: 210afcafd9fd2829ae7cc1865150acd329a175d9b9afc1506dd81d3bd10c9778
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1bcda4beaed9ffdd7f9d2e254da451dade55bed7861e6691029d987e0df6e4d469e74091649dbdb3aab77dfb05885c965f03131d7e26174148ecb03ef23aeaf9
|
7
|
+
data.tar.gz: 2530fcf8cfcf4b7a5bff064097f16da2de02fc0db0ea32ba7c7270424b3adfa42854c7d4e561acd137aa79ef4fa0961e702cc67b71f51dc857891ff52758ee78
|
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", "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
@@ -16,11 +16,11 @@ module Hsss
|
|
16
16
|
attr_accessor :struct_name, :hashes_struct, :names_struct, :scripts_struct, :count_name, :iter_macro_name, :row_struct_name
|
17
17
|
|
18
18
|
def cased_prefix(prefix, name)
|
19
|
-
if name
|
19
|
+
if name
|
20
20
|
if name.upcase == name and name.downcase != name
|
21
|
-
name = "#{prefix.upcase}#{name}"
|
21
|
+
name = "#{(prefix || DEFAULT_PREFIX).upcase}#{name}"
|
22
22
|
else
|
23
|
-
name = "#{prefix}#{name}"
|
23
|
+
name = "#{(prefix || DEFAULT_PREFIX)}#{name}"
|
24
24
|
end
|
25
25
|
end
|
26
26
|
name
|
@@ -39,9 +39,12 @@ 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]
|
45
48
|
@include_hash = !!hashes_struct
|
46
49
|
|
47
50
|
(Array === files ? files : [ files ]).each do |f|
|
@@ -122,7 +125,7 @@ module Hsss
|
|
122
125
|
|
123
126
|
EOS
|
124
127
|
@struct_fmt= <<-EOS.gsub(/^ {8}/, '')
|
125
|
-
#{
|
128
|
+
#{@static}#{struct_name} %s = {
|
126
129
|
%s
|
127
130
|
};
|
128
131
|
|
@@ -139,28 +142,41 @@ module Hsss
|
|
139
142
|
|
140
143
|
def to_s
|
141
144
|
out = ""
|
145
|
+
if @header_only
|
142
146
|
out << sprintf(@head, @struct.join("\n"))
|
143
|
-
|
144
|
-
out <<
|
145
|
-
out <<
|
146
|
-
out <<
|
147
|
+
out << "#{@static}#{struct_name} #{hashes_struct};\n" if hashes_struct
|
148
|
+
out << "#{@static}#{struct_name} #{names_struct};\n" if names_struct
|
149
|
+
out << "#{@static}#{struct_name} #{scripts_struct};\n" if scripts_struct
|
150
|
+
out << "const int #{@count_name};\n" if @include_count
|
151
|
+
out << iter_macro
|
147
152
|
else
|
148
|
-
out
|
153
|
+
out = ""
|
154
|
+
out << sprintf(@head, @struct.join("\n")) unless @data_only
|
155
|
+
if @scripts.count > 0
|
156
|
+
out << sprintf(@struct_fmt, hashes_struct, @hashed_table.map{|v|" \"#{v}\""}.join(",\n")) if hashes_struct
|
157
|
+
out << sprintf(@struct_fmt, names_struct, @name_table.map{|v|" \"#{v}\","}.join("\n")) if names_struct
|
158
|
+
out << sprintf(@struct_fmt, scripts_struct, @script_table.join(",\n\n")) if scripts_struct
|
159
|
+
else
|
160
|
+
out << "//no scrpts\n"
|
161
|
+
end
|
162
|
+
out << "const int #{@count_name}=#{@scripts.count};\n" if @include_count
|
163
|
+
out << iter_macro
|
149
164
|
end
|
150
165
|
|
151
|
-
out
|
152
|
-
|
166
|
+
out
|
167
|
+
end
|
168
|
+
|
169
|
+
def iter_macro
|
153
170
|
if @include_iter_macro
|
154
171
|
macro = []
|
155
172
|
macro << "#define #{iter_macro_name}(script_src, script_name, script_hash) \\"
|
156
173
|
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
|
-
|
174
|
+
macro.join("\n")
|
175
|
+
else
|
176
|
+
""
|
158
177
|
end
|
159
|
-
|
160
|
-
out
|
161
178
|
end
|
162
179
|
|
163
|
-
|
164
180
|
end
|
165
181
|
|
166
182
|
|
@@ -170,7 +186,7 @@ module Hsss
|
|
170
186
|
|
171
187
|
def initialize(files, opt={})
|
172
188
|
super
|
173
|
-
@
|
189
|
+
@headf= <<-EOS.gsub(/^ {8}/, '')
|
174
190
|
// don't edit this please, it was auto-generated by hsss
|
175
191
|
// https://github.com/slact/hsss
|
176
192
|
|
@@ -182,8 +198,11 @@ module Hsss
|
|
182
198
|
typedef struct {
|
183
199
|
%s
|
184
200
|
} #{struct_name};
|
201
|
+
EOS
|
202
|
+
@cout= <<-EOS.gsub(/^ {8}/, '')
|
203
|
+
#{@headf}
|
185
204
|
|
186
|
-
#{
|
205
|
+
#{@static}#{struct_name} #{scripts_struct} = {
|
187
206
|
%s
|
188
207
|
};
|
189
208
|
|
@@ -198,26 +217,50 @@ module Hsss
|
|
198
217
|
cquote(script, " ")
|
199
218
|
end
|
200
219
|
def to_s
|
220
|
+
out = ""
|
221
|
+
|
201
222
|
if @scripts.count > 0
|
202
223
|
scrapts=[]
|
203
224
|
for i in 0...@scripts.count do
|
204
225
|
scrapts<< " {\"#{@name_table[i]}\", #{@include_hash ? "\"#{@hashed_table[i]}\"," : ""}\n#{@script_table[i]}}"
|
205
226
|
end
|
206
|
-
out=sprintf @cout, @struct.join("\n"), scrapts.join(",\n\n")
|
207
227
|
else
|
208
|
-
|
228
|
+
scripties = nil
|
209
229
|
end
|
210
|
-
|
211
|
-
|
212
|
-
|
230
|
+
if @header_only
|
231
|
+
if @header_guard
|
232
|
+
out << "#ifndef #{@header_guard}\n"
|
233
|
+
out << "#define #{@header_guard}\n"
|
234
|
+
end
|
235
|
+
out << sprintf(@headf, @struct.join("\n"))
|
236
|
+
out << "#{@static}#{struct_name} #{scripts_struct};\n"
|
237
|
+
out << "const int #{@count_name};\n" if @include_count
|
238
|
+
out << iter_macro
|
239
|
+
if @header_guard
|
240
|
+
out << "#endif //#{@header_guard}\n"
|
241
|
+
end
|
242
|
+
elsif @data_only
|
243
|
+
out << "#{@static}#{struct_name} #{scripts_struct} = {\n"
|
244
|
+
out << "#{scrapts.join(",\n\n")}\n"
|
245
|
+
out << "};\n"
|
246
|
+
out << "const int #{@count_name}=#{@scripts.count};\n" if @include_count
|
247
|
+
else
|
248
|
+
out << sprintf(@cout, (@struct || []).join("\n"), (scrapts || []).join(",\n\n"))
|
249
|
+
out << "const int #{@count_name}=#{@scripts.count};\n" if @include_count
|
250
|
+
out << iter_macro
|
251
|
+
end
|
252
|
+
out
|
253
|
+
end
|
254
|
+
|
255
|
+
def iter_macro
|
213
256
|
if @include_iter_macro
|
214
257
|
macro = []
|
215
258
|
macro << "#define #{iter_macro_name}(script) \\"
|
216
259
|
macro << "for((script)=(#{row_struct_name} *)&#{scripts_struct}; (script) < (#{row_struct_name} *)(&#{scripts_struct} + 1); (script)++) "
|
217
|
-
|
260
|
+
macro.join("\n")
|
261
|
+
else
|
262
|
+
""
|
218
263
|
end
|
219
|
-
|
220
|
-
out
|
221
264
|
end
|
222
265
|
|
223
266
|
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.19
|
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: []
|