Update procedures
[shapes.git] / source / consts.cc
blob953f2cd28fa06bad3832e5578d4ba8f0c31f801b
1 /* This file is part of Shapes.
3 * Shapes is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * any later version.
8 * Shapes is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with Shapes. If not, see <http://www.gnu.org/licenses/>.
16 * Copyright 2008, 2014, 2015 Henrik Tidefelt
19 #include "Shapes_Kernel_decls.h"
21 #include "consts.h"
22 #include "shapesexceptions.h"
23 #include "classtypes.h"
24 #include "statetypes.h"
25 #include "fonttypes.h"
27 using namespace Shapes;
29 /* Helper function just for initializing namespace constants.
31 static
32 RefCountPtr< Ast::NamespacePath >
33 makeCoreNamespacePath( const Ast::NamespacePath & prefix, const char * name )
35 RefCountPtr< Ast::NamespacePath > path( new Ast::NamespacePath( prefix ) );
36 path->push_back( name );
37 return path;
39 static Ast::NamespacePath globalNamespace; /* Just like Ast::THE_EMPTY_NAMESPACE_PATH, but not introducing an unnecessary global initialization order constraint. */
41 /* Make sure these are initialized before used to initialize other constants!
43 const RefCountPtr< const Ast::NamespacePath > Lang::THE_NAMESPACE_Shapes = makeCoreNamespacePath( globalNamespace, "Shapes" );
44 const RefCountPtr< const Ast::NamespacePath > Lang::THE_NAMESPACE_Shapes_Data = makeCoreNamespacePath( *Lang::THE_NAMESPACE_Shapes, "Data" );
45 const RefCountPtr< const Ast::NamespacePath > Lang::THE_NAMESPACE_Shapes_Data_Type = makeCoreNamespacePath( *THE_NAMESPACE_Shapes_Data, "Type" );
46 const RefCountPtr< const Ast::NamespacePath > Lang::THE_NAMESPACE_Shapes_Debug = makeCoreNamespacePath( *Lang::THE_NAMESPACE_Shapes, "Debug" );
47 const RefCountPtr< const Ast::NamespacePath > Lang::THE_NAMESPACE_Shapes_Geometry = makeCoreNamespacePath( *Lang::THE_NAMESPACE_Shapes, "Geometry" );
48 const RefCountPtr< const Ast::NamespacePath > Lang::THE_NAMESPACE_Shapes_Geometry3D = makeCoreNamespacePath( *Lang::THE_NAMESPACE_Shapes, "Geometry3D" );
49 const RefCountPtr< const Ast::NamespacePath > Lang::THE_NAMESPACE_Shapes_Graphics = makeCoreNamespacePath( *Lang::THE_NAMESPACE_Shapes, "Graphics" );
50 const RefCountPtr< const Ast::NamespacePath > Lang::THE_NAMESPACE_Shapes_Graphics_PDF = makeCoreNamespacePath( *THE_NAMESPACE_Shapes_Graphics, "PDF" );
51 const RefCountPtr< const Ast::NamespacePath > Lang::THE_NAMESPACE_Shapes_Graphics_Tag = makeCoreNamespacePath( *THE_NAMESPACE_Shapes_Graphics, "Tag" );
52 const RefCountPtr< const Ast::NamespacePath > Lang::THE_NAMESPACE_Shapes_Graphics3D = makeCoreNamespacePath( *Lang::THE_NAMESPACE_Shapes, "Graphics3D" );
53 const RefCountPtr< const Ast::NamespacePath > Lang::THE_NAMESPACE_Shapes_Graphics3D_Tag = makeCoreNamespacePath( *THE_NAMESPACE_Shapes_Graphics3D, "Tag" );
54 const RefCountPtr< const Ast::NamespacePath > Lang::THE_NAMESPACE_Shapes_IO = makeCoreNamespacePath( *Lang::THE_NAMESPACE_Shapes, "IO" );
55 const RefCountPtr< const Ast::NamespacePath > Lang::THE_NAMESPACE_Shapes_Layout = makeCoreNamespacePath( *Lang::THE_NAMESPACE_Shapes, "Layout" );
56 const RefCountPtr< const Ast::NamespacePath > Lang::THE_NAMESPACE_Shapes_Numeric = makeCoreNamespacePath( *Lang::THE_NAMESPACE_Shapes, "Numeric" );
57 const RefCountPtr< const Ast::NamespacePath > Lang::THE_NAMESPACE_Shapes_Numeric_Constant = makeCoreNamespacePath( *THE_NAMESPACE_Shapes_Numeric, "Constant" );
58 const RefCountPtr< const Ast::NamespacePath > Lang::THE_NAMESPACE_Shapes_Numeric_Math = makeCoreNamespacePath( *THE_NAMESPACE_Shapes_Numeric, "Math" );
59 const RefCountPtr< const Ast::NamespacePath > Lang::THE_NAMESPACE_Shapes_Numeric_Random = makeCoreNamespacePath( *THE_NAMESPACE_Shapes_Numeric, "Random" );
60 const RefCountPtr< const Ast::NamespacePath > Lang::THE_NAMESPACE_Shapes_String = makeCoreNamespacePath( *Lang::THE_NAMESPACE_Shapes, "String" );
61 const RefCountPtr< const Ast::NamespacePath > Lang::THE_NAMESPACE_Shapes_Text = makeCoreNamespacePath( *Lang::THE_NAMESPACE_Shapes, "Text" );
62 const RefCountPtr< const Ast::NamespacePath > Lang::THE_NAMESPACE_Shapes_Text_Font = makeCoreNamespacePath( *THE_NAMESPACE_Shapes_Text, "Font" );
63 const RefCountPtr< const Ast::NamespacePath > Lang::THE_NAMESPACE_Shapes_Traits = makeCoreNamespacePath( *Lang::THE_NAMESPACE_Shapes, "Traits" );
64 const RefCountPtr< const Ast::NamespacePath > Lang::THE_NAMESPACE_Shapes_Traits_BW = makeCoreNamespacePath( *THE_NAMESPACE_Shapes_Traits, "BW" );
65 const RefCountPtr< const Ast::NamespacePath > Lang::THE_NAMESPACE_Shapes_Traits_Blend = makeCoreNamespacePath( *THE_NAMESPACE_Shapes_Traits, "Blend" );
66 const RefCountPtr< const Ast::NamespacePath > Lang::THE_NAMESPACE_Shapes_Traits_Cap = makeCoreNamespacePath( *THE_NAMESPACE_Shapes_Traits, "Cap" );
67 const RefCountPtr< const Ast::NamespacePath > Lang::THE_NAMESPACE_Shapes_Traits_Device = makeCoreNamespacePath( *THE_NAMESPACE_Shapes_Traits, "Device" );
68 const RefCountPtr< const Ast::NamespacePath > Lang::THE_NAMESPACE_Shapes_Traits_Join = makeCoreNamespacePath( *THE_NAMESPACE_Shapes_Traits, "Join" );
69 const RefCountPtr< const Ast::NamespacePath > Lang::THE_NAMESPACE_Shapes_Traits_Light = makeCoreNamespacePath( *THE_NAMESPACE_Shapes_Traits, "Light" );
70 const RefCountPtr< const Ast::NamespacePath > Lang::THE_NAMESPACE_Shapes_Traits_RGB = makeCoreNamespacePath( *THE_NAMESPACE_Shapes_Traits, "RGB" );
73 RefCountPtr< const char > Interaction::SEVERAL_TYPES = strrefdup( "(several types)" );
74 RefCountPtr< const char > Interaction::PUBLIC_SCOPE_NAME = strrefdup( "public" );
75 RefCountPtr< const char > Interaction::PROTECTED_SCOPE_NAME = strrefdup( "protected" );
77 const char Interaction::NAMESPACE_SEPARATOR[] = "..";
78 const char Interaction::ENCAPSULATION_MARK[] = "^^";
79 const char Interaction::DYNAMIC_VARIABLE_PREFIX[] = "@";
80 const char Interaction::STATE_PREFIX[] = "•";
81 const char Interaction::DYNAMIC_STATE_PREFIX[] = "@•";
83 const char Interaction::BUILD_REQ_LIBJPEG[] = "JPEG";
84 const char Interaction::BUILD_REQ_LIBPNG[] = "PNG";
85 const char Interaction::BUILD_REQ_FREETYPE[] = "FreeType";
86 const char Interaction::BUILD_REQ_FONTCONFIG[] = "FontConfig";
87 const char Interaction::BUILD_REQ_OPENSSL[] = "OpenSSL";
89 /* The initialization of Lang::TEX_SYNTAX_ID is placed in coreast.cc to ensure it gets initialized before we need it there.
92 const Ast::Identifier Lang::SELF_ID( Ast::THE_EMPTY_SEARCH_CONTEXT, Ast::NamespaceReference::ABSOLUTE, Lang::THE_NAMESPACE_Shapes, "self" ); /* Warning! Has Ast::THE_EMPTY_SEARCH_CONTEXT been initialized before being used here? */
93 const char Kernel::SPLIT_VAR_PREFIX[] = ".splvar"; /* Note that the leading dot puts this variable aside all user-variables. */
94 const char Kernel::HTML_DIR[] = HTML_DIRDEF;
95 const char Kernel::RESOURCES_DIR[] = RESOURCES_DIRDEF;
96 const Ast::PlacedIdentifier Kernel::SEQUENTIAL_EXPR_VAR_ID( Lang::THE_NAMESPACE_Shapes, ".seqvar" ); /* Note that the leading dot puts this variable aside all user-variables. */
97 const Ast::PlacedIdentifier Kernel::MUTATOR_CURRY_VAR_ID( Lang::THE_NAMESPACE_Shapes, ".callvar" ); /* Note that the leading dot puts this variable aside all user-variables. */
99 const char Lang::CONTINUATION_ID_ERROR[] = "error";
101 const Ast::PlacedIdentifier Lang::HANDLER_NO_INTERSECTION( Lang::THE_NAMESPACE_Shapes_Geometry, "handler_NoIntersection" );
102 const Ast::PlacedIdentifier Lang::CANVAS_ID( Lang::THE_NAMESPACE_Shapes_IO, "page" );
103 const Ast::PlacedIdentifier Lang::CATALOG_ID( Lang::THE_NAMESPACE_Shapes_IO, "catalog" );
105 const Ast::PlacedIdentifier Lang::DYNAMIC_VARIABLE_ID_EYEZ( Lang::THE_NAMESPACE_Shapes_Geometry3D, "eyez" );
106 const Ast::PlacedIdentifier Lang::DYNAMIC_VARIABLE_ID_TEX_BLEED( Lang::THE_NAMESPACE_Shapes_Layout, "TeX_bleed" );
107 const Ast::PlacedIdentifier Lang::DYNAMIC_VARIABLE_ID_DEFAULT_UNIT( Lang::THE_NAMESPACE_Shapes_Geometry, "defaultunit" );
108 const Ast::PlacedIdentifier Lang::DYNAMIC_VARIABLE_ID_BLEND_SPACE( Lang::THE_NAMESPACE_Shapes_Traits, "blendspace" );
109 const Ast::PlacedIdentifier Lang::DYNAMIC_VARIABLE_ID_STROKING( Lang::THE_NAMESPACE_Shapes_Traits, "stroking" );
110 const Ast::PlacedIdentifier Lang::DYNAMIC_VARIABLE_ID_WIDTH( Lang::THE_NAMESPACE_Shapes_Traits, "width" );
111 const Ast::PlacedIdentifier Lang::DYNAMIC_VARIABLE_ID_NONSTROKING( Lang::THE_NAMESPACE_Shapes_Traits, "nonstroking" );
112 const Ast::PlacedIdentifier Lang::DYNAMIC_VARIABLE_ID_AUTOINTENSITY( Lang::THE_NAMESPACE_Shapes_Traits_Light, "autointensity" );
114 const Ast::PlacedIdentifier Lang::DYNAMIC_VARIABLE_ID_TEXT_SIZE( Lang::THE_NAMESPACE_Shapes_Text, "size" );
115 const Ast::PlacedIdentifier Lang::DYNAMIC_VARIABLE_ID_TEXT_FONT( Lang::THE_NAMESPACE_Shapes_Text, "font" );
117 const Ast::MemberMode Ast::MEMBER_ACCESS_BITS = 0x000F;
118 const Ast::MemberMode Ast::MEMBER_ACCESS_PRIVATE = 0x0000;
119 const Ast::MemberMode Ast::MEMBER_ACCESS_PUBLIC_GET = 0x0001;
120 const Ast::MemberMode Ast::MEMBER_ACCESS_PUBLIC_INSERT = 0x0002;
121 const Ast::MemberMode Ast::MEMBER_ACCESS_PROTECTED_GET = 0x0004;
122 const Ast::MemberMode Ast::MEMBER_ACCESS_PROTECTED_INSERT = 0x0008;
123 const Ast::MemberMode Ast::MEMBER_CONST = 0x0010;
124 const Ast::MemberMode Ast::MEMBER_METHOD = 0x0020;
125 const Ast::MemberMode Ast::MEMBER_ABSTRACT = 0x0040;
126 const Ast::MemberMode Ast::MEMBER_FINAL = 0x0080;
127 const Ast::MemberMode Ast::MEMBER_TRANSFORMING = 0x0100;
129 const Ast::ClassMode Ast::CLASS_MODE_ABSTRACT = 0x0001;
130 const Ast::ClassMode Ast::CLASS_MODE_FINAL = 0x0002;
132 const Ast::FunctionMode Ast::FUNCTION_TRANSFORMING = 0x0001;
134 const char Lang::MESSAGE_DRAWABLE_DRAW_ID[] = "draw";
136 const double Computation::SINGULAR_TRANSFORM_LIMIT = 1e-8;
139 RefCountPtr< const char > BuiltInFonts::TIMES_ROMAN = strrefdup( "Times-Roman" );
140 RefCountPtr< const char > BuiltInFonts::TIMES_BOLD = strrefdup( "Times-Bold" );
141 RefCountPtr< const char > BuiltInFonts::TIMES_ITALIC = strrefdup( "Times-Italic" );
142 RefCountPtr< const char > BuiltInFonts::TIMES_BOLDITALIC = strrefdup( "Times-BoldItalic" );
143 // HELVETICA is initialized in globals.cc to ensure correct order of initialization.
144 RefCountPtr< const char > BuiltInFonts::HELVETICA_BOLD = strrefdup( "Helvetica-Bold" );
145 RefCountPtr< const char > BuiltInFonts::HELVETICA_OBLIQUE = strrefdup( "Helvetica-Oblique" );
146 RefCountPtr< const char > BuiltInFonts::HELVETICA_BOLDOBLIQUE = strrefdup( "Helvetica-BoldOblique" );
147 RefCountPtr< const char > BuiltInFonts::COURIER = strrefdup( "Courier" );
148 RefCountPtr< const char > BuiltInFonts::COURIER_BOLD = strrefdup( "Courier-Bold" );
149 RefCountPtr< const char > BuiltInFonts::COURIER_OBLIQUE = strrefdup( "Courier-Oblique" );
150 RefCountPtr< const char > BuiltInFonts::COURIER_BOLDOBLIQUE = strrefdup( "Courier-BoldOblique" );
151 RefCountPtr< const char > BuiltInFonts::SYMBOL = strrefdup( "Symbol" );
152 RefCountPtr< const char > BuiltInFonts::ZAPFDINGBATS = strrefdup( "ZapfDingbats" );
155 const size_t Computation::RREL_SIZE = 33;
156 const double Computation::RREL_TH_STEP = 0.1;
157 const double Computation::RREL_TABLE[RREL_SIZE] =
158 { 1/3,0.3341686344960354,0.33668841107954134,
159 0.3409422096583605,0.34701519474761894,
160 0.35502910405887494,0.36514854168289823,
161 0.3775911942845651,0.3926341399960872,
162 0.41062983298282885,0.43202211298939736,
163 0.45737337400783484,0.4873946524706331,
164 0.522992662410542,0.5653317708668038,
165 0.6159221561762755,0.6767424374123584,
166 0.7504184408114359,0.8404852622717847,
167 0.9517742868557572,1.0910034113732654,
168 1.267683405767762,1.4955440295942208,
169 1.7947857010553352,2.1956618428196286,
170 2.7440092614738933,3.5090279091817442,
171 4.590771723726686,6.112526284299868,8.144027798714662,
172 10.441038625842998,12.076454051457787,13};