#! /usr/bin/perl -w

$type = $ARGV[0];
if (!defined($type))
{
  print STDERR <<"EOF";
usage: $0 PrefixInterfaceName

Prints the recommended GSK casting macros.
EOF
  exit (1);
}

($prefix, $base) = ($type =~ m/([A-Z][a-z0-9]+)(.*)/);
$uc_prefix = uc($prefix);
$lc_prefix = lc($prefix);
$uc_und_base = $base;
$uc_und_base =~ s/([A-Z])/_$1/g;
$uc_und_base =~ s/^_//;
$uc_und_base = uc($uc_und_base);
$lc_und_base = lc($uc_und_base);
$uc_type = $uc_prefix . "_TYPE_" . $uc_und_base . "_IFACE";

print <<"EOF";
typedef struct _$type $type;
typedef struct _${type}Iface ${type}Iface;

GskInterfaceType ${lc_prefix}_${lc_und_base}_iface_get_type ();
#define $uc_type 		(${lc_prefix}_${lc_und_base}_iface_get_type ())
#define ${uc_prefix}_IS_${uc_und_base}(obj)		GSK_INTERFACE_TEST (obj, $uc_type)
#define ${uc_prefix}_${uc_und_base}(obj)		GSK_INTERFACE_CAST ($type, obj, $uc_type)
#define ${uc_prefix}_${uc_und_base}_GET_IFACE(obj)	GSK_INTERFACE_GET_IFACE (${type}Iface, obj, $uc_type)
EOF

