class Sass::Compiler::Host::Protofier
def from_proto(proto)
def from_proto(proto) oneof = proto.value obj = proto.public_send(oneof) case oneof when :string Sass::Value::String.new( obj.text, quoted: obj.quoted ) when :number Number.from_proto(obj) when :color obj.to_s if RUBY_ENGINE == 'jruby' # TODO: https://github.com/protocolbuffers/protobuf/issues/18807 Sass::Value::Color.send( :for_space, obj.space, obj.has_channel1? ? obj.channel1 : nil, obj.has_channel2? ? obj.channel2 : nil, obj.has_channel3? ? obj.channel3 : nil, obj.has_alpha? ? obj.alpha : nil ) when :argument_list Sass::Value::ArgumentList.new( obj.contents.map do |element| from_proto(element) end, obj.keywords.to_enum.with_object({}) do |(key, value), hash| hash[key.to_sym] = from_proto(value) end, ListSeparator.from_proto(obj.separator) ).instance_eval do @id = obj.id self end when :list Sass::Value::List.new( obj.contents.map do |element| from_proto(element) end, separator: ListSeparator.from_proto(obj.separator), bracketed: obj.has_brackets ) when :map Sass::Value::Map.new( obj.entries.to_enum.with_object({}) do |entry, hash| hash[from_proto(entry.key)] = from_proto(entry.value) end ) when :compiler_function Sass::Value::Function.new(nil).instance_eval do @id = obj.id self end when :host_function raise Sass::ScriptError, 'The compiler may not send Value.host_function to host' when :compiler_mixin Sass::Value::Mixin.send(:new).instance_eval do @id = obj.id self end when :calculation Calculation.from_proto(obj) when :singleton case obj when :TRUE Sass::Value::Boolean::TRUE when :FALSE Sass::Value::Boolean::FALSE when :NULL Sass::Value::Null::NULL else raise Sass::ScriptError, "Unknown Value.singleton #{obj}" end else raise Sass::ScriptError, "Unknown Value.value #{obj}" end end