From 765dddc0f047caced64ee5c1efb9e1c3593e0599 Mon Sep 17 00:00:00 2001 From: Gammasoft Date: Wed, 31 Jul 2024 14:50:55 +0200 Subject: [PATCH] replace *int_least* by *int* types --- docs/types.md | 30 +-- .../include/xtd/native/linux/mutex.h | 2 +- .../include/xtd/native/linux/semaphore.h | 2 +- .../include/xtd/native/linux/strings.h | 2 +- .../xtd/native/linux/condition_variable.cpp | 2 +- .../src/xtd/native/linux/console.cpp | 112 +++++----- .../src/xtd/native/linux/cryptography.cpp | 6 +- .../src/xtd/native/linux/date_time.cpp | 4 +- .../src/xtd/native/linux/debugger.cpp | 4 +- .../src/xtd/native/linux/directory.cpp | 12 +- .../src/xtd/native/linux/dns.cpp | 12 +- .../src/xtd/native/linux/drive.cpp | 4 +- .../src/xtd/native/linux/environment.cpp | 32 +-- .../src/xtd/native/linux/file.cpp | 6 +- .../src/xtd/native/linux/file_system.cpp | 22 +- .../src/xtd/native/linux/guid.cpp | 8 +- .../src/xtd/native/linux/interlocked.cpp | 20 +- .../native/linux/named_event_wait_handle.cpp | 2 +- .../src/xtd/native/linux/named_mutex.cpp | 2 +- .../src/xtd/native/linux/named_semaphore.cpp | 6 +- .../src/xtd/native/linux/process.cpp | 34 ++-- .../src/xtd/native/linux/socket.cpp | 180 ++++++++-------- .../xtd/native/linux/speech_synthesizer.cpp | 4 +- .../src/xtd/native/linux/system_sound.cpp | 6 +- .../src/xtd/native/linux/thread.cpp | 8 +- .../linux/unnamed_event_wait_handle.cpp | 2 +- .../src/xtd/native/linux/unnamed_mutex.cpp | 2 +- .../xtd/native/linux/unnamed_semaphore.cpp | 6 +- .../include/xtd/native/macos/mutex.h | 2 +- .../include/xtd/native/macos/semaphore.h | 2 +- .../include/xtd/native/macos/strings.h | 2 +- .../xtd/native/macos/condition_variable.mm | 2 +- .../src/xtd/native/macos/console.mm | 116 +++++------ .../src/xtd/native/macos/cryptography.mm | 6 +- .../src/xtd/native/macos/date_time.mm | 4 +- .../src/xtd/native/macos/debugger.mm | 4 +- .../src/xtd/native/macos/directory.mm | 12 +- .../src/xtd/native/macos/dns.mm | 12 +- .../src/xtd/native/macos/drive.mm | 2 +- .../src/xtd/native/macos/environment.mm | 36 ++-- .../src/xtd/native/macos/file.mm | 6 +- .../src/xtd/native/macos/file_system.mm | 22 +- .../src/xtd/native/macos/guid.mm | 4 +- .../src/xtd/native/macos/interlocked.mm | 20 +- .../native/macos/named_event_wait_handle.mm | 2 +- .../src/xtd/native/macos/named_mutex.mm | 2 +- .../src/xtd/native/macos/named_semaphore.mm | 6 +- .../src/xtd/native/macos/process.mm | 34 ++-- .../src/xtd/native/macos/socket.mm | 192 +++++++++--------- .../xtd/native/macos/speech_synthesizer.mm | 2 +- .../src/xtd/native/macos/system_sound.mm | 4 +- .../src/xtd/native/macos/thread.mm | 8 +- .../native/macos/unnamed_event_wait_handle.mm | 2 +- .../src/xtd/native/macos/unnamed_mutex.mm | 2 +- .../src/xtd/native/macos/unnamed_semaphore.mm | 6 +- .../include/xtd/native/posix/mutex.h | 2 +- .../include/xtd/native/posix/semaphore.h | 2 +- .../include/xtd/native/posix/strings.h | 2 +- .../xtd/native/posix/condition_variable.cpp | 2 +- .../src/xtd/native/posix/console.cpp | 114 +++++------ .../src/xtd/native/posix/cryptography.cpp | 6 +- .../src/xtd/native/posix/date_time.cpp | 4 +- .../src/xtd/native/posix/debugger.cpp | 4 +- .../src/xtd/native/posix/directory.cpp | 12 +- .../src/xtd/native/posix/dns.cpp | 12 +- .../src/xtd/native/posix/drive.cpp | 2 +- .../src/xtd/native/posix/environment.cpp | 32 +-- .../src/xtd/native/posix/file.cpp | 6 +- .../src/xtd/native/posix/file_system.cpp | 30 +-- .../src/xtd/native/posix/guid.cpp | 4 +- .../src/xtd/native/posix/interlocked.cpp | 20 +- .../native/posix/named_event_wait_handle.cpp | 2 +- .../src/xtd/native/posix/named_mutex.cpp | 2 +- .../src/xtd/native/posix/named_semaphore.cpp | 6 +- .../src/xtd/native/posix/process.cpp | 44 ++-- .../src/xtd/native/posix/socket.cpp | 190 ++++++++--------- .../xtd/native/posix/speech_synthesizer.cpp | 6 +- .../src/xtd/native/posix/system_sound.cpp | 4 +- .../src/xtd/native/posix/thread.cpp | 8 +- .../posix/unnamed_event_wait_handle.cpp | 2 +- .../src/xtd/native/posix/unnamed_mutex.cpp | 2 +- .../xtd/native/posix/unnamed_semaphore.cpp | 6 +- .../include/xtd/native/unix/mutex.h | 2 +- .../include/xtd/native/unix/semaphore.h | 2 +- .../include/xtd/native/unix/strings.h | 2 +- .../xtd/native/unix/condition_variable.cpp | 2 +- .../src/xtd/native/unix/console.cpp | 112 +++++----- .../src/xtd/native/unix/cryptography.cpp | 6 +- .../src/xtd/native/unix/date_time.cpp | 4 +- .../src/xtd/native/unix/debugger.cpp | 4 +- .../src/xtd/native/unix/directory.cpp | 12 +- .../src/xtd/native/unix/dns.cpp | 12 +- .../src/xtd/native/unix/drive.cpp | 2 +- .../src/xtd/native/unix/environment.cpp | 32 +-- .../src/xtd/native/unix/file.cpp | 6 +- .../src/xtd/native/unix/file_system.cpp | 30 +-- .../src/xtd/native/unix/guid.cpp | 4 +- .../src/xtd/native/unix/interlocked.cpp | 20 +- .../native/unix/named_event_wait_handle.cpp | 2 +- .../src/xtd/native/unix/named_mutex.cpp | 2 +- .../src/xtd/native/unix/named_semaphore.cpp | 6 +- .../src/xtd/native/unix/process.cpp | 44 ++-- .../src/xtd/native/unix/socket.cpp | 190 ++++++++--------- .../xtd/native/unix/speech_synthesizer.cpp | 6 +- .../src/xtd/native/unix/system_sound.cpp | 4 +- .../src/xtd/native/unix/thread.cpp | 8 +- .../native/unix/unnamed_event_wait_handle.cpp | 2 +- .../src/xtd/native/unix/unnamed_mutex.cpp | 2 +- .../src/xtd/native/unix/unnamed_semaphore.cpp | 6 +- .../include/xtd/native/win32/strings.h | 2 +- .../xtd/native/win32/condition_variable.cpp | 2 +- .../src/xtd/native/win32/console.cpp | 90 ++++---- .../src/xtd/native/win32/cryptography.cpp | 6 +- .../src/xtd/native/win32/date_time.cpp | 4 +- .../src/xtd/native/win32/debugger.cpp | 4 +- .../src/xtd/native/win32/directory.cpp | 6 +- .../src/xtd/native/win32/dns.cpp | 14 +- .../src/xtd/native/win32/drive.cpp | 2 +- .../src/xtd/native/win32/environment.cpp | 28 +-- .../src/xtd/native/win32/file.cpp | 8 +- .../src/xtd/native/win32/file_system.cpp | 20 +- .../src/xtd/native/win32/guid.cpp | 4 +- .../src/xtd/native/win32/interlocked.cpp | 20 +- .../native/win32/named_event_wait_handle.cpp | 4 +- .../src/xtd/native/win32/named_mutex.cpp | 4 +- .../src/xtd/native/win32/named_semaphore.cpp | 8 +- .../src/xtd/native/win32/process.cpp | 18 +- .../src/xtd/native/win32/socket.cpp | 136 ++++++------- .../xtd/native/win32/speech_synthesizer.cpp | 2 +- .../src/xtd/native/win32/system_sound.cpp | 2 +- .../src/xtd/native/win32/thread.cpp | 8 +- .../win32/unnamed_event_wait_handle.cpp | 4 +- .../src/xtd/native/win32/unnamed_mutex.cpp | 4 +- .../xtd/native/win32/unnamed_semaphore.cpp | 8 +- .../xtd/native/address_family_constants.h | 60 +++--- .../xtd/native/assert_dialog_results.h | 6 +- .../include/xtd/native/condition_variable.h | 2 +- .../include/xtd/native/console.h | 58 +++--- .../include/xtd/native/console_color.h | 34 ++-- .../include/xtd/native/console_special_key.h | 8 +- .../native/constant_special_item_id_list.h | 116 +++++------ .../include/xtd/native/cryptography.h | 2 +- .../include/xtd/native/date_time.h | 42 ++-- .../include/xtd/native/debugger.h | 4 +- .../include/xtd/native/directory.h | 12 +- src/xtd.core.native/include/xtd/native/dns.h | 6 +- .../include/xtd/native/drive.h | 2 +- .../include/xtd/native/drive_type.h | 14 +- .../include/xtd/native/environment.h | 26 +-- .../xtd/native/environment_variable_target.h | 6 +- src/xtd.core.native/include/xtd/native/file.h | 6 +- .../include/xtd/native/file_attribute.h | 44 ++-- .../include/xtd/native/file_permission.h | 38 ++-- .../include/xtd/native/file_system.h | 16 +- src/xtd.core.native/include/xtd/native/guid.h | 2 +- .../include/xtd/native/interlocked.h | 24 +-- .../xtd/native/named_event_wait_handle.h | 2 +- .../include/xtd/native/named_mutex.h | 2 +- .../include/xtd/native/named_semaphore.h | 6 +- .../include/xtd/native/platform_ids.h | 36 ++-- .../include/xtd/native/priority_class.h | 12 +- .../include/xtd/native/process.h | 12 +- .../xtd/native/process_creation_flags.h | 34 ++-- .../include/xtd/native/process_window_style.h | 8 +- .../xtd/native/protocol_type_constants.h | 50 ++--- .../xtd/native/select_mode_constants.h | 6 +- .../include/xtd/native/socket.h | 56 ++--- .../xtd/native/socket_error_constants.h | 94 ++++----- .../native/socket_option_level_constants.h | 10 +- .../xtd/native/socket_option_name_constants.h | 90 ++++---- .../xtd/native/socket_shutdown_constants.h | 6 +- .../xtd/native/socket_type_constants.h | 12 +- .../include/xtd/native/sounds.h | 20 +- .../include/xtd/native/system_sound.h | 2 +- .../include/xtd/native/thread.h | 6 +- .../xtd/native/unnamed_event_wait_handle.h | 2 +- .../include/xtd/native/unnamed_mutex.h | 2 +- .../include/xtd/native/unnamed_semaphore.h | 6 +- .../include/xtd/native/value_types.h | 8 +- src/xtd.core/include/xtd/byte.h | 2 +- src/xtd.core/include/xtd/int16.h | 2 +- src/xtd.core/include/xtd/int32.h | 2 +- src/xtd.core/include/xtd/int64.h | 2 +- src/xtd.core/include/xtd/sbyte.h | 2 +- src/xtd.core/include/xtd/slong.h | 2 +- src/xtd.core/include/xtd/uint16.h | 2 +- src/xtd.core/include/xtd/uint32.h | 2 +- src/xtd.core/include/xtd/uint64.h | 2 +- src/xtd.core/include/xtd/ulong.h | 2 +- .../include/xtd/drawing/native/fl_dc.h | 34 ++-- .../include/xtd/drawing/native/fl_pen.h | 14 +- .../src/xtd/drawing/native/fltk/brush.cpp | 2 +- .../src/xtd/drawing/native/fltk/font.cpp | 8 +- .../xtd/drawing/native/fltk/font_family.cpp | 8 +- .../src/xtd/drawing/native/fltk/graphics.cpp | 24 +-- .../src/xtd/drawing/native/fltk/pen.cpp | 2 +- .../xtd/drawing/native/fltk/system_colors.cpp | 8 +- .../src/xtd/forms/native/cocoa/file_dialog.mm | 6 +- .../src/xtd/forms/native/cocoa/message_box.mm | 24 +-- .../src/xtd/forms/native/fltk/application.cpp | 4 +- .../xtd/forms/native/fltk/color_dialog.cpp | 2 +- .../src/xtd/forms/native/fltk/control.cpp | 10 +- .../xtd/forms/native/fltk/control_handler.h | 14 +- .../src/xtd/forms/native/fltk/fl_timer.h | 2 +- .../src/xtd/forms/native/fltk/font_dialog.cpp | 2 +- .../src/xtd/forms/native/fltk/form.cpp | 4 +- .../src/xtd/forms/native/fltk/message_box.cpp | 20 +- .../xtd/forms/native/fltk/progress_bar.cpp | 6 +- .../src/xtd/forms/native/fltk/screen.cpp | 2 +- .../src/xtd/forms/native/fltk/timer.cpp | 2 +- .../src/xtd/forms/native/fltk/track_bar.cpp | 14 +- 211 files changed, 1872 insertions(+), 1872 deletions(-) diff --git a/docs/types.md b/docs/types.md index 63cc76e3189..a8ccfc3ae31 100644 --- a/docs/types.md +++ b/docs/types.md @@ -12,30 +12,30 @@ For more performance prefere used `unboxed` type. Used `boxed` type when necessa ## Types list -| Unboxed type | Boxed type | C++11 type | C++ standard type | Size in bytes | Value | -| --------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------- | ----------------- | ---------------------------------------------- | ---------------- | ----------------------------------------------------------------------------- | -| bool | [xtd::boolean_object](https://gammasoft71.github.io/xtd/reference_guides/latest/group__system.html#ga020fbeceaf011505de3ac30168375664) | bool | bool | 1 | Represents a boolean value. | -| char | [xtd::char_object](https://gammasoft71.github.io/xtd/reference_guides/latest/group__system.html#gaa1de2ea24769d6024df6172bd9355575) | char | char | 1 | Represents a characters. | +| Unboxed type | Boxed type | C++11 type | C++ standard type | Size in bytes | Value | +| ------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------- | ----------------- | ---------------------------------------------- | ---------------- | ----------------------------------------------------------------------------- | +| bool | [xtd::boolean_object](https://gammasoft71.github.io/xtd/reference_guides/latest/group__system.html#ga020fbeceaf011505de3ac30168375664) | bool | bool | 1 | Represents a boolean value. | +| char | [xtd::char_object](https://gammasoft71.github.io/xtd/reference_guides/latest/group__system.html#gaa1de2ea24769d6024df6172bd9355575) | char | char | 1 | Represents a characters. | | [xtd::char8](https://gammasoft71.github.io/xtd/reference_guides/latest/group__types.html#ga1259090c8918e75847a8cb2a64b8912a) | [xtd::char8_object](https://gammasoft71.github.io/xtd/reference_guides/latest/group__system.html#ga7852d6b3b5f17dbe722a606cd06a1bce) | char8_t | char | 1 | Represents a unicode characters. | | [xtd::char16](https://gammasoft71.github.io/xtd/reference_guides/latest/group__types.html#ga39d5c4947c807e5f78b8a9abe3692570) | [xtd::char16_object](https://gammasoft71.github.io/xtd/reference_guides/latest/group__system.html#ga0ff1609eee070b97921316138e506ec9) | char16_t | short | 2 | Represents a unicode characters. | | [xtd::char32](https://gammasoft71.github.io/xtd/reference_guides/latest/group__types.html#ga989a1148b6ff15567dca430966b17c92) | [xtd::char32_object](https://gammasoft71.github.io/xtd/reference_guides/latest/group__system.html#ga7f4267b36e2ac25a835ea91593bd0a2d) | char32_t | int | 4 | Represents a unicode characters. | | [xtd::wchar](https://gammasoft71.github.io/xtd/reference_guides/latest/group__types.html#ga442d09ba9c8530e03cd30e729738e0fa) | [xtd::wchar_object](https://gammasoft71.github.io/xtd/reference_guides/latest/group__system.html#ga60f9b7c5831e5f533c5f5a6b35e22478) | wchar_t | short - or - int *(1)* | 2 - or - 4 *(1)* | Represents a unicode characters. | -| [xtd::byte](https://gammasoft71.github.io/xtd/reference_guides/latest/group__types.html#gabb9d3031d62e3725b4265c7e5d2a98e1) | [xtd::byte_object](https://gammasoft71.github.io/xtd/reference_guides/latest/group__system.html#ga3fc22386b24ad6ba85daeff85cb79661) | uint_least8_t | unsigned char | 1 | Represents a 8-bit unsigned integer. | -| [xtd::int16](https://gammasoft71.github.io/xtd/reference_guides/latest/group__types.html#ga09d26135a9af4f7a5f4cae382627d6d1) | [xtd::int16_object](https://gammasoft71.github.io/xtd/reference_guides/latest/group__system.html#ga9b68e8829910e613dac8a6148477ad7c) | int_least16_t | short | 2 | Represents a 16-bit signed integer. | -| [xtd::int32](https://gammasoft71.github.io/xtd/reference_guides/latest/group__types.html#ga205462e259a4eca1545511085c2c350e) | [xtd::int32_object](https://gammasoft71.github.io/xtd/reference_guides/latest/group__system.html#ga4be46d51c646a03427dc92e2bf35cd38) | int_least32_t | int | 4 | Represents a 32-bit signed integer. | -| [xtd::int64](https://gammasoft71.github.io/xtd/reference_guides/latest/group__types.html#ga2f2888f55e58cac4c07eb490db7868c4) | [xtd::int64_object](https://gammasoft71.github.io/xtd/reference_guides/latest/group__system.html#ga6186e201158c8307f663ac4d00466b86) | int_least64_t | long long. | 8 | Represents a 64-bit signed integer. | +| [xtd::byte](https://gammasoft71.github.io/xtd/reference_guides/latest/group__types.html#gabb9d3031d62e3725b4265c7e5d2a98e1) | [xtd::byte_object](https://gammasoft71.github.io/xtd/reference_guides/latest/group__system.html#ga3fc22386b24ad6ba85daeff85cb79661) | uint8_t | unsigned char | 1 | Represents a 8-bit unsigned integer. | +| [xtd::int16](https://gammasoft71.github.io/xtd/reference_guides/latest/group__types.html#ga09d26135a9af4f7a5f4cae382627d6d1) | [xtd::int16_object](https://gammasoft71.github.io/xtd/reference_guides/latest/group__system.html#ga9b68e8829910e613dac8a6148477ad7c) | int16_t | short | 2 | Represents a 16-bit signed integer. | +| [xtd::int32](https://gammasoft71.github.io/xtd/reference_guides/latest/group__types.html#ga205462e259a4eca1545511085c2c350e) | [xtd::int32_object](https://gammasoft71.github.io/xtd/reference_guides/latest/group__system.html#ga4be46d51c646a03427dc92e2bf35cd38) | int32_t | int | 4 | Represents a 32-bit signed integer. | +| [xtd::int64](https://gammasoft71.github.io/xtd/reference_guides/latest/group__types.html#ga2f2888f55e58cac4c07eb490db7868c4) | [xtd::int64_object](https://gammasoft71.github.io/xtd/reference_guides/latest/group__system.html#ga6186e201158c8307f663ac4d00466b86) | int64_t | long long. | 8 | Represents a 64-bit signed integer. | | [xtd::intptr](https://gammasoft71.github.io/xtd/reference_guides/latest/group__types.html#ga9afc9e1ad3e9f8aba95c76280be5e16e) | [xtd::intptr_object](https://gammasoft71.github.io/xtd/reference_guides/latest/group__system.html#ga9745a7872319ad41c528993da735ad1f) | intmax_t | int* - or - long long* *(2)* | 4 - or - 8 *(2)* | Represent a pointer or a handle. | -| [xtd::sbyte](https://gammasoft71.github.io/xtd/reference_guides/latest/group__types.html#ga37e983ceedf5a7f73bc4568eaeae0aa2) | [xtd::sbyte_object](https://gammasoft71.github.io/xtd/reference_guides/latest/group__system.html#gaf42f67c02d59e5180de4a25c387c4ce7) | int_least8_t | char | 1 | Represents a 8-bit signed integer. | -| [xtd::uint16](https://gammasoft71.github.io/xtd/reference_guides/latest/group__types.html#gad8523b51611f0fac793f78f16b155b21) | [xtd::uint16_object](https://gammasoft71.github.io/xtd/reference_guides/latest/group__system.html#gad2d2369e4e7ed6c9add6ed934441941b) | uint_least16_t | unsigned short | 2 | Represents a 16-bit unsigned integer. | -| [xtd::uint32](https://gammasoft71.github.io/xtd/reference_guides/latest/group__types.html#ga41c5d8b5d999ac5a2ff06fe57f38d5f5) | [xtd::uint32_object](https://gammasoft71.github.io/xtd/reference_guides/latest/group__system.html#gaf4dd9a26c2e1c77bc7ea42452ba0794f) | uint_least32_t | unsigned int | 4 | Represents a 32-bit unsigned integer. | -| [xtd::uint64](https://gammasoft71.github.io/xtd/reference_guides/latest/group__types.html#gab5833228ed21371660af349c9b1fe797) | [xtd::uint64_object](https://gammasoft71.github.io/xtd/reference_guides/latest/group__system.html#gae01c8c184846ba16e80a4c5af471be3b) | uint_least64_t | unsigned long long | 8 | Represents a 64-bit unsigned integer. | +| [xtd::sbyte](https://gammasoft71.github.io/xtd/reference_guides/latest/group__types.html#ga37e983ceedf5a7f73bc4568eaeae0aa2) | [xtd::sbyte_object](https://gammasoft71.github.io/xtd/reference_guides/latest/group__system.html#gaf42f67c02d59e5180de4a25c387c4ce7) | int8_t | char | 1 | Represents a 8-bit signed integer. | +| [xtd::uint16](https://gammasoft71.github.io/xtd/reference_guides/latest/group__types.html#gad8523b51611f0fac793f78f16b155b21) | [xtd::uint16_object](https://gammasoft71.github.io/xtd/reference_guides/latest/group__system.html#gad2d2369e4e7ed6c9add6ed934441941b) | uint16_t | unsigned short | 2 | Represents a 16-bit unsigned integer. | +| [xtd::uint32](https://gammasoft71.github.io/xtd/reference_guides/latest/group__types.html#ga41c5d8b5d999ac5a2ff06fe57f38d5f5) | [xtd::uint32_object](https://gammasoft71.github.io/xtd/reference_guides/latest/group__system.html#gaf4dd9a26c2e1c77bc7ea42452ba0794f) | uint32_t | unsigned int | 4 | Represents a 32-bit unsigned integer. | +| [xtd::uint64](https://gammasoft71.github.io/xtd/reference_guides/latest/group__types.html#gab5833228ed21371660af349c9b1fe797) | [xtd::uint64_object](https://gammasoft71.github.io/xtd/reference_guides/latest/group__system.html#gae01c8c184846ba16e80a4c5af471be3b) | uint64_t | unsigned long long | 8 | Represents a 64-bit unsigned integer. | | [xtd::uintptr](https://gammasoft71.github.io/xtd/reference_guides/latest/group__types.html#ga4393f509bf08c7e4ad25357e80f3ffff) | [xtd::uintptr_object](https://gammasoft71.github.io/xtd/reference_guides/latest/group__system.html#ga35c697da631eefc57a902da5ccc07e68) | uintmax_t | unsigned int* - or - unsigned long long* *(2)* | 4 - or - 8 *(2)* | Represent an unsigned pointer or a handle. | -| float | [xtd::single_object](https://gammasoft71.github.io/xtd/reference_guides/latest/group__system.html#ga84ac56442074e9ba86390626d8f83b7b) | float | float | 4 | Represents a single-precision floating-point number. | -| double | [xtd::double_object](https://gammasoft71.github.io/xtd/reference_guides/latest/group__system.html#ga9c0f11ebf71e3121a21e785a0c97c99d) | double | double | 8 | Represents a double-precision floating-point number. | +| float | [xtd::single_object](https://gammasoft71.github.io/xtd/reference_guides/latest/group__system.html#ga84ac56442074e9ba86390626d8f83b7b) | float | float | 4 | Represents a single-precision floating-point number. | +| double | [xtd::double_object](https://gammasoft71.github.io/xtd/reference_guides/latest/group__system.html#ga9c0f11ebf71e3121a21e785a0c97c99d) | double | double | 8 | Represents a double-precision floating-point number. | | [xtd::decimal](https://gammasoft71.github.io/xtd/reference_guides/latest/group__types.html#ga1f5ab1e551070e04d6450399622c6f29) *(3)* | [xtd::decimal_object](https://gammasoft71.github.io/xtd/reference_guides/latest/group__system.html#ga19d2fddd55b417489b4cf929a40a293e) | long double *(3)* | long double *(3)* | 8 - or -16 *(3)* | Represents a double-precision floating-point number. | | [xtd::size](https://gammasoft71.github.io/xtd/reference_guides/latest/group__types.html#ga92c4f59ae39104d31ce9c0c20810001d) | [xtd::size_object](https://gammasoft71.github.io/xtd/reference_guides/latest/group__system.html#ga38c2e723413a561059a0c53c07f167af) | size_t | result of the sizeof operator *(2)* | 4 - or - 8 *(2)* | Represent an unsigned pointer or a handle. | | [xtd::date_time](https://gammasoft71.github.io/xtd/reference_guides/latest/classxtd_1_1date__time.html) | [xtd::date_time](https://gammasoft71.github.io/xtd/reference_guides/latest/classxtd_1_1date__time.html) | / | / | 8 | Represents an instant in time, typically expressed as a date and time of day. | -| const char* | [xtd::ustring](https://gammasoft71.github.io/xtd/reference_guides/latest/classxtd_1_1ustring.html) | std::string | std::string *(4)* | variable | Represents text as a series of unicode characters. | +| const char* | [xtd::ustring](https://gammasoft71.github.io/xtd/reference_guides/latest/classxtd_1_1ustring.html) | std::string | std::string *(4)* | variable | Represents text as a series of unicode characters. | *(1) Depend of OS : if build on Windows is 2 bytes, if build on Linux or many other non-Windows systems is 4 bytes.* diff --git a/src/xtd.core.native.linux/include/xtd/native/linux/mutex.h b/src/xtd.core.native.linux/include/xtd/native/linux/mutex.h index 1cffb25c784..cd0bb5e013f 100644 --- a/src/xtd.core.native.linux/include/xtd/native/linux/mutex.h +++ b/src/xtd.core.native.linux/include/xtd/native/linux/mutex.h @@ -12,7 +12,7 @@ inline static const pthread_mutex_t* MUTEX_FAILED = reinterpret_cast(-1); -static inline int pthread_mutex_milliseconds_timedlock(pthread_mutex_t* mut, int_least32_t milliseconds_timeout) { +static inline int pthread_mutex_milliseconds_timedlock(pthread_mutex_t* mut, int32_t milliseconds_timeout) { struct timespec timeout; clock_gettime(CLOCK_REALTIME, &timeout); timeout.tv_sec += milliseconds_timeout / 1000; diff --git a/src/xtd.core.native.linux/include/xtd/native/linux/semaphore.h b/src/xtd.core.native.linux/include/xtd/native/linux/semaphore.h index 039f23908e9..fb2fd266153 100644 --- a/src/xtd.core.native.linux/include/xtd/native/linux/semaphore.h +++ b/src/xtd.core.native.linux/include/xtd/native/linux/semaphore.h @@ -12,7 +12,7 @@ inline static constexpr size_t PSEMNAMLEN = 31; -static inline int sem_milliseconds_timedwait(sem_t *sem, int_least32_t milliseconds_timeout) { +static inline int sem_milliseconds_timedwait(sem_t *sem, int32_t milliseconds_timeout) { struct timespec timeout; clock_gettime(CLOCK_REALTIME, &timeout); timeout.tv_sec += milliseconds_timeout / 1000; diff --git a/src/xtd.core.native.linux/include/xtd/native/linux/strings.h b/src/xtd.core.native.linux/include/xtd/native/linux/strings.h index 2011fb5be74..9988121d3c0 100644 --- a/src/xtd.core.native.linux/include/xtd/native/linux/strings.h +++ b/src/xtd.core.native.linux/include/xtd/native/linux/strings.h @@ -135,7 +135,7 @@ namespace xtd::native::linux { return result; } - static bool try_parse(const std::string& str, int_least32_t& value) noexcept { + static bool try_parse(const std::string& str, int32_t& value) noexcept { try { value = std::atoi(str.c_str()); return true; diff --git a/src/xtd.core.native.linux/src/xtd/native/linux/condition_variable.cpp b/src/xtd.core.native.linux/src/xtd/native/linux/condition_variable.cpp index ced1bc86964..695064a40cd 100644 --- a/src/xtd.core.native.linux/src/xtd/native/linux/condition_variable.cpp +++ b/src/xtd.core.native.linux/src/xtd/native/linux/condition_variable.cpp @@ -31,7 +31,7 @@ void condition_variable::pulse_all(intmax_t handle) { pthread_cond_broadcast(reinterpret_cast(handle)); } -bool condition_variable::wait(intmax_t handle, intmax_t critical_section_handle, int_least32_t milliseconds_timeout) { +bool condition_variable::wait(intmax_t handle, intmax_t critical_section_handle, int32_t milliseconds_timeout) { if (handle == reinterpret_cast(MUTEX_FAILED)) return false; if (reinterpret_cast(critical_section_handle) == nullptr) return false; diff --git a/src/xtd.core.native.linux/src/xtd/native/linux/console.cpp b/src/xtd.core.native.linux/src/xtd/native/linux/console.cpp index cff27b31d52..d2f26568d6b 100644 --- a/src/xtd.core.native.linux/src/xtd/native/linux/console.cpp +++ b/src/xtd.core.native.linux/src/xtd/native/linux/console.cpp @@ -21,8 +21,8 @@ using namespace xtd::native; namespace { auto treat_control_c_as_input = false; - std::vector signal_couter_; - std::function user_cancel_callback; + std::vector signal_couter_; + std::function user_cancel_callback; struct console_intercept_signals { private: @@ -36,14 +36,14 @@ namespace { ::signal(signal.first, SIG_DFL); } - static void signal_handler(int_least32_t signal) { + static void signal_handler(int32_t signal) { ::signal(signal, console_intercept_signals::signal_handler); if (treat_control_c_as_input) signal_couter_.push_back(signal_keys_[signal]); else if (user_cancel_callback && user_cancel_callback(signal_keys_[signal]) == false) exit(EXIT_FAILURE); } // The SIGINT signal catcher conflicts with with xtd::environment::cancel_interrupt signal... - inline static std::map signal_keys_ {{SIGQUIT, CONSOLE_SPECIAL_KEY_CTRL_BS}, {SIGTSTP, CONSOLE_SPECIAL_KEY_CTRL_Z}/*, {SIGINT, CONSOLE_SPECIAL_KEY_CTRL_C}*/}; + inline static std::map signal_keys_ {{SIGQUIT, CONSOLE_SPECIAL_KEY_CTRL_BS}, {SIGTSTP, CONSOLE_SPECIAL_KEY_CTRL_Z}/*, {SIGINT, CONSOLE_SPECIAL_KEY_CTRL_C}*/}; static console_intercept_signals console_intercept_signals_; }; @@ -69,7 +69,7 @@ namespace { return tcsetattr(0, TCSANOW, &status) == 0; } - int_least32_t getch() { + int32_t getch() { if (peek_character != -1) { auto character = peek_character; peek_character = -1; @@ -146,7 +146,7 @@ namespace { } - int_least8_t peek_character {-1}; + int8_t peek_character {-1}; std::vector statuses; }; @@ -157,8 +157,8 @@ namespace { class input_list { public: input_list() {} - explicit input_list(const std::list& chars) : chars(chars) {} - explicit input_list(std::initializer_list il) : chars(il) {} + explicit input_list(const std::list& chars) : chars(chars) {} + explicit input_list(std::initializer_list il) : chars(il) {} input_list(const input_list& il) : chars(il.chars) {} input_list& operator =(const input_list& il) { @@ -169,8 +169,8 @@ namespace { bool operator ==(const input_list& il) const noexcept {return chars == il.chars;} bool operator !=(const input_list& il) const noexcept {return chars != il.chars;} - using const_iterator = std::list::const_iterator; - using iterator = std::list::iterator; + using const_iterator = std::list::const_iterator; + using iterator = std::list::iterator; const_iterator cbegin() const {return chars.begin();} const_iterator cend() const {return chars.end();} @@ -179,18 +179,18 @@ namespace { const_iterator end() const {return chars.end();} iterator end() {return chars.end();} - void add(int_least32_t c) {chars.push_back(c);} - void add_front(int_least32_t c) {chars.push_front(c);} - void remove(int_least32_t c) {chars.remove(c);} - int_least32_t count() const {return static_cast(chars.size());} - int_least32_t pop() { int_least32_t c = chars.front(); chars.erase(chars.begin()); return c;} + void add(int32_t c) {chars.push_back(c);} + void add_front(int32_t c) {chars.push_front(c);} + void remove(int32_t c) {chars.remove(c);} + int32_t count() const {return static_cast(chars.size());} + int32_t pop() { int32_t c = chars.front(); chars.erase(chars.begin()); return c;} void clear() {chars.clear();} bool is_empty() const {return chars.empty();} std::string to_string() const { std::stringstream result; - std::list::const_iterator iterator = chars.begin(); + std::list::const_iterator iterator = chars.begin(); while (iterator != chars.end()) { if (char(*iterator & 0xFF) == 27) result << "^["; @@ -216,7 +216,7 @@ namespace { } private: - std::list chars; + std::list chars; }; key_info(const key_info& ki) : key_(ki.key_), key_char_(ki.key_char_), has_alt_modifier_(ki.has_alt_modifier_), has_control_modifier_(ki.has_control_modifier_), has_shift_modifier_(ki.has_shift_modifier_) {} @@ -269,31 +269,31 @@ namespace { std::string to_string() const { std::stringstream result; - result << "{key=" << std::hex << static_cast(key_) << ", key_char=" << std::dec << static_cast(key_char_) << ", has_alt_modifier=" << to_string(has_alt_modifier_) << ", has_control_modifier=" << to_string(has_control_modifier_) << ", has_shift_modifier=" << to_string(has_shift_modifier_) << "}"; + result << "{key=" << std::hex << static_cast(key_) << ", key_char=" << std::dec << static_cast(key_char_) << ", has_alt_modifier=" << to_string(has_alt_modifier_) << ", has_control_modifier=" << to_string(has_control_modifier_) << ", has_shift_modifier=" << to_string(has_shift_modifier_) << "}"; return result.str(); } private: key_info() : key_(U'0'), key_char_(U'0'), has_alt_modifier_(false), has_control_modifier_(false), has_shift_modifier_(false) {} - key_info(int_least32_t key, int_least32_t key_char) : key_(key), key_char_(key_char), has_alt_modifier_(false), has_control_modifier_(false), has_shift_modifier_(false) {} - key_info(int_least32_t key, int_least32_t key_char, bool has_alt_modifier, bool has_control_modifier, bool has_shift_modifier) : key_(key), key_char_(key_char), has_alt_modifier_(has_alt_modifier), has_control_modifier_(has_control_modifier), has_shift_modifier_(has_shift_modifier) {} + key_info(int32_t key, int32_t key_char) : key_(key), key_char_(key_char), has_alt_modifier_(false), has_control_modifier_(false), has_shift_modifier_(false) {} + key_info(int32_t key, int32_t key_char, bool has_alt_modifier, bool has_control_modifier, bool has_shift_modifier) : key_(key), key_char_(key_char), has_alt_modifier_(has_alt_modifier), has_control_modifier_(has_control_modifier), has_shift_modifier_(has_shift_modifier) {} static std::string to_string(bool b) {return b ? "true" : "false";} - static int_least32_t to_key(input_list& inputs) { - int_least32_t result = 0; - int_least32_t index = 1; + static int32_t to_key(input_list& inputs) { + int32_t result = 0; + int32_t index = 1; for (auto c : inputs) result |= (c & 0xFF) << (8 * index--); inputs.clear(); return result; } - static key_info to_key_info(int_least32_t key) { + static key_info to_key_info(int32_t key) { return to_key_info(key, false); } - static key_info to_key_info(int_least32_t key, bool alt) { + static key_info to_key_info(int32_t key, bool alt) { // Ctrl + Space if (key == 0) return key_info(' ', ' ', false, true, false); @@ -588,12 +588,12 @@ namespace { auto window_width = 80; } -int_least32_t console::background_color() { +int32_t console::background_color() { return ::background_color; } -bool console::background_color(int_least32_t color) { - static auto colors = std::map {{CONSOLE_COLOR_DEFAULT, "\x1b[49m"}, {CONSOLE_COLOR_BLACK, "\x1b[40m"}, {CONSOLE_COLOR_DARK_BLUE, "\x1b[44m"}, {CONSOLE_COLOR_DARK_GREEN, "\x1b[42m"}, {CONSOLE_COLOR_DARK_CYAN, "\x1b[46m"}, {CONSOLE_COLOR_DARK_RED, "\x1b[41m"}, {CONSOLE_COLOR_DARK_MAGENTA, "\x1b[45m"}, {CONSOLE_COLOR_DARK_YELLOW, "\x1b[43m"}, {CONSOLE_COLOR_GRAY, "\x1b[47m"}, {CONSOLE_COLOR_DARK_GRAY, "\x1b[100m"}, {CONSOLE_COLOR_BLUE, "\x1b[104m"}, {CONSOLE_COLOR_GREEN, "\x1b[102m"}, {CONSOLE_COLOR_CYAN, "\x1b[106m"}, {CONSOLE_COLOR_RED, "\x1b[101m"}, {CONSOLE_COLOR_MAGENTA, "\x1b[105m"}, {CONSOLE_COLOR_YELLOW, "\x1b[103m"}, {CONSOLE_COLOR_WHITE, "\x1b[107m"}}; +bool console::background_color(int32_t color) { + static auto colors = std::map {{CONSOLE_COLOR_DEFAULT, "\x1b[49m"}, {CONSOLE_COLOR_BLACK, "\x1b[40m"}, {CONSOLE_COLOR_DARK_BLUE, "\x1b[44m"}, {CONSOLE_COLOR_DARK_GREEN, "\x1b[42m"}, {CONSOLE_COLOR_DARK_CYAN, "\x1b[46m"}, {CONSOLE_COLOR_DARK_RED, "\x1b[41m"}, {CONSOLE_COLOR_DARK_MAGENTA, "\x1b[45m"}, {CONSOLE_COLOR_DARK_YELLOW, "\x1b[43m"}, {CONSOLE_COLOR_GRAY, "\x1b[47m"}, {CONSOLE_COLOR_DARK_GRAY, "\x1b[100m"}, {CONSOLE_COLOR_BLUE, "\x1b[104m"}, {CONSOLE_COLOR_GREEN, "\x1b[102m"}, {CONSOLE_COLOR_CYAN, "\x1b[106m"}, {CONSOLE_COLOR_RED, "\x1b[101m"}, {CONSOLE_COLOR_MAGENTA, "\x1b[105m"}, {CONSOLE_COLOR_YELLOW, "\x1b[103m"}, {CONSOLE_COLOR_WHITE, "\x1b[107m"}}; auto it = colors.find(color); if (it == colors.end()) return false; ::background_color = color; @@ -601,7 +601,7 @@ bool console::background_color(int_least32_t color) { return true; } -bool console::beep(uint_least32_t frequency, uint_least32_t duration) { +bool console::beep(uint32_t frequency, uint32_t duration) { if (frequency < 37 || frequency > 32767) return false; static constexpr auto simple_rate = 8000u; @@ -622,25 +622,25 @@ bool console::beep(uint_least32_t frequency, uint_least32_t duration) { return true; } -int_least32_t console::buffer_height() { +int32_t console::buffer_height() { /// @todo console buffer Height on linux and macOS if (::buffer_height == -1) ::buffer_height = console::window_height(); return ::buffer_height; } -bool console::buffer_height(int_least32_t height) { +bool console::buffer_height(int32_t height) { /// @todo set console buffer height on linux and macOS ::buffer_height = height; return true; } -int_least32_t console::buffer_width() { +int32_t console::buffer_width() { /// @todo console buffer Width on linux and macOS if (::buffer_width == -1) ::buffer_width = console::window_width(); return ::buffer_width; } -bool console::buffer_width(int_least32_t width) { +bool console::buffer_width(int32_t width) { /// @todo set console buffer width on linux and macOS ::buffer_width = width; return true; @@ -656,7 +656,7 @@ bool console::clear() { return set_cursor_position(0, 0); } -int_least32_t console::cursor_left() { +int32_t console::cursor_left() { if (!terminal::is_ansi_supported()) return ::cursor_left; std::cout << "\x1b[6n" << std::flush; terminal::terminal_.getch(); @@ -669,11 +669,11 @@ int_least32_t console::cursor_left() { return ::cursor_left; } -int_least32_t console::cursor_size() { +int32_t console::cursor_size() { return ::cursor_size; } -bool console::cursor_size(int_least32_t size) { +bool console::cursor_size(int32_t size) { ::cursor_size = size; if (!terminal::is_ansi_supported()) return true; if (size < 50) std::cout << "\x1b[4 q" << std::flush; @@ -681,7 +681,7 @@ bool console::cursor_size(int_least32_t size) { return true; } -int_least32_t console::cursor_top() { +int32_t console::cursor_top() { if (!terminal::is_ansi_supported()) return ::cursor_top; std::cout << "\x1b[6n" << std::flush; terminal::terminal_.getch(); @@ -708,12 +708,12 @@ bool console::echo(bool on) { return terminal::terminal_.echo(on); } -int_least32_t console::foreground_color() { +int32_t console::foreground_color() { return ::foreground_color; } -bool console::foreground_color(int_least32_t color) { - static auto colors = std::map {{CONSOLE_COLOR_DEFAULT, "\x1b[39m"}, {CONSOLE_COLOR_BLACK, "\x1b[30m"}, {CONSOLE_COLOR_DARK_BLUE, "\x1b[34m"}, {CONSOLE_COLOR_DARK_GREEN, "\x1b[32m"}, {CONSOLE_COLOR_DARK_CYAN, "\x1b[36m"}, {CONSOLE_COLOR_DARK_RED, "\x1b[31m"}, {CONSOLE_COLOR_DARK_MAGENTA, "\x1b[35m"}, {CONSOLE_COLOR_DARK_YELLOW, "\x1b[33m"}, {CONSOLE_COLOR_GRAY, "\x1b[37m"}, {CONSOLE_COLOR_DARK_GRAY, "\x1b[90m"}, {CONSOLE_COLOR_BLUE, "\x1b[94m"}, {CONSOLE_COLOR_GREEN, "\x1b[92m"}, {CONSOLE_COLOR_CYAN, "\x1b[96m"}, {CONSOLE_COLOR_RED, "\x1b[91m"}, {CONSOLE_COLOR_MAGENTA, "\x1b[95m"}, {CONSOLE_COLOR_YELLOW, "\x1b[93m"}, {CONSOLE_COLOR_WHITE, "\x1b[97m"}}; +bool console::foreground_color(int32_t color) { + static auto colors = std::map {{CONSOLE_COLOR_DEFAULT, "\x1b[39m"}, {CONSOLE_COLOR_BLACK, "\x1b[30m"}, {CONSOLE_COLOR_DARK_BLUE, "\x1b[34m"}, {CONSOLE_COLOR_DARK_GREEN, "\x1b[32m"}, {CONSOLE_COLOR_DARK_CYAN, "\x1b[36m"}, {CONSOLE_COLOR_DARK_RED, "\x1b[31m"}, {CONSOLE_COLOR_DARK_MAGENTA, "\x1b[35m"}, {CONSOLE_COLOR_DARK_YELLOW, "\x1b[33m"}, {CONSOLE_COLOR_GRAY, "\x1b[37m"}, {CONSOLE_COLOR_DARK_GRAY, "\x1b[90m"}, {CONSOLE_COLOR_BLUE, "\x1b[94m"}, {CONSOLE_COLOR_GREEN, "\x1b[92m"}, {CONSOLE_COLOR_CYAN, "\x1b[96m"}, {CONSOLE_COLOR_RED, "\x1b[91m"}, {CONSOLE_COLOR_MAGENTA, "\x1b[95m"}, {CONSOLE_COLOR_YELLOW, "\x1b[93m"}, {CONSOLE_COLOR_WHITE, "\x1b[97m"}}; auto it = colors.find(color); if (it == colors.end()) return false; ::foreground_color = color; @@ -721,12 +721,12 @@ bool console::foreground_color(int_least32_t color) { return true; } -int_least32_t console::input_code_page() { +int32_t console::input_code_page() { /// @todo console input code page status on linux and macOS return ::input_code_page; } -bool console::input_code_page(int_least32_t code_page) { +bool console::input_code_page(int32_t code_page) { /// @todo set console input code page on linux and macOS ::input_code_page = code_page; return true; @@ -736,11 +736,11 @@ bool console::key_available() { return key_info::key_available(); } -int_least32_t console::largest_window_height() { +int32_t console::largest_window_height() { return ::largest_window_height; } -int_least32_t console::largest_window_width() { +int32_t console::largest_window_width() { return ::largest_window_width; } @@ -749,12 +749,12 @@ bool console::number_lock() { return ::number_lock; } -int_least32_t console::output_code_page() { +int32_t console::output_code_page() { /// @todo console output code page status on linux and macOS return ::output_code_page; } -bool console::output_code_page(int_least32_t code_page) { +bool console::output_code_page(int32_t code_page) { /// @todo set console output code page on linux and macOS ::output_code_page = code_page; return true; @@ -769,7 +769,7 @@ void console::read_key(char32_t& key_char, char32_t& key_code, bool& alt, bool& shift = key_info.has_shift_modifier(); } -void console::register_user_cancel_callback(std::function user_cancel_callback) { +void console::register_user_cancel_callback(std::function user_cancel_callback) { ::user_cancel_callback = user_cancel_callback; } @@ -777,7 +777,7 @@ bool console::reset_color() { return console::background_color(CONSOLE_COLOR_DEFAULT) && console::foreground_color(CONSOLE_COLOR_DEFAULT); } -bool console::set_cursor_position(int_least32_t left, int_least32_t top) { +bool console::set_cursor_position(int32_t left, int32_t top) { ::cursor_left = left; ::cursor_top = top; if (terminal::is_ansi_supported()) std::cout << "\x1b[" << top + 1 << ";" << left + 1 << "f" << std::flush; @@ -814,7 +814,7 @@ bool console::treat_control_c_as_input(bool treat_control_c_as_input) { return true; } -int_least32_t console::window_height() { +int32_t console::window_height() { if (!terminal::is_ansi_supported()) return ::window_height; auto top = console::cursor_top(); console::set_cursor_position(console::cursor_left(), 999); @@ -824,35 +824,35 @@ int_least32_t console::window_height() { return ::window_height; } -bool console::window_height(int_least32_t height) { +bool console::window_height(int32_t height) { /// @todo set console window height on linux and macOS ::window_height = height; return true; } -int_least32_t console::window_left() { +int32_t console::window_left() { /// @todo get console window left on linux and macOS return ::window_left; } -bool console::window_left(int_least32_t left) { +bool console::window_left(int32_t left) { /// @todo set console window left on linux and macOS ::window_left = left; return true; } -int_least32_t console::window_top() { +int32_t console::window_top() { /// @todo get console window top on linux and macOS return ::window_top; } -bool console::window_top(int_least32_t top) { +bool console::window_top(int32_t top) { /// @todo set console window top on linux and macOS ::window_top = top; return true; } -int_least32_t console::window_width() { +int32_t console::window_width() { if (!terminal::is_ansi_supported()) return ::window_width; auto left = console::cursor_left(); console::set_cursor_position(999, console::cursor_top()); @@ -862,7 +862,7 @@ int_least32_t console::window_width() { return ::window_width; } -bool console::window_width(int_least32_t width) { +bool console::window_width(int32_t width) { /// @todo set console window width on linux and macOS ::window_width = width; return true; diff --git a/src/xtd.core.native.linux/src/xtd/native/linux/cryptography.cpp b/src/xtd.core.native.linux/src/xtd/native/linux/cryptography.cpp index 9730e652776..e62d01d33c9 100644 --- a/src/xtd.core.native.linux/src/xtd/native/linux/cryptography.cpp +++ b/src/xtd.core.native.linux/src/xtd/native/linux/cryptography.cpp @@ -8,7 +8,7 @@ using namespace std; using namespace xtd::native; -vector cryptography::machine_guid() { +vector cryptography::machine_guid() { static auto guid_str = linux::shell_execute::run("{ uname -n ; cat /proc/meminfo | head -n1 ; cat /proc/cpuinfo ; } | md5sum"); static const auto guid_fallback = string {"30395f0ed6aa4a5eb4af6f90a608c605"}; @@ -17,8 +17,8 @@ vector cryptography::machine_guid() { if (hex_chars.find(static_cast(toupper(guid_str[index]))) == hex_chars.npos) guid_str.erase(index--, 1); if (guid_str.size() != 32) guid_str = guid_fallback; - auto bytes = vector {}; + auto bytes = vector {}; for (auto index = 0u; index < guid_str.size(); index += 2) - bytes.push_back(static_cast(stoi(guid_str.substr(index, 2), 0, 16))); + bytes.push_back(static_cast(stoi(guid_str.substr(index, 2), 0, 16))); return bytes; } diff --git a/src/xtd.core.native.linux/src/xtd/native/linux/date_time.cpp b/src/xtd.core.native.linux/src/xtd/native/linux/date_time.cpp index 320a98bfac2..3a15a2a6eba 100644 --- a/src/xtd.core.native.linux/src/xtd/native/linux/date_time.cpp +++ b/src/xtd.core.native.linux/src/xtd/native/linux/date_time.cpp @@ -13,7 +13,7 @@ using namespace std; using namespace xtd::native; namespace { - static const int_least64_t ticks_per_second = 10000000; + static const int64_t ticks_per_second = 10000000; /* Generate by this c# code source : @@ -240,7 +240,7 @@ date_time::time_zone_info date_time::get_local_time_zone() { if (iterator != stzis.end()) { local_time_zone = *iterator; local_time_zone.id = reinterpret_cast(tzname[0]); - local_time_zone.base_utc_offset = static_cast(-timezone * ticks_per_second); + local_time_zone.base_utc_offset = static_cast(-timezone * ticks_per_second); local_time_zone.daylight_name = reinterpret_cast(tzname[1]); local_time_zone.display_name = string_printf("(UTC%s%02d:%02d) %s", (-timezone) ? "+" : "", abs(timezone) / 3600, (abs(timezone) % 3600) / 60, reinterpret_cast(tzname[0])); local_time_zone.standard_name = reinterpret_cast(tzname[0]); diff --git a/src/xtd.core.native.linux/src/xtd/native/linux/debugger.cpp b/src/xtd.core.native.linux/src/xtd/native/linux/debugger.cpp index 36a3052b816..092aa89474e 100644 --- a/src/xtd.core.native.linux/src/xtd/native/linux/debugger.cpp +++ b/src/xtd.core.native.linux/src/xtd/native/linux/debugger.cpp @@ -45,7 +45,7 @@ bool debugger::launch() { return true; } -int_least32_t debugger::show_assert_dialog(const std::string& text, const std::string& caption) { +int32_t debugger::show_assert_dialog(const std::string& text, const std::string& caption) { gtk_init_check(0, nullptr); auto dialog = gtk_message_dialog_new(nullptr, GtkDialogFlags::GTK_DIALOG_MODAL, GtkMessageType::GTK_MESSAGE_ERROR, GtkButtonsType::GTK_BUTTONS_NONE, "%s", text.c_str()); gtk_window_set_title(GTK_WINDOW(dialog), caption.c_str()); @@ -57,7 +57,7 @@ int_least32_t debugger::show_assert_dialog(const std::string& text, const std::s return return_code == GTK_RESPONSE_YES ? ADR_ABORT : (return_code == GTK_RESPONSE_NO ? ADR_RETRY : ADR_IGNORE); } -void debugger::log(int_least32_t level, const std::string& category, const std::string& message) { +void debugger::log(int32_t level, const std::string& category, const std::string& message) { syslog(LOG_EMERG | LOG_USER, "%s", message.c_str()); std::cerr << message << std::flush; } diff --git a/src/xtd.core.native.linux/src/xtd/native/linux/directory.cpp b/src/xtd.core.native.linux/src/xtd/native/linux/directory.cpp index 1bd31a55af8..876112212ca 100644 --- a/src/xtd.core.native.linux/src/xtd/native/linux/directory.cpp +++ b/src/xtd.core.native.linux/src/xtd/native/linux/directory.cpp @@ -60,7 +60,7 @@ directory::directory_iterator& directory::directory_iterator::operator ++() { return *this; } -directory::directory_iterator directory::directory_iterator::operator ++(int_least32_t) { +directory::directory_iterator directory::directory_iterator::operator ++(int32_t) { auto result = *this; ++(*this); return result; @@ -130,7 +130,7 @@ directory::file_iterator& directory::file_iterator::operator ++() { return *this; } -directory::file_iterator directory::file_iterator::operator ++(int_least32_t) { +directory::file_iterator directory::file_iterator::operator ++(int32_t) { auto result = *this; ++(*this); return result; @@ -200,7 +200,7 @@ directory::file_and_directory_iterator& directory::file_and_directory_iterator:: return *this; } -directory::file_and_directory_iterator directory::file_and_directory_iterator::operator ++(int_least32_t) { +directory::file_and_directory_iterator directory::file_and_directory_iterator::operator ++(int32_t) { auto result = *this; ++(*this); return result; @@ -231,7 +231,7 @@ const std::string& directory::file_and_directory_iterator::pattern() const { return data_->pattern_; } -int_least32_t directory::create(const std::string& directory_name) { +int32_t directory::create(const std::string& directory_name) { return mkdir(directory_name.c_str(), S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IXGRP | S_IROTH | S_IWOTH | S_IXOTH); } @@ -260,10 +260,10 @@ string directory::get_current_directory() { return result ? path : ""; } -int_least32_t directory::remove(const std::string& directory_name) { +int32_t directory::remove(const std::string& directory_name) { return rmdir(directory_name.c_str()); } -int_least32_t directory::set_current_directory(const std::string& directory_name) { +int32_t directory::set_current_directory(const std::string& directory_name) { return chdir(directory_name.c_str()); } diff --git a/src/xtd.core.native.linux/src/xtd/native/linux/dns.cpp b/src/xtd.core.native.linux/src/xtd/native/linux/dns.cpp index 9a7cc698fc4..6b3f0561527 100644 --- a/src/xtd.core.native.linux/src/xtd/native/linux/dns.cpp +++ b/src/xtd.core.native.linux/src/xtd/native/linux/dns.cpp @@ -26,9 +26,9 @@ void dns::destroy(intmax_t host) { delete reinterpret_cast(host); } -intmax_t dns::get_host_by_address(const string& host_address, int_least32_t host_address_type) { +intmax_t dns::get_host_by_address(const string& host_address, int32_t host_address_type) { auto lock = lock_guard {dns_mutex}; - int_least64_t internet_address = 0; + int64_t internet_address = 0; inet_pton(host_address_type, host_address.c_str(), &internet_address); hostent* host = gethostbyaddr(reinterpret_cast(&internet_address), host_address_type == ADDRESS_FAMILY_INTER_NETWORK ? 4 : 16, host_address_type); if (host == nullptr) return 0; @@ -50,11 +50,11 @@ vector dns::get_aliases(intmax_t host) { return aliases; } -vector> dns::get_addresses(intmax_t host) { - auto addresses = vector> {}; +vector> dns::get_addresses(intmax_t host) { + auto addresses = vector> {}; auto index = size_t {0}; while (reinterpret_cast(host)->h_addr_list[index] != nullptr) { - addresses.emplace_back(reinterpret_cast(reinterpret_cast(host)->h_addr_list[index]), reinterpret_cast(reinterpret_cast(host)->h_addr_list[index]) + (reinterpret_cast(host)->h_addrtype == ADDRESS_FAMILY_INTER_NETWORK ? 4 : 16)); + addresses.emplace_back(reinterpret_cast(reinterpret_cast(host)->h_addr_list[index]), reinterpret_cast(reinterpret_cast(host)->h_addr_list[index]) + (reinterpret_cast(host)->h_addrtype == ADDRESS_FAMILY_INTER_NETWORK ? 4 : 16)); index++; } return addresses; @@ -64,7 +64,7 @@ string dns::get_host_name(intmax_t host) { return reinterpret_cast(host)->h_name; } -int_least32_t dns::get_host_name(string& host_name) { +int32_t dns::get_host_name(string& host_name) { char name[1024]; auto result = gethostname(name, 1024); host_name = name; diff --git a/src/xtd.core.native.linux/src/xtd/native/linux/drive.cpp b/src/xtd.core.native.linux/src/xtd/native/linux/drive.cpp index a0b73eb51f3..2c7f99aaaac 100644 --- a/src/xtd.core.native.linux/src/xtd/native/linux/drive.cpp +++ b/src/xtd.core.native.linux/src/xtd/native/linux/drive.cpp @@ -33,7 +33,7 @@ bool drive::get_available_free_space(const std::string& root_path_name, size_t& return true; } -int_least32_t drive::get_drive_type(const std::string& root_path_name) { +int32_t drive::get_drive_type(const std::string& root_path_name) { if (root_drive == root_path_name) return DRIVE_FIXED; if (find(ram_drives.begin(), ram_drives.end(), root_path_name) != ram_drives.end()) return DRIVE_RAMDISK; if (find(network_drives.begin(), network_drives.end(), root_path_name) != network_drives.end()) return DRIVE_REMOTE; @@ -84,7 +84,7 @@ bool drive::get_volume_information(const std::string& root_path_name, std::strin return false; volume_name = root_path_name; - static auto file_system_names = map {{0x0000adf5, "adfs"}, {0x0000adff, "adfs"}, {0x42465331, "befs"}, {0x1BADFACE, "bfs"}, {0xFF534D42, "cifs"}, {0x73757245, "coda"}, {0x012FF7B7, "coh"}, {0x28cd3d45, "cramfs"}, {0x00001373, "devfs"}, {0x00414A53, "efs"}, {0x0000137D, "ext"}, {0x0000EF51, "ext2"}, {0x0000EF52, "ext3"}, {0x0000EF53, "ext4"}, {0x00004244, "hfs"}, {0xF995E849, "hpfs"}, {0x958458f6, "hgfs"}, {0x00009660, "isofs"}, {0x000072b6, "jffs2"}, {0x3153464a, "jfs"}, {0x0000137F, "minix"}, {0x0000138F, "minix"}, {0x00002468, "minix2"}, {0x00002478, "minix2"}, {0x00004d44, "fat32"}, {0x0000564c, "ncp"}, {0x00006969, "nfs"}, {0x5346544e, "ntfs"}, {0x00009fa1, "openprom"}, {0x00009fa0, "proc"}, {0x0000002f, "qnx4"}, {0x52654973, "reiserfs"}, {0x00007275, "romfs"}, {0x0000517B, "smb"}, {0x012FF7B6, "sysv2"}, {0x012FF7B5, "sysv4"}, {0x01021994, "tmpfs"}, {0x15013346, "udf"}, {0x00011954, "ufs"}, {0x00009fa2, "usb device"}, {0xa501FCF5, "vxfs"}, {0x012FF7B4, "xenix"}, {0x58465342, "xfs"}, {0x012FD16D, "_xiafs"}}; + static auto file_system_names = map {{0x0000adf5, "adfs"}, {0x0000adff, "adfs"}, {0x42465331, "befs"}, {0x1BADFACE, "bfs"}, {0xFF534D42, "cifs"}, {0x73757245, "coda"}, {0x012FF7B7, "coh"}, {0x28cd3d45, "cramfs"}, {0x00001373, "devfs"}, {0x00414A53, "efs"}, {0x0000137D, "ext"}, {0x0000EF51, "ext2"}, {0x0000EF52, "ext3"}, {0x0000EF53, "ext4"}, {0x00004244, "hfs"}, {0xF995E849, "hpfs"}, {0x958458f6, "hgfs"}, {0x00009660, "isofs"}, {0x000072b6, "jffs2"}, {0x3153464a, "jfs"}, {0x0000137F, "minix"}, {0x0000138F, "minix"}, {0x00002468, "minix2"}, {0x00002478, "minix2"}, {0x00004d44, "fat32"}, {0x0000564c, "ncp"}, {0x00006969, "nfs"}, {0x5346544e, "ntfs"}, {0x00009fa1, "openprom"}, {0x00009fa0, "proc"}, {0x0000002f, "qnx4"}, {0x52654973, "reiserfs"}, {0x00007275, "romfs"}, {0x0000517B, "smb"}, {0x012FF7B6, "sysv2"}, {0x012FF7B5, "sysv4"}, {0x01021994, "tmpfs"}, {0x15013346, "udf"}, {0x00011954, "ufs"}, {0x00009fa2, "usb device"}, {0xa501FCF5, "vxfs"}, {0x012FF7B4, "xenix"}, {0x58465342, "xfs"}, {0x012FD16D, "_xiafs"}}; auto it = file_system_names.find(stat.f_type); file_system_name = it == file_system_names.end() ? "unknown" : it->second; return true; diff --git a/src/xtd.core.native.linux/src/xtd/native/linux/environment.cpp b/src/xtd.core.native.linux/src/xtd/native/linux/environment.cpp index fd846ecb261..97d110c5a48 100644 --- a/src/xtd.core.native.linux/src/xtd/native/linux/environment.cpp +++ b/src/xtd.core.native.linux/src/xtd/native/linux/environment.cpp @@ -17,11 +17,11 @@ using namespace std::literals; using namespace xtd::native; extern char** environ; -int_least32_t __environment_argc = 0; +int32_t __environment_argc = 0; char** __environment_argv; namespace { - __attribute__((constructor)) void startup_program(int_least32_t argc, char** argv) { + __attribute__((constructor)) void startup_program(int32_t argc, char** argv) { __environment_argc = argc; __environment_argv = argv; } @@ -43,7 +43,7 @@ namespace { } } -int_least32_t environment::at_quick_exit(void (*on_quick_exit)(void)) { +int32_t environment::at_quick_exit(void (*on_quick_exit)(void)) { return std::at_quick_exit(on_quick_exit); } @@ -112,7 +112,7 @@ string environment::get_distribution_name() { return name_it->second; } -void environment::get_distribution_version(int_least32_t& major, int_least32_t& minor, int_least32_t& build, int_least32_t& revision) { +void environment::get_distribution_version(int32_t& major, int32_t& minor, int32_t& build, int32_t& revision) { auto name_it = get_distribution_key_values().find("VERSION_ID"); if (name_it == get_distribution_key_values().end()) return; auto versions = xtd::native::linux::strings::split(name_it->second, {'.'}); @@ -126,7 +126,7 @@ string environment::get_distribution_version_string() { return iterator->second; } -string environment::get_environment_variable(const string& variable, int_least32_t target) { +string environment::get_environment_variable(const string& variable, int32_t target) { if (target == ENVIRONMENT_VARIABLE_TARGET_PROCESS) { auto value = getenv(variable.c_str()); return value ? value : ""; @@ -140,7 +140,7 @@ string environment::get_environment_variable(const string& variable, int_least32 return ""; } -map& environment::get_environment_variables(int_least32_t target) { +map& environment::get_environment_variables(int32_t target) { if (target == ENVIRONMENT_VARIABLE_TARGET_PROCESS) { static auto envs = map {}; if (envs.size() == 0) { @@ -166,8 +166,8 @@ map& environment::get_environment_variables(int_least32_t target return envs; } -string environment::get_know_folder_path(int_least32_t csidl) { - static auto special_folders = map {{CSIDL_DESKTOP, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS) + "/Desktop"}, {CSIDL_PERSONAL, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS)}, {CSIDL_MYMUSIC, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS) + "/Music"}, {CSIDL_MYVIDEO, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS) + "/Videos"}, {CSIDL_DESKTOPDIRECTORY, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS) + "/Desktop"}, {CSIDL_FONTS, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS) + "/.fonts"}, {CSIDL_TEMPLATES, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS) + "/Templates"}, {CSIDL_APPDATA, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS) + "/.config"}, {CSIDL_LOCAL_APPDATA, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS) + "/.local/share"}, {CSIDL_COMMON_APPDATA, "/usr/share"}, {CSIDL_MYPICTURES, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS) + "/Pictures"}, {CSIDL_PROFILE, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS)}, {CSIDL_COMMON_TEMPLATES, "/usr/share/templates"}, {CSIDL_HOME, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS)}}; +string environment::get_know_folder_path(int32_t csidl) { + static auto special_folders = map {{CSIDL_DESKTOP, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS) + "/Desktop"}, {CSIDL_PERSONAL, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS)}, {CSIDL_MYMUSIC, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS) + "/Music"}, {CSIDL_MYVIDEO, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS) + "/Videos"}, {CSIDL_DESKTOPDIRECTORY, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS) + "/Desktop"}, {CSIDL_FONTS, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS) + "/.fonts"}, {CSIDL_TEMPLATES, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS) + "/Templates"}, {CSIDL_APPDATA, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS) + "/.config"}, {CSIDL_LOCAL_APPDATA, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS) + "/.local/share"}, {CSIDL_COMMON_APPDATA, "/usr/share"}, {CSIDL_MYPICTURES, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS) + "/Pictures"}, {CSIDL_PROFILE, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS)}, {CSIDL_COMMON_TEMPLATES, "/usr/share/templates"}, {CSIDL_HOME, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS)}}; auto it = special_folders.find(csidl); if (it == special_folders.end()) return ""; return it->second; @@ -177,7 +177,7 @@ string environment::get_machine_name() { return linux::strings::replace(linux::shell_execute::run("uname", "-n"), "\n", ""); } -int_least32_t environment::get_os_platform_id() { +int32_t environment::get_os_platform_id() { #if defined(__ANDROID__) return PLATFORM_ANDROID; #else @@ -186,7 +186,7 @@ int_least32_t environment::get_os_platform_id() { #endif } -void environment::get_os_version(int_least32_t& major, int_least32_t& minor, int_least32_t& build, int_least32_t& revision) { +void environment::get_os_version(int32_t& major, int32_t& minor, int32_t& build, int32_t& revision) { auto numbers = linux::strings::split(linux::shell_execute::run("uname", "-r"), {'.', '-', '\n'}); if (numbers.size() < 1 || !linux::strings::try_parse(numbers[0], major)) major = 0; if (numbers.size() < 2 || !linux::strings::try_parse(numbers[1], minor)) minor = 0; @@ -194,7 +194,7 @@ void environment::get_os_version(int_least32_t& major, int_least32_t& minor, int if (numbers.size() < 4 || !linux::strings::try_parse(numbers[3], revision)) revision = 0; } -uint_least32_t environment::get_processor_count() { +uint32_t environment::get_processor_count() { return thread::hardware_concurrency(); } @@ -212,7 +212,7 @@ size_t environment::get_system_page_size() { return sysconf(_SC_PAGESIZE); } -uint_least32_t environment::get_tick_count() { +uint32_t environment::get_tick_count() { // https://stackoverflow.com/questions/1540627/what-api-do-i-call-to-get-the-system-uptime using struct_sysinfo = struct sysinfo; auto info = struct_sysinfo {}; @@ -253,11 +253,11 @@ string environment::new_line() { return "\n"; } -void environment::quick_exit(int_least32_t exit_code) noexcept { +void environment::quick_exit(int32_t exit_code) noexcept { std::quick_exit(exit_code); } -void environment::set_environment_variable(const string& name, const string& value, int_least32_t target) { +void environment::set_environment_variable(const string& name, const string& value, int32_t target) { if (target == ENVIRONMENT_VARIABLE_TARGET_PROCESS) setenv(name.c_str(), value.c_str(), 1); else if (target == ENVIRONMENT_VARIABLE_TARGET_USER) { @@ -267,7 +267,7 @@ void environment::set_environment_variable(const string& name, const string& val } } -void environment::unset_environment_variable(const string& name, int_least32_t target) { +void environment::unset_environment_variable(const string& name, int32_t target) { if (target == ENVIRONMENT_VARIABLE_TARGET_PROCESS) unsetenv(name.c_str()); else if (target == ENVIRONMENT_VARIABLE_TARGET_USER) { @@ -277,6 +277,6 @@ void environment::unset_environment_variable(const string& name, int_least32_t t } } -int_least64_t environment::working_set() { +int64_t environment::working_set() { return 0; } diff --git a/src/xtd.core.native.linux/src/xtd/native/linux/file.cpp b/src/xtd.core.native.linux/src/xtd/native/linux/file.cpp index d1f09886a0f..d54c5472ce7 100644 --- a/src/xtd.core.native.linux/src/xtd/native/linux/file.cpp +++ b/src/xtd.core.native.linux/src/xtd/native/linux/file.cpp @@ -11,7 +11,7 @@ using namespace std; using namespace xtd::native; -int_least32_t file::copy(const std::string& source_file, const std::string& target_file) { +int32_t file::copy(const std::string& source_file, const std::string& target_file) { auto ifs = ifstream {source_file, ios::binary}; if (!ifs) return -1; auto ofs = ofstream {target_file, ios::trunc | ios::binary}; @@ -34,12 +34,12 @@ size_t file::get_size(const std::string& path) { return static_cast(status.st_size); } -int_least32_t file::move(const std::string& old_path, const std::string& new_path) { +int32_t file::move(const std::string& old_path, const std::string& new_path) { auto file_attributes = 0; if (file_system::get_attributes(new_path, file_attributes) == 0) return -1; return rename(old_path.c_str(), new_path.c_str()); } -int_least32_t file::remove(const std::string& file) { +int32_t file::remove(const std::string& file) { return unlink(file.c_str()); } diff --git a/src/xtd.core.native.linux/src/xtd/native/linux/file_system.cpp b/src/xtd.core.native.linux/src/xtd/native/linux/file_system.cpp index f9fa156a914..ebf071abb9e 100644 --- a/src/xtd.core.native.linux/src/xtd/native/linux/file_system.cpp +++ b/src/xtd.core.native.linux/src/xtd/native/linux/file_system.cpp @@ -19,9 +19,9 @@ namespace { using struct_stat = struct stat; } -int_least32_t file_system::get_attributes(const std::string& path, int_least32_t& attributes) { +int32_t file_system::get_attributes(const std::string& path, int32_t& attributes) { struct system_attribute_to_file_attribute_converter { - int_least32_t operator()(int_least32_t attribute) { + int32_t operator()(int32_t attribute) { auto file_attributes = 0; if ((attribute & S_IRUSR) == S_IRUSR && (attribute & S_IWUSR) != S_IWUSR) file_attributes |= FILE_ATTRIBUTE_READONLY; if ((attribute & S_IFSOCK) == S_IFSOCK || (attribute & S_IFIFO) == S_IFIFO) file_attributes |= FILE_ATTRIBUTE_SYSTEM; @@ -38,7 +38,7 @@ int_least32_t file_system::get_attributes(const std::string& path, int_least32_t return 0; } -int_least32_t file_system::get_file_times(const std::string& path, time_t& creation_time, time_t& last_access_time, time_t& last_write_time) { +int32_t file_system::get_file_times(const std::string& path, time_t& creation_time, time_t& last_access_time, time_t& last_write_time) { auto status = struct_stat {}; if (stat(path.c_str(), &status) != 0) return -1; @@ -74,9 +74,9 @@ string file_system::get_full_path(const string& relative_path) { return full_path; } -int_least32_t file_system::get_permissions(const std::string& path, int_least32_t& permissions) { +int32_t file_system::get_permissions(const std::string& path, int32_t& permissions) { struct system_permission_to_file_permission_converter { - int_least32_t operator()(mode_t permission) { + int32_t operator()(mode_t permission) { auto file_permissions = 0; if ((permission & S_IRUSR) == S_IRUSR) file_permissions |= FILE_PERMISSIONS_OWNER_READ; if ((permission & S_IWUSR) == S_IWUSR) file_permissions |= FILE_PERMISSIONS_OWNER_WRITE; @@ -114,7 +114,7 @@ bool file_system::is_path_too_long(const std::string& path) { return file_name.size() > NAME_MAX; } -int_least32_t file_system::set_attributes(const std::string& path, int_least32_t attributes) { +int32_t file_system::set_attributes(const std::string& path, int32_t attributes) { auto s = struct_stat {}; if (stat(path.c_str(), &s) != 0) return -1; @@ -128,7 +128,7 @@ int_least32_t file_system::set_attributes(const std::string& path, int_least32_t return chmod(path.c_str(), s.st_mode); } -int_least32_t file_system::set_creation_time(const std::string& path, time_t creation_time) { +int32_t file_system::set_creation_time(const std::string& path, time_t creation_time) { // There is no creation time on linux so we update the last modification time instead... auto times = utimbuf {}; time_t creation_time_old = 0, last_access_time = 0, last_write_time = 0; @@ -138,7 +138,7 @@ int_least32_t file_system::set_creation_time(const std::string& path, time_t cre return utime(path.c_str(), ×); } -int_least32_t file_system::set_last_access_time(const std::string& path, time_t last_access_time) { +int32_t file_system::set_last_access_time(const std::string& path, time_t last_access_time) { auto times = utimbuf {}; time_t creation_time = 0, last_access_time_old = 0, last_write_time = 0; get_file_times(path, creation_time, last_access_time_old, last_write_time); @@ -147,7 +147,7 @@ int_least32_t file_system::set_last_access_time(const std::string& path, time_t return utime(path.c_str(), ×); } -int_least32_t file_system::set_last_write_time(const std::string& path, time_t last_write_time) { +int32_t file_system::set_last_write_time(const std::string& path, time_t last_write_time) { auto times = utimbuf {}; time_t creation_time = 0, last_access_time = 0, last_write_time_old = 0; get_file_times(path, creation_time, last_access_time, last_write_time_old); @@ -156,9 +156,9 @@ int_least32_t file_system::set_last_write_time(const std::string& path, time_t l return utime(path.c_str(), ×); } -int_least32_t file_system::set_permissions(const std::string& path, int_least32_t permissions) { +int32_t file_system::set_permissions(const std::string& path, int32_t permissions) { struct file_permission_to_system_permission_converter { - mode_t operator()(int_least32_t permission) { + mode_t operator()(int32_t permission) { auto system_permissions = 0; if ((permission & FILE_PERMISSIONS_OWNER_READ) == FILE_PERMISSIONS_OWNER_READ) system_permissions |= S_IRUSR; if ((permission & FILE_PERMISSIONS_OWNER_WRITE) == FILE_PERMISSIONS_OWNER_WRITE) system_permissions |= S_IWUSR; diff --git a/src/xtd.core.native.linux/src/xtd/native/linux/guid.cpp b/src/xtd.core.native.linux/src/xtd/native/linux/guid.cpp index f9b64c6726b..ba9d13a76b6 100644 --- a/src/xtd.core.native.linux/src/xtd/native/linux/guid.cpp +++ b/src/xtd.core.native.linux/src/xtd/native/linux/guid.cpp @@ -10,8 +10,8 @@ using namespace xtd::native; -std::vector guid::new_guid() { - auto guid = std::vector(16); +std::vector guid::new_guid() { + auto guid = std::vector(16); #if !defined(__ANDROID__) uuid_generate(guid.data()); #else @@ -39,8 +39,8 @@ std::vector guid::new_guid() { // o Set the four most significant bits (bits 12 through 15) of the time_hi_and_version field to the 4-bit version number from Section 4.1.3. // o Set all the other bits to randomly (or pseudo-randomly) chosen values. static auto rand = std::random_device {}; - std::uniform_int_distribution rand_byte_distribution(0, std::numeric_limits::max()); - std::for_each(guid.begin(), guid.end(), [&](uint_least8_t& value) {value = static_cast(rand_byte_distribution(rand));}); + std::uniform_int_distribution rand_byte_distribution(0, std::numeric_limits::max()); + std::for_each(guid.begin(), guid.end(), [&](uint8_t& value) {value = static_cast(rand_byte_distribution(rand));}); guid[6] = (guid[6] & 0x0f) | 0x40; guid[8] = (guid[8] & 0x3f) | 0x80; #endif diff --git a/src/xtd.core.native.linux/src/xtd/native/linux/interlocked.cpp b/src/xtd.core.native.linux/src/xtd/native/linux/interlocked.cpp index b3f4f4288e9..5ea9044feaa 100644 --- a/src/xtd.core.native.linux/src/xtd/native/linux/interlocked.cpp +++ b/src/xtd.core.native.linux/src/xtd/native/linux/interlocked.cpp @@ -12,21 +12,21 @@ using namespace std; using namespace xtd::native; -int_least32_t interlocked::add(int_least32_t& location, int_least32_t value) { +int32_t interlocked::add(int32_t& location, int32_t value) { __sync_fetch_and_add(&location, value); return location; } -int_least64_t interlocked::add(int_least64_t& location, int_least64_t value) { +int64_t interlocked::add(int64_t& location, int64_t value) { __sync_fetch_and_add(&location, value); return location; } -int_least32_t interlocked::compare_exchange(int_least32_t& location, int_least32_t value, int_least32_t comparand) { +int32_t interlocked::compare_exchange(int32_t& location, int32_t value, int32_t comparand) { return __sync_val_compare_and_swap(&location, comparand, value); } -int_least64_t interlocked::compare_exchange(int_least64_t& location, int_least64_t value, int_least64_t comparand) { +int64_t interlocked::compare_exchange(int64_t& location, int64_t value, int64_t comparand) { return __sync_val_compare_and_swap(&location, comparand, value); } @@ -38,21 +38,21 @@ void* interlocked::compare_exchange(void*& location, void* value, void* comparan return __sync_val_compare_and_swap(&location, comparand, value); } -int_least32_t interlocked::decrement(int_least32_t& location) { +int32_t interlocked::decrement(int32_t& location) { __sync_fetch_and_sub(&location, 1); return location; } -int_least64_t interlocked::decrement(int_least64_t& location) { +int64_t interlocked::decrement(int64_t& location) { __sync_fetch_and_sub(&location, 1); return location; } -int_least32_t interlocked::exchange(int_least32_t& location, int_least32_t value) { +int32_t interlocked::exchange(int32_t& location, int32_t value) { return __sync_val_compare_and_swap(&location, location, value); } -int_least64_t interlocked::exchange(int_least64_t& location, int_least64_t value) { +int64_t interlocked::exchange(int64_t& location, int64_t value) { return __sync_val_compare_and_swap(&location, location, value); } @@ -64,12 +64,12 @@ void* interlocked::exchange(void*& location, void* value) { return __sync_val_compare_and_swap(&location, location, value); } -int_least32_t interlocked::increment(int_least32_t& location) { +int32_t interlocked::increment(int32_t& location) { __sync_fetch_and_add(&location, 1); return location; } -int_least64_t interlocked::increment(int_least64_t& location) { +int64_t interlocked::increment(int64_t& location) { __sync_fetch_and_add(&location, 1); return location; } diff --git a/src/xtd.core.native.linux/src/xtd/native/linux/named_event_wait_handle.cpp b/src/xtd.core.native.linux/src/xtd/native/linux/named_event_wait_handle.cpp index 4ac0492c3a7..4e9ae24365d 100644 --- a/src/xtd.core.native.linux/src/xtd/native/linux/named_event_wait_handle.cpp +++ b/src/xtd.core.native.linux/src/xtd/native/linux/named_event_wait_handle.cpp @@ -49,7 +49,7 @@ bool named_event_wait_handle::reset(intmax_t handle, bool& io_error) { return true; } -uint_least32_t named_event_wait_handle::wait(intmax_t handle, int_least32_t milliseconds_timeout, bool manual_reset) { +uint32_t named_event_wait_handle::wait(intmax_t handle, int32_t milliseconds_timeout, bool manual_reset) { if (reinterpret_cast(handle) == SEM_FAILED) return 0xFFFFFFFF; auto result = milliseconds_timeout == -1 ? sem_wait(reinterpret_cast(handle)) : sem_milliseconds_timedwait(reinterpret_cast(handle), milliseconds_timeout); if (result && errno == EAGAIN) return 0xFFFFFFFF; diff --git a/src/xtd.core.native.linux/src/xtd/native/linux/named_mutex.cpp b/src/xtd.core.native.linux/src/xtd/native/linux/named_mutex.cpp index f1b579cc656..5ba247d499f 100644 --- a/src/xtd.core.native.linux/src/xtd/native/linux/named_mutex.cpp +++ b/src/xtd.core.native.linux/src/xtd/native/linux/named_mutex.cpp @@ -35,7 +35,7 @@ bool named_mutex::signal(intmax_t handle, bool& io_error) { return !io_error; } -uint_least32_t named_mutex::wait(intmax_t handle, int_least32_t milliseconds_timeout) { +uint32_t named_mutex::wait(intmax_t handle, int32_t milliseconds_timeout) { if (reinterpret_cast(handle) == SEM_FAILED) return 0xFFFFFFFF; auto result = milliseconds_timeout == -1 ? sem_wait(reinterpret_cast(handle)) : sem_milliseconds_timedwait(reinterpret_cast(handle), milliseconds_timeout); if (result && errno == EAGAIN) return 0xFFFFFFFF; diff --git a/src/xtd.core.native.linux/src/xtd/native/linux/named_semaphore.cpp b/src/xtd.core.native.linux/src/xtd/native/linux/named_semaphore.cpp index 8d4a6f61316..9d908963f98 100644 --- a/src/xtd.core.native.linux/src/xtd/native/linux/named_semaphore.cpp +++ b/src/xtd.core.native.linux/src/xtd/native/linux/named_semaphore.cpp @@ -5,7 +5,7 @@ using namespace xtd::native; -intmax_t named_semaphore::create(int_least32_t initial_count, int_least32_t max_count, const std::string& name) { +intmax_t named_semaphore::create(int32_t initial_count, int32_t max_count, const std::string& name) { auto semaphore = sem_open(name.c_str(), O_CREAT | O_EXCL, S_IRUSR | S_IWUSR, std::min(initial_count, max_count)); return reinterpret_cast(semaphore); } @@ -24,7 +24,7 @@ intmax_t named_semaphore::open(const std::string& name) { return reinterpret_cast(semaphore); } -bool named_semaphore::signal(intmax_t handle, int_least32_t release_count, int_least32_t& previous_count, bool& io_error) { +bool named_semaphore::signal(intmax_t handle, int32_t release_count, int32_t& previous_count, bool& io_error) { io_error = false; if (reinterpret_cast(handle) == SEM_FAILED) { io_error = true; @@ -37,7 +37,7 @@ bool named_semaphore::signal(intmax_t handle, int_least32_t release_count, int_l return !io_error; } -uint_least32_t named_semaphore::wait(intmax_t handle, int_least32_t milliseconds_timeout) { +uint32_t named_semaphore::wait(intmax_t handle, int32_t milliseconds_timeout) { if (reinterpret_cast(handle) == SEM_FAILED) return 0xFFFFFFFF; auto result = milliseconds_timeout == -1 ? sem_wait(reinterpret_cast(handle)) : sem_milliseconds_timedwait(reinterpret_cast(handle), milliseconds_timeout); if (result && errno == EAGAIN) return 0xFFFFFFFF; diff --git a/src/xtd.core.native.linux/src/xtd/native/linux/process.cpp b/src/xtd.core.native.linux/src/xtd/native/linux/process.cpp index a6da6663745..ba7552feb57 100644 --- a/src/xtd.core.native.linux/src/xtd/native/linux/process.cpp +++ b/src/xtd.core.native.linux/src/xtd/native/linux/process.cpp @@ -23,11 +23,11 @@ using namespace xtd::native; namespace { class file_descriptor_streambuf : public streambuf { public: - explicit file_descriptor_streambuf(int_least32_t file_descriptor) : file_descriptor_(file_descriptor) {} + explicit file_descriptor_streambuf(int32_t file_descriptor) : file_descriptor_(file_descriptor) {} ~file_descriptor_streambuf() {close(file_descriptor_);} protected: - int_least32_t underflow() override { + int32_t underflow() override { if (read(file_descriptor_, &value_, 1) == 1) { this->setg(&value_, &value_, &value_ + 1); return value_; @@ -35,7 +35,7 @@ namespace { return streambuf::underflow(); // EOF } - int_least32_t overflow(int_least32_t c) override { + int32_t overflow(int32_t c) override { value_ = static_cast(c); if (write(file_descriptor_, &value_, 1) != -1) { this->setp(&value_, &value_); @@ -44,13 +44,13 @@ namespace { return streambuf::overflow(c); // EOF } - int_least32_t file_descriptor_; + int32_t file_descriptor_; char value_ = EOF; }; class process_istream : public istream { public: - explicit process_istream(int_least32_t file_descriptor) : istream(&stream_buf_), stream_buf_(file_descriptor) {} + explicit process_istream(int32_t file_descriptor) : istream(&stream_buf_), stream_buf_(file_descriptor) {} private: file_descriptor_streambuf stream_buf_; @@ -58,7 +58,7 @@ namespace { class process_ostream : public ostream { public: - explicit process_ostream(int_least32_t file_descriptor) : ostream(&stream_buf_), stream_buf_(file_descriptor) {} + explicit process_ostream(int32_t file_descriptor) : ostream(&stream_buf_), stream_buf_(file_descriptor) {} private: file_descriptor_streambuf stream_buf_; @@ -138,8 +138,8 @@ namespace { return arguments; } - bool compute_base_priority(int_least32_t priority, int_least32_t& base_priority) { - static auto base_priorities = map {{IDLE_PRIORITY_CLASS, PRIO_MIN}, {BELOW_NORMAL_PRIORITY_CLASS, PRIO_MIN + (PRIO_MAX - PRIO_MIN) / 4}, {NORMAL_PRIORITY_CLASS, PRIO_MIN + (PRIO_MAX - PRIO_MIN) / 2}, {ABOVE_NORMAL_PRIORITY_CLASS, PRIO_MAX - (PRIO_MAX - PRIO_MIN) / 4}, {HIGH_PRIORITY_CLASS, PRIO_MAX - (PRIO_MAX - PRIO_MIN) / 8}, {REALTIME_PRIORITY_CLASS, PRIO_MAX}}; + bool compute_base_priority(int32_t priority, int32_t& base_priority) { + static auto base_priorities = map {{IDLE_PRIORITY_CLASS, PRIO_MIN}, {BELOW_NORMAL_PRIORITY_CLASS, PRIO_MIN + (PRIO_MAX - PRIO_MIN) / 4}, {NORMAL_PRIORITY_CLASS, PRIO_MIN + (PRIO_MAX - PRIO_MIN) / 2}, {ABOVE_NORMAL_PRIORITY_CLASS, PRIO_MAX - (PRIO_MAX - PRIO_MIN) / 4}, {HIGH_PRIORITY_CLASS, PRIO_MAX - (PRIO_MAX - PRIO_MIN) / 8}, {REALTIME_PRIORITY_CLASS, PRIO_MAX}}; auto it = base_priorities.find(priority); if (it == base_priorities.end()) return false; base_priority = it->second; @@ -147,7 +147,7 @@ namespace { } } -int_least32_t process::base_priority(int_least32_t priority) { +int32_t process::base_priority(int32_t priority) { auto base_priority = PRIO_MIN + (PRIO_MAX - PRIO_MIN) / 2; compute_base_priority(priority, base_priority); return base_priority; @@ -158,13 +158,13 @@ bool process::kill(intmax_t process) { return ::kill(static_cast(process), SIGTERM) == 0; } -bool process::priority_class(intmax_t process, int_least32_t priority) { +bool process::priority_class(intmax_t process, int32_t priority) { auto base_priority = PRIO_MIN + (PRIO_MAX - PRIO_MIN) / 2; if (compute_base_priority(priority, base_priority) == false) return false; return setpriority(PRIO_PROCESS, static_cast(process), base_priority) == 0; } -intmax_t process::shell_execute(const std::string& verb, const string& file_name, const string& arguments, const string& working_directory, int_least32_t process_window_style) { +intmax_t process::shell_execute(const std::string& verb, const string& file_name, const string& arguments, const string& working_directory, int32_t process_window_style) { auto process = fork(); if (process == 0) { auto is_shell_execute = is_valid_shell_execute_process(&linux::strings::split, file_name, working_directory); @@ -201,15 +201,15 @@ intmax_t process::shell_execute(const std::string& verb, const string& file_name return static_cast(process); } -process::started_process process::start(const string& file_name, const string& arguments, const string& working_directory, int_least32_t process_window_style, int_least32_t process_creation_flags, tuple redirect_standard_streams) { +process::started_process process::start(const string& file_name, const string& arguments, const string& working_directory, int32_t process_window_style, int32_t process_creation_flags, tuple redirect_standard_streams) { auto [redirect_standard_input, redirect_standard_output, redirect_standard_error] = redirect_standard_streams; auto pipe_result = 0; - int_least32_t pipe_stdin[2]; + int32_t pipe_stdin[2]; if (redirect_standard_input) pipe_result = pipe(pipe_stdin); - int_least32_t pipe_stdout[2]; + int32_t pipe_stdout[2]; if (redirect_standard_output) pipe_result = pipe(pipe_stdout); - int_least32_t pipe_stderr[2]; + int32_t pipe_stderr[2]; if (redirect_standard_error) pipe_result = pipe(pipe_stderr); if (pipe_result) {/*do nothing*/} @@ -248,10 +248,10 @@ process::started_process process::start(const string& file_name, const string& a if (redirect_standard_output) close(pipe_stdout[1]); if (redirect_standard_error) close(pipe_stderr[1]); - return make_tuple(static_cast(process), static_cast(process), make_unique(pipe_stdin[1]), make_unique(pipe_stdout[0]), make_unique(pipe_stderr[0])); + return make_tuple(static_cast(process), static_cast(process), make_unique(pipe_stdin[1]), make_unique(pipe_stdout[0]), make_unique(pipe_stderr[0])); } -bool process::wait(intmax_t process, int_least32_t& exit_code) { +bool process::wait(intmax_t process, int32_t& exit_code) { if (process == 0) return false; auto wait_info = siginfo_t {}; wait_info.si_pid = static_cast(process); diff --git a/src/xtd.core.native.linux/src/xtd/native/linux/socket.cpp b/src/xtd.core.native.linux/src/xtd/native/linux/socket.cpp index 485668f4852..b39d410b7c1 100644 --- a/src/xtd.core.native.linux/src/xtd/native/linux/socket.cpp +++ b/src/xtd.core.native.linux/src/xtd/native/linux/socket.cpp @@ -23,90 +23,90 @@ using namespace std; using namespace xtd::native; namespace { - static int_least32_t native_to_socket_error(int_least32_t error) { - static auto socket_errors = map {{0, SOCKET_ERROR_SUCCESS}, {EINTR, SOCKET_ERROR_INTERRUPTED}, {EACCES, SOCKET_ERROR_ACCESS_DENIED}, {EFAULT, SOCKET_ERROR_FAULT}, {EINVAL, SOCKET_ERROR_INVALID_ARGUMENT}, {EMFILE, SOCKET_ERROR_TOO_MANY_OPEN_SOCKETS}, {EAGAIN, SOCKET_ERROR_WOULD_BLOCK}, {EINPROGRESS, SOCKET_ERROR_IN_PROGRESS}, {EALREADY, SOCKET_ERROR_ALREADY_IN_PROGRESS}, {ENOTSOCK, SOCKET_ERROR_NOT_SOCKET}, {EDESTADDRREQ, SOCKET_ERROR_DESTINATION_ADDRESS_REQUIRED}, {EMSGSIZE, SOCKET_ERROR_MESSAGE_SIZE}, {EPROTOTYPE, SOCKET_ERROR_PROTOCOL_TYPE}, {ENOPROTOOPT, SOCKET_ERROR_PROTOCOL_OPTION}, {EPROTONOSUPPORT, SOCKET_ERROR_PROTOCOL_NOT_SUPPORTED}, {ESOCKTNOSUPPORT, SOCKET_ERROR_SOCKET_NOT_SUPPORTED}, {ENOTSUP, SOCKET_ERROR_OPERATION_NOT_SUPPORTED}, {EPFNOSUPPORT, SOCKET_ERROR_PROTOCOL_FAMILY_NOT_SUPPORTED}, {EAFNOSUPPORT, SOCKET_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED}, {EADDRINUSE, SOCKET_ERROR_ADDRESS_ALREADY_IN_USE}, {EADDRNOTAVAIL, SOCKET_ERROR_ADDRESS_NOT_AVAILABLE}, {ENETDOWN, SOCKET_ERROR_NETWORK_DOWN}, {ENETUNREACH, SOCKET_ERROR_NETWORK_UNREACHABLE}, {ENETRESET, SOCKET_ERROR_NETWORK_RESET}, {ECONNABORTED, SOCKET_ERROR_CONNECTION_ABORTED}, {ECONNRESET, SOCKET_ERROR_CONNECTION_RESET}, {ENOBUFS, SOCKET_ERROR_NO_BUFFER_SPACE_AVAILABLE}, {EISCONN, SOCKET_ERROR_IS_CONNECTED}, {ENOTCONN, SOCKET_ERROR_NOT_CONNECTED}, {ESHUTDOWN, SOCKET_ERROR_SHUTDOWN}, {ETIMEDOUT, SOCKET_ERROR_TIMED_OUT}, {ECONNREFUSED, SOCKET_ERROR_CONNECTION_REFUSED}, {EHOSTDOWN, SOCKET_ERROR_HOST_DOWN}, {EHOSTUNREACH, SOCKET_ERROR_HOST_UNREACHABLE}, {EOPNOTSUPP, SOCKET_ERROR_SOCKET_NOT_SUPPORTED}}; + static int32_t native_to_socket_error(int32_t error) { + static auto socket_errors = map {{0, SOCKET_ERROR_SUCCESS}, {EINTR, SOCKET_ERROR_INTERRUPTED}, {EACCES, SOCKET_ERROR_ACCESS_DENIED}, {EFAULT, SOCKET_ERROR_FAULT}, {EINVAL, SOCKET_ERROR_INVALID_ARGUMENT}, {EMFILE, SOCKET_ERROR_TOO_MANY_OPEN_SOCKETS}, {EAGAIN, SOCKET_ERROR_WOULD_BLOCK}, {EINPROGRESS, SOCKET_ERROR_IN_PROGRESS}, {EALREADY, SOCKET_ERROR_ALREADY_IN_PROGRESS}, {ENOTSOCK, SOCKET_ERROR_NOT_SOCKET}, {EDESTADDRREQ, SOCKET_ERROR_DESTINATION_ADDRESS_REQUIRED}, {EMSGSIZE, SOCKET_ERROR_MESSAGE_SIZE}, {EPROTOTYPE, SOCKET_ERROR_PROTOCOL_TYPE}, {ENOPROTOOPT, SOCKET_ERROR_PROTOCOL_OPTION}, {EPROTONOSUPPORT, SOCKET_ERROR_PROTOCOL_NOT_SUPPORTED}, {ESOCKTNOSUPPORT, SOCKET_ERROR_SOCKET_NOT_SUPPORTED}, {ENOTSUP, SOCKET_ERROR_OPERATION_NOT_SUPPORTED}, {EPFNOSUPPORT, SOCKET_ERROR_PROTOCOL_FAMILY_NOT_SUPPORTED}, {EAFNOSUPPORT, SOCKET_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED}, {EADDRINUSE, SOCKET_ERROR_ADDRESS_ALREADY_IN_USE}, {EADDRNOTAVAIL, SOCKET_ERROR_ADDRESS_NOT_AVAILABLE}, {ENETDOWN, SOCKET_ERROR_NETWORK_DOWN}, {ENETUNREACH, SOCKET_ERROR_NETWORK_UNREACHABLE}, {ENETRESET, SOCKET_ERROR_NETWORK_RESET}, {ECONNABORTED, SOCKET_ERROR_CONNECTION_ABORTED}, {ECONNRESET, SOCKET_ERROR_CONNECTION_RESET}, {ENOBUFS, SOCKET_ERROR_NO_BUFFER_SPACE_AVAILABLE}, {EISCONN, SOCKET_ERROR_IS_CONNECTED}, {ENOTCONN, SOCKET_ERROR_NOT_CONNECTED}, {ESHUTDOWN, SOCKET_ERROR_SHUTDOWN}, {ETIMEDOUT, SOCKET_ERROR_TIMED_OUT}, {ECONNREFUSED, SOCKET_ERROR_CONNECTION_REFUSED}, {EHOSTDOWN, SOCKET_ERROR_HOST_DOWN}, {EHOSTUNREACH, SOCKET_ERROR_HOST_UNREACHABLE}, {EOPNOTSUPP, SOCKET_ERROR_SOCKET_NOT_SUPPORTED}}; auto it = socket_errors.find(error); if (it == socket_errors.end()) return SOCKET_ERROR_SOCKET_ERROR; return it->second; } - static int_least32_t protocol_type_to_native(int_least32_t protocol_type) { - static auto protocol_types = map {/*{PROTOCOL_TYPE_UNKNOWN, IPPROTO_}, {PROTOCOL_TYPE_IP_V6_HOP_BY_HOP_OPTIONS, IPPROTO_}, {PROTOCOL_TYPE_UNSPECIFIED, IPPROTO_},*/ {PROTOCOL_TYPE_IP, IPPROTO_IP}, {PROTOCOL_TYPE_ICMP, IPPROTO_ICMP}, {PROTOCOL_TYPE_IGMP, IPPROTO_IGMP}, {PROTOCOL_TYPE_GGP, 3 /*IPPROTO_GGP*/}, {PROTOCOL_TYPE_IP_V4, IPPROTO_IPIP}, {PROTOCOL_TYPE_TCP, IPPROTO_TCP}, {PROTOCOL_TYPE_PUP, IPPROTO_PUP}, {PROTOCOL_TYPE_UDP, IPPROTO_UDP}, {PROTOCOL_TYPE_IDP, IPPROTO_IDP}, {PROTOCOL_TYPE_IP_V6, IPPROTO_IPV6}, {PROTOCOL_TYPE_IP_V6_ROUTING_HEADER, IPPROTO_ROUTING}, {PROTOCOL_TYPE_IP_V6_FRAGMENT_HEADER, IPPROTO_FRAGMENT}, {PROTOCOL_TYPE_IP_SEC_ENCAPSULATING_SECURITY_PAYLOAD, IPPROTO_ESP}, {PROTOCOL_TYPE_IP_SEC_AUTHENTICATION_HEADER, IPPROTO_AH}, {PROTOCOL_TYPE_ICMP_V6, IPPROTO_ICMPV6}, {PROTOCOL_TYPE_IP_V6_NO_NEXT_HEADER, IPPROTO_NONE}, {PROTOCOL_TYPE_IP_V6_DESTINATION_OPTIONS, IPPROTO_DSTOPTS}, {PROTOCOL_TYPE_ND, IPPROTO_IP}, {PROTOCOL_TYPE_RAW, IPPROTO_RAW} /*{PROTOCOL_TYPE_IPX, IPPROTO_}, {PROTOCOL_TYPE_SPX, IPPROTO_IP}, {PROTOCOL_TYPE_SPX_2, IPPROTO_},*/}; + static int32_t protocol_type_to_native(int32_t protocol_type) { + static auto protocol_types = map {/*{PROTOCOL_TYPE_UNKNOWN, IPPROTO_}, {PROTOCOL_TYPE_IP_V6_HOP_BY_HOP_OPTIONS, IPPROTO_}, {PROTOCOL_TYPE_UNSPECIFIED, IPPROTO_},*/ {PROTOCOL_TYPE_IP, IPPROTO_IP}, {PROTOCOL_TYPE_ICMP, IPPROTO_ICMP}, {PROTOCOL_TYPE_IGMP, IPPROTO_IGMP}, {PROTOCOL_TYPE_GGP, 3 /*IPPROTO_GGP*/}, {PROTOCOL_TYPE_IP_V4, IPPROTO_IPIP}, {PROTOCOL_TYPE_TCP, IPPROTO_TCP}, {PROTOCOL_TYPE_PUP, IPPROTO_PUP}, {PROTOCOL_TYPE_UDP, IPPROTO_UDP}, {PROTOCOL_TYPE_IDP, IPPROTO_IDP}, {PROTOCOL_TYPE_IP_V6, IPPROTO_IPV6}, {PROTOCOL_TYPE_IP_V6_ROUTING_HEADER, IPPROTO_ROUTING}, {PROTOCOL_TYPE_IP_V6_FRAGMENT_HEADER, IPPROTO_FRAGMENT}, {PROTOCOL_TYPE_IP_SEC_ENCAPSULATING_SECURITY_PAYLOAD, IPPROTO_ESP}, {PROTOCOL_TYPE_IP_SEC_AUTHENTICATION_HEADER, IPPROTO_AH}, {PROTOCOL_TYPE_ICMP_V6, IPPROTO_ICMPV6}, {PROTOCOL_TYPE_IP_V6_NO_NEXT_HEADER, IPPROTO_NONE}, {PROTOCOL_TYPE_IP_V6_DESTINATION_OPTIONS, IPPROTO_DSTOPTS}, {PROTOCOL_TYPE_ND, IPPROTO_IP}, {PROTOCOL_TYPE_RAW, IPPROTO_RAW} /*{PROTOCOL_TYPE_IPX, IPPROTO_}, {PROTOCOL_TYPE_SPX, IPPROTO_IP}, {PROTOCOL_TYPE_SPX_2, IPPROTO_},*/}; auto it = protocol_types.find(protocol_type); if (it == protocol_types.end()) return IPPROTO_IP; return it->second; } - static int_least32_t socket_option_level_to_native(int_least32_t socket_option_level) { - static auto socket_option_levels = map {{SOCKET_OPTION_LEVEL_SOCKET, SOL_SOCKET}, {SOCKET_OPTION_LEVEL_IP, IPPROTO_IP}, {SOCKET_OPTION_LEVEL_IP_V6, IPPROTO_IPV6}, {SOCKET_OPTION_LEVEL_TCP, IPPROTO_TCP}, {SOCKET_OPTION_LEVEL_UDP, IPPROTO_UDP}}; + static int32_t socket_option_level_to_native(int32_t socket_option_level) { + static auto socket_option_levels = map {{SOCKET_OPTION_LEVEL_SOCKET, SOL_SOCKET}, {SOCKET_OPTION_LEVEL_IP, IPPROTO_IP}, {SOCKET_OPTION_LEVEL_IP_V6, IPPROTO_IPV6}, {SOCKET_OPTION_LEVEL_TCP, IPPROTO_TCP}, {SOCKET_OPTION_LEVEL_UDP, IPPROTO_UDP}}; auto it = socket_option_levels.find(socket_option_level); if (it == socket_option_levels.end()) return SOL_SOCKET; return it->second; } - static int_least32_t socket_option_name_to_native(int_least32_t socket_option_name) { - static auto socket_option_names = map {{SOCKET_OPTION_NAME_DEBUG, SO_DEBUG}, {SOCKET_OPTION_NAME_ACCEPT_CONNECTION, SO_ACCEPTCONN}, {SOCKET_OPTION_NAME_REUSE_ADDRESS, SO_REUSEADDR}, {SOCKET_OPTION_NAME_KEEP_ALIVE, SO_KEEPALIVE}, {SOCKET_OPTION_NAME_DONT_ROUTE, SO_DONTROUTE}, {SOCKET_OPTION_NAME_BROADCAST, SO_BROADCAST}, /*{SOCKET_OPTION_NAME_USE_LOOPBACK, SO_},*/ {SOCKET_OPTION_NAME_LINGER, SO_LINGER}, {SOCKET_OPTION_NAME_EXCLUSIVE_ADDRESS_USE, SO_REUSEADDR}, {SOCKET_OPTION_NAME_OUT_OF_BAND_INLINE, SO_OOBINLINE}, {SOCKET_OPTION_NAME_SEND_BUFFER, SO_SNDBUF}, {SOCKET_OPTION_NAME_RECEIVE_BUFFER, SO_RCVBUF}, {SOCKET_OPTION_NAME_SEND_LOW_WATER, SO_SNDLOWAT}, {SOCKET_OPTION_NAME_RECEIVE_LOW_WATER, SO_RCVLOWAT}, {SOCKET_OPTION_NAME_SEND_TIMEOUT, SO_SNDTIMEO}, {SOCKET_OPTION_NAME_RECEIVE_TIMEOUT, SO_RCVTIMEO}, {SOCKET_OPTION_NAME_ERROR, SO_ERROR}, {SOCKET_OPTION_NAME_TYPE, SO_TYPE}, /*{SOCKET_OPTION_NAME_MAX_CONNECTION, SO_},*/ {SOCKET_OPTION_NAME_IP_OPTIONS, IP_OPTIONS}, {SOCKET_OPTION_NAME_HEADER_INCLUDED, IP_HDRINCL}, {SOCKET_OPTION_NAME_TYPE_OF_SERVICE, IP_TOS}, {SOCKET_OPTION_NAME_IP_TIME_TO_LIVE, IP_TTL}, {SOCKET_OPTION_NAME_MULTICAST_INTERFACE, IP_MULTICAST_IF}, {SOCKET_OPTION_NAME_MULTICAST_TIME_TO_LIVE, IP_MULTICAST_TTL}, {SOCKET_OPTION_NAME_MULTICAST_LOOPBACK, IP_MULTICAST_LOOP}, {SOCKET_OPTION_NAME_ADD_MEMBERSHIP, IP_ADD_MEMBERSHIP}, {SOCKET_OPTION_NAME_DROP_MEMBERSHIP, IP_DROP_MEMBERSHIP}, {SOCKET_OPTION_NAME_DONT_FRAGMENT, IP_NODEFRAG}, {SOCKET_OPTION_NAME_ADD_SOURCE_MEMBERSHIP, IP_ADD_SOURCE_MEMBERSHIP}, {SOCKET_OPTION_NAME_DROP_SOURCE_MEMBERSHIP, IP_DROP_SOURCE_MEMBERSHIP}, {SOCKET_OPTION_NAME_BLOCK_SOURCE, IP_BLOCK_SOURCE}, {SOCKET_OPTION_NAME_UNBLOCK_SOURCE, IP_UNBLOCK_SOURCE}, {SOCKET_OPTION_NAME_PACKET_INFORMATION, IP_PKTINFO}, {SOCKET_OPTION_NAME_HOP_LIMIT, IPV6_HOPLIMIT}, /*{SOCKET_OPTION_NAME_IP_PROTECT_LEVEL, IPV6_},*/ {SOCKET_OPTION_NAME_IP_V6_ONLY, IPV6_V6ONLY}, /*{SOCKET_OPTION_NAME_NO_DELAY, TCP_}, {SOCKET_OPTION_NAME_BSD_URGENT, TCP_}, {SOCKET_OPTION_NAME_EXPEDITED, TCP_}, {SOCKET_OPTION_NAME_NO_CHECKSUM, UDP_}, {SOCKET_OPTION_NAME_CHECKSUM_COVERAGE, ...}, {SOCKET_OPTION_NAME_UPDATE_ACCEPT_CONTEXT, ...}, {SOCKET_OPTION_NAME_UPDATE_CONNECT_CONTEXT, ...},*/}; + static int32_t socket_option_name_to_native(int32_t socket_option_name) { + static auto socket_option_names = map {{SOCKET_OPTION_NAME_DEBUG, SO_DEBUG}, {SOCKET_OPTION_NAME_ACCEPT_CONNECTION, SO_ACCEPTCONN}, {SOCKET_OPTION_NAME_REUSE_ADDRESS, SO_REUSEADDR}, {SOCKET_OPTION_NAME_KEEP_ALIVE, SO_KEEPALIVE}, {SOCKET_OPTION_NAME_DONT_ROUTE, SO_DONTROUTE}, {SOCKET_OPTION_NAME_BROADCAST, SO_BROADCAST}, /*{SOCKET_OPTION_NAME_USE_LOOPBACK, SO_},*/ {SOCKET_OPTION_NAME_LINGER, SO_LINGER}, {SOCKET_OPTION_NAME_EXCLUSIVE_ADDRESS_USE, SO_REUSEADDR}, {SOCKET_OPTION_NAME_OUT_OF_BAND_INLINE, SO_OOBINLINE}, {SOCKET_OPTION_NAME_SEND_BUFFER, SO_SNDBUF}, {SOCKET_OPTION_NAME_RECEIVE_BUFFER, SO_RCVBUF}, {SOCKET_OPTION_NAME_SEND_LOW_WATER, SO_SNDLOWAT}, {SOCKET_OPTION_NAME_RECEIVE_LOW_WATER, SO_RCVLOWAT}, {SOCKET_OPTION_NAME_SEND_TIMEOUT, SO_SNDTIMEO}, {SOCKET_OPTION_NAME_RECEIVE_TIMEOUT, SO_RCVTIMEO}, {SOCKET_OPTION_NAME_ERROR, SO_ERROR}, {SOCKET_OPTION_NAME_TYPE, SO_TYPE}, /*{SOCKET_OPTION_NAME_MAX_CONNECTION, SO_},*/ {SOCKET_OPTION_NAME_IP_OPTIONS, IP_OPTIONS}, {SOCKET_OPTION_NAME_HEADER_INCLUDED, IP_HDRINCL}, {SOCKET_OPTION_NAME_TYPE_OF_SERVICE, IP_TOS}, {SOCKET_OPTION_NAME_IP_TIME_TO_LIVE, IP_TTL}, {SOCKET_OPTION_NAME_MULTICAST_INTERFACE, IP_MULTICAST_IF}, {SOCKET_OPTION_NAME_MULTICAST_TIME_TO_LIVE, IP_MULTICAST_TTL}, {SOCKET_OPTION_NAME_MULTICAST_LOOPBACK, IP_MULTICAST_LOOP}, {SOCKET_OPTION_NAME_ADD_MEMBERSHIP, IP_ADD_MEMBERSHIP}, {SOCKET_OPTION_NAME_DROP_MEMBERSHIP, IP_DROP_MEMBERSHIP}, {SOCKET_OPTION_NAME_DONT_FRAGMENT, IP_NODEFRAG}, {SOCKET_OPTION_NAME_ADD_SOURCE_MEMBERSHIP, IP_ADD_SOURCE_MEMBERSHIP}, {SOCKET_OPTION_NAME_DROP_SOURCE_MEMBERSHIP, IP_DROP_SOURCE_MEMBERSHIP}, {SOCKET_OPTION_NAME_BLOCK_SOURCE, IP_BLOCK_SOURCE}, {SOCKET_OPTION_NAME_UNBLOCK_SOURCE, IP_UNBLOCK_SOURCE}, {SOCKET_OPTION_NAME_PACKET_INFORMATION, IP_PKTINFO}, {SOCKET_OPTION_NAME_HOP_LIMIT, IPV6_HOPLIMIT}, /*{SOCKET_OPTION_NAME_IP_PROTECT_LEVEL, IPV6_},*/ {SOCKET_OPTION_NAME_IP_V6_ONLY, IPV6_V6ONLY}, /*{SOCKET_OPTION_NAME_NO_DELAY, TCP_}, {SOCKET_OPTION_NAME_BSD_URGENT, TCP_}, {SOCKET_OPTION_NAME_EXPEDITED, TCP_}, {SOCKET_OPTION_NAME_NO_CHECKSUM, UDP_}, {SOCKET_OPTION_NAME_CHECKSUM_COVERAGE, ...}, {SOCKET_OPTION_NAME_UPDATE_ACCEPT_CONTEXT, ...}, {SOCKET_OPTION_NAME_UPDATE_CONNECT_CONTEXT, ...},*/}; auto it = socket_option_names.find(socket_option_name); if (it == socket_option_names.end()) return -1; return it->second; } - static int_least32_t socket_type_to_native(int_least32_t socket_type) { - static auto socket_types = map {{SOCKET_TYPE_UNKNOWN, SOCK_STREAM | SOCK_CLOEXEC}, {SOCKET_TYPE_STREAM, SOCK_STREAM | SOCK_CLOEXEC}, {SOCKET_TYPE_DGRAM, SOCK_DGRAM | SOCK_CLOEXEC}, {SOCKET_TYPE_RAW, SOCK_RAW | SOCK_CLOEXEC}, {SOCKET_TYPE_RDM, SOCK_RDM | SOCK_CLOEXEC}, {SOCKET_TYPE_SEQPACKET, SOCK_SEQPACKET | SOCK_CLOEXEC}}; + static int32_t socket_type_to_native(int32_t socket_type) { + static auto socket_types = map {{SOCKET_TYPE_UNKNOWN, SOCK_STREAM | SOCK_CLOEXEC}, {SOCKET_TYPE_STREAM, SOCK_STREAM | SOCK_CLOEXEC}, {SOCKET_TYPE_DGRAM, SOCK_DGRAM | SOCK_CLOEXEC}, {SOCKET_TYPE_RAW, SOCK_RAW | SOCK_CLOEXEC}, {SOCKET_TYPE_RDM, SOCK_RDM | SOCK_CLOEXEC}, {SOCKET_TYPE_SEQPACKET, SOCK_SEQPACKET | SOCK_CLOEXEC}}; auto it = socket_types.find(socket_type); if (it == socket_types.end()) return SOCK_STREAM; return it->second; } } -int_least32_t socket::address_family_to_native(int_least32_t address_family) { - static auto address_families = map {{ADDRESS_FAMILY_UNKNOWN, -1}, {ADDRESS_FAMILY_UNSPECIFIED, AF_UNSPEC}, {ADDRESS_FAMILY_UNIX, AF_UNIX}, {ADDRESS_FAMILY_INTER_NETWORK, AF_INET}, {ADDRESS_FAMILY_SNA, AF_SNA}, /*{ADDRESS_FAMILY_IMP_LINK, AF_IMPLINK}, {ADDRESS_FAMILY_PUP, AF_PUP}, {ADDRESS_FAMILY_CHAOS, AF_CHAOS}, {ADDRESS_FAMILY_NS, AF_NS}, {ADDRESS_FAMILY_IPX, AF_}, {ADDRESS_FAMILY_ISO, AF_ISO}, {ADDRESS_FAMILY_ECMA, AF_ECMA}, {ADDRESS_FAMILY_DATA_KIT, AF_DATAKIT}, {ADDRESS_FAMILY_CCITT, AF_CCITT},*/ {ADDRESS_FAMILY_DEC_NET, AF_DECnet}, /*{ADDRESS_FAMILY_DATA_LINK, AF_DLI}, {ADDRESS_FAMILY_LAT, AF_LAT}, {ADDRESS_FAMILY_HYPER_CHANNEL, AF_HYLINK},*/ {ADDRESS_FAMILY_APPLE_TALK, AF_APPLETALK}, /*{ADDRESS_FAMILY_NET_BIOS, AF_NETBIOS}, {ADDRESS_FAMILY_VOICE_VIEW, AF_}, {ADDRESS_FAMILY_FIRE_FOX, AF_}, {ADDRESS_FAMILY_BANYAN, AF_}, {ADDRESS_FAMILY_ATM, AF_NATM},*/ {ADDRESS_FAMILY_INTER_NETWORK_V6, AF_INET6}, /*{ADDRESS_FAMILY_CLUSTER, AF_}, {ADDRESS_FAMILY_IEEE12844, AF_}, {ADDRESS_FAMILY_IRDA, AF_}, {ADDRESS_FAMILY_NETWORK_DESIGNERS, AF_},*/ {ADDRESS_FAMILY_MAX, AF_MAX}}; +int32_t socket::address_family_to_native(int32_t address_family) { + static auto address_families = map {{ADDRESS_FAMILY_UNKNOWN, -1}, {ADDRESS_FAMILY_UNSPECIFIED, AF_UNSPEC}, {ADDRESS_FAMILY_UNIX, AF_UNIX}, {ADDRESS_FAMILY_INTER_NETWORK, AF_INET}, {ADDRESS_FAMILY_SNA, AF_SNA}, /*{ADDRESS_FAMILY_IMP_LINK, AF_IMPLINK}, {ADDRESS_FAMILY_PUP, AF_PUP}, {ADDRESS_FAMILY_CHAOS, AF_CHAOS}, {ADDRESS_FAMILY_NS, AF_NS}, {ADDRESS_FAMILY_IPX, AF_}, {ADDRESS_FAMILY_ISO, AF_ISO}, {ADDRESS_FAMILY_ECMA, AF_ECMA}, {ADDRESS_FAMILY_DATA_KIT, AF_DATAKIT}, {ADDRESS_FAMILY_CCITT, AF_CCITT},*/ {ADDRESS_FAMILY_DEC_NET, AF_DECnet}, /*{ADDRESS_FAMILY_DATA_LINK, AF_DLI}, {ADDRESS_FAMILY_LAT, AF_LAT}, {ADDRESS_FAMILY_HYPER_CHANNEL, AF_HYLINK},*/ {ADDRESS_FAMILY_APPLE_TALK, AF_APPLETALK}, /*{ADDRESS_FAMILY_NET_BIOS, AF_NETBIOS}, {ADDRESS_FAMILY_VOICE_VIEW, AF_}, {ADDRESS_FAMILY_FIRE_FOX, AF_}, {ADDRESS_FAMILY_BANYAN, AF_}, {ADDRESS_FAMILY_ATM, AF_NATM},*/ {ADDRESS_FAMILY_INTER_NETWORK_V6, AF_INET6}, /*{ADDRESS_FAMILY_CLUSTER, AF_}, {ADDRESS_FAMILY_IEEE12844, AF_}, {ADDRESS_FAMILY_IRDA, AF_}, {ADDRESS_FAMILY_NETWORK_DESIGNERS, AF_},*/ {ADDRESS_FAMILY_MAX, AF_MAX}}; auto it = address_families.find(address_family); if (it == address_families.end()) return AF_UNSPEC; return it->second; } -int_least32_t socket::native_to_address_family(int_least32_t address_family) { - static auto address_families = map {/*{-1, ADDRESS_FAMILY_UNKNOWN}, */ {AF_UNSPEC, ADDRESS_FAMILY_UNSPECIFIED}, {AF_UNIX, ADDRESS_FAMILY_UNIX}, {AF_INET, ADDRESS_FAMILY_INTER_NETWORK}, /*{AF_IMPLINK, ADDRESS_FAMILY_IMP_LINK}, {AF_PUP, ADDRESS_FAMILY_PUP}, {AF_CHAOS, ADDRESS_FAMILY_CHAOS}, {AF_NS, ADDRESS_FAMILY_NS}, {AF_ISO, ADDRESS_FAMILY_ISO}, {AF_, ADDRESS_FAMILY_IPX}, {AF_ECMA, ADDRESS_FAMILY_ECMA}, {AF_DATAKIT, ADDRESS_FAMILY_DATA_KIT}, {AF_CCITT, ADDRESS_FAMILY_CCITT},*/ {AF_SNA, ADDRESS_FAMILY_SNA}, {AF_DECnet, ADDRESS_FAMILY_DEC_NET}, /*{AF_DLI, ADDRESS_FAMILY_DATA_LINK}, {AF_LAT, ADDRESS_FAMILY_LAT}, {AF_HYLINK, ADDRESS_FAMILY_HYPER_CHANNEL},*/ {AF_APPLETALK, ADDRESS_FAMILY_APPLE_TALK}, /*{AF_NETBIOS, ADDRESS_FAMILY_NET_BIOS}, {AF_, ADDRESS_FAMILY_VOICE_VIEW}, {AF_, ADDRESS_FAMILY_FIRE_FOX}, {AF_, ADDRESS_FAMILY_BANYAN}, {AF_NATM, ADDRESS_FAMILY_ATM},*/ {AF_INET6, ADDRESS_FAMILY_INTER_NETWORK_V6}, /*{AF_, ADDRESS_FAMILY_CLUSTER}, {AF_, ADDRESS_FAMILY_IEEE12844}, {AF_, ADDRESS_FAMILY_IRDA}, {AF_, ADDRESS_FAMILY_NETWORK_DESIGNERS},*/ {AF_MAX, ADDRESS_FAMILY_MAX}}; +int32_t socket::native_to_address_family(int32_t address_family) { + static auto address_families = map {/*{-1, ADDRESS_FAMILY_UNKNOWN}, */ {AF_UNSPEC, ADDRESS_FAMILY_UNSPECIFIED}, {AF_UNIX, ADDRESS_FAMILY_UNIX}, {AF_INET, ADDRESS_FAMILY_INTER_NETWORK}, /*{AF_IMPLINK, ADDRESS_FAMILY_IMP_LINK}, {AF_PUP, ADDRESS_FAMILY_PUP}, {AF_CHAOS, ADDRESS_FAMILY_CHAOS}, {AF_NS, ADDRESS_FAMILY_NS}, {AF_ISO, ADDRESS_FAMILY_ISO}, {AF_, ADDRESS_FAMILY_IPX}, {AF_ECMA, ADDRESS_FAMILY_ECMA}, {AF_DATAKIT, ADDRESS_FAMILY_DATA_KIT}, {AF_CCITT, ADDRESS_FAMILY_CCITT},*/ {AF_SNA, ADDRESS_FAMILY_SNA}, {AF_DECnet, ADDRESS_FAMILY_DEC_NET}, /*{AF_DLI, ADDRESS_FAMILY_DATA_LINK}, {AF_LAT, ADDRESS_FAMILY_LAT}, {AF_HYLINK, ADDRESS_FAMILY_HYPER_CHANNEL},*/ {AF_APPLETALK, ADDRESS_FAMILY_APPLE_TALK}, /*{AF_NETBIOS, ADDRESS_FAMILY_NET_BIOS}, {AF_, ADDRESS_FAMILY_VOICE_VIEW}, {AF_, ADDRESS_FAMILY_FIRE_FOX}, {AF_, ADDRESS_FAMILY_BANYAN}, {AF_NATM, ADDRESS_FAMILY_ATM},*/ {AF_INET6, ADDRESS_FAMILY_INTER_NETWORK_V6}, /*{AF_, ADDRESS_FAMILY_CLUSTER}, {AF_, ADDRESS_FAMILY_IEEE12844}, {AF_, ADDRESS_FAMILY_IRDA}, {AF_, ADDRESS_FAMILY_NETWORK_DESIGNERS},*/ {AF_MAX, ADDRESS_FAMILY_MAX}}; auto it = address_families.find(address_family); if (it == address_families.end()) return ADDRESS_FAMILY_UNSPECIFIED; return it->second; } -intmax_t socket::accept(intmax_t handle, vector& socket_address) { +intmax_t socket::accept(intmax_t handle, vector& socket_address) { auto address_length = static_cast(socket_address.size()); - auto socket = static_cast(::accept(static_cast(handle), reinterpret_cast(socket_address.data()), &address_length)); + auto socket = static_cast(::accept(static_cast(handle), reinterpret_cast(socket_address.data()), &address_length)); //if (socket_address.size() != address_length) socket_address.resize(address_length); return socket; } -int_least32_t socket::bind(intmax_t handle, const vector& socket_address) { - return ::bind(static_cast(handle), reinterpret_cast(socket_address.data()), static_cast(socket_address.size())); +int32_t socket::bind(intmax_t handle, const vector& socket_address) { + return ::bind(static_cast(handle), reinterpret_cast(socket_address.data()), static_cast(socket_address.size())); } void socket::cleanup() { // Nothing to do on linux and macOS. } -int_least32_t socket::connect(intmax_t handle, const vector& socket_address) { - return ::connect(static_cast(handle), reinterpret_cast(socket_address.data()), static_cast(socket_address.size())); +int32_t socket::connect(intmax_t handle, const vector& socket_address) { + return ::connect(static_cast(handle), reinterpret_cast(socket_address.data()), static_cast(socket_address.size())); } -intmax_t socket::create(int_least32_t address_family, int_least32_t socket_type, int_least32_t protocol_type) { +intmax_t socket::create(int32_t address_family, int32_t socket_type, int32_t protocol_type) { return static_cast(::socket(address_family_to_native(address_family), socket_type_to_native(socket_type), protocol_type_to_native(protocol_type))); } -int_least32_t socket::destroy(intmax_t handle) { - return ::close(static_cast(handle)); +int32_t socket::destroy(intmax_t handle) { + return ::close(static_cast(handle)); } size_t socket::get_available(intmax_t handle) { auto nbr_bytes_available = 0; - if (ioctl(static_cast(handle), FIONREAD, &nbr_bytes_available) != 0) return -1; + if (ioctl(static_cast(handle), FIONREAD, &nbr_bytes_available) != 0) return -1; return static_cast(nbr_bytes_available); } -int_least32_t socket::get_last_error() { +int32_t socket::get_last_error() { return native_to_socket_error(errno); } @@ -124,43 +124,43 @@ bool socket::get_os_supports_ip_v6() noexcept { return true; } -int_least32_t socket::get_raw_socket_option(intmax_t handle, int_least32_t socket_option_level, int_least32_t socket_option_name, intmax_t option, size_t& option_length) { - return ::getsockopt(static_cast(handle), socket_option_level, socket_option_name, reinterpret_cast(option), reinterpret_cast(&option_length)); +int32_t socket::get_raw_socket_option(intmax_t handle, int32_t socket_option_level, int32_t socket_option_name, intmax_t option, size_t& option_length) { + return ::getsockopt(static_cast(handle), socket_option_level, socket_option_name, reinterpret_cast(option), reinterpret_cast(&option_length)); } -int_least32_t socket::get_socket_option(intmax_t handle, int_least32_t socket_option_level, int_least32_t socket_option_name, intmax_t option, size_t& option_length) { +int32_t socket::get_socket_option(intmax_t handle, int32_t socket_option_level, int32_t socket_option_name, intmax_t option, size_t& option_length) { if (socket_option_name_to_native(socket_option_name) == -1) { errno = ENOTSUP; return -1; } if (socket_option_level == SOCKET_OPTION_LEVEL_SOCKET && (socket_option_name == SOCKET_OPTION_NAME_SEND_TIMEOUT || socket_option_name == SOCKET_OPTION_NAME_RECEIVE_TIMEOUT)) { auto timeout = timeval {0, 0}; - int_least32_t result = ::getsockopt(static_cast(handle), socket_option_level_to_native(socket_option_level), socket_option_name_to_native(socket_option_name), &timeout, reinterpret_cast(&option_length)); - *reinterpret_cast(option) = static_cast(timeout.tv_sec * 1000 + timeout.tv_usec / 1000); + int32_t result = ::getsockopt(static_cast(handle), socket_option_level_to_native(socket_option_level), socket_option_name_to_native(socket_option_name), &timeout, reinterpret_cast(&option_length)); + *reinterpret_cast(option) = static_cast(timeout.tv_sec * 1000 + timeout.tv_usec / 1000); return result; } - return ::getsockopt(static_cast(handle), socket_option_level_to_native(socket_option_level), socket_option_name_to_native(socket_option_name), reinterpret_cast(option), reinterpret_cast(&option_length)); + return ::getsockopt(static_cast(handle), socket_option_level_to_native(socket_option_level), socket_option_name_to_native(socket_option_name), reinterpret_cast(option), reinterpret_cast(&option_length)); } -int_least32_t socket::get_socket_linger_option(intmax_t handle, bool& enabled, uint_least32_t& linger_time) { - auto l = linger {static_cast(enabled), static_cast(linger_time)}; +int32_t socket::get_socket_linger_option(intmax_t handle, bool& enabled, uint32_t& linger_time) { + auto l = linger {static_cast(enabled), static_cast(linger_time)}; size_t linger_size = 0; - auto result = ::getsockopt(static_cast(handle), SOL_SOCKET, SO_LINGER, &l, reinterpret_cast(&linger_size)); + auto result = ::getsockopt(static_cast(handle), SOL_SOCKET, SO_LINGER, &l, reinterpret_cast(&linger_size)); if (result == 0) { enabled = static_cast(l.l_onoff); - linger_time = static_cast(l.l_linger); + linger_time = static_cast(l.l_linger); } return result; } -int_least32_t socket::get_socket_multicast_option(intmax_t handle, int_least32_t socket_option_name, uint_least32_t& multicast_address, uint_least32_t& interface_index) { +int32_t socket::get_socket_multicast_option(intmax_t handle, int32_t socket_option_name, uint32_t& multicast_address, uint32_t& interface_index) { struct multicast { - uint_least32_t multicast_address; - uint_least32_t interface_index; + uint32_t multicast_address; + uint32_t interface_index; } m; size_t multicast_size = 0; - auto result = getsockopt(static_cast(handle), IPPROTO_IP, socket_option_name_to_native(socket_option_name), &m, reinterpret_cast(&multicast_size)); + auto result = getsockopt(static_cast(handle), IPPROTO_IP, socket_option_name_to_native(socket_option_name), &m, reinterpret_cast(&multicast_size)); if (result == 0) { multicast_address = m.multicast_address; interface_index = m.interface_index; @@ -168,13 +168,13 @@ int_least32_t socket::get_socket_multicast_option(intmax_t handle, int_least32_t return result; } -int_least32_t socket::get_socket_ip_v6_multicast_option(intmax_t handle, int_least32_t socket_option_name, vector& multicast_address, uint_least32_t& interface_index) { +int32_t socket::get_socket_ip_v6_multicast_option(intmax_t handle, int32_t socket_option_name, vector& multicast_address, uint32_t& interface_index) { struct multicast { - uint_least8_t multicast_address[16]; - uint_least32_t interface_index; + uint8_t multicast_address[16]; + uint32_t interface_index; } m; size_t multicast_size = 0; - auto result = getsockopt(static_cast(handle), IPPROTO_IP, socket_option_name_to_native(socket_option_name), &m, reinterpret_cast(&multicast_size)); + auto result = getsockopt(static_cast(handle), IPPROTO_IP, socket_option_name_to_native(socket_option_name), &m, reinterpret_cast(&multicast_size)); if (result == 0) { for (auto index = 0U; index < multicast_address.size(); ++index) multicast_address[index] = m.multicast_address[index]; @@ -183,22 +183,22 @@ int_least32_t socket::get_socket_ip_v6_multicast_option(intmax_t handle, int_lea return result; } -int_least32_t socket::io_control(intmax_t handle, int_least32_t io_control, vector& option_in_value, vector& option_out_value) { +int32_t socket::io_control(intmax_t handle, int32_t io_control, vector& option_in_value, vector& option_out_value) { // Not implemented errno = ENOTSUP; return -1; } -int_least32_t socket::listen(intmax_t handle, size_t backlog) { - auto backlog_value = backlog != static_cast(-1) ? static_cast(backlog) : SOMAXCONN; - return ::listen(static_cast(handle), backlog_value); +int32_t socket::listen(intmax_t handle, size_t backlog) { + auto backlog_value = backlog != static_cast(-1) ? static_cast(backlog) : SOMAXCONN; + return ::listen(static_cast(handle), backlog_value); } -int_least32_t socket::poll(intmax_t handle, int_least32_t microseconds, int_least32_t mode) { +int32_t socket::poll(intmax_t handle, int32_t microseconds, int32_t mode) { if (handle == 0 || microseconds < 0) return -1; auto poll_fd = pollfd {}; - poll_fd.fd = static_cast(handle); + poll_fd.fd = static_cast(handle); switch (mode) { case SELECT_MODE_READ: poll_fd.events = POLLIN; break; case SELECT_MODE_WRITE: poll_fd.events = POLLOUT; break; @@ -208,16 +208,16 @@ int_least32_t socket::poll(intmax_t handle, int_least32_t microseconds, int_leas return ::poll(&poll_fd, 1, microseconds); } -int_least32_t socket::receive(intmax_t handle, vector& buffer, size_t offset, size_t size, int_least32_t flags) { - auto result = static_cast(::recv(static_cast(handle), &buffer.data()[offset], size, flags)); +int32_t socket::receive(intmax_t handle, vector& buffer, size_t offset, size_t size, int32_t flags) { + auto result = static_cast(::recv(static_cast(handle), &buffer.data()[offset], size, flags)); if (result == -1 && errno == EBADF) errno = EINTR; if (result == -1 && errno == EAGAIN) errno = ETIMEDOUT; return result; } -int_least32_t socket::receive_from(intmax_t handle, vector& buffer, size_t offset, size_t size, int_least32_t flags, vector& socket_address) { +int32_t socket::receive_from(intmax_t handle, vector& buffer, size_t offset, size_t size, int32_t flags, vector& socket_address) { auto address_length = static_cast(socket_address.size()); - auto result = static_cast(::recvfrom(static_cast(handle), &buffer.data()[offset], size, flags, reinterpret_cast(socket_address.data()), &address_length)); + auto result = static_cast(::recvfrom(static_cast(handle), &buffer.data()[offset], size, flags, reinterpret_cast(socket_address.data()), &address_length)); //if (socket_address.size() != address_length) socket_address.resize(address_length); if (result == -1 && errno == EBADF) errno = EINTR; @@ -225,111 +225,111 @@ int_least32_t socket::receive_from(intmax_t handle, vector& buffe return result; } -int_least32_t socket::select(vector& check_read, vector& check_write, vector& check_error, int_least32_t microseconds) { +int32_t socket::select(vector& check_read, vector& check_write, vector& check_error, int32_t microseconds) { size_t nfds = 0; auto read_fds = fd_set {}; FD_ZERO(&read_fds); for (auto i = 0U; i < check_read.size() && i < FD_SETSIZE; i++) - FD_SET(static_cast(check_read[i]), &read_fds); + FD_SET(static_cast(check_read[i]), &read_fds); if (check_read.size() > nfds) nfds = check_read.size(); auto write_fds = fd_set {}; FD_ZERO(&write_fds); for (auto i = 0U; i < check_write.size() && i < FD_SETSIZE; i++) - FD_SET(static_cast(check_write[i]), &write_fds); + FD_SET(static_cast(check_write[i]), &write_fds); if (check_write.size() > nfds) nfds = check_write.size(); auto error_fds = fd_set {}; FD_ZERO(&error_fds); for (auto i = 0U; i < check_error.size() && i < FD_SETSIZE; i++) - FD_SET(static_cast(check_error[i]), &error_fds); + FD_SET(static_cast(check_error[i]), &error_fds); if (check_error.size() > nfds) nfds = check_error.size(); auto timeout = timeval {microseconds / 1000000, microseconds % 1000000}; - auto result = ::select(static_cast(nfds + 1), &read_fds, &write_fds, &error_fds, microseconds == -1 ? nullptr : &timeout); + auto result = ::select(static_cast(nfds + 1), &read_fds, &write_fds, &error_fds, microseconds == -1 ? nullptr : &timeout); for (auto i = 0U; i < check_read.size(); i++) { - FD_CLR(static_cast(check_read[i]), &read_fds); - if (FD_ISSET(static_cast(check_read[i]), &read_fds) == 0) check_read[i] = 0; + FD_CLR(static_cast(check_read[i]), &read_fds); + if (FD_ISSET(static_cast(check_read[i]), &read_fds) == 0) check_read[i] = 0; } for (auto i = 0U; i < check_write.size(); i++) { - FD_CLR(static_cast(check_write[i]), &write_fds); - if (FD_ISSET(static_cast(check_write[i]), &write_fds) == 0) check_write[i] = 0; + FD_CLR(static_cast(check_write[i]), &write_fds); + if (FD_ISSET(static_cast(check_write[i]), &write_fds) == 0) check_write[i] = 0; } for (auto i = 0U; i < check_error.size(); i++) { - FD_CLR(static_cast(check_error[i]), &error_fds); - if (FD_ISSET(static_cast(check_error[i]), &error_fds) == 0) check_error[i] = 0; + FD_CLR(static_cast(check_error[i]), &error_fds); + if (FD_ISSET(static_cast(check_error[i]), &error_fds) == 0) check_error[i] = 0; } return result; } -int_least32_t socket::send(intmax_t handle, const vector& buffer, size_t offset, size_t size, int_least32_t flags) { - return static_cast(::send(static_cast(handle), &buffer.data()[offset], size, flags)); +int32_t socket::send(intmax_t handle, const vector& buffer, size_t offset, size_t size, int32_t flags) { + return static_cast(::send(static_cast(handle), &buffer.data()[offset], size, flags)); } -int_least32_t socket::send_to(intmax_t handle, const vector& buffer, size_t offset, size_t size, int_least32_t flags, const vector& socket_address) { - return static_cast(::sendto(static_cast(handle), &buffer.data()[offset], size, flags, reinterpret_cast(socket_address.data()), static_cast(socket_address.size()))); +int32_t socket::send_to(intmax_t handle, const vector& buffer, size_t offset, size_t size, int32_t flags, const vector& socket_address) { + return static_cast(::sendto(static_cast(handle), &buffer.data()[offset], size, flags, reinterpret_cast(socket_address.data()), static_cast(socket_address.size()))); } -int_least32_t socket::set_blocking(intmax_t handle, bool blocking) { +int32_t socket::set_blocking(intmax_t handle, bool blocking) { auto result = -1; - if ((result = fcntl(static_cast(handle), F_GETFL, 0)) != -1) { + if ((result = fcntl(static_cast(handle), F_GETFL, 0)) != -1) { auto flags = result; if (blocking == true) flags &= ~O_NONBLOCK; else flags |= O_NONBLOCK; - result = fcntl(static_cast(handle), F_SETFL, flags) == -1 ? -1 : 0; + result = fcntl(static_cast(handle), F_SETFL, flags) == -1 ? -1 : 0; } return result; } -int_least32_t socket::set_raw_socket_option(intmax_t handle, int_least32_t socket_option_level, int_least32_t socket_option_name, intmax_t option, size_t option_length) { - return setsockopt(static_cast(handle), socket_option_level, socket_option_name, reinterpret_cast(option), static_cast(option_length)); +int32_t socket::set_raw_socket_option(intmax_t handle, int32_t socket_option_level, int32_t socket_option_name, intmax_t option, size_t option_length) { + return setsockopt(static_cast(handle), socket_option_level, socket_option_name, reinterpret_cast(option), static_cast(option_length)); } -int_least32_t socket::set_socket_option(intmax_t handle, int_least32_t socket_option_level, int_least32_t socket_option_name, intmax_t option, size_t option_length) { +int32_t socket::set_socket_option(intmax_t handle, int32_t socket_option_level, int32_t socket_option_name, intmax_t option, size_t option_length) { if (socket_option_name_to_native(socket_option_name) == -1) { errno = ENOTSUP; return -1; } if (socket_option_level == SOCKET_OPTION_LEVEL_SOCKET && (socket_option_name == SOCKET_OPTION_NAME_SEND_TIMEOUT || socket_option_name == SOCKET_OPTION_NAME_RECEIVE_TIMEOUT)) { - timeval timeout = {*reinterpret_cast(option) / 1000, *reinterpret_cast(option) % 1000 * 1000}; - return ::setsockopt(static_cast(handle), socket_option_level_to_native(socket_option_level), socket_option_name_to_native(socket_option_name), &timeout, sizeof(timeval)); + timeval timeout = {*reinterpret_cast(option) / 1000, *reinterpret_cast(option) % 1000 * 1000}; + return ::setsockopt(static_cast(handle), socket_option_level_to_native(socket_option_level), socket_option_name_to_native(socket_option_name), &timeout, sizeof(timeval)); } - return setsockopt(static_cast(handle), socket_option_level_to_native(socket_option_level), socket_option_name_to_native(socket_option_name), reinterpret_cast(option), static_cast(option_length)); + return setsockopt(static_cast(handle), socket_option_level_to_native(socket_option_level), socket_option_name_to_native(socket_option_name), reinterpret_cast(option), static_cast(option_length)); } -int_least32_t socket::set_socket_linger_option(intmax_t handle, bool enabled, uint_least32_t linger_time) { - auto l = linger {static_cast(enabled), static_cast(linger_time)}; - return setsockopt(static_cast(handle), SOL_SOCKET, SO_LINGER, &l, static_cast(sizeof(linger))); +int32_t socket::set_socket_linger_option(intmax_t handle, bool enabled, uint32_t linger_time) { + auto l = linger {static_cast(enabled), static_cast(linger_time)}; + return setsockopt(static_cast(handle), SOL_SOCKET, SO_LINGER, &l, static_cast(sizeof(linger))); } -int_least32_t socket::set_socket_multicast_option(intmax_t handle, int_least32_t socket_option_name, uint_least32_t multicast_address, uint_least32_t interface_index) { +int32_t socket::set_socket_multicast_option(intmax_t handle, int32_t socket_option_name, uint32_t multicast_address, uint32_t interface_index) { struct multicast { - uint_least32_t multicast_address; - uint_least32_t interface_index; + uint32_t multicast_address; + uint32_t interface_index; } m {multicast_address, interface_index}; - return setsockopt(static_cast(handle), IPPROTO_TCP, socket_option_name_to_native(socket_option_name), &m, static_cast(sizeof(multicast))); + return setsockopt(static_cast(handle), IPPROTO_TCP, socket_option_name_to_native(socket_option_name), &m, static_cast(sizeof(multicast))); } -int_least32_t socket::set_socket_ip_v6_multicast_option(intmax_t handle, int_least32_t socket_option_name, const vector& multicast_address, uint_least32_t interface_index) { +int32_t socket::set_socket_ip_v6_multicast_option(intmax_t handle, int32_t socket_option_name, const vector& multicast_address, uint32_t interface_index) { struct multicast { - uint_least8_t multicast_address[16]; - uint_least32_t interface_index; + uint8_t multicast_address[16]; + uint32_t interface_index; } m; for (auto index = 0U; index < multicast_address.size(); ++index) m.multicast_address[index] = multicast_address[index]; m.interface_index = interface_index; - return setsockopt(static_cast(handle), IPPROTO_IP, socket_option_name_to_native(socket_option_name), &m, static_cast(sizeof(multicast))); + return setsockopt(static_cast(handle), IPPROTO_IP, socket_option_name_to_native(socket_option_name), &m, static_cast(sizeof(multicast))); } -int_least32_t socket::shutdown(intmax_t handle, int_least32_t how) { - auto result = ::shutdown(static_cast(handle), how); +int32_t socket::shutdown(intmax_t handle, int32_t how) { + auto result = ::shutdown(static_cast(handle), how); if (how == SOCKET_SHUTDOWN_BOTH && result == -1 && errno == ENOTCONN) { errno = 0; result = 0; diff --git a/src/xtd.core.native.linux/src/xtd/native/linux/speech_synthesizer.cpp b/src/xtd.core.native.linux/src/xtd/native/linux/speech_synthesizer.cpp index bd78f775f4b..2f7b7fecc1e 100644 --- a/src/xtd.core.native.linux/src/xtd/native/linux/speech_synthesizer.cpp +++ b/src/xtd.core.native.linux/src/xtd/native/linux/speech_synthesizer.cpp @@ -27,7 +27,7 @@ namespace { } static string get_unique_speak_cmd_file_name() { - static int_least32_t cpt = 0; + static int32_t cpt = 0; stringstream ss; ss << get_temp_path() << "/__xtd_speech_synthesizer_speak_process_" << ++cpt << "__.cmd"; return ss.str(); @@ -66,7 +66,7 @@ void speech_synthesizer::speak(intmax_t handle, const string& text_to_speak) { void speech_synthesizer::speak_async(intmax_t handle, const string& text_to_speak, std::function on_speak_completed) { reinterpret_cast(handle)->process_handle = native::process::shell_execute("", reinterpret_cast(handle)->say_cmd_file_name, text_to_speak, "", PROCESS_WINDOW_STYLE_HIDDEN); auto wait_process_thread = thread {[on_speak_completed, handle] { - int_least32_t exit_code = 0; + int32_t exit_code = 0; native::process::wait(reinterpret_cast(handle)->process_handle, exit_code); on_speak_completed(); }}; diff --git a/src/xtd.core.native.linux/src/xtd/native/linux/system_sound.cpp b/src/xtd.core.native.linux/src/xtd/native/linux/system_sound.cpp index c51ff674d01..d346e3276f6 100644 --- a/src/xtd.core.native.linux/src/xtd/native/linux/system_sound.cpp +++ b/src/xtd.core.native.linux/src/xtd/native/linux/system_sound.cpp @@ -10,12 +10,12 @@ using namespace xtd::native; #if defined(__XTD_USE_GSOUND__) #include -void system_sound::play(uint_least32_t sound) { - static auto sounds = map {{ST_BEEP, "bell-window-system"}, {ST_ICONERROR, "dialog-error"}, {ST_ICONQUESTION, "dialog-question"}, {ST_ICONWARNING, "dialog-warning"}, {ST_ICONINFORMATION, "dialog-information"}, {ST_OK, "bell-window-system"}}; +void system_sound::play(uint32_t sound) { + static auto sounds = map {{ST_BEEP, "bell-window-system"}, {ST_ICONERROR, "dialog-error"}, {ST_ICONQUESTION, "dialog-question"}, {ST_ICONWARNING, "dialog-warning"}, {ST_ICONINFORMATION, "dialog-information"}, {ST_OK, "bell-window-system"}}; static auto gsound_context = gsound_context_new(nullptr, nullptr); gsound_context_play_simple(gsound_context, nullptr, nullptr, GSOUND_ATTR_EVENT_ID, sounds[sound].c_str(), nullptr); } #else -void system_sound::play(uint_least32_t sound) { +void system_sound::play(uint32_t sound) { } #endif diff --git a/src/xtd.core.native.linux/src/xtd/native/linux/thread.cpp b/src/xtd.core.native.linux/src/xtd/native/linux/thread.cpp index 2f6dc4e05a8..8513e9a01db 100644 --- a/src/xtd.core.native.linux/src/xtd/native/linux/thread.cpp +++ b/src/xtd.core.native.linux/src/xtd/native/linux/thread.cpp @@ -15,7 +15,7 @@ bool thread::cancel(intmax_t handle) { return pthread_cancel(static_cast(handle)) == 0; } -intmax_t thread::create(std::function start, intmax_t obj, int_least32_t max_stack_size, bool suspended, intmax_t& id) { +intmax_t thread::create(std::function start, intmax_t obj, int32_t max_stack_size, bool suspended, intmax_t& id) { auto thread = pthread_t {}; int error = pthread_create(&thread, nullptr, [](void* thread_arg)->void* { auto start_obj = reinterpret_cast, intmax_t>*>(thread_arg); @@ -58,18 +58,18 @@ bool thread::set_current_thread_name(const std::string& name) { return true; } -bool thread::set_priority(intmax_t handle, int_least32_t priority) { +bool thread::set_priority(intmax_t handle, int32_t priority) { if (static_cast(handle) == PTHREAD_FAILED) return false; auto policy = 0; auto sched_param = ::sched_param {}; if (::pthread_getschedparam(static_cast(handle), &policy, &sched_param) != 0) return false; - sched_param.sched_priority = static_cast(ceil((static_cast(priority) * (sched_get_priority_max(policy) - sched_get_priority_min(policy)) / 4) + sched_get_priority_min(policy))); + sched_param.sched_priority = static_cast(ceil((static_cast(priority) * (sched_get_priority_max(policy) - sched_get_priority_min(policy)) / 4) + sched_get_priority_min(policy))); return pthread_setschedparam(static_cast(handle), policy, &sched_param) == 0; } -void thread::sleep(int_least32_t milliseconds_timeout) { +void thread::sleep(int32_t milliseconds_timeout) { auto infinite_sleep = [] {while (true) std::this_thread::sleep_for(std::chrono::hours::max());}; if (milliseconds_timeout == -1) infinite_sleep(); else if (milliseconds_timeout == 0) yield(); diff --git a/src/xtd.core.native.linux/src/xtd/native/linux/unnamed_event_wait_handle.cpp b/src/xtd.core.native.linux/src/xtd/native/linux/unnamed_event_wait_handle.cpp index 3e36685dc98..ef3b37e615b 100644 --- a/src/xtd.core.native.linux/src/xtd/native/linux/unnamed_event_wait_handle.cpp +++ b/src/xtd.core.native.linux/src/xtd/native/linux/unnamed_event_wait_handle.cpp @@ -41,7 +41,7 @@ bool unnamed_event_wait_handle::reset(intmax_t handle, bool& io_error) { return true; } -uint_least32_t unnamed_event_wait_handle::wait(intmax_t handle, int_least32_t milliseconds_timeout, bool manual_reset) { +uint32_t unnamed_event_wait_handle::wait(intmax_t handle, int32_t milliseconds_timeout, bool manual_reset) { if (reinterpret_cast(handle) == SEM_FAILED) return 0xFFFFFFFF; auto result = milliseconds_timeout == -1 ? sem_wait(reinterpret_cast(handle)) : sem_milliseconds_timedwait(reinterpret_cast(handle), milliseconds_timeout); if (result && errno == EAGAIN) return 0xFFFFFFFF; diff --git a/src/xtd.core.native.linux/src/xtd/native/linux/unnamed_mutex.cpp b/src/xtd.core.native.linux/src/xtd/native/linux/unnamed_mutex.cpp index a0e2698aed4..449d87e6b1f 100644 --- a/src/xtd.core.native.linux/src/xtd/native/linux/unnamed_mutex.cpp +++ b/src/xtd.core.native.linux/src/xtd/native/linux/unnamed_mutex.cpp @@ -32,7 +32,7 @@ bool unnamed_mutex::signal(intmax_t handle, bool& io_error) { return !io_error; } -uint_least32_t unnamed_mutex::wait(intmax_t handle, int_least32_t milliseconds_timeout) { +uint32_t unnamed_mutex::wait(intmax_t handle, int32_t milliseconds_timeout) { if (reinterpret_cast(handle) == MUTEX_FAILED) return 0xFFFFFFFF; auto result = milliseconds_timeout == -1 ? pthread_mutex_unlock(reinterpret_cast(handle)) : pthread_mutex_milliseconds_timedlock(reinterpret_cast(handle), milliseconds_timeout); if (result && errno == EAGAIN) return 0xFFFFFFFF; diff --git a/src/xtd.core.native.linux/src/xtd/native/linux/unnamed_semaphore.cpp b/src/xtd.core.native.linux/src/xtd/native/linux/unnamed_semaphore.cpp index 79f8efcb3ed..2f13a1a37b7 100644 --- a/src/xtd.core.native.linux/src/xtd/native/linux/unnamed_semaphore.cpp +++ b/src/xtd.core.native.linux/src/xtd/native/linux/unnamed_semaphore.cpp @@ -5,7 +5,7 @@ using namespace xtd::native; -intmax_t unnamed_semaphore::create(int_least32_t initial_count, int_least32_t max_count) { +intmax_t unnamed_semaphore::create(int32_t initial_count, int32_t max_count) { auto semaphore = new sem_t; if (sem_init(semaphore, 0, std::min(initial_count, max_count)) == -1) return reinterpret_cast(SEM_FAILED); return reinterpret_cast(semaphore); @@ -17,7 +17,7 @@ void unnamed_semaphore::destroy(intmax_t handle) { delete reinterpret_cast(handle); } -bool unnamed_semaphore::signal(intmax_t handle, int_least32_t release_count, int_least32_t& previous_count, bool& io_error) { +bool unnamed_semaphore::signal(intmax_t handle, int32_t release_count, int32_t& previous_count, bool& io_error) { io_error = false; if (reinterpret_cast(handle) == SEM_FAILED) { io_error = true; @@ -30,7 +30,7 @@ bool unnamed_semaphore::signal(intmax_t handle, int_least32_t release_count, int return !io_error; } -uint_least32_t unnamed_semaphore::wait(intmax_t handle, int_least32_t milliseconds_timeout) { +uint32_t unnamed_semaphore::wait(intmax_t handle, int32_t milliseconds_timeout) { if (reinterpret_cast(handle) == SEM_FAILED) return 0xFFFFFFFF; auto result = milliseconds_timeout == -1 ? sem_wait(reinterpret_cast(handle)) : sem_milliseconds_timedwait(reinterpret_cast(handle), milliseconds_timeout); if (result && errno == EAGAIN) return 0xFFFFFFFF; diff --git a/src/xtd.core.native.macos/include/xtd/native/macos/mutex.h b/src/xtd.core.native.macos/include/xtd/native/macos/mutex.h index 8193fa58e88..a7699378f6a 100644 --- a/src/xtd.core.native.macos/include/xtd/native/macos/mutex.h +++ b/src/xtd.core.native.macos/include/xtd/native/macos/mutex.h @@ -27,7 +27,7 @@ static inline int pthread_mutex_timedlock(pthread_mutex_t* mut, const struct tim return 0; } -static inline int pthread_mutex_milliseconds_timedlock(pthread_mutex_t* mut, int_least32_t milliseconds_timeout) { +static inline int pthread_mutex_milliseconds_timedlock(pthread_mutex_t* mut, int32_t milliseconds_timeout) { struct timespec timeout; clock_gettime(CLOCK_REALTIME, &timeout); timeout.tv_sec += milliseconds_timeout / 1000; diff --git a/src/xtd.core.native.macos/include/xtd/native/macos/semaphore.h b/src/xtd.core.native.macos/include/xtd/native/macos/semaphore.h index f48b3243537..ed01b91fdf7 100644 --- a/src/xtd.core.native.macos/include/xtd/native/macos/semaphore.h +++ b/src/xtd.core.native.macos/include/xtd/native/macos/semaphore.h @@ -30,7 +30,7 @@ static inline int sem_timedwait(sem_t *sem, const struct timespec *abs_timeout) return 0; } -static inline int sem_milliseconds_timedwait(sem_t *sem, int_least32_t milliseconds_timeout) { +static inline int sem_milliseconds_timedwait(sem_t *sem, int32_t milliseconds_timeout) { struct timespec timeout; clock_gettime(CLOCK_REALTIME, &timeout); timeout.tv_sec += milliseconds_timeout / 1000; diff --git a/src/xtd.core.native.macos/include/xtd/native/macos/strings.h b/src/xtd.core.native.macos/include/xtd/native/macos/strings.h index 1707a703afd..298cc1c76d5 100644 --- a/src/xtd.core.native.macos/include/xtd/native/macos/strings.h +++ b/src/xtd.core.native.macos/include/xtd/native/macos/strings.h @@ -140,7 +140,7 @@ namespace xtd::native::macos { return result; } - static bool try_parse(const std::string& str, int_least32_t& value) noexcept { + static bool try_parse(const std::string& str, int32_t& value) noexcept { try { value = std::atoi(str.c_str()); return true; diff --git a/src/xtd.core.native.macos/src/xtd/native/macos/condition_variable.mm b/src/xtd.core.native.macos/src/xtd/native/macos/condition_variable.mm index bbf87643b3a..ca55d8fc8fe 100644 --- a/src/xtd.core.native.macos/src/xtd/native/macos/condition_variable.mm +++ b/src/xtd.core.native.macos/src/xtd/native/macos/condition_variable.mm @@ -31,7 +31,7 @@ pthread_cond_broadcast(reinterpret_cast(handle)); } -bool condition_variable::wait(intmax_t handle, intmax_t critical_section_handle, int_least32_t milliseconds_timeout) { +bool condition_variable::wait(intmax_t handle, intmax_t critical_section_handle, int32_t milliseconds_timeout) { if (handle == reinterpret_cast(MUTEX_FAILED)) return false; if (reinterpret_cast(critical_section_handle) == nullptr) return false; diff --git a/src/xtd.core.native.macos/src/xtd/native/macos/console.mm b/src/xtd.core.native.macos/src/xtd/native/macos/console.mm index c2e12629b7b..703b465f160 100644 --- a/src/xtd.core.native.macos/src/xtd/native/macos/console.mm +++ b/src/xtd.core.native.macos/src/xtd/native/macos/console.mm @@ -19,8 +19,8 @@ namespace { auto treat_control_c_as_input = false; - auto signal_couter_ = std::vector {}; - auto user_cancel_callback = std::function {}; + auto signal_couter_ = std::vector {}; + auto user_cancel_callback = std::function {}; struct console_intercept_signals { private: @@ -34,14 +34,14 @@ ::signal(signal.first, SIG_DFL); } - static void signal_handler(int_least32_t signal) { + static void signal_handler(int32_t signal) { ::signal(signal, console_intercept_signals::signal_handler); if (treat_control_c_as_input) signal_couter_.push_back(signal_keys_[signal]); else if (user_cancel_callback && user_cancel_callback(signal_keys_[signal]) == false) exit(EXIT_FAILURE); } // The SIGINT signal catcher conflicts with with xtd::environment::cancel_interrupt signal... - inline static std::map signal_keys_ {{SIGQUIT, CONSOLE_SPECIAL_KEY_CTRL_BS}, {SIGTSTP, CONSOLE_SPECIAL_KEY_CTRL_Z}/*, {SIGINT, CONSOLE_SPECIAL_KEY_CTRL_C}*/}; + inline static std::map signal_keys_ {{SIGQUIT, CONSOLE_SPECIAL_KEY_CTRL_BS}, {SIGTSTP, CONSOLE_SPECIAL_KEY_CTRL_Z}/*, {SIGINT, CONSOLE_SPECIAL_KEY_CTRL_C}*/}; static console_intercept_signals console_intercept_signals_; }; @@ -67,7 +67,7 @@ bool icanon(bool on) { return tcsetattr(0, TCSANOW, &status) == 0; } - int_least32_t getch() { + int32_t getch() { if (peek_character != -1) { auto character = peek_character; peek_character = -1; @@ -144,7 +144,7 @@ termios pop_status() { } - int_least8_t peek_character {-1}; + int8_t peek_character {-1}; std::vector statuses; }; @@ -155,8 +155,8 @@ termios pop_status() { class input_list { public: input_list() {} - explicit input_list(const std::list& chars) : chars(chars) {} - explicit input_list(std::initializer_list il) : chars(il) {} + explicit input_list(const std::list& chars) : chars(chars) {} + explicit input_list(std::initializer_list il) : chars(il) {} input_list(const input_list& il) : chars(il.chars) {} input_list& operator =(const input_list& il) { @@ -167,8 +167,8 @@ explicit input_list(std::initializer_list il) : chars(il) {} bool operator ==(const input_list& il) const noexcept {return chars == il.chars;} bool operator !=(const input_list& il) const noexcept {return chars != il.chars;} - using const_iterator = std::list::const_iterator; - using iterator = std::list::iterator; + using const_iterator = std::list::const_iterator; + using iterator = std::list::iterator; const_iterator cbegin() const {return chars.begin();} const_iterator cend() const {return chars.end();} @@ -177,11 +177,11 @@ explicit input_list(std::initializer_list il) : chars(il) {} const_iterator end() const {return chars.end();} iterator end() {return chars.end();} - void add(int_least32_t c) {chars.push_back(c);} - void add_front(int_least32_t c) {chars.push_front(c);} - void remove(int_least32_t c) {chars.remove(c);} - int_least32_t count() const {return static_cast(chars.size());} - int_least32_t pop() { int_least32_t c = chars.front(); chars.erase(chars.begin()); return c;} + void add(int32_t c) {chars.push_back(c);} + void add_front(int32_t c) {chars.push_front(c);} + void remove(int32_t c) {chars.remove(c);} + int32_t count() const {return static_cast(chars.size());} + int32_t pop() { int32_t c = chars.front(); chars.erase(chars.begin()); return c;} void clear() {chars.clear();} bool is_empty() const {return chars.empty();} @@ -214,7 +214,7 @@ static input_list parse(const std::string& value) { } private: - std::list chars; + std::list chars; }; key_info(const key_info& ki) : key_(ki.key_), key_char_(ki.key_char_), has_alt_modifier_(ki.has_alt_modifier_), has_control_modifier_(ki.has_control_modifier_), has_shift_modifier_(ki.has_shift_modifier_) {} @@ -267,18 +267,18 @@ static key_info read() { std::string to_string() const { auto result = std::stringstream {}; - result << "{key=" << std::hex << static_cast(key_) << ", key_char=" << std::dec << static_cast(key_char_) << ", has_alt_modifier=" << to_string(has_alt_modifier_) << ", has_control_modifier=" << to_string(has_control_modifier_) << ", has_shift_modifier=" << to_string(has_shift_modifier_) << "}"; + result << "{key=" << std::hex << static_cast(key_) << ", key_char=" << std::dec << static_cast(key_char_) << ", has_alt_modifier=" << to_string(has_alt_modifier_) << ", has_control_modifier=" << to_string(has_control_modifier_) << ", has_shift_modifier=" << to_string(has_shift_modifier_) << "}"; return result.str(); } private: key_info() : key_(U'0'), key_char_(U'0'), has_alt_modifier_(false), has_control_modifier_(false), has_shift_modifier_(false) {} - key_info(int_least32_t key, int_least32_t key_char) : key_(key), key_char_(key_char), has_alt_modifier_(false), has_control_modifier_(false), has_shift_modifier_(false) {} - key_info(int_least32_t key, int_least32_t key_char, bool has_alt_modifier, bool has_control_modifier, bool has_shift_modifier) : key_(key), key_char_(key_char), has_alt_modifier_(has_alt_modifier), has_control_modifier_(has_control_modifier), has_shift_modifier_(has_shift_modifier) {} + key_info(int32_t key, int32_t key_char) : key_(key), key_char_(key_char), has_alt_modifier_(false), has_control_modifier_(false), has_shift_modifier_(false) {} + key_info(int32_t key, int32_t key_char, bool has_alt_modifier, bool has_control_modifier, bool has_shift_modifier) : key_(key), key_char_(key_char), has_alt_modifier_(has_alt_modifier), has_control_modifier_(has_control_modifier), has_shift_modifier_(has_shift_modifier) {} static std::string to_string(bool b) {return b ? "true" : "false";} - static int_least32_t to_key(input_list& inputs) { + static int32_t to_key(input_list& inputs) { auto result = 0; auto index = 1; for (auto c : inputs) @@ -287,11 +287,11 @@ static int_least32_t to_key(input_list& inputs) { return result; } - static key_info to_key_info(int_least32_t key) { + static key_info to_key_info(int32_t key) { return to_key_info(key, false); } - static key_info to_key_info(int_least32_t key, bool alt) { + static key_info to_key_info(int32_t key, bool alt) { // Ctrl + Space if (key == 0) return key_info {' ', ' ', false, true, false}; @@ -585,12 +585,12 @@ static key_info to_key_info(int_least32_t key, bool alt) { auto window_width = 80; } -int_least32_t console::background_color() { +int32_t console::background_color() { return ::background_color; } -bool console::background_color(int_least32_t color) { - static auto colors = std::map {{CONSOLE_COLOR_DEFAULT, "\x1b[49m"}, {CONSOLE_COLOR_BLACK, "\x1b[40m"}, {CONSOLE_COLOR_DARK_BLUE, "\x1b[44m"}, {CONSOLE_COLOR_DARK_GREEN, "\x1b[42m"}, {CONSOLE_COLOR_DARK_CYAN, "\x1b[46m"}, {CONSOLE_COLOR_DARK_RED, "\x1b[41m"}, {CONSOLE_COLOR_DARK_MAGENTA, "\x1b[45m"}, {CONSOLE_COLOR_DARK_YELLOW, "\x1b[43m"}, {CONSOLE_COLOR_GRAY, "\x1b[47m"}, {CONSOLE_COLOR_DARK_GRAY, "\x1b[100m"}, {CONSOLE_COLOR_BLUE, "\x1b[104m"}, {CONSOLE_COLOR_GREEN, "\x1b[102m"}, {CONSOLE_COLOR_CYAN, "\x1b[106m"}, {CONSOLE_COLOR_RED, "\x1b[101m"}, {CONSOLE_COLOR_MAGENTA, "\x1b[105m"}, {CONSOLE_COLOR_YELLOW, "\x1b[103m"}, {CONSOLE_COLOR_WHITE, "\x1b[107m"}}; +bool console::background_color(int32_t color) { + static auto colors = std::map {{CONSOLE_COLOR_DEFAULT, "\x1b[49m"}, {CONSOLE_COLOR_BLACK, "\x1b[40m"}, {CONSOLE_COLOR_DARK_BLUE, "\x1b[44m"}, {CONSOLE_COLOR_DARK_GREEN, "\x1b[42m"}, {CONSOLE_COLOR_DARK_CYAN, "\x1b[46m"}, {CONSOLE_COLOR_DARK_RED, "\x1b[41m"}, {CONSOLE_COLOR_DARK_MAGENTA, "\x1b[45m"}, {CONSOLE_COLOR_DARK_YELLOW, "\x1b[43m"}, {CONSOLE_COLOR_GRAY, "\x1b[47m"}, {CONSOLE_COLOR_DARK_GRAY, "\x1b[100m"}, {CONSOLE_COLOR_BLUE, "\x1b[104m"}, {CONSOLE_COLOR_GREEN, "\x1b[102m"}, {CONSOLE_COLOR_CYAN, "\x1b[106m"}, {CONSOLE_COLOR_RED, "\x1b[101m"}, {CONSOLE_COLOR_MAGENTA, "\x1b[105m"}, {CONSOLE_COLOR_YELLOW, "\x1b[103m"}, {CONSOLE_COLOR_WHITE, "\x1b[107m"}}; auto it = colors.find(color); if (it == colors.end()) return false; ::background_color = color; @@ -601,7 +601,7 @@ static key_info to_key_info(int_least32_t key, bool alt) { namespace { class audio { public: - static bool beep(uint_least32_t frequency, uint_least32_t duration) { + static bool beep(uint32_t frequency, uint32_t duration) { if (frequency < 37 || frequency > 32767) return false; dispatch_semaphore_wait(idle_semaphore, DISPATCH_TIME_FOREVER); @@ -635,7 +635,7 @@ static bool beep(uint_least32_t frequency, uint_least32_t duration) { } private: - static OSStatus au_renderer_proc(void* in_ref_con, AudioUnitRenderActionFlags* io_action_flags, const AudioTimeStamp* in_time_stamp, uint_least32_t in_bus_number, uint_least32_t in_number_frames, AudioBufferList* io_data) { + static OSStatus au_renderer_proc(void* in_ref_con, AudioUnitRenderActionFlags* io_action_flags, const AudioTimeStamp* in_time_stamp, uint32_t in_bus_number, uint32_t in_number_frames, AudioBufferList* io_data) { static auto counter = 0; while (counter == 0) { dispatch_semaphore_wait(start_playing_semaphore, DISPATCH_TIME_FOREVER); @@ -655,40 +655,40 @@ static OSStatus au_renderer_proc(void* in_ref_con, AudioUnitRenderActionFlags* i return 0; } - inline static constexpr int_least32_t simple_rate = 8000; - inline static constexpr int_least32_t bits_per_channel = 8; + inline static constexpr int32_t simple_rate = 8000; + inline static constexpr int32_t bits_per_channel = 8; inline static dispatch_semaphore_t idle_semaphore = dispatch_semaphore_create(1); inline static dispatch_semaphore_t start_playing_semaphore = dispatch_semaphore_create(0); inline static dispatch_semaphore_t end_playing_semaphore = dispatch_semaphore_create(0); inline static AudioUnit audio_unit; inline static unsigned int beep_freq = 0; - inline static int_least32_t beep_samples = 0; + inline static int32_t beep_samples = 0; }; } -bool console::beep(uint_least32_t frequency, uint_least32_t duration) { +bool console::beep(uint32_t frequency, uint32_t duration) { return audio::beep(frequency, duration); } -int_least32_t console::buffer_height() { +int32_t console::buffer_height() { /// @todo console buffer Height on linux and macOS if (::buffer_height == -1) ::buffer_height = console::window_height(); return ::buffer_height; } -bool console::buffer_height(int_least32_t height) { +bool console::buffer_height(int32_t height) { /// @todo set console buffer height on linux and macOS ::buffer_height = height; return true; } -int_least32_t console::buffer_width() { +int32_t console::buffer_width() { /// @todo console buffer Width on linux and macOS if (::buffer_width == -1) ::buffer_width = console::window_width(); return ::buffer_width; } -bool console::buffer_width(int_least32_t width) { +bool console::buffer_width(int32_t width) { /// @todo set console buffer width on linux and macOS ::buffer_width = width; return true; @@ -704,7 +704,7 @@ static OSStatus au_renderer_proc(void* in_ref_con, AudioUnitRenderActionFlags* i return set_cursor_position(0, 0); } -int_least32_t console::cursor_left() { +int32_t console::cursor_left() { if (!terminal::is_ansi_supported()) return ::cursor_left; std::cout << "\x1b[6n" << std::flush; terminal::terminal_.getch(); @@ -717,11 +717,11 @@ static OSStatus au_renderer_proc(void* in_ref_con, AudioUnitRenderActionFlags* i return ::cursor_left; } -int_least32_t console::cursor_size() { +int32_t console::cursor_size() { return ::cursor_size; } -bool console::cursor_size(int_least32_t size) { +bool console::cursor_size(int32_t size) { ::cursor_size = size; if (!terminal::is_ansi_supported()) return true; if (size < 50) std::cout << "\x1b[4 q" << std::flush; @@ -729,7 +729,7 @@ static OSStatus au_renderer_proc(void* in_ref_con, AudioUnitRenderActionFlags* i return true; } -int_least32_t console::cursor_top() { +int32_t console::cursor_top() { if (!terminal::is_ansi_supported()) return ::cursor_top; std::cout << "\x1b[6n" << std::flush; terminal::terminal_.getch(); @@ -752,7 +752,7 @@ static OSStatus au_renderer_proc(void* in_ref_con, AudioUnitRenderActionFlags* i return true; } -int_least32_t console::foreground_color() { +int32_t console::foreground_color() { return ::foreground_color; } @@ -760,8 +760,8 @@ static OSStatus au_renderer_proc(void* in_ref_con, AudioUnitRenderActionFlags* i return terminal::terminal_.echo(on); } -bool console::foreground_color(int_least32_t color) { - static auto colors = std::map {{CONSOLE_COLOR_DEFAULT, "\x1b[39m"}, {CONSOLE_COLOR_BLACK, "\x1b[30m"}, {CONSOLE_COLOR_DARK_BLUE, "\x1b[34m"}, {CONSOLE_COLOR_DARK_GREEN, "\x1b[32m"}, {CONSOLE_COLOR_DARK_CYAN, "\x1b[36m"}, {CONSOLE_COLOR_DARK_RED, "\x1b[31m"}, {CONSOLE_COLOR_DARK_MAGENTA, "\x1b[35m"}, {CONSOLE_COLOR_DARK_YELLOW, "\x1b[33m"}, {CONSOLE_COLOR_GRAY, "\x1b[37m"}, {CONSOLE_COLOR_DARK_GRAY, "\x1b[90m"}, {CONSOLE_COLOR_BLUE, "\x1b[94m"}, {CONSOLE_COLOR_GREEN, "\x1b[92m"}, {CONSOLE_COLOR_CYAN, "\x1b[96m"}, {CONSOLE_COLOR_RED, "\x1b[91m"}, {CONSOLE_COLOR_MAGENTA, "\x1b[95m"}, {CONSOLE_COLOR_YELLOW, "\x1b[93m"}, {CONSOLE_COLOR_WHITE, "\x1b[97m"}}; +bool console::foreground_color(int32_t color) { + static auto colors = std::map {{CONSOLE_COLOR_DEFAULT, "\x1b[39m"}, {CONSOLE_COLOR_BLACK, "\x1b[30m"}, {CONSOLE_COLOR_DARK_BLUE, "\x1b[34m"}, {CONSOLE_COLOR_DARK_GREEN, "\x1b[32m"}, {CONSOLE_COLOR_DARK_CYAN, "\x1b[36m"}, {CONSOLE_COLOR_DARK_RED, "\x1b[31m"}, {CONSOLE_COLOR_DARK_MAGENTA, "\x1b[35m"}, {CONSOLE_COLOR_DARK_YELLOW, "\x1b[33m"}, {CONSOLE_COLOR_GRAY, "\x1b[37m"}, {CONSOLE_COLOR_DARK_GRAY, "\x1b[90m"}, {CONSOLE_COLOR_BLUE, "\x1b[94m"}, {CONSOLE_COLOR_GREEN, "\x1b[92m"}, {CONSOLE_COLOR_CYAN, "\x1b[96m"}, {CONSOLE_COLOR_RED, "\x1b[91m"}, {CONSOLE_COLOR_MAGENTA, "\x1b[95m"}, {CONSOLE_COLOR_YELLOW, "\x1b[93m"}, {CONSOLE_COLOR_WHITE, "\x1b[97m"}}; auto it = colors.find(color); if (it == colors.end()) return false; ::foreground_color = color; @@ -769,12 +769,12 @@ static OSStatus au_renderer_proc(void* in_ref_con, AudioUnitRenderActionFlags* i return true; } -int_least32_t console::input_code_page() { +int32_t console::input_code_page() { /// @todo console input code page status on linux and macOS return ::input_code_page; } -bool console::input_code_page(int_least32_t code_page) { +bool console::input_code_page(int32_t code_page) { /// @todo set console input code page on linux and macOS ::input_code_page = code_page; return true; @@ -784,11 +784,11 @@ static OSStatus au_renderer_proc(void* in_ref_con, AudioUnitRenderActionFlags* i return key_info::key_available(); } -int_least32_t console::largest_window_height() { +int32_t console::largest_window_height() { return ::largest_window_height; } -int_least32_t console::largest_window_width() { +int32_t console::largest_window_width() { return ::largest_window_width; } @@ -797,12 +797,12 @@ static OSStatus au_renderer_proc(void* in_ref_con, AudioUnitRenderActionFlags* i return ::number_lock; } -int_least32_t console::output_code_page() { +int32_t console::output_code_page() { /// @todo console output code page status on linux and macOS return ::output_code_page; } -bool console::output_code_page(int_least32_t code_page) { +bool console::output_code_page(int32_t code_page) { /// @todo set console output code page on linux and macOS ::output_code_page = code_page; return true; @@ -817,7 +817,7 @@ static OSStatus au_renderer_proc(void* in_ref_con, AudioUnitRenderActionFlags* i shift = key_info.has_shift_modifier(); } -void console::register_user_cancel_callback(std::function user_cancel_callback) { +void console::register_user_cancel_callback(std::function user_cancel_callback) { ::user_cancel_callback = user_cancel_callback; } @@ -825,7 +825,7 @@ static OSStatus au_renderer_proc(void* in_ref_con, AudioUnitRenderActionFlags* i return console::background_color(CONSOLE_COLOR_DEFAULT) && console::foreground_color(CONSOLE_COLOR_DEFAULT); } -bool console::set_cursor_position(int_least32_t left, int_least32_t top) { +bool console::set_cursor_position(int32_t left, int32_t top) { ::cursor_left = left; ::cursor_top = top; if (terminal::is_ansi_supported()) std::cout << "\x1b[" << top + 1 << ";" << left + 1 << "f" << std::flush; @@ -862,7 +862,7 @@ static OSStatus au_renderer_proc(void* in_ref_con, AudioUnitRenderActionFlags* i return true; } -int_least32_t console::window_height() { +int32_t console::window_height() { if (!terminal::is_ansi_supported()) return ::window_height; auto top = console::cursor_top(); console::set_cursor_position(console::cursor_left(), 999); @@ -872,35 +872,35 @@ static OSStatus au_renderer_proc(void* in_ref_con, AudioUnitRenderActionFlags* i return ::window_height; } -bool console::window_height(int_least32_t height) { +bool console::window_height(int32_t height) { /// @todo set console window height on linux and macOS ::window_height = height; return true; } -int_least32_t console::window_left() { +int32_t console::window_left() { /// @todo get console window left on linux and macOS return ::window_left; } -bool console::window_left(int_least32_t left) { +bool console::window_left(int32_t left) { /// @todo set console window left on linux and macOS ::window_left = left; return true; } -int_least32_t console::window_top() { +int32_t console::window_top() { /// @todo get console window top on linux and macOS return ::window_top; } -bool console::window_top(int_least32_t top) { +bool console::window_top(int32_t top) { /// @todo set console window top on linux and macOS ::window_top = top; return true; } -int_least32_t console::window_width() { +int32_t console::window_width() { if (!terminal::is_ansi_supported()) return ::window_width; auto left = console::cursor_left(); console::set_cursor_position(999, console::cursor_top()); @@ -910,7 +910,7 @@ static OSStatus au_renderer_proc(void* in_ref_con, AudioUnitRenderActionFlags* i return ::window_width; } -bool console::window_width(int_least32_t width) { +bool console::window_width(int32_t width) { /// @todo set console window width on linux and macOS ::window_width = width; return true; diff --git a/src/xtd.core.native.macos/src/xtd/native/macos/cryptography.mm b/src/xtd.core.native.macos/src/xtd/native/macos/cryptography.mm index f31715790b4..932595c6f06 100644 --- a/src/xtd.core.native.macos/src/xtd/native/macos/cryptography.mm +++ b/src/xtd.core.native.macos/src/xtd/native/macos/cryptography.mm @@ -8,7 +8,7 @@ using namespace std; using namespace xtd::native; -vector cryptography::machine_guid() { +vector cryptography::machine_guid() { static auto first = true; static auto guid_str = macos::shell_execute::run("ioreg", "-rd1 -c IOPlatformExpertDevice | grep -E '(UUID)'"); if (first) guid_str = guid_str.substr(guid_str.find("=") + 1); @@ -20,8 +20,8 @@ if (hex_chars.find(static_cast(toupper(guid_str[index]))) == hex_chars.npos) guid_str.erase(index--, 1); if (guid_str.size() != 32) guid_str = guid_fallback; - auto bytes = vector {}; + auto bytes = vector {}; for (auto index = 0u; index < guid_str.size(); index += 2) - bytes.push_back(static_cast(stoi(guid_str.substr(index, 2), 0, 16))); + bytes.push_back(static_cast(stoi(guid_str.substr(index, 2), 0, 16))); return bytes; } diff --git a/src/xtd.core.native.macos/src/xtd/native/macos/date_time.mm b/src/xtd.core.native.macos/src/xtd/native/macos/date_time.mm index 28dbaebdeb5..cc55c6b936d 100644 --- a/src/xtd.core.native.macos/src/xtd/native/macos/date_time.mm +++ b/src/xtd.core.native.macos/src/xtd/native/macos/date_time.mm @@ -15,7 +15,7 @@ using namespace xtd::native; namespace { - static const int_least64_t ticks_per_second = 10000000; + static const int64_t ticks_per_second = 10000000; /* Generate by this c# code source : @@ -242,7 +242,7 @@ string alias_to_time_zone_info_id(const string& alias) { if (iterator != stzis.end()) { local_time_zone = *iterator; local_time_zone.id = reinterpret_cast(tzname[0]); - local_time_zone.base_utc_offset = static_cast(-timezone * ticks_per_second); + local_time_zone.base_utc_offset = static_cast(-timezone * ticks_per_second); local_time_zone.daylight_name = reinterpret_cast(tzname[1]); local_time_zone.display_name = string_printf("(UTC%s%02d:%02d) %s", (-timezone) ? "+" : "", abs(timezone) / 3600, (abs(timezone) % 3600) / 60, reinterpret_cast(tzname[0])); local_time_zone.standard_name = reinterpret_cast(tzname[0]); diff --git a/src/xtd.core.native.macos/src/xtd/native/macos/debugger.mm b/src/xtd.core.native.macos/src/xtd/native/macos/debugger.mm index c2d6970851d..c465501b8b3 100644 --- a/src/xtd.core.native.macos/src/xtd/native/macos/debugger.mm +++ b/src/xtd.core.native.macos/src/xtd/native/macos/debugger.mm @@ -32,7 +32,7 @@ return true; } -int_least32_t debugger::show_assert_dialog(const std::string& text, const std::string& caption) { +int32_t debugger::show_assert_dialog(const std::string& text, const std::string& caption) { //#if !defined(TARGET_IPHONE_SIMULATOR) && !defined(TARGET_OS_MACCATALYST) && !defined(TARGET_OS_IPHONE) [NSApplication sharedApplication]; [NSApp finishLaunching]; @@ -58,6 +58,6 @@ //#endif } -void debugger::log(int_least32_t level, const std::string& category, const std::string& message) { +void debugger::log(int32_t level, const std::string& category, const std::string& message) { syslog(LOG_EMERG | LOG_USER, "%s", message.c_str()); } diff --git a/src/xtd.core.native.macos/src/xtd/native/macos/directory.mm b/src/xtd.core.native.macos/src/xtd/native/macos/directory.mm index 40162c886c8..dd29fde50ed 100644 --- a/src/xtd.core.native.macos/src/xtd/native/macos/directory.mm +++ b/src/xtd.core.native.macos/src/xtd/native/macos/directory.mm @@ -60,7 +60,7 @@ bool pattern_compare(const string& file_name, const string& pattern) { return *this; } -directory::directory_iterator directory::directory_iterator::operator ++(int_least32_t) { +directory::directory_iterator directory::directory_iterator::operator ++(int32_t) { auto result = directory_iterator {*this}; ++(*this); return result; @@ -130,7 +130,7 @@ bool pattern_compare(const string& file_name, const string& pattern) { return *this; } -directory::file_iterator directory::file_iterator::operator ++(int_least32_t) { +directory::file_iterator directory::file_iterator::operator ++(int32_t) { auto result = file_iterator {*this}; ++(*this); return result; @@ -200,7 +200,7 @@ bool pattern_compare(const string& file_name, const string& pattern) { return *this; } -directory::file_and_directory_iterator directory::file_and_directory_iterator::operator ++(int_least32_t) { +directory::file_and_directory_iterator directory::file_and_directory_iterator::operator ++(int32_t) { auto result = file_and_directory_iterator {*this}; ++(*this); return result; @@ -231,7 +231,7 @@ bool pattern_compare(const string& file_name, const string& pattern) { return data_->pattern_; } -int_least32_t directory::create(const std::string& directory_name) { +int32_t directory::create(const std::string& directory_name) { return mkdir(directory_name.c_str(), S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IXGRP | S_IROTH | S_IWOTH | S_IXOTH); } @@ -262,10 +262,10 @@ bool pattern_compare(const string& file_name, const string& pattern) { return result ? path : ""; } -int_least32_t directory::remove(const std::string& directory_name) { +int32_t directory::remove(const std::string& directory_name) { return rmdir(directory_name.c_str()); } -int_least32_t directory::set_current_directory(const std::string& directory_name) { +int32_t directory::set_current_directory(const std::string& directory_name) { return chdir(directory_name.c_str()); } diff --git a/src/xtd.core.native.macos/src/xtd/native/macos/dns.mm b/src/xtd.core.native.macos/src/xtd/native/macos/dns.mm index 11a8c807bc8..786e849a665 100644 --- a/src/xtd.core.native.macos/src/xtd/native/macos/dns.mm +++ b/src/xtd.core.native.macos/src/xtd/native/macos/dns.mm @@ -24,9 +24,9 @@ delete reinterpret_cast(host); } -intmax_t dns::get_host_by_address(const string& host_address, int_least32_t host_address_type) { +intmax_t dns::get_host_by_address(const string& host_address, int32_t host_address_type) { auto lock = lock_guard {dns_mutex}; - auto internet_address = int_least64_t {0}; + auto internet_address = int64_t {0}; inet_pton(host_address_type, host_address.c_str(), &internet_address); auto host = gethostbyaddr(reinterpret_cast(&internet_address), host_address_type == ADDRESS_FAMILY_INTER_NETWORK ? 4 : 16, host_address_type); if (host == nullptr) return 0; @@ -48,11 +48,11 @@ return aliases; } -vector> dns::get_addresses(intmax_t host) { - auto addresses = vector> {}; +vector> dns::get_addresses(intmax_t host) { + auto addresses = vector> {}; auto index = size_t {0}; while (reinterpret_cast(host)->h_addr_list[index] != nullptr) { - addresses.emplace_back(reinterpret_cast(reinterpret_cast(host)->h_addr_list[index]), reinterpret_cast(reinterpret_cast(host)->h_addr_list[index]) + (reinterpret_cast(host)->h_addrtype == ADDRESS_FAMILY_INTER_NETWORK ? 4 : 16)); + addresses.emplace_back(reinterpret_cast(reinterpret_cast(host)->h_addr_list[index]), reinterpret_cast(reinterpret_cast(host)->h_addr_list[index]) + (reinterpret_cast(host)->h_addrtype == ADDRESS_FAMILY_INTER_NETWORK ? 4 : 16)); index++; } return addresses; @@ -62,7 +62,7 @@ return reinterpret_cast(host)->h_name; } -int_least32_t dns::get_host_name(string& host_name) { +int32_t dns::get_host_name(string& host_name) { auto name_length = static_cast(sysconf(_SC_HOST_NAME_MAX)); auto name = string(name_length, '\0'); auto result = gethostname(name.data(), name_length); diff --git a/src/xtd.core.native.macos/src/xtd/native/macos/drive.mm b/src/xtd.core.native.macos/src/xtd/native/macos/drive.mm index 28eb69fc976..767494e6d21 100644 --- a/src/xtd.core.native.macos/src/xtd/native/macos/drive.mm +++ b/src/xtd.core.native.macos/src/xtd/native/macos/drive.mm @@ -32,7 +32,7 @@ return true; } -int_least32_t drive::get_drive_type(const std::string& root_path_name) { +int32_t drive::get_drive_type(const std::string& root_path_name) { if (root_drive == root_path_name) return DRIVE_FIXED; if (find(ram_drives.begin(), ram_drives.end(), root_path_name) != ram_drives.end()) return DRIVE_RAMDISK; if (find(network_drives.begin(), network_drives.end(), root_path_name) != network_drives.end()) return DRIVE_REMOTE; diff --git a/src/xtd.core.native.macos/src/xtd/native/macos/environment.mm b/src/xtd.core.native.macos/src/xtd/native/macos/environment.mm index cd9113be429..049e63bd8b4 100644 --- a/src/xtd.core.native.macos/src/xtd/native/macos/environment.mm +++ b/src/xtd.core.native.macos/src/xtd/native/macos/environment.mm @@ -19,11 +19,11 @@ using namespace xtd::native; extern char** environ; -int_least32_t __environment_argc = 0; +int32_t __environment_argc = 0; char** __environment_argv; namespace { - __attribute__((constructor)) void startup_program(int_least32_t argc, char** argv) { + __attribute__((constructor)) void startup_program(int32_t argc, char** argv) { __environment_argc = argc; __environment_argv = argv; } @@ -102,7 +102,7 @@ void (*__on_quick_exit__)(void) = nullptr; } -int_least32_t environment::at_quick_exit(void (*on_quick_exit)(void)) { +int32_t environment::at_quick_exit(void (*on_quick_exit)(void)) { /// Workaround std::quick_exit and std::at_quick_exit are not implemented on macOS ! /// See https://github.com/runtimeverification/k/issues/1580 for more informtion //return std::at_quick_exit(on_quick_exit); @@ -165,7 +165,7 @@ return name_it->second; } -void environment::get_distribution_version(int_least32_t& major, int_least32_t& minor, int_least32_t& build, int_least32_t& revision) { +void environment::get_distribution_version(int32_t& major, int32_t& minor, int32_t& build, int32_t& revision) { auto name_it = get_distribution_key_values().find("VERSION_ID"); if (name_it == get_distribution_key_values().end()) return; auto versions = xtd::native::macos::strings::split(name_it->second, {'.'}); @@ -179,7 +179,7 @@ return iterator->second; } -string environment::get_environment_variable(const string& variable, int_least32_t target) { +string environment::get_environment_variable(const string& variable, int32_t target) { if (target == ENVIRONMENT_VARIABLE_TARGET_PROCESS) { auto value = getenv(variable.c_str()); return value ? value : ""; @@ -193,7 +193,7 @@ return ""; } -map& environment::get_environment_variables(int_least32_t target) { +map& environment::get_environment_variables(int32_t target) { if (target == ENVIRONMENT_VARIABLE_TARGET_PROCESS) { static auto envs = map {}; if (envs.size() == 0) { @@ -219,8 +219,8 @@ return envs; } -string environment::get_know_folder_path(int_least32_t csidl) { - static auto special_folders = map {{CSIDL_DESKTOP, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS) + "/Desktop"}, {CSIDL_PERSONAL, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS)}, {CSIDL_FAVORITES, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS) + "/Library/Favorites"}, {CSIDL_MYMUSIC, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS) + "/Music"}, {CSIDL_MYVIDEO, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS) + "/Movies"}, {CSIDL_DESKTOPDIRECTORY, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS) + "/Desktop"}, {CSIDL_FONTS, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS) + "/Library/Fonts"}, {CSIDL_TEMPLATES, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS) + "/Templates"}, {CSIDL_APPDATA, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS) + "/Library/Preferences"}, {CSIDL_LOCAL_APPDATA, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS) + "/.local/share"}, {CSIDL_INTERNET_CACHE, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS) + "/Library/Caches"}, {CSIDL_COMMON_APPDATA, "/usr/share"}, {CSIDL_SYSTEM, "/System"}, {CSIDL_PROGRAM_FILES, "/Applications"}, {CSIDL_MYPICTURES, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS) + "/Pictures"}, {CSIDL_PROFILE, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS)}, {CSIDL_COMMON_TEMPLATES, "/usr/share/templates"}, {CSIDL_HOME, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS)}}; +string environment::get_know_folder_path(int32_t csidl) { + static auto special_folders = map {{CSIDL_DESKTOP, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS) + "/Desktop"}, {CSIDL_PERSONAL, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS)}, {CSIDL_FAVORITES, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS) + "/Library/Favorites"}, {CSIDL_MYMUSIC, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS) + "/Music"}, {CSIDL_MYVIDEO, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS) + "/Movies"}, {CSIDL_DESKTOPDIRECTORY, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS) + "/Desktop"}, {CSIDL_FONTS, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS) + "/Library/Fonts"}, {CSIDL_TEMPLATES, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS) + "/Templates"}, {CSIDL_APPDATA, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS) + "/Library/Preferences"}, {CSIDL_LOCAL_APPDATA, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS) + "/.local/share"}, {CSIDL_INTERNET_CACHE, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS) + "/Library/Caches"}, {CSIDL_COMMON_APPDATA, "/usr/share"}, {CSIDL_SYSTEM, "/System"}, {CSIDL_PROGRAM_FILES, "/Applications"}, {CSIDL_MYPICTURES, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS) + "/Pictures"}, {CSIDL_PROFILE, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS)}, {CSIDL_COMMON_TEMPLATES, "/usr/share/templates"}, {CSIDL_HOME, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS)}}; auto it = special_folders.find(csidl); if (it == special_folders.end()) return ""; return it->second; @@ -230,7 +230,7 @@ return macos::strings::replace(macos::shell_execute::run("uname", "-n"), "\n", ""); } -int_least32_t environment::get_os_platform_id() { +int32_t environment::get_os_platform_id() { #if TARGET_OS_SIMULATOR == 1 || TARGET_OS_IPHONE == 1 return PLATFORM_IOS; #else @@ -238,7 +238,7 @@ #endif } -void environment::get_os_version(int_least32_t& major, int_least32_t& minor, int_least32_t& build, int_least32_t& revision) { +void environment::get_os_version(int32_t& major, int32_t& minor, int32_t& build, int32_t& revision) { auto numbers = macos::strings::split(macos::shell_execute::run("sw_vers", "-productVersion"), {'.', '\n'}); if (numbers.size() < 1 || !macos::strings::try_parse(numbers[0], major)) major = 0; if (numbers.size() < 2 || !macos::strings::try_parse(numbers[1], minor)) minor = 0; @@ -246,7 +246,7 @@ if (numbers.size() < 4 || !macos::strings::try_parse(numbers[3], revision)) revision = 0; } -uint_least32_t environment::get_processor_count() { +uint32_t environment::get_processor_count() { return thread::hardware_concurrency(); } @@ -268,15 +268,15 @@ return sysconf(_SC_PAGESIZE); } -uint_least32_t environment::get_tick_count() { +uint32_t environment::get_tick_count() { // https://stackoverflow.com/questions/3269321/osx-programmatically-get-uptime auto boottime = timeval {}; auto nowtime = timeval {}; auto len = sizeof(boottime); - int_least32_t mib[2] = {CTL_KERN, KERN_BOOTTIME}; + int32_t mib[2] = {CTL_KERN, KERN_BOOTTIME}; sysctl(mib, 2, &boottime, &len, nullptr, 0); gettimeofday(&nowtime, nullptr); - return static_cast((nowtime.tv_sec - boottime.tv_sec) * 1000) + static_cast((nowtime.tv_usec - boottime.tv_usec) / 1000); + return static_cast((nowtime.tv_sec - boottime.tv_sec) * 1000) + static_cast((nowtime.tv_usec - boottime.tv_usec) / 1000); } bool environment::get_user_administrator() { @@ -312,7 +312,7 @@ return "\n"; } -void environment::quick_exit(int_least32_t exit_code) noexcept { +void environment::quick_exit(int32_t exit_code) noexcept { /// Workaround std::quick_exit and std::at_quick_exit are not implemented on macOS ! /// See https://github.com/runtimeverification/k/issues/1580 for more informtion //std::quick_exit(exit_code) @@ -320,7 +320,7 @@ std::_Exit(exit_code); } -void environment::set_environment_variable(const string& name, const string& value, int_least32_t target) { +void environment::set_environment_variable(const string& name, const string& value, int32_t target) { if (target == ENVIRONMENT_VARIABLE_TARGET_PROCESS) setenv(name.c_str(), value.c_str(), 1); else if (target == ENVIRONMENT_VARIABLE_TARGET_USER) { @@ -330,7 +330,7 @@ } } -void environment::unset_environment_variable(const string& name, int_least32_t target) { +void environment::unset_environment_variable(const string& name, int32_t target) { if (target == ENVIRONMENT_VARIABLE_TARGET_PROCESS) unsetenv(name.c_str()); else if (target == ENVIRONMENT_VARIABLE_TARGET_USER) { @@ -340,6 +340,6 @@ } } -int_least64_t environment::working_set() { +int64_t environment::working_set() { return 0; } diff --git a/src/xtd.core.native.macos/src/xtd/native/macos/file.mm b/src/xtd.core.native.macos/src/xtd/native/macos/file.mm index 3da8d5d9d56..65268c759e4 100644 --- a/src/xtd.core.native.macos/src/xtd/native/macos/file.mm +++ b/src/xtd.core.native.macos/src/xtd/native/macos/file.mm @@ -11,7 +11,7 @@ using namespace std; using namespace xtd::native; -int_least32_t file::copy(const std::string& source_file, const std::string& target_file) { +int32_t file::copy(const std::string& source_file, const std::string& target_file) { auto ifs = ifstream {source_file, ios::binary}; if (!ifs) return -1; auto ofs = ofstream {target_file, ios::trunc | ios::binary}; @@ -33,12 +33,12 @@ return static_cast(status.st_size); } -int_least32_t file::move(const std::string& old_path, const std::string& new_path) { +int32_t file::move(const std::string& old_path, const std::string& new_path) { auto file_attributes = 0; if (file_system::get_attributes(new_path, file_attributes) == 0) return -1; return rename(old_path.c_str(), new_path.c_str()); } -int_least32_t file::remove(const std::string& file) { +int32_t file::remove(const std::string& file) { return unlink(file.c_str()); } diff --git a/src/xtd.core.native.macos/src/xtd/native/macos/file_system.mm b/src/xtd.core.native.macos/src/xtd/native/macos/file_system.mm index d87455b8ae0..96c4116938e 100644 --- a/src/xtd.core.native.macos/src/xtd/native/macos/file_system.mm +++ b/src/xtd.core.native.macos/src/xtd/native/macos/file_system.mm @@ -15,9 +15,9 @@ using namespace std; using namespace xtd::native; -int_least32_t file_system::get_attributes(const std::string& path, int_least32_t& attributes) { +int32_t file_system::get_attributes(const std::string& path, int32_t& attributes) { struct system_attribute_to_file_attribute_converter { - int_least32_t operator()(int_least32_t attribute) { + int32_t operator()(int32_t attribute) { auto file_attributes = 0; if ((attribute & S_IRUSR) == S_IRUSR && (attribute & S_IWUSR) != S_IWUSR) file_attributes |= FILE_ATTRIBUTE_READONLY; if ((attribute & S_IFSOCK) == S_IFSOCK || (attribute & S_IFIFO) == S_IFIFO) file_attributes |= FILE_ATTRIBUTE_SYSTEM; @@ -34,7 +34,7 @@ int_least32_t operator()(int_least32_t attribute) { return 0; } -int_least32_t file_system::get_file_times(const std::string& path, time_t& creation_time, time_t& last_access_time, time_t& last_write_time) { +int32_t file_system::get_file_times(const std::string& path, time_t& creation_time, time_t& last_access_time, time_t& last_write_time) { NSFileManager* fm = [NSFileManager defaultManager]; creation_time = [[[fm attributesOfItemAtPath:[NSString stringWithUTF8String:path.c_str()] error:Nil] fileCreationDate] timeIntervalSince1970]; last_access_time = [[[fm attributesOfItemAtPath:[NSString stringWithUTF8String:path.c_str()] error:Nil] fileModificationDate] timeIntervalSince1970]; @@ -68,9 +68,9 @@ int_least32_t operator()(int_least32_t attribute) { return full_path; } -int_least32_t file_system::get_permissions(const std::string& path, int_least32_t& permissions) { +int32_t file_system::get_permissions(const std::string& path, int32_t& permissions) { struct system_permission_to_file_permission_converter { - int_least32_t operator()(mode_t permission) { + int32_t operator()(mode_t permission) { auto file_permissions = 0; if ((permission & S_IRUSR) == S_IRUSR) file_permissions |= FILE_PERMISSIONS_OWNER_READ; if ((permission & S_IWUSR) == S_IWUSR) file_permissions |= FILE_PERMISSIONS_OWNER_WRITE; @@ -108,7 +108,7 @@ int_least32_t operator()(mode_t permission) { return file_name.size() > NAME_MAX; } -int_least32_t file_system::set_attributes(const std::string& path, int_least32_t attributes) { +int32_t file_system::set_attributes(const std::string& path, int32_t attributes) { struct stat s; if (stat(path.c_str(), &s) != 0) return -1; @@ -122,7 +122,7 @@ int_least32_t operator()(mode_t permission) { return chmod(path.c_str(), s.st_mode); } -int_least32_t file_system::set_creation_time(const std::string& path, time_t creation_time) { +int32_t file_system::set_creation_time(const std::string& path, time_t creation_time) { // There is no creation time on linux so we update the last modification time instead... auto times = utimbuf {}; time_t creation_time_old = 0, last_access_time = 0, last_write_time = 0; @@ -132,7 +132,7 @@ int_least32_t operator()(mode_t permission) { return utime(path.c_str(), ×); } -int_least32_t file_system::set_last_access_time(const std::string& path, time_t last_access_time) { +int32_t file_system::set_last_access_time(const std::string& path, time_t last_access_time) { auto times = utimbuf {}; time_t creation_time = 0, last_access_time_old = 0, last_write_time = 0; get_file_times(path, creation_time, last_access_time_old, last_write_time); @@ -141,7 +141,7 @@ int_least32_t operator()(mode_t permission) { return utime(path.c_str(), ×); } -int_least32_t file_system::set_last_write_time(const std::string& path, time_t last_write_time) { +int32_t file_system::set_last_write_time(const std::string& path, time_t last_write_time) { auto times = utimbuf {}; time_t creation_time = 0, last_access_time = 0, last_write_time_old = 0; get_file_times(path, creation_time, last_access_time, last_write_time_old); @@ -150,9 +150,9 @@ int_least32_t operator()(mode_t permission) { return utime(path.c_str(), ×); } -int_least32_t file_system::set_permissions(const std::string& path, int_least32_t permissions) { +int32_t file_system::set_permissions(const std::string& path, int32_t permissions) { struct file_permission_to_system_permission_converter { - mode_t operator()(int_least32_t permission) { + mode_t operator()(int32_t permission) { auto system_permissions = 0; if ((permission & FILE_PERMISSIONS_OWNER_READ) == FILE_PERMISSIONS_OWNER_READ) system_permissions |= S_IRUSR; if ((permission & FILE_PERMISSIONS_OWNER_WRITE) == FILE_PERMISSIONS_OWNER_WRITE) system_permissions |= S_IWUSR; diff --git a/src/xtd.core.native.macos/src/xtd/native/macos/guid.mm b/src/xtd.core.native.macos/src/xtd/native/macos/guid.mm index d13c8531e08..0bcb5371758 100644 --- a/src/xtd.core.native.macos/src/xtd/native/macos/guid.mm +++ b/src/xtd.core.native.macos/src/xtd/native/macos/guid.mm @@ -8,8 +8,8 @@ using namespace xtd::native; -std::vector guid::new_guid() { - auto guid = std::vector(16); +std::vector guid::new_guid() { + auto guid = std::vector(16); uuid_generate(guid.data()); return guid; } diff --git a/src/xtd.core.native.macos/src/xtd/native/macos/interlocked.mm b/src/xtd.core.native.macos/src/xtd/native/macos/interlocked.mm index 392dda4a9f5..d5b66975ab6 100644 --- a/src/xtd.core.native.macos/src/xtd/native/macos/interlocked.mm +++ b/src/xtd.core.native.macos/src/xtd/native/macos/interlocked.mm @@ -11,21 +11,21 @@ using namespace std; using namespace xtd::native; -int_least32_t interlocked::add(int_least32_t& location, int_least32_t value) { +int32_t interlocked::add(int32_t& location, int32_t value) { __sync_fetch_and_add(&location, value); return location; } -int_least64_t interlocked::add(int_least64_t& location, int_least64_t value) { +int64_t interlocked::add(int64_t& location, int64_t value) { __sync_fetch_and_add(&location, value); return location; } -int_least32_t interlocked::compare_exchange(int_least32_t& location, int_least32_t value, int_least32_t comparand) { +int32_t interlocked::compare_exchange(int32_t& location, int32_t value, int32_t comparand) { return __sync_val_compare_and_swap(&location, comparand, value); } -int_least64_t interlocked::compare_exchange(int_least64_t& location, int_least64_t value, int_least64_t comparand) { +int64_t interlocked::compare_exchange(int64_t& location, int64_t value, int64_t comparand) { return __sync_val_compare_and_swap(&location, comparand, value); } @@ -37,21 +37,21 @@ return __sync_val_compare_and_swap(&location, comparand, value); } -int_least32_t interlocked::decrement(int_least32_t& location) { +int32_t interlocked::decrement(int32_t& location) { __sync_fetch_and_sub(&location, 1); return location; } -int_least64_t interlocked::decrement(int_least64_t& location) { +int64_t interlocked::decrement(int64_t& location) { __sync_fetch_and_sub(&location, 1); return location; } -int_least32_t interlocked::exchange(int_least32_t& location, int_least32_t value) { +int32_t interlocked::exchange(int32_t& location, int32_t value) { return __sync_val_compare_and_swap(&location, location, value); } -int_least64_t interlocked::exchange(int_least64_t& location, int_least64_t value) { +int64_t interlocked::exchange(int64_t& location, int64_t value) { return __sync_val_compare_and_swap(&location, location, value); } @@ -63,12 +63,12 @@ return __sync_val_compare_and_swap(&location, location, value); } -int_least32_t interlocked::increment(int_least32_t& location) { +int32_t interlocked::increment(int32_t& location) { __sync_fetch_and_add(&location, 1); return location; } -int_least64_t interlocked::increment(int_least64_t& location) { +int64_t interlocked::increment(int64_t& location) { __sync_fetch_and_add(&location, 1); return location; } diff --git a/src/xtd.core.native.macos/src/xtd/native/macos/named_event_wait_handle.mm b/src/xtd.core.native.macos/src/xtd/native/macos/named_event_wait_handle.mm index 81be4674f8b..58190482537 100644 --- a/src/xtd.core.native.macos/src/xtd/native/macos/named_event_wait_handle.mm +++ b/src/xtd.core.native.macos/src/xtd/native/macos/named_event_wait_handle.mm @@ -47,7 +47,7 @@ return true; } -uint_least32_t named_event_wait_handle::wait(intmax_t handle, int_least32_t milliseconds_timeout, bool manual_reset) { +uint32_t named_event_wait_handle::wait(intmax_t handle, int32_t milliseconds_timeout, bool manual_reset) { if (reinterpret_cast(handle) == SEM_FAILED) return 0xFFFFFFFF; auto result = milliseconds_timeout == -1 ? sem_wait(reinterpret_cast(handle)) : sem_milliseconds_timedwait(reinterpret_cast(handle), milliseconds_timeout); if (result && errno == EAGAIN) return 0xFFFFFFFF; diff --git a/src/xtd.core.native.macos/src/xtd/native/macos/named_mutex.mm b/src/xtd.core.native.macos/src/xtd/native/macos/named_mutex.mm index 423a408aac3..e531ab70cd6 100644 --- a/src/xtd.core.native.macos/src/xtd/native/macos/named_mutex.mm +++ b/src/xtd.core.native.macos/src/xtd/native/macos/named_mutex.mm @@ -36,7 +36,7 @@ return !io_error; } -uint_least32_t named_mutex::wait(intmax_t handle, int_least32_t milliseconds_timeout) { +uint32_t named_mutex::wait(intmax_t handle, int32_t milliseconds_timeout) { if (reinterpret_cast(handle) == SEM_FAILED) return 0xFFFFFFFF; auto result = milliseconds_timeout == -1 ? sem_wait(reinterpret_cast(handle)) : sem_milliseconds_timedwait(reinterpret_cast(handle), milliseconds_timeout); if (result && errno == EAGAIN) return 0xFFFFFFFF; diff --git a/src/xtd.core.native.macos/src/xtd/native/macos/named_semaphore.mm b/src/xtd.core.native.macos/src/xtd/native/macos/named_semaphore.mm index 641246b020f..88ce557661d 100644 --- a/src/xtd.core.native.macos/src/xtd/native/macos/named_semaphore.mm +++ b/src/xtd.core.native.macos/src/xtd/native/macos/named_semaphore.mm @@ -9,7 +9,7 @@ using namespace xtd::native; -intmax_t named_semaphore::create(int_least32_t initial_count, int_least32_t max_count, const std::string& name) { +intmax_t named_semaphore::create(int32_t initial_count, int32_t max_count, const std::string& name) { auto semaphore = sem_open(name.c_str(), O_CREAT | O_EXCL, S_IRUSR | S_IWUSR, std::min(initial_count, max_count)); return reinterpret_cast(semaphore); } @@ -28,7 +28,7 @@ return reinterpret_cast(semaphore); } -bool named_semaphore::signal(intmax_t handle, int_least32_t release_count, int_least32_t& previous_count, bool& io_error) { +bool named_semaphore::signal(intmax_t handle, int32_t release_count, int32_t& previous_count, bool& io_error) { io_error = false; if (reinterpret_cast(handle) == SEM_FAILED) { io_error = true; @@ -41,7 +41,7 @@ return !io_error; } -uint_least32_t named_semaphore::wait(intmax_t handle, int_least32_t milliseconds_timeout) { +uint32_t named_semaphore::wait(intmax_t handle, int32_t milliseconds_timeout) { if (reinterpret_cast(handle) == SEM_FAILED) return 0xFFFFFFFF; auto result = milliseconds_timeout == -1 ? sem_wait(reinterpret_cast(handle)) : sem_milliseconds_timedwait(reinterpret_cast(handle), milliseconds_timeout); if (result && errno == EAGAIN) return 0xFFFFFFFF; diff --git a/src/xtd.core.native.macos/src/xtd/native/macos/process.mm b/src/xtd.core.native.macos/src/xtd/native/macos/process.mm index b81b806d653..cff6dfa1740 100644 --- a/src/xtd.core.native.macos/src/xtd/native/macos/process.mm +++ b/src/xtd.core.native.macos/src/xtd/native/macos/process.mm @@ -24,11 +24,11 @@ namespace { class file_descriptor_streambuf : public streambuf { public: - explicit file_descriptor_streambuf(int_least32_t file_descriptor) : file_descriptor_(file_descriptor) {} + explicit file_descriptor_streambuf(int32_t file_descriptor) : file_descriptor_(file_descriptor) {} ~file_descriptor_streambuf() {close(file_descriptor_);} protected: - int_least32_t underflow() override { + int32_t underflow() override { if (read(file_descriptor_, &value_, 1) == 1) { this->setg(&value_, &value_, &value_ + 1); return value_; @@ -36,7 +36,7 @@ int_least32_t underflow() override { return streambuf::underflow(); // EOF } - int_least32_t overflow(int_least32_t c) override { + int32_t overflow(int32_t c) override { value_ = static_cast(c); if (write(file_descriptor_, &value_, 1) != -1) { this->setp(&value_, &value_); @@ -45,13 +45,13 @@ int_least32_t overflow(int_least32_t c) override { return streambuf::overflow(c); // EOF } - int_least32_t file_descriptor_ = 0; + int32_t file_descriptor_ = 0; char value_ = EOF; }; class process_istream : public istream { public: - explicit process_istream(int_least32_t file_descriptor) : istream(&stream_buf_), stream_buf_(file_descriptor) {} + explicit process_istream(int32_t file_descriptor) : istream(&stream_buf_), stream_buf_(file_descriptor) {} private: file_descriptor_streambuf stream_buf_; @@ -59,7 +59,7 @@ explicit process_istream(int_least32_t file_descriptor) : istream(&stream_buf_), class process_ostream : public ostream { public: - explicit process_ostream(int_least32_t file_descriptor) : ostream(&stream_buf_), stream_buf_(file_descriptor) {} + explicit process_ostream(int32_t file_descriptor) : ostream(&stream_buf_), stream_buf_(file_descriptor) {} private: file_descriptor_streambuf stream_buf_; @@ -142,8 +142,8 @@ bool is_valid_shell_execute_process(function(const string& str, c return arguments; } - bool compute_base_priority(int_least32_t priority, int_least32_t& base_priority) { - static auto base_priorities = map {{IDLE_PRIORITY_CLASS, PRIO_MIN}, {BELOW_NORMAL_PRIORITY_CLASS, PRIO_MIN + (PRIO_MAX - PRIO_MIN) / 4}, {NORMAL_PRIORITY_CLASS, PRIO_MIN + (PRIO_MAX - PRIO_MIN) / 2}, {ABOVE_NORMAL_PRIORITY_CLASS, PRIO_MAX - (PRIO_MAX - PRIO_MIN) / 4}, {HIGH_PRIORITY_CLASS, PRIO_MAX - (PRIO_MAX - PRIO_MIN) / 8}, {REALTIME_PRIORITY_CLASS, PRIO_MAX}}; + bool compute_base_priority(int32_t priority, int32_t& base_priority) { + static auto base_priorities = map {{IDLE_PRIORITY_CLASS, PRIO_MIN}, {BELOW_NORMAL_PRIORITY_CLASS, PRIO_MIN + (PRIO_MAX - PRIO_MIN) / 4}, {NORMAL_PRIORITY_CLASS, PRIO_MIN + (PRIO_MAX - PRIO_MIN) / 2}, {ABOVE_NORMAL_PRIORITY_CLASS, PRIO_MAX - (PRIO_MAX - PRIO_MIN) / 4}, {HIGH_PRIORITY_CLASS, PRIO_MAX - (PRIO_MAX - PRIO_MIN) / 8}, {REALTIME_PRIORITY_CLASS, PRIO_MAX}}; auto it = base_priorities.find(priority); if (it == base_priorities.end()) return false; base_priority = it->second; @@ -151,7 +151,7 @@ bool compute_base_priority(int_least32_t priority, int_least32_t& base_priority) } } -int_least32_t process::base_priority(int_least32_t priority) { +int32_t process::base_priority(int32_t priority) { auto base_priority = PRIO_MIN + (PRIO_MAX - PRIO_MIN) / 2; compute_base_priority(priority, base_priority); return base_priority; @@ -162,13 +162,13 @@ bool compute_base_priority(int_least32_t priority, int_least32_t& base_priority) return ::kill(static_cast(process), SIGTERM) == 0; } -bool process::priority_class(intmax_t process, int_least32_t priority) { +bool process::priority_class(intmax_t process, int32_t priority) { auto base_priority = PRIO_MIN + (PRIO_MAX - PRIO_MIN) / 2; if (compute_base_priority(priority, base_priority) == false) return false; return setpriority(PRIO_PROCESS, static_cast(process), base_priority) == 0; } -intmax_t process::shell_execute(const std::string& verb, const string& file_name, const string& arguments, const string& working_directory, int_least32_t process_window_style) { +intmax_t process::shell_execute(const std::string& verb, const string& file_name, const string& arguments, const string& working_directory, int32_t process_window_style) { auto process = fork(); if (process == 0) { auto is_shell_execute = is_valid_shell_execute_process(&macos::strings::split, file_name, working_directory); @@ -214,16 +214,16 @@ bool compute_base_priority(int_least32_t priority, int_least32_t& base_priority) return static_cast(process); } -process::started_process process::start(const string& file_name, const string& arguments, const string& working_directory, int_least32_t process_window_style, int_least32_t process_creation_flags, tuple redirect_standard_streams) { +process::started_process process::start(const string& file_name, const string& arguments, const string& working_directory, int32_t process_window_style, int32_t process_creation_flags, tuple redirect_standard_streams) { if (!is_valid_process(&macos::strings::split, file_name, working_directory)) return make_tuple(0, 0, std::unique_ptr {}, std::unique_ptr {}, std::unique_ptr {}); auto [redirect_standard_input, redirect_standard_output, redirect_standard_error] = redirect_standard_streams; auto pipe_result = 0; - int_least32_t pipe_stdin[] = {0, 0}; + int32_t pipe_stdin[] = {0, 0}; if (redirect_standard_input) pipe_result = pipe(pipe_stdin); - int_least32_t pipe_stdout[] = {0, 0}; + int32_t pipe_stdout[] = {0, 0}; if (redirect_standard_output) pipe_result = pipe(pipe_stdout); - int_least32_t pipe_stderr[] = {0, 0}; + int32_t pipe_stderr[] = {0, 0}; if (redirect_standard_error) pipe_result = pipe(pipe_stderr); if (pipe_result) {/*do nothing*/} @@ -260,10 +260,10 @@ bool compute_base_priority(int_least32_t priority, int_least32_t& base_priority) if (redirect_standard_output) close(pipe_stdout[1]); if (redirect_standard_error) close(pipe_stderr[1]); - return make_tuple(static_cast(process), static_cast(process), make_unique(pipe_stdin[1]), make_unique(pipe_stdout[0]), make_unique(pipe_stderr[0])); + return make_tuple(static_cast(process), static_cast(process), make_unique(pipe_stdin[1]), make_unique(pipe_stdout[0]), make_unique(pipe_stderr[0])); } -bool process::wait(intmax_t process, int_least32_t& exit_code) { +bool process::wait(intmax_t process, int32_t& exit_code) { if (process == 0) return false; auto wait_info = siginfo_t {}; wait_info.si_pid = static_cast(process); diff --git a/src/xtd.core.native.macos/src/xtd/native/macos/socket.mm b/src/xtd.core.native.macos/src/xtd/native/macos/socket.mm index 6a87b9699a0..666ad8e68fb 100644 --- a/src/xtd.core.native.macos/src/xtd/native/macos/socket.mm +++ b/src/xtd.core.native.macos/src/xtd/native/macos/socket.mm @@ -23,69 +23,69 @@ using namespace xtd::native; namespace { - static int_least32_t native_to_socket_error(int_least32_t error) { - static auto socket_errors = map {{0, SOCKET_ERROR_SUCCESS}, {EINTR, SOCKET_ERROR_INTERRUPTED}, {EACCES, SOCKET_ERROR_ACCESS_DENIED}, {EFAULT, SOCKET_ERROR_FAULT}, {EINVAL, SOCKET_ERROR_INVALID_ARGUMENT}, {EMFILE, SOCKET_ERROR_TOO_MANY_OPEN_SOCKETS}, {EAGAIN, SOCKET_ERROR_WOULD_BLOCK}, {EINPROGRESS, SOCKET_ERROR_IN_PROGRESS}, {EALREADY, SOCKET_ERROR_ALREADY_IN_PROGRESS}, {ENOTSOCK, SOCKET_ERROR_NOT_SOCKET}, {EDESTADDRREQ, SOCKET_ERROR_DESTINATION_ADDRESS_REQUIRED}, {EMSGSIZE, SOCKET_ERROR_MESSAGE_SIZE}, {EPROTOTYPE, SOCKET_ERROR_PROTOCOL_TYPE}, {ENOPROTOOPT, SOCKET_ERROR_PROTOCOL_OPTION}, {EPROTONOSUPPORT, SOCKET_ERROR_PROTOCOL_NOT_SUPPORTED}, {ESOCKTNOSUPPORT, SOCKET_ERROR_SOCKET_NOT_SUPPORTED}, {ENOTSUP, SOCKET_ERROR_OPERATION_NOT_SUPPORTED}, {EPFNOSUPPORT, SOCKET_ERROR_PROTOCOL_FAMILY_NOT_SUPPORTED}, {EAFNOSUPPORT, SOCKET_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED}, {EADDRINUSE, SOCKET_ERROR_ADDRESS_ALREADY_IN_USE}, {EADDRNOTAVAIL, SOCKET_ERROR_ADDRESS_NOT_AVAILABLE}, {ENETDOWN, SOCKET_ERROR_NETWORK_DOWN}, {ENETUNREACH, SOCKET_ERROR_NETWORK_UNREACHABLE}, {ENETRESET, SOCKET_ERROR_NETWORK_RESET}, {ECONNABORTED, SOCKET_ERROR_CONNECTION_ABORTED}, {ECONNRESET, SOCKET_ERROR_CONNECTION_RESET}, {ENOBUFS, SOCKET_ERROR_NO_BUFFER_SPACE_AVAILABLE}, {EISCONN, SOCKET_ERROR_IS_CONNECTED}, {ENOTCONN, SOCKET_ERROR_NOT_CONNECTED}, {ESHUTDOWN, SOCKET_ERROR_SHUTDOWN}, {ETIMEDOUT, SOCKET_ERROR_TIMED_OUT}, {ECONNREFUSED, SOCKET_ERROR_CONNECTION_REFUSED}, {EHOSTDOWN, SOCKET_ERROR_HOST_DOWN}, {EHOSTUNREACH, SOCKET_ERROR_HOST_UNREACHABLE}, {EPROCLIM, SOCKET_ERROR_PROCESS_LIMIT}, {ERPCMISMATCH, SOCKET_ERROR_VERSION_NOT_SUPPORTED}, {EOPNOTSUPP, SOCKET_ERROR_SOCKET_NOT_SUPPORTED}}; + static int32_t native_to_socket_error(int32_t error) { + static auto socket_errors = map {{0, SOCKET_ERROR_SUCCESS}, {EINTR, SOCKET_ERROR_INTERRUPTED}, {EACCES, SOCKET_ERROR_ACCESS_DENIED}, {EFAULT, SOCKET_ERROR_FAULT}, {EINVAL, SOCKET_ERROR_INVALID_ARGUMENT}, {EMFILE, SOCKET_ERROR_TOO_MANY_OPEN_SOCKETS}, {EAGAIN, SOCKET_ERROR_WOULD_BLOCK}, {EINPROGRESS, SOCKET_ERROR_IN_PROGRESS}, {EALREADY, SOCKET_ERROR_ALREADY_IN_PROGRESS}, {ENOTSOCK, SOCKET_ERROR_NOT_SOCKET}, {EDESTADDRREQ, SOCKET_ERROR_DESTINATION_ADDRESS_REQUIRED}, {EMSGSIZE, SOCKET_ERROR_MESSAGE_SIZE}, {EPROTOTYPE, SOCKET_ERROR_PROTOCOL_TYPE}, {ENOPROTOOPT, SOCKET_ERROR_PROTOCOL_OPTION}, {EPROTONOSUPPORT, SOCKET_ERROR_PROTOCOL_NOT_SUPPORTED}, {ESOCKTNOSUPPORT, SOCKET_ERROR_SOCKET_NOT_SUPPORTED}, {ENOTSUP, SOCKET_ERROR_OPERATION_NOT_SUPPORTED}, {EPFNOSUPPORT, SOCKET_ERROR_PROTOCOL_FAMILY_NOT_SUPPORTED}, {EAFNOSUPPORT, SOCKET_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED}, {EADDRINUSE, SOCKET_ERROR_ADDRESS_ALREADY_IN_USE}, {EADDRNOTAVAIL, SOCKET_ERROR_ADDRESS_NOT_AVAILABLE}, {ENETDOWN, SOCKET_ERROR_NETWORK_DOWN}, {ENETUNREACH, SOCKET_ERROR_NETWORK_UNREACHABLE}, {ENETRESET, SOCKET_ERROR_NETWORK_RESET}, {ECONNABORTED, SOCKET_ERROR_CONNECTION_ABORTED}, {ECONNRESET, SOCKET_ERROR_CONNECTION_RESET}, {ENOBUFS, SOCKET_ERROR_NO_BUFFER_SPACE_AVAILABLE}, {EISCONN, SOCKET_ERROR_IS_CONNECTED}, {ENOTCONN, SOCKET_ERROR_NOT_CONNECTED}, {ESHUTDOWN, SOCKET_ERROR_SHUTDOWN}, {ETIMEDOUT, SOCKET_ERROR_TIMED_OUT}, {ECONNREFUSED, SOCKET_ERROR_CONNECTION_REFUSED}, {EHOSTDOWN, SOCKET_ERROR_HOST_DOWN}, {EHOSTUNREACH, SOCKET_ERROR_HOST_UNREACHABLE}, {EPROCLIM, SOCKET_ERROR_PROCESS_LIMIT}, {ERPCMISMATCH, SOCKET_ERROR_VERSION_NOT_SUPPORTED}, {EOPNOTSUPP, SOCKET_ERROR_SOCKET_NOT_SUPPORTED}}; auto it = socket_errors.find(error); if (it == socket_errors.end()) return SOCKET_ERROR_SOCKET_ERROR; return it->second; } - static int_least32_t protocol_type_to_native(int_least32_t protocol_type) { - static auto protocol_types = map {/*{PROTOCOL_TYPE_UNKNOWN, IPPROTO_}, {PROTOCOL_TYPE_IP_V6_HOP_BY_HOP_OPTIONS, IPPROTO_}, {PROTOCOL_TYPE_UNSPECIFIED, IPPROTO_},*/ {PROTOCOL_TYPE_IP, IPPROTO_IP}, {PROTOCOL_TYPE_ICMP, IPPROTO_ICMP}, {PROTOCOL_TYPE_IGMP, IPPROTO_IGMP}, {PROTOCOL_TYPE_GGP, IPPROTO_GGP}, {PROTOCOL_TYPE_IP_V4, IPPROTO_IPV4}, {PROTOCOL_TYPE_TCP, IPPROTO_TCP}, {PROTOCOL_TYPE_PUP, IPPROTO_PUP}, {PROTOCOL_TYPE_UDP, IPPROTO_UDP}, {PROTOCOL_TYPE_IDP, IPPROTO_IDP}, {PROTOCOL_TYPE_IP_V6, IPPROTO_IPV6}, {PROTOCOL_TYPE_IP_V6_ROUTING_HEADER, IPPROTO_ROUTING}, {PROTOCOL_TYPE_IP_V6_FRAGMENT_HEADER, IPPROTO_FRAGMENT}, {PROTOCOL_TYPE_IP_SEC_ENCAPSULATING_SECURITY_PAYLOAD, IPPROTO_ESP}, {PROTOCOL_TYPE_IP_SEC_AUTHENTICATION_HEADER, IPPROTO_AH}, {PROTOCOL_TYPE_ICMP_V6, IPPROTO_ICMPV6}, {PROTOCOL_TYPE_IP_V6_NO_NEXT_HEADER, IPPROTO_NONE}, {PROTOCOL_TYPE_IP_V6_DESTINATION_OPTIONS, IPPROTO_DSTOPTS}, {PROTOCOL_TYPE_ND, IPPROTO_ND}, {PROTOCOL_TYPE_RAW, IPPROTO_RAW} /*{PROTOCOL_TYPE_IPX, IPPROTO_}, {PROTOCOL_TYPE_SPX, IPPROTO_IP}, {PROTOCOL_TYPE_SPX_2, IPPROTO_},*/}; + static int32_t protocol_type_to_native(int32_t protocol_type) { + static auto protocol_types = map {/*{PROTOCOL_TYPE_UNKNOWN, IPPROTO_}, {PROTOCOL_TYPE_IP_V6_HOP_BY_HOP_OPTIONS, IPPROTO_}, {PROTOCOL_TYPE_UNSPECIFIED, IPPROTO_},*/ {PROTOCOL_TYPE_IP, IPPROTO_IP}, {PROTOCOL_TYPE_ICMP, IPPROTO_ICMP}, {PROTOCOL_TYPE_IGMP, IPPROTO_IGMP}, {PROTOCOL_TYPE_GGP, IPPROTO_GGP}, {PROTOCOL_TYPE_IP_V4, IPPROTO_IPV4}, {PROTOCOL_TYPE_TCP, IPPROTO_TCP}, {PROTOCOL_TYPE_PUP, IPPROTO_PUP}, {PROTOCOL_TYPE_UDP, IPPROTO_UDP}, {PROTOCOL_TYPE_IDP, IPPROTO_IDP}, {PROTOCOL_TYPE_IP_V6, IPPROTO_IPV6}, {PROTOCOL_TYPE_IP_V6_ROUTING_HEADER, IPPROTO_ROUTING}, {PROTOCOL_TYPE_IP_V6_FRAGMENT_HEADER, IPPROTO_FRAGMENT}, {PROTOCOL_TYPE_IP_SEC_ENCAPSULATING_SECURITY_PAYLOAD, IPPROTO_ESP}, {PROTOCOL_TYPE_IP_SEC_AUTHENTICATION_HEADER, IPPROTO_AH}, {PROTOCOL_TYPE_ICMP_V6, IPPROTO_ICMPV6}, {PROTOCOL_TYPE_IP_V6_NO_NEXT_HEADER, IPPROTO_NONE}, {PROTOCOL_TYPE_IP_V6_DESTINATION_OPTIONS, IPPROTO_DSTOPTS}, {PROTOCOL_TYPE_ND, IPPROTO_ND}, {PROTOCOL_TYPE_RAW, IPPROTO_RAW} /*{PROTOCOL_TYPE_IPX, IPPROTO_}, {PROTOCOL_TYPE_SPX, IPPROTO_IP}, {PROTOCOL_TYPE_SPX_2, IPPROTO_},*/}; auto it = protocol_types.find(protocol_type); if (it == protocol_types.end()) return IPPROTO_IP; return it->second; } - static int_least32_t socket_option_level_to_native(int_least32_t socket_option_level) { - static auto socket_option_levels = map {{SOCKET_OPTION_LEVEL_SOCKET, SOL_SOCKET}, {SOCKET_OPTION_LEVEL_IP, IPPROTO_IP}, {SOCKET_OPTION_LEVEL_IP_V6, IPPROTO_IPV6}, {SOCKET_OPTION_LEVEL_TCP, IPPROTO_TCP}, {SOCKET_OPTION_LEVEL_UDP, IPPROTO_UDP}}; + static int32_t socket_option_level_to_native(int32_t socket_option_level) { + static auto socket_option_levels = map {{SOCKET_OPTION_LEVEL_SOCKET, SOL_SOCKET}, {SOCKET_OPTION_LEVEL_IP, IPPROTO_IP}, {SOCKET_OPTION_LEVEL_IP_V6, IPPROTO_IPV6}, {SOCKET_OPTION_LEVEL_TCP, IPPROTO_TCP}, {SOCKET_OPTION_LEVEL_UDP, IPPROTO_UDP}}; auto it = socket_option_levels.find(socket_option_level); if (it == socket_option_levels.end()) return SOL_SOCKET; return it->second; } - static int_least32_t socket_option_name_to_native(int_least32_t socket_option_name) { - static auto socket_option_names = map {{SOCKET_OPTION_NAME_DEBUG, SO_DEBUG}, {SOCKET_OPTION_NAME_ACCEPT_CONNECTION, SO_ACCEPTCONN}, {SOCKET_OPTION_NAME_REUSE_ADDRESS, SO_REUSEADDR}, {SOCKET_OPTION_NAME_KEEP_ALIVE, SO_KEEPALIVE}, {SOCKET_OPTION_NAME_DONT_ROUTE, SO_DONTROUTE}, {SOCKET_OPTION_NAME_BROADCAST, SO_BROADCAST}, {SOCKET_OPTION_NAME_USE_LOOPBACK, SO_USELOOPBACK}, {SOCKET_OPTION_NAME_LINGER, SO_LINGER}, {SOCKET_OPTION_NAME_EXCLUSIVE_ADDRESS_USE, SO_REUSEADDR}, {SOCKET_OPTION_NAME_OUT_OF_BAND_INLINE, SO_OOBINLINE}, {SOCKET_OPTION_NAME_SEND_BUFFER, SO_SNDBUF}, {SOCKET_OPTION_NAME_RECEIVE_BUFFER, SO_RCVBUF}, {SOCKET_OPTION_NAME_SEND_LOW_WATER, SO_SNDLOWAT}, {SOCKET_OPTION_NAME_RECEIVE_LOW_WATER, SO_RCVLOWAT}, {SOCKET_OPTION_NAME_SEND_TIMEOUT, SO_SNDTIMEO}, {SOCKET_OPTION_NAME_RECEIVE_TIMEOUT, SO_RCVTIMEO}, {SOCKET_OPTION_NAME_ERROR, SO_ERROR}, {SOCKET_OPTION_NAME_TYPE, SO_TYPE}, /*{SOCKET_OPTION_NAME_MAX_CONNECTION, SO_},*/ {SOCKET_OPTION_NAME_IP_OPTIONS, IP_OPTIONS}, {SOCKET_OPTION_NAME_HEADER_INCLUDED, IP_HDRINCL}, {SOCKET_OPTION_NAME_TYPE_OF_SERVICE, IP_TOS}, {SOCKET_OPTION_NAME_IP_TIME_TO_LIVE, IP_TTL}, {SOCKET_OPTION_NAME_MULTICAST_INTERFACE, IP_MULTICAST_IF}, {SOCKET_OPTION_NAME_MULTICAST_TIME_TO_LIVE, IP_MULTICAST_TTL}, {SOCKET_OPTION_NAME_MULTICAST_LOOPBACK, IP_MULTICAST_LOOP}, {SOCKET_OPTION_NAME_ADD_MEMBERSHIP, IP_ADD_MEMBERSHIP}, {SOCKET_OPTION_NAME_DROP_MEMBERSHIP, IP_DROP_MEMBERSHIP}, {SOCKET_OPTION_NAME_DONT_FRAGMENT, IP_DONTFRAG}, {SOCKET_OPTION_NAME_ADD_SOURCE_MEMBERSHIP, IP_ADD_SOURCE_MEMBERSHIP}, {SOCKET_OPTION_NAME_DROP_SOURCE_MEMBERSHIP, IP_DROP_SOURCE_MEMBERSHIP}, {SOCKET_OPTION_NAME_BLOCK_SOURCE, IP_BLOCK_SOURCE}, {SOCKET_OPTION_NAME_UNBLOCK_SOURCE, IP_UNBLOCK_SOURCE}, {SOCKET_OPTION_NAME_PACKET_INFORMATION, IP_PKTINFO}, {SOCKET_OPTION_NAME_HOP_LIMIT, IPV6_2292HOPLIMIT /*IPV6_HOPLIMIT*/}, /*{SOCKET_OPTION_NAME_IP_PROTECT_LEVEL, IPV6_},*/ {SOCKET_OPTION_NAME_IP_V6_ONLY, IPV6_V6ONLY}, /*{SOCKET_OPTION_NAME_NO_DELAY, TCP_}, {SOCKET_OPTION_NAME_BSD_URGENT, TCP_}, {SOCKET_OPTION_NAME_EXPEDITED, TCP_}, {SOCKET_OPTION_NAME_NO_CHECKSUM, UDP_}, {SOCKET_OPTION_NAME_CHECKSUM_COVERAGE, ...}, {SOCKET_OPTION_NAME_UPDATE_ACCEPT_CONTEXT, ...}, {SOCKET_OPTION_NAME_UPDATE_CONNECT_CONTEXT, ...},*/}; + static int32_t socket_option_name_to_native(int32_t socket_option_name) { + static auto socket_option_names = map {{SOCKET_OPTION_NAME_DEBUG, SO_DEBUG}, {SOCKET_OPTION_NAME_ACCEPT_CONNECTION, SO_ACCEPTCONN}, {SOCKET_OPTION_NAME_REUSE_ADDRESS, SO_REUSEADDR}, {SOCKET_OPTION_NAME_KEEP_ALIVE, SO_KEEPALIVE}, {SOCKET_OPTION_NAME_DONT_ROUTE, SO_DONTROUTE}, {SOCKET_OPTION_NAME_BROADCAST, SO_BROADCAST}, {SOCKET_OPTION_NAME_USE_LOOPBACK, SO_USELOOPBACK}, {SOCKET_OPTION_NAME_LINGER, SO_LINGER}, {SOCKET_OPTION_NAME_EXCLUSIVE_ADDRESS_USE, SO_REUSEADDR}, {SOCKET_OPTION_NAME_OUT_OF_BAND_INLINE, SO_OOBINLINE}, {SOCKET_OPTION_NAME_SEND_BUFFER, SO_SNDBUF}, {SOCKET_OPTION_NAME_RECEIVE_BUFFER, SO_RCVBUF}, {SOCKET_OPTION_NAME_SEND_LOW_WATER, SO_SNDLOWAT}, {SOCKET_OPTION_NAME_RECEIVE_LOW_WATER, SO_RCVLOWAT}, {SOCKET_OPTION_NAME_SEND_TIMEOUT, SO_SNDTIMEO}, {SOCKET_OPTION_NAME_RECEIVE_TIMEOUT, SO_RCVTIMEO}, {SOCKET_OPTION_NAME_ERROR, SO_ERROR}, {SOCKET_OPTION_NAME_TYPE, SO_TYPE}, /*{SOCKET_OPTION_NAME_MAX_CONNECTION, SO_},*/ {SOCKET_OPTION_NAME_IP_OPTIONS, IP_OPTIONS}, {SOCKET_OPTION_NAME_HEADER_INCLUDED, IP_HDRINCL}, {SOCKET_OPTION_NAME_TYPE_OF_SERVICE, IP_TOS}, {SOCKET_OPTION_NAME_IP_TIME_TO_LIVE, IP_TTL}, {SOCKET_OPTION_NAME_MULTICAST_INTERFACE, IP_MULTICAST_IF}, {SOCKET_OPTION_NAME_MULTICAST_TIME_TO_LIVE, IP_MULTICAST_TTL}, {SOCKET_OPTION_NAME_MULTICAST_LOOPBACK, IP_MULTICAST_LOOP}, {SOCKET_OPTION_NAME_ADD_MEMBERSHIP, IP_ADD_MEMBERSHIP}, {SOCKET_OPTION_NAME_DROP_MEMBERSHIP, IP_DROP_MEMBERSHIP}, {SOCKET_OPTION_NAME_DONT_FRAGMENT, IP_DONTFRAG}, {SOCKET_OPTION_NAME_ADD_SOURCE_MEMBERSHIP, IP_ADD_SOURCE_MEMBERSHIP}, {SOCKET_OPTION_NAME_DROP_SOURCE_MEMBERSHIP, IP_DROP_SOURCE_MEMBERSHIP}, {SOCKET_OPTION_NAME_BLOCK_SOURCE, IP_BLOCK_SOURCE}, {SOCKET_OPTION_NAME_UNBLOCK_SOURCE, IP_UNBLOCK_SOURCE}, {SOCKET_OPTION_NAME_PACKET_INFORMATION, IP_PKTINFO}, {SOCKET_OPTION_NAME_HOP_LIMIT, IPV6_2292HOPLIMIT /*IPV6_HOPLIMIT*/}, /*{SOCKET_OPTION_NAME_IP_PROTECT_LEVEL, IPV6_},*/ {SOCKET_OPTION_NAME_IP_V6_ONLY, IPV6_V6ONLY}, /*{SOCKET_OPTION_NAME_NO_DELAY, TCP_}, {SOCKET_OPTION_NAME_BSD_URGENT, TCP_}, {SOCKET_OPTION_NAME_EXPEDITED, TCP_}, {SOCKET_OPTION_NAME_NO_CHECKSUM, UDP_}, {SOCKET_OPTION_NAME_CHECKSUM_COVERAGE, ...}, {SOCKET_OPTION_NAME_UPDATE_ACCEPT_CONTEXT, ...}, {SOCKET_OPTION_NAME_UPDATE_CONNECT_CONTEXT, ...},*/}; auto it = socket_option_names.find(socket_option_name); if (it == socket_option_names.end()) return -1; return it->second; } - static int_least32_t socket_type_to_native(int_least32_t socket_type) { - static auto socket_types = map {{SOCKET_TYPE_UNKNOWN, SOCK_STREAM}, {SOCKET_TYPE_STREAM, SOCK_STREAM}, {SOCKET_TYPE_DGRAM, SOCK_DGRAM}, {SOCKET_TYPE_RAW, SOCK_RAW}, {SOCKET_TYPE_RDM, SOCK_RDM}, {SOCKET_TYPE_SEQPACKET, SOCK_SEQPACKET}}; + static int32_t socket_type_to_native(int32_t socket_type) { + static auto socket_types = map {{SOCKET_TYPE_UNKNOWN, SOCK_STREAM}, {SOCKET_TYPE_STREAM, SOCK_STREAM}, {SOCKET_TYPE_DGRAM, SOCK_DGRAM}, {SOCKET_TYPE_RAW, SOCK_RAW}, {SOCKET_TYPE_RDM, SOCK_RDM}, {SOCKET_TYPE_SEQPACKET, SOCK_SEQPACKET}}; auto it = socket_types.find(socket_type); if (it == socket_types.end()) return SOCK_STREAM; return it->second; } } -int_least32_t socket::address_family_to_native(int_least32_t address_family) { - static auto address_families = map {{ADDRESS_FAMILY_UNKNOWN, -1}, {ADDRESS_FAMILY_UNSPECIFIED, AF_UNSPEC}, {ADDRESS_FAMILY_UNIX, AF_UNIX}, {ADDRESS_FAMILY_INTER_NETWORK, AF_INET}, {ADDRESS_FAMILY_IMP_LINK, AF_IMPLINK}, {ADDRESS_FAMILY_PUP, AF_PUP}, {ADDRESS_FAMILY_CHAOS, AF_CHAOS}, {ADDRESS_FAMILY_NS, AF_NS}, /*{ADDRESS_FAMILY_IPX, AF_},*/ {ADDRESS_FAMILY_ISO, AF_ISO}, {ADDRESS_FAMILY_ECMA, AF_ECMA}, {ADDRESS_FAMILY_DATA_KIT, AF_DATAKIT}, {ADDRESS_FAMILY_CCITT, AF_CCITT}, {ADDRESS_FAMILY_SNA, AF_SNA}, {ADDRESS_FAMILY_DEC_NET, AF_DECnet}, {ADDRESS_FAMILY_DATA_LINK, AF_DLI}, {ADDRESS_FAMILY_LAT, AF_LAT}, {ADDRESS_FAMILY_HYPER_CHANNEL, AF_HYLINK}, {ADDRESS_FAMILY_APPLE_TALK, AF_APPLETALK}, {ADDRESS_FAMILY_NET_BIOS, AF_NETBIOS}, /*{ADDRESS_FAMILY_VOICE_VIEW, AF_}, {ADDRESS_FAMILY_FIRE_FOX, AF_}, {ADDRESS_FAMILY_BANYAN, AF_},*/ {ADDRESS_FAMILY_ATM, AF_NATM}, {ADDRESS_FAMILY_INTER_NETWORK_V6, AF_INET6}, /*{ADDRESS_FAMILY_CLUSTER, AF_}, {ADDRESS_FAMILY_IEEE12844, AF_}, {ADDRESS_FAMILY_IRDA, AF_}, {ADDRESS_FAMILY_NETWORK_DESIGNERS, AF_},*/ {ADDRESS_FAMILY_MAX, AF_MAX}}; +int32_t socket::address_family_to_native(int32_t address_family) { + static auto address_families = map {{ADDRESS_FAMILY_UNKNOWN, -1}, {ADDRESS_FAMILY_UNSPECIFIED, AF_UNSPEC}, {ADDRESS_FAMILY_UNIX, AF_UNIX}, {ADDRESS_FAMILY_INTER_NETWORK, AF_INET}, {ADDRESS_FAMILY_IMP_LINK, AF_IMPLINK}, {ADDRESS_FAMILY_PUP, AF_PUP}, {ADDRESS_FAMILY_CHAOS, AF_CHAOS}, {ADDRESS_FAMILY_NS, AF_NS}, /*{ADDRESS_FAMILY_IPX, AF_},*/ {ADDRESS_FAMILY_ISO, AF_ISO}, {ADDRESS_FAMILY_ECMA, AF_ECMA}, {ADDRESS_FAMILY_DATA_KIT, AF_DATAKIT}, {ADDRESS_FAMILY_CCITT, AF_CCITT}, {ADDRESS_FAMILY_SNA, AF_SNA}, {ADDRESS_FAMILY_DEC_NET, AF_DECnet}, {ADDRESS_FAMILY_DATA_LINK, AF_DLI}, {ADDRESS_FAMILY_LAT, AF_LAT}, {ADDRESS_FAMILY_HYPER_CHANNEL, AF_HYLINK}, {ADDRESS_FAMILY_APPLE_TALK, AF_APPLETALK}, {ADDRESS_FAMILY_NET_BIOS, AF_NETBIOS}, /*{ADDRESS_FAMILY_VOICE_VIEW, AF_}, {ADDRESS_FAMILY_FIRE_FOX, AF_}, {ADDRESS_FAMILY_BANYAN, AF_},*/ {ADDRESS_FAMILY_ATM, AF_NATM}, {ADDRESS_FAMILY_INTER_NETWORK_V6, AF_INET6}, /*{ADDRESS_FAMILY_CLUSTER, AF_}, {ADDRESS_FAMILY_IEEE12844, AF_}, {ADDRESS_FAMILY_IRDA, AF_}, {ADDRESS_FAMILY_NETWORK_DESIGNERS, AF_},*/ {ADDRESS_FAMILY_MAX, AF_MAX}}; auto it = address_families.find(address_family); if (it == address_families.end()) return AF_UNSPEC; return it->second; } -int_least32_t socket::native_to_address_family(int_least32_t address_family) { - static auto address_families = map {/*{-1, ADDRESS_FAMILY_UNKNOWN},*/ {AF_UNSPEC, ADDRESS_FAMILY_UNSPECIFIED}, {AF_UNIX, ADDRESS_FAMILY_UNIX}, {AF_INET, ADDRESS_FAMILY_INTER_NETWORK}, {AF_IMPLINK, ADDRESS_FAMILY_IMP_LINK}, {AF_PUP, ADDRESS_FAMILY_PUP}, {AF_CHAOS, ADDRESS_FAMILY_CHAOS}, {AF_NS, ADDRESS_FAMILY_NS}, {AF_ISO, ADDRESS_FAMILY_ISO}, /*{AF_, ADDRESS_FAMILY_IPX},*/ {AF_ECMA, ADDRESS_FAMILY_ECMA}, {AF_DATAKIT, ADDRESS_FAMILY_DATA_KIT}, {AF_CCITT, ADDRESS_FAMILY_CCITT}, {AF_SNA, ADDRESS_FAMILY_SNA}, {AF_DECnet, ADDRESS_FAMILY_DEC_NET}, {AF_DLI, ADDRESS_FAMILY_DATA_LINK}, {AF_LAT, ADDRESS_FAMILY_LAT}, {AF_HYLINK, ADDRESS_FAMILY_HYPER_CHANNEL}, {AF_APPLETALK, ADDRESS_FAMILY_APPLE_TALK}, {AF_NETBIOS, ADDRESS_FAMILY_NET_BIOS}, /*{AF_, ADDRESS_FAMILY_VOICE_VIEW}, {AF_, ADDRESS_FAMILY_FIRE_FOX}, {AF_, ADDRESS_FAMILY_BANYAN},*/ {AF_NATM, ADDRESS_FAMILY_ATM}, {AF_INET6, ADDRESS_FAMILY_INTER_NETWORK_V6}, /*{AF_, ADDRESS_FAMILY_CLUSTER}, {AF_, ADDRESS_FAMILY_IEEE12844}, {AF_, ADDRESS_FAMILY_IRDA}, {AF_, ADDRESS_FAMILY_NETWORK_DESIGNERS},*/ {AF_MAX, ADDRESS_FAMILY_MAX}}; +int32_t socket::native_to_address_family(int32_t address_family) { + static auto address_families = map {/*{-1, ADDRESS_FAMILY_UNKNOWN},*/ {AF_UNSPEC, ADDRESS_FAMILY_UNSPECIFIED}, {AF_UNIX, ADDRESS_FAMILY_UNIX}, {AF_INET, ADDRESS_FAMILY_INTER_NETWORK}, {AF_IMPLINK, ADDRESS_FAMILY_IMP_LINK}, {AF_PUP, ADDRESS_FAMILY_PUP}, {AF_CHAOS, ADDRESS_FAMILY_CHAOS}, {AF_NS, ADDRESS_FAMILY_NS}, {AF_ISO, ADDRESS_FAMILY_ISO}, /*{AF_, ADDRESS_FAMILY_IPX},*/ {AF_ECMA, ADDRESS_FAMILY_ECMA}, {AF_DATAKIT, ADDRESS_FAMILY_DATA_KIT}, {AF_CCITT, ADDRESS_FAMILY_CCITT}, {AF_SNA, ADDRESS_FAMILY_SNA}, {AF_DECnet, ADDRESS_FAMILY_DEC_NET}, {AF_DLI, ADDRESS_FAMILY_DATA_LINK}, {AF_LAT, ADDRESS_FAMILY_LAT}, {AF_HYLINK, ADDRESS_FAMILY_HYPER_CHANNEL}, {AF_APPLETALK, ADDRESS_FAMILY_APPLE_TALK}, {AF_NETBIOS, ADDRESS_FAMILY_NET_BIOS}, /*{AF_, ADDRESS_FAMILY_VOICE_VIEW}, {AF_, ADDRESS_FAMILY_FIRE_FOX}, {AF_, ADDRESS_FAMILY_BANYAN},*/ {AF_NATM, ADDRESS_FAMILY_ATM}, {AF_INET6, ADDRESS_FAMILY_INTER_NETWORK_V6}, /*{AF_, ADDRESS_FAMILY_CLUSTER}, {AF_, ADDRESS_FAMILY_IEEE12844}, {AF_, ADDRESS_FAMILY_IRDA}, {AF_, ADDRESS_FAMILY_NETWORK_DESIGNERS},*/ {AF_MAX, ADDRESS_FAMILY_MAX}}; auto it = address_families.find(address_family); if (it == address_families.end()) return ADDRESS_FAMILY_UNSPECIFIED; return it->second; } -intmax_t socket::accept(intmax_t handle, vector& socket_address) { +intmax_t socket::accept(intmax_t handle, vector& socket_address) { swap(socket_address[0], socket_address[1]); auto address_length = static_cast(socket_address.size()); - auto socket = static_cast(::accept(static_cast(handle), reinterpret_cast(socket_address.data()), &address_length)); + auto socket = static_cast(::accept(static_cast(handle), reinterpret_cast(socket_address.data()), &address_length)); //if (socket_address.size() != address_length) socket_address.resize(address_length); swap(socket_address[0], socket_address[1]); return socket; } -int_least32_t socket::bind(intmax_t handle, const vector& socket_address) { - swap(const_cast&>(socket_address)[0], const_cast&>(socket_address)[1]); - auto result = ::bind(static_cast(handle), reinterpret_cast(socket_address.data()), static_cast(socket_address.size())); - swap(const_cast&>(socket_address)[0], const_cast&>(socket_address)[1]); +int32_t socket::bind(intmax_t handle, const vector& socket_address) { + swap(const_cast&>(socket_address)[0], const_cast&>(socket_address)[1]); + auto result = ::bind(static_cast(handle), reinterpret_cast(socket_address.data()), static_cast(socket_address.size())); + swap(const_cast&>(socket_address)[0], const_cast&>(socket_address)[1]); return result; } @@ -93,28 +93,28 @@ static int_least32_t socket_type_to_native(int_least32_t socket_type) { // Nothing to do on linux and macOS. } -int_least32_t socket::connect(intmax_t handle, const vector& socket_address) { - swap(const_cast&>(socket_address)[0], const_cast&>(socket_address)[1]); - auto result = ::connect(static_cast(handle), reinterpret_cast(socket_address.data()), static_cast(socket_address.size())); - swap(const_cast&>(socket_address)[0], const_cast&>(socket_address)[1]); +int32_t socket::connect(intmax_t handle, const vector& socket_address) { + swap(const_cast&>(socket_address)[0], const_cast&>(socket_address)[1]); + auto result = ::connect(static_cast(handle), reinterpret_cast(socket_address.data()), static_cast(socket_address.size())); + swap(const_cast&>(socket_address)[0], const_cast&>(socket_address)[1]); return result; } -intmax_t socket::create(int_least32_t address_family, int_least32_t socket_type, int_least32_t protocol_type) { +intmax_t socket::create(int32_t address_family, int32_t socket_type, int32_t protocol_type) { return static_cast(::socket(address_family_to_native(address_family), socket_type_to_native(socket_type), protocol_type_to_native(protocol_type))); } -int_least32_t socket::destroy(intmax_t handle) { - return ::close(static_cast(handle)); +int32_t socket::destroy(intmax_t handle) { + return ::close(static_cast(handle)); } size_t socket::get_available(intmax_t handle) { auto nbr_bytes_available = 0; - if (ioctl(static_cast(handle), FIONREAD, &nbr_bytes_available) != 0) return -1; + if (ioctl(static_cast(handle), FIONREAD, &nbr_bytes_available) != 0) return -1; return static_cast(nbr_bytes_available); } -int_least32_t socket::get_last_error() { +int32_t socket::get_last_error() { return native_to_socket_error(errno); } @@ -132,43 +132,43 @@ static int_least32_t socket_type_to_native(int_least32_t socket_type) { return true; } -int_least32_t socket::get_raw_socket_option(intmax_t handle, int_least32_t socket_option_level, int_least32_t socket_option_name, intmax_t option, size_t& option_length) { - return ::getsockopt(static_cast(handle), socket_option_level, socket_option_name, reinterpret_cast(option), reinterpret_cast(&option_length)); +int32_t socket::get_raw_socket_option(intmax_t handle, int32_t socket_option_level, int32_t socket_option_name, intmax_t option, size_t& option_length) { + return ::getsockopt(static_cast(handle), socket_option_level, socket_option_name, reinterpret_cast(option), reinterpret_cast(&option_length)); } -int_least32_t socket::get_socket_option(intmax_t handle, int_least32_t socket_option_level, int_least32_t socket_option_name, intmax_t option, size_t& option_length) { +int32_t socket::get_socket_option(intmax_t handle, int32_t socket_option_level, int32_t socket_option_name, intmax_t option, size_t& option_length) { if (socket_option_name_to_native(socket_option_name) == -1) { errno = ENOTSUP; return -1; } if (socket_option_level == SOCKET_OPTION_LEVEL_SOCKET && (socket_option_name == SOCKET_OPTION_NAME_SEND_TIMEOUT || socket_option_name == SOCKET_OPTION_NAME_RECEIVE_TIMEOUT)) { auto timeout = timeval {0, 0}; - auto result = ::getsockopt(static_cast(handle), socket_option_level_to_native(socket_option_level), socket_option_name_to_native(socket_option_name), &timeout, reinterpret_cast(&option_length)); - *reinterpret_cast(option) = static_cast(timeout.tv_sec * 1000 + timeout.tv_usec / 1000); + auto result = ::getsockopt(static_cast(handle), socket_option_level_to_native(socket_option_level), socket_option_name_to_native(socket_option_name), &timeout, reinterpret_cast(&option_length)); + *reinterpret_cast(option) = static_cast(timeout.tv_sec * 1000 + timeout.tv_usec / 1000); return result; } - return ::getsockopt(static_cast(handle), socket_option_level_to_native(socket_option_level), socket_option_name_to_native(socket_option_name), reinterpret_cast(option), reinterpret_cast(&option_length)); + return ::getsockopt(static_cast(handle), socket_option_level_to_native(socket_option_level), socket_option_name_to_native(socket_option_name), reinterpret_cast(option), reinterpret_cast(&option_length)); } -int_least32_t socket::get_socket_linger_option(intmax_t handle, bool& enabled, uint_least32_t& linger_time) { - auto l= linger {static_cast(enabled), static_cast(linger_time)}; +int32_t socket::get_socket_linger_option(intmax_t handle, bool& enabled, uint32_t& linger_time) { + auto l= linger {static_cast(enabled), static_cast(linger_time)}; auto linger_size = size_t {0}; - auto result = ::getsockopt(static_cast(handle), SOL_SOCKET, SO_LINGER, &l, reinterpret_cast(&linger_size)); + auto result = ::getsockopt(static_cast(handle), SOL_SOCKET, SO_LINGER, &l, reinterpret_cast(&linger_size)); if (result == 0) { enabled = static_cast(l.l_onoff); - linger_time = static_cast(l.l_linger); + linger_time = static_cast(l.l_linger); } return result; } -int_least32_t socket::get_socket_multicast_option(intmax_t handle, int_least32_t socket_option_name, uint_least32_t& multicast_address, uint_least32_t& interface_index) { +int32_t socket::get_socket_multicast_option(intmax_t handle, int32_t socket_option_name, uint32_t& multicast_address, uint32_t& interface_index) { struct multicast { - uint_least32_t multicast_address; - uint_least32_t interface_index; + uint32_t multicast_address; + uint32_t interface_index; } m; auto multicast_size = size_t {0}; - auto result = getsockopt(static_cast(handle), IPPROTO_IP, socket_option_name_to_native(socket_option_name), &m, reinterpret_cast(&multicast_size)); + auto result = getsockopt(static_cast(handle), IPPROTO_IP, socket_option_name_to_native(socket_option_name), &m, reinterpret_cast(&multicast_size)); if (result == 0) { multicast_address = m.multicast_address; interface_index = m.interface_index; @@ -176,13 +176,13 @@ static int_least32_t socket_type_to_native(int_least32_t socket_type) { return result; } -int_least32_t socket::get_socket_ip_v6_multicast_option(intmax_t handle, int_least32_t socket_option_name, vector& multicast_address, uint_least32_t& interface_index) { +int32_t socket::get_socket_ip_v6_multicast_option(intmax_t handle, int32_t socket_option_name, vector& multicast_address, uint32_t& interface_index) { struct multicast { - uint_least8_t multicast_address[16]; - uint_least32_t interface_index; + uint8_t multicast_address[16]; + uint32_t interface_index; } m; auto multicast_size = size_t {0}; - auto result = getsockopt(static_cast(handle), IPPROTO_IP, socket_option_name_to_native(socket_option_name), &m, reinterpret_cast(&multicast_size)); + auto result = getsockopt(static_cast(handle), IPPROTO_IP, socket_option_name_to_native(socket_option_name), &m, reinterpret_cast(&multicast_size)); if (result == 0) { for (auto index = 0u; index < multicast_address.size(); ++index) multicast_address[index] = m.multicast_address[index]; @@ -191,22 +191,22 @@ static int_least32_t socket_type_to_native(int_least32_t socket_type) { return result; } -int_least32_t socket::io_control(intmax_t handle, int_least32_t io_control, vector& option_in_value, vector& option_out_value) { +int32_t socket::io_control(intmax_t handle, int32_t io_control, vector& option_in_value, vector& option_out_value) { // Not implemented errno = ENOTSUP; return -1; } -int_least32_t socket::listen(intmax_t handle, size_t backlog) { - auto backlog_value = backlog != static_cast(-1) ? static_cast(backlog) : SOMAXCONN; - return ::listen(static_cast(handle), backlog_value); +int32_t socket::listen(intmax_t handle, size_t backlog) { + auto backlog_value = backlog != static_cast(-1) ? static_cast(backlog) : SOMAXCONN; + return ::listen(static_cast(handle), backlog_value); } -int_least32_t socket::poll(intmax_t handle, int_least32_t microseconds, int_least32_t mode) { +int32_t socket::poll(intmax_t handle, int32_t microseconds, int32_t mode) { if (handle == 0 || microseconds < 0) return -1; auto poll_fd = pollfd {}; - poll_fd.fd = static_cast(handle); + poll_fd.fd = static_cast(handle); switch (mode) { case SELECT_MODE_READ: poll_fd.events = POLLIN; break; case SELECT_MODE_WRITE: poll_fd.events = POLLOUT; break; @@ -216,17 +216,17 @@ static int_least32_t socket_type_to_native(int_least32_t socket_type) { return ::poll(&poll_fd, 1, microseconds); } -int_least32_t socket::receive(intmax_t handle, vector& buffer, size_t offset, size_t size, int_least32_t flags) { - auto result = static_cast(::recv(static_cast(handle), &buffer.data()[offset], size, flags)); +int32_t socket::receive(intmax_t handle, vector& buffer, size_t offset, size_t size, int32_t flags) { + auto result = static_cast(::recv(static_cast(handle), &buffer.data()[offset], size, flags)); if (result == -1 && errno == EBADF) errno = EINTR; if (result == -1 && errno == EAGAIN) errno = ETIMEDOUT; return result; } -int_least32_t socket::receive_from(intmax_t handle, vector& buffer, size_t offset, size_t size, int_least32_t flags, vector& socket_address) { +int32_t socket::receive_from(intmax_t handle, vector& buffer, size_t offset, size_t size, int32_t flags, vector& socket_address) { swap(socket_address[0], socket_address[1]); auto address_length = static_cast(socket_address.size()); - auto result = static_cast(::recvfrom(static_cast(handle), &buffer.data()[offset], size, flags, reinterpret_cast(socket_address.data()), &address_length)); + auto result = static_cast(::recvfrom(static_cast(handle), &buffer.data()[offset], size, flags, reinterpret_cast(socket_address.data()), &address_length)); //if (socket_address.size() != address_length) socket_address.resize(address_length); swap(socket_address[0], socket_address[1]); @@ -235,114 +235,114 @@ static int_least32_t socket_type_to_native(int_least32_t socket_type) { return result; } -int_least32_t socket::select(vector& check_read, vector& check_write, vector& check_error, int_least32_t microseconds) { +int32_t socket::select(vector& check_read, vector& check_write, vector& check_error, int32_t microseconds) { auto nfds = size_t {0}; auto read_fds = fd_set {}; FD_ZERO(&read_fds); for (auto i = 0u; i < check_read.size() && i < FD_SETSIZE; i++) - FD_SET(static_cast(check_read[i]), &read_fds); + FD_SET(static_cast(check_read[i]), &read_fds); if (check_read.size() > nfds) nfds = check_read.size(); auto write_fds = fd_set {}; FD_ZERO(&write_fds); for (auto i = 0u; i < check_write.size() && i < FD_SETSIZE; i++) - FD_SET(static_cast(check_write[i]), &write_fds); + FD_SET(static_cast(check_write[i]), &write_fds); if (check_write.size() > nfds) nfds = check_write.size(); auto error_fds = fd_set {}; FD_ZERO(&error_fds); for (auto i = 0u; i < check_error.size() && i < FD_SETSIZE; i++) - FD_SET(static_cast(check_error[i]), &error_fds); + FD_SET(static_cast(check_error[i]), &error_fds); if (check_error.size() > nfds) nfds = check_error.size(); auto timeout = timeval {microseconds / 1000000, microseconds % 1000000}; - auto result = ::select(static_cast(nfds + 1), &read_fds, &write_fds, &error_fds, microseconds == -1 ? nullptr : &timeout); + auto result = ::select(static_cast(nfds + 1), &read_fds, &write_fds, &error_fds, microseconds == -1 ? nullptr : &timeout); for (auto i = 0u; i < check_read.size(); i++) { - FD_CLR(static_cast(check_read[i]), &read_fds); - if (FD_ISSET(static_cast(check_read[i]), &read_fds) == 0) check_read[i] = 0; + FD_CLR(static_cast(check_read[i]), &read_fds); + if (FD_ISSET(static_cast(check_read[i]), &read_fds) == 0) check_read[i] = 0; } for (auto i = 0u; i < check_write.size(); i++) { - FD_CLR(static_cast(check_write[i]), &write_fds); - if (FD_ISSET(static_cast(check_write[i]), &write_fds) == 0) check_write[i] = 0; + FD_CLR(static_cast(check_write[i]), &write_fds); + if (FD_ISSET(static_cast(check_write[i]), &write_fds) == 0) check_write[i] = 0; } for (auto i = 0u; i < check_error.size(); i++) { - FD_CLR(static_cast(check_error[i]), &error_fds); - if (FD_ISSET(static_cast(check_error[i]), &error_fds) == 0) check_error[i] = 0; + FD_CLR(static_cast(check_error[i]), &error_fds); + if (FD_ISSET(static_cast(check_error[i]), &error_fds) == 0) check_error[i] = 0; } return result; } -int_least32_t socket::send(intmax_t handle, const vector& buffer, size_t offset, size_t size, int_least32_t flags) { - return static_cast(::send(static_cast(handle), &buffer.data()[offset], size, flags)); +int32_t socket::send(intmax_t handle, const vector& buffer, size_t offset, size_t size, int32_t flags) { + return static_cast(::send(static_cast(handle), &buffer.data()[offset], size, flags)); } -int_least32_t socket::send_to(intmax_t handle, const vector& buffer, size_t offset, size_t size, int_least32_t flags, const vector& socket_address) { - swap(const_cast&>(socket_address)[0], const_cast&>(socket_address)[1]); - auto result = static_cast(::sendto(static_cast(handle), &buffer.data()[offset], size, flags, reinterpret_cast(socket_address.data()), static_cast(socket_address.size()))); - swap(const_cast&>(socket_address)[0], const_cast&>(socket_address)[1]); +int32_t socket::send_to(intmax_t handle, const vector& buffer, size_t offset, size_t size, int32_t flags, const vector& socket_address) { + swap(const_cast&>(socket_address)[0], const_cast&>(socket_address)[1]); + auto result = static_cast(::sendto(static_cast(handle), &buffer.data()[offset], size, flags, reinterpret_cast(socket_address.data()), static_cast(socket_address.size()))); + swap(const_cast&>(socket_address)[0], const_cast&>(socket_address)[1]); return result; } -int_least32_t socket::set_blocking(intmax_t handle, bool blocking) { +int32_t socket::set_blocking(intmax_t handle, bool blocking) { auto result = -1; - if ((result = fcntl(static_cast(handle), F_GETFL, 0)) != -1) { + if ((result = fcntl(static_cast(handle), F_GETFL, 0)) != -1) { auto flags = result; if (blocking == true) flags &= ~O_NONBLOCK; else flags |= O_NONBLOCK; - result = fcntl(static_cast(handle), F_SETFL, flags) == -1 ? -1 : 0; + result = fcntl(static_cast(handle), F_SETFL, flags) == -1 ? -1 : 0; } return result; } -int_least32_t socket::set_raw_socket_option(intmax_t handle, int_least32_t socket_option_level, int_least32_t socket_option_name, intmax_t option, size_t option_length) { - return setsockopt(static_cast(handle), socket_option_level, socket_option_name, reinterpret_cast(option), static_cast(option_length)); +int32_t socket::set_raw_socket_option(intmax_t handle, int32_t socket_option_level, int32_t socket_option_name, intmax_t option, size_t option_length) { + return setsockopt(static_cast(handle), socket_option_level, socket_option_name, reinterpret_cast(option), static_cast(option_length)); } -int_least32_t socket::set_socket_option(intmax_t handle, int_least32_t socket_option_level, int_least32_t socket_option_name, intmax_t option, size_t option_length) { +int32_t socket::set_socket_option(intmax_t handle, int32_t socket_option_level, int32_t socket_option_name, intmax_t option, size_t option_length) { if (socket_option_name_to_native(socket_option_name) == -1) { errno = ENOTSUP; return -1; } if (socket_option_level == SOCKET_OPTION_LEVEL_SOCKET && (socket_option_name == SOCKET_OPTION_NAME_SEND_TIMEOUT || socket_option_name == SOCKET_OPTION_NAME_RECEIVE_TIMEOUT)) { - auto timeout = timeval {*reinterpret_cast(option) / 1000, *reinterpret_cast(option) % 1000 * 1000}; - return ::setsockopt(static_cast(handle), socket_option_level_to_native(socket_option_level), socket_option_name_to_native(socket_option_name), &timeout, sizeof(timeval)); + auto timeout = timeval {*reinterpret_cast(option) / 1000, *reinterpret_cast(option) % 1000 * 1000}; + return ::setsockopt(static_cast(handle), socket_option_level_to_native(socket_option_level), socket_option_name_to_native(socket_option_name), &timeout, sizeof(timeval)); } - return setsockopt(static_cast(handle), socket_option_level_to_native(socket_option_level), socket_option_name_to_native(socket_option_name), reinterpret_cast(option), static_cast(option_length)); + return setsockopt(static_cast(handle), socket_option_level_to_native(socket_option_level), socket_option_name_to_native(socket_option_name), reinterpret_cast(option), static_cast(option_length)); } -int_least32_t socket::set_socket_linger_option(intmax_t handle, bool enabled, uint_least32_t linger_time) { - auto l = linger {static_cast(enabled), static_cast(linger_time)}; - return setsockopt(static_cast(handle), SOL_SOCKET, SO_LINGER, &l, static_cast(sizeof(linger))); +int32_t socket::set_socket_linger_option(intmax_t handle, bool enabled, uint32_t linger_time) { + auto l = linger {static_cast(enabled), static_cast(linger_time)}; + return setsockopt(static_cast(handle), SOL_SOCKET, SO_LINGER, &l, static_cast(sizeof(linger))); } -int_least32_t socket::set_socket_multicast_option(intmax_t handle, int_least32_t socket_option_name, uint_least32_t multicast_address, uint_least32_t interface_index) { +int32_t socket::set_socket_multicast_option(intmax_t handle, int32_t socket_option_name, uint32_t multicast_address, uint32_t interface_index) { struct multicast { - uint_least32_t multicast_address; - uint_least32_t interface_index; + uint32_t multicast_address; + uint32_t interface_index; } m {multicast_address, interface_index}; - return setsockopt(static_cast(handle), IPPROTO_TCP, socket_option_name_to_native(socket_option_name), &m, static_cast(sizeof(multicast))); + return setsockopt(static_cast(handle), IPPROTO_TCP, socket_option_name_to_native(socket_option_name), &m, static_cast(sizeof(multicast))); } -int_least32_t socket::set_socket_ip_v6_multicast_option(intmax_t handle, int_least32_t socket_option_name, const vector& multicast_address, uint_least32_t interface_index) { +int32_t socket::set_socket_ip_v6_multicast_option(intmax_t handle, int32_t socket_option_name, const vector& multicast_address, uint32_t interface_index) { struct multicast { - uint_least8_t multicast_address[16]; - uint_least32_t interface_index; + uint8_t multicast_address[16]; + uint32_t interface_index; } m; for (auto index = 0u; index < multicast_address.size(); ++index) m.multicast_address[index] = multicast_address[index]; m.interface_index = interface_index; - return setsockopt(static_cast(handle), IPPROTO_IP, socket_option_name_to_native(socket_option_name), &m, static_cast(sizeof(multicast))); + return setsockopt(static_cast(handle), IPPROTO_IP, socket_option_name_to_native(socket_option_name), &m, static_cast(sizeof(multicast))); } -int_least32_t socket::shutdown(intmax_t handle, int_least32_t how) { - auto result = ::shutdown(static_cast(handle), how); +int32_t socket::shutdown(intmax_t handle, int32_t how) { + auto result = ::shutdown(static_cast(handle), how); if (how == SOCKET_SHUTDOWN_BOTH && result == -1 && errno == ENOTCONN) { errno = 0; result = 0; diff --git a/src/xtd.core.native.macos/src/xtd/native/macos/speech_synthesizer.mm b/src/xtd.core.native.macos/src/xtd/native/macos/speech_synthesizer.mm index d582029ced5..d08912d2870 100644 --- a/src/xtd.core.native.macos/src/xtd/native/macos/speech_synthesizer.mm +++ b/src/xtd.core.native.macos/src/xtd/native/macos/speech_synthesizer.mm @@ -66,7 +66,7 @@ static string get_unique_speak_cmd_file_name() { void speech_synthesizer::speak_async(intmax_t handle, const string& text_to_speak, std::function on_speak_completed) { reinterpret_cast(handle)->process_handle = native::process::shell_execute("", reinterpret_cast(handle)->say_cmd_file_name, text_to_speak, "", PROCESS_WINDOW_STYLE_HIDDEN); auto wait_process_thread = thread {[on_speak_completed, handle] { - int_least32_t exit_code = 0; + int32_t exit_code = 0; native::process::wait(reinterpret_cast(handle)->process_handle, exit_code); on_speak_completed(); }}; diff --git a/src/xtd.core.native.macos/src/xtd/native/macos/system_sound.mm b/src/xtd.core.native.macos/src/xtd/native/macos/system_sound.mm index 0c56045fbc3..a61e3679a84 100644 --- a/src/xtd.core.native.macos/src/xtd/native/macos/system_sound.mm +++ b/src/xtd.core.native.macos/src/xtd/native/macos/system_sound.mm @@ -10,10 +10,10 @@ using namespace std; using namespace xtd::native; -void system_sound::play(uint_least32_t sound) { +void system_sound::play(uint32_t sound) { if (sound == ST_BEEP || sound == ST_OK) NSBeep(); else @autoreleasepool { - static auto sounds = map {{ST_ICONERROR, "Funk"}, {ST_ICONQUESTION, "Purr"}, {ST_ICONWARNING, "Hero"}, {ST_ICONASTERISK, "Glass"}}; + static auto sounds = map {{ST_ICONERROR, "Funk"}, {ST_ICONQUESTION, "Purr"}, {ST_ICONWARNING, "Hero"}, {ST_ICONASTERISK, "Glass"}}; [[NSSound soundNamed:[NSString stringWithUTF8String:sounds[sound].c_str()]] play]; } } diff --git a/src/xtd.core.native.macos/src/xtd/native/macos/thread.mm b/src/xtd.core.native.macos/src/xtd/native/macos/thread.mm index 00c84aebede..c3640ed259b 100644 --- a/src/xtd.core.native.macos/src/xtd/native/macos/thread.mm +++ b/src/xtd.core.native.macos/src/xtd/native/macos/thread.mm @@ -14,7 +14,7 @@ return pthread_cancel(reinterpret_cast(handle)) == 0; } -intmax_t thread::create(std::function start, intmax_t obj, int_least32_t max_stack_size, bool suspended, intmax_t& id) { +intmax_t thread::create(std::function start, intmax_t obj, int32_t max_stack_size, bool suspended, intmax_t& id) { auto thread = pthread_t {}; int error = pthread_create(&thread, nullptr, [](void* thread_arg)->void* { auto start_obj = reinterpret_cast, intmax_t>*>(thread_arg); @@ -57,18 +57,18 @@ return true; } -bool thread::set_priority(intmax_t handle, int_least32_t priority) { +bool thread::set_priority(intmax_t handle, int32_t priority) { if (reinterpret_cast(handle) == PTHREAD_FAILED) return false; auto policy = 0; auto schedParam = sched_param {}; if (::pthread_getschedparam(reinterpret_cast(handle), &policy, &schedParam) != 0) return false; - schedParam.sched_priority = static_cast(std::ceil((static_cast(priority) * (sched_get_priority_max(policy) - sched_get_priority_min(policy)) / 4) + sched_get_priority_min(policy))); + schedParam.sched_priority = static_cast(std::ceil((static_cast(priority) * (sched_get_priority_max(policy) - sched_get_priority_min(policy)) / 4) + sched_get_priority_min(policy))); return pthread_setschedparam(reinterpret_cast(handle), policy, &schedParam) == 0; } -void thread::sleep(int_least32_t milliseconds_timeout) { +void thread::sleep(int32_t milliseconds_timeout) { auto infinite_sleep = [] {while (true) std::this_thread::sleep_for(std::chrono::hours::max());}; if (milliseconds_timeout == -1) infinite_sleep(); else if (milliseconds_timeout == 0) yield(); diff --git a/src/xtd.core.native.macos/src/xtd/native/macos/unnamed_event_wait_handle.mm b/src/xtd.core.native.macos/src/xtd/native/macos/unnamed_event_wait_handle.mm index 13e6198207c..492e9907179 100644 --- a/src/xtd.core.native.macos/src/xtd/native/macos/unnamed_event_wait_handle.mm +++ b/src/xtd.core.native.macos/src/xtd/native/macos/unnamed_event_wait_handle.mm @@ -44,7 +44,7 @@ return true; } -uint_least32_t unnamed_event_wait_handle::wait(intmax_t handle, int_least32_t milliseconds_timeout, bool manual_reset) { +uint32_t unnamed_event_wait_handle::wait(intmax_t handle, int32_t milliseconds_timeout, bool manual_reset) { if (reinterpret_cast(handle) == SEM_FAILED) return 0xFFFFFFFF; auto result = milliseconds_timeout == -1 ? sem_wait(reinterpret_cast(handle)) : sem_milliseconds_timedwait(reinterpret_cast(handle), milliseconds_timeout); if (result && errno == EAGAIN) return 0xFFFFFFFF; diff --git a/src/xtd.core.native.macos/src/xtd/native/macos/unnamed_mutex.mm b/src/xtd.core.native.macos/src/xtd/native/macos/unnamed_mutex.mm index 3955e2bbac5..5fd27ccf32b 100644 --- a/src/xtd.core.native.macos/src/xtd/native/macos/unnamed_mutex.mm +++ b/src/xtd.core.native.macos/src/xtd/native/macos/unnamed_mutex.mm @@ -34,7 +34,7 @@ return !io_error; } -uint_least32_t unnamed_mutex::wait(intmax_t handle, int_least32_t milliseconds_timeout) { +uint32_t unnamed_mutex::wait(intmax_t handle, int32_t milliseconds_timeout) { if (reinterpret_cast(handle) == MUTEX_FAILED) return 0xFFFFFFFF; auto result = milliseconds_timeout == -1 ? pthread_mutex_unlock(reinterpret_cast(handle)) : pthread_mutex_milliseconds_timedlock(reinterpret_cast(handle), milliseconds_timeout); if (result && errno == EAGAIN) return 0xFFFFFFFF; diff --git a/src/xtd.core.native.macos/src/xtd/native/macos/unnamed_semaphore.mm b/src/xtd.core.native.macos/src/xtd/native/macos/unnamed_semaphore.mm index 43e6efd955f..336c2c6a8a2 100644 --- a/src/xtd.core.native.macos/src/xtd/native/macos/unnamed_semaphore.mm +++ b/src/xtd.core.native.macos/src/xtd/native/macos/unnamed_semaphore.mm @@ -11,7 +11,7 @@ using namespace xtd::native; -intmax_t unnamed_semaphore::create(int_least32_t initial_count, int_least32_t maximum_count) { +intmax_t unnamed_semaphore::create(int32_t initial_count, int32_t maximum_count) { auto semaphore = semaphore_t {}; if (semaphore_create(current_task(), &semaphore, SYNC_POLICY_FIFO, std::min(initial_count, maximum_count)) != err_none) return reinterpret_cast(SEM_FAILED); @@ -23,7 +23,7 @@ semaphore_destroy(current_task(), static_cast(handle)); } -bool unnamed_semaphore::signal(intmax_t handle, int_least32_t release_count, int_least32_t& previous_count, bool& io_error) { +bool unnamed_semaphore::signal(intmax_t handle, int32_t release_count, int32_t& previous_count, bool& io_error) { io_error = false; if (reinterpret_cast(handle) == SEM_FAILED) { io_error = true; @@ -36,7 +36,7 @@ return !io_error; } -uint_least32_t unnamed_semaphore::wait(intmax_t handle, int_least32_t milliseconds_timeout) { +uint32_t unnamed_semaphore::wait(intmax_t handle, int32_t milliseconds_timeout) { if (reinterpret_cast(handle) == SEM_FAILED) return 0xFFFFFFFF; auto result = milliseconds_timeout == -1 ? sem_wait(reinterpret_cast(handle)) : sem_milliseconds_timedwait(reinterpret_cast(handle), milliseconds_timeout); if (result && errno == EAGAIN) return 0xFFFFFFFF; diff --git a/src/xtd.core.native.posix/include/xtd/native/posix/mutex.h b/src/xtd.core.native.posix/include/xtd/native/posix/mutex.h index a466f21c17f..f382f59fe48 100644 --- a/src/xtd.core.native.posix/include/xtd/native/posix/mutex.h +++ b/src/xtd.core.native.posix/include/xtd/native/posix/mutex.h @@ -11,7 +11,7 @@ inline static const pthread_mutex_t* MUTEX_FAILED = reinterpret_cast(-1); -static inline int pthread_mutex_milliseconds_timedlock(pthread_mutex_t* mut, int_least32_t milliseconds_timeout) { +static inline int pthread_mutex_milliseconds_timedlock(pthread_mutex_t* mut, int32_t milliseconds_timeout) { struct timespec timeout; clock_gettime(CLOCK_REALTIME, &timeout); timeout.tv_sec += milliseconds_timeout / 1000; diff --git a/src/xtd.core.native.posix/include/xtd/native/posix/semaphore.h b/src/xtd.core.native.posix/include/xtd/native/posix/semaphore.h index c7d37af387f..ee9af4a8593 100644 --- a/src/xtd.core.native.posix/include/xtd/native/posix/semaphore.h +++ b/src/xtd.core.native.posix/include/xtd/native/posix/semaphore.h @@ -11,7 +11,7 @@ inline static constexpr size_t PSEMNAMLEN = 31; -static inline int sem_milliseconds_timedwait(sem_t *sem, int_least32_t milliseconds_timeout) { +static inline int sem_milliseconds_timedwait(sem_t *sem, int32_t milliseconds_timeout) { struct timespec timeout; clock_gettime(CLOCK_REALTIME, &timeout); timeout.tv_sec += milliseconds_timeout / 1000; diff --git a/src/xtd.core.native.posix/include/xtd/native/posix/strings.h b/src/xtd.core.native.posix/include/xtd/native/posix/strings.h index 245786ec1b5..809e71ccd68 100644 --- a/src/xtd.core.native.posix/include/xtd/native/posix/strings.h +++ b/src/xtd.core.native.posix/include/xtd/native/posix/strings.h @@ -135,7 +135,7 @@ namespace xtd::native::posix { return result; } - static bool try_parse(const std::string& str, int_least32_t& value) noexcept { + static bool try_parse(const std::string& str, int32_t& value) noexcept { try { value = std::atoi(str.c_str()); return true; diff --git a/src/xtd.core.native.posix/src/xtd/native/posix/condition_variable.cpp b/src/xtd.core.native.posix/src/xtd/native/posix/condition_variable.cpp index 242d57e4e73..a3d97f88ffc 100644 --- a/src/xtd.core.native.posix/src/xtd/native/posix/condition_variable.cpp +++ b/src/xtd.core.native.posix/src/xtd/native/posix/condition_variable.cpp @@ -31,7 +31,7 @@ void condition_variable::pulse_all(intmax_t handle) { pthread_cond_broadcast(reinterpret_cast(handle)); } -bool condition_variable::wait(intmax_t handle, intmax_t critical_section_handle, int_least32_t milliseconds_timeout) { +bool condition_variable::wait(intmax_t handle, intmax_t critical_section_handle, int32_t milliseconds_timeout) { if (handle == reinterpret_cast(MUTEX_FAILED)) return false; if (reinterpret_cast(critical_section_handle) == nullptr) return false; diff --git a/src/xtd.core.native.posix/src/xtd/native/posix/console.cpp b/src/xtd.core.native.posix/src/xtd/native/posix/console.cpp index 1956b2e2ddf..0a9fa94c8db 100644 --- a/src/xtd.core.native.posix/src/xtd/native/posix/console.cpp +++ b/src/xtd.core.native.posix/src/xtd/native/posix/console.cpp @@ -20,8 +20,8 @@ using namespace xtd::native; namespace { auto treat_control_c_as_input = false; - auto signal_couter_ = std::vector {}; - auto user_cancel_callback = std::function {}; + auto signal_couter_ = std::vector {}; + auto user_cancel_callback = std::function {}; struct console_intercept_signals { private: @@ -35,14 +35,14 @@ namespace { ::signal(signal.first, SIG_DFL); } - static void signal_handler(int_least32_t signal) { + static void signal_handler(int32_t signal) { ::signal(signal, console_intercept_signals::signal_handler); if (treat_control_c_as_input) signal_couter_.push_back(signal_keys_[signal]); else if (user_cancel_callback && user_cancel_callback(signal_keys_[signal]) == false) exit(EXIT_FAILURE); } // The SIGINT signal catcher conflicts with with xtd::environment::cancel_interrupt signal... - inline static std::map signal_keys_ {{SIGQUIT, CONSOLE_SPECIAL_KEY_CTRL_BS}, {SIGTSTP, CONSOLE_SPECIAL_KEY_CTRL_Z}/*, {SIGINT, CONSOLE_SPECIAL_KEY_CTRL_C}*/}; + inline static std::map signal_keys_ {{SIGQUIT, CONSOLE_SPECIAL_KEY_CTRL_BS}, {SIGTSTP, CONSOLE_SPECIAL_KEY_CTRL_Z}/*, {SIGINT, CONSOLE_SPECIAL_KEY_CTRL_C}*/}; static console_intercept_signals console_intercept_signals_; }; @@ -68,7 +68,7 @@ namespace { return tcsetattr(0, TCSANOW, &status) == 0; } - int_least32_t getch() { + int32_t getch() { if (peek_character != -1) { auto character = peek_character; peek_character = -1; @@ -145,7 +145,7 @@ namespace { } - int_least8_t peek_character {-1}; + int8_t peek_character {-1}; std::vector statuses; }; @@ -156,8 +156,8 @@ namespace { class input_list { public: input_list() {} - explicit input_list(const std::list& chars) : chars(chars) {} - explicit input_list(std::initializer_list il) : chars(il) {} + explicit input_list(const std::list& chars) : chars(chars) {} + explicit input_list(std::initializer_list il) : chars(il) {} input_list(const input_list& il) : chars(il.chars) {} input_list& operator =(const input_list& il) { @@ -168,8 +168,8 @@ namespace { bool operator ==(const input_list& il) const noexcept {return chars == il.chars;} bool operator !=(const input_list& il) const noexcept {return chars != il.chars;} - using const_iterator = std::list::const_iterator; - using iterator = std::list::iterator; + using const_iterator = std::list::const_iterator; + using iterator = std::list::iterator; const_iterator cbegin() const {return chars.begin();} const_iterator cend() const {return chars.end();} @@ -178,11 +178,11 @@ namespace { const_iterator end() const {return chars.end();} iterator end() {return chars.end();} - void add(int_least32_t c) {chars.push_back(c);} - void add_front(int_least32_t c) {chars.push_front(c);} - void remove(int_least32_t c) {chars.remove(c);} - int_least32_t count() const {return static_cast(chars.size());} - int_least32_t pop() { int_least32_t c = chars.front(); chars.erase(chars.begin()); return c;} + void add(int32_t c) {chars.push_back(c);} + void add_front(int32_t c) {chars.push_front(c);} + void remove(int32_t c) {chars.remove(c);} + int32_t count() const {return static_cast(chars.size());} + int32_t pop() { int32_t c = chars.front(); chars.erase(chars.begin()); return c;} void clear() {chars.clear();} bool is_empty() const {return chars.empty();} @@ -215,7 +215,7 @@ namespace { } private: - std::list chars; + std::list chars; }; key_info(const key_info& ki) : key_(ki.key_), key_char_(ki.key_char_), has_alt_modifier_(ki.has_alt_modifier_), has_control_modifier_(ki.has_control_modifier_), has_shift_modifier_(ki.has_shift_modifier_) {} @@ -268,18 +268,18 @@ namespace { std::string to_string() const { auto result = std::stringstream {}; - result << "{key=" << std::hex << static_cast(key_) << ", key_char=" << std::dec << static_cast(key_char_) << ", has_alt_modifier=" << to_string(has_alt_modifier_) << ", has_control_modifier=" << to_string(has_control_modifier_) << ", has_shift_modifier=" << to_string(has_shift_modifier_) << "}"; + result << "{key=" << std::hex << static_cast(key_) << ", key_char=" << std::dec << static_cast(key_char_) << ", has_alt_modifier=" << to_string(has_alt_modifier_) << ", has_control_modifier=" << to_string(has_control_modifier_) << ", has_shift_modifier=" << to_string(has_shift_modifier_) << "}"; return result.str(); } private: key_info() : key_(U'0'), key_char_(U'0'), has_alt_modifier_(false), has_control_modifier_(false), has_shift_modifier_(false) {} - key_info(int_least32_t key, int_least32_t key_char) : key_(key), key_char_(key_char), has_alt_modifier_(false), has_control_modifier_(false), has_shift_modifier_(false) {} - key_info(int_least32_t key, int_least32_t key_char, bool has_alt_modifier, bool has_control_modifier, bool has_shift_modifier) : key_(key), key_char_(key_char), has_alt_modifier_(has_alt_modifier), has_control_modifier_(has_control_modifier), has_shift_modifier_(has_shift_modifier) {} + key_info(int32_t key, int32_t key_char) : key_(key), key_char_(key_char), has_alt_modifier_(false), has_control_modifier_(false), has_shift_modifier_(false) {} + key_info(int32_t key, int32_t key_char, bool has_alt_modifier, bool has_control_modifier, bool has_shift_modifier) : key_(key), key_char_(key_char), has_alt_modifier_(has_alt_modifier), has_control_modifier_(has_control_modifier), has_shift_modifier_(has_shift_modifier) {} static std::string to_string(bool b) {return b ? "true" : "false";} - static int_least32_t to_key(input_list& inputs) { + static int32_t to_key(input_list& inputs) { auto result = 0; auto index = 1; for (auto c : inputs) @@ -288,11 +288,11 @@ namespace { return result; } - static key_info to_key_info(int_least32_t key) { + static key_info to_key_info(int32_t key) { return to_key_info(key, false); } - static key_info to_key_info(int_least32_t key, bool alt) { + static key_info to_key_info(int32_t key, bool alt) { // Ctrl + Space if (key == 0) return key_info {' ', ' ', false, true, false}; @@ -586,12 +586,12 @@ namespace { auto window_width = 80; } -int_least32_t console::background_color() { +int32_t console::background_color() { return ::background_color; } -bool console::background_color(int_least32_t color) { - static auto colors = std::map {{CONSOLE_COLOR_DEFAULT, "\x1b[49m"}, {CONSOLE_COLOR_BLACK, "\x1b[40m"}, {CONSOLE_COLOR_DARK_BLUE, "\x1b[44m"}, {CONSOLE_COLOR_DARK_GREEN, "\x1b[42m"}, {CONSOLE_COLOR_DARK_CYAN, "\x1b[46m"}, {CONSOLE_COLOR_DARK_RED, "\x1b[41m"}, {CONSOLE_COLOR_DARK_MAGENTA, "\x1b[45m"}, {CONSOLE_COLOR_DARK_YELLOW, "\x1b[43m"}, {CONSOLE_COLOR_GRAY, "\x1b[47m"}, {CONSOLE_COLOR_DARK_GRAY, "\x1b[100m"}, {CONSOLE_COLOR_BLUE, "\x1b[104m"}, {CONSOLE_COLOR_GREEN, "\x1b[102m"}, {CONSOLE_COLOR_CYAN, "\x1b[106m"}, {CONSOLE_COLOR_RED, "\x1b[101m"}, {CONSOLE_COLOR_MAGENTA, "\x1b[105m"}, {CONSOLE_COLOR_YELLOW, "\x1b[103m"}, {CONSOLE_COLOR_WHITE, "\x1b[107m"}}; +bool console::background_color(int32_t color) { + static auto colors = std::map {{CONSOLE_COLOR_DEFAULT, "\x1b[49m"}, {CONSOLE_COLOR_BLACK, "\x1b[40m"}, {CONSOLE_COLOR_DARK_BLUE, "\x1b[44m"}, {CONSOLE_COLOR_DARK_GREEN, "\x1b[42m"}, {CONSOLE_COLOR_DARK_CYAN, "\x1b[46m"}, {CONSOLE_COLOR_DARK_RED, "\x1b[41m"}, {CONSOLE_COLOR_DARK_MAGENTA, "\x1b[45m"}, {CONSOLE_COLOR_DARK_YELLOW, "\x1b[43m"}, {CONSOLE_COLOR_GRAY, "\x1b[47m"}, {CONSOLE_COLOR_DARK_GRAY, "\x1b[100m"}, {CONSOLE_COLOR_BLUE, "\x1b[104m"}, {CONSOLE_COLOR_GREEN, "\x1b[102m"}, {CONSOLE_COLOR_CYAN, "\x1b[106m"}, {CONSOLE_COLOR_RED, "\x1b[101m"}, {CONSOLE_COLOR_MAGENTA, "\x1b[105m"}, {CONSOLE_COLOR_YELLOW, "\x1b[103m"}, {CONSOLE_COLOR_WHITE, "\x1b[107m"}}; auto it = colors.find(color); if (it == colors.end()) return false; ::background_color = color; @@ -599,10 +599,10 @@ bool console::background_color(int_least32_t color) { return true; } -bool console::beep(uint_least32_t frequency, uint_least32_t duration) { +bool console::beep(uint32_t frequency, uint32_t duration) { if (frequency < 37 || frequency > 32767) return false; - static constexpr uint_least32_t simple_rate = 8000; + static constexpr uint32_t simple_rate = 8000; static snd_pcm_t* pcm_handle = nullptr; if (pcm_handle == nullptr) { if (snd_pcm_open(&pcm_handle, "default", SND_PCM_STREAM_PLAYBACK, 0)) return false; @@ -610,9 +610,9 @@ bool console::beep(uint_least32_t frequency, uint_least32_t duration) { } unsigned char buffer[2400]; - for (uint_least32_t duration_index = 0; duration_index < duration / 200; ++duration_index) { + for (uint32_t duration_index = 0; duration_index < duration / 200; ++duration_index) { snd_pcm_prepare(pcm_handle); - for (uint_least32_t buffer_index = 0; buffer_index < sizeof(buffer); ++buffer_index) + for (uint32_t buffer_index = 0; buffer_index < sizeof(buffer); ++buffer_index) buffer[buffer_index] = frequency > 0 ? (255 * buffer_index * frequency / simple_rate) : 0; snd_pcm_sframes_t written_frames = snd_pcm_writei(pcm_handle, buffer, sizeof(buffer)); if (written_frames < 0) snd_pcm_recover(pcm_handle, written_frames, 0); @@ -620,29 +620,29 @@ bool console::beep(uint_least32_t frequency, uint_least32_t duration) { return true; } -bool console::beep(uint_least32_t frequency, uint_least32_t duration) { +bool console::beep(uint32_t frequency, uint32_t duration) { return audio::beep(frequency, duration); } -int_least32_t console::buffer_height() { +int32_t console::buffer_height() { /// @todo console buffer Height on linux and macOS if (::buffer_height == -1) ::buffer_height = console::window_height(); return ::buffer_height; } -bool console::buffer_height(int_least32_t height) { +bool console::buffer_height(int32_t height) { /// @todo set console buffer height on linux and macOS ::buffer_height = height; return true; } -int_least32_t console::buffer_width() { +int32_t console::buffer_width() { /// @todo console buffer Width on linux and macOS if (::buffer_width == -1) ::buffer_width = console::window_width(); return ::buffer_width; } -bool console::buffer_width(int_least32_t width) { +bool console::buffer_width(int32_t width) { /// @todo set console buffer width on linux and macOS ::buffer_width = width; return true; @@ -658,7 +658,7 @@ bool console::clear() { return set_cursor_position(0, 0); } -int_least32_t console::cursor_left() { +int32_t console::cursor_left() { if (!terminal::is_ansi_supported()) return ::cursor_left; std::cout << "\x1b[6n" << std::flush; terminal::terminal_.getch(); @@ -671,11 +671,11 @@ int_least32_t console::cursor_left() { return ::cursor_left; } -int_least32_t console::cursor_size() { +int32_t console::cursor_size() { return ::cursor_size; } -bool console::cursor_size(int_least32_t size) { +bool console::cursor_size(int32_t size) { ::cursor_size = size; if (!terminal::is_ansi_supported()) return true; if (size < 50) std::cout << "\x1b[4 q" << std::flush; @@ -683,7 +683,7 @@ bool console::cursor_size(int_least32_t size) { return true; } -int_least32_t console::cursor_top() { +int32_t console::cursor_top() { if (!terminal::is_ansi_supported()) return ::cursor_top; std::cout << "\x1b[6n" << std::flush; terminal::terminal_.getch(); @@ -706,7 +706,7 @@ bool console::cursor_visible(bool visible) { return true; } -int_least32_t console::foreground_color() { +int32_t console::foreground_color() { return ::foreground_color; } @@ -714,8 +714,8 @@ bool console::echo(bool on) { return terminal::terminal_.echo(on); } -bool console::foreground_color(int_least32_t color) { - static auto colors = std::map {{CONSOLE_COLOR_DEFAULT, "\x1b[39m"}, {CONSOLE_COLOR_BLACK, "\x1b[30m"}, {CONSOLE_COLOR_DARK_BLUE, "\x1b[34m"}, {CONSOLE_COLOR_DARK_GREEN, "\x1b[32m"}, {CONSOLE_COLOR_DARK_CYAN, "\x1b[36m"}, {CONSOLE_COLOR_DARK_RED, "\x1b[31m"}, {CONSOLE_COLOR_DARK_MAGENTA, "\x1b[35m"}, {CONSOLE_COLOR_DARK_YELLOW, "\x1b[33m"}, {CONSOLE_COLOR_GRAY, "\x1b[37m"}, {CONSOLE_COLOR_DARK_GRAY, "\x1b[90m"}, {CONSOLE_COLOR_BLUE, "\x1b[94m"}, {CONSOLE_COLOR_GREEN, "\x1b[92m"}, {CONSOLE_COLOR_CYAN, "\x1b[96m"}, {CONSOLE_COLOR_RED, "\x1b[91m"}, {CONSOLE_COLOR_MAGENTA, "\x1b[95m"}, {CONSOLE_COLOR_YELLOW, "\x1b[93m"}, {CONSOLE_COLOR_WHITE, "\x1b[97m"}}; +bool console::foreground_color(int32_t color) { + static auto colors = std::map {{CONSOLE_COLOR_DEFAULT, "\x1b[39m"}, {CONSOLE_COLOR_BLACK, "\x1b[30m"}, {CONSOLE_COLOR_DARK_BLUE, "\x1b[34m"}, {CONSOLE_COLOR_DARK_GREEN, "\x1b[32m"}, {CONSOLE_COLOR_DARK_CYAN, "\x1b[36m"}, {CONSOLE_COLOR_DARK_RED, "\x1b[31m"}, {CONSOLE_COLOR_DARK_MAGENTA, "\x1b[35m"}, {CONSOLE_COLOR_DARK_YELLOW, "\x1b[33m"}, {CONSOLE_COLOR_GRAY, "\x1b[37m"}, {CONSOLE_COLOR_DARK_GRAY, "\x1b[90m"}, {CONSOLE_COLOR_BLUE, "\x1b[94m"}, {CONSOLE_COLOR_GREEN, "\x1b[92m"}, {CONSOLE_COLOR_CYAN, "\x1b[96m"}, {CONSOLE_COLOR_RED, "\x1b[91m"}, {CONSOLE_COLOR_MAGENTA, "\x1b[95m"}, {CONSOLE_COLOR_YELLOW, "\x1b[93m"}, {CONSOLE_COLOR_WHITE, "\x1b[97m"}}; auto it = colors.find(color); if (it == colors.end()) return false; ::foreground_color = color; @@ -723,12 +723,12 @@ bool console::foreground_color(int_least32_t color) { return true; } -int_least32_t console::input_code_page() { +int32_t console::input_code_page() { /// @todo console input code page status on linux and macOS return ::input_code_page; } -bool console::input_code_page(int_least32_t code_page) { +bool console::input_code_page(int32_t code_page) { /// @todo set console input code page on linux and macOS ::input_code_page = code_page; return true; @@ -738,11 +738,11 @@ bool console::key_available() { return key_info::key_available(); } -int_least32_t console::largest_window_height() { +int32_t console::largest_window_height() { return ::largest_window_height; } -int_least32_t console::largest_window_width() { +int32_t console::largest_window_width() { return ::largest_window_width; } @@ -751,12 +751,12 @@ bool console::number_lock() { return ::number_lock; } -int_least32_t console::output_code_page() { +int32_t console::output_code_page() { /// @todo console output code page status on linux and macOS return ::output_code_page; } -bool console::output_code_page(int_least32_t code_page) { +bool console::output_code_page(int32_t code_page) { /// @todo set console output code page on linux and macOS ::output_code_page = code_page; return true; @@ -771,7 +771,7 @@ void console::read_key(char32_t& key_char, char32_t& key_code, bool& alt, bool& shift = key_info.has_shift_modifier(); } -void console::register_user_cancel_callback(std::function user_cancel_callback) { +void console::register_user_cancel_callback(std::function user_cancel_callback) { ::user_cancel_callback = user_cancel_callback; } @@ -779,7 +779,7 @@ bool console::reset_color() { return console::background_color(CONSOLE_COLOR_DEFAULT) && console::foreground_color(CONSOLE_COLOR_DEFAULT); } -bool console::set_cursor_position(int_least32_t left, int_least32_t top) { +bool console::set_cursor_position(int32_t left, int32_t top) { ::cursor_left = left; ::cursor_top = top; if (terminal::is_ansi_supported()) std::cout << "\x1b[" << top + 1 << ";" << left + 1 << "f" << std::flush; @@ -816,7 +816,7 @@ bool console::treat_control_c_as_input(bool treat_control_c_as_input) { return true; } -int_least32_t console::window_height() { +int32_t console::window_height() { if (!terminal::is_ansi_supported()) return ::window_height; auto top = console::cursor_top(); console::set_cursor_position(console::cursor_left(), 999); @@ -826,35 +826,35 @@ int_least32_t console::window_height() { return ::window_height; } -bool console::window_height(int_least32_t height) { +bool console::window_height(int32_t height) { /// @todo set console window height on linux and macOS ::window_height = height; return true; } -int_least32_t console::window_left() { +int32_t console::window_left() { /// @todo get console window left on linux and macOS return ::window_left; } -bool console::window_left(int_least32_t left) { +bool console::window_left(int32_t left) { /// @todo set console window left on linux and macOS ::window_left = left; return true; } -int_least32_t console::window_top() { +int32_t console::window_top() { /// @todo get console window top on linux and macOS return ::window_top; } -bool console::window_top(int_least32_t top) { +bool console::window_top(int32_t top) { /// @todo set console window top on linux and macOS ::window_top = top; return true; } -int_least32_t console::window_width() { +int32_t console::window_width() { if (!terminal::is_ansi_supported()) return ::window_width; auto left = console::cursor_left(); console::set_cursor_position(999, console::cursor_top()); @@ -864,7 +864,7 @@ int_least32_t console::window_width() { return ::window_width; } -bool console::window_width(int_least32_t width) { +bool console::window_width(int32_t width) { /// @todo set console window width on linux and macOS ::window_width = width; return true; diff --git a/src/xtd.core.native.posix/src/xtd/native/posix/cryptography.cpp b/src/xtd.core.native.posix/src/xtd/native/posix/cryptography.cpp index dae6b19c2b0..ba760273e6f 100644 --- a/src/xtd.core.native.posix/src/xtd/native/posix/cryptography.cpp +++ b/src/xtd.core.native.posix/src/xtd/native/posix/cryptography.cpp @@ -22,7 +22,7 @@ namespace { } } -vector cryptography::machine_guid() { +vector cryptography::machine_guid() { static auto first = true; static auto guid_str = create_process("ioreg -rd1 -c IOPlatformExpertDevice | grep -E '(UUID)'"); if (first) guid_str = guid_str.substr(guid_str.find("=") + 1); @@ -34,8 +34,8 @@ vector cryptography::machine_guid() { if (hex_chars.find(static_cast(toupper(guid_str[index]))) == hex_chars.npos) guid_str.erase(index--, 1); if (guid_str.size() != 32) guid_str = guid_fallback; - auto bytes = vector {}; + auto bytes = vector {}; for (auto index = 0u; index < guid_str.size(); index += 2) - bytes.push_back(static_cast(stoi(guid_str.substr(index, 2), 0, 16))); + bytes.push_back(static_cast(stoi(guid_str.substr(index, 2), 0, 16))); return bytes; } diff --git a/src/xtd.core.native.posix/src/xtd/native/posix/date_time.cpp b/src/xtd.core.native.posix/src/xtd/native/posix/date_time.cpp index aa05eb06210..6ca480ed0d0 100644 --- a/src/xtd.core.native.posix/src/xtd/native/posix/date_time.cpp +++ b/src/xtd.core.native.posix/src/xtd/native/posix/date_time.cpp @@ -13,7 +13,7 @@ using namespace std; using namespace xtd::native; namespace { - static const int_least64_t ticks_per_second = 10000000; + static const int64_t ticks_per_second = 10000000; /* Generate by this c# code source : @@ -240,7 +240,7 @@ date_time::time_zone_info date_time::get_local_time_zone() { if (iterator != stzis.end()) { local_time_zone = *iterator; local_time_zone.id = reinterpret_cast(tzname[0]); - local_time_zone.base_utc_offset = static_cast(-timezone * ticks_per_second); + local_time_zone.base_utc_offset = static_cast(-timezone * ticks_per_second); local_time_zone.daylight_name = reinterpret_cast(tzname[1]); local_time_zone.display_name = string_printf("(UTC%s%02d:%02d) %s", (-timezone) ? "+" : "", abs(timezone) / 3600, (abs(timezone) % 3600) / 60, reinterpret_cast(tzname[0])); local_time_zone.standard_name = reinterpret_cast(tzname[0]); diff --git a/src/xtd.core.native.posix/src/xtd/native/posix/debugger.cpp b/src/xtd.core.native.posix/src/xtd/native/posix/debugger.cpp index 5dcd6f62962..640eb6612a6 100644 --- a/src/xtd.core.native.posix/src/xtd/native/posix/debugger.cpp +++ b/src/xtd.core.native.posix/src/xtd/native/posix/debugger.cpp @@ -44,7 +44,7 @@ bool debugger::launch() { return true; } -int_least32_t debugger::show_assert_dialog(const std::string& text, const std::string& caption) { +int32_t debugger::show_assert_dialog(const std::string& text, const std::string& caption) { gtk_init_check(0, nullptr); auto dialog = gtk_message_dialog_new(nullptr, GtkDialogFlags::GTK_DIALOG_MODAL, GtkMessageType::GTK_MESSAGE_ERROR, GtkButtonsType::GTK_BUTTONS_NONE, "%s", text.c_str()); gtk_window_set_title(GTK_WINDOW(dialog), caption.c_str()); @@ -56,7 +56,7 @@ int_least32_t debugger::show_assert_dialog(const std::string& text, const std::s return return_code == GTK_RESPONSE_YES ? ADR_ABORT : (return_code == GTK_RESPONSE_NO ? ADR_RETRY : ADR_IGNORE); } -void debugger::log(int_least32_t level, const std::string& category, const std::string& message) { +void debugger::log(int32_t level, const std::string& category, const std::string& message) { syslog(LOG_EMERG | LOG_USER, "%s", message.c_str()); std::cerr << message << std::flush; } diff --git a/src/xtd.core.native.posix/src/xtd/native/posix/directory.cpp b/src/xtd.core.native.posix/src/xtd/native/posix/directory.cpp index 61a141b9fb2..4e84d533b1b 100644 --- a/src/xtd.core.native.posix/src/xtd/native/posix/directory.cpp +++ b/src/xtd.core.native.posix/src/xtd/native/posix/directory.cpp @@ -60,7 +60,7 @@ directory::directory_iterator& directory::directory_iterator::operator ++() { return *this; } -directory::directory_iterator directory::directory_iterator::operator ++(int_least32_t) { +directory::directory_iterator directory::directory_iterator::operator ++(int32_t) { auto result = directory_iterator {*this}; ++(*this); return result; @@ -130,7 +130,7 @@ directory::file_iterator& directory::file_iterator::operator ++() { return *this; } -directory::file_iterator directory::file_iterator::operator ++(int_least32_t) { +directory::file_iterator directory::file_iterator::operator ++(int32_t) { auto result = file_iterator {*this}; ++(*this); return result; @@ -200,7 +200,7 @@ directory::file_and_directory_iterator& directory::file_and_directory_iterator:: return *this; } -directory::file_and_directory_iterator directory::file_and_directory_iterator::operator ++(int_least32_t) { +directory::file_and_directory_iterator directory::file_and_directory_iterator::operator ++(int32_t) { auto result = file_and_directory_iterator {*this}; ++(*this); return result; @@ -231,7 +231,7 @@ const std::string& directory::file_and_directory_iterator::pattern() const { return data_->pattern_; } -int_least32_t directory::create(const std::string& directory_name) { +int32_t directory::create(const std::string& directory_name) { return mkdir(directory_name.c_str(), S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IXGRP | S_IROTH | S_IWOTH | S_IXOTH); } @@ -260,10 +260,10 @@ string directory::get_current_directory() { return result ? path : ""; } -int_least32_t directory::remove(const std::string& directory_name) { +int32_t directory::remove(const std::string& directory_name) { return rmdir(directory_name.c_str()); } -int_least32_t directory::set_current_directory(const std::string& directory_name) { +int32_t directory::set_current_directory(const std::string& directory_name) { return chdir(directory_name.c_str()); } diff --git a/src/xtd.core.native.posix/src/xtd/native/posix/dns.cpp b/src/xtd.core.native.posix/src/xtd/native/posix/dns.cpp index 11a8c807bc8..786e849a665 100644 --- a/src/xtd.core.native.posix/src/xtd/native/posix/dns.cpp +++ b/src/xtd.core.native.posix/src/xtd/native/posix/dns.cpp @@ -24,9 +24,9 @@ void dns::destroy(intmax_t host) { delete reinterpret_cast(host); } -intmax_t dns::get_host_by_address(const string& host_address, int_least32_t host_address_type) { +intmax_t dns::get_host_by_address(const string& host_address, int32_t host_address_type) { auto lock = lock_guard {dns_mutex}; - auto internet_address = int_least64_t {0}; + auto internet_address = int64_t {0}; inet_pton(host_address_type, host_address.c_str(), &internet_address); auto host = gethostbyaddr(reinterpret_cast(&internet_address), host_address_type == ADDRESS_FAMILY_INTER_NETWORK ? 4 : 16, host_address_type); if (host == nullptr) return 0; @@ -48,11 +48,11 @@ vector dns::get_aliases(intmax_t host) { return aliases; } -vector> dns::get_addresses(intmax_t host) { - auto addresses = vector> {}; +vector> dns::get_addresses(intmax_t host) { + auto addresses = vector> {}; auto index = size_t {0}; while (reinterpret_cast(host)->h_addr_list[index] != nullptr) { - addresses.emplace_back(reinterpret_cast(reinterpret_cast(host)->h_addr_list[index]), reinterpret_cast(reinterpret_cast(host)->h_addr_list[index]) + (reinterpret_cast(host)->h_addrtype == ADDRESS_FAMILY_INTER_NETWORK ? 4 : 16)); + addresses.emplace_back(reinterpret_cast(reinterpret_cast(host)->h_addr_list[index]), reinterpret_cast(reinterpret_cast(host)->h_addr_list[index]) + (reinterpret_cast(host)->h_addrtype == ADDRESS_FAMILY_INTER_NETWORK ? 4 : 16)); index++; } return addresses; @@ -62,7 +62,7 @@ string dns::get_host_name(intmax_t host) { return reinterpret_cast(host)->h_name; } -int_least32_t dns::get_host_name(string& host_name) { +int32_t dns::get_host_name(string& host_name) { auto name_length = static_cast(sysconf(_SC_HOST_NAME_MAX)); auto name = string(name_length, '\0'); auto result = gethostname(name.data(), name_length); diff --git a/src/xtd.core.native.posix/src/xtd/native/posix/drive.cpp b/src/xtd.core.native.posix/src/xtd/native/posix/drive.cpp index 34dfa80b5e2..a5a109d4a00 100644 --- a/src/xtd.core.native.posix/src/xtd/native/posix/drive.cpp +++ b/src/xtd.core.native.posix/src/xtd/native/posix/drive.cpp @@ -34,7 +34,7 @@ bool drive::get_available_free_space(const std::string& root_path_name, size_t& return true; } -int_least32_t drive::get_drive_type(const std::string& root_path_name) { +int32_t drive::get_drive_type(const std::string& root_path_name) { if (root_drive == root_path_name) return DRIVE_FIXED; if (find(ram_drives.begin(), ram_drives.end(), root_path_name) != ram_drives.end()) return DRIVE_RAMDISK; if (find(network_drives.begin(), network_drives.end(), root_path_name) != network_drives.end()) return DRIVE_REMOTE; diff --git a/src/xtd.core.native.posix/src/xtd/native/posix/environment.cpp b/src/xtd.core.native.posix/src/xtd/native/posix/environment.cpp index c798b3bf5a6..05f95df68be 100644 --- a/src/xtd.core.native.posix/src/xtd/native/posix/environment.cpp +++ b/src/xtd.core.native.posix/src/xtd/native/posix/environment.cpp @@ -16,7 +16,7 @@ using namespace std::literals; using namespace xtd::native; extern char** environ; -int_least32_t __environment_argc = 0; +int32_t __environment_argc = 0; char** __environment_argv; namespace { @@ -33,7 +33,7 @@ namespace { return result; } - __attribute__((constructor)) void startup_program(int_least32_t argc, char** argv) { + __attribute__((constructor)) void startup_program(int32_t argc, char** argv) { __environment_argc = argc; __environment_argv = argv; } @@ -55,7 +55,7 @@ namespace { } } -int_least32_t environment::at_quick_exit(void (*on_quick_exit)(void)) { +int32_t environment::at_quick_exit(void (*on_quick_exit)(void)) { return std::at_quick_exit(on_quick_exit); } @@ -124,7 +124,7 @@ string environment::get_distribution_name() { return name_it->second; } -void environment::get_distribution_version(int_least32_t& major, int_least32_t& minor, int_least32_t& build, int_least32_t& revision) { +void environment::get_distribution_version(int32_t& major, int32_t& minor, int32_t& build, int32_t& revision) { auto name_it = get_distribution_key_values().find("VERSION_ID"); if (name_it == get_distribution_key_values().end()) return; auto versions = xtd::native::posix::strings::split(name_it->second, {'.'}); @@ -138,7 +138,7 @@ string environment::get_distribution_version_string() { return iterator->second; } -string environment::get_environment_variable(const string& variable, int_least32_t target) { +string environment::get_environment_variable(const string& variable, int32_t target) { if (target == ENVIRONMENT_VARIABLE_TARGET_PROCESS) { auto value = getenv(variable.c_str()); return value ? value : ""; @@ -152,7 +152,7 @@ string environment::get_environment_variable(const string& variable, int_least32 return ""; } -map& environment::get_environment_variables(int_least32_t target) { +map& environment::get_environment_variables(int32_t target) { if (target == ENVIRONMENT_VARIABLE_TARGET_PROCESS) { static auto envs = map {}; if (envs.size() == 0) { @@ -178,8 +178,8 @@ map& environment::get_environment_variables(int_least32_t target return envs; } -string environment::get_know_folder_path(int_least32_t csidl) { - static auto special_folders = map {{CSIDL_DESKTOP, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS) + "/Desktop"}, {CSIDL_PERSONAL, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS)}, {CSIDL_MYMUSIC, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS) + "/Music"}, {CSIDL_MYVIDEO, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS) + "/Videos"}, {CSIDL_DESKTOPDIRECTORY, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS) + "/Desktop"}, {CSIDL_FONTS, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS) + "/.fonts"}, {CSIDL_TEMPLATES, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS) + "/Templates"}, {CSIDL_APPDATA, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS) + "/.config"}, {CSIDL_LOCAL_APPDATA, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS) + "/.local/share"}, {CSIDL_COMMON_APPDATA, "/usr/share"}, {CSIDL_MYPICTURES, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS) + "/Pictures"}, {CSIDL_PROFILE, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS)}, {CSIDL_COMMON_TEMPLATES, "/usr/share/templates"}, {CSIDL_HOME, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS)}}; +string environment::get_know_folder_path(int32_t csidl) { + static auto special_folders = map {{CSIDL_DESKTOP, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS) + "/Desktop"}, {CSIDL_PERSONAL, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS)}, {CSIDL_MYMUSIC, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS) + "/Music"}, {CSIDL_MYVIDEO, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS) + "/Videos"}, {CSIDL_DESKTOPDIRECTORY, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS) + "/Desktop"}, {CSIDL_FONTS, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS) + "/.fonts"}, {CSIDL_TEMPLATES, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS) + "/Templates"}, {CSIDL_APPDATA, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS) + "/.config"}, {CSIDL_LOCAL_APPDATA, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS) + "/.local/share"}, {CSIDL_COMMON_APPDATA, "/usr/share"}, {CSIDL_MYPICTURES, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS) + "/Pictures"}, {CSIDL_PROFILE, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS)}, {CSIDL_COMMON_TEMPLATES, "/usr/share/templates"}, {CSIDL_HOME, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS)}}; auto it = special_folders.find(csidl); if (it == special_folders.end()) return ""; return it->second; @@ -189,13 +189,13 @@ string environment::get_machine_name() { return posix::strings::replace(create_process("uname -n"), "\n", ""); } -int_least32_t environment::get_os_platform_id() { +int32_t environment::get_os_platform_id() { if (create_process("uname -a").find("MINGW") != string::npos) return PLATFORM_MINGW; if (create_process("uname -a").find("MSYS") != string::npos) return PLATFORM_MSYS; return PLATFORM_UNIX; } -void environment::get_os_version(int_least32_t& major, int_least32_t& minor, int_least32_t& build, int_least32_t& revision) { +void environment::get_os_version(int32_t& major, int32_t& minor, int32_t& build, int32_t& revision) { auto numbers = posix::strings::split(create_process("uname -r"), {'.', '-', '\n'}); if (numbers.size() < 1 || !posix::strings::try_parse(numbers[0], major)) major = 0; if (numbers.size() < 2 || !posix::strings::try_parse(numbers[1], minor)) minor = 0; @@ -203,7 +203,7 @@ void environment::get_os_version(int_least32_t& major, int_least32_t& minor, int if (numbers.size() < 4 || !posix::strings::try_parse(numbers[3], revision)) revision = 0; } -uint_least32_t environment::get_processor_count() { +uint32_t environment::get_processor_count() { return thread::hardware_concurrency(); } @@ -221,7 +221,7 @@ size_t environment::get_system_page_size() { return sysconf(_SC_PAGESIZE); } -uint_least32_t environment::get_tick_count() { +uint32_t environment::get_tick_count() { // https://stackoverflow.com/questions/1540627/what-api-do-i-call-to-get-the-system-uptime struct sysinfo info {}; sysinfo(&info); @@ -261,11 +261,11 @@ string environment::new_line() { return "\n"; } -void environment::quick_exit(int_least32_t exit_code) noexcept { +void environment::quick_exit(int32_t exit_code) noexcept { std::quick_exit(exit_code); } -void environment::set_environment_variable(const string& name, const string& value, int_least32_t target) { +void environment::set_environment_variable(const string& name, const string& value, int32_t target) { if (target == ENVIRONMENT_VARIABLE_TARGET_PROCESS) setenv(name.c_str(), value.c_str(), 1); else if (target == ENVIRONMENT_VARIABLE_TARGET_USER) { @@ -275,7 +275,7 @@ void environment::set_environment_variable(const string& name, const string& val } } -void environment::unset_environment_variable(const string& name, int_least32_t target) { +void environment::unset_environment_variable(const string& name, int32_t target) { if (target == ENVIRONMENT_VARIABLE_TARGET_PROCESS) unsetenv(name.c_str()); else if (target == ENVIRONMENT_VARIABLE_TARGET_USER) { @@ -285,6 +285,6 @@ void environment::unset_environment_variable(const string& name, int_least32_t t } } -int_least64_t environment::working_set() { +int64_t environment::working_set() { return 0; } diff --git a/src/xtd.core.native.posix/src/xtd/native/posix/file.cpp b/src/xtd.core.native.posix/src/xtd/native/posix/file.cpp index 3da8d5d9d56..65268c759e4 100644 --- a/src/xtd.core.native.posix/src/xtd/native/posix/file.cpp +++ b/src/xtd.core.native.posix/src/xtd/native/posix/file.cpp @@ -11,7 +11,7 @@ using namespace std; using namespace xtd::native; -int_least32_t file::copy(const std::string& source_file, const std::string& target_file) { +int32_t file::copy(const std::string& source_file, const std::string& target_file) { auto ifs = ifstream {source_file, ios::binary}; if (!ifs) return -1; auto ofs = ofstream {target_file, ios::trunc | ios::binary}; @@ -33,12 +33,12 @@ size_t file::get_size(const std::string& path) { return static_cast(status.st_size); } -int_least32_t file::move(const std::string& old_path, const std::string& new_path) { +int32_t file::move(const std::string& old_path, const std::string& new_path) { auto file_attributes = 0; if (file_system::get_attributes(new_path, file_attributes) == 0) return -1; return rename(old_path.c_str(), new_path.c_str()); } -int_least32_t file::remove(const std::string& file) { +int32_t file::remove(const std::string& file) { return unlink(file.c_str()); } diff --git a/src/xtd.core.native.posix/src/xtd/native/posix/file_system.cpp b/src/xtd.core.native.posix/src/xtd/native/posix/file_system.cpp index 091cbc28866..ab9b911cac1 100644 --- a/src/xtd.core.native.posix/src/xtd/native/posix/file_system.cpp +++ b/src/xtd.core.native.posix/src/xtd/native/posix/file_system.cpp @@ -18,10 +18,10 @@ using namespace std; using namespace xtd::native; -int_least32_t file_system::get_attributes(const std::string& path, int_least32_t& attributes) { +int32_t file_system::get_attributes(const std::string& path, int32_t& attributes) { struct system_attribute_to_file_attribute_converter { - int_least32_t operator()(int_least32_t attribute) { - int_least32_t file_attributes = 0; + int32_t operator()(int32_t attribute) { + int32_t file_attributes = 0; if ((attribute & S_IRUSR) == S_IRUSR && (attribute & S_IWUSR) != S_IWUSR) file_attributes |= FILE_ATTRIBUTE_READONLY; if ((attribute & S_IFSOCK) == S_IFSOCK || (attribute & S_IFIFO) == S_IFIFO) file_attributes |= FILE_ATTRIBUTE_SYSTEM; if ((attribute & S_IFDIR) == S_IFDIR) file_attributes |= FILE_ATTRIBUTE_DIRECTORY; @@ -37,7 +37,7 @@ int_least32_t file_system::get_attributes(const std::string& path, int_least32_t return 0; } -int_least32_t file_system::get_file_times(const std::string& path, time_t& creation_time, time_t& last_access_time, time_t& last_write_time) { +int32_t file_system::get_file_times(const std::string& path, time_t& creation_time, time_t& last_access_time, time_t& last_write_time) { struct stat status; if (stat(path.c_str(), &status) != 0) return -1; @@ -73,10 +73,10 @@ string file_system::get_full_path(const string& relative_path) { return full_path; } -int_least32_t file_system::get_permissions(const std::string& path, int_least32_t& permissions) { +int32_t file_system::get_permissions(const std::string& path, int32_t& permissions) { struct system_permission_to_file_permission_converter { - int_least32_t operator()(mode_t permission) { - int_least32_t file_permissions = 0; + int32_t operator()(mode_t permission) { + int32_t file_permissions = 0; if ((permission & S_IRUSR) == S_IRUSR) file_permissions |= FILE_PERMISSIONS_OWNER_READ; if ((permission & S_IWUSR) == S_IWUSR) file_permissions |= FILE_PERMISSIONS_OWNER_WRITE; if ((permission & S_IXUSR) == S_IXUSR) file_permissions |= FILE_PERMISSIONS_OWNER_EXECUTE; @@ -99,7 +99,7 @@ int_least32_t file_system::get_permissions(const std::string& path, int_least32_ } }; struct stat s; - int_least32_t ret_value = stat(path.c_str(), &s); + int32_t ret_value = stat(path.c_str(), &s); permissions = system_permission_to_file_permission_converter()(s.st_mode); return ret_value; } @@ -113,7 +113,7 @@ bool file_system::is_path_too_long(const std::string& path) { return file_name.size() > NAME_MAX; } -int_least32_t file_system::set_attributes(const std::string& path, int_least32_t attributes) { +int32_t file_system::set_attributes(const std::string& path, int32_t attributes) { struct stat s; if (stat(path.c_str(), &s) != 0) return -1; @@ -127,7 +127,7 @@ int_least32_t file_system::set_attributes(const std::string& path, int_least32_t return chmod(path.c_str(), s.st_mode); } -int_least32_t file_system::set_creation_time(const std::string& path, time_t creation_time) { +int32_t file_system::set_creation_time(const std::string& path, time_t creation_time) { // There is no creation time on linux so we update the last modification time instead... utimbuf times; time_t creation_time_old = 0, last_access_time = 0, last_write_time = 0; @@ -137,7 +137,7 @@ int_least32_t file_system::set_creation_time(const std::string& path, time_t cre return utime(path.c_str(), ×); } -int_least32_t file_system::set_last_access_time(const std::string& path, time_t last_access_time) { +int32_t file_system::set_last_access_time(const std::string& path, time_t last_access_time) { utimbuf times; time_t creation_time = 0, last_access_time_old = 0, last_write_time = 0; get_file_times(path, creation_time, last_access_time_old, last_write_time); @@ -146,7 +146,7 @@ int_least32_t file_system::set_last_access_time(const std::string& path, time_t return utime(path.c_str(), ×); } -int_least32_t file_system::set_last_write_time(const std::string& path, time_t last_write_time) { +int32_t file_system::set_last_write_time(const std::string& path, time_t last_write_time) { utimbuf times; time_t creation_time = 0, last_access_time = 0, last_write_time_old = 0; get_file_times(path, creation_time, last_access_time, last_write_time_old); @@ -155,10 +155,10 @@ int_least32_t file_system::set_last_write_time(const std::string& path, time_t l return utime(path.c_str(), ×); } -int_least32_t file_system::set_permissions(const std::string& path, int_least32_t permissions) { +int32_t file_system::set_permissions(const std::string& path, int32_t permissions) { struct file_permission_to_system_permission_converter { - mode_t operator()(int_least32_t permission) { - int_least32_t system_permissions = 0; + mode_t operator()(int32_t permission) { + int32_t system_permissions = 0; if ((permission & FILE_PERMISSIONS_OWNER_READ) == FILE_PERMISSIONS_OWNER_READ) system_permissions |= S_IRUSR; if ((permission & FILE_PERMISSIONS_OWNER_WRITE) == FILE_PERMISSIONS_OWNER_WRITE) system_permissions |= S_IWUSR; if ((permission & FILE_PERMISSIONS_OWNER_EXECUTE) == FILE_PERMISSIONS_OWNER_EXECUTE) system_permissions |= S_IXUSR; diff --git a/src/xtd.core.native.posix/src/xtd/native/posix/guid.cpp b/src/xtd.core.native.posix/src/xtd/native/posix/guid.cpp index d13c8531e08..0bcb5371758 100644 --- a/src/xtd.core.native.posix/src/xtd/native/posix/guid.cpp +++ b/src/xtd.core.native.posix/src/xtd/native/posix/guid.cpp @@ -8,8 +8,8 @@ using namespace xtd::native; -std::vector guid::new_guid() { - auto guid = std::vector(16); +std::vector guid::new_guid() { + auto guid = std::vector(16); uuid_generate(guid.data()); return guid; } diff --git a/src/xtd.core.native.posix/src/xtd/native/posix/interlocked.cpp b/src/xtd.core.native.posix/src/xtd/native/posix/interlocked.cpp index b3f4f4288e9..5ea9044feaa 100644 --- a/src/xtd.core.native.posix/src/xtd/native/posix/interlocked.cpp +++ b/src/xtd.core.native.posix/src/xtd/native/posix/interlocked.cpp @@ -12,21 +12,21 @@ using namespace std; using namespace xtd::native; -int_least32_t interlocked::add(int_least32_t& location, int_least32_t value) { +int32_t interlocked::add(int32_t& location, int32_t value) { __sync_fetch_and_add(&location, value); return location; } -int_least64_t interlocked::add(int_least64_t& location, int_least64_t value) { +int64_t interlocked::add(int64_t& location, int64_t value) { __sync_fetch_and_add(&location, value); return location; } -int_least32_t interlocked::compare_exchange(int_least32_t& location, int_least32_t value, int_least32_t comparand) { +int32_t interlocked::compare_exchange(int32_t& location, int32_t value, int32_t comparand) { return __sync_val_compare_and_swap(&location, comparand, value); } -int_least64_t interlocked::compare_exchange(int_least64_t& location, int_least64_t value, int_least64_t comparand) { +int64_t interlocked::compare_exchange(int64_t& location, int64_t value, int64_t comparand) { return __sync_val_compare_and_swap(&location, comparand, value); } @@ -38,21 +38,21 @@ void* interlocked::compare_exchange(void*& location, void* value, void* comparan return __sync_val_compare_and_swap(&location, comparand, value); } -int_least32_t interlocked::decrement(int_least32_t& location) { +int32_t interlocked::decrement(int32_t& location) { __sync_fetch_and_sub(&location, 1); return location; } -int_least64_t interlocked::decrement(int_least64_t& location) { +int64_t interlocked::decrement(int64_t& location) { __sync_fetch_and_sub(&location, 1); return location; } -int_least32_t interlocked::exchange(int_least32_t& location, int_least32_t value) { +int32_t interlocked::exchange(int32_t& location, int32_t value) { return __sync_val_compare_and_swap(&location, location, value); } -int_least64_t interlocked::exchange(int_least64_t& location, int_least64_t value) { +int64_t interlocked::exchange(int64_t& location, int64_t value) { return __sync_val_compare_and_swap(&location, location, value); } @@ -64,12 +64,12 @@ void* interlocked::exchange(void*& location, void* value) { return __sync_val_compare_and_swap(&location, location, value); } -int_least32_t interlocked::increment(int_least32_t& location) { +int32_t interlocked::increment(int32_t& location) { __sync_fetch_and_add(&location, 1); return location; } -int_least64_t interlocked::increment(int_least64_t& location) { +int64_t interlocked::increment(int64_t& location) { __sync_fetch_and_add(&location, 1); return location; } diff --git a/src/xtd.core.native.posix/src/xtd/native/posix/named_event_wait_handle.cpp b/src/xtd.core.native.posix/src/xtd/native/posix/named_event_wait_handle.cpp index 0e12eaaedf5..0c259576dfe 100644 --- a/src/xtd.core.native.posix/src/xtd/native/posix/named_event_wait_handle.cpp +++ b/src/xtd.core.native.posix/src/xtd/native/posix/named_event_wait_handle.cpp @@ -47,7 +47,7 @@ bool named_event_wait_handle::reset(intmax_t handle, bool& io_error) { return true; } -uint_least32_t named_event_wait_handle::wait(intmax_t handle, int_least32_t milliseconds_timeout, bool manual_reset) { +uint32_t named_event_wait_handle::wait(intmax_t handle, int32_t milliseconds_timeout, bool manual_reset) { if (reinterpret_cast(handle) == SEM_FAILED) return 0xFFFFFFFF; auto result = milliseconds_timeout == -1 ? sem_wait(reinterpret_cast(handle)) : sem_milliseconds_timedwait(reinterpret_cast(handle), milliseconds_timeout); if (result && errno == EAGAIN) return 0xFFFFFFFF; diff --git a/src/xtd.core.native.posix/src/xtd/native/posix/named_mutex.cpp b/src/xtd.core.native.posix/src/xtd/native/posix/named_mutex.cpp index 74ad1e08e45..95d056cafdc 100644 --- a/src/xtd.core.native.posix/src/xtd/native/posix/named_mutex.cpp +++ b/src/xtd.core.native.posix/src/xtd/native/posix/named_mutex.cpp @@ -36,7 +36,7 @@ bool named_mutex::signal(intmax_t handle, bool& io_error) { return !io_error; } -uint_least32_t named_mutex::wait(intmax_t handle, int_least32_t milliseconds_timeout) { +uint32_t named_mutex::wait(intmax_t handle, int32_t milliseconds_timeout) { if (reinterpret_cast(handle) == SEM_FAILED) return 0xFFFFFFFF; auto result = milliseconds_timeout == -1 ? sem_wait(reinterpret_cast(handle)) : sem_milliseconds_timedwait(reinterpret_cast(handle), milliseconds_timeout); if (result && errno == EAGAIN) return 0xFFFFFFFF; diff --git a/src/xtd.core.native.posix/src/xtd/native/posix/named_semaphore.cpp b/src/xtd.core.native.posix/src/xtd/native/posix/named_semaphore.cpp index b0760f57c4f..cf2f49f2447 100644 --- a/src/xtd.core.native.posix/src/xtd/native/posix/named_semaphore.cpp +++ b/src/xtd.core.native.posix/src/xtd/native/posix/named_semaphore.cpp @@ -9,7 +9,7 @@ using namespace xtd::native; -intmax_t named_semaphore::create(int_least32_t initial_count, int_least32_t max_count, const std::string& name) { +intmax_t named_semaphore::create(int32_t initial_count, int32_t max_count, const std::string& name) { auto semaphore = sem_open(name.c_str(), O_CREAT | O_EXCL, S_IRUSR | S_IWUSR, std::min(initial_count, max_count)); return reinterpret_cast(semaphore); } @@ -28,7 +28,7 @@ intmax_t named_semaphore::open(const std::string& name) { return reinterpret_cast(semaphore); } -bool named_semaphore::signal(intmax_t handle, int_least32_t release_count, int_least32_t& previous_count, bool& io_error) { +bool named_semaphore::signal(intmax_t handle, int32_t release_count, int32_t& previous_count, bool& io_error) { io_error = false; if (reinterpret_cast(handle) == SEM_FAILED) { io_error = true; @@ -41,7 +41,7 @@ bool named_semaphore::signal(intmax_t handle, int_least32_t release_count, int_l return !io_error; } -uint_least32_t named_semaphore::wait(intmax_t handle, int_least32_t milliseconds_timeout) { +uint32_t named_semaphore::wait(intmax_t handle, int32_t milliseconds_timeout) { if (reinterpret_cast(handle) == SEM_FAILED) return 0xFFFFFFFF; auto result = milliseconds_timeout == -1 ? sem_wait(reinterpret_cast(handle)) : sem_milliseconds_timedwait(reinterpret_cast(handle), milliseconds_timeout); if (result && errno == EAGAIN) return 0xFFFFFFFF; diff --git a/src/xtd.core.native.posix/src/xtd/native/posix/process.cpp b/src/xtd.core.native.posix/src/xtd/native/posix/process.cpp index 9af06d6a43e..097cc9799ff 100644 --- a/src/xtd.core.native.posix/src/xtd/native/posix/process.cpp +++ b/src/xtd.core.native.posix/src/xtd/native/posix/process.cpp @@ -23,11 +23,11 @@ using namespace xtd::native; namespace { class file_descriptor_streambuf : public streambuf { public: - explicit file_descriptor_streambuf(int_least32_t file_descriptor) : file_descriptor_(file_descriptor) {} + explicit file_descriptor_streambuf(int32_t file_descriptor) : file_descriptor_(file_descriptor) {} ~file_descriptor_streambuf() {close(file_descriptor_);} protected: - int_least32_t underflow() override { + int32_t underflow() override { if (read(file_descriptor_, &value_, 1) == 1) { this->setg(&value_, &value_, &value_ + 1); return value_; @@ -35,7 +35,7 @@ namespace { return streambuf::underflow(); // EOF } - int_least32_t overflow(int_least32_t c) override { + int32_t overflow(int32_t c) override { value_ = static_cast(c); if (write(file_descriptor_, &value_, 1) != -1) { this->setp(&value_, &value_); @@ -44,13 +44,13 @@ namespace { return streambuf::overflow(c); // EOF } - int_least32_t file_descriptor_; + int32_t file_descriptor_; char value_ = EOF; }; class process_istream : public istream { public: - explicit process_istream(int_least32_t file_descriptor) : istream(&stream_buf_), stream_buf_(file_descriptor) {} + explicit process_istream(int32_t file_descriptor) : istream(&stream_buf_), stream_buf_(file_descriptor) {} private: file_descriptor_streambuf stream_buf_; @@ -58,7 +58,7 @@ namespace { class process_ostream : public ostream { public: - explicit process_ostream(int_least32_t file_descriptor) : ostream(&stream_buf_), stream_buf_(file_descriptor) {} + explicit process_ostream(int32_t file_descriptor) : ostream(&stream_buf_), stream_buf_(file_descriptor) {} private: file_descriptor_streambuf stream_buf_; @@ -103,8 +103,8 @@ namespace { vector arguments; bool skip_next_space = false; bool quotes_empty = false; - int_least32_t left_space_count = 0; - int_least32_t right_space_count = 0; + int32_t left_space_count = 0; + int32_t right_space_count = 0; string argument; for (size_t index = 0; index < line_argument.size(); index++) { @@ -138,8 +138,8 @@ namespace { return arguments; } - bool compute_base_priority(int_least32_t priority, int_least32_t& base_priority) { - static map base_priorities {{IDLE_PRIORITY_CLASS, PRIO_MIN}, {BELOW_NORMAL_PRIORITY_CLASS, PRIO_MIN + (PRIO_MAX - PRIO_MIN) / 4}, {NORMAL_PRIORITY_CLASS, PRIO_MIN + (PRIO_MAX - PRIO_MIN) / 2}, {ABOVE_NORMAL_PRIORITY_CLASS, PRIO_MAX - (PRIO_MAX - PRIO_MIN) / 4}, {HIGH_PRIORITY_CLASS, PRIO_MAX - (PRIO_MAX - PRIO_MIN) / 8}, {REALTIME_PRIORITY_CLASS, PRIO_MAX}}; + bool compute_base_priority(int32_t priority, int32_t& base_priority) { + static map base_priorities {{IDLE_PRIORITY_CLASS, PRIO_MIN}, {BELOW_NORMAL_PRIORITY_CLASS, PRIO_MIN + (PRIO_MAX - PRIO_MIN) / 4}, {NORMAL_PRIORITY_CLASS, PRIO_MIN + (PRIO_MAX - PRIO_MIN) / 2}, {ABOVE_NORMAL_PRIORITY_CLASS, PRIO_MAX - (PRIO_MAX - PRIO_MIN) / 4}, {HIGH_PRIORITY_CLASS, PRIO_MAX - (PRIO_MAX - PRIO_MIN) / 8}, {REALTIME_PRIORITY_CLASS, PRIO_MAX}}; auto it = base_priorities.find(priority); if (it == base_priorities.end()) return false; base_priority = it->second; @@ -147,8 +147,8 @@ namespace { } } -int_least32_t process::base_priority(int_least32_t priority) { - int_least32_t base_priority = PRIO_MIN + (PRIO_MAX - PRIO_MIN) / 2; +int32_t process::base_priority(int32_t priority) { + int32_t base_priority = PRIO_MIN + (PRIO_MAX - PRIO_MIN) / 2; compute_base_priority(priority, base_priority); return base_priority; } @@ -158,13 +158,13 @@ bool process::kill(intmax_t process) { return ::kill(static_cast(process), SIGTERM) == 0; } -bool process::priority_class(intmax_t process, int_least32_t priority) { - int_least32_t base_priority = PRIO_MIN + (PRIO_MAX - PRIO_MIN) / 2; +bool process::priority_class(intmax_t process, int32_t priority) { + int32_t base_priority = PRIO_MIN + (PRIO_MAX - PRIO_MIN) / 2; if (compute_base_priority(priority, base_priority) == false) return false; return setpriority(PRIO_PROCESS, static_cast(process), base_priority) == 0; } -intmax_t process::shell_execute(const std::string& verb, const string& file_name, const string& arguments, const string& working_directory, int_least32_t process_window_style) { +intmax_t process::shell_execute(const std::string& verb, const string& file_name, const string& arguments, const string& working_directory, int32_t process_window_style) { pid_t process = fork(); if (process == 0) { bool is_shell_execute = is_valid_shell_execute_process(&posix::strings::split, file_name, working_directory); @@ -201,15 +201,15 @@ intmax_t process::shell_execute(const std::string& verb, const string& file_name return static_cast(process); } -process::started_process process::start(const string& file_name, const string& arguments, const string& working_directory, int_least32_t process_window_style, int_least32_t process_creation_flags, tuple redirect_standard_streams) { +process::started_process process::start(const string& file_name, const string& arguments, const string& working_directory, int32_t process_window_style, int32_t process_creation_flags, tuple redirect_standard_streams) { auto [redirect_standard_input, redirect_standard_output, redirect_standard_error] = redirect_standard_streams; - int_least32_t pipe_result = 0; - int_least32_t pipe_stdin[2]; + int32_t pipe_result = 0; + int32_t pipe_stdin[2]; if (redirect_standard_input) pipe_result = pipe(pipe_stdin); - int_least32_t pipe_stdout[2]; + int32_t pipe_stdout[2]; if (redirect_standard_output) pipe_result = pipe(pipe_stdout); - int_least32_t pipe_stderr[2]; + int32_t pipe_stderr[2]; if (redirect_standard_error) pipe_result = pipe(pipe_stderr); if (pipe_result) {/*do nothing*/} @@ -248,10 +248,10 @@ process::started_process process::start(const string& file_name, const string& a if (redirect_standard_output) close(pipe_stdout[1]); if (redirect_standard_error) close(pipe_stderr[1]); - return make_tuple(static_cast(process), static_cast(process), make_unique(pipe_stdin[1]), make_unique(pipe_stdout[0]), make_unique(pipe_stderr[0])); + return make_tuple(static_cast(process), static_cast(process), make_unique(pipe_stdin[1]), make_unique(pipe_stdout[0]), make_unique(pipe_stderr[0])); } -bool process::wait(intmax_t process, int_least32_t& exit_code) { +bool process::wait(intmax_t process, int32_t& exit_code) { if (process == 0) return false; siginfo_t wait_info {}; wait_info.si_pid = static_cast(process); diff --git a/src/xtd.core.native.posix/src/xtd/native/posix/socket.cpp b/src/xtd.core.native.posix/src/xtd/native/posix/socket.cpp index 98ea4c2de66..57dedeb3cad 100644 --- a/src/xtd.core.native.posix/src/xtd/native/posix/socket.cpp +++ b/src/xtd.core.native.posix/src/xtd/native/posix/socket.cpp @@ -23,144 +23,144 @@ using namespace std; using namespace xtd::native; namespace { - static int_least32_t native_to_socket_error(int_least32_t error) { - static map socket_errors {{0, SOCKET_ERROR_SUCCESS}, {EINTR, SOCKET_ERROR_INTERRUPTED}, {EACCES, SOCKET_ERROR_ACCESS_DENIED}, {EFAULT, SOCKET_ERROR_FAULT}, {EINVAL, SOCKET_ERROR_INVALID_ARGUMENT}, {EMFILE, SOCKET_ERROR_TOO_MANY_OPEN_SOCKETS}, {EAGAIN, SOCKET_ERROR_WOULD_BLOCK}, {EINPROGRESS, SOCKET_ERROR_IN_PROGRESS}, {EALREADY, SOCKET_ERROR_ALREADY_IN_PROGRESS}, {ENOTSOCK, SOCKET_ERROR_NOT_SOCKET}, {EDESTADDRREQ, SOCKET_ERROR_DESTINATION_ADDRESS_REQUIRED}, {EMSGSIZE, SOCKET_ERROR_MESSAGE_SIZE}, {EPROTOTYPE, SOCKET_ERROR_PROTOCOL_TYPE}, {ENOPROTOOPT, SOCKET_ERROR_PROTOCOL_OPTION}, {EPROTONOSUPPORT, SOCKET_ERROR_PROTOCOL_NOT_SUPPORTED}, {ESOCKTNOSUPPORT, SOCKET_ERROR_SOCKET_NOT_SUPPORTED}, {ENOTSUP, SOCKET_ERROR_OPERATION_NOT_SUPPORTED}, {EPFNOSUPPORT, SOCKET_ERROR_PROTOCOL_FAMILY_NOT_SUPPORTED}, {EAFNOSUPPORT, SOCKET_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED}, {EADDRINUSE, SOCKET_ERROR_ADDRESS_ALREADY_IN_USE}, {EADDRNOTAVAIL, SOCKET_ERROR_ADDRESS_NOT_AVAILABLE}, {ENETDOWN, SOCKET_ERROR_NETWORK_DOWN}, {ENETUNREACH, SOCKET_ERROR_NETWORK_UNREACHABLE}, {ENETRESET, SOCKET_ERROR_NETWORK_RESET}, {ECONNABORTED, SOCKET_ERROR_CONNECTION_ABORTED}, {ECONNRESET, SOCKET_ERROR_CONNECTION_RESET}, {ENOBUFS, SOCKET_ERROR_NO_BUFFER_SPACE_AVAILABLE}, {EISCONN, SOCKET_ERROR_IS_CONNECTED}, {ENOTCONN, SOCKET_ERROR_NOT_CONNECTED}, {ESHUTDOWN, SOCKET_ERROR_SHUTDOWN}, {ETIMEDOUT, SOCKET_ERROR_TIMED_OUT}, {ECONNREFUSED, SOCKET_ERROR_CONNECTION_REFUSED}, {EHOSTDOWN, SOCKET_ERROR_HOST_DOWN}, {EHOSTUNREACH, SOCKET_ERROR_HOST_UNREACHABLE}, {EOPNOTSUPP, SOCKET_ERROR_SOCKET_NOT_SUPPORTED}}; + static int32_t native_to_socket_error(int32_t error) { + static map socket_errors {{0, SOCKET_ERROR_SUCCESS}, {EINTR, SOCKET_ERROR_INTERRUPTED}, {EACCES, SOCKET_ERROR_ACCESS_DENIED}, {EFAULT, SOCKET_ERROR_FAULT}, {EINVAL, SOCKET_ERROR_INVALID_ARGUMENT}, {EMFILE, SOCKET_ERROR_TOO_MANY_OPEN_SOCKETS}, {EAGAIN, SOCKET_ERROR_WOULD_BLOCK}, {EINPROGRESS, SOCKET_ERROR_IN_PROGRESS}, {EALREADY, SOCKET_ERROR_ALREADY_IN_PROGRESS}, {ENOTSOCK, SOCKET_ERROR_NOT_SOCKET}, {EDESTADDRREQ, SOCKET_ERROR_DESTINATION_ADDRESS_REQUIRED}, {EMSGSIZE, SOCKET_ERROR_MESSAGE_SIZE}, {EPROTOTYPE, SOCKET_ERROR_PROTOCOL_TYPE}, {ENOPROTOOPT, SOCKET_ERROR_PROTOCOL_OPTION}, {EPROTONOSUPPORT, SOCKET_ERROR_PROTOCOL_NOT_SUPPORTED}, {ESOCKTNOSUPPORT, SOCKET_ERROR_SOCKET_NOT_SUPPORTED}, {ENOTSUP, SOCKET_ERROR_OPERATION_NOT_SUPPORTED}, {EPFNOSUPPORT, SOCKET_ERROR_PROTOCOL_FAMILY_NOT_SUPPORTED}, {EAFNOSUPPORT, SOCKET_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED}, {EADDRINUSE, SOCKET_ERROR_ADDRESS_ALREADY_IN_USE}, {EADDRNOTAVAIL, SOCKET_ERROR_ADDRESS_NOT_AVAILABLE}, {ENETDOWN, SOCKET_ERROR_NETWORK_DOWN}, {ENETUNREACH, SOCKET_ERROR_NETWORK_UNREACHABLE}, {ENETRESET, SOCKET_ERROR_NETWORK_RESET}, {ECONNABORTED, SOCKET_ERROR_CONNECTION_ABORTED}, {ECONNRESET, SOCKET_ERROR_CONNECTION_RESET}, {ENOBUFS, SOCKET_ERROR_NO_BUFFER_SPACE_AVAILABLE}, {EISCONN, SOCKET_ERROR_IS_CONNECTED}, {ENOTCONN, SOCKET_ERROR_NOT_CONNECTED}, {ESHUTDOWN, SOCKET_ERROR_SHUTDOWN}, {ETIMEDOUT, SOCKET_ERROR_TIMED_OUT}, {ECONNREFUSED, SOCKET_ERROR_CONNECTION_REFUSED}, {EHOSTDOWN, SOCKET_ERROR_HOST_DOWN}, {EHOSTUNREACH, SOCKET_ERROR_HOST_UNREACHABLE}, {EOPNOTSUPP, SOCKET_ERROR_SOCKET_NOT_SUPPORTED}}; auto it = socket_errors.find(error); if (it == socket_errors.end()) return SOCKET_ERROR_SOCKET_ERROR; return it->second; } - static int_least32_t protocol_type_to_native(int_least32_t protocol_type) { - static map protocol_types = {/*{PROTOCOL_TYPE_UNKNOWN, IPPROTO_}, {PROTOCOL_TYPE_IP_V6_HOP_BY_HOP_OPTIONS, IPPROTO_}, {PROTOCOL_TYPE_UNSPECIFIED, IPPROTO_},*/ {PROTOCOL_TYPE_IP, IPPROTO_IP}, {PROTOCOL_TYPE_ICMP, IPPROTO_ICMP}, {PROTOCOL_TYPE_IGMP, IPPROTO_IGMP}, {PROTOCOL_TYPE_GGP, 3 /*IPPROTO_GGP*/}, {PROTOCOL_TYPE_IP_V4, IPPROTO_IPIP}, {PROTOCOL_TYPE_TCP, IPPROTO_TCP}, {PROTOCOL_TYPE_PUP, IPPROTO_PUP}, {PROTOCOL_TYPE_UDP, IPPROTO_UDP}, {PROTOCOL_TYPE_IDP, IPPROTO_IDP}, {PROTOCOL_TYPE_IP_V6, IPPROTO_IPV6}, {PROTOCOL_TYPE_IP_V6_ROUTING_HEADER, IPPROTO_ROUTING}, {PROTOCOL_TYPE_IP_V6_FRAGMENT_HEADER, IPPROTO_FRAGMENT}, {PROTOCOL_TYPE_IP_SEC_ENCAPSULATING_SECURITY_PAYLOAD, IPPROTO_ESP}, {PROTOCOL_TYPE_IP_SEC_AUTHENTICATION_HEADER, IPPROTO_AH}, {PROTOCOL_TYPE_ICMP_V6, IPPROTO_ICMPV6}, {PROTOCOL_TYPE_IP_V6_NO_NEXT_HEADER, IPPROTO_NONE}, {PROTOCOL_TYPE_IP_V6_DESTINATION_OPTIONS, IPPROTO_DSTOPTS}, {PROTOCOL_TYPE_ND, IPPROTO_IP}, {PROTOCOL_TYPE_RAW, IPPROTO_RAW} /*{PROTOCOL_TYPE_IPX, IPPROTO_}, {PROTOCOL_TYPE_SPX, IPPROTO_IP}, {PROTOCOL_TYPE_SPX_2, IPPROTO_},*/}; + static int32_t protocol_type_to_native(int32_t protocol_type) { + static map protocol_types = {/*{PROTOCOL_TYPE_UNKNOWN, IPPROTO_}, {PROTOCOL_TYPE_IP_V6_HOP_BY_HOP_OPTIONS, IPPROTO_}, {PROTOCOL_TYPE_UNSPECIFIED, IPPROTO_},*/ {PROTOCOL_TYPE_IP, IPPROTO_IP}, {PROTOCOL_TYPE_ICMP, IPPROTO_ICMP}, {PROTOCOL_TYPE_IGMP, IPPROTO_IGMP}, {PROTOCOL_TYPE_GGP, 3 /*IPPROTO_GGP*/}, {PROTOCOL_TYPE_IP_V4, IPPROTO_IPIP}, {PROTOCOL_TYPE_TCP, IPPROTO_TCP}, {PROTOCOL_TYPE_PUP, IPPROTO_PUP}, {PROTOCOL_TYPE_UDP, IPPROTO_UDP}, {PROTOCOL_TYPE_IDP, IPPROTO_IDP}, {PROTOCOL_TYPE_IP_V6, IPPROTO_IPV6}, {PROTOCOL_TYPE_IP_V6_ROUTING_HEADER, IPPROTO_ROUTING}, {PROTOCOL_TYPE_IP_V6_FRAGMENT_HEADER, IPPROTO_FRAGMENT}, {PROTOCOL_TYPE_IP_SEC_ENCAPSULATING_SECURITY_PAYLOAD, IPPROTO_ESP}, {PROTOCOL_TYPE_IP_SEC_AUTHENTICATION_HEADER, IPPROTO_AH}, {PROTOCOL_TYPE_ICMP_V6, IPPROTO_ICMPV6}, {PROTOCOL_TYPE_IP_V6_NO_NEXT_HEADER, IPPROTO_NONE}, {PROTOCOL_TYPE_IP_V6_DESTINATION_OPTIONS, IPPROTO_DSTOPTS}, {PROTOCOL_TYPE_ND, IPPROTO_IP}, {PROTOCOL_TYPE_RAW, IPPROTO_RAW} /*{PROTOCOL_TYPE_IPX, IPPROTO_}, {PROTOCOL_TYPE_SPX, IPPROTO_IP}, {PROTOCOL_TYPE_SPX_2, IPPROTO_},*/}; auto it = protocol_types.find(protocol_type); if (it == protocol_types.end()) return IPPROTO_IP; return it->second; } - static int_least32_t socket_option_level_to_native(int_least32_t socket_option_level) { - static map socket_option_levels = {{SOCKET_OPTION_LEVEL_SOCKET, SOL_SOCKET}, {SOCKET_OPTION_LEVEL_IP, IPPROTO_IP}, {SOCKET_OPTION_LEVEL_IP_V6, IPPROTO_IPV6}, {SOCKET_OPTION_LEVEL_TCP, IPPROTO_TCP}, {SOCKET_OPTION_LEVEL_UDP, IPPROTO_UDP}}; + static int32_t socket_option_level_to_native(int32_t socket_option_level) { + static map socket_option_levels = {{SOCKET_OPTION_LEVEL_SOCKET, SOL_SOCKET}, {SOCKET_OPTION_LEVEL_IP, IPPROTO_IP}, {SOCKET_OPTION_LEVEL_IP_V6, IPPROTO_IPV6}, {SOCKET_OPTION_LEVEL_TCP, IPPROTO_TCP}, {SOCKET_OPTION_LEVEL_UDP, IPPROTO_UDP}}; auto it = socket_option_levels.find(socket_option_level); if (it == socket_option_levels.end()) return SOL_SOCKET; return it->second; } - static int_least32_t socket_option_name_to_native(int_least32_t socket_option_name) { - static map socket_option_names = {{SOCKET_OPTION_NAME_DEBUG, SO_DEBUG}, {SOCKET_OPTION_NAME_ACCEPT_CONNECTION, SO_ACCEPTCONN}, {SOCKET_OPTION_NAME_REUSE_ADDRESS, SO_REUSEADDR}, {SOCKET_OPTION_NAME_KEEP_ALIVE, SO_KEEPALIVE}, {SOCKET_OPTION_NAME_DONT_ROUTE, SO_DONTROUTE}, {SOCKET_OPTION_NAME_BROADCAST, SO_BROADCAST}, /*{SOCKET_OPTION_NAME_USE_LOOPBACK, SO_},*/ {SOCKET_OPTION_NAME_LINGER, SO_LINGER}, {SOCKET_OPTION_NAME_EXCLUSIVE_ADDRESS_USE, SO_REUSEADDR}, {SOCKET_OPTION_NAME_OUT_OF_BAND_INLINE, SO_OOBINLINE}, {SOCKET_OPTION_NAME_SEND_BUFFER, SO_SNDBUF}, {SOCKET_OPTION_NAME_RECEIVE_BUFFER, SO_RCVBUF}, {SOCKET_OPTION_NAME_SEND_LOW_WATER, SO_SNDLOWAT}, {SOCKET_OPTION_NAME_RECEIVE_LOW_WATER, SO_RCVLOWAT}, {SOCKET_OPTION_NAME_SEND_TIMEOUT, SO_SNDTIMEO}, {SOCKET_OPTION_NAME_RECEIVE_TIMEOUT, SO_RCVTIMEO}, {SOCKET_OPTION_NAME_ERROR, SO_ERROR}, {SOCKET_OPTION_NAME_TYPE, SO_TYPE}, /*{SOCKET_OPTION_NAME_MAX_CONNECTION, SO_},*/ {SOCKET_OPTION_NAME_IP_OPTIONS, IP_OPTIONS}, {SOCKET_OPTION_NAME_HEADER_INCLUDED, IP_HDRINCL}, {SOCKET_OPTION_NAME_TYPE_OF_SERVICE, IP_TOS}, {SOCKET_OPTION_NAME_IP_TIME_TO_LIVE, IP_TTL}, {SOCKET_OPTION_NAME_MULTICAST_INTERFACE, IP_MULTICAST_IF}, {SOCKET_OPTION_NAME_MULTICAST_TIME_TO_LIVE, IP_MULTICAST_TTL}, {SOCKET_OPTION_NAME_MULTICAST_LOOPBACK, IP_MULTICAST_LOOP}, {SOCKET_OPTION_NAME_ADD_MEMBERSHIP, IP_ADD_MEMBERSHIP}, {SOCKET_OPTION_NAME_DROP_MEMBERSHIP, IP_DROP_MEMBERSHIP}, {SOCKET_OPTION_NAME_DONT_FRAGMENT, IP_NODEFRAG}, {SOCKET_OPTION_NAME_ADD_SOURCE_MEMBERSHIP, IP_ADD_SOURCE_MEMBERSHIP}, {SOCKET_OPTION_NAME_DROP_SOURCE_MEMBERSHIP, IP_DROP_SOURCE_MEMBERSHIP}, {SOCKET_OPTION_NAME_BLOCK_SOURCE, IP_BLOCK_SOURCE}, {SOCKET_OPTION_NAME_UNBLOCK_SOURCE, IP_UNBLOCK_SOURCE}, {SOCKET_OPTION_NAME_PACKET_INFORMATION, IP_PKTINFO}, {SOCKET_OPTION_NAME_HOP_LIMIT, IPV6_HOPLIMIT}, /*{SOCKET_OPTION_NAME_IP_PROTECT_LEVEL, IPV6_},*/ {SOCKET_OPTION_NAME_IP_V6_ONLY, IPV6_V6ONLY}, /*{SOCKET_OPTION_NAME_NO_DELAY, TCP_}, {SOCKET_OPTION_NAME_BSD_URGENT, TCP_}, {SOCKET_OPTION_NAME_EXPEDITED, TCP_}, {SOCKET_OPTION_NAME_NO_CHECKSUM, UDP_}, {SOCKET_OPTION_NAME_CHECKSUM_COVERAGE, ...}, {SOCKET_OPTION_NAME_UPDATE_ACCEPT_CONTEXT, ...}, {SOCKET_OPTION_NAME_UPDATE_CONNECT_CONTEXT, ...},*/}; + static int32_t socket_option_name_to_native(int32_t socket_option_name) { + static map socket_option_names = {{SOCKET_OPTION_NAME_DEBUG, SO_DEBUG}, {SOCKET_OPTION_NAME_ACCEPT_CONNECTION, SO_ACCEPTCONN}, {SOCKET_OPTION_NAME_REUSE_ADDRESS, SO_REUSEADDR}, {SOCKET_OPTION_NAME_KEEP_ALIVE, SO_KEEPALIVE}, {SOCKET_OPTION_NAME_DONT_ROUTE, SO_DONTROUTE}, {SOCKET_OPTION_NAME_BROADCAST, SO_BROADCAST}, /*{SOCKET_OPTION_NAME_USE_LOOPBACK, SO_},*/ {SOCKET_OPTION_NAME_LINGER, SO_LINGER}, {SOCKET_OPTION_NAME_EXCLUSIVE_ADDRESS_USE, SO_REUSEADDR}, {SOCKET_OPTION_NAME_OUT_OF_BAND_INLINE, SO_OOBINLINE}, {SOCKET_OPTION_NAME_SEND_BUFFER, SO_SNDBUF}, {SOCKET_OPTION_NAME_RECEIVE_BUFFER, SO_RCVBUF}, {SOCKET_OPTION_NAME_SEND_LOW_WATER, SO_SNDLOWAT}, {SOCKET_OPTION_NAME_RECEIVE_LOW_WATER, SO_RCVLOWAT}, {SOCKET_OPTION_NAME_SEND_TIMEOUT, SO_SNDTIMEO}, {SOCKET_OPTION_NAME_RECEIVE_TIMEOUT, SO_RCVTIMEO}, {SOCKET_OPTION_NAME_ERROR, SO_ERROR}, {SOCKET_OPTION_NAME_TYPE, SO_TYPE}, /*{SOCKET_OPTION_NAME_MAX_CONNECTION, SO_},*/ {SOCKET_OPTION_NAME_IP_OPTIONS, IP_OPTIONS}, {SOCKET_OPTION_NAME_HEADER_INCLUDED, IP_HDRINCL}, {SOCKET_OPTION_NAME_TYPE_OF_SERVICE, IP_TOS}, {SOCKET_OPTION_NAME_IP_TIME_TO_LIVE, IP_TTL}, {SOCKET_OPTION_NAME_MULTICAST_INTERFACE, IP_MULTICAST_IF}, {SOCKET_OPTION_NAME_MULTICAST_TIME_TO_LIVE, IP_MULTICAST_TTL}, {SOCKET_OPTION_NAME_MULTICAST_LOOPBACK, IP_MULTICAST_LOOP}, {SOCKET_OPTION_NAME_ADD_MEMBERSHIP, IP_ADD_MEMBERSHIP}, {SOCKET_OPTION_NAME_DROP_MEMBERSHIP, IP_DROP_MEMBERSHIP}, {SOCKET_OPTION_NAME_DONT_FRAGMENT, IP_NODEFRAG}, {SOCKET_OPTION_NAME_ADD_SOURCE_MEMBERSHIP, IP_ADD_SOURCE_MEMBERSHIP}, {SOCKET_OPTION_NAME_DROP_SOURCE_MEMBERSHIP, IP_DROP_SOURCE_MEMBERSHIP}, {SOCKET_OPTION_NAME_BLOCK_SOURCE, IP_BLOCK_SOURCE}, {SOCKET_OPTION_NAME_UNBLOCK_SOURCE, IP_UNBLOCK_SOURCE}, {SOCKET_OPTION_NAME_PACKET_INFORMATION, IP_PKTINFO}, {SOCKET_OPTION_NAME_HOP_LIMIT, IPV6_HOPLIMIT}, /*{SOCKET_OPTION_NAME_IP_PROTECT_LEVEL, IPV6_},*/ {SOCKET_OPTION_NAME_IP_V6_ONLY, IPV6_V6ONLY}, /*{SOCKET_OPTION_NAME_NO_DELAY, TCP_}, {SOCKET_OPTION_NAME_BSD_URGENT, TCP_}, {SOCKET_OPTION_NAME_EXPEDITED, TCP_}, {SOCKET_OPTION_NAME_NO_CHECKSUM, UDP_}, {SOCKET_OPTION_NAME_CHECKSUM_COVERAGE, ...}, {SOCKET_OPTION_NAME_UPDATE_ACCEPT_CONTEXT, ...}, {SOCKET_OPTION_NAME_UPDATE_CONNECT_CONTEXT, ...},*/}; auto it = socket_option_names.find(socket_option_name); if (it == socket_option_names.end()) return -1; return it->second; } - static int_least32_t socket_type_to_native(int_least32_t socket_type) { - static map socket_types = {{SOCKET_TYPE_UNKNOWN, SOCK_STREAM | SOCK_CLOEXEC}, {SOCKET_TYPE_STREAM, SOCK_STREAM | SOCK_CLOEXEC}, {SOCKET_TYPE_DGRAM, SOCK_DGRAM | SOCK_CLOEXEC}, {SOCKET_TYPE_RAW, SOCK_RAW | SOCK_CLOEXEC}, {SOCKET_TYPE_RDM, SOCK_RDM | SOCK_CLOEXEC}, {SOCKET_TYPE_SEQPACKET, SOCK_SEQPACKET | SOCK_CLOEXEC}}; + static int32_t socket_type_to_native(int32_t socket_type) { + static map socket_types = {{SOCKET_TYPE_UNKNOWN, SOCK_STREAM | SOCK_CLOEXEC}, {SOCKET_TYPE_STREAM, SOCK_STREAM | SOCK_CLOEXEC}, {SOCKET_TYPE_DGRAM, SOCK_DGRAM | SOCK_CLOEXEC}, {SOCKET_TYPE_RAW, SOCK_RAW | SOCK_CLOEXEC}, {SOCKET_TYPE_RDM, SOCK_RDM | SOCK_CLOEXEC}, {SOCKET_TYPE_SEQPACKET, SOCK_SEQPACKET | SOCK_CLOEXEC}}; auto it = socket_types.find(socket_type); if (it == socket_types.end()) return SOCK_STREAM; return it->second; } } -int_least32_t socket::address_family_to_native(int_least32_t address_family) { - static map address_families = {{ADDRESS_FAMILY_UNKNOWN, -1}, {ADDRESS_FAMILY_UNSPECIFIED, AF_UNSPEC}, {ADDRESS_FAMILY_UNIX, AF_UNIX}, {ADDRESS_FAMILY_INTER_NETWORK, AF_INET}, {ADDRESS_FAMILY_SNA, AF_SNA}, /*{ADDRESS_FAMILY_IMP_LINK, AF_IMPLINK}, {ADDRESS_FAMILY_PUP, AF_PUP}, {ADDRESS_FAMILY_CHAOS, AF_CHAOS}, {ADDRESS_FAMILY_NS, AF_NS}, {ADDRESS_FAMILY_IPX, AF_}, {ADDRESS_FAMILY_ISO, AF_ISO}, {ADDRESS_FAMILY_ECMA, AF_ECMA}, {ADDRESS_FAMILY_DATA_KIT, AF_DATAKIT}, {ADDRESS_FAMILY_CCITT, AF_CCITT},*/ {ADDRESS_FAMILY_DEC_NET, AF_DECnet}, /*{ADDRESS_FAMILY_DATA_LINK, AF_DLI}, {ADDRESS_FAMILY_LAT, AF_LAT}, {ADDRESS_FAMILY_HYPER_CHANNEL, AF_HYLINK},*/ {ADDRESS_FAMILY_APPLE_TALK, AF_APPLETALK}, /*{ADDRESS_FAMILY_NET_BIOS, AF_NETBIOS}, {ADDRESS_FAMILY_VOICE_VIEW, AF_}, {ADDRESS_FAMILY_FIRE_FOX, AF_}, {ADDRESS_FAMILY_BANYAN, AF_}, {ADDRESS_FAMILY_ATM, AF_NATM},*/ {ADDRESS_FAMILY_INTER_NETWORK_V6, AF_INET6}, /*{ADDRESS_FAMILY_CLUSTER, AF_}, {ADDRESS_FAMILY_IEEE12844, AF_}, {ADDRESS_FAMILY_IRDA, AF_}, {ADDRESS_FAMILY_NETWORK_DESIGNERS, AF_},*/ {ADDRESS_FAMILY_MAX, AF_MAX}}; +int32_t socket::address_family_to_native(int32_t address_family) { + static map address_families = {{ADDRESS_FAMILY_UNKNOWN, -1}, {ADDRESS_FAMILY_UNSPECIFIED, AF_UNSPEC}, {ADDRESS_FAMILY_UNIX, AF_UNIX}, {ADDRESS_FAMILY_INTER_NETWORK, AF_INET}, {ADDRESS_FAMILY_SNA, AF_SNA}, /*{ADDRESS_FAMILY_IMP_LINK, AF_IMPLINK}, {ADDRESS_FAMILY_PUP, AF_PUP}, {ADDRESS_FAMILY_CHAOS, AF_CHAOS}, {ADDRESS_FAMILY_NS, AF_NS}, {ADDRESS_FAMILY_IPX, AF_}, {ADDRESS_FAMILY_ISO, AF_ISO}, {ADDRESS_FAMILY_ECMA, AF_ECMA}, {ADDRESS_FAMILY_DATA_KIT, AF_DATAKIT}, {ADDRESS_FAMILY_CCITT, AF_CCITT},*/ {ADDRESS_FAMILY_DEC_NET, AF_DECnet}, /*{ADDRESS_FAMILY_DATA_LINK, AF_DLI}, {ADDRESS_FAMILY_LAT, AF_LAT}, {ADDRESS_FAMILY_HYPER_CHANNEL, AF_HYLINK},*/ {ADDRESS_FAMILY_APPLE_TALK, AF_APPLETALK}, /*{ADDRESS_FAMILY_NET_BIOS, AF_NETBIOS}, {ADDRESS_FAMILY_VOICE_VIEW, AF_}, {ADDRESS_FAMILY_FIRE_FOX, AF_}, {ADDRESS_FAMILY_BANYAN, AF_}, {ADDRESS_FAMILY_ATM, AF_NATM},*/ {ADDRESS_FAMILY_INTER_NETWORK_V6, AF_INET6}, /*{ADDRESS_FAMILY_CLUSTER, AF_}, {ADDRESS_FAMILY_IEEE12844, AF_}, {ADDRESS_FAMILY_IRDA, AF_}, {ADDRESS_FAMILY_NETWORK_DESIGNERS, AF_},*/ {ADDRESS_FAMILY_MAX, AF_MAX}}; auto it = address_families.find(address_family); if (it == address_families.end()) return AF_UNSPEC; return it->second; } -int_least32_t socket::native_to_address_family(int_least32_t address_family) { - static map address_families = {/*{-1, ADDRESS_FAMILY_UNKNOWN}, */ {AF_UNSPEC, ADDRESS_FAMILY_UNSPECIFIED}, {AF_UNIX, ADDRESS_FAMILY_UNIX}, {AF_INET, ADDRESS_FAMILY_INTER_NETWORK}, /*{AF_IMPLINK, ADDRESS_FAMILY_IMP_LINK}, {AF_PUP, ADDRESS_FAMILY_PUP}, {AF_CHAOS, ADDRESS_FAMILY_CHAOS}, {AF_NS, ADDRESS_FAMILY_NS}, {AF_ISO, ADDRESS_FAMILY_ISO}, {AF_, ADDRESS_FAMILY_IPX}, {AF_ECMA, ADDRESS_FAMILY_ECMA}, {AF_DATAKIT, ADDRESS_FAMILY_DATA_KIT}, {AF_CCITT, ADDRESS_FAMILY_CCITT},*/ {AF_SNA, ADDRESS_FAMILY_SNA}, {AF_DECnet, ADDRESS_FAMILY_DEC_NET}, /*{AF_DLI, ADDRESS_FAMILY_DATA_LINK}, {AF_LAT, ADDRESS_FAMILY_LAT}, {AF_HYLINK, ADDRESS_FAMILY_HYPER_CHANNEL},*/ {AF_APPLETALK, ADDRESS_FAMILY_APPLE_TALK}, /*{AF_NETBIOS, ADDRESS_FAMILY_NET_BIOS}, {AF_, ADDRESS_FAMILY_VOICE_VIEW}, {AF_, ADDRESS_FAMILY_FIRE_FOX}, {AF_, ADDRESS_FAMILY_BANYAN}, {AF_NATM, ADDRESS_FAMILY_ATM},*/ {AF_INET6, ADDRESS_FAMILY_INTER_NETWORK_V6}, /*{AF_, ADDRESS_FAMILY_CLUSTER}, {AF_, ADDRESS_FAMILY_IEEE12844}, {AF_, ADDRESS_FAMILY_IRDA}, {AF_, ADDRESS_FAMILY_NETWORK_DESIGNERS},*/ {AF_MAX, ADDRESS_FAMILY_MAX}}; +int32_t socket::native_to_address_family(int32_t address_family) { + static map address_families = {/*{-1, ADDRESS_FAMILY_UNKNOWN}, */ {AF_UNSPEC, ADDRESS_FAMILY_UNSPECIFIED}, {AF_UNIX, ADDRESS_FAMILY_UNIX}, {AF_INET, ADDRESS_FAMILY_INTER_NETWORK}, /*{AF_IMPLINK, ADDRESS_FAMILY_IMP_LINK}, {AF_PUP, ADDRESS_FAMILY_PUP}, {AF_CHAOS, ADDRESS_FAMILY_CHAOS}, {AF_NS, ADDRESS_FAMILY_NS}, {AF_ISO, ADDRESS_FAMILY_ISO}, {AF_, ADDRESS_FAMILY_IPX}, {AF_ECMA, ADDRESS_FAMILY_ECMA}, {AF_DATAKIT, ADDRESS_FAMILY_DATA_KIT}, {AF_CCITT, ADDRESS_FAMILY_CCITT},*/ {AF_SNA, ADDRESS_FAMILY_SNA}, {AF_DECnet, ADDRESS_FAMILY_DEC_NET}, /*{AF_DLI, ADDRESS_FAMILY_DATA_LINK}, {AF_LAT, ADDRESS_FAMILY_LAT}, {AF_HYLINK, ADDRESS_FAMILY_HYPER_CHANNEL},*/ {AF_APPLETALK, ADDRESS_FAMILY_APPLE_TALK}, /*{AF_NETBIOS, ADDRESS_FAMILY_NET_BIOS}, {AF_, ADDRESS_FAMILY_VOICE_VIEW}, {AF_, ADDRESS_FAMILY_FIRE_FOX}, {AF_, ADDRESS_FAMILY_BANYAN}, {AF_NATM, ADDRESS_FAMILY_ATM},*/ {AF_INET6, ADDRESS_FAMILY_INTER_NETWORK_V6}, /*{AF_, ADDRESS_FAMILY_CLUSTER}, {AF_, ADDRESS_FAMILY_IEEE12844}, {AF_, ADDRESS_FAMILY_IRDA}, {AF_, ADDRESS_FAMILY_NETWORK_DESIGNERS},*/ {AF_MAX, ADDRESS_FAMILY_MAX}}; auto it = address_families.find(address_family); if (it == address_families.end()) return ADDRESS_FAMILY_UNSPECIFIED; return it->second; } -intmax_t socket::accept(intmax_t handle, vector& socket_address) { +intmax_t socket::accept(intmax_t handle, vector& socket_address) { socklen_t address_length = static_cast(socket_address.size()); - intmax_t socket = static_cast(::accept(static_cast(handle), reinterpret_cast(socket_address.data()), &address_length)); + intmax_t socket = static_cast(::accept(static_cast(handle), reinterpret_cast(socket_address.data()), &address_length)); //if (socket_address.size() != address_length) socket_address.resize(address_length); return socket; } -int_least32_t socket::bind(intmax_t handle, const vector& socket_address) { - return ::bind(static_cast(handle), reinterpret_cast(socket_address.data()), static_cast(socket_address.size())); +int32_t socket::bind(intmax_t handle, const vector& socket_address) { + return ::bind(static_cast(handle), reinterpret_cast(socket_address.data()), static_cast(socket_address.size())); } void socket::cleanup() { // Nothing to do on linux and macOS. } -int_least32_t socket::connect(intmax_t handle, const vector& socket_address) { - return ::connect(static_cast(handle), reinterpret_cast(socket_address.data()), static_cast(socket_address.size())); +int32_t socket::connect(intmax_t handle, const vector& socket_address) { + return ::connect(static_cast(handle), reinterpret_cast(socket_address.data()), static_cast(socket_address.size())); } -intmax_t socket::create(int_least32_t address_family, int_least32_t socket_type, int_least32_t protocol_type) { +intmax_t socket::create(int32_t address_family, int32_t socket_type, int32_t protocol_type) { return static_cast(::socket(address_family_to_native(address_family), socket_type_to_native(socket_type), protocol_type_to_native(protocol_type))); } -int_least32_t socket::destroy(intmax_t handle) { - return ::close(static_cast(handle)); +int32_t socket::destroy(intmax_t handle) { + return ::close(static_cast(handle)); } size_t socket::get_available(intmax_t handle) { - int_least32_t nbr_bytes_available = 0; - if (ioctl(static_cast(handle), FIONREAD, &nbr_bytes_available) != 0) return -1; + int32_t nbr_bytes_available = 0; + if (ioctl(static_cast(handle), FIONREAD, &nbr_bytes_available) != 0) return -1; return static_cast(nbr_bytes_available); } -int_least32_t socket::get_last_error() { +int32_t socket::get_last_error() { return native_to_socket_error(errno); } bool socket::get_os_supports_ip_v4() noexcept { - int_least32_t s = ::socket(AF_INET, SOCK_STREAM, IPPROTO_IP); + int32_t s = ::socket(AF_INET, SOCK_STREAM, IPPROTO_IP); if (s == -1) return false; close(s); return true; } bool socket::get_os_supports_ip_v6() noexcept { - int_least32_t s = ::socket(AF_INET6, SOCK_STREAM, IPPROTO_IP); + int32_t s = ::socket(AF_INET6, SOCK_STREAM, IPPROTO_IP); if (s == -1) return false; close(s); return true; } -int_least32_t socket::get_raw_socket_option(intmax_t handle, int_least32_t socket_option_level, int_least32_t socket_option_name, intmax_t option, size_t& option_length) { - return ::getsockopt(static_cast(handle), socket_option_level, socket_option_name, reinterpret_cast(option), reinterpret_cast(&option_length)); +int32_t socket::get_raw_socket_option(intmax_t handle, int32_t socket_option_level, int32_t socket_option_name, intmax_t option, size_t& option_length) { + return ::getsockopt(static_cast(handle), socket_option_level, socket_option_name, reinterpret_cast(option), reinterpret_cast(&option_length)); } -int_least32_t socket::get_socket_option(intmax_t handle, int_least32_t socket_option_level, int_least32_t socket_option_name, intmax_t option, size_t& option_length) { +int32_t socket::get_socket_option(intmax_t handle, int32_t socket_option_level, int32_t socket_option_name, intmax_t option, size_t& option_length) { if (socket_option_name_to_native(socket_option_name) == -1) { errno = ENOTSUP; return -1; } if (socket_option_level == SOCKET_OPTION_LEVEL_SOCKET && (socket_option_name == SOCKET_OPTION_NAME_SEND_TIMEOUT || socket_option_name == SOCKET_OPTION_NAME_RECEIVE_TIMEOUT)) { timeval timeout = {0, 0}; - int_least32_t result = ::getsockopt(static_cast(handle), socket_option_level_to_native(socket_option_level), socket_option_name_to_native(socket_option_name), &timeout, reinterpret_cast(&option_length)); - *reinterpret_cast(option) = static_cast(timeout.tv_sec * 1000 + timeout.tv_usec / 1000); + int32_t result = ::getsockopt(static_cast(handle), socket_option_level_to_native(socket_option_level), socket_option_name_to_native(socket_option_name), &timeout, reinterpret_cast(&option_length)); + *reinterpret_cast(option) = static_cast(timeout.tv_sec * 1000 + timeout.tv_usec / 1000); return result; } - return ::getsockopt(static_cast(handle), socket_option_level_to_native(socket_option_level), socket_option_name_to_native(socket_option_name), reinterpret_cast(option), reinterpret_cast(&option_length)); + return ::getsockopt(static_cast(handle), socket_option_level_to_native(socket_option_level), socket_option_name_to_native(socket_option_name), reinterpret_cast(option), reinterpret_cast(&option_length)); } -int_least32_t socket::get_socket_linger_option(intmax_t handle, bool& enabled, uint_least32_t& linger_time) { - linger l {static_cast(enabled), static_cast(linger_time)}; +int32_t socket::get_socket_linger_option(intmax_t handle, bool& enabled, uint32_t& linger_time) { + linger l {static_cast(enabled), static_cast(linger_time)}; size_t linger_size = 0; - int_least32_t result = ::getsockopt(static_cast(handle), SOL_SOCKET, SO_LINGER, &l, reinterpret_cast(&linger_size)); + int32_t result = ::getsockopt(static_cast(handle), SOL_SOCKET, SO_LINGER, &l, reinterpret_cast(&linger_size)); if (result == 0) { enabled = static_cast(l.l_onoff); - linger_time = static_cast(l.l_linger); + linger_time = static_cast(l.l_linger); } return result; } -int_least32_t socket::get_socket_multicast_option(intmax_t handle, int_least32_t socket_option_name, uint_least32_t& multicast_address, uint_least32_t& interface_index) { +int32_t socket::get_socket_multicast_option(intmax_t handle, int32_t socket_option_name, uint32_t& multicast_address, uint32_t& interface_index) { struct multicast { - uint_least32_t multicast_address; - uint_least32_t interface_index; + uint32_t multicast_address; + uint32_t interface_index; } m; size_t multicast_size = 0; - int_least32_t result = getsockopt(static_cast(handle), IPPROTO_IP, socket_option_name_to_native(socket_option_name), &m, reinterpret_cast(&multicast_size)); + int32_t result = getsockopt(static_cast(handle), IPPROTO_IP, socket_option_name_to_native(socket_option_name), &m, reinterpret_cast(&multicast_size)); if (result == 0) { multicast_address = m.multicast_address; interface_index = m.interface_index; @@ -168,13 +168,13 @@ int_least32_t socket::get_socket_multicast_option(intmax_t handle, int_least32_t return result; } -int_least32_t socket::get_socket_ip_v6_multicast_option(intmax_t handle, int_least32_t socket_option_name, vector& multicast_address, uint_least32_t& interface_index) { +int32_t socket::get_socket_ip_v6_multicast_option(intmax_t handle, int32_t socket_option_name, vector& multicast_address, uint32_t& interface_index) { struct multicast { - uint_least8_t multicast_address[16]; - uint_least32_t interface_index; + uint8_t multicast_address[16]; + uint32_t interface_index; } m; size_t multicast_size = 0; - int_least32_t result = getsockopt(static_cast(handle), IPPROTO_IP, socket_option_name_to_native(socket_option_name), &m, reinterpret_cast(&multicast_size)); + int32_t result = getsockopt(static_cast(handle), IPPROTO_IP, socket_option_name_to_native(socket_option_name), &m, reinterpret_cast(&multicast_size)); if (result == 0) { for (auto index = 0U; index < multicast_address.size(); ++index) multicast_address[index] = m.multicast_address[index]; @@ -183,22 +183,22 @@ int_least32_t socket::get_socket_ip_v6_multicast_option(intmax_t handle, int_lea return result; } -int_least32_t socket::io_control(intmax_t handle, int_least32_t io_control, vector& option_in_value, vector& option_out_value) { +int32_t socket::io_control(intmax_t handle, int32_t io_control, vector& option_in_value, vector& option_out_value) { // Not implemented errno = ENOTSUP; return -1; } -int_least32_t socket::listen(intmax_t handle, size_t backlog) { - int_least32_t backlog_value = backlog != static_cast(-1) ? static_cast(backlog) : SOMAXCONN; - return ::listen(static_cast(handle), backlog_value); +int32_t socket::listen(intmax_t handle, size_t backlog) { + int32_t backlog_value = backlog != static_cast(-1) ? static_cast(backlog) : SOMAXCONN; + return ::listen(static_cast(handle), backlog_value); } -int_least32_t socket::poll(intmax_t handle, int_least32_t microseconds, int_least32_t mode) { +int32_t socket::poll(intmax_t handle, int32_t microseconds, int32_t mode) { if (handle == 0 || microseconds < 0) return -1; pollfd poll_fd {}; - poll_fd.fd = static_cast(handle); + poll_fd.fd = static_cast(handle); switch (mode) { case SELECT_MODE_READ: poll_fd.events = POLLIN; break; case SELECT_MODE_WRITE: poll_fd.events = POLLOUT; break; @@ -208,16 +208,16 @@ int_least32_t socket::poll(intmax_t handle, int_least32_t microseconds, int_leas return ::poll(&poll_fd, 1, microseconds); } -int_least32_t socket::receive(intmax_t handle, vector& buffer, size_t offset, size_t size, int_least32_t flags) { - int_least32_t result = static_cast(::recv(static_cast(handle), &buffer.data()[offset], size, flags)); +int32_t socket::receive(intmax_t handle, vector& buffer, size_t offset, size_t size, int32_t flags) { + int32_t result = static_cast(::recv(static_cast(handle), &buffer.data()[offset], size, flags)); if (result == -1 && errno == EBADF) errno = EINTR; if (result == -1 && errno == EAGAIN) errno = ETIMEDOUT; return result; } -int_least32_t socket::receive_from(intmax_t handle, vector& buffer, size_t offset, size_t size, int_least32_t flags, vector& socket_address) { +int32_t socket::receive_from(intmax_t handle, vector& buffer, size_t offset, size_t size, int32_t flags, vector& socket_address) { socklen_t address_length = static_cast(socket_address.size()); - int_least32_t result = static_cast(::recvfrom(static_cast(handle), &buffer.data()[offset], size, flags, reinterpret_cast(socket_address.data()), &address_length)); + int32_t result = static_cast(::recvfrom(static_cast(handle), &buffer.data()[offset], size, flags, reinterpret_cast(socket_address.data()), &address_length)); //if (socket_address.size() != address_length) socket_address.resize(address_length); if (result == -1 && errno == EBADF) errno = EINTR; @@ -225,111 +225,111 @@ int_least32_t socket::receive_from(intmax_t handle, vector& buffe return result; } -int_least32_t socket::select(vector& check_read, vector& check_write, vector& check_error, int_least32_t microseconds) { +int32_t socket::select(vector& check_read, vector& check_write, vector& check_error, int32_t microseconds) { size_t nfds = 0; fd_set read_fds; FD_ZERO(&read_fds); for (auto i = 0U; i < check_read.size() && i < FD_SETSIZE; i++) - FD_SET(static_cast(check_read[i]), &read_fds); + FD_SET(static_cast(check_read[i]), &read_fds); if (check_read.size() > nfds) nfds = check_read.size(); fd_set write_fds; FD_ZERO(&write_fds); for (auto i = 0U; i < check_write.size() && i < FD_SETSIZE; i++) - FD_SET(static_cast(check_write[i]), &write_fds); + FD_SET(static_cast(check_write[i]), &write_fds); if (check_write.size() > nfds) nfds = check_write.size(); fd_set error_fds; FD_ZERO(&error_fds); for (auto i = 0U; i < check_error.size() && i < FD_SETSIZE; i++) - FD_SET(static_cast(check_error[i]), &error_fds); + FD_SET(static_cast(check_error[i]), &error_fds); if (check_error.size() > nfds) nfds = check_error.size(); timeval timeout {microseconds / 1000000, microseconds % 1000000}; - int_least32_t result = ::select(static_cast(nfds + 1), &read_fds, &write_fds, &error_fds, microseconds == -1 ? nullptr : &timeout); + int32_t result = ::select(static_cast(nfds + 1), &read_fds, &write_fds, &error_fds, microseconds == -1 ? nullptr : &timeout); for (auto i = 0U; i < check_read.size(); i++) { - FD_CLR(static_cast(check_read[i]), &read_fds); - if (FD_ISSET(static_cast(check_read[i]), &read_fds) == 0) check_read[i] = 0; + FD_CLR(static_cast(check_read[i]), &read_fds); + if (FD_ISSET(static_cast(check_read[i]), &read_fds) == 0) check_read[i] = 0; } for (auto i = 0U; i < check_write.size(); i++) { - FD_CLR(static_cast(check_write[i]), &write_fds); - if (FD_ISSET(static_cast(check_write[i]), &write_fds) == 0) check_write[i] = 0; + FD_CLR(static_cast(check_write[i]), &write_fds); + if (FD_ISSET(static_cast(check_write[i]), &write_fds) == 0) check_write[i] = 0; } for (auto i = 0U; i < check_error.size(); i++) { - FD_CLR(static_cast(check_error[i]), &error_fds); - if (FD_ISSET(static_cast(check_error[i]), &error_fds) == 0) check_error[i] = 0; + FD_CLR(static_cast(check_error[i]), &error_fds); + if (FD_ISSET(static_cast(check_error[i]), &error_fds) == 0) check_error[i] = 0; } return result; } -int_least32_t socket::send(intmax_t handle, const vector& buffer, size_t offset, size_t size, int_least32_t flags) { - return static_cast(::send(static_cast(handle), &buffer.data()[offset], size, flags)); +int32_t socket::send(intmax_t handle, const vector& buffer, size_t offset, size_t size, int32_t flags) { + return static_cast(::send(static_cast(handle), &buffer.data()[offset], size, flags)); } -int_least32_t socket::send_to(intmax_t handle, const vector& buffer, size_t offset, size_t size, int_least32_t flags, const vector& socket_address) { - return static_cast(::sendto(static_cast(handle), &buffer.data()[offset], size, flags, reinterpret_cast(socket_address.data()), static_cast(socket_address.size()))); +int32_t socket::send_to(intmax_t handle, const vector& buffer, size_t offset, size_t size, int32_t flags, const vector& socket_address) { + return static_cast(::sendto(static_cast(handle), &buffer.data()[offset], size, flags, reinterpret_cast(socket_address.data()), static_cast(socket_address.size()))); } -int_least32_t socket::set_blocking(intmax_t handle, bool blocking) { - int_least32_t result = -1; +int32_t socket::set_blocking(intmax_t handle, bool blocking) { + int32_t result = -1; - if ((result = fcntl(static_cast(handle), F_GETFL, 0)) != -1) { - int_least32_t flags = result; + if ((result = fcntl(static_cast(handle), F_GETFL, 0)) != -1) { + int32_t flags = result; if (blocking == true) flags &= ~O_NONBLOCK; else flags |= O_NONBLOCK; - result = fcntl(static_cast(handle), F_SETFL, flags) == -1 ? -1 : 0; + result = fcntl(static_cast(handle), F_SETFL, flags) == -1 ? -1 : 0; } return result; } -int_least32_t socket::set_raw_socket_option(intmax_t handle, int_least32_t socket_option_level, int_least32_t socket_option_name, intmax_t option, size_t option_length) { - return setsockopt(static_cast(handle), socket_option_level, socket_option_name, reinterpret_cast(option), static_cast(option_length)); +int32_t socket::set_raw_socket_option(intmax_t handle, int32_t socket_option_level, int32_t socket_option_name, intmax_t option, size_t option_length) { + return setsockopt(static_cast(handle), socket_option_level, socket_option_name, reinterpret_cast(option), static_cast(option_length)); } -int_least32_t socket::set_socket_option(intmax_t handle, int_least32_t socket_option_level, int_least32_t socket_option_name, intmax_t option, size_t option_length) { +int32_t socket::set_socket_option(intmax_t handle, int32_t socket_option_level, int32_t socket_option_name, intmax_t option, size_t option_length) { if (socket_option_name_to_native(socket_option_name) == -1) { errno = ENOTSUP; return -1; } if (socket_option_level == SOCKET_OPTION_LEVEL_SOCKET && (socket_option_name == SOCKET_OPTION_NAME_SEND_TIMEOUT || socket_option_name == SOCKET_OPTION_NAME_RECEIVE_TIMEOUT)) { - timeval timeout = {*reinterpret_cast(option) / 1000, *reinterpret_cast(option) % 1000 * 1000}; - return ::setsockopt(static_cast(handle), socket_option_level_to_native(socket_option_level), socket_option_name_to_native(socket_option_name), &timeout, sizeof(timeval)); + timeval timeout = {*reinterpret_cast(option) / 1000, *reinterpret_cast(option) % 1000 * 1000}; + return ::setsockopt(static_cast(handle), socket_option_level_to_native(socket_option_level), socket_option_name_to_native(socket_option_name), &timeout, sizeof(timeval)); } - return setsockopt(static_cast(handle), socket_option_level_to_native(socket_option_level), socket_option_name_to_native(socket_option_name), reinterpret_cast(option), static_cast(option_length)); + return setsockopt(static_cast(handle), socket_option_level_to_native(socket_option_level), socket_option_name_to_native(socket_option_name), reinterpret_cast(option), static_cast(option_length)); } -int_least32_t socket::set_socket_linger_option(intmax_t handle, bool enabled, uint_least32_t linger_time) { - linger l {static_cast(enabled), static_cast(linger_time)}; - return setsockopt(static_cast(handle), SOL_SOCKET, SO_LINGER, &l, static_cast(sizeof(linger))); +int32_t socket::set_socket_linger_option(intmax_t handle, bool enabled, uint32_t linger_time) { + linger l {static_cast(enabled), static_cast(linger_time)}; + return setsockopt(static_cast(handle), SOL_SOCKET, SO_LINGER, &l, static_cast(sizeof(linger))); } -int_least32_t socket::set_socket_multicast_option(intmax_t handle, int_least32_t socket_option_name, uint_least32_t multicast_address, uint_least32_t interface_index) { +int32_t socket::set_socket_multicast_option(intmax_t handle, int32_t socket_option_name, uint32_t multicast_address, uint32_t interface_index) { struct multicast { - uint_least32_t multicast_address; - uint_least32_t interface_index; + uint32_t multicast_address; + uint32_t interface_index; } m {multicast_address, interface_index}; - return setsockopt(static_cast(handle), IPPROTO_TCP, socket_option_name_to_native(socket_option_name), &m, static_cast(sizeof(multicast))); + return setsockopt(static_cast(handle), IPPROTO_TCP, socket_option_name_to_native(socket_option_name), &m, static_cast(sizeof(multicast))); } -int_least32_t socket::set_socket_ip_v6_multicast_option(intmax_t handle, int_least32_t socket_option_name, const vector& multicast_address, uint_least32_t interface_index) { +int32_t socket::set_socket_ip_v6_multicast_option(intmax_t handle, int32_t socket_option_name, const vector& multicast_address, uint32_t interface_index) { struct multicast { - uint_least8_t multicast_address[16]; - uint_least32_t interface_index; + uint8_t multicast_address[16]; + uint32_t interface_index; } m; for (auto index = 0U; index < multicast_address.size(); ++index) m.multicast_address[index] = multicast_address[index]; m.interface_index = interface_index; - return setsockopt(static_cast(handle), IPPROTO_IP, socket_option_name_to_native(socket_option_name), &m, static_cast(sizeof(multicast))); + return setsockopt(static_cast(handle), IPPROTO_IP, socket_option_name_to_native(socket_option_name), &m, static_cast(sizeof(multicast))); } -int_least32_t socket::shutdown(intmax_t handle, int_least32_t how) { - int_least32_t result = ::shutdown(static_cast(handle), how); +int32_t socket::shutdown(intmax_t handle, int32_t how) { + int32_t result = ::shutdown(static_cast(handle), how); if (how == SOCKET_SHUTDOWN_BOTH && result == -1 && errno == ENOTCONN) { errno = 0; result = 0; diff --git a/src/xtd.core.native.posix/src/xtd/native/posix/speech_synthesizer.cpp b/src/xtd.core.native.posix/src/xtd/native/posix/speech_synthesizer.cpp index 6e3281b47fd..75d62eadc46 100644 --- a/src/xtd.core.native.posix/src/xtd/native/posix/speech_synthesizer.cpp +++ b/src/xtd.core.native.posix/src/xtd/native/posix/speech_synthesizer.cpp @@ -27,7 +27,7 @@ namespace { } static string get_unique_speak_cmd_file_name() { - static int_least32_t cpt = 0; + static int32_t cpt = 0; stringstream ss; ss << get_temp_path() << "/__xtd_speech_synthesizer_speak_process_" << ++cpt << "__.cmd"; return ss.str(); @@ -59,14 +59,14 @@ void speech_synthesizer::resume(intmax_t handle) { void speech_synthesizer::speak(intmax_t handle, const string& text_to_speak) { speak_async(handle, text_to_speak, [] {}); - int_least32_t exit_code = 0; + int32_t exit_code = 0; native::process::wait(reinterpret_cast(handle)->process_handle, exit_code); } void speech_synthesizer::speak_async(intmax_t handle, const string& text_to_speak, std::function on_speak_completed) { reinterpret_cast(handle)->process_handle = native::process::shell_execute("", reinterpret_cast(handle)->say_cmd_file_name, text_to_speak, "", PROCESS_WINDOW_STYLE_HIDDEN); thread wait_process_thread([on_speak_completed, handle] { - int_least32_t exit_code = 0; + int32_t exit_code = 0; native::process::wait(reinterpret_cast(handle)->process_handle, exit_code); on_speak_completed(); }); diff --git a/src/xtd.core.native.posix/src/xtd/native/posix/system_sound.cpp b/src/xtd.core.native.posix/src/xtd/native/posix/system_sound.cpp index 1c7f63aacd7..4d3a5d7e549 100644 --- a/src/xtd.core.native.posix/src/xtd/native/posix/system_sound.cpp +++ b/src/xtd.core.native.posix/src/xtd/native/posix/system_sound.cpp @@ -11,9 +11,9 @@ using namespace std; using namespace xtd::native; -void system_sound::play(uint_least32_t sound) { +void system_sound::play(uint32_t sound) { #if defined(__XTD_USE_GSOUND__) - static map sounds = {{ST_BEEP, "bell-window-system"}, {ST_ICONERROR, "dialog-error"}, {ST_ICONQUESTION, "dialog-question"}, {ST_ICONWARNING, "dialog-warning"}, {ST_ICONINFORMATION, "dialog-information"}, {ST_OK, "bell-window-system"}}; + static map sounds = {{ST_BEEP, "bell-window-system"}, {ST_ICONERROR, "dialog-error"}, {ST_ICONQUESTION, "dialog-question"}, {ST_ICONWARNING, "dialog-warning"}, {ST_ICONINFORMATION, "dialog-information"}, {ST_OK, "bell-window-system"}}; static GSoundContext* gsound_context = gsound_context_new(nullptr, nullptr); gsound_context_play_simple(gsound_context, nullptr, nullptr, GSOUND_ATTR_EVENT_ID, sounds[sound].c_str(), nullptr); #endif diff --git a/src/xtd.core.native.posix/src/xtd/native/posix/thread.cpp b/src/xtd.core.native.posix/src/xtd/native/posix/thread.cpp index 00c84aebede..c3640ed259b 100644 --- a/src/xtd.core.native.posix/src/xtd/native/posix/thread.cpp +++ b/src/xtd.core.native.posix/src/xtd/native/posix/thread.cpp @@ -14,7 +14,7 @@ bool thread::cancel(intmax_t handle) { return pthread_cancel(reinterpret_cast(handle)) == 0; } -intmax_t thread::create(std::function start, intmax_t obj, int_least32_t max_stack_size, bool suspended, intmax_t& id) { +intmax_t thread::create(std::function start, intmax_t obj, int32_t max_stack_size, bool suspended, intmax_t& id) { auto thread = pthread_t {}; int error = pthread_create(&thread, nullptr, [](void* thread_arg)->void* { auto start_obj = reinterpret_cast, intmax_t>*>(thread_arg); @@ -57,18 +57,18 @@ bool thread::set_current_thread_name(const std::string& name) { return true; } -bool thread::set_priority(intmax_t handle, int_least32_t priority) { +bool thread::set_priority(intmax_t handle, int32_t priority) { if (reinterpret_cast(handle) == PTHREAD_FAILED) return false; auto policy = 0; auto schedParam = sched_param {}; if (::pthread_getschedparam(reinterpret_cast(handle), &policy, &schedParam) != 0) return false; - schedParam.sched_priority = static_cast(std::ceil((static_cast(priority) * (sched_get_priority_max(policy) - sched_get_priority_min(policy)) / 4) + sched_get_priority_min(policy))); + schedParam.sched_priority = static_cast(std::ceil((static_cast(priority) * (sched_get_priority_max(policy) - sched_get_priority_min(policy)) / 4) + sched_get_priority_min(policy))); return pthread_setschedparam(reinterpret_cast(handle), policy, &schedParam) == 0; } -void thread::sleep(int_least32_t milliseconds_timeout) { +void thread::sleep(int32_t milliseconds_timeout) { auto infinite_sleep = [] {while (true) std::this_thread::sleep_for(std::chrono::hours::max());}; if (milliseconds_timeout == -1) infinite_sleep(); else if (milliseconds_timeout == 0) yield(); diff --git a/src/xtd.core.native.posix/src/xtd/native/posix/unnamed_event_wait_handle.cpp b/src/xtd.core.native.posix/src/xtd/native/posix/unnamed_event_wait_handle.cpp index 8d6f6172bf1..8a8d815c39a 100644 --- a/src/xtd.core.native.posix/src/xtd/native/posix/unnamed_event_wait_handle.cpp +++ b/src/xtd.core.native.posix/src/xtd/native/posix/unnamed_event_wait_handle.cpp @@ -43,7 +43,7 @@ bool unnamed_event_wait_handle::reset(intmax_t handle, bool& io_error) { return true; } -uint_least32_t unnamed_event_wait_handle::wait(intmax_t handle, int_least32_t milliseconds_timeout, bool manual_reset) { +uint32_t unnamed_event_wait_handle::wait(intmax_t handle, int32_t milliseconds_timeout, bool manual_reset) { if (reinterpret_cast(handle) == SEM_FAILED) return 0xFFFFFFFF; auto result = milliseconds_timeout == -1 ? sem_wait(reinterpret_cast(handle)) : sem_milliseconds_timedwait(reinterpret_cast(handle), milliseconds_timeout); if (result && errno == EAGAIN) return 0xFFFFFFFF; diff --git a/src/xtd.core.native.posix/src/xtd/native/posix/unnamed_mutex.cpp b/src/xtd.core.native.posix/src/xtd/native/posix/unnamed_mutex.cpp index 6bb66292ca3..2f46169b41f 100644 --- a/src/xtd.core.native.posix/src/xtd/native/posix/unnamed_mutex.cpp +++ b/src/xtd.core.native.posix/src/xtd/native/posix/unnamed_mutex.cpp @@ -35,7 +35,7 @@ bool unnamed_mutex::signal(intmax_t handle, bool& io_error) { return !io_error; } -uint_least32_t unnamed_mutex::wait(intmax_t handle, int_least32_t milliseconds_timeout) { +uint32_t unnamed_mutex::wait(intmax_t handle, int32_t milliseconds_timeout) { if (reinterpret_cast(handle) == MUTEX_FAILED) return 0xFFFFFFFF; auto result = milliseconds_timeout == -1 ? pthread_mutex_unlock(reinterpret_cast(handle)) : pthread_mutex_milliseconds_timedlock(reinterpret_cast(handle), milliseconds_timeout); if (result && errno == EAGAIN) return 0xFFFFFFFF; diff --git a/src/xtd.core.native.posix/src/xtd/native/posix/unnamed_semaphore.cpp b/src/xtd.core.native.posix/src/xtd/native/posix/unnamed_semaphore.cpp index de13297da03..3330d59fa21 100644 --- a/src/xtd.core.native.posix/src/xtd/native/posix/unnamed_semaphore.cpp +++ b/src/xtd.core.native.posix/src/xtd/native/posix/unnamed_semaphore.cpp @@ -7,7 +7,7 @@ using namespace xtd::native; -intmax_t unnamed_semaphore::create(int_least32_t initial_count, int_least32_t max_count) { +intmax_t unnamed_semaphore::create(int32_t initial_count, int32_t max_count) { auto semaphore = new sem_t; if (sem_init(semaphore, 0, std::min(initial_count, max_count)) == -1) return reinterpret_cast(SEM_FAILED); return reinterpret_cast(semaphore); @@ -19,7 +19,7 @@ void unnamed_semaphore::destroy(intmax_t handle) { delete reinterpret_cast(handle); } -bool unnamed_semaphore::signal(intmax_t handle, int_least32_t release_count, int_least32_t& previous_count, bool& io_error) { +bool unnamed_semaphore::signal(intmax_t handle, int32_t release_count, int32_t& previous_count, bool& io_error) { io_error = false; if (reinterpret_cast(handle) == SEM_FAILED) { io_error = true; @@ -32,7 +32,7 @@ bool unnamed_semaphore::signal(intmax_t handle, int_least32_t release_count, int return !io_error; } -uint_least32_t unnamed_semaphore::wait(intmax_t handle, int_least32_t milliseconds_timeout) { +uint32_t unnamed_semaphore::wait(intmax_t handle, int32_t milliseconds_timeout) { if (reinterpret_cast(handle) == SEM_FAILED) return 0xFFFFFFFF; auto result = milliseconds_timeout == -1 ? sem_wait(reinterpret_cast(handle)) : sem_milliseconds_timedwait(reinterpret_cast(handle), milliseconds_timeout); if (result && errno == EAGAIN) return 0xFFFFFFFF; diff --git a/src/xtd.core.native.unix/include/xtd/native/unix/mutex.h b/src/xtd.core.native.unix/include/xtd/native/unix/mutex.h index a466f21c17f..f382f59fe48 100644 --- a/src/xtd.core.native.unix/include/xtd/native/unix/mutex.h +++ b/src/xtd.core.native.unix/include/xtd/native/unix/mutex.h @@ -11,7 +11,7 @@ inline static const pthread_mutex_t* MUTEX_FAILED = reinterpret_cast(-1); -static inline int pthread_mutex_milliseconds_timedlock(pthread_mutex_t* mut, int_least32_t milliseconds_timeout) { +static inline int pthread_mutex_milliseconds_timedlock(pthread_mutex_t* mut, int32_t milliseconds_timeout) { struct timespec timeout; clock_gettime(CLOCK_REALTIME, &timeout); timeout.tv_sec += milliseconds_timeout / 1000; diff --git a/src/xtd.core.native.unix/include/xtd/native/unix/semaphore.h b/src/xtd.core.native.unix/include/xtd/native/unix/semaphore.h index c7d37af387f..ee9af4a8593 100644 --- a/src/xtd.core.native.unix/include/xtd/native/unix/semaphore.h +++ b/src/xtd.core.native.unix/include/xtd/native/unix/semaphore.h @@ -11,7 +11,7 @@ inline static constexpr size_t PSEMNAMLEN = 31; -static inline int sem_milliseconds_timedwait(sem_t *sem, int_least32_t milliseconds_timeout) { +static inline int sem_milliseconds_timedwait(sem_t *sem, int32_t milliseconds_timeout) { struct timespec timeout; clock_gettime(CLOCK_REALTIME, &timeout); timeout.tv_sec += milliseconds_timeout / 1000; diff --git a/src/xtd.core.native.unix/include/xtd/native/unix/strings.h b/src/xtd.core.native.unix/include/xtd/native/unix/strings.h index 8c30d230eb1..61381c9c788 100644 --- a/src/xtd.core.native.unix/include/xtd/native/unix/strings.h +++ b/src/xtd.core.native.unix/include/xtd/native/unix/strings.h @@ -135,7 +135,7 @@ namespace xtd::native::unix { return result; } - static bool try_parse(const std::string& str, int_least32_t& value) noexcept { + static bool try_parse(const std::string& str, int32_t& value) noexcept { try { value = std::atoi(str.c_str()); return true; diff --git a/src/xtd.core.native.unix/src/xtd/native/unix/condition_variable.cpp b/src/xtd.core.native.unix/src/xtd/native/unix/condition_variable.cpp index 2e76bba7215..27d74c91c59 100644 --- a/src/xtd.core.native.unix/src/xtd/native/unix/condition_variable.cpp +++ b/src/xtd.core.native.unix/src/xtd/native/unix/condition_variable.cpp @@ -31,7 +31,7 @@ void condition_variable::pulse_all(intmax_t handle) { pthread_cond_broadcast(reinterpret_cast(handle)); } -bool condition_variable::wait(intmax_t handle, intmax_t critical_section_handle, int_least32_t milliseconds_timeout) { +bool condition_variable::wait(intmax_t handle, intmax_t critical_section_handle, int32_t milliseconds_timeout) { if (handle == reinterpret_cast(MUTEX_FAILED)) return false; if (reinterpret_cast(critical_section_handle) == nullptr) return false; diff --git a/src/xtd.core.native.unix/src/xtd/native/unix/console.cpp b/src/xtd.core.native.unix/src/xtd/native/unix/console.cpp index d177bc186d1..7773b4d30e2 100644 --- a/src/xtd.core.native.unix/src/xtd/native/unix/console.cpp +++ b/src/xtd.core.native.unix/src/xtd/native/unix/console.cpp @@ -20,8 +20,8 @@ using namespace xtd::native; namespace { auto treat_control_c_as_input = false; - auto signal_couter_ = std::vector {}; - auto user_cancel_callback = std::function {}; + auto signal_couter_ = std::vector {}; + auto user_cancel_callback = std::function {}; struct console_intercept_signals { private: @@ -35,14 +35,14 @@ namespace { ::signal(signal.first, SIG_DFL); } - static void signal_handler(int_least32_t signal) { + static void signal_handler(int32_t signal) { ::signal(signal, console_intercept_signals::signal_handler); if (treat_control_c_as_input) signal_couter_.push_back(signal_keys_[signal]); else if (user_cancel_callback && user_cancel_callback(signal_keys_[signal]) == false) exit(EXIT_FAILURE); } // The SIGINT signal catcher conflicts with with xtd::environment::cancel_interrupt signal... - inline static std::map signal_keys_ {{SIGQUIT, CONSOLE_SPECIAL_KEY_CTRL_BS}, {SIGTSTP, CONSOLE_SPECIAL_KEY_CTRL_Z}/*, {SIGINT, CONSOLE_SPECIAL_KEY_CTRL_C}*/}; + inline static std::map signal_keys_ {{SIGQUIT, CONSOLE_SPECIAL_KEY_CTRL_BS}, {SIGTSTP, CONSOLE_SPECIAL_KEY_CTRL_Z}/*, {SIGINT, CONSOLE_SPECIAL_KEY_CTRL_C}*/}; static console_intercept_signals console_intercept_signals_; }; @@ -68,7 +68,7 @@ namespace { return tcsetattr(0, TCSANOW, &status) == 0; } - int_least32_t getch() { + int32_t getch() { if (peek_character != -1) { auto character = peek_character; peek_character = -1; @@ -145,7 +145,7 @@ namespace { } - int_least8_t peek_character {-1}; + int8_t peek_character {-1}; std::vector statuses; }; @@ -156,8 +156,8 @@ namespace { class input_list { public: input_list() {} - explicit input_list(const std::list& chars) : chars(chars) {} - explicit input_list(std::initializer_list il) : chars(il) {} + explicit input_list(const std::list& chars) : chars(chars) {} + explicit input_list(std::initializer_list il) : chars(il) {} input_list(const input_list& il) : chars(il.chars) {} input_list& operator =(const input_list& il) { @@ -168,8 +168,8 @@ namespace { bool operator ==(const input_list& il) const noexcept {return chars == il.chars;} bool operator !=(const input_list& il) const noexcept {return chars != il.chars;} - using const_iterator = std::list::const_iterator; - using iterator = std::list::iterator; + using const_iterator = std::list::const_iterator; + using iterator = std::list::iterator; const_iterator cbegin() const {return chars.begin();} const_iterator cend() const {return chars.end();} @@ -178,11 +178,11 @@ namespace { const_iterator end() const {return chars.end();} iterator end() {return chars.end();} - void add(int_least32_t c) {chars.push_back(c);} - void add_front(int_least32_t c) {chars.push_front(c);} - void remove(int_least32_t c) {chars.remove(c);} - int_least32_t count() const {return static_cast(chars.size());} - int_least32_t pop() { int_least32_t c = chars.front(); chars.erase(chars.begin()); return c;} + void add(int32_t c) {chars.push_back(c);} + void add_front(int32_t c) {chars.push_front(c);} + void remove(int32_t c) {chars.remove(c);} + int32_t count() const {return static_cast(chars.size());} + int32_t pop() { int32_t c = chars.front(); chars.erase(chars.begin()); return c;} void clear() {chars.clear();} bool is_empty() const {return chars.empty();} @@ -215,7 +215,7 @@ namespace { } private: - std::list chars; + std::list chars; }; key_info(const key_info& ki) : key_(ki.key_), key_char_(ki.key_char_), has_alt_modifier_(ki.has_alt_modifier_), has_control_modifier_(ki.has_control_modifier_), has_shift_modifier_(ki.has_shift_modifier_) {} @@ -268,18 +268,18 @@ namespace { std::string to_string() const { auto result = std::stringstream {}; - result << "{key=" << std::hex << static_cast(key_) << ", key_char=" << std::dec << static_cast(key_char_) << ", has_alt_modifier=" << to_string(has_alt_modifier_) << ", has_control_modifier=" << to_string(has_control_modifier_) << ", has_shift_modifier=" << to_string(has_shift_modifier_) << "}"; + result << "{key=" << std::hex << static_cast(key_) << ", key_char=" << std::dec << static_cast(key_char_) << ", has_alt_modifier=" << to_string(has_alt_modifier_) << ", has_control_modifier=" << to_string(has_control_modifier_) << ", has_shift_modifier=" << to_string(has_shift_modifier_) << "}"; return result.str(); } private: key_info() : key_(U'0'), key_char_(U'0'), has_alt_modifier_(false), has_control_modifier_(false), has_shift_modifier_(false) {} - key_info(int_least32_t key, int_least32_t key_char) : key_(key), key_char_(key_char), has_alt_modifier_(false), has_control_modifier_(false), has_shift_modifier_(false) {} - key_info(int_least32_t key, int_least32_t key_char, bool has_alt_modifier, bool has_control_modifier, bool has_shift_modifier) : key_(key), key_char_(key_char), has_alt_modifier_(has_alt_modifier), has_control_modifier_(has_control_modifier), has_shift_modifier_(has_shift_modifier) {} + key_info(int32_t key, int32_t key_char) : key_(key), key_char_(key_char), has_alt_modifier_(false), has_control_modifier_(false), has_shift_modifier_(false) {} + key_info(int32_t key, int32_t key_char, bool has_alt_modifier, bool has_control_modifier, bool has_shift_modifier) : key_(key), key_char_(key_char), has_alt_modifier_(has_alt_modifier), has_control_modifier_(has_control_modifier), has_shift_modifier_(has_shift_modifier) {} static std::string to_string(bool b) {return b ? "true" : "false";} - static int_least32_t to_key(input_list& inputs) { + static int32_t to_key(input_list& inputs) { auto result = 0; auto index = 1; for (auto c : inputs) @@ -288,11 +288,11 @@ namespace { return result; } - static key_info to_key_info(int_least32_t key) { + static key_info to_key_info(int32_t key) { return to_key_info(key, false); } - static key_info to_key_info(int_least32_t key, bool alt) { + static key_info to_key_info(int32_t key, bool alt) { // Ctrl + Space if (key == 0) return key_info {' ', ' ', false, true, false}; @@ -586,12 +586,12 @@ namespace { auto window_width = 80; } -int_least32_t console::background_color() { +int32_t console::background_color() { return ::background_color; } -bool console::background_color(int_least32_t color) { - static auto colors = std::map {{CONSOLE_COLOR_DEFAULT, "\x1b[49m"}, {CONSOLE_COLOR_BLACK, "\x1b[40m"}, {CONSOLE_COLOR_DARK_BLUE, "\x1b[44m"}, {CONSOLE_COLOR_DARK_GREEN, "\x1b[42m"}, {CONSOLE_COLOR_DARK_CYAN, "\x1b[46m"}, {CONSOLE_COLOR_DARK_RED, "\x1b[41m"}, {CONSOLE_COLOR_DARK_MAGENTA, "\x1b[45m"}, {CONSOLE_COLOR_DARK_YELLOW, "\x1b[43m"}, {CONSOLE_COLOR_GRAY, "\x1b[47m"}, {CONSOLE_COLOR_DARK_GRAY, "\x1b[100m"}, {CONSOLE_COLOR_BLUE, "\x1b[104m"}, {CONSOLE_COLOR_GREEN, "\x1b[102m"}, {CONSOLE_COLOR_CYAN, "\x1b[106m"}, {CONSOLE_COLOR_RED, "\x1b[101m"}, {CONSOLE_COLOR_MAGENTA, "\x1b[105m"}, {CONSOLE_COLOR_YELLOW, "\x1b[103m"}, {CONSOLE_COLOR_WHITE, "\x1b[107m"}}; +bool console::background_color(int32_t color) { + static auto colors = std::map {{CONSOLE_COLOR_DEFAULT, "\x1b[49m"}, {CONSOLE_COLOR_BLACK, "\x1b[40m"}, {CONSOLE_COLOR_DARK_BLUE, "\x1b[44m"}, {CONSOLE_COLOR_DARK_GREEN, "\x1b[42m"}, {CONSOLE_COLOR_DARK_CYAN, "\x1b[46m"}, {CONSOLE_COLOR_DARK_RED, "\x1b[41m"}, {CONSOLE_COLOR_DARK_MAGENTA, "\x1b[45m"}, {CONSOLE_COLOR_DARK_YELLOW, "\x1b[43m"}, {CONSOLE_COLOR_GRAY, "\x1b[47m"}, {CONSOLE_COLOR_DARK_GRAY, "\x1b[100m"}, {CONSOLE_COLOR_BLUE, "\x1b[104m"}, {CONSOLE_COLOR_GREEN, "\x1b[102m"}, {CONSOLE_COLOR_CYAN, "\x1b[106m"}, {CONSOLE_COLOR_RED, "\x1b[101m"}, {CONSOLE_COLOR_MAGENTA, "\x1b[105m"}, {CONSOLE_COLOR_YELLOW, "\x1b[103m"}, {CONSOLE_COLOR_WHITE, "\x1b[107m"}}; auto it = colors.find(color); if (it == colors.end()) return false; ::background_color = color; @@ -599,10 +599,10 @@ bool console::background_color(int_least32_t color) { return true; } -bool console::beep(uint_least32_t frequency, uint_least32_t duration) { +bool console::beep(uint32_t frequency, uint32_t duration) { if (frequency < 37 || frequency > 32767) return false; - static constexpr uint_least32_t simple_rate = 8000; + static constexpr uint32_t simple_rate = 8000; static snd_pcm_t* pcm_handle = nullptr; if (pcm_handle == nullptr) { if (snd_pcm_open(&pcm_handle, "default", SND_PCM_STREAM_PLAYBACK, 0)) return false; @@ -610,9 +610,9 @@ bool console::beep(uint_least32_t frequency, uint_least32_t duration) { } unsigned char buffer[2400]; - for (uint_least32_t duration_index = 0; duration_index < duration / 200; ++duration_index) { + for (uint32_t duration_index = 0; duration_index < duration / 200; ++duration_index) { snd_pcm_prepare(pcm_handle); - for (uint_least32_t buffer_index = 0; buffer_index < sizeof(buffer); ++buffer_index) + for (uint32_t buffer_index = 0; buffer_index < sizeof(buffer); ++buffer_index) buffer[buffer_index] = frequency > 0 ? (255 * buffer_index * frequency / simple_rate) : 0; snd_pcm_sframes_t written_frames = snd_pcm_writei(pcm_handle, buffer, sizeof(buffer)); if (written_frames < 0) snd_pcm_recover(pcm_handle, written_frames, 0); @@ -620,25 +620,25 @@ bool console::beep(uint_least32_t frequency, uint_least32_t duration) { return true; } -int_least32_t console::buffer_height() { +int32_t console::buffer_height() { /// @todo console buffer Height on linux and macOS if (::buffer_height == -1) ::buffer_height = console::window_height(); return ::buffer_height; } -bool console::buffer_height(int_least32_t height) { +bool console::buffer_height(int32_t height) { /// @todo set console buffer height on linux and macOS ::buffer_height = height; return true; } -int_least32_t console::buffer_width() { +int32_t console::buffer_width() { /// @todo console buffer Width on linux and macOS if (::buffer_width == -1) ::buffer_width = console::window_width(); return ::buffer_width; } -bool console::buffer_width(int_least32_t width) { +bool console::buffer_width(int32_t width) { /// @todo set console buffer width on linux and macOS ::buffer_width = width; return true; @@ -654,7 +654,7 @@ bool console::clear() { return set_cursor_position(0, 0); } -int_least32_t console::cursor_left() { +int32_t console::cursor_left() { if (!terminal::is_ansi_supported()) return ::cursor_left; std::cout << "\x1b[6n" << std::flush; terminal::terminal_.getch(); @@ -667,11 +667,11 @@ int_least32_t console::cursor_left() { return ::cursor_left; } -int_least32_t console::cursor_size() { +int32_t console::cursor_size() { return ::cursor_size; } -bool console::cursor_size(int_least32_t size) { +bool console::cursor_size(int32_t size) { ::cursor_size = size; if (!terminal::is_ansi_supported()) return true; if (size < 50) std::cout << "\x1b[4 q" << std::flush; @@ -679,7 +679,7 @@ bool console::cursor_size(int_least32_t size) { return true; } -int_least32_t console::cursor_top() { +int32_t console::cursor_top() { if (!terminal::is_ansi_supported()) return ::cursor_top; std::cout << "\x1b[6n" << std::flush; terminal::terminal_.getch(); @@ -702,7 +702,7 @@ bool console::cursor_visible(bool visible) { return true; } -int_least32_t console::foreground_color() { +int32_t console::foreground_color() { return ::foreground_color; } @@ -710,8 +710,8 @@ bool console::echo(bool on) { return terminal::terminal_.echo(on); } -bool console::foreground_color(int_least32_t color) { - static auto colors = std::map {{CONSOLE_COLOR_DEFAULT, "\x1b[39m"}, {CONSOLE_COLOR_BLACK, "\x1b[30m"}, {CONSOLE_COLOR_DARK_BLUE, "\x1b[34m"}, {CONSOLE_COLOR_DARK_GREEN, "\x1b[32m"}, {CONSOLE_COLOR_DARK_CYAN, "\x1b[36m"}, {CONSOLE_COLOR_DARK_RED, "\x1b[31m"}, {CONSOLE_COLOR_DARK_MAGENTA, "\x1b[35m"}, {CONSOLE_COLOR_DARK_YELLOW, "\x1b[33m"}, {CONSOLE_COLOR_GRAY, "\x1b[37m"}, {CONSOLE_COLOR_DARK_GRAY, "\x1b[90m"}, {CONSOLE_COLOR_BLUE, "\x1b[94m"}, {CONSOLE_COLOR_GREEN, "\x1b[92m"}, {CONSOLE_COLOR_CYAN, "\x1b[96m"}, {CONSOLE_COLOR_RED, "\x1b[91m"}, {CONSOLE_COLOR_MAGENTA, "\x1b[95m"}, {CONSOLE_COLOR_YELLOW, "\x1b[93m"}, {CONSOLE_COLOR_WHITE, "\x1b[97m"}}; +bool console::foreground_color(int32_t color) { + static auto colors = std::map {{CONSOLE_COLOR_DEFAULT, "\x1b[39m"}, {CONSOLE_COLOR_BLACK, "\x1b[30m"}, {CONSOLE_COLOR_DARK_BLUE, "\x1b[34m"}, {CONSOLE_COLOR_DARK_GREEN, "\x1b[32m"}, {CONSOLE_COLOR_DARK_CYAN, "\x1b[36m"}, {CONSOLE_COLOR_DARK_RED, "\x1b[31m"}, {CONSOLE_COLOR_DARK_MAGENTA, "\x1b[35m"}, {CONSOLE_COLOR_DARK_YELLOW, "\x1b[33m"}, {CONSOLE_COLOR_GRAY, "\x1b[37m"}, {CONSOLE_COLOR_DARK_GRAY, "\x1b[90m"}, {CONSOLE_COLOR_BLUE, "\x1b[94m"}, {CONSOLE_COLOR_GREEN, "\x1b[92m"}, {CONSOLE_COLOR_CYAN, "\x1b[96m"}, {CONSOLE_COLOR_RED, "\x1b[91m"}, {CONSOLE_COLOR_MAGENTA, "\x1b[95m"}, {CONSOLE_COLOR_YELLOW, "\x1b[93m"}, {CONSOLE_COLOR_WHITE, "\x1b[97m"}}; auto it = colors.find(color); if (it == colors.end()) return false; ::foreground_color = color; @@ -719,12 +719,12 @@ bool console::foreground_color(int_least32_t color) { return true; } -int_least32_t console::input_code_page() { +int32_t console::input_code_page() { /// @todo console input code page status on linux and macOS return ::input_code_page; } -bool console::input_code_page(int_least32_t code_page) { +bool console::input_code_page(int32_t code_page) { /// @todo set console input code page on linux and macOS ::input_code_page = code_page; return true; @@ -734,11 +734,11 @@ bool console::key_available() { return key_info::key_available(); } -int_least32_t console::largest_window_height() { +int32_t console::largest_window_height() { return ::largest_window_height; } -int_least32_t console::largest_window_width() { +int32_t console::largest_window_width() { return ::largest_window_width; } @@ -747,12 +747,12 @@ bool console::number_lock() { return ::number_lock; } -int_least32_t console::output_code_page() { +int32_t console::output_code_page() { /// @todo console output code page status on linux and macOS return ::output_code_page; } -bool console::output_code_page(int_least32_t code_page) { +bool console::output_code_page(int32_t code_page) { /// @todo set console output code page on linux and macOS ::output_code_page = code_page; return true; @@ -767,7 +767,7 @@ void console::read_key(char32_t& key_char, char32_t& key_code, bool& alt, bool& shift = key_info.has_shift_modifier(); } -void console::register_user_cancel_callback(std::function user_cancel_callback) { +void console::register_user_cancel_callback(std::function user_cancel_callback) { ::user_cancel_callback = user_cancel_callback; } @@ -775,7 +775,7 @@ bool console::reset_color() { return console::background_color(CONSOLE_COLOR_DEFAULT) && console::foreground_color(CONSOLE_COLOR_DEFAULT); } -bool console::set_cursor_position(int_least32_t left, int_least32_t top) { +bool console::set_cursor_position(int32_t left, int32_t top) { ::cursor_left = left; ::cursor_top = top; if (terminal::is_ansi_supported()) std::cout << "\x1b[" << top + 1 << ";" << left + 1 << "f" << std::flush; @@ -812,7 +812,7 @@ bool console::treat_control_c_as_input(bool treat_control_c_as_input) { return true; } -int_least32_t console::window_height() { +int32_t console::window_height() { if (!terminal::is_ansi_supported()) return ::window_height; auto top = console::cursor_top(); console::set_cursor_position(console::cursor_left(), 999); @@ -822,35 +822,35 @@ int_least32_t console::window_height() { return ::window_height; } -bool console::window_height(int_least32_t height) { +bool console::window_height(int32_t height) { /// @todo set console window height on linux and macOS ::window_height = height; return true; } -int_least32_t console::window_left() { +int32_t console::window_left() { /// @todo get console window left on linux and macOS return ::window_left; } -bool console::window_left(int_least32_t left) { +bool console::window_left(int32_t left) { /// @todo set console window left on linux and macOS ::window_left = left; return true; } -int_least32_t console::window_top() { +int32_t console::window_top() { /// @todo get console window top on linux and macOS return ::window_top; } -bool console::window_top(int_least32_t top) { +bool console::window_top(int32_t top) { /// @todo set console window top on linux and macOS ::window_top = top; return true; } -int_least32_t console::window_width() { +int32_t console::window_width() { if (!terminal::is_ansi_supported()) return ::window_width; auto left = console::cursor_left(); console::set_cursor_position(999, console::cursor_top()); @@ -860,7 +860,7 @@ int_least32_t console::window_width() { return ::window_width; } -bool console::window_width(int_least32_t width) { +bool console::window_width(int32_t width) { /// @todo set console window width on linux and macOS ::window_width = width; return true; diff --git a/src/xtd.core.native.unix/src/xtd/native/unix/cryptography.cpp b/src/xtd.core.native.unix/src/xtd/native/unix/cryptography.cpp index 03cff6fe8e6..d56d1ca762a 100644 --- a/src/xtd.core.native.unix/src/xtd/native/unix/cryptography.cpp +++ b/src/xtd.core.native.unix/src/xtd/native/unix/cryptography.cpp @@ -8,7 +8,7 @@ using namespace std; using namespace xtd::native; -vector cryptography::machine_guid() { +vector cryptography::machine_guid() { static auto first = true; static auto guid_str = unix::shell_execute::run("ioreg", "-rd1 -c IOPlatformExpertDevice | grep -E '(UUID)'"); if (first) guid_str = guid_str.substr(guid_str.find("=") + 1); @@ -20,8 +20,8 @@ vector cryptography::machine_guid() { if (hex_chars.find(static_cast(toupper(guid_str[index]))) == hex_chars.npos) guid_str.erase(index--, 1); if (guid_str.size() != 32) guid_str = guid_fallback; - auto bytes = vector {}; + auto bytes = vector {}; for (auto index = 0u; index < guid_str.size(); index += 2) - bytes.push_back(static_cast(stoi(guid_str.substr(index, 2), 0, 16))); + bytes.push_back(static_cast(stoi(guid_str.substr(index, 2), 0, 16))); return bytes; } diff --git a/src/xtd.core.native.unix/src/xtd/native/unix/date_time.cpp b/src/xtd.core.native.unix/src/xtd/native/unix/date_time.cpp index ef9bdcfef08..d865fbcfab8 100644 --- a/src/xtd.core.native.unix/src/xtd/native/unix/date_time.cpp +++ b/src/xtd.core.native.unix/src/xtd/native/unix/date_time.cpp @@ -13,7 +13,7 @@ using namespace std; using namespace xtd::native; namespace { - static const int_least64_t ticks_per_second = 10000000; + static const int64_t ticks_per_second = 10000000; /* Generate by this c# code source : @@ -240,7 +240,7 @@ date_time::time_zone_info date_time::get_local_time_zone() { if (iterator != stzis.end()) { local_time_zone = *iterator; local_time_zone.id = reinterpret_cast(tzname[0]); - //local_time_zone.base_utc_offset = static_cast(-timezone * ticks_per_second); + //local_time_zone.base_utc_offset = static_cast(-timezone * ticks_per_second); local_time_zone.daylight_name = reinterpret_cast(tzname[1]); //local_time_zone.display_name = string_printf("(UTC%s%02d:%02d) %s", (-timezone) ? "+" : "", abs(timezone) / 3600, (abs(timezone) % 3600) / 60, reinterpret_cast(tzname[0])); local_time_zone.standard_name = reinterpret_cast(tzname[0]); diff --git a/src/xtd.core.native.unix/src/xtd/native/unix/debugger.cpp b/src/xtd.core.native.unix/src/xtd/native/unix/debugger.cpp index 5dcd6f62962..640eb6612a6 100644 --- a/src/xtd.core.native.unix/src/xtd/native/unix/debugger.cpp +++ b/src/xtd.core.native.unix/src/xtd/native/unix/debugger.cpp @@ -44,7 +44,7 @@ bool debugger::launch() { return true; } -int_least32_t debugger::show_assert_dialog(const std::string& text, const std::string& caption) { +int32_t debugger::show_assert_dialog(const std::string& text, const std::string& caption) { gtk_init_check(0, nullptr); auto dialog = gtk_message_dialog_new(nullptr, GtkDialogFlags::GTK_DIALOG_MODAL, GtkMessageType::GTK_MESSAGE_ERROR, GtkButtonsType::GTK_BUTTONS_NONE, "%s", text.c_str()); gtk_window_set_title(GTK_WINDOW(dialog), caption.c_str()); @@ -56,7 +56,7 @@ int_least32_t debugger::show_assert_dialog(const std::string& text, const std::s return return_code == GTK_RESPONSE_YES ? ADR_ABORT : (return_code == GTK_RESPONSE_NO ? ADR_RETRY : ADR_IGNORE); } -void debugger::log(int_least32_t level, const std::string& category, const std::string& message) { +void debugger::log(int32_t level, const std::string& category, const std::string& message) { syslog(LOG_EMERG | LOG_USER, "%s", message.c_str()); std::cerr << message << std::flush; } diff --git a/src/xtd.core.native.unix/src/xtd/native/unix/directory.cpp b/src/xtd.core.native.unix/src/xtd/native/unix/directory.cpp index 61a141b9fb2..4e84d533b1b 100644 --- a/src/xtd.core.native.unix/src/xtd/native/unix/directory.cpp +++ b/src/xtd.core.native.unix/src/xtd/native/unix/directory.cpp @@ -60,7 +60,7 @@ directory::directory_iterator& directory::directory_iterator::operator ++() { return *this; } -directory::directory_iterator directory::directory_iterator::operator ++(int_least32_t) { +directory::directory_iterator directory::directory_iterator::operator ++(int32_t) { auto result = directory_iterator {*this}; ++(*this); return result; @@ -130,7 +130,7 @@ directory::file_iterator& directory::file_iterator::operator ++() { return *this; } -directory::file_iterator directory::file_iterator::operator ++(int_least32_t) { +directory::file_iterator directory::file_iterator::operator ++(int32_t) { auto result = file_iterator {*this}; ++(*this); return result; @@ -200,7 +200,7 @@ directory::file_and_directory_iterator& directory::file_and_directory_iterator:: return *this; } -directory::file_and_directory_iterator directory::file_and_directory_iterator::operator ++(int_least32_t) { +directory::file_and_directory_iterator directory::file_and_directory_iterator::operator ++(int32_t) { auto result = file_and_directory_iterator {*this}; ++(*this); return result; @@ -231,7 +231,7 @@ const std::string& directory::file_and_directory_iterator::pattern() const { return data_->pattern_; } -int_least32_t directory::create(const std::string& directory_name) { +int32_t directory::create(const std::string& directory_name) { return mkdir(directory_name.c_str(), S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IXGRP | S_IROTH | S_IWOTH | S_IXOTH); } @@ -260,10 +260,10 @@ string directory::get_current_directory() { return result ? path : ""; } -int_least32_t directory::remove(const std::string& directory_name) { +int32_t directory::remove(const std::string& directory_name) { return rmdir(directory_name.c_str()); } -int_least32_t directory::set_current_directory(const std::string& directory_name) { +int32_t directory::set_current_directory(const std::string& directory_name) { return chdir(directory_name.c_str()); } diff --git a/src/xtd.core.native.unix/src/xtd/native/unix/dns.cpp b/src/xtd.core.native.unix/src/xtd/native/unix/dns.cpp index 11a8c807bc8..786e849a665 100644 --- a/src/xtd.core.native.unix/src/xtd/native/unix/dns.cpp +++ b/src/xtd.core.native.unix/src/xtd/native/unix/dns.cpp @@ -24,9 +24,9 @@ void dns::destroy(intmax_t host) { delete reinterpret_cast(host); } -intmax_t dns::get_host_by_address(const string& host_address, int_least32_t host_address_type) { +intmax_t dns::get_host_by_address(const string& host_address, int32_t host_address_type) { auto lock = lock_guard {dns_mutex}; - auto internet_address = int_least64_t {0}; + auto internet_address = int64_t {0}; inet_pton(host_address_type, host_address.c_str(), &internet_address); auto host = gethostbyaddr(reinterpret_cast(&internet_address), host_address_type == ADDRESS_FAMILY_INTER_NETWORK ? 4 : 16, host_address_type); if (host == nullptr) return 0; @@ -48,11 +48,11 @@ vector dns::get_aliases(intmax_t host) { return aliases; } -vector> dns::get_addresses(intmax_t host) { - auto addresses = vector> {}; +vector> dns::get_addresses(intmax_t host) { + auto addresses = vector> {}; auto index = size_t {0}; while (reinterpret_cast(host)->h_addr_list[index] != nullptr) { - addresses.emplace_back(reinterpret_cast(reinterpret_cast(host)->h_addr_list[index]), reinterpret_cast(reinterpret_cast(host)->h_addr_list[index]) + (reinterpret_cast(host)->h_addrtype == ADDRESS_FAMILY_INTER_NETWORK ? 4 : 16)); + addresses.emplace_back(reinterpret_cast(reinterpret_cast(host)->h_addr_list[index]), reinterpret_cast(reinterpret_cast(host)->h_addr_list[index]) + (reinterpret_cast(host)->h_addrtype == ADDRESS_FAMILY_INTER_NETWORK ? 4 : 16)); index++; } return addresses; @@ -62,7 +62,7 @@ string dns::get_host_name(intmax_t host) { return reinterpret_cast(host)->h_name; } -int_least32_t dns::get_host_name(string& host_name) { +int32_t dns::get_host_name(string& host_name) { auto name_length = static_cast(sysconf(_SC_HOST_NAME_MAX)); auto name = string(name_length, '\0'); auto result = gethostname(name.data(), name_length); diff --git a/src/xtd.core.native.unix/src/xtd/native/unix/drive.cpp b/src/xtd.core.native.unix/src/xtd/native/unix/drive.cpp index d220bdc0733..bd140fcc438 100644 --- a/src/xtd.core.native.unix/src/xtd/native/unix/drive.cpp +++ b/src/xtd.core.native.unix/src/xtd/native/unix/drive.cpp @@ -34,7 +34,7 @@ bool drive::get_available_free_space(const std::string& root_path_name, size_t& return true; } -int_least32_t drive::get_drive_type(const std::string& root_path_name) { +int32_t drive::get_drive_type(const std::string& root_path_name) { if (root_drive == root_path_name) return DRIVE_FIXED; if (find(ram_drives.begin(), ram_drives.end(), root_path_name) != ram_drives.end()) return DRIVE_RAMDISK; if (find(network_drives.begin(), network_drives.end(), root_path_name) != network_drives.end()) return DRIVE_REMOTE; diff --git a/src/xtd.core.native.unix/src/xtd/native/unix/environment.cpp b/src/xtd.core.native.unix/src/xtd/native/unix/environment.cpp index b2ec3a49ad4..68e28a8504b 100644 --- a/src/xtd.core.native.unix/src/xtd/native/unix/environment.cpp +++ b/src/xtd.core.native.unix/src/xtd/native/unix/environment.cpp @@ -17,11 +17,11 @@ using namespace std::literals; using namespace xtd::native; extern char** environ; -int_least32_t __environment_argc = 0; +int32_t __environment_argc = 0; char** __environment_argv; namespace { - __attribute__((constructor)) void startup_program(int_least32_t argc, char** argv) { + __attribute__((constructor)) void startup_program(int32_t argc, char** argv) { __environment_argc = argc; __environment_argv = argv; } @@ -43,7 +43,7 @@ namespace { } } -int_least32_t environment::at_quick_exit(void (*on_quick_exit)(void)) { +int32_t environment::at_quick_exit(void (*on_quick_exit)(void)) { return std::at_quick_exit(on_quick_exit); } @@ -112,7 +112,7 @@ string environment::get_distribution_name() { return name_it->second; } -void environment::get_distribution_version(int_least32_t& major, int_least32_t& minor, int_least32_t& build, int_least32_t& revision) { +void environment::get_distribution_version(int32_t& major, int32_t& minor, int32_t& build, int32_t& revision) { auto name_it = get_distribution_key_values().find("VERSION_ID"); if (name_it == get_distribution_key_values().end()) return; auto versions = xtd::native::unix::strings::split(name_it->second, {'.'}); @@ -126,7 +126,7 @@ string environment::get_distribution_version_string() { return iterator->second; } -string environment::get_environment_variable(const string& variable, int_least32_t target) { +string environment::get_environment_variable(const string& variable, int32_t target) { if (target == ENVIRONMENT_VARIABLE_TARGET_PROCESS) { auto value = getenv(variable.c_str()); return value ? value : ""; @@ -140,7 +140,7 @@ string environment::get_environment_variable(const string& variable, int_least32 return ""; } -map& environment::get_environment_variables(int_least32_t target) { +map& environment::get_environment_variables(int32_t target) { if (target == ENVIRONMENT_VARIABLE_TARGET_PROCESS) { static auto envs = map {}; if (envs.size() == 0) { @@ -166,8 +166,8 @@ map& environment::get_environment_variables(int_least32_t target return envs; } -string environment::get_know_folder_path(int_least32_t csidl) { - static auto special_folders = map {{CSIDL_DESKTOP, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS) + "/Desktop"}, {CSIDL_PERSONAL, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS)}, {CSIDL_MYMUSIC, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS) + "/Music"}, {CSIDL_MYVIDEO, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS) + "/Videos"}, {CSIDL_DESKTOPDIRECTORY, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS) + "/Desktop"}, {CSIDL_FONTS, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS) + "/.fonts"}, {CSIDL_TEMPLATES, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS) + "/Templates"}, {CSIDL_APPDATA, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS) + "/.config"}, {CSIDL_LOCAL_APPDATA, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS) + "/.local/share"}, {CSIDL_COMMON_APPDATA, "/usr/share"}, {CSIDL_MYPICTURES, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS) + "/Pictures"}, {CSIDL_PROFILE, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS)}, {CSIDL_COMMON_TEMPLATES, "/usr/share/templates"}, {CSIDL_HOME, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS)}}; +string environment::get_know_folder_path(int32_t csidl) { + static auto special_folders = map {{CSIDL_DESKTOP, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS) + "/Desktop"}, {CSIDL_PERSONAL, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS)}, {CSIDL_MYMUSIC, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS) + "/Music"}, {CSIDL_MYVIDEO, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS) + "/Videos"}, {CSIDL_DESKTOPDIRECTORY, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS) + "/Desktop"}, {CSIDL_FONTS, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS) + "/.fonts"}, {CSIDL_TEMPLATES, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS) + "/Templates"}, {CSIDL_APPDATA, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS) + "/.config"}, {CSIDL_LOCAL_APPDATA, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS) + "/.local/share"}, {CSIDL_COMMON_APPDATA, "/usr/share"}, {CSIDL_MYPICTURES, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS) + "/Pictures"}, {CSIDL_PROFILE, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS)}, {CSIDL_COMMON_TEMPLATES, "/usr/share/templates"}, {CSIDL_HOME, get_environment_variable("HOME", ENVIRONMENT_VARIABLE_TARGET_PROCESS)}}; auto it = special_folders.find(csidl); if (it == special_folders.end()) return ""; return it->second; @@ -177,12 +177,12 @@ string environment::get_machine_name() { return unix::strings::replace(unix::shell_execute::run("uname", "-n"), "\n", ""); } -int_least32_t environment::get_os_platform_id() { +int32_t environment::get_os_platform_id() { if (unix::shell_execute::run("uname", "-a").find("FreeBSD") != string::npos) return PLATFORM_FREEBSD; return PLATFORM_UNIX; } -void environment::get_os_version(int_least32_t& major, int_least32_t& minor, int_least32_t& build, int_least32_t& revision) { +void environment::get_os_version(int32_t& major, int32_t& minor, int32_t& build, int32_t& revision) { auto numbers = unix::strings::split(unix::shell_execute::run("uname", "-r"), {'.', '-', '\n'}); if (numbers.size() < 1 || !unix::strings::try_parse(numbers[0], major)) major = 0; if (numbers.size() < 2 || !unix::strings::try_parse(numbers[1], minor)) minor = 0; @@ -190,7 +190,7 @@ void environment::get_os_version(int_least32_t& major, int_least32_t& minor, int if (numbers.size() < 4 || !unix::strings::try_parse(numbers[3], revision)) revision = 0; } -uint_least32_t environment::get_processor_count() { +uint32_t environment::get_processor_count() { return thread::hardware_concurrency(); } @@ -208,7 +208,7 @@ size_t environment::get_system_page_size() { return sysconf(_SC_PAGESIZE); } -uint_least32_t environment::get_tick_count() { +uint32_t environment::get_tick_count() { // https://stackoverflow.com/questions/1540627/what-api-do-i-call-to-get-the-system-uptime struct sysinfo info {}; sysinfo(&info); @@ -248,11 +248,11 @@ string environment::new_line() { return "\n"; } -void environment::quick_exit(int_least32_t exit_code) noexcept { +void environment::quick_exit(int32_t exit_code) noexcept { std::quick_exit(exit_code); } -void environment::set_environment_variable(const string& name, const string& value, int_least32_t target) { +void environment::set_environment_variable(const string& name, const string& value, int32_t target) { if (target == ENVIRONMENT_VARIABLE_TARGET_PROCESS) setenv(name.c_str(), value.c_str(), 1); else if (target == ENVIRONMENT_VARIABLE_TARGET_USER) { @@ -262,7 +262,7 @@ void environment::set_environment_variable(const string& name, const string& val } } -void environment::unset_environment_variable(const string& name, int_least32_t target) { +void environment::unset_environment_variable(const string& name, int32_t target) { if (target == ENVIRONMENT_VARIABLE_TARGET_PROCESS) unsetenv(name.c_str()); else if (target == ENVIRONMENT_VARIABLE_TARGET_USER) { @@ -272,6 +272,6 @@ void environment::unset_environment_variable(const string& name, int_least32_t t } } -int_least64_t environment::working_set() { +int64_t environment::working_set() { return 0; } diff --git a/src/xtd.core.native.unix/src/xtd/native/unix/file.cpp b/src/xtd.core.native.unix/src/xtd/native/unix/file.cpp index 3da8d5d9d56..65268c759e4 100644 --- a/src/xtd.core.native.unix/src/xtd/native/unix/file.cpp +++ b/src/xtd.core.native.unix/src/xtd/native/unix/file.cpp @@ -11,7 +11,7 @@ using namespace std; using namespace xtd::native; -int_least32_t file::copy(const std::string& source_file, const std::string& target_file) { +int32_t file::copy(const std::string& source_file, const std::string& target_file) { auto ifs = ifstream {source_file, ios::binary}; if (!ifs) return -1; auto ofs = ofstream {target_file, ios::trunc | ios::binary}; @@ -33,12 +33,12 @@ size_t file::get_size(const std::string& path) { return static_cast(status.st_size); } -int_least32_t file::move(const std::string& old_path, const std::string& new_path) { +int32_t file::move(const std::string& old_path, const std::string& new_path) { auto file_attributes = 0; if (file_system::get_attributes(new_path, file_attributes) == 0) return -1; return rename(old_path.c_str(), new_path.c_str()); } -int_least32_t file::remove(const std::string& file) { +int32_t file::remove(const std::string& file) { return unlink(file.c_str()); } diff --git a/src/xtd.core.native.unix/src/xtd/native/unix/file_system.cpp b/src/xtd.core.native.unix/src/xtd/native/unix/file_system.cpp index 091cbc28866..ab9b911cac1 100644 --- a/src/xtd.core.native.unix/src/xtd/native/unix/file_system.cpp +++ b/src/xtd.core.native.unix/src/xtd/native/unix/file_system.cpp @@ -18,10 +18,10 @@ using namespace std; using namespace xtd::native; -int_least32_t file_system::get_attributes(const std::string& path, int_least32_t& attributes) { +int32_t file_system::get_attributes(const std::string& path, int32_t& attributes) { struct system_attribute_to_file_attribute_converter { - int_least32_t operator()(int_least32_t attribute) { - int_least32_t file_attributes = 0; + int32_t operator()(int32_t attribute) { + int32_t file_attributes = 0; if ((attribute & S_IRUSR) == S_IRUSR && (attribute & S_IWUSR) != S_IWUSR) file_attributes |= FILE_ATTRIBUTE_READONLY; if ((attribute & S_IFSOCK) == S_IFSOCK || (attribute & S_IFIFO) == S_IFIFO) file_attributes |= FILE_ATTRIBUTE_SYSTEM; if ((attribute & S_IFDIR) == S_IFDIR) file_attributes |= FILE_ATTRIBUTE_DIRECTORY; @@ -37,7 +37,7 @@ int_least32_t file_system::get_attributes(const std::string& path, int_least32_t return 0; } -int_least32_t file_system::get_file_times(const std::string& path, time_t& creation_time, time_t& last_access_time, time_t& last_write_time) { +int32_t file_system::get_file_times(const std::string& path, time_t& creation_time, time_t& last_access_time, time_t& last_write_time) { struct stat status; if (stat(path.c_str(), &status) != 0) return -1; @@ -73,10 +73,10 @@ string file_system::get_full_path(const string& relative_path) { return full_path; } -int_least32_t file_system::get_permissions(const std::string& path, int_least32_t& permissions) { +int32_t file_system::get_permissions(const std::string& path, int32_t& permissions) { struct system_permission_to_file_permission_converter { - int_least32_t operator()(mode_t permission) { - int_least32_t file_permissions = 0; + int32_t operator()(mode_t permission) { + int32_t file_permissions = 0; if ((permission & S_IRUSR) == S_IRUSR) file_permissions |= FILE_PERMISSIONS_OWNER_READ; if ((permission & S_IWUSR) == S_IWUSR) file_permissions |= FILE_PERMISSIONS_OWNER_WRITE; if ((permission & S_IXUSR) == S_IXUSR) file_permissions |= FILE_PERMISSIONS_OWNER_EXECUTE; @@ -99,7 +99,7 @@ int_least32_t file_system::get_permissions(const std::string& path, int_least32_ } }; struct stat s; - int_least32_t ret_value = stat(path.c_str(), &s); + int32_t ret_value = stat(path.c_str(), &s); permissions = system_permission_to_file_permission_converter()(s.st_mode); return ret_value; } @@ -113,7 +113,7 @@ bool file_system::is_path_too_long(const std::string& path) { return file_name.size() > NAME_MAX; } -int_least32_t file_system::set_attributes(const std::string& path, int_least32_t attributes) { +int32_t file_system::set_attributes(const std::string& path, int32_t attributes) { struct stat s; if (stat(path.c_str(), &s) != 0) return -1; @@ -127,7 +127,7 @@ int_least32_t file_system::set_attributes(const std::string& path, int_least32_t return chmod(path.c_str(), s.st_mode); } -int_least32_t file_system::set_creation_time(const std::string& path, time_t creation_time) { +int32_t file_system::set_creation_time(const std::string& path, time_t creation_time) { // There is no creation time on linux so we update the last modification time instead... utimbuf times; time_t creation_time_old = 0, last_access_time = 0, last_write_time = 0; @@ -137,7 +137,7 @@ int_least32_t file_system::set_creation_time(const std::string& path, time_t cre return utime(path.c_str(), ×); } -int_least32_t file_system::set_last_access_time(const std::string& path, time_t last_access_time) { +int32_t file_system::set_last_access_time(const std::string& path, time_t last_access_time) { utimbuf times; time_t creation_time = 0, last_access_time_old = 0, last_write_time = 0; get_file_times(path, creation_time, last_access_time_old, last_write_time); @@ -146,7 +146,7 @@ int_least32_t file_system::set_last_access_time(const std::string& path, time_t return utime(path.c_str(), ×); } -int_least32_t file_system::set_last_write_time(const std::string& path, time_t last_write_time) { +int32_t file_system::set_last_write_time(const std::string& path, time_t last_write_time) { utimbuf times; time_t creation_time = 0, last_access_time = 0, last_write_time_old = 0; get_file_times(path, creation_time, last_access_time, last_write_time_old); @@ -155,10 +155,10 @@ int_least32_t file_system::set_last_write_time(const std::string& path, time_t l return utime(path.c_str(), ×); } -int_least32_t file_system::set_permissions(const std::string& path, int_least32_t permissions) { +int32_t file_system::set_permissions(const std::string& path, int32_t permissions) { struct file_permission_to_system_permission_converter { - mode_t operator()(int_least32_t permission) { - int_least32_t system_permissions = 0; + mode_t operator()(int32_t permission) { + int32_t system_permissions = 0; if ((permission & FILE_PERMISSIONS_OWNER_READ) == FILE_PERMISSIONS_OWNER_READ) system_permissions |= S_IRUSR; if ((permission & FILE_PERMISSIONS_OWNER_WRITE) == FILE_PERMISSIONS_OWNER_WRITE) system_permissions |= S_IWUSR; if ((permission & FILE_PERMISSIONS_OWNER_EXECUTE) == FILE_PERMISSIONS_OWNER_EXECUTE) system_permissions |= S_IXUSR; diff --git a/src/xtd.core.native.unix/src/xtd/native/unix/guid.cpp b/src/xtd.core.native.unix/src/xtd/native/unix/guid.cpp index d13c8531e08..0bcb5371758 100644 --- a/src/xtd.core.native.unix/src/xtd/native/unix/guid.cpp +++ b/src/xtd.core.native.unix/src/xtd/native/unix/guid.cpp @@ -8,8 +8,8 @@ using namespace xtd::native; -std::vector guid::new_guid() { - auto guid = std::vector(16); +std::vector guid::new_guid() { + auto guid = std::vector(16); uuid_generate(guid.data()); return guid; } diff --git a/src/xtd.core.native.unix/src/xtd/native/unix/interlocked.cpp b/src/xtd.core.native.unix/src/xtd/native/unix/interlocked.cpp index b3f4f4288e9..5ea9044feaa 100644 --- a/src/xtd.core.native.unix/src/xtd/native/unix/interlocked.cpp +++ b/src/xtd.core.native.unix/src/xtd/native/unix/interlocked.cpp @@ -12,21 +12,21 @@ using namespace std; using namespace xtd::native; -int_least32_t interlocked::add(int_least32_t& location, int_least32_t value) { +int32_t interlocked::add(int32_t& location, int32_t value) { __sync_fetch_and_add(&location, value); return location; } -int_least64_t interlocked::add(int_least64_t& location, int_least64_t value) { +int64_t interlocked::add(int64_t& location, int64_t value) { __sync_fetch_and_add(&location, value); return location; } -int_least32_t interlocked::compare_exchange(int_least32_t& location, int_least32_t value, int_least32_t comparand) { +int32_t interlocked::compare_exchange(int32_t& location, int32_t value, int32_t comparand) { return __sync_val_compare_and_swap(&location, comparand, value); } -int_least64_t interlocked::compare_exchange(int_least64_t& location, int_least64_t value, int_least64_t comparand) { +int64_t interlocked::compare_exchange(int64_t& location, int64_t value, int64_t comparand) { return __sync_val_compare_and_swap(&location, comparand, value); } @@ -38,21 +38,21 @@ void* interlocked::compare_exchange(void*& location, void* value, void* comparan return __sync_val_compare_and_swap(&location, comparand, value); } -int_least32_t interlocked::decrement(int_least32_t& location) { +int32_t interlocked::decrement(int32_t& location) { __sync_fetch_and_sub(&location, 1); return location; } -int_least64_t interlocked::decrement(int_least64_t& location) { +int64_t interlocked::decrement(int64_t& location) { __sync_fetch_and_sub(&location, 1); return location; } -int_least32_t interlocked::exchange(int_least32_t& location, int_least32_t value) { +int32_t interlocked::exchange(int32_t& location, int32_t value) { return __sync_val_compare_and_swap(&location, location, value); } -int_least64_t interlocked::exchange(int_least64_t& location, int_least64_t value) { +int64_t interlocked::exchange(int64_t& location, int64_t value) { return __sync_val_compare_and_swap(&location, location, value); } @@ -64,12 +64,12 @@ void* interlocked::exchange(void*& location, void* value) { return __sync_val_compare_and_swap(&location, location, value); } -int_least32_t interlocked::increment(int_least32_t& location) { +int32_t interlocked::increment(int32_t& location) { __sync_fetch_and_add(&location, 1); return location; } -int_least64_t interlocked::increment(int_least64_t& location) { +int64_t interlocked::increment(int64_t& location) { __sync_fetch_and_add(&location, 1); return location; } diff --git a/src/xtd.core.native.unix/src/xtd/native/unix/named_event_wait_handle.cpp b/src/xtd.core.native.unix/src/xtd/native/unix/named_event_wait_handle.cpp index d5e7c764c86..a523233db5a 100644 --- a/src/xtd.core.native.unix/src/xtd/native/unix/named_event_wait_handle.cpp +++ b/src/xtd.core.native.unix/src/xtd/native/unix/named_event_wait_handle.cpp @@ -47,7 +47,7 @@ bool named_event_wait_handle::reset(intmax_t handle, bool& io_error) { return true; } -uint_least32_t named_event_wait_handle::wait(intmax_t handle, int_least32_t milliseconds_timeout, bool manual_reset) { +uint32_t named_event_wait_handle::wait(intmax_t handle, int32_t milliseconds_timeout, bool manual_reset) { if (reinterpret_cast(handle) == SEM_FAILED) return 0xFFFFFFFF; auto result = milliseconds_timeout == -1 ? sem_wait(reinterpret_cast(handle)) : sem_milliseconds_timedwait(reinterpret_cast(handle), milliseconds_timeout); if (result && errno == EAGAIN) return 0xFFFFFFFF; diff --git a/src/xtd.core.native.unix/src/xtd/native/unix/named_mutex.cpp b/src/xtd.core.native.unix/src/xtd/native/unix/named_mutex.cpp index fa953dc16e6..acdb5b06251 100644 --- a/src/xtd.core.native.unix/src/xtd/native/unix/named_mutex.cpp +++ b/src/xtd.core.native.unix/src/xtd/native/unix/named_mutex.cpp @@ -36,7 +36,7 @@ bool named_mutex::signal(intmax_t handle, bool& io_error) { return !io_error; } -uint_least32_t named_mutex::wait(intmax_t handle, int_least32_t milliseconds_timeout) { +uint32_t named_mutex::wait(intmax_t handle, int32_t milliseconds_timeout) { if (reinterpret_cast(handle) == SEM_FAILED) return 0xFFFFFFFF; auto result = milliseconds_timeout == -1 ? sem_wait(reinterpret_cast(handle)) : sem_milliseconds_timedwait(reinterpret_cast(handle), milliseconds_timeout); if (result && errno == EAGAIN) return 0xFFFFFFFF; diff --git a/src/xtd.core.native.unix/src/xtd/native/unix/named_semaphore.cpp b/src/xtd.core.native.unix/src/xtd/native/unix/named_semaphore.cpp index 67d212feda7..3349ccafc5c 100644 --- a/src/xtd.core.native.unix/src/xtd/native/unix/named_semaphore.cpp +++ b/src/xtd.core.native.unix/src/xtd/native/unix/named_semaphore.cpp @@ -9,7 +9,7 @@ using namespace xtd::native; -intmax_t named_semaphore::create(int_least32_t initial_count, int_least32_t max_count, const std::string& name) { +intmax_t named_semaphore::create(int32_t initial_count, int32_t max_count, const std::string& name) { auto semaphore = sem_open(name.c_str(), O_CREAT | O_EXCL, S_IRUSR | S_IWUSR, std::min(initial_count, max_count)); return reinterpret_cast(semaphore); } @@ -28,7 +28,7 @@ intmax_t named_semaphore::open(const std::string& name) { return reinterpret_cast(semaphore); } -bool named_semaphore::signal(intmax_t handle, int_least32_t release_count, int_least32_t& previous_count, bool& io_error) { +bool named_semaphore::signal(intmax_t handle, int32_t release_count, int32_t& previous_count, bool& io_error) { io_error = false; if (reinterpret_cast(handle) == SEM_FAILED) { io_error = true; @@ -41,7 +41,7 @@ bool named_semaphore::signal(intmax_t handle, int_least32_t release_count, int_l return !io_error; } -uint_least32_t named_semaphore::wait(intmax_t handle, int_least32_t milliseconds_timeout) { +uint32_t named_semaphore::wait(intmax_t handle, int32_t milliseconds_timeout) { if (reinterpret_cast(handle) == SEM_FAILED) return 0xFFFFFFFF; auto result = milliseconds_timeout == -1 ? sem_wait(reinterpret_cast(handle)) : sem_milliseconds_timedwait(reinterpret_cast(handle), milliseconds_timeout); if (result && errno == EAGAIN) return 0xFFFFFFFF; diff --git a/src/xtd.core.native.unix/src/xtd/native/unix/process.cpp b/src/xtd.core.native.unix/src/xtd/native/unix/process.cpp index 51ff83cee44..7ebcddf1b3d 100644 --- a/src/xtd.core.native.unix/src/xtd/native/unix/process.cpp +++ b/src/xtd.core.native.unix/src/xtd/native/unix/process.cpp @@ -23,11 +23,11 @@ using namespace xtd::native; namespace { class file_descriptor_streambuf : public streambuf { public: - explicit file_descriptor_streambuf(int_least32_t file_descriptor) : file_descriptor_(file_descriptor) {} + explicit file_descriptor_streambuf(int32_t file_descriptor) : file_descriptor_(file_descriptor) {} ~file_descriptor_streambuf() {close(file_descriptor_);} protected: - int_least32_t underflow() override { + int32_t underflow() override { if (read(file_descriptor_, &value_, 1) == 1) { this->setg(&value_, &value_, &value_ + 1); return value_; @@ -35,7 +35,7 @@ namespace { return streambuf::underflow(); // EOF } - int_least32_t overflow(int_least32_t c) override { + int32_t overflow(int32_t c) override { value_ = static_cast(c); if (write(file_descriptor_, &value_, 1) != -1) { this->setp(&value_, &value_); @@ -44,13 +44,13 @@ namespace { return streambuf::overflow(c); // EOF } - int_least32_t file_descriptor_; + int32_t file_descriptor_; char value_ = EOF; }; class process_istream : public istream { public: - explicit process_istream(int_least32_t file_descriptor) : istream(&stream_buf_), stream_buf_(file_descriptor) {} + explicit process_istream(int32_t file_descriptor) : istream(&stream_buf_), stream_buf_(file_descriptor) {} private: file_descriptor_streambuf stream_buf_; @@ -58,7 +58,7 @@ namespace { class process_ostream : public ostream { public: - explicit process_ostream(int_least32_t file_descriptor) : ostream(&stream_buf_), stream_buf_(file_descriptor) {} + explicit process_ostream(int32_t file_descriptor) : ostream(&stream_buf_), stream_buf_(file_descriptor) {} private: file_descriptor_streambuf stream_buf_; @@ -103,8 +103,8 @@ namespace { vector arguments; bool skip_next_space = false; bool quotes_empty = false; - int_least32_t left_space_count = 0; - int_least32_t right_space_count = 0; + int32_t left_space_count = 0; + int32_t right_space_count = 0; string argument; for (size_t index = 0; index < line_argument.size(); index++) { @@ -138,8 +138,8 @@ namespace { return arguments; } - bool compute_base_priority(int_least32_t priority, int_least32_t& base_priority) { - static map base_priorities {{IDLE_PRIORITY_CLASS, PRIO_MIN}, {BELOW_NORMAL_PRIORITY_CLASS, PRIO_MIN + (PRIO_MAX - PRIO_MIN) / 4}, {NORMAL_PRIORITY_CLASS, PRIO_MIN + (PRIO_MAX - PRIO_MIN) / 2}, {ABOVE_NORMAL_PRIORITY_CLASS, PRIO_MAX - (PRIO_MAX - PRIO_MIN) / 4}, {HIGH_PRIORITY_CLASS, PRIO_MAX - (PRIO_MAX - PRIO_MIN) / 8}, {REALTIME_PRIORITY_CLASS, PRIO_MAX}}; + bool compute_base_priority(int32_t priority, int32_t& base_priority) { + static map base_priorities {{IDLE_PRIORITY_CLASS, PRIO_MIN}, {BELOW_NORMAL_PRIORITY_CLASS, PRIO_MIN + (PRIO_MAX - PRIO_MIN) / 4}, {NORMAL_PRIORITY_CLASS, PRIO_MIN + (PRIO_MAX - PRIO_MIN) / 2}, {ABOVE_NORMAL_PRIORITY_CLASS, PRIO_MAX - (PRIO_MAX - PRIO_MIN) / 4}, {HIGH_PRIORITY_CLASS, PRIO_MAX - (PRIO_MAX - PRIO_MIN) / 8}, {REALTIME_PRIORITY_CLASS, PRIO_MAX}}; auto it = base_priorities.find(priority); if (it == base_priorities.end()) return false; base_priority = it->second; @@ -147,8 +147,8 @@ namespace { } } -int_least32_t process::base_priority(int_least32_t priority) { - int_least32_t base_priority = PRIO_MIN + (PRIO_MAX - PRIO_MIN) / 2; +int32_t process::base_priority(int32_t priority) { + int32_t base_priority = PRIO_MIN + (PRIO_MAX - PRIO_MIN) / 2; compute_base_priority(priority, base_priority); return base_priority; } @@ -158,13 +158,13 @@ bool process::kill(intmax_t process) { return ::kill(static_cast(process), SIGTERM) == 0; } -bool process::priority_class(intmax_t process, int_least32_t priority) { - int_least32_t base_priority = PRIO_MIN + (PRIO_MAX - PRIO_MIN) / 2; +bool process::priority_class(intmax_t process, int32_t priority) { + int32_t base_priority = PRIO_MIN + (PRIO_MAX - PRIO_MIN) / 2; if (compute_base_priority(priority, base_priority) == false) return false; return setpriority(PRIO_PROCESS, static_cast(process), base_priority) == 0; } -intmax_t process::shell_execute(const std::string& verb, const string& file_name, const string& arguments, const string& working_directory, int_least32_t process_window_style) { +intmax_t process::shell_execute(const std::string& verb, const string& file_name, const string& arguments, const string& working_directory, int32_t process_window_style) { pid_t process = fork(); if (process == 0) { bool is_shell_execute = is_valid_shell_execute_process(&unix::strings::split, file_name, working_directory); @@ -201,16 +201,16 @@ intmax_t process::shell_execute(const std::string& verb, const string& file_name return static_cast(process); } -process::started_process process::start(const string& file_name, const string& arguments, const string& working_directory, int_least32_t process_window_style, int_least32_t process_creation_flags, tuple redirect_standard_streams) { +process::started_process process::start(const string& file_name, const string& arguments, const string& working_directory, int32_t process_window_style, int32_t process_creation_flags, tuple redirect_standard_streams) { if (!is_valid_process(&unix::strings::split, file_name, working_directory)) return make_tuple(0, 0, std::unique_ptr {}, std::unique_ptr {}, std::unique_ptr {}); auto [redirect_standard_input, redirect_standard_output, redirect_standard_error] = redirect_standard_streams; - int_least32_t pipe_result = 0; - int_least32_t pipe_stdin[] = {0, 0}; + int32_t pipe_result = 0; + int32_t pipe_stdin[] = {0, 0}; if (redirect_standard_input) pipe_result = pipe(pipe_stdin); - int_least32_t pipe_stdout[] = {0, 0}; + int32_t pipe_stdout[] = {0, 0}; if (redirect_standard_output) pipe_result = pipe(pipe_stdout); - int_least32_t pipe_stderr[] = {0, 0}; + int32_t pipe_stderr[] = {0, 0}; if (redirect_standard_error) pipe_result = pipe(pipe_stderr); if (pipe_result) {/*do nothing*/} @@ -247,10 +247,10 @@ process::started_process process::start(const string& file_name, const string& a if (redirect_standard_output) close(pipe_stdout[1]); if (redirect_standard_error) close(pipe_stderr[1]); - return make_tuple(static_cast(process), static_cast(process), make_unique(pipe_stdin[1]), make_unique(pipe_stdout[0]), make_unique(pipe_stderr[0])); + return make_tuple(static_cast(process), static_cast(process), make_unique(pipe_stdin[1]), make_unique(pipe_stdout[0]), make_unique(pipe_stderr[0])); } -bool process::wait(intmax_t process, int_least32_t& exit_code) { +bool process::wait(intmax_t process, int32_t& exit_code) { if (process == 0) return false; siginfo_t wait_info {}; wait_info.si_pid = static_cast(process); diff --git a/src/xtd.core.native.unix/src/xtd/native/unix/socket.cpp b/src/xtd.core.native.unix/src/xtd/native/unix/socket.cpp index 5cd4f81933d..b734b25d819 100644 --- a/src/xtd.core.native.unix/src/xtd/native/unix/socket.cpp +++ b/src/xtd.core.native.unix/src/xtd/native/unix/socket.cpp @@ -23,144 +23,144 @@ using namespace std; using namespace xtd::native; namespace { - static int_least32_t native_to_socket_error(int_least32_t error) { - static map socket_errors {{0, SOCKET_ERROR_SUCCESS}, {EINTR, SOCKET_ERROR_INTERRUPTED}, {EACCES, SOCKET_ERROR_ACCESS_DENIED}, {EFAULT, SOCKET_ERROR_FAULT}, {EINVAL, SOCKET_ERROR_INVALID_ARGUMENT}, {EMFILE, SOCKET_ERROR_TOO_MANY_OPEN_SOCKETS}, {EAGAIN, SOCKET_ERROR_WOULD_BLOCK}, {EINPROGRESS, SOCKET_ERROR_IN_PROGRESS}, {EALREADY, SOCKET_ERROR_ALREADY_IN_PROGRESS}, {ENOTSOCK, SOCKET_ERROR_NOT_SOCKET}, {EDESTADDRREQ, SOCKET_ERROR_DESTINATION_ADDRESS_REQUIRED}, {EMSGSIZE, SOCKET_ERROR_MESSAGE_SIZE}, {EPROTOTYPE, SOCKET_ERROR_PROTOCOL_TYPE}, {ENOPROTOOPT, SOCKET_ERROR_PROTOCOL_OPTION}, {EPROTONOSUPPORT, SOCKET_ERROR_PROTOCOL_NOT_SUPPORTED}, {ESOCKTNOSUPPORT, SOCKET_ERROR_SOCKET_NOT_SUPPORTED}, {ENOTSUP, SOCKET_ERROR_OPERATION_NOT_SUPPORTED}, {EPFNOSUPPORT, SOCKET_ERROR_PROTOCOL_FAMILY_NOT_SUPPORTED}, {EAFNOSUPPORT, SOCKET_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED}, {EADDRINUSE, SOCKET_ERROR_ADDRESS_ALREADY_IN_USE}, {EADDRNOTAVAIL, SOCKET_ERROR_ADDRESS_NOT_AVAILABLE}, {ENETDOWN, SOCKET_ERROR_NETWORK_DOWN}, {ENETUNREACH, SOCKET_ERROR_NETWORK_UNREACHABLE}, {ENETRESET, SOCKET_ERROR_NETWORK_RESET}, {ECONNABORTED, SOCKET_ERROR_CONNECTION_ABORTED}, {ECONNRESET, SOCKET_ERROR_CONNECTION_RESET}, {ENOBUFS, SOCKET_ERROR_NO_BUFFER_SPACE_AVAILABLE}, {EISCONN, SOCKET_ERROR_IS_CONNECTED}, {ENOTCONN, SOCKET_ERROR_NOT_CONNECTED}, {ESHUTDOWN, SOCKET_ERROR_SHUTDOWN}, {ETIMEDOUT, SOCKET_ERROR_TIMED_OUT}, {ECONNREFUSED, SOCKET_ERROR_CONNECTION_REFUSED}, {EHOSTDOWN, SOCKET_ERROR_HOST_DOWN}, {EHOSTUNREACH, SOCKET_ERROR_HOST_UNREACHABLE}, {EOPNOTSUPP, SOCKET_ERROR_SOCKET_NOT_SUPPORTED}}; + static int32_t native_to_socket_error(int32_t error) { + static map socket_errors {{0, SOCKET_ERROR_SUCCESS}, {EINTR, SOCKET_ERROR_INTERRUPTED}, {EACCES, SOCKET_ERROR_ACCESS_DENIED}, {EFAULT, SOCKET_ERROR_FAULT}, {EINVAL, SOCKET_ERROR_INVALID_ARGUMENT}, {EMFILE, SOCKET_ERROR_TOO_MANY_OPEN_SOCKETS}, {EAGAIN, SOCKET_ERROR_WOULD_BLOCK}, {EINPROGRESS, SOCKET_ERROR_IN_PROGRESS}, {EALREADY, SOCKET_ERROR_ALREADY_IN_PROGRESS}, {ENOTSOCK, SOCKET_ERROR_NOT_SOCKET}, {EDESTADDRREQ, SOCKET_ERROR_DESTINATION_ADDRESS_REQUIRED}, {EMSGSIZE, SOCKET_ERROR_MESSAGE_SIZE}, {EPROTOTYPE, SOCKET_ERROR_PROTOCOL_TYPE}, {ENOPROTOOPT, SOCKET_ERROR_PROTOCOL_OPTION}, {EPROTONOSUPPORT, SOCKET_ERROR_PROTOCOL_NOT_SUPPORTED}, {ESOCKTNOSUPPORT, SOCKET_ERROR_SOCKET_NOT_SUPPORTED}, {ENOTSUP, SOCKET_ERROR_OPERATION_NOT_SUPPORTED}, {EPFNOSUPPORT, SOCKET_ERROR_PROTOCOL_FAMILY_NOT_SUPPORTED}, {EAFNOSUPPORT, SOCKET_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED}, {EADDRINUSE, SOCKET_ERROR_ADDRESS_ALREADY_IN_USE}, {EADDRNOTAVAIL, SOCKET_ERROR_ADDRESS_NOT_AVAILABLE}, {ENETDOWN, SOCKET_ERROR_NETWORK_DOWN}, {ENETUNREACH, SOCKET_ERROR_NETWORK_UNREACHABLE}, {ENETRESET, SOCKET_ERROR_NETWORK_RESET}, {ECONNABORTED, SOCKET_ERROR_CONNECTION_ABORTED}, {ECONNRESET, SOCKET_ERROR_CONNECTION_RESET}, {ENOBUFS, SOCKET_ERROR_NO_BUFFER_SPACE_AVAILABLE}, {EISCONN, SOCKET_ERROR_IS_CONNECTED}, {ENOTCONN, SOCKET_ERROR_NOT_CONNECTED}, {ESHUTDOWN, SOCKET_ERROR_SHUTDOWN}, {ETIMEDOUT, SOCKET_ERROR_TIMED_OUT}, {ECONNREFUSED, SOCKET_ERROR_CONNECTION_REFUSED}, {EHOSTDOWN, SOCKET_ERROR_HOST_DOWN}, {EHOSTUNREACH, SOCKET_ERROR_HOST_UNREACHABLE}, {EOPNOTSUPP, SOCKET_ERROR_SOCKET_NOT_SUPPORTED}}; auto it = socket_errors.find(error); if (it == socket_errors.end()) return SOCKET_ERROR_SOCKET_ERROR; return it->second; } - static int_least32_t protocol_type_to_native(int_least32_t protocol_type) { - static map protocol_types = {/*{PROTOCOL_TYPE_UNKNOWN, IPPROTO_}, {PROTOCOL_TYPE_IP_V6_HOP_BY_HOP_OPTIONS, IPPROTO_}, {PROTOCOL_TYPE_UNSPECIFIED, IPPROTO_},*/ {PROTOCOL_TYPE_IP, IPPROTO_IP}, {PROTOCOL_TYPE_ICMP, IPPROTO_ICMP}, {PROTOCOL_TYPE_IGMP, IPPROTO_IGMP}, {PROTOCOL_TYPE_GGP, 3 /*IPPROTO_GGP*/}, {PROTOCOL_TYPE_IP_V4, IPPROTO_IPIP}, {PROTOCOL_TYPE_TCP, IPPROTO_TCP}, {PROTOCOL_TYPE_PUP, IPPROTO_PUP}, {PROTOCOL_TYPE_UDP, IPPROTO_UDP}, {PROTOCOL_TYPE_IDP, IPPROTO_IDP}, {PROTOCOL_TYPE_IP_V6, IPPROTO_IPV6}, {PROTOCOL_TYPE_IP_V6_ROUTING_HEADER, IPPROTO_ROUTING}, {PROTOCOL_TYPE_IP_V6_FRAGMENT_HEADER, IPPROTO_FRAGMENT}, {PROTOCOL_TYPE_IP_SEC_ENCAPSULATING_SECURITY_PAYLOAD, IPPROTO_ESP}, {PROTOCOL_TYPE_IP_SEC_AUTHENTICATION_HEADER, IPPROTO_AH}, {PROTOCOL_TYPE_ICMP_V6, IPPROTO_ICMPV6}, {PROTOCOL_TYPE_IP_V6_NO_NEXT_HEADER, IPPROTO_NONE}, {PROTOCOL_TYPE_IP_V6_DESTINATION_OPTIONS, IPPROTO_DSTOPTS}, {PROTOCOL_TYPE_ND, IPPROTO_IP}, {PROTOCOL_TYPE_RAW, IPPROTO_RAW} /*{PROTOCOL_TYPE_IPX, IPPROTO_}, {PROTOCOL_TYPE_SPX, IPPROTO_IP}, {PROTOCOL_TYPE_SPX_2, IPPROTO_},*/}; + static int32_t protocol_type_to_native(int32_t protocol_type) { + static map protocol_types = {/*{PROTOCOL_TYPE_UNKNOWN, IPPROTO_}, {PROTOCOL_TYPE_IP_V6_HOP_BY_HOP_OPTIONS, IPPROTO_}, {PROTOCOL_TYPE_UNSPECIFIED, IPPROTO_},*/ {PROTOCOL_TYPE_IP, IPPROTO_IP}, {PROTOCOL_TYPE_ICMP, IPPROTO_ICMP}, {PROTOCOL_TYPE_IGMP, IPPROTO_IGMP}, {PROTOCOL_TYPE_GGP, 3 /*IPPROTO_GGP*/}, {PROTOCOL_TYPE_IP_V4, IPPROTO_IPIP}, {PROTOCOL_TYPE_TCP, IPPROTO_TCP}, {PROTOCOL_TYPE_PUP, IPPROTO_PUP}, {PROTOCOL_TYPE_UDP, IPPROTO_UDP}, {PROTOCOL_TYPE_IDP, IPPROTO_IDP}, {PROTOCOL_TYPE_IP_V6, IPPROTO_IPV6}, {PROTOCOL_TYPE_IP_V6_ROUTING_HEADER, IPPROTO_ROUTING}, {PROTOCOL_TYPE_IP_V6_FRAGMENT_HEADER, IPPROTO_FRAGMENT}, {PROTOCOL_TYPE_IP_SEC_ENCAPSULATING_SECURITY_PAYLOAD, IPPROTO_ESP}, {PROTOCOL_TYPE_IP_SEC_AUTHENTICATION_HEADER, IPPROTO_AH}, {PROTOCOL_TYPE_ICMP_V6, IPPROTO_ICMPV6}, {PROTOCOL_TYPE_IP_V6_NO_NEXT_HEADER, IPPROTO_NONE}, {PROTOCOL_TYPE_IP_V6_DESTINATION_OPTIONS, IPPROTO_DSTOPTS}, {PROTOCOL_TYPE_ND, IPPROTO_IP}, {PROTOCOL_TYPE_RAW, IPPROTO_RAW} /*{PROTOCOL_TYPE_IPX, IPPROTO_}, {PROTOCOL_TYPE_SPX, IPPROTO_IP}, {PROTOCOL_TYPE_SPX_2, IPPROTO_},*/}; auto it = protocol_types.find(protocol_type); if (it == protocol_types.end()) return IPPROTO_IP; return it->second; } - static int_least32_t socket_option_level_to_native(int_least32_t socket_option_level) { - static map socket_option_levels = {{SOCKET_OPTION_LEVEL_SOCKET, SOL_SOCKET}, {SOCKET_OPTION_LEVEL_IP, IPPROTO_IP}, {SOCKET_OPTION_LEVEL_IP_V6, IPPROTO_IPV6}, {SOCKET_OPTION_LEVEL_TCP, IPPROTO_TCP}, {SOCKET_OPTION_LEVEL_UDP, IPPROTO_UDP}}; + static int32_t socket_option_level_to_native(int32_t socket_option_level) { + static map socket_option_levels = {{SOCKET_OPTION_LEVEL_SOCKET, SOL_SOCKET}, {SOCKET_OPTION_LEVEL_IP, IPPROTO_IP}, {SOCKET_OPTION_LEVEL_IP_V6, IPPROTO_IPV6}, {SOCKET_OPTION_LEVEL_TCP, IPPROTO_TCP}, {SOCKET_OPTION_LEVEL_UDP, IPPROTO_UDP}}; auto it = socket_option_levels.find(socket_option_level); if (it == socket_option_levels.end()) return SOL_SOCKET; return it->second; } - static int_least32_t socket_option_name_to_native(int_least32_t socket_option_name) { - static map socket_option_names = {{SOCKET_OPTION_NAME_DEBUG, SO_DEBUG}, {SOCKET_OPTION_NAME_ACCEPT_CONNECTION, SO_ACCEPTCONN}, {SOCKET_OPTION_NAME_REUSE_ADDRESS, SO_REUSEADDR}, {SOCKET_OPTION_NAME_KEEP_ALIVE, SO_KEEPALIVE}, {SOCKET_OPTION_NAME_DONT_ROUTE, SO_DONTROUTE}, {SOCKET_OPTION_NAME_BROADCAST, SO_BROADCAST}, /*{SOCKET_OPTION_NAME_USE_LOOPBACK, SO_},*/ {SOCKET_OPTION_NAME_LINGER, SO_LINGER}, {SOCKET_OPTION_NAME_EXCLUSIVE_ADDRESS_USE, SO_REUSEADDR}, {SOCKET_OPTION_NAME_OUT_OF_BAND_INLINE, SO_OOBINLINE}, {SOCKET_OPTION_NAME_SEND_BUFFER, SO_SNDBUF}, {SOCKET_OPTION_NAME_RECEIVE_BUFFER, SO_RCVBUF}, {SOCKET_OPTION_NAME_SEND_LOW_WATER, SO_SNDLOWAT}, {SOCKET_OPTION_NAME_RECEIVE_LOW_WATER, SO_RCVLOWAT}, {SOCKET_OPTION_NAME_SEND_TIMEOUT, SO_SNDTIMEO}, {SOCKET_OPTION_NAME_RECEIVE_TIMEOUT, SO_RCVTIMEO}, {SOCKET_OPTION_NAME_ERROR, SO_ERROR}, {SOCKET_OPTION_NAME_TYPE, SO_TYPE}, /*{SOCKET_OPTION_NAME_MAX_CONNECTION, SO_},*/ {SOCKET_OPTION_NAME_IP_OPTIONS, IP_OPTIONS}, {SOCKET_OPTION_NAME_HEADER_INCLUDED, IP_HDRINCL}, {SOCKET_OPTION_NAME_TYPE_OF_SERVICE, IP_TOS}, {SOCKET_OPTION_NAME_IP_TIME_TO_LIVE, IP_TTL}, {SOCKET_OPTION_NAME_MULTICAST_INTERFACE, IP_MULTICAST_IF}, {SOCKET_OPTION_NAME_MULTICAST_TIME_TO_LIVE, IP_MULTICAST_TTL}, {SOCKET_OPTION_NAME_MULTICAST_LOOPBACK, IP_MULTICAST_LOOP}, {SOCKET_OPTION_NAME_ADD_MEMBERSHIP, IP_ADD_MEMBERSHIP}, {SOCKET_OPTION_NAME_DROP_MEMBERSHIP, IP_DROP_MEMBERSHIP}, {SOCKET_OPTION_NAME_DONT_FRAGMENT, IP_DONTFRAG}, {SOCKET_OPTION_NAME_ADD_SOURCE_MEMBERSHIP, IP_ADD_SOURCE_MEMBERSHIP}, {SOCKET_OPTION_NAME_DROP_SOURCE_MEMBERSHIP, IP_DROP_SOURCE_MEMBERSHIP}, {SOCKET_OPTION_NAME_BLOCK_SOURCE, IP_BLOCK_SOURCE}, {SOCKET_OPTION_NAME_UNBLOCK_SOURCE, IP_UNBLOCK_SOURCE}, {SOCKET_OPTION_NAME_PACKET_INFORMATION, IPV6_PKTINFO}, {SOCKET_OPTION_NAME_HOP_LIMIT, IPV6_HOPLIMIT}, /*{SOCKET_OPTION_NAME_IP_PROTECT_LEVEL, IPV6_},*/ {SOCKET_OPTION_NAME_IP_V6_ONLY, IPV6_V6ONLY}, /*{SOCKET_OPTION_NAME_NO_DELAY, TCP_}, {SOCKET_OPTION_NAME_BSD_URGENT, TCP_}, {SOCKET_OPTION_NAME_EXPEDITED, TCP_}, {SOCKET_OPTION_NAME_NO_CHECKSUM, UDP_}, {SOCKET_OPTION_NAME_CHECKSUM_COVERAGE, ...}, {SOCKET_OPTION_NAME_UPDATE_ACCEPT_CONTEXT, ...}, {SOCKET_OPTION_NAME_UPDATE_CONNECT_CONTEXT, ...},*/}; + static int32_t socket_option_name_to_native(int32_t socket_option_name) { + static map socket_option_names = {{SOCKET_OPTION_NAME_DEBUG, SO_DEBUG}, {SOCKET_OPTION_NAME_ACCEPT_CONNECTION, SO_ACCEPTCONN}, {SOCKET_OPTION_NAME_REUSE_ADDRESS, SO_REUSEADDR}, {SOCKET_OPTION_NAME_KEEP_ALIVE, SO_KEEPALIVE}, {SOCKET_OPTION_NAME_DONT_ROUTE, SO_DONTROUTE}, {SOCKET_OPTION_NAME_BROADCAST, SO_BROADCAST}, /*{SOCKET_OPTION_NAME_USE_LOOPBACK, SO_},*/ {SOCKET_OPTION_NAME_LINGER, SO_LINGER}, {SOCKET_OPTION_NAME_EXCLUSIVE_ADDRESS_USE, SO_REUSEADDR}, {SOCKET_OPTION_NAME_OUT_OF_BAND_INLINE, SO_OOBINLINE}, {SOCKET_OPTION_NAME_SEND_BUFFER, SO_SNDBUF}, {SOCKET_OPTION_NAME_RECEIVE_BUFFER, SO_RCVBUF}, {SOCKET_OPTION_NAME_SEND_LOW_WATER, SO_SNDLOWAT}, {SOCKET_OPTION_NAME_RECEIVE_LOW_WATER, SO_RCVLOWAT}, {SOCKET_OPTION_NAME_SEND_TIMEOUT, SO_SNDTIMEO}, {SOCKET_OPTION_NAME_RECEIVE_TIMEOUT, SO_RCVTIMEO}, {SOCKET_OPTION_NAME_ERROR, SO_ERROR}, {SOCKET_OPTION_NAME_TYPE, SO_TYPE}, /*{SOCKET_OPTION_NAME_MAX_CONNECTION, SO_},*/ {SOCKET_OPTION_NAME_IP_OPTIONS, IP_OPTIONS}, {SOCKET_OPTION_NAME_HEADER_INCLUDED, IP_HDRINCL}, {SOCKET_OPTION_NAME_TYPE_OF_SERVICE, IP_TOS}, {SOCKET_OPTION_NAME_IP_TIME_TO_LIVE, IP_TTL}, {SOCKET_OPTION_NAME_MULTICAST_INTERFACE, IP_MULTICAST_IF}, {SOCKET_OPTION_NAME_MULTICAST_TIME_TO_LIVE, IP_MULTICAST_TTL}, {SOCKET_OPTION_NAME_MULTICAST_LOOPBACK, IP_MULTICAST_LOOP}, {SOCKET_OPTION_NAME_ADD_MEMBERSHIP, IP_ADD_MEMBERSHIP}, {SOCKET_OPTION_NAME_DROP_MEMBERSHIP, IP_DROP_MEMBERSHIP}, {SOCKET_OPTION_NAME_DONT_FRAGMENT, IP_DONTFRAG}, {SOCKET_OPTION_NAME_ADD_SOURCE_MEMBERSHIP, IP_ADD_SOURCE_MEMBERSHIP}, {SOCKET_OPTION_NAME_DROP_SOURCE_MEMBERSHIP, IP_DROP_SOURCE_MEMBERSHIP}, {SOCKET_OPTION_NAME_BLOCK_SOURCE, IP_BLOCK_SOURCE}, {SOCKET_OPTION_NAME_UNBLOCK_SOURCE, IP_UNBLOCK_SOURCE}, {SOCKET_OPTION_NAME_PACKET_INFORMATION, IPV6_PKTINFO}, {SOCKET_OPTION_NAME_HOP_LIMIT, IPV6_HOPLIMIT}, /*{SOCKET_OPTION_NAME_IP_PROTECT_LEVEL, IPV6_},*/ {SOCKET_OPTION_NAME_IP_V6_ONLY, IPV6_V6ONLY}, /*{SOCKET_OPTION_NAME_NO_DELAY, TCP_}, {SOCKET_OPTION_NAME_BSD_URGENT, TCP_}, {SOCKET_OPTION_NAME_EXPEDITED, TCP_}, {SOCKET_OPTION_NAME_NO_CHECKSUM, UDP_}, {SOCKET_OPTION_NAME_CHECKSUM_COVERAGE, ...}, {SOCKET_OPTION_NAME_UPDATE_ACCEPT_CONTEXT, ...}, {SOCKET_OPTION_NAME_UPDATE_CONNECT_CONTEXT, ...},*/}; auto it = socket_option_names.find(socket_option_name); if (it == socket_option_names.end()) return -1; return it->second; } - static int_least32_t socket_type_to_native(int_least32_t socket_type) { - static map socket_types = {{SOCKET_TYPE_UNKNOWN, SOCK_STREAM | SOCK_CLOEXEC}, {SOCKET_TYPE_STREAM, SOCK_STREAM | SOCK_CLOEXEC}, {SOCKET_TYPE_DGRAM, SOCK_DGRAM | SOCK_CLOEXEC}, {SOCKET_TYPE_RAW, SOCK_RAW | SOCK_CLOEXEC}, {SOCKET_TYPE_RDM, SOCK_RDM | SOCK_CLOEXEC}, {SOCKET_TYPE_SEQPACKET, SOCK_SEQPACKET | SOCK_CLOEXEC}}; + static int32_t socket_type_to_native(int32_t socket_type) { + static map socket_types = {{SOCKET_TYPE_UNKNOWN, SOCK_STREAM | SOCK_CLOEXEC}, {SOCKET_TYPE_STREAM, SOCK_STREAM | SOCK_CLOEXEC}, {SOCKET_TYPE_DGRAM, SOCK_DGRAM | SOCK_CLOEXEC}, {SOCKET_TYPE_RAW, SOCK_RAW | SOCK_CLOEXEC}, {SOCKET_TYPE_RDM, SOCK_RDM | SOCK_CLOEXEC}, {SOCKET_TYPE_SEQPACKET, SOCK_SEQPACKET | SOCK_CLOEXEC}}; auto it = socket_types.find(socket_type); if (it == socket_types.end()) return SOCK_STREAM; return it->second; } } -int_least32_t socket::address_family_to_native(int_least32_t address_family) { - static map address_families = {{ADDRESS_FAMILY_UNKNOWN, -1}, {ADDRESS_FAMILY_UNSPECIFIED, AF_UNSPEC}, {ADDRESS_FAMILY_UNIX, AF_UNIX}, {ADDRESS_FAMILY_INTER_NETWORK, AF_INET}, {ADDRESS_FAMILY_SNA, AF_SNA}, /*{ADDRESS_FAMILY_IMP_LINK, AF_IMPLINK}, {ADDRESS_FAMILY_PUP, AF_PUP}, {ADDRESS_FAMILY_CHAOS, AF_CHAOS}, {ADDRESS_FAMILY_NS, AF_NS}, {ADDRESS_FAMILY_IPX, AF_}, {ADDRESS_FAMILY_ISO, AF_ISO}, {ADDRESS_FAMILY_ECMA, AF_ECMA}, {ADDRESS_FAMILY_DATA_KIT, AF_DATAKIT}, {ADDRESS_FAMILY_CCITT, AF_CCITT},*/ {ADDRESS_FAMILY_DEC_NET, AF_DECnet}, /*{ADDRESS_FAMILY_DATA_LINK, AF_DLI}, {ADDRESS_FAMILY_LAT, AF_LAT}, {ADDRESS_FAMILY_HYPER_CHANNEL, AF_HYLINK},*/ {ADDRESS_FAMILY_APPLE_TALK, AF_APPLETALK}, /*{ADDRESS_FAMILY_NET_BIOS, AF_NETBIOS}, {ADDRESS_FAMILY_VOICE_VIEW, AF_}, {ADDRESS_FAMILY_FIRE_FOX, AF_}, {ADDRESS_FAMILY_BANYAN, AF_}, {ADDRESS_FAMILY_ATM, AF_NATM},*/ {ADDRESS_FAMILY_INTER_NETWORK_V6, AF_INET6}, /*{ADDRESS_FAMILY_CLUSTER, AF_}, {ADDRESS_FAMILY_IEEE12844, AF_}, {ADDRESS_FAMILY_IRDA, AF_}, {ADDRESS_FAMILY_NETWORK_DESIGNERS, AF_},*/ {ADDRESS_FAMILY_MAX, AF_MAX}}; +int32_t socket::address_family_to_native(int32_t address_family) { + static map address_families = {{ADDRESS_FAMILY_UNKNOWN, -1}, {ADDRESS_FAMILY_UNSPECIFIED, AF_UNSPEC}, {ADDRESS_FAMILY_UNIX, AF_UNIX}, {ADDRESS_FAMILY_INTER_NETWORK, AF_INET}, {ADDRESS_FAMILY_SNA, AF_SNA}, /*{ADDRESS_FAMILY_IMP_LINK, AF_IMPLINK}, {ADDRESS_FAMILY_PUP, AF_PUP}, {ADDRESS_FAMILY_CHAOS, AF_CHAOS}, {ADDRESS_FAMILY_NS, AF_NS}, {ADDRESS_FAMILY_IPX, AF_}, {ADDRESS_FAMILY_ISO, AF_ISO}, {ADDRESS_FAMILY_ECMA, AF_ECMA}, {ADDRESS_FAMILY_DATA_KIT, AF_DATAKIT}, {ADDRESS_FAMILY_CCITT, AF_CCITT},*/ {ADDRESS_FAMILY_DEC_NET, AF_DECnet}, /*{ADDRESS_FAMILY_DATA_LINK, AF_DLI}, {ADDRESS_FAMILY_LAT, AF_LAT}, {ADDRESS_FAMILY_HYPER_CHANNEL, AF_HYLINK},*/ {ADDRESS_FAMILY_APPLE_TALK, AF_APPLETALK}, /*{ADDRESS_FAMILY_NET_BIOS, AF_NETBIOS}, {ADDRESS_FAMILY_VOICE_VIEW, AF_}, {ADDRESS_FAMILY_FIRE_FOX, AF_}, {ADDRESS_FAMILY_BANYAN, AF_}, {ADDRESS_FAMILY_ATM, AF_NATM},*/ {ADDRESS_FAMILY_INTER_NETWORK_V6, AF_INET6}, /*{ADDRESS_FAMILY_CLUSTER, AF_}, {ADDRESS_FAMILY_IEEE12844, AF_}, {ADDRESS_FAMILY_IRDA, AF_}, {ADDRESS_FAMILY_NETWORK_DESIGNERS, AF_},*/ {ADDRESS_FAMILY_MAX, AF_MAX}}; auto it = address_families.find(address_family); if (it == address_families.end()) return AF_UNSPEC; return it->second; } -int_least32_t socket::native_to_address_family(int_least32_t address_family) { - static map address_families = {/*{-1, ADDRESS_FAMILY_UNKNOWN}, */ {AF_UNSPEC, ADDRESS_FAMILY_UNSPECIFIED}, {AF_UNIX, ADDRESS_FAMILY_UNIX}, {AF_INET, ADDRESS_FAMILY_INTER_NETWORK}, /*{AF_IMPLINK, ADDRESS_FAMILY_IMP_LINK}, {AF_PUP, ADDRESS_FAMILY_PUP}, {AF_CHAOS, ADDRESS_FAMILY_CHAOS}, {AF_NS, ADDRESS_FAMILY_NS}, {AF_ISO, ADDRESS_FAMILY_ISO}, {AF_, ADDRESS_FAMILY_IPX}, {AF_ECMA, ADDRESS_FAMILY_ECMA}, {AF_DATAKIT, ADDRESS_FAMILY_DATA_KIT}, {AF_CCITT, ADDRESS_FAMILY_CCITT},*/ {AF_SNA, ADDRESS_FAMILY_SNA}, {AF_DECnet, ADDRESS_FAMILY_DEC_NET}, /*{AF_DLI, ADDRESS_FAMILY_DATA_LINK}, {AF_LAT, ADDRESS_FAMILY_LAT}, {AF_HYLINK, ADDRESS_FAMILY_HYPER_CHANNEL},*/ {AF_APPLETALK, ADDRESS_FAMILY_APPLE_TALK}, /*{AF_NETBIOS, ADDRESS_FAMILY_NET_BIOS}, {AF_, ADDRESS_FAMILY_VOICE_VIEW}, {AF_, ADDRESS_FAMILY_FIRE_FOX}, {AF_, ADDRESS_FAMILY_BANYAN}, {AF_NATM, ADDRESS_FAMILY_ATM},*/ {AF_INET6, ADDRESS_FAMILY_INTER_NETWORK_V6}, /*{AF_, ADDRESS_FAMILY_CLUSTER}, {AF_, ADDRESS_FAMILY_IEEE12844}, {AF_, ADDRESS_FAMILY_IRDA}, {AF_, ADDRESS_FAMILY_NETWORK_DESIGNERS},*/ {AF_MAX, ADDRESS_FAMILY_MAX}}; +int32_t socket::native_to_address_family(int32_t address_family) { + static map address_families = {/*{-1, ADDRESS_FAMILY_UNKNOWN}, */ {AF_UNSPEC, ADDRESS_FAMILY_UNSPECIFIED}, {AF_UNIX, ADDRESS_FAMILY_UNIX}, {AF_INET, ADDRESS_FAMILY_INTER_NETWORK}, /*{AF_IMPLINK, ADDRESS_FAMILY_IMP_LINK}, {AF_PUP, ADDRESS_FAMILY_PUP}, {AF_CHAOS, ADDRESS_FAMILY_CHAOS}, {AF_NS, ADDRESS_FAMILY_NS}, {AF_ISO, ADDRESS_FAMILY_ISO}, {AF_, ADDRESS_FAMILY_IPX}, {AF_ECMA, ADDRESS_FAMILY_ECMA}, {AF_DATAKIT, ADDRESS_FAMILY_DATA_KIT}, {AF_CCITT, ADDRESS_FAMILY_CCITT},*/ {AF_SNA, ADDRESS_FAMILY_SNA}, {AF_DECnet, ADDRESS_FAMILY_DEC_NET}, /*{AF_DLI, ADDRESS_FAMILY_DATA_LINK}, {AF_LAT, ADDRESS_FAMILY_LAT}, {AF_HYLINK, ADDRESS_FAMILY_HYPER_CHANNEL},*/ {AF_APPLETALK, ADDRESS_FAMILY_APPLE_TALK}, /*{AF_NETBIOS, ADDRESS_FAMILY_NET_BIOS}, {AF_, ADDRESS_FAMILY_VOICE_VIEW}, {AF_, ADDRESS_FAMILY_FIRE_FOX}, {AF_, ADDRESS_FAMILY_BANYAN}, {AF_NATM, ADDRESS_FAMILY_ATM},*/ {AF_INET6, ADDRESS_FAMILY_INTER_NETWORK_V6}, /*{AF_, ADDRESS_FAMILY_CLUSTER}, {AF_, ADDRESS_FAMILY_IEEE12844}, {AF_, ADDRESS_FAMILY_IRDA}, {AF_, ADDRESS_FAMILY_NETWORK_DESIGNERS},*/ {AF_MAX, ADDRESS_FAMILY_MAX}}; auto it = address_families.find(address_family); if (it == address_families.end()) return ADDRESS_FAMILY_UNSPECIFIED; return it->second; } -intmax_t socket::accept(intmax_t handle, vector& socket_address) { +intmax_t socket::accept(intmax_t handle, vector& socket_address) { socklen_t address_length = static_cast(socket_address.size()); - intmax_t socket = static_cast(::accept(static_cast(handle), reinterpret_cast(socket_address.data()), &address_length)); + intmax_t socket = static_cast(::accept(static_cast(handle), reinterpret_cast(socket_address.data()), &address_length)); //if (socket_address.size() != address_length) socket_address.resize(address_length); return socket; } -int_least32_t socket::bind(intmax_t handle, const vector& socket_address) { - return ::bind(static_cast(handle), reinterpret_cast(socket_address.data()), static_cast(socket_address.size())); +int32_t socket::bind(intmax_t handle, const vector& socket_address) { + return ::bind(static_cast(handle), reinterpret_cast(socket_address.data()), static_cast(socket_address.size())); } void socket::cleanup() { // Nothing to do on linux and macOS. } -int_least32_t socket::connect(intmax_t handle, const vector& socket_address) { - return ::connect(static_cast(handle), reinterpret_cast(socket_address.data()), static_cast(socket_address.size())); +int32_t socket::connect(intmax_t handle, const vector& socket_address) { + return ::connect(static_cast(handle), reinterpret_cast(socket_address.data()), static_cast(socket_address.size())); } -intmax_t socket::create(int_least32_t address_family, int_least32_t socket_type, int_least32_t protocol_type) { +intmax_t socket::create(int32_t address_family, int32_t socket_type, int32_t protocol_type) { return static_cast(::socket(address_family_to_native(address_family), socket_type_to_native(socket_type), protocol_type_to_native(protocol_type))); } -int_least32_t socket::destroy(intmax_t handle) { - return ::close(static_cast(handle)); +int32_t socket::destroy(intmax_t handle) { + return ::close(static_cast(handle)); } size_t socket::get_available(intmax_t handle) { - int_least32_t nbr_bytes_available = 0; - if (ioctl(static_cast(handle), FIONREAD, &nbr_bytes_available) != 0) return -1; + int32_t nbr_bytes_available = 0; + if (ioctl(static_cast(handle), FIONREAD, &nbr_bytes_available) != 0) return -1; return static_cast(nbr_bytes_available); } -int_least32_t socket::get_last_error() { +int32_t socket::get_last_error() { return native_to_socket_error(errno); } bool socket::get_os_supports_ip_v4() noexcept { - int_least32_t s = ::socket(AF_INET, SOCK_STREAM, IPPROTO_IP); + int32_t s = ::socket(AF_INET, SOCK_STREAM, IPPROTO_IP); if (s == -1) return false; close(s); return true; } bool socket::get_os_supports_ip_v6() noexcept { - int_least32_t s = ::socket(AF_INET6, SOCK_STREAM, IPPROTO_IP); + int32_t s = ::socket(AF_INET6, SOCK_STREAM, IPPROTO_IP); if (s == -1) return false; close(s); return true; } -int_least32_t socket::get_raw_socket_option(intmax_t handle, int_least32_t socket_option_level, int_least32_t socket_option_name, intmax_t option, size_t& option_length) { - return ::getsockopt(static_cast(handle), socket_option_level, socket_option_name, reinterpret_cast(option), reinterpret_cast(&option_length)); +int32_t socket::get_raw_socket_option(intmax_t handle, int32_t socket_option_level, int32_t socket_option_name, intmax_t option, size_t& option_length) { + return ::getsockopt(static_cast(handle), socket_option_level, socket_option_name, reinterpret_cast(option), reinterpret_cast(&option_length)); } -int_least32_t socket::get_socket_option(intmax_t handle, int_least32_t socket_option_level, int_least32_t socket_option_name, intmax_t option, size_t& option_length) { +int32_t socket::get_socket_option(intmax_t handle, int32_t socket_option_level, int32_t socket_option_name, intmax_t option, size_t& option_length) { if (socket_option_name_to_native(socket_option_name) == -1) { errno = ENOTSUP; return -1; } if (socket_option_level == SOCKET_OPTION_LEVEL_SOCKET && (socket_option_name == SOCKET_OPTION_NAME_SEND_TIMEOUT || socket_option_name == SOCKET_OPTION_NAME_RECEIVE_TIMEOUT)) { timeval timeout = {0, 0}; - int_least32_t result = ::getsockopt(static_cast(handle), socket_option_level_to_native(socket_option_level), socket_option_name_to_native(socket_option_name), &timeout, reinterpret_cast(&option_length)); - *reinterpret_cast(option) = static_cast(timeout.tv_sec * 1000 + timeout.tv_usec / 1000); + int32_t result = ::getsockopt(static_cast(handle), socket_option_level_to_native(socket_option_level), socket_option_name_to_native(socket_option_name), &timeout, reinterpret_cast(&option_length)); + *reinterpret_cast(option) = static_cast(timeout.tv_sec * 1000 + timeout.tv_usec / 1000); return result; } - return ::getsockopt(static_cast(handle), socket_option_level_to_native(socket_option_level), socket_option_name_to_native(socket_option_name), reinterpret_cast(option), reinterpret_cast(&option_length)); + return ::getsockopt(static_cast(handle), socket_option_level_to_native(socket_option_level), socket_option_name_to_native(socket_option_name), reinterpret_cast(option), reinterpret_cast(&option_length)); } -int_least32_t socket::get_socket_linger_option(intmax_t handle, bool& enabled, uint_least32_t& linger_time) { - linger l {static_cast(enabled), static_cast(linger_time)}; +int32_t socket::get_socket_linger_option(intmax_t handle, bool& enabled, uint32_t& linger_time) { + linger l {static_cast(enabled), static_cast(linger_time)}; size_t linger_size = 0; - int_least32_t result = ::getsockopt(static_cast(handle), SOL_SOCKET, SO_LINGER, &l, reinterpret_cast(&linger_size)); + int32_t result = ::getsockopt(static_cast(handle), SOL_SOCKET, SO_LINGER, &l, reinterpret_cast(&linger_size)); if (result == 0) { enabled = static_cast(l.l_onoff); - linger_time = static_cast(l.l_linger); + linger_time = static_cast(l.l_linger); } return result; } -int_least32_t socket::get_socket_multicast_option(intmax_t handle, int_least32_t socket_option_name, uint_least32_t& multicast_address, uint_least32_t& interface_index) { +int32_t socket::get_socket_multicast_option(intmax_t handle, int32_t socket_option_name, uint32_t& multicast_address, uint32_t& interface_index) { struct multicast { - uint_least32_t multicast_address; - uint_least32_t interface_index; + uint32_t multicast_address; + uint32_t interface_index; } m; size_t multicast_size = 0; - int_least32_t result = getsockopt(static_cast(handle), IPPROTO_IP, socket_option_name_to_native(socket_option_name), &m, reinterpret_cast(&multicast_size)); + int32_t result = getsockopt(static_cast(handle), IPPROTO_IP, socket_option_name_to_native(socket_option_name), &m, reinterpret_cast(&multicast_size)); if (result == 0) { multicast_address = m.multicast_address; interface_index = m.interface_index; @@ -168,13 +168,13 @@ int_least32_t socket::get_socket_multicast_option(intmax_t handle, int_least32_t return result; } -int_least32_t socket::get_socket_ip_v6_multicast_option(intmax_t handle, int_least32_t socket_option_name, vector& multicast_address, uint_least32_t& interface_index) { +int32_t socket::get_socket_ip_v6_multicast_option(intmax_t handle, int32_t socket_option_name, vector& multicast_address, uint32_t& interface_index) { struct multicast { - uint_least8_t multicast_address[16]; - uint_least32_t interface_index; + uint8_t multicast_address[16]; + uint32_t interface_index; } m; size_t multicast_size = 0; - int_least32_t result = getsockopt(static_cast(handle), IPPROTO_IP, socket_option_name_to_native(socket_option_name), &m, reinterpret_cast(&multicast_size)); + int32_t result = getsockopt(static_cast(handle), IPPROTO_IP, socket_option_name_to_native(socket_option_name), &m, reinterpret_cast(&multicast_size)); if (result == 0) { for (auto index = 0U; index < multicast_address.size(); ++index) multicast_address[index] = m.multicast_address[index]; @@ -183,22 +183,22 @@ int_least32_t socket::get_socket_ip_v6_multicast_option(intmax_t handle, int_lea return result; } -int_least32_t socket::io_control(intmax_t handle, int_least32_t io_control, vector& option_in_value, vector& option_out_value) { +int32_t socket::io_control(intmax_t handle, int32_t io_control, vector& option_in_value, vector& option_out_value) { // Not implemented errno = ENOTSUP; return -1; } -int_least32_t socket::listen(intmax_t handle, size_t backlog) { - int_least32_t backlog_value = backlog != static_cast(-1) ? static_cast(backlog) : SOMAXCONN; - return ::listen(static_cast(handle), backlog_value); +int32_t socket::listen(intmax_t handle, size_t backlog) { + int32_t backlog_value = backlog != static_cast(-1) ? static_cast(backlog) : SOMAXCONN; + return ::listen(static_cast(handle), backlog_value); } -int_least32_t socket::poll(intmax_t handle, int_least32_t microseconds, int_least32_t mode) { +int32_t socket::poll(intmax_t handle, int32_t microseconds, int32_t mode) { if (handle == 0 || microseconds < 0) return -1; pollfd poll_fd {}; - poll_fd.fd = static_cast(handle); + poll_fd.fd = static_cast(handle); switch (mode) { case SELECT_MODE_READ: poll_fd.events = POLLIN; break; case SELECT_MODE_WRITE: poll_fd.events = POLLOUT; break; @@ -208,16 +208,16 @@ int_least32_t socket::poll(intmax_t handle, int_least32_t microseconds, int_leas return ::poll(&poll_fd, 1, microseconds); } -int_least32_t socket::receive(intmax_t handle, vector& buffer, size_t offset, size_t size, int_least32_t flags) { - int_least32_t result = static_cast(::recv(static_cast(handle), &buffer.data()[offset], size, flags)); +int32_t socket::receive(intmax_t handle, vector& buffer, size_t offset, size_t size, int32_t flags) { + int32_t result = static_cast(::recv(static_cast(handle), &buffer.data()[offset], size, flags)); if (result == -1 && errno == EBADF) errno = EINTR; if (result == -1 && errno == EAGAIN) errno = ETIMEDOUT; return result; } -int_least32_t socket::receive_from(intmax_t handle, vector& buffer, size_t offset, size_t size, int_least32_t flags, vector& socket_address) { +int32_t socket::receive_from(intmax_t handle, vector& buffer, size_t offset, size_t size, int32_t flags, vector& socket_address) { socklen_t address_length = static_cast(socket_address.size()); - int_least32_t result = static_cast(::recvfrom(static_cast(handle), &buffer.data()[offset], size, flags, reinterpret_cast(socket_address.data()), &address_length)); + int32_t result = static_cast(::recvfrom(static_cast(handle), &buffer.data()[offset], size, flags, reinterpret_cast(socket_address.data()), &address_length)); //if (socket_address.size() != address_length) socket_address.resize(address_length); if (result == -1 && errno == EBADF) errno = EINTR; @@ -225,111 +225,111 @@ int_least32_t socket::receive_from(intmax_t handle, vector& buffe return result; } -int_least32_t socket::select(vector& check_read, vector& check_write, vector& check_error, int_least32_t microseconds) { +int32_t socket::select(vector& check_read, vector& check_write, vector& check_error, int32_t microseconds) { size_t nfds = 0; fd_set read_fds; FD_ZERO(&read_fds); for (auto i = 0U; i < check_read.size() && i < FD_SETSIZE; i++) - FD_SET(static_cast(check_read[i]), &read_fds); + FD_SET(static_cast(check_read[i]), &read_fds); if (check_read.size() > nfds) nfds = check_read.size(); fd_set write_fds; FD_ZERO(&write_fds); for (auto i = 0U; i < check_write.size() && i < FD_SETSIZE; i++) - FD_SET(static_cast(check_write[i]), &write_fds); + FD_SET(static_cast(check_write[i]), &write_fds); if (check_write.size() > nfds) nfds = check_write.size(); fd_set error_fds; FD_ZERO(&error_fds); for (auto i = 0U; i < check_error.size() && i < FD_SETSIZE; i++) - FD_SET(static_cast(check_error[i]), &error_fds); + FD_SET(static_cast(check_error[i]), &error_fds); if (check_error.size() > nfds) nfds = check_error.size(); timeval timeout {microseconds / 1000000, microseconds % 1000000}; - int_least32_t result = ::select(static_cast(nfds + 1), &read_fds, &write_fds, &error_fds, microseconds == -1 ? nullptr : &timeout); + int32_t result = ::select(static_cast(nfds + 1), &read_fds, &write_fds, &error_fds, microseconds == -1 ? nullptr : &timeout); for (auto i = 0U; i < check_read.size(); i++) { - FD_CLR(static_cast(check_read[i]), &read_fds); - if (FD_ISSET(static_cast(check_read[i]), &read_fds) == 0) check_read[i] = 0; + FD_CLR(static_cast(check_read[i]), &read_fds); + if (FD_ISSET(static_cast(check_read[i]), &read_fds) == 0) check_read[i] = 0; } for (auto i = 0U; i < check_write.size(); i++) { - FD_CLR(static_cast(check_write[i]), &write_fds); - if (FD_ISSET(static_cast(check_write[i]), &write_fds) == 0) check_write[i] = 0; + FD_CLR(static_cast(check_write[i]), &write_fds); + if (FD_ISSET(static_cast(check_write[i]), &write_fds) == 0) check_write[i] = 0; } for (auto i = 0U; i < check_error.size(); i++) { - FD_CLR(static_cast(check_error[i]), &error_fds); - if (FD_ISSET(static_cast(check_error[i]), &error_fds) == 0) check_error[i] = 0; + FD_CLR(static_cast(check_error[i]), &error_fds); + if (FD_ISSET(static_cast(check_error[i]), &error_fds) == 0) check_error[i] = 0; } return result; } -int_least32_t socket::send(intmax_t handle, const vector& buffer, size_t offset, size_t size, int_least32_t flags) { - return static_cast(::send(static_cast(handle), &buffer.data()[offset], size, flags)); +int32_t socket::send(intmax_t handle, const vector& buffer, size_t offset, size_t size, int32_t flags) { + return static_cast(::send(static_cast(handle), &buffer.data()[offset], size, flags)); } -int_least32_t socket::send_to(intmax_t handle, const vector& buffer, size_t offset, size_t size, int_least32_t flags, const vector& socket_address) { - return static_cast(::sendto(static_cast(handle), &buffer.data()[offset], size, flags, reinterpret_cast(socket_address.data()), static_cast(socket_address.size()))); +int32_t socket::send_to(intmax_t handle, const vector& buffer, size_t offset, size_t size, int32_t flags, const vector& socket_address) { + return static_cast(::sendto(static_cast(handle), &buffer.data()[offset], size, flags, reinterpret_cast(socket_address.data()), static_cast(socket_address.size()))); } -int_least32_t socket::set_blocking(intmax_t handle, bool blocking) { - int_least32_t result = -1; +int32_t socket::set_blocking(intmax_t handle, bool blocking) { + int32_t result = -1; - if ((result = fcntl(static_cast(handle), F_GETFL, 0)) != -1) { - int_least32_t flags = result; + if ((result = fcntl(static_cast(handle), F_GETFL, 0)) != -1) { + int32_t flags = result; if (blocking == true) flags &= ~O_NONBLOCK; else flags |= O_NONBLOCK; - result = fcntl(static_cast(handle), F_SETFL, flags) == -1 ? -1 : 0; + result = fcntl(static_cast(handle), F_SETFL, flags) == -1 ? -1 : 0; } return result; } -int_least32_t socket::set_raw_socket_option(intmax_t handle, int_least32_t socket_option_level, int_least32_t socket_option_name, intmax_t option, size_t option_length) { - return setsockopt(static_cast(handle), socket_option_level, socket_option_name, reinterpret_cast(option), static_cast(option_length)); +int32_t socket::set_raw_socket_option(intmax_t handle, int32_t socket_option_level, int32_t socket_option_name, intmax_t option, size_t option_length) { + return setsockopt(static_cast(handle), socket_option_level, socket_option_name, reinterpret_cast(option), static_cast(option_length)); } -int_least32_t socket::set_socket_option(intmax_t handle, int_least32_t socket_option_level, int_least32_t socket_option_name, intmax_t option, size_t option_length) { +int32_t socket::set_socket_option(intmax_t handle, int32_t socket_option_level, int32_t socket_option_name, intmax_t option, size_t option_length) { if (socket_option_name_to_native(socket_option_name) == -1) { errno = ENOTSUP; return -1; } if (socket_option_level == SOCKET_OPTION_LEVEL_SOCKET && (socket_option_name == SOCKET_OPTION_NAME_SEND_TIMEOUT || socket_option_name == SOCKET_OPTION_NAME_RECEIVE_TIMEOUT)) { - timeval timeout = {*reinterpret_cast(option) / 1000, *reinterpret_cast(option) % 1000 * 1000}; - return ::setsockopt(static_cast(handle), socket_option_level_to_native(socket_option_level), socket_option_name_to_native(socket_option_name), &timeout, sizeof(timeval)); + timeval timeout = {*reinterpret_cast(option) / 1000, *reinterpret_cast(option) % 1000 * 1000}; + return ::setsockopt(static_cast(handle), socket_option_level_to_native(socket_option_level), socket_option_name_to_native(socket_option_name), &timeout, sizeof(timeval)); } - return setsockopt(static_cast(handle), socket_option_level_to_native(socket_option_level), socket_option_name_to_native(socket_option_name), reinterpret_cast(option), static_cast(option_length)); + return setsockopt(static_cast(handle), socket_option_level_to_native(socket_option_level), socket_option_name_to_native(socket_option_name), reinterpret_cast(option), static_cast(option_length)); } -int_least32_t socket::set_socket_linger_option(intmax_t handle, bool enabled, uint_least32_t linger_time) { - linger l {static_cast(enabled), static_cast(linger_time)}; - return setsockopt(static_cast(handle), SOL_SOCKET, SO_LINGER, &l, static_cast(sizeof(linger))); +int32_t socket::set_socket_linger_option(intmax_t handle, bool enabled, uint32_t linger_time) { + linger l {static_cast(enabled), static_cast(linger_time)}; + return setsockopt(static_cast(handle), SOL_SOCKET, SO_LINGER, &l, static_cast(sizeof(linger))); } -int_least32_t socket::set_socket_multicast_option(intmax_t handle, int_least32_t socket_option_name, uint_least32_t multicast_address, uint_least32_t interface_index) { +int32_t socket::set_socket_multicast_option(intmax_t handle, int32_t socket_option_name, uint32_t multicast_address, uint32_t interface_index) { struct multicast { - uint_least32_t multicast_address; - uint_least32_t interface_index; + uint32_t multicast_address; + uint32_t interface_index; } m {multicast_address, interface_index}; - return setsockopt(static_cast(handle), IPPROTO_TCP, socket_option_name_to_native(socket_option_name), &m, static_cast(sizeof(multicast))); + return setsockopt(static_cast(handle), IPPROTO_TCP, socket_option_name_to_native(socket_option_name), &m, static_cast(sizeof(multicast))); } -int_least32_t socket::set_socket_ip_v6_multicast_option(intmax_t handle, int_least32_t socket_option_name, const vector& multicast_address, uint_least32_t interface_index) { +int32_t socket::set_socket_ip_v6_multicast_option(intmax_t handle, int32_t socket_option_name, const vector& multicast_address, uint32_t interface_index) { struct multicast { - uint_least8_t multicast_address[16]; - uint_least32_t interface_index; + uint8_t multicast_address[16]; + uint32_t interface_index; } m; for (auto index = 0U; index < multicast_address.size(); ++index) m.multicast_address[index] = multicast_address[index]; m.interface_index = interface_index; - return setsockopt(static_cast(handle), IPPROTO_IP, socket_option_name_to_native(socket_option_name), &m, static_cast(sizeof(multicast))); + return setsockopt(static_cast(handle), IPPROTO_IP, socket_option_name_to_native(socket_option_name), &m, static_cast(sizeof(multicast))); } -int_least32_t socket::shutdown(intmax_t handle, int_least32_t how) { - int_least32_t result = ::shutdown(static_cast(handle), how); +int32_t socket::shutdown(intmax_t handle, int32_t how) { + int32_t result = ::shutdown(static_cast(handle), how); if (how == SOCKET_SHUTDOWN_BOTH && result == -1 && errno == ENOTCONN) { errno = 0; result = 0; diff --git a/src/xtd.core.native.unix/src/xtd/native/unix/speech_synthesizer.cpp b/src/xtd.core.native.unix/src/xtd/native/unix/speech_synthesizer.cpp index 6e3281b47fd..75d62eadc46 100644 --- a/src/xtd.core.native.unix/src/xtd/native/unix/speech_synthesizer.cpp +++ b/src/xtd.core.native.unix/src/xtd/native/unix/speech_synthesizer.cpp @@ -27,7 +27,7 @@ namespace { } static string get_unique_speak_cmd_file_name() { - static int_least32_t cpt = 0; + static int32_t cpt = 0; stringstream ss; ss << get_temp_path() << "/__xtd_speech_synthesizer_speak_process_" << ++cpt << "__.cmd"; return ss.str(); @@ -59,14 +59,14 @@ void speech_synthesizer::resume(intmax_t handle) { void speech_synthesizer::speak(intmax_t handle, const string& text_to_speak) { speak_async(handle, text_to_speak, [] {}); - int_least32_t exit_code = 0; + int32_t exit_code = 0; native::process::wait(reinterpret_cast(handle)->process_handle, exit_code); } void speech_synthesizer::speak_async(intmax_t handle, const string& text_to_speak, std::function on_speak_completed) { reinterpret_cast(handle)->process_handle = native::process::shell_execute("", reinterpret_cast(handle)->say_cmd_file_name, text_to_speak, "", PROCESS_WINDOW_STYLE_HIDDEN); thread wait_process_thread([on_speak_completed, handle] { - int_least32_t exit_code = 0; + int32_t exit_code = 0; native::process::wait(reinterpret_cast(handle)->process_handle, exit_code); on_speak_completed(); }); diff --git a/src/xtd.core.native.unix/src/xtd/native/unix/system_sound.cpp b/src/xtd.core.native.unix/src/xtd/native/unix/system_sound.cpp index 1c7f63aacd7..4d3a5d7e549 100644 --- a/src/xtd.core.native.unix/src/xtd/native/unix/system_sound.cpp +++ b/src/xtd.core.native.unix/src/xtd/native/unix/system_sound.cpp @@ -11,9 +11,9 @@ using namespace std; using namespace xtd::native; -void system_sound::play(uint_least32_t sound) { +void system_sound::play(uint32_t sound) { #if defined(__XTD_USE_GSOUND__) - static map sounds = {{ST_BEEP, "bell-window-system"}, {ST_ICONERROR, "dialog-error"}, {ST_ICONQUESTION, "dialog-question"}, {ST_ICONWARNING, "dialog-warning"}, {ST_ICONINFORMATION, "dialog-information"}, {ST_OK, "bell-window-system"}}; + static map sounds = {{ST_BEEP, "bell-window-system"}, {ST_ICONERROR, "dialog-error"}, {ST_ICONQUESTION, "dialog-question"}, {ST_ICONWARNING, "dialog-warning"}, {ST_ICONINFORMATION, "dialog-information"}, {ST_OK, "bell-window-system"}}; static GSoundContext* gsound_context = gsound_context_new(nullptr, nullptr); gsound_context_play_simple(gsound_context, nullptr, nullptr, GSOUND_ATTR_EVENT_ID, sounds[sound].c_str(), nullptr); #endif diff --git a/src/xtd.core.native.unix/src/xtd/native/unix/thread.cpp b/src/xtd.core.native.unix/src/xtd/native/unix/thread.cpp index 0178dc6d7b6..a3e6c9960c1 100644 --- a/src/xtd.core.native.unix/src/xtd/native/unix/thread.cpp +++ b/src/xtd.core.native.unix/src/xtd/native/unix/thread.cpp @@ -14,7 +14,7 @@ bool thread::cancel(intmax_t handle) { return pthread_cancel(reinterpret_cast(handle)) == 0; } -intmax_t thread::create(std::function start, intmax_t obj, int_least32_t max_stack_size, bool suspended, intmax_t& id) { +intmax_t thread::create(std::function start, intmax_t obj, int32_t max_stack_size, bool suspended, intmax_t& id) { auto thread = pthread_t {}; int error = pthread_create(&thread, nullptr, [](void* thread_arg)->void* { auto start_obj = reinterpret_cast, intmax_t>*>(thread_arg); @@ -57,18 +57,18 @@ bool thread::set_current_thread_name(const std::string& name) { return true; } -bool thread::set_priority(intmax_t handle, int_least32_t priority) { +bool thread::set_priority(intmax_t handle, int32_t priority) { if (reinterpret_cast(handle) == PTHREAD_FAILED) return false; auto policy = 0; auto schedParam = sched_param {}; if (::pthread_getschedparam(reinterpret_cast(handle), &policy, &schedParam) != 0) return false; - schedParam.sched_priority = static_cast(std::ceil((static_cast(priority) * (sched_get_priority_max(policy) - sched_get_priority_min(policy)) / 4) + sched_get_priority_min(policy))); + schedParam.sched_priority = static_cast(std::ceil((static_cast(priority) * (sched_get_priority_max(policy) - sched_get_priority_min(policy)) / 4) + sched_get_priority_min(policy))); return pthread_setschedparam(reinterpret_cast(handle), policy, &schedParam) == 0; } -void thread::sleep(int_least32_t milliseconds_timeout) { +void thread::sleep(int32_t milliseconds_timeout) { auto infinite_sleep = [] {while (true) std::this_thread::sleep_for(std::chrono::hours::max());}; if (milliseconds_timeout == -1) infinite_sleep(); else if (milliseconds_timeout == 0) yield(); diff --git a/src/xtd.core.native.unix/src/xtd/native/unix/unnamed_event_wait_handle.cpp b/src/xtd.core.native.unix/src/xtd/native/unix/unnamed_event_wait_handle.cpp index 39170481daf..c4ce38885e9 100644 --- a/src/xtd.core.native.unix/src/xtd/native/unix/unnamed_event_wait_handle.cpp +++ b/src/xtd.core.native.unix/src/xtd/native/unix/unnamed_event_wait_handle.cpp @@ -43,7 +43,7 @@ bool unnamed_event_wait_handle::reset(intmax_t handle, bool& io_error) { return true; } -uint_least32_t unnamed_event_wait_handle::wait(intmax_t handle, int_least32_t milliseconds_timeout, bool manual_reset) { +uint32_t unnamed_event_wait_handle::wait(intmax_t handle, int32_t milliseconds_timeout, bool manual_reset) { if (reinterpret_cast(handle) == SEM_FAILED) return 0xFFFFFFFF; auto result = milliseconds_timeout == -1 ? sem_wait(reinterpret_cast(handle)) : sem_milliseconds_timedwait(reinterpret_cast(handle), milliseconds_timeout); if (result && errno == EAGAIN) return 0xFFFFFFFF; diff --git a/src/xtd.core.native.unix/src/xtd/native/unix/unnamed_mutex.cpp b/src/xtd.core.native.unix/src/xtd/native/unix/unnamed_mutex.cpp index 28e5873de9f..07f4abfbbc2 100644 --- a/src/xtd.core.native.unix/src/xtd/native/unix/unnamed_mutex.cpp +++ b/src/xtd.core.native.unix/src/xtd/native/unix/unnamed_mutex.cpp @@ -35,7 +35,7 @@ bool unnamed_mutex::signal(intmax_t handle, bool& io_error) { return !io_error; } -uint_least32_t unnamed_mutex::wait(intmax_t handle, int_least32_t milliseconds_timeout) { +uint32_t unnamed_mutex::wait(intmax_t handle, int32_t milliseconds_timeout) { if (reinterpret_cast(handle) == MUTEX_FAILED) return 0xFFFFFFFF; auto result = milliseconds_timeout == -1 ? pthread_mutex_unlock(reinterpret_cast(handle)) : pthread_mutex_milliseconds_timedlock(reinterpret_cast(handle), milliseconds_timeout); if (result && errno == EAGAIN) return 0xFFFFFFFF; diff --git a/src/xtd.core.native.unix/src/xtd/native/unix/unnamed_semaphore.cpp b/src/xtd.core.native.unix/src/xtd/native/unix/unnamed_semaphore.cpp index d5175bafc6b..aab76246a9e 100644 --- a/src/xtd.core.native.unix/src/xtd/native/unix/unnamed_semaphore.cpp +++ b/src/xtd.core.native.unix/src/xtd/native/unix/unnamed_semaphore.cpp @@ -7,7 +7,7 @@ using namespace xtd::native; -intmax_t unnamed_semaphore::create(int_least32_t initial_count, int_least32_t max_count) { +intmax_t unnamed_semaphore::create(int32_t initial_count, int32_t max_count) { auto semaphore = new sem_t; if (sem_init(semaphore, 0, std::min(initial_count, max_count)) == -1) return reinterpret_cast(SEM_FAILED); return reinterpret_cast(semaphore); @@ -19,7 +19,7 @@ void unnamed_semaphore::destroy(intmax_t handle) { delete reinterpret_cast(handle); } -bool unnamed_semaphore::signal(intmax_t handle, int_least32_t release_count, int_least32_t& previous_count, bool& io_error) { +bool unnamed_semaphore::signal(intmax_t handle, int32_t release_count, int32_t& previous_count, bool& io_error) { io_error = false; if (reinterpret_cast(handle) == SEM_FAILED) { io_error = true; @@ -32,7 +32,7 @@ bool unnamed_semaphore::signal(intmax_t handle, int_least32_t release_count, int return !io_error; } -uint_least32_t unnamed_semaphore::wait(intmax_t handle, int_least32_t milliseconds_timeout) { +uint32_t unnamed_semaphore::wait(intmax_t handle, int32_t milliseconds_timeout) { if (reinterpret_cast(handle) == SEM_FAILED) return 0xFFFFFFFF; auto result = milliseconds_timeout == -1 ? sem_wait(reinterpret_cast(handle)) : sem_milliseconds_timedwait(reinterpret_cast(handle), milliseconds_timeout); if (result && errno == EAGAIN) return 0xFFFFFFFF; diff --git a/src/xtd.core.native.win32/include/xtd/native/win32/strings.h b/src/xtd.core.native.win32/include/xtd/native/win32/strings.h index ee826e71bb6..90afe1ae0e0 100644 --- a/src/xtd.core.native.win32/include/xtd/native/win32/strings.h +++ b/src/xtd.core.native.win32/include/xtd/native/win32/strings.h @@ -166,7 +166,7 @@ namespace xtd::native { return result; } - static bool try_parse(const std::string& str, int_least32_t& value) { + static bool try_parse(const std::string& str, int32_t& value) { try { value = std::atoi(str.c_str()); return true; diff --git a/src/xtd.core.native.win32/src/xtd/native/win32/condition_variable.cpp b/src/xtd.core.native.win32/src/xtd/native/win32/condition_variable.cpp index ac8ffb4a2fd..4d1764fa795 100644 --- a/src/xtd.core.native.win32/src/xtd/native/win32/condition_variable.cpp +++ b/src/xtd.core.native.win32/src/xtd/native/win32/condition_variable.cpp @@ -30,7 +30,7 @@ void condition_variable::pulse_all(intmax_t handle) { WakeAllConditionVariable(reinterpret_cast(handle)); } -bool condition_variable::wait(intmax_t handle, intmax_t critical_section_handle, int_least32_t milliseconds_timeout) { +bool condition_variable::wait(intmax_t handle, intmax_t critical_section_handle, int32_t milliseconds_timeout) { if (handle == reinterpret_cast(INVALID_HANDLE_VALUE)) return false; if (critical_section_handle == reinterpret_cast(INVALID_HANDLE_VALUE)) return false; return SleepConditionVariableCS(reinterpret_cast(handle), reinterpret_cast(critical_section_handle), milliseconds_timeout) == TRUE; diff --git a/src/xtd.core.native.win32/src/xtd/native/win32/console.cpp b/src/xtd.core.native.win32/src/xtd/native/win32/console.cpp index bbbd2c0d9d4..0f6fa09f700 100644 --- a/src/xtd.core.native.win32/src/xtd/native/win32/console.cpp +++ b/src/xtd.core.native.win32/src/xtd/native/win32/console.cpp @@ -14,9 +14,9 @@ using namespace xtd::native; namespace { - std::function user_cancel_callback; + std::function user_cancel_callback; - int_least32_t __default_background_color() { + int32_t __default_background_color() { static auto color = CONSOLE_COLOR_DEFAULT; if (color != CONSOLE_COLOR_DEFAULT) return color; auto csbi = CONSOLE_SCREEN_BUFFER_INFO {}; @@ -25,7 +25,7 @@ namespace { return color; } - int_least32_t __default_foreground_color() { + int32_t __default_foreground_color() { static auto color = CONSOLE_COLOR_DEFAULT; if (color != CONSOLE_COLOR_DEFAULT) return color; auto csbi = CONSOLE_SCREEN_BUFFER_INFO {}; @@ -85,22 +85,22 @@ namespace { GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi); csbi.wAttributes &= 0xFF0F; - csbi.wAttributes |= ((int_least32_t)background_color_ << 4) | (int_least32_t)foreground_color_; + csbi.wAttributes |= ((int32_t)background_color_ << 4) | (int32_t)foreground_color_; SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), csbi.wAttributes); } - int_least32_t background_color_ = __default_background_color(); - int_least32_t foreground_color_ = __default_foreground_color(); + int32_t background_color_ = __default_background_color(); + int32_t foreground_color_ = __default_foreground_color(); }; terminal terminal::terminal_; } -int_least32_t console::background_color() { +int32_t console::background_color() { return ::background_color; } -bool console::background_color(int_least32_t color) { +bool console::background_color(int32_t color) { ::background_color = color; terminal::terminal_.force_compiler_optimizer_to_create_object(); auto csbi = CONSOLE_SCREEN_BUFFER_INFO {}; @@ -111,12 +111,12 @@ bool console::background_color(int_least32_t color) { return SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), csbi.wAttributes) == TRUE; } -bool console::beep(uint_least32_t frequency, uint_least32_t duration) { +bool console::beep(uint32_t frequency, uint32_t duration) { if (frequency < 37 || frequency > 32767) return false; return Beep(frequency, duration) == TRUE; } -int_least32_t console::buffer_height() { +int32_t console::buffer_height() { /* auto csbi = CONSOLE_SCREEN_BUFFER_INFO {}; ::buffer_height = GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi) == TRUE ? csbi.dwSize.Y : console::window_height(); @@ -125,18 +125,18 @@ int_least32_t console::buffer_height() { return ::buffer_height; } -bool console::buffer_height(int_least32_t height) { +bool console::buffer_height(int32_t height) { ::buffer_height = height; /* auto csbi = CONSOLE_SCREEN_BUFFER_INFO {}; GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi); - csbi.dwSize.Y = static_cast(height); + csbi.dwSize.Y = static_cast(height); return SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE), csbi.dwSize) == TRUE; */ return true; } -int_least32_t console::buffer_width() { +int32_t console::buffer_width() { /* auto csbi = CONSOLE_SCREEN_BUFFER_INFO {}; ::buffer_width = GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi) == TRUE ? csbi.dwSize.X : console::window_width(); @@ -145,12 +145,12 @@ int_least32_t console::buffer_width() { return ::buffer_width; } -bool console::buffer_width(int_least32_t width) { +bool console::buffer_width(int32_t width) { ::buffer_width = width; /* auto csbi = CONSOLE_SCREEN_BUFFER_INFO {}; GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi); - csbi.dwSize.X = static_cast(width); + csbi.dwSize.X = static_cast(width); return SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE), csbi.dwSize) == TRUE; */ return true; @@ -172,19 +172,19 @@ bool console::clear() { return console::set_cursor_position(0, 0); } -int_least32_t console::cursor_left() { +int32_t console::cursor_left() { auto csbi = CONSOLE_SCREEN_BUFFER_INFO {}; if (GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi) == TRUE) ::cursor_left = csbi.dwCursorPosition.X; return ::cursor_left; } -int_least32_t console::cursor_size() { +int32_t console::cursor_size() { auto cci = CONSOLE_CURSOR_INFO {}; if (GetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cci) == TRUE) ::cursor_size = cci.dwSize; return ::cursor_size; } -bool console::cursor_size(int_least32_t size) { +bool console::cursor_size(int32_t size) { ::cursor_size = size; auto cci = CONSOLE_CURSOR_INFO {}; GetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cci); @@ -193,7 +193,7 @@ bool console::cursor_size(int_least32_t size) { return SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cci) == TRUE; } -int_least32_t console::cursor_top() { +int32_t console::cursor_top() { auto csbi = CONSOLE_SCREEN_BUFFER_INFO {}; if (GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi) == TRUE) ::cursor_top = csbi.dwCursorPosition.Y; return ::cursor_top; @@ -221,11 +221,11 @@ bool console::echo(bool on) { return SetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), mode) == TRUE; } -int_least32_t console::foreground_color() { +int32_t console::foreground_color() { return ::foreground_color; } -bool console::foreground_color(int_least32_t color) { +bool console::foreground_color(int32_t color) { ::foreground_color = color; terminal::terminal_.force_compiler_optimizer_to_create_object(); auto csbi = CONSOLE_SCREEN_BUFFER_INFO {}; @@ -236,12 +236,12 @@ bool console::foreground_color(int_least32_t color) { return SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), csbi.wAttributes) == TRUE; } -int_least32_t console::input_code_page() { +int32_t console::input_code_page() { ::input_code_page = GetConsoleCP(); return ::input_code_page; } -bool console::input_code_page(int_least32_t code_page) { +bool console::input_code_page(int32_t code_page) { ::input_code_page = code_page; return SetConsoleCP(code_page) == TRUE; } @@ -250,13 +250,13 @@ bool console::key_available() { return _kbhit() != 0; } -int_least32_t console::largest_window_height() { +int32_t console::largest_window_height() { auto csbi = CONSOLE_SCREEN_BUFFER_INFO {}; if (GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi) == TRUE) ::largest_window_height = csbi.srWindow.Bottom - csbi.srWindow.Top + 1; return ::largest_window_height; } -int_least32_t console::largest_window_width() { +int32_t console::largest_window_width() { auto csbi = CONSOLE_SCREEN_BUFFER_INFO {}; if (GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi) == TRUE) ::largest_window_width = csbi.srWindow.Right - csbi.srWindow.Left + 1; return ::largest_window_width; @@ -267,12 +267,12 @@ bool console::number_lock() { return ::number_lock; } -int_least32_t console::output_code_page() { +int32_t console::output_code_page() { ::output_code_page = GetConsoleOutputCP(); return ::output_code_page; } -bool console::output_code_page(int_least32_t code_page) { +bool console::output_code_page(int32_t code_page) { ::output_code_page = code_page; return SetConsoleOutputCP(code_page) == TRUE; } @@ -291,7 +291,7 @@ void console::read_key(char32_t& key_char, char32_t& key_code, bool& alt, bool& ctrl = (input_record.Event.KeyEvent.dwControlKeyState & LEFT_CTRL_PRESSED) == LEFT_CTRL_PRESSED || (input_record.Event.KeyEvent.dwControlKeyState & RIGHT_CTRL_PRESSED) == RIGHT_CTRL_PRESSED; } -void console::register_user_cancel_callback(std::function user_cancel_callback) { +void console::register_user_cancel_callback(std::function user_cancel_callback) { ::user_cancel_callback = user_cancel_callback; } @@ -301,13 +301,13 @@ bool console::reset_color() { return result; } -bool console::set_cursor_position(int_least32_t left, int_least32_t top) { +bool console::set_cursor_position(int32_t left, int32_t top) { ::cursor_left = left; ::cursor_top = top; auto csbi = CONSOLE_SCREEN_BUFFER_INFO {}; GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi); - csbi.dwCursorPosition.X = static_cast(left); - csbi.dwCursorPosition.Y = static_cast(top); + csbi.dwCursorPosition.X = static_cast(left); + csbi.dwCursorPosition.Y = static_cast(top); return SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), csbi.dwCursorPosition) == TRUE; } @@ -337,61 +337,61 @@ bool console::treat_control_c_as_input(bool treat_control_c_as_input) { return SetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), mode) == TRUE; } -int_least32_t console::window_height() { +int32_t console::window_height() { auto csbi = CONSOLE_SCREEN_BUFFER_INFO {}; ::window_height = GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi) == TRUE ? csbi.srWindow.Bottom - csbi.srWindow.Top + 1 : 25; return ::window_height; } -bool console::window_height(int_least32_t height) { +bool console::window_height(int32_t height) { ::window_height = height; auto csbi = CONSOLE_SCREEN_BUFFER_INFO {}; GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi); - csbi.srWindow.Bottom = static_cast(csbi.srWindow.Top + height - 1); + csbi.srWindow.Bottom = static_cast(csbi.srWindow.Top + height - 1); return SetConsoleWindowInfo(GetStdHandle(STD_OUTPUT_HANDLE), TRUE, &csbi.srWindow) == TRUE; } -int_least32_t console::window_left() { +int32_t console::window_left() { auto csbi = CONSOLE_SCREEN_BUFFER_INFO {}; ::window_left = GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi) == TRUE ? csbi.srWindow.Left : 0; return ::window_left; } -bool console::window_left(int_least32_t left) { +bool console::window_left(int32_t left) { ::window_left = left; auto csbi = CONSOLE_SCREEN_BUFFER_INFO {}; GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi); - csbi.srWindow.Left = static_cast(left); - csbi.srWindow.Right += static_cast(left); + csbi.srWindow.Left = static_cast(left); + csbi.srWindow.Right += static_cast(left); return SetConsoleWindowInfo(GetStdHandle(STD_OUTPUT_HANDLE), TRUE, &csbi.srWindow) == TRUE; } -int_least32_t console::window_top() { +int32_t console::window_top() { auto csbi = CONSOLE_SCREEN_BUFFER_INFO {}; ::window_top = GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi) == TRUE ? csbi.srWindow.Top : 0; return ::window_top; } -bool console::window_top(int_least32_t top) { +bool console::window_top(int32_t top) { ::window_top = top; auto csbi = CONSOLE_SCREEN_BUFFER_INFO {}; GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi); - csbi.srWindow.Top = static_cast(top); - csbi.srWindow.Bottom += static_cast(top); + csbi.srWindow.Top = static_cast(top); + csbi.srWindow.Bottom += static_cast(top); return SetConsoleWindowInfo(GetStdHandle(STD_OUTPUT_HANDLE), TRUE, &csbi.srWindow) == TRUE; } -int_least32_t console::window_width() { +int32_t console::window_width() { auto csbi = CONSOLE_SCREEN_BUFFER_INFO {}; ::window_width = GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi) == TRUE ? csbi.srWindow.Right - csbi.srWindow.Left + 1 : 80; return ::window_width; } -bool console::window_width(int_least32_t width) { +bool console::window_width(int32_t width) { ::window_width = width; auto csbi = CONSOLE_SCREEN_BUFFER_INFO {}; GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi); - csbi.srWindow.Right = static_cast(csbi.srWindow.Left + width - 1); + csbi.srWindow.Right = static_cast(csbi.srWindow.Left + width - 1); return SetConsoleWindowInfo(GetStdHandle(STD_OUTPUT_HANDLE), TRUE, &csbi.srWindow) == TRUE; } diff --git a/src/xtd.core.native.win32/src/xtd/native/win32/cryptography.cpp b/src/xtd.core.native.win32/src/xtd/native/win32/cryptography.cpp index 83ed222860f..461b4a42b90 100644 --- a/src/xtd.core.native.win32/src/xtd/native/win32/cryptography.cpp +++ b/src/xtd.core.native.win32/src/xtd/native/win32/cryptography.cpp @@ -16,7 +16,7 @@ namespace { } } -vector cryptography::machine_guid() { +vector cryptography::machine_guid() { auto guid_str = win32::strings::to_string(get_machine_guid_str()); static const auto guid_fallback = string {"30395f0ed6aa4a5eb4af6f90a608c605"}; @@ -25,8 +25,8 @@ vector cryptography::machine_guid() { if (hex_chars.find(static_cast(toupper(guid_str[index]))) == hex_chars.npos) guid_str.erase(index--, 1); if (guid_str.size() != 32) guid_str = guid_fallback; - auto bytes = vector {}; + auto bytes = vector {}; for (auto index = 0U; index < guid_str.size(); index += 2) - bytes.push_back(static_cast(stoi(guid_str.substr(index, 2), 0, 16))); + bytes.push_back(static_cast(stoi(guid_str.substr(index, 2), 0, 16))); return bytes; } diff --git a/src/xtd.core.native.win32/src/xtd/native/win32/date_time.cpp b/src/xtd.core.native.win32/src/xtd/native/win32/date_time.cpp index 220a4b075ec..5d2318785e0 100644 --- a/src/xtd.core.native.win32/src/xtd/native/win32/date_time.cpp +++ b/src/xtd.core.native.win32/src/xtd/native/win32/date_time.cpp @@ -23,7 +23,7 @@ using namespace std; using namespace xtd::native; namespace { - static const int_least64_t ticks_per_second = 10000000; + static const int64_t ticks_per_second = 10000000; /* Generate by this c# code source : @@ -248,7 +248,7 @@ date_time::time_zone_info date_time::get_local_time_zone() { if (iterator != stzis.end()) { local_time_zone = *iterator; local_time_zone.id = reinterpret_cast(tzname[0]); - local_time_zone.base_utc_offset = static_cast(-timezone * ticks_per_second); + local_time_zone.base_utc_offset = static_cast(-timezone * ticks_per_second); local_time_zone.daylight_name = reinterpret_cast(tzname[1]); local_time_zone.display_name = string_printf("(UTC%s%02d:%02d) %s", (-timezone) ? "+" : "", abs(timezone) / 3600, (abs(timezone) % 3600) / 60, reinterpret_cast(tzname[0])); local_time_zone.standard_name = reinterpret_cast(tzname[0]); diff --git a/src/xtd.core.native.win32/src/xtd/native/win32/debugger.cpp b/src/xtd.core.native.win32/src/xtd/native/win32/debugger.cpp index 0e3f5bdd2f4..cfb0b30f798 100644 --- a/src/xtd.core.native.win32/src/xtd/native/win32/debugger.cpp +++ b/src/xtd.core.native.win32/src/xtd/native/win32/debugger.cpp @@ -41,10 +41,10 @@ bool debugger::launch() { return true; } -int_least32_t debugger::show_assert_dialog(const std::string& text, const std::string& caption) { +int32_t debugger::show_assert_dialog(const std::string& text, const std::string& caption) { return MessageBox(nullptr, win32::strings::to_wstring(text).c_str(), win32::strings::to_wstring(caption).c_str(), MB_TOPMOST | MB_ICONERROR | MB_ABORTRETRYIGNORE | MB_DEFBUTTON3); } -void debugger::log(int_least32_t level, const std::string& category, const std::string& message) { +void debugger::log(int32_t level, const std::string& category, const std::string& message) { OutputDebugString(win32::strings::to_wstring(message).c_str()); } diff --git a/src/xtd.core.native.win32/src/xtd/native/win32/directory.cpp b/src/xtd.core.native.win32/src/xtd/native/win32/directory.cpp index cfa78ff72e6..ef7034b0808 100644 --- a/src/xtd.core.native.win32/src/xtd/native/win32/directory.cpp +++ b/src/xtd.core.native.win32/src/xtd/native/win32/directory.cpp @@ -238,7 +238,7 @@ const std::string& directory::file_and_directory_iterator::pattern() const { return data_->pattern_; } -int_least32_t directory::create(const std::string& directory_name) { +int32_t directory::create(const std::string& directory_name) { return CreateDirectory(win32::strings::to_wstring(directory_name).c_str(), nullptr) != FALSE ? 0 : -1; } @@ -267,10 +267,10 @@ string directory::get_current_directory() { return win32::strings::to_string(current_directory); } -int_least32_t directory::remove(const std::string& directory_name) { +int32_t directory::remove(const std::string& directory_name) { return RemoveDirectory(win32::strings::to_wstring(directory_name).c_str()) != FALSE ? 0 : -1; } -int_least32_t directory::set_current_directory(const std::string& directory_name) { +int32_t directory::set_current_directory(const std::string& directory_name) { return SetCurrentDirectory(win32::strings::to_wstring(directory_name).c_str()) != FALSE ? 0 : -1; } diff --git a/src/xtd.core.native.win32/src/xtd/native/win32/dns.cpp b/src/xtd.core.native.win32/src/xtd/native/win32/dns.cpp index c0a8334bc30..41d1a40413e 100644 --- a/src/xtd.core.native.win32/src/xtd/native/win32/dns.cpp +++ b/src/xtd.core.native.win32/src/xtd/native/win32/dns.cpp @@ -23,9 +23,9 @@ void dns::destroy(intmax_t host) { delete reinterpret_cast(host); } -intmax_t dns::get_host_by_address(const string& host_address, int_least32_t host_address_type) { +intmax_t dns::get_host_by_address(const string& host_address, int32_t host_address_type) { auto lock = lock_guard {dns_mutex}; - auto internet_address = int_least64_t {}; + auto internet_address = int64_t {}; inet_pton(host_address_type, host_address.c_str(), &internet_address); auto host = gethostbyaddr(reinterpret_cast(&internet_address), host_address_type == ADDRESS_FAMILY_INTER_NETWORK ? 4 : 16, host_address_type); if (host == nullptr) return 0; @@ -47,11 +47,11 @@ vector dns::get_aliases(intmax_t host) { return aliases; } -vector> dns::get_addresses(intmax_t host) { +vector> dns::get_addresses(intmax_t host) { auto index = size_t {}; - auto addresses = vector> {}; + auto addresses = vector> {}; while (reinterpret_cast(host)->h_addr_list[index] != nullptr) { - addresses.push_back(vector(reinterpret_cast(reinterpret_cast(host)->h_addr_list[index]), reinterpret_cast(reinterpret_cast(host)->h_addr_list[index]) + (reinterpret_cast(host)->h_addrtype == ADDRESS_FAMILY_INTER_NETWORK ? 4 : 16))); + addresses.push_back(vector(reinterpret_cast(reinterpret_cast(host)->h_addr_list[index]), reinterpret_cast(reinterpret_cast(host)->h_addr_list[index]) + (reinterpret_cast(host)->h_addrtype == ADDRESS_FAMILY_INTER_NETWORK ? 4 : 16))); index++; } return addresses; @@ -61,9 +61,9 @@ string dns::get_host_name(intmax_t host) { return reinterpret_cast(host)->h_name; } -int_least32_t dns::get_host_name(string& host_name) { +int32_t dns::get_host_name(string& host_name) { auto name = std::string(1024, '\0'); - int_least32_t result = gethostname(name.data(), static_cast(name.size())); + int32_t result = gethostname(name.data(), static_cast(name.size())); host_name = name.c_str();; return result; } diff --git a/src/xtd.core.native.win32/src/xtd/native/win32/drive.cpp b/src/xtd.core.native.win32/src/xtd/native/win32/drive.cpp index 07b7f808d43..360fbc6cccc 100644 --- a/src/xtd.core.native.win32/src/xtd/native/win32/drive.cpp +++ b/src/xtd.core.native.win32/src/xtd/native/win32/drive.cpp @@ -18,7 +18,7 @@ bool drive::get_available_free_space(const std::string& root_path_name, size_t& return GetDiskFreeSpaceEx(win32::strings::to_wstring(root_path_name).c_str(), reinterpret_cast(&free_bytes), reinterpret_cast(&total_number_of_bytes), reinterpret_cast(&total_number_of_free_bytes)) != FALSE; } -int_least32_t drive::get_drive_type(const std::string& root_path_name) { +int32_t drive::get_drive_type(const std::string& root_path_name) { return GetDriveType(win32::strings::to_wstring(root_path_name).c_str()); } diff --git a/src/xtd.core.native.win32/src/xtd/native/win32/environment.cpp b/src/xtd.core.native.win32/src/xtd/native/win32/environment.cpp index 6ae971f41f1..51eefeca002 100644 --- a/src/xtd.core.native.win32/src/xtd/native/win32/environment.cpp +++ b/src/xtd.core.native.win32/src/xtd/native/win32/environment.cpp @@ -31,7 +31,7 @@ auto __process_envs__ = map {}; auto __user_envs__ = map {}; namespace { - void get_windows_version(int_least32_t& major, int_least32_t& minor, int_least32_t& build, int_least32_t& revision) { + void get_windows_version(int32_t& major, int32_t& minor, int32_t& build, int32_t& revision) { // GetVersionEx (https://docs.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getversionexa) allows you to get the version for a Windows 8 at most. For Windows 10 and more see : // https://stackoverflow.com/questions/32115255/c-how-to-detect-windows-10 NTSTATUS(WINAPI * RtlGetVersion)(LPOSVERSIONINFOEXW); @@ -106,7 +106,7 @@ namespace { } } -int_least32_t environment::at_quick_exit(void (*on_quick_exit)(void)) { +int32_t environment::at_quick_exit(void (*on_quick_exit)(void)) { return std::at_quick_exit(on_quick_exit); } @@ -160,7 +160,7 @@ string environment::get_distribution_name() { return name; } -void environment::get_distribution_version(int_least32_t& major, int_least32_t& minor, int_least32_t& build, int_least32_t& revision) { +void environment::get_distribution_version(int32_t& major, int32_t& minor, int32_t& build, int32_t& revision) { auto dummy = -1; get_os_version(major, minor, build, dummy); } @@ -174,7 +174,7 @@ string environment::get_distribution_version_string() { return version + (version.empty() ? "" : " ") + to_string(major) + "." + to_string(minor) + "." + to_string(build) + (code_name.empty() ? "" : " (" + code_name + ")"); } -string environment::get_environment_variable(const string& variable, int_least32_t target) { +string environment::get_environment_variable(const string& variable, int32_t target) { if (target == ENVIRONMENT_VARIABLE_TARGET_PROCESS) { auto environent_variable_size = DWORD {65535}; auto environment_variable = wstring(environent_variable_size, '\0'); @@ -191,7 +191,7 @@ string environment::get_environment_variable(const string& variable, int_least32 return ""; } -map& environment::get_environment_variables(int_least32_t target) { +map& environment::get_environment_variables(int32_t target) { auto& envs = __none_envs__; if (target == ENVIRONMENT_VARIABLE_TARGET_PROCESS) { @@ -235,7 +235,7 @@ map& environment::get_environment_variables(int_least32_t target return envs; } -string environment::get_know_folder_path(int_least32_t id) { +string environment::get_know_folder_path(int32_t id) { if (id == CSIDL_HOME) return get_environment_variable("HOMEDRIVE", ENVIRONMENT_VARIABLE_TARGET_PROCESS) + get_environment_variable("HOMEPATH", ENVIRONMENT_VARIABLE_TARGET_PROCESS); auto path = wstring(65535 , '\0'); @@ -250,15 +250,15 @@ string environment::get_machine_name() { return win32::strings::to_string(machine_name); } -int_least32_t environment::get_os_platform_id() { +int32_t environment::get_os_platform_id() { return PLATFORM_WIN32_NT; } -void environment::get_os_version(int_least32_t& major, int_least32_t& minor, int_least32_t& build, int_least32_t& revision) { +void environment::get_os_version(int32_t& major, int32_t& minor, int32_t& build, int32_t& revision) { return get_windows_version(major, minor, build, revision); } -uint_least32_t environment::get_processor_count() { +uint32_t environment::get_processor_count() { auto system_info = SYSTEM_INFO {}; GetNativeSystemInfo(&system_info); return system_info.dwNumberOfProcessors; @@ -287,7 +287,7 @@ size_t environment::get_system_page_size() { return system_info.dwPageSize; } -uint_least32_t environment::get_tick_count() { +uint32_t environment::get_tick_count() { return GetTickCount(); } @@ -335,11 +335,11 @@ string environment::new_line() { return "\n"; } -void environment::quick_exit(int_least32_t exit_code) noexcept { +void environment::quick_exit(int32_t exit_code) noexcept { std::quick_exit(exit_code); } -void environment::set_environment_variable(const string& name, const string& value, int_least32_t target) { +void environment::set_environment_variable(const string& name, const string& value, int32_t target) { if (target == ENVIRONMENT_VARIABLE_TARGET_PROCESS) SetEnvironmentVariable(win32::strings::to_wstring(name).c_str(), win32::strings::to_wstring(value).c_str()); else if (target == ENVIRONMENT_VARIABLE_TARGET_USER) { @@ -349,7 +349,7 @@ void environment::set_environment_variable(const string& name, const string& val } } -void environment::unset_environment_variable(const string& name, int_least32_t target) { +void environment::unset_environment_variable(const string& name, int32_t target) { if (target == ENVIRONMENT_VARIABLE_TARGET_PROCESS) SetEnvironmentVariable(win32::strings::to_wstring(name).c_str(), nullptr); else if (target == ENVIRONMENT_VARIABLE_TARGET_USER) { @@ -359,6 +359,6 @@ void environment::unset_environment_variable(const string& name, int_least32_t t } } -int_least64_t environment::working_set() { +int64_t environment::working_set() { return 0; } diff --git a/src/xtd.core.native.win32/src/xtd/native/win32/file.cpp b/src/xtd.core.native.win32/src/xtd/native/win32/file.cpp index d40c315e332..e4c47ef70fa 100644 --- a/src/xtd.core.native.win32/src/xtd/native/win32/file.cpp +++ b/src/xtd.core.native.win32/src/xtd/native/win32/file.cpp @@ -12,12 +12,12 @@ using namespace xtd::native; #undef max #undef min -int_least32_t file::copy(const std::string& source_file, const std::string& target_file) { +int32_t file::copy(const std::string& source_file, const std::string& target_file) { return CopyFile(win32::strings::to_wstring(source_file).c_str(), win32::strings::to_wstring(target_file).c_str(), TRUE) != FALSE ? 0 : -1; } bool file::exists(const std::string& path) { - int_least32_t attributes = 0; + int32_t attributes = 0; return file_system::get_attributes(path, attributes) == 0 && (attributes & FILE_ATTRIBUTE_DIRECTORY) != FILE_ATTRIBUTE_DIRECTORY; } @@ -34,10 +34,10 @@ size_t file::get_size(const std::string& path) { return static_cast(size.QuadPart); } -int_least32_t file::move(const std::string& old_path, const std::string& new_path) { +int32_t file::move(const std::string& old_path, const std::string& new_path) { return MoveFile(win32::strings::to_wstring(old_path).c_str(), win32::strings::to_wstring(new_path).c_str()) != FALSE ? 0 : -1; } -int_least32_t file::remove(const std::string& file) { +int32_t file::remove(const std::string& file) { return DeleteFile(win32::strings::to_wstring(file).c_str()) != FALSE ? 0 : -1; } diff --git a/src/xtd.core.native.win32/src/xtd/native/win32/file_system.cpp b/src/xtd.core.native.win32/src/xtd/native/win32/file_system.cpp index 66dc93a51a0..44c80901d7c 100644 --- a/src/xtd.core.native.win32/src/xtd/native/win32/file_system.cpp +++ b/src/xtd.core.native.win32/src/xtd/native/win32/file_system.cpp @@ -32,13 +32,13 @@ namespace { } } -int_least32_t file_system::get_attributes(const string& path, int_least32_t& attributes) { +int32_t file_system::get_attributes(const string& path, int32_t& attributes) { auto attrib = GetFileAttributes(win32::strings::to_wstring(path).c_str()); - if (attrib != INVALID_FILE_ATTRIBUTES) attributes = static_cast(attrib); + if (attrib != INVALID_FILE_ATTRIBUTES) attributes = static_cast(attrib); return attrib != INVALID_FILE_ATTRIBUTES ? 0 : -1; } -int_least32_t file_system::get_file_times(const string& path, time_t& creation_time, time_t& last_access_time, time_t& last_write_time) { +int32_t file_system::get_file_times(const string& path, time_t& creation_time, time_t& last_access_time, time_t& last_write_time) { auto file_handle = CreateFile(win32::strings::to_wstring(path).c_str(), 0, 0, nullptr, OPEN_EXISTING, 0, nullptr); if (file_handle == INVALID_HANDLE_VALUE) file_handle = CreateFile(win32::strings::to_wstring(path).c_str(), 0, 0, nullptr, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, nullptr); if (file_handle == INVALID_HANDLE_VALUE) return 1; @@ -62,7 +62,7 @@ string file_system::get_full_path(const string& relative_path) { return win32::strings::to_string(full_path); } -int_least32_t file_system::get_permissions(const std::string& path, int_least32_t& permissions) { +int32_t file_system::get_permissions(const std::string& path, int32_t& permissions) { struct system_permission_to_file_permission_converter { int operator()(std::filesystem::perms permission) { auto file_permissions = 0; @@ -95,11 +95,11 @@ bool file_system::is_path_too_long(const string& path) { return path.size() > MAX_PATH; } -int_least32_t file_system::set_attributes(const std::string& path, int_least32_t attributes) { +int32_t file_system::set_attributes(const std::string& path, int32_t attributes) { return SetFileAttributes(win32::strings::to_wstring(path).c_str(), attributes) == TRUE ? 0 : -1; } -int_least32_t file_system::set_creation_time(const string& path, time_t creation_time) { +int32_t file_system::set_creation_time(const string& path, time_t creation_time) { auto file_handle = CreateFile(win32::strings::to_wstring(path).c_str(), 0, 0, nullptr, OPEN_EXISTING, 0, nullptr); if (file_handle == INVALID_HANDLE_VALUE) file_handle = CreateFile(win32::strings::to_wstring(path).c_str(), 0, 0, nullptr, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, nullptr); if (file_handle == INVALID_HANDLE_VALUE) return 1; @@ -113,7 +113,7 @@ int_least32_t file_system::set_creation_time(const string& path, time_t creation return result == TRUE ? 0 : 2; } -int_least32_t file_system::set_last_access_time(const string& path, time_t last_access_time) { +int32_t file_system::set_last_access_time(const string& path, time_t last_access_time) { HANDLE file_handle = CreateFile(win32::strings::to_wstring(path).c_str(), 0, 0, nullptr, OPEN_EXISTING, 0, nullptr); if (file_handle == INVALID_HANDLE_VALUE) file_handle = CreateFile(win32::strings::to_wstring(path).c_str(), 0, 0, nullptr, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, nullptr); if (file_handle == 0) return 1; @@ -127,7 +127,7 @@ int_least32_t file_system::set_last_access_time(const string& path, time_t last_ return result == TRUE ? 0 : 2; } -int_least32_t file_system::set_last_write_time(const string& path, time_t last_write_time) { +int32_t file_system::set_last_write_time(const string& path, time_t last_write_time) { HANDLE file_handle = CreateFile(win32::strings::to_wstring(path).c_str(), 0, 0, nullptr, OPEN_EXISTING, 0, nullptr); if (file_handle == INVALID_HANDLE_VALUE) file_handle = CreateFile(win32::strings::to_wstring(path).c_str(), 0, 0, nullptr, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, nullptr); if (file_handle == 0) return 1; @@ -141,9 +141,9 @@ int_least32_t file_system::set_last_write_time(const string& path, time_t last_w return result == TRUE ? 0 : 2; } -int_least32_t file_system::set_permissions(const std::string& path, int_least32_t permissions) { +int32_t file_system::set_permissions(const std::string& path, int32_t permissions) { struct file_permission_to_system_permission_converter { - std::filesystem::perms operator()(int_least32_t permission) { + std::filesystem::perms operator()(int32_t permission) { auto system_permissions = std::filesystem::perms::none; if ((permission & FILE_PERMISSIONS_OWNER_READ) == FILE_PERMISSIONS_OWNER_READ) system_permissions |= std::filesystem::perms::owner_read; if ((permission & FILE_PERMISSIONS_OWNER_WRITE) == FILE_PERMISSIONS_OWNER_WRITE) system_permissions |= std::filesystem::perms::owner_write; diff --git a/src/xtd.core.native.win32/src/xtd/native/win32/guid.cpp b/src/xtd.core.native.win32/src/xtd/native/win32/guid.cpp index f42c7212d7f..2bbab65a246 100644 --- a/src/xtd.core.native.win32/src/xtd/native/win32/guid.cpp +++ b/src/xtd.core.native.win32/src/xtd/native/win32/guid.cpp @@ -13,8 +13,8 @@ using namespace xtd::native; #undef min #undef max -std::vector guid::new_guid() { +std::vector guid::new_guid() { auto guid = UUID {}; UuidCreate(&guid); - return {reinterpret_cast(&guid), reinterpret_cast(&guid) + 16}; + return {reinterpret_cast(&guid), reinterpret_cast(&guid) + 16}; } diff --git a/src/xtd.core.native.win32/src/xtd/native/win32/interlocked.cpp b/src/xtd.core.native.win32/src/xtd/native/win32/interlocked.cpp index 96a56b17f97..1c8357c071f 100644 --- a/src/xtd.core.native.win32/src/xtd/native/win32/interlocked.cpp +++ b/src/xtd.core.native.win32/src/xtd/native/win32/interlocked.cpp @@ -8,21 +8,21 @@ using namespace std; using namespace xtd::native; -int_least32_t interlocked::add(int_least32_t& location, int_least32_t value) { +int32_t interlocked::add(int32_t& location, int32_t value) { InterlockedExchange((long*)&location, location + value); return location; } -int_least64_t interlocked::add(int_least64_t& location, int_least64_t value) { +int64_t interlocked::add(int64_t& location, int64_t value) { InterlockedExchange64((long long*)&location, location + value); return location; } -int_least32_t interlocked::compare_exchange(int_least32_t& location, int_least32_t value, int_least32_t comparand) { +int32_t interlocked::compare_exchange(int32_t& location, int32_t value, int32_t comparand) { return InterlockedCompareExchange((long*)&location, value, comparand); } -int_least64_t interlocked::compare_exchange(int_least64_t& location, int_least64_t value, int_least64_t comparand) { +int64_t interlocked::compare_exchange(int64_t& location, int64_t value, int64_t comparand) { return InterlockedCompareExchange64((long long*)&location, value, comparand); } @@ -43,19 +43,19 @@ void* interlocked::compare_exchange(void*& location, void* value, void* comparan } #pragma warning(pop) -int_least32_t interlocked::decrement(int_least32_t& location) { +int32_t interlocked::decrement(int32_t& location) { return InterlockedDecrement((long*)&location); } -int_least64_t interlocked::decrement(int_least64_t& location) { +int64_t interlocked::decrement(int64_t& location) { return InterlockedDecrement64((long long*)&location); } -int_least32_t interlocked::exchange(int_least32_t& location, int_least32_t value) { +int32_t interlocked::exchange(int32_t& location, int32_t value) { return InterlockedExchange((long*)&location, value); } -int_least64_t interlocked::exchange(int_least64_t& location, int_least64_t value) { +int64_t interlocked::exchange(int64_t& location, int64_t value) { return InterlockedExchange64((long long*)&location, value); } @@ -76,10 +76,10 @@ void* interlocked::exchange(void*& location, void* value) { } #pragma warning(pop) -int_least32_t interlocked::increment(int_least32_t& location) { +int32_t interlocked::increment(int32_t& location) { return InterlockedIncrement((long*)&location); } -int_least64_t interlocked::increment(int_least64_t& location) { +int64_t interlocked::increment(int64_t& location) { return InterlockedIncrement64((long long*)&location); } diff --git a/src/xtd.core.native.win32/src/xtd/native/win32/named_event_wait_handle.cpp b/src/xtd.core.native.win32/src/xtd/native/win32/named_event_wait_handle.cpp index 104b091ec28..4fe5eb7f36b 100644 --- a/src/xtd.core.native.win32/src/xtd/native/win32/named_event_wait_handle.cpp +++ b/src/xtd.core.native.win32/src/xtd/native/win32/named_event_wait_handle.cpp @@ -51,7 +51,7 @@ bool named_event_wait_handle::reset(intmax_t handle, bool& io_error) { return !io_error; } -uint_least32_t named_event_wait_handle::wait(intmax_t handle, int_least32_t milliseconds_timeout, bool manual_reset) { +uint32_t named_event_wait_handle::wait(intmax_t handle, int32_t milliseconds_timeout, bool manual_reset) { if (reinterpret_cast(handle) == INVALID_HANDLE_VALUE) return WAIT_FAILED; - return static_cast(WaitForSingleObject(reinterpret_cast(handle), milliseconds_timeout == -1 ? INFINITE : milliseconds_timeout)); + return static_cast(WaitForSingleObject(reinterpret_cast(handle), milliseconds_timeout == -1 ? INFINITE : milliseconds_timeout)); } diff --git a/src/xtd.core.native.win32/src/xtd/native/win32/named_mutex.cpp b/src/xtd.core.native.win32/src/xtd/native/win32/named_mutex.cpp index 09432de4711..15ca64b8a2d 100644 --- a/src/xtd.core.native.win32/src/xtd/native/win32/named_mutex.cpp +++ b/src/xtd.core.native.win32/src/xtd/native/win32/named_mutex.cpp @@ -42,7 +42,7 @@ bool named_mutex::signal(intmax_t handle, bool& io_error) { return !io_error; } -uint_least32_t named_mutex::wait(intmax_t handle, int_least32_t milliseconds_timeout) { +uint32_t named_mutex::wait(intmax_t handle, int32_t milliseconds_timeout) { if (reinterpret_cast(handle) == INVALID_HANDLE_VALUE) return WAIT_FAILED; - return static_cast(WaitForSingleObject(reinterpret_cast(handle), milliseconds_timeout == -1 ? INFINITE : milliseconds_timeout)); + return static_cast(WaitForSingleObject(reinterpret_cast(handle), milliseconds_timeout == -1 ? INFINITE : milliseconds_timeout)); } diff --git a/src/xtd.core.native.win32/src/xtd/native/win32/named_semaphore.cpp b/src/xtd.core.native.win32/src/xtd/native/win32/named_semaphore.cpp index b0f71757407..927858e498f 100644 --- a/src/xtd.core.native.win32/src/xtd/native/win32/named_semaphore.cpp +++ b/src/xtd.core.native.win32/src/xtd/native/win32/named_semaphore.cpp @@ -9,7 +9,7 @@ using namespace xtd::native; -intmax_t named_semaphore::create(int_least32_t initial_count, int_least32_t max_count, const std::string& name) { +intmax_t named_semaphore::create(int32_t initial_count, int32_t max_count, const std::string& name) { auto handle = CreateSemaphore(nullptr, initial_count, max_count, win32::strings::to_wstring(name).c_str()); if (handle != INVALID_HANDLE_VALUE && GetLastError() == ERROR_ALREADY_EXISTS) { CloseHandle(handle); @@ -33,7 +33,7 @@ intmax_t named_semaphore::open(const std::string& name) { return reinterpret_cast(handle); } -bool named_semaphore::signal(intmax_t handle, int_least32_t release_count, int_least32_t& previous_count, bool& io_error) { +bool named_semaphore::signal(intmax_t handle, int32_t release_count, int32_t& previous_count, bool& io_error) { if (reinterpret_cast(handle) == INVALID_HANDLE_VALUE) { io_error = true; return false; @@ -44,7 +44,7 @@ bool named_semaphore::signal(intmax_t handle, int_least32_t release_count, int_l } -uint_least32_t named_semaphore::wait(intmax_t handle, int_least32_t milliseconds_timeout) { +uint32_t named_semaphore::wait(intmax_t handle, int32_t milliseconds_timeout) { if (reinterpret_cast(handle) == INVALID_HANDLE_VALUE) return WAIT_FAILED; - return static_cast(WaitForSingleObject(reinterpret_cast(handle), milliseconds_timeout == -1 ? INFINITE : milliseconds_timeout)); + return static_cast(WaitForSingleObject(reinterpret_cast(handle), milliseconds_timeout == -1 ? INFINITE : milliseconds_timeout)); } diff --git a/src/xtd.core.native.win32/src/xtd/native/win32/process.cpp b/src/xtd.core.native.win32/src/xtd/native/win32/process.cpp index d95c320613c..16d6864106e 100644 --- a/src/xtd.core.native.win32/src/xtd/native/win32/process.cpp +++ b/src/xtd.core.native.win32/src/xtd/native/win32/process.cpp @@ -71,8 +71,8 @@ namespace { } } -int_least32_t process::base_priority(int_least32_t priority) { - static auto base_priorities = map {{IDLE_PRIORITY_CLASS, 4}, {BELOW_NORMAL_PRIORITY_CLASS, 6}, {NORMAL_PRIORITY_CLASS, 8}, {ABOVE_NORMAL_PRIORITY_CLASS, 10}, {HIGH_PRIORITY_CLASS, 13}, {REALTIME_PRIORITY_CLASS, 24}}; +int32_t process::base_priority(int32_t priority) { + static auto base_priorities = map {{IDLE_PRIORITY_CLASS, 4}, {BELOW_NORMAL_PRIORITY_CLASS, 6}, {NORMAL_PRIORITY_CLASS, 8}, {ABOVE_NORMAL_PRIORITY_CLASS, 10}, {HIGH_PRIORITY_CLASS, 13}, {REALTIME_PRIORITY_CLASS, 24}}; auto it = base_priorities.find(priority); if (it == base_priorities.end()) it = base_priorities.find(NORMAL_PRIORITY_CLASS); return it->second; @@ -80,16 +80,16 @@ int_least32_t process::base_priority(int_least32_t priority) { bool process::kill(intmax_t handle) { if (handle == 0) return false; - return TerminateProcess(reinterpret_cast(handle), static_cast(-1)) != 0; + return TerminateProcess(reinterpret_cast(handle), static_cast(-1)) != 0; } -bool process::priority_class(intmax_t process, int_least32_t priority) { +bool process::priority_class(intmax_t process, int32_t priority) { return SetPriorityClass(reinterpret_cast(process), priority) == TRUE; } -intmax_t process::shell_execute(const std::string& verb, const std::string& file_name, const std::string& arguments, const std::string& working_directory, int_least32_t process_window_style) { +intmax_t process::shell_execute(const std::string& verb, const std::string& file_name, const std::string& arguments, const std::string& working_directory, int32_t process_window_style) { initialize(); - static auto window_styles = map {{PROCESS_WINDOW_STYLE_NORMAL, SW_NORMAL}, {PROCESS_WINDOW_STYLE_HIDDEN, SW_HIDE}, {PROCESS_WINDOW_STYLE_MINIMIZED, SW_SHOWMINIMIZED}, {PROCESS_WINDOW_STYLE_MAXIMIZED, SW_SHOWMAXIMIZED}}; + static auto window_styles = map {{PROCESS_WINDOW_STYLE_NORMAL, SW_NORMAL}, {PROCESS_WINDOW_STYLE_HIDDEN, SW_HIDE}, {PROCESS_WINDOW_STYLE_MINIMIZED, SW_SHOWMINIMIZED}, {PROCESS_WINDOW_STYLE_MAXIMIZED, SW_SHOWMAXIMIZED}}; auto wverb = win32::strings::to_wstring(verb); auto wfile_name = win32::strings::to_wstring(file_name); auto warguments = win32::strings::to_wstring(arguments); @@ -109,7 +109,7 @@ intmax_t process::shell_execute(const std::string& verb, const std::string& file return reinterpret_cast(shell_execute_info.hInstApp); } -process::started_process process::start(const string& file_name, const string& arguments, const string& working_directory, int_least32_t process_window_style, int_least32_t process_creation_flags, tuple redirect_standard_streams) { +process::started_process process::start(const string& file_name, const string& arguments, const string& working_directory, int32_t process_window_style, int32_t process_creation_flags, tuple redirect_standard_streams) { initialize(); auto [redirect_standard_input, redirect_standard_output, redirect_standard_error] = redirect_standard_streams; auto startup_info = STARTUPINFO {}; @@ -149,10 +149,10 @@ process::started_process process::start(const string& file_name, const string& a process_infos[reinterpret_cast(process_information.hProcess)] = make_tuple(reinterpret_cast(process_information.hProcess), reinterpret_cast(process_information.hThread), L"", win32::strings::to_wstring(file_name), win32::strings::to_wstring(arguments), win32::strings::to_wstring(working_directory)); - return make_tuple(reinterpret_cast(process_information.hProcess), static_cast(process_information.dwProcessId), make_unique(pipe_stdin[1]), make_unique(pipe_stdout[0]), make_unique(pipe_stderr[0])); + return make_tuple(reinterpret_cast(process_information.hProcess), static_cast(process_information.dwProcessId), make_unique(pipe_stdin[1]), make_unique(pipe_stdout[0]), make_unique(pipe_stderr[0])); } -bool process::wait(intmax_t process, int_least32_t& exit_code) { +bool process::wait(intmax_t process, int32_t& exit_code) { initialize(); if (process == 0) return false; auto it = process_infos.find(process); diff --git a/src/xtd.core.native.win32/src/xtd/native/win32/socket.cpp b/src/xtd.core.native.win32/src/xtd/native/win32/socket.cpp index 771f1c8bf88..51f9a55d6fb 100644 --- a/src/xtd.core.native.win32/src/xtd/native/win32/socket.cpp +++ b/src/xtd.core.native.win32/src/xtd/native/win32/socket.cpp @@ -17,73 +17,73 @@ using namespace std; using namespace xtd::native; namespace { - static int_least32_t protocol_type_to_native(int_least32_t protocol_type) { - static auto protocol_types = map {{PROTOCOL_TYPE_UNKNOWN, IPPROTO_IP}, {PROTOCOL_TYPE_IP, IPPROTO_IP}, {PROTOCOL_TYPE_ICMP, IPPROTO_ICMP}, {PROTOCOL_TYPE_IGMP, IPPROTO_IGMP}, {PROTOCOL_TYPE_GGP, IPPROTO_GGP}, {PROTOCOL_TYPE_IP_V4, IPPROTO_IPV4}, {PROTOCOL_TYPE_IP_V6, IPPROTO_IPV6}, {PROTOCOL_TYPE_TCP, IPPROTO_TCP}, {PROTOCOL_TYPE_PUP, IPPROTO_PUP}, {PROTOCOL_TYPE_UDP, IPPROTO_UDP}, {PROTOCOL_TYPE_IDP, IPPROTO_IDP}, {PROTOCOL_TYPE_IP_V6, IPPROTO_IPV6}, {PROTOCOL_TYPE_IP_V6_ROUTING_HEADER, IPPROTO_ROUTING}, {PROTOCOL_TYPE_IP_V6_FRAGMENT_HEADER, IPPROTO_FRAGMENT}, {PROTOCOL_TYPE_IP_SEC_ENCAPSULATING_SECURITY_PAYLOAD, IPPROTO_ESP}, {PROTOCOL_TYPE_IP_SEC_AUTHENTICATION_HEADER, IPPROTO_AH}, {PROTOCOL_TYPE_ICMP_V6, IPPROTO_ICMPV6}, {PROTOCOL_TYPE_IP_V6_NO_NEXT_HEADER, IPPROTO_NONE}, {PROTOCOL_TYPE_IP_V6_DESTINATION_OPTIONS, IPPROTO_DSTOPTS}, {PROTOCOL_TYPE_ND, IPPROTO_ND}, {PROTOCOL_TYPE_RAW, IPPROTO_RAW}, {PROTOCOL_TYPE_SPX, IPPROTO_IP}, {PROTOCOL_TYPE_SPX_2, IPPROTO_IP}}; + static int32_t protocol_type_to_native(int32_t protocol_type) { + static auto protocol_types = map {{PROTOCOL_TYPE_UNKNOWN, IPPROTO_IP}, {PROTOCOL_TYPE_IP, IPPROTO_IP}, {PROTOCOL_TYPE_ICMP, IPPROTO_ICMP}, {PROTOCOL_TYPE_IGMP, IPPROTO_IGMP}, {PROTOCOL_TYPE_GGP, IPPROTO_GGP}, {PROTOCOL_TYPE_IP_V4, IPPROTO_IPV4}, {PROTOCOL_TYPE_IP_V6, IPPROTO_IPV6}, {PROTOCOL_TYPE_TCP, IPPROTO_TCP}, {PROTOCOL_TYPE_PUP, IPPROTO_PUP}, {PROTOCOL_TYPE_UDP, IPPROTO_UDP}, {PROTOCOL_TYPE_IDP, IPPROTO_IDP}, {PROTOCOL_TYPE_IP_V6, IPPROTO_IPV6}, {PROTOCOL_TYPE_IP_V6_ROUTING_HEADER, IPPROTO_ROUTING}, {PROTOCOL_TYPE_IP_V6_FRAGMENT_HEADER, IPPROTO_FRAGMENT}, {PROTOCOL_TYPE_IP_SEC_ENCAPSULATING_SECURITY_PAYLOAD, IPPROTO_ESP}, {PROTOCOL_TYPE_IP_SEC_AUTHENTICATION_HEADER, IPPROTO_AH}, {PROTOCOL_TYPE_ICMP_V6, IPPROTO_ICMPV6}, {PROTOCOL_TYPE_IP_V6_NO_NEXT_HEADER, IPPROTO_NONE}, {PROTOCOL_TYPE_IP_V6_DESTINATION_OPTIONS, IPPROTO_DSTOPTS}, {PROTOCOL_TYPE_ND, IPPROTO_ND}, {PROTOCOL_TYPE_RAW, IPPROTO_RAW}, {PROTOCOL_TYPE_SPX, IPPROTO_IP}, {PROTOCOL_TYPE_SPX_2, IPPROTO_IP}}; auto it = protocol_types.find(protocol_type); if (it == protocol_types.end()) return IPPROTO_IP; return it->second; } - static int_least32_t socket_option_name_to_native(int_least32_t socket_option_name) { - static auto socket_option_names = map {{SOCKET_OPTION_NAME_DEBUG, SO_DEBUG}, {SOCKET_OPTION_NAME_ACCEPT_CONNECTION, SO_ACCEPTCONN}, {SOCKET_OPTION_NAME_REUSE_ADDRESS, SO_REUSEADDR}, {SOCKET_OPTION_NAME_KEEP_ALIVE, SO_KEEPALIVE}, {SOCKET_OPTION_NAME_DONT_ROUTE, SO_DONTROUTE}, {SOCKET_OPTION_NAME_BROADCAST, SO_BROADCAST}, {SOCKET_OPTION_NAME_USE_LOOPBACK, SO_USELOOPBACK}, {SOCKET_OPTION_NAME_LINGER, SO_LINGER}, {SOCKET_OPTION_NAME_OUT_OF_BAND_INLINE, SO_OOBINLINE}, {SOCKET_OPTION_NAME_SEND_BUFFER, SO_SNDBUF}, {SOCKET_OPTION_NAME_RECEIVE_BUFFER, SO_RCVBUF}, {SOCKET_OPTION_NAME_SEND_LOW_WATER, SO_SNDLOWAT}, {SOCKET_OPTION_NAME_RECEIVE_LOW_WATER, SO_RCVLOWAT}, {SOCKET_OPTION_NAME_SEND_TIMEOUT, SO_SNDTIMEO}, {SOCKET_OPTION_NAME_RECEIVE_TIMEOUT, SO_RCVTIMEO}, {SOCKET_OPTION_NAME_ERROR, SO_ERROR}, {SOCKET_OPTION_NAME_TYPE, SO_TYPE}}; + static int32_t socket_option_name_to_native(int32_t socket_option_name) { + static auto socket_option_names = map {{SOCKET_OPTION_NAME_DEBUG, SO_DEBUG}, {SOCKET_OPTION_NAME_ACCEPT_CONNECTION, SO_ACCEPTCONN}, {SOCKET_OPTION_NAME_REUSE_ADDRESS, SO_REUSEADDR}, {SOCKET_OPTION_NAME_KEEP_ALIVE, SO_KEEPALIVE}, {SOCKET_OPTION_NAME_DONT_ROUTE, SO_DONTROUTE}, {SOCKET_OPTION_NAME_BROADCAST, SO_BROADCAST}, {SOCKET_OPTION_NAME_USE_LOOPBACK, SO_USELOOPBACK}, {SOCKET_OPTION_NAME_LINGER, SO_LINGER}, {SOCKET_OPTION_NAME_OUT_OF_BAND_INLINE, SO_OOBINLINE}, {SOCKET_OPTION_NAME_SEND_BUFFER, SO_SNDBUF}, {SOCKET_OPTION_NAME_RECEIVE_BUFFER, SO_RCVBUF}, {SOCKET_OPTION_NAME_SEND_LOW_WATER, SO_SNDLOWAT}, {SOCKET_OPTION_NAME_RECEIVE_LOW_WATER, SO_RCVLOWAT}, {SOCKET_OPTION_NAME_SEND_TIMEOUT, SO_SNDTIMEO}, {SOCKET_OPTION_NAME_RECEIVE_TIMEOUT, SO_RCVTIMEO}, {SOCKET_OPTION_NAME_ERROR, SO_ERROR}, {SOCKET_OPTION_NAME_TYPE, SO_TYPE}}; auto it = socket_option_names.find(socket_option_name); if (it == socket_option_names.end()) return socket_option_name; return it->second; } - static int_least32_t socket_option_level_to_native(int_least32_t socket_option_level) { - static auto socket_option_levels = map {{SOCKET_OPTION_LEVEL_SOCKET, SOL_SOCKET}, {SOCKET_OPTION_LEVEL_IP, IPPROTO_IP}, {SOCKET_OPTION_LEVEL_IP_V6, IPPROTO_IPV6}, {SOCKET_OPTION_LEVEL_TCP, IPPROTO_TCP}, {SOCKET_OPTION_LEVEL_UDP, IPPROTO_UDP}}; + static int32_t socket_option_level_to_native(int32_t socket_option_level) { + static auto socket_option_levels = map {{SOCKET_OPTION_LEVEL_SOCKET, SOL_SOCKET}, {SOCKET_OPTION_LEVEL_IP, IPPROTO_IP}, {SOCKET_OPTION_LEVEL_IP_V6, IPPROTO_IPV6}, {SOCKET_OPTION_LEVEL_TCP, IPPROTO_TCP}, {SOCKET_OPTION_LEVEL_UDP, IPPROTO_UDP}}; auto it = socket_option_levels.find(socket_option_level); if (it == socket_option_levels.end()) return SOL_SOCKET; return it->second; } - static int_least32_t socket_type_to_native(int_least32_t socket_type) { - static auto socket_types = map {{SOCKET_TYPE_UNKNOWN, SOCK_STREAM}, {SOCKET_TYPE_STREAM, SOCK_STREAM}, {SOCKET_TYPE_DGRAM, SOCK_DGRAM}, {SOCKET_TYPE_RAW, SOCK_RAW}, {SOCKET_TYPE_RDM, SOCK_RDM}, {SOCKET_TYPE_SEQPACKET, SOCK_SEQPACKET}}; + static int32_t socket_type_to_native(int32_t socket_type) { + static auto socket_types = map {{SOCKET_TYPE_UNKNOWN, SOCK_STREAM}, {SOCKET_TYPE_STREAM, SOCK_STREAM}, {SOCKET_TYPE_DGRAM, SOCK_DGRAM}, {SOCKET_TYPE_RAW, SOCK_RAW}, {SOCKET_TYPE_RDM, SOCK_RDM}, {SOCKET_TYPE_SEQPACKET, SOCK_SEQPACKET}}; auto it = socket_types.find(socket_type); if (it == socket_types.end()) return SOCK_STREAM; return it->second; } } -int_least32_t socket::address_family_to_native(int_least32_t address_family) { - static auto address_families = map {{ADDRESS_FAMILY_UNIX, AF_UNIX}, {ADDRESS_FAMILY_INTER_NETWORK, AF_INET}, {ADDRESS_FAMILY_IMP_LINK, AF_IMPLINK}, {ADDRESS_FAMILY_PUP, AF_PUP}, {ADDRESS_FAMILY_CHAOS, AF_CHAOS}, {ADDRESS_FAMILY_NS, AF_NS}, {ADDRESS_FAMILY_ISO, AF_ISO}, {ADDRESS_FAMILY_ECMA, AF_ECMA}, {ADDRESS_FAMILY_DATA_KIT, AF_DATAKIT}, {ADDRESS_FAMILY_CCITT, AF_CCITT}, {ADDRESS_FAMILY_SNA, AF_SNA}, {ADDRESS_FAMILY_DEC_NET, AF_DECnet}, {ADDRESS_FAMILY_DATA_LINK, AF_DLI}, {ADDRESS_FAMILY_LAT, AF_LAT}, {ADDRESS_FAMILY_HYPER_CHANNEL, AF_HYLINK}, {ADDRESS_FAMILY_APPLE_TALK, AF_APPLETALK}, {ADDRESS_FAMILY_NET_BIOS, AF_NETBIOS}, {ADDRESS_FAMILY_VOICE_VIEW, AF_VOICEVIEW}, {ADDRESS_FAMILY_FIRE_FOX, AF_FIREFOX}, {ADDRESS_FAMILY_BANYAN, AF_BAN}, {ADDRESS_FAMILY_ATM, AF_ATM}, {ADDRESS_FAMILY_INTER_NETWORK_V6, AF_INET6}, {ADDRESS_FAMILY_CLUSTER, AF_CLUSTER}, {ADDRESS_FAMILY_IEEE12844, AF_12844}, {ADDRESS_FAMILY_IRDA, AF_IRDA}, {ADDRESS_FAMILY_NETWORK_DESIGNERS, AF_NETDES}, {ADDRESS_FAMILY_MAX, AF_MAX}}; +int32_t socket::address_family_to_native(int32_t address_family) { + static auto address_families = map {{ADDRESS_FAMILY_UNIX, AF_UNIX}, {ADDRESS_FAMILY_INTER_NETWORK, AF_INET}, {ADDRESS_FAMILY_IMP_LINK, AF_IMPLINK}, {ADDRESS_FAMILY_PUP, AF_PUP}, {ADDRESS_FAMILY_CHAOS, AF_CHAOS}, {ADDRESS_FAMILY_NS, AF_NS}, {ADDRESS_FAMILY_ISO, AF_ISO}, {ADDRESS_FAMILY_ECMA, AF_ECMA}, {ADDRESS_FAMILY_DATA_KIT, AF_DATAKIT}, {ADDRESS_FAMILY_CCITT, AF_CCITT}, {ADDRESS_FAMILY_SNA, AF_SNA}, {ADDRESS_FAMILY_DEC_NET, AF_DECnet}, {ADDRESS_FAMILY_DATA_LINK, AF_DLI}, {ADDRESS_FAMILY_LAT, AF_LAT}, {ADDRESS_FAMILY_HYPER_CHANNEL, AF_HYLINK}, {ADDRESS_FAMILY_APPLE_TALK, AF_APPLETALK}, {ADDRESS_FAMILY_NET_BIOS, AF_NETBIOS}, {ADDRESS_FAMILY_VOICE_VIEW, AF_VOICEVIEW}, {ADDRESS_FAMILY_FIRE_FOX, AF_FIREFOX}, {ADDRESS_FAMILY_BANYAN, AF_BAN}, {ADDRESS_FAMILY_ATM, AF_ATM}, {ADDRESS_FAMILY_INTER_NETWORK_V6, AF_INET6}, {ADDRESS_FAMILY_CLUSTER, AF_CLUSTER}, {ADDRESS_FAMILY_IEEE12844, AF_12844}, {ADDRESS_FAMILY_IRDA, AF_IRDA}, {ADDRESS_FAMILY_NETWORK_DESIGNERS, AF_NETDES}, {ADDRESS_FAMILY_MAX, AF_MAX}}; auto it = address_families.find(address_family); if (it == address_families.end()) return AF_UNSPEC; return it->second; } -int_least32_t socket::native_to_address_family(int_least32_t address_family) { - static auto address_families = map {{AF_UNIX, ADDRESS_FAMILY_UNIX}, {AF_INET, ADDRESS_FAMILY_INTER_NETWORK}, {AF_IMPLINK, ADDRESS_FAMILY_IMP_LINK}, {AF_PUP, ADDRESS_FAMILY_PUP}, {AF_CHAOS, ADDRESS_FAMILY_CHAOS}, {AF_NS, ADDRESS_FAMILY_NS}, {AF_ISO, ADDRESS_FAMILY_ISO}, {AF_ECMA, ADDRESS_FAMILY_ECMA}, {AF_DATAKIT, ADDRESS_FAMILY_DATA_KIT}, {AF_CCITT, ADDRESS_FAMILY_CCITT}, {AF_SNA, ADDRESS_FAMILY_SNA}, {AF_DECnet, ADDRESS_FAMILY_DEC_NET}, {AF_DLI, ADDRESS_FAMILY_DATA_LINK}, {AF_LAT, ADDRESS_FAMILY_LAT}, {AF_HYLINK, ADDRESS_FAMILY_HYPER_CHANNEL}, {AF_APPLETALK, ADDRESS_FAMILY_APPLE_TALK}, {AF_NETBIOS, ADDRESS_FAMILY_NET_BIOS}, {AF_VOICEVIEW, ADDRESS_FAMILY_VOICE_VIEW}, {AF_FIREFOX, ADDRESS_FAMILY_FIRE_FOX}, {AF_BAN, ADDRESS_FAMILY_BANYAN}, {AF_ATM, ADDRESS_FAMILY_ATM}, {AF_INET6, ADDRESS_FAMILY_INTER_NETWORK_V6}, {AF_CLUSTER, ADDRESS_FAMILY_CLUSTER}, {AF_12844, ADDRESS_FAMILY_IEEE12844}, {AF_IRDA, ADDRESS_FAMILY_IRDA}, {AF_NETDES, ADDRESS_FAMILY_NETWORK_DESIGNERS}, {AF_MAX, ADDRESS_FAMILY_MAX}}; +int32_t socket::native_to_address_family(int32_t address_family) { + static auto address_families = map {{AF_UNIX, ADDRESS_FAMILY_UNIX}, {AF_INET, ADDRESS_FAMILY_INTER_NETWORK}, {AF_IMPLINK, ADDRESS_FAMILY_IMP_LINK}, {AF_PUP, ADDRESS_FAMILY_PUP}, {AF_CHAOS, ADDRESS_FAMILY_CHAOS}, {AF_NS, ADDRESS_FAMILY_NS}, {AF_ISO, ADDRESS_FAMILY_ISO}, {AF_ECMA, ADDRESS_FAMILY_ECMA}, {AF_DATAKIT, ADDRESS_FAMILY_DATA_KIT}, {AF_CCITT, ADDRESS_FAMILY_CCITT}, {AF_SNA, ADDRESS_FAMILY_SNA}, {AF_DECnet, ADDRESS_FAMILY_DEC_NET}, {AF_DLI, ADDRESS_FAMILY_DATA_LINK}, {AF_LAT, ADDRESS_FAMILY_LAT}, {AF_HYLINK, ADDRESS_FAMILY_HYPER_CHANNEL}, {AF_APPLETALK, ADDRESS_FAMILY_APPLE_TALK}, {AF_NETBIOS, ADDRESS_FAMILY_NET_BIOS}, {AF_VOICEVIEW, ADDRESS_FAMILY_VOICE_VIEW}, {AF_FIREFOX, ADDRESS_FAMILY_FIRE_FOX}, {AF_BAN, ADDRESS_FAMILY_BANYAN}, {AF_ATM, ADDRESS_FAMILY_ATM}, {AF_INET6, ADDRESS_FAMILY_INTER_NETWORK_V6}, {AF_CLUSTER, ADDRESS_FAMILY_CLUSTER}, {AF_12844, ADDRESS_FAMILY_IEEE12844}, {AF_IRDA, ADDRESS_FAMILY_IRDA}, {AF_NETDES, ADDRESS_FAMILY_NETWORK_DESIGNERS}, {AF_MAX, ADDRESS_FAMILY_MAX}}; auto it = address_families.find(address_family); if (it == address_families.end()) return ADDRESS_FAMILY_UNSPECIFIED; return it->second; } -intmax_t socket::accept(intmax_t handle, vector& socket_address) { - auto address_length = static_cast(socket_address.size()); +intmax_t socket::accept(intmax_t handle, vector& socket_address) { + auto address_length = static_cast(socket_address.size()); auto socket = static_cast(::accept(static_cast(handle), reinterpret_cast(socket_address.data()), &address_length)); if (socket_address.size() != static_cast(address_length)) socket_address.resize(static_cast(address_length)); return socket; } -int_least32_t socket::bind(intmax_t handle, const vector& socket_address) { - return ::bind(static_cast(handle), reinterpret_cast(socket_address.data()), static_cast(socket_address.size())); +int32_t socket::bind(intmax_t handle, const vector& socket_address) { + return ::bind(static_cast(handle), reinterpret_cast(socket_address.data()), static_cast(socket_address.size())); } void socket::cleanup() { WSACleanup(); } -int_least32_t socket::connect(intmax_t handle, const vector& socket_address) { - return ::connect(static_cast(handle), reinterpret_cast(socket_address.data()), static_cast(socket_address.size())); +int32_t socket::connect(intmax_t handle, const vector& socket_address) { + return ::connect(static_cast(handle), reinterpret_cast(socket_address.data()), static_cast(socket_address.size())); } -intmax_t socket::create(int_least32_t address_family, int_least32_t socket_type, int_least32_t protocol_type) { +intmax_t socket::create(int32_t address_family, int32_t socket_type, int32_t protocol_type) { return static_cast(::socket(address_family_to_native(address_family), socket_type_to_native(socket_type), protocol_type_to_native(protocol_type))); } -int_least32_t socket::destroy(intmax_t handle) { +int32_t socket::destroy(intmax_t handle) { return ::closesocket(static_cast(handle)); } @@ -93,7 +93,7 @@ size_t socket::get_available(intmax_t handle) { return static_cast(nbr_bytes_available); } -int_least32_t socket::get_last_error() { +int32_t socket::get_last_error() { return WSAGetLastError(); } @@ -111,32 +111,32 @@ bool socket::get_os_supports_ip_v6() noexcept { return true; } -int_least32_t socket::get_raw_socket_option(intmax_t handle, int_least32_t socket_option_level, int_least32_t socket_option_name, intmax_t option, size_t& option_length) { - return ::getsockopt(static_cast(handle), socket_option_level, socket_option_name, reinterpret_cast(option), reinterpret_cast(&option_length)); +int32_t socket::get_raw_socket_option(intmax_t handle, int32_t socket_option_level, int32_t socket_option_name, intmax_t option, size_t& option_length) { + return ::getsockopt(static_cast(handle), socket_option_level, socket_option_name, reinterpret_cast(option), reinterpret_cast(&option_length)); } -int_least32_t socket::get_socket_option(intmax_t handle, int_least32_t socket_option_level, int_least32_t socket_option_name, intmax_t option, size_t& option_length) { - return ::getsockopt(static_cast(handle), socket_option_level_to_native(socket_option_level), socket_option_name_to_native(socket_option_name), reinterpret_cast(option), reinterpret_cast(&option_length)); +int32_t socket::get_socket_option(intmax_t handle, int32_t socket_option_level, int32_t socket_option_name, intmax_t option, size_t& option_length) { + return ::getsockopt(static_cast(handle), socket_option_level_to_native(socket_option_level), socket_option_name_to_native(socket_option_name), reinterpret_cast(option), reinterpret_cast(&option_length)); } -int_least32_t socket::get_socket_linger_option(intmax_t handle, bool& enabled, uint_least32_t& linger_time) { +int32_t socket::get_socket_linger_option(intmax_t handle, bool& enabled, uint32_t& linger_time) { auto l = LINGER {static_cast(enabled), static_cast(linger_time)}; auto linger_size = sizeof(LINGER); - auto result = ::getsockopt(static_cast(handle), SOL_SOCKET, SO_LINGER, reinterpret_cast(&l), reinterpret_cast(&linger_size)); + auto result = ::getsockopt(static_cast(handle), SOL_SOCKET, SO_LINGER, reinterpret_cast(&l), reinterpret_cast(&linger_size)); if (result == 0) { enabled = static_cast(l.l_onoff); - linger_time = static_cast(l.l_linger); + linger_time = static_cast(l.l_linger); } return result; } -int_least32_t socket::get_socket_multicast_option(intmax_t handle, int_least32_t socket_option_name, uint_least32_t& multicast_address, uint_least32_t& interface_index) { +int32_t socket::get_socket_multicast_option(intmax_t handle, int32_t socket_option_name, uint32_t& multicast_address, uint32_t& interface_index) { struct multicast { - uint_least32_t multicast_address; - uint_least32_t interface_index; + uint32_t multicast_address; + uint32_t interface_index; } m; auto multicast_size = sizeof(multicast); - auto result = getsockopt(static_cast(handle), IPPROTO_IP, socket_option_name_to_native(socket_option_name), reinterpret_cast(&m), reinterpret_cast(&multicast_size)); + auto result = getsockopt(static_cast(handle), IPPROTO_IP, socket_option_name_to_native(socket_option_name), reinterpret_cast(&m), reinterpret_cast(&multicast_size)); if (result == 0) { multicast_address = m.multicast_address; interface_index = m.interface_index; @@ -144,13 +144,13 @@ int_least32_t socket::get_socket_multicast_option(intmax_t handle, int_least32_t return result; } -int_least32_t socket::get_socket_ip_v6_multicast_option(intmax_t handle, int_least32_t socket_option_name, vector& multicast_address, uint_least32_t& interface_index) { +int32_t socket::get_socket_ip_v6_multicast_option(intmax_t handle, int32_t socket_option_name, vector& multicast_address, uint32_t& interface_index) { struct multicast { - uint_least8_t multicast_address[16]; - uint_least32_t interface_index; + uint8_t multicast_address[16]; + uint32_t interface_index; } m; auto multicast_size = sizeof(multicast); - auto result = getsockopt(static_cast(handle), IPPROTO_IP, socket_option_name_to_native(socket_option_name), reinterpret_cast(&m), reinterpret_cast(&multicast_size)); + auto result = getsockopt(static_cast(handle), IPPROTO_IP, socket_option_name_to_native(socket_option_name), reinterpret_cast(&m), reinterpret_cast(&multicast_size)); if (result == 0) { for (auto index = 0U; index < multicast_address.size(); ++index) multicast_address[index] = m.multicast_address[index]; @@ -159,19 +159,19 @@ int_least32_t socket::get_socket_ip_v6_multicast_option(intmax_t handle, int_lea return result; } -int_least32_t socket::io_control(intmax_t handle, int_least32_t io_control, vector& option_in_value, vector& option_out_value) { +int32_t socket::io_control(intmax_t handle, int32_t io_control, vector& option_in_value, vector& option_out_value) { auto option_out_value_size = size_t {}; - auto result = WSAIoctl(static_cast(handle), io_control, option_in_value.data(), static_cast(option_in_value.size()), option_out_value.data(), static_cast(option_out_value.size()), reinterpret_cast(&option_out_value_size), nullptr, nullptr); + auto result = WSAIoctl(static_cast(handle), io_control, option_in_value.data(), static_cast(option_in_value.size()), option_out_value.data(), static_cast(option_out_value.size()), reinterpret_cast(&option_out_value_size), nullptr, nullptr); if (option_out_value.size() != option_out_value_size) option_out_value.resize(option_out_value_size); return result; } -int_least32_t socket::listen(intmax_t handle, size_t backlog) { - auto backlog_value = backlog != static_cast(-1) ? static_cast(backlog) : SOMAXCONN; +int32_t socket::listen(intmax_t handle, size_t backlog) { + auto backlog_value = backlog != static_cast(-1) ? static_cast(backlog) : SOMAXCONN; return ::listen(static_cast(handle), backlog_value); } -int_least32_t socket::poll(intmax_t handle, int_least32_t microseconds, int_least32_t mode) { +int32_t socket::poll(intmax_t handle, int32_t microseconds, int32_t mode) { if (handle == 0 || microseconds < 0) return -1; auto timeout = timeval {microseconds / 1000000, microseconds % 1000000}; @@ -186,18 +186,18 @@ int_least32_t socket::poll(intmax_t handle, int_least32_t microseconds, int_leas } } -int_least32_t socket::receive(intmax_t handle, vector& buffer, size_t offset, size_t size, int_least32_t flags) { - return static_cast(::recv(static_cast(handle), reinterpret_cast(&buffer.data()[offset]), static_cast(size), flags)); +int32_t socket::receive(intmax_t handle, vector& buffer, size_t offset, size_t size, int32_t flags) { + return static_cast(::recv(static_cast(handle), reinterpret_cast(&buffer.data()[offset]), static_cast(size), flags)); } -int_least32_t socket::receive_from(intmax_t handle, vector& buffer, size_t offset, size_t size, int_least32_t flags, vector& socket_address) { - auto address_length = static_cast(socket_address.size()); - auto result = static_cast(::recvfrom(static_cast(handle), reinterpret_cast(&buffer.data()[offset]), static_cast(size), flags, reinterpret_cast(socket_address.data()), &address_length)); +int32_t socket::receive_from(intmax_t handle, vector& buffer, size_t offset, size_t size, int32_t flags, vector& socket_address) { + auto address_length = static_cast(socket_address.size()); + auto result = static_cast(::recvfrom(static_cast(handle), reinterpret_cast(&buffer.data()[offset]), static_cast(size), flags, reinterpret_cast(socket_address.data()), &address_length)); if (socket_address.size() != static_cast(address_length)) socket_address.resize(static_cast(address_length)); return result; } -int_least32_t socket::select(vector& check_read, vector& check_write, vector& check_error, int_least32_t microseconds) { +int32_t socket::select(vector& check_read, vector& check_write, vector& check_error, int32_t microseconds) { auto nfds = size_t {}; auto read_fds = fd_set {}; @@ -223,7 +223,7 @@ int_least32_t socket::select(vector& check_read, vector& che tv.tv_sec = microseconds / 1000000; tv.tv_usec = microseconds % 1000000; } - auto result = ::select(static_cast(nfds + 1), &read_fds, &write_fds, &error_fds, &tv); + auto result = ::select(static_cast(nfds + 1), &read_fds, &write_fds, &error_fds, &tv); for (auto i = 0U; i < check_read.size(); i++) { FD_CLR(static_cast(check_read[i]), &read_fds); @@ -243,52 +243,52 @@ int_least32_t socket::select(vector& check_read, vector& che return result; } -int_least32_t socket::send(intmax_t handle, const vector& buffer, size_t offset, size_t size, int_least32_t flags) { - return static_cast(::send(static_cast(handle), reinterpret_cast(&buffer.data()[offset]), static_cast(size), flags)); +int32_t socket::send(intmax_t handle, const vector& buffer, size_t offset, size_t size, int32_t flags) { + return static_cast(::send(static_cast(handle), reinterpret_cast(&buffer.data()[offset]), static_cast(size), flags)); } -int_least32_t socket::send_to(intmax_t handle, const vector& buffer, size_t offset, size_t size, int_least32_t flags, const vector& socket_address) { - return static_cast(::sendto(static_cast(handle), reinterpret_cast(&buffer.data()[offset]), static_cast(size), flags, reinterpret_cast(socket_address.data()), static_cast(socket_address.size()))); +int32_t socket::send_to(intmax_t handle, const vector& buffer, size_t offset, size_t size, int32_t flags, const vector& socket_address) { + return static_cast(::sendto(static_cast(handle), reinterpret_cast(&buffer.data()[offset]), static_cast(size), flags, reinterpret_cast(socket_address.data()), static_cast(socket_address.size()))); } -int_least32_t socket::set_blocking(intmax_t handle, bool blocking) { +int32_t socket::set_blocking(intmax_t handle, bool blocking) { auto mode = u_long {blocking ? 0ul : 1ul}; return ioctlsocket(static_cast(handle), FIONBIO, &mode); } -int_least32_t socket::set_raw_socket_option(intmax_t handle, int_least32_t socket_option_level, int_least32_t socket_option_name, intmax_t option, size_t option_length) { - return setsockopt(static_cast(handle), socket_option_level, socket_option_name, reinterpret_cast(option), static_cast(option_length)); +int32_t socket::set_raw_socket_option(intmax_t handle, int32_t socket_option_level, int32_t socket_option_name, intmax_t option, size_t option_length) { + return setsockopt(static_cast(handle), socket_option_level, socket_option_name, reinterpret_cast(option), static_cast(option_length)); } -int_least32_t socket::set_socket_option(intmax_t handle, int_least32_t socket_option_level, int_least32_t socket_option_name, intmax_t option, size_t option_length) { - return setsockopt(static_cast(handle), socket_option_level_to_native(socket_option_level), socket_option_name_to_native(socket_option_name), reinterpret_cast(option), static_cast(option_length)); +int32_t socket::set_socket_option(intmax_t handle, int32_t socket_option_level, int32_t socket_option_name, intmax_t option, size_t option_length) { + return setsockopt(static_cast(handle), socket_option_level_to_native(socket_option_level), socket_option_name_to_native(socket_option_name), reinterpret_cast(option), static_cast(option_length)); } -int_least32_t socket::set_socket_linger_option(intmax_t handle, bool enabled, uint_least32_t linger_time) { +int32_t socket::set_socket_linger_option(intmax_t handle, bool enabled, uint32_t linger_time) { LINGER l {static_cast(enabled), static_cast(linger_time)}; - return setsockopt(static_cast(handle), SOL_SOCKET, SO_LINGER, reinterpret_cast(&l), static_cast(sizeof(LINGER))); + return setsockopt(static_cast(handle), SOL_SOCKET, SO_LINGER, reinterpret_cast(&l), static_cast(sizeof(LINGER))); } -int_least32_t socket::set_socket_multicast_option(intmax_t handle, int_least32_t socket_option_name, uint_least32_t multicast_address, uint_least32_t interface_index) { +int32_t socket::set_socket_multicast_option(intmax_t handle, int32_t socket_option_name, uint32_t multicast_address, uint32_t interface_index) { struct multicast { - uint_least32_t multicast_address; - uint_least32_t interface_index; + uint32_t multicast_address; + uint32_t interface_index; } m {multicast_address, interface_index}; - return setsockopt(static_cast(handle), IPPROTO_TCP, socket_option_name_to_native(socket_option_name), reinterpret_cast(&m), static_cast(sizeof(multicast))); + return setsockopt(static_cast(handle), IPPROTO_TCP, socket_option_name_to_native(socket_option_name), reinterpret_cast(&m), static_cast(sizeof(multicast))); } -int_least32_t socket::set_socket_ip_v6_multicast_option(intmax_t handle, int_least32_t socket_option_name, const vector& multicast_address, uint_least32_t interface_index) { +int32_t socket::set_socket_ip_v6_multicast_option(intmax_t handle, int32_t socket_option_name, const vector& multicast_address, uint32_t interface_index) { struct multicast { - uint_least8_t multicast_address[16]; - uint_least32_t interface_index; + uint8_t multicast_address[16]; + uint32_t interface_index; } m; for (auto index = 0U; index < multicast_address.size(); ++index) m.multicast_address[index] = multicast_address[index]; m.interface_index = interface_index; - return setsockopt(static_cast(handle), IPPROTO_TCP, socket_option_name_to_native(socket_option_name), reinterpret_cast(&m), static_cast(sizeof(multicast))); + return setsockopt(static_cast(handle), IPPROTO_TCP, socket_option_name_to_native(socket_option_name), reinterpret_cast(&m), static_cast(sizeof(multicast))); } -int_least32_t socket::shutdown(intmax_t handle, int_least32_t how) { +int32_t socket::shutdown(intmax_t handle, int32_t how) { return ::shutdown(static_cast(handle), how); } diff --git a/src/xtd.core.native.win32/src/xtd/native/win32/speech_synthesizer.cpp b/src/xtd.core.native.win32/src/xtd/native/win32/speech_synthesizer.cpp index b8dfe3a3803..85fdbc8ec25 100644 --- a/src/xtd.core.native.win32/src/xtd/native/win32/speech_synthesizer.cpp +++ b/src/xtd.core.native.win32/src/xtd/native/win32/speech_synthesizer.cpp @@ -68,7 +68,7 @@ void speech_synthesizer::speak(intmax_t handle, const string& text_to_speak) { void speech_synthesizer::speak_async(intmax_t handle, const string& text_to_speak, std::function on_speak_completed) { reinterpret_cast(handle)->process_handle = native::process::shell_execute("", reinterpret_cast(handle)->say_cmd_file_name, text_to_speak, "", PROCESS_WINDOW_STYLE_HIDDEN); auto wait_process_thread = thread{[on_speak_completed, handle] { - int_least32_t exit_code = 0; + int32_t exit_code = 0; native::process::wait(reinterpret_cast(handle)->process_handle, exit_code); on_speak_completed(); }}; diff --git a/src/xtd.core.native.win32/src/xtd/native/win32/system_sound.cpp b/src/xtd.core.native.win32/src/xtd/native/win32/system_sound.cpp index c17033a71eb..10bbed286f3 100644 --- a/src/xtd.core.native.win32/src/xtd/native/win32/system_sound.cpp +++ b/src/xtd.core.native.win32/src/xtd/native/win32/system_sound.cpp @@ -9,6 +9,6 @@ using namespace xtd::native; #undef max #undef min -void system_sound::play(uint_least32_t sound) { +void system_sound::play(uint32_t sound) { MessageBeep(sound); } diff --git a/src/xtd.core.native.win32/src/xtd/native/win32/thread.cpp b/src/xtd.core.native.win32/src/xtd/native/win32/thread.cpp index f57ab8137ec..16ac3be9a70 100644 --- a/src/xtd.core.native.win32/src/xtd/native/win32/thread.cpp +++ b/src/xtd.core.native.win32/src/xtd/native/win32/thread.cpp @@ -13,7 +13,7 @@ bool thread::cancel(intmax_t handle) { return TerminateThread(reinterpret_cast(handle), static_cast(- 1)) != FALSE; } -intmax_t thread::create(std::function start, intmax_t obj, int_least32_t max_stack_size, bool suspended, intmax_t& id) { +intmax_t thread::create(std::function start, intmax_t obj, int32_t max_stack_size, bool suspended, intmax_t& id) { auto sa = SECURITY_ATTRIBUTES {}; sa.bInheritHandle = TRUE; sa.lpSecurityDescriptor = nullptr; @@ -22,7 +22,7 @@ intmax_t thread::create(std::function start, intmax_t obj, int_l if (suspended) flags |= CREATE_SUSPENDED; auto thread_id = DWORD {}; auto thread = CreateThread(nullptr, max_stack_size, [](void* thread_arg)->DWORD { - auto start_obj = reinterpret_cast, intmax_t>*>(thread_arg); + auto start_obj = reinterpret_cast, intmax_t>*>(thread_arg); start_obj->first(start_obj->second); delete start_obj; return 0; @@ -60,12 +60,12 @@ bool thread::set_current_thread_name(const std::string& name) { return SUCCEEDED(SetThreadDescription(GetCurrentThread(), win32::strings::to_wstring(name).data())); } -bool thread::set_priority(intmax_t handle, int_least32_t priority) { +bool thread::set_priority(intmax_t handle, int32_t priority) { if (reinterpret_cast(handle) == INVALID_HANDLE_VALUE) return false; return SetThreadPriority((HANDLE)handle, priority - 2) != FALSE; } -void thread::sleep(int_least32_t milliseconds_timeout) { +void thread::sleep(int32_t milliseconds_timeout) { Sleep(milliseconds_timeout); } diff --git a/src/xtd.core.native.win32/src/xtd/native/win32/unnamed_event_wait_handle.cpp b/src/xtd.core.native.win32/src/xtd/native/win32/unnamed_event_wait_handle.cpp index 3abca6a917f..38f397aa1d3 100644 --- a/src/xtd.core.native.win32/src/xtd/native/win32/unnamed_event_wait_handle.cpp +++ b/src/xtd.core.native.win32/src/xtd/native/win32/unnamed_event_wait_handle.cpp @@ -36,7 +36,7 @@ bool unnamed_event_wait_handle::reset(intmax_t handle, bool& io_error) { return !io_error; } -uint_least32_t unnamed_event_wait_handle::wait(intmax_t handle, int_least32_t milliseconds_timeout, bool manual_reset) { +uint32_t unnamed_event_wait_handle::wait(intmax_t handle, int32_t milliseconds_timeout, bool manual_reset) { if (reinterpret_cast(handle) == INVALID_HANDLE_VALUE) return WAIT_FAILED; - return static_cast(WaitForSingleObject(reinterpret_cast(handle), milliseconds_timeout == -1 ? INFINITE : milliseconds_timeout)); + return static_cast(WaitForSingleObject(reinterpret_cast(handle), milliseconds_timeout == -1 ? INFINITE : milliseconds_timeout)); } diff --git a/src/xtd.core.native.win32/src/xtd/native/win32/unnamed_mutex.cpp b/src/xtd.core.native.win32/src/xtd/native/win32/unnamed_mutex.cpp index 4235abb1039..5f7c567a4f9 100644 --- a/src/xtd.core.native.win32/src/xtd/native/win32/unnamed_mutex.cpp +++ b/src/xtd.core.native.win32/src/xtd/native/win32/unnamed_mutex.cpp @@ -27,7 +27,7 @@ bool unnamed_mutex::signal(intmax_t handle, bool& io_error) { return !io_error; } -uint_least32_t unnamed_mutex::wait(intmax_t handle, int_least32_t milliseconds_timeout) { +uint32_t unnamed_mutex::wait(intmax_t handle, int32_t milliseconds_timeout) { if (reinterpret_cast(handle) == INVALID_HANDLE_VALUE) return WAIT_FAILED; - return static_cast(WaitForSingleObject(reinterpret_cast(handle), milliseconds_timeout == -1 ? INFINITE : milliseconds_timeout)); + return static_cast(WaitForSingleObject(reinterpret_cast(handle), milliseconds_timeout == -1 ? INFINITE : milliseconds_timeout)); } diff --git a/src/xtd.core.native.win32/src/xtd/native/win32/unnamed_semaphore.cpp b/src/xtd.core.native.win32/src/xtd/native/win32/unnamed_semaphore.cpp index 302ffa8fe09..c564ef12ce6 100644 --- a/src/xtd.core.native.win32/src/xtd/native/win32/unnamed_semaphore.cpp +++ b/src/xtd.core.native.win32/src/xtd/native/win32/unnamed_semaphore.cpp @@ -8,7 +8,7 @@ using namespace xtd::native; -intmax_t unnamed_semaphore::create(int_least32_t initial_count, int_least32_t max_count) { +intmax_t unnamed_semaphore::create(int32_t initial_count, int32_t max_count) { auto handle = CreateSemaphore(nullptr, initial_count, max_count, nullptr); return reinterpret_cast(handle); } @@ -18,7 +18,7 @@ void unnamed_semaphore::destroy(intmax_t handle) { CloseHandle(reinterpret_cast(handle)); } -bool unnamed_semaphore::signal(intmax_t handle, int_least32_t release_count, int_least32_t& previous_count, bool& io_error) { +bool unnamed_semaphore::signal(intmax_t handle, int32_t release_count, int32_t& previous_count, bool& io_error) { if (reinterpret_cast(handle) == INVALID_HANDLE_VALUE) { io_error = true; return false; @@ -29,7 +29,7 @@ bool unnamed_semaphore::signal(intmax_t handle, int_least32_t release_count, int } -uint_least32_t unnamed_semaphore::wait(intmax_t handle, int_least32_t milliseconds_timeout) { +uint32_t unnamed_semaphore::wait(intmax_t handle, int32_t milliseconds_timeout) { if (reinterpret_cast(handle) == INVALID_HANDLE_VALUE) return WAIT_FAILED; - return static_cast(WaitForSingleObject(reinterpret_cast(handle), milliseconds_timeout == -1 ? INFINITE : milliseconds_timeout)); + return static_cast(WaitForSingleObject(reinterpret_cast(handle), milliseconds_timeout == -1 ? INFINITE : milliseconds_timeout)); } diff --git a/src/xtd.core.native/include/xtd/native/address_family_constants.h b/src/xtd.core.native/include/xtd/native/address_family_constants.h index 11d72e03701..e8195dadac3 100644 --- a/src/xtd.core.native/include/xtd/native/address_family_constants.h +++ b/src/xtd.core.native/include/xtd/native/address_family_constants.h @@ -17,7 +17,7 @@ /// @ingroup xtd_core_native address_family /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t ADDRESS_FAMILY_UNKNOWN = -1; +constexpr int32_t ADDRESS_FAMILY_UNKNOWN = -1; /// @brief Unspecified address family. /// @par Library @@ -25,7 +25,7 @@ constexpr int_least32_t ADDRESS_FAMILY_UNKNOWN = -1; /// @ingroup xtd_core_native address_family /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t ADDRESS_FAMILY_UNSPECIFIED = 0; +constexpr int32_t ADDRESS_FAMILY_UNSPECIFIED = 0; /// @brief Unix local to host address. /// @par Library @@ -33,7 +33,7 @@ constexpr int_least32_t ADDRESS_FAMILY_UNSPECIFIED = 0; /// @ingroup xtd_core_native address_family /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t ADDRESS_FAMILY_UNIX = 1; +constexpr int32_t ADDRESS_FAMILY_UNIX = 1; /// @brief Address for IP version 4. /// @par Library @@ -41,7 +41,7 @@ constexpr int_least32_t ADDRESS_FAMILY_UNIX = 1; /// @ingroup xtd_core_native address_family /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t ADDRESS_FAMILY_INTER_NETWORK = 2; +constexpr int32_t ADDRESS_FAMILY_INTER_NETWORK = 2; /// @brief ARPANET IMP address. /// @par Library @@ -49,7 +49,7 @@ constexpr int_least32_t ADDRESS_FAMILY_INTER_NETWORK = 2; /// @ingroup xtd_core_native address_family /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t ADDRESS_FAMILY_IMP_LINK = 3; +constexpr int32_t ADDRESS_FAMILY_IMP_LINK = 3; /// @brief Address for PUP protocols. /// @par Library @@ -57,7 +57,7 @@ constexpr int_least32_t ADDRESS_FAMILY_IMP_LINK = 3; /// @ingroup xtd_core_native address_family /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t ADDRESS_FAMILY_PUP = 4; +constexpr int32_t ADDRESS_FAMILY_PUP = 4; /// @brief Address for MIT CHAOS protocols. /// @par Library @@ -65,7 +65,7 @@ constexpr int_least32_t ADDRESS_FAMILY_PUP = 4; /// @ingroup xtd_core_native address_family /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t ADDRESS_FAMILY_CHAOS = 5; +constexpr int32_t ADDRESS_FAMILY_CHAOS = 5; /// @brief Address for Xerox NS protocols. /// @par Library @@ -73,7 +73,7 @@ constexpr int_least32_t ADDRESS_FAMILY_CHAOS = 5; /// @ingroup xtd_core_native address_family /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t ADDRESS_FAMILY_NS = 6; +constexpr int32_t ADDRESS_FAMILY_NS = 6; /// @brief Address for ISO protocols. /// @par Library @@ -81,7 +81,7 @@ constexpr int_least32_t ADDRESS_FAMILY_NS = 6; /// @ingroup xtd_core_native address_family /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t ADDRESS_FAMILY_ISO = 7; +constexpr int32_t ADDRESS_FAMILY_ISO = 7; /// @brief Address for OSI protocols. /// @par Library @@ -89,7 +89,7 @@ constexpr int_least32_t ADDRESS_FAMILY_ISO = 7; /// @ingroup xtd_core_native address_family /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t ADDRESS_FAMILY_OSI = 7; +constexpr int32_t ADDRESS_FAMILY_OSI = 7; /// @brief European Computer Manufacturers Association (ECMA) address. /// @par Library @@ -97,7 +97,7 @@ constexpr int_least32_t ADDRESS_FAMILY_OSI = 7; /// @ingroup xtd_core_native address_family /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t ADDRESS_FAMILY_ECMA = 8; +constexpr int32_t ADDRESS_FAMILY_ECMA = 8; /// @brief Address for Datakit protocols. /// @par Library @@ -105,7 +105,7 @@ constexpr int_least32_t ADDRESS_FAMILY_ECMA = 8; /// @ingroup xtd_core_native address_family /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t ADDRESS_FAMILY_DATA_KIT = 9; +constexpr int32_t ADDRESS_FAMILY_DATA_KIT = 9; /// @brief Addresses for CCITT protocols, such as X.25. /// @par Library @@ -113,7 +113,7 @@ constexpr int_least32_t ADDRESS_FAMILY_DATA_KIT = 9; /// @ingroup xtd_core_native address_family /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t ADDRESS_FAMILY_CCITT = 10; +constexpr int32_t ADDRESS_FAMILY_CCITT = 10; /// @brief IBM SNA address. /// @par Library @@ -121,7 +121,7 @@ constexpr int_least32_t ADDRESS_FAMILY_CCITT = 10; /// @ingroup xtd_core_native address_family /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t ADDRESS_FAMILY_SNA = 11; +constexpr int32_t ADDRESS_FAMILY_SNA = 11; /// @brief DECnet address. /// @par Library @@ -129,7 +129,7 @@ constexpr int_least32_t ADDRESS_FAMILY_SNA = 11; /// @ingroup xtd_core_native address_family /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t ADDRESS_FAMILY_DEC_NET = 12; +constexpr int32_t ADDRESS_FAMILY_DEC_NET = 12; /// @brief Direct data-link interface address. /// @par Library @@ -137,7 +137,7 @@ constexpr int_least32_t ADDRESS_FAMILY_DEC_NET = 12; /// @ingroup xtd_core_native address_family /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t ADDRESS_FAMILY_DATA_LINK = 13; +constexpr int32_t ADDRESS_FAMILY_DATA_LINK = 13; /// @brief LAT address. /// @par Library @@ -145,7 +145,7 @@ constexpr int_least32_t ADDRESS_FAMILY_DATA_LINK = 13; /// @ingroup xtd_core_native address_family /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t ADDRESS_FAMILY_LAT = 14; +constexpr int32_t ADDRESS_FAMILY_LAT = 14; /// @brief NSC Hyperchannel address. /// @par Library @@ -153,7 +153,7 @@ constexpr int_least32_t ADDRESS_FAMILY_LAT = 14; /// @ingroup xtd_core_native address_family /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t ADDRESS_FAMILY_HYPER_CHANNEL = 15; +constexpr int32_t ADDRESS_FAMILY_HYPER_CHANNEL = 15; /// @brief AppleTalk address. /// @par Library @@ -161,7 +161,7 @@ constexpr int_least32_t ADDRESS_FAMILY_HYPER_CHANNEL = 15; /// @ingroup xtd_core_native address_family /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t ADDRESS_FAMILY_APPLE_TALK = 16; +constexpr int32_t ADDRESS_FAMILY_APPLE_TALK = 16; /// @brief NetBios address. /// @par Library @@ -169,7 +169,7 @@ constexpr int_least32_t ADDRESS_FAMILY_APPLE_TALK = 16; /// @ingroup xtd_core_native address_family /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t ADDRESS_FAMILY_NET_BIOS = 17; +constexpr int32_t ADDRESS_FAMILY_NET_BIOS = 17; /// @brief VoiceView address. /// @par Library @@ -177,7 +177,7 @@ constexpr int_least32_t ADDRESS_FAMILY_NET_BIOS = 17; /// @ingroup xtd_core_native address_family /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t ADDRESS_FAMILY_VOICE_VIEW = 18; +constexpr int32_t ADDRESS_FAMILY_VOICE_VIEW = 18; /// @brief FireFox address. /// @par Library @@ -185,7 +185,7 @@ constexpr int_least32_t ADDRESS_FAMILY_VOICE_VIEW = 18; /// @ingroup xtd_core_native address_family /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t ADDRESS_FAMILY_FIRE_FOX = 19; +constexpr int32_t ADDRESS_FAMILY_FIRE_FOX = 19; /// @brief Banyan address. /// @par Library @@ -193,7 +193,7 @@ constexpr int_least32_t ADDRESS_FAMILY_FIRE_FOX = 19; /// @ingroup xtd_core_native address_family /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t ADDRESS_FAMILY_BANYAN = 21; +constexpr int32_t ADDRESS_FAMILY_BANYAN = 21; /// @brief Native ATM services address. /// @par Library @@ -201,7 +201,7 @@ constexpr int_least32_t ADDRESS_FAMILY_BANYAN = 21; /// @ingroup xtd_core_native address_family /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t ADDRESS_FAMILY_ATM = 22; +constexpr int32_t ADDRESS_FAMILY_ATM = 22; /// @brief Address for IP version 6. /// @par Library @@ -209,7 +209,7 @@ constexpr int_least32_t ADDRESS_FAMILY_ATM = 22; /// @ingroup xtd_core_native address_family /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t ADDRESS_FAMILY_INTER_NETWORK_V6 = 23; +constexpr int32_t ADDRESS_FAMILY_INTER_NETWORK_V6 = 23; /// @brief Address for Microsoft cluster products. /// @par Library @@ -217,7 +217,7 @@ constexpr int_least32_t ADDRESS_FAMILY_INTER_NETWORK_V6 = 23; /// @ingroup xtd_core_native address_family /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t ADDRESS_FAMILY_CLUSTER = 24; +constexpr int32_t ADDRESS_FAMILY_CLUSTER = 24; /// @brief IEEE 1284.4 workgroup address. /// @par Library @@ -225,7 +225,7 @@ constexpr int_least32_t ADDRESS_FAMILY_CLUSTER = 24; /// @ingroup xtd_core_native address_family /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t ADDRESS_FAMILY_IEEE12844 = 25; +constexpr int32_t ADDRESS_FAMILY_IEEE12844 = 25; /// @brief IrDA address. /// @par Library @@ -233,7 +233,7 @@ constexpr int_least32_t ADDRESS_FAMILY_IEEE12844 = 25; /// @ingroup xtd_core_native address_family /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t ADDRESS_FAMILY_IRDA = 26; +constexpr int32_t ADDRESS_FAMILY_IRDA = 26; /// @brief Address for Network Designers OSI gateway-enabled protocols. /// @par Library @@ -241,7 +241,7 @@ constexpr int_least32_t ADDRESS_FAMILY_IRDA = 26; /// @ingroup xtd_core_native address_family /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t ADDRESS_FAMILY_NETWORK_DESIGNERS = 28; +constexpr int32_t ADDRESS_FAMILY_NETWORK_DESIGNERS = 28; /// @brief MAX address. /// @par Library @@ -249,4 +249,4 @@ constexpr int_least32_t ADDRESS_FAMILY_NETWORK_DESIGNERS = 28; /// @ingroup xtd_core_native address_family /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t ADDRESS_FAMILY_MAX = 29; +constexpr int32_t ADDRESS_FAMILY_MAX = 29; diff --git a/src/xtd.core.native/include/xtd/native/assert_dialog_results.h b/src/xtd.core.native/include/xtd/native/assert_dialog_results.h index 00597ad7373..49fb9dfc819 100644 --- a/src/xtd.core.native/include/xtd/native/assert_dialog_results.h +++ b/src/xtd.core.native/include/xtd/native/assert_dialog_results.h @@ -17,18 +17,18 @@ /// @ingroup xtd_core_native adr /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t ADR_ABORT = 3; +constexpr int32_t ADR_ABORT = 3; /// @brief The assert dialog return value is Retry (usually sent from a button labeled Retry). /// @par Library /// xtd.core.native /// @ingroup xtd_core_native adr /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t ADR_RETRY = 4; +constexpr int32_t ADR_RETRY = 4; /// @brief The assert dialog return value is Ignore (usually sent from a button labeled Ignore). /// @par Library /// xtd.core.native /// @ingroup xtd_core_native adr /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t ADR_IGNORE = 5; +constexpr int32_t ADR_IGNORE = 5; diff --git a/src/xtd.core.native/include/xtd/native/condition_variable.h b/src/xtd.core.native/include/xtd/native/condition_variable.h index d3691d69777..4c6dcdb4c1e 100644 --- a/src/xtd.core.native/include/xtd/native/condition_variable.h +++ b/src/xtd.core.native/include/xtd/native/condition_variable.h @@ -65,7 +65,7 @@ namespace xtd { /// @param milliseconds_timeout The timeout in milliseconds (-1 is infinite timeout). /// @return true if succeed; otherwhise false. /// @warning Internal use only - static bool wait(intmax_t handle, intmax_t critical_section_handle, int_least32_t milliseconds_timeout); + static bool wait(intmax_t handle, intmax_t critical_section_handle, int32_t milliseconds_timeout); /// @} }; } diff --git a/src/xtd.core.native/include/xtd/native/console.h b/src/xtd.core.native/include/xtd/native/console.h index 389f435bc71..a9f5c6d8989 100644 --- a/src/xtd.core.native/include/xtd/native/console.h +++ b/src/xtd.core.native/include/xtd/native/console.h @@ -40,39 +40,39 @@ namespace xtd { /// @brief Gets the background color of the console. /// @return the background console color. /// @warning Internal use only - static int_least32_t background_color(); + static int32_t background_color(); /// @brief Sets the background color of the console. /// @param color the background console color. /// @return true if successfull; otherwhise false. /// @warning Internal use only - static bool background_color(int_least32_t color); + static bool background_color(int32_t color); /// @brief Plays the sound of a beep of a specified frequency and duration through the console speaker. /// @param frequency The frequency of the beep, ranging from 37 to 32767 hertz /// @param duration The duration of the beep measured in milliseconds /// @return true if successfull; otherwhise false. /// @warning Internal use only - static bool beep(uint_least32_t frequency, uint_least32_t duration); + static bool beep(uint32_t frequency, uint32_t duration); /// @brief Gets the height of the buffer area. /// @return The current height, in rows, of the buffer area. /// @warning Internal use only - static int_least32_t buffer_height(); + static int32_t buffer_height(); /// @brief Sets or sets the height of the buffer area. /// @param height The current height, in rows, of the buffer area. /// @return true if successfull; otherwhise false. /// @warning Internal use only - static bool buffer_height(int_least32_t height); + static bool buffer_height(int32_t height); /// @brief Gets the width of the buffer area. /// @return The current width, in columns, of the buffer area. /// @warning Internal use only - static int_least32_t buffer_width(); + static int32_t buffer_width(); /// @brief Sets the width of the buffer area. /// @param width The current width, in columns, of the buffer area. /// @return true if successfull; otherwhise false. /// @warning Internal use only - static bool buffer_width(int_least32_t width); + static bool buffer_width(int32_t width); /// @brief Gets a value indicating whether the CAPS LOCK keyboard toggle is turned on or turned off. /// @return true if CAPS LOCK is turned on; false if CAPS LOCK is turned off. @@ -87,22 +87,22 @@ namespace xtd { /// @brief Gets the column position of the cursor within the buffer area. /// @return The current position, in columns, of the cursor. /// @warning Internal use only - static int_least32_t cursor_left(); + static int32_t cursor_left(); /// @brief Gets or sets the height of the cursor within a character cell. /// @return The size of the cursor expressed as a percentage of the height of a character cell. The property value ranges from 1 to 100. /// @warning Internal use only - static int_least32_t cursor_size(); + static int32_t cursor_size(); /// @brief Sets the height of the cursor within a character cell. /// @param size The size of the cursor expressed as a percentage of the height of a character cell. The property value ranges from 1 to 100. /// @return true if successfull; otherwhise false. /// @warning Internal use only - static bool cursor_size(int_least32_t size); + static bool cursor_size(int32_t size); /// @brief Gets the row position of the cursor within the buffer area. /// @return The current position, in rows, of the cursor. /// @warning Internal use only - static int_least32_t cursor_top(); + static int32_t cursor_top(); /// @brief Gets a value indicating whether the cursor is visible. /// @return true if the cursor is visible; otherwise, false. @@ -122,22 +122,22 @@ namespace xtd { /// @brief Gets the foreground color of the console. /// @return the foreground console color. /// @warning Internal use only - static int_least32_t foreground_color(); + static int32_t foreground_color(); /// @brief Sets the foreground color of the console. /// @param color the foreground console color. /// @return true if successfull; otherwhise false. /// @warning Internal use only - static bool foreground_color(int_least32_t color); + static bool foreground_color(int32_t color); /// @brief Gets the code page the console uses to read input. /// @return The code page used to read console input. /// @warning Internal use only - static int_least32_t input_code_page(); + static int32_t input_code_page(); /// @brief Sets the code page the console uses to read input. /// @param code_page The code page used to read console input. /// @return true if successfull; otherwhise false. /// @warning Internal use only - static bool input_code_page(int_least32_t codePage); + static bool input_code_page(int32_t codePage); /// @brief Gets a value indicating whether a key press is available in the input stream. /// @param true if a key press is available; otherwise, false @@ -147,11 +147,11 @@ namespace xtd { /// @brief Gets the largest possible number of console window rows, based on the current font and screen resolution. /// @param The height of the largest possible console window measured in rows. /// @warning Internal use only - static int_least32_t largest_window_height(); + static int32_t largest_window_height(); /// @brief Gets the largest possible number of console window columns, based on the current font and screen resolution. /// @param The width of the largest possible console window measured in columns. /// @warning Internal use only - static int_least32_t largest_window_width(); + static int32_t largest_window_width(); /// @brief Gets a value indicating whether the NUM LOCK keyboard toggle is turned on or turned off. /// @param true if NUM LOCK is turned on; false if NUM LOCK is turned off. @@ -161,12 +161,12 @@ namespace xtd { /// @brief Gets the code page the console uses to write output. /// @return The code page used to write console output. /// @warning Internal use only - static int_least32_t output_code_page(); + static int32_t output_code_page(); /// @brief Sets the code page the console uses to write output. /// @param code_page The code page used to write console output. /// @return true if successfull; otherwhise false. /// @warning Internal use only - static bool output_code_page(int_least32_t codePage); + static bool output_code_page(int32_t codePage); /// @brief Obtains the next character or function key pressed by the user. /// @param key_char A bitwise combination of the enumeration values. There is no default value. @@ -183,7 +183,7 @@ namespace xtd { /// @remarks This callback is call when when the Control modifier key (Ctrl) and either the ConsoleKey.C console key (C) or the Break key are pressed simultaneously (Ctrl+C or Ctrl+Break). /// @remarks By default, the return of callback is false, which causes program execution to terminate when the event handler exits. Changing its return to true specifies that the application should continue to execute. /// @warning Internal use only - static void register_user_cancel_callback(std::function user_cancel_callback); + static void register_user_cancel_callback(std::function user_cancel_callback); /// @brief Sets the foreground and background console colors to their defaults. /// @remarks The foreground and background colors are restored to the colors that existed when the current process began. For more information, see the foreground_color and background_color properties. @@ -196,7 +196,7 @@ namespace xtd { /// @param top The row position of the cursor. Rows are numbered from top to bottom starting at 0. /// @return true if successfull; otherwhise false. /// @warning Internal use only - static bool set_cursor_position(int_least32_t left, int_least32_t top); + static bool set_cursor_position(int32_t left, int32_t top); /// @brief Gets the title to display in the console title bar. /// @return The string to be displayed in the title bar of the console. The maximum length of the title string is 24500 characters. @@ -221,42 +221,42 @@ namespace xtd { /// @brief Gets the height of the console window area. /// @return The height of the console window measured in rows. /// @warning Internal use only - static int_least32_t window_height(); + static int32_t window_height(); /// @brief Sets the height of the console window area. /// @param height The height of the console window measured in rows. /// @return true if successfull; otherwhise false. /// @warning Internal use only - static bool window_height(int_least32_t height); + static bool window_height(int32_t height); /// @brief Gets the left of the console window area. /// @return The left of the console window measured in columns. /// @warning Internal use only - static int_least32_t window_left(); + static int32_t window_left(); /// @brief Sets the left of the console window area. /// @param left The left of the console window measured in columns. /// @return true if successfull; otherwhise false. /// @warning Internal use only - static bool window_left(int_least32_t left); + static bool window_left(int32_t left); /// @brief Gets the top of the console window area. /// @return The top of the console window measured in rows. /// @warning Internal use only - static int_least32_t window_top(); + static int32_t window_top(); /// @brief Sets the top of the console window area. /// @param top The top of the console window measured in rows. /// @return true if successfull; otherwhise false. /// @warning Internal use only - static bool window_top(int_least32_t top); + static bool window_top(int32_t top); /// @brief Gets the width of the console window area. /// @return The width of the console window measured in columns. /// @warning Internal use only - static int_least32_t window_width(); + static int32_t window_width(); /// @brief Sets the width of the console window area. /// @param width The width of the console window measured in columns. /// @return true if successfull; otherwhise false. /// @warning Internal use only - static bool window_width(int_least32_t width); + static bool window_width(int32_t width); /// @} }; } diff --git a/src/xtd.core.native/include/xtd/native/console_color.h b/src/xtd.core.native/include/xtd/native/console_color.h index d6f0a5a30ce..f53d70166c4 100644 --- a/src/xtd.core.native/include/xtd/native/console_color.h +++ b/src/xtd.core.native/include/xtd/native/console_color.h @@ -17,7 +17,7 @@ /// @ingroup xtd_core_native console_color /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t CONSOLE_COLOR_DEFAULT = -1; +constexpr int32_t CONSOLE_COLOR_DEFAULT = -1; /// @brief Console color black. /// @par Library @@ -25,7 +25,7 @@ constexpr int_least32_t CONSOLE_COLOR_DEFAULT = -1; /// @ingroup xtd_core_native console_color /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t CONSOLE_COLOR_BLACK = 0; +constexpr int32_t CONSOLE_COLOR_BLACK = 0; /// @brief Console color dark blue. /// @par Library @@ -33,7 +33,7 @@ constexpr int_least32_t CONSOLE_COLOR_BLACK = 0; /// @ingroup xtd_core_native console_color /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t CONSOLE_COLOR_DARK_BLUE = 1; +constexpr int32_t CONSOLE_COLOR_DARK_BLUE = 1; /// @brief Console color dark green. /// @par Library @@ -41,7 +41,7 @@ constexpr int_least32_t CONSOLE_COLOR_DARK_BLUE = 1; /// @ingroup xtd_core_native console_color /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t CONSOLE_COLOR_DARK_GREEN = 2; +constexpr int32_t CONSOLE_COLOR_DARK_GREEN = 2; /// @brief Console color dark cyan. /// @par Library @@ -49,7 +49,7 @@ constexpr int_least32_t CONSOLE_COLOR_DARK_GREEN = 2; /// @ingroup xtd_core_native console_color /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t CONSOLE_COLOR_DARK_CYAN = 3; +constexpr int32_t CONSOLE_COLOR_DARK_CYAN = 3; /// @brief Console color dark red. /// @par Library @@ -57,7 +57,7 @@ constexpr int_least32_t CONSOLE_COLOR_DARK_CYAN = 3; /// @ingroup xtd_core_native console_color /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t CONSOLE_COLOR_DARK_RED = 4; +constexpr int32_t CONSOLE_COLOR_DARK_RED = 4; /// @brief Console color dark magenta. /// @par Library @@ -65,7 +65,7 @@ constexpr int_least32_t CONSOLE_COLOR_DARK_RED = 4; /// @ingroup xtd_core_native console_color /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t CONSOLE_COLOR_DARK_MAGENTA = 5; +constexpr int32_t CONSOLE_COLOR_DARK_MAGENTA = 5; /// @brief Console color dark yellow. /// @par Library @@ -73,7 +73,7 @@ constexpr int_least32_t CONSOLE_COLOR_DARK_MAGENTA = 5; /// @ingroup xtd_core_native console_color /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t CONSOLE_COLOR_DARK_YELLOW = 6; +constexpr int32_t CONSOLE_COLOR_DARK_YELLOW = 6; /// @brief Console color gray. /// @par Library @@ -81,7 +81,7 @@ constexpr int_least32_t CONSOLE_COLOR_DARK_YELLOW = 6; /// @ingroup xtd_core_native console_color /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t CONSOLE_COLOR_GRAY = 7; +constexpr int32_t CONSOLE_COLOR_GRAY = 7; /// @brief Console color dark gray. /// @par Library @@ -89,7 +89,7 @@ constexpr int_least32_t CONSOLE_COLOR_GRAY = 7; /// @ingroup xtd_core_native console_color /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t CONSOLE_COLOR_DARK_GRAY = 8; +constexpr int32_t CONSOLE_COLOR_DARK_GRAY = 8; /// @brief Console color blue. /// @par Library @@ -97,7 +97,7 @@ constexpr int_least32_t CONSOLE_COLOR_DARK_GRAY = 8; /// @ingroup xtd_core_native console_color /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t CONSOLE_COLOR_BLUE = 9; +constexpr int32_t CONSOLE_COLOR_BLUE = 9; /// @brief Console color dark green. /// @par Library @@ -105,7 +105,7 @@ constexpr int_least32_t CONSOLE_COLOR_BLUE = 9; /// @ingroup xtd_core_native console_color /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t CONSOLE_COLOR_GREEN = 10; +constexpr int32_t CONSOLE_COLOR_GREEN = 10; /// @brief Console color cyan. /// @par Library @@ -113,7 +113,7 @@ constexpr int_least32_t CONSOLE_COLOR_GREEN = 10; /// @ingroup xtd_core_native console_color /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t CONSOLE_COLOR_CYAN = 11; +constexpr int32_t CONSOLE_COLOR_CYAN = 11; /// @brief Console color red. /// @par Library @@ -121,7 +121,7 @@ constexpr int_least32_t CONSOLE_COLOR_CYAN = 11; /// @ingroup xtd_core_native console_color /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t CONSOLE_COLOR_RED = 12; +constexpr int32_t CONSOLE_COLOR_RED = 12; /// @brief Console color magenta. /// @par Library @@ -129,7 +129,7 @@ constexpr int_least32_t CONSOLE_COLOR_RED = 12; /// @ingroup xtd_core_native console_color /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t CONSOLE_COLOR_MAGENTA = 13; +constexpr int32_t CONSOLE_COLOR_MAGENTA = 13; /// @brief Console color yellow. /// @par Library @@ -137,7 +137,7 @@ constexpr int_least32_t CONSOLE_COLOR_MAGENTA = 13; /// @ingroup xtd_core_native console_color /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t CONSOLE_COLOR_YELLOW = 14; +constexpr int32_t CONSOLE_COLOR_YELLOW = 14; /// @brief Console color white. /// @par Library @@ -145,4 +145,4 @@ constexpr int_least32_t CONSOLE_COLOR_YELLOW = 14; /// @ingroup xtd_core_native console_color /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t CONSOLE_COLOR_WHITE = 15; +constexpr int32_t CONSOLE_COLOR_WHITE = 15; diff --git a/src/xtd.core.native/include/xtd/native/console_special_key.h b/src/xtd.core.native/include/xtd/native/console_special_key.h index 90c555b058e..71990bc5f2a 100644 --- a/src/xtd.core.native/include/xtd/native/console_special_key.h +++ b/src/xtd.core.native/include/xtd/native/console_special_key.h @@ -17,7 +17,7 @@ /// @ingroup xtd_core_native console_special_key /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t CONSOLE_SPECIAL_KEY_CTRL_BREAK = 0; +constexpr int32_t CONSOLE_SPECIAL_KEY_CTRL_BREAK = 0; /// @brief The control modifier key plus the C console key. /// @par Library @@ -25,7 +25,7 @@ constexpr int_least32_t CONSOLE_SPECIAL_KEY_CTRL_BREAK = 0; /// @ingroup xtd_core_native console_special_key /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t CONSOLE_SPECIAL_KEY_CTRL_C = 1; +constexpr int32_t CONSOLE_SPECIAL_KEY_CTRL_C = 1; /// @brief The control modifier key plus the \\ console key. /// @par Library @@ -33,7 +33,7 @@ constexpr int_least32_t CONSOLE_SPECIAL_KEY_CTRL_C = 1; /// @ingroup xtd_core_native console_special_key /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t CONSOLE_SPECIAL_KEY_CTRL_BS = 2; +constexpr int32_t CONSOLE_SPECIAL_KEY_CTRL_BS = 2; /// @brief The control modifier key plus the Z console key. /// @par Library @@ -41,4 +41,4 @@ constexpr int_least32_t CONSOLE_SPECIAL_KEY_CTRL_BS = 2; /// @ingroup xtd_core_native console_special_key /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t CONSOLE_SPECIAL_KEY_CTRL_Z = 3; +constexpr int32_t CONSOLE_SPECIAL_KEY_CTRL_Z = 3; diff --git a/src/xtd.core.native/include/xtd/native/constant_special_item_id_list.h b/src/xtd.core.native/include/xtd/native/constant_special_item_id_list.h index ef222d2563e..365a72a8977 100644 --- a/src/xtd.core.native/include/xtd/native/constant_special_item_id_list.h +++ b/src/xtd.core.native/include/xtd/native/constant_special_item_id_list.h @@ -18,392 +18,392 @@ /// @ingroup xtd_core_native csidl /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t CSIDL_DESKTOP = 0x0000; +constexpr int32_t CSIDL_DESKTOP = 0x0000; /// @brief The directory that contains the Internet Explorer (icon on desktop). /// @par Library /// xtd.core.native /// @ingroup xtd_core_native csidl /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t CSIDL_INTERNET = 0x0001; +constexpr int32_t CSIDL_INTERNET = 0x0001; /// @brief The directory that contains the user's program groups. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native csidl /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t CSIDL_PROGRAMS = 0x0002; +constexpr int32_t CSIDL_PROGRAMS = 0x0002; /// @brief The directory that contains "My Computer\Control Panel". /// @par Library /// xtd.core.native /// @ingroup xtd_core_native csidl /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t CSIDL_CONTROLS = 0x0003; +constexpr int32_t CSIDL_CONTROLS = 0x0003; /// @brief The directory that contains "My Computer\Printers". /// @par Library /// xtd.core.native /// @ingroup xtd_core_native csidl /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t CSIDL_PRINTERS = 0x0004; +constexpr int32_t CSIDL_PRINTERS = 0x0004; /// @brief The directory that serves as a common repository for documents. This member is equivalent to MyDocuments. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native csidl /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t CSIDL_PERSONAL = 0x0005; +constexpr int32_t CSIDL_PERSONAL = 0x0005; /// @brief The directory that serves as a common repository for the user's favorite items. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native csidl /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t CSIDL_FAVORITES = 0x0006; +constexpr int32_t CSIDL_FAVORITES = 0x0006; /// @brief The directory that corresponds to the user's Startup program group. The system starts these programs whenever a user logs on or starts Windows NT or later, or starts Windows 98. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native csidl /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t CSIDL_STARTUP = 0x0007; +constexpr int32_t CSIDL_STARTUP = 0x0007; /// @brief The directory that contains the user's most recently used documents. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native csidl /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t CSIDL_RECENT = 0x0008; +constexpr int32_t CSIDL_RECENT = 0x0008; /// @brief The directory that contains the Send To menu items. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native csidl /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t CSIDL_SENDTO = 0x0009; +constexpr int32_t CSIDL_SENDTO = 0x0009; /// @brief The directory that contains the Recycle bin. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native csidl /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t CSIDL_BITBUCKET = 0x000a; +constexpr int32_t CSIDL_BITBUCKET = 0x000a; /// @brief The directory that contains the Start menu items. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native csidl /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t CSIDL_STARTMENU = 0x000b; +constexpr int32_t CSIDL_STARTMENU = 0x000b; /// @brief The My Documents folder. This member is equivalent to Personal. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native csidl /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t CSIDL_MYDOCUMENTS = CSIDL_PERSONAL; +constexpr int32_t CSIDL_MYDOCUMENTS = CSIDL_PERSONAL; /// @brief The My Music folder. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native csidl /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t CSIDL_MYMUSIC = 0x000d; +constexpr int32_t CSIDL_MYMUSIC = 0x000d; /// @brief The file system directory that serves as a repository for videos that belong to a user. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native csidl /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t CSIDL_MYVIDEO = 0x000e; +constexpr int32_t CSIDL_MYVIDEO = 0x000e; /// @brief The directory used to physically store file objects on the desktop. Do not confuse this directory with the desktop folder itself, which is a virtual folder. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native csidl /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t CSIDL_DESKTOPDIRECTORY = 0x0010; +constexpr int32_t CSIDL_DESKTOPDIRECTORY = 0x0010; /// @brief The My Computer folder. The MyComputer constant always yields the empty string ("") because no path is defined for the My Computer folder. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native csidl /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t CSIDL_DRIVES = 0x0011; +constexpr int32_t CSIDL_DRIVES = 0x0011; /// @brief A file system directory that contains Network Neighborhood (My Network Places). /// @par Library /// xtd.core.native /// @ingroup xtd_core_native csidl /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t CSIDL_NETWORK = 0x0012; +constexpr int32_t CSIDL_NETWORK = 0x0012; /// @brief A file system directory that contains the link objects that may exist in the My Network Places virtual folder. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native csidl /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t CSIDL_NETHOOD = 0x0013; +constexpr int32_t CSIDL_NETHOOD = 0x0013; /// @brief A virtual folder that contains fonts. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native csidl /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t CSIDL_FONTS = 0x0014; +constexpr int32_t CSIDL_FONTS = 0x0014; /// @brief The directory that serves as a common repository for document templates. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native csidl /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t CSIDL_TEMPLATES = 0x0015; +constexpr int32_t CSIDL_TEMPLATES = 0x0015; /// @brief The file system directory that contains the programs and folders that appear on the Start menu for all users. This special folder is valid only for Windows NT systems. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native csidl /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t CSIDL_COMMON_STARTMENU = 0x0016; +constexpr int32_t CSIDL_COMMON_STARTMENU = 0x0016; /// @brief A folder for components that are shared across applications. This special folder is valid only for Windows NT, Windows 2000, and Windows XP systems. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native csidl /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t CSIDL_COMMON_PROGRAMS = 0X0017; +constexpr int32_t CSIDL_COMMON_PROGRAMS = 0X0017; /// @brief The file system directory that contains the programs that appear in the Startup folder for all users. This special folder is valid only for Windows NT systems. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native csidl /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t CSIDL_COMMON_STARTUP = 0x0018; +constexpr int32_t CSIDL_COMMON_STARTUP = 0x0018; /// @brief The file system directory that contains files and folders that appear on the desktop for all users. This special folder is valid only for Windows NT systems. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native csidl /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t CSIDL_COMMON_DESKTOPDIRECTORY = 0x0019; +constexpr int32_t CSIDL_COMMON_DESKTOPDIRECTORY = 0x0019; /// @brief The directory that serves as a common repository for application-specific data for the current roaming user. A roaming user works on more than one computer on a network. A roaming user's profile is kept on a server on the network and is loaded onto a system when the user logs on. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native csidl /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t CSIDL_APPDATA = 0x001a; +constexpr int32_t CSIDL_APPDATA = 0x001a; /// @brief The file system directory that contains the link objects that can exist in the Printers virtual folder. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native csidl /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t CSIDL_PRINTHOOD = 0x001b; +constexpr int32_t CSIDL_PRINTHOOD = 0x001b; /// @brief The directory that serves as a common repository for application-specific data that is used by the current, non-roaming user. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native csidl /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t CSIDL_LOCAL_APPDATA = 0x001c; +constexpr int32_t CSIDL_LOCAL_APPDATA = 0x001c; /// @brief The file system directory that contains non localized startup /// @par Library /// xtd.core.native /// @ingroup xtd_core_native csidl /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t CSIDL_ALTSTARTUP = 0x001d; +constexpr int32_t CSIDL_ALTSTARTUP = 0x001d; /// @brief The file system directory that contains non localized common startup /// @par Library /// xtd.core.native /// @ingroup xtd_core_native csidl /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t CSIDL_COMMON_ALTSTARTUP = 0x001e; +constexpr int32_t CSIDL_COMMON_ALTSTARTUP = 0x001e; /// @brief The file system directory that contains common favorites /// @par Library /// xtd.core.native /// @ingroup xtd_core_native csidl /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t CSIDL_COMMON_FAVORITES = 0x001f; +constexpr int32_t CSIDL_COMMON_FAVORITES = 0x001f; /// @brief The directory that serves as a common repository for temporary Internet files. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native csidl /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t CSIDL_INTERNET_CACHE = 0x0020; +constexpr int32_t CSIDL_INTERNET_CACHE = 0x0020; /// @brief The directory that serves as a common repository for Internet cookies. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native csidl /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t CSIDL_COOKIES = 0x0021; +constexpr int32_t CSIDL_COOKIES = 0x0021; /// @brief The directory that serves as a common repository for Internet history items. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native csidl /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t CSIDL_HISTORY = 0x0022; +constexpr int32_t CSIDL_HISTORY = 0x0022; /// @brief The directory that serves as a common repository for application-specific data that is used by all users. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native csidl /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t CSIDL_COMMON_APPDATA = 0x0023; +constexpr int32_t CSIDL_COMMON_APPDATA = 0x0023; /// @brief The Windows directory or SYSROOT. This corresponds to the %windir% or %SYSTEMROOT% environment variables. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native csidl /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t CSIDL_WINDOWS = 0x0024; +constexpr int32_t CSIDL_WINDOWS = 0x0024; /// @brief The System directory. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native csidl /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t CSIDL_SYSTEM = 0x0025; +constexpr int32_t CSIDL_SYSTEM = 0x0025; /// @brief The program files directory.On a non-x86 system, passing ProgramFiles to the GetFolderPath method returns the path for non-x86 programs. To get the x86 program files directory on a non-x86 system, use the ProgramFilesX86 member. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native csidl /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t CSIDL_PROGRAM_FILES = 0x0026; +constexpr int32_t CSIDL_PROGRAM_FILES = 0x0026; /// @brief The My Pictures folder. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native csidl /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t CSIDL_MYPICTURES = 0x0027; +constexpr int32_t CSIDL_MYPICTURES = 0x0027; /// @brief The user's profile folder. Applications should not create files or folders at this level; they should put their data under the locations referred to by ApplicationData. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native csidl /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t CSIDL_PROFILE = 0x0028; +constexpr int32_t CSIDL_PROFILE = 0x0028; /// @brief The Windows System folder. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native csidl /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t CSIDL_SYSTEMX86 = 0x0029; +constexpr int32_t CSIDL_SYSTEMX86 = 0x0029; /// @brief The Program Files folder On an x86 system, passing the ProgramFilesX86 member to the Environment.GetFolderPath method returns string.Empty; use the ProgramFiles member instead. You can determine whether Windows is a 32-bit operating system by calling the Environment.Is64BitOperatingSystem property. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native csidl /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t CSIDL_PROGRAM_FILESX86 = 0x002a; +constexpr int32_t CSIDL_PROGRAM_FILESX86 = 0x002a; /// @brief The directory for components that are shared across applications.To get the x86 common program files directory on a non-x86 system, use the ProgramFilesX86 member. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native csidl /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t CSIDL_PROGRAM_FILES_COMMON = 0x002b; +constexpr int32_t CSIDL_PROGRAM_FILES_COMMON = 0x002b; /// @brief The Program Files folder. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native csidl /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t CSIDL_PROGRAM_FILES_COMMONX86 = 0x002c; +constexpr int32_t CSIDL_PROGRAM_FILES_COMMONX86 = 0x002c; /// @brief The file system directory that contains the templates that are available to all users. This special folder is valid only for Windows NT systems. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native csidl /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t CSIDL_COMMON_TEMPLATES = 0x002d; +constexpr int32_t CSIDL_COMMON_TEMPLATES = 0x002d; /// @brief The file system directory that contains documents that are common to all users. This special folder is valid for Windows NT systems, Windows 95, and Windows 98 systems with Shfolder.dll installed. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native csidl /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t CSIDL_COMMON_DOCUMENTS = 0x002e; +constexpr int32_t CSIDL_COMMON_DOCUMENTS = 0x002e; /// @brief The file system directory that contains administrative tools for all users of the computer. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native csidl /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t CSIDL_COMMON_ADMINTOOLS = 0x002f; +constexpr int32_t CSIDL_COMMON_ADMINTOOLS = 0x002f; /// @brief The file system directory that is used to store administrative tools for an individual user. The Microsoft Management Console (MMC) will save customized consoles to this directory, and it will roam with the user. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native csidl /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t CSIDL_ADMINTOOLS = 0x0030; +constexpr int32_t CSIDL_ADMINTOOLS = 0x0030; /// @brief The file system directory that contains Network and Dial-up Connections. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native csidl /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t CSIDL_CONNECTIONS = 0x0031; +constexpr int32_t CSIDL_CONNECTIONS = 0x0031; /// @brief The file system directory that serves as a repository for music files common to all users. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native csidl /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t CSIDL_COMMON_MUSIC = 0x0035; +constexpr int32_t CSIDL_COMMON_MUSIC = 0x0035; /// @brief The file system directory that serves as a repository for image files common to all users. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native csidl /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t CSIDL_COMMON_PICTURES = 0x0036; +constexpr int32_t CSIDL_COMMON_PICTURES = 0x0036; /// @brief The file system directory that serves as a repository for video files common to all users. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native csidl /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t CSIDL_COMMON_VIDEO = 0x0037; +constexpr int32_t CSIDL_COMMON_VIDEO = 0x0037; /// @brief The file system directory that contains resource data. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native csidl /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t CSIDL_RESOURCES = 0x0038; +constexpr int32_t CSIDL_RESOURCES = 0x0038; /// @brief The file system directory that contains localized resource data. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native csidl /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t CSIDL_RESOURCES_LOCALIZED = 0x0039; +constexpr int32_t CSIDL_RESOURCES_LOCALIZED = 0x0039; /// @brief This value is recognized in Windows Vista for backward compatibility, but the special folder itself is no longer used. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native csidl /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t CSIDL_COMMON_OEM_LINKS = 0x003a; +constexpr int32_t CSIDL_COMMON_OEM_LINKS = 0x003a; /// @brief The file system directory that acts as a staging area for files waiting to be written to a CD. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native csidl /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t CSIDL_CDBURN_AREA = 0x003b; +constexpr int32_t CSIDL_CDBURN_AREA = 0x003b; // unused 0x003c @@ -412,7 +412,7 @@ constexpr int_least32_t CSIDL_CDBURN_AREA = 0x003b; /// @ingroup xtd_core_native csidl /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t CSIDL_COMPUTERSNEARME = 0x003d; +constexpr int32_t CSIDL_COMPUTERSNEARME = 0x003d; #endif /// @brief The file system directory that contains home folder. /// @par Library @@ -420,4 +420,4 @@ constexpr int_least32_t CSIDL_COMPUTERSNEARME = 0x003d; /// @ingroup xtd_core_native csidl /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t CSIDL_HOME = 0x0040; +constexpr int32_t CSIDL_HOME = 0x0040; diff --git a/src/xtd.core.native/include/xtd/native/cryptography.h b/src/xtd.core.native/include/xtd/native/cryptography.h index 6d93121329e..c1ad9c8f528 100644 --- a/src/xtd.core.native/include/xtd/native/cryptography.h +++ b/src/xtd.core.native/include/xtd/native/cryptography.h @@ -42,7 +42,7 @@ namespace xtd { /// @brief Gets the machine's GUID. /// @return A byte array that contains the machine GUID. /// @warning Internal use only - static std::vector machine_guid(); + static std::vector machine_guid(); /// @} }; } diff --git a/src/xtd.core.native/include/xtd/native/date_time.h b/src/xtd.core.native/include/xtd/native/date_time.h index 42ccd9d0514..90c4c5893a0 100644 --- a/src/xtd.core.native/include/xtd/native/date_time.h +++ b/src/xtd.core.native/include/xtd/native/date_time.h @@ -36,36 +36,36 @@ namespace xtd { public: struct time_zone_info { struct transition_time { - uint_least32_t day {0}; - uint_least32_t day_of_week {0}; + uint32_t day {0}; + uint32_t day_of_week {0}; bool is_fixed_date_rule {false}; - uint_least32_t month {0}; - uint_least32_t time_of_day_hour {0}; - uint_least32_t time_of_day_minute {0}; - uint_least32_t time_of_day_second {0}; - uint_least32_t week {0}; + uint32_t month {0}; + uint32_t time_of_day_hour {0}; + uint32_t time_of_day_minute {0}; + uint32_t time_of_day_second {0}; + uint32_t week {0}; }; struct adjustement_rule { - uint_least32_t date_start_year; - uint_least32_t date_start_month; - uint_least32_t date_start_day; - uint_least32_t date_start_hour; - uint_least32_t date_start_minute; - uint_least32_t date_start_second; - uint_least32_t date_end_year; - uint_least32_t date_end_month; - uint_least32_t date_end_day; - uint_least32_t date_end_hour; - uint_least32_t date_end_minute; - uint_least32_t date_end_second; - int_least64_t daylight_delta {0}; + uint32_t date_start_year; + uint32_t date_start_month; + uint32_t date_start_day; + uint32_t date_start_hour; + uint32_t date_start_minute; + uint32_t date_start_second; + uint32_t date_end_year; + uint32_t date_end_month; + uint32_t date_end_day; + uint32_t date_end_hour; + uint32_t date_end_minute; + uint32_t date_end_second; + int64_t daylight_delta {0}; time_zone_info::transition_time daylight_transition_start_; time_zone_info::transition_time daylight_transition_end; }; std::string id; - int_least64_t base_utc_offset {0}; + int64_t base_utc_offset {0}; std::string daylight_name; std::string display_name; std::string standard_name; diff --git a/src/xtd.core.native/include/xtd/native/debugger.h b/src/xtd.core.native/include/xtd/native/debugger.h index 0cc879704ee..d976a77f6ea 100644 --- a/src/xtd.core.native/include/xtd/native/debugger.h +++ b/src/xtd.core.native/include/xtd/native/debugger.h @@ -64,14 +64,14 @@ namespace xtd { /// @return The assert dialog result. (see assert_dialog_results.h file). /// @remarks In general the assert dialog is a system message box. /// @warning Internal use only - static int_least32_t show_assert_dialog(const std::string& text, const std::string& caption); + static int32_t show_assert_dialog(const std::string& text, const std::string& caption); /// @brief Posts a message for the attached debugger. /// @param level A description of the importance of the message. /// @param category The category of the message. /// @param message The message to show. /// @remarks If there is no debugger attached, this method has no effect. The debugger might or might not report the message, depending upon its settings. /// @warning Internal use only - static void log(int_least32_t level, const std::string& category, const std::string& message); + static void log(int32_t level, const std::string& category, const std::string& message); /// @} }; } diff --git a/src/xtd.core.native/include/xtd/native/directory.h b/src/xtd.core.native/include/xtd/native/directory.h index 14ad445fa70..cfea819ebb4 100644 --- a/src/xtd.core.native/include/xtd/native/directory.h +++ b/src/xtd.core.native/include/xtd/native/directory.h @@ -68,7 +68,7 @@ namespace xtd { ~directory_iterator(); directory_iterator& operator ++(); - directory_iterator operator ++(int_least32_t); + directory_iterator operator ++(int32_t); bool operator ==(directory_iterator other) const; bool operator !=(directory_iterator other) const {return !operator ==(other);} value_type operator *() const; @@ -107,7 +107,7 @@ namespace xtd { ~file_iterator(); file_iterator& operator ++(); - file_iterator operator ++(int_least32_t); + file_iterator operator ++(int32_t); bool operator ==(file_iterator other) const; bool operator !=(file_iterator other) const {return !operator ==(other);} value_type operator *() const; @@ -145,7 +145,7 @@ namespace xtd { ~file_and_directory_iterator(); file_and_directory_iterator& operator ++(); - file_and_directory_iterator operator ++(int_least32_t); + file_and_directory_iterator operator ++(int32_t); bool operator ==(file_and_directory_iterator other) const; bool operator !=(file_and_directory_iterator other) const {return !operator ==(other);} value_type operator *() const; @@ -171,7 +171,7 @@ namespace xtd { /// @param directory_name The directory to create. /// @return 0 if success; otherwise failed. /// @warning Internal use only - static int_least32_t create(const std::string& directory_name); + static int32_t create(const std::string& directory_name); /// @brief Returns an enumerable collection of directory full names that match a search pattern in a specified path. /// @param path The relative or absolute path to the directory to search. /// @param pattern The search string to match against the names of directories in path. This parameter can contain a combination of valid literal path and wildcard (* and ?) characters, but it doesn't support regular expressions. @@ -204,12 +204,12 @@ namespace xtd { /// @param directory_name The name of the empty directory to remove. This directory must be writable and empty. /// @return 0 if success; otherwise failed. /// @warning Internal use only - static int_least32_t remove(const std::string& directory_name); + static int32_t remove(const std::string& directory_name); /// @brief Sets the current directory. /// @param dirrectory_name The currrent directory. /// @return 0 if success; -1 operation is not supported; otherwise failed. /// @warning Internal use only - static int_least32_t set_current_directory(const std::string& directory_name); + static int32_t set_current_directory(const std::string& directory_name); /// @} }; } diff --git a/src/xtd.core.native/include/xtd/native/dns.h b/src/xtd.core.native/include/xtd/native/dns.h index ce5411f40de..2abe97f9e90 100644 --- a/src/xtd.core.native/include/xtd/native/dns.h +++ b/src/xtd.core.native/include/xtd/native/dns.h @@ -56,7 +56,7 @@ namespace xtd { /// @param host_address_type The address family (see address_family_constants.h) to resolve. /// @return The host handle. /// @warning Internal use only - static intmax_t get_host_by_address(const std::string& host_address, int_least32_t host_address_type); + static intmax_t get_host_by_address(const std::string& host_address, int32_t host_address_type); /// @brief Gets host by host name. /// @param host_name The name to resolve. /// @return The host handle. @@ -71,7 +71,7 @@ namespace xtd { /// @param host The host handle to retrieve IP addresses. /// @return An IP address array for yhe host. /// @warning Internal use only - static std::vector> get_addresses(intmax_t host); + static std::vector> get_addresses(intmax_t host); /// @brief Gets name for a host. /// @param host The host handle to retrieve name. /// @return A string that represent the host. @@ -81,7 +81,7 @@ namespace xtd { /// @param host_name The string that will contain the host name. /// @return 0 if succeed; otherwise error. /// @warning Internal use only - static int_least32_t get_host_name(std::string& host_name); + static int32_t get_host_name(std::string& host_name); /// @brief Opens the file /etc/hosts. /// @warning Internal use only static void startup(); diff --git a/src/xtd.core.native/include/xtd/native/drive.h b/src/xtd.core.native/include/xtd/native/drive.h index e3b507bd89d..480ead3c106 100644 --- a/src/xtd.core.native/include/xtd/native/drive.h +++ b/src/xtd.core.native/include/xtd/native/drive.h @@ -52,7 +52,7 @@ namespace xtd { /// @param root_path_name root path name to get drive type. /// @return The drive type (see drive_type.h file). /// @warning Internal use only - static int_least32_t get_drive_type(const std::string& root_path_name); + static int32_t get_drive_type(const std::string& root_path_name); /// @brief Gets system drive names array. /// @return An array of system drive names. /// @warning Internal use only diff --git a/src/xtd.core.native/include/xtd/native/drive_type.h b/src/xtd.core.native/include/xtd/native/drive_type.h index b69232b1cd8..90789e248bd 100644 --- a/src/xtd.core.native/include/xtd/native/drive_type.h +++ b/src/xtd.core.native/include/xtd/native/drive_type.h @@ -18,7 +18,7 @@ /// @ingroup xtd_core_native drive_type /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t DRIVE_UNKNOWN = 0; +constexpr int32_t DRIVE_UNKNOWN = 0; /// @brief The root path is invalid; for example, there is no volume mounted at the specified path. /// @par Library @@ -26,7 +26,7 @@ constexpr int_least32_t DRIVE_UNKNOWN = 0; /// @ingroup xtd_core_native drive_type /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t DRIVE_NO_ROOT_DIR = 1; +constexpr int32_t DRIVE_NO_ROOT_DIR = 1; /// @brief The drive has removable media; for example, a floppy drive, thumb drive, or flash card reader. /// @par Library @@ -34,7 +34,7 @@ constexpr int_least32_t DRIVE_NO_ROOT_DIR = 1; /// @ingroup xtd_core_native drive_type /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t DRIVE_REMOVABLE = 2; +constexpr int32_t DRIVE_REMOVABLE = 2; /// @brief The drive has fixed media; for example, a hard disk drive or flash drive. /// @par Library @@ -42,7 +42,7 @@ constexpr int_least32_t DRIVE_REMOVABLE = 2; /// @ingroup xtd_core_native drive_type /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t DRIVE_FIXED = 3; +constexpr int32_t DRIVE_FIXED = 3; /// @brief The drive is a remote (network) drive. /// @par Library @@ -50,7 +50,7 @@ constexpr int_least32_t DRIVE_FIXED = 3; /// @ingroup xtd_core_native drive_type /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t DRIVE_REMOTE = 4; +constexpr int32_t DRIVE_REMOTE = 4; /// @brief The drive is a CD-ROM drive. /// @par Library @@ -58,7 +58,7 @@ constexpr int_least32_t DRIVE_REMOTE = 4; /// @ingroup xtd_core_native drive_type /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t DRIVE_CDROM = 5; +constexpr int32_t DRIVE_CDROM = 5; /// @brief The drive is a RAM disk. /// @par Library @@ -66,5 +66,5 @@ constexpr int_least32_t DRIVE_CDROM = 5; /// @ingroup xtd_core_native drive_type /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t DRIVE_RAMDISK = 6; +constexpr int32_t DRIVE_RAMDISK = 6; #endif diff --git a/src/xtd.core.native/include/xtd/native/environment.h b/src/xtd.core.native/include/xtd/native/environment.h index d6d2e77c643..33d1711f9ee 100644 --- a/src/xtd.core.native/include/xtd/native/environment.h +++ b/src/xtd.core.native/include/xtd/native/environment.h @@ -49,7 +49,7 @@ namespace xtd { /// @param on_quick_exit pointer to a function to be called on quick program termination. /// @return 0​ if the registration succeeds, nonzero value otherwise. /// @warning Internal use only - static int_least32_t at_quick_exit(void (*on_quick_exit)(void)); + static int32_t at_quick_exit(void (*on_quick_exit)(void)); /// @brief Returns a string array containing the command-line arguments for the current process. /// @return An array of string where each element contains a command-line argument. The first element is the executable file name, and the following zero or more elements contain the remaining command-line arguments. @@ -110,7 +110,7 @@ namespace xtd { /// @param build return the build. /// @param revision return the revision numbers for the distribution. /// @warning Internal use only - static void get_distribution_version(int_least32_t& major, int_least32_t& minor, int_least32_t& build, int_least32_t& revision); + static void get_distribution_version(int32_t& major, int32_t& minor, int32_t& build, int32_t& revision); /// @brief Gets the distribution version string. /// @return std::string A string containing distribution version string. /// @remarks Return "" if not found or defined. @@ -120,17 +120,17 @@ namespace xtd { /// @param target The environment variable target (see environment_variable_target.h file). /// @return std::map A dictionary that contains all environment variable names and their values from the source specified by the target parameter; otherwise, an empty dictionary if no environment variables are found. /// @warning Internal use only - static std::map& get_environment_variables(int_least32_t target); + static std::map& get_environment_variables(int32_t target); /// @brief Retrieves the value of an environment variable from the current process. /// @param variable The name of the environment variable. /// @return std::string The value of the environment variable specified by variable, or empty "" if the environment variable is not found. /// @warning Internal use only - static std::string get_environment_variable(const std::string& variable, int_least32_t target); + static std::string get_environment_variable(const std::string& variable, int32_t target); /// @brief Gets the path to the system special folder that is identified by the specified enumeration. /// @param csidl System special folder identifier (see constant_special_item_id_list.h file). /// @return The path to the specified system special folder, if that folder physically exists on your computer; otherwise, an empty string (""). /// @warning Internal use only - static std::string get_know_folder_path(int_least32_t csidl); + static std::string get_know_folder_path(int32_t csidl); /// @brief Gets the NetBIOS name of this local computer. /// @return A string containing the name of this computer. /// @warning Internal use only @@ -138,18 +138,18 @@ namespace xtd { /// @brief Gets a platform id that identifies the operating system platform. /// @return Operating system platform identifier (see platform_ids.h file). /// @warning Internal use only - static int_least32_t get_os_platform_id(); + static int32_t get_os_platform_id(); /// @brief Gets a xtd::version object that identifies the operating system. /// @param major return the major version. /// @param minor return the minor version, build, and revision numbers for the operating system. /// @param build return the build. /// @param revision return the revision numbers for the operating system. /// @warning Internal use only - static void get_os_version(int_least32_t& major, int_least32_t& minor, int_least32_t& build, int_least32_t& revision); + static void get_os_version(int32_t& major, int32_t& minor, int32_t& build, int32_t& revision); /// @brief Gets the number of processors on the current machine. /// @return The 32-bit unsigned integer that specifies the number of processors on the current machine. There is no default. If the current machine contains multiple processor groups, this property returns the number of logical processors that are available for use. /// @warning Internal use only - static uint_least32_t get_processor_count(); + static uint32_t get_processor_count(); /// @brief Gets the path of the resources folder. /// @return A string that represents the path of the resources folder. /// @warning Internal use only @@ -165,7 +165,7 @@ namespace xtd { /// @brief Gets the number of milliseconds elapsed since the system started. /// @return A 32-bit unsigned integer containing the amount of time in milliseconds that has passed since the last time the computer was started. /// @warning Internal use only - static uint_least32_t get_tick_count(); + static uint32_t get_tick_count(); /// @brief Gets a value indicating whether the current user is an administrator. /// @return bool true if the current user is an administrator; otherwise, false. /// @warning Internal use only @@ -197,20 +197,20 @@ namespace xtd { /// @brief Terminates this process and returns an exit code to the operating system without completely cleaning the resources.. /// @param exit_code The exit code to return to the operating system. Use 0 (zero) to indicate that the process completed successfully. /// @warning Internal use only - [[noreturn]] static void quick_exit(int_least32_t exit_code) noexcept; + [[noreturn]] static void quick_exit(int32_t exit_code) noexcept; /// @brief Creates or modifies an environment variable stored in the current process. /// @param variable The name of an environment variable. /// @param value A value to assign to variable. /// @warning Internal use only - static void set_environment_variable(const std::string& name, const std::string& value, int_least32_t target); + static void set_environment_variable(const std::string& name, const std::string& value, int32_t target); /// @brief Deletes an environment variable stored in the current process. /// @param variable The name of an environment variable. /// @warning Internal use only - static void unset_environment_variable(const std::string& name, int_least32_t target); + static void unset_environment_variable(const std::string& name, int32_t target); /// @brief Gets the amount of physical memory mapped to the process context. /// @return Int64 A 64-bit signed integer containing the number of bytes of physical memory mapped to the process context. /// @warning Internal use only - static int_least64_t working_set(); + static int64_t working_set(); /// @} }; } diff --git a/src/xtd.core.native/include/xtd/native/environment_variable_target.h b/src/xtd.core.native/include/xtd/native/environment_variable_target.h index 380c238108d..6ac4af28438 100644 --- a/src/xtd.core.native/include/xtd/native/environment_variable_target.h +++ b/src/xtd.core.native/include/xtd/native/environment_variable_target.h @@ -17,19 +17,19 @@ /// @ingroup xtd_core_native environment_variable_target /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t ENVIRONMENT_VARIABLE_TARGET_PROCESS = 0; +constexpr int32_t ENVIRONMENT_VARIABLE_TARGET_PROCESS = 0; /// @brief The environment variable is stored or retrieved from the HKEY_CURRENT_USER\Environment key in the Windows operating system registry. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native environment_variable_target /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t ENVIRONMENT_VARIABLE_TARGET_USER = 1; +constexpr int32_t ENVIRONMENT_VARIABLE_TARGET_USER = 1; /// @brief The environment variable is stored or retrieved from the HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment key in the Windows operating system registry. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native environment_variable_target /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t ENVIRONMENT_VARIABLE_TARGET_MACHINE = 2; +constexpr int32_t ENVIRONMENT_VARIABLE_TARGET_MACHINE = 2; /// @brief Console color black. diff --git a/src/xtd.core.native/include/xtd/native/file.h b/src/xtd.core.native/include/xtd/native/file.h index 4549bce53de..eb4082fa7da 100644 --- a/src/xtd.core.native/include/xtd/native/file.h +++ b/src/xtd.core.native/include/xtd/native/file.h @@ -45,7 +45,7 @@ namespace xtd { /// @param target_file The target file where copy. /// @return 0 if success; otherwise failed. /// @warning Internal use only - static int_least32_t copy(const std::string& source_file, const std::string& target_file); + static int32_t copy(const std::string& source_file, const std::string& target_file); /// @brief Check if specified file exist. /// @param path The file path to check. /// @return true is file exist; otherwise false. @@ -61,12 +61,12 @@ namespace xtd { /// @param new_path The path to the new location for old_path. If old_path is a file, then new_path must also be a file name. /// @return 0 if success; otherwise failed. /// @warning Internal use only - static int_least32_t move(const std::string& old_path, const std::string& new_path); + static int32_t move(const std::string& old_path, const std::string& new_path); /// @brief Permanently deletes a speccified file. /// @param file The file name to delete. /// @return 0 if success; otherwise failed. /// @warning Internal use only - static int_least32_t remove(const std::string& file); + static int32_t remove(const std::string& file); /// @} }; } diff --git a/src/xtd.core.native/include/xtd/native/file_attribute.h b/src/xtd.core.native/include/xtd/native/file_attribute.h index 8999dfec67c..b3ade6ca6ae 100644 --- a/src/xtd.core.native/include/xtd/native/file_attribute.h +++ b/src/xtd.core.native/include/xtd/native/file_attribute.h @@ -18,152 +18,152 @@ /// @ingroup xtd_core_native file_attributes /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t FILE_ATTRIBUTE_READONLY = 0x0001; +constexpr int32_t FILE_ATTRIBUTE_READONLY = 0x0001; /// @brief The file is hidden, and thus is not included in an ordinary directory listing. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native file_attributes /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t FILE_ATTRIBUTE_HIDDEN = 0x0002; +constexpr int32_t FILE_ATTRIBUTE_HIDDEN = 0x0002; /// @brief The file is a system file. The file is part of the operating system or is used exclusively by the operating system. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native file_attributes /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t FILE_ATTRIBUTE_SYSTEM = 0x0004; +constexpr int32_t FILE_ATTRIBUTE_SYSTEM = 0x0004; /// @brief The file is a directory. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native file_attributes /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t FILE_ATTRIBUTE_DIRECTORY = 0x0010; +constexpr int32_t FILE_ATTRIBUTE_DIRECTORY = 0x0010; /// @brief The file's archive status. Applications use this attribute to mark files for backup or removal. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native file_attributes /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t FILE_ATTRIBUTE_ARCHIVE = 0x0020; +constexpr int32_t FILE_ATTRIBUTE_ARCHIVE = 0x0020; /// @brief Reserved for future use. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native file_attributes /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t FILE_ATTRIBUTE_DEVICE = 0x0040; +constexpr int32_t FILE_ATTRIBUTE_DEVICE = 0x0040; /// @brief The file is normal and has no other attributes set. This attribute is valid only if used alone. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native file_attributes /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t FILE_ATTRIBUTE_NORMAL = 0x0080; +constexpr int32_t FILE_ATTRIBUTE_NORMAL = 0x0080; /// @brief The file is temporary. File systems attempt to keep all of the data in memory for quicker access rather than flushing the data back to mass storage. A temporary file should be deleted by the application as soon as it is no longer needed. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native file_attributes /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t FILE_ATTRIBUTE_TEMPORARY = 0x0100; +constexpr int32_t FILE_ATTRIBUTE_TEMPORARY = 0x0100; /// @brief The file is a sparse file. Sparse files are typically large files whose data are mostly zeros. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native file_attributes /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t FILE_ATTRIBUTE_SPARSE_FILE = 0x0200; +constexpr int32_t FILE_ATTRIBUTE_SPARSE_FILE = 0x0200; /// @brief The file contains a reparse point, which is a block of user-defined data associated with a file or a directory. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native file_attributes /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t FILE_ATTRIBUTE_REPARSE_POINT = 0x0400; +constexpr int32_t FILE_ATTRIBUTE_REPARSE_POINT = 0x0400; /// @brief The file is compressed. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native file_attributes /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t FILE_ATTRIBUTE_COMPRESSED = 0x0800; +constexpr int32_t FILE_ATTRIBUTE_COMPRESSED = 0x0800; /// @brief The file is offline. The data of the file is not immediately available. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native file_attributes /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t FILE_ATTRIBUTE_OFFLINE = 0x1000; +constexpr int32_t FILE_ATTRIBUTE_OFFLINE = 0x1000; /// @brief The file will not be indexed by the operating system's content indexing service. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native file_attributes /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t FILE_ATTRIBUTE_NOT_CONTENT_INDEXED = 0x2000; +constexpr int32_t FILE_ATTRIBUTE_NOT_CONTENT_INDEXED = 0x2000; /// @brief The file or directory is encrypted. For a file, this means that all data in the file is encrypted. For a directory, this means that encryption is the default for newly created files and directories. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native file_attributes /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t FILE_ATTRIBUTE_ENCRYPTED = 0x4000; +constexpr int32_t FILE_ATTRIBUTE_ENCRYPTED = 0x4000; /// @brief The directory or user data stream is configured with integrity (only supported on ReFS volumes). It is not included in an ordinary directory listing. The integrity setting persists with the file if it's renamed. If a file is copied the destination file will have integrity set if either the source file or destination directory have integrity set. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native file_attributes /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t FILE_ATTRIBUTE_INTEGRITY_STREAM = 0x00008000; +constexpr int32_t FILE_ATTRIBUTE_INTEGRITY_STREAM = 0x00008000; /// @brief This value is reserved for system use. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native file_attributes /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t FILE_ATTRIBUTE_VIRTUAL = 0x00010000; +constexpr int32_t FILE_ATTRIBUTE_VIRTUAL = 0x00010000; /// @brief The user data stream not to be read by the background data integrity scanner (AKA scrubber). When set on a directory it only provides inheritance. This flag is only supported on Storage Spaces and ReFS volumes. It is not included in an ordinary directory listing. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native file_attributes /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t FILE_ATTRIBUTE_NO_SCRUB_DATA = 0x00020000; +constexpr int32_t FILE_ATTRIBUTE_NO_SCRUB_DATA = 0x00020000; /// @brief (Not documented). /// @par Library /// xtd.core.native /// @ingroup xtd_core_native file_attributes /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t FILE_ATTRIBUTE_EA = 0x00040000; +constexpr int32_t FILE_ATTRIBUTE_EA = 0x00040000; /// @brief (Not documented). /// @par Library /// xtd.core.native /// @ingroup xtd_core_native file_attributes /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t FILE_ATTRIBUTE_PINNED = 0x00080000; +constexpr int32_t FILE_ATTRIBUTE_PINNED = 0x00080000; /// @brief (Not documented). /// @par Library /// xtd.core.native /// @ingroup xtd_core_native file_attributes /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t FILE_ATTRIBUTE_UNPINNED = 0x00100000; +constexpr int32_t FILE_ATTRIBUTE_UNPINNED = 0x00100000; /// @brief This attribute only appears in directory enumeration classes (FILE_DIRECTORY_INFORMATION, FILE_BOTH_DIR_INFORMATION, etc.). When this attribute is set, it means that the file or directory has no physical representation on the local system; the item is virtual. Opening the item will be more expensive than normal, e.g. it will cause at least some of it to be fetched from a remote store. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native file_attributes /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t FILE_ATTRIBUTE_RECALL_ON_OPEN = 0x00040000; +constexpr int32_t FILE_ATTRIBUTE_RECALL_ON_OPEN = 0x00040000; /// @brief When this attribute is set, it means that the file or directory is not fully present locally. For a file that means that not all of its data is on local storage (e.g. it may be sparse with some data still in remote storage). For a directory it means that some of the directory contents are being virtualized from another location. Reading the file / enumerating the directory will be more expensive than normal, e.g. it will cause at least some of the file/directory content to be fetched from a remote store. Only kernel-mode callers can set this bit. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native file_attributes /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS = 0x00400000; +constexpr int32_t FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS = 0x00400000; #endif diff --git a/src/xtd.core.native/include/xtd/native/file_permission.h b/src/xtd.core.native/include/xtd/native/file_permission.h index 4b1e59b6ed2..aece6018d1d 100644 --- a/src/xtd.core.native/include/xtd/native/file_permission.h +++ b/src/xtd.core.native/include/xtd/native/file_permission.h @@ -17,30 +17,30 @@ /// @ingroup xtd_core_native console_color /// @remarks Added specificALLy for xtd. /// @warning Internal use only -constexpr int_least32_t FILE_PERMISSIONS_NONE = 0; +constexpr int32_t FILE_PERMISSIONS_NONE = 0; -constexpr int_least32_t FILE_PERMISSIONS_OWNER_READ = 0400; -constexpr int_least32_t FILE_PERMISSIONS_OWNER_WRITE = 0200; -constexpr int_least32_t FILE_PERMISSIONS_OWNER_EXECUTE = 0100; -constexpr int_least32_t FILE_PERMISSIONS_OWNER_ALL = FILE_PERMISSIONS_OWNER_READ | FILE_PERMISSIONS_OWNER_WRITE | FILE_PERMISSIONS_OWNER_EXECUTE; +constexpr int32_t FILE_PERMISSIONS_OWNER_READ = 0400; +constexpr int32_t FILE_PERMISSIONS_OWNER_WRITE = 0200; +constexpr int32_t FILE_PERMISSIONS_OWNER_EXECUTE = 0100; +constexpr int32_t FILE_PERMISSIONS_OWNER_ALL = FILE_PERMISSIONS_OWNER_READ | FILE_PERMISSIONS_OWNER_WRITE | FILE_PERMISSIONS_OWNER_EXECUTE; -constexpr int_least32_t FILE_PERMISSIONS_GROUP_READ = 040; -constexpr int_least32_t FILE_PERMISSIONS_GROUP_WRITE = 020; -constexpr int_least32_t FILE_PERMISSIONS_GROUP_EXECUTE = 010; -constexpr int_least32_t FILE_PERMISSIONS_GROUP_ALL = FILE_PERMISSIONS_GROUP_READ | FILE_PERMISSIONS_GROUP_WRITE | FILE_PERMISSIONS_GROUP_EXECUTE; +constexpr int32_t FILE_PERMISSIONS_GROUP_READ = 040; +constexpr int32_t FILE_PERMISSIONS_GROUP_WRITE = 020; +constexpr int32_t FILE_PERMISSIONS_GROUP_EXECUTE = 010; +constexpr int32_t FILE_PERMISSIONS_GROUP_ALL = FILE_PERMISSIONS_GROUP_READ | FILE_PERMISSIONS_GROUP_WRITE | FILE_PERMISSIONS_GROUP_EXECUTE; -constexpr int_least32_t FILE_PERMISSIONS_OTHERS_READ = 04; -constexpr int_least32_t FILE_PERMISSIONS_OTHERS_WRITE = 02; -constexpr int_least32_t FILE_PERMISSIONS_OTHERS_EXECUTE = 01; -constexpr int_least32_t FILE_PERMISSIONS_OTHERS_ALL = FILE_PERMISSIONS_OTHERS_READ | FILE_PERMISSIONS_OTHERS_WRITE | FILE_PERMISSIONS_OTHERS_EXECUTE; +constexpr int32_t FILE_PERMISSIONS_OTHERS_READ = 04; +constexpr int32_t FILE_PERMISSIONS_OTHERS_WRITE = 02; +constexpr int32_t FILE_PERMISSIONS_OTHERS_EXECUTE = 01; +constexpr int32_t FILE_PERMISSIONS_OTHERS_ALL = FILE_PERMISSIONS_OTHERS_READ | FILE_PERMISSIONS_OTHERS_WRITE | FILE_PERMISSIONS_OTHERS_EXECUTE; -constexpr int_least32_t FILE_PERMISSIONS_ALL = FILE_PERMISSIONS_OWNER_ALL | FILE_PERMISSIONS_GROUP_ALL | FILE_PERMISSIONS_OTHERS_ALL; +constexpr int32_t FILE_PERMISSIONS_ALL = FILE_PERMISSIONS_OWNER_ALL | FILE_PERMISSIONS_GROUP_ALL | FILE_PERMISSIONS_OTHERS_ALL; -constexpr int_least32_t FILE_PERMISSIONS_SET_UID = 04000; -constexpr int_least32_t FILE_PERMISSIONS_SET_GID = 02000; -constexpr int_least32_t FILE_PERMISSIONS_STICKY_BIT = 01000; +constexpr int32_t FILE_PERMISSIONS_SET_UID = 04000; +constexpr int32_t FILE_PERMISSIONS_SET_GID = 02000; +constexpr int32_t FILE_PERMISSIONS_STICKY_BIT = 01000; -constexpr int_least32_t FILE_PERMISSIONS_MASK = 07777; +constexpr int32_t FILE_PERMISSIONS_MASK = 07777; -constexpr int_least32_t FILE_PERMISSIONS_UNKNOWN = 0xFFFF; +constexpr int32_t FILE_PERMISSIONS_UNKNOWN = 0xFFFF; diff --git a/src/xtd.core.native/include/xtd/native/file_system.h b/src/xtd.core.native/include/xtd/native/file_system.h index bc68717689a..137dcbc0ad5 100644 --- a/src/xtd.core.native/include/xtd/native/file_system.h +++ b/src/xtd.core.native/include/xtd/native/file_system.h @@ -66,7 +66,7 @@ namespace xtd { /// @param attribute The file or path attribute. (see file_attribute.h) /// @return 0 if success; otherwise failed. /// @warning Internal use only - static int_least32_t get_attributes(const std::string& path, int_least32_t& attributes); + static int32_t get_attributes(const std::string& path, int32_t& attributes); /// @brief Gets file creeation time, last access time and lastt write time of specified path. /// @param path The relative or absolute path to the directory to get times. /// @param creation_time That contains the creation time. @@ -74,7 +74,7 @@ namespace xtd { /// @param last_write_time That contains the last write time. /// @return 0 if success; otherwise failed. /// @warning Internal use only - static int_least32_t get_file_times(const std::string& path, time_t& creation_time, time_t& last_access_time, time_t& last_write_time); + static int32_t get_file_times(const std::string& path, time_t& creation_time, time_t& last_access_time, time_t& last_write_time); /// @brief Gets full path of specified path. /// @param relative_path The relative path to the directory to search. /// @return The fulll path. @@ -90,37 +90,37 @@ namespace xtd { /// @param attribute The file or path attribute. (see file_attribute.h) /// @return 0 if success; -1 operation is not supported; otherwise failed. /// @warning Internal use only - static int_least32_t set_attributes(const std::string& path, int_least32_t attributes); + static int32_t set_attributes(const std::string& path, int32_t attributes); /// @brief Sets the creation time for the specified file or directory path. /// @param path The relative or absolute path to the directory to get attribute. /// @param creation_time The file or path creation time. /// @return 0 if success; -1 operation is not supported; otherwise failed. /// @warning Internal use only - static int_least32_t set_creation_time(const std::string& path, time_t creation_time); + static int32_t set_creation_time(const std::string& path, time_t creation_time); /// @brief Sets the last access time for the specified file or directory path. /// @param path The relative or absolute path to the directory to get attribute. /// @param last_access_time The file or path last access time. /// @return 0 if success; -1 operation is not supported; otherwise failed. /// @warning Internal use only - static int_least32_t set_last_access_time(const std::string& path, time_t last_access_time); + static int32_t set_last_access_time(const std::string& path, time_t last_access_time); /// @brief Sets the last write time for the specified file or directory path. /// @param path The relative or absolute path to the directory to get attribute. /// @param last_write_time The file or path last write time. /// @return 0 if success; -1 operation is not supported; otherwise failed. /// @warning Internal use only - static int_least32_t set_last_write_time(const std::string& path, time_t last_write_time); + static int32_t set_last_write_time(const std::string& path, time_t last_write_time); /// @brief Gets the permissions for the specified file or directory path. /// @param path The relative or absolute path to the directory to get attribute. /// @param attribute The file or path permissions. (see file_permission.h) /// @return 0 if success; otherwise failed. /// @warning Internal use only - static int_least32_t get_permissions(const std::string& path, int_least32_t& permissions); + static int32_t get_permissions(const std::string& path, int32_t& permissions); /// @brief Sets the permissions for the specified file or directory path. /// @param path The relative or absolute path to the directory to get attribute. /// @param attribute The file or path permissions. (see file_permission.h) /// @return 0 if success; otherwise failed. /// @warning Internal use only - static int_least32_t set_permissions(const std::string& path, int_least32_t permissions); + static int32_t set_permissions(const std::string& path, int32_t permissions); /// @} }; } diff --git a/src/xtd.core.native/include/xtd/native/guid.h b/src/xtd.core.native/include/xtd/native/guid.h index 7560b9504ab..7bbdd80d901 100644 --- a/src/xtd.core.native/include/xtd/native/guid.h +++ b/src/xtd.core.native/include/xtd/native/guid.h @@ -44,7 +44,7 @@ namespace xtd { /// @return A 16-element byte array containing GUID. /// @remarks A GUID is a 128-bit integer (16 bytes) that can be used across all computers and networks wherever a unique identifier is required. Such an identifier has a very low probability of being duplicated. /// @warning Internal use only - static std::vector new_guid(); + static std::vector new_guid(); /// @} }; } diff --git a/src/xtd.core.native/include/xtd/native/interlocked.h b/src/xtd.core.native/include/xtd/native/interlocked.h index 01c2094f88e..254318edc22 100644 --- a/src/xtd.core.native/include/xtd/native/interlocked.h +++ b/src/xtd.core.native/include/xtd/native/interlocked.h @@ -50,15 +50,15 @@ namespace xtd { /// @brief Adds two 32-bit integers and replaces the first integer with the sum, as an atomic operation. /// @param location A variable containing the first value to be added. The sum of the two values is stored in location. /// @param value The value to be added to the integer at location. - /// @return int_least32_t The new value stored at location. + /// @return int32_t The new value stored at location. /// @warning Internal use only - static int_least32_t add(int_least32_t& location, int_least32_t value); + static int32_t add(int32_t& location, int32_t value); /// @brief Adds two 64-bit integers and replaces the first integer with the sum, as an atomic operation. /// @param location A variable containing the first value to be added. The sum of the two values is stored in location. /// @param value The value to be added to the integer at location. - /// @return int_least64_t The new value stored at location. + /// @return int64_t The new value stored at location. /// @warning Internal use only - static int_least64_t add(int_least64_t& location, int_least64_t value); + static int64_t add(int64_t& location, int64_t value); /// @brief Compares two 32-bit signed integers for equality and, if they are equal, replaces one of the values. /// @param location The destination, whose value is compared with Comparand and possibly replaced. @@ -66,14 +66,14 @@ namespace xtd { /// @param Comparand The value that is compared to the value at location. /// @return The original value in location. /// @warning Internal use only - static int_least32_t compare_exchange(int_least32_t& location, int_least32_t value, int_least32_t comparand); + static int32_t compare_exchange(int32_t& location, int32_t value, int32_t comparand); /// @brief Compares two 64-bit signed integers for equality and, if they are equal, replaces one of the values. /// @param location The destination, whose value is compared with comparand and possibly replaced. /// @param value The value that replaces the destination value if the comparison results in equality. /// @param comparand The value that is compared to the value at location. /// @return The original value in location. /// @warning Internal use only - static int_least64_t compare_exchange(int_least64_t& location, int_least64_t value, int_least64_t comparand); + static int64_t compare_exchange(int64_t& location, int64_t value, int64_t comparand); /// @brief Compares two __slong__ signed integers for equality and, if they are equal, replaces one of the values. /// @param location The destination, whose value is compared with comparand and possibly replaced. /// @param value The value that replaces the destination value if the comparison results in equality. @@ -93,25 +93,25 @@ namespace xtd { /// @param location The variable whose value is to be decremented. /// @return The decremented value. /// @warning Internal use only - static int_least32_t decrement(int_least32_t& location); + static int32_t decrement(int32_t& location); /// @brief Decrements a specified variable and stores the result, as an atomic operation. /// @param location The variable whose value is to be decremented. /// @return The decremented value. /// @warning Internal use only - static int_least64_t decrement(int_least64_t& location); + static int64_t decrement(int64_t& location); /// @brief Sets a 32-bit signed integer to a specified value and returns the original value, as an atomic operation. /// @param location The variable to set to the specified value. /// @param value The value to which the location parameter is set. /// @return The original value of location. /// @warning Internal use only - static int_least32_t exchange(int_least32_t& location, int_least32_t value); + static int32_t exchange(int32_t& location, int32_t value); /// @brief Sets a 64-bit signed integer to a specified value and returns the original value, as an atomic operation. /// @param location The variable to set to the specified value. /// @param value The value to which the location parameter is set. /// @return The original value of location. /// @warning Internal use only - static int_least64_t exchange(int_least64_t& location, int_least64_t value); + static int64_t exchange(int64_t& location, int64_t value); /// @brief Sets a __slong__ signed integer to a specified value and returns the original value, as an atomic operation. /// @param location The variable to set to the specified value. /// @param value The value to which the location parameter is set. @@ -129,12 +129,12 @@ namespace xtd { /// @param location The variable whose value is to be incremented. /// @return The incremented value. /// @warning Internal use only - static int_least32_t increment(int_least32_t& location); + static int32_t increment(int32_t& location); /// @brief Increments a specified variable and stores the result, as an atomic operation. /// @param location The variable whose value is to be incremented. /// @return The incremented value. /// @warning Internal use only - static int_least64_t increment(int_least64_t& location); + static int64_t increment(int64_t& location); /// @} }; } diff --git a/src/xtd.core.native/include/xtd/native/named_event_wait_handle.h b/src/xtd.core.native/include/xtd/native/named_event_wait_handle.h index b0f16d21909..ba516baf330 100644 --- a/src/xtd.core.native/include/xtd/native/named_event_wait_handle.h +++ b/src/xtd.core.native/include/xtd/native/named_event_wait_handle.h @@ -85,7 +85,7 @@ namespace xtd { /// * 0x00000102 : Timeout /// * 0xFFFFFFFF : Failed /// @warning Internal use only - static uint_least32_t wait(intmax_t handle, int_least32_t milliseconds_timeout, bool manual_reset); + static uint32_t wait(intmax_t handle, int32_t milliseconds_timeout, bool manual_reset); /// @} }; } diff --git a/src/xtd.core.native/include/xtd/native/named_mutex.h b/src/xtd.core.native/include/xtd/native/named_mutex.h index 663b9144f14..dcaa2cfe08f 100644 --- a/src/xtd.core.native/include/xtd/native/named_mutex.h +++ b/src/xtd.core.native/include/xtd/native/named_mutex.h @@ -77,7 +77,7 @@ namespace xtd { /// * 0x00000102 : Timeout /// * 0xFFFFFFFF : Failed /// @warning Internal use only - static uint_least32_t wait(intmax_t handle, int_least32_t milliseconds_timeout); + static uint32_t wait(intmax_t handle, int32_t milliseconds_timeout); /// @} }; } diff --git a/src/xtd.core.native/include/xtd/native/named_semaphore.h b/src/xtd.core.native/include/xtd/native/named_semaphore.h index 87a2fbc3662..4b62b51e001 100644 --- a/src/xtd.core.native/include/xtd/native/named_semaphore.h +++ b/src/xtd.core.native/include/xtd/native/named_semaphore.h @@ -42,7 +42,7 @@ namespace xtd { /// @param name The name, if the synchronization object is to be shared with other processes. /// @return The handle of the created semaphore. /// @warning Internal use only - static intmax_t create(int_least32_t initial_count, int_least32_t max_count, const std::string& name); + static intmax_t create(int32_t initial_count, int32_t max_count, const std::string& name); /// @brief Destroy named semaphore with specified semaphore handle. /// @param name The name of the semaphore. @@ -65,7 +65,7 @@ namespace xtd { /// @param handle The semaphore handle to signal. /// @return true if succeed; otherwhise false. /// @warning Internal use only - static bool signal(intmax_t handle, int_least32_t release_count, int_least32_t& previous_count, bool& io_error); + static bool signal(intmax_t handle, int32_t release_count, int32_t& previous_count, bool& io_error); /// @brief Wait named semaphore with specified semaphore handle and timeout. /// @param handle The semaphore handle to wait. @@ -76,7 +76,7 @@ namespace xtd { /// * 0x00000102 : Timeout /// * 0xFFFFFFFF : Failed /// @warning Internal use only - static uint_least32_t wait(intmax_t handle, int_least32_t milliseconds_timeout); + static uint32_t wait(intmax_t handle, int32_t milliseconds_timeout); /// @} }; } diff --git a/src/xtd.core.native/include/xtd/native/platform_ids.h b/src/xtd.core.native/include/xtd/native/platform_ids.h index fc21e035fcb..80398130ef8 100644 --- a/src/xtd.core.native/include/xtd/native/platform_ids.h +++ b/src/xtd.core.native/include/xtd/native/platform_ids.h @@ -17,123 +17,123 @@ /// @ingroup xtd_core_native platform_id /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t PLATFORM_UNKNOWN = -1; +constexpr int32_t PLATFORM_UNKNOWN = -1; /// @brief The operating system is Win32s. Win32s is a layer that runs on 16-bit versions of Windows to provide access to 32-bit applications. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native platform_id /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t PLATFORM_WIN32S = 0; +constexpr int32_t PLATFORM_WIN32S = 0; /// @brief The operating system is Windows 95 or Windows 98. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native platform_id /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t PLATFORM_WIN32_WINDOWS = 1; +constexpr int32_t PLATFORM_WIN32_WINDOWS = 1; /// @brief The operating system is Windows NT or later. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native platform_id /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t PLATFORM_WIN32_NT = 2; +constexpr int32_t PLATFORM_WIN32_NT = 2; /// @brief The operating system is Windows CE. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native platform_id /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t PLATFORM_WIN_CE = 3; +constexpr int32_t PLATFORM_WIN_CE = 3; /// @brief The operating system is Unix. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native platform_id /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t PLATFORM_UNIX = 4; +constexpr int32_t PLATFORM_UNIX = 4; /// @brief The development platform is Xbox 360. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native platform_id /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t PLATFORM_WBOX = 5; +constexpr int32_t PLATFORM_WBOX = 5; /// @brief The operating system is Macintosh. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native platform_id /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t PLATFORM_MACOS = 6; +constexpr int32_t PLATFORM_MACOS = 6; /// @brief The operating system is IOs Apple. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native platform_id /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t PLATFORM_IOS = 7; +constexpr int32_t PLATFORM_IOS = 7; /// @brief The operating system is Android. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native platform_id /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t PLATFORM_ANDROID = 8; +constexpr int32_t PLATFORM_ANDROID = 8; /// @brief The operating system is linux. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native platform_id /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t PLATFORM_LINUX = 9; +constexpr int32_t PLATFORM_LINUX = 9; /// @brief The operating system is tvOS Apple. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native platform_id /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t PLATFORM_TVOS = 10; +constexpr int32_t PLATFORM_TVOS = 10; /// @brief The operating system is watchOS Apple. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native platform_id /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t PLATFORM_WATCHOS = 11; +constexpr int32_t PLATFORM_WATCHOS = 11; /// @brief The operating system is FreeBSD. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native platform_id /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t PLATFORM_FREEBSD = 12; +constexpr int32_t PLATFORM_FREEBSD = 12; /// @brief The operating system is MINGW. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native platform_id /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t PLATFORM_MINGW = 13; +constexpr int32_t PLATFORM_MINGW = 13; /// @brief The operating system is MSYS. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native platform_id /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t PLATFORM_MSYS = 14; +constexpr int32_t PLATFORM_MSYS = 14; /// @brief The operating system is Posix. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native platform_id /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t PLATFORM_POSIX = 15; +constexpr int32_t PLATFORM_POSIX = 15; /// @brief The operating system is other. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native platform_id /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t PLATFORM_OTHER = 32767; +constexpr int32_t PLATFORM_OTHER = 32767; diff --git a/src/xtd.core.native/include/xtd/native/priority_class.h b/src/xtd.core.native/include/xtd/native/priority_class.h index fa7b667e15a..2c264c82a0a 100644 --- a/src/xtd.core.native/include/xtd/native/priority_class.h +++ b/src/xtd.core.native/include/xtd/native/priority_class.h @@ -18,40 +18,40 @@ /// @ingroup xtd_core_native ppc /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t NORMAL_PRIORITY_CLASS = 0x00000020; +constexpr int32_t NORMAL_PRIORITY_CLASS = 0x00000020; /// @brief Process whose threads run only when the system is idle and are preempted by the threads of any process running in a higher priority class. An example is a screen saver. The idle priority class is inherited by child processes. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native ppc /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t IDLE_PRIORITY_CLASS = 0x00000040; +constexpr int32_t IDLE_PRIORITY_CLASS = 0x00000040; /// @brief Process that performs time-critical tasks that must be executed immediately for it to run correctly. The threads of a high-priority class process preempt the threads of normal or idle priority class processes. An example is the Task List, which must respond quickly when called by the user, regardless of the load on the operating system. Use extreme care when using the high-priority class, because a high-priority class CPU-bound application can use nearly all available cycles. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native ppc /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t HIGH_PRIORITY_CLASS = 0x00000080; +constexpr int32_t HIGH_PRIORITY_CLASS = 0x00000080; /// @brief Process that has the highest possible priority. The threads of a real-time priority class process preempt the threads of all other processes, including operating system processes performing important tasks. For example, a real-time process that executes for more than a very brief interval can cause disk caches not to flush or cause the mouse to be unresponsive. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native ppc /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t REALTIME_PRIORITY_CLASS = 0x00000100; +constexpr int32_t REALTIME_PRIORITY_CLASS = 0x00000100; /// @brief Process that has priority above IDLE_PRIORITY_CLASS but below NORMAL_PRIORITY_CLASS. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native ppc /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t BELOW_NORMAL_PRIORITY_CLASS = 0x00004000; +constexpr int32_t BELOW_NORMAL_PRIORITY_CLASS = 0x00004000; /// @brief Process that has priority above NORMAL_PRIORITY_CLASS but below HIGH_PRIORITY_CLASS. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native ppc /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t ABOVE_NORMAL_PRIORITY_CLASS = 0x00008000; +constexpr int32_t ABOVE_NORMAL_PRIORITY_CLASS = 0x00008000; #endif diff --git a/src/xtd.core.native/include/xtd/native/process.h b/src/xtd.core.native/include/xtd/native/process.h index 5d0be97ae89..6ce5855f37f 100644 --- a/src/xtd.core.native/include/xtd/native/process.h +++ b/src/xtd.core.native/include/xtd/native/process.h @@ -50,7 +50,7 @@ namespace xtd { /// * [2] : The created ostream for the standard input. /// * [3] : The created istream for the standard output. /// * [4] : The created istream for the standard error. - using started_process = std::tuple, std::unique_ptr, std::unique_ptr>; + using started_process = std::tuple, std::unique_ptr, std::unique_ptr>; /// @} /// @name Protected Static Methods @@ -68,7 +68,7 @@ namespace xtd { /// | 10 | PRIO_MAX - (PRIO_MAX - PRIO_MIN) / 4 (10) | PRIO_MAX - (PRIO_MAX - PRIO_MIN) / 4 (10) | ABOVE_NORMAL_PRIORITY_CLASS | /// | 13 | PRIO_MAX - (PRIO_MAX - PRIO_MIN) / 8 (15) | PRIO_MAX - (PRIO_MAX - PRIO_MIN) / 8 (15) | HIGH_PRIORITY_CLASS | /// | 24 | PRIO_MAX (20) | PRIO_MAX (20) | REALTIME_PRIORITY_CLASS | - static int_least32_t base_priority(int_least32_t priority); + static int32_t base_priority(int32_t priority); /// @brief Kill process. /// @param process The process handle to kill. /// @return true if succeed; otherwise false. @@ -79,7 +79,7 @@ namespace xtd { /// @param priority The priority category for the associated process, from which the base_priority of the process is calculated. (see priority_class.h file). /// @return true if succeed; otherwise false. /// @warning Internal use only - static bool priority_class(intmax_t process, int_least32_t priority); + static bool priority_class(intmax_t process, int32_t priority); /// @brief Creates a process with specified file name, specified arguments, specified working directory, specified process creation flags, and specified process window style. /// @param file_name the name of the application file to run in process launched by the shell execute. /// @param arguments Command-line arguments to pass when starting the process. @@ -87,7 +87,7 @@ namespace xtd { /// @param process_window_style One of the values that indicates whether the process is started in a window that is maximized, minimized, normal (neither maximized nor minimized), or not visible. The default is Normal. (see process_window_window_style.h file). /// @return The created process handle. /// @warning Internal use only - static intmax_t shell_execute(const std::string& verb, const std::string& file_name, const std::string& arguments, const std::string& working_directory, int_least32_t process_window_style); + static intmax_t shell_execute(const std::string& verb, const std::string& file_name, const std::string& arguments, const std::string& working_directory, int32_t process_window_style); /// @brief Starts a process with specified file name, specified arguments, specified working directory, specified process window style, specified process creation flags, and specified boolean tuples that represent redirect standard streams. /// @param file_name the name of the application file to run in the process. /// @param arguments Command-line arguments to pass when starting the process. @@ -100,13 +100,13 @@ namespace xtd { /// * [2] : true if input should be written to standard_error; otherwise, false. The default is false. /// @return A process::started_process that contains the created process handle, id and created standard streams. /// @warning Internal use only - static started_process start(const std::string& file_name, const std::string& arguments, const std::string& working_directory, int_least32_t process_window_style, int_least32_t process_creation_flags, std::tuple redirect_standard_streams); + static started_process start(const std::string& file_name, const std::string& arguments, const std::string& working_directory, int32_t process_window_style, int32_t process_creation_flags, std::tuple redirect_standard_streams); /// @brief Wait process and close handles. /// @param process The process handle to wait. /// @param exit Receives the process exit code. /// @return true if succeed; otherwise false. /// @warning Internal use only - static bool wait(intmax_t process, int_least32_t& exit_code); + static bool wait(intmax_t process, int32_t& exit_code); /// @} }; } diff --git a/src/xtd.core.native/include/xtd/native/process_creation_flags.h b/src/xtd.core.native/include/xtd/native/process_creation_flags.h index dfc66a420ef..715528f362a 100644 --- a/src/xtd.core.native/include/xtd/native/process_creation_flags.h +++ b/src/xtd.core.native/include/xtd/native/process_creation_flags.h @@ -18,117 +18,117 @@ /// @ingroup xtd_core_native pcf /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t DEBUG_PROCESS = 0x00000001; +constexpr int32_t DEBUG_PROCESS = 0x00000001; /// @brief The calling thread starts and debugs the new process. It can receive all related debug events using the WaitForDebugEvent function. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native pcf /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t DEBUG_ONLY_THIS_PROCESS = 0x00000002; +constexpr int32_t DEBUG_ONLY_THIS_PROCESS = 0x00000002; /// @brief The primary thread of the new process is created in a suspended state, and does not run until the ResumeThread function is called. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native pcf /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t CREATE_SUSPENDED = 0x00000004; +constexpr int32_t CREATE_SUSPENDED = 0x00000004; /// @brief For console processes, the new process does not inherit its parent's console (the default). The new process can call the AllocConsole function at a later time to create a console. For more information, see Creation of a Console. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native pcf /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t DETACHED_PROCESS = 0x00000008; +constexpr int32_t DETACHED_PROCESS = 0x00000008; /// @brief The new process has a new console, instead of inheriting its parent's console (the default). For more information, see Creation of a Console. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native pcf /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t CREATE_NEW_CONSOLE = 0x00000010; +constexpr int32_t CREATE_NEW_CONSOLE = 0x00000010; /// @brief The new process is the root process of a new process group. The process group includes all processes that are descendants of this root process. The process identifier of the new process group is the same as the process identifier, which is returned in the lpProcessInformation parameter. Process groups are used by the GenerateConsoleCtrlEvent function to enable sending a CTRL+BREAK signal to a group of console processes. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native pcf /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t CREATE_NEW_PROCESS_GROUP = 0x00000200; +constexpr int32_t CREATE_NEW_PROCESS_GROUP = 0x00000200; /// @brief If this flag is set, the environment block pointed to by lpEnvironment uses Unicode characters. Otherwise, the environment block uses ANSI characters. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native pcf /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t CREATE_UNICODE_ENVIRONMENT = 0x00000400; +constexpr int32_t CREATE_UNICODE_ENVIRONMENT = 0x00000400; /// @brief This flag is valid only when starting a 16-bit Windows-based application. If set, the new process runs in a private Virtual DOS Machine (VDM). By default, all 16-bit Windows-based applications run as threads in a single, shared VDM. The advantage of running separately is that a crash only terminates the single VDM; any other programs running in distinct VDMs continue to function normally. Also, 16-bit Windows-based applications that are run in separate VDMs have separate input queues. That means that if one application stops responding momentarily, applications in separate VDMs continue to receive input. The disadvantage of running separately is that it takes significantly more memory to do so. You should use this flag only if the user requests that 16-bit applications should run in their own VDM. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native pcf /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t CREATE_SEPARATE_WOW_VDM = 0x00000800; +constexpr int32_t CREATE_SEPARATE_WOW_VDM = 0x00000800; /// @brief The flag is valid only when starting a 16-bit Windows-based application. If the /// @par Library /// xtd.core.native /// @ingroup xtd_core_native pcf /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t CREATE_SHARED_WOW_VDM = 0x00001000; +constexpr int32_t CREATE_SHARED_WOW_VDM = 0x00001000; /// @brief The process inherits its parent's affinity. If the parent process has threads in more than one processor group, the new process inherits the group-relative affinity of an arbitrary group in use by the parent. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native pcf /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t INHERIT_PARENT_AFFINITY = 0x00010000; +constexpr int32_t INHERIT_PARENT_AFFINITY = 0x00010000; /// @brief The process is to be run as a protected process. The system restricts access to protected processes and the threads of protected processes. For more information on how processes can interact with protect /// @par Library /// xtd.core.native /// @ingroup xtd_core_native pcf /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t CREATE_PROTECTED_PROCESS = 0x00040000; +constexpr int32_t CREATE_PROTECTED_PROCESS = 0x00040000; /// @brief The process is created with extended startup information; the lpStartupInfo parameter specifies a STARTUPINFOEX structure. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native pcf /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t EXTENDED_STARTUPINFO_PRESENT = 0x00080000; +constexpr int32_t EXTENDED_STARTUPINFO_PRESENT = 0x00080000; /// @brief This flag allows secure processes, that run in the Virtualization-Based Security environment, to launch. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native pcf /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t CREATE_SECURE_PROCESS = 0x00400000; +constexpr int32_t CREATE_SECURE_PROCESS = 0x00400000; /// @brief The child processes of a process associated with a job are not associated with the job. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native pcf /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t CREATE_BREAKAWAY_FROM_JOB = 0x01000000; +constexpr int32_t CREATE_BREAKAWAY_FROM_JOB = 0x01000000; /// @brief Allows the caller to execute a child process that bypasses the process restrictions that would normally be applied automatically to the process. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native pcf /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t CREATE_PRESERVE_CODE_AUTHZ_LEVEL = 0x02000000; +constexpr int32_t CREATE_PRESERVE_CODE_AUTHZ_LEVEL = 0x02000000; /// @brief The new process does not inherit the error mode of the calling process. Instead, the new process gets the default error mode. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native pcf /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t CREATE_DEFAULT_ERROR_MODE = 0x04000000; +constexpr int32_t CREATE_DEFAULT_ERROR_MODE = 0x04000000; /// @brief The process is a console application that is being run without a console window. Therefore, the console handle for the application is not set. /// @par Library /// xtd.core.native /// @ingroup xtd_core_native pcf /// @remarks For more info see https://docs.microsoft.com . /// @warning Internal use only -constexpr int_least32_t CREATE_NO_WINDOW = 0x08000000; +constexpr int32_t CREATE_NO_WINDOW = 0x08000000; #endif diff --git a/src/xtd.core.native/include/xtd/native/process_window_style.h b/src/xtd.core.native/include/xtd/native/process_window_style.h index b1c077e501c..4c72d0130d2 100644 --- a/src/xtd.core.native/include/xtd/native/process_window_style.h +++ b/src/xtd.core.native/include/xtd/native/process_window_style.h @@ -17,7 +17,7 @@ /// @ingroup xtd_core_native pws /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t PROCESS_WINDOW_STYLE_NORMAL = 0; +constexpr int32_t PROCESS_WINDOW_STYLE_NORMAL = 0; /// @brief The hidden window style. A window can be either visible or hidden. The system displays a hidden window by not drawing it. If a window is hidden, it is effectively disabled. A hidden window can process messages from the system or from other windows, but it cannot process input from the user or display output. Frequently, an application may keep a new window hidden while it customizes the window's appearance, and then make the window style Normal. To use process_window_style.Hidden, the ProcessStartInfo.UseShellExecute property must be false. /// @par Library @@ -25,7 +25,7 @@ constexpr int_least32_t PROCESS_WINDOW_STYLE_NORMAL = 0; /// @ingroup xtd_core_native pws /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t PROCESS_WINDOW_STYLE_HIDDEN = 1; +constexpr int32_t PROCESS_WINDOW_STYLE_HIDDEN = 1; /// @brief The minimized window style. By default, the system reduces a minimized window to the size of its taskbar button and moves the minimized window to the taskbar. /// @par Library @@ -33,7 +33,7 @@ constexpr int_least32_t PROCESS_WINDOW_STYLE_HIDDEN = 1; /// @ingroup xtd_core_native pws /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t PROCESS_WINDOW_STYLE_MINIMIZED = 2; +constexpr int32_t PROCESS_WINDOW_STYLE_MINIMIZED = 2; /// @brief The maximized window style. By default, the system enlarges a maximized window so that it fills the screen or, in the case of a child window, the parent window's client area. If the window has a title bar, the system automatically moves it to the top of the screen or to the top of the parent window's client area. Also, the system disables the window's sizing border and the window-positioning capability of the title bar so that the user cannot move the window by dragging the title bar. /// @par Library @@ -41,4 +41,4 @@ constexpr int_least32_t PROCESS_WINDOW_STYLE_MINIMIZED = 2; /// @ingroup xtd_core_native pws /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t PROCESS_WINDOW_STYLE_MAXIMIZED = 3; +constexpr int32_t PROCESS_WINDOW_STYLE_MAXIMIZED = 3; diff --git a/src/xtd.core.native/include/xtd/native/protocol_type_constants.h b/src/xtd.core.native/include/xtd/native/protocol_type_constants.h index 576282737e1..0b19168c416 100644 --- a/src/xtd.core.native/include/xtd/native/protocol_type_constants.h +++ b/src/xtd.core.native/include/xtd/native/protocol_type_constants.h @@ -16,7 +16,7 @@ /// @ingroup xtd_core_native protocol_type /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t PROTOCOL_TYPE_UNKNOWN = -1; +constexpr int32_t PROTOCOL_TYPE_UNKNOWN = -1; /// @brief IPv6 Hop by Hop Options header. /// @par Library @@ -24,7 +24,7 @@ constexpr int_least32_t PROTOCOL_TYPE_UNKNOWN = -1; /// @ingroup xtd_core_native protocol_type /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t PROTOCOL_TYPE_IP_V6_HOP_BY_HOP_OPTIONS = 0; +constexpr int32_t PROTOCOL_TYPE_IP_V6_HOP_BY_HOP_OPTIONS = 0; /// @brief Unspecified Protocol. /// @par Library @@ -32,7 +32,7 @@ constexpr int_least32_t PROTOCOL_TYPE_IP_V6_HOP_BY_HOP_OPTIONS = 0; /// @ingroup xtd_core_native protocol_type /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t PROTOCOL_TYPE_UNSPECIFIED = 0; +constexpr int32_t PROTOCOL_TYPE_UNSPECIFIED = 0; /// @brief Internet Protocol. /// @par Library @@ -40,7 +40,7 @@ constexpr int_least32_t PROTOCOL_TYPE_UNSPECIFIED = 0; /// @ingroup xtd_core_native protocol_type /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t PROTOCOL_TYPE_IP = 0; +constexpr int32_t PROTOCOL_TYPE_IP = 0; /// @brief Internet Control Message Protocol. /// @par Library @@ -48,7 +48,7 @@ constexpr int_least32_t PROTOCOL_TYPE_IP = 0; /// @ingroup xtd_core_native protocol_type /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t PROTOCOL_TYPE_ICMP = 1; +constexpr int32_t PROTOCOL_TYPE_ICMP = 1; /// @brief Internet Group Management Protocol. /// @par Library @@ -56,7 +56,7 @@ constexpr int_least32_t PROTOCOL_TYPE_ICMP = 1; /// @ingroup xtd_core_native protocol_type /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t PROTOCOL_TYPE_IGMP = 2; +constexpr int32_t PROTOCOL_TYPE_IGMP = 2; /// @brief Gateway To Gateway Protocol. /// @par Library @@ -64,7 +64,7 @@ constexpr int_least32_t PROTOCOL_TYPE_IGMP = 2; /// @ingroup xtd_core_native protocol_type /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t PROTOCOL_TYPE_GGP = 3; +constexpr int32_t PROTOCOL_TYPE_GGP = 3; /// @brief Internet Protocol version 4. /// @par Library @@ -72,7 +72,7 @@ constexpr int_least32_t PROTOCOL_TYPE_GGP = 3; /// @ingroup xtd_core_native protocol_type /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t PROTOCOL_TYPE_IP_V4 = 4; +constexpr int32_t PROTOCOL_TYPE_IP_V4 = 4; /// @brief Transmission Control Protocol. /// @par Library @@ -80,7 +80,7 @@ constexpr int_least32_t PROTOCOL_TYPE_IP_V4 = 4; /// @ingroup xtd_core_native protocol_type /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t PROTOCOL_TYPE_TCP = 6; +constexpr int32_t PROTOCOL_TYPE_TCP = 6; /// @brief PARC Universal Packet Protocol. /// @par Library @@ -88,7 +88,7 @@ constexpr int_least32_t PROTOCOL_TYPE_TCP = 6; /// @ingroup xtd_core_native protocol_type /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t PROTOCOL_TYPE_PUP = 12; +constexpr int32_t PROTOCOL_TYPE_PUP = 12; /// @brief User Datagram Protocol. /// @par Library @@ -96,7 +96,7 @@ constexpr int_least32_t PROTOCOL_TYPE_PUP = 12; /// @ingroup xtd_core_native protocol_type /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t PROTOCOL_TYPE_UDP = 17; +constexpr int32_t PROTOCOL_TYPE_UDP = 17; /// @brief Internet Datagram Protocol. /// @par Library @@ -104,7 +104,7 @@ constexpr int_least32_t PROTOCOL_TYPE_UDP = 17; /// @ingroup xtd_core_native protocol_type /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t PROTOCOL_TYPE_IDP = 22; +constexpr int32_t PROTOCOL_TYPE_IDP = 22; /// @brief Internet Protocol version 6 (IPv6). /// @par Library @@ -112,7 +112,7 @@ constexpr int_least32_t PROTOCOL_TYPE_IDP = 22; /// @ingroup xtd_core_native protocol_type /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t PROTOCOL_TYPE_IP_V6 = 41; +constexpr int32_t PROTOCOL_TYPE_IP_V6 = 41; /// @brief IPv6 Routing header. /// @par Library @@ -120,7 +120,7 @@ constexpr int_least32_t PROTOCOL_TYPE_IP_V6 = 41; /// @ingroup xtd_core_native protocol_type /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t PROTOCOL_TYPE_IP_V6_ROUTING_HEADER = 43; +constexpr int32_t PROTOCOL_TYPE_IP_V6_ROUTING_HEADER = 43; /// @brief IPv6 Fragment header. /// @par Library @@ -128,7 +128,7 @@ constexpr int_least32_t PROTOCOL_TYPE_IP_V6_ROUTING_HEADER = 43; /// @ingroup xtd_core_native protocol_type /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t PROTOCOL_TYPE_IP_V6_FRAGMENT_HEADER = 44; +constexpr int32_t PROTOCOL_TYPE_IP_V6_FRAGMENT_HEADER = 44; /// @brief IPv6 Encapsulating Security Payload header. /// @par Library @@ -136,7 +136,7 @@ constexpr int_least32_t PROTOCOL_TYPE_IP_V6_FRAGMENT_HEADER = 44; /// @ingroup xtd_core_native protocol_type /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t PROTOCOL_TYPE_IP_SEC_ENCAPSULATING_SECURITY_PAYLOAD = 50; +constexpr int32_t PROTOCOL_TYPE_IP_SEC_ENCAPSULATING_SECURITY_PAYLOAD = 50; /// @brief IPv6 Authentication header. For details, see RFC 2292 section 2.2.1, available at http://www.ietf.org. /// @par Library @@ -144,7 +144,7 @@ constexpr int_least32_t PROTOCOL_TYPE_IP_SEC_ENCAPSULATING_SECURITY_PAYLOAD = 50 /// @ingroup xtd_core_native protocol_type /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t PROTOCOL_TYPE_IP_SEC_AUTHENTICATION_HEADER = 51; +constexpr int32_t PROTOCOL_TYPE_IP_SEC_AUTHENTICATION_HEADER = 51; /// @brief Internet Control Message Protocol for IPv6. /// @par Library @@ -152,7 +152,7 @@ constexpr int_least32_t PROTOCOL_TYPE_IP_SEC_AUTHENTICATION_HEADER = 51; /// @ingroup xtd_core_native protocol_type /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t PROTOCOL_TYPE_ICMP_V6 = 58; +constexpr int32_t PROTOCOL_TYPE_ICMP_V6 = 58; /// @brief IPv6 No next header. /// @par Library @@ -160,7 +160,7 @@ constexpr int_least32_t PROTOCOL_TYPE_ICMP_V6 = 58; /// @ingroup xtd_core_native protocol_type /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t PROTOCOL_TYPE_IP_V6_NO_NEXT_HEADER = 59; +constexpr int32_t PROTOCOL_TYPE_IP_V6_NO_NEXT_HEADER = 59; /// @brief IPv6 Destination Options header. /// @par Library @@ -168,7 +168,7 @@ constexpr int_least32_t PROTOCOL_TYPE_IP_V6_NO_NEXT_HEADER = 59; /// @ingroup xtd_core_native protocol_type /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t PROTOCOL_TYPE_IP_V6_DESTINATION_OPTIONS = 60; +constexpr int32_t PROTOCOL_TYPE_IP_V6_DESTINATION_OPTIONS = 60; /// @brief Net Disk Protocol (unofficial). /// @par Library @@ -176,7 +176,7 @@ constexpr int_least32_t PROTOCOL_TYPE_IP_V6_DESTINATION_OPTIONS = 60; /// @ingroup xtd_core_native protocol_type /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t PROTOCOL_TYPE_ND = 77; +constexpr int32_t PROTOCOL_TYPE_ND = 77; /// @brief Raw IP packet protocol. /// @par Library @@ -184,7 +184,7 @@ constexpr int_least32_t PROTOCOL_TYPE_ND = 77; /// @ingroup xtd_core_native protocol_type /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t PROTOCOL_TYPE_RAW = 255; +constexpr int32_t PROTOCOL_TYPE_RAW = 255; /// @brief Internet Packet Exchange Protocol. /// @par Library @@ -192,7 +192,7 @@ constexpr int_least32_t PROTOCOL_TYPE_RAW = 255; /// @ingroup xtd_core_native protocol_type /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t PROTOCOL_TYPE_IPX = 1000; +constexpr int32_t PROTOCOL_TYPE_IPX = 1000; /// @brief Sequenced Packet Exchange protocol. /// @par Library @@ -200,7 +200,7 @@ constexpr int_least32_t PROTOCOL_TYPE_IPX = 1000; /// @ingroup xtd_core_native protocol_type /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t PROTOCOL_TYPE_SPX = 1256; +constexpr int32_t PROTOCOL_TYPE_SPX = 1256; /// @brief Sequenced Packet Exchange version 2 protocol. /// @par Library @@ -208,4 +208,4 @@ constexpr int_least32_t PROTOCOL_TYPE_SPX = 1256; /// @ingroup xtd_core_native protocol_type /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t PROTOCOL_TYPE_SPX_2 = 1257; +constexpr int32_t PROTOCOL_TYPE_SPX_2 = 1257; diff --git a/src/xtd.core.native/include/xtd/native/select_mode_constants.h b/src/xtd.core.native/include/xtd/native/select_mode_constants.h index ba0b2a54b66..543c4e6a702 100644 --- a/src/xtd.core.native/include/xtd/native/select_mode_constants.h +++ b/src/xtd.core.native/include/xtd/native/select_mode_constants.h @@ -16,7 +16,7 @@ /// @ingroup xtd_core_native select_mode /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SELECT_MODE_READ = 0; +constexpr int32_t SELECT_MODE_READ = 0; /// @brief Write status mode. /// @par Library @@ -24,7 +24,7 @@ constexpr int_least32_t SELECT_MODE_READ = 0; /// @ingroup xtd_core_native select_mode /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SELECT_MODE_WRITE = 1; +constexpr int32_t SELECT_MODE_WRITE = 1; /// @brief Error status mode. /// @par Library @@ -32,4 +32,4 @@ constexpr int_least32_t SELECT_MODE_WRITE = 1; /// @ingroup xtd_core_native select_mode /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SELECT_MODE_ERROR = 2; +constexpr int32_t SELECT_MODE_ERROR = 2; diff --git a/src/xtd.core.native/include/xtd/native/socket.h b/src/xtd.core.native/include/xtd/native/socket.h index b283347772d..c9a2bd5fc94 100644 --- a/src/xtd.core.native/include/xtd/native/socket.h +++ b/src/xtd.core.native/include/xtd/native/socket.h @@ -50,23 +50,23 @@ namespace xtd { /// @brief Gets the native address family value corresponding to xtd address family. /// @return The native address family value corresponding to xtd address family (see address_family_constants.h). /// @warning Internal use only - static int_least32_t address_family_to_native(int_least32_t address_family); + static int32_t address_family_to_native(int32_t address_family); /// @brief Gets the xtd address family value corresponding to native address family. /// @return The xtd address family value corresponding to native address family (see address_family_constants.h). /// @warning Internal use only - static int_least32_t native_to_address_family(int_least32_t address_family); + static int32_t native_to_address_family(int32_t address_family); /// @brief Accepts a connection on a socket. /// @param handle The socket handle. /// @param socket_address A byte array socket address is a result parameter that is filled in with the address of the connecting entity, as known to the communications layer. /// @return The new socket handle created. /// @warning Internal use only - static intmax_t accept(intmax_t handle, std::vector& socket_address); + static intmax_t accept(intmax_t handle, std::vector& socket_address); /// @brief Binds a name to a socket. /// @param handle The socket handle. /// @param socket_address A byte array socket address to bind. /// @return Zero (0) if succeed; otherwise on error. /// @warning Internal use only - static int_least32_t bind(intmax_t handle, const std::vector& socket_address); + static int32_t bind(intmax_t handle, const std::vector& socket_address); /// @brief Cleanup the socket library. /// @warning Internal use only static void cleanup(); @@ -75,19 +75,19 @@ namespace xtd { /// @param socket_address A byte array socket address to connect. /// @return Zero (0) if succeed; otherwise on error. /// @warning Internal use only - static int_least32_t connect(intmax_t handle, const std::vector& socket_address); + static int32_t connect(intmax_t handle, const std::vector& socket_address); /// @brief Creates an endpoint for communication. /// @param address_family One of address family values (see address_family_constants.h). /// @param socket_type One of socket type values (see socket_type_constants.h). /// @param protocol_type One of protocol type values (see protocol_type_constants.h). /// @return The new socket handle created. /// @warning Internal use only - static intmax_t create(int_least32_t address_family, int_least32_t socket_type, int_least32_t protocol_type); + static intmax_t create(int32_t address_family, int32_t socket_type, int32_t protocol_type); /// @brief Destroys the socket. /// @param handle The socket handle. /// @return Zero (0) if succeed; otherwise on error. /// @warning Internal use only - static int_least32_t destroy(intmax_t handle); + static int32_t destroy(intmax_t handle); /// @brief Gets the amount of data that has been received from the network and is available to be read. /// @param handle The socket handle. /// @return The number of bytes of data received from the network and available to be read. @@ -97,7 +97,7 @@ namespace xtd { /// @brief Gets last error. /// @return One of socket error value (see socket_error_constants.h). /// @warning Internal use only - static int_least32_t get_last_error(); + static int32_t get_last_error(); /// @brief Indicates whether the underlying operating system and network adaptors support Internet Protocol version 4 (IPv4). /// @return bool true if the operating system and network adaptors support the IPv4 protocol; otherwise, false. /// @warning Internal use only @@ -114,7 +114,7 @@ namespace xtd { /// @param option_length The option size will contains the size of option value. /// @return Zero (0) if succeed; otherwise on error. /// @warning Internal use only - static int_least32_t get_raw_socket_option(intmax_t handle, int_least32_t socket_option_level, int_least32_t socket_option_name, intmax_t option, size_t& option_length); + static int32_t get_raw_socket_option(intmax_t handle, int32_t socket_option_level, int32_t socket_option_name, intmax_t option, size_t& option_length); /// @brief Gets options on socket. /// @param handle The socket handle. /// @param socket_option_level One of socket option level values (see socket_option_level_constants.h). @@ -123,14 +123,14 @@ namespace xtd { /// @param option_length The option size will contains the size of option value. /// @return Zero (0) if succeed; otherwise on error. /// @warning Internal use only - static int_least32_t get_socket_option(intmax_t handle, int_least32_t socket_option_level, int_least32_t socket_option_name, intmax_t option, size_t& option_length); + static int32_t get_socket_option(intmax_t handle, int32_t socket_option_level, int32_t socket_option_name, intmax_t option, size_t& option_length); /// @brief Gets linger option on socket. /// @param handle The socket handle. /// @param enabled Indicates whether to linger after the socket is closed.. /// @param linger_time The amount of time to remain connected after calling the socket close method if data remains to be sent. /// @return Zero (0) if succeed; otherwise on error. /// @warning Internal use only - static int_least32_t get_socket_linger_option(intmax_t handle, bool& enabled, uint_least32_t& linger_time); + static int32_t get_socket_linger_option(intmax_t handle, bool& enabled, uint32_t& linger_time); /// @brief Gets multicast option on socket. /// @param handle The socket handle. /// @param socket_option_name One of socket option name values (see socket_option_name_constants.h). @@ -138,7 +138,7 @@ namespace xtd { /// @param interface_index The interface index that is associated with a multicast group. /// @return Zero (0) if succeed; otherwise on error. /// @warning Internal use only - static int_least32_t get_socket_multicast_option(intmax_t handle, int_least32_t socket_option_name, uint_least32_t& multicast_address, uint_least32_t& interface_index); + static int32_t get_socket_multicast_option(intmax_t handle, int32_t socket_option_name, uint32_t& multicast_address, uint32_t& interface_index); /// @brief Gets IP v6 multicast option on socket. /// @param handle The socket handle. /// @param socket_option_name One of socket option name values (see socket_option_name_constants.h). @@ -146,7 +146,7 @@ namespace xtd { /// @param interface_index The interface index that is associated with a multicast group. /// @return Zero (0) if succeed; otherwise on error. /// @warning Internal use only - static int_least32_t get_socket_ip_v6_multicast_option(intmax_t handle, int_least32_t socket_option_name, std::vector& multicast_address, uint_least32_t& interface_index); + static int32_t get_socket_ip_v6_multicast_option(intmax_t handle, int32_t socket_option_name, std::vector& multicast_address, uint32_t& interface_index); /// @brief Sets low-level operating modes for the Socket using the IOControlCode enumeration to specify control codes. /// @param handle The socket handle. /// @param io_control A io control code value that specifies the control code of the operation to perform (see io_control_code_constants.h). @@ -154,20 +154,20 @@ namespace xtd { /// @param option_out_value An array of type byte that contains the output data returned by the operation. /// @return Zero (0) if succeed; otherwise on error. /// @warning Internal use only - static int_least32_t io_control(intmax_t handle, int_least32_t io_control, std::vector& option_in_value, std::vector& option_out_value); + static int32_t io_control(intmax_t handle, int32_t io_control, std::vector& option_in_value, std::vector& option_out_value); /// @brief Listens for connections on a socket. /// @param handle The socket handle. /// @param backlog The maximum length for the queue of pending connections. /// @return Zero (0) if succeed; otherwise on error. /// @warning Internal use only - static int_least32_t listen(intmax_t handle, size_t backlog); + static int32_t listen(intmax_t handle, size_t backlog); /// @brief Synchronous I/O multiplexing /// @param handle The socket handle. /// @param microseconds Timeout in microseconds. /// @param mode One of select mode value (see select_mode_constants.h). /// @return Zero (0) if succeed; otherwise on error. /// @warning Internal use only - static int_least32_t poll(intmax_t handle, int_least32_t microseconds, int_least32_t mode); + static int32_t poll(intmax_t handle, int32_t microseconds, int32_t mode); /// @brief Receives a message from a socket. /// @param handle The socket handle. /// @param buffer An array of type byte that is the storage location for the received data. @@ -176,7 +176,7 @@ namespace xtd { /// @param flags A bitwise combination of the socket flags values. (see socket_flags_constants.h) /// @return Zero (0) if succeed; otherwise on error. /// @warning Internal use only - static int_least32_t receive(intmax_t handle, std::vector& buffer, size_t offset, size_t size, int_least32_t flags); + static int32_t receive(intmax_t handle, std::vector& buffer, size_t offset, size_t size, int32_t flags); /// @brief Receives a message from a socket. /// @param handle The socket handle. /// @param buffer An array of type byte that is the storage location for the received data. @@ -186,7 +186,7 @@ namespace xtd { /// @param socket_address A byte array socket address to receive from. /// @return Zero (0) if succeed; otherwise on error. /// @warning Internal use only - static int_least32_t receive_from(intmax_t handle, std::vector& buffer, size_t offset, size_t size, int_least32_t flags, std::vector& socket_address); + static int32_t receive_from(intmax_t handle, std::vector& buffer, size_t offset, size_t size, int32_t flags, std::vector& socket_address); /// @brief Determines the status of one or more sockets. /// @param check_read An IList of Socket instances to check for readability. /// @param check_write An IList of Socket instances to check for writability. @@ -194,7 +194,7 @@ namespace xtd { /// @param microseconds The time-out value, in microseconds. A -1 value indicates an infinite time-out. /// @return Zero (0) if succeed; otherwise on error. /// @warning Internal use only - static int_least32_t select(std::vector& check_read, std::vector& check_write, std::vector& check_error, int_least32_t microseconds); + static int32_t select(std::vector& check_read, std::vector& check_write, std::vector& check_error, int32_t microseconds); /// @brief send a message from a socket. /// @param buffer An array of type Byte that contains the data to be sent. /// @param offset TThe position in the data buffer at which to begin sending data. @@ -202,7 +202,7 @@ namespace xtd { /// @param flags A bitwise combination of the socket flags values. (see socket_flags_constants.h) /// @return Zero (0) if succeed; otherwise on error. /// @warning Internal use only - static int_least32_t send(intmax_t handle, const std::vector& buffer, size_t offset, size_t size, int_least32_t flags); + static int32_t send(intmax_t handle, const std::vector& buffer, size_t offset, size_t size, int32_t flags); /// @brief send a message from a socket. /// @param handle The socket handle. /// @param buffer An array of type Byte that contains the data to be sent. @@ -212,13 +212,13 @@ namespace xtd { /// @param socket_address A byte array socket address to send to. /// @return Zero (0) if succeed; otherwise on error. /// @warning Internal use only - static int_least32_t send_to(intmax_t handle, const std::vector& buffer, size_t offset, size_t size, int_least32_t flags, const std::vector& socket_address); + static int32_t send_to(intmax_t handle, const std::vector& buffer, size_t offset, size_t size, int32_t flags, const std::vector& socket_address); /// @brief Sets a value that indicates whether the socket is in blocking mode. /// @param handle The socket handle. /// @param blocking bool true if the Socket will block; otherwise, false. The default is true /// @return Zero (0) if succeed; otherwise on error. /// @warning Internal use only - static int_least32_t set_blocking(intmax_t handle, bool blocking); + static int32_t set_blocking(intmax_t handle, bool blocking); /// @brief Sets options on socket. /// @param handle The socket handle. /// @param socket_option_level The platform-defined option name. @@ -227,7 +227,7 @@ namespace xtd { /// @param option_length Contains the option value size. /// @return Zero (0) if succeed; otherwise on error. /// @warning Internal use only - static int_least32_t set_raw_socket_option(intmax_t handle, int_least32_t socket_option_level, int_least32_t socket_option_name, intmax_t option, size_t option_length); + static int32_t set_raw_socket_option(intmax_t handle, int32_t socket_option_level, int32_t socket_option_name, intmax_t option, size_t option_length); /// @brief Sets options on socket. /// @param handle The socket handle. /// @param socket_option_level One of socket option level values (see socket_option_level_constants.h). @@ -236,14 +236,14 @@ namespace xtd { /// @param option_length Contains the option value size. /// @return Zero (0) if succeed; otherwise on error. /// @warning Internal use only - static int_least32_t set_socket_option(intmax_t handle, int_least32_t socket_option_level, int_least32_t socket_option_name, intmax_t option, size_t option_length); + static int32_t set_socket_option(intmax_t handle, int32_t socket_option_level, int32_t socket_option_name, intmax_t option, size_t option_length); /// @brief Sets linger option on socket. /// @param handle The socket handle. /// @param enabled Indicates whether to linger after the socket is closed.. /// @param linger_time The amount of time to remain connected after calling the socket close method if data remains to be sent. /// @return Zero (0) if succeed; otherwise on error. /// @warning Internal use only - static int_least32_t set_socket_linger_option(intmax_t handle, bool enabled, uint_least32_t linger_time); + static int32_t set_socket_linger_option(intmax_t handle, bool enabled, uint32_t linger_time); /// @brief Sets multicast option on socket. /// @param handle The socket handle. /// @param socket_option_name One of socket option name values (see socket_option_name_constants.h). @@ -251,7 +251,7 @@ namespace xtd { /// @param interface_index The interface index that is associated with a multicast group. /// @return Zero (0) if succeed; otherwise on error. /// @warning Internal use only - static int_least32_t set_socket_multicast_option(intmax_t handle, int_least32_t socket_option_name, uint_least32_t multicast_address, uint_least32_t interface_index); + static int32_t set_socket_multicast_option(intmax_t handle, int32_t socket_option_name, uint32_t multicast_address, uint32_t interface_index); /// @brief Sets IP v6 multicast option on socket. /// @param handle The socket handle. /// @param socket_option_name One of socket option name values (see socket_option_name_constants.h). @@ -260,13 +260,13 @@ namespace xtd { /// @param linger_time The amount of time to remain connected after calling the socket close method if data remains to be sent. /// @return Zero (0) if succeed; otherwise on error. /// @warning Internal use only - static int_least32_t set_socket_ip_v6_multicast_option(intmax_t handle, int_least32_t socket_option_name, const std::vector& multicast_address, uint_least32_t interface_index); + static int32_t set_socket_ip_v6_multicast_option(intmax_t handle, int32_t socket_option_name, const std::vector& multicast_address, uint32_t interface_index); /// @brief Shut down part of a full-duplex connection. /// @param handle The socket handle. /// @param how One of socket shutdown values (see socket_shutdown_constants.h). /// @return Zero (0) if succeed; otherwise on error. /// @warning Internal use only - static int_least32_t shutdown(intmax_t handle, int_least32_t how); + static int32_t shutdown(intmax_t handle, int32_t how); /// @brief Startup the socket library. /// @warning Internal use only static void startup(); diff --git a/src/xtd.core.native/include/xtd/native/socket_error_constants.h b/src/xtd.core.native/include/xtd/native/socket_error_constants.h index c19236162a4..14251b57384 100644 --- a/src/xtd.core.native/include/xtd/native/socket_error_constants.h +++ b/src/xtd.core.native/include/xtd/native/socket_error_constants.h @@ -16,7 +16,7 @@ /// @ingroup xtd_core_native socket_error /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_ERROR_SOCKET_ERROR = -1; +constexpr int32_t SOCKET_ERROR_SOCKET_ERROR = -1; /// @brief Operation successful /// @par Library @@ -24,7 +24,7 @@ constexpr int_least32_t SOCKET_ERROR_SOCKET_ERROR = -1; /// @ingroup xtd_core_native socket_error /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_ERROR_SUCCESS = 0; +constexpr int32_t SOCKET_ERROR_SUCCESS = 0; /// @brief The overlapped operation was aborted due to the closure of the socket /// @par Library @@ -32,7 +32,7 @@ constexpr int_least32_t SOCKET_ERROR_SUCCESS = 0; /// @ingroup xtd_core_native socket_error /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_ERROR_OPERATION_ABORTED = 995; +constexpr int32_t SOCKET_ERROR_OPERATION_ABORTED = 995; /// @brief The application has initiated an overlapped operation that cannot be completed immediately /// @par Library @@ -40,7 +40,7 @@ constexpr int_least32_t SOCKET_ERROR_OPERATION_ABORTED = 995; /// @ingroup xtd_core_native socket_error /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_ERROR_IO_PENDING = 997; +constexpr int32_t SOCKET_ERROR_IO_PENDING = 997; /// @brief A blocking call was canceled /// @par Library @@ -48,7 +48,7 @@ constexpr int_least32_t SOCKET_ERROR_IO_PENDING = 997; /// @ingroup xtd_core_native socket_error /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_ERROR_INTERRUPTED = 10004; +constexpr int32_t SOCKET_ERROR_INTERRUPTED = 10004; /// @brief Access denied /// @par Library @@ -56,7 +56,7 @@ constexpr int_least32_t SOCKET_ERROR_INTERRUPTED = 10004; /// @ingroup xtd_core_native socket_error /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_ERROR_ACCESS_DENIED = 10013; +constexpr int32_t SOCKET_ERROR_ACCESS_DENIED = 10013; /// @brief Invalid pointer address /// @par Library @@ -64,7 +64,7 @@ constexpr int_least32_t SOCKET_ERROR_ACCESS_DENIED = 10013; /// @ingroup xtd_core_native socket_error /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_ERROR_FAULT = 10014; +constexpr int32_t SOCKET_ERROR_FAULT = 10014; /// @brief Invalid argument /// @par Library @@ -72,7 +72,7 @@ constexpr int_least32_t SOCKET_ERROR_FAULT = 10014; /// @ingroup xtd_core_native socket_error /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_ERROR_INVALID_ARGUMENT = 10022; +constexpr int32_t SOCKET_ERROR_INVALID_ARGUMENT = 10022; /// @brief Too many sockets opened /// @par Library @@ -80,7 +80,7 @@ constexpr int_least32_t SOCKET_ERROR_INVALID_ARGUMENT = 10022; /// @ingroup xtd_core_native socket_error /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_ERROR_TOO_MANY_OPEN_SOCKETS = 10024; +constexpr int32_t SOCKET_ERROR_TOO_MANY_OPEN_SOCKETS = 10024; /// @brief An operation on a nonblocking socket cannot be completed immediately /// @par Library @@ -88,7 +88,7 @@ constexpr int_least32_t SOCKET_ERROR_TOO_MANY_OPEN_SOCKETS = 10024; /// @ingroup xtd_core_native socket_error /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_ERROR_WOULD_BLOCK = 10035; +constexpr int32_t SOCKET_ERROR_WOULD_BLOCK = 10035; /// @brief A blocking operation is in progress /// @par Library @@ -96,7 +96,7 @@ constexpr int_least32_t SOCKET_ERROR_WOULD_BLOCK = 10035; /// @ingroup xtd_core_native socket_error /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_ERROR_IN_PROGRESS = 10036; +constexpr int32_t SOCKET_ERROR_IN_PROGRESS = 10036; /// @brief The nonblocking socket has an operation in progress /// @par Library @@ -104,7 +104,7 @@ constexpr int_least32_t SOCKET_ERROR_IN_PROGRESS = 10036; /// @ingroup xtd_core_native socket_error /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_ERROR_ALREADY_IN_PROGRESS = 10037; +constexpr int32_t SOCKET_ERROR_ALREADY_IN_PROGRESS = 10037; /// @brief Operation attempted on a non-socket object /// @par Library @@ -112,7 +112,7 @@ constexpr int_least32_t SOCKET_ERROR_ALREADY_IN_PROGRESS = 10037; /// @ingroup xtd_core_native socket_error /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_ERROR_NOT_SOCKET = 10038; +constexpr int32_t SOCKET_ERROR_NOT_SOCKET = 10038; /// @brief Required destination missing /// @par Library @@ -120,7 +120,7 @@ constexpr int_least32_t SOCKET_ERROR_NOT_SOCKET = 10038; /// @ingroup xtd_core_native socket_error /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_ERROR_DESTINATION_ADDRESS_REQUIRED = 10039; +constexpr int32_t SOCKET_ERROR_DESTINATION_ADDRESS_REQUIRED = 10039; /// @brief Datagram message is too long /// @par Library @@ -128,7 +128,7 @@ constexpr int_least32_t SOCKET_ERROR_DESTINATION_ADDRESS_REQUIRED = 10039; /// @ingroup xtd_core_native socket_error /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_ERROR_MESSAGE_SIZE = 10040; +constexpr int32_t SOCKET_ERROR_MESSAGE_SIZE = 10040; /// @brief The protocol type is incorrect /// @par Library @@ -136,7 +136,7 @@ constexpr int_least32_t SOCKET_ERROR_MESSAGE_SIZE = 10040; /// @ingroup xtd_core_native socket_error /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_ERROR_PROTOCOL_TYPE = 10041; +constexpr int32_t SOCKET_ERROR_PROTOCOL_TYPE = 10041; /// @brief An unknown, invalid, or unsupported option or level was used /// @par Library @@ -144,7 +144,7 @@ constexpr int_least32_t SOCKET_ERROR_PROTOCOL_TYPE = 10041; /// @ingroup xtd_core_native socket_error /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_ERROR_PROTOCOL_OPTION = 10042; +constexpr int32_t SOCKET_ERROR_PROTOCOL_OPTION = 10042; /// @brief The protocol is not implemented or has not been configured /// @par Library @@ -152,7 +152,7 @@ constexpr int_least32_t SOCKET_ERROR_PROTOCOL_OPTION = 10042; /// @ingroup xtd_core_native socket_error /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_ERROR_PROTOCOL_NOT_SUPPORTED = 10043; +constexpr int32_t SOCKET_ERROR_PROTOCOL_NOT_SUPPORTED = 10043; /// @brief The support for the specified socket type does not exist in this address family /// @par Library @@ -160,7 +160,7 @@ constexpr int_least32_t SOCKET_ERROR_PROTOCOL_NOT_SUPPORTED = 10043; /// @ingroup xtd_core_native socket_error /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_ERROR_SOCKET_NOT_SUPPORTED = 10044; +constexpr int32_t SOCKET_ERROR_SOCKET_NOT_SUPPORTED = 10044; /// @brief The address family is not supported by the protocol family /// @par Library @@ -168,7 +168,7 @@ constexpr int_least32_t SOCKET_ERROR_SOCKET_NOT_SUPPORTED = 10044; /// @ingroup xtd_core_native socket_error /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_ERROR_OPERATION_NOT_SUPPORTED = 10045; +constexpr int32_t SOCKET_ERROR_OPERATION_NOT_SUPPORTED = 10045; /// @brief The protocol family is not implemented or has not been configured /// @par Library @@ -176,7 +176,7 @@ constexpr int_least32_t SOCKET_ERROR_OPERATION_NOT_SUPPORTED = 10045; /// @ingroup xtd_core_native socket_error /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_ERROR_PROTOCOL_FAMILY_NOT_SUPPORTED = 10046; +constexpr int32_t SOCKET_ERROR_PROTOCOL_FAMILY_NOT_SUPPORTED = 10046; /// @brief The address family specified is not supported. This error is returned if the IPv6 address family was specified and the IPv6 stack is not installed on the local machine. This error is returned if the IPv4 address family was specified and the IPv4 stack is not installed on the local machine. /// @par Library @@ -184,7 +184,7 @@ constexpr int_least32_t SOCKET_ERROR_PROTOCOL_FAMILY_NOT_SUPPORTED = 10046; /// @ingroup xtd_core_native socket_error /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED = 10047; +constexpr int32_t SOCKET_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED = 10047; /// @brief Only one use of an address is normally permitted /// @par Library @@ -192,7 +192,7 @@ constexpr int_least32_t SOCKET_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED = 10047; /// @ingroup xtd_core_native socket_error /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_ERROR_ADDRESS_ALREADY_IN_USE = 10048; +constexpr int32_t SOCKET_ERROR_ADDRESS_ALREADY_IN_USE = 10048; /// @brief The selected IP address is not valid in this context /// @par Library @@ -200,7 +200,7 @@ constexpr int_least32_t SOCKET_ERROR_ADDRESS_ALREADY_IN_USE = 10048; /// @ingroup xtd_core_native socket_error /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_ERROR_ADDRESS_NOT_AVAILABLE = 10049; +constexpr int32_t SOCKET_ERROR_ADDRESS_NOT_AVAILABLE = 10049; /// @brief The network is not available /// @par Library @@ -208,7 +208,7 @@ constexpr int_least32_t SOCKET_ERROR_ADDRESS_NOT_AVAILABLE = 10049; /// @ingroup xtd_core_native socket_error /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_ERROR_NETWORK_DOWN = 10050; +constexpr int32_t SOCKET_ERROR_NETWORK_DOWN = 10050; /// @brief No route to the remote host exists /// @par Library @@ -216,7 +216,7 @@ constexpr int_least32_t SOCKET_ERROR_NETWORK_DOWN = 10050; /// @ingroup xtd_core_native socket_error /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_ERROR_NETWORK_UNREACHABLE = 10051; +constexpr int32_t SOCKET_ERROR_NETWORK_UNREACHABLE = 10051; /// @brief The application tried to set "keep alive" on a connection that timed out /// @par Library @@ -224,7 +224,7 @@ constexpr int_least32_t SOCKET_ERROR_NETWORK_UNREACHABLE = 10051; /// @ingroup xtd_core_native socket_error /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_ERROR_NETWORK_RESET = 10052; +constexpr int32_t SOCKET_ERROR_NETWORK_RESET = 10052; /// @brief Connection aborted /// @par Library @@ -232,7 +232,7 @@ constexpr int_least32_t SOCKET_ERROR_NETWORK_RESET = 10052; /// @ingroup xtd_core_native socket_error /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_ERROR_CONNECTION_ABORTED = 10053; +constexpr int32_t SOCKET_ERROR_CONNECTION_ABORTED = 10053; /// @brief Connection reset by the remote peer /// @par Library @@ -240,7 +240,7 @@ constexpr int_least32_t SOCKET_ERROR_CONNECTION_ABORTED = 10053; /// @ingroup xtd_core_native socket_error /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_ERROR_CONNECTION_RESET = 10054; +constexpr int32_t SOCKET_ERROR_CONNECTION_RESET = 10054; /// @brief No free buffer space available /// @par Library @@ -248,7 +248,7 @@ constexpr int_least32_t SOCKET_ERROR_CONNECTION_RESET = 10054; /// @ingroup xtd_core_native socket_error /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_ERROR_NO_BUFFER_SPACE_AVAILABLE = 10055; +constexpr int32_t SOCKET_ERROR_NO_BUFFER_SPACE_AVAILABLE = 10055; /// @brief Already connected /// @par Library @@ -256,7 +256,7 @@ constexpr int_least32_t SOCKET_ERROR_NO_BUFFER_SPACE_AVAILABLE = 10055; /// @ingroup xtd_core_native socket_error /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_ERROR_IS_CONNECTED = 10056; +constexpr int32_t SOCKET_ERROR_IS_CONNECTED = 10056; /// @brief The socket is not connected /// @par Library @@ -264,7 +264,7 @@ constexpr int_least32_t SOCKET_ERROR_IS_CONNECTED = 10056; /// @ingroup xtd_core_native socket_error /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_ERROR_NOT_CONNECTED = 10057; +constexpr int32_t SOCKET_ERROR_NOT_CONNECTED = 10057; /// @brief A request to send or receive data was disallowed because the socket is closed /// @par Library @@ -272,7 +272,7 @@ constexpr int_least32_t SOCKET_ERROR_NOT_CONNECTED = 10057; /// @ingroup xtd_core_native socket_error /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_ERROR_SHUTDOWN = 10058; +constexpr int32_t SOCKET_ERROR_SHUTDOWN = 10058; /// @brief The connection attempt timed out, or the connected host has failed to respond /// @par Library @@ -280,7 +280,7 @@ constexpr int_least32_t SOCKET_ERROR_SHUTDOWN = 10058; /// @ingroup xtd_core_native socket_error /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_ERROR_TIMED_OUT = 10060; +constexpr int32_t SOCKET_ERROR_TIMED_OUT = 10060; /// @brief The remote host is actively refusing a connection /// @par Library @@ -288,7 +288,7 @@ constexpr int_least32_t SOCKET_ERROR_TIMED_OUT = 10060; /// @ingroup xtd_core_native socket_error /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_ERROR_CONNECTION_REFUSED = 10061; +constexpr int32_t SOCKET_ERROR_CONNECTION_REFUSED = 10061; /// @brief The operation failed because the remote host is down /// @par Library @@ -296,7 +296,7 @@ constexpr int_least32_t SOCKET_ERROR_CONNECTION_REFUSED = 10061; /// @ingroup xtd_core_native socket_error /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_ERROR_HOST_DOWN = 10064; +constexpr int32_t SOCKET_ERROR_HOST_DOWN = 10064; /// @brief There is no network route to the specified host /// @par Library @@ -304,7 +304,7 @@ constexpr int_least32_t SOCKET_ERROR_HOST_DOWN = 10064; /// @ingroup xtd_core_native socket_error /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_ERROR_HOST_UNREACHABLE = 10065; +constexpr int32_t SOCKET_ERROR_HOST_UNREACHABLE = 10065; /// @brief Too many processes are using the underlying socket provider /// @par Library @@ -312,7 +312,7 @@ constexpr int_least32_t SOCKET_ERROR_HOST_UNREACHABLE = 10065; /// @ingroup xtd_core_native socket_error /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_ERROR_PROCESS_LIMIT = 10067; +constexpr int32_t SOCKET_ERROR_PROCESS_LIMIT = 10067; /// @brief The network subsystem is unavailable /// @par Library @@ -320,7 +320,7 @@ constexpr int_least32_t SOCKET_ERROR_PROCESS_LIMIT = 10067; /// @ingroup xtd_core_native socket_error /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_ERROR_SYSTEM_NOT_READY = 10091; +constexpr int32_t SOCKET_ERROR_SYSTEM_NOT_READY = 10091; /// @brief The version of the underlying socket provider is out of range /// @par Library @@ -328,7 +328,7 @@ constexpr int_least32_t SOCKET_ERROR_SYSTEM_NOT_READY = 10091; /// @ingroup xtd_core_native socket_error /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_ERROR_VERSION_NOT_SUPPORTED = 10092; +constexpr int32_t SOCKET_ERROR_VERSION_NOT_SUPPORTED = 10092; /// @brief The underlying socket provider has not been initialized /// @par Library @@ -336,7 +336,7 @@ constexpr int_least32_t SOCKET_ERROR_VERSION_NOT_SUPPORTED = 10092; /// @ingroup xtd_core_native socket_error /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_ERROR_NOT_INITIALIZED = 10093; +constexpr int32_t SOCKET_ERROR_NOT_INITIALIZED = 10093; /// @brief A graceful shutdown is in progress /// @par Library @@ -344,7 +344,7 @@ constexpr int_least32_t SOCKET_ERROR_NOT_INITIALIZED = 10093; /// @ingroup xtd_core_native socket_error /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_ERROR_DISCONNECTING = 10101; +constexpr int32_t SOCKET_ERROR_DISCONNECTING = 10101; /// @brief The specified class was not found /// @par Library @@ -352,7 +352,7 @@ constexpr int_least32_t SOCKET_ERROR_DISCONNECTING = 10101; /// @ingroup xtd_core_native socket_error /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_ERROR_TYPE_NOT_FOUND = 10109; +constexpr int32_t SOCKET_ERROR_TYPE_NOT_FOUND = 10109; /// @brief No such host is known. The name is not an official host name or alias. /// @par Library @@ -360,7 +360,7 @@ constexpr int_least32_t SOCKET_ERROR_TYPE_NOT_FOUND = 10109; /// @ingroup xtd_core_native socket_error /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_ERROR_HOST_NOT_FOUND = 10001; +constexpr int32_t SOCKET_ERROR_HOST_NOT_FOUND = 10001; /// @brief The name of the host could not be resolved. Try again later. /// @par Library @@ -368,7 +368,7 @@ constexpr int_least32_t SOCKET_ERROR_HOST_NOT_FOUND = 10001; /// @ingroup xtd_core_native socket_error /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_ERROR_TRY_AGAIN = 10002; +constexpr int32_t SOCKET_ERROR_TRY_AGAIN = 10002; /// @brief The error is unrecoverable or the requested database cannot be located. /// @par Library @@ -376,7 +376,7 @@ constexpr int_least32_t SOCKET_ERROR_TRY_AGAIN = 10002; /// @ingroup xtd_core_native socket_error /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_ERROR_NOT_RECOVERY = 10003; +constexpr int32_t SOCKET_ERROR_NOT_RECOVERY = 10003; /// @brief The requested name or IP address was not found on the name server. /// @par Library @@ -384,4 +384,4 @@ constexpr int_least32_t SOCKET_ERROR_NOT_RECOVERY = 10003; /// @ingroup xtd_core_native socket_error /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_ERROR_NO_DATA = 10004; +constexpr int32_t SOCKET_ERROR_NO_DATA = 10004; diff --git a/src/xtd.core.native/include/xtd/native/socket_option_level_constants.h b/src/xtd.core.native/include/xtd/native/socket_option_level_constants.h index fcbf7a18bb5..768ad67333b 100644 --- a/src/xtd.core.native/include/xtd/native/socket_option_level_constants.h +++ b/src/xtd.core.native/include/xtd/native/socket_option_level_constants.h @@ -17,7 +17,7 @@ /// @ingroup xtd_core_native socket_option_level /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_OPTION_LEVEL_SOCKET = 65535; +constexpr int32_t SOCKET_OPTION_LEVEL_SOCKET = 65535; /// @brief Socket options apply only to IP sockets. /// @par Library @@ -25,7 +25,7 @@ constexpr int_least32_t SOCKET_OPTION_LEVEL_SOCKET = 65535; /// @ingroup xtd_core_native socket_option_level /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_OPTION_LEVEL_IP = 0; +constexpr int32_t SOCKET_OPTION_LEVEL_IP = 0; /// @brief Socket options apply only to IPv6 sockets. /// @par Library @@ -33,7 +33,7 @@ constexpr int_least32_t SOCKET_OPTION_LEVEL_IP = 0; /// @ingroup xtd_core_native socket_option_level /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_OPTION_LEVEL_IP_V6 = 41; +constexpr int32_t SOCKET_OPTION_LEVEL_IP_V6 = 41; /// @brief Socket options apply only to TCP sockets. /// @par Library @@ -41,7 +41,7 @@ constexpr int_least32_t SOCKET_OPTION_LEVEL_IP_V6 = 41; /// @ingroup xtd_core_native socket_option_level /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_OPTION_LEVEL_TCP = 6; +constexpr int32_t SOCKET_OPTION_LEVEL_TCP = 6; /// @brief Socket options apply only to UDP sockets. /// @par Library @@ -49,4 +49,4 @@ constexpr int_least32_t SOCKET_OPTION_LEVEL_TCP = 6; /// @ingroup xtd_core_native socket_option_level /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_OPTION_LEVEL_UDP = 17; +constexpr int32_t SOCKET_OPTION_LEVEL_UDP = 17; diff --git a/src/xtd.core.native/include/xtd/native/socket_option_name_constants.h b/src/xtd.core.native/include/xtd/native/socket_option_name_constants.h index 71f85da2308..5e01568c94f 100644 --- a/src/xtd.core.native/include/xtd/native/socket_option_name_constants.h +++ b/src/xtd.core.native/include/xtd/native/socket_option_name_constants.h @@ -17,7 +17,7 @@ /// @ingroup xtd_core_native socket_option_name /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_OPTION_NAME_DEBUG = 1; +constexpr int32_t SOCKET_OPTION_NAME_DEBUG = 1; /// @brief The socket is listening. /// @par Library @@ -25,7 +25,7 @@ constexpr int_least32_t SOCKET_OPTION_NAME_DEBUG = 1; /// @ingroup xtd_core_native socket_option_name /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_OPTION_NAME_ACCEPT_CONNECTION = 2; +constexpr int32_t SOCKET_OPTION_NAME_ACCEPT_CONNECTION = 2; /// @brief Allows the socket to be bound to an address that is already in use. /// @par Library @@ -33,7 +33,7 @@ constexpr int_least32_t SOCKET_OPTION_NAME_ACCEPT_CONNECTION = 2; /// @ingroup xtd_core_native socket_option_name /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_OPTION_NAME_REUSE_ADDRESS = 4; +constexpr int32_t SOCKET_OPTION_NAME_REUSE_ADDRESS = 4; /// @brief Use keep-alive. /// @par Library @@ -41,7 +41,7 @@ constexpr int_least32_t SOCKET_OPTION_NAME_REUSE_ADDRESS = 4; /// @ingroup xtd_core_native socket_option_name /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_OPTION_NAME_KEEP_ALIVE = 8; +constexpr int32_t SOCKET_OPTION_NAME_KEEP_ALIVE = 8; /// @brief Do not route; send the packet directly to the interface addresses. /// @par Library @@ -49,7 +49,7 @@ constexpr int_least32_t SOCKET_OPTION_NAME_KEEP_ALIVE = 8; /// @ingroup xtd_core_native socket_option_name /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_OPTION_NAME_DONT_ROUTE = 16; +constexpr int32_t SOCKET_OPTION_NAME_DONT_ROUTE = 16; /// @brief Permit sending broadcast messages on the socket. /// @par Library @@ -57,7 +57,7 @@ constexpr int_least32_t SOCKET_OPTION_NAME_DONT_ROUTE = 16; /// @ingroup xtd_core_native socket_option_name /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_OPTION_NAME_BROADCAST = 32; +constexpr int32_t SOCKET_OPTION_NAME_BROADCAST = 32; /// @brief Bypass hardware when possible. /// @par Library @@ -65,7 +65,7 @@ constexpr int_least32_t SOCKET_OPTION_NAME_BROADCAST = 32; /// @ingroup xtd_core_native socket_option_name /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_OPTION_NAME_USE_LOOPBACK = 64; +constexpr int32_t SOCKET_OPTION_NAME_USE_LOOPBACK = 64; /// @brief Linger on close if unsent data is present. /// @par Library @@ -73,7 +73,7 @@ constexpr int_least32_t SOCKET_OPTION_NAME_USE_LOOPBACK = 64; /// @ingroup xtd_core_native socket_option_name /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_OPTION_NAME_LINGER = 128; +constexpr int32_t SOCKET_OPTION_NAME_LINGER = 128; /// @brief Receives out-of-band data in the normal data stream. /// @par Library @@ -81,7 +81,7 @@ constexpr int_least32_t SOCKET_OPTION_NAME_LINGER = 128; /// @ingroup xtd_core_native socket_option_name /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_OPTION_NAME_OUT_OF_BAND_INLINE = 256; +constexpr int32_t SOCKET_OPTION_NAME_OUT_OF_BAND_INLINE = 256; /// @brief Close the socket gracefully without lingering. /// @par Library @@ -89,7 +89,7 @@ constexpr int_least32_t SOCKET_OPTION_NAME_OUT_OF_BAND_INLINE = 256; /// @ingroup xtd_core_native socket_option_name /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_OPTION_NAME_DONT_LINGER = -129; +constexpr int32_t SOCKET_OPTION_NAME_DONT_LINGER = -129; /// @brief Enables a socket to be bound for exclusive access. /// @par Library @@ -97,7 +97,7 @@ constexpr int_least32_t SOCKET_OPTION_NAME_DONT_LINGER = -129; /// @ingroup xtd_core_native socket_option_name /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_OPTION_NAME_EXCLUSIVE_ADDRESS_USE = -5; +constexpr int32_t SOCKET_OPTION_NAME_EXCLUSIVE_ADDRESS_USE = -5; /// @brief Specifies the total per-socket buffer space reserved for sends. This is unrelated to the maximum message size or the size of a TCP window. /// @par Library @@ -105,7 +105,7 @@ constexpr int_least32_t SOCKET_OPTION_NAME_EXCLUSIVE_ADDRESS_USE = -5; /// @ingroup xtd_core_native socket_option_name /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_OPTION_NAME_SEND_BUFFER = 4097; +constexpr int32_t SOCKET_OPTION_NAME_SEND_BUFFER = 4097; /// @brief Specifies the total per-socket buffer space reserved for receives. This is unrelated to the maximum message size or the size of a TCP window. /// @par Library @@ -113,7 +113,7 @@ constexpr int_least32_t SOCKET_OPTION_NAME_SEND_BUFFER = 4097; /// @ingroup xtd_core_native socket_option_name /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_OPTION_NAME_RECEIVE_BUFFER = 4098; +constexpr int32_t SOCKET_OPTION_NAME_RECEIVE_BUFFER = 4098; /// @brief Specifies the low water mark for xtd::net::sockets::socket::send operations. /// @par Library @@ -121,7 +121,7 @@ constexpr int_least32_t SOCKET_OPTION_NAME_RECEIVE_BUFFER = 4098; /// @ingroup xtd_core_native socket_option_name /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_OPTION_NAME_SEND_LOW_WATER = 4099; +constexpr int32_t SOCKET_OPTION_NAME_SEND_LOW_WATER = 4099; /// @brief Specifies the low water mark for xtd::net::sockets::socket::receive operations. /// @par Library @@ -129,7 +129,7 @@ constexpr int_least32_t SOCKET_OPTION_NAME_SEND_LOW_WATER = 4099; /// @ingroup xtd_core_native socket_option_name /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_OPTION_NAME_RECEIVE_LOW_WATER = 4100; +constexpr int32_t SOCKET_OPTION_NAME_RECEIVE_LOW_WATER = 4100; /// @brief Send a time-out. This option applies only to synchronous methods; it has no effect on asynchronous methods such as the xtd::net::sockets::socket::begin_send method. /// @par Library @@ -137,7 +137,7 @@ constexpr int_least32_t SOCKET_OPTION_NAME_RECEIVE_LOW_WATER = 4100; /// @ingroup xtd_core_native socket_option_name /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_OPTION_NAME_SEND_TIMEOUT = 4101; +constexpr int32_t SOCKET_OPTION_NAME_SEND_TIMEOUT = 4101; /// @brief Receive a time-out. This option applies only to synchronous methods; it has no effect on asynchronous methods such as the xtd::net::sockets::socket::begin_send method. /// @par Library @@ -145,7 +145,7 @@ constexpr int_least32_t SOCKET_OPTION_NAME_SEND_TIMEOUT = 4101; /// @ingroup xtd_core_native socket_option_name /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_OPTION_NAME_RECEIVE_TIMEOUT = 4102; +constexpr int32_t SOCKET_OPTION_NAME_RECEIVE_TIMEOUT = 4102; /// @brief Gets the error status and clear. /// @par Library @@ -153,7 +153,7 @@ constexpr int_least32_t SOCKET_OPTION_NAME_RECEIVE_TIMEOUT = 4102; /// @ingroup xtd_core_native socket_option_name /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_OPTION_NAME_ERROR = 4103; +constexpr int32_t SOCKET_OPTION_NAME_ERROR = 4103; /// @brief Gets the socket type. /// @par Library @@ -161,7 +161,7 @@ constexpr int_least32_t SOCKET_OPTION_NAME_ERROR = 4103; /// @ingroup xtd_core_native socket_option_name /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_OPTION_NAME_TYPE = 4104; +constexpr int32_t SOCKET_OPTION_NAME_TYPE = 4104; /// @brief Not supported; will throw a xtd::net::sockets::socket_exception exception if used. /// @par Library @@ -169,7 +169,7 @@ constexpr int_least32_t SOCKET_OPTION_NAME_TYPE = 4104; /// @ingroup xtd_core_native socket_option_name /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_OPTION_NAME_MAX_CONNECTION = 2147483647; +constexpr int32_t SOCKET_OPTION_NAME_MAX_CONNECTION = 2147483647; /// @brief Specifies the IP options to be inserted into outgoing datagrams. /// @par Library @@ -177,7 +177,7 @@ constexpr int_least32_t SOCKET_OPTION_NAME_MAX_CONNECTION = 2147483647; /// @ingroup xtd_core_native socket_option_name /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_OPTION_NAME_IP_OPTIONS = 1; +constexpr int32_t SOCKET_OPTION_NAME_IP_OPTIONS = 1; /// @brief Indicates that the application provides the IP header for outgoing datagrams. /// @par Library @@ -185,7 +185,7 @@ constexpr int_least32_t SOCKET_OPTION_NAME_IP_OPTIONS = 1; /// @ingroup xtd_core_native socket_option_name /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_OPTION_NAME_HEADER_INCLUDED = 2; +constexpr int32_t SOCKET_OPTION_NAME_HEADER_INCLUDED = 2; /// @brief Change the IP header type of the service field. /// @par Library @@ -193,7 +193,7 @@ constexpr int_least32_t SOCKET_OPTION_NAME_HEADER_INCLUDED = 2; /// @ingroup xtd_core_native socket_option_name /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_OPTION_NAME_TYPE_OF_SERVICE = 3; +constexpr int32_t SOCKET_OPTION_NAME_TYPE_OF_SERVICE = 3; /// @brief Sets the IP header Time-to-Live field. /// @par Library @@ -201,7 +201,7 @@ constexpr int_least32_t SOCKET_OPTION_NAME_TYPE_OF_SERVICE = 3; /// @ingroup xtd_core_native socket_option_name /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_OPTION_NAME_IP_TIME_TO_LIVE = 4; +constexpr int32_t SOCKET_OPTION_NAME_IP_TIME_TO_LIVE = 4; /// @brief Sets the interface for outgoing multicast packets. /// @par Library @@ -209,7 +209,7 @@ constexpr int_least32_t SOCKET_OPTION_NAME_IP_TIME_TO_LIVE = 4; /// @ingroup xtd_core_native socket_option_name /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_OPTION_NAME_MULTICAST_INTERFACE = 9; +constexpr int32_t SOCKET_OPTION_NAME_MULTICAST_INTERFACE = 9; /// @brief An IP multicast Time to Live. /// @par Library @@ -217,7 +217,7 @@ constexpr int_least32_t SOCKET_OPTION_NAME_MULTICAST_INTERFACE = 9; /// @ingroup xtd_core_native socket_option_name /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_OPTION_NAME_MULTICAST_TIME_TO_LIVE = 10; +constexpr int32_t SOCKET_OPTION_NAME_MULTICAST_TIME_TO_LIVE = 10; /// @brief An IP multicast loopback. /// @par Library @@ -225,7 +225,7 @@ constexpr int_least32_t SOCKET_OPTION_NAME_MULTICAST_TIME_TO_LIVE = 10; /// @ingroup xtd_core_native socket_option_name /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_OPTION_NAME_MULTICAST_LOOPBACK = 11; +constexpr int32_t SOCKET_OPTION_NAME_MULTICAST_LOOPBACK = 11; /// @brief Add an IP group membership. /// @par Library @@ -233,7 +233,7 @@ constexpr int_least32_t SOCKET_OPTION_NAME_MULTICAST_LOOPBACK = 11; /// @ingroup xtd_core_native socket_option_name /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_OPTION_NAME_ADD_MEMBERSHIP = 12; +constexpr int32_t SOCKET_OPTION_NAME_ADD_MEMBERSHIP = 12; /// @brief Drop an IP group membership. /// @par Library @@ -241,7 +241,7 @@ constexpr int_least32_t SOCKET_OPTION_NAME_ADD_MEMBERSHIP = 12; /// @ingroup xtd_core_native socket_option_name /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_OPTION_NAME_DROP_MEMBERSHIP = 13; +constexpr int32_t SOCKET_OPTION_NAME_DROP_MEMBERSHIP = 13; /// @brief Do not fragment IP datagrams. /// @par Library @@ -249,7 +249,7 @@ constexpr int_least32_t SOCKET_OPTION_NAME_DROP_MEMBERSHIP = 13; /// @ingroup xtd_core_native socket_option_name /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_OPTION_NAME_DONT_FRAGMENT = 14; +constexpr int32_t SOCKET_OPTION_NAME_DONT_FRAGMENT = 14; /// @brief Join a source group. /// @par Library @@ -257,7 +257,7 @@ constexpr int_least32_t SOCKET_OPTION_NAME_DONT_FRAGMENT = 14; /// @ingroup xtd_core_native socket_option_name /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_OPTION_NAME_ADD_SOURCE_MEMBERSHIP = 15; +constexpr int32_t SOCKET_OPTION_NAME_ADD_SOURCE_MEMBERSHIP = 15; /// @brief Drop a source group. /// @par Library @@ -265,7 +265,7 @@ constexpr int_least32_t SOCKET_OPTION_NAME_ADD_SOURCE_MEMBERSHIP = 15; /// @ingroup xtd_core_native socket_option_name /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_OPTION_NAME_DROP_SOURCE_MEMBERSHIP = 16; +constexpr int32_t SOCKET_OPTION_NAME_DROP_SOURCE_MEMBERSHIP = 16; /// @brief Block data from a source. /// @par Library @@ -273,7 +273,7 @@ constexpr int_least32_t SOCKET_OPTION_NAME_DROP_SOURCE_MEMBERSHIP = 16; /// @ingroup xtd_core_native socket_option_name /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_OPTION_NAME_BLOCK_SOURCE = 17; +constexpr int32_t SOCKET_OPTION_NAME_BLOCK_SOURCE = 17; /// @brief Unblock a previously blocked source. /// @par Library @@ -281,7 +281,7 @@ constexpr int_least32_t SOCKET_OPTION_NAME_BLOCK_SOURCE = 17; /// @ingroup xtd_core_native socket_option_name /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_OPTION_NAME_UNBLOCK_SOURCE = 18; +constexpr int32_t SOCKET_OPTION_NAME_UNBLOCK_SOURCE = 18; /// @brief Return information about received packets. /// @par Library @@ -289,7 +289,7 @@ constexpr int_least32_t SOCKET_OPTION_NAME_UNBLOCK_SOURCE = 18; /// @ingroup xtd_core_native socket_option_name /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_OPTION_NAME_PACKET_INFORMATION = 19; +constexpr int32_t SOCKET_OPTION_NAME_PACKET_INFORMATION = 19; /// @brief Specifies the maximum number of router hops for an Internet Protocol version 6 (IPv6) packet. This is similar to Time to Live (TTL) for Internet Protocol version 4. /// @par Library @@ -297,7 +297,7 @@ constexpr int_least32_t SOCKET_OPTION_NAME_PACKET_INFORMATION = 19; /// @ingroup xtd_core_native socket_option_name /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_OPTION_NAME_HOP_LIMIT = 21; +constexpr int32_t SOCKET_OPTION_NAME_HOP_LIMIT = 21; /// @brief Enables restriction of a IPv6 socket to a specified scope, such as addresses with the same link local or site local prefix.This socket option enables applications to place access restrictions on IPv6 sockets. Such restrictions enable an application running on a private LAN to simply and robustly harden itself against external attacks. This socket option widens or narrows the scope of a listening socket, enabling unrestricted access from public and private users when appropriate, or restricting access only to the same site, as required. This socket option has defined protection levels specified in the xtd::net::sockets::ip_protection_level enumeration. /// @par Library @@ -305,7 +305,7 @@ constexpr int_least32_t SOCKET_OPTION_NAME_HOP_LIMIT = 21; /// @ingroup xtd_core_native socket_option_name /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_OPTION_NAME_IP_PROTECT_LEVEL = 23; +constexpr int32_t SOCKET_OPTION_NAME_IP_PROTECT_LEVEL = 23; /// @brief Indicates if a socket created for the AF_INET6 address family is restricted to IPv6 communications only. Sockets created for the AF_INET6 address family may be used for both IPv6 and IPv4 communications. Some applications may want to restrict their use of a socket created for the AF_INET6 address family to IPv6 communications only. When this value is non-zero (the default on Windows), a socket created for the AF_INET6 address family can be used to send and receive IPv6 packets only. When this value is zero, a socket created for the AF_INET6 address family can be used to send and receive packets to and from an IPv6 address or an IPv4 address. Note that the ability to interact with an IPv4 address requires the use of IPv4 mapped addresses. This socket option is supported on Windows Vista or later. /// @par Library @@ -313,7 +313,7 @@ constexpr int_least32_t SOCKET_OPTION_NAME_IP_PROTECT_LEVEL = 23; /// @ingroup xtd_core_native socket_option_name /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_OPTION_NAME_IP_V6_ONLY = 27; +constexpr int32_t SOCKET_OPTION_NAME_IP_V6_ONLY = 27; /// @brief Disables the Nagle algorithm for send coalescing. /// @par Library @@ -321,7 +321,7 @@ constexpr int_least32_t SOCKET_OPTION_NAME_IP_V6_ONLY = 27; /// @ingroup xtd_core_native socket_option_name /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_OPTION_NAME_NO_DELAY = 1; +constexpr int32_t SOCKET_OPTION_NAME_NO_DELAY = 1; /// @brief Use urgent data as defined in RFC-1222. This option can be set only once; after it is set, it cannot be turned off. /// @par Library @@ -329,7 +329,7 @@ constexpr int_least32_t SOCKET_OPTION_NAME_NO_DELAY = 1; /// @ingroup xtd_core_native socket_option_name /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_OPTION_NAME_BSD_URGENT = 2; +constexpr int32_t SOCKET_OPTION_NAME_BSD_URGENT = 2; /// @brief Use expedited data as defined in RFC-1222. This option can be set only once; after it is set, it cannot be turned off. /// @par Library @@ -337,7 +337,7 @@ constexpr int_least32_t SOCKET_OPTION_NAME_BSD_URGENT = 2; /// @ingroup xtd_core_native socket_option_name /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_OPTION_NAME_EXPEDITED = 2; +constexpr int32_t SOCKET_OPTION_NAME_EXPEDITED = 2; /// @brief Send UDP datagrams with checksum set to zero. /// @par Library @@ -345,7 +345,7 @@ constexpr int_least32_t SOCKET_OPTION_NAME_EXPEDITED = 2; /// @ingroup xtd_core_native socket_option_name /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_OPTION_NAME_NO_CHECKSUM = 1; +constexpr int32_t SOCKET_OPTION_NAME_NO_CHECKSUM = 1; /// @brief Sets or get the UDP checksum coverage. /// @par Library @@ -353,7 +353,7 @@ constexpr int_least32_t SOCKET_OPTION_NAME_NO_CHECKSUM = 1; /// @ingroup xtd_core_native socket_option_name /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_OPTION_NAME_CHECKSUM_COVERAGE = 20; +constexpr int32_t SOCKET_OPTION_NAME_CHECKSUM_COVERAGE = 20; /// @brief Updates an accepted socket's properties by using those of an existing socket. This is equivalent to using the Winsock2 SO_UPDATE_ACCEPT_CONTEXT socket option and is supported only on connection-oriented sockets. /// @par Library @@ -361,7 +361,7 @@ constexpr int_least32_t SOCKET_OPTION_NAME_CHECKSUM_COVERAGE = 20; /// @ingroup xtd_core_native socket_option_name /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_OPTION_NAME_UPDATE_ACCEPT_CONTEXT = 28683; +constexpr int32_t SOCKET_OPTION_NAME_UPDATE_ACCEPT_CONTEXT = 28683; /// @brief Updates a connected socket's properties by using those of an existing socket. This is equivalent to using the Winsock2 SO_UPDATE_CONNECT_CONTEXT socket option and is supported only on connection-oriented sockets. /// @par Library @@ -369,4 +369,4 @@ constexpr int_least32_t SOCKET_OPTION_NAME_UPDATE_ACCEPT_CONTEXT = 28683; /// @ingroup xtd_core_native socket_option_name /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_OPTION_NAME_UPDATE_CONNECT_CONTEXT = 28688; +constexpr int32_t SOCKET_OPTION_NAME_UPDATE_CONNECT_CONTEXT = 28688; diff --git a/src/xtd.core.native/include/xtd/native/socket_shutdown_constants.h b/src/xtd.core.native/include/xtd/native/socket_shutdown_constants.h index a0b33d7b61b..e5277c269fe 100644 --- a/src/xtd.core.native/include/xtd/native/socket_shutdown_constants.h +++ b/src/xtd.core.native/include/xtd/native/socket_shutdown_constants.h @@ -17,7 +17,7 @@ /// @ingroup xtd_core_native socket_shutdown /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_SHUTDOWN_RECEIVE = 0; +constexpr int32_t SOCKET_SHUTDOWN_RECEIVE = 0; /// @brief Disables a xtd::net::sockets::socket for sending. /// @par Library @@ -25,7 +25,7 @@ constexpr int_least32_t SOCKET_SHUTDOWN_RECEIVE = 0; /// @ingroup xtd_core_native socket_shutdown /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_SHUTDOWN_SEND = 1; +constexpr int32_t SOCKET_SHUTDOWN_SEND = 1; /// @brief Disables a xtd::net::sockets::socket for both sending and receiving. /// @par Library @@ -33,4 +33,4 @@ constexpr int_least32_t SOCKET_SHUTDOWN_SEND = 1; /// @ingroup xtd_core_native socket_shutdown /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_SHUTDOWN_BOTH = 2; +constexpr int32_t SOCKET_SHUTDOWN_BOTH = 2; diff --git a/src/xtd.core.native/include/xtd/native/socket_type_constants.h b/src/xtd.core.native/include/xtd/native/socket_type_constants.h index 96a376688f8..5281df3231c 100644 --- a/src/xtd.core.native/include/xtd/native/socket_type_constants.h +++ b/src/xtd.core.native/include/xtd/native/socket_type_constants.h @@ -17,7 +17,7 @@ /// @ingroup xtd_core_native socket_type /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_TYPE_UNKNOWN = -1; +constexpr int32_t SOCKET_TYPE_UNKNOWN = -1; /// @brief Supports reliable, two-way, connection-based byte streams without the duplication of data and without preservation of boundaries. A xtd::net::sockets::socket of this type communicates with a single peer and requires a remote host connection before communication can begin. xtd::net::sockets::socket_types::stream uses the Transmission Control Protocol (xtd::net::sockets::protocol_type::tcp) and the xtd::net::sockets::address_family::inter_network address family. /// @par Library @@ -25,7 +25,7 @@ constexpr int_least32_t SOCKET_TYPE_UNKNOWN = -1; /// @ingroup xtd_core_native socket_type /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_TYPE_STREAM = 1; +constexpr int32_t SOCKET_TYPE_STREAM = 1; /// @brief Supports datagrams, which are connectionless, unreliable messages of a fixed (typically small) maximum length. Messages might be lost or duplicated and might arrive out of order. A xtd::net::sockets::socket of type xtd::net::sockets::socket_type::dgram requires no connection prior to sending and receiving data, and can communicate with multiple peers. xtd::net::sockets::socket_type::dgram uses the Datagram Protocol (xtd::net::sockets::protocol_type::udp) and the xtd::net::sockets::address_family::inter_network address family. /// @par Library @@ -33,7 +33,7 @@ constexpr int_least32_t SOCKET_TYPE_STREAM = 1; /// @ingroup xtd_core_native socket_type /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_TYPE_DGRAM = 2; +constexpr int32_t SOCKET_TYPE_DGRAM = 2; /// @brief Supports access to the underlying transport protocol. Using the xtd::net::sockets::socket_type::raw, you can communicate using protocols like Internet Control Message Protocol (xtd::net::sockets::protocol_type::icmp) and Internet Group Management Protocol (xtd::net::sockets::protocol_type::Igmp). Your application must provide a complete IP header when sending. Received datagrams return with the IP header and options intact. /// @par Library @@ -41,7 +41,7 @@ constexpr int_least32_t SOCKET_TYPE_DGRAM = 2; /// @ingroup xtd_core_native socket_type /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_TYPE_RAW = 3; +constexpr int32_t SOCKET_TYPE_RAW = 3; /// @brief Supports connectionless, message-oriented, reliably delivered messages, and preserves message boundaries in data. xtd::net::sockets::socket_type::rdm (Reliably Delivered Messages) messages arrive unique and in order. Furthermore, the sender is notified if messages are lost. If you initialize a xtd::net::sockets::socket using xtd::net::sockets::socket_type::rdm, you do not require a remote host connection before sending and receiving data. With xtd::net::sockets::socket_typerdm, you can communicate with multiple peers. /// @par Library @@ -49,7 +49,7 @@ constexpr int_least32_t SOCKET_TYPE_RAW = 3; /// @ingroup xtd_core_native socket_type /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_TYPE_RDM = 4; +constexpr int32_t SOCKET_TYPE_RDM = 4; /// @brief Provides connection-oriented and reliable two-way transfer of ordered byte streams across a network. xtd::net::sockets::socket_type::seqpacket does not duplicate data, and it preserves boundaries within the data stream. A xtd::net::sockets::socket of type xtd::net::sockets::socket_type::seqpacket communicates with a single peer and requires a remote host connection before communication can begin. /// @par Library @@ -57,4 +57,4 @@ constexpr int_least32_t SOCKET_TYPE_RDM = 4; /// @ingroup xtd_core_native socket_type /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr int_least32_t SOCKET_TYPE_SEQPACKET = 5; +constexpr int32_t SOCKET_TYPE_SEQPACKET = 5; diff --git a/src/xtd.core.native/include/xtd/native/sounds.h b/src/xtd.core.native/include/xtd/native/sounds.h index 177b38274c5..5c6664397fe 100644 --- a/src/xtd.core.native/include/xtd/native/sounds.h +++ b/src/xtd.core.native/include/xtd/native/sounds.h @@ -16,7 +16,7 @@ /// @ingroup xtd_core_native sound_type /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr uint_least32_t ST_OK = 0x00000000; +constexpr uint32_t ST_OK = 0x00000000; /// @brief The sound specified as the Windows Critical Stop sound. /// @par Library @@ -24,7 +24,7 @@ constexpr uint_least32_t ST_OK = 0x00000000; /// @ingroup xtd_core_native sound_type /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr uint_least32_t ST_ICONERROR = 0x00000010; +constexpr uint32_t ST_ICONERROR = 0x00000010; /// @brief See ST_ICONERROR. /// @par Library @@ -32,7 +32,7 @@ constexpr uint_least32_t ST_ICONERROR = 0x00000010; /// @ingroup xtd_core_native sound_type /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr uint_least32_t ST_ICONHAND = 0x00000010; +constexpr uint32_t ST_ICONHAND = 0x00000010; /// @brief See ST_ICONERROR. /// @par Library @@ -40,7 +40,7 @@ constexpr uint_least32_t ST_ICONHAND = 0x00000010; /// @ingroup xtd_core_native sound_type /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr uint_least32_t ST_ICONSTOP = 0x00000010; +constexpr uint32_t ST_ICONSTOP = 0x00000010; /// @brief The sound specified as the Windows Question sound. /// @par Library @@ -48,7 +48,7 @@ constexpr uint_least32_t ST_ICONSTOP = 0x00000010; /// @ingroup xtd_core_native sound_type /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr uint_least32_t ST_ICONQUESTION = 0x00000020; +constexpr uint32_t ST_ICONQUESTION = 0x00000020; /// @brief The sound specified as the Windows Exclamation sound. /// @par Library @@ -56,7 +56,7 @@ constexpr uint_least32_t ST_ICONQUESTION = 0x00000020; /// @ingroup xtd_core_native sound_type /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr uint_least32_t ST_ICONWARNING = 0x00000030; +constexpr uint32_t ST_ICONWARNING = 0x00000030; /// @brief See ST_ICONWARNING. /// @par Library @@ -64,7 +64,7 @@ constexpr uint_least32_t ST_ICONWARNING = 0x00000030; /// @ingroup xtd_core_native sound_type /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr uint_least32_t ST_ICONEXCLAMATION = 0x00000030; +constexpr uint32_t ST_ICONEXCLAMATION = 0x00000030; /// @brief The sound specified as the Windows Asterisk sound. /// @par Library @@ -72,7 +72,7 @@ constexpr uint_least32_t ST_ICONEXCLAMATION = 0x00000030; /// @ingroup xtd_core_native sound_type /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr uint_least32_t ST_ICONINFORMATION = 0x00000040; +constexpr uint32_t ST_ICONINFORMATION = 0x00000040; /// @brief See ST_ICONINFORMATION. /// @par Library @@ -80,7 +80,7 @@ constexpr uint_least32_t ST_ICONINFORMATION = 0x00000040; /// @ingroup xtd_core_native sound_type /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr uint_least32_t ST_ICONASTERISK = 0x00000040; +constexpr uint32_t ST_ICONASTERISK = 0x00000040; /// @brief A simple beep. If the sound card is not available, the sound is generated using the speaker. /// @par Library @@ -88,4 +88,4 @@ constexpr uint_least32_t ST_ICONASTERISK = 0x00000040; /// @ingroup xtd_core_native sound_type /// @remarks Added specifically for xtd. /// @warning Internal use only -constexpr uint_least32_t ST_BEEP = 0xFFFFFFFF; +constexpr uint32_t ST_BEEP = 0xFFFFFFFF; diff --git a/src/xtd.core.native/include/xtd/native/system_sound.h b/src/xtd.core.native/include/xtd/native/system_sound.h index e65ec9d3c1e..873e5fc0583 100644 --- a/src/xtd.core.native/include/xtd/native/system_sound.h +++ b/src/xtd.core.native/include/xtd/native/system_sound.h @@ -40,7 +40,7 @@ namespace xtd { /// @brief Play system sound. /// @param sound The sound to play (see souund.h). /// @warning Internal use only - static void play(uint_least32_t sound); + static void play(uint32_t sound); /// @} }; } diff --git a/src/xtd.core.native/include/xtd/native/thread.h b/src/xtd.core.native/include/xtd/native/thread.h index 51023b00079..6f4a67b563b 100644 --- a/src/xtd.core.native/include/xtd/native/thread.h +++ b/src/xtd.core.native/include/xtd/native/thread.h @@ -51,7 +51,7 @@ namespace xtd { /// @param max_stack_size The maximum stack size, in bytes, to be used by the thread, or 0 to use the default maximum stack size specified in the header for the executable. /// @return The thread handle. /// @warning Internal use only - static intmax_t create(std::function start, intmax_t obj, int_least32_t max_stack_size, bool suspended, intmax_t& id); + static intmax_t create(std::function start, intmax_t obj, int32_t max_stack_size, bool suspended, intmax_t& id); /// @brief Detach thread with specified handle. /// @param handle The thread handle. @@ -99,13 +99,13 @@ namespace xtd { /// * 2 : normal /// * 3 : above_normal /// * 4 : highest - static bool set_priority(intmax_t handle, int_least32_t priority); + static bool set_priority(intmax_t handle, int32_t priority); /// @brief Suspends the current thread for a specified time. /// @param milliseconds_timeout The number of milliseconds for which the thread is blocked. Specify zero (0) to indicate that this thread should be suspended to allow other waiting threads to execute. Specify -1 to block the thread indefinitely. /// @return true if succeed; otherwise false. /// @warning Internal use only - static void sleep(int_least32_t milliseconds_timeout); + static void sleep(int32_t milliseconds_timeout); /// @brief Suspend thread with specified handle. /// @param handle The thread handle. diff --git a/src/xtd.core.native/include/xtd/native/unnamed_event_wait_handle.h b/src/xtd.core.native/include/xtd/native/unnamed_event_wait_handle.h index cd97f79f2e3..6e3eae51885 100644 --- a/src/xtd.core.native/include/xtd/native/unnamed_event_wait_handle.h +++ b/src/xtd.core.native/include/xtd/native/unnamed_event_wait_handle.h @@ -74,7 +74,7 @@ namespace xtd { /// * 0x00000102 : Timeout /// * 0xFFFFFFFF : Failed /// @warning Internal use only - static uint_least32_t wait(intmax_t handle, int_least32_t milliseconds_timeout, bool manual_reset); + static uint32_t wait(intmax_t handle, int32_t milliseconds_timeout, bool manual_reset); /// @} }; } diff --git a/src/xtd.core.native/include/xtd/native/unnamed_mutex.h b/src/xtd.core.native/include/xtd/native/unnamed_mutex.h index 9eab766f675..cc5a7658c50 100644 --- a/src/xtd.core.native/include/xtd/native/unnamed_mutex.h +++ b/src/xtd.core.native/include/xtd/native/unnamed_mutex.h @@ -67,7 +67,7 @@ namespace xtd { /// * 0x00000102 : Timeout /// * 0xFFFFFFFF : Failed /// @warning Internal use only - static uint_least32_t wait(intmax_t handle, int_least32_t milliseconds_timeout); + static uint32_t wait(intmax_t handle, int32_t milliseconds_timeout); /// @} }; } diff --git a/src/xtd.core.native/include/xtd/native/unnamed_semaphore.h b/src/xtd.core.native/include/xtd/native/unnamed_semaphore.h index a57aac3e05b..334c0c6c401 100644 --- a/src/xtd.core.native/include/xtd/native/unnamed_semaphore.h +++ b/src/xtd.core.native/include/xtd/native/unnamed_semaphore.h @@ -42,7 +42,7 @@ namespace xtd { /// @brief Create named semaphore with specified initial count and maxixum count. /// @return The handle of the created semaphore. /// @warning Internal use only - static intmax_t create(int_least32_t initial_count, int_least32_t max_count); + static intmax_t create(int32_t initial_count, int32_t max_count); /// @brief Destroy named semaphore with specified semaphore handle. /// @param name The name of the semaphore. @@ -60,7 +60,7 @@ namespace xtd { /// @param handle The semaphore handle to signal. /// @return true if succeed; otherwhise false. /// @warning Internal use only - static bool signal(intmax_t handle, int_least32_t release_count, int_least32_t& previous_count, bool& io_error); + static bool signal(intmax_t handle, int32_t release_count, int32_t& previous_count, bool& io_error); /// @brief Wait named semaphore with specified semaphore handle and timeout. /// @param handle The semaphore handle to wait. @@ -71,7 +71,7 @@ namespace xtd { /// * 0x00000102 : Timeout /// * 0xFFFFFFFF : Failed /// @warning Internal use only - static uint_least32_t wait(intmax_t handle, int_least32_t milliseconds_timeout); + static uint32_t wait(intmax_t handle, int32_t milliseconds_timeout); /// @} }; } diff --git a/src/xtd.core.native/include/xtd/native/value_types.h b/src/xtd.core.native/include/xtd/native/value_types.h index 4a1329feece..45451592e25 100644 --- a/src/xtd.core.native/include/xtd/native/value_types.h +++ b/src/xtd.core.native/include/xtd/native/value_types.h @@ -13,15 +13,15 @@ #if defined(_LP64) && !defined(__APPLE__) && (defined(_POSIX_VERSION) || defined(__ANDROID__) || defined(__CYGWIN__) || defined(__linux__) || defined(__MSYS__) || defined(__unix__)) /// @brief Represents a 32-bit or 64-bit signed integer. /// @warning Internal use only -using __slong__ = signed long long int; // Workaround : On Linux and Unix 64 bits unfortunately 'int_least64_t' is an alias on 'long' and not on 'long long int' as other platforms. In order to avoid conflicts in operator or method overloads, it is necessary to give the type that is not taken into account. +using __slong__ = signed long long int; // Workaround : On Linux and Unix 64 bits unfortunately 'int64_t' is an alias on 'long' and not on 'long long int' as other platforms. In order to avoid conflicts in operator or method overloads, it is necessary to give the type that is not taken into account. /// @brief Represents a 32-bit or 64-bit unsigned integer. /// @warning Internal use only -using __ulong__ = unsigned long long int; // Workaround : On Linux and Unix 64 bits unfortunately 'uint_least64_t' is an alias on 'unigned long' and not on 'unsigned long long int' as other platforms. In order to avoid conflicts in operator or method overloads, it is necessary to give the type that is not taken into account. +using __ulong__ = unsigned long long int; // Workaround : On Linux and Unix 64 bits unfortunately 'uint64_t' is an alias on 'unigned long' and not on 'unsigned long long int' as other platforms. In order to avoid conflicts in operator or method overloads, it is necessary to give the type that is not taken into account. #else /// @brief Represents a 32-bit or 64-bit signed integer. /// @warning Internal use only -using __slong__ = signed long; // Workaround : On linux 64 bits unfortunately 'int_least64_t' is an alias on 'long' and not on 'long long int' as other platforms. In order to avoid conflicts in operator or method overloads, it is necessary to give the type that is not taken into account. +using __slong__ = signed long; // Workaround : On linux 64 bits unfortunately 'int64_t' is an alias on 'long' and not on 'long long int' as other platforms. In order to avoid conflicts in operator or method overloads, it is necessary to give the type that is not taken into account. /// @brief Represents a 32-bit or 64-bit unsigned integer. /// @warning Internal use only -using __ulong__ = unsigned long; // Workaround : On linux 64 bits unfortunately 'uint_least64_t' is an alias on 'unigned long' and not on 'unsigned long long int' as other platforms. In order to avoid conflicts in operator or method overloads, it is necessary to give the type that is not taken into account. +using __ulong__ = unsigned long; // Workaround : On linux 64 bits unfortunately 'uint64_t' is an alias on 'unigned long' and not on 'unsigned long long int' as other platforms. In order to avoid conflicts in operator or method overloads, it is necessary to give the type that is not taken into account. #endif diff --git a/src/xtd.core/include/xtd/byte.h b/src/xtd.core/include/xtd/byte.h index 7301259d23c..2e426666a84 100644 --- a/src/xtd.core/include/xtd/byte.h +++ b/src/xtd.core/include/xtd/byte.h @@ -20,6 +20,6 @@ namespace xtd { /// xtd.core /// @ingroup xtd_core types /// @remarks For more information about types, see [Native types, boxing and unboxing](https://gammasoft71.github.io/xtd/docs/documentation/Guides/xtd.core/Types%20overview/types). - using byte = uint_least8_t; + using byte = uint8_t; /// @} } diff --git a/src/xtd.core/include/xtd/int16.h b/src/xtd.core/include/xtd/int16.h index 6376802f30c..0e996a06376 100644 --- a/src/xtd.core/include/xtd/int16.h +++ b/src/xtd.core/include/xtd/int16.h @@ -20,6 +20,6 @@ namespace xtd { /// xtd.core /// @ingroup xtd_core types /// @remarks For more information about types, see [Native types, boxing and unboxing](https://gammasoft71.github.io/xtd/docs/documentation/Guides/xtd.core/Types%20overview/types). - using int16 = int_least16_t; + using int16 = int16_t; /// @} } diff --git a/src/xtd.core/include/xtd/int32.h b/src/xtd.core/include/xtd/int32.h index 95ea2207cb5..1cf80ae1dac 100644 --- a/src/xtd.core/include/xtd/int32.h +++ b/src/xtd.core/include/xtd/int32.h @@ -20,6 +20,6 @@ namespace xtd { /// xtd.core /// @ingroup xtd_core types /// @remarks For more information about types, see [Native types, boxing and unboxing](https://gammasoft71.github.io/xtd/docs/documentation/Guides/xtd.core/Types%20overview/types). - using int32 = int_least32_t; + using int32 = int32_t; /// @} } diff --git a/src/xtd.core/include/xtd/int64.h b/src/xtd.core/include/xtd/int64.h index 48946b3ba05..f7255bacba8 100644 --- a/src/xtd.core/include/xtd/int64.h +++ b/src/xtd.core/include/xtd/int64.h @@ -20,6 +20,6 @@ namespace xtd { /// xtd.core /// @ingroup xtd_core types /// @remarks For more information about types, see [Native types, boxing and unboxing](https://gammasoft71.github.io/xtd/docs/documentation/Guides/xtd.core/Types%20overview/types). - using int64 = int_least64_t; + using int64 = int64_t; /// @} } diff --git a/src/xtd.core/include/xtd/sbyte.h b/src/xtd.core/include/xtd/sbyte.h index 93e86146b63..a51cdc0d795 100644 --- a/src/xtd.core/include/xtd/sbyte.h +++ b/src/xtd.core/include/xtd/sbyte.h @@ -20,6 +20,6 @@ namespace xtd { /// xtd.core /// @ingroup xtd_core types /// @remarks For more information about types, see [Native types, boxing and unboxing](https://gammasoft71.github.io/xtd/docs/documentation/Guides/xtd.core/Types%20overview/types). - using sbyte = int_least8_t; + using sbyte = int8_t; /// @} } diff --git a/src/xtd.core/include/xtd/slong.h b/src/xtd.core/include/xtd/slong.h index cc676dbe2f1..6044d0c6ac9 100644 --- a/src/xtd.core/include/xtd/slong.h +++ b/src/xtd.core/include/xtd/slong.h @@ -24,6 +24,6 @@ namespace xtd { /// xtd.core /// @ingroup xtd_core types /// @remarks For more information about types, see [Native types, boxing and unboxing](https://gammasoft71.github.io/xtd/docs/documentation/Guides/xtd.core/Types%20overview/types). - using slong = __slong__; // Workaround : On linux 64 bits unfortunately 'int_least64_t' is an alias on 'long' and not on 'long long int' as other platforms. In order to avoid conflicts in operator or method overloads, it is necessary to give the type that is not taken into account. + using slong = __slong__; // Workaround : On linux 64 bits unfortunately 'int64_t' is an alias on 'long' and not on 'long long int' as other platforms. In order to avoid conflicts in operator or method overloads, it is necessary to give the type that is not taken into account. /// @} } diff --git a/src/xtd.core/include/xtd/uint16.h b/src/xtd.core/include/xtd/uint16.h index 7c9b0668e2d..32eae88db8f 100644 --- a/src/xtd.core/include/xtd/uint16.h +++ b/src/xtd.core/include/xtd/uint16.h @@ -20,6 +20,6 @@ namespace xtd { /// xtd.core /// @ingroup xtd_core types /// @remarks For more information about types, see [Native types, boxing and unboxing](https://gammasoft71.github.io/xtd/docs/documentation/Guides/xtd.core/Types%20overview/types). - using uint16 = uint_least16_t; + using uint16 = uint16_t; /// @} } diff --git a/src/xtd.core/include/xtd/uint32.h b/src/xtd.core/include/xtd/uint32.h index e82e388fdb9..b444d3ae519 100644 --- a/src/xtd.core/include/xtd/uint32.h +++ b/src/xtd.core/include/xtd/uint32.h @@ -20,6 +20,6 @@ namespace xtd { /// xtd.core /// @ingroup xtd_core types /// @remarks For more information about types, see [Native types, boxing and unboxing](https://gammasoft71.github.io/xtd/docs/documentation/Guides/xtd.core/Types%20overview/types). - using uint32 = uint_least32_t; + using uint32 = uint32_t; /// @} } diff --git a/src/xtd.core/include/xtd/uint64.h b/src/xtd.core/include/xtd/uint64.h index 5b0a05564d3..e37fb4cf363 100644 --- a/src/xtd.core/include/xtd/uint64.h +++ b/src/xtd.core/include/xtd/uint64.h @@ -20,6 +20,6 @@ namespace xtd { /// xtd.core /// @ingroup xtd_core types /// @remarks For more information about types, see [Native types, boxing and unboxing](https://gammasoft71.github.io/xtd/docs/documentation/Guides/xtd.core/Types%20overview/types). - using uint64 = uint_least64_t; + using uint64 = uint64_t; /// @} } diff --git a/src/xtd.core/include/xtd/ulong.h b/src/xtd.core/include/xtd/ulong.h index f4eec908cab..ca9c45c218d 100644 --- a/src/xtd.core/include/xtd/ulong.h +++ b/src/xtd.core/include/xtd/ulong.h @@ -21,6 +21,6 @@ namespace xtd { /// xtd.core /// @ingroup xtd_core types /// @remarks For more information about types, see [Native types, boxing and unboxing](https://gammasoft71.github.io/xtd/docs/documentation/Guides/xtd.core/Types%20overview/types). - using ulong = __ulong__; // Workaround : On linux 64 bits unfortunately 'uint_least64_t' is an alias on 'unigned long' and not on 'unsigned long long int' as other platforms. In order to avoid conflicts in operator or method overloads, it is necessary to give the type that is not taken into account. + using ulong = __ulong__; // Workaround : On linux 64 bits unfortunately 'uint64_t' is an alias on 'unigned long' and not on 'unsigned long long int' as other platforms. In order to avoid conflicts in operator or method overloads, it is necessary to give the type that is not taken into account. /// @} } diff --git a/src/xtd.drawing.native.fltk/include/xtd/drawing/native/fl_dc.h b/src/xtd.drawing.native.fltk/include/xtd/drawing/native/fl_dc.h index fe302166c7f..a610b5327e4 100644 --- a/src/xtd.drawing.native.fltk/include/xtd/drawing/native/fl_dc.h +++ b/src/xtd.drawing.native.fltk/include/xtd/drawing/native/fl_dc.h @@ -31,7 +31,7 @@ namespace xtd::drawing::native { public: virtual ~fl_dc() {} - int_least32_t ascent(Fl_Font font, Fl_Fontsize font_size) { + int32_t ascent(Fl_Font font, Fl_Fontsize font_size) { context c; fl_font(font, font_size); return font_size - fl_descent(); @@ -41,55 +41,55 @@ namespace xtd::drawing::native { fl_draw_box(Fl_Boxtype::FL_FLAT_BOX, x_, y_, w_, h_, color); } - int_least32_t descent(Fl_Font font, Fl_Fontsize font_size) { + int32_t descent(Fl_Font font, Fl_Fontsize font_size) { context c; fl_font(font, font_size); return fl_descent(); } - void draw_arc(Fl_Color color, int thick, int style, int_least32_t x, int_least32_t y, int_least32_t w, int_least32_t h, int_least32_t start_angle, int_least32_t sweep_angle) { + void draw_arc(Fl_Color color, int thick, int style, int32_t x, int32_t y, int32_t w, int32_t h, int32_t start_angle, int32_t sweep_angle) { context c; fl_color(color); fl_line_style(style, thick); fl_arc(x_ + x, y_ + y, w, h, start_angle, start_angle + sweep_angle); } - void draw_bezier(Fl_Color color, int thick, int style, int_least32_t x1, int_least32_t y1, int_least32_t x2, int_least32_t y2, int_least32_t x3, int_least32_t y3, int_least32_t x4, int_least32_t y4) { + void draw_bezier(Fl_Color color, int thick, int style, int32_t x1, int32_t y1, int32_t x2, int32_t y2, int32_t x3, int32_t y3, int32_t x4, int32_t y4) { context c; fl_color(color); fl_line_style(style, thick); fl_curve(x_ + x1, y_ + y1, x_ + x2, y_ + y2, x_ + x3, y_ + y3, x_ + x4, y_ + y4); } - void draw_ellipse(Fl_Color color, int thick, int style, int_least32_t x, int_least32_t y, int_least32_t w, int_least32_t h) { + void draw_ellipse(Fl_Color color, int thick, int style, int32_t x, int32_t y, int32_t w, int32_t h) { context c; fl_color(color); fl_line_style(style, thick); fl_arc(x_ + x, y_ + y, w, h, 0, 360); } - void draw_line(Fl_Color color, int thick, int style, int_least32_t x1, int_least32_t y1, int_least32_t x2, int_least32_t y2) { + void draw_line(Fl_Color color, int thick, int style, int32_t x1, int32_t y1, int32_t x2, int32_t y2) { context c; fl_color(color); fl_line_style(style, thick); fl_line(x_ + x1, y_ + y1, x_ + x2, y_ + y2); } - void draw_rectangle(Fl_Color color, int thick, int style, int_least32_t x, int_least32_t y, int_least32_t w, int_least32_t h) { + void draw_rectangle(Fl_Color color, int thick, int style, int32_t x, int32_t y, int32_t w, int32_t h) { context c; fl_color(color); fl_line_style(style, thick); fl_rect(x_ + x, y_ + y, w, h); } - void draw_string(const std::string& text, int_least32_t x, int_least32_t y, Fl_Font font, Fl_Fontsize font_size, Fl_Color color) { + void draw_string(const std::string& text, int32_t x, int32_t y, Fl_Font font, Fl_Fontsize font_size, Fl_Color color) { context c; fl_color(color); fl_font(font, font_size); fl_draw(text.c_str(), x_ + x, y_ + y + font_size); } - void draw_string(const std::string& text, int_least32_t x1, int_least32_t y1, int_least32_t x2, int_least32_t y2, Fl_Font font, Fl_Fontsize font_size, Fl_Color color) { + void draw_string(const std::string& text, int32_t x1, int32_t y1, int32_t x2, int32_t y2, Fl_Font font, Fl_Fontsize font_size, Fl_Color color) { context c; fl_push_clip(x_ + x1, y_ + y2, x_ + x2, y_ + y2); fl_color(color); @@ -98,33 +98,33 @@ namespace xtd::drawing::native { fl_pop_clip(); } - void fill_ellipse(Fl_Color color, int_least32_t x, int_least32_t y, int_least32_t w, int_least32_t h) { + void fill_ellipse(Fl_Color color, int32_t x, int32_t y, int32_t w, int32_t h) { context c; fl_color(color); fl_pie(x_ + x, y_ + y, w, h, 0, 360); } - void fill_pie(Fl_Color color, int_least32_t x, int_least32_t y, int_least32_t w, int_least32_t h, int_least32_t start_angle, int_least32_t sweep_angle) { + void fill_pie(Fl_Color color, int32_t x, int32_t y, int32_t w, int32_t h, int32_t start_angle, int32_t sweep_angle) { context c; fl_color(color); fl_pie(x_ + x, y_ + y, w, h, start_angle, start_angle + sweep_angle); } - void fill_rectangle(Fl_Color color, int_least32_t x, int_least32_t y, int_least32_t w, int_least32_t h) { + void fill_rectangle(Fl_Color color, int32_t x, int32_t y, int32_t w, int32_t h) { fl_draw_box(Fl_Boxtype::FL_FLAT_BOX, x_ + x, y_ + x, w, h, color); } - void measure_string(const std::string& text, Fl_Font font, Fl_Fontsize font_size, int_least32_t& width, int_least32_t& height) { + void measure_string(const std::string& text, Fl_Font font, Fl_Fontsize font_size, int32_t& width, int32_t& height) { context c; fl_font(font, font_size); fl_measure(text.c_str(), width, height); } protected: - int_least32_t x_ = 0; - int_least32_t y_ = 0; - int_least32_t w_ = 0; - int_least32_t h_ = 0; + int32_t x_ = 0; + int32_t y_ = 0; + int32_t w_ = 0; + int32_t h_ = 0; }; class fl_paint_dc : public fl_dc { diff --git a/src/xtd.drawing.native.fltk/include/xtd/drawing/native/fl_pen.h b/src/xtd.drawing.native.fltk/include/xtd/drawing/native/fl_pen.h index b8196be6fab..f2e97fe4762 100644 --- a/src/xtd.drawing.native.fltk/include/xtd/drawing/native/fl_pen.h +++ b/src/xtd.drawing.native.fltk/include/xtd/drawing/native/fl_pen.h @@ -6,21 +6,21 @@ namespace xtd::drawing::native { public: fl_pen() = default; fl_pen(Fl_Color color) : color_(color) {} - fl_pen(Fl_Color color, int_least32_t width) : color_(color), width_(width) {} - fl_pen(Fl_Color color, int_least32_t width, int_least32_t style) : color_(color), width_(width), style_(style) {} + fl_pen(Fl_Color color, int32_t width) : color_(color), width_(width) {} + fl_pen(Fl_Color color, int32_t width, int32_t style) : color_(color), width_(width), style_(style) {} Fl_Color color() const {return this->color_;} void color(Fl_Color color) {this->color_ = color;} - int_least32_t style() const {return this->width_;} - void style(int_least32_t style) {this->style_ = style;} + int32_t style() const {return this->width_;} + void style(int32_t style) {this->style_ = style;} - int_least32_t width() const {return this->width_;} - void width(int_least32_t width) {this->width_ = width;} + int32_t width() const {return this->width_;} + void width(int32_t width) {this->width_ = width;} private: Fl_Color color_ = FL_BLACK; - int_least32_t width_ = 1; + int32_t width_ = 1; int style_ = FL_SOLID; }; } diff --git a/src/xtd.drawing.native.fltk/src/xtd/drawing/native/fltk/brush.cpp b/src/xtd.drawing.native.fltk/src/xtd/drawing/native/fltk/brush.cpp index 272ceb5be99..c99166b67b7 100644 --- a/src/xtd.drawing.native.fltk/src/xtd/drawing/native/fltk/brush.cpp +++ b/src/xtd.drawing.native.fltk/src/xtd/drawing/native/fltk/brush.cpp @@ -7,7 +7,7 @@ intmax_t brush::create() { return reinterpret_cast(new fl_brush()); } -void brush::color(intmax_t brush, uint_least8_t a, uint_least8_t r, uint_least8_t g, uint_least8_t b) { +void brush::color(intmax_t brush, uint8_t a, uint8_t r, uint8_t g, uint8_t b) { reinterpret_cast(brush)->color(fl_rgb_color(r, g, b)); } diff --git a/src/xtd.drawing.native.fltk/src/xtd/drawing/native/fltk/font.cpp b/src/xtd.drawing.native.fltk/src/xtd/drawing/native/fltk/font.cpp index 2c9a30803c0..ccc9c99d2a0 100644 --- a/src/xtd.drawing.native.fltk/src/xtd/drawing/native/fltk/font.cpp +++ b/src/xtd.drawing.native.fltk/src/xtd/drawing/native/fltk/font.cpp @@ -39,7 +39,7 @@ namespace { } } -intmax_t font::create(const std::string& name, float em_size, bool bold, bool italic, bool underline, bool strikeout, uint_least8_t gdi_char_set, bool gdi_vertical_font) { +intmax_t font::create(const std::string& name, float em_size, bool bold, bool italic, bool underline, bool strikeout, uint8_t gdi_char_set, bool gdi_vertical_font) { return reinterpret_cast(new xtd::drawing::native::fl_font(fonts()[name], points_to_native_font_graphics_untit(em_size))); } @@ -55,13 +55,13 @@ void font::destroy(intmax_t font) { delete reinterpret_cast(font); } -int_least32_t font::dpi() { +int32_t font::dpi() { float h = 0, v = 0; Fl::screen_dpi(h, v); - return static_cast(v); + return static_cast(v); } -void font::get_information(intmax_t font, std::string& name, float& em_size, bool& bold, bool& italic, bool& underline, bool& strikeout, uint_least8_t& gdi_char_set, bool& gdi_vertical_font) { +void font::get_information(intmax_t font, std::string& name, float& em_size, bool& bold, bool& italic, bool& underline, bool& strikeout, uint8_t& gdi_char_set, bool& gdi_vertical_font) { xtd::drawing::native::fl_font* fl_font = reinterpret_cast(font); std::string font_name = Fl::get_font_name(fl_font->font()); name = xtd::strings::replace(xtd::strings::replace(xtd::strings::replace(xtd::strings::replace(font_name, " Italic", ""), " italic", ""), " Bold", ""), " bold", ""); diff --git a/src/xtd.drawing.native.fltk/src/xtd/drawing/native/fltk/font_family.cpp b/src/xtd.drawing.native.fltk/src/xtd/drawing/native/fltk/font_family.cpp index 254a9898f16..53c001ad706 100644 --- a/src/xtd.drawing.native.fltk/src/xtd/drawing/native/fltk/font_family.cpp +++ b/src/xtd.drawing.native.fltk/src/xtd/drawing/native/fltk/font_family.cpp @@ -59,23 +59,23 @@ std::vector font_family::installed_font_families() { return std::vector(families().begin(), families().end()); } -int_least32_t font_family::get_cell_ascent(intmax_t font_family, int_least32_t em_height, bool bold, bool italic, bool underline, bool strikeout) { +int32_t font_family::get_cell_ascent(intmax_t font_family, int32_t em_height, bool bold, bool italic, bool underline, bool strikeout) { fl_screen_dc screen_dc; fl_font font(font_family, em_height); return screen_dc.ascent(font.font(), pixel_to_native_font_graphics_untit(font.size())); } -int_least32_t font_family::get_cell_descent(intmax_t font_family, int_least32_t em_height, bool bold, bool italic, bool underline, bool strikeout) { +int32_t font_family::get_cell_descent(intmax_t font_family, int32_t em_height, bool bold, bool italic, bool underline, bool strikeout) { fl_screen_dc screen_dc; fl_font font(font_family, em_height); return screen_dc.descent(font.font(), pixel_to_native_font_graphics_untit(font.size())); } -int_least32_t font_family::get_line_spacing(intmax_t font_family, int_least32_t em_height, bool bold, bool italic, bool underline, bool strikeout) { +int32_t font_family::get_line_spacing(intmax_t font_family, int32_t em_height, bool bold, bool italic, bool underline, bool strikeout) { return 0; } -std::string font_family::get_name(intmax_t font_family, int_least32_t language) { +std::string font_family::get_name(intmax_t font_family, int32_t language) { return *reinterpret_cast(font_family); } diff --git a/src/xtd.drawing.native.fltk/src/xtd/drawing/native/fltk/graphics.cpp b/src/xtd.drawing.native.fltk/src/xtd/drawing/native/fltk/graphics.cpp index 1d8e12390b0..9a4be6f8846 100644 --- a/src/xtd.drawing.native.fltk/src/xtd/drawing/native/fltk/graphics.cpp +++ b/src/xtd.drawing.native.fltk/src/xtd/drawing/native/fltk/graphics.cpp @@ -7,22 +7,22 @@ using namespace xtd::drawing::native; -void graphics::clear(intmax_t hdc, uint_least8_t a, uint_least8_t r, uint_least8_t g, uint_least8_t b) { +void graphics::clear(intmax_t hdc, uint8_t a, uint8_t r, uint8_t g, uint8_t b) { if (hdc == 0) return; reinterpret_cast(hdc)->clear(fl_rgb_color(r, g, b)); } -void graphics::draw_arc(intmax_t hdc, intmax_t pen, int_least32_t x, int_least32_t y, int_least32_t width, int_least32_t height, int_least32_t start_angle, int_least32_t sweep_angle) { +void graphics::draw_arc(intmax_t hdc, intmax_t pen, int32_t x, int32_t y, int32_t width, int32_t height, int32_t start_angle, int32_t sweep_angle) { if (!hdc) return; reinterpret_cast(hdc)->draw_arc(reinterpret_cast(pen)->color(), reinterpret_cast(pen)->width(), reinterpret_cast(pen)->style(), x, y, width, height, start_angle, sweep_angle); } -void graphics::draw_bezier(intmax_t hdc, intmax_t pen, int_least32_t x1, int_least32_t y1, int_least32_t x2, int_least32_t y2, int_least32_t x3, int_least32_t y3, int_least32_t x4, int_least32_t y4) { +void graphics::draw_bezier(intmax_t hdc, intmax_t pen, int32_t x1, int32_t y1, int32_t x2, int32_t y2, int32_t x3, int32_t y3, int32_t x4, int32_t y4) { if (!hdc) return; reinterpret_cast(hdc)->draw_bezier(reinterpret_cast(pen)->color(), reinterpret_cast(pen)->width(), reinterpret_cast(pen)->style(), x1, y1, x2, y2, x3, y3, x4, y4); } -void graphics::draw_ellipse(intmax_t hdc, intmax_t pen, int_least32_t x, int_least32_t y, int_least32_t width, int_least32_t height) { +void graphics::draw_ellipse(intmax_t hdc, intmax_t pen, int32_t x, int32_t y, int32_t width, int32_t height) { if (!hdc) return; reinterpret_cast(hdc)->draw_ellipse(reinterpret_cast(pen)->color(), reinterpret_cast(pen)->width(), reinterpret_cast(pen)->style(), x, y, width, height); } @@ -33,42 +33,42 @@ void graphics::destroy(intmax_t hdc) { delete fldc; } -void graphics::draw_line(intmax_t hdc, intmax_t pen, int_least32_t x1, int_least32_t y1, int_least32_t x2, int_least32_t y2) { +void graphics::draw_line(intmax_t hdc, intmax_t pen, int32_t x1, int32_t y1, int32_t x2, int32_t y2) { if (!hdc) return; reinterpret_cast(hdc)->draw_line(reinterpret_cast(pen)->color(), reinterpret_cast(pen)->width(), reinterpret_cast(pen)->style(), x1, y1, x2, y2); } -void graphics::draw_rectangle(intmax_t hdc, intmax_t pen, int_least32_t x, int_least32_t y, int_least32_t width, int_least32_t height) { +void graphics::draw_rectangle(intmax_t hdc, intmax_t pen, int32_t x, int32_t y, int32_t width, int32_t height) { if (!hdc) return; reinterpret_cast(hdc)->draw_rectangle(reinterpret_cast(pen)->color(), reinterpret_cast(pen)->width(), reinterpret_cast(pen)->style(), x, y, width, height); } -void graphics::draw_string(intmax_t hdc, const std::string& text, intmax_t font, int_least32_t x, int_least32_t y, uint_least8_t a, uint_least8_t r, uint_least8_t g, uint_least8_t b) { +void graphics::draw_string(intmax_t hdc, const std::string& text, intmax_t font, int32_t x, int32_t y, uint8_t a, uint8_t r, uint8_t g, uint8_t b) { if (!hdc) return; reinterpret_cast(hdc)->draw_string(text, x, y, reinterpret_cast(font)->font(), reinterpret_cast(font)->size(), fl_rgb_color(r, g, b)); } -void graphics::draw_string(intmax_t hdc, const std::string& text, intmax_t font, int_least32_t x, int_least32_t y, int_least32_t w, int_least32_t h, uint_least8_t a, uint_least8_t r, uint_least8_t g, uint_least8_t b) { +void graphics::draw_string(intmax_t hdc, const std::string& text, intmax_t font, int32_t x, int32_t y, int32_t w, int32_t h, uint8_t a, uint8_t r, uint8_t g, uint8_t b) { if (!hdc) return; reinterpret_cast(hdc)->draw_string(text, x, y, w, h, reinterpret_cast(font)->font(), reinterpret_cast(font)->size(), fl_rgb_color(r, g, b)); } -void graphics::fill_ellipse(intmax_t hdc, intmax_t brush, int_least32_t x, int_least32_t y, int_least32_t width, int_least32_t height) { +void graphics::fill_ellipse(intmax_t hdc, intmax_t brush, int32_t x, int32_t y, int32_t width, int32_t height) { if (!hdc) return; reinterpret_cast(hdc)->fill_ellipse(reinterpret_cast(brush)->color(), x, y, width, height); } -void graphics::fill_pie(intmax_t hdc, intmax_t brush, int_least32_t x, int_least32_t y, int_least32_t width, int_least32_t height, int_least32_t start_angle, int_least32_t sweep_angle) { +void graphics::fill_pie(intmax_t hdc, intmax_t brush, int32_t x, int32_t y, int32_t width, int32_t height, int32_t start_angle, int32_t sweep_angle) { if (!hdc) return; reinterpret_cast(hdc)->fill_pie(reinterpret_cast(brush)->color(), x, y, width, height, start_angle, sweep_angle); } -void graphics::fill_rectangle(intmax_t hdc, intmax_t brush, int_least32_t x, int_least32_t y, int_least32_t width, int_least32_t height) { +void graphics::fill_rectangle(intmax_t hdc, intmax_t brush, int32_t x, int32_t y, int32_t width, int32_t height) { if (!hdc) return; reinterpret_cast(hdc)->fill_rectangle(reinterpret_cast(brush)->color(), x, y, width, height); } -void graphics::measure_string(intmax_t hdc, const std::string& text, intmax_t font, int_least32_t& width, int_least32_t& height) { +void graphics::measure_string(intmax_t hdc, const std::string& text, intmax_t font, int32_t& width, int32_t& height) { if (!hdc) return; reinterpret_cast(hdc)->measure_string(text, reinterpret_cast(font)->font(), reinterpret_cast(font)->size(), width, height); } diff --git a/src/xtd.drawing.native.fltk/src/xtd/drawing/native/fltk/pen.cpp b/src/xtd.drawing.native.fltk/src/xtd/drawing/native/fltk/pen.cpp index 697bee1ddac..22b30dc7ff5 100644 --- a/src/xtd.drawing.native.fltk/src/xtd/drawing/native/fltk/pen.cpp +++ b/src/xtd.drawing.native.fltk/src/xtd/drawing/native/fltk/pen.cpp @@ -7,7 +7,7 @@ intmax_t pen::create() { return reinterpret_cast(new fl_pen()); } -void pen::color(intmax_t pen, uint_least8_t a, uint_least8_t r, uint_least8_t g, uint_least8_t b) { +void pen::color(intmax_t pen, uint8_t a, uint8_t r, uint8_t g, uint8_t b) { reinterpret_cast(pen)->color(fl_rgb_color(r, g, b)); } diff --git a/src/xtd.drawing.native.fltk/src/xtd/drawing/native/fltk/system_colors.cpp b/src/xtd.drawing.native.fltk/src/xtd/drawing/native/fltk/system_colors.cpp index 7f03f041897..97436225f4b 100644 --- a/src/xtd.drawing.native.fltk/src/xtd/drawing/native/fltk/system_colors.cpp +++ b/src/xtd.drawing.native.fltk/src/xtd/drawing/native/fltk/system_colors.cpp @@ -6,13 +6,13 @@ using namespace xtd::drawing::native; namespace { - uint_least32_t to_argb(Fl_Color color) { - return static_cast(color) >> 8; + uint32_t to_argb(Fl_Color color) { + return static_cast(color) >> 8; } } -uint_least32_t system_colors::to_argb(intmax_t color) { - return static_cast(color); +uint32_t system_colors::to_argb(intmax_t color) { + return static_cast(color); } intmax_t system_colors::active_border() { diff --git a/src/xtd.forms.native.cocoa/src/xtd/forms/native/cocoa/file_dialog.mm b/src/xtd.forms.native.cocoa/src/xtd/forms/native/cocoa/file_dialog.mm index a507634fb72..faa9c6ac662 100644 --- a/src/xtd.forms.native.cocoa/src/xtd/forms/native/cocoa/file_dialog.mm +++ b/src/xtd.forms.native.cocoa/src/xtd/forms/native/cocoa/file_dialog.mm @@ -153,7 +153,7 @@ static bool PatternCompare(const std::string& fileName, const std::vector filter_patterns = strings::split(filter, {'|'}); std::vector>> filters; if (filter_patterns.size() % 2 != 0) throw std::invalid_argument("Filter bad format"); - for (int_least32_t index = 0; index < filter_patterns.size(); index += 2) + for (int32_t index = 0; index < filter_patterns.size(); index += 2) filters.push_back({filter_patterns[index], strings::split(filter_patterns[index + 1], {';'})}); return filters; } @@ -181,8 +181,8 @@ static bool PatternCompare(const std::string& fileName, const std::vector fileNames((int_least32_t)[urls count]); - for (int_least32_t index = 0; index < (int_least32_t)[urls count]; index++) + std::vector fileNames((int32_t)[urls count]); + for (int32_t index = 0; index < (int32_t)[urls count]; index++) fileNames[index] = [[(NSURL*)[urls objectAtIndex:index] path] UTF8String]; file_name = fileNames[0]; file_names = fileNames; diff --git a/src/xtd.forms.native.cocoa/src/xtd/forms/native/cocoa/message_box.mm b/src/xtd.forms.native.cocoa/src/xtd/forms/native/cocoa/message_box.mm index 1a962826e8e..591ae59104b 100644 --- a/src/xtd.forms.native.cocoa/src/xtd/forms/native/cocoa/message_box.mm +++ b/src/xtd.forms.native.cocoa/src/xtd/forms/native/cocoa/message_box.mm @@ -10,8 +10,8 @@ using namespace xtd::forms::native; namespace { - constexpr int_least32_t MB_BUTTONS_MASK = 0x7; - constexpr int_least32_t MB_ICON_MASK = 0x70; + constexpr int32_t MB_BUTTONS_MASK = 0x7; + constexpr int32_t MB_ICON_MASK = 0x70; static void message_box_add_buttons_ok(NSAlert* alert) { [alert addButtonWithTitle:@"OK"]; @@ -44,16 +44,16 @@ static void message_box_add_buttons_retry_cancel(NSAlert* alert) { [alert addButtonWithTitle:@"Cancel"]; } - static int_least32_t message_box_show_modal_ok(NSAlert* alert) { + static int32_t message_box_show_modal_ok(NSAlert* alert) { [alert runModal]; return IDOK; } - static int_least32_t message_box_show_modal_ok_cancel(NSAlert* alert) { + static int32_t message_box_show_modal_ok_cancel(NSAlert* alert) { return [alert runModal] == NSAlertFirstButtonReturn ? IDOK : IDCANCEL; } - static int_least32_t message_box_show_modal_abort_retry_ignore(NSAlert* alert) { + static int32_t message_box_show_modal_abort_retry_ignore(NSAlert* alert) { NSModalResponse result = [alert runModal]; if (result == NSAlertFirstButtonReturn) return IDABORT; @@ -62,7 +62,7 @@ static int_least32_t message_box_show_modal_abort_retry_ignore(NSAlert* alert) { return IDIGNORE; } - static int_least32_t message_box_show_modal_yes_no_cancel(NSAlert* alert) { + static int32_t message_box_show_modal_yes_no_cancel(NSAlert* alert) { NSModalResponse result = [alert runModal]; if (result == NSAlertFirstButtonReturn) return IDYES; @@ -71,15 +71,15 @@ static int_least32_t message_box_show_modal_yes_no_cancel(NSAlert* alert) { return IDCANCEL; } - static int_least32_t message_box_show_modal_yes_no(NSAlert* alert) { + static int32_t message_box_show_modal_yes_no(NSAlert* alert) { return [alert runModal] == NSAlertFirstButtonReturn ? IDYES : IDNO; } - static int_least32_t message_box_show_modal_retry_cancel(NSAlert* alert) { + static int32_t message_box_show_modal_retry_cancel(NSAlert* alert) { return [alert runModal] == NSAlertFirstButtonReturn ? IDRETRY : IDCANCEL; } - static void add_buttons(uint_least32_t style, NSAlert* alert) { + static void add_buttons(uint32_t style, NSAlert* alert) { if ((style & MB_BUTTONS_MASK) == MB_RETRYCANCEL) message_box_add_buttons_retry_cancel(alert); else if ((style & MB_BUTTONS_MASK) == MB_YESNOCANCEL) message_box_add_buttons_yes_no_cancel(alert); else if ((style & MB_BUTTONS_MASK) == MB_YESNO) message_box_add_buttons_yes_no(alert); @@ -88,7 +88,7 @@ static void add_buttons(uint_least32_t style, NSAlert* alert) { else message_box_add_buttons_ok(alert); } - static NSAlertStyle convert_to_icon(int_least32_t style) { + static NSAlertStyle convert_to_icon(int32_t style) { if ((style & MB_ICON_MASK) == MB_ICONINFORMATION) return NSAlertStyleInformational; if ((style & MB_ICON_MASK) == MB_ICONEXCLAMATION) return NSAlertStyleCritical; if ((style & MB_ICON_MASK) == MB_ICONQUESTION) return NSAlertStyleInformational; @@ -96,7 +96,7 @@ static NSAlertStyle convert_to_icon(int_least32_t style) { return NSAlertStyleWarning; } - static int_least32_t show_modal(int_least32_t style, NSAlert* alert) { + static int32_t show_modal(int32_t style, NSAlert* alert) { if ((style & MB_BUTTONS_MASK) == MB_RETRYCANCEL) return message_box_show_modal_retry_cancel(alert); if ((style & MB_BUTTONS_MASK) == MB_YESNOCANCEL) return message_box_show_modal_yes_no_cancel(alert); if ((style & MB_BUTTONS_MASK) == MB_YESNO) return message_box_show_modal_yes_no(alert); @@ -106,7 +106,7 @@ static int_least32_t show_modal(int_least32_t style, NSAlert* alert) { } } -int_least32_t message_box::show(intmax_t control, const std::string& text, const std::string& caption, uint_least32_t style, bool displayHelpButton) { +int32_t message_box::show(intmax_t control, const std::string& text, const std::string& caption, uint32_t style, bool displayHelpButton) { @autoreleasepool { NSAlert* alert = [[NSAlert alloc] init]; add_buttons(style, alert); diff --git a/src/xtd.forms.native.fltk/src/xtd/forms/native/fltk/application.cpp b/src/xtd.forms.native.fltk/src/xtd/forms/native/fltk/application.cpp index 5a7b234b4ed..d0a19ebd9d6 100644 --- a/src/xtd.forms.native.fltk/src/xtd/forms/native/fltk/application.cpp +++ b/src/xtd.forms.native.fltk/src/xtd/forms/native/fltk/application.cpp @@ -66,11 +66,11 @@ void application::initialize() { } } -void application::register_message_filter(const delegate& message_filter_proc) { +void application::register_message_filter(const delegate& message_filter_proc) { initialize(); // Must be first } -void application::register_wnd_proc(const delegate& wnd_proc) { +void application::register_wnd_proc(const delegate& wnd_proc) { initialize(); // Must be first } diff --git a/src/xtd.forms.native.fltk/src/xtd/forms/native/fltk/color_dialog.cpp b/src/xtd.forms.native.fltk/src/xtd/forms/native/fltk/color_dialog.cpp index e1678c4ee0e..18eca6fd4e4 100644 --- a/src/xtd.forms.native.fltk/src/xtd/forms/native/fltk/color_dialog.cpp +++ b/src/xtd.forms.native.fltk/src/xtd/forms/native/fltk/color_dialog.cpp @@ -5,7 +5,7 @@ using namespace xtd; using namespace xtd::forms::native; -bool color_dialog::run_dialog(intmax_t hwnd, drawing::color& color, std::optional>& custom_colors, size_t options) { +bool color_dialog::run_dialog(intmax_t hwnd, drawing::color& color, std::optional>& custom_colors, size_t options) { uchar r = color.r(); uchar g = color.g(); uchar b = color.b(); diff --git a/src/xtd.forms.native.fltk/src/xtd/forms/native/fltk/control.cpp b/src/xtd.forms.native.fltk/src/xtd/forms/native/fltk/control.cpp index e8c9895989b..9acadd58d0f 100644 --- a/src/xtd.forms.native.fltk/src/xtd/forms/native/fltk/control.cpp +++ b/src/xtd.forms.native.fltk/src/xtd/forms/native/fltk/control.cpp @@ -27,7 +27,7 @@ using namespace xtd; using namespace xtd::drawing; using namespace xtd::forms::native; -extern int_least32_t __mainloop_runnning__; +extern int32_t __mainloop_runnning__; color control::back_color(intmax_t control) { if (control == 0) return color::empty; @@ -74,7 +74,7 @@ intmax_t control::create_graphics(intmax_t control) { return control; } -intmax_t control::def_wnd_proc(intmax_t control, intmax_t hwnd, int_least32_t msg, intmax_t wparam, intmax_t lparam, intmax_t presult, intmax_t handle) { +intmax_t control::def_wnd_proc(intmax_t control, intmax_t hwnd, int32_t msg, intmax_t wparam, intmax_t lparam, intmax_t presult, intmax_t handle) { if (!control || handle == 0) return 0; return reinterpret_cast(control)->call_def_wnd_proc(hwnd, msg, wparam, lparam, presult, handle); } @@ -233,17 +233,17 @@ void control::update(intmax_t control) { reinterpret_cast(control)->control()->redraw(); } -void control::register_wnd_proc(intmax_t control, const delegate& wnd_proc) { +void control::register_wnd_proc(intmax_t control, const delegate& wnd_proc) { if (control == 0) return; reinterpret_cast(control)->wnd_proc += wnd_proc; } -void control::unregister_wnd_proc(intmax_t control, const delegate& wnd_proc) { +void control::unregister_wnd_proc(intmax_t control, const delegate& wnd_proc) { if (control == 0) return; reinterpret_cast(control)->wnd_proc -= wnd_proc; } -intmax_t control::send_message(intmax_t control, intmax_t hwnd, int_least32_t msg, intmax_t wparam, intmax_t lparam) { +intmax_t control::send_message(intmax_t control, intmax_t hwnd, int32_t msg, intmax_t wparam, intmax_t lparam) { if (hwnd == 0) return -1; return reinterpret_cast(control)->send_message(hwnd, msg, wparam, lparam, 0); } diff --git a/src/xtd.forms.native.fltk/src/xtd/forms/native/fltk/control_handler.h b/src/xtd.forms.native.fltk/src/xtd/forms/native/fltk/control_handler.h index 587df3e19eb..75dc567fc93 100644 --- a/src/xtd.forms.native.fltk/src/xtd/forms/native/fltk/control_handler.h +++ b/src/xtd.forms.native.fltk/src/xtd/forms/native/fltk/control_handler.h @@ -26,7 +26,7 @@ namespace xtd { control_wrapper(control_handler* event_handler, args_type&& ...args) : TControl(args...), event_handler_(event_handler) {} - virtual int_least32_t handle(int_least32_t event); + virtual int32_t handle(int32_t event); private: intmax_t convert_to_virtual_key(intmax_t fl_key) { @@ -35,8 +35,8 @@ namespace xtd { control_handler* event_handler_; bool process_result_ = true; - int_least32_t height_ = 0; - int_least32_t width_ = 0; + int32_t height_ = 0; + int32_t width_ = 0; }; class control_handler { @@ -56,7 +56,7 @@ namespace xtd { Fl_Cursor cursor() const {return this->cursor_;} void cursor(Fl_Cursor cursor) {this->cursor_ = cursor;} - intmax_t call_def_wnd_proc(intmax_t hwnd, int_least32_t msg, intmax_t wparam, intmax_t lparam, intmax_t result, intmax_t handle) {return this->def_wnd_proc(hwnd, msg, wparam, lparam, result, handle);} + intmax_t call_def_wnd_proc(intmax_t hwnd, int32_t msg, intmax_t wparam, intmax_t lparam, intmax_t result, intmax_t handle) {return this->def_wnd_proc(hwnd, msg, wparam, lparam, result, handle);} void destroy() { delete this->control_; @@ -76,8 +76,8 @@ namespace xtd { return result; } - event> wnd_proc; - event> def_wnd_proc; + event> wnd_proc; + event> def_wnd_proc; private: Fl_Widget* control_ = nullptr; @@ -85,7 +85,7 @@ namespace xtd { }; template - inline int_least32_t control_wrapper::handle(int_least32_t event) { + inline int32_t control_wrapper::handle(int32_t event) { return this->control_t::handle(event); /* bool intercepted_event = this->control_t::handle(event) != 0; diff --git a/src/xtd.forms.native.fltk/src/xtd/forms/native/fltk/fl_timer.h b/src/xtd.forms.native.fltk/src/xtd/forms/native/fltk/fl_timer.h index 9ea83886af5..5f79eaefdcf 100644 --- a/src/xtd.forms.native.fltk/src/xtd/forms/native/fltk/fl_timer.h +++ b/src/xtd.forms.native.fltk/src/xtd/forms/native/fltk/fl_timer.h @@ -9,7 +9,7 @@ namespace xtd { public: fl_timer(delegate tick) : tick_(tick) {} - void Start(int_least32_t interval) { + void Start(int32_t interval) { enable_timer_ = true; interval_ = (double)interval / 1000; Fl::add_timeout(interval_, on_timer_tick); diff --git a/src/xtd.forms.native.fltk/src/xtd/forms/native/fltk/font_dialog.cpp b/src/xtd.forms.native.fltk/src/xtd/forms/native/fltk/font_dialog.cpp index 23ce622e7f9..70516985bb3 100644 --- a/src/xtd.forms.native.fltk/src/xtd/forms/native/fltk/font_dialog.cpp +++ b/src/xtd.forms.native.fltk/src/xtd/forms/native/fltk/font_dialog.cpp @@ -12,6 +12,6 @@ bool font_dialog::run_dialog(intmax_t hwnd, drawing::font& font, drawing::color& Fl_Color flcolor = fl_rgb_color(color.r(), color.g(), color.b()); if (fl_font_chooser("Font", flfont, flfontsize, flcolor) == 0) return false; font = drawing::font(reinterpret_cast(new drawing::native::fl_font(flfont, flfontsize))); - color = drawing::color::from_argb(static_cast(flcolor) >> 8); + color = drawing::color::from_argb(static_cast(flcolor) >> 8); return true; } diff --git a/src/xtd.forms.native.fltk/src/xtd/forms/native/fltk/form.cpp b/src/xtd.forms.native.fltk/src/xtd/forms/native/fltk/form.cpp index 50d3c90829c..8c7668b22bb 100644 --- a/src/xtd.forms.native.fltk/src/xtd/forms/native/fltk/form.cpp +++ b/src/xtd.forms.native.fltk/src/xtd/forms/native/fltk/form.cpp @@ -61,7 +61,7 @@ void form::restore(intmax_t form) { static_cast(reinterpret_cast(form)->control())->show(); } -int_least32_t form::show_dialog(intmax_t form) { +int32_t form::show_dialog(intmax_t form) { if (form == 0) return 0; static_cast(reinterpret_cast(form)->control())->set_modal(); static_cast(reinterpret_cast(form)->control())->show(); @@ -70,7 +70,7 @@ int_least32_t form::show_dialog(intmax_t form) { return reinterpret_cast(form)->dialog_result_; } -void form::end_dialog(intmax_t form, int_least32_t result) { +void form::end_dialog(intmax_t form, int32_t result) { if (form == 0) return; reinterpret_cast(form)->dialog_result_ = result; static_cast(reinterpret_cast(form)->control())->set_non_modal(); diff --git a/src/xtd.forms.native.fltk/src/xtd/forms/native/fltk/message_box.cpp b/src/xtd.forms.native.fltk/src/xtd/forms/native/fltk/message_box.cpp index 4dd35823cb8..b50287de973 100644 --- a/src/xtd.forms.native.fltk/src/xtd/forms/native/fltk/message_box.cpp +++ b/src/xtd.forms.native.fltk/src/xtd/forms/native/fltk/message_box.cpp @@ -12,7 +12,7 @@ using namespace xtd; using namespace xtd::forms::native; namespace { - int_least32_t result_for_ok_cancel(int_least32_t result) { + int32_t result_for_ok_cancel(int32_t result) { switch (result) { case 1: return IDOK; case 2: return IDCANCEL; @@ -20,7 +20,7 @@ namespace { return IDCANCEL; } - int_least32_t result_for_abort_retry_ignore(int_least32_t result) { + int32_t result_for_abort_retry_ignore(int32_t result) { switch (result) { case 0: return IDABORT; case 1: return IDRETRY; @@ -29,7 +29,7 @@ namespace { return IDCANCEL; } - int_least32_t result_for_yes_no_cancel(int_least32_t result) { + int32_t result_for_yes_no_cancel(int32_t result) { switch (result) { case 0: return IDYES; case 1: return IDNO; @@ -38,7 +38,7 @@ namespace { return IDCANCEL; } - int_least32_t result_for_yes_no(int_least32_t result) { + int32_t result_for_yes_no(int32_t result) { switch (result) { case 1: return IDYES; case 2: return IDNO; @@ -46,7 +46,7 @@ namespace { return IDCANCEL; } - int_least32_t result_for_retry_cancel(int_least32_t result) { + int32_t result_for_retry_cancel(int32_t result) { switch (result) { case 1: return IDRETRY; case 2: return IDCANCEL; @@ -54,7 +54,7 @@ namespace { return IDCANCEL; } - int_least32_t convert_to_dialog_result(int_least32_t result, uint_least32_t style) { + int32_t convert_to_dialog_result(int32_t result, uint32_t style) { if ((style & MB_OKCANCEL) == MB_OKCANCEL) return result_for_ok_cancel(result); if ((style & MB_ABORTRETRYIGNORE) == MB_ABORTRETRYIGNORE) return result_for_abort_retry_ignore(result); if ((style & MB_YESNOCANCEL) == MB_YESNOCANCEL) return result_for_yes_no_cancel(result); @@ -63,7 +63,7 @@ namespace { return IDCANCEL; } - vector convert_to_buttons(uint_least32_t style) { + vector convert_to_buttons(uint32_t style) { if ((style & MB_OKCANCEL) == MB_OKCANCEL) return {fl_ok, fl_cancel}; if ((style & MB_ABORTRETRYIGNORE) == MB_ABORTRETRYIGNORE) return {"Abort", "Retry", "Ignore"}; if ((style & MB_YESNOCANCEL) == MB_YESNOCANCEL) return {fl_yes, fl_no, fl_cancel}; @@ -72,7 +72,7 @@ namespace { return {}; } - void convert_to_colored_icon(uint_least32_t style) { + void convert_to_colored_icon(uint32_t style) { if ((style & MB_ICONSTOP) == MB_ICONSTOP) fl_message_icon()->label("X"); else if ((style & MB_ICONQUESTION) == MB_ICONQUESTION) fl_message_icon()->label("?"); else if ((style & MB_ICONEXCLAMATION) == MB_ICONEXCLAMATION) fl_message_icon()->label("!"); @@ -91,12 +91,12 @@ namespace { } } -int_least32_t message_box::show(intmax_t control, const ustring& text, const ustring& caption, uint_least32_t style, bool display_help_button) { +int32_t message_box::show(intmax_t control, const ustring& text, const ustring& caption, uint32_t style, bool display_help_button) { native::application::initialize(); // Must be first fl_message_title(caption.c_str()); convert_to_colored_icon(style); auto buttons = convert_to_buttons(style); - int_least32_t result = fl_choice("%s", buttons.size() >= 1 ? buttons[0].c_str() : nullptr, buttons.size() >= 2 ? buttons[1].c_str() : nullptr, buttons.size() >= 3 ? buttons[2].c_str() : nullptr, text.c_str()); + int32_t result = fl_choice("%s", buttons.size() >= 1 ? buttons[0].c_str() : nullptr, buttons.size() >= 2 ? buttons[1].c_str() : nullptr, buttons.size() >= 3 ? buttons[2].c_str() : nullptr, text.c_str()); fl_message_icon()->color(fl_rgb_color(255, 255, 255)); fl_message_icon()->labelcolor(fl_rgb_color(0, 0, 255)); return convert_to_dialog_result(result, style); diff --git a/src/xtd.forms.native.fltk/src/xtd/forms/native/fltk/progress_bar.cpp b/src/xtd.forms.native.fltk/src/xtd/forms/native/fltk/progress_bar.cpp index 6382ce0c998..7e0dbde4ca0 100644 --- a/src/xtd.forms.native.fltk/src/xtd/forms/native/fltk/progress_bar.cpp +++ b/src/xtd.forms.native.fltk/src/xtd/forms/native/fltk/progress_bar.cpp @@ -5,17 +5,17 @@ using namespace xtd; using namespace xtd::drawing; using namespace xtd::forms::native; -void progress_bar::value(intmax_t control, int_least32_t value) { +void progress_bar::value(intmax_t control, int32_t value) { if (control == 0) return; static_cast(reinterpret_cast(control)->control())->value(value); } -void progress_bar::maximum(intmax_t control, int_least32_t maximum) { +void progress_bar::maximum(intmax_t control, int32_t maximum) { if (control == 0) return; static_cast(reinterpret_cast(control)->control())->maximum(maximum); } -void progress_bar::minimum(intmax_t control, int_least32_t minimum) { +void progress_bar::minimum(intmax_t control, int32_t minimum) { if (control == 0) return; static_cast(reinterpret_cast(control)->control())->minimum(minimum); } diff --git a/src/xtd.forms.native.fltk/src/xtd/forms/native/fltk/screen.cpp b/src/xtd.forms.native.fltk/src/xtd/forms/native/fltk/screen.cpp index db1e899a7a2..f2944b3788c 100644 --- a/src/xtd.forms.native.fltk/src/xtd/forms/native/fltk/screen.cpp +++ b/src/xtd.forms.native.fltk/src/xtd/forms/native/fltk/screen.cpp @@ -20,7 +20,7 @@ size_t screen::count() { return Fl::screen_count(); } -int_least32_t screen::bits_per_pixel(size_t index) { +int32_t screen::bits_per_pixel(size_t index) { application::initialize(); float h = 0, v = 0; Fl::screen_dpi(h, v, index); diff --git a/src/xtd.forms.native.fltk/src/xtd/forms/native/fltk/timer.cpp b/src/xtd.forms.native.fltk/src/xtd/forms/native/fltk/timer.cpp index ed918ce8df8..5fc766386d9 100644 --- a/src/xtd.forms.native.fltk/src/xtd/forms/native/fltk/timer.cpp +++ b/src/xtd.forms.native.fltk/src/xtd/forms/native/fltk/timer.cpp @@ -5,7 +5,7 @@ using namespace xtd; using namespace xtd::forms::native; -intmax_t timer::create(int_least32_t interval, const delegate& tick) { +intmax_t timer::create(int32_t interval, const delegate& tick) { fl_timer* timer = new class fl_timer(tick); timer->Start(interval); return reinterpret_cast(timer); diff --git a/src/xtd.forms.native.fltk/src/xtd/forms/native/fltk/track_bar.cpp b/src/xtd.forms.native.fltk/src/xtd/forms/native/fltk/track_bar.cpp index e635b71be77..81f9f4ed2be 100644 --- a/src/xtd.forms.native.fltk/src/xtd/forms/native/fltk/track_bar.cpp +++ b/src/xtd.forms.native.fltk/src/xtd/forms/native/fltk/track_bar.cpp @@ -5,31 +5,31 @@ using namespace xtd; using namespace xtd::drawing; using namespace xtd::forms::native; -void track_bar::large_change(intmax_t control, int_least32_t large_change) { +void track_bar::large_change(intmax_t control, int32_t large_change) { } -void track_bar::maximum(intmax_t control, int_least32_t maximum) { +void track_bar::maximum(intmax_t control, int32_t maximum) { if (control == 0) return; static_cast(reinterpret_cast(control)->control())->maximum(maximum); } -void track_bar::minimum(intmax_t control, int_least32_t minimum) { +void track_bar::minimum(intmax_t control, int32_t minimum) { if (control == 0) return; static_cast(reinterpret_cast(control)->control())->minimum(minimum); } -void track_bar::small_change(intmax_t control, int_least32_t small_change) { +void track_bar::small_change(intmax_t control, int32_t small_change) { } -void track_bar::tick_frequency(intmax_t control, int_least32_t tick_frequency) { +void track_bar::tick_frequency(intmax_t control, int32_t tick_frequency) { } -int_least32_t track_bar::value(intmax_t control) { +int32_t track_bar::value(intmax_t control) { if (control == 0) return 0; return static_cast(reinterpret_cast(control)->control())->value(); } -void track_bar::value(intmax_t control, int_least32_t value) { +void track_bar::value(intmax_t control, int32_t value) { if (control == 0) return; static_cast(reinterpret_cast(control)->control())->value(value); }