cxxstdlib: typed: strong
This commit is contained in:
parent
0029308844
commit
cce425dda1
@ -1,23 +1,30 @@
|
|||||||
# typed: true # rubocop:todo Sorbet/StrictSigil
|
# typed: strong
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "compilers"
|
require "compilers"
|
||||||
|
|
||||||
# Combination of C++ standard library and compiler.
|
# Combination of C++ standard library and compiler.
|
||||||
class CxxStdlib
|
class CxxStdlib
|
||||||
|
sig { params(type: T.nilable(Symbol), compiler: T.any(Symbol, String)).returns(CxxStdlib) }
|
||||||
def self.create(type, compiler)
|
def self.create(type, compiler)
|
||||||
raise ArgumentError, "Invalid C++ stdlib type: #{type}" if type && [:libstdcxx, :libcxx].exclude?(type)
|
raise ArgumentError, "Invalid C++ stdlib type: #{type}" if type && [:libstdcxx, :libcxx].exclude?(type)
|
||||||
|
|
||||||
CxxStdlib.new(type, compiler)
|
CxxStdlib.new(type, compiler)
|
||||||
end
|
end
|
||||||
|
|
||||||
attr_reader :type, :compiler
|
sig { returns(T.nilable(Symbol)) }
|
||||||
|
attr_reader :type
|
||||||
|
|
||||||
|
sig { returns(Symbol) }
|
||||||
|
attr_reader :compiler
|
||||||
|
|
||||||
|
sig { params(type: T.nilable(Symbol), compiler: T.any(Symbol, String)).void }
|
||||||
def initialize(type, compiler)
|
def initialize(type, compiler)
|
||||||
@type = type
|
@type = type
|
||||||
@compiler = compiler.to_sym
|
@compiler = T.let(compiler.to_sym, Symbol)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig { returns(String) }
|
||||||
def type_string
|
def type_string
|
||||||
type.to_s.gsub(/cxx$/, "c++")
|
type.to_s.gsub(/cxx$/, "c++")
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user