class RbPlusPlus::Writers::MultipleFilesWriter::RbppCustomFileWriter

Public Class Methods

new() click to toggle source
# File lib/rbplusplus/writers/multiple_files_writer.rb, line 286
def initialize
  @base_name = "rbpp_custom"
  @header = "_#{@base_name}.rb.hpp"
  @source = "_#{@base_name}.rb.cpp"
  @nodes = []
  @needs_closing = false
  @additional_includes = []
  @require_custom = true

  @register_method = nil
  @register_includes = []
  @register_methods = []
end

Public Instance Methods

with_includes(includes) click to toggle source
# File lib/rbplusplus/writers/multiple_files_writer.rb, line 300
def with_includes(includes)
  @additional_includes =
    includes.flatten.inject([]) do |memo, incl|
      memo << "#include \"#{incl}\""; memo
    end
end

Protected Instance Methods

write_header() click to toggle source
# File lib/rbplusplus/writers/multiple_files_writer.rb, line 309
def write_header
  return unless @registrations.flatten.compact.any?

  include_guard = "__RICE_GENERATED_#{@base_name}_HPP__"

  File.open(File.join(@build_dir, @header), "w+") do |hpp|
    hpp.puts "#ifndef #{include_guard}"
    hpp.puts "#define #{include_guard}"

    if (incls = [@includes, @additional_includes].flatten.compact).any?
      hpp.puts "", incls.uniq.sort.reverse.join("\n"), ""
    end

    if (decls = @declarations.flatten.compact).any?
      hpp.puts "", decls.join("\n"), ""
    end
    hpp.puts
    hpp.puts "#endif // #{include_guard}"
  end

  @declarations = []
  @includes = []
end
write_source() click to toggle source
# File lib/rbplusplus/writers/multiple_files_writer.rb, line 333
def write_source
  super if @registrations.flatten.compact.any?
end