equal
deleted
inserted
replaced
|
1 # Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 # All rights reserved. |
|
3 # This component and the accompanying materials are made available |
|
4 # under the terms of "Eclipse Public License v1.0" |
|
5 # which accompanies this distribution, and is available |
|
6 # at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 # |
|
8 # Initial Contributors: |
|
9 # Nokia Corporation - initial contribution. |
|
10 # |
|
11 # Contributors: |
|
12 # |
|
13 # Description: |
|
14 # Runtime module-loading routine for loading e32tools modules into 'main' module |
|
15 # |
|
16 # |
|
17 |
|
18 |
|
19 package Modload; |
|
20 |
|
21 require Exporter; |
|
22 @ISA=qw(Exporter); |
|
23 |
|
24 @EXPORT=qw( |
|
25 Load_SetVerbose |
|
26 Load_SetModulePath |
|
27 Load_ModuleL |
|
28 ); |
|
29 |
|
30 use strict; |
|
31 |
|
32 use Pathutl; |
|
33 |
|
34 my %Mode=( |
|
35 Verbose=>0 |
|
36 ); |
|
37 my $ModulePath; |
|
38 |
|
39 sub Load_SetVerbose () { |
|
40 $Mode{Verbose}=1; |
|
41 } |
|
42 |
|
43 sub Load_SetModulePath ($) { |
|
44 $ModulePath=$_[0]; |
|
45 } |
|
46 |
|
47 sub Load_ModuleL (@) { |
|
48 # Loads a module into the 'main' package, including all the functions the module defines for export |
|
49 |
|
50 my @ModBaseList=@_; |
|
51 my $ModBase; |
|
52 foreach $ModBase (@ModBaseList) { |
|
53 $ModBase=uc $ModBase; |
|
54 die "ERROR: Can't load \"$ModulePath$ModBase.PM\"\n" unless -e "$ModulePath$ModBase.PM"; |
|
55 if ($Mode{Verbose}) { |
|
56 print "Loading Module: \"",$ModBase,".PM\"\n"; |
|
57 } |
|
58 package main; |
|
59 require $ModBase.".PM" or die "ERROR: Can't load function from \"$ModulePath$ModBase.PM\"\n"; |
|
60 my $Package=ucfirst lc $ModBase; |
|
61 $Package->import; |
|
62 } |
|
63 } |
|
64 |
|
65 1; |