Skip to content

Commit f80452d

Browse files
add useResult annotation (#762)
1 parent acf1b39 commit f80452d

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

lib/src/libedax.dart

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ class LibEdax {
106106
void edaxGo() => _bindings.edax_go();
107107

108108
/// Get hint.
109+
@useResult
109110
List<Hint> edaxHint(final int n) {
110111
final dst = calloc<bindings.HintList>();
111112
_bindings.edax_hint(n, dst);
@@ -120,6 +121,7 @@ class LibEdax {
120121
}
121122

122123
/// Get book move list.
124+
@useResult
123125
List<Move> edaxGetBookMove() {
124126
final dst = calloc<bindings.MoveList>();
125127
_bindings.edax_get_bookmove(dst);
@@ -134,6 +136,7 @@ class LibEdax {
134136
}
135137

136138
/// Get book move list with position.
139+
@useResult
137140
MoveListWithPosition edaxGetBookMoveWithPosition() {
138141
final dstM = calloc<bindings.MoveList>();
139142
final dstP = calloc<bindings.Position>();
@@ -154,6 +157,7 @@ class LibEdax {
154157
}
155158

156159
/// Get book move list with position by specified moves.
160+
@useResult
157161
MoveListWithPosition edaxGetBookMoveWithPositionByMoves(final String moves) {
158162
final dstM = calloc<bindings.MoveList>();
159163
final dstP = calloc<bindings.Position>();
@@ -189,6 +193,7 @@ class LibEdax {
189193
///
190194
/// __Call [edaxHintPrepare] before calling this function__. <br>
191195
/// If there are no more hints, `hint.isNoMove` will be true.
196+
@useResult
192197
Hint edaxHintNext() {
193198
final dst = calloc<bindings.Hint>();
194199
_bindings.edax_hint_next(dst);
@@ -202,6 +207,7 @@ class LibEdax {
202207
/// __Call [edaxHintPrepare] before calling this function__. <br>
203208
/// If there are no more hints, `hint.isNoMove` will be true. <br>
204209
/// __This function doesn't use Multi-PV search for analyze usecase. This can be faster than [edaxHintNext]__.
210+
@useResult
205211
Hint edaxHintNextNoMultiPvDepth() {
206212
final dst = calloc<bindings.Hint>();
207213
_bindings.edax_hint_next_no_multipv_depth(dst);
@@ -243,6 +249,7 @@ class LibEdax {
243249
/// Get the opening name of the current game, in English.
244250
///
245251
/// e.g. `brightwell`, `tiger`, `rose`, ....
252+
@useResult
246253
String edaxOpening() => _bindings.edax_opening().toDartStr();
247254

248255
/// Use book on `edaxGo`, `edaxHint`, `mode 2`.<br>
@@ -295,6 +302,7 @@ class LibEdax {
295302
}
296303

297304
/// Get current moves.
305+
@useResult
298306
String edaxGetMoves() {
299307
final moves = calloc<Char>(80 * 2 + 1);
300308
final result = _bindings.edax_get_moves(moves).toDartStr();
@@ -303,14 +311,17 @@ class LibEdax {
303311
}
304312

305313
/// Check if the current game is over.
314+
@useResult
306315
bool edaxIsGameOver() => _bindings.edax_is_game_over() == 1;
307316

308317
/// Check if the current player can move.
318+
@useResult
309319
bool edaxCanMove() => _bindings.edax_can_move() == 1;
310320

311321
/// Get the last move.
312322
///
313323
/// NOTE: you have to handle the case that noMove is true.
324+
@useResult
314325
Move edaxGetLastMove() {
315326
final moves = edaxGetMoves();
316327
if (moves.isEmpty) return const Move(0, MoveMark.noMove, 0, 0);
@@ -323,6 +334,7 @@ class LibEdax {
323334
}
324335

325336
/// Get the current board.
337+
@useResult
326338
Board edaxGetBoard() {
327339
final dst = calloc<bindings.Board>();
328340
_bindings.edax_get_board(dst);
@@ -334,11 +346,13 @@ class LibEdax {
334346
/// Get the current player.
335347
/// * 0: BLACK
336348
/// * 1: WHITE
349+
@useResult
337350
int edaxGetCurrentPlayer() => _bindings.edax_get_current_player();
338351

339352
/// Get the opponent player.
340353
/// * 0: BLACK
341354
/// * 1: WHITE
355+
@useResult
342356
int edaxGetOpponentPlayer() {
343357
final currentPlayer = _bindings.edax_get_current_player();
344358
if (currentPlayer == TurnColor.black) {
@@ -349,13 +363,16 @@ class LibEdax {
349363
}
350364

351365
/// Get the current number of discs.
366+
@useResult
352367
int edaxGetDisc(final int color) => _bindings.edax_get_disc(color);
353368

354369
/// Get the legal move count.
370+
@useResult
355371
int edaxGetMobilityCount(final int color) =>
356372
_bindings.edax_get_mobility_count(color);
357373

358374
/// Count bit.
375+
@useResult
359376
int popCount(final int bit) => _bindings.bit_count(bit);
360377

361378
/// Count bestpath with book.
@@ -373,6 +390,7 @@ class LibEdax {
373390
/// * The depth of this feature depends on your book.
374391
/// * The moves which meet up with another moves is counted respectively.
375392
/// * btw, symmetric moves is counted 1 because of edax book structure.
393+
@useResult
376394
CountBestpathResult edaxBookCountBoardBestpath(
377395
final Board board, {
378396
required final int playerColor,
@@ -460,6 +478,7 @@ class LibEdax {
460478
_bindings.edax_book_verbose(verbosity);
461479

462480
/// Check if current player should pass.
481+
@useResult
463482
bool edaxBoardIsPass(final Board board) {
464483
final dstB = calloc<bindings.Board>();
465484
dstB.ref.player = board.player;
@@ -471,6 +490,7 @@ class LibEdax {
471490

472491
/// Get square color.
473492
/// 0 = player, 1 = opponent, 2 = empty.
493+
@useResult
474494
int edaxBoardGetSquareColor(final Board board, final int x) {
475495
final dstB = calloc<bindings.Board>();
476496
dstB.ref.player = board.player;

0 commit comments

Comments
 (0)