11import { isToStringTag , toStringTag } from '@hqtsm/class' ;
2- import { type Arr , array , type Const , Int8Ptr } from '@hqtsm/struct' ;
2+ import { type Arr , array , type Const , Int8Ptr , type Ptr } from '@hqtsm/struct' ;
3+ import type { bool , char , int } from '../libc/c.ts' ;
4+ import type { size_t } from '../libc/stddef.ts' ;
5+ import type { OSStatus } from '../MacOSX/MacTypes.ts' ;
36import { errSecSuccess } from './SecBase.ts' ;
47
58/**
@@ -47,7 +50,7 @@ export class CommonError extends Error {
4750 *
4851 * @returns Status code.
4952 */
50- public osStatus ( ) : number {
53+ public osStatus ( ) : OSStatus {
5154 return 0 ;
5255 }
5356
@@ -56,19 +59,19 @@ export class CommonError extends Error {
5659 *
5760 * @returns Error code.
5861 */
59- public unixError ( ) : number {
62+ public unixError ( ) : int {
6063 return 0 ;
6164 }
6265
6366 /**
6467 * Error message.
6568 */
66- public readonly whatBuffer : Arr < number > ;
69+ public readonly whatBuffer : Arr < char > ;
6770
6871 /**
6972 * Error message buffer size.
7073 */
71- public get whatBufferSize ( ) : number {
74+ public get whatBufferSize ( ) : size_t {
7275 return whatBufferSize ;
7376 }
7477
@@ -108,23 +111,23 @@ export class UnixError extends CommonError {
108111 * @param err Error code.
109112 * @param suppresslogging Suppress logging.
110113 */
111- protected constructor ( err : number , suppresslogging : boolean ) ;
114+ protected constructor ( err : int , suppresslogging : bool ) ;
112115
113116 /**
114117 * Constructor.
115118 *
116119 * @param context Context.
117120 */
118- protected constructor ( context : { errno : number } ) ;
121+ protected constructor ( context : { errno : int } ) ;
119122
120123 /**
121124 * Constructor.
122125 *
123126 * @param err Error code or context.
124127 */
125128 protected constructor (
126- err : number | { errno : number } ,
127- suppresslogging ?: boolean ,
129+ err : int | { errno : int } ,
130+ suppresslogging ?: bool ,
128131 ) {
129132 super ( ) ;
130133 let message ;
@@ -148,13 +151,13 @@ export class UnixError extends CommonError {
148151 /**
149152 * Error code.
150153 */
151- public readonly error : number ;
154+ public readonly error : int ;
152155
153- public override osStatus ( ) : number {
156+ public override osStatus ( ) : OSStatus {
154157 return this . error + errSecErrnoBase ;
155158 }
156159
157- public override unixError ( ) : number {
160+ public override unixError ( ) : int {
158161 return this . error ;
159162 }
160163
@@ -163,7 +166,7 @@ export class UnixError extends CommonError {
163166 *
164167 * @returns Error message buffer.
165168 */
166- public what ( ) : Const < Int8Ptr > {
169+ public what ( ) : Const < Ptr < char > > {
167170 return this . whatBuffer ;
168171 }
169172
@@ -173,7 +176,7 @@ export class UnixError extends CommonError {
173176 * @param result Result.
174177 * @param context Context.
175178 */
176- public static check ( result : number , context : { errno : number } ) : void {
179+ public static check ( result : int , context : { errno : int } ) : void {
177180 if ( result === - 1 ) {
178181 UnixError . throwMe ( context ) ;
179182 }
@@ -184,7 +187,7 @@ export class UnixError extends CommonError {
184187 *
185188 * @param err Error code or context.
186189 */
187- public static throwMe ( err : number | { errno : number } ) : never {
190+ public static throwMe ( err : int | { errno : int } ) : never {
188191 throw new UnixError ( typeof err === 'number' ? err : err . errno , false ) ;
189192 }
190193
@@ -193,7 +196,7 @@ export class UnixError extends CommonError {
193196 *
194197 * @param err Error code or context.
195198 */
196- public static throwMeNoLogging ( err : number | { errno : number } ) : never {
199+ public static throwMeNoLogging ( err : int | { errno : int } ) : never {
197200 throw new UnixError ( typeof err === 'number' ? err : err . errno , true ) ;
198201 }
199202
@@ -203,7 +206,7 @@ export class UnixError extends CommonError {
203206 * @param err Error code or context.
204207 * @returns UnixError.
205208 */
206- public static make ( err : number | { errno : number } ) : UnixError {
209+ public static make ( err : int | { errno : int } ) : UnixError {
207210 return new UnixError ( typeof err === 'number' ? err : err . errno , false ) ;
208211 }
209212
@@ -237,7 +240,7 @@ export class MacOSError extends CommonError {
237240 *
238241 * @param err Error code.
239242 */
240- protected constructor ( err : number ) {
243+ protected constructor ( err : int ) {
241244 super ( ) ;
242245 this . error = err ;
243246 const message = `MacOS error: ${ err } ` ;
@@ -250,13 +253,13 @@ export class MacOSError extends CommonError {
250253 /**
251254 * Error code.
252255 */
253- public readonly error : number ;
256+ public readonly error : int ;
254257
255- public override osStatus ( ) : number {
258+ public override osStatus ( ) : OSStatus {
256259 return this . error ;
257260 }
258261
259- public override unixError ( ) : number {
262+ public override unixError ( ) : int {
260263 const { error } = this ;
261264 return ( error >= errSecErrnoBase && error <= errSecErrnoLimit )
262265 ? error - errSecErrnoBase
@@ -268,7 +271,7 @@ export class MacOSError extends CommonError {
268271 *
269272 * @returns Error message buffer.
270273 */
271- public what ( ) : Const < Int8Ptr > {
274+ public what ( ) : Const < Ptr < char > > {
272275 return this . whatBuffer ;
273276 }
274277
@@ -277,7 +280,7 @@ export class MacOSError extends CommonError {
277280 *
278281 * @param status Status.
279282 */
280- public static check ( status : number ) : void {
283+ public static check ( status : OSStatus ) : void {
281284 if ( status !== errSecSuccess ) {
282285 MacOSError . throwMe ( status ) ;
283286 }
@@ -288,7 +291,7 @@ export class MacOSError extends CommonError {
288291 *
289292 * @param err Error code.
290293 */
291- public static throwMe ( err : number ) : never {
294+ public static throwMe ( err : int ) : never {
292295 throw new MacOSError ( err ) ;
293296 }
294297
@@ -298,7 +301,7 @@ export class MacOSError extends CommonError {
298301 * @param err Error code.
299302 * @returns MacOSError.
300303 */
301- public static make ( err : number ) : MacOSError {
304+ public static make ( err : int ) : MacOSError {
302305 return new MacOSError ( err ) ;
303306 }
304307
0 commit comments