diff --git a/ast.hpp b/ast.hpp index 12e3be473f..73f31e4ef7 100644 --- a/ast.hpp +++ b/ast.hpp @@ -644,8 +644,9 @@ namespace Sass { ADD_PROPERTY(Env*, environment); ADD_PROPERTY(Type, type); ADD_PROPERTY(Native_Function, native_function); - ADD_PROPERTY(Sass_C_Function, c_function); + ADD_PROPERTY(Sass_Function_Entry, c_cb); ADD_PROPERTY(void*, cookie); + ADD_PROPERTY(Context*, ctx); ADD_PROPERTY(bool, is_overload_stub); ADD_PROPERTY(Signature, signature); public: @@ -653,6 +654,7 @@ namespace Sass { string n, Parameters* params, Block* b, + Context* ctx, Type t) : Has_Block(pstate, b), name_(n), @@ -660,8 +662,9 @@ namespace Sass { environment_(0), type_(t), native_function_(0), - c_function_(0), + c_cb_(0), cookie_(0), + ctx_(ctx), is_overload_stub_(false), signature_(0) { } @@ -670,6 +673,7 @@ namespace Sass { string n, Parameters* params, Native_Function func_ptr, + Context* ctx, bool overload_stub = false) : Has_Block(pstate, 0), name_(n), @@ -677,8 +681,9 @@ namespace Sass { environment_(0), type_(FUNCTION), native_function_(func_ptr), - c_function_(0), + c_cb_(0), cookie_(0), + ctx_(ctx), is_overload_stub_(overload_stub), signature_(sig) { } @@ -686,8 +691,8 @@ namespace Sass { Signature sig, string n, Parameters* params, - Sass_C_Function func_ptr, - void* cookie, + Sass_Function_Entry c_func, + Context* ctx, bool whatever, bool whatever2) : Has_Block(pstate, 0), @@ -696,8 +701,9 @@ namespace Sass { environment_(0), type_(FUNCTION), native_function_(0), - c_function_(func_ptr), - cookie_(cookie), + c_cb_(c_func), + cookie_(sass_function_get_cookie(c_func)), + ctx_(ctx), is_overload_stub_(false), signature_(sig) { } diff --git a/context.cpp b/context.cpp index 3ee3c9fce8..880bedb321 100644 --- a/context.cpp +++ b/context.cpp @@ -50,12 +50,14 @@ namespace Sass { this->source = source; } - inline bool sort_importers (const Sass_C_Importer_Call& i, const Sass_C_Importer_Call& j) + inline bool sort_importers (const Sass_Importer_Entry& i, const Sass_Importer_Entry& j) { return sass_importer_get_priority(i) < sass_importer_get_priority(j); } Context::Context(Context::Data initializers) : // Output(this), mem(Memory_Manager()), + c_options (initializers.c_options()), + c_compiler (initializers.c_compiler()), source_c_str (initializers.source_c_str()), sources (vector()), plugin_paths (initializers.plugin_paths()), @@ -63,8 +65,8 @@ namespace Sass { queue (vector()), style_sheets (map()), emitter (this), - c_functions (vector()), - c_importers (vector()), + c_functions (vector()), + c_importers (vector()), indent (initializers.indent()), linefeed (initializers.linefeed()), input_path (make_canonical_path(initializers.input_path())), @@ -123,11 +125,11 @@ namespace Sass { } - void Context::add_c_function(Sass_C_Function_Call function) + void Context::add_c_function(Sass_Function_Entry function) { c_functions.push_back(function); } - void Context::add_c_importer(Sass_C_Importer_Call importer) + void Context::add_c_importer(Sass_Importer_Entry importer) { c_importers.push_back(importer); // need to sort the array afterwards (no big deal) @@ -279,8 +281,8 @@ namespace Sass { void register_function(Context&, Signature sig, Native_Function f, size_t arity, Env* env); void register_overload_stub(Context&, string name, Env* env); void register_built_in_functions(Context&, Env* env); - void register_c_functions(Context&, Env* env, Sass_C_Function_List); - void register_c_function(Context&, Env* env, Sass_C_Function_Call); + void register_c_functions(Context&, Env* env, Sass_Function_List); + void register_c_function(Context&, Env* env, Sass_Function_Entry); char* Context::compile_block(Block* root) { @@ -299,7 +301,7 @@ namespace Sass { { Block* root = 0; for (size_t i = 0; i < queue.size(); ++i) { - struct Sass_Import* import = sass_make_import( + Sass_Import_Entry import = sass_make_import( queue[i].load_path.c_str(), queue[i].abs_path.c_str(), 0, 0 @@ -427,6 +429,7 @@ namespace Sass { name, 0, 0, + &ctx, true); (*env)[name + "[f]"] = stub; } @@ -525,21 +528,16 @@ namespace Sass { register_function(ctx, unique_id_sig, unique_id, env); } - void register_c_functions(Context& ctx, Env* env, Sass_C_Function_List descrs) + void register_c_functions(Context& ctx, Env* env, Sass_Function_List descrs) { while (descrs && *descrs) { register_c_function(ctx, env, *descrs); ++descrs; } } - void register_c_function(Context& ctx, Env* env, Sass_C_Function_Call descr) + void register_c_function(Context& ctx, Env* env, Sass_Function_Entry descr) { - Definition* def = make_c_function( - sass_function_get_signature(descr), - sass_function_get_function(descr), - sass_function_get_cookie(descr), - ctx - ); + Definition* def = make_c_function(descr, ctx); def->environment(env); (*env)[def->name() + "[f]"] = def; } diff --git a/context.hpp b/context.hpp index a0bf28d353..f5ba38db1b 100644 --- a/context.hpp +++ b/context.hpp @@ -18,7 +18,7 @@ #include "plugins.hpp" #include "sass_functions.h" -struct Sass_C_Function_Descriptor; +struct Sass_Function; namespace Sass { using namespace std; @@ -34,6 +34,8 @@ namespace Sass { public: Memory_Manager mem; + struct Sass_Options* c_options; + struct Sass_Compiler* c_compiler; const char* source_c_str; // c-strs containing Sass file contents @@ -52,11 +54,11 @@ namespace Sass { // SourceMap source_map; Output emitter; - vector c_functions; - vector c_importers; + vector c_functions; + vector c_importers; - void add_c_function(Sass_C_Function_Call function); - void add_c_importer(Sass_C_Importer_Call importer); + void add_c_function(Sass_Function_Entry function); + void add_c_importer(Sass_Importer_Entry importer); string indent; // String to be used for indentation string linefeed; // String to be used for line feeds @@ -72,7 +74,7 @@ namespace Sass { bool is_indented_syntax_src; // treat source string as sass // overload import calls - vector import_stack; + vector import_stack; map names_to_colors; map colors_to_names; @@ -80,6 +82,8 @@ namespace Sass { size_t precision; // precision for outputting fractional numbers KWD_ARG_SET(Data) { + KWD_ARG(Data, struct Sass_Options*, c_options); + KWD_ARG(Data, struct Sass_Compiler*, c_compiler); KWD_ARG(Data, const char*, source_c_str); KWD_ARG(Data, string, entry_point); KWD_ARG(Data, string, input_path); diff --git a/contrib/plugin.cpp b/contrib/plugin.cpp index ec765f4a33..1c676f865b 100644 --- a/contrib/plugin.cpp +++ b/contrib/plugin.cpp @@ -6,25 +6,52 @@ // gcc: g++ -shared plugin.cpp -o plugin.so -fPIC -Llib -lsass // mingw: g++ -shared plugin.cpp -o plugin.dll -Llib -lsass -union Sass_Value* call_fn_foo(const union Sass_Value* s_args, void* cookie) +extern "C" const char* ADDCALL libsass_get_version() { + return libsass_version(); +} + +union Sass_Value* custom_function(const union Sass_Value* s_args, Sass_Function_Entry cb, struct Sass_Options* opts) { + // get the cookie from function descriptor + void* cookie = sass_function_get_cookie(cb); // we actually abuse the void* to store an "int" return sass_make_number((intptr_t)cookie, "px"); } -extern "C" const char* ADDCALL libsass_get_version() { - return libsass_version(); +extern "C" Sass_Function_List ADDCALL libsass_load_functions() +{ + // allocate a custom function caller + Sass_Function_Entry c_func = + sass_make_function("foo()", custom_function, (void*)42); + // create list of all custom functions + Sass_Function_List fn_list = sass_make_function_list(1); + // put the only function in this plugin to the list + sass_function_set_list_entry(fn_list, 0, c_func); + // return the list + return fn_list; } -extern "C" Sass_C_Function_List ADDCALL libsass_load_functions() +Sass_Import_List custom_importer(const char* cur_path, Sass_Importer_Entry cb, struct Sass_Compiler* comp) +{ + // get the cookie from importer descriptor + void* cookie = sass_importer_get_cookie(cb); + // create a list to hold our import entries + Sass_Import_List incs = sass_make_import_list(1); + // create our only import entry (route path back) + incs[0] = sass_make_import_entry(cur_path, 0, 0); + // return imports + return incs; +} + +extern "C" Sass_Importer_List ADDCALL libsass_load_importers() { // allocate a custom function caller - Sass_C_Function_Call fn_foo = - sass_make_function("foo()", call_fn_foo, (void*)42); + Sass_Importer_Entry c_imp = + sass_make_importer(custom_importer, - 99, (void*)42); // create list of all custom functions - Sass_C_Function_List fn_list = sass_make_function_list(1); + Sass_Importer_List imp_list = sass_make_importer_list(1); // put the only function in this plugin to the list - sass_function_set_list_entry(fn_list, 0, fn_foo); + sass_importer_set_list_entry(imp_list, 0, c_imp); // return the list - return fn_list; + return imp_list; } diff --git a/eval.cpp b/eval.cpp index bca02c2da0..94db9f20d9 100644 --- a/eval.cpp +++ b/eval.cpp @@ -256,12 +256,13 @@ namespace Sass { Definition* def = static_cast((*env)["@warn[f]"]); // Block* body = def->block(); // Native_Function func = def->native_function(); - Sass_C_Function c_func = def->c_function(); + Sass_Function_Entry c_cb = def->c_cb(); + Sass_Function_Fn c_func = sass_function_get_function(c_cb); To_C to_c; union Sass_Value* c_args = sass_make_list(1, SASS_COMMA); sass_list_set_value(c_args, 0, message->perform(&to_c)); - Sass_Value* c_val = c_func(c_args, def->cookie()); + Sass_Value* c_val = c_func(c_args, c_cb, ctx.c_options); sass_delete_value(c_args); sass_delete_value(c_val); return 0; @@ -287,12 +288,13 @@ namespace Sass { Definition* def = static_cast((*env)["@error[f]"]); // Block* body = def->block(); // Native_Function func = def->native_function(); - Sass_C_Function c_func = def->c_function(); + Sass_Function_Entry c_cb = def->c_cb(); + Sass_Function_Fn c_func = sass_function_get_function(c_cb); To_C to_c; union Sass_Value* c_args = sass_make_list(1, SASS_COMMA); sass_list_set_value(c_args, 0, message->perform(&to_c)); - Sass_Value* c_val = c_func(c_args, def->cookie()); + Sass_Value* c_val = c_func(c_args, c_cb, ctx.c_options); sass_delete_value(c_args); sass_delete_value(c_val); return 0; @@ -315,12 +317,13 @@ namespace Sass { Definition* def = static_cast((*env)["@debug[f]"]); // Block* body = def->block(); // Native_Function func = def->native_function(); - Sass_C_Function c_func = def->c_function(); + Sass_Function_Entry c_cb = def->c_cb(); + Sass_Function_Fn c_func = sass_function_get_function(c_cb); To_C to_c; union Sass_Value* c_args = sass_make_list(1, SASS_COMMA); sass_list_set_value(c_args, 0, message->perform(&to_c)); - Sass_Value* c_val = c_func(c_args, def->cookie()); + Sass_Value* c_val = c_func(c_args, c_cb, ctx.c_options); sass_delete_value(c_args); sass_delete_value(c_val); return 0; @@ -500,7 +503,7 @@ namespace Sass { Definition* def = static_cast((*env)[full_name]); Block* body = def->block(); Native_Function func = def->native_function(); - Sass_C_Function c_func = def->c_function(); + Sass_Function_Entry c_cb = def->c_cb(); if (full_name != "if[f]") { for (size_t i = 0, L = args->length(); i < L; ++i) { @@ -551,8 +554,9 @@ namespace Sass { env = old_env; } // else if it's a user-defined c function - else if (c_func) { + else if (c_cb) { + Sass_Function_Fn c_func = sass_function_get_function(c_cb); if (full_name == "*[f]") { String_Constant *str = new (ctx.mem) String_Constant(c->pstate(), c->name()); Arguments* new_args = new (ctx.mem) Arguments(c->pstate()); @@ -577,7 +581,7 @@ namespace Sass { Expression* arg = static_cast(node); sass_list_set_value(c_args, i, arg->perform(&to_c)); } - Sass_Value* c_val = c_func(c_args, def->cookie()); + Sass_Value* c_val = c_func(c_args, c_cb, ctx.c_options); if (sass_value_get_tag(c_val) == SASS_ERROR) { error("error in C function " + c->name() + ": " + sass_error_get_message(c_val), c->pstate(), backtrace); } else if (sass_value_get_tag(c_val) == SASS_WARNING) { diff --git a/expand.cpp b/expand.cpp index dd08dc69b9..9b9c19b874 100644 --- a/expand.cpp +++ b/expand.cpp @@ -497,6 +497,7 @@ namespace Sass { "@content", new (ctx.mem) Parameters(c->pstate()), c->block(), + &ctx, Definition::MIXIN); thunk->environment(env); new_env.local_frame()["@content[m]"] = thunk; diff --git a/functions.cpp b/functions.cpp index 24a5164751..7d09241780 100644 --- a/functions.cpp +++ b/functions.cpp @@ -35,7 +35,7 @@ namespace Sass { using std::stringstream; using std::endl; - Definition* make_native_function(Signature sig, Native_Function f, Context& ctx) + Definition* make_native_function(Signature sig, Native_Function func, Context& ctx) { Parser sig_parser = Parser::from_c_str(sig, ctx, ParserState("[built-in function]")); sig_parser.lex(); @@ -45,12 +45,14 @@ namespace Sass { sig, name, params, - f, + func, + &ctx, false); } - Definition* make_c_function(Signature sig, Sass_C_Function f, void* cookie, Context& ctx) + Definition* make_c_function(Sass_Function_Entry c_func, Context& ctx) { + const char* sig = sass_function_get_signature(c_func); Parser sig_parser = Parser::from_c_str(sig, ctx, ParserState("[c function]")); // allow to overload generic callback plus @warn, @error and @debug with custom functions sig_parser.lex < alternatives < identifier, exactly <'*'>, @@ -64,8 +66,8 @@ namespace Sass { sig, name, params, - f, - cookie, + c_func, + &ctx, false, true); } diff --git a/functions.hpp b/functions.hpp index b8498c33c1..4d825c1915 100644 --- a/functions.hpp +++ b/functions.hpp @@ -20,8 +20,8 @@ namespace Sass { typedef const char* Signature; typedef Expression* (*Native_Function)(Env&, Env&, Context&, Signature, ParserState, Backtrace*); - Definition* make_native_function(Signature, Native_Function, Context&); - Definition* make_c_function(Signature sig, Sass_C_Function f, void* cookie, Context& ctx); + Definition* make_native_function(Signature, Native_Function, Context& ctx); + Definition* make_c_function(Sass_Function_Entry c_func, Context& ctx); namespace Functions { diff --git a/parser.cpp b/parser.cpp index 49afcb0f71..8bb55097c5 100644 --- a/parser.cpp +++ b/parser.cpp @@ -203,20 +203,17 @@ namespace Sass { if (lex< quoted_string >()) { string import_path(lexed); bool has_custom_import = false; - Sass_Import* current = ctx.import_stack.back(); - const char* cur_path = sass_import_get_path(current); string load_path = unquote(import_path); for (auto importer : ctx.c_importers) { if (has_custom_import) break; - Sass_C_Importer fn = sass_importer_get_function(importer); + Sass_Importer_Fn fn = sass_importer_get_function(importer); // int priority = sass_importer_get_priority(importer); - void* cookie = sass_importer_get_cookie(importer); - if (struct Sass_Import** includes = - fn(load_path.c_str(), cur_path, cookie) + if (Sass_Import_List includes = + fn(load_path.c_str(), importer, ctx.c_compiler) ) { - struct Sass_Import** list = includes; + Sass_Import_List list = includes; while (*includes) { - struct Sass_Import* include = *includes; + Sass_Import_Entry include = *includes; const char *file = sass_import_get_path(include); char* source = sass_import_take_source(include); size_t line = sass_import_get_error_line(include); @@ -280,7 +277,7 @@ namespace Sass { else stack.push_back(function_def); Block* body = parse_block(); stack.pop_back(); - Definition* def = new (ctx.mem) Definition(source_position_of_def, name, params, body, which_type); + Definition* def = new (ctx.mem) Definition(source_position_of_def, name, params, body, &ctx, which_type); return def; } diff --git a/plugins.cpp b/plugins.cpp index e670bd1500..d12a835dfb 100644 --- a/plugins.cpp +++ b/plugins.cpp @@ -45,8 +45,8 @@ namespace Sass { { typedef const char* (*__plugin_version__)(void); - typedef Sass_C_Function_List (*__plugin_load_fns__)(void); - typedef Sass_C_Importer_List (*__plugin_load_imps__)(void); + typedef Sass_Function_List (*__plugin_load_fns__)(void); + typedef Sass_Importer_List (*__plugin_load_imps__)(void); if (LOAD_LIB(plugin, path)) { @@ -58,13 +58,13 @@ namespace Sass { // try to get import address for "libsass_load_functions" if (LOAD_LIB_FN(__plugin_load_fns__, plugin_load_functions, "libsass_load_functions")) { - Sass_C_Function_List fns = plugin_load_functions(); + Sass_Function_List fns = plugin_load_functions(); while (fns && *fns) { functions.push_back(*fns); ++ fns; } } // try to get import address for "libsass_load_importers" if (LOAD_LIB_FN(__plugin_load_imps__, plugin_load_importers, "libsass_load_importers")) { - Sass_C_Importer_List imps = plugin_load_importers(); + Sass_Importer_List imps = plugin_load_importers(); while (imps && *imps) { importers.push_back(*imps); ++ imps; } } // success diff --git a/plugins.hpp b/plugins.hpp index a0abb0806a..87497d68c4 100644 --- a/plugins.hpp +++ b/plugins.hpp @@ -42,12 +42,12 @@ namespace Sass { size_t load_plugins(const string& path); public: // public accessors - const vector get_importers(void) { return importers; }; - const vector get_functions(void) { return functions; }; + const vector get_importers(void) { return importers; }; + const vector get_functions(void) { return functions; }; private: // private vars - vector importers; - vector functions; + vector importers; + vector functions; }; diff --git a/sass_context.cpp b/sass_context.cpp index deee53fa3b..98cb15bfac 100644 --- a/sass_context.cpp +++ b/sass_context.cpp @@ -14,6 +14,7 @@ #include "context.hpp" #include "sass_values.h" #include "sass_context.h" +#include "ast_fwd_decl.hpp" #include "error_handling.hpp" extern "C" { @@ -99,10 +100,10 @@ extern "C" { char* source_map_root; // Custom functions that can be called from sccs code - Sass_C_Function_List c_functions; + Sass_Function_List c_functions; // Callback to overload imports - Sass_C_Importer_List c_importers; + Sass_Importer_List c_importers; }; @@ -151,13 +152,6 @@ extern "C" { }; - // Compiler states - enum Sass_Compiler_State { - SASS_COMPILER_CREATED, - SASS_COMPILER_PARSED, - SASS_COMPILER_EXECUTED - }; - // link c and cpp context struct Sass_Compiler { // progress status @@ -165,9 +159,9 @@ extern "C" { // original c context Sass_Context* c_ctx; // Sass::Context - void* cpp_ctx; + Context* cpp_ctx; // Sass::Block - void* root; + Block* root; }; static void copy_options(struct Sass_Options* to, struct Sass_Options* from) { *to = *from; } @@ -389,7 +383,9 @@ extern "C" { } // transfer the options to c++ - cpp_opt.input_path(input_path) + cpp_opt.c_compiler(0) + .c_options(c_ctx) + .input_path(input_path) .output_path(output_path) .output_style((Output_Style) c_ctx->output_style) .is_indented_syntax_src(c_ctx->is_indented_syntax_src) @@ -405,9 +401,9 @@ extern "C" { // .plugin_paths_array(plugin_paths) .include_paths(vector()) .plugin_paths(vector()) - .precision(c_ctx->precision ? c_ctx->precision : 5) - .linefeed(c_ctx->linefeed ? c_ctx->linefeed : LFEED) - .indent(c_ctx->indent ? c_ctx->indent : " "); + .precision(c_ctx->precision) + .linefeed(c_ctx->linefeed) + .indent(c_ctx->indent); // create new c++ Context Context* cpp_ctx = new Context(cpp_opt); @@ -525,9 +521,19 @@ extern "C" { return c_ctx->error_status; } + inline void init_options (struct Sass_Options* options) + { + options->precision = 5; + options->indent = " "; + options->linefeed = LFEED; + } + Sass_Options* ADDCALL sass_make_options (void) { - return (struct Sass_Options*) calloc(1, sizeof(struct Sass_Options)); + struct Sass_Options* options = (struct Sass_Options*) calloc(1, sizeof(struct Sass_Options)); + if (options == 0) { cerr << "Error allocating memory for options" << endl; return 0; } + init_options(options); + return options; } Sass_File_Context* ADDCALL sass_make_file_context(const char* input_path) @@ -535,6 +541,7 @@ extern "C" { struct Sass_File_Context* ctx = (struct Sass_File_Context*) calloc(1, sizeof(struct Sass_File_Context)); if (ctx == 0) { cerr << "Error allocating memory for file context" << endl; return 0; } ctx->type = SASS_CONTEXT_FILE; + init_options(ctx); try { if (input_path == 0) { throw(runtime_error("File context created without an input path")); } if (*input_path == 0) { throw(runtime_error("File context created with empty input path")); } @@ -550,6 +557,7 @@ extern "C" { struct Sass_Data_Context* ctx = (struct Sass_Data_Context*) calloc(1, sizeof(struct Sass_Data_Context)); if (ctx == 0) { cerr << "Error allocating memory for data context" << endl; return 0; } ctx->type = SASS_CONTEXT_DATA; + init_options(ctx); try { if (source_string == 0) { throw(runtime_error("Data context created without a source string")); } if (*source_string == 0) { throw(runtime_error("Data context created with empty source string")); } @@ -570,6 +578,7 @@ extern "C" { Context::Data cpp_opt = Context::Data(); cpp_opt.entry_point(c_ctx->input_path); compiler->cpp_ctx = sass_prepare_context(c_ctx, cpp_opt); + compiler->cpp_ctx->c_compiler = compiler; return compiler; } @@ -583,6 +592,7 @@ extern "C" { Context::Data cpp_opt = Context::Data(); cpp_opt.source_c_str(c_ctx->source_string); compiler->cpp_ctx = sass_prepare_context(c_ctx, cpp_opt); + compiler->cpp_ctx->c_compiler = compiler; return compiler; } @@ -664,7 +674,7 @@ extern "C" { if (options == 0) return; // Deallocate custom functions if (options->c_functions) { - struct Sass_C_Function_Descriptor** this_func_data = options->c_functions; + struct Sass_Function** this_func_data = options->c_functions; while (this_func_data && *this_func_data) { free(*this_func_data); ++this_func_data; @@ -672,7 +682,7 @@ extern "C" { } // Deallocate custom importers if (options->c_importers) { - struct Sass_C_Importer_Descriptor** this_imp_data = options->c_importers; + struct Sass_Importer** this_imp_data = options->c_importers; while (this_imp_data && *this_imp_data) { free(*this_imp_data); ++this_imp_data; @@ -772,6 +782,14 @@ extern "C" { void ADDCALL sass_file_context_set_options (struct Sass_File_Context* ctx, struct Sass_Options* opt) { copy_options(ctx, opt); } void ADDCALL sass_data_context_set_options (struct Sass_Data_Context* ctx, struct Sass_Options* opt) { copy_options(ctx, opt); } + // Getters for Sass_Compiler options (get conected sass context) + enum Sass_Compiler_State ADDCALL sass_compiler_get_state(struct Sass_Compiler* compiler) { return compiler->state; } + struct Sass_Context* ADDCALL sass_compiler_get_context(struct Sass_Compiler* compiler) { return compiler->c_ctx; } + // Getters for Sass_Compiler options (query import stack) + size_t ADDCALL sass_compiler_get_import_stack_size(struct Sass_Compiler* compiler) { return compiler->cpp_ctx->import_stack.size(); } + Sass_Import_Entry ADDCALL sass_compiler_get_last_import(struct Sass_Compiler* compiler) { return compiler->cpp_ctx->import_stack.back(); } + Sass_Import_Entry ADDCALL sass_compiler_get_import_entry(struct Sass_Compiler* compiler, size_t idx) { return compiler->cpp_ctx->import_stack[idx]; } + // Create getter and setters for options IMPLEMENT_SASS_OPTION_ACCESSOR(int, precision); IMPLEMENT_SASS_OPTION_ACCESSOR(enum Sass_Output_Style, output_style); @@ -780,8 +798,8 @@ extern "C" { IMPLEMENT_SASS_OPTION_ACCESSOR(bool, source_map_contents); IMPLEMENT_SASS_OPTION_ACCESSOR(bool, omit_source_map_url); IMPLEMENT_SASS_OPTION_ACCESSOR(bool, is_indented_syntax_src); - IMPLEMENT_SASS_OPTION_ACCESSOR(Sass_C_Function_List, c_functions); - IMPLEMENT_SASS_OPTION_ACCESSOR(Sass_C_Importer_List, c_importers); + IMPLEMENT_SASS_OPTION_ACCESSOR(Sass_Function_List, c_functions); + IMPLEMENT_SASS_OPTION_ACCESSOR(Sass_Importer_List, c_importers); IMPLEMENT_SASS_OPTION_ACCESSOR(const char*, indent); IMPLEMENT_SASS_OPTION_ACCESSOR(const char*, linefeed); IMPLEMENT_SASS_OPTION_STRING_ACCESSOR(const char*, input_path); diff --git a/sass_context.h b/sass_context.h index 89b744d3e3..b4f5a7fe4a 100644 --- a/sass_context.h +++ b/sass_context.h @@ -14,11 +14,18 @@ extern "C" { struct Sass_Compiler; // Forward declaration -struct Sass_Options; +struct Sass_Options; // base struct struct Sass_Context; // : Sass_Options struct Sass_File_Context; // : Sass_Context struct Sass_Data_Context; // : Sass_Context +// Compiler states +enum Sass_Compiler_State { + SASS_COMPILER_CREATED, + SASS_COMPILER_PARSED, + SASS_COMPILER_EXECUTED +}; + // Create and initialize an option struct ADDAPI struct Sass_Options* ADDCALL sass_make_options (void); // Create and initialize a specific context @@ -74,8 +81,8 @@ ADDAPI const char* ADDCALL sass_option_get_plugin_path (struct Sass_Options* opt ADDAPI const char* ADDCALL sass_option_get_include_path (struct Sass_Options* options); ADDAPI const char* ADDCALL sass_option_get_source_map_file (struct Sass_Options* options); ADDAPI const char* ADDCALL sass_option_get_source_map_root (struct Sass_Options* options); -ADDAPI Sass_C_Function_List ADDCALL sass_option_get_c_functions (struct Sass_Options* options); -ADDAPI Sass_C_Importer_List ADDCALL sass_option_get_c_importers (struct Sass_Options* options); +ADDAPI Sass_Function_List ADDCALL sass_option_get_c_functions (struct Sass_Options* options); +ADDAPI Sass_Importer_List ADDCALL sass_option_get_c_importers (struct Sass_Options* options); // Setters for Context_Option values ADDAPI void ADDCALL sass_option_set_precision (struct Sass_Options* options, int precision); @@ -93,8 +100,8 @@ ADDAPI void ADDCALL sass_option_set_plugin_path (struct Sass_Options* options, c ADDAPI void ADDCALL sass_option_set_include_path (struct Sass_Options* options, const char* include_path); ADDAPI void ADDCALL sass_option_set_source_map_file (struct Sass_Options* options, const char* source_map_file); ADDAPI void ADDCALL sass_option_set_source_map_root (struct Sass_Options* options, const char* source_map_root); -ADDAPI void ADDCALL sass_option_set_c_functions (struct Sass_Options* options, Sass_C_Function_List c_functions); -ADDAPI void ADDCALL sass_option_set_c_importers (struct Sass_Options* options, Sass_C_Importer_List c_importers); +ADDAPI void ADDCALL sass_option_set_c_functions (struct Sass_Options* options, Sass_Function_List c_functions); +ADDAPI void ADDCALL sass_option_set_c_importers (struct Sass_Options* options, Sass_Importer_List c_importers); // Getters for Sass_Context values @@ -119,6 +126,13 @@ ADDAPI char* ADDCALL sass_context_take_output_string (struct Sass_Context* ctx); ADDAPI char* ADDCALL sass_context_take_source_map_string (struct Sass_Context* ctx); ADDAPI char** ADDCALL sass_context_take_included_files (struct Sass_Context* ctx); +// Getters for Sass_Compiler options +ADDAPI enum Sass_Compiler_State ADDCALL sass_compiler_get_state(struct Sass_Compiler* compiler); +ADDAPI struct Sass_Context* ADDCALL sass_compiler_get_context(struct Sass_Compiler* compiler); +ADDAPI size_t ADDCALL sass_compiler_get_import_stack_size(struct Sass_Compiler* compiler); +ADDAPI Sass_Import_Entry ADDCALL sass_compiler_get_last_import(struct Sass_Compiler* compiler); +ADDAPI Sass_Import_Entry ADDCALL sass_compiler_get_import_entry(struct Sass_Compiler* compiler, size_t idx); + // Push function for paths (no manipulation support for now) ADDAPI void ADDCALL sass_option_push_plugin_path (struct Sass_Options* options, const char* path); ADDAPI void ADDCALL sass_option_push_include_path (struct Sass_Options* options, const char* path); diff --git a/sass_functions.cpp b/sass_functions.cpp index 87d644c11e..3905fd66d3 100644 --- a/sass_functions.cpp +++ b/sass_functions.cpp @@ -14,20 +14,20 @@ extern "C" { using namespace Sass; // Struct to hold custom function callback - struct Sass_C_Function_Descriptor { - const char* signature; - Sass_C_Function function; - void* cookie; + struct Sass_Function { + const char* signature; + Sass_Function_Fn function; + void* cookie; }; - Sass_C_Function_List ADDCALL sass_make_function_list(size_t length) + Sass_Function_List ADDCALL sass_make_function_list(size_t length) { - return (Sass_C_Function_List) calloc(length + 1, sizeof(Sass_C_Function_Call)); + return (Sass_Function_List) calloc(length + 1, sizeof(Sass_Function_Entry)); } - Sass_C_Function_Call ADDCALL sass_make_function(const char* signature, Sass_C_Function function, void* cookie) + Sass_Function_Entry ADDCALL sass_make_function(const char* signature, Sass_Function_Fn function, void* cookie) { - Sass_C_Function_Call cb = (Sass_C_Function_Call) calloc(1, sizeof(Sass_C_Function_Descriptor)); + Sass_Function_Entry cb = (Sass_Function_Entry) calloc(1, sizeof(Sass_Function)); if (cb == 0) return 0; cb->signature = signature; cb->function = function; @@ -36,12 +36,12 @@ extern "C" { } // Setters and getters for callbacks on function lists - Sass_C_Function_Call ADDCALL sass_function_get_list_entry(Sass_C_Function_List list, size_t pos) { return list[pos]; } - void sass_function_set_list_entry(Sass_C_Function_List list, size_t pos, Sass_C_Function_Call cb) { list[pos] = cb; } + Sass_Function_Entry ADDCALL sass_function_get_list_entry(Sass_Function_List list, size_t pos) { return list[pos]; } + void sass_function_set_list_entry(Sass_Function_List list, size_t pos, Sass_Function_Entry cb) { list[pos] = cb; } - const char* ADDCALL sass_function_get_signature(Sass_C_Function_Call cb) { return cb->signature; } - Sass_C_Function ADDCALL sass_function_get_function(Sass_C_Function_Call cb) { return cb->function; } - void* ADDCALL sass_function_get_cookie(Sass_C_Function_Call cb) { return cb->cookie; } + const char* ADDCALL sass_function_get_signature(Sass_Function_Entry cb) { return cb->signature; } + Sass_Function_Fn ADDCALL sass_function_get_function(Sass_Function_Entry cb) { return cb->function; } + void* ADDCALL sass_function_get_cookie(Sass_Function_Entry cb) { return cb->cookie; } // External import entry struct Sass_Import { @@ -56,15 +56,15 @@ extern "C" { }; // Struct to hold importer callback - struct Sass_C_Importer_Descriptor { - Sass_C_Importer importer; - double priority; - void* cookie; + struct Sass_Importer { + Sass_Importer_Fn importer; + double priority; + void* cookie; }; - Sass_C_Importer_Call ADDCALL sass_make_importer(Sass_C_Importer importer, double priority, void* cookie) + Sass_Importer_Entry ADDCALL sass_make_importer(Sass_Importer_Fn importer, double priority, void* cookie) { - Sass_C_Importer_Call cb = (Sass_C_Importer_Call) calloc(1, sizeof(Sass_C_Importer_Descriptor)); + Sass_Importer_Entry cb = (Sass_Importer_Entry) calloc(1, sizeof(Sass_Importer)); if (cb == 0) return 0; cb->importer = importer; cb->priority = priority; @@ -72,31 +72,31 @@ extern "C" { return cb; } - Sass_C_Importer ADDCALL sass_importer_get_function(Sass_C_Importer_Call cb) { return cb->importer; } - double ADDCALL sass_importer_get_priority (Sass_C_Importer_Call cb) { return cb->priority; } - void* ADDCALL sass_importer_get_cookie(Sass_C_Importer_Call cb) { return cb->cookie; } + Sass_Importer_Fn ADDCALL sass_importer_get_function(Sass_Importer_Entry cb) { return cb->importer; } + double ADDCALL sass_importer_get_priority (Sass_Importer_Entry cb) { return cb->priority; } + void* ADDCALL sass_importer_get_cookie(Sass_Importer_Entry cb) { return cb->cookie; } // Just in case we have some stray import structs - void ADDCALL sass_delete_importer (Sass_C_Importer_Call cb) + void ADDCALL sass_delete_importer (Sass_Importer_Entry cb) { free(cb); } // Creator for sass custom importer function list - Sass_C_Importer_List ADDCALL sass_make_importer_list(size_t length) + Sass_Importer_List ADDCALL sass_make_importer_list(size_t length) { - return (Sass_C_Importer_List) calloc(length + 1, sizeof(Sass_C_Importer_Call)); + return (Sass_Importer_List) calloc(length + 1, sizeof(Sass_Importer_Entry)); } // Creator for sass custom importer return argument list - struct Sass_Import** ADDCALL sass_make_import_list(size_t length) + Sass_Import_List ADDCALL sass_make_import_list(size_t length) { return (Sass_Import**) calloc(length + 1, sizeof(Sass_Import*)); } // Creator for a single import entry returned by the custom importer inside the list // We take ownership of the memory for source and srcmap (freed when context is destroyd) - struct Sass_Import* ADDCALL sass_make_import(const char* path, const char* base, char* source, char* srcmap) + Sass_Import_Entry ADDCALL sass_make_import(const char* path, const char* base, char* source, char* srcmap) { Sass_Import* v = (Sass_Import*) calloc(1, sizeof(Sass_Import)); if (v == 0) return 0; @@ -111,13 +111,13 @@ extern "C" { } // Older style, but somehow still valid - keep around or deprecate? - struct Sass_Import* ADDCALL sass_make_import_entry(const char* path, char* source, char* srcmap) + Sass_Import_Entry ADDCALL sass_make_import_entry(const char* path, char* source, char* srcmap) { return sass_make_import(path, path, source, srcmap); } // Upgrade a normal import entry to throw an error (original path can be re-used by error reporting) - struct Sass_Import* ADDCALL sass_import_set_error(struct Sass_Import* import, const char* error, size_t line, size_t col) + Sass_Import_Entry ADDCALL sass_import_set_error(Sass_Import_Entry import, const char* error, size_t line, size_t col) { if (import == 0) return 0; if (import->error) free(import->error); @@ -128,13 +128,13 @@ extern "C" { } // Setters and getters for entries on the import list - void ADDCALL sass_import_set_list_entry(struct Sass_Import** list, size_t idx, struct Sass_Import* entry) { list[idx] = entry; } - struct Sass_Import* ADDCALL sass_import_get_list_entry(struct Sass_Import** list, size_t idx) { return list[idx]; } + void ADDCALL sass_import_set_list_entry(Sass_Import_List list, size_t idx, Sass_Import_Entry entry) { list[idx] = entry; } + Sass_Import_Entry ADDCALL sass_import_get_list_entry(Sass_Import_List list, size_t idx) { return list[idx]; } // Deallocator for the allocated memory - void ADDCALL sass_delete_import_list(struct Sass_Import** list) + void ADDCALL sass_delete_import_list(Sass_Import_List list) { - struct Sass_Import** it = list; + Sass_Import_List it = list; if (list == 0) return; while(*list) { sass_delete_import(*list); @@ -144,7 +144,7 @@ extern "C" { } // Just in case we have some stray import structs - void ADDCALL sass_delete_import(struct Sass_Import* import) + void ADDCALL sass_delete_import(Sass_Import_Entry import) { free(import->path); free(import->base); @@ -155,19 +155,19 @@ extern "C" { } // Getter for import entry - const char* ADDCALL sass_import_get_path(struct Sass_Import* entry) { return entry->path; } - const char* ADDCALL sass_import_get_base(struct Sass_Import* entry) { return entry->base; } - const char* ADDCALL sass_import_get_source(struct Sass_Import* entry) { return entry->source; } - const char* ADDCALL sass_import_get_srcmap(struct Sass_Import* entry) { return entry->srcmap; } + const char* ADDCALL sass_import_get_path(Sass_Import_Entry entry) { return entry->path; } + const char* ADDCALL sass_import_get_base(Sass_Import_Entry entry) { return entry->base; } + const char* ADDCALL sass_import_get_source(Sass_Import_Entry entry) { return entry->source; } + const char* ADDCALL sass_import_get_srcmap(Sass_Import_Entry entry) { return entry->srcmap; } // Getter for import error entry - size_t ADDCALL sass_import_get_error_line(struct Sass_Import* entry) { return entry->line; } - size_t ADDCALL sass_import_get_error_column(struct Sass_Import* entry) { return entry->column; } - const char* ADDCALL sass_import_get_error_message(struct Sass_Import* entry) { return entry->error; } + size_t ADDCALL sass_import_get_error_line(Sass_Import_Entry entry) { return entry->line; } + size_t ADDCALL sass_import_get_error_column(Sass_Import_Entry entry) { return entry->column; } + const char* ADDCALL sass_import_get_error_message(Sass_Import_Entry entry) { return entry->error; } // Explicit functions to take ownership of the memory // Resets our own property since we do not know if it is still alive - char* ADDCALL sass_import_take_source(struct Sass_Import* entry) { char* ptr = entry->source; entry->source = 0; return ptr; } - char* ADDCALL sass_import_take_srcmap(struct Sass_Import* entry) { char* ptr = entry->srcmap; entry->srcmap = 0; return ptr; } + char* ADDCALL sass_import_take_source(Sass_Import_Entry entry) { char* ptr = entry->source; entry->source = 0; return ptr; } + char* ADDCALL sass_import_take_srcmap(Sass_Import_Entry entry) { char* ptr = entry->srcmap; entry->srcmap = 0; return ptr; } } diff --git a/sass_functions.h b/sass_functions.h index be9a77e8d8..7549f83b68 100644 --- a/sass_functions.h +++ b/sass_functions.h @@ -12,86 +12,93 @@ extern "C" { // Forward declaration struct Sass_Import; +struct Sass_Options; +struct Sass_Compiler; +struct Sass_Importer; +struct Sass_Function; + +// Typedef helpers for import lists +typedef struct Sass_Import (*Sass_Import_Entry); +typedef struct Sass_Import* (*Sass_Import_List); +// Typedef helpers for custom importer lists +typedef struct Sass_Importer (*Sass_Importer_Entry); +typedef struct Sass_Importer* (*Sass_Importer_List); +// Typedef defining importer signature and return type +typedef Sass_Import_List (*Sass_Importer_Fn) + (const char* url, Sass_Importer_Entry cb, struct Sass_Compiler* compiler); + +// Typedef helpers for custom functions lists +typedef struct Sass_Function (*Sass_Function_Entry); +typedef struct Sass_Function* (*Sass_Function_List); +// Typedef defining function signature and return type +typedef union Sass_Value*(*Sass_Function_Fn) + (const union Sass_Value*, Sass_Function_Entry cb, struct Sass_Options* options); -// Forward declaration -struct Sass_C_Importer_Descriptor; - -// Typedef defining the custom importer callback -typedef struct Sass_C_Importer_Descriptor (*Sass_C_Importer_Call); -typedef struct Sass_C_Importer_Descriptor* (*Sass_C_Importer_List); -// Typedef defining the importer c function prototype -typedef struct Sass_Import** (*Sass_C_Importer) (const char* url, const char* prev, void* cookie); // Creator for sass custom importer return argument list -ADDAPI Sass_C_Importer_List ADDCALL sass_make_importer_list (size_t length); +ADDAPI Sass_Importer_List ADDCALL sass_make_importer_list (size_t length); +ADDAPI Sass_Importer_Entry ADDCALL sass_importer_get_list_entry (Sass_Importer_List list, size_t idx); +ADDAPI void ADDCALL sass_importer_set_list_entry (Sass_Importer_List list, size_t idx, Sass_Importer_Entry entry); + // Creators for custom importer callback (with some additional pointer) // The pointer is mostly used to store the callback into the actual binding -ADDAPI Sass_C_Importer_Call ADDCALL sass_make_importer (Sass_C_Importer importer, double priority, void* cookie); +ADDAPI Sass_Importer_Entry ADDCALL sass_make_importer (Sass_Importer_Fn importer, double priority, void* cookie); // Getters for import function descriptors -ADDAPI Sass_C_Importer ADDCALL sass_importer_get_function (Sass_C_Importer_Call cb); -ADDAPI double ADDCALL sass_importer_get_priority (Sass_C_Importer_Call cb); -ADDAPI void* ADDCALL sass_importer_get_cookie (Sass_C_Importer_Call cb); +ADDAPI Sass_Importer_Fn ADDCALL sass_importer_get_function (Sass_Importer_Entry cb); +ADDAPI double ADDCALL sass_importer_get_priority (Sass_Importer_Entry cb); +ADDAPI void* ADDCALL sass_importer_get_cookie (Sass_Importer_Entry cb); // Deallocator for associated memory -ADDAPI void ADDCALL sass_delete_importer (Sass_C_Importer_Call cb); +ADDAPI void ADDCALL sass_delete_importer (Sass_Importer_Entry cb); // Creator for sass custom importer return argument list -ADDAPI struct Sass_Import** ADDCALL sass_make_import_list (size_t length); +ADDAPI Sass_Import_List ADDCALL sass_make_import_list (size_t length); // Creator for a single import entry returned by the custom importer inside the list -ADDAPI struct Sass_Import* ADDCALL sass_make_import_entry (const char* path, char* source, char* srcmap); -ADDAPI struct Sass_Import* ADDCALL sass_make_import (const char* path, const char* base, char* source, char* srcmap); +ADDAPI Sass_Import_Entry ADDCALL sass_make_import_entry (const char* path, char* source, char* srcmap); +ADDAPI Sass_Import_Entry ADDCALL sass_make_import (const char* path, const char* base, char* source, char* srcmap); // set error message to abort import and to print out a message (path from existing object is used in output) -ADDAPI struct Sass_Import* ADDCALL sass_import_set_error(struct Sass_Import* import, const char* message, size_t line, size_t col); +ADDAPI Sass_Import_Entry ADDCALL sass_import_set_error(Sass_Import_Entry import, const char* message, size_t line, size_t col); // Setters to insert an entry into the import list (you may also use [] access directly) // Since we are dealing with pointers they should have a guaranteed and fixed size -ADDAPI void ADDCALL sass_import_set_list_entry (struct Sass_Import** list, size_t idx, struct Sass_Import* entry); -ADDAPI struct Sass_Import* ADDCALL sass_import_get_list_entry (struct Sass_Import** list, size_t idx); +ADDAPI void ADDCALL sass_import_set_list_entry (Sass_Import_List list, size_t idx, Sass_Import_Entry entry); +ADDAPI Sass_Import_Entry ADDCALL sass_import_get_list_entry (Sass_Import_List list, size_t idx); // Getters for import entry -ADDAPI const char* ADDCALL sass_import_get_path (struct Sass_Import*); -ADDAPI const char* ADDCALL sass_import_get_base (struct Sass_Import*); -ADDAPI const char* ADDCALL sass_import_get_source (struct Sass_Import*); -ADDAPI const char* ADDCALL sass_import_get_srcmap (struct Sass_Import*); +ADDAPI const char* ADDCALL sass_import_get_path (Sass_Import_Entry); +ADDAPI const char* ADDCALL sass_import_get_base (Sass_Import_Entry); +ADDAPI const char* ADDCALL sass_import_get_source (Sass_Import_Entry); +ADDAPI const char* ADDCALL sass_import_get_srcmap (Sass_Import_Entry); // Explicit functions to take ownership of these items // The property on our struct will be reset to NULL -ADDAPI char* ADDCALL sass_import_take_source (struct Sass_Import*); -ADDAPI char* ADDCALL sass_import_take_srcmap (struct Sass_Import*); +ADDAPI char* ADDCALL sass_import_take_source (Sass_Import_Entry); +ADDAPI char* ADDCALL sass_import_take_srcmap (Sass_Import_Entry); // Getters from import error entry -ADDAPI size_t ADDCALL sass_import_get_error_line (struct Sass_Import*); -ADDAPI size_t ADDCALL sass_import_get_error_column (struct Sass_Import*); -ADDAPI const char* ADDCALL sass_import_get_error_message (struct Sass_Import*); +ADDAPI size_t ADDCALL sass_import_get_error_line (Sass_Import_Entry); +ADDAPI size_t ADDCALL sass_import_get_error_column (Sass_Import_Entry); +ADDAPI const char* ADDCALL sass_import_get_error_message (Sass_Import_Entry); // Deallocator for associated memory (incl. entries) -ADDAPI void ADDCALL sass_delete_import_list (struct Sass_Import**); +ADDAPI void ADDCALL sass_delete_import_list (Sass_Import_List); // Just in case we have some stray import structs -ADDAPI void ADDCALL sass_delete_import (struct Sass_Import*); - - -// Forward declaration -struct Sass_C_Function_Descriptor; +ADDAPI void ADDCALL sass_delete_import (Sass_Import_Entry); -// Typedef defining null terminated list of custom callbacks -typedef struct Sass_C_Function_Descriptor (*Sass_C_Function_Call); -typedef struct Sass_C_Function_Descriptor* (*Sass_C_Function_List); -// Typedef defining custom function prototype and its return value type -typedef union Sass_Value*(*Sass_C_Function) (const union Sass_Value*, void* cookie); // Creators for sass function list and function descriptors -ADDAPI Sass_C_Function_List ADDCALL sass_make_function_list (size_t length); -ADDAPI Sass_C_Function_Call ADDCALL sass_make_function (const char* signature, Sass_C_Function cb, void* cookie); +ADDAPI Sass_Function_List ADDCALL sass_make_function_list (size_t length); +ADDAPI Sass_Function_Entry ADDCALL sass_make_function (const char* signature, Sass_Function_Fn cb, void* cookie); // Setters and getters for callbacks on function lists -ADDAPI Sass_C_Function_Call ADDCALL sass_function_get_list_entry(Sass_C_Function_List list, size_t pos); -ADDAPI void ADDCALL sass_function_set_list_entry(Sass_C_Function_List list, size_t pos, Sass_C_Function_Call cb); +ADDAPI Sass_Function_Entry ADDCALL sass_function_get_list_entry(Sass_Function_List list, size_t pos); +ADDAPI void ADDCALL sass_function_set_list_entry(Sass_Function_List list, size_t pos, Sass_Function_Entry cb); // Getters for custom function descriptors -ADDAPI const char* ADDCALL sass_function_get_signature (Sass_C_Function_Call cb); -ADDAPI Sass_C_Function ADDCALL sass_function_get_function (Sass_C_Function_Call cb); -ADDAPI void* ADDCALL sass_function_get_cookie (Sass_C_Function_Call cb); +ADDAPI const char* ADDCALL sass_function_get_signature (Sass_Function_Entry cb); +ADDAPI Sass_Function_Fn ADDCALL sass_function_get_function (Sass_Function_Entry cb); +ADDAPI void* ADDCALL sass_function_get_cookie (Sass_Function_Entry cb); #ifdef __cplusplus diff --git a/sass_interface.cpp b/sass_interface.cpp index 7ba71af29c..39d375186e 100644 --- a/sass_interface.cpp +++ b/sass_interface.cpp @@ -130,7 +130,7 @@ extern "C" { .linefeed(c_ctx->options.linefeed ? c_ctx->options.linefeed : LFEED) ); if (c_ctx->c_functions) { - struct Sass_C_Function_Descriptor** this_func_data = c_ctx->c_functions; + struct Sass_Function** this_func_data = c_ctx->c_functions; while ((this_func_data) && (*this_func_data)) { cpp_ctx.c_functions.push_back(*this_func_data); ++this_func_data; @@ -220,7 +220,7 @@ extern "C" { .precision(c_ctx->options.precision ? c_ctx->options.precision : 5) ); if (c_ctx->c_functions) { - struct Sass_C_Function_Descriptor** this_func_data = c_ctx->c_functions; + struct Sass_Function** this_func_data = c_ctx->c_functions; while ((this_func_data) && (*this_func_data)) { cpp_ctx.c_functions.push_back(*this_func_data); ++this_func_data; diff --git a/sass_interface.h b/sass_interface.h index 16bc41c212..405dd68316 100644 --- a/sass_interface.h +++ b/sass_interface.h @@ -53,7 +53,7 @@ struct sass_context { struct sass_options options; int error_status; char* error_message; - Sass_C_Function_List c_functions; + Sass_Function_List c_functions; char** included_files; int num_included_files; }; @@ -66,7 +66,7 @@ struct sass_file_context { struct sass_options options; int error_status; char* error_message; - Sass_C_Function_List c_functions; + Sass_Function_List c_functions; char** included_files; int num_included_files; }; @@ -77,7 +77,7 @@ struct sass_folder_context { struct sass_options options; int error_status; char* error_message; - Sass_C_Function_List c_functions; + Sass_Function_List c_functions; char** included_files; int num_included_files; };