dan-zheng / Echo

A complete reflection library for Swift

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Echo

A complete reflection package for Swift.

Build Status

Usage

let arrayOfInt = reflect([Int].self) as! StructMetadata
print(arrayOfInt.descriptor.name) // Array
print(arrayOfInt.genericTypes) // [Swift.Int]

let add = reflect(((Int, Int) -> Int).self) as! FunctionMetadata
print(add.resultType) // Int
print(add.paramTypes) // [Swift.Int, Swift.Int]

let point = reflect((x: Double, y: Double).self) as! TupleMetadata
print(point.numElements) // 2
print(point.labels) // ["x", "y"]
for element in point.elements {
  print(element.type) // Swift.Double, Swift.Double
  print(element.offset) // 0, 8
}

Installation

Simply add the following dependency to your Package.swift:

.package(url: "https://github.com/Azoy/Echo.git", from: "0.0.1")

About

A complete reflection library for Swift

License:MIT License


Languages

Language:Swift 96.9%Language:C 3.1%