Sha256: 0d6304e210468c93e8bf171361999b53676319dd78855f6f707e26b4211b2da4

Contents?: true

Size: 1.83 KB

Versions: 37

Compression:

Stored size: 1.83 KB

Contents

# frozen_string_literal: true

require "ffi"

module SassC
  module Native
    extend FFI::Library

    dl_ext = RbConfig::MAKEFILE_CONFIG['DLEXT']
    begin
      ffi_lib File.expand_path("libsass.#{dl_ext}", __dir__)
    rescue LoadError # Some non-rvm environments don't copy a shared object over to lib/sassc
      ffi_lib File.expand_path("libsass.#{dl_ext}", "#{__dir__}/../../ext")
    end

    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"

    # 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)
      m = FFI::MemoryPointer.from_string(string)
      m.autorelease = false
      m
    end

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

Version data entries

37 entries across 36 versions & 5 rubygems

Version Path
trusty-cms-7.0.9.1 vendor/bundle/ruby/3.1.0/gems/sassc-2.4.0/lib/sassc/native.rb
trusty-cms-7.0.9.1 vendor/bundle/ruby/3.3.0/gems/sassc-2.4.0/lib/sassc/native.rb
sassc-embedded-1.80.2 vendor/github.com/sass/sassc-ruby/lib/sassc/native.rb
sassc-embedded-1.80.1 vendor/github.com/sass/sassc-ruby/lib/sassc/native.rb
sassc-embedded-1.80.0 vendor/github.com/sass/sassc-ruby/lib/sassc/native.rb
sassc-embedded-1.79.0 vendor/github.com/sass/sassc-ruby/lib/sassc/native.rb
sassc-embedded-1.78.0 vendor/github.com/sass/sassc-ruby/lib/sassc/native.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/sassc-2.4.0/lib/sassc/native.rb
sassc-embedded-1.77.8 vendor/github.com/sass/sassc-ruby/lib/sassc/native.rb
sassc-embedded-1.77.7 vendor/github.com/sass/sassc-ruby/lib/sassc/native.rb
sassc-embedded-1.77.6 vendor/github.com/sass/sassc-ruby/lib/sassc/native.rb
sassc-embedded-1.77.5 vendor/github.com/sass/sassc-ruby/lib/sassc/native.rb
sassc-embedded-1.77.4 vendor/github.com/sass/sassc-ruby/lib/sassc/native.rb
sassc-embedded-1.77.3 vendor/github.com/sass/sassc-ruby/lib/sassc/native.rb
sassc-embedded-1.77.2 vendor/github.com/sass/sassc-ruby/lib/sassc/native.rb
sassc-embedded-1.77.1 vendor/github.com/sass/sassc-ruby/lib/sassc/native.rb
sassc-embedded-1.77.0 vendor/github.com/sass/sassc-ruby/lib/sassc/native.rb
sassc-embedded-1.76.0 vendor/github.com/sass/sassc-ruby/lib/sassc/native.rb
sassc-embedded-1.75.2 vendor/github.com/sass/sassc-ruby/lib/sassc/native.rb
sassc-embedded-1.75.1 vendor/github.com/sass/sassc-ruby/lib/sassc/native.rb