Permalink
Browse files

Updated to Crystal > 0.15.0

  • Loading branch information...
asterite committed Apr 12, 2016
1 parent 685b09e commit f5839e93bcfd4672a37c250163f70d94a2d5efa1
View
@@ -175,7 +175,7 @@ describe Parser do
nodes = parse("typedef int foo(float);")
typedef = nodes.last as Typedef
typedef.name.should eq("foo")
typedef.type.should eq(FunctionType.new([PrimitiveType.float], PrimitiveType.int))
typedef.type.should eq(FunctionType.new([PrimitiveType.float] of Type, PrimitiveType.int))
end
it "parses enum" do
@@ -245,7 +245,7 @@ describe Parser do
nodes = parse("int (*tester)(float, char) = 0;")
var = nodes.last as Var
var.name.should eq("tester")
var.type.should eq(FunctionType.new([PrimitiveType.float, PrimitiveType.char], PrimitiveType.int))
var.type.should eq(FunctionType.new([PrimitiveType.float, PrimitiveType.char] of Type, PrimitiveType.int))
end
end
end
View
@@ -1,7 +1,7 @@
require "./type"
struct Clang::Cursor
def initialize(@cursor)
def initialize(@cursor : LibClang::Cursor)
end
def definition
@@ -1 +1,5 @@
record Clang::FileLocation, filename, line, column, offset
record Clang::FileLocation,
filename : String?,
line : UInt32,
column : UInt32,
offset : UInt32
@@ -1,5 +1,5 @@
struct Clang::SourceLocation
def initialize(@location)
def initialize(@location : LibClang::SourceLocation)
end
def is_from_main_file?
@@ -1,5 +1,5 @@
struct Clang::SourceRange
def initialize(@range)
def initialize(@range : LibClang::SourceRange)
end
def start
View
@@ -1,5 +1,5 @@
struct Clang::Token
def initialize(@tokenization, @token)
def initialize(@tokenization : Tokenization, @token : LibClang::Token)
end
def to_unsafe
@@ -1,7 +1,7 @@
class Clang::Tokenization
include Enumerable(Token)
def initialize(@translation_unit, @tokens)
def initialize(@translation_unit : TranslationUnit, @tokens : Slice(LibClang::Token))
end
def each
@@ -1,5 +1,5 @@
class Clang::TranslationUnit
def initialize(@tu)
def initialize(@tu : LibClang::TranslationUnit)
end
def num_diagnostics
View
@@ -1,5 +1,5 @@
struct Clang::Type
def initialize(@type)
def initialize(@type : LibClang::Type)
end
def spelling
View
@@ -9,7 +9,7 @@ module CrystalLib
property name
property value
def initialize(@name, @value)
def initialize(@name : String, @value : String)
end
def to_s(io, semicolon = true)
@@ -23,7 +23,7 @@ module CrystalLib
property name
property type
def initialize(@name, @type)
def initialize(@name : String, @type : Type)
end
def to_s(io, semicolon = true)
@@ -40,7 +40,7 @@ module CrystalLib
property return_type
property? variadic
def initialize(@name, @return_type, @variadic)
def initialize(@name : String, @return_type : Type, @variadic : Bool)
@args = [] of Arg
end
@@ -63,7 +63,7 @@ module CrystalLib
property name
property type
def initialize(@name, @type)
def initialize(@name : String, @type : Type)
end
def to_s(io, semicolon = true)
@@ -81,7 +81,7 @@ module CrystalLib
getter unscoped_name
def initialize(@kind, name)
def initialize(@kind : Symbol, name : String)
@unscoped_name = name
if name.empty?
@name = ""
@@ -112,7 +112,7 @@ module CrystalLib
property name
property type
def initialize(@name, @type)
def initialize(@name : String, @type : Type)
end
def to_s(io, semicolon = true)
@@ -128,7 +128,7 @@ module CrystalLib
property type
property values
def initialize(@name, @type)
def initialize(@name : String, @type : Type)
@values = [] of EnumValue
end
@@ -155,7 +155,7 @@ module CrystalLib
property name
property value
def initialize(@name, @value)
def initialize(@name : String, @value : Int64)
end
def to_s(io, semicolon = true)
View
@@ -9,7 +9,9 @@ class CrystalLib::Parser
nodes
end
def initialize(@source, flags = [] of String)
@tu : Clang::TranslationUnit
def initialize(@source : String, flags = [] of String)
@nodes = [] of ASTNode
@cursor_hash_to_node = {} of UInt32 => ASTNode
@idx = Clang::Index.new
@@ -270,11 +272,11 @@ class CrystalLib::Parser
end
def pointer_types
@pointer_types ||= {} of typeof(object_id) => Type
@pointer_types ||= {} of UInt64 => Type
end
def block_pointer_types
@block_pointer_types ||= {} of typeof(object_id) => Type
@block_pointer_types ||= {} of UInt64 => Type
end
def named_types
@@ -285,17 +287,20 @@ class CrystalLib::Parser
@named_nodes ||= {} of String => ASTNode
end
record ConstantArrayKey, object_id, size
record ConstantArrayKey,
object_id : UInt64, size : Int32
def constant_array_types
@constant_array_types ||= {} of ConstantArrayKey => Type
end
def incomplete_array_types
@incomplete_array_types ||= {} of typeof(object_id) => Type
@incomplete_array_types ||= {} of UInt64 => Type
end
record FunctionKey, inputs_ids, output_id
record FunctionKey,
inputs_ids : Array(UInt64),
output_id : UInt64
def function_types
@function_types ||= {} of FunctionKey => Type
@@ -1,12 +1,17 @@
class CrystalLib::TypeMapper
record PendingStruct, crystal_node, clang_type, original_name
record PendingStruct,
crystal_node : Crystal::StructOrUnionDef,
clang_type : CrystalLib::StructOrUnion,
original_name : String
getter pending_definitions
@typedef_name : String?
def initialize(@prefix_matcher = nil)
@pending_definitions = [] of Crystal::ASTNode
@pending_structs = [] of PendingStruct
@generated = {} of typeof(object_id) => Crystal::ASTNode
@generated = {} of UInt64 => Crystal::ASTNode
# When completing a struct's fields we keep that struct and the field name in
# case we find a nested struct, such as in:#
View
@@ -117,7 +117,7 @@ module CrystalLib
class PointerType < Type
property type
def initialize(@type)
def initialize(@type : Type)
end
def to_s(io)
@@ -130,7 +130,7 @@ module CrystalLib
class BlockPointerType < Type
property type
def initialize(@type)
def initialize(@type : Type)
end
def to_s(io)
@@ -144,7 +144,7 @@ module CrystalLib
property type
property size
def initialize(@type, @size)
def initialize(@type : Type, @size : Int32)
end
def to_s(io)
@@ -157,7 +157,7 @@ module CrystalLib
class IncompleteArrayType < Type
property type
def initialize(@type)
def initialize(@type : Type)
end
def to_s(io)
@@ -171,7 +171,7 @@ module CrystalLib
property inputs
property output
def initialize(@inputs, @output)
def initialize(@inputs : Array(Type), @output : Type)
end
def to_s(io)
@@ -186,7 +186,7 @@ module CrystalLib
property name
property type
def initialize(@name, @type)
def initialize(@name : String, @type : Type)
end
def to_s(io)
@@ -199,7 +199,7 @@ module CrystalLib
class UnexposedType < Type
property name
def initialize(@name)
def initialize(@name : String)
end
def to_s(io)
@@ -212,7 +212,7 @@ module CrystalLib
class ErrorType < Type
property name
def initialize(@name)
def initialize(@name : String)
end
def to_s(io)
@@ -225,7 +225,7 @@ module CrystalLib
class NodeRef < Type
property node
def initialize(@node)
def initialize(@node : ASTNode)
end
def to_s(io)

0 comments on commit f5839e9

Please sign in to comment.