#############################################################################
#  $Id: typemap,v 1.10 2010-02-02 00:04:34 chu11 Exp $
#############################################################################
#  Copyright (C) 2007-2019 Lawrence Livermore National Security, LLC.
#  Copyright (C) 2001-2007 The Regents of the University of California.
#  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
#  Written by Jim Garlick <garlick@llnl.gov> and Albert Chu <chu11@llnl.gov>.
#  UCRL-CODE-2003-004.
#  
#  This file is part of Genders, a cluster configuration database.
#  For details, see <http://www.llnl.gov/linux/genders/>.
#  
#  Genders is free software; you can redistribute it and/or modify it under
#  the terms of the GNU General Public License as published by the Free
#  Software Foundation; either version 2 of the License, or (at your option)
#  any later version.
#  
#  Genders is distributed in the hope that it will be useful, but WITHOUT ANY
#  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
#  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
#  details.
#  
#  You should have received a copy of the GNU General Public License along
#  with Genders.  If not, see <http://www.gnu.org/licenses/>.
#############################################################################

#
# O_OBJECT from Dean Roehrich's Cookbook      
# http://www.cpan.org/modules/by-authors/id/DMR/
#

TYPEMAP
genders_t  O_OBJECT
char *     T_CHAR_PTR

OUTPUT

T_CHAR_PTR 
        sv_setpv((SV*)$arg, $var);

O_OBJECT
        sv_setref_pv( $arg, CLASS, (void*)$var );

INPUT

T_CHAR_PTR
        $var = (SvOK($arg)) ? ($type)SvPV($arg, PL_na) : NULL

O_OBJECT
        if( sv_isobject($arg) && (SvTYPE(SvRV($arg)) == SVt_PVMG) )
                $var = ($type)SvIV((SV*)SvRV( $arg ));
        else{
                warn( \"${Package}::$func_name() -- $var is not a blessed SV reference\" );
                XSRETURN_UNDEF;
        }
