Skip to content

Commit

Permalink
Clean up get_arg_m in fn_utils
Browse files Browse the repository at this point in the history
  • Loading branch information
mgreter committed Mar 17, 2018
1 parent 025dc4e commit 0c5e27c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
1 change: 1 addition & 0 deletions src/bind.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "sass.hpp"
#include "bind.hpp"
#include "ast.hpp"
#include "backtrace.hpp"
#include "context.hpp"
#include "expand.hpp"
#include "eval.hpp"
Expand Down
3 changes: 2 additions & 1 deletion src/bind.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

namespace Sass {

void bind(std::string type, std::string name, Parameters_Obj, Arguments_Obj, Env*, Eval*, Backtraces traces);
void bind(std::string type, std::string name, Parameters_Obj, Arguments_Obj, Env*, Eval*, Backtraces& traces);

}

#endif
18 changes: 7 additions & 11 deletions src/fn_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,17 @@ namespace Sass {

Map_Ptr get_arg_m(const std::string& argname, Env& env, Signature sig, ParserState pstate, Backtraces traces)
{
// Minimal error handling -- the expectation is that built-ins will be written correctly!
Map_Ptr val = Cast<Map>(env[argname]);
if (val) return val;

List_Ptr lval = Cast<List>(env[argname]);
if (lval && lval->length() == 0) return SASS_MEMORY_NEW(Map, pstate, 0);

// fallback on get_arg for error handling
val = get_arg<Map>(argname, env, sig, pstate, traces);
return val;
AST_Node_Ptr value = env[argname];
if (Map_Ptr map = Cast<Map>(value)) return map;
List_Ptr list = Cast<List>(value);
if (list && list->length() == 0) {
return SASS_MEMORY_NEW(Map, pstate, 0);
}
return get_arg<Map>(argname, env, sig, pstate, traces);
}

double get_arg_r(const std::string& argname, Env& env, Signature sig, ParserState pstate, Backtraces traces, double lo, double hi)
{
// Minimal error handling -- the expectation is that built-ins will be written correctly!
Number_Ptr val = get_arg<Number>(argname, env, sig, pstate, traces);
Number tmpnr(val);
tmpnr.reduce();
Expand Down

0 comments on commit 0c5e27c

Please sign in to comment.