Skip to content

Commit 859d11d

Browse files
author
Aaron Leung
committed
Merge pull request sass#517 from wonja/call_function
call function (Fixes sass#418) it works I seen it with my own eyes
2 parents 3a404a8 + e560fbb commit 859d11d

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

context.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,7 @@ namespace Sass {
418418
register_function(ctx, global_variable_exists_sig, global_variable_exists, env);
419419
register_function(ctx, function_exists_sig, function_exists, env);
420420
register_function(ctx, mixin_exists_sig, mixin_exists, env);
421+
register_function(ctx, call_sig, call, env);
421422
// Boolean Functions
422423
register_function(ctx, not_sig, sass_not, env);
423424
register_function(ctx, if_sig, sass_if, env);

functions.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1348,6 +1348,23 @@ namespace Sass {
13481348
}
13491349
}
13501350

1351+
Signature call_sig = "call($name, $args...)";
1352+
BUILT_IN(call)
1353+
{
1354+
string name = unquote(ARG("$name", String_Constant)->value());
1355+
List* arglist = new (ctx.mem) List(*ARG("$args", List));
1356+
1357+
Arguments* args = new (ctx.mem) Arguments(path, position);
1358+
for (size_t i = 0, L = arglist->length(); i < L; ++i) {
1359+
Argument* arg = new (ctx.mem) Argument(path, position, arglist->value_at_index(i));
1360+
*args << arg;
1361+
}
1362+
Function_Call* func = new (ctx.mem) Function_Call(path, position, name, args);
1363+
Eval eval(ctx, &d_env, backtrace);
1364+
return func->perform(&eval);
1365+
1366+
}
1367+
13511368
////////////////////
13521369
// BOOLEAN FUNCTIONS
13531370
////////////////////

functions.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ namespace Sass {
9393
extern Signature global_variable_exists_sig;
9494
extern Signature function_exists_sig;
9595
extern Signature mixin_exists_sig;
96+
extern Signature call_sig;
9697
extern Signature not_sig;
9798
extern Signature if_sig;
9899
extern Signature image_url_sig;
@@ -162,6 +163,7 @@ namespace Sass {
162163
BUILT_IN(global_variable_exists);
163164
BUILT_IN(function_exists);
164165
BUILT_IN(mixin_exists);
166+
BUILT_IN(call);
165167
BUILT_IN(sass_not);
166168
BUILT_IN(sass_if);
167169
BUILT_IN(image_url);

0 commit comments

Comments
 (0)