Changeset 2710 for code/trunk/src/tolua/lua/doit.lua
- Timestamp:
- Feb 28, 2009, 7:46:37 PM (16 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:ignore deleted
- Property svn:mergeinfo changed
-
code/trunk/src/tolua/lua/doit.lua
r2087 r2710 14 14 function parse_extra() 15 15 16 17 18 19 20 21 22 23 24 16 for k,v in ipairs(_extra_parameters or {}) do 17 18 local b,e,name,value = string.find(v, "^([^=])=(.*)$") 19 if b then 20 _extra_parameters[name] = value 21 else 22 _extra_parameters[v] = true 23 end 24 end 25 25 end 26 26 27 27 function doit () 28 29 30 31 32 33 34 35 36 28 -- define package name, if not provided 29 if not flags.n then 30 if flags.f then 31 flags.n = gsub(flags.f,"%..*$","") 32 _,_,flags.n = string.find(flags.n, "([^/\\]*)$") 33 else 34 error("#no package name nor input file provided") 35 end 36 end 37 37 38 39 38 -- parse table with extra paramters 39 parse_extra() 40 40 41 -- do this after setting the package name 42 if flags['L']then43 dofile(flags['L']) 44 41 -- get potential working directory 42 if not flags.w then 43 flags.w = '' 44 end 45 45 46 -- add cppstring 47 if not flags['S'] then 48 _basic['string'] = 'cppstring' 49 _basic['std::string'] = 'cppstring' 50 _basic_ctype.cppstring = 'const char*' 51 end 46 -- do this after setting the package name 47 if flags.L then 48 if string.sub(flags.L, 1, 1) == '/' or string.sub(flags.L, 1, 1) == '\\' or (string.len(flags.L) > 1 and string.sub(flags.L, 2, 2) == ':') then 49 dofile(flags.L) 50 else 51 dofile(flags.w..'/'..flags.L) 52 end 53 end 52 54 53 -- proccess package 54 local p = Package(flags.n,flags.f) 55 -- add cppstring 56 if not flags.S then 57 _basic['string'] = 'cppstring' 58 _basic['std::string'] = 'cppstring' 59 _basic_ctype.cppstring = 'const char*' 60 end 55 61 56 if flags.p then 57 return -- only parse 58 end 62 -- proccess package 63 local file 64 if flags.f then 65 if string.sub(flags.f, 1, 1) == '/' or string.sub(flags.f, 1, 1) == '\\' or (string.len(flags.f) > 1 and string.sub(flags.f, 2, 2) == ':') then 66 file = flags.f 67 else 68 file = flags.w..'/'..flags.f 69 end 70 else 71 file = flags.f 72 end 73 local p = Package(flags.n, file) 59 74 60 if flags.o then 61 local st,msg = writeto(flags.o) 62 if not st then 63 error('#'..msg) 64 end 65 end 75 if flags.p then 76 return -- only parse 77 end 66 78 67 p:decltype() 68 if flags.P then 69 p:print() 70 else 71 p:preamble() 72 p:supcode() 73 p:register() 74 push(p) 75 post_output_hook(p) 76 pop() 77 end 79 if flags.o then 80 local file 81 if string.sub(flags.o, 1, 1) == '/' or string.sub(flags.o, 1, 1) == '\\' or (string.len(flags.o) > 1 and string.sub(flags.o, 2, 2) == ':') then 82 file = flags.o 83 else 84 file = flags.w..'/'..flags.o 85 end 86 local st,msg = writeto(file) 87 if not st then 88 error('#'..msg) 89 end 90 end 78 91 79 if flags.o then 80 writeto() 81 end 92 p:decltype() 93 if flags.P then 94 p:print() 95 else 96 p:preamble() 97 p:supcode() 98 p:register() 99 push(p) 100 post_output_hook(p) 101 pop() 102 end 82 103 83 -- write header file 84 if not flags.P then 85 if flags.H then 86 local st,msg = writeto(flags.H) 87 if not st then 88 error('#'..msg) 89 end 90 p:header() 91 writeto() 92 end 93 end 104 if flags.o then 105 writeto() 106 end 107 108 -- write header file 109 if not flags.P then 110 if flags.H then 111 local file 112 if string.sub(flags.H, 1, 1) == '/' or string.sub(flags.H, 1, 1) == '\\' or (string.len(flags.H) > 1 and string.sub(flags.H, 2, 2) == ':') then 113 file = flags.H 114 else 115 file = flags.w..'/'..flags.H 116 end 117 local st,msg = writeto(file) 118 if not st then 119 error('#'..msg) 120 end 121 p:header() 122 writeto() 123 end 124 end 94 125 end 95 126
Note: See TracChangeset
for help on using the changeset viewer.