Sha256: f2cae0dcbfb280b68097f8cc094c0373195e46566efbfd8b57adffffac5c6e49

Contents?: true

Size: 1.74 KB

Versions: 29

Compression:

Stored size: 1.74 KB

Contents

# frozen_string_literal: true

require "ffi"

module SassC
  module Native
    extend FFI::Library

    dl_ext = (RbConfig::CONFIG['host_os'] =~ /darwin/ ? 'bundle' : 'so')
    ffi_lib File.expand_path("libsass.#{dl_ext}", __dir__)

    require_relative "native/sass_value"

    typedef :pointer, :sass_options_ptr
    typedef :pointer, :sass_context_ptr
    typedef :pointer, :sass_file_context_ptr
    typedef :pointer, :sass_data_context_ptr

    typedef :pointer, :sass_c_function_list_ptr
    typedef :pointer, :sass_c_function_callback_ptr
    typedef :pointer, :sass_value_ptr

    typedef :pointer, :sass_import_list_ptr
    typedef :pointer, :sass_importer
    typedef :pointer, :sass_import_ptr

    callback :sass_c_function, [:pointer, :pointer], :pointer
    callback :sass_c_import_function, [:pointer, :pointer, :pointer], :pointer

    require_relative "native/sass_input_style"
    require_relative "native/sass_output_style"
    require_relative "native/string_list"
    require_relative "native/lib_c"

    # Remove the redundant "sass_" from the beginning of every method name
    def self.attach_function(*args)
      return super if args.size != 3

      if args[0] =~ /^sass_/
        args.unshift args[0].to_s.sub(/^sass_/, "")
      end

      super(*args)
    end

    # https://github.com/ffi/ffi/wiki/Examples#array-of-strings
    def self.return_string_array(ptr)
      ptr.null? ? [] : ptr.get_array_of_string(0).compact
    end

    def self.native_string(string)
      string = "#{string}\0"
      data = Native::LibC.malloc(string.bytesize)
      data.write_string(string)
      data
    end

    require_relative "native/native_context_api"
    require_relative "native/native_functions_api"
    require_relative "native/sass2scss_api"
  end
end

Version data entries

29 entries across 24 versions & 2 rubygems

Version Path
zuora_connect_ui-0.10.0 vendor/ruby/2.6.0/gems/sassc-2.2.0/lib/sassc/native.rb
zuora_connect_ui-0.10.0 vendor/ruby/2.6.0/gems/sassc-2.1.0-x86_64-linux/lib/sassc/native.rb
zuora_connect_ui-0.9.2 vendor/ruby/2.6.0/gems/sassc-2.1.0-x86_64-linux/lib/sassc/native.rb
zuora_connect_ui-0.9.2 vendor/ruby/2.6.0/gems/sassc-2.2.0/lib/sassc/native.rb
zuora_connect_ui-0.9.1 vendor/ruby/2.6.0/gems/sassc-2.1.0-x86_64-linux/lib/sassc/native.rb
zuora_connect_ui-0.9.1 vendor/ruby/2.6.0/gems/sassc-2.2.0/lib/sassc/native.rb
zuora_connect_ui-0.9.0 vendor/ruby/2.6.0/gems/sassc-2.2.0/lib/sassc/native.rb
zuora_connect_ui-0.9.0 vendor/ruby/2.6.0/gems/sassc-2.1.0-x86_64-linux/lib/sassc/native.rb
zuora_connect_ui-0.8.3 vendor/ruby/2.6.0/gems/sassc-2.2.0/lib/sassc/native.rb
zuora_connect_ui-0.8.3 vendor/ruby/2.6.0/gems/sassc-2.1.0-x86_64-linux/lib/sassc/native.rb
sassc-2.2.0-x86-mingw32 lib/sassc/native.rb
sassc-2.2.0-x64-mingw32 lib/sassc/native.rb
sassc-2.2.0 lib/sassc/native.rb
zuora_connect_ui-0.8.2 vendor/ruby/2.6.0/gems/sassc-2.1.0-x86_64-linux/lib/sassc/native.rb
sassc-2.1.0-x86_64-linux lib/sassc/native.rb
sassc-2.1.0-x86-mingw32 lib/sassc/native.rb
sassc-2.1.0-x86-linux lib/sassc/native.rb
sassc-2.1.0-x64-mingw32 lib/sassc/native.rb
sassc-2.1.0 lib/sassc/native.rb
sassc-2.1.0.pre3-x86_64-linux lib/sassc/native.rb