@@ -98,7 +98,7 @@ namespace Sass {
9898 // Value& val(Value::unwrap(value));
9999 // Compiler& compiler(Compiler::unwrap(comp));
100100 // compiler.setVariable(key.assertString(compiler, "name")->getText(), &val, false, false);
101- return sass_make_null () ;
101+ return value ;
102102 }
103103
104104 // so far only pow has two arguments
@@ -471,7 +471,7 @@ struct SassValue* fn_##fn(struct SassValue* s_args, Sass_Function_Entry cb, stru
471471 for (struct SassImporter * importer : importers) {
472472
473473 // Get the external importer function
474- SassImporterLambda fn = sass_importer_get_callback ( importer) ;
474+ SassImporterLambda fn = importer-> importer ;
475475
476476 // std::cerr << "Calling custom loader " << fn << "\n";
477477
@@ -735,35 +735,22 @@ struct SassValue* fn_##fn(struct SassValue* s_args, Sass_Function_Entry cb, stru
735735 // Interface for external custom functions
736736 // ///////////////////////////////////////////////////////////////////////
737737
738- // Create a new external callable from the sass function. Parses
739- // function signature into function name and argument declaration .
740- ExternalCallable* Compiler::makeExternalCallable (struct SassFunction * function)
738+ // Register an external custom sass function on the global scope.
739+ // Main entry point for custom functions passed through the C-API .
740+ void Compiler::registerCustomFunction (struct SassFunction * function)
741741 {
742- // Create temporary source object for signature
743- SourceStringObj source = SASS_MEMORY_NEW (SourceString,
744- " sass://signature" , function->signature );
745- // Create a new scss parser instance
742+ EnvRoot root (*this );
743+ SourceDataObj source = SASS_MEMORY_NEW (SourceString,
744+ " sass://signature" , sass::string (function->signature ));
746745 ScssParser parser (*this , source.ptr ());
747746 ExternalCallable* callable =
748747 parser.parseExternalCallable ();
749748 callable->function (function);
750- return callable;
751- }
752- // EO makeExternalCallable
753-
754- // Register an external custom sass function on the global scope.
755- // Main entry point for custom functions passed through the C-API.
756- void Compiler::registerCustomFunction (struct SassFunction * function)
757- {
758- // EnvRoot root(*this);
759- // Create a new external callable from the sass function
760- // ExternalCallable* callable = makeExternalCallable(function);
761- // Currently external functions are treated globally
762- // if (fnLookup.count(callable->envkey()) == 0) {
763- // fnLookup.insert(std::make_pair(callable->envkey(), callable));
764- // varRoot.createFunction(callable->envkey());
765- // fnList.push_back(callable);
766- // }
749+ auto & functions (varRoot.intFunction );
750+ uint32_t offset ((uint32_t )functions.size ());
751+ varRoot.intFunction .push_back (callable);
752+ varRoot.idxs ->fnIdxs [callable->name ()] = offset;
753+ varRoot.privateFnOffset = offset;
767754 }
768755 // EO registerCustomFunction
769756
@@ -903,7 +890,7 @@ struct SassValue* fn_##fn(struct SassValue* s_args, Sass_Function_Entry cb, stru
903890
904891 // registerCustomFunction(qwe);
905892
906- // registerCustomFunction(sass_make_function("set-local($name, $value)", fn_set_local, (void*)31));
893+ registerCustomFunction (sass_make_function (" set-local($name, $value)" , fn_set_local, (void *)31 ));
907894 // registerCustomFunction(sass_make_function("set-global($name, $value)", fn_set_global, (void*)31));
908895 // registerCustomFunction(sass_make_function("set-lexical($name, $value)", fn_set_lexical, (void*)31));
909896 //
0 commit comments