class MxxRu::Generators::Impl::Cpp::TemplateParams
Class to be used in ERb template generation.
Usage:
template_params = TemplateParams.new( target_type, options ) template = ERb.new( IO.read( some_template_file ) ) result = template.generate( template.get_binding )
Constants
- YOUR_IMPLIB_PATH
For a case when
implib_path
is undetectable.- YOUR_TARGET_NAME
For a case when
target_name
is undetectable.
Attributes
Name of import library path.
Name of target.
Type of target.
Public Class Methods
target_type
checker.
Raises exception if target_type
has unsupported value.
# File lib/mxx_ru/generators/impl/cpp/generation.rb, line 136 def TemplateParams.check_target_type( target_type ) if nil == @@setup_target_functions.fetch( target_type, nil ) raise InvalidValueEx.new( "unsupported target_type: #{target_type}" ) end end
Param target_type
must be present in @@setup_target_functions.
# File lib/mxx_ru/generators/impl/cpp/generation.rb, line 155 def initialize( target_type, options ) TemplateParams.check_target_type( target_type ) @target_type = target_type @options = options try_setup_target_name try_setup_implib_name end
Public Instance Methods
Returns binding to use in ERb generation.
# File lib/mxx_ru/generators/impl/cpp/generation.rb, line 178 def get_binding binding end
Returns true if implib_path
need to be defined for this type of target. Or, in case of EXE target, if implib_path
defined in options. (Under Windows even EXEs may have import libraries).
# File lib/mxx_ru/generators/impl/cpp/generation.rb, line 173 def has_or_require_implib DLL == @target_type || nil != @options.implib_path end
Name of setup target functions (like lib_target, dll_target, etc).
# File lib/mxx_ru/generators/impl/cpp/generation.rb, line 166 def setup_target_function @@setup_target_functions.fetch( @target_type ) end
Private Instance Methods
Try to setup name of implib path from options.
If –implib-path specified then its value used. Otherwise value 'your import library path' is used.
# File lib/mxx_ru/generators/impl/cpp/generation.rb, line 204 def try_setup_implib_name @implib_path = @options.implib_path ? @options.implib_path : YOUR_IMPLIB_PATH end
Try to setup name of target from options.
If –target specified target name is gotten from it. Otherwise if project path specified then name is constructed from it. Otherwise value 'your target name' is used.
# File lib/mxx_ru/generators/impl/cpp/generation.rb, line 189 def try_setup_target_name @target_name = if @options.target_name @options.target_name elsif @options.project_path @options.project_path.gsub( /[\\\/]/, '.' ) else YOUR_TARGET_NAME end end