#
# Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License, Version 1.0 only
# (the "License").  You may not use this file except in compliance
# with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#ident	"%Z%%M%	%I%	%E% SMI"
#
# Typemap for common exacct types.
#
# Note that the Exacct types need to end in REF to make xsubpp do
# the right thing.
#

TYPEMAP
	idtype_t		T_IV
	id_t			T_IV
	taskid_t		T_IV
	projid_t		T_IV
	xs_ea_object_t *	T_XSEAOBJREF
	ea_file_t *		T_EAFILEREF

INPUT

#
# xs_ea_object_t must be blessed into either ::Object::Item or ::Object::Group.
# The underlying value is a pointer masquerading as an IV.
#
T_XSEAOBJREF
	{
		SV *sv = SvRV($arg);
		HV *stash = sv ? SvSTASH(sv) : NULL;
		if (stash == Sun_Solaris_Exacct_Object_Item_stash ||
		    stash == Sun_Solaris_Exacct_Object_Group_stash) {
			IV tmp = SvIV(sv);
			$var = INT2PTR($type, tmp);
		} else {
			croak(\"$var is not of type $Package\");
		}
	}

#
# ea_file_t must be blessed into ::File.
# The underlying value is a pointer masquerading as an IV.
#
T_EAFILEREF
	{
		SV *sv = SvRV($arg);
		HV *stash = sv ? SvSTASH(sv) : NULL;
		if (stash == ${my $p=$Package.'_stash'; $p=~s/::/_/g; \$p}) {
			IV tmp = SvIV(sv);
			$var = INT2PTR($type, tmp);
		} else {
			croak(\"$var is not of type $Package\");
		}
	}

OUTPUT

T_XSEAOBJREF
	if ($var == NULL) {
		sv_setsv($arg, &PL_sv_undef);
	} else {
		sv_setiv(newSVrv($arg, NULL), PTR2IV($var));
		sv_bless($arg, ${my $p=$Package.'_stash'; $p=~s/::/_/g; \$p});
		SvREADONLY_on(SvRV($arg));
	}

T_EAFILEREF
	if ($var == NULL) {
		sv_setsv($arg, &PL_sv_undef);
	} else {
		sv_setiv(newSVrv($arg, NULL), PTR2IV($var));
		sv_bless($arg, ${my $p=$Package.'_stash'; $p=~s/::/_/g; \$p});
		SvREADONLY_on(SvRV($arg));
	}
