Top Level Namespace

Defined Under Namespace

Modules: CType, CelltypePluginModule, GenOpaqueMarshaler, GenParamCopy, GenTransparentMarshaler, HasType, Importable, MrubyBridgeCelltypePluginModule, MrubyBridgeSignaturePluginModule, PluginModule, TCFlow, TECSCDE, TECSFlow, TECSInfo Classes: ATK1AlarmPlugin, ATK1DelayTaskPlugin, ATK1EventPlugin, ATK1ISRPlugin, ATK1KernelPlugin, ATK1ResourcePlugin, ATK1TaskPlugin, AppFile, Array, ArrayType, BDNode, BaseVal, BoolType, BoolVal, C2TECSBridgePlugin, CArrayType, CBoolType, CDLInitializer, CDLString, CDefinedType, CEnumType, CFile, CFloatType, CFuncType, CIntType, CPtrType, CStructType, CVoidType, C_EXP, C_parser, Cell, CellPlugin, Celltype, CelltypePlugin, CompositeCelltype, CompositeCelltypeJoin, CompositePlugin, Console, Decl, DefinedType, DescriptorType, DomainPlugin, DomainType, EnumType, Expression, Factory, FloatType, FloatVal, FuncHead, FuncType, Generate, Generator, HRP2AlarmHandlerPlugin, HRP2CyclicHandlerPlugin, HRP2DataqueuePlugin, HRP2EventflagPlugin, HRP2FixedSizeMemoryPoolPlugin, HRP2HandlerPlugin, HRP2KernelObjectPlugin, HRP2ObjectPlugin, HRP2Plugin, HRP2PostHook, HRP2PriorityDataqueuePlugin, HRP2RPCPlugin, HRP2SVCPlugin, HRP2SemaphorePlugin, HRP2TaskPlugin, HRPHandlerPlugin, HRPKernelObjectManager, HRPKernelObjectPlugin, HRPObjectPlugin, HRPPlugin, HRPRPCPlugin, HRPSVCPlugin, HRPTaskPlugin, Import, Import_C, IntType, IntegerVal, Join, MemFile, Mruby2CBridgePlugin, MrubyBridgeCellPlugin, MrubyBridgeCelltypePlugin, MrubyBridgeCompositePlugin, MrubyBridgePlugin, MrubyBridgeSignaturePlugin, MrubyInfoBridgePlugin, MrubyInfoBridgeSignaturePlugin, MultiPlugin, NSBDNode, NamedList, Namespace, NamespacePath, Node, NotifierPlugin, Object, OpaqueMarshalerPlugin, OpaqueRPCPlugin, ParamDecl, ParamList, Plugin, PointerVal, Port, Proc, PtrType, RPCPlugin, Region, RepeatCellPlugin, RepeatJoinPlugin, ReverseJoin, SVCManage, SharedOpaqueRPCPlugin, SharedRPCPlugin, Signature, SignaturePlugin, StringVal, StructType, TCFLOW_Cparser, TECS2CBridgePlugin, TECSGEN, TECSIO, TECSInfoPlugin, TECSMsg, TECS_LANG, TOOL_INFO, ThroughPlugin, Token, TracePlugin, Type, Typedef, VoidType

Constant Summary collapse

Include =

ファイル => INCLUDE(“header”)の配列

Hash.new {|hash, key| hash[key] = []}
XML_INDENT =

TECS Generator

   Generator for TOPPERS Embedded Component System

Copyright (C) 2008-2014 by TOPPERS Project

++

"    "
NotifierPluginArgProc =

TECS Generator

    Generator for TOPPERS Embedded Component System

Copyright (C) 2015 by Ushio Laboratory
            Graduate School of Engineering Science, Osaka Univ., JAPAN
Copyright (C) 2015-2016 by Embedded and Real-Time Systems Laboratory
            Graduate School of Information Science, Nagoya Univ., JAPAN
Copyright (C) 2015-2018 by TOPPERS Project

 

++

{
  "factory" => Proc.new {|obj, rhs| obj.set_factory(rhs) },
  "output_file" => Proc.new {|obj, rhs| obj.set_factory_output_file(rhs) }
}

Instance Method Summary collapse

Instance Method Details

#begin_extern_C(f) ⇒ Object



81
82
83
84
85
86
87
# File 'lib/tecsgen/core/generate.rb', line 81

def begin_extern_C(f)
  f.print  "#ifdef __cplusplus\nextern \"C\" {\n#endif /* __cplusplus */\n"
end

#dbgPrint(str) ⇒ Object



174
175
176
177
178
# File 'lib/tecsgen.rb', line 174

def dbgPrint(str)
  if $debug
    print str
  end
end

#dbgPrintf(*param) ⇒ Object



180
181
182
183
184
# File 'lib/tecsgen.rb', line 180

def dbgPrintf(*param)
  if $debug
    printf(*param)
  end
end

#end_extern_C(f) ⇒ Object



89
90
91
92
93
94
95
# File 'lib/tecsgen/core/generate.rb', line 89

def end_extern_C(f)
  f.print  "#ifdef __cplusplus\n}\n#endif /* __cplusplus */\n"
end

#endif_cb_type_only(f) ⇒ Object



74
75
76
77
78
79
# File 'lib/tecsgen/core/generate.rb', line 74

def endif_cb_type_only(f)
  f.print "#endif /* TOPPERS_CB_TYPE_ONLY */\n\n"
end

#endif_macro_only(f) ⇒ Object



53
54
55
56
57
58
# File 'lib/tecsgen/core/generate.rb', line 53

def endif_macro_only(f)
  f.print "#endif /* TOPPERS_MACRO_ONLY */\n\n"
end

#ifdef_cb_type_only(f) ⇒ Object



67
68
69
70
71
72
# File 'lib/tecsgen/core/generate.rb', line 67

def ifdef_cb_type_only(f)
  f.print "#ifdef TOPPERS_CB_TYPE_ONLY\n\n"
end

#ifdef_macro_only(f) ⇒ Object

TECS Generator

   Generator for TOPPERS Embedded Component System

Copyright (C) 2008-2019 by TOPPERS Project

++



39
40
41
42
43
44
# File 'lib/tecsgen/core/generate.rb', line 39

def ifdef_macro_only(f)
  f.print "#ifndef TOPPERS_MACRO_ONLY\n\n"
end

#ifndef_cb_type_only(f) ⇒ Object



60
61
62
63
64
65
# File 'lib/tecsgen/core/generate.rb', line 60

def ifndef_cb_type_only(f)
  f.print "#ifndef TOPPERS_CB_TYPE_ONLY\n\n"
end

#ifndef_macro_only(f) ⇒ Object



46
47
48
49
50
51
# File 'lib/tecsgen/core/generate.rb', line 46

def ifndef_macro_only(f)
  f.print "#ifndef TOPPERS_MACRO_ONLY\n\n"
end

例外の表示

evar

Exception



162
163
164
165
166
167
168
169
170
171
172
# File 'lib/tecsgen.rb', line 162

def print_exception(evar)
# もしスタックトレースが出るまでい時間がかかるようならば、次をコメントアウトしてみるべし
  print "*** Begin Ruby exception message ***\n"
  puts(evar.to_s)

  if $debug
    puts "#### stack trace ####"
    pp evar.backtrace
  end
  print "*** End Ruby exception message ***\n"
end


59
60
61
62
63
64
65
66
# File 'lib/tecsflow.rb', line 59

def print_indent( level )
  if level > 0 then
    print "    " * level
    return level
  else
    return - level
  end
end


111
112
113
# File 'lib/tecsgen/core/generate.rb', line 111

def print_Makefile_note(f)
  f.print TECSMsg.get(:Makefile_note)
end


97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/tecsgen/core/generate.rb', line 97

def print_note(f, b_complete = true)
  if b_complete
    f.print "/*\n"
  else
    f.print " *\n"
  end
  f.print TECSMsg.get(:note)
  if b_complete
    f.print " */\n"
  else
    f.print " *\n"
  end
end

エラーおよび警告のレポート



187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
# File 'lib/tecsgen.rb', line 187

def print_report
  msg = nil

  if Generator.get_n_error != 0
    msg = "#{Generator.get_n_error} error"
    msg = "#{msg}s" if Generator.get_n_error >= 2
  end

  if Generator.get_n_warning != 0
    msg = "#{msg}  " if msg
    msg = "#{msg}#{Generator.get_n_warning} warning"
    msg = "#{msg}s" if Generator.get_n_warning >= 2
  end

  puts msg if msg
end

#require_tecsgen_lib(fname, b_fatal = true) ⇒ Object

RUBY ライブラリをロードする

-L, $RUBYLIB, システム(/usr/lib/rub..など) の順にサーチが行われるexerb 対応のため、上記パスにファイルが見つからない場合 require を実行してみる

プラグインの場合は b_fatal = false を指定。ファイルがなくてもエラー出力後、処理続行b_fatal = false の場合 tecslib/core がサーチパスに追加されるRETURN::Bool : true=成功、 false=失敗 失敗した場合、Generator.error は呼び元で出力する



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
# File 'lib/tecsgen.rb', line 94

def require_tecsgen_lib(fname, b_fatal = true)
  dbgPrint("require_lib: #{fname}\n")
  begin
    b_require = false
    b_exception = false

    # -L 、 $RUBYLIB で指定されたパスおよびシステムのパスからサーチ
    #   exerb では $LOAD_PATH は ["."] のみ入っているようだ
    ($library_path + $LOAD_PATH).each{|path|
      ["", "tecslib/plugin/"].each {|lp|
        lib = File.expand_path(path) + "/" + lp + fname

        if File.exist? lib # ファイル存否と他のエラーを区別するため存在確認をする
          begin
            require(lib)
            b_require = true
          rescue Exception => evar
            b_exception = true
            print_exception(evar)
          end
          break
        end
      }
      if b_require
        break
      end
    }

    if b_require == false && b_exception == false
      # exerb 対応 "." をサーチパスの最初に加える
      #   "tecslib/" は RPCPlugin.rb, TracePlugin.rb のために用意してある
      #   RPCPlugin.rb, TracePlugin.rb が tecslib 下でなければ不要になるが、このようにしておく
      ["", "tecslib/plugin/"].each{|lp|
        path = lp + fname
        begin
          require path
          return true
        rescue LoadError => e
          # p "LoadError to load #{fname}"
          # 2015.12.18 exerb 版でプラグインのロードでエラーが出るので、無視する. おそらく昔からエラーは出ていた
          # print_exception( e )
        rescue Exception => e
          b_exception = true
          # 文法エラーなどが発生
          print_exception(e)
          break
        end
      }
    end

    if b_require == false
      # 見つからなかった
      if b_exception == false
        STDERR << "tecsgen: Fail to load #{fname}. Check $RUBYLIB environment variable or -L option\n"
      end
      # tecsgen を構成するファイルの場合は中止する
      if b_fatal
        STDERR << "tecsgen: Exit because of unrecoverble error\n"
        exit 1
      end
      return false
    end
    return true
  end
end