1#!/bin/bash
2
3rm -f register_all_functions.cpp
4
5cat <<EOF >> register_all_functions.cpp
6/* AUTO GENERATED FILE.  DO NOT EDIT */
7
8/* Should be updated by update_register_all_functions script when new functions are added */
9
10#include "libfunction_precompiled.h"
11
12#include "register_all_functions.h"
13
14#include "function_boilerplate.h"
15EOF
16
17HEADERS=`grep -l FUNCTION_BEGIN *.h | sed 's/function_boilerplate.h//'`
18
19for f in $HEADERS ; do
20    sed -f stripcomments.sed "$f" \
21	| grep FUNCTION_BEGIN \
22	| sed 's/FUNCTION_BEGIN(//' \
23	| sed 's/,.*//' \
24	| awk '{printf("REGISTER_DCL(%s);\n",$0);}' \
25	>> register_all_functions.cpp
26done
27
28cat <<EOF >> register_all_functions.cpp
29
30void register_all_functions(FunctionRegistry& r)
31{
32EOF
33
34for f in $HEADERS ; do
35    sed -f stripcomments.sed "$f" \
36	| grep FUNCTION_BEGIN \
37	| sed 's/FUNCTION_BEGIN(//' \
38	| sed 's/,.*//' \
39	| awk '{printf("  register_%s(r);\n",$0);}' \
40	>> register_all_functions.cpp
41done
42
43cat <<EOF >> register_all_functions.cpp
44}
45EOF
46