Commit 121f32bb by Aaron Leung

Working on color name conversion stuff. Not ready yet.

parent 55c191c2
...@@ -153,7 +153,7 @@ namespace Sass { ...@@ -153,7 +153,7 @@ namespace Sass {
"yellowgreen", "yellowgreen",
// sentinel value // sentinel value
0 0
} };
const double color_values[] = const double color_values[] =
{ {
...@@ -306,6 +306,6 @@ namespace Sass { ...@@ -306,6 +306,6 @@ namespace Sass {
0x9a, 0xcd, 0x32, 0x9a, 0xcd, 0x32,
// sentinel value // sentinel value
0xfff 0xfff
} };
} }
\ No newline at end of file
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#include <iostream> #include <iostream>
#include <unistd.h> #include <unistd.h>
#include "prelexer.hpp" #include "prelexer.hpp"
#include "color_names.hpp"
using std::cerr; using std::endl; using std::cerr; using std::endl;
namespace Sass { namespace Sass {
...@@ -47,12 +48,15 @@ namespace Sass { ...@@ -47,12 +48,15 @@ namespace Sass {
pending_extensions(vector<pair<Node, Node> >()), pending_extensions(vector<pair<Node, Node> >()),
source_refs(vector<char*>()), source_refs(vector<char*>()),
include_paths(vector<string>()), include_paths(vector<string>()),
color_names_to_values(map<string, Node>()),
color_values_to_names(map<Node, string>()),
new_Node(Node_Factory()), new_Node(Node_Factory()),
ref_count(0), ref_count(0),
has_extensions(false) has_extensions(false)
{ {
register_functions(); register_functions();
collect_include_paths(paths_str); collect_include_paths(paths_str);
setup_color_map();
} }
Context::~Context() Context::~Context()
...@@ -60,7 +64,6 @@ namespace Sass { ...@@ -60,7 +64,6 @@ namespace Sass {
for (size_t i = 0; i < source_refs.size(); ++i) { for (size_t i = 0; i < source_refs.size(); ++i) {
delete[] source_refs[i]; delete[] source_refs[i];
} }
new_Node.free(); new_Node.free();
// cerr << "Deallocated " << i << " source string(s)." << endl; // cerr << "Deallocated " << i << " source string(s)." << endl;
} }
...@@ -149,4 +152,20 @@ namespace Sass { ...@@ -149,4 +152,20 @@ namespace Sass {
register_function(not_descriptor, not_impl); register_function(not_descriptor, not_impl);
} }
void Context::setup_color_map()
{
size_t i = 0;
while (color_names[i] != 0) {
string name(color_names[i]);
Node value(new_Node("[COLOR TABLE]", 0,
color_values[i*3],
color_values[i*3+1],
color_values[i*3+2],
1));
color_names_to_values[name] = value;
color_values_to_names[value] = name;
++i;
}
}
} }
...@@ -47,6 +47,8 @@ namespace Sass { ...@@ -47,6 +47,8 @@ namespace Sass {
vector<pair<Node, Node> > pending_extensions; vector<pair<Node, Node> > pending_extensions;
vector<char*> source_refs; // all the source c-strings vector<char*> source_refs; // all the source c-strings
vector<string> include_paths; vector<string> include_paths;
map<string, Node> color_names_to_values;
map<Node, string> color_values_to_names;
Node_Factory new_Node; Node_Factory new_Node;
size_t ref_count; size_t ref_count;
string sass_path; string sass_path;
...@@ -61,6 +63,7 @@ namespace Sass { ...@@ -61,6 +63,7 @@ namespace Sass {
void register_function(Function_Descriptor d, Primitive ip, size_t arity); void register_function(Function_Descriptor d, Primitive ip, size_t arity);
void register_overload_stub(string name); void register_overload_stub(string name);
void register_functions(); void register_functions();
void setup_color_map();
}; };
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment