#!/bin/sh
#
# Produces two lists in docscripts:
#    public-api with the public API except the Wapi 
#    wapi       the public WAPI API
#

dir=`dirname $0`
add_h4()
{
	sed -e 's/^\t<h4>//' -e 's/$/<\/h4>/'
}

ignore_known()
{
	fgrep -v -f $dir/ignore
}

ignore_hidden ()
{
    fgrep -w -v -f $dir/hidden_methods
}

clean_nm ()
{
	grep ' T ' | sed 's/.* T //'
}

ignore_wapi ()
{
	grep -v _wapi | fgrep -v -f $dir/wapi
}

if grep ^$ ignore >/dev/null; then
    echo The ignore file contains empty lines, which breaks this script, please remove
    echo the empty lines.
    exit 1
fi

# generate the internals file
objdump -t ../mono/mini/.libs/libmono-2.0.a | grep "\.hidden" | sed 's/.*\.hidden //' > hidden_methods

nm  $dir/../mono/io-layer/.libs/*.o | clean_nm | grep -v _wapi | ignore_known | sort > $dir/wapi
nm  $dir/../mono/mini/.libs/libmono-2.0.a | clean_nm | ignore_known | ignore_hidden | ignore_wapi | grep -v ^ves_icall | egrep -v '^(mono_arch_|monoeg)'  | sort > $dir/public-api
