Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[C] Add more standard types from ISO C #4076

Merged
merged 1 commit into from
Nov 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions C++/C++.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,6 @@ contexts:
scope: keyword.operator.word.c++

unique-types:
- match: \b(char8_t|char16_t|char32_t|wchar_t|nullptr_t)\b
scope: storage.type.c++
- match: \bclass\b
scope: keyword.declaration.class.c++

Expand Down
11 changes: 10 additions & 1 deletion C++/C.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ variables:
microsoft_types: '__int8|__int16|__int32|__int64'
windows_types: 'APIENTRY|ATOM|BOOL|BOOLEAN|BYTE|CALLBACK|CCHAR|CHAR|COLORREF|CONST|DWORD|DWORDLONG|DWORD_PTR|DWORD32|DWORD64|FLOAT|HACCEL|HALF_PTR|HANDLE|HBITMAP|HBRUSH|HCOLORSPACE|HCONV|HCONVLIST|HCURSOR|HDC|HDDEDATA|HDESK|HDROP|HDWP|HENHMETAFILE|HFILE|HFONT|HGDIOBJ|HGLOBAL|HHOOK|HICON|HINSTANCE|HKEY|HKL|HLOCAL|HMENU|HMETAFILE|HMODULE|HMONITOR|HPALETTE|HPEN|HRESULT|HRGN|HRSRC|HSZ|HWINSTA|HWND|INT|INT_PTR|INT8|INT16|INT32|INT64|LANGID|LCID|LCTYPE|LGRPID|LONG|LONGLONG|LONG_PTR|LONG32|LONG64|LPARAM|LPBOOL|LPBYTE|LPCOLORREF|LPCSTR|LPCTSTR|LPCVOID|LPCWSTR|LPDWORD|LPHANDLE|LPINT|LPLONG|LPSTR|LPTSTR|LPVOID|LPWORD|LPWSTR|LRESULT|PBOOL|PBOOLEAN|PBYTE|PCHAR|PCSTR|PCTSTR|PCWSTR|PDWORD|PDWORDLONG|PDWORD_PTR|PDWORD32|PDWORD64|PFLOAT|PHALF_PTR|PHANDLE|PHKEY|PINT|PINT_PTR|PINT8|PINT16|PINT32|PINT64|PLCID|PLONG|PLONGLONG|PLONG_PTR|PLONG32|PLONG64|POINTER_32|POINTER_64|POINTER_SIGNED|POINTER_UNSIGNED|PSHORT|PSIZE_T|PSSIZE_T|PSTR|PTBYTE|PTCHAR|PTSTR|PUCHAR|PUHALF_PTR|PUINT|PUINT_PTR|PUINT8|PUINT16|PUINT32|PUINT64|PULONG|PULONGLONG|PULONG_PTR|PULONG32|PULONG64|PUSHORT|PVOID|PWCHAR|PWORD|PWSTR|QWORD|SC_HANDLE|SC_LOCK|SERVICE_STATUS_HANDLE|SHORT|SIZE_T|SSIZE_T|TBYTE|TCHAR|UCHAR|UHALF_PTR|UINT|UINT_PTR|UINT8|UINT16|UINT32|UINT64|ULONG|ULONGLONG|ULONG_PTR|ULONG32|ULONG64|UNICODE_STRING|USHORT|USN|VOID|WCHAR|WINAPI|WORD|WPARAM'
stdint: 'int8_t|int16_t|int32_t|int64_t|uint8_t|uint16_t|uint32_t|uint64_t|int_least8_t|int_least16_t|int_least32_t|int_least64_t|uint_least8_t|uint_least16_t|uint_least32_t|uint_least64_t|int_fast8_t|int_fast16_t|int_fast32_t|int_fast64_t|uint_fast8_t|uint_fast16_t|uint_fast32_t|uint_fast64_t|intptr_t|uintptr_t|intmax_t|intmax_t|uintmax_t|uintmax_t'
stddef: 'size_t|ptrdiff_t|max_align_t|nullptr_t'
wchar: 'wchar_t|wint_t|wctrans_t|wctype_t'
uchar: 'mbstate_t|char8_t|char16_t|char32_t'
declspec: '__declspec\(\s*\w+(?:\([^)]+\))?\s*\)'
storage_classes: 'static|extern|register|thread_local|_Thread_local|constexpr|{{declspec}}'
type_qualifier: 'const|volatile'
Expand Down Expand Up @@ -236,12 +239,18 @@ contexts:
scope: keyword.declaration.c
- match: \b({{basic_types}})\b
scope: storage.type.c
- match: \b(u_char|u_short|u_int|u_long|ushort|uint|u_quad_t|quad_t|qaddr_t|caddr_t|daddr_t|dev_t|fixpt_t|blkcnt_t|blksize_t|gid_t|in_addr_t|in_port_t|ino_t|key_t|mode_t|nlink_t|id_t|pid_t|off_t|segsz_t|swblk_t|uid_t|id_t|clock_t|size_t|ssize_t|time_t|useconds_t|suseconds_t|ptrdiff_t)\b
- match: \b(u_char|u_short|u_int|u_long|ushort|uint|u_quad_t|quad_t|qaddr_t|caddr_t|daddr_t|dev_t|fixpt_t|blkcnt_t|blksize_t|gid_t|in_addr_t|in_port_t|ino_t|key_t|mode_t|nlink_t|id_t|pid_t|off_t|segsz_t|swblk_t|uid_t|id_t|clock_t|ssize_t|time_t|useconds_t|suseconds_t)\b
scope: support.type.sys-types.c
- match: \b(pthread_attr_t|pthread_cond_t|pthread_condattr_t|pthread_mutex_t|pthread_mutexattr_t|pthread_once_t|pthread_rwlock_t|pthread_rwlockattr_t|pthread_t|pthread_key_t)\b
scope: support.type.pthread.c
- match: \b({{stdint}})\b
scope: support.type.stdint.c
- match: \b({{stddef}})\b
scope: support.type.stddef.c
- match: \b({{wchar}})\b
scope: support.type.wchar.c
- match: \b({{uchar}})\b
scope: support.type.uchar.c
- match: '\b({{microsoft_types}})\b'
scope: support.type.microsoft.c
- match: '\b({{windows_types}})\b'
Expand Down
36 changes: 36 additions & 0 deletions C++/syntax_test_c.c
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,42 @@ bool still_C_code_here = true;
/* <- storage.type */
/* ^ constant.language */

size_t size_t_var;
/* <- support.type.stddef */

ptrdiff_t ptrdiff_t_var;
/* <- support.type.stddef */

max_align_t max_align_t_var;
/* <- support.type.stddef */

nullptr_t nullptr_t_var;
/* <- support.type.stddef */

wchar_t wchar_t_var;
/* <- support.type.wchar */

wint_t wint_t_var;
/* <- support.type.wchar */

wctrans_t wctrans_t_var;
/* <- support.type.wchar */

wctype_t wctype_t_var;
/* <- support.type.wchar */

mbstate_t mbstate_t_var;
/* <- support.type.uchar */

char8_t char8_t_var;
/* <- support.type.uchar */

char16_t char16_t_var;
/* <- support.type.uchar */

char32_t char32_t_var;
/* <- support.type.uchar */

void *null_pointer1 = NULL;
/* ^ constant.language.null */

Expand Down
39 changes: 33 additions & 6 deletions C++/syntax_test_cpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -460,14 +460,41 @@ bool b;
char ch;
/* <- storage.type */

char16_t ch16;
/* <- storage.type */
size_t size_t_var;
/* <- support.type.stddef */

char32_t ch32;
/* <- storage.type */
ptrdiff_t ptrdiff_t_var;
/* <- support.type.stddef */

wchar_t wch;
/* <- storage.type */
max_align_t max_align_t_var;
/* <- support.type.stddef */

nullptr_t nullptr_t_var;
/* <- support.type.stddef */

wchar_t wchar_t_var;
/* <- support.type.wchar */

wint_t wint_t_var;
/* <- support.type.wchar */

wctrans_t wctrans_t_var;
/* <- support.type.wchar */

wctype_t wctype_t_var;
/* <- support.type.wchar */

mbstate_t mbstate_t_var;
/* <- support.type.uchar */

char8_t char8_t_var;
/* <- support.type.uchar */

char16_t char16_t_var;
/* <- support.type.uchar */

char32_t char32_t_var;
/* <- support.type.uchar */

unsigned int ui;
/* <- storage.type */
Expand Down
39 changes: 33 additions & 6 deletions Objective-C/syntax_test_objc++.mm
Original file line number Diff line number Diff line change
Expand Up @@ -450,14 +450,41 @@ bool foo (bool run=true) {}
char ch;
/* <- storage.type */

char16_t ch16;
/* <- storage.type */
size_t size_t_var;
/* <- support.type.stddef */

char32_t ch32;
/* <- storage.type */
ptrdiff_t ptrdiff_t_var;
/* <- support.type.stddef */

wchar_t wch;
/* <- storage.type */
max_align_t max_align_t_var;
/* <- support.type.stddef */

nullptr_t nullptr_t_var;
/* <- support.type.stddef */

wchar_t wchar_t_var;
/* <- support.type.wchar */

wint_t wint_t_var;
/* <- support.type.wchar */

wctrans_t wctrans_t_var;
/* <- support.type.wchar */

wctype_t wctype_t_var;
/* <- support.type.wchar */

mbstate_t mbstate_t_var;
/* <- support.type.uchar */

char8_t char8_t_var;
/* <- support.type.uchar */

char16_t char16_t_var;
/* <- support.type.uchar */

char32_t char32_t_var;
/* <- support.type.uchar */

unsigned int ui;
/* <- storage.type */
Expand Down
36 changes: 36 additions & 0 deletions Objective-C/syntax_test_objc.m
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,42 @@ int f(int x, \
/* <- storage.type */
/* ^ constant.language */

size_t size_t_var;
/* <- support.type.stddef */

ptrdiff_t ptrdiff_t_var;
/* <- support.type.stddef */

max_align_t max_align_t_var;
/* <- support.type.stddef */

nullptr_t nullptr_t_var;
/* <- support.type.stddef */

wchar_t wchar_t_var;
/* <- support.type.wchar */

wint_t wint_t_var;
/* <- support.type.wchar */

wctrans_t wctrans_t_var;
/* <- support.type.wchar */

wctype_t wctype_t_var;
/* <- support.type.wchar */

mbstate_t mbstate_t_var;
/* <- support.type.uchar */

char8_t char8_t_var;
/* <- support.type.uchar */

char16_t char16_t_var;
/* <- support.type.uchar */

char32_t char32_t_var;
/* <- support.type.uchar */

FOOBAR
hello() {
/* <- meta.function entity.name.function */
Expand Down