Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf41f6fc

Browse files
committed
Update README, other minor changes
- Convenience init for `Method` which takes a `Signature`- Fixed `Pointer.calloc()` from passing 5 for some reason (should be 1)- Added `#if os(Linux)` check to `Pointer.calloc()`
1 parent85059e1 commitf41f6fc

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

‎README.md‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,21 @@ _msgSend(Person.class.ref, "someClassMethod")
243243

244244
In general, use`class.ref` whenever you wish to treat a`Class` as an object.
245245

246+
###Other caveats
247+
248+
`Class` objects will not be available via`Class.named(_:)` until they have been accessed statically. You should "load" these classes manually by accessing all classes you define, like so:
249+
250+
```swift
251+
funcruntimeInit() {
252+
// Runtime initialization
253+
_= RootObject.class
254+
_= Person.class
255+
...
256+
}
257+
```
258+
259+
Ideally this shouldn't be necessary, or should be easier. Please submit a pull request if you have suggestions on how to make this easier or unnecessary!
260+
246261
---
247262

248263
##To-do

‎Runtime/Method.swift‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ public class Method: Hashable {
2727
self.imp= imp
2828
}
2929

30+
conveniencepublicinit(_ name:String, signature:Signauture=(.void,[]), _ imp:@escapingIMP){
31+
self.init(name, returns: signature.returnType, args: signature.argumentTypes, imp)
32+
}
33+
3034
publicvarhashValue:Int{
3135
returnself.name.hashValue
3236
}

‎Runtime/Pointer.swift‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,11 @@ public struct Pointer<Pointee>: Strideable, Hashable, Equatable {
8383
}
8484

8585
publicstaticfunc calloc(_ count:Int)->Pointer{
86-
returnPointer(raw:Darwin.calloc(count,5))
86+
#if os(Linux)
87+
returnPointer(raw:Glibc.calloc(count,1))
88+
#else
89+
returnPointer(raw:Darwin.calloc(count,1))
90+
#endif
8791
}
8892

8993
publicfunc free(_ count:Int){

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp