/[cvs]/nfo/php/libs/org.netfrag.glib/Exporter.php
ViewVC logotype

Diff of /nfo/php/libs/org.netfrag.glib/Exporter.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by joko, Mon Mar 3 21:08:21 2003 UTC revision 1.5 by joko, Fri Mar 28 03:05:20 2003 UTC
# Line 5  Line 5 
5   *   *
6   * @author Andreas Motl <andreas.motl@ilo.de>   * @author Andreas Motl <andreas.motl@ilo.de>
7   * @package org.netfrag.glib   * @package org.netfrag.glib
8   * @module Exporter   * @name Exporter
9   *   *
10   */   */
11    
# Line 13  Line 13 
13   * $Id$   * $Id$
14   *   *
15   * $Log$   * $Log$
16     * Revision 1.5  2003/03/28 03:05:20  joko
17     * minor update: fixed labels, modified debugging level
18     *
19     * Revision 1.4  2003/03/10 22:58:45  joko
20     * + fixed metadata for phpDocumentor
21     *
22     * Revision 1.3  2003/03/05 23:16:46  joko
23     * updated docu - phpDocumentor is very strict about its 'blocks'...
24     *
25     * Revision 1.2  2003/03/05 18:54:41  joko
26     * updated docu - phpDocumentor is very strict about its 'blocks'...
27     *
28   * Revision 1.1  2003/03/03 21:08:21  joko   * Revision 1.1  2003/03/03 21:08:21  joko
29   * refactored from flib/utils   * refactored from flib/utils
30   *   *
31   *   *
32   */   */
33    
34    /**
35     * --- shortcut functions
36     *
37     */
38    
39    //function &export_symbol() { return Exporter::export_symbol(func_get_args()); }
40    
41    
42  /**  /**
43   * --- The Exporter   * The Exporter
44   *   *
45     * This tries to mimic a very small subset of the
46     * functionality of CPAN's Exporter.
47     *
48     * <pre>
49   *  x export_symbol   *  x export_symbol
50   *  x export_symbols   *  x export_symbols
51   *   *
  *  
52   *  Synopsis:   *  Synopsis:
53   *   *    <code>
54   *    define('EXPORT_OK', 'loadModule mkInstance' );   *    define('EXPORT_OK', 'loadModule mkInstance' );
55   *    require_once("php_extensions.php");   *    require_once("php_extensions.php");
56     *    </code>
57   *   *
58   *  Example output:   *  Example output:
59   *   *
60   *     Exporting symbol 'php::loadModule' to 'global::loadModule' (type='__php_function').   *     Exporting symbol 'php::loadModule' to 'global::loadModule' (type='__php_function').
61   *     selected stub:   *     selected stub:
62     *    <code>
63   *     function &loadModule() { return php::loadModule(Exporter::wrap_args(func_get_args())); }   *     function &loadModule() { return php::loadModule(Exporter::wrap_args(func_get_args())); }
64     *    </code>
65   *   *
66   *     Exporting symbol 'php::mkInstance' to 'global::mkInstance' (type='__php_function').   *     Exporting symbol 'php::mkInstance' to 'global::mkInstance' (type='__php_function').
67   *     selected stub:   *     selected stub:
68     *    <code>
69   *     function &mkInstance() { return php::mkInstance(Exporter::wrap_args(func_get_args())); }   *     function &mkInstance() { return php::mkInstance(Exporter::wrap_args(func_get_args())); }
70   *   *    </code>
71     * </pre>
72   *   *
73   *   *
74   * @author Andreas Motl <andreas.motl@ilo.de>   * @author Andreas Motl <andreas.motl@ilo.de>
75   * @copyright (c) 2003 - All Rights reserved.   * @copyright (c) 2003 - All Rights reserved.
76   * @license GNU LGPL (GNU Lesser General Public License)   * @license GNU LGPL (GNU Lesser General Public License)
77   *   *
78   * @author-url http://www.netfrag.org/~joko/   * @link http://www.netfrag.org/~joko/
79   * @license-url http://www.gnu.org/licenses/lgpl.txt   * @link http://www.gnu.org/licenses/lgpl.txt
80   *   *
81   * @package org.netfrag.glib   * @package org.netfrag.glib
82   * @module Exporter   * @name Exporter
83   *   *
84   */   * @link http://search.cpan.org/author/JHI/perl-5.8.0/lib/Exporter.pm
   
 /**  
  * Todo / Ideas:  
  *  x look at http://www.php.net/manual/en/function.method-exists.php  
  *    x $bool_exists = (in_array(strtolower($methodName), get_class_methods($className)));  
  *    x -> implemented in php::class_has_method  
  *  
  */  
   
   
   
 /**  
  * --- shortcut functions  
  *  
  */  
   
 //function &export_symbol() { return Exporter::export_symbol(func_get_args()); }  
   
   
 /**  
  * --- Exporter class  
85   *   *
86     * @todo (x) look at http://www.php.net/manual/en/function.method-exists.php
87     * @todo (x) $bool_exists = (in_array(strtolower($methodName), get_class_methods($className)));
88     * @todo (x) -> implemented in php::class_has_method
89   *   *
90   */   */
   
91  class Exporter {  class Exporter {
92    
93    function export_symbol($from = null, $symbol = null, $to = array()) {    function export_symbol($from = null, $symbol = null, $to = array()) {
# Line 195  class Exporter { Line 203  class Exporter {
203      static $target_cache;      static $target_cache;
204    
205      if (!php::class_has_method($source_class, $source_name)) {      if (!php::class_has_method($source_class, $source_name)) {
206        user_error("Exporter error: class '$source_class' does not implement method '$source_name', will skip exporting this symbol.");        user_error("Exporter::create_stub_function - Error: class '$source_class' does not implement method '$source_name', will skip exporting this symbol.");
207        return;        return;
208      }      }
209    
210      // prevent redeclarations      // prevent redeclarations
211      if ($target_cache[$target_name]) {      if ($target_cache[$target_name]) {
212        $msg = "php::create_stub_function: already declared: $target_name";        $msg = "Exporter::create_stub_function - Warning: already declared: $target_name";
213        php::append_log($msg, PEAR_LOG_ERR);        php::append_log($msg, PEAR_LOG_DEBUG);
214        return 1;        return 1;
215      } else {      } else {
216        $target_cache[$target_name]++;        $target_cache[$target_name]++;

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.5

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed