1------------------------------------------------------------------------------
2--                                                                          --
3--                            Matreshka Project                             --
4--                                                                          --
5--                          Ada Modeling Framework                          --
6--                                                                          --
7--                        Runtime Library Component                         --
8--                                                                          --
9------------------------------------------------------------------------------
10--                                                                          --
11-- Copyright © 2011-2012, Vadim Godunko <vgodunko@gmail.com>                --
12-- All rights reserved.                                                     --
13--                                                                          --
14-- Redistribution and use in source and binary forms, with or without       --
15-- modification, are permitted provided that the following conditions       --
16-- are met:                                                                 --
17--                                                                          --
18--  * Redistributions of source code must retain the above copyright        --
19--    notice, this list of conditions and the following disclaimer.         --
20--                                                                          --
21--  * Redistributions in binary form must reproduce the above copyright     --
22--    notice, this list of conditions and the following disclaimer in the   --
23--    documentation and/or other materials provided with the distribution.  --
24--                                                                          --
25--  * Neither the name of the Vadim Godunko, IE nor the names of its        --
26--    contributors may be used to endorse or promote products derived from  --
27--    this software without specific prior written permission.              --
28--                                                                          --
29-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS      --
30-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT        --
31-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR    --
32-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT     --
33-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,   --
34-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
35-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR   --
36-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF   --
37-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING     --
38-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS       --
39-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.             --
40--                                                                          --
41------------------------------------------------------------------------------
42--  $Revision: 2937 $ $Date: 2012-05-01 21:07:27 +0400 (Tue, 01 May 2012) $
43------------------------------------------------------------------------------
44with AMF.Elements;
45with AMF.Internals.Element_Collections;
46with AMF.Internals.Helpers;
47with AMF.Internals.Tables.UML_Attributes;
48with AMF.String_Collections.Internals;
49with AMF.Visitors.UML_Iterators;
50with AMF.Visitors.UML_Visitors;
51with League.Strings.Internals;
52with Matreshka.Internals.Strings;
53
54package body AMF.Internals.UML_Opaque_Expressions is
55
56   -------------------
57   -- Enter_Element --
58   -------------------
59
60   overriding procedure Enter_Element
61    (Self    : not null access constant UML_Opaque_Expression_Proxy;
62     Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
63     Control : in out AMF.Visitors.Traverse_Control) is
64   begin
65      if Visitor in AMF.Visitors.UML_Visitors.UML_Visitor'Class then
66         AMF.Visitors.UML_Visitors.UML_Visitor'Class
67          (Visitor).Enter_Opaque_Expression
68            (AMF.UML.Opaque_Expressions.UML_Opaque_Expression_Access (Self),
69           Control);
70      end if;
71   end Enter_Element;
72
73   -------------------
74   -- Leave_Element --
75   -------------------
76
77   overriding procedure Leave_Element
78    (Self    : not null access constant UML_Opaque_Expression_Proxy;
79     Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
80     Control : in out AMF.Visitors.Traverse_Control) is
81   begin
82      if Visitor in AMF.Visitors.UML_Visitors.UML_Visitor'Class then
83         AMF.Visitors.UML_Visitors.UML_Visitor'Class
84          (Visitor).Leave_Opaque_Expression
85            (AMF.UML.Opaque_Expressions.UML_Opaque_Expression_Access (Self),
86           Control);
87      end if;
88   end Leave_Element;
89
90   -------------------
91   -- Visit_Element --
92   -------------------
93
94   overriding procedure Visit_Element
95    (Self     : not null access constant UML_Opaque_Expression_Proxy;
96     Iterator : in out AMF.Visitors.Abstract_Iterator'Class;
97     Visitor  : in out AMF.Visitors.Abstract_Visitor'Class;
98     Control  : in out AMF.Visitors.Traverse_Control) is
99   begin
100      if Iterator in AMF.Visitors.UML_Iterators.UML_Iterator'Class then
101         AMF.Visitors.UML_Iterators.UML_Iterator'Class
102          (Iterator).Visit_Opaque_Expression
103            (Visitor,
104             AMF.UML.Opaque_Expressions.UML_Opaque_Expression_Access (Self),
105             Control);
106      end if;
107   end Visit_Element;
108
109   ------------------
110   -- Get_Behavior --
111   ------------------
112
113   overriding function Get_Behavior
114    (Self : not null access constant UML_Opaque_Expression_Proxy)
115       return AMF.UML.Behaviors.UML_Behavior_Access is
116   begin
117      return
118        AMF.UML.Behaviors.UML_Behavior_Access
119         (AMF.Internals.Helpers.To_Element
120           (AMF.Internals.Tables.UML_Attributes.Internal_Get_Behavior
121             (Self.Element)));
122   end Get_Behavior;
123
124   ------------------
125   -- Set_Behavior --
126   ------------------
127
128   overriding procedure Set_Behavior
129    (Self : not null access UML_Opaque_Expression_Proxy;
130     To   : AMF.UML.Behaviors.UML_Behavior_Access) is
131   begin
132      AMF.Internals.Tables.UML_Attributes.Internal_Set_Behavior
133       (Self.Element,
134        AMF.Internals.Helpers.To_Element
135         (AMF.Elements.Element_Access (To)));
136   end Set_Behavior;
137
138   --------------
139   -- Get_Body --
140   --------------
141
142   overriding function Get_Body
143    (Self : not null access constant UML_Opaque_Expression_Proxy)
144       return AMF.String_Collections.Sequence_Of_String is
145   begin
146      return
147        AMF.String_Collections.Internals.Wrap
148         (AMF.Internals.Tables.UML_Attributes.Internal_Get_Body (Self.Element));
149   end Get_Body;
150
151   ------------------
152   -- Get_Language --
153   ------------------
154
155   overriding function Get_Language
156    (Self : not null access constant UML_Opaque_Expression_Proxy)
157       return AMF.String_Collections.Ordered_Set_Of_String is
158   begin
159      return
160        AMF.String_Collections.Internals.Wrap
161         (AMF.Internals.Tables.UML_Attributes.Internal_Get_Language (Self.Element));
162   end Get_Language;
163
164   ----------------
165   -- Get_Result --
166   ----------------
167
168   overriding function Get_Result
169    (Self : not null access constant UML_Opaque_Expression_Proxy)
170       return AMF.UML.Parameters.UML_Parameter_Access is
171   begin
172      return
173        AMF.UML.Parameters.UML_Parameter_Access
174         (AMF.Internals.Helpers.To_Element
175           (AMF.Internals.Tables.UML_Attributes.Internal_Get_Result
176             (Self.Element)));
177   end Get_Result;
178
179   --------------
180   -- Get_Type --
181   --------------
182
183   overriding function Get_Type
184    (Self : not null access constant UML_Opaque_Expression_Proxy)
185       return AMF.UML.Types.UML_Type_Access is
186   begin
187      return
188        AMF.UML.Types.UML_Type_Access
189         (AMF.Internals.Helpers.To_Element
190           (AMF.Internals.Tables.UML_Attributes.Internal_Get_Type
191             (Self.Element)));
192   end Get_Type;
193
194   --------------
195   -- Set_Type --
196   --------------
197
198   overriding procedure Set_Type
199    (Self : not null access UML_Opaque_Expression_Proxy;
200     To   : AMF.UML.Types.UML_Type_Access) is
201   begin
202      AMF.Internals.Tables.UML_Attributes.Internal_Set_Type
203       (Self.Element,
204        AMF.Internals.Helpers.To_Element
205         (AMF.Elements.Element_Access (To)));
206   end Set_Type;
207
208   ---------------------------
209   -- Get_Client_Dependency --
210   ---------------------------
211
212   overriding function Get_Client_Dependency
213    (Self : not null access constant UML_Opaque_Expression_Proxy)
214       return AMF.UML.Dependencies.Collections.Set_Of_UML_Dependency is
215   begin
216      return
217        AMF.UML.Dependencies.Collections.Wrap
218         (AMF.Internals.Element_Collections.Wrap
219           (AMF.Internals.Tables.UML_Attributes.Internal_Get_Client_Dependency
220             (Self.Element)));
221   end Get_Client_Dependency;
222
223   -------------------------
224   -- Get_Name_Expression --
225   -------------------------
226
227   overriding function Get_Name_Expression
228    (Self : not null access constant UML_Opaque_Expression_Proxy)
229       return AMF.UML.String_Expressions.UML_String_Expression_Access is
230   begin
231      return
232        AMF.UML.String_Expressions.UML_String_Expression_Access
233         (AMF.Internals.Helpers.To_Element
234           (AMF.Internals.Tables.UML_Attributes.Internal_Get_Name_Expression
235             (Self.Element)));
236   end Get_Name_Expression;
237
238   -------------------------
239   -- Set_Name_Expression --
240   -------------------------
241
242   overriding procedure Set_Name_Expression
243    (Self : not null access UML_Opaque_Expression_Proxy;
244     To   : AMF.UML.String_Expressions.UML_String_Expression_Access) is
245   begin
246      AMF.Internals.Tables.UML_Attributes.Internal_Set_Name_Expression
247       (Self.Element,
248        AMF.Internals.Helpers.To_Element
249         (AMF.Elements.Element_Access (To)));
250   end Set_Name_Expression;
251
252   -------------------
253   -- Get_Namespace --
254   -------------------
255
256   overriding function Get_Namespace
257    (Self : not null access constant UML_Opaque_Expression_Proxy)
258       return AMF.UML.Namespaces.UML_Namespace_Access is
259   begin
260      return
261        AMF.UML.Namespaces.UML_Namespace_Access
262         (AMF.Internals.Helpers.To_Element
263           (AMF.Internals.Tables.UML_Attributes.Internal_Get_Namespace
264             (Self.Element)));
265   end Get_Namespace;
266
267   ------------------------
268   -- Get_Qualified_Name --
269   ------------------------
270
271   overriding function Get_Qualified_Name
272    (Self : not null access constant UML_Opaque_Expression_Proxy)
273       return AMF.Optional_String is
274   begin
275      declare
276         use type Matreshka.Internals.Strings.Shared_String_Access;
277
278         Aux : constant Matreshka.Internals.Strings.Shared_String_Access
279           := AMF.Internals.Tables.UML_Attributes.Internal_Get_Qualified_Name (Self.Element);
280
281      begin
282         if Aux = null then
283            return (Is_Empty => True);
284
285         else
286            return (False, League.Strings.Internals.Create (Aux));
287         end if;
288      end;
289   end Get_Qualified_Name;
290
291   -----------------------------------
292   -- Get_Owning_Template_Parameter --
293   -----------------------------------
294
295   overriding function Get_Owning_Template_Parameter
296    (Self : not null access constant UML_Opaque_Expression_Proxy)
297       return AMF.UML.Template_Parameters.UML_Template_Parameter_Access is
298   begin
299      return
300        AMF.UML.Template_Parameters.UML_Template_Parameter_Access
301         (AMF.Internals.Helpers.To_Element
302           (AMF.Internals.Tables.UML_Attributes.Internal_Get_Owning_Template_Parameter
303             (Self.Element)));
304   end Get_Owning_Template_Parameter;
305
306   -----------------------------------
307   -- Set_Owning_Template_Parameter --
308   -----------------------------------
309
310   overriding procedure Set_Owning_Template_Parameter
311    (Self : not null access UML_Opaque_Expression_Proxy;
312     To   : AMF.UML.Template_Parameters.UML_Template_Parameter_Access) is
313   begin
314      AMF.Internals.Tables.UML_Attributes.Internal_Set_Owning_Template_Parameter
315       (Self.Element,
316        AMF.Internals.Helpers.To_Element
317         (AMF.Elements.Element_Access (To)));
318   end Set_Owning_Template_Parameter;
319
320   ----------------------------
321   -- Get_Template_Parameter --
322   ----------------------------
323
324   overriding function Get_Template_Parameter
325    (Self : not null access constant UML_Opaque_Expression_Proxy)
326       return AMF.UML.Template_Parameters.UML_Template_Parameter_Access is
327   begin
328      return
329        AMF.UML.Template_Parameters.UML_Template_Parameter_Access
330         (AMF.Internals.Helpers.To_Element
331           (AMF.Internals.Tables.UML_Attributes.Internal_Get_Template_Parameter
332             (Self.Element)));
333   end Get_Template_Parameter;
334
335   ----------------------------
336   -- Set_Template_Parameter --
337   ----------------------------
338
339   overriding procedure Set_Template_Parameter
340    (Self : not null access UML_Opaque_Expression_Proxy;
341     To   : AMF.UML.Template_Parameters.UML_Template_Parameter_Access) is
342   begin
343      AMF.Internals.Tables.UML_Attributes.Internal_Set_Template_Parameter
344       (Self.Element,
345        AMF.Internals.Helpers.To_Element
346         (AMF.Elements.Element_Access (To)));
347   end Set_Template_Parameter;
348
349   -----------------
350   -- Is_Integral --
351   -----------------
352
353   overriding function Is_Integral
354    (Self : not null access constant UML_Opaque_Expression_Proxy)
355       return Boolean is
356   begin
357      --  Generated stub: replace with real body!
358      pragma Compile_Time_Warning (Standard.True, "Is_Integral unimplemented");
359      raise Program_Error with "Unimplemented procedure UML_Opaque_Expression_Proxy.Is_Integral";
360      return Is_Integral (Self);
361   end Is_Integral;
362
363   ---------------------
364   -- Is_Non_Negative --
365   ---------------------
366
367   overriding function Is_Non_Negative
368    (Self : not null access constant UML_Opaque_Expression_Proxy)
369       return Boolean is
370   begin
371      --  Generated stub: replace with real body!
372      pragma Compile_Time_Warning (Standard.True, "Is_Non_Negative unimplemented");
373      raise Program_Error with "Unimplemented procedure UML_Opaque_Expression_Proxy.Is_Non_Negative";
374      return Is_Non_Negative (Self);
375   end Is_Non_Negative;
376
377   -----------------
378   -- Is_Positive --
379   -----------------
380
381   overriding function Is_Positive
382    (Self : not null access constant UML_Opaque_Expression_Proxy)
383       return Boolean is
384   begin
385      --  Generated stub: replace with real body!
386      pragma Compile_Time_Warning (Standard.True, "Is_Positive unimplemented");
387      raise Program_Error with "Unimplemented procedure UML_Opaque_Expression_Proxy.Is_Positive";
388      return Is_Positive (Self);
389   end Is_Positive;
390
391   ------------
392   -- Result --
393   ------------
394
395   overriding function Result
396    (Self : not null access constant UML_Opaque_Expression_Proxy)
397       return AMF.UML.Parameters.UML_Parameter_Access is
398   begin
399      --  Generated stub: replace with real body!
400      pragma Compile_Time_Warning (Standard.True, "Result unimplemented");
401      raise Program_Error with "Unimplemented procedure UML_Opaque_Expression_Proxy.Result";
402      return Result (Self);
403   end Result;
404
405   -----------
406   -- Value --
407   -----------
408
409   overriding function Value
410    (Self : not null access constant UML_Opaque_Expression_Proxy)
411       return Integer is
412   begin
413      --  Generated stub: replace with real body!
414      pragma Compile_Time_Warning (Standard.True, "Value unimplemented");
415      raise Program_Error with "Unimplemented procedure UML_Opaque_Expression_Proxy.Value";
416      return Value (Self);
417   end Value;
418
419   -------------------
420   -- Boolean_Value --
421   -------------------
422
423   overriding function Boolean_Value
424    (Self : not null access constant UML_Opaque_Expression_Proxy)
425       return AMF.Optional_Boolean is
426   begin
427      --  Generated stub: replace with real body!
428      pragma Compile_Time_Warning (Standard.True, "Boolean_Value unimplemented");
429      raise Program_Error with "Unimplemented procedure UML_Opaque_Expression_Proxy.Boolean_Value";
430      return Boolean_Value (Self);
431   end Boolean_Value;
432
433   -------------------
434   -- Integer_Value --
435   -------------------
436
437   overriding function Integer_Value
438    (Self : not null access constant UML_Opaque_Expression_Proxy)
439       return AMF.Optional_Integer is
440   begin
441      --  Generated stub: replace with real body!
442      pragma Compile_Time_Warning (Standard.True, "Integer_Value unimplemented");
443      raise Program_Error with "Unimplemented procedure UML_Opaque_Expression_Proxy.Integer_Value";
444      return Integer_Value (Self);
445   end Integer_Value;
446
447   ------------------------
448   -- Is_Compatible_With --
449   ------------------------
450
451   overriding function Is_Compatible_With
452    (Self : not null access constant UML_Opaque_Expression_Proxy;
453     P : AMF.UML.Parameterable_Elements.UML_Parameterable_Element_Access)
454       return Boolean is
455   begin
456      --  Generated stub: replace with real body!
457      pragma Compile_Time_Warning (Standard.True, "Is_Compatible_With unimplemented");
458      raise Program_Error with "Unimplemented procedure UML_Opaque_Expression_Proxy.Is_Compatible_With";
459      return Is_Compatible_With (Self, P);
460   end Is_Compatible_With;
461
462   -------------------
463   -- Is_Computable --
464   -------------------
465
466   overriding function Is_Computable
467    (Self : not null access constant UML_Opaque_Expression_Proxy)
468       return Boolean is
469   begin
470      --  Generated stub: replace with real body!
471      pragma Compile_Time_Warning (Standard.True, "Is_Computable unimplemented");
472      raise Program_Error with "Unimplemented procedure UML_Opaque_Expression_Proxy.Is_Computable";
473      return Is_Computable (Self);
474   end Is_Computable;
475
476   -------------
477   -- Is_Null --
478   -------------
479
480   overriding function Is_Null
481    (Self : not null access constant UML_Opaque_Expression_Proxy)
482       return Boolean is
483   begin
484      --  Generated stub: replace with real body!
485      pragma Compile_Time_Warning (Standard.True, "Is_Null unimplemented");
486      raise Program_Error with "Unimplemented procedure UML_Opaque_Expression_Proxy.Is_Null";
487      return Is_Null (Self);
488   end Is_Null;
489
490   ----------------
491   -- Real_Value --
492   ----------------
493
494   overriding function Real_Value
495    (Self : not null access constant UML_Opaque_Expression_Proxy)
496       return AMF.Optional_Real is
497   begin
498      --  Generated stub: replace with real body!
499      pragma Compile_Time_Warning (Standard.True, "Real_Value unimplemented");
500      raise Program_Error with "Unimplemented procedure UML_Opaque_Expression_Proxy.Real_Value";
501      return Real_Value (Self);
502   end Real_Value;
503
504   ------------------
505   -- String_Value --
506   ------------------
507
508   overriding function String_Value
509    (Self : not null access constant UML_Opaque_Expression_Proxy)
510       return AMF.Optional_String is
511   begin
512      --  Generated stub: replace with real body!
513      pragma Compile_Time_Warning (Standard.True, "String_Value unimplemented");
514      raise Program_Error with "Unimplemented procedure UML_Opaque_Expression_Proxy.String_Value";
515      return String_Value (Self);
516   end String_Value;
517
518   ---------------------
519   -- Unlimited_Value --
520   ---------------------
521
522   overriding function Unlimited_Value
523    (Self : not null access constant UML_Opaque_Expression_Proxy)
524       return AMF.Optional_Unlimited_Natural is
525   begin
526      --  Generated stub: replace with real body!
527      pragma Compile_Time_Warning (Standard.True, "Unlimited_Value unimplemented");
528      raise Program_Error with "Unimplemented procedure UML_Opaque_Expression_Proxy.Unlimited_Value";
529      return Unlimited_Value (Self);
530   end Unlimited_Value;
531
532   -------------------------
533   -- All_Owning_Packages --
534   -------------------------
535
536   overriding function All_Owning_Packages
537    (Self : not null access constant UML_Opaque_Expression_Proxy)
538       return AMF.UML.Packages.Collections.Set_Of_UML_Package is
539   begin
540      --  Generated stub: replace with real body!
541      pragma Compile_Time_Warning (Standard.True, "All_Owning_Packages unimplemented");
542      raise Program_Error with "Unimplemented procedure UML_Opaque_Expression_Proxy.All_Owning_Packages";
543      return All_Owning_Packages (Self);
544   end All_Owning_Packages;
545
546   -----------------------------
547   -- Is_Distinguishable_From --
548   -----------------------------
549
550   overriding function Is_Distinguishable_From
551    (Self : not null access constant UML_Opaque_Expression_Proxy;
552     N : AMF.UML.Named_Elements.UML_Named_Element_Access;
553     Ns : AMF.UML.Namespaces.UML_Namespace_Access)
554       return Boolean is
555   begin
556      --  Generated stub: replace with real body!
557      pragma Compile_Time_Warning (Standard.True, "Is_Distinguishable_From unimplemented");
558      raise Program_Error with "Unimplemented procedure UML_Opaque_Expression_Proxy.Is_Distinguishable_From";
559      return Is_Distinguishable_From (Self, N, Ns);
560   end Is_Distinguishable_From;
561
562   ---------------
563   -- Namespace --
564   ---------------
565
566   overriding function Namespace
567    (Self : not null access constant UML_Opaque_Expression_Proxy)
568       return AMF.UML.Namespaces.UML_Namespace_Access is
569   begin
570      --  Generated stub: replace with real body!
571      pragma Compile_Time_Warning (Standard.True, "Namespace unimplemented");
572      raise Program_Error with "Unimplemented procedure UML_Opaque_Expression_Proxy.Namespace";
573      return Namespace (Self);
574   end Namespace;
575
576   ---------------------------
577   -- Is_Template_Parameter --
578   ---------------------------
579
580   overriding function Is_Template_Parameter
581    (Self : not null access constant UML_Opaque_Expression_Proxy)
582       return Boolean is
583   begin
584      --  Generated stub: replace with real body!
585      pragma Compile_Time_Warning (Standard.True, "Is_Template_Parameter unimplemented");
586      raise Program_Error with "Unimplemented procedure UML_Opaque_Expression_Proxy.Is_Template_Parameter";
587      return Is_Template_Parameter (Self);
588   end Is_Template_Parameter;
589
590end AMF.Internals.UML_Opaque_Expressions;
591