Commit 0cb702ba by Aaron Leung

Added a few more builtins.

parent 13787485
...@@ -33,6 +33,9 @@ namespace Sass { ...@@ -33,6 +33,9 @@ namespace Sass {
register_function(rgb_descriptor, rgb); register_function(rgb_descriptor, rgb);
register_function(rgba_4_descriptor, rgba_4); register_function(rgba_4_descriptor, rgba_4);
register_function(rgba_2_descriptor, rgba_2); register_function(rgba_2_descriptor, rgba_2);
register_function(red_descriptor, red);
register_function(green_descriptor, green);
register_function(blue_descriptor, blue);
} }
} }
\ No newline at end of file
#include "functions.hpp" #include "functions.hpp"
#include <iostream> #include <iostream>
#
using std::cerr; using std::endl; using std::cerr; using std::endl;
namespace Sass { namespace Sass {
...@@ -35,6 +34,23 @@ namespace Sass { ...@@ -35,6 +34,23 @@ namespace Sass {
return bindings[parameters[0]].clone() << bindings[parameters[1]]; return bindings[parameters[0]].clone() << bindings[parameters[1]];
} }
Function_Descriptor red_descriptor =
{ "red", "$color", 0 };
Node red(const vector<Token>& parameters, map<Token, Node>& bindings) {
return bindings[parameters[0]][0];
}
Function_Descriptor green_descriptor =
{ "green", "$color", 0 };
Node green(const vector<Token>& parameters, map<Token, Node>& bindings) {
return bindings[parameters[0]][1];
}
Function_Descriptor blue_descriptor =
{ "blue", "$color", 0 };
Node blue(const vector<Token>& parameters, map<Token, Node>& bindings) {
return bindings[parameters[0]][2];
}
} }
} }
\ No newline at end of file
...@@ -51,6 +51,15 @@ namespace Sass { ...@@ -51,6 +51,15 @@ namespace Sass {
extern Function_Descriptor rgba_2_descriptor; extern Function_Descriptor rgba_2_descriptor;
Node rgba_2(const vector<Token>& parameters, map<Token, Node>& bindings); Node rgba_2(const vector<Token>& parameters, map<Token, Node>& bindings);
extern Function_Descriptor red_descriptor;
Node red(const vector<Token>& parameters, map<Token, Node>& bindings);
extern Function_Descriptor green_descriptor;
Node green(const vector<Token>& parameters, map<Token, Node>& bindings);
extern Function_Descriptor blue_descriptor;
Node blue(const vector<Token>& parameters, map<Token, Node>& bindings);
} }
} }
...@@ -10,4 +10,10 @@ div { ...@@ -10,4 +10,10 @@ div {
floo: $x; floo: $x;
bloo: rgba($x, 0.7); bloo: rgba($x, 0.7);
groo: $x; groo: $x;
$x: rgb(123, 45, 6);
hoo: red($x);
moo: green($x);
poo: blue($x);
} }
...@@ -6,4 +6,7 @@ div { ...@@ -6,4 +6,7 @@ div {
blah: rgba(1, 2, 3, 0.6); blah: rgba(1, 2, 3, 0.6);
floo: aqua; floo: aqua;
bloo: rgba(0, 255, 255, 0.7); bloo: rgba(0, 255, 255, 0.7);
groo: aqua; } groo: aqua;
hoo: 123;
moo: 45;
poo: 6; }
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