Skip to content
This repository was archived by the owner on Jun 14, 2019. It is now read-only.

Commit 121f32b

Browse files
author
Aaron Leung
committed
Working on color name conversion stuff. Not ready yet.
1 parent 55c191c commit 121f32b

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

color_names.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ namespace Sass {
153153
"yellowgreen",
154154
// sentinel value
155155
0
156-
}
156+
};
157157

158158
const double color_values[] =
159159
{
@@ -306,6 +306,6 @@ namespace Sass {
306306
0x9a, 0xcd, 0x32,
307307
// sentinel value
308308
0xfff
309-
}
309+
};
310310

311311
}

context.cpp

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include <iostream>
33
#include <unistd.h>
44
#include "prelexer.hpp"
5+
#include "color_names.hpp"
56
using std::cerr; using std::endl;
67

78
namespace Sass {
@@ -47,20 +48,22 @@ namespace Sass {
4748
pending_extensions(vector<pair<Node, Node> >()),
4849
source_refs(vector<char*>()),
4950
include_paths(vector<string>()),
51+
color_names_to_values(map<string, Node>()),
52+
color_values_to_names(map<Node, string>()),
5053
new_Node(Node_Factory()),
5154
ref_count(0),
5255
has_extensions(false)
5356
{
5457
register_functions();
5558
collect_include_paths(paths_str);
59+
setup_color_map();
5660
}
5761

5862
Context::~Context()
5963
{
6064
for (size_t i = 0; i < source_refs.size(); ++i) {
6165
delete[] source_refs[i];
6266
}
63-
6467
new_Node.free();
6568
// cerr << "Deallocated " << i << " source string(s)." << endl;
6669
}
@@ -148,5 +151,21 @@ namespace Sass {
148151
// Boolean Functions
149152
register_function(not_descriptor, not_impl);
150153
}
154+
155+
void Context::setup_color_map()
156+
{
157+
size_t i = 0;
158+
while (color_names[i] != 0) {
159+
string name(color_names[i]);
160+
Node value(new_Node("[COLOR TABLE]", 0,
161+
color_values[i*3],
162+
color_values[i*3+1],
163+
color_values[i*3+2],
164+
1));
165+
color_names_to_values[name] = value;
166+
color_values_to_names[value] = name;
167+
++i;
168+
}
169+
}
151170

152171
}

context.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ namespace Sass {
4747
vector<pair<Node, Node> > pending_extensions;
4848
vector<char*> source_refs; // all the source c-strings
4949
vector<string> include_paths;
50+
map<string, Node> color_names_to_values;
51+
map<Node, string> color_values_to_names;
5052
Node_Factory new_Node;
5153
size_t ref_count;
5254
string sass_path;
@@ -61,6 +63,7 @@ namespace Sass {
6163
void register_function(Function_Descriptor d, Primitive ip, size_t arity);
6264
void register_overload_stub(string name);
6365
void register_functions();
66+
void setup_color_map();
6467
};
6568

6669
}

0 commit comments

Comments
 (0)