/src/tools/wrappers-generator/c_namespace.e
Specman e | 92 lines | 47 code | 12 blank | 33 comment | 3 complexity | 450d51633c394b584bc0eafc4323012b MD5 | raw file
1class C_NAMESPACE 2 -- A node of an XML file made by gccxml representing a C++ namespace. 3 -- A C++ name-space is modelled in Liberty as a cluster, a directory 4 -- containing classes, subclusters and how they shall be compiled and 5 -- linked. 6 7inherit 8 GCCXML_NODE 9 CONTEXTED_NODE 10 NAMED_NODE 11 redefine compute_eiffel_name 12 end 13 IDENTIFIED_NODE 14 STORABLE_NODE 15 16create {GCCXML_TREE} 17 make 18 19feature {ANY} 20 store 21 do 22 namespaces.put(Current, id) 23 if not is_main then 24 symbols.put(Current, c_string_name) 25 end 26 end 27 28 is_main: BOOLEAN 29 -- Is Current name space the "main" default namespace? The default namespace is named "::" 30 do 31 Result := c_string_name.is_equal(once "::") 32 end 33 34 path: PATH_NAME 35 -- Path of the directory representing Current namespace 36 do 37 if cached_path = Void then 38 if is_main then 39 create {POSIX_PATH_NAME} cached_path.make_current 40 else 41 -- Recursively build the path 42 cached_path := namespace.path / c_string_name 43 end 44 end 45 Result := cached_path 46 end 47 48 are_members_wrapped: BOOLEAN 49 -- Shall the members of th namespace be wrapped? 50 51 compute_eiffel_name 52 -- Compute cluster name as basename of path (its last part). 53 do 54 cached_eiffel_name := path.last 55 end 56 57 emit_wrapper 58 -- The wrapper of a namespace actually is not any Liberty code but only 59 -- a directory that will be the cluster representing that namespace. 60 do 61 -- local cwd: STRING; bd: BASIC_DIRECTORY; 62 -- Create a directory named like Current namespace that will contain everything defined in that namespace. 63 -- Try to create the directory and forget about the result 64 log("Faking creation of «" + path.to_string + "»directory%N") 65 -- outcome := bd.create_new_directory(path.to_string); 66 -- if path.is_directory then 67 -- are_members_wrapped:=True 68 -- -- Each gccxml node will query its containing namespace to see if it shall be wrapped. 69 -- else -- directory still doesn't exists, we cannot wrap its content. 70 -- log("Namespace `#(1)' would be wrapped into `#(2)', but it is not a directory or could not be created: its contents shall not be wrapped.%N" 71 -- # c_string_name # path.to_string) 72 -- end 73 end 74 75feature {STORABLE_NODE} -- Contained nodes 76 77 78feature {} -- Implementation 79 cached_path: PATH_NAME 80 81end -- class C_NAMESPACE 82-- Copyright (C) 2008-2017: Paolo Redaelli 83-- wrappers-generator is free software: you can redistribute it and/or modify it 84-- under the terms of the GNU General Public License as publhed by the Free 85-- Software Foundation, either version 2 of the License, or (at your option) 86-- any later version. 87-- wrappers-generator is distributed in the hope that it will be useful, but 88-- WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 89-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 90-- more details. 91-- You should have received a copy of the GNU General Public License along with 92-- th program. If not, see <http://www.gnu.org/licenses/>.