/[eiffelstudio]/FreeELKS/trunk/library/kernel/function.e
ViewVC logotype

Contents of /FreeELKS/trunk/library/kernel/function.e

Parent Directory Parent Directory | Revision Log Revision Log


Revision 91477 - (show annotations)
Sun Jan 14 09:47:13 2007 UTC (13 years ago) by ericb
File size: 3750 byte(s)
Synchronized with ISE 6.0.65740
1 indexing
2 description: "[
3 Objects representing delayed calls to a function,
4 with some arguments possibly still open.
5
6 Note: Features are the same as those of ROUTINE,
7 with `apply' made effective, and the addition
8 of `last_result' and `item'.
9 ]"
10 library: "Free implementation of ELKS library"
11 copyright: "Copyright (c) 1986-2004, Eiffel Software and others"
12 license: "Eiffel Forum License v2 (see forum.txt)"
13 date: "$Date$"
14 revision: "$Revision$"
15
16 class
17 FUNCTION [BASE_TYPE, OPEN_ARGS -> TUPLE create default_create end, RESULT_TYPE]
18
19 inherit
20 ROUTINE [BASE_TYPE, OPEN_ARGS]
21 redefine
22 is_equal, copy
23 end
24
25 feature -- Access
26
27 last_result: RESULT_TYPE
28 -- Result of last call, if any.
29
30 call (args: OPEN_ARGS) is
31 local
32 l_closed_count: INTEGER
33 do
34 l_closed_count := closed_operands.count
35 last_result := fast_item (encaps_rout_disp, calc_rout_addr, $closed_operands, $args, class_id, feature_id,
36 is_precompiled, is_basic, is_inline_agent, l_closed_count, open_count, $open_map)
37 end
38
39 item (args: OPEN_ARGS): RESULT_TYPE is
40 -- Result of calling function with `args' as operands.
41 require
42 valid_operands: valid_operands (args)
43 local
44 l_closed_count: INTEGER
45 do
46 l_closed_count := closed_operands.count
47 Result := fast_item (encaps_rout_disp, calc_rout_addr, $closed_operands, $args, class_id, feature_id,
48 is_precompiled, is_basic, is_inline_agent, l_closed_count, open_count, $open_map)
49 end
50
51 apply is
52 -- Call function with `operands' as last set.
53 local
54 l_closed_count: INTEGER
55 do
56 l_closed_count := closed_operands.count
57 last_result := fast_item (encaps_rout_disp, calc_rout_addr, $closed_operands, $operands, class_id, feature_id,
58 is_precompiled, is_basic, is_inline_agent, l_closed_count, open_count, $open_map)
59 end
60
61 feature -- Comparison
62
63 is_equal (other: like Current): BOOLEAN is
64 -- Is associated function the same as the one
65 -- associated with `other'?
66 do
67 Result := Precursor (other) and then
68 equal (last_result, other.last_result)
69 end
70
71 feature -- Duplication
72
73 copy (other: like Current) is
74 -- Use same function as `other'.
75 do
76 Precursor (other)
77 last_result := other.last_result
78 end
79
80 feature -- Obsolete
81
82 eval (args: OPEN_ARGS): RESULT_TYPE is
83 -- Result of evaluating function for `args'.
84 obsolete
85 "Please use `item' instead"
86 require
87 valid_operands: valid_operands (args)
88 do
89 Result := item (args)
90 end
91
92 feature -- Removal
93
94 clear_last_result is
95 -- Reset content of `last_result' to its default value
96 local
97 l_result: RESULT_TYPE
98 do
99 last_result := l_result
100 end
101
102 feature {NONE} -- Implementation
103
104 fast_item (a_rout_disp, a_calc_rout_addr: POINTER
105 a_closed_operands: POINTER; a_operands: POINTER
106 a_class_id, a_feature_id: INTEGER; a_is_precompiled, a_is_basic, a_is_inline_agent: BOOLEAN
107 a_closed_count, a_open_count: INTEGER; a_open_map: POINTER): RESULT_TYPE
108 external
109 "C inline use %"eif_rout_obj.h%""
110 alias
111 "[
112 #ifdef WORKBENCH
113 $$_result_type result;
114 if ($a_rout_disp != 0) {
115 return (FUNCTION_CAST($$_result_type, (EIF_POINTER, EIF_REFERENCE, EIF_REFERENCE)) $a_rout_disp)(
116 $a_calc_rout_addr, $a_closed_operands, $a_operands);
117 } else {
118 rout_obj_call_function_dynamic (
119 $a_class_id,
120 $a_feature_id,
121 $a_is_precompiled,
122 $a_is_basic,
123 $a_is_inline_agent,
124 $a_closed_operands,
125 $a_closed_count,
126 $a_operands,
127 $a_open_count,
128 $a_open_map,
129 &result);
130 return result;
131 }
132 #else
133 return (FUNCTION_CAST($$_result_type, (EIF_POINTER, EIF_REFERENCE, EIF_REFERENCE)) $a_rout_disp)(
134 $a_calc_rout_addr, $a_closed_operands, $a_operands);
135 #endif
136 ]"
137 end
138
139 end

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.23