HACK: pinfo->private_data points to smb_info again
[wireshark-wip.git] / epan / wslua / make-reg.pl
blob4323805847aa4adf5929af04262662df0cc5769f
1 #!/usr/bin/perl
3 # make-reg.pl
4 # Registration Macros Generator
6 # (c) 2006, Luis E. Garcia Onatnon <luis.ontanon@gmail.com>
8 # $Id$
10 # Wireshark - Network traffic analyzer
11 # By Gerald Combs <gerald@wireshark.org>
12 # Copyright 1998 Gerald Combs
14 # This program is free software; you can redistribute it and/or
15 # modify it under the terms of the GNU General Public License
16 # as published by the Free Software Foundation; either version 2
17 # of the License, or (at your option) any later version.
19 # This program is distributed in the hope that it will be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 # GNU General Public License for more details.
24 # You should have received a copy of the GNU General Public License
25 # along with this program; if not, write to the Free Software
26 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28 use strict;
30 my @classes = ();
31 my @functions = ();
33 while (<>) {
34 push @classes, $1 if /WSLUA_CLASS_DEFINE\050\s*([A-Za-z0-9]+)/;
35 push @functions, $1 if /WSLUA_FUNCTION\s+wslua_([a-z_0-9]+)/;
38 open C, ">register_wslua.c";
39 open H, ">declare_wslua.h";
41 print H "/* This file is automatically genrated by make-reg.pl do not edit */\n\n";
42 print C "/* This file is automatically genrated by make-reg.pl do not edit */\n\n";
44 print H "#define WSLUA_DECLARE_CLASSES() \\\n";
45 for (@classes) {
46 print H "\tWSLUA_CLASS_DECLARE($_);\\\n"
48 print H "\n\n";
50 print H "#define WSLUA_DECLARE_FUNCTIONS() \\\n";
51 for (@functions) {
52 print H "\tWSLUA_FUNCTION wslua_$_(lua_State* L);\\\n"
54 print H "\n\n";
55 print H "extern void wslua_register_classes(lua_State* L);\n";
56 print H "extern void wslua_register_functions(lua_State* L);\n";
57 print H "\n\n";
59 print C '#include "config.h"' . "\n";
61 print C '#include "wslua.h"' . "\n\n";
62 print C "static void wslua_reg_module(lua_State* L, const char *name, lua_CFunction func) { \n";
63 print C "\tlua_pushcfunction(L, func);\n";
64 print C "\tlua_pushstring(L, name);\n";
65 print C "\tlua_call(L, 1, 0);\n";
66 print C "}\n\n";
67 print C "void wslua_register_classes(lua_State* L) { \n";
68 for (@classes) {
69 print C "\twslua_reg_module(L, \"${_}\", ${_}_register);\n";
71 print C "\twslua_reg_module(L, \"bit\", luaopen_bit);\n";
72 print C "}\n\n";
75 print C "void wslua_register_functions(lua_State* L) {\n";
76 for (@functions) {
77 print C "\tWSLUA_REGISTER_FUNCTION($_); \n"
79 print C "}\n\n";
81 close H;
82 close C;