Skip to content

Commit d420950

Browse files
committed
Add support for signed int primitive types
1 parent 06f80aa commit d420950

File tree

1 file changed

+41
-1
lines changed

1 file changed

+41
-1
lines changed

src/parser.mts

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,46 @@ export default class Parser {
689689
rustType.swiftRawSignature = 'UInt64';
690690
rustType.kind = RustKind.Primitive;
691691
}
692+
} else if (relevantTypeLine.startsWith('int8_t')) {
693+
rustType = new RustPrimitive();
694+
typelessLineRemainder = relevantTypeLine.substring('int8_t'.length).trim();
695+
if (rustType instanceof RustPrimitive) {
696+
rustType.cSignature = 'int8_t';
697+
rustType.swiftRawSignature = 'Int8';
698+
rustType.kind = RustKind.Primitive;
699+
}
700+
} else if (relevantTypeLine.startsWith('intptr_t')) {
701+
rustType = new RustPrimitive();
702+
typelessLineRemainder = relevantTypeLine.substring('intptr_t'.length).trim();
703+
if (rustType instanceof RustPrimitive) {
704+
rustType.cSignature = 'intptr_t';
705+
rustType.swiftRawSignature = 'Int';
706+
rustType.kind = RustKind.Primitive;
707+
}
708+
} else if (relevantTypeLine.startsWith('int16_t')) {
709+
rustType = new RustPrimitive();
710+
typelessLineRemainder = relevantTypeLine.substring('int16_t'.length).trim();
711+
if (rustType instanceof RustPrimitive) {
712+
rustType.cSignature = 'int16_t';
713+
rustType.swiftRawSignature = 'Int16';
714+
rustType.kind = RustKind.Primitive;
715+
}
716+
} else if (relevantTypeLine.startsWith('int32_t')) {
717+
rustType = new RustPrimitive();
718+
typelessLineRemainder = relevantTypeLine.substring('int32_t'.length).trim();
719+
if (rustType instanceof RustPrimitive) {
720+
rustType.cSignature = 'int32_t';
721+
rustType.swiftRawSignature = 'Int32';
722+
rustType.kind = RustKind.Primitive;
723+
}
724+
} else if (relevantTypeLine.startsWith('int64_t')) {
725+
rustType = new RustPrimitive();
726+
typelessLineRemainder = relevantTypeLine.substring('int64_t'.length).trim();
727+
if (rustType instanceof RustPrimitive) {
728+
rustType.cSignature = 'int64_t';
729+
rustType.swiftRawSignature = 'Int64';
730+
rustType.kind = RustKind.Primitive;
731+
}
692732
} else if (relevantTypeLine.startsWith('bool')) {
693733
rustType = new RustPrimitive();
694734
typelessLineRemainder = relevantTypeLine.substring('bool'.length).trim();
@@ -960,7 +1000,7 @@ export default class Parser {
9601000
*
9611001
*/
9621002

963-
const METHOD_TYPE_ASSOCIATION_PREFIX_REGEX = /^([A-Z][a-zA-Z0-9]*)(_([A-Z_][a-zA-Z0-9]*))*(_(u5|u8|u16|u32|u64|u128|usize|bool)[a-zA-Z0-9]+)?/;
1003+
const METHOD_TYPE_ASSOCIATION_PREFIX_REGEX = /^([A-Z][a-zA-Z0-9]*)(_([A-Z_][a-zA-Z0-9]*))*(_(i5|i8|i16|i32|i64|i128|u5|u8|u16|u32|u64|u128|usize|bool)[a-zA-Z0-9]+)?/;
9641004
const prefixMatches = METHOD_TYPE_ASSOCIATION_PREFIX_REGEX.exec(name);
9651005
if (!prefixMatches) {
9661006
// debug('object-unassociated method name: %s', name);

0 commit comments

Comments
 (0)