xref: /aoo41x/main/autodoc/source/ary/cpp/cs_type.cxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #include <precomp.h>
29 #include "cs_type.hxx"
30 
31 // NOT FULLY DEFINED SERVICES
32 #include <ary/cpp/c_builtintype.hxx>
33 
34 
35 namespace
36 {
37     const uintt
38         C_nReservedElements = ary::cpp::predefined::t_MAX;    // Skipping "0" and the builtin types
39 }
40 
41 
42 namespace ary
43 {
44 namespace cpp
45 {
46 
47 
48 
49 Type_Storage *    Type_Storage::pInstance_ = 0;
50 
51 
52 
53 
54 Type_Storage::Type_Storage()
55     :   stg::Storage<Type>(C_nReservedElements),
56         aBuiltInTypes()
57 {
58     Setup_BuiltInTypes();
59 
60     csv_assert(pInstance_ == 0);
61     pInstance_ = this;
62 }
63 
64 Type_Storage::~Type_Storage()
65 {
66     csv_assert(pInstance_ != 0);
67     pInstance_ = 0;
68 }
69 
70 Type_id
71 Type_Storage::Search_BuiltInType( const String & i_specializedName ) const
72 {
73     return csv::value_from_map(aBuiltInTypes, i_specializedName, Tid(0));
74 }
75 
76 void
77 Type_Storage::Setup_BuiltInTypes()
78 {
79 	Set_BuiltInType( predefined::t_void, "void" );
80 	Set_BuiltInType( predefined::t_bool, "bool" );
81 	Set_BuiltInType( predefined::t_char, "char" );
82 	Set_BuiltInType( predefined::t_signed_char, "char", TYSP_signed );
83 	Set_BuiltInType( predefined::t_unsigned_char, "char", TYSP_unsigned );
84 	Set_BuiltInType( predefined::t_short, "short" );
85 	Set_BuiltInType( predefined::t_unsigned_short, "short", TYSP_unsigned );
86 	Set_BuiltInType( predefined::t_int, "int" );
87 	Set_BuiltInType( predefined::t_unsigned_int, "int", TYSP_unsigned );
88 	Set_BuiltInType( predefined::t_long, "long" );
89 	Set_BuiltInType( predefined::t_unsigned_long, "long", TYSP_unsigned );
90 	Set_BuiltInType( predefined::t_float, "float" );
91 	Set_BuiltInType( predefined::t_double, "double" );
92 	Set_BuiltInType( predefined::t_size_t, "size_t" );
93 	Set_BuiltInType( predefined::t_wchar_t, "wchar_t" );
94 	Set_BuiltInType( predefined::t_ptrdiff_t, "ptrdiff_t" );
95 	Set_BuiltInType( predefined::t_ellipse, "..." );
96 }
97 
98 void
99 Type_Storage::Set_BuiltInType( Rid							    i_id,
100 							   const char *		                i_sName,
101 							   ary::cpp::E_TypeSpecialisation   i_eSpecialisation )
102 {
103     DYN BuiltInType &
104         rNew = *new BuiltInType(i_sName, i_eSpecialisation);
105     Set_Reserved( i_id, rNew);  // Here goes the ownership for rNew.
106     aBuiltInTypes[rNew.SpecializedName()] = rNew.TypeId();
107 }
108 
109 
110 
111 }   // namespace cpp
112 }   // namespace ary
113