Class: SassC::FunctionsHandler
- Inherits:
-
Object
- Object
- SassC::FunctionsHandler
- Defined in:
- lib/sassc/functions_handler.rb
Defined Under Namespace
Classes: FunctionWrapper
Instance Method Summary collapse
-
#initialize(options) ⇒ FunctionsHandler
constructor
A new instance of FunctionsHandler.
- #setup(native_options) ⇒ Object
Constructor Details
#initialize(options) ⇒ FunctionsHandler
Returns a new instance of FunctionsHandler.
3 4 5 |
# File 'lib/sassc/functions_handler.rb', line 3 def initialize() @options = end |
Instance Method Details
#setup(native_options) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/sassc/functions_handler.rb', line 7 def setup() @callbacks = {} @function_names = {} list = Native.make_function_list(Script.custom_functions.count) functs = FunctionWrapper.extend(Script::Functions) functs. = @options Script.custom_functions.each_with_index do |custom_function, i| @callbacks[custom_function] = FFI::Function.new(:pointer, [:pointer, :pointer]) do |s_args, | length = Native.list_get_length(s_args) v = Native.list_get_value(s_args, 0) v = Native.string_get_value(v).dup s = Script::String.new(Script::String.unquote(v), Script::String.type(v)) value = functs.send(custom_function, s) if value value = Script::String.new(Script::String.unquote(value.to_s), value.type) value.to_native else Script::String.new("").to_native end end @function_names[custom_function] = Script.formatted_function_name(custom_function) callback = Native.make_function( @function_names[custom_function], @callbacks[custom_function], nil ) Native::function_set_list_entry(list, i, callback) end Native::option_set_c_functions(, list) end |