Skip to content

Commit 33f02af

Browse files
committed
[core] refactor slightly for pub guidelines
1 parent db5b403 commit 33f02af

File tree

5 files changed

+32
-26
lines changed

5 files changed

+32
-26
lines changed

dargon2_core/analysis_options.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# details and rationale, see
33
# https://github.com/dart-lang/pedantic#enabled-lints.
44

5-
include: package:pedantic/analysis_options.yaml
5+
include: package:lints/recommended.yaml
66

77
# For lint rules and documentation, see http://dart-lang.github.io/linter/lints.
88

dargon2_core/lib/src/native/dargon2_native.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ import 'loaders/lib_loader.dart';
1313
import 'local_binder.dart';
1414

1515
class DArgon2Native extends DArgon2 {
16-
factory DArgon2Native._(LibLoader loader) => DArgon2Native(loader);
17-
1816
DArgon2Native(LibLoader loader) {
1917
LocalBinder.initialize(loader);
2018
}

dargon2_core/lib/src/native/local_binder.dart

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ import 'package:ffi/ffi.dart';
1313
/// This method is used in the [getHash] method and maps to the Dart method [_Argon2Hash].
1414
///
1515
/// This method returns an [Int32] which maps to a Dart [int] for the error/result code.
16-
typedef _argon2_hash = Int32 Function(
17-
Uint32 t_cost,
18-
Uint32 m_cost,
16+
typedef _CArgon2Hash = Int32 Function(
17+
Uint32 tCost,
18+
Uint32 mCost,
1919
Uint32 parallelism,
2020
Pointer<Uint8> pwd,
2121
IntPtr pwdlen,
@@ -29,7 +29,7 @@ typedef _argon2_hash = Int32 Function(
2929
Uint32 version,
3030
);
3131

32-
/// The Dart function definition for [_argon2_hash], and is used to bind the C types
32+
/// The Dart function definition for [_CArgon2Hash], and is used to bind the C types
3333
/// to given Dart inputs.
3434
///
3535
/// All parameters are named in symmetry with the C library's name. [t_cost] refers to the
@@ -44,8 +44,8 @@ typedef _argon2_hash = Int32 Function(
4444
/// Returns an [int] with the result code for the hash, while the real raw hash & encoded hashes
4545
/// are written to the [hash] and [encoded] pointers respectively.
4646
typedef _Argon2Hash = int Function(
47-
int t_cost,
48-
int m_cost,
47+
int tCost,
48+
int mCost,
4949
int parallelism,
5050
Pointer<Uint8> pwd,
5151
int pwdlen,
@@ -64,14 +64,14 @@ typedef _Argon2Hash = int Function(
6464
/// This method is used in the [verifyHash] method and maps to the Dart method [_Argon2Verify].
6565
///
6666
/// This method returns an [Int32] which maps to a Dart [int] for the true/false output.
67-
typedef _argon2_verify = Int32 Function(
67+
typedef _CArgon2Verify = Int32 Function(
6868
Pointer<Utf8> encoded,
6969
Pointer<Uint8> pwd,
7070
IntPtr pwdlen,
7171
Uint32 type,
7272
);
7373

74-
/// The Dart function definition for [_argon2_verify], and is used to bind the C types
74+
/// The Dart function definition for [_CArgon2Verify], and is used to bind the C types
7575
/// to given Dart inputs.
7676
///
7777
/// All parameters are named in symmetry with the C library's name. [pwd] is a [Uint8] pointer for the password byte. [pwdlen] refers to the length
@@ -88,10 +88,10 @@ typedef _Argon2Verify = int Function(
8888
/// This method is used in the [getEncodedHashLength] method and maps to the Dart method [_Argon2Encodedlen].
8989
///
9090
/// This method returns an [IntPtr] which maps to a Dart [int] for the length of the encoded hash
91-
typedef _argon2_encodedlen = IntPtr Function(Uint32 t_cost, Uint32 m_cost,
91+
typedef _CArgon2Encodedlen = IntPtr Function(Uint32 tCost, Uint32 mCost,
9292
Uint32 parallelism, Uint32 saltlen, Uint32 hashlen, Uint32 type);
9393

94-
/// The Dart function definition for [_argon2_encodedlen], and is used to bind the C types
94+
/// The Dart function definition for [_CArgon2Encodedlen], and is used to bind the C types
9595
/// to given Dart inputs.
9696
///
9797
/// All parameters are named in symmetry with the C library's name. [t_cost] refers to the iteration
@@ -100,24 +100,24 @@ typedef _argon2_encodedlen = IntPtr Function(Uint32 t_cost, Uint32 m_cost,
100100
/// refers to the Argon2 Hash Type (i, d, or id).
101101
///
102102
/// Returns an [int], signifying the length of the encoded hash.
103-
typedef _Argon2Encodedlen = int Function(int t_cost, int m_cost,
104-
int parallelism, int saltlen, int hashlen, int type);
103+
typedef _Argon2Encodedlen = int Function(
104+
int tCost, int mCost, int parallelism, int saltlen, int hashlen, int type);
105105

106106
/// A function definition for the Argon2 error message getter. This method will map to the
107107
/// one in the C library, passing the necessary values to the C library via dart:ffi.
108108
/// This method is used in the [getErrorMessage] method and maps to the Dart method [_Argon2ErrorMessage].
109109
///
110110
/// This method returns an [Int32] which maps to a Dart [int] for the length of the encoded hash
111-
typedef _argon2_error_message = Pointer<Utf8> Function(Int32 error_code);
111+
typedef _CArgon2ErrorMessage = Pointer<Utf8> Function(Int32 errorCode);
112112

113-
/// The Dart function definition for [_argon2_error_message], and is used to bind the C types
113+
/// The Dart function definition for [_CArgon2ErrorMessage], and is used to bind the C types
114114
/// to given Dart inputs.
115115
///
116116
/// All parameters are named in symmetry with the C library's name. [error_code] refers to the
117117
/// error code that we are getting the message for.
118118
///
119119
/// Returns an [Pointer] of type [Utf8], signifying the error message string.
120-
typedef _Argon2ErrorMessage = Pointer<Utf8> Function(int error_code);
120+
typedef _Argon2ErrorMessage = Pointer<Utf8> Function(int errorCode);
121121

122122
/// The main class to handle communication between the C methods and their Dart bindings.
123123
/// Unless users are working on a low level and need to directly change the bindings or paths,
@@ -129,16 +129,16 @@ class LocalBinder {
129129
static void initialize(LibLoader libLoader) =>
130130
_privateInstance = LocalBinder._(libLoader);
131131

132-
/// Callable method of type [_Argon2Hash] that binds to [_argon2_hash].
132+
/// Callable method of type [_Argon2Hash] that binds to [_CArgon2Hash].
133133
late _Argon2Hash getHash;
134134

135-
/// Callable method of type [_Argon2Verify] that binds to [_argon2_verify].
135+
/// Callable method of type [_Argon2Verify] that binds to [_CArgon2Verify].
136136
late _Argon2Verify verifyHash;
137137

138-
/// Callable method of type [_Argon2Encodedlen] that binds to [_argon2_encodedlen].
138+
/// Callable method of type [_Argon2Encodedlen] that binds to [_CArgon2Encodedlen].
139139
late _Argon2Encodedlen getEncodedHashLength;
140140

141-
/// Callable method of type [_Argon2ErrorMessage] that binds to [_argon2_error_message].
141+
/// Callable method of type [_Argon2ErrorMessage] that binds to [_CArgon2ErrorMessage].
142142
late _Argon2ErrorMessage getErrorMessage;
143143

144144
/// The getter for the main instance, which returns the private instance if set correctly.
@@ -154,16 +154,16 @@ class LocalBinder {
154154
LocalBinder._(LibLoader libLoader) {
155155
var argon2lib = libLoader.loadLib();
156156
getHash = argon2lib
157-
.lookup<NativeFunction<_argon2_hash>>('argon2_hash')
157+
.lookup<NativeFunction<_CArgon2Hash>>('argon2_hash')
158158
.asFunction<_Argon2Hash>();
159159
verifyHash = argon2lib
160-
.lookup<NativeFunction<_argon2_verify>>('argon2_verify')
160+
.lookup<NativeFunction<_CArgon2Verify>>('argon2_verify')
161161
.asFunction<_Argon2Verify>();
162162
getEncodedHashLength = argon2lib
163-
.lookup<NativeFunction<_argon2_encodedlen>>('argon2_encodedlen')
163+
.lookup<NativeFunction<_CArgon2Encodedlen>>('argon2_encodedlen')
164164
.asFunction<_Argon2Encodedlen>();
165165
getErrorMessage = argon2lib
166-
.lookup<NativeFunction<_argon2_error_message>>('argon2_error_message')
166+
.lookup<NativeFunction<_CArgon2ErrorMessage>>('argon2_error_message')
167167
.asFunction<_Argon2ErrorMessage>();
168168
}
169169
}

dargon2_core/pubspec.lock

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,13 @@ packages:
141141
url: "https://pub.dartlang.org"
142142
source: hosted
143143
version: "0.6.3"
144+
lints:
145+
dependency: "direct dev"
146+
description:
147+
name: lints
148+
url: "https://pub.dartlang.org"
149+
source: hosted
150+
version: "2.0.0"
144151
logging:
145152
dependency: transitive
146153
description:

dargon2_core/pubspec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@ dependencies:
1212
dargon2_interface: '^1.1.0'
1313

1414
dev_dependencies:
15+
lints: ^2.0.0
1516
pedantic: ^1.10.0
1617
test: ^1.16.0

0 commit comments

Comments
 (0)