# Copyright (c) 2006-2009 bivio Software, Inc. All Rights Reserved. # # Visit http://www.bivio.biz for more info. # # This library is free software; you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as # published by the Free Software Foundation; either version 2.1 of the # License, or (at your option) any later version. # # This library 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 # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; If not, you may get a copy from: # http://www.opensource.org/licenses/lgpl-license.html # # $Id: ViewLanguageAUTOLOAD.pm,v 1.6 2009/05/25 19:12:55 nagler Exp $ package Bivio::UI::ViewLanguageAUTOLOAD; use strict; use Bivio::Base 'Bivio.UNIVERSAL'; our($VERSION) = sprintf('%d.%02d', q$Revision: 1.6 $ =~ /\d+/g); our($AUTOLOAD); our($_CALLING_CONTEXT); our($_CALLING_CONTEXT_METHOD); my($_A) = b_use('IO.Alert'); my($_VL); sub AUTOLOAD { local($_CALLING_CONTEXT) = $_A->calling_context; local($_CALLING_CONTEXT_METHOD) = $AUTOLOAD; $_VL ||= b_use('UI.ViewLanguage'); return $_VL->call_method($AUTOLOAD, $_VL, @_); } sub import { my($pkg) = caller(); no strict qw(refs); *{$pkg.'::AUTOLOAD'} = \&AUTOLOAD; return; } sub unsafe_calling_context { return undef unless $_CALLING_CONTEXT_METHOD && (caller)[0]->simple_package_name eq ($_CALLING_CONTEXT_METHOD =~ /(\w+)$/)[0]; return $_CALLING_CONTEXT || b_die('no calling context'); } 1;