Skip to content

Commit 237ba8d

Browse files
munificentCommit Queue
authored and
Commit Queue
committed
Reformat samples/ with 3.8 style.
Change-Id: I13ecd6339afd62cb5ebeb29c29d80470bcc22671 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425146 Auto-Submit: Bob Nystrom <[email protected]> Commit-Queue: Lasse Nielsen <[email protected]> Reviewed-by: Lasse Nielsen <[email protected]>
1 parent 361cf93 commit 237ba8d

File tree

5 files changed

+137
-91
lines changed

5 files changed

+137
-91
lines changed

samples/embedder/futures.dart

+3-4
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,9 @@ Stream<int> produceIntStreamWithController(int count, int delayMs) {
5454
}
5555

5656
Future<int> sumIntStream(int count, int delayMs, bool useAsyncStar) async {
57-
final stream =
58-
useAsyncStar
59-
? produceIntStreamWithAsyncStar(count, delayMs)
60-
: produceIntStreamWithController(count, delayMs);
57+
final stream = useAsyncStar
58+
? produceIntStreamWithAsyncStar(count, delayMs)
59+
: produceIntStreamWithController(count, delayMs);
6160
var sum = 0;
6261
await for (var value in stream) {
6362
sum += value;

samples/ffi/sqlite/lib/src/bindings/bindings.dart

+42-29
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,18 @@ class _SQLiteBindings {
2828
/// an English language description of the error following a failure of any
2929
/// of the sqlite3_open() routines.
3030
late int Function(
31-
Pointer<Utf8> filename,
32-
Pointer<Pointer<Database>> databaseOut,
33-
int flags,
34-
Pointer<Utf8> vfs) sqlite3_open_v2;
31+
Pointer<Utf8> filename,
32+
Pointer<Pointer<Database>> databaseOut,
33+
int flags,
34+
Pointer<Utf8> vfs,
35+
)
36+
sqlite3_open_v2;
3537

3638
late int Function(Pointer<Database> database) sqlite3_close_v2;
3739
late Pointer<NativeFunction<sqlite3_close_v2_native_t>>
38-
sqlite3_close_v2_native;
40+
sqlite3_close_v2_native;
3941
late Pointer<NativeFunction<Void Function(Pointer<Database> database)>>
40-
sqlite3_close_v2_native_return_void;
42+
sqlite3_close_v2_native_return_void;
4143

4244
/// Compiling An SQL Statement
4345
///
@@ -87,11 +89,13 @@ class _SQLiteBindings {
8789
/// original SQL text. This causes the [sqlite3_step] interface to
8890
/// behave differently in three ways:
8991
late int Function(
90-
Pointer<Database> database,
91-
Pointer<Utf8> query,
92-
int nbytes,
93-
Pointer<Pointer<Statement>> statementOut,
94-
Pointer<Pointer<Utf8>> tail) sqlite3_prepare_v2;
92+
Pointer<Database> database,
93+
Pointer<Utf8> query,
94+
int nbytes,
95+
Pointer<Pointer<Statement>> statementOut,
96+
Pointer<Pointer<Utf8>> tail,
97+
)
98+
sqlite3_prepare_v2;
9599

96100
/// Evaluate An SQL Statement
97101
///
@@ -219,9 +223,9 @@ class _SQLiteBindings {
219223
/// undesirable behavior such as segfaults and heap corruption.
220224
late int Function(Pointer<Statement> statement) sqlite3_finalize;
221225
late Pointer<NativeFunction<sqlite3_finalize_native_t>>
222-
sqlite3_finalize_native;
226+
sqlite3_finalize_native;
223227
late Pointer<NativeFunction<Void Function(Pointer<Statement> statement)>>
224-
sqlite3_finalize_native_return_void;
228+
sqlite3_finalize_native_return_void;
225229

226230
/// Number Of Columns In A Result Set
227231
///
@@ -254,7 +258,7 @@ class _SQLiteBindings {
254258
/// that column, if there is an AS clause. If there is no AS clause
255259
/// then the name of the column is unspecified and may change from
256260
late Pointer<Utf8> Function(Pointer<Statement> statement, int columnIndex)
257-
sqlite3_column_name;
261+
sqlite3_column_name;
258262

259263
/// CAPI3REF: Declared Datatype Of A Query Result
260264
///
@@ -284,22 +288,22 @@ class _SQLiteBindings {
284288
/// is associated with individual values, not with the containers
285289
/// used to hold those values.
286290
late Pointer<Utf8> Function(Pointer<Statement> statement, int columnIndex)
287-
sqlite3_column_decltype;
291+
sqlite3_column_decltype;
288292

289293
late int Function(Pointer<Statement> statement, int columnIndex)
290-
sqlite3_column_type;
294+
sqlite3_column_type;
291295

292296
late Pointer<Value> Function(Pointer<Statement> statement, int columnIndex)
293-
sqlite3_column_value;
297+
sqlite3_column_value;
294298

295299
late double Function(Pointer<Statement> statement, int columnIndex)
296-
sqlite3_column_double;
300+
sqlite3_column_double;
297301

298302
late int Function(Pointer<Statement> statement, int columnIndex)
299-
sqlite3_column_int;
303+
sqlite3_column_int;
300304

301305
late Pointer<Utf8> Function(Pointer<Statement> statement, int columnIndex)
302-
sqlite3_column_text;
306+
sqlite3_column_text;
303307

304308
/// The sqlite3_errstr() interface returns the English-language text that
305309
/// describes the result code, as UTF-8. Memory to hold the error message
@@ -350,7 +354,8 @@ class _SQLiteBindings {
350354
sqlite3_close_v2 = sqlite3_close_v2_native.asFunction();
351355
sqlite3_prepare_v2 = sqlite
352356
.lookup<NativeFunction<sqlite3_prepare_v2_native_t>>(
353-
"sqlite3_prepare_v2")
357+
"sqlite3_prepare_v2",
358+
)
354359
.asFunction();
355360
sqlite3_step = sqlite
356361
.lookup<NativeFunction<sqlite3_step_native_t>>("sqlite3_step")
@@ -370,35 +375,43 @@ class _SQLiteBindings {
370375
.asFunction();
371376
sqlite3_column_count = sqlite
372377
.lookup<NativeFunction<sqlite3_column_count_native_t>>(
373-
"sqlite3_column_count")
378+
"sqlite3_column_count",
379+
)
374380
.asFunction();
375381
sqlite3_column_name = sqlite
376382
.lookup<NativeFunction<sqlite3_column_name_native_t>>(
377-
"sqlite3_column_name")
383+
"sqlite3_column_name",
384+
)
378385
.asFunction();
379386
sqlite3_column_decltype = sqlite
380387
.lookup<NativeFunction<sqlite3_column_decltype_native_t>>(
381-
"sqlite3_column_decltype")
388+
"sqlite3_column_decltype",
389+
)
382390
.asFunction();
383391
sqlite3_column_type = sqlite
384392
.lookup<NativeFunction<sqlite3_column_type_native_t>>(
385-
"sqlite3_column_type")
393+
"sqlite3_column_type",
394+
)
386395
.asFunction();
387396
sqlite3_column_value = sqlite
388397
.lookup<NativeFunction<sqlite3_column_value_native_t>>(
389-
"sqlite3_column_value")
398+
"sqlite3_column_value",
399+
)
390400
.asFunction();
391401
sqlite3_column_double = sqlite
392402
.lookup<NativeFunction<sqlite3_column_double_native_t>>(
393-
"sqlite3_column_double")
403+
"sqlite3_column_double",
404+
)
394405
.asFunction();
395406
sqlite3_column_int = sqlite
396407
.lookup<NativeFunction<sqlite3_column_int_native_t>>(
397-
"sqlite3_column_int")
408+
"sqlite3_column_int",
409+
)
398410
.asFunction();
399411
sqlite3_column_text = sqlite
400412
.lookup<NativeFunction<sqlite3_column_text_native_t>>(
401-
"sqlite3_column_text")
413+
"sqlite3_column_text",
414+
)
402415
.asFunction();
403416
}
404417
}

samples/ffi/sqlite/lib/src/bindings/signatures.dart

+35-28
Original file line numberDiff line numberDiff line change
@@ -8,50 +8,57 @@ import "package:ffi/ffi.dart";
88

99
import "types.dart";
1010

11-
typedef sqlite3_open_v2_native_t = Int32 Function(Pointer<Utf8> filename,
12-
Pointer<Pointer<Database>> ppDb, Int32 flags, Pointer<Utf8> vfs);
11+
typedef sqlite3_open_v2_native_t =
12+
Int32 Function(
13+
Pointer<Utf8> filename,
14+
Pointer<Pointer<Database>> ppDb,
15+
Int32 flags,
16+
Pointer<Utf8> vfs,
17+
);
1318

1419
typedef sqlite3_close_v2_native_t = Int32 Function(Pointer<Database> database);
1520

16-
typedef sqlite3_prepare_v2_native_t = Int32 Function(
17-
Pointer<Database> database,
18-
Pointer<Utf8> query,
19-
Int32 nbytes,
20-
Pointer<Pointer<Statement>> statementOut,
21-
Pointer<Pointer<Utf8>> tail);
21+
typedef sqlite3_prepare_v2_native_t =
22+
Int32 Function(
23+
Pointer<Database> database,
24+
Pointer<Utf8> query,
25+
Int32 nbytes,
26+
Pointer<Pointer<Statement>> statementOut,
27+
Pointer<Pointer<Utf8>> tail,
28+
);
2229

2330
typedef sqlite3_step_native_t = Int32 Function(Pointer<Statement> statement);
2431

2532
typedef sqlite3_reset_native_t = Int32 Function(Pointer<Statement> statement);
2633

27-
typedef sqlite3_finalize_native_t = Int32 Function(
28-
Pointer<Statement> statement);
34+
typedef sqlite3_finalize_native_t =
35+
Int32 Function(Pointer<Statement> statement);
2936

3037
typedef sqlite3_errstr_native_t = Pointer<Utf8> Function(Int32 error);
3138

32-
typedef sqlite3_errmsg_native_t = Pointer<Utf8> Function(
33-
Pointer<Database> database);
39+
typedef sqlite3_errmsg_native_t =
40+
Pointer<Utf8> Function(Pointer<Database> database);
3441

35-
typedef sqlite3_column_count_native_t = Int32 Function(
36-
Pointer<Statement> statement);
42+
typedef sqlite3_column_count_native_t =
43+
Int32 Function(Pointer<Statement> statement);
3744

38-
typedef sqlite3_column_name_native_t = Pointer<Utf8> Function(
39-
Pointer<Statement> statement, Int32 columnIndex);
45+
typedef sqlite3_column_name_native_t =
46+
Pointer<Utf8> Function(Pointer<Statement> statement, Int32 columnIndex);
4047

41-
typedef sqlite3_column_decltype_native_t = Pointer<Utf8> Function(
42-
Pointer<Statement> statement, Int32 columnIndex);
48+
typedef sqlite3_column_decltype_native_t =
49+
Pointer<Utf8> Function(Pointer<Statement> statement, Int32 columnIndex);
4350

44-
typedef sqlite3_column_type_native_t = Int32 Function(
45-
Pointer<Statement> statement, Int32 columnIndex);
51+
typedef sqlite3_column_type_native_t =
52+
Int32 Function(Pointer<Statement> statement, Int32 columnIndex);
4653

47-
typedef sqlite3_column_value_native_t = Pointer<Value> Function(
48-
Pointer<Statement> statement, Int32 columnIndex);
54+
typedef sqlite3_column_value_native_t =
55+
Pointer<Value> Function(Pointer<Statement> statement, Int32 columnIndex);
4956

50-
typedef sqlite3_column_double_native_t = Double Function(
51-
Pointer<Statement> statement, Int32 columnIndex);
57+
typedef sqlite3_column_double_native_t =
58+
Double Function(Pointer<Statement> statement, Int32 columnIndex);
5259

53-
typedef sqlite3_column_int_native_t = Int32 Function(
54-
Pointer<Statement> statement, Int32 columnIndex);
60+
typedef sqlite3_column_int_native_t =
61+
Int32 Function(Pointer<Statement> statement, Int32 columnIndex);
5562

56-
typedef sqlite3_column_text_native_t = Pointer<Utf8> Function(
57-
Pointer<Statement> statement, Int32 columnIndex);
63+
typedef sqlite3_column_text_native_t =
64+
Pointer<Utf8> Function(Pointer<Statement> statement, Int32 columnIndex);

samples/ffi/sqlite/lib/src/database.dart

+47-22
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,18 @@ class Database {
2525
bool _open = false;
2626

2727
/// Open a database located at the file [path].
28-
Database(String path,
29-
[int flags = Flags.SQLITE_OPEN_READWRITE | Flags.SQLITE_OPEN_CREATE]) {
28+
Database(
29+
String path, [
30+
int flags = Flags.SQLITE_OPEN_READWRITE | Flags.SQLITE_OPEN_CREATE,
31+
]) {
3032
Pointer<Pointer<types.Database>> dbOut = calloc();
3133
final pathC = Utf8Resource(path.toNativeUtf8());
32-
final int resultCode =
33-
bindings.sqlite3_open_v2(pathC.unsafe(), dbOut, flags, nullptr);
34+
final int resultCode = bindings.sqlite3_open_v2(
35+
pathC.unsafe(),
36+
dbOut,
37+
flags,
38+
nullptr,
39+
);
3440
_database = DatabaseResource(dbOut.value);
3541
calloc.free(dbOut);
3642
pathC.free();
@@ -108,10 +114,12 @@ class Database {
108114
if (errorCode == null) {
109115
return SQLiteException(errorMessage);
110116
}
111-
String errorCodeExplanation =
112-
bindings.sqlite3_errstr(errorCode).toDartString();
117+
String errorCodeExplanation = bindings
118+
.sqlite3_errstr(errorCode)
119+
.toDartString();
113120
return SQLiteException(
114-
"$errorMessage (Code $errorCode: $errorCodeExplanation)");
121+
"$errorMessage (Code $errorCode: $errorCodeExplanation)",
122+
);
115123
}
116124
}
117125

@@ -185,8 +193,10 @@ class Row {
185193
/// By default it returns a dynamically typed value. If [convert] is set to
186194
/// [Convert.StaticType] the value is converted to the static type computed
187195
/// for the column by the query compiler.
188-
dynamic readColumn(String columnName,
189-
{Convert convert = Convert.DynamicType}) {
196+
dynamic readColumn(
197+
String columnName, {
198+
Convert convert = Convert.DynamicType,
199+
}) {
190200
return readColumnByIndex(_columnIndices[columnName]!, convert: convert);
191201
}
192202

@@ -195,16 +205,19 @@ class Row {
195205
/// By default it returns a dynamically typed value. If [convert] is set to
196206
/// [Convert.StaticType] the value is converted to the static type computed
197207
/// for the column by the query compiler.
198-
dynamic readColumnByIndex(int columnIndex,
199-
{Convert convert = Convert.DynamicType}) {
208+
dynamic readColumnByIndex(
209+
int columnIndex, {
210+
Convert convert = Convert.DynamicType,
211+
}) {
200212
_checkIsCurrentRow();
201213

202214
Type dynamicType;
203215
if (convert == Convert.DynamicType) {
204216
dynamicType = _typeFromCode(_statement.columnType(columnIndex));
205217
} else {
206-
dynamicType =
207-
_typeFromText(_statement.columnDecltype(columnIndex).toDartString());
218+
dynamicType = _typeFromText(
219+
_statement.columnDecltype(columnIndex).toDartString(),
220+
);
208221
}
209222

210223
switch (dynamicType) {
@@ -245,8 +258,9 @@ class Row {
245258
void _checkIsCurrentRow() {
246259
if (!_isCurrentRow) {
247260
throw Exception(
248-
"This row is not the current row, reading data from the non-current"
249-
" row is not supported by sqlite.");
261+
"This row is not the current row, reading data from the non-current"
262+
" row is not supported by sqlite.",
263+
);
250264
}
251265
}
252266

@@ -256,8 +270,9 @@ class Row {
256270
}
257271

258272
class DatabaseResource implements Finalizable {
259-
static final NativeFinalizer _finalizer =
260-
NativeFinalizer(bindings.sqlite3_close_v2_native_return_void.cast());
273+
static final NativeFinalizer _finalizer = NativeFinalizer(
274+
bindings.sqlite3_close_v2_native_return_void.cast(),
275+
);
261276

262277
/// [_statement] must never escape [StatementResource], otherwise the
263278
/// [_finalizer] will run prematurely.
@@ -272,19 +287,29 @@ class DatabaseResource implements Finalizable {
272287
return bindings.sqlite3_close_v2(_database);
273288
}
274289

275-
int prepare(Utf8Resource query, int nbytes,
276-
Pointer<Pointer<Statement>> statementOut, Pointer<Pointer<Utf8>> tail) {
290+
int prepare(
291+
Utf8Resource query,
292+
int nbytes,
293+
Pointer<Pointer<Statement>> statementOut,
294+
Pointer<Pointer<Utf8>> tail,
295+
) {
277296
int result = bindings.sqlite3_prepare_v2(
278-
_database, query.unsafe(), nbytes, statementOut, tail);
297+
_database,
298+
query.unsafe(),
299+
nbytes,
300+
statementOut,
301+
tail,
302+
);
279303
return result;
280304
}
281305

282306
Pointer<Utf8> errmsg() => bindings.sqlite3_errmsg(_database);
283307
}
284308

285309
class StatementResource implements Finalizable {
286-
static final NativeFinalizer _finalizer =
287-
NativeFinalizer(bindings.sqlite3_finalize_native_return_void.cast());
310+
static final NativeFinalizer _finalizer = NativeFinalizer(
311+
bindings.sqlite3_finalize_native_return_void.cast(),
312+
);
288313

289314
/// [_statement] must never escape [StatementResource], otherwise the
290315
/// [_finalizer] will run prematurely.

0 commit comments

Comments
 (0)