Class: Hsss::CWhole
Constant Summary
collapse
- EXT =
"lua"
Instance Attribute Summary
Attributes inherited from COutput
#count_macro_name, #count_name, #hashes_struct, #iter_macro_name, #names_struct, #row_struct_name, #scripts_struct, #struct_name
Instance Method Summary
collapse
Methods inherited from COutput
#cased_prefix, #check_script, #count_macro, #cquote
Constructor Details
#initialize(files, opt = {}) ⇒ CWhole
Returns a new instance of CWhole.
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
|
# File 'lib/hsss.rb', line 200
def initialize(files, opt={})
super
@headf= " // don't edit this please, it was auto-generated by hsss\n // https://github.com/slact/hsss\n \n typedef struct {\n char *name;\#{@include_hash ? \"\\n char *hash;\" : \"\"}\n char *script;\n } \#{row_struct_name};\n \n typedef struct {\n %s\n } \#{struct_name};\n EOS\n @cout= <<-EOS.gsub(/^ {8}/, '')\n \#{@headf}\n \n \#{@static}\#{struct_name} \#{scripts_struct} = {\n %s\n };\n \n EOS\n \nend\n".gsub(/^ {8}/, '')
|
Instance Method Details
#failed? ⇒ Boolean
281
282
283
|
# File 'lib/hsss.rb', line 281
def failed?
@failed
end
|
#iter_macro ⇒ Object
270
271
272
273
274
275
276
277
278
279
|
# File 'lib/hsss.rb', line 270
def iter_macro
if @include_iter_macro
macro = []
macro << "#define #{iter_macro_name}(script) \\"
macro << "for((script)=(#{row_struct_name} *)&#{scripts_struct}; (script) < (#{row_struct_name} *)(&#{scripts_struct} + 1); (script)++) "
macro.join("\n")
else
""
end
end
|
#script_name_line(name) ⇒ Object
226
227
228
|
# File 'lib/hsss.rb', line 226
def script_name_line(name)
"#{row_struct_name} #{name};"
end
|
#script_string(name, script) ⇒ Object
229
230
231
|
# File 'lib/hsss.rb', line 229
def script_string(name, script)
cquote(script, " ")
end
|
#to_s ⇒ Object
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
|
# File 'lib/hsss.rb', line 232
def to_s
out = ""
if @scripts.count > 0
scrapts=[]
for i in 0...@scripts.count do
scrapts<< " {\"#{@name_table[i]}\", #{@include_hash ? "\"#{@hashed_table[i]}\"," : ""}\n#{@script_table[i]}}"
end
else
scripties = nil
end
if
if
out << "#ifndef #{@header_guard}\n"
out << "#define #{@header_guard}\n"
end
out << sprintf(@headf, @struct.join("\n"))
out << "extern #{@static}#{struct_name} #{scripts_struct};\n"
out << "extern const int #{@count_name};\n" if @include_count
out << count_macro
out << iter_macro
if
out << "\n#endif //#{@header_guard}\n"
end
elsif @data_only
out << "#{@static}#{struct_name} #{scripts_struct} = {\n"
out << "#{scrapts.join(",\n\n")}\n"
out << "};\n"
out << "const int #{@count_name}=#{@scripts.count};\n" if @include_count
else
out << sprintf(@cout, (@struct || []).join("\n"), (scrapts || []).join(",\n\n"))
out << "const int #{@count_name}=#{@scripts.count};\n" if @include_count
out << count_macro
out << iter_macro
end
out
end
|