Skip to content

Commit 579762d

Browse files
authored
Half-indent public: and private: (#3139)
* Half-indent public: and private: This improves the readability of unified diffs and Github code reviews. The diff format tries to tell you the context of the change with a text appended to the @@ line, like so: @@ -22,7 +22,7 @@ bool contains(kj::StringPtr haystack, kj::StringPtr needle) { However with our old public/private indentation style we would often not see the class name, but rather just whether we were in the public or private section, like so: @@ -121,7 +121,7 @@ public:
1 parent f32706b commit 579762d

File tree

208 files changed

+1318
-1313
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

208 files changed

+1318
-1313
lines changed

.clang-format

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ IndentCaseLabels: true
4040
PointerAlignment: Left
4141
DerivePointerAlignment: true
4242

43+
# Move public and private in by a half-indentation. This makes
44+
# diffs and Github code reviews more readable by letting you
45+
# see which class the diff snippet is part of.
46+
AccessModifierOffset: -1
47+
4348
# Really "Attach" but empty braces aren't split.
4449
BreakBeforeBraces: Custom
4550
BraceWrapping:

src/workerd/api/actor-state-iocontext-test.c++

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ bool contains(kj::StringPtr haystack, kj::StringPtr needle) {
2222
}
2323

2424
class MockActorId: public ActorIdFactory::ActorId {
25-
public:
25+
public:
2626
MockActorId(kj::String id): id(kj::mv(id)) {}
2727
kj::String toString() const override {
2828
return kj::str("MockActorId<", id, ">");
@@ -42,7 +42,7 @@ public:
4242

4343
virtual ~MockActorId() {};
4444

45-
private:
45+
private:
4646
kj::String id;
4747
};
4848

src/workerd/api/actor-state.h

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jsg::JsValue deserializeV8Value(
3131
// Common implementation of DurableObjectStorage and DurableObjectTransaction. This class is
3232
// designed to be used as a mixin.
3333
class DurableObjectStorageOperations {
34-
public:
34+
public:
3535
struct GetOptions {
3636
jsg::Optional<bool> allowConcurrency;
3737
jsg::Optional<bool> noCache;
@@ -121,7 +121,7 @@ class DurableObjectStorageOperations {
121121
jsg::Lock& js, kj::Date scheduledTime, jsg::Optional<SetAlarmOptions> options);
122122
jsg::Promise<void> deleteAlarm(jsg::Lock& js, jsg::Optional<SetAlarmOptions> options);
123123

124-
protected:
124+
protected:
125125
typedef kj::StringPtr OpName;
126126
static constexpr OpName OP_GET = "get()"_kj;
127127
static constexpr OpName OP_GET_ALARM = "getAlarm()"_kj;
@@ -153,7 +153,7 @@ class DurableObjectStorageOperations {
153153
return kj::mv(options);
154154
}
155155

156-
private:
156+
private:
157157
jsg::Promise<jsg::JsRef<jsg::JsValue>> getOne(
158158
jsg::Lock& js, kj::String key, const GetOptions& options);
159159
jsg::Promise<jsg::JsRef<jsg::JsValue>> getMultiple(
@@ -172,7 +172,7 @@ class DurableObjectStorageOperations {
172172
class DurableObjectTransaction;
173173

174174
class DurableObjectStorage: public jsg::Object, public DurableObjectStorageOperations {
175-
public:
175+
public:
176176
DurableObjectStorage(IoPtr<ActorCacheInterface> cache, bool enableSql)
177177
: cache(kj::mv(cache)),
178178
enableSql(enableSql) {}
@@ -285,21 +285,21 @@ class DurableObjectStorage: public jsg::Object, public DurableObjectStorageOpera
285285
});
286286
}
287287

288-
protected:
288+
protected:
289289
ActorCacheOps& getCache(kj::StringPtr op) override;
290290

291291
bool useDirectIo() override {
292292
return false;
293293
}
294294

295-
private:
295+
private:
296296
IoPtr<ActorCacheInterface> cache;
297297
bool enableSql;
298298
uint transactionSyncDepth = 0;
299299
};
300300

301301
class DurableObjectTransaction final: public jsg::Object, public DurableObjectStorageOperations {
302-
public:
302+
public:
303303
DurableObjectTransaction(IoOwn<ActorCacheInterface::Transaction> cacheTxn)
304304
: cacheTxn(kj::mv(cacheTxn)) {}
305305

@@ -343,14 +343,14 @@ class DurableObjectTransaction final: public jsg::Object, public DurableObjectSt
343343
});
344344
}
345345

346-
protected:
346+
protected:
347347
ActorCacheOps& getCache(kj::StringPtr op) override;
348348

349349
bool useDirectIo() override {
350350
return false;
351351
}
352352

353-
private:
353+
private:
354354
// Becomes null when committed or rolled back.
355355
kj::Maybe<IoOwn<ActorCacheInterface::Transaction>> cacheTxn;
356356

@@ -364,7 +364,7 @@ class DurableObjectTransaction final: public jsg::Object, public DurableObjectSt
364364
// used for colo-local namespaces.
365365
class ActorState: public jsg::Object {
366366
// TODO(cleanup): Remove getPersistent method that isn't supported for colo-local actors anymore.
367-
public:
367+
public:
368368
ActorState(Worker::Actor::Id actorId,
369369
kj::Maybe<jsg::JsRef<jsg::JsValue>> transient,
370370
kj::Maybe<jsg::Ref<DurableObjectStorage>> persistent);
@@ -402,14 +402,14 @@ class ActorState: public jsg::Object {
402402
tracker.trackField("persistent", persistent);
403403
}
404404

405-
private:
405+
private:
406406
Worker::Actor::Id id;
407407
kj::Maybe<jsg::JsRef<jsg::JsValue>> transient;
408408
kj::Maybe<jsg::Ref<DurableObjectStorage>> persistent;
409409
};
410410

411411
class WebSocketRequestResponsePair: public jsg::Object {
412-
public:
412+
public:
413413
WebSocketRequestResponsePair(kj::String request, kj::String response)
414414
: request(kj::mv(request)),
415415
response(kj::mv(response)) {};
@@ -436,14 +436,14 @@ class WebSocketRequestResponsePair: public jsg::Object {
436436
tracker.trackField("response", response);
437437
}
438438

439-
private:
439+
private:
440440
kj::String request;
441441
kj::String response;
442442
};
443443

444444
// The type passed as the first parameter to durable object class's constructor.
445445
class DurableObjectState: public jsg::Object {
446-
public:
446+
public:
447447
DurableObjectState(Worker::Actor::Id actorId, kj::Maybe<jsg::Ref<DurableObjectStorage>> storage);
448448

449449
void waitUntil(kj::Promise<void> promise);
@@ -553,7 +553,7 @@ class DurableObjectState: public jsg::Object {
553553
tracker.trackField("storage", storage);
554554
}
555555

556-
private:
556+
private:
557557
Worker::Actor::Id id;
558558
kj::Maybe<jsg::Ref<DurableObjectStorage>> storage;
559559

src/workerd/api/actor.c++

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
namespace workerd::api {
1717

1818
class LocalActorOutgoingFactory final: public Fetcher::OutgoingFactory {
19-
public:
19+
public:
2020
LocalActorOutgoingFactory(uint channelId, kj::String actorId)
2121
: channelId(channelId),
2222
actorId(kj::mv(actorId)) {}
@@ -43,14 +43,14 @@ public:
4343
.operationName = kj::ConstString("actor_subrequest"_kjc)}));
4444
}
4545

46-
private:
46+
private:
4747
uint channelId;
4848
kj::String actorId;
4949
kj::Maybe<kj::Own<IoChannelFactory::ActorChannel>> actorChannel;
5050
};
5151

5252
class GlobalActorOutgoingFactory final: public Fetcher::OutgoingFactory {
53-
public:
53+
public:
5454
GlobalActorOutgoingFactory(uint channelId,
5555
jsg::Ref<DurableObjectId> id,
5656
kj::Maybe<kj::String> locationHint,
@@ -85,7 +85,7 @@ public:
8585
.operationName = kj::ConstString("actor_subrequest"_kjc)}));
8686
}
8787

88-
private:
88+
private:
8989
uint channelId;
9090
jsg::Ref<DurableObjectId> id;
9191
kj::Maybe<kj::String> locationHint;

src/workerd/api/actor.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ namespace workerd::api {
2626

2727
// A capability to an ephemeral Actor namespace.
2828
class ColoLocalActorNamespace: public jsg::Object {
29-
public:
29+
public:
3030
ColoLocalActorNamespace(uint channel): channel(channel) {}
3131

3232
jsg::Ref<Fetcher> get(kj::String actorId);
@@ -35,15 +35,15 @@ class ColoLocalActorNamespace: public jsg::Object {
3535
JSG_METHOD(get);
3636
}
3737

38-
private:
38+
private:
3939
uint channel;
4040
};
4141

4242
class DurableObjectNamespace;
4343

4444
// DurableObjectId type seen by JavaScript.
4545
class DurableObjectId: public jsg::Object {
46-
public:
46+
public:
4747
DurableObjectId(kj::Own<ActorIdFactory::ActorId> id): id(kj::mv(id)) {}
4848

4949
const ActorIdFactory::ActorId& getInner() {
@@ -75,7 +75,7 @@ class DurableObjectId: public jsg::Object {
7575
tracker.trackFieldWithSize("id", sizeof(ActorIdFactory::ActorId));
7676
}
7777

78-
private:
78+
private:
7979
kj::Own<ActorIdFactory::ActorId> id;
8080

8181
friend class DurableObjectNamespace;
@@ -84,7 +84,7 @@ class DurableObjectId: public jsg::Object {
8484
// Stub object used to send messages to a remote durable object.
8585
class DurableObject final: public Fetcher {
8686

87-
public:
87+
public:
8888
DurableObject(jsg::Ref<DurableObjectId> id,
8989
IoOwn<OutgoingFactory> outgoingFactory,
9090
RequiresHostAndProtocol requiresHost)
@@ -127,7 +127,7 @@ class DurableObject final: public Fetcher {
127127
tracker.trackField("id", id);
128128
}
129129

130-
private:
130+
private:
131131
jsg::Ref<DurableObjectId> id;
132132

133133
void visitForGc(jsg::GcVisitor& visitor) {
@@ -138,7 +138,7 @@ class DurableObject final: public Fetcher {
138138
// Global durable object class binding type.
139139
class DurableObjectNamespace: public jsg::Object {
140140

141-
public:
141+
public:
142142
DurableObjectNamespace(uint channel, kj::Own<ActorIdFactory> idFactory)
143143
: channel(channel),
144144
idFactory(kj::mv(idFactory)) {}
@@ -219,7 +219,7 @@ class DurableObjectNamespace: public jsg::Object {
219219
}
220220
}
221221

222-
private:
222+
private:
223223
uint channel;
224224
kj::Own<ActorIdFactory> idFactory;
225225

src/workerd/api/analytics-engine.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ namespace workerd::api {
2626
//
2727
// https://blog.cloudflare.com/workers-analytics-engine/
2828
class AnalyticsEngine: public jsg::Object {
29-
public:
29+
public:
3030
explicit AnalyticsEngine(
3131
uint logfwdrChannel, kj::String dataset, int64_t version, uint32_t ownerId)
3232
: logfwdrChannel(logfwdrChannel),
@@ -66,7 +66,7 @@ class AnalyticsEngine: public jsg::Object {
6666
tracker.trackField("dataset", dataset);
6767
}
6868

69-
private:
69+
private:
7070
double millisToNanos(double m) {
7171
return m * 1000000;
7272
}

0 commit comments

Comments
 (0)