Sha256: 1820eaa4b6468ae807506ce4435f11a36082123714893181b587e18c21ab635e

Contents?: true

Size: 924 Bytes

Versions: 5

Compression:

Stored size: 924 Bytes

Contents

module GirFFI
  module InfoExt
    # Extension module provinding a #safe_name method suitable for types.
    module SafeConstantName
      def safe_name
        name.tr('-', '_').gsub(/^./) do |char|
          case char
          when "_"
            "Private___"
          else
            char.upcase
          end
        end
      end

      # FIXME: This is invalid for ISignalInfo and IVFuncInfo
      def full_type_name
        "#{safe_namespace}::#{safe_name}"
      end
    end
  end
end

GObjectIntrospection::ICallbackInfo.send :include, GirFFI::InfoExt::SafeConstantName
GObjectIntrospection::IConstantInfo.send :include, GirFFI::InfoExt::SafeConstantName
GObjectIntrospection::IRegisteredTypeInfo.send :include, GirFFI::InfoExt::SafeConstantName
GObjectIntrospection::ISignalInfo.send :include, GirFFI::InfoExt::SafeConstantName
GObjectIntrospection::IVFuncInfo.send :include, GirFFI::InfoExt::SafeConstantName

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
gir_ffi-0.7.4 lib/gir_ffi/info_ext/safe_constant_name.rb
gir_ffi-0.7.3 lib/gir_ffi/info_ext/safe_constant_name.rb
gir_ffi-0.7.2 lib/gir_ffi/info_ext/safe_constant_name.rb
gir_ffi-0.7.1 lib/gir_ffi/info_ext/safe_constant_name.rb
gir_ffi-0.7.0 lib/gir_ffi/info_ext/safe_constant_name.rb