Class: MxxRu::Generators::Impl::Cpp::TemplateParams
- Inherits:
-
Object
- Object
- MxxRu::Generators::Impl::Cpp::TemplateParams
- Defined in:
- lib/mxx_ru/generators/impl/cpp/generation.rb
Overview
Class to be used in ERb template generation.
Usage:
template_params = TemplateParams.new( target_type, )
template = ERb.new( IO.read( some_template_file ) )
result = template.generate( template.get_binding )
Constant Summary collapse
- YOUR_TARGET_NAME =
For a case when target_name is undetectable.
'your target name'
- YOUR_IMPLIB_PATH =
For a case when implib_path is undetectable.
'your import library path'
- @@setup_target_functions =
Dependencies between target_type and setup_target function name.
{ LIB => 'lib_target', LIB_COLLECTION => 'lib_collection_target', DLL => 'dll_target', EXE => 'exe_target', COMPOSITE => 'composite_target' }
Instance Attribute Summary collapse
-
#implib_path ⇒ Object
readonly
Name of import library path.
-
#target_name ⇒ Object
readonly
Name of target.
-
#target_type ⇒ Object
readonly
Type of target.
Class Method Summary collapse
-
.check_target_type(target_type) ⇒ Object
target_type checker.
Instance Method Summary collapse
-
#get_binding ⇒ Object
Returns binding to use in ERb generation.
-
#has_or_require_implib ⇒ Object
Returns true if implib_path need to be defined for this type of target.
-
#initialize(target_type, options) ⇒ TemplateParams
constructor
Param target_type must be present in @@setup_target_functions.
-
#setup_target_function ⇒ Object
Name of setup target functions (like lib_target, dll_target, etc).
Constructor Details
#initialize(target_type, options) ⇒ TemplateParams
Param target_type must be present in @@setup_target_functions.
155 156 157 158 159 160 161 162 163 |
# File 'lib/mxx_ru/generators/impl/cpp/generation.rb', line 155 def initialize( target_type, ) TemplateParams.check_target_type( target_type ) @target_type = target_type @options = try_setup_target_name try_setup_implib_name end |
Instance Attribute Details
#implib_path ⇒ Object (readonly)
Name of import library path.
152 153 154 |
# File 'lib/mxx_ru/generators/impl/cpp/generation.rb', line 152 def implib_path @implib_path end |
#target_name ⇒ Object (readonly)
Name of target.
150 151 152 |
# File 'lib/mxx_ru/generators/impl/cpp/generation.rb', line 150 def target_name @target_name end |
#target_type ⇒ Object (readonly)
Type of target.
148 149 150 |
# File 'lib/mxx_ru/generators/impl/cpp/generation.rb', line 148 def target_type @target_type end |
Class Method Details
.check_target_type(target_type) ⇒ Object
target_type checker.
Raises exception if target_type has unsupported value.
136 137 138 139 140 |
# 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 |
Instance Method Details
#get_binding ⇒ Object
Returns binding to use in ERb generation.
178 179 180 |
# File 'lib/mxx_ru/generators/impl/cpp/generation.rb', line 178 def get_binding binding end |
#has_or_require_implib ⇒ Object
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).
173 174 175 |
# File 'lib/mxx_ru/generators/impl/cpp/generation.rb', line 173 def has_or_require_implib DLL == @target_type || nil != @options.implib_path end |
#setup_target_function ⇒ Object
Name of setup target functions (like lib_target, dll_target, etc).
166 167 168 |
# File 'lib/mxx_ru/generators/impl/cpp/generation.rb', line 166 def setup_target_function @@setup_target_functions.fetch( @target_type ) end |