Functions
The following functions are available globally.
-
Wrapper for POSIX
getopt()to return a Swift tuple. Returnsnilif thegetopt()returned -1, otherwise returns a tuple of the option character with an optional argumentDeclaration
Swift
public func get_opt(_ options: String) -> (Character, String?)?
-
return setter/getter pairs from a list of methods
Declaration
Swift
public func getterSetterPairs(for allMethods: [GIR.Method]) -> [GetterSetterPair] -
SwiftDoc representation of comments
Declaration
Swift
public func commentCode(_ thing: GIR.Thing, indentation: String = "") -> String -
Swift representation of deprecation
Declaration
Swift
public func deprecatedCode(_ thing: GIR.Thing, indentation: String) -> String? -
Swift code representation with code following the comments
Declaration
Swift
public func swiftCode(_ thing: GIR.Thing, _ postfix: String = "", indentation: String = "") -> String -
Swift code representation of a type alias
Declaration
Swift
public func swiftCode(alias: GIR.Alias) -> String -
Swift code representation of a callback as a type alias
Declaration
Swift
public func swiftCallbackAliasCode(callback: GIR.Callback) -> String -
Swift code representation of a constant
Declaration
Swift
public func swiftCode(constant: GIR.Constant) -> String -
Swift code type alias representation of an enum
Declaration
Swift
public func typeAlias(_ e: GIR.Enumeration) -> String -
Swift code representation of an enum
Declaration
Swift
public func swiftCode(_ e: GIR.Enumeration) -> String -
Swift code representation of an enum value
Declaration
Swift
public func valueCode(_ indentation: String) -> (GIR.Enumeration.Member) -> String -
Swift protocol representation of a record/class as a wrapper of a pointer
Declaration
Swift
public func recordProtocolCode(_ e: GIR.Record, parent: String, indentation: String = " ", ptr: String = "ptr") -> String -
Default implementation for record methods as protocol extension
Declaration
-
Default implementation for functions
Declaration
Swift
public func functionCode(_ f: GIR.Function, indentation: String = " ", initialIndentation i: String = "") -> String -
Swift code for methods (with a given indentation)
Declaration
-
Swift code for computed properties
Declaration
Swift
public func computedPropertyCode(_ indentation: String, record: GIR.Record, publicDesignation: String = "public ", ptr ptrName: String = "ptr") -> (GetterSetterPair) -> String -
Swift code for convenience constructors
Declaration
-
Return the return type of a method,
Declaration
-
Return code declaration for functions/methods/convenience constructors
Declaration
-
Return code for functions/methods/convenience constructors
Declaration
-
Swift code for calling the underlying function and assigning the raw return value
Declaration
-
Swift code for calling the underlying setter function and assigning the raw return value
Declaration
-
Swift code for the parameters of a constructor
Declaration
Swift
public func constructorParam(_ method: GIR.Method, prefix: String?) -> String -
Swift code for constructor first argument prefix extracted from a method name
Declaration
Swift
public func constructorPrefix(_ method: GIR.Method) -> String? -
Swift code for auto-prefixed arguments
Declaration
Swift
public func codeFor(argument a: GIR.Argument) -> String -
Swift code for methods
Declaration
Swift
public func codeFor(argument a: GIR.Argument, prefix: String) -> String -
Swift code for passing an argument to a free standing function
Declaration
Swift
public func toSwift(_ arg: GIR.Argument, ptr: String = "ptr") -> String -
Swift code for passing a setter to a method of a record / class
Declaration
-
Swift code for signal names without prefixes
Declaration
Swift
public func signalNameCode(indentation indent: String, convertName: @escaping (String) -> String = { $0.camelSignal }) -> (GIR.CType) -> String -
Swift code for signal names with prefixes
Declaration
Swift
public func signalNameCode(indentation indent: String, prefixes: (String, String), convertName: @escaping (String) -> String = { $0.camelSignalComponent }) -> (GIR.CType) -> String -
Swift struct representation of a record/class as a wrapper of a pointer
Declaration
Swift
public func recordStructCode(_ e: GIR.Record, indentation: String = " ", ptr: String = "ptr") -> String -
Swift struct representation of a record/class as a wrapper of a pointer
Declaration
Swift
public func recordClassCode(_ e: GIR.Record, parent: String, indentation: String = " ", ptr: String = "ptr") -> String -
Swift code representation of a record
Declaration
-
Swift code representation of a free standing function
Declaration
Swift
public func swiftCode(_ f: GIR.Function) -> String
-
Comparator to check whether two
Things are equalParameters
lhsThingto comparerhsThingto compare with -
Comparator to check the ordering of two
ThingsParameters
lhsfirst
Thingto comparerhssecond
Thingto compare
-
Convert the given String to SwiftDoc
Declaration
Swift
public func gtkDoc2SwiftDoc(_ gtkDoc: String, linePrefix: String = "/// ") -> StringParameters
gtkDocString in
gtk-docformatlinePrefixstring to prefix each line with (e.g. indentation and/or
///
)Return Value
String in SwiftDoc format
-
memory map the given file with the given protection and flags, then call the
processfunction with the memory address of the mapped fileDeclaration
Swift
public func with_mmap(_ file: String, protection: Int32 = PROT_READ, flags: Int32 = MAP_PRIVATE, process: (UnsafeMutableRawPointer, Int) -> Void)Parameters
fileName of the file to
open()andmmap()protectionmemory protection flags to use
flagsmemory mapping flags to use
processcallback for processing the content of the file while memory mapped
-
memory map the given file to an unsafe buffer pointer then call the
processfunction with the memory address of the mapped fileDeclaration
Swift
public func with_mmap<Element>(_ file: String, protection p: Int32 = PROT_READ, flags f: Int32 = MAP_PRIVATE, process: (UnsafeBufferPointer<Element>) -> Void)Parameters
fileName of the file to
open()andmmap()to memory pointing to the givenElementtypepmemory protection flags to use
fmemory mapping flags to use
processcallback for processing the content of the file while memory mapped and bound to
Element
View on GitHub
Install in Dash
Functions Reference