#! /bin/sh
#
#	This script lists the member functions found within the
#	specified header file.  The output of this script is then
#	parsed to determine what member functions and variables
#	currently exist for the specified subclass.
#
#	usage:
#		subclass_members classnam filenam
#
#-------------------------------------------------------------------
#	Extract the definition for our class
#-------------------------------------------------------------------
sed -n -e '/class[ 	].*'"$1"'/,/};/p' $2 | sed -e '

#-------------------------------------------------------------------
#	Concatenate each member function so the member function is
#	completely contained on one line.
#-------------------------------------------------------------------
: appnd
/(/{
	/)/b cntu
	N
	s/\n//
	b appnd
}
: cntu

#-------------------------------------------------------------------
#	Globally remove extraneous information
#-------------------------------------------------------------------
/class[ 	].*'"$1"'/d
s/\/\/.*$//
s/public://
s/private://
s/protected://
s/{.*$//
/};/d
s/\/\*.*\*\///
/^\#/d

#
# remove known constructors
# remove known destructors
# remove known member functions
#
/construct(/d
/:/d
/static[ 	].*OI_class[ 	].*\*clsp/d
/[ 	]init(/d
/[ 	]get_resources(/d
/[ 	]save_obj(/d
/[ 	\*]make_minimal(/d

#
# remove whitespace - pass 1
#
s/[ 	][ 	]*/ /g
s/^ *//
/^$/d

#-------------------------------------------------------------------
#	Remove everything but member functions
#-------------------------------------------------------------------
/(/!d

#-------------------------------------------------------------------
#	Clean up the member function declarations
#-------------------------------------------------------------------
#
# tighten up declaration
#
s/^virtual[ 	]/ /g
s/^static[ 	]/ /g

#
# remove constructors and destructors
#
/^'"$1"'(/d
/^~'"$1"'(/d

#
# remove default values
#
s/=.*,/,/g
s/=.*)/)/g

#
# remove whitespace - pass 2
#
s/;.*$/;/
s/) /)/
s/)$/);/
s/\* /*/g
s/ \*,/*,/g
s/ \*)/*)/
s/[ 	][ 	]*/ /g
s/^ *//
/}/d
/^$/d

#
# remove dummy parameter names
#
s/\([a-zA-Z_0-9][a-zA-Z_0-9]*\)[ ]\(\**\)[a-zA-Z_0-9]*\([,)]\)/\1\2\3/g
s/\([a-zA-Z_0-9][a-zA-Z_0-9]*\)[ ]\(\**\)[a-zA-Z_0-9]*)/\1\2)/g

#
# final kill of whitespace
#
s/ //g

#-------------------------------------------------------------------
#	Done.
#-------------------------------------------------------------------
'
