28 skel_h =
"""// -*- C++ -*- 31 * THIS FILE IS GENERATED AUTOMATICALLY!! DO NOT EDIT!! 35 * @brief [basename] server skeleton header wrapper code 41 #ifndef [skel_h_inc_guard] 43 #define [skel_h_inc_guard] 49 #if defined ORB_IS_TAO 50 # include "[include_dir][basename]C.h" 51 # include "[include_dir][basename]S.h" 52 #elif defined ORB_IS_OMNIORB 53 # if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__) 54 # undef USE_stub_in_nt_dll 56 # include "[include_dir][basename].hh" 57 #elif defined ORB_IS_MICO 58 # include "[include_dir][basename].h" 59 #elif defined ORB_IS_ORBIT2 60 # include "[include_dir]/[basename]-cpp-stubs.h" 61 # include "[include_dir]/[basename]-cpp-skels.h" 62 #elif defined ORB_IS_RTORB 63 # include "[include_dir][basename].h" 65 # error "NO ORB defined" 68 #endif // [skel_h_inc_guard] 76 skel_cpp =
"""// -*- C++ -*- 79 * THIS FILE IS GENERATED AUTOMATICALLY!! DO NOT EDIT!! 83 * @brief [basename] server skeleton wrapper 91 #if defined ORB_IS_TAO 92 # include "[include_dir][basename]C.cpp" 93 # include "[include_dir][basename]S.cpp" 94 #elif defined ORB_IS_OMNIORB 95 # include "[include_dir][basename]SK.cc" 96 # include "[include_dir][basename]DynSK.cc" 97 #elif defined ORB_IS_MICO 98 # include "[include_dir][basename].cc" 99 # include "[include_dir][basename]_skel.cc" 100 #elif defined ORB_IS_ORBIT2 101 # include "[include_dir][basename]-cpp-stubs.cc" 102 # include "[include_dir][basename]-cpp-skels.cc" 103 #elif defined ORB_IS_RTORB 104 [include_openrtm_idl_decls] 105 # include "[include_dir][basename]-common.c" 106 # include "[include_dir][basename]-stubs.c" 107 # include "[include_dir][basename]-skels.c" 108 # include "[include_dir][basename]-skelimpl.c" 110 # error "NO ORB defined" 120 stub_h =
"""// -*- C++ -*- 123 * THIS FILE IS GENERATED AUTOMATICALLY!! DO NOT EDIT!! 127 * @brief [basename] client stub header wrapper code 133 #ifndef [stub_h_inc_guard] 135 #define [stub_h_inc_guard] 141 #if defined ORB_IS_TAO 142 # include "[include_dir][basename]C.h" 143 #elif defined ORB_IS_OMNIORB 144 # if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__) 145 # undef USE_stub_in_nt_dll 147 # include "[include_dir][basename].hh" 148 #elif defined ORB_IS_MICO 149 # include "[include_dir][basename].h" 150 #elif defined ORB_IS_ORBIT2 151 # include "[include_dir][basename]-cpp-stubs.h" 152 #elif defined ORB_IS_RTORB 153 # include "[include_dir][basename].h" 155 # error "NO ORB defined" 158 #endif // [stub_h_inc_guard] 165 stub_cpp =
"""// -*- C++ -*- 168 * THIS FILE IS GENERATED AUTOMATICALLY!! DO NOT EDIT!! 172 * @brief [basename] client stub wrapper code 180 #if defined ORB_IS_TAO 181 # include "[include_dir][basename]C.cpp" 182 #elif defined ORB_IS_OMNIORB 183 # include "[include_dir][basename]SK.cc" 184 # include "[include_dir][basename]DynSK.cc" 185 #elif defined ORB_IS_MICO 186 # include "[include_dir][basename].cc" 187 #elif defined ORB_IS_ORBIT2 188 # include "[include_dir][basename]-cpp-stubs.cc" 189 #elif defined ORB_IS_RTORB 190 [include_openrtm_idl_decls] 191 # include "[include_dir][basename]-common.c" 192 # include "[include_dir][basename]-stubs.c" 194 # error "NO ORB defined" 203 #include <[rtm_dir]config_rtc.h> 204 #undef PACKAGE_BUGREPORT 206 #undef PACKAGE_STRING 207 #undef PACKAGE_TARNAME 208 #undef PACKAGE_VERSION 212 def __init__(self, idl_fname, skel_suffix = "Skel",
213 stub_suffix =
"Stub", include_dir =
"",
214 config_inc =
"", output_dir =
"./"):
216 self.
data[
"include_dir"] = include_dir
217 self.
data[
"output_dir"] = output_dir
218 self.
data[
"idl_fname"] = idl_fname
219 m = re.search(
"\.[iI][dD][lL]$", idl_fname)
221 basename = idl_fname.replace(m.group(0),
"")
223 sys.stderr.write(
"Invalid IDL file name specified.\n")
226 dirname = os.path.dirname(basename) +
"/" 227 basename = os.path.basename(basename)
228 self.
data[
"basename"] = basename
229 self.
data[
"skel_h"] = basename + skel_suffix +
".h" 230 self.
data[
"skel_cpp"] = basename + skel_suffix +
".cpp" 231 self.
data[
"stub_h"] = basename + stub_suffix +
".h" 232 self.
data[
"stub_cpp"] = basename + stub_suffix +
".cpp" 234 skel_h_guard = dirname + self.
data[
"skel_h"].replace(
".",
"_")
235 skel_h_guard = skel_h_guard.replace(
"/",
"_")
236 skel_h_guard = skel_h_guard.upper()
237 stub_h_guard = dirname + self.
data[
"stub_h"].replace(
".",
"_")
238 stub_h_guard = stub_h_guard.replace(
"/",
"_")
239 stub_h_guard = stub_h_guard.upper()
240 self.
data[
"skel_h_inc_guard"] = skel_h_guard
241 self.
data[
"stub_h_inc_guard"] = stub_h_guard
243 self.
data[
"date"] = time.ctime()
244 self.
data[
"config_inc"] = config_inc
245 if basename ==
"OpenRTM-aist" :
246 self.
data[
"include_openrtm_idl_decls"] =
"" 248 self.
data[
"include_openrtm_idl_decls"] =
"# include \"OpenRTM-aist-decls.h\"\n" 251 def gen(self, fname, temp_txt):
254 text = t.generate(data)
256 if os.access(fname, os.F_OK):
261 newtext = re.sub(" \@date.*?\n",
"", text)
262 oldtext2 = re.sub(
" \@date.*?\n",
"", oldtext)
263 if newtext == oldtext2:
264 print "\"" + fname + \
265 "\" exists and contents is same." 266 print "No need to generate the file." 270 "\" already exists but contents are not same" 275 print "\"" + fname +
"\"" " was generated." 279 fname = self.
data[
"output_dir"] + self.
data[
"skel_h"]
280 self.
gen(fname, skel_h)
284 fname = self.
data[
"output_dir"] + self.
data[
"skel_cpp"]
285 self.
gen(fname, skel_cpp)
289 fname = self.
data[
"output_dir"] + self.
data[
"stub_h"]
290 self.
gen(fname, stub_h)
294 fname = self.
data[
"output_dir"] + self.
data[
"stub_cpp"]
295 self.
gen(fname, stub_cpp)
309 if __name__ ==
"__main__":
def __init__(self, idl_fname, skel_suffix="Skel", stub_suffix="Stub", include_dir="", config_inc="", output_dir="./")
def gen(self, fname, temp_txt)