close
Warning:
Can't synchronize with repository "(default)" (/var/svn/tolp does not appear to be a Subversion repository.). Look in the Trac log for more information.
Ticket #738: ticket_10.Bug_725_II.tol
| File ticket_10.Bug_725_II.tol, 1.2 KB (added by pgea@…, 16 years ago) |
|
|
| Line | |
|---|
| 1 | |
|---|
| 2 | // ClaseA |
|---|
| 3 | |
|---|
| 4 | Class ClaseA { |
|---|
| 5 | Real a = 1 |
|---|
| 6 | }; |
|---|
| 7 | |
|---|
| 8 | // Constructor de ClaseA |
|---|
| 9 | |
|---|
| 10 | ClaseA ClaseA.New(NameBlock args) { |
|---|
| 11 | ClaseA new = [[ |
|---|
| 12 | Real a = args::a |
|---|
| 13 | ]] |
|---|
| 14 | }; |
|---|
| 15 | |
|---|
| 16 | // ClaseB que contiene un objeto ClaseA |
|---|
| 17 | |
|---|
| 18 | Class ClaseB { |
|---|
| 19 | Text _.name; |
|---|
| 20 | Text _.description; |
|---|
| 21 | ClaseA _.variable |
|---|
| 22 | }; |
|---|
| 23 | |
|---|
| 24 | // Constructor de ClaseB |
|---|
| 25 | |
|---|
| 26 | ClaseB ClaseB.New(NameBlock args) { |
|---|
| 27 | ClaseB new = [[ |
|---|
| 28 | Text _.name = args::_.name; |
|---|
| 29 | Text _.description = getOptArg(args,"_.description", ""); |
|---|
| 30 | ClaseA _.variable = args::_.variable |
|---|
| 31 | ]] |
|---|
| 32 | }; |
|---|
| 33 | |
|---|
| 34 | // [1] Creación paso a paso (sin errores) |
|---|
| 35 | |
|---|
| 36 | ClaseA obj1_A = ClaseA.New([[ |
|---|
| 37 | Real a = 3 |
|---|
| 38 | ]]); |
|---|
| 39 | |
|---|
| 40 | ClaseB obj1 = ClaseB.New([[ |
|---|
| 41 | Text _.name = "hola"; |
|---|
| 42 | Text _.description = "desc"; |
|---|
| 43 | ClaseA _.variable = obj1_A |
|---|
| 44 | ]]); |
|---|
| 45 | |
|---|
| 46 | // [2] Creación de una vez (da errores) |
|---|
| 47 | |
|---|
| 48 | ClaseB obj2 = ClaseB.New([[ |
|---|
| 49 | Text _.name = "hola"; |
|---|
| 50 | Text _.description = "desc"; |
|---|
| 51 | ClaseA _.variable = ClaseA.New([[ |
|---|
| 52 | Real a = 3 |
|---|
| 53 | ]]) |
|---|
| 54 | ]]); |
|---|
| 55 | //> ERROR: [3] Un NameBlock no puede tener miembros sin un nombre válido '' |
|---|
| 56 | |
|---|
| 57 | // [3] Creación de una vez (evitar el error) |
|---|
| 58 | |
|---|
| 59 | ClaseB obj3 = ClaseB.New([[ |
|---|
| 60 | Text _.name = "hola"; |
|---|
| 61 | Text _.description = "desc"; |
|---|
| 62 | ClaseA _.variable = ClaseA.New( NOMBRE = [[ |
|---|
| 63 | Real a = 3 |
|---|
| 64 | ]]) |
|---|
| 65 | ]]); |
|---|
| 66 | |
|---|
Download in other formats: