Skip to content

Commit 60801a5

Browse files
committed
Merge branch 'master' of git://github.com/hcatlin/libsass into python
2 parents 9fcf879 + 580c318 commit 60801a5

19 files changed

+1206
-782
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ CC=g++
22
CFLAGS=-c -Wall -O2 -fPIC
33
LDFLAGS= -fPIC
44
SOURCES = \
5-
context.cpp functions.cpp document.cpp \
5+
constants.cpp context.cpp functions.cpp document.cpp \
66
document_parser.cpp eval_apply.cpp node.cpp \
77
node_factory.cpp node_emitters.cpp prelexer.cpp \
88
sass_interface.cpp

Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ ACLOCAL_AMFLAGS = -I m4
22

33
lib_LTLIBRARIES = libsass.la
44
libsass_la_SOURCES = context.cpp functions.cpp document.cpp \
5-
document_parser.cpp eval_apply.cpp node.cpp \
5+
constants.cpp document_parser.cpp eval_apply.cpp node.cpp \
66
node_factory.cpp node_emitters.cpp prelexer.cpp \
77
sass_interface.cpp
88
libsass_la_LDFLAGS = -no-undefined -version-info 0:0:0

Makefile.in

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(includedir)"
8585
LTLIBRARIES = $(lib_LTLIBRARIES)
8686
libsass_la_LIBADD =
8787
am_libsass_la_OBJECTS = context.lo functions.lo document.lo \
88-
document_parser.lo eval_apply.lo node.lo node_factory.lo \
88+
constants.lo document_parser.lo eval_apply.lo node.lo node_factory.lo \
8989
node_emitters.lo prelexer.lo sass_interface.lo
9090
libsass_la_OBJECTS = $(am_libsass_la_OBJECTS)
9191
libsass_la_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \
@@ -245,7 +245,7 @@ top_srcdir = @top_srcdir@
245245
ACLOCAL_AMFLAGS = -I m4
246246
lib_LTLIBRARIES = libsass.la
247247
libsass_la_SOURCES = context.cpp functions.cpp document.cpp \
248-
document_parser.cpp eval_apply.cpp node.cpp \
248+
constants.cpp document_parser.cpp eval_apply.cpp node.cpp \
249249
node_factory.cpp node_emitters.cpp prelexer.cpp \
250250
sass_interface.cpp
251251

@@ -347,6 +347,7 @@ distclean-compile:
347347

348348
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/context.Plo@am__quote@
349349
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/document.Plo@am__quote@
350+
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/constants.Plo@am__quote@
350351
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/document_parser.Plo@am__quote@
351352
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eval_apply.Plo@am__quote@
352353
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/functions.Plo@am__quote@

constants.cpp

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
#include "constants.hpp"
2+
3+
namespace Sass {
4+
namespace Constants {
5+
6+
// hidden variable name for the image path (for the image-url built-in)
7+
extern const char image_path_var[] = "$[image path]";
8+
9+
// sass keywords
10+
extern const char import_kwd[] = "@import";
11+
extern const char mixin_kwd[] = "@mixin";
12+
extern const char function_kwd[] = "@function";
13+
extern const char return_kwd[] = "@return";
14+
extern const char include_kwd[] = "@include";
15+
extern const char extend_kwd[] = "@extend";
16+
extern const char if_kwd[] = "@if";
17+
extern const char else_kwd[] = "@else";
18+
extern const char if_after_else_kwd[] = "if";
19+
extern const char for_kwd[] = "@for";
20+
extern const char from_kwd[] = "from";
21+
extern const char to_kwd[] = "to";
22+
extern const char through_kwd[] = "through";
23+
extern const char each_kwd[] = "@each";
24+
extern const char in_kwd[] = "in";
25+
extern const char while_kwd[] = "@while";
26+
extern const char warn_kwd[] = "@warn";
27+
extern const char default_kwd[] = "default";
28+
29+
// css standard units
30+
extern const char em_kwd[] = "em";
31+
extern const char ex_kwd[] = "ex";
32+
extern const char px_kwd[] = "px";
33+
extern const char cm_kwd[] = "cm";
34+
extern const char mm_kwd[] = "mm";
35+
extern const char pt_kwd[] = "pt";
36+
extern const char pc_kwd[] = "pc";
37+
extern const char deg_kwd[] = "deg";
38+
extern const char rad_kwd[] = "rad";
39+
extern const char grad_kwd[] = "grad";
40+
extern const char ms_kwd[] = "ms";
41+
extern const char s_kwd[] = "s";
42+
extern const char Hz_kwd[] = "Hz";
43+
extern const char kHz_kwd[] = "kHz";
44+
45+
// css functions and keywords
46+
extern const char media_kwd[] = "@media";
47+
extern const char only_kwd[] = "only";
48+
extern const char rgb_kwd[] = "rgb(";
49+
extern const char url_kwd[] = "url(";
50+
extern const char image_url_kwd[] = "image-url(";
51+
extern const char important_kwd[] = "important";
52+
extern const char pseudo_not_kwd[] = ":not(";
53+
extern const char even_kwd[] = "even";
54+
extern const char odd_kwd[] = "odd";
55+
56+
// css attribute-matching operators
57+
extern const char tilde_equal[] = "~=";
58+
extern const char pipe_equal[] = "|=";
59+
extern const char caret_equal[] = "^=";
60+
extern const char dollar_equal[] = "$=";
61+
extern const char star_equal[] = "*=";
62+
63+
// relational & logical operators and constants
64+
extern const char and_kwd[] = "and";
65+
extern const char or_kwd[] = "or";
66+
extern const char not_kwd[] = "not";
67+
extern const char gt[] = ">";
68+
extern const char gte[] = ">=";
69+
extern const char lt[] = "<";
70+
extern const char lte[] = "<=";
71+
extern const char eq[] = "==";
72+
extern const char neq[] = "!=";
73+
extern const char true_kwd[] = "true";
74+
extern const char false_kwd[] = "false";
75+
76+
// miscellaneous punctuation and delimiters
77+
extern const char percent_str[] = "%";
78+
extern const char empty_str[] = "";
79+
extern const char slash_slash[] = "//";
80+
extern const char slash_star[] = "/*";
81+
extern const char star_slash[] = "*/";
82+
extern const char hash_lbrace[] = "#{";
83+
extern const char rbrace[] = "}";
84+
extern const char rparen[] = ")";
85+
extern const char sign_chars[] = "-+";
86+
87+
// type names
88+
extern const char numeric_name[] = "numeric value";
89+
extern const char number_name[] = "number";
90+
extern const char percentage_name[] = "percentage";
91+
extern const char dimension_name[] = "numeric dimension";
92+
extern const char string_name[] = "string";
93+
extern const char bool_name[] = "bool";
94+
extern const char color_name[] = "color";
95+
extern const char list_name[] = "list";
96+
97+
}
98+
}

constants.hpp

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
#define SASS_CONSTANTS
2+
3+
namespace Sass {
4+
namespace Constants {
5+
6+
// hidden variable name for the image path (for the image-url built-in)
7+
extern const char image_path_var[];
8+
9+
// sass keywords
10+
extern const char import_kwd[];
11+
extern const char mixin_kwd[];
12+
extern const char function_kwd[];
13+
extern const char return_kwd[];
14+
extern const char include_kwd[];
15+
extern const char extend_kwd[];
16+
extern const char if_kwd[];
17+
extern const char else_kwd[];
18+
extern const char if_after_else_kwd[];
19+
extern const char for_kwd[];
20+
extern const char from_kwd[];
21+
extern const char to_kwd[];
22+
extern const char through_kwd[];
23+
extern const char each_kwd[];
24+
extern const char in_kwd[];
25+
extern const char while_kwd[];
26+
extern const char warn_kwd[];
27+
extern const char default_kwd[];
28+
29+
// css standard units
30+
extern const char em_kwd[];
31+
extern const char ex_kwd[];
32+
extern const char px_kwd[];
33+
extern const char cm_kwd[];
34+
extern const char mm_kwd[];
35+
extern const char pt_kwd[];
36+
extern const char pc_kwd[];
37+
extern const char deg_kwd[];
38+
extern const char rad_kwd[];
39+
extern const char grad_kwd[];
40+
extern const char ms_kwd[];
41+
extern const char s_kwd[];
42+
extern const char Hz_kwd[];
43+
extern const char kHz_kwd[];
44+
45+
// css functions and keywords
46+
extern const char media_kwd[];
47+
extern const char only_kwd[];
48+
extern const char rgb_kwd[];
49+
extern const char url_kwd[];
50+
extern const char image_url_kwd[];
51+
extern const char important_kwd[];
52+
extern const char pseudo_not_kwd[];
53+
extern const char even_kwd[];
54+
extern const char odd_kwd[];
55+
56+
// css attribute-matching operators
57+
extern const char tilde_equal[];
58+
extern const char pipe_equal[];
59+
extern const char caret_equal[];
60+
extern const char dollar_equal[];
61+
extern const char star_equal[];
62+
63+
// relational & logical operators and constants
64+
extern const char and_kwd[];
65+
extern const char or_kwd[];
66+
extern const char not_kwd[];
67+
extern const char gt[];
68+
extern const char gte[];
69+
extern const char lt[];
70+
extern const char lte[];
71+
extern const char eq[];
72+
extern const char neq[];
73+
extern const char true_kwd[];
74+
extern const char false_kwd[];
75+
76+
// miscellaneous punctuation and delimiters
77+
extern const char percent_str[];
78+
extern const char empty_str[];
79+
extern const char slash_slash[];
80+
extern const char slash_star[];
81+
extern const char star_slash[];
82+
extern const char hash_lbrace[];
83+
extern const char rbrace[];
84+
extern const char rparen[];
85+
extern const char sign_chars[];
86+
87+
// type names
88+
extern const char numeric_name[];
89+
extern const char number_name[];
90+
extern const char percentage_name[];
91+
extern const char dimension_name[];
92+
extern const char string_name[];
93+
extern const char bool_name[];
94+
extern const char color_name[];
95+
extern const char list_name[];
96+
}
97+
}

context.cpp

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1-
#include "context.hpp"
21
#include <cstring>
32
#include <iostream>
43
#include <sstream>
54
#include <unistd.h>
6-
#include "prelexer.hpp"
5+
#include "context.hpp"
6+
#include "constants.hpp"
77
#include "color_names.hpp"
8-
using std::cerr; using std::endl;
8+
#include "prelexer.hpp"
9+
910

1011
namespace Sass {
11-
using std::pair;
12-
12+
using namespace Constants;
13+
using std::pair; using std::cerr; using std::endl;
14+
1315
void Context::collect_include_paths(const char* paths_str)
1416
{
1517
const size_t wd_len = 1024;
@@ -65,6 +67,9 @@ namespace Sass {
6567
path_string = "'" + path_string + "/'";
6668
image_path = new char[path_string.length() + 1];
6769
std::strcpy(image_path, path_string.c_str());
70+
71+
// stash this hidden variable for the image-url built-in to use
72+
global_env[Token::make(image_path_var)] = new_Node(Node::string_constant, "[IMAGE PATH]", 0, Token::make(image_path));
6873
}
6974

7075
Context::~Context()
@@ -131,6 +136,7 @@ namespace Sass {
131136
register_function(fade_out_sig, fade_out);
132137
// Other Color Functions
133138
register_function(adjust_color_sig, adjust_color);
139+
register_function(scale_color_sig, scale_color);
134140
register_function(change_color_sig, change_color);
135141
// String Functions
136142
register_function(unquote_sig, unquote);
@@ -144,9 +150,23 @@ namespace Sass {
144150
// List Functions
145151
register_function(length_sig, length);
146152
register_function(nth_sig, nth);
153+
register_function(index_sig, index);
147154
register_function(join_sig, join);
148155
register_function(append_sig, append);
149-
register_function(compact_sig, compact);
156+
register_overload_stub("compact");
157+
register_function(compact_1_sig, compact_1, 1);
158+
register_function(compact_n_sig, compact_n, 0);
159+
register_function(compact_n_sig, compact_n, 2);
160+
register_function(compact_n_sig, compact_n, 3);
161+
register_function(compact_n_sig, compact_n, 4);
162+
register_function(compact_n_sig, compact_n, 5);
163+
register_function(compact_n_sig, compact_n, 6);
164+
register_function(compact_n_sig, compact_n, 7);
165+
register_function(compact_n_sig, compact_n, 8);
166+
register_function(compact_n_sig, compact_n, 9);
167+
register_function(compact_n_sig, compact_n, 10);
168+
register_function(compact_n_sig, compact_n, 11);
169+
register_function(compact_n_sig, compact_n, 12);
150170
// Introspection Functions
151171
register_function(type_of_sig, type_of);
152172
register_function(unit_sig, unit);
@@ -155,6 +175,8 @@ namespace Sass {
155175
// Boolean Functions
156176
register_function(not_sig, not_impl);
157177
register_function(if_sig, if_impl);
178+
// Path Functions
179+
register_function(image_url_sig, image_url);
158180
}
159181

160182
void Context::setup_color_map()

docs/changes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Version 0.2.3
77
To be released.
88

99
- :mod:`sassutils.distutils`: Prevent double monkey patch of ``sdist``.
10+
- Merged upstream changes of libsass.
1011

1112

1213
Version 0.2.2

document.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ namespace Sass {
164164
Node parse_string();
165165
Node parse_value_schema();
166166
Node parse_identifier_schema();
167+
Node parse_url_schema();
167168
Node parse_if_directive(Node surrounding_ruleset, Node::Type inside_of = Node::none);
168169
Node parse_for_directive(Node surrounding_ruleset, Node::Type inside_of = Node::none);
169170
Node parse_each_directive(Node surrounding_ruleset, Node::Type inside_of = Node::none);

0 commit comments

Comments
 (0)