Commit | Line | Data |
---|---|---|
970ed795 | 1 | /****************************************************************************** |
d44e3c4f | 2 | * Copyright (c) 2000-2016 Ericsson Telecom AB |
970ed795 EL |
3 | * All rights reserved. This program and the accompanying materials |
4 | * are made available under the terms of the Eclipse Public License v1.0 | |
5 | * which accompanies this distribution, and is available at | |
6 | * http://www.eclipse.org/legal/epl-v10.html | |
d44e3c4f | 7 | * |
8 | * Contributors: | |
9 | * Balasko, Jeno | |
10 | * Czerman, Oliver | |
11 | * Szabados, Kristof | |
12 | * | |
970ed795 EL |
13 | ******************************************************************************/ |
14 | module module1 | |
15 | { | |
16 | ||
17 | public modulepar charstring ts_m1:="public"; | |
18 | private modulepar charstring ts_m2:="private"; | |
19 | friend modulepar charstring ts_m3:="friend"; | |
20 | ||
21 | friend module Visibility, module2; | |
22 | ||
23 | private import from module2 all;//OK | |
24 | private import from module3 all;//OK | |
25 | private import from module4 all;//OK | |
26 | //public import from module2 all;//NOK | |
27 | //friend import from module2 all;//NOK | |
28 | ||
29 | const module2Type akarmi1 := 1; //OK, type is implicitly public | |
30 | const module2TypePublic akarmi2 := 2; //OK, type is explicitly public | |
31 | const module2TypeFriend akarmi3 := 3; //OK, module1 is friend of module2 | |
32 | //const module2TypePrivate akarmi4 := 4; //NOK, module2TypePrivate is private to module2 | |
33 | ||
34 | group g_MyGroup{ | |
35 | const module3Type akarmi5 := 5; //OK, type is implicitly public | |
36 | const module3TypePublic akarmi6 := 6; //OK, type is explicitly public | |
37 | //const module3TypeFriend akarmi7 := 7; //NOK, module1 is NOT a friend of module3 | |
38 | //const module3TypePrivate akarmi8 := 8; //NOK, module2TypePrivate is private to module2 | |
39 | } | |
40 | ||
41 | function MyFunc1() runs on Lib4_CT {} //OK | |
42 | function MyFunc2() runs on Lib4Friend_CT {} //OK, module1 is friend for module4 | |
43 | //function MyFunc3() runs on Lib4Private_CT {} //NOK, the *name* Lib4Private_CT is not | |
44 | //visible for module1, thus fails at checking the runs on clause, whatever is the content! | |
45 | ||
46 | ||
47 | function f_set2_Lib4_1() runs on Lib4_CT { v_Lib4_1 := 0 } //OK | |
48 | function f_set2_Lib4_2() runs on Lib4_CT { v_Lib4_2 := 0 } //OK | |
49 | function f_set2_Lib4_3() runs on Lib4_CT { v_Lib4_3 := 0 } //OK | |
50 | function f_set2_Lib4Friend_1() runs on Lib4Friend_CT { v_Lib4Friend_1 := 0 } //OK | |
51 | function f_set2_Lib4Friend_2() runs on Lib4Friend_CT { v_Lib4Friend_2 := 0 } //OK | |
52 | function f_set2_Lib4Friend_3() runs on Lib4Friend_CT { v_Lib4Friend_3 := 0 } //OK | |
53 | ||
54 | ||
55 | type component User_CT extends Lib4_CT {}; | |
56 | function f_set3_Lib4_1() runs on User_CT { v_Lib4_1 := 0 } //OK | |
57 | function f_set3_Lib4_2() runs on User_CT { v_Lib4_2 := 0 } //OK | |
58 | //function f_set3_Lib4_3() runs on User_CT { v_Lib4_3 := 0 } //NOK, v_Lib4_3 is private, can be used | |
59 | //in functions with "Lib4_CT" in their runs on (but not in children) | |
60 | ||
61 | //in short: visibility of the component type definition (name) and allowed use of the component | |
62 | //type definitions are two different things. Component type visibility is checked when checking | |
63 | //the runs on clause. Component definition visibility is checked (after a successful runs on | |
64 | //check), when the definition is used within the body of the function | |
65 | ||
66 | ||
67 | //All setter functions of module4 are public, hence can be called from any function | |
68 | //with a compatible runs on clause | |
69 | function f_MyFunc_1() runs on User_CT { f_set_Lib4_1() } //OK | |
70 | function f_MyFunc_2() runs on User_CT { f_set_Lib4_2() } //OK | |
71 | function f_MyFunc_3() runs on User_CT { f_set_Lib4_3() } //OK | |
72 | ||
73 | type component UserFriend_CT extends Lib4Friend_CT {}; //OK | |
74 | function f_MyFuncFriend_1() runs on UserFriend_CT { f_set_Lib4Friend_1() } //OK | |
75 | function f_MyFuncFriend_2() runs on UserFriend_CT { f_set_Lib4Friend_2() } //OK | |
76 | function f_MyFuncFriend_3() runs on UserFriend_CT { f_set_Lib4Friend_3() } //OK | |
77 | ||
78 | ||
79 | //type component UserPrivate_CT extends Lib4Private_CT {}; //NOK, the name Lib4Private_CT is not | |
80 | //visible in module1 | |
81 | //function MyFunc() { | |
82 | //var Lib4Private_CT v_Lib4Private := Lib4Private_CT.create; //NOK, the name Lib4Private_CT is not | |
83 | //visible in module1 | |
84 | //} | |
85 | //function f_MyFuncPrivate_1() runs on UserPrivate_CT { f_set_Lib4Private_1() } //NOK, UserPrivate_CT has an error | |
86 | //function f_MyFuncPrivate_2() runs on UserPrivate_CT { f_set_Lib4Private_2() } //NOK, UserPrivate_CT has an error | |
87 | //function f_MyFuncPrivate_3() runs on UserPrivate_CT { f_set_Lib4Private_3() } //NOK, UserPrivate_CT has an error | |
88 | ||
89 | control{} | |
90 | ||
91 | } // end of module1 |