class Hsss::CWhole
Constants
- EXT
Public Class Methods
new(files, opt={})
click to toggle source
Calls superclass method
Hsss::COutput::new
# File lib/hsss.rb, line 188 def initialize(files, opt={}) super @headf= <<-EOS.gsub(/^ {8}/, '') // don't edit this please, it was auto-generated by hsss // https://github.com/slact/hsss typedef struct { char *name;#{@include_hash ? "\n char *hash;" : ""} char *script; } #{row_struct_name}; typedef struct { %s } #{struct_name}; EOS @cout= <<-EOS.gsub(/^ {8}/, '') #{@headf} #{@static}#{struct_name} #{scripts_struct} = { %s }; EOS end
Public Instance Methods
failed?()
click to toggle source
# File lib/hsss.rb, line 267 def failed? @failed end
iter_macro()
click to toggle source
# File lib/hsss.rb, line 256 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)
click to toggle source
# File lib/hsss.rb, line 214 def script_name_line(name) "#{row_struct_name} #{name};" end
script_string(name, script)
click to toggle source
# File lib/hsss.rb, line 217 def script_string(name, script) cquote(script, " ") end
to_s()
click to toggle source
# File lib/hsss.rb, line 220 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 @header_only if @header_guard 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 << iter_macro if @header_guard 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 << iter_macro end out end