Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/buildsystem/src/tolua/lua/doit.lua @ 2233

Last change on this file since 2233 was 2229, checked in by rgrieder, 16 years ago

Cleaned up indentation chaos in tolua. There were tabs and 1 space indentations, even mixed in a single block.
It should now be possible to actually pimp these files.

File size: 2.0 KB
Line 
1-- Generate binding code
2-- Written by Waldemar Celes
3-- TeCGraf/PUC-Rio
4-- Jul 1998
5-- Last update: Apr 2003
6-- $Id: $
7
8
9-- This code is free software; you can redistribute it and/or modify it.
10-- The software provided hereunder is on an "as is" basis, and
11-- the author has no obligation to provide maintenance, support, updates,
12-- enhancements, or modifications.
13
14function parse_extra()
15
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
25end
26
27function doit ()
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
38    -- parse table with extra paramters
39    parse_extra()
40
41    -- do this after setting the package name
42    if flags['L'] then
43        dofile(flags['L'])
44    end
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
52
53    -- proccess package
54    local p  = Package(flags.n,flags.f)
55
56    if flags.p then
57        return        -- only parse
58    end
59
60    if flags.o then
61        local st,msg = writeto(flags.o)
62        if not st then
63            error('#'..msg)
64        end
65    end
66
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
78
79    if flags.o then
80        writeto()
81    end
82
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
94end
95
Note: See TracBrowser for help on using the repository browser.