Skip to content

Commit

Permalink
Implements call stack queries (functions and mixins)
Browse files Browse the repository at this point in the history
  • Loading branch information
mgreter committed Dec 7, 2016
1 parent 00ec13f commit 196fbd3
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 1 deletion.
98 changes: 98 additions & 0 deletions Sass.xs
Original file line number Diff line number Diff line change
Expand Up @@ -1121,6 +1121,104 @@ get_import_imp_path(back)
OUTPUT:
RETVAL

SV*
get_callee_stack_size()
CODE:
{

SV* comp = get_sv("CSS::Sass::compiler", GV_ADDWARN);
struct Sass_Compiler* compiler = INT2PTR(struct Sass_Compiler*, SvIV(comp));
RETVAL = newSViv(sass_compiler_get_callee_stack_size(compiler));

}
OUTPUT:
RETVAL

SV*
get_callee_type(back)
size_t back
CODE:
{

SV* comp = get_sv("CSS::Sass::compiler", GV_ADDWARN);
struct Sass_Compiler* compiler = INT2PTR(struct Sass_Compiler*, SvIV(comp));
size_t idx = sass_compiler_get_callee_stack_size(compiler);
if (idx <= back) croak("Callee stack access out of boundary");
Sass_Callee_Entry entry = sass_compiler_get_callee_entry(compiler, idx - back - 1);
RETVAL = newSViv(sass_callee_get_type(entry));

}
OUTPUT:
RETVAL

SV*
get_callee_name(back)
size_t back
CODE:
{

SV* comp = get_sv("CSS::Sass::compiler", GV_ADDWARN);
struct Sass_Compiler* compiler = INT2PTR(struct Sass_Compiler*, SvIV(comp));
size_t idx = sass_compiler_get_callee_stack_size(compiler);
if (idx <= back) croak("Callee stack access out of boundary");
Sass_Callee_Entry entry = sass_compiler_get_callee_entry(compiler, idx - back - 1);
RETVAL = newSVpv(sass_callee_get_name(entry), 0);

}
OUTPUT:
RETVAL

SV*
get_callee_path(back)
size_t back
CODE:
{

SV* comp = get_sv("CSS::Sass::compiler", GV_ADDWARN);
struct Sass_Compiler* compiler = INT2PTR(struct Sass_Compiler*, SvIV(comp));
size_t idx = sass_compiler_get_callee_stack_size(compiler);
if (idx <= back) croak("Callee stack access out of boundary");
Sass_Callee_Entry entry = sass_compiler_get_callee_entry(compiler, idx - back - 1);
RETVAL = newSVpv(sass_callee_get_path(entry), 0);

}
OUTPUT:
RETVAL

SV*
get_callee_line(back)
size_t back
CODE:
{

SV* comp = get_sv("CSS::Sass::compiler", GV_ADDWARN);
struct Sass_Compiler* compiler = INT2PTR(struct Sass_Compiler*, SvIV(comp));
size_t idx = sass_compiler_get_callee_stack_size(compiler);
if (idx <= back) croak("Callee stack access out of boundary");
Sass_Callee_Entry entry = sass_compiler_get_callee_entry(compiler, idx - back - 1);
RETVAL = newSViv(sass_callee_get_line(entry));

}
OUTPUT:
RETVAL


SV*
get_callee_column(back)
size_t back
CODE:
{

SV* comp = get_sv("CSS::Sass::compiler", GV_ADDWARN);
struct Sass_Compiler* compiler = INT2PTR(struct Sass_Compiler*, SvIV(comp));
size_t idx = sass_compiler_get_callee_stack_size(compiler);
if (idx <= back) croak("Callee stack access out of boundary");
Sass_Callee_Entry entry = sass_compiler_get_callee_entry(compiler, idx - back - 1);
RETVAL = newSViv(sass_callee_get_column(entry));

}
OUTPUT:
RETVAL

SV*
libsass_version()
Expand Down
9 changes: 9 additions & 0 deletions lib/CSS/Sass.pm
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,22 @@ our @EXPORT_OK = qw(
import_sv
sass_compile
sass_compile_file
get_callee_stack_size
get_callee_type
get_callee_name
get_callee_path
get_callee_line
get_callee_column
get_import_abs_path
get_import_imp_path
get_import_stack_size
libsass_version
sass2scss_version
sass_operation
sass_stringify
SASS_CALLEE_MIXIN
SASS_CALLEE_FUNCTION
SASS_CALLEE_C_FUNCTION
SASS_COMMA
SASS_SPACE
SASS_ERROR
Expand Down

0 comments on commit 196fbd3

Please sign in to comment.