Skip to content

Commit f80d02a

Browse files
committed
[refactor] Controllable -> Callable 이름 수정
1 parent be8f683 commit f80d02a

File tree

5 files changed

+37
-37
lines changed

5 files changed

+37
-37
lines changed

README.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Delegation is a Swift macro package that unlocks builder-style configuration for
99
## 주요 기능 (Features)
1010

1111
- `@Delegatable` 애트리뷰트 하나로 체이닝 가능한 빌더 메서드 자동 생성
12-
- `@Controllable` 애트리뷰트를 void 메서드에 붙여 체이닝 가능한 `Self` 반환 메서드 생성
12+
- `@Callable` 애트리뷰트를 void 메서드에 붙여 체이닝 가능한 `Self` 반환 메서드 생성
1313
- `async`, `throws`, 다중 파라미터, `@Sendable` 등 클로저 특성 그대로 유지
1414
- 시스템 기본 언어에 맞춰 한국어/영어 진단 메시지 자동 출력
1515

@@ -28,7 +28,7 @@ let package = Package(
2828
name: "YourApp",
2929
platforms: [.iOS(.v14), .macOS(.v11), .tvOS(.v14), .watchOS(.v7), .macCatalyst(.v13)],
3030
dependencies: [
31-
.package(url: "https://github.com/ShapeKim98/Delegation.git", from: "0.2.0")
31+
.package(url: "https://github.com/ShapeKim98/Delegation.git", from: "0.3.0")
3232
],
3333
targets: [
3434
.target(
@@ -41,8 +41,8 @@ let package = Package(
4141
)
4242
```
4343

44-
> 현재 최신 태그는 `0.2.0`이며 릴리스에 맞춰 갱신해 주세요.
45-
> The current release tag is `0.2.0`; bump it as you publish newer versions.
44+
> 현재 최신 태그는 `0.3.0`이며 릴리스에 맞춰 갱신해 주세요.
45+
> The current release tag is `0.3.0`; bump it as you publish newer versions.
4646
4747
## 사용 방법 (Usage)
4848

@@ -74,14 +74,14 @@ ContentView()
7474
}
7575
```
7676

77-
### @Controllable
77+
### @Callable
7878

7979
```swift
8080
struct NumberController {
8181
private var number = 0
8282
var currentNumber: Int { number }
8383

84-
@Controllable
84+
@Callable
8585
private mutating func changeNumber(_ value: Int) {
8686
number = value
8787
}
@@ -93,8 +93,8 @@ let controller = NumberController()
9393
print(controller.currentNumber) // 10
9494
```
9595

96-
- 반환 타입이 없는 메서드에 `@Controllable`을 붙이면 본문을 복사한 뒤 `Self`를 반환하는 빌더 메서드가 추가됩니다. 값 타입은 복사본을, 참조 타입은 원본 인스턴스를 그대로 반환합니다.
97-
Annotate void functions with `@Controllable` to synthesise a builder method that mirrors the body and returns `Self`; value types return a copy while reference types return the original instance.
96+
- 반환 타입이 없는 메서드에 `@Callable`을 붙이면 본문을 복사한 뒤 `Self`를 반환하는 빌더 메서드가 추가됩니다. 값 타입은 복사본을, 참조 타입은 원본 인스턴스를 그대로 반환합니다.
97+
Annotate void functions with `@Callable` to synthesise a builder method that mirrors the body and returns `Self`; value types return a copy while reference types return the original instance.
9898
- `mutating`, `async`, `throws` 등 기존 선언의 효과는 새 메서드에도 유지됩니다.
9999
Existing modifiers such as `mutating`, `async`, and `throws` propagate to the generated method.
100100
- SwiftUI `View`처럼 `@State`를 사용하는 값 타입 샘플은 `Sources/DelegationClient/main.swift`에서 확인할 수 있습니다.
@@ -133,7 +133,7 @@ struct ContentView: View {
133133
@Delegatable private var buttonClicked: (() -> Void)?
134134
@State private var title = "Hello, world!"
135135

136-
@Controllable
136+
@Callable
137137
private func changeTitle(_ text: String) {
138138
title = text
139139
}
@@ -175,8 +175,8 @@ ContentView()
175175
.changeTitle("Delegation")
176176
```
177177

178-
- `@Controllable`이 생성한 빌더를 통해 SwiftUI 상태(`@State`)를 체이닝으로 갱신할 수 있습니다.
179-
Use the builder produced by `@Controllable` to update SwiftUI `@State` via chaining.
178+
- `@Callable`이 생성한 빌더를 통해 SwiftUI 상태(`@State`)를 체이닝으로 갱신할 수 있습니다.
179+
Use the builder produced by `@Callable` to update SwiftUI `@State` via chaining.
180180
- 패키지는 별도 실행 타깃을 포함하지 않으며, 위 코드는 문서용 예시입니다.
181181
The package ships without an executable sample target; the snippet above is for documentation only.
182182

@@ -194,7 +194,7 @@ final class ListViewController: UIViewController {
194194
@Delegatable private var presentSettings: (() -> Void)?
195195
private var titleText = "목록"
196196

197-
@Controllable
197+
@Callable
198198
private func updateTitle(_ text: String) {
199199
titleText = text
200200
title = text
@@ -233,8 +233,8 @@ let controller = ListViewController()
233233
.updateTitle("목록 화면")
234234
```
235235

236-
- 클래스에서도 `@Controllable`이 생성한 체이닝 메서드로 내부 상태를 직접 갱신할 수 있습니다.
237-
The `@Controllable` builder lets reference types update their internal state while participating in the chain.
236+
- 클래스에서도 `@Callable`이 생성한 체이닝 메서드로 내부 상태를 직접 갱신할 수 있습니다.
237+
The `@Callable` builder lets reference types update their internal state while participating in the chain.
238238
- 샘플 코드는 문서용 예시이며, 실제 앱 구조에 맞춰 델리게이트 채택과 레이아웃을 조정하세요.
239239
The snippet is documentation-only; adapt delegate conformance and layout to your project needs.
240240

Sources/Delegation/Delegation.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@
3030
@attached(peer, names: arbitrary)
3131
public macro Delegatable() = #externalMacro(module: "DelegationMacros", type: "DelegatableMacro")
3232

33-
/// `@Controllable`를 void 메서드에 붙이면 동일한 시그니처로 `Self`를 반환하는 메서드를 생성합니다.
33+
/// `@Callable`을 void 메서드에 붙이면 동일한 시그니처로 `Self`를 반환하는 메서드를 생성합니다.
3434
///
3535
/// ```swift
36-
/// @Controllable
36+
/// @Callable
3737
/// private func changeNumber(_ number: Int) {
3838
/// self.number = number
3939
/// }
@@ -49,4 +49,4 @@ public macro Delegatable() = #externalMacro(module: "DelegationMacros", type: "D
4949
/// }
5050
/// ```
5151
@attached(peer, names: arbitrary)
52-
public macro Controllable() = #externalMacro(module: "DelegationMacros", type: "ControllableMacro")
52+
public macro Callable() = #externalMacro(module: "DelegationMacros", type: "CallableMacro")

Sources/DelegationClient/main.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ struct ContentView: View {
3535

3636
var currentNumber: Int { _number.wrappedValue }
3737

38-
@Controllable
38+
@Callable
3939
private mutating func changeNumber(_ number: Int) {
4040
_number = State(initialValue: number)
4141
}
@@ -67,7 +67,7 @@ print("SwiftUI 뷰 상태 숫자: \(contentView.currentNumber)")
6767
final class NumberController {
6868
var number = 0
6969

70-
@Controllable
70+
@Callable
7171
private func changeNumber(_ number: Int) {
7272
self.number = number
7373
}

Sources/DelegationMacros/ControllableMacro.swift renamed to Sources/DelegationMacros/CallableMacro.swift

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import SwiftSyntax
33
import SwiftSyntaxBuilder
44
import SwiftSyntaxMacros
55

6-
enum ControllableMacroSupport {
6+
enum CallableMacroSupport {
77
static func attributeBaseName(from attribute: AttributeSyntax) -> String {
88
let description = attribute.attributeName.trimmedDescription
99
if let lastComponent = description.split(separator: ".").last {
@@ -68,7 +68,7 @@ enum ControllableMacroSupport {
6868
}
6969
}
7070

71-
public struct ControllableMacro: PeerMacro {
71+
public struct CallableMacro: PeerMacro {
7272
public static func expansion(
7373
of attribute: AttributeSyntax,
7474
providingPeersOf declaration: some DeclSyntaxProtocol,
@@ -77,17 +77,17 @@ public struct ControllableMacro: PeerMacro {
7777
guard let functionDecl = declaration.as(FunctionDeclSyntax.self) else {
7878
throw DelegationMacroError.message(
7979
MacroSupport.localizedMessage(
80-
korean: "@Controllable는 함수 선언에만 사용할 수 있습니다.",
81-
english: "Apply @Controllable to functions only."
80+
korean: "@Callable는 함수 선언에만 사용할 수 있습니다.",
81+
english: "Apply @Callable to functions only."
8282
)
8383
)
8484
}
8585

8686
guard functionDecl.body != nil else {
8787
throw DelegationMacroError.message(
8888
MacroSupport.localizedMessage(
89-
korean: "@Controllable 메서드는 본문을 포함해야 합니다.",
90-
english: "@Controllable functions must provide a body."
89+
korean: "@Callable 메서드는 본문을 포함해야 합니다.",
90+
english: "@Callable functions must provide a body."
9191
)
9292
)
9393
}
@@ -97,8 +97,8 @@ public struct ControllableMacro: PeerMacro {
9797
if returnType != "Void" && returnType != "()" {
9898
throw DelegationMacroError.message(
9999
MacroSupport.localizedMessage(
100-
korean: "@Controllable는 반환 타입이 없는 함수에서만 사용할 수 있습니다.",
101-
english: "Use @Controllable only on functions without a return type."
100+
korean: "@Callable는 반환 타입이 없는 함수에서만 사용할 수 있습니다.",
101+
english: "Use @Callable only on functions without a return type."
102102
)
103103
)
104104
}
@@ -117,8 +117,8 @@ public struct ControllableMacro: PeerMacro {
117117
continue
118118
}
119119

120-
let name = ControllableMacroSupport.attributeBaseName(from: attribute)
121-
if name.caseInsensitiveCompare("Controllable") == .orderedSame {
120+
let name = CallableMacroSupport.attributeBaseName(from: attribute)
121+
if name.caseInsensitiveCompare("Callable") == .orderedSame {
122122
continue
123123
}
124124

@@ -146,7 +146,7 @@ public struct ControllableMacro: PeerMacro {
146146

147147
let modifiers = functionDecl.modifiers
148148
for modifier in modifiers where MacroSupport.shouldCopyToBuilder(modifier) {
149-
let text = ControllableMacroSupport.modifierDescription(modifier)
149+
let text = CallableMacroSupport.modifierDescription(modifier)
150150
if !text.isEmpty {
151151
modifierComponents.append(text)
152152
}
@@ -173,21 +173,21 @@ public struct ControllableMacro: PeerMacro {
173173
}
174174
}
175175

176-
let callPrefix = ControllableMacroSupport.callPrefix(for: functionDecl.signature)
177-
let arguments = ControllableMacroSupport.argumentList(from: functionDecl.signature.parameterClause)
176+
let callPrefix = CallableMacroSupport.callPrefix(for: functionDecl.signature)
177+
let arguments = CallableMacroSupport.argumentList(from: functionDecl.signature.parameterClause)
178178
let isReferenceType = MacroSupport.isReferenceTypeContext(for: functionDecl)
179-
let requiresCopy = ControllableMacroSupport.requiresMutableCopy(functionDecl.modifiers) && !isReferenceType
179+
let requiresCopy = CallableMacroSupport.requiresMutableCopy(functionDecl.modifiers) && !isReferenceType
180180

181-
let invocationTarget = requiresCopy ? "controllable" : "self"
181+
let invocationTarget = requiresCopy ? "callable" : "self"
182182
let invocation = arguments.isEmpty
183183
? "\(invocationTarget).\(identifier)()"
184184
: "\(invocationTarget).\(identifier)(\(arguments))"
185185

186186
var bodyLines: [String] = []
187187
if requiresCopy {
188-
bodyLines.append(" var controllable = self")
188+
bodyLines.append(" var callable = self")
189189
bodyLines.append(" let _: Void = \(callPrefix)\(invocation)")
190-
bodyLines.append(" return controllable")
190+
bodyLines.append(" return callable")
191191
} else {
192192
bodyLines.append(" let _: Void = \(callPrefix)\(invocation)")
193193
bodyLines.append(" return self")

Sources/DelegationMacros/DelegatableMacro.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,6 @@ public struct DelegatableMacro: PeerMacro {
113113
struct DelegationPlugin: CompilerPlugin {
114114
let providingMacros: [Macro.Type] = [
115115
DelegatableMacro.self,
116-
ControllableMacro.self,
116+
CallableMacro.self,
117117
]
118118
}

0 commit comments

Comments
 (0)