diff --git a/.gitignore b/.gitignore index a0adca8..8072825 100644 --- a/.gitignore +++ b/.gitignore @@ -26,6 +26,13 @@ !/bld/src/ /bld/src/* +# /bld/src/d +!/bld/src/d/ +/bld/src/d/* + +!/bld/src/d/dub.sdl +!/bld/src/d/dub.selections.json + # /doc !/doc/ /doc/* @@ -97,8 +104,8 @@ !/src/filesize /src/filesize/* -!/src/filesize/filesize.c -!/src/filesize/filesize.h +!/src/filesize/size.c +!/src/filesize/ # /src/logging !/src/logging @@ -111,38 +118,20 @@ !/src/init /src/init/* -# /src/init/c -!/src/init/c/ -/src/init/c/* - -!/src/init/c/gdextension_interface.c - -# /src/init/c/util -!/src/init/c/util -/src/init/c/util/* - -!/src/init/c/util/inttypes.c -!/src/init/c/util/inttypes.h -!/src/init/c/util/iso646.h -!/src/init/c/util/locale.c -!/src/init/c/util/locale.h -!/src/init/c/util/Q8defs.h -!/src/init/c/util/signal.c -!/src/init/c/util/signal.h -!/src/init/c/util/sitest.c -!/src/init/c/util/stdbool.h -!/src/init/c/util/stdint.h -!/src/init/c/util/wchar.c -!/src/init/c/util/wchar.h -!/src/init/c/util/wctype.c -!/src/init/c/util/wctype.h - # /src/init/cpp !/src/init/cpp/ /src/init/cpp/* !/src/init/cpp/bind.cpp +# /src/init/d +!/src/init/d/ +/src/init/d/* + +!/src/init/d/bind.d + +!/src/init/d + # /res !/res/ /res/* @@ -160,3 +149,4 @@ # Godot 4+ specific ignores .godot/ + diff --git a/README b/README index dc84ca7..0d58f4e 100755 --- a/README +++ b/README @@ -13,19 +13,10 @@ installed to run the compiled binary. - Godot 4.4 - Vulkan Developement Libraries (version compatible with Godot 4.4) - Godot Jolt - - Boost C++ Libraries: https://www.boost.org/ - - cwebsocket: https://github.com/jeremyhahn/cwebsocket - - TinyCThread: https://github.com/tinycthread/tinycthread Some platforms may require that shared libraries be placed alongside the source files, such as MSYS-2.0.dll. - C Reference: - https://en.cppreference.com/w/c - - C++ Reference: - https://en.cppreference.com/w/ - Build ----- @@ -34,6 +25,9 @@ Build - GNU Autotools - UNIX Shell - GCC (with G++) + - LDC + - DUB + - Tubolent W2C2 (optional; testing only) 1.) Install the dependencies listed above. @@ -54,6 +48,9 @@ Quick Setup In a terminal run Godot with the "--dump-extension-api" flag; this will generate the "extension_api.json" required by your installation. + Following this, run the following command: + + dub run godot-dlang:generator -- -j extension_api.json -o Refer to documentation for more information. diff --git a/bld/src/d/dub.sdl b/bld/src/d/dub.sdl new file mode 100644 index 0000000..f69ba99 --- /dev/null +++ b/bld/src/d/dub.sdl @@ -0,0 +1,12 @@ +name "spruce-basin" +description "Source material." +authors "AUTHORS" +copyright "Copyright © 2025, AUTHORS" +license "proprietary" +dependency "godot-dlang" version="~master" +configuration "spruce-basin" { + targetType "dynamicLibrary" + dflags "-dllimport=defaultLibsOnly" platform="windows-ldc2" + targetName "../../obj/spruce-basin" + mainSourceFile "../../../src/init/bind.d" +} diff --git a/bld/src/d/dub.selections.json b/bld/src/d/dub.selections.json new file mode 100644 index 0000000..8c8874a --- /dev/null +++ b/bld/src/d/dub.selections.json @@ -0,0 +1,7 @@ +{ + "fileVersion": 1, + "versions": { + "godot-dlang": "~master", + "utf_bc": "0.2.1" + } +} diff --git a/build.sh b/build.sh index f2539f5..b42c5c6 100644 --- a/build.sh +++ b/build.sh @@ -18,5 +18,3 @@ automake --add-missing # Disable static linking and enable GUI component; builds complete version. ./configure --disable-static --enable-shared make - -cp ./src/.libs/* ./bld/obj/ diff --git a/configure.ac b/configure.ac index 7dea2d0..f87f890 100644 --- a/configure.ac +++ b/configure.ac @@ -1,13 +1,13 @@ # Title, version, etc. AC_INIT(\ - [SB0], \ + [RTR], \ [0.1.0], \ [mail@acm.contact], \ - [sb0], \ + [rtr], \ [https://www.delay.cloud/] \ ) -AC_COPYRIGHT(All rights reserved.) +AC_COPYRIGHT(ISC License) # AC_CHECK_LIB is not utilized, since it checks the presence of libraries by # linking them to test program; this process introduces more overhead and longer @@ -57,25 +57,16 @@ AC_CONFIG_FILES([\ AC_CONFIG_SRCDIR([src/main.c]) -CFLAGS="$CFLAGS -std=c89 -pedantic-errors -Wall -Wold-style-definition -Wextra \ - -Wmissing-prototypes -Wstrict-prototypes" # Compile to C89 +CFLAGS="$CFLAGS -std=c99 -pedantic-errors -Wall -Wold-style-definition -Wextra \ + -Wmissing-prototypes -Wstrict-prototypes" # Compile to C11 # without # GNU extensions. # Warnings on. -# Change -std=c++98 to -std=c++11. - -CXXFLAGS="$CFLAGS -std=c++98 -pedantic-errors -Wall -Wold-style-definition \ - -Wextra -Wmissing-prototypes -Wstrict-prototypes" # Compile to C++98 - # without - # GNU extensions. - # Warnings on. - LT_INIT([shared disable-static]) # Start GNU Libtool. Satic libraries # disabled; shared/dynamic linking. AC_PROG_CC([gcc]) # Autoconf for C compiler; obviously set to use GCC. -AC_PROG_CXX([g++]) AC_OUTPUT # Generate files. diff --git a/engine/bin/libsb.gdextension b/engine/bin/libsb.gdextension index ebb5063..a113978 100644 --- a/engine/bin/libsb.gdextension +++ b/engine/bin/libsb.gdextension @@ -1,10 +1,13 @@ [configuration] -entry_symbol = "libsb" +entry_symbol = "libsb_init" compatibility_minimum = "4.4" [libraries] -linux.x86_64 = "res://../bld/obj/libsb.so" -darwin.x86_64 = "res://../bld/obj/libsb.dylib" -windows.x86_64 = "res://../bld/obj/libsb.dll" +linux.x86_64 = "res://../bld/obj/.libs/libbind.so" +linux.x86_64 = "res://../bld/obj/.libs/libsb.so" +darwin.x86_64 = "res://../bld/obj/.libs/libbind.dylib" +darwin.x86_64 = "res://../bld/obj/.libs/libsb.dylib" +windows.x86_64 = "res://../bld/obj/.libs/libbind.dll" +windows.x86_64 = "res://../bld/obj/.libs/libsb.dll" diff --git a/src/Makefile.am b/src/Makefile.am index 9449c86..6a29f83 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -3,14 +3,11 @@ #bin_PROGRAMS = $(top_builddir)/bin/rtr # Program name. #__top_builddir__bin_rtr_CFLAGS = -DBUILD # Define BUILD variable. #__top_builddir__bin_rtr_SOURCES = main.c # Sources - -# The .la extension is an AutoTools library format that is automatically -# converted into the host OS's object format. -lib_LTLIBRARIES = libsb.la -libsb_la_SOURCES = main.c +lib_LTLIBRARIES = librtr.la +librtr_la_SOURCES = main.c # Compile as shared library. -libsb_la_LDFLAGS = -module -avoid-version -export-dynamic -no-undefined +librtr_la_LDFLAGS = -module -avoid-version -export-dynamic -no-undefined #bin_PROGRAMS = rtr #rtr_CFLAGS = -DBUILD -c -fPIC -shared # Define BUILD and output shared. diff --git a/src/filesize/filesize.h b/src/filesize/filesize.h deleted file mode 100755 index 92e299f..0000000 --- a/src/filesize/filesize.h +++ /dev/null @@ -1,15 +0,0 @@ -/** - * @author : Aidan Mullen (git@acm.contact) - * @file : sfileize - * @created : Wednesday Jun 19, 2024 21:13:29 EDT - */ - -#ifndef FILESIZE_H - -#define FILESIZE_H - -#endif /* end of include guard SIZE_H */ - -int get_size_fallback(void); - -/* --- end of SIZE_H --- */ diff --git a/src/filesize/filesize.c b/src/filesize/size.c similarity index 100% rename from src/filesize/filesize.c rename to src/filesize/size.c diff --git a/src/gdextension_interface.h b/src/gdextension_interface.h new file mode 100644 index 0000000..60ec8d4 --- /dev/null +++ b/src/gdextension_interface.h @@ -0,0 +1,2842 @@ +/**************************************************************************/ +/* gdextension_interface.h */ +/**************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/**************************************************************************/ +/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ +/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/**************************************************************************/ + +#ifndef GDEXTENSION_INTERFACE_H +#define GDEXTENSION_INTERFACE_H + +/* This is a C class header, you can copy it and use it directly in your own binders. + * Together with the JSON file, you should be able to generate any binder. + */ + +#include +#include + +#ifndef __cplusplus +typedef uint32_t char32_t; +typedef uint16_t char16_t; +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* VARIANT TYPES */ + +typedef enum { + GDEXTENSION_VARIANT_TYPE_NIL, + + /* atomic types */ + GDEXTENSION_VARIANT_TYPE_BOOL, + GDEXTENSION_VARIANT_TYPE_INT, + GDEXTENSION_VARIANT_TYPE_FLOAT, + GDEXTENSION_VARIANT_TYPE_STRING, + + /* math types */ + GDEXTENSION_VARIANT_TYPE_VECTOR2, + GDEXTENSION_VARIANT_TYPE_VECTOR2I, + GDEXTENSION_VARIANT_TYPE_RECT2, + GDEXTENSION_VARIANT_TYPE_RECT2I, + GDEXTENSION_VARIANT_TYPE_VECTOR3, + GDEXTENSION_VARIANT_TYPE_VECTOR3I, + GDEXTENSION_VARIANT_TYPE_TRANSFORM2D, + GDEXTENSION_VARIANT_TYPE_VECTOR4, + GDEXTENSION_VARIANT_TYPE_VECTOR4I, + GDEXTENSION_VARIANT_TYPE_PLANE, + GDEXTENSION_VARIANT_TYPE_QUATERNION, + GDEXTENSION_VARIANT_TYPE_AABB, + GDEXTENSION_VARIANT_TYPE_BASIS, + GDEXTENSION_VARIANT_TYPE_TRANSFORM3D, + GDEXTENSION_VARIANT_TYPE_PROJECTION, + + /* misc types */ + GDEXTENSION_VARIANT_TYPE_COLOR, + GDEXTENSION_VARIANT_TYPE_STRING_NAME, + GDEXTENSION_VARIANT_TYPE_NODE_PATH, + GDEXTENSION_VARIANT_TYPE_RID, + GDEXTENSION_VARIANT_TYPE_OBJECT, + GDEXTENSION_VARIANT_TYPE_CALLABLE, + GDEXTENSION_VARIANT_TYPE_SIGNAL, + GDEXTENSION_VARIANT_TYPE_DICTIONARY, + GDEXTENSION_VARIANT_TYPE_ARRAY, + + /* typed arrays */ + GDEXTENSION_VARIANT_TYPE_PACKED_BYTE_ARRAY, + GDEXTENSION_VARIANT_TYPE_PACKED_INT32_ARRAY, + GDEXTENSION_VARIANT_TYPE_PACKED_INT64_ARRAY, + GDEXTENSION_VARIANT_TYPE_PACKED_FLOAT32_ARRAY, + GDEXTENSION_VARIANT_TYPE_PACKED_FLOAT64_ARRAY, + GDEXTENSION_VARIANT_TYPE_PACKED_STRING_ARRAY, + GDEXTENSION_VARIANT_TYPE_PACKED_VECTOR2_ARRAY, + GDEXTENSION_VARIANT_TYPE_PACKED_VECTOR3_ARRAY, + GDEXTENSION_VARIANT_TYPE_PACKED_COLOR_ARRAY, + + GDEXTENSION_VARIANT_TYPE_VARIANT_MAX +} GDExtensionVariantType; + +typedef enum { + /* comparison */ + GDEXTENSION_VARIANT_OP_EQUAL, + GDEXTENSION_VARIANT_OP_NOT_EQUAL, + GDEXTENSION_VARIANT_OP_LESS, + GDEXTENSION_VARIANT_OP_LESS_EQUAL, + GDEXTENSION_VARIANT_OP_GREATER, + GDEXTENSION_VARIANT_OP_GREATER_EQUAL, + + /* mathematic */ + GDEXTENSION_VARIANT_OP_ADD, + GDEXTENSION_VARIANT_OP_SUBTRACT, + GDEXTENSION_VARIANT_OP_MULTIPLY, + GDEXTENSION_VARIANT_OP_DIVIDE, + GDEXTENSION_VARIANT_OP_NEGATE, + GDEXTENSION_VARIANT_OP_POSITIVE, + GDEXTENSION_VARIANT_OP_MODULE, + GDEXTENSION_VARIANT_OP_POWER, + + /* bitwise */ + GDEXTENSION_VARIANT_OP_SHIFT_LEFT, + GDEXTENSION_VARIANT_OP_SHIFT_RIGHT, + GDEXTENSION_VARIANT_OP_BIT_AND, + GDEXTENSION_VARIANT_OP_BIT_OR, + GDEXTENSION_VARIANT_OP_BIT_XOR, + GDEXTENSION_VARIANT_OP_BIT_NEGATE, + + /* logic */ + GDEXTENSION_VARIANT_OP_AND, + GDEXTENSION_VARIANT_OP_OR, + GDEXTENSION_VARIANT_OP_XOR, + GDEXTENSION_VARIANT_OP_NOT, + + /* containment */ + GDEXTENSION_VARIANT_OP_IN, + GDEXTENSION_VARIANT_OP_MAX + +} GDExtensionVariantOperator; + +// In this API there are multiple functions which expect the caller to pass a pointer +// on return value as parameter. +// In order to make it clear if the caller should initialize the return value or not +// we have two flavor of types: +// - `GDExtensionXXXPtr` for pointer on an initialized value +// - `GDExtensionUninitializedXXXPtr` for pointer on uninitialized value +// +// Notes: +// - Not respecting those requirements can seems harmless, but will lead to unexpected +// segfault or memory leak (for instance with a specific compiler/OS, or when two +// native extensions start doing ptrcall on each other). +// - Initialization must be done with the function pointer returned by `variant_get_ptr_constructor`, +// zero-initializing the variable should not be considered a valid initialization method here ! +// - Some types have no destructor (see `extension_api.json`'s `has_destructor` field), for +// them it is always safe to skip the constructor for the return value if you are in a hurry ;-) + +typedef void *GDExtensionVariantPtr; +typedef const void *GDExtensionConstVariantPtr; +typedef void *GDExtensionUninitializedVariantPtr; +typedef void *GDExtensionStringNamePtr; +typedef const void *GDExtensionConstStringNamePtr; +typedef void *GDExtensionUninitializedStringNamePtr; +typedef void *GDExtensionStringPtr; +typedef const void *GDExtensionConstStringPtr; +typedef void *GDExtensionUninitializedStringPtr; +typedef void *GDExtensionObjectPtr; +typedef const void *GDExtensionConstObjectPtr; +typedef void *GDExtensionUninitializedObjectPtr; +typedef void *GDExtensionTypePtr; +typedef const void *GDExtensionConstTypePtr; +typedef void *GDExtensionUninitializedTypePtr; +typedef const void *GDExtensionMethodBindPtr; +typedef int64_t GDExtensionInt; +typedef uint8_t GDExtensionBool; +typedef uint64_t GDObjectInstanceID; +typedef void *GDExtensionRefPtr; +typedef const void *GDExtensionConstRefPtr; + +/* VARIANT DATA I/O */ + +typedef enum { + GDEXTENSION_CALL_OK, + GDEXTENSION_CALL_ERROR_INVALID_METHOD, + GDEXTENSION_CALL_ERROR_INVALID_ARGUMENT, // Expected a different variant type. + GDEXTENSION_CALL_ERROR_TOO_MANY_ARGUMENTS, // Expected lower number of arguments. + GDEXTENSION_CALL_ERROR_TOO_FEW_ARGUMENTS, // Expected higher number of arguments. + GDEXTENSION_CALL_ERROR_INSTANCE_IS_NULL, + GDEXTENSION_CALL_ERROR_METHOD_NOT_CONST, // Used for const call. +} GDExtensionCallErrorType; + +typedef struct { + GDExtensionCallErrorType error; + int32_t argument; + int32_t expected; +} GDExtensionCallError; + +typedef void (*GDExtensionVariantFromTypeConstructorFunc)(GDExtensionUninitializedVariantPtr, GDExtensionTypePtr); +typedef void (*GDExtensionTypeFromVariantConstructorFunc)(GDExtensionUninitializedTypePtr, GDExtensionVariantPtr); +typedef void (*GDExtensionPtrOperatorEvaluator)(GDExtensionConstTypePtr p_left, GDExtensionConstTypePtr p_right, GDExtensionTypePtr r_result); +typedef void (*GDExtensionPtrBuiltInMethod)(GDExtensionTypePtr p_base, const GDExtensionConstTypePtr *p_args, GDExtensionTypePtr r_return, int p_argument_count); +typedef void (*GDExtensionPtrConstructor)(GDExtensionUninitializedTypePtr p_base, const GDExtensionConstTypePtr *p_args); +typedef void (*GDExtensionPtrDestructor)(GDExtensionTypePtr p_base); +typedef void (*GDExtensionPtrSetter)(GDExtensionTypePtr p_base, GDExtensionConstTypePtr p_value); +typedef void (*GDExtensionPtrGetter)(GDExtensionConstTypePtr p_base, GDExtensionTypePtr r_value); +typedef void (*GDExtensionPtrIndexedSetter)(GDExtensionTypePtr p_base, GDExtensionInt p_index, GDExtensionConstTypePtr p_value); +typedef void (*GDExtensionPtrIndexedGetter)(GDExtensionConstTypePtr p_base, GDExtensionInt p_index, GDExtensionTypePtr r_value); +typedef void (*GDExtensionPtrKeyedSetter)(GDExtensionTypePtr p_base, GDExtensionConstTypePtr p_key, GDExtensionConstTypePtr p_value); +typedef void (*GDExtensionPtrKeyedGetter)(GDExtensionConstTypePtr p_base, GDExtensionConstTypePtr p_key, GDExtensionTypePtr r_value); +typedef uint32_t (*GDExtensionPtrKeyedChecker)(GDExtensionConstVariantPtr p_base, GDExtensionConstVariantPtr p_key); +typedef void (*GDExtensionPtrUtilityFunction)(GDExtensionTypePtr r_return, const GDExtensionConstTypePtr *p_args, int p_argument_count); + +typedef GDExtensionObjectPtr (*GDExtensionClassConstructor)(); + +typedef void *(*GDExtensionInstanceBindingCreateCallback)(void *p_token, void *p_instance); +typedef void (*GDExtensionInstanceBindingFreeCallback)(void *p_token, void *p_instance, void *p_binding); +typedef GDExtensionBool (*GDExtensionInstanceBindingReferenceCallback)(void *p_token, void *p_binding, GDExtensionBool p_reference); + +typedef struct { + GDExtensionInstanceBindingCreateCallback create_callback; + GDExtensionInstanceBindingFreeCallback free_callback; + GDExtensionInstanceBindingReferenceCallback reference_callback; +} GDExtensionInstanceBindingCallbacks; + +/* EXTENSION CLASSES */ + +typedef void *GDExtensionClassInstancePtr; + +typedef GDExtensionBool (*GDExtensionClassSet)(GDExtensionClassInstancePtr p_instance, GDExtensionConstStringNamePtr p_name, GDExtensionConstVariantPtr p_value); +typedef GDExtensionBool (*GDExtensionClassGet)(GDExtensionClassInstancePtr p_instance, GDExtensionConstStringNamePtr p_name, GDExtensionVariantPtr r_ret); +typedef uint64_t (*GDExtensionClassGetRID)(GDExtensionClassInstancePtr p_instance); + +typedef struct { + GDExtensionVariantType type; + GDExtensionStringNamePtr name; + GDExtensionStringNamePtr class_name; + uint32_t hint; // Bitfield of `PropertyHint` (defined in `extension_api.json`). + GDExtensionStringPtr hint_string; + uint32_t usage; // Bitfield of `PropertyUsageFlags` (defined in `extension_api.json`). +} GDExtensionPropertyInfo; + +typedef struct { + GDExtensionStringNamePtr name; + GDExtensionPropertyInfo return_value; + uint32_t flags; // Bitfield of `GDExtensionClassMethodFlags`. + int32_t id; + + /* Arguments: `default_arguments` is an array of size `argument_count`. */ + uint32_t argument_count; + GDExtensionPropertyInfo *arguments; + + /* Default arguments: `default_arguments` is an array of size `default_argument_count`. */ + uint32_t default_argument_count; + GDExtensionVariantPtr *default_arguments; +} GDExtensionMethodInfo; + +typedef const GDExtensionPropertyInfo *(*GDExtensionClassGetPropertyList)(GDExtensionClassInstancePtr p_instance, uint32_t *r_count); +typedef void (*GDExtensionClassFreePropertyList)(GDExtensionClassInstancePtr p_instance, const GDExtensionPropertyInfo *p_list); +typedef GDExtensionBool (*GDExtensionClassPropertyCanRevert)(GDExtensionClassInstancePtr p_instance, GDExtensionConstStringNamePtr p_name); +typedef GDExtensionBool (*GDExtensionClassPropertyGetRevert)(GDExtensionClassInstancePtr p_instance, GDExtensionConstStringNamePtr p_name, GDExtensionVariantPtr r_ret); +typedef GDExtensionBool (*GDExtensionClassValidateProperty)(GDExtensionClassInstancePtr p_instance, GDExtensionPropertyInfo *p_property); +typedef void (*GDExtensionClassNotification)(GDExtensionClassInstancePtr p_instance, int32_t p_what); // Deprecated. Use GDExtensionClassNotification2 instead. +typedef void (*GDExtensionClassNotification2)(GDExtensionClassInstancePtr p_instance, int32_t p_what, GDExtensionBool p_reversed); +typedef void (*GDExtensionClassToString)(GDExtensionClassInstancePtr p_instance, GDExtensionBool *r_is_valid, GDExtensionStringPtr p_out); +typedef void (*GDExtensionClassReference)(GDExtensionClassInstancePtr p_instance); +typedef void (*GDExtensionClassUnreference)(GDExtensionClassInstancePtr p_instance); +typedef void (*GDExtensionClassCallVirtual)(GDExtensionClassInstancePtr p_instance, const GDExtensionConstTypePtr *p_args, GDExtensionTypePtr r_ret); +typedef GDExtensionObjectPtr (*GDExtensionClassCreateInstance)(void *p_class_userdata); +typedef void (*GDExtensionClassFreeInstance)(void *p_class_userdata, GDExtensionClassInstancePtr p_instance); +typedef GDExtensionClassInstancePtr (*GDExtensionClassRecreateInstance)(void *p_class_userdata, GDExtensionObjectPtr p_object); +typedef GDExtensionClassCallVirtual (*GDExtensionClassGetVirtual)(void *p_class_userdata, GDExtensionConstStringNamePtr p_name); +typedef void *(*GDExtensionClassGetVirtualCallData)(void *p_class_userdata, GDExtensionConstStringNamePtr p_name); +typedef void (*GDExtensionClassCallVirtualWithData)(GDExtensionClassInstancePtr p_instance, GDExtensionConstStringNamePtr p_name, void *p_virtual_call_userdata, const GDExtensionConstTypePtr *p_args, GDExtensionTypePtr r_ret); + +typedef struct { + GDExtensionBool is_virtual; + GDExtensionBool is_abstract; + GDExtensionClassSet set_func; + GDExtensionClassGet get_func; + GDExtensionClassGetPropertyList get_property_list_func; + GDExtensionClassFreePropertyList free_property_list_func; + GDExtensionClassPropertyCanRevert property_can_revert_func; + GDExtensionClassPropertyGetRevert property_get_revert_func; + GDExtensionClassNotification notification_func; + GDExtensionClassToString to_string_func; + GDExtensionClassReference reference_func; + GDExtensionClassUnreference unreference_func; + GDExtensionClassCreateInstance create_instance_func; // (Default) constructor; mandatory. If the class is not instantiable, consider making it virtual or abstract. + GDExtensionClassFreeInstance free_instance_func; // Destructor; mandatory. + GDExtensionClassGetVirtual get_virtual_func; // Queries a virtual function by name and returns a callback to invoke the requested virtual function. + GDExtensionClassGetRID get_rid_func; + void *class_userdata; // Per-class user data, later accessible in instance bindings. +} GDExtensionClassCreationInfo; // Deprecated. Use GDExtensionClassCreationInfo3 instead. + +typedef struct { + GDExtensionBool is_virtual; + GDExtensionBool is_abstract; + GDExtensionBool is_exposed; + GDExtensionClassSet set_func; + GDExtensionClassGet get_func; + GDExtensionClassGetPropertyList get_property_list_func; + GDExtensionClassFreePropertyList free_property_list_func; + GDExtensionClassPropertyCanRevert property_can_revert_func; + GDExtensionClassPropertyGetRevert property_get_revert_func; + GDExtensionClassValidateProperty validate_property_func; + GDExtensionClassNotification2 notification_func; + GDExtensionClassToString to_string_func; + GDExtensionClassReference reference_func; + GDExtensionClassUnreference unreference_func; + GDExtensionClassCreateInstance create_instance_func; // (Default) constructor; mandatory. If the class is not instantiable, consider making it virtual or abstract. + GDExtensionClassFreeInstance free_instance_func; // Destructor; mandatory. + GDExtensionClassRecreateInstance recreate_instance_func; + // Queries a virtual function by name and returns a callback to invoke the requested virtual function. + GDExtensionClassGetVirtual get_virtual_func; + // Paired with `call_virtual_with_data_func`, this is an alternative to `get_virtual_func` for extensions that + // need or benefit from extra data when calling virtual functions. + // Returns user data that will be passed to `call_virtual_with_data_func`. + // Returning `NULL` from this function signals to Godot that the virtual function is not overridden. + // Data returned from this function should be managed by the extension and must be valid until the extension is deinitialized. + // You should supply either `get_virtual_func`, or `get_virtual_call_data_func` with `call_virtual_with_data_func`. + GDExtensionClassGetVirtualCallData get_virtual_call_data_func; + // Used to call virtual functions when `get_virtual_call_data_func` is not null. + GDExtensionClassCallVirtualWithData call_virtual_with_data_func; + GDExtensionClassGetRID get_rid_func; + void *class_userdata; // Per-class user data, later accessible in instance bindings. +} GDExtensionClassCreationInfo2; // Deprecated. Use GDExtensionClassCreationInfo3 instead. + +typedef struct { + GDExtensionBool is_virtual; + GDExtensionBool is_abstract; + GDExtensionBool is_exposed; + GDExtensionBool is_runtime; + GDExtensionClassSet set_func; + GDExtensionClassGet get_func; + GDExtensionClassGetPropertyList get_property_list_func; + GDExtensionClassFreePropertyList free_property_list_func; + GDExtensionClassPropertyCanRevert property_can_revert_func; + GDExtensionClassPropertyGetRevert property_get_revert_func; + GDExtensionClassValidateProperty validate_property_func; + GDExtensionClassNotification2 notification_func; + GDExtensionClassToString to_string_func; + GDExtensionClassReference reference_func; + GDExtensionClassUnreference unreference_func; + GDExtensionClassCreateInstance create_instance_func; // (Default) constructor; mandatory. If the class is not instantiable, consider making it virtual or abstract. + GDExtensionClassFreeInstance free_instance_func; // Destructor; mandatory. + GDExtensionClassRecreateInstance recreate_instance_func; + // Queries a virtual function by name and returns a callback to invoke the requested virtual function. + GDExtensionClassGetVirtual get_virtual_func; + // Paired with `call_virtual_with_data_func`, this is an alternative to `get_virtual_func` for extensions that + // need or benefit from extra data when calling virtual functions. + // Returns user data that will be passed to `call_virtual_with_data_func`. + // Returning `NULL` from this function signals to Godot that the virtual function is not overridden. + // Data returned from this function should be managed by the extension and must be valid until the extension is deinitialized. + // You should supply either `get_virtual_func`, or `get_virtual_call_data_func` with `call_virtual_with_data_func`. + GDExtensionClassGetVirtualCallData get_virtual_call_data_func; + // Used to call virtual functions when `get_virtual_call_data_func` is not null. + GDExtensionClassCallVirtualWithData call_virtual_with_data_func; + GDExtensionClassGetRID get_rid_func; + void *class_userdata; // Per-class user data, later accessible in instance bindings. +} GDExtensionClassCreationInfo3; + +typedef void *GDExtensionClassLibraryPtr; + +/* Method */ + +typedef enum { + GDEXTENSION_METHOD_FLAG_NORMAL = 1, + GDEXTENSION_METHOD_FLAG_EDITOR = 2, + GDEXTENSION_METHOD_FLAG_CONST = 4, + GDEXTENSION_METHOD_FLAG_VIRTUAL = 8, + GDEXTENSION_METHOD_FLAG_VARARG = 16, + GDEXTENSION_METHOD_FLAG_STATIC = 32, + GDEXTENSION_METHOD_FLAGS_DEFAULT = GDEXTENSION_METHOD_FLAG_NORMAL, +} GDExtensionClassMethodFlags; + +typedef enum { + GDEXTENSION_METHOD_ARGUMENT_METADATA_NONE, + GDEXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_INT8, + GDEXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_INT16, + GDEXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_INT32, + GDEXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_INT64, + GDEXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_UINT8, + GDEXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_UINT16, + GDEXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_UINT32, + GDEXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_UINT64, + GDEXTENSION_METHOD_ARGUMENT_METADATA_REAL_IS_FLOAT, + GDEXTENSION_METHOD_ARGUMENT_METADATA_REAL_IS_DOUBLE +} GDExtensionClassMethodArgumentMetadata; + +typedef void (*GDExtensionClassMethodCall)(void *method_userdata, GDExtensionClassInstancePtr p_instance, const GDExtensionConstVariantPtr *p_args, GDExtensionInt p_argument_count, GDExtensionVariantPtr r_return, GDExtensionCallError *r_error); +typedef void (*GDExtensionClassMethodValidatedCall)(void *method_userdata, GDExtensionClassInstancePtr p_instance, const GDExtensionConstVariantPtr *p_args, GDExtensionVariantPtr r_return); +typedef void (*GDExtensionClassMethodPtrCall)(void *method_userdata, GDExtensionClassInstancePtr p_instance, const GDExtensionConstTypePtr *p_args, GDExtensionTypePtr r_ret); + +typedef struct { + GDExtensionStringNamePtr name; + void *method_userdata; + GDExtensionClassMethodCall call_func; + GDExtensionClassMethodPtrCall ptrcall_func; + uint32_t method_flags; // Bitfield of `GDExtensionClassMethodFlags`. + + /* If `has_return_value` is false, `return_value_info` and `return_value_metadata` are ignored. + * + * @todo Consider dropping `has_return_value` and making the other two properties match `GDExtensionMethodInfo` and `GDExtensionClassVirtualMethod` for consistency in future version of this struct. + */ + GDExtensionBool has_return_value; + GDExtensionPropertyInfo *return_value_info; + GDExtensionClassMethodArgumentMetadata return_value_metadata; + + /* Arguments: `arguments_info` and `arguments_metadata` are array of size `argument_count`. + * Name and hint information for the argument can be omitted in release builds. Class name should always be present if it applies. + * + * @todo Consider renaming `arguments_info` to `arguments` for consistency in future version of this struct. + */ + uint32_t argument_count; + GDExtensionPropertyInfo *arguments_info; + GDExtensionClassMethodArgumentMetadata *arguments_metadata; + + /* Default arguments: `default_arguments` is an array of size `default_argument_count`. */ + uint32_t default_argument_count; + GDExtensionVariantPtr *default_arguments; +} GDExtensionClassMethodInfo; + +typedef struct { + GDExtensionStringNamePtr name; + uint32_t method_flags; // Bitfield of `GDExtensionClassMethodFlags`. + + GDExtensionPropertyInfo return_value; + GDExtensionClassMethodArgumentMetadata return_value_metadata; + + uint32_t argument_count; + GDExtensionPropertyInfo *arguments; + GDExtensionClassMethodArgumentMetadata *arguments_metadata; +} GDExtensionClassVirtualMethodInfo; + +typedef void (*GDExtensionCallableCustomCall)(void *callable_userdata, const GDExtensionConstVariantPtr *p_args, GDExtensionInt p_argument_count, GDExtensionVariantPtr r_return, GDExtensionCallError *r_error); +typedef GDExtensionBool (*GDExtensionCallableCustomIsValid)(void *callable_userdata); +typedef void (*GDExtensionCallableCustomFree)(void *callable_userdata); + +typedef uint32_t (*GDExtensionCallableCustomHash)(void *callable_userdata); +typedef GDExtensionBool (*GDExtensionCallableCustomEqual)(void *callable_userdata_a, void *callable_userdata_b); +typedef GDExtensionBool (*GDExtensionCallableCustomLessThan)(void *callable_userdata_a, void *callable_userdata_b); + +typedef void (*GDExtensionCallableCustomToString)(void *callable_userdata, GDExtensionBool *r_is_valid, GDExtensionStringPtr r_out); + +typedef GDExtensionInt (*GDExtensionCallableCustomGetArgumentCount)(void *callable_userdata, GDExtensionBool *r_is_valid); + +typedef struct { + /* Only `call_func` and `token` are strictly required, however, `object_id` should be passed if its not a static method. + * + * `token` should point to an address that uniquely identifies the GDExtension (for example, the + * `GDExtensionClassLibraryPtr` passed to the entry symbol function. + * + * `hash_func`, `equal_func`, and `less_than_func` are optional. If not provided both `call_func` and + * `callable_userdata` together are used as the identity of the callable for hashing and comparison purposes. + * + * The hash returned by `hash_func` is cached, `hash_func` will not be called more than once per callable. + * + * `is_valid_func` is necessary if the validity of the callable can change before destruction. + * + * `free_func` is necessary if `callable_userdata` needs to be cleaned up when the callable is freed. + */ + void *callable_userdata; + void *token; + + GDObjectInstanceID object_id; + + GDExtensionCallableCustomCall call_func; + GDExtensionCallableCustomIsValid is_valid_func; + GDExtensionCallableCustomFree free_func; + + GDExtensionCallableCustomHash hash_func; + GDExtensionCallableCustomEqual equal_func; + GDExtensionCallableCustomLessThan less_than_func; + + GDExtensionCallableCustomToString to_string_func; +} GDExtensionCallableCustomInfo; // Deprecated. Use GDExtensionCallableCustomInfo2 instead. + +typedef struct { + /* Only `call_func` and `token` are strictly required, however, `object_id` should be passed if its not a static method. + * + * `token` should point to an address that uniquely identifies the GDExtension (for example, the + * `GDExtensionClassLibraryPtr` passed to the entry symbol function. + * + * `hash_func`, `equal_func`, and `less_than_func` are optional. If not provided both `call_func` and + * `callable_userdata` together are used as the identity of the callable for hashing and comparison purposes. + * + * The hash returned by `hash_func` is cached, `hash_func` will not be called more than once per callable. + * + * `is_valid_func` is necessary if the validity of the callable can change before destruction. + * + * `free_func` is necessary if `callable_userdata` needs to be cleaned up when the callable is freed. + */ + void *callable_userdata; + void *token; + + GDObjectInstanceID object_id; + + GDExtensionCallableCustomCall call_func; + GDExtensionCallableCustomIsValid is_valid_func; + GDExtensionCallableCustomFree free_func; + + GDExtensionCallableCustomHash hash_func; + GDExtensionCallableCustomEqual equal_func; + GDExtensionCallableCustomLessThan less_than_func; + + GDExtensionCallableCustomToString to_string_func; + + GDExtensionCallableCustomGetArgumentCount get_argument_count_func; +} GDExtensionCallableCustomInfo2; + +/* SCRIPT INSTANCE EXTENSION */ + +typedef void *GDExtensionScriptInstanceDataPtr; // Pointer to custom ScriptInstance native implementation. + +typedef GDExtensionBool (*GDExtensionScriptInstanceSet)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionConstStringNamePtr p_name, GDExtensionConstVariantPtr p_value); +typedef GDExtensionBool (*GDExtensionScriptInstanceGet)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionConstStringNamePtr p_name, GDExtensionVariantPtr r_ret); +typedef const GDExtensionPropertyInfo *(*GDExtensionScriptInstanceGetPropertyList)(GDExtensionScriptInstanceDataPtr p_instance, uint32_t *r_count); +typedef void (*GDExtensionScriptInstanceFreePropertyList)(GDExtensionScriptInstanceDataPtr p_instance, const GDExtensionPropertyInfo *p_list); // Deprecated. Use GDExtensionScriptInstanceFreePropertyList2 instead. +typedef void (*GDExtensionScriptInstanceFreePropertyList2)(GDExtensionScriptInstanceDataPtr p_instance, const GDExtensionPropertyInfo *p_list, uint32_t p_count); +typedef GDExtensionBool (*GDExtensionScriptInstanceGetClassCategory)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionPropertyInfo *p_class_category); + +typedef GDExtensionVariantType (*GDExtensionScriptInstanceGetPropertyType)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionConstStringNamePtr p_name, GDExtensionBool *r_is_valid); +typedef GDExtensionBool (*GDExtensionScriptInstanceValidateProperty)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionPropertyInfo *p_property); + +typedef GDExtensionBool (*GDExtensionScriptInstancePropertyCanRevert)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionConstStringNamePtr p_name); +typedef GDExtensionBool (*GDExtensionScriptInstancePropertyGetRevert)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionConstStringNamePtr p_name, GDExtensionVariantPtr r_ret); + +typedef GDExtensionObjectPtr (*GDExtensionScriptInstanceGetOwner)(GDExtensionScriptInstanceDataPtr p_instance); +typedef void (*GDExtensionScriptInstancePropertyStateAdd)(GDExtensionConstStringNamePtr p_name, GDExtensionConstVariantPtr p_value, void *p_userdata); +typedef void (*GDExtensionScriptInstanceGetPropertyState)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionScriptInstancePropertyStateAdd p_add_func, void *p_userdata); + +typedef const GDExtensionMethodInfo *(*GDExtensionScriptInstanceGetMethodList)(GDExtensionScriptInstanceDataPtr p_instance, uint32_t *r_count); +typedef void (*GDExtensionScriptInstanceFreeMethodList)(GDExtensionScriptInstanceDataPtr p_instance, const GDExtensionMethodInfo *p_list); // Deprecated. Use GDExtensionScriptInstanceFreeMethodList2 instead. +typedef void (*GDExtensionScriptInstanceFreeMethodList2)(GDExtensionScriptInstanceDataPtr p_instance, const GDExtensionMethodInfo *p_list, uint32_t p_count); + +typedef GDExtensionBool (*GDExtensionScriptInstanceHasMethod)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionConstStringNamePtr p_name); + +typedef GDExtensionInt (*GDExtensionScriptInstanceGetMethodArgumentCount)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionConstStringNamePtr p_name, GDExtensionBool *r_is_valid); + +typedef void (*GDExtensionScriptInstanceCall)(GDExtensionScriptInstanceDataPtr p_self, GDExtensionConstStringNamePtr p_method, const GDExtensionConstVariantPtr *p_args, GDExtensionInt p_argument_count, GDExtensionVariantPtr r_return, GDExtensionCallError *r_error); +typedef void (*GDExtensionScriptInstanceNotification)(GDExtensionScriptInstanceDataPtr p_instance, int32_t p_what); // Deprecated. Use GDExtensionScriptInstanceNotification2 instead. +typedef void (*GDExtensionScriptInstanceNotification2)(GDExtensionScriptInstanceDataPtr p_instance, int32_t p_what, GDExtensionBool p_reversed); +typedef void (*GDExtensionScriptInstanceToString)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionBool *r_is_valid, GDExtensionStringPtr r_out); + +typedef void (*GDExtensionScriptInstanceRefCountIncremented)(GDExtensionScriptInstanceDataPtr p_instance); +typedef GDExtensionBool (*GDExtensionScriptInstanceRefCountDecremented)(GDExtensionScriptInstanceDataPtr p_instance); + +typedef GDExtensionObjectPtr (*GDExtensionScriptInstanceGetScript)(GDExtensionScriptInstanceDataPtr p_instance); +typedef GDExtensionBool (*GDExtensionScriptInstanceIsPlaceholder)(GDExtensionScriptInstanceDataPtr p_instance); + +typedef void *GDExtensionScriptLanguagePtr; + +typedef GDExtensionScriptLanguagePtr (*GDExtensionScriptInstanceGetLanguage)(GDExtensionScriptInstanceDataPtr p_instance); + +typedef void (*GDExtensionScriptInstanceFree)(GDExtensionScriptInstanceDataPtr p_instance); + +typedef void *GDExtensionScriptInstancePtr; // Pointer to ScriptInstance. + +typedef struct { + GDExtensionScriptInstanceSet set_func; + GDExtensionScriptInstanceGet get_func; + GDExtensionScriptInstanceGetPropertyList get_property_list_func; + GDExtensionScriptInstanceFreePropertyList free_property_list_func; + + GDExtensionScriptInstancePropertyCanRevert property_can_revert_func; + GDExtensionScriptInstancePropertyGetRevert property_get_revert_func; + + GDExtensionScriptInstanceGetOwner get_owner_func; + GDExtensionScriptInstanceGetPropertyState get_property_state_func; + + GDExtensionScriptInstanceGetMethodList get_method_list_func; + GDExtensionScriptInstanceFreeMethodList free_method_list_func; + GDExtensionScriptInstanceGetPropertyType get_property_type_func; + + GDExtensionScriptInstanceHasMethod has_method_func; + + GDExtensionScriptInstanceCall call_func; + GDExtensionScriptInstanceNotification notification_func; + + GDExtensionScriptInstanceToString to_string_func; + + GDExtensionScriptInstanceRefCountIncremented refcount_incremented_func; + GDExtensionScriptInstanceRefCountDecremented refcount_decremented_func; + + GDExtensionScriptInstanceGetScript get_script_func; + + GDExtensionScriptInstanceIsPlaceholder is_placeholder_func; + + GDExtensionScriptInstanceSet set_fallback_func; + GDExtensionScriptInstanceGet get_fallback_func; + + GDExtensionScriptInstanceGetLanguage get_language_func; + + GDExtensionScriptInstanceFree free_func; + +} GDExtensionScriptInstanceInfo; // Deprecated. Use GDExtensionScriptInstanceInfo3 instead. + +typedef struct { + GDExtensionScriptInstanceSet set_func; + GDExtensionScriptInstanceGet get_func; + GDExtensionScriptInstanceGetPropertyList get_property_list_func; + GDExtensionScriptInstanceFreePropertyList free_property_list_func; + GDExtensionScriptInstanceGetClassCategory get_class_category_func; // Optional. Set to NULL for the default behavior. + + GDExtensionScriptInstancePropertyCanRevert property_can_revert_func; + GDExtensionScriptInstancePropertyGetRevert property_get_revert_func; + + GDExtensionScriptInstanceGetOwner get_owner_func; + GDExtensionScriptInstanceGetPropertyState get_property_state_func; + + GDExtensionScriptInstanceGetMethodList get_method_list_func; + GDExtensionScriptInstanceFreeMethodList free_method_list_func; + GDExtensionScriptInstanceGetPropertyType get_property_type_func; + GDExtensionScriptInstanceValidateProperty validate_property_func; + + GDExtensionScriptInstanceHasMethod has_method_func; + + GDExtensionScriptInstanceCall call_func; + GDExtensionScriptInstanceNotification2 notification_func; + + GDExtensionScriptInstanceToString to_string_func; + + GDExtensionScriptInstanceRefCountIncremented refcount_incremented_func; + GDExtensionScriptInstanceRefCountDecremented refcount_decremented_func; + + GDExtensionScriptInstanceGetScript get_script_func; + + GDExtensionScriptInstanceIsPlaceholder is_placeholder_func; + + GDExtensionScriptInstanceSet set_fallback_func; + GDExtensionScriptInstanceGet get_fallback_func; + + GDExtensionScriptInstanceGetLanguage get_language_func; + + GDExtensionScriptInstanceFree free_func; + +} GDExtensionScriptInstanceInfo2; // Deprecated. Use GDExtensionScriptInstanceInfo3 instead. + +typedef struct { + GDExtensionScriptInstanceSet set_func; + GDExtensionScriptInstanceGet get_func; + GDExtensionScriptInstanceGetPropertyList get_property_list_func; + GDExtensionScriptInstanceFreePropertyList2 free_property_list_func; + GDExtensionScriptInstanceGetClassCategory get_class_category_func; // Optional. Set to NULL for the default behavior. + + GDExtensionScriptInstancePropertyCanRevert property_can_revert_func; + GDExtensionScriptInstancePropertyGetRevert property_get_revert_func; + + GDExtensionScriptInstanceGetOwner get_owner_func; + GDExtensionScriptInstanceGetPropertyState get_property_state_func; + + GDExtensionScriptInstanceGetMethodList get_method_list_func; + GDExtensionScriptInstanceFreeMethodList2 free_method_list_func; + GDExtensionScriptInstanceGetPropertyType get_property_type_func; + GDExtensionScriptInstanceValidateProperty validate_property_func; + + GDExtensionScriptInstanceHasMethod has_method_func; + + GDExtensionScriptInstanceGetMethodArgumentCount get_method_argument_count_func; + + GDExtensionScriptInstanceCall call_func; + GDExtensionScriptInstanceNotification2 notification_func; + + GDExtensionScriptInstanceToString to_string_func; + + GDExtensionScriptInstanceRefCountIncremented refcount_incremented_func; + GDExtensionScriptInstanceRefCountDecremented refcount_decremented_func; + + GDExtensionScriptInstanceGetScript get_script_func; + + GDExtensionScriptInstanceIsPlaceholder is_placeholder_func; + + GDExtensionScriptInstanceSet set_fallback_func; + GDExtensionScriptInstanceGet get_fallback_func; + + GDExtensionScriptInstanceGetLanguage get_language_func; + + GDExtensionScriptInstanceFree free_func; + +} GDExtensionScriptInstanceInfo3; + +/* INITIALIZATION */ + +typedef enum { + GDEXTENSION_INITIALIZATION_CORE, + GDEXTENSION_INITIALIZATION_SERVERS, + GDEXTENSION_INITIALIZATION_SCENE, + GDEXTENSION_INITIALIZATION_EDITOR, + GDEXTENSION_MAX_INITIALIZATION_LEVEL, +} GDExtensionInitializationLevel; + +typedef struct { + /* Minimum initialization level required. + * If Core or Servers, the extension needs editor or game restart to take effect */ + GDExtensionInitializationLevel minimum_initialization_level; + /* Up to the user to supply when initializing */ + void *userdata; + /* This function will be called multiple times for each initialization level. */ + void (*initialize)(void *userdata, GDExtensionInitializationLevel p_level); + void (*deinitialize)(void *userdata, GDExtensionInitializationLevel p_level); +} GDExtensionInitialization; + +typedef void (*GDExtensionInterfaceFunctionPtr)(); +typedef GDExtensionInterfaceFunctionPtr (*GDExtensionInterfaceGetProcAddress)(const char *p_function_name); + +/* + * Each GDExtension should define a C function that matches the signature of GDExtensionInitializationFunction, + * and export it so that it can be loaded via dlopen() or equivalent for the given platform. + * + * For example: + * + * GDExtensionBool my_extension_init(GDExtensionInterfaceGetProcAddress p_get_proc_address, GDExtensionClassLibraryPtr p_library, GDExtensionInitialization *r_initialization); + * + * This function's name must be specified as the 'entry_symbol' in the .gdextension file. + * + * This makes it the entry point of the GDExtension and will be called on initialization. + * + * The GDExtension can then modify the r_initialization structure, setting the minimum initialization level, + * and providing pointers to functions that will be called at various stages of initialization/shutdown. + * + * The rest of the GDExtension's interface to Godot consists of function pointers that can be loaded + * by calling p_get_proc_address("...") with the name of the function. + * + * For example: + * + * GDExtensionInterfaceGetGodotVersion get_godot_version = (GDExtensionInterfaceGetGodotVersion)p_get_proc_address("get_godot_version"); + * + * (Note that snippet may cause "cast between incompatible function types" on some compilers, you can + * silence this by adding an intermediary `void*` cast.) + * + * You can then call it like a normal function: + * + * GDExtensionGodotVersion godot_version; + * get_godot_version(&godot_version); + * printf("Godot v%d.%d.%d\n", godot_version.major, godot_version.minor, godot_version.patch); + * + * All of these interface functions are described below, together with the name that's used to load it, + * and the function pointer typedef that shows its signature. + */ +typedef GDExtensionBool (*GDExtensionInitializationFunction)(GDExtensionInterfaceGetProcAddress p_get_proc_address, GDExtensionClassLibraryPtr p_library, GDExtensionInitialization *r_initialization); + +/* INTERFACE */ + +typedef struct { + uint32_t major; + uint32_t minor; + uint32_t patch; + const char *string; +} GDExtensionGodotVersion; + +/** + * @name get_godot_version + * @since 4.1 + * + * Gets the Godot version that the GDExtension was loaded into. + * + * @param r_godot_version A pointer to the structure to write the version information into. + */ +typedef void (*GDExtensionInterfaceGetGodotVersion)(GDExtensionGodotVersion *r_godot_version); + +/* INTERFACE: Memory */ + +/** + * @name mem_alloc + * @since 4.1 + * + * Allocates memory. + * + * @param p_bytes The amount of memory to allocate in bytes. + * + * @return A pointer to the allocated memory, or NULL if unsuccessful. + */ +typedef void *(*GDExtensionInterfaceMemAlloc)(size_t p_bytes); + +/** + * @name mem_realloc + * @since 4.1 + * + * Reallocates memory. + * + * @param p_ptr A pointer to the previously allocated memory. + * @param p_bytes The number of bytes to resize the memory block to. + * + * @return A pointer to the allocated memory, or NULL if unsuccessful. + */ +typedef void *(*GDExtensionInterfaceMemRealloc)(void *p_ptr, size_t p_bytes); + +/** + * @name mem_free + * @since 4.1 + * + * Frees memory. + * + * @param p_ptr A pointer to the previously allocated memory. + */ +typedef void (*GDExtensionInterfaceMemFree)(void *p_ptr); + +/* INTERFACE: Godot Core */ + +/** + * @name print_error + * @since 4.1 + * + * Logs an error to Godot's built-in debugger and to the OS terminal. + * + * @param p_description The code trigging the error. + * @param p_function The function name where the error occurred. + * @param p_file The file where the error occurred. + * @param p_line The line where the error occurred. + * @param p_editor_notify Whether or not to notify the editor. + */ +typedef void (*GDExtensionInterfacePrintError)(const char *p_description, const char *p_function, const char *p_file, int32_t p_line, GDExtensionBool p_editor_notify); + +/** + * @name print_error_with_message + * @since 4.1 + * + * Logs an error with a message to Godot's built-in debugger and to the OS terminal. + * + * @param p_description The code trigging the error. + * @param p_message The message to show along with the error. + * @param p_function The function name where the error occurred. + * @param p_file The file where the error occurred. + * @param p_line The line where the error occurred. + * @param p_editor_notify Whether or not to notify the editor. + */ +typedef void (*GDExtensionInterfacePrintErrorWithMessage)(const char *p_description, const char *p_message, const char *p_function, const char *p_file, int32_t p_line, GDExtensionBool p_editor_notify); + +/** + * @name print_warning + * @since 4.1 + * + * Logs a warning to Godot's built-in debugger and to the OS terminal. + * + * @param p_description The code trigging the warning. + * @param p_function The function name where the warning occurred. + * @param p_file The file where the warning occurred. + * @param p_line The line where the warning occurred. + * @param p_editor_notify Whether or not to notify the editor. + */ +typedef void (*GDExtensionInterfacePrintWarning)(const char *p_description, const char *p_function, const char *p_file, int32_t p_line, GDExtensionBool p_editor_notify); + +/** + * @name print_warning_with_message + * @since 4.1 + * + * Logs a warning with a message to Godot's built-in debugger and to the OS terminal. + * + * @param p_description The code trigging the warning. + * @param p_message The message to show along with the warning. + * @param p_function The function name where the warning occurred. + * @param p_file The file where the warning occurred. + * @param p_line The line where the warning occurred. + * @param p_editor_notify Whether or not to notify the editor. + */ +typedef void (*GDExtensionInterfacePrintWarningWithMessage)(const char *p_description, const char *p_message, const char *p_function, const char *p_file, int32_t p_line, GDExtensionBool p_editor_notify); + +/** + * @name print_script_error + * @since 4.1 + * + * Logs a script error to Godot's built-in debugger and to the OS terminal. + * + * @param p_description The code trigging the error. + * @param p_function The function name where the error occurred. + * @param p_file The file where the error occurred. + * @param p_line The line where the error occurred. + * @param p_editor_notify Whether or not to notify the editor. + */ +typedef void (*GDExtensionInterfacePrintScriptError)(const char *p_description, const char *p_function, const char *p_file, int32_t p_line, GDExtensionBool p_editor_notify); + +/** + * @name print_script_error_with_message + * @since 4.1 + * + * Logs a script error with a message to Godot's built-in debugger and to the OS terminal. + * + * @param p_description The code trigging the error. + * @param p_message The message to show along with the error. + * @param p_function The function name where the error occurred. + * @param p_file The file where the error occurred. + * @param p_line The line where the error occurred. + * @param p_editor_notify Whether or not to notify the editor. + */ +typedef void (*GDExtensionInterfacePrintScriptErrorWithMessage)(const char *p_description, const char *p_message, const char *p_function, const char *p_file, int32_t p_line, GDExtensionBool p_editor_notify); + +/** + * @name get_native_struct_size + * @since 4.1 + * + * Gets the size of a native struct (ex. ObjectID) in bytes. + * + * @param p_name A pointer to a StringName identifying the struct name. + * + * @return The size in bytes. + */ +typedef uint64_t (*GDExtensionInterfaceGetNativeStructSize)(GDExtensionConstStringNamePtr p_name); + +/* INTERFACE: Variant */ + +/** + * @name variant_new_copy + * @since 4.1 + * + * Copies one Variant into a another. + * + * @param r_dest A pointer to the destination Variant. + * @param p_src A pointer to the source Variant. + */ +typedef void (*GDExtensionInterfaceVariantNewCopy)(GDExtensionUninitializedVariantPtr r_dest, GDExtensionConstVariantPtr p_src); + +/** + * @name variant_new_nil + * @since 4.1 + * + * Creates a new Variant containing nil. + * + * @param r_dest A pointer to the destination Variant. + */ +typedef void (*GDExtensionInterfaceVariantNewNil)(GDExtensionUninitializedVariantPtr r_dest); + +/** + * @name variant_destroy + * @since 4.1 + * + * Destroys a Variant. + * + * @param p_self A pointer to the Variant to destroy. + */ +typedef void (*GDExtensionInterfaceVariantDestroy)(GDExtensionVariantPtr p_self); + +/** + * @name variant_call + * @since 4.1 + * + * Calls a method on a Variant. + * + * @param p_self A pointer to the Variant. + * @param p_method A pointer to a StringName identifying the method. + * @param p_args A pointer to a C array of Variant. + * @param p_argument_count The number of arguments. + * @param r_return A pointer a Variant which will be assigned the return value. + * @param r_error A pointer the structure which will hold error information. + * + * @see Variant::callp() + */ +typedef void (*GDExtensionInterfaceVariantCall)(GDExtensionVariantPtr p_self, GDExtensionConstStringNamePtr p_method, const GDExtensionConstVariantPtr *p_args, GDExtensionInt p_argument_count, GDExtensionUninitializedVariantPtr r_return, GDExtensionCallError *r_error); + +/** + * @name variant_call_static + * @since 4.1 + * + * Calls a static method on a Variant. + * + * @param p_self A pointer to the Variant. + * @param p_method A pointer to a StringName identifying the method. + * @param p_args A pointer to a C array of Variant. + * @param p_argument_count The number of arguments. + * @param r_return A pointer a Variant which will be assigned the return value. + * @param r_error A pointer the structure which will be updated with error information. + * + * @see Variant::call_static() + */ +typedef void (*GDExtensionInterfaceVariantCallStatic)(GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_method, const GDExtensionConstVariantPtr *p_args, GDExtensionInt p_argument_count, GDExtensionUninitializedVariantPtr r_return, GDExtensionCallError *r_error); + +/** + * @name variant_evaluate + * @since 4.1 + * + * Evaluate an operator on two Variants. + * + * @param p_op The operator to evaluate. + * @param p_a The first Variant. + * @param p_b The second Variant. + * @param r_return A pointer a Variant which will be assigned the return value. + * @param r_valid A pointer to a boolean which will be set to false if the operation is invalid. + * + * @see Variant::evaluate() + */ +typedef void (*GDExtensionInterfaceVariantEvaluate)(GDExtensionVariantOperator p_op, GDExtensionConstVariantPtr p_a, GDExtensionConstVariantPtr p_b, GDExtensionUninitializedVariantPtr r_return, GDExtensionBool *r_valid); + +/** + * @name variant_set + * @since 4.1 + * + * Sets a key on a Variant to a value. + * + * @param p_self A pointer to the Variant. + * @param p_key A pointer to a Variant representing the key. + * @param p_value A pointer to a Variant representing the value. + * @param r_valid A pointer to a boolean which will be set to false if the operation is invalid. + * + * @see Variant::set() + */ +typedef void (*GDExtensionInterfaceVariantSet)(GDExtensionVariantPtr p_self, GDExtensionConstVariantPtr p_key, GDExtensionConstVariantPtr p_value, GDExtensionBool *r_valid); + +/** + * @name variant_set_named + * @since 4.1 + * + * Sets a named key on a Variant to a value. + * + * @param p_self A pointer to the Variant. + * @param p_key A pointer to a StringName representing the key. + * @param p_value A pointer to a Variant representing the value. + * @param r_valid A pointer to a boolean which will be set to false if the operation is invalid. + * + * @see Variant::set_named() + */ +typedef void (*GDExtensionInterfaceVariantSetNamed)(GDExtensionVariantPtr p_self, GDExtensionConstStringNamePtr p_key, GDExtensionConstVariantPtr p_value, GDExtensionBool *r_valid); + +/** + * @name variant_set_keyed + * @since 4.1 + * + * Sets a keyed property on a Variant to a value. + * + * @param p_self A pointer to the Variant. + * @param p_key A pointer to a Variant representing the key. + * @param p_value A pointer to a Variant representing the value. + * @param r_valid A pointer to a boolean which will be set to false if the operation is invalid. + * + * @see Variant::set_keyed() + */ +typedef void (*GDExtensionInterfaceVariantSetKeyed)(GDExtensionVariantPtr p_self, GDExtensionConstVariantPtr p_key, GDExtensionConstVariantPtr p_value, GDExtensionBool *r_valid); + +/** + * @name variant_set_indexed + * @since 4.1 + * + * Sets an index on a Variant to a value. + * + * @param p_self A pointer to the Variant. + * @param p_index The index. + * @param p_value A pointer to a Variant representing the value. + * @param r_valid A pointer to a boolean which will be set to false if the operation is invalid. + * @param r_oob A pointer to a boolean which will be set to true if the index is out of bounds. + */ +typedef void (*GDExtensionInterfaceVariantSetIndexed)(GDExtensionVariantPtr p_self, GDExtensionInt p_index, GDExtensionConstVariantPtr p_value, GDExtensionBool *r_valid, GDExtensionBool *r_oob); + +/** + * @name variant_get + * @since 4.1 + * + * Gets the value of a key from a Variant. + * + * @param p_self A pointer to the Variant. + * @param p_key A pointer to a Variant representing the key. + * @param r_ret A pointer to a Variant which will be assigned the value. + * @param r_valid A pointer to a boolean which will be set to false if the operation is invalid. + */ +typedef void (*GDExtensionInterfaceVariantGet)(GDExtensionConstVariantPtr p_self, GDExtensionConstVariantPtr p_key, GDExtensionUninitializedVariantPtr r_ret, GDExtensionBool *r_valid); + +/** + * @name variant_get_named + * @since 4.1 + * + * Gets the value of a named key from a Variant. + * + * @param p_self A pointer to the Variant. + * @param p_key A pointer to a StringName representing the key. + * @param r_ret A pointer to a Variant which will be assigned the value. + * @param r_valid A pointer to a boolean which will be set to false if the operation is invalid. + */ +typedef void (*GDExtensionInterfaceVariantGetNamed)(GDExtensionConstVariantPtr p_self, GDExtensionConstStringNamePtr p_key, GDExtensionUninitializedVariantPtr r_ret, GDExtensionBool *r_valid); + +/** + * @name variant_get_keyed + * @since 4.1 + * + * Gets the value of a keyed property from a Variant. + * + * @param p_self A pointer to the Variant. + * @param p_key A pointer to a Variant representing the key. + * @param r_ret A pointer to a Variant which will be assigned the value. + * @param r_valid A pointer to a boolean which will be set to false if the operation is invalid. + */ +typedef void (*GDExtensionInterfaceVariantGetKeyed)(GDExtensionConstVariantPtr p_self, GDExtensionConstVariantPtr p_key, GDExtensionUninitializedVariantPtr r_ret, GDExtensionBool *r_valid); + +/** + * @name variant_get_indexed + * @since 4.1 + * + * Gets the value of an index from a Variant. + * + * @param p_self A pointer to the Variant. + * @param p_index The index. + * @param r_ret A pointer to a Variant which will be assigned the value. + * @param r_valid A pointer to a boolean which will be set to false if the operation is invalid. + * @param r_oob A pointer to a boolean which will be set to true if the index is out of bounds. + */ +typedef void (*GDExtensionInterfaceVariantGetIndexed)(GDExtensionConstVariantPtr p_self, GDExtensionInt p_index, GDExtensionUninitializedVariantPtr r_ret, GDExtensionBool *r_valid, GDExtensionBool *r_oob); + +/** + * @name variant_iter_init + * @since 4.1 + * + * Initializes an iterator over a Variant. + * + * @param p_self A pointer to the Variant. + * @param r_iter A pointer to a Variant which will be assigned the iterator. + * @param r_valid A pointer to a boolean which will be set to false if the operation is invalid. + * + * @return true if the operation is valid; otherwise false. + * + * @see Variant::iter_init() + */ +typedef GDExtensionBool (*GDExtensionInterfaceVariantIterInit)(GDExtensionConstVariantPtr p_self, GDExtensionUninitializedVariantPtr r_iter, GDExtensionBool *r_valid); + +/** + * @name variant_iter_next + * @since 4.1 + * + * Gets the next value for an iterator over a Variant. + * + * @param p_self A pointer to the Variant. + * @param r_iter A pointer to a Variant which will be assigned the iterator. + * @param r_valid A pointer to a boolean which will be set to false if the operation is invalid. + * + * @return true if the operation is valid; otherwise false. + * + * @see Variant::iter_next() + */ +typedef GDExtensionBool (*GDExtensionInterfaceVariantIterNext)(GDExtensionConstVariantPtr p_self, GDExtensionVariantPtr r_iter, GDExtensionBool *r_valid); + +/** + * @name variant_iter_get + * @since 4.1 + * + * Gets the next value for an iterator over a Variant. + * + * @param p_self A pointer to the Variant. + * @param r_iter A pointer to a Variant which will be assigned the iterator. + * @param r_ret A pointer to a Variant which will be assigned false if the operation is invalid. + * @param r_valid A pointer to a boolean which will be set to false if the operation is invalid. + * + * @see Variant::iter_get() + */ +typedef void (*GDExtensionInterfaceVariantIterGet)(GDExtensionConstVariantPtr p_self, GDExtensionVariantPtr r_iter, GDExtensionUninitializedVariantPtr r_ret, GDExtensionBool *r_valid); + +/** + * @name variant_hash + * @since 4.1 + * + * Gets the hash of a Variant. + * + * @param p_self A pointer to the Variant. + * + * @return The hash value. + * + * @see Variant::hash() + */ +typedef GDExtensionInt (*GDExtensionInterfaceVariantHash)(GDExtensionConstVariantPtr p_self); + +/** + * @name variant_recursive_hash + * @since 4.1 + * + * Gets the recursive hash of a Variant. + * + * @param p_self A pointer to the Variant. + * @param p_recursion_count The number of recursive loops so far. + * + * @return The hash value. + * + * @see Variant::recursive_hash() + */ +typedef GDExtensionInt (*GDExtensionInterfaceVariantRecursiveHash)(GDExtensionConstVariantPtr p_self, GDExtensionInt p_recursion_count); + +/** + * @name variant_hash_compare + * @since 4.1 + * + * Compares two Variants by their hash. + * + * @param p_self A pointer to the Variant. + * @param p_other A pointer to the other Variant to compare it to. + * + * @return The hash value. + * + * @see Variant::hash_compare() + */ +typedef GDExtensionBool (*GDExtensionInterfaceVariantHashCompare)(GDExtensionConstVariantPtr p_self, GDExtensionConstVariantPtr p_other); + +/** + * @name variant_booleanize + * @since 4.1 + * + * Converts a Variant to a boolean. + * + * @param p_self A pointer to the Variant. + * + * @return The boolean value of the Variant. + */ +typedef GDExtensionBool (*GDExtensionInterfaceVariantBooleanize)(GDExtensionConstVariantPtr p_self); + +/** + * @name variant_duplicate + * @since 4.1 + * + * Duplicates a Variant. + * + * @param p_self A pointer to the Variant. + * @param r_ret A pointer to a Variant to store the duplicated value. + * @param p_deep Whether or not to duplicate deeply (when supported by the Variant type). + */ +typedef void (*GDExtensionInterfaceVariantDuplicate)(GDExtensionConstVariantPtr p_self, GDExtensionVariantPtr r_ret, GDExtensionBool p_deep); + +/** + * @name variant_stringify + * @since 4.1 + * + * Converts a Variant to a string. + * + * @param p_self A pointer to the Variant. + * @param r_ret A pointer to a String to store the resulting value. + */ +typedef void (*GDExtensionInterfaceVariantStringify)(GDExtensionConstVariantPtr p_self, GDExtensionStringPtr r_ret); + +/** + * @name variant_get_type + * @since 4.1 + * + * Gets the type of a Variant. + * + * @param p_self A pointer to the Variant. + * + * @return The variant type. + */ +typedef GDExtensionVariantType (*GDExtensionInterfaceVariantGetType)(GDExtensionConstVariantPtr p_self); + +/** + * @name variant_has_method + * @since 4.1 + * + * Checks if a Variant has the given method. + * + * @param p_self A pointer to the Variant. + * @param p_method A pointer to a StringName with the method name. + * + * @return + */ +typedef GDExtensionBool (*GDExtensionInterfaceVariantHasMethod)(GDExtensionConstVariantPtr p_self, GDExtensionConstStringNamePtr p_method); + +/** + * @name variant_has_member + * @since 4.1 + * + * Checks if a type of Variant has the given member. + * + * @param p_type The Variant type. + * @param p_member A pointer to a StringName with the member name. + * + * @return + */ +typedef GDExtensionBool (*GDExtensionInterfaceVariantHasMember)(GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_member); + +/** + * @name variant_has_key + * @since 4.1 + * + * Checks if a Variant has a key. + * + * @param p_self A pointer to the Variant. + * @param p_key A pointer to a Variant representing the key. + * @param r_valid A pointer to a boolean which will be set to false if the key doesn't exist. + * + * @return true if the key exists; otherwise false. + */ +typedef GDExtensionBool (*GDExtensionInterfaceVariantHasKey)(GDExtensionConstVariantPtr p_self, GDExtensionConstVariantPtr p_key, GDExtensionBool *r_valid); + +/** + * @name variant_get_type_name + * @since 4.1 + * + * Gets the name of a Variant type. + * + * @param p_type The Variant type. + * @param r_name A pointer to a String to store the Variant type name. + */ +typedef void (*GDExtensionInterfaceVariantGetTypeName)(GDExtensionVariantType p_type, GDExtensionUninitializedStringPtr r_name); + +/** + * @name variant_can_convert + * @since 4.1 + * + * Checks if Variants can be converted from one type to another. + * + * @param p_from The Variant type to convert from. + * @param p_to The Variant type to convert to. + * + * @return true if the conversion is possible; otherwise false. + */ +typedef GDExtensionBool (*GDExtensionInterfaceVariantCanConvert)(GDExtensionVariantType p_from, GDExtensionVariantType p_to); + +/** + * @name variant_can_convert_strict + * @since 4.1 + * + * Checks if Variant can be converted from one type to another using stricter rules. + * + * @param p_from The Variant type to convert from. + * @param p_to The Variant type to convert to. + * + * @return true if the conversion is possible; otherwise false. + */ +typedef GDExtensionBool (*GDExtensionInterfaceVariantCanConvertStrict)(GDExtensionVariantType p_from, GDExtensionVariantType p_to); + +/** + * @name get_variant_from_type_constructor + * @since 4.1 + * + * Gets a pointer to a function that can create a Variant of the given type from a raw value. + * + * @param p_type The Variant type. + * + * @return A pointer to a function that can create a Variant of the given type from a raw value. + */ +typedef GDExtensionVariantFromTypeConstructorFunc (*GDExtensionInterfaceGetVariantFromTypeConstructor)(GDExtensionVariantType p_type); + +/** + * @name get_variant_to_type_constructor + * @since 4.1 + * + * Gets a pointer to a function that can get the raw value from a Variant of the given type. + * + * @param p_type The Variant type. + * + * @return A pointer to a function that can get the raw value from a Variant of the given type. + */ +typedef GDExtensionTypeFromVariantConstructorFunc (*GDExtensionInterfaceGetVariantToTypeConstructor)(GDExtensionVariantType p_type); + +/** + * @name variant_get_ptr_operator_evaluator + * @since 4.1 + * + * Gets a pointer to a function that can evaluate the given Variant operator on the given Variant types. + * + * @param p_operator The variant operator. + * @param p_type_a The type of the first Variant. + * @param p_type_b The type of the second Variant. + * + * @return A pointer to a function that can evaluate the given Variant operator on the given Variant types. + */ +typedef GDExtensionPtrOperatorEvaluator (*GDExtensionInterfaceVariantGetPtrOperatorEvaluator)(GDExtensionVariantOperator p_operator, GDExtensionVariantType p_type_a, GDExtensionVariantType p_type_b); + +/** + * @name variant_get_ptr_builtin_method + * @since 4.1 + * + * Gets a pointer to a function that can call a builtin method on a type of Variant. + * + * @param p_type The Variant type. + * @param p_method A pointer to a StringName with the method name. + * @param p_hash A hash representing the method signature. + * + * @return A pointer to a function that can call a builtin method on a type of Variant. + */ +typedef GDExtensionPtrBuiltInMethod (*GDExtensionInterfaceVariantGetPtrBuiltinMethod)(GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_method, GDExtensionInt p_hash); + +/** + * @name variant_get_ptr_constructor + * @since 4.1 + * + * Gets a pointer to a function that can call one of the constructors for a type of Variant. + * + * @param p_type The Variant type. + * @param p_constructor The index of the constructor. + * + * @return A pointer to a function that can call one of the constructors for a type of Variant. + */ +typedef GDExtensionPtrConstructor (*GDExtensionInterfaceVariantGetPtrConstructor)(GDExtensionVariantType p_type, int32_t p_constructor); + +/** + * @name variant_get_ptr_destructor + * @since 4.1 + * + * Gets a pointer to a function than can call the destructor for a type of Variant. + * + * @param p_type The Variant type. + * + * @return A pointer to a function than can call the destructor for a type of Variant. + */ +typedef GDExtensionPtrDestructor (*GDExtensionInterfaceVariantGetPtrDestructor)(GDExtensionVariantType p_type); + +/** + * @name variant_construct + * @since 4.1 + * + * Constructs a Variant of the given type, using the first constructor that matches the given arguments. + * + * @param p_type The Variant type. + * @param p_base A pointer to a Variant to store the constructed value. + * @param p_args A pointer to a C array of Variant pointers representing the arguments for the constructor. + * @param p_argument_count The number of arguments to pass to the constructor. + * @param r_error A pointer the structure which will be updated with error information. + */ +typedef void (*GDExtensionInterfaceVariantConstruct)(GDExtensionVariantType p_type, GDExtensionUninitializedVariantPtr r_base, const GDExtensionConstVariantPtr *p_args, int32_t p_argument_count, GDExtensionCallError *r_error); + +/** + * @name variant_get_ptr_setter + * @since 4.1 + * + * Gets a pointer to a function that can call a member's setter on the given Variant type. + * + * @param p_type The Variant type. + * @param p_member A pointer to a StringName with the member name. + * + * @return A pointer to a function that can call a member's setter on the given Variant type. + */ +typedef GDExtensionPtrSetter (*GDExtensionInterfaceVariantGetPtrSetter)(GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_member); + +/** + * @name variant_get_ptr_getter + * @since 4.1 + * + * Gets a pointer to a function that can call a member's getter on the given Variant type. + * + * @param p_type The Variant type. + * @param p_member A pointer to a StringName with the member name. + * + * @return A pointer to a function that can call a member's getter on the given Variant type. + */ +typedef GDExtensionPtrGetter (*GDExtensionInterfaceVariantGetPtrGetter)(GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_member); + +/** + * @name variant_get_ptr_indexed_setter + * @since 4.1 + * + * Gets a pointer to a function that can set an index on the given Variant type. + * + * @param p_type The Variant type. + * + * @return A pointer to a function that can set an index on the given Variant type. + */ +typedef GDExtensionPtrIndexedSetter (*GDExtensionInterfaceVariantGetPtrIndexedSetter)(GDExtensionVariantType p_type); + +/** + * @name variant_get_ptr_indexed_getter + * @since 4.1 + * + * Gets a pointer to a function that can get an index on the given Variant type. + * + * @param p_type The Variant type. + * + * @return A pointer to a function that can get an index on the given Variant type. + */ +typedef GDExtensionPtrIndexedGetter (*GDExtensionInterfaceVariantGetPtrIndexedGetter)(GDExtensionVariantType p_type); + +/** + * @name variant_get_ptr_keyed_setter + * @since 4.1 + * + * Gets a pointer to a function that can set a key on the given Variant type. + * + * @param p_type The Variant type. + * + * @return A pointer to a function that can set a key on the given Variant type. + */ +typedef GDExtensionPtrKeyedSetter (*GDExtensionInterfaceVariantGetPtrKeyedSetter)(GDExtensionVariantType p_type); + +/** + * @name variant_get_ptr_keyed_getter + * @since 4.1 + * + * Gets a pointer to a function that can get a key on the given Variant type. + * + * @param p_type The Variant type. + * + * @return A pointer to a function that can get a key on the given Variant type. + */ +typedef GDExtensionPtrKeyedGetter (*GDExtensionInterfaceVariantGetPtrKeyedGetter)(GDExtensionVariantType p_type); + +/** + * @name variant_get_ptr_keyed_checker + * @since 4.1 + * + * Gets a pointer to a function that can check a key on the given Variant type. + * + * @param p_type The Variant type. + * + * @return A pointer to a function that can check a key on the given Variant type. + */ +typedef GDExtensionPtrKeyedChecker (*GDExtensionInterfaceVariantGetPtrKeyedChecker)(GDExtensionVariantType p_type); + +/** + * @name variant_get_constant_value + * @since 4.1 + * + * Gets the value of a constant from the given Variant type. + * + * @param p_type The Variant type. + * @param p_constant A pointer to a StringName with the constant name. + * @param r_ret A pointer to a Variant to store the value. + */ +typedef void (*GDExtensionInterfaceVariantGetConstantValue)(GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_constant, GDExtensionUninitializedVariantPtr r_ret); + +/** + * @name variant_get_ptr_utility_function + * @since 4.1 + * + * Gets a pointer to a function that can call a Variant utility function. + * + * @param p_function A pointer to a StringName with the function name. + * @param p_hash A hash representing the function signature. + * + * @return A pointer to a function that can call a Variant utility function. + */ +typedef GDExtensionPtrUtilityFunction (*GDExtensionInterfaceVariantGetPtrUtilityFunction)(GDExtensionConstStringNamePtr p_function, GDExtensionInt p_hash); + +/* INTERFACE: String Utilities */ + +/** + * @name string_new_with_latin1_chars + * @since 4.1 + * + * Creates a String from a Latin-1 encoded C string. + * + * @param r_dest A pointer to a Variant to hold the newly created String. + * @param p_contents A pointer to a Latin-1 encoded C string (null terminated). + */ +typedef void (*GDExtensionInterfaceStringNewWithLatin1Chars)(GDExtensionUninitializedStringPtr r_dest, const char *p_contents); + +/** + * @name string_new_with_utf8_chars + * @since 4.1 + * + * Creates a String from a UTF-8 encoded C string. + * + * @param r_dest A pointer to a Variant to hold the newly created String. + * @param p_contents A pointer to a UTF-8 encoded C string (null terminated). + */ +typedef void (*GDExtensionInterfaceStringNewWithUtf8Chars)(GDExtensionUninitializedStringPtr r_dest, const char *p_contents); + +/** + * @name string_new_with_utf16_chars + * @since 4.1 + * + * Creates a String from a UTF-16 encoded C string. + * + * @param r_dest A pointer to a Variant to hold the newly created String. + * @param p_contents A pointer to a UTF-16 encoded C string (null terminated). + */ +typedef void (*GDExtensionInterfaceStringNewWithUtf16Chars)(GDExtensionUninitializedStringPtr r_dest, const char16_t *p_contents); + +/** + * @name string_new_with_utf32_chars + * @since 4.1 + * + * Creates a String from a UTF-32 encoded C string. + * + * @param r_dest A pointer to a Variant to hold the newly created String. + * @param p_contents A pointer to a UTF-32 encoded C string (null terminated). + */ +typedef void (*GDExtensionInterfaceStringNewWithUtf32Chars)(GDExtensionUninitializedStringPtr r_dest, const char32_t *p_contents); + +/** + * @name string_new_with_wide_chars + * @since 4.1 + * + * Creates a String from a wide C string. + * + * @param r_dest A pointer to a Variant to hold the newly created String. + * @param p_contents A pointer to a wide C string (null terminated). + */ +typedef void (*GDExtensionInterfaceStringNewWithWideChars)(GDExtensionUninitializedStringPtr r_dest, const wchar_t *p_contents); + +/** + * @name string_new_with_latin1_chars_and_len + * @since 4.1 + * + * Creates a String from a Latin-1 encoded C string with the given length. + * + * @param r_dest A pointer to a Variant to hold the newly created String. + * @param p_contents A pointer to a Latin-1 encoded C string. + * @param p_size The number of characters (= number of bytes). + */ +typedef void (*GDExtensionInterfaceStringNewWithLatin1CharsAndLen)(GDExtensionUninitializedStringPtr r_dest, const char *p_contents, GDExtensionInt p_size); + +/** + * @name string_new_with_utf8_chars_and_len + * @since 4.1 + * + * Creates a String from a UTF-8 encoded C string with the given length. + * + * @param r_dest A pointer to a Variant to hold the newly created String. + * @param p_contents A pointer to a UTF-8 encoded C string. + * @param p_size The number of bytes (not code units). + */ +typedef void (*GDExtensionInterfaceStringNewWithUtf8CharsAndLen)(GDExtensionUninitializedStringPtr r_dest, const char *p_contents, GDExtensionInt p_size); + +/** + * @name string_new_with_utf16_chars_and_len + * @since 4.1 + * + * Creates a String from a UTF-16 encoded C string with the given length. + * + * @param r_dest A pointer to a Variant to hold the newly created String. + * @param p_contents A pointer to a UTF-16 encoded C string. + * @param p_size The number of characters (not bytes). + */ +typedef void (*GDExtensionInterfaceStringNewWithUtf16CharsAndLen)(GDExtensionUninitializedStringPtr r_dest, const char16_t *p_contents, GDExtensionInt p_char_count); + +/** + * @name string_new_with_utf32_chars_and_len + * @since 4.1 + * + * Creates a String from a UTF-32 encoded C string with the given length. + * + * @param r_dest A pointer to a Variant to hold the newly created String. + * @param p_contents A pointer to a UTF-32 encoded C string. + * @param p_size The number of characters (not bytes). + */ +typedef void (*GDExtensionInterfaceStringNewWithUtf32CharsAndLen)(GDExtensionUninitializedStringPtr r_dest, const char32_t *p_contents, GDExtensionInt p_char_count); + +/** + * @name string_new_with_wide_chars_and_len + * @since 4.1 + * + * Creates a String from a wide C string with the given length. + * + * @param r_dest A pointer to a Variant to hold the newly created String. + * @param p_contents A pointer to a wide C string. + * @param p_size The number of characters (not bytes). + */ +typedef void (*GDExtensionInterfaceStringNewWithWideCharsAndLen)(GDExtensionUninitializedStringPtr r_dest, const wchar_t *p_contents, GDExtensionInt p_char_count); + +/** + * @name string_to_latin1_chars + * @since 4.1 + * + * Converts a String to a Latin-1 encoded C string. + * + * It doesn't write a null terminator. + * + * @param p_self A pointer to the String. + * @param r_text A pointer to the buffer to hold the resulting data. If NULL is passed in, only the length will be computed. + * @param p_max_write_length The maximum number of characters that can be written to r_text. It has no affect on the return value. + * + * @return The resulting encoded string length in characters (not bytes), not including a null terminator. + */ +typedef GDExtensionInt (*GDExtensionInterfaceStringToLatin1Chars)(GDExtensionConstStringPtr p_self, char *r_text, GDExtensionInt p_max_write_length); + +/** + * @name string_to_utf8_chars + * @since 4.1 + * + * Converts a String to a UTF-8 encoded C string. + * + * It doesn't write a null terminator. + * + * @param p_self A pointer to the String. + * @param r_text A pointer to the buffer to hold the resulting data. If NULL is passed in, only the length will be computed. + * @param p_max_write_length The maximum number of characters that can be written to r_text. It has no affect on the return value. + * + * @return The resulting encoded string length in characters (not bytes), not including a null terminator. + */ +typedef GDExtensionInt (*GDExtensionInterfaceStringToUtf8Chars)(GDExtensionConstStringPtr p_self, char *r_text, GDExtensionInt p_max_write_length); + +/** + * @name string_to_utf16_chars + * @since 4.1 + * + * Converts a String to a UTF-16 encoded C string. + * + * It doesn't write a null terminator. + * + * @param p_self A pointer to the String. + * @param r_text A pointer to the buffer to hold the resulting data. If NULL is passed in, only the length will be computed. + * @param p_max_write_length The maximum number of characters that can be written to r_text. It has no affect on the return value. + * + * @return The resulting encoded string length in characters (not bytes), not including a null terminator. + */ +typedef GDExtensionInt (*GDExtensionInterfaceStringToUtf16Chars)(GDExtensionConstStringPtr p_self, char16_t *r_text, GDExtensionInt p_max_write_length); + +/** + * @name string_to_utf32_chars + * @since 4.1 + * + * Converts a String to a UTF-32 encoded C string. + * + * It doesn't write a null terminator. + * + * @param p_self A pointer to the String. + * @param r_text A pointer to the buffer to hold the resulting data. If NULL is passed in, only the length will be computed. + * @param p_max_write_length The maximum number of characters that can be written to r_text. It has no affect on the return value. + * + * @return The resulting encoded string length in characters (not bytes), not including a null terminator. + */ +typedef GDExtensionInt (*GDExtensionInterfaceStringToUtf32Chars)(GDExtensionConstStringPtr p_self, char32_t *r_text, GDExtensionInt p_max_write_length); + +/** + * @name string_to_wide_chars + * @since 4.1 + * + * Converts a String to a wide C string. + * + * It doesn't write a null terminator. + * + * @param p_self A pointer to the String. + * @param r_text A pointer to the buffer to hold the resulting data. If NULL is passed in, only the length will be computed. + * @param p_max_write_length The maximum number of characters that can be written to r_text. It has no affect on the return value. + * + * @return The resulting encoded string length in characters (not bytes), not including a null terminator. + */ +typedef GDExtensionInt (*GDExtensionInterfaceStringToWideChars)(GDExtensionConstStringPtr p_self, wchar_t *r_text, GDExtensionInt p_max_write_length); + +/** + * @name string_operator_index + * @since 4.1 + * + * Gets a pointer to the character at the given index from a String. + * + * @param p_self A pointer to the String. + * @param p_index The index. + * + * @return A pointer to the requested character. + */ +typedef char32_t *(*GDExtensionInterfaceStringOperatorIndex)(GDExtensionStringPtr p_self, GDExtensionInt p_index); + +/** + * @name string_operator_index_const + * @since 4.1 + * + * Gets a const pointer to the character at the given index from a String. + * + * @param p_self A pointer to the String. + * @param p_index The index. + * + * @return A const pointer to the requested character. + */ +typedef const char32_t *(*GDExtensionInterfaceStringOperatorIndexConst)(GDExtensionConstStringPtr p_self, GDExtensionInt p_index); + +/** + * @name string_operator_plus_eq_string + * @since 4.1 + * + * Appends another String to a String. + * + * @param p_self A pointer to the String. + * @param p_b A pointer to the other String to append. + */ +typedef void (*GDExtensionInterfaceStringOperatorPlusEqString)(GDExtensionStringPtr p_self, GDExtensionConstStringPtr p_b); + +/** + * @name string_operator_plus_eq_char + * @since 4.1 + * + * Appends a character to a String. + * + * @param p_self A pointer to the String. + * @param p_b A pointer to the character to append. + */ +typedef void (*GDExtensionInterfaceStringOperatorPlusEqChar)(GDExtensionStringPtr p_self, char32_t p_b); + +/** + * @name string_operator_plus_eq_cstr + * @since 4.1 + * + * Appends a Latin-1 encoded C string to a String. + * + * @param p_self A pointer to the String. + * @param p_b A pointer to a Latin-1 encoded C string (null terminated). + */ +typedef void (*GDExtensionInterfaceStringOperatorPlusEqCstr)(GDExtensionStringPtr p_self, const char *p_b); + +/** + * @name string_operator_plus_eq_wcstr + * @since 4.1 + * + * Appends a wide C string to a String. + * + * @param p_self A pointer to the String. + * @param p_b A pointer to a wide C string (null terminated). + */ +typedef void (*GDExtensionInterfaceStringOperatorPlusEqWcstr)(GDExtensionStringPtr p_self, const wchar_t *p_b); + +/** + * @name string_operator_plus_eq_c32str + * @since 4.1 + * + * Appends a UTF-32 encoded C string to a String. + * + * @param p_self A pointer to the String. + * @param p_b A pointer to a UTF-32 encoded C string (null terminated). + */ +typedef void (*GDExtensionInterfaceStringOperatorPlusEqC32str)(GDExtensionStringPtr p_self, const char32_t *p_b); + +/** + * @name string_resize + * @since 4.2 + * + * Resizes the underlying string data to the given number of characters. + * + * Space needs to be allocated for the null terminating character ('\0') which + * also must be added manually, in order for all string functions to work correctly. + * + * Warning: This is an error-prone operation - only use it if there's no other + * efficient way to accomplish your goal. + * + * @param p_self A pointer to the String. + * @param p_resize The new length for the String. + * + * @return Error code signifying if the operation successful. + */ +typedef GDExtensionInt (*GDExtensionInterfaceStringResize)(GDExtensionStringPtr p_self, GDExtensionInt p_resize); + +/* INTERFACE: StringName Utilities */ + +/** + * @name string_name_new_with_latin1_chars + * @since 4.2 + * + * Creates a StringName from a Latin-1 encoded C string. + * + * If `p_is_static` is true, then: + * - The StringName will reuse the `p_contents` buffer instead of copying it. + * You must guarantee that the buffer remains valid for the duration of the application (e.g. string literal). + * - You must not call a destructor for this StringName. Incrementing the initial reference once should achieve this. + * + * `p_is_static` is purely an optimization and can easily introduce undefined behavior if used wrong. In case of doubt, set it to false. + * + * @param r_dest A pointer to uninitialized storage, into which the newly created StringName is constructed. + * @param p_contents A pointer to a C string (null terminated and Latin-1 or ASCII encoded). + * @param p_is_static Whether the StringName reuses the buffer directly (see above). + */ +typedef void (*GDExtensionInterfaceStringNameNewWithLatin1Chars)(GDExtensionUninitializedStringNamePtr r_dest, const char *p_contents, GDExtensionBool p_is_static); + +/** + * @name string_name_new_with_utf8_chars + * @since 4.2 + * + * Creates a StringName from a UTF-8 encoded C string. + * + * @param r_dest A pointer to uninitialized storage, into which the newly created StringName is constructed. + * @param p_contents A pointer to a C string (null terminated and UTF-8 encoded). + */ +typedef void (*GDExtensionInterfaceStringNameNewWithUtf8Chars)(GDExtensionUninitializedStringNamePtr r_dest, const char *p_contents); + +/** + * @name string_name_new_with_utf8_chars_and_len + * @since 4.2 + * + * Creates a StringName from a UTF-8 encoded string with a given number of characters. + * + * @param r_dest A pointer to uninitialized storage, into which the newly created StringName is constructed. + * @param p_contents A pointer to a C string (null terminated and UTF-8 encoded). + * @param p_size The number of bytes (not UTF-8 code points). + */ +typedef void (*GDExtensionInterfaceStringNameNewWithUtf8CharsAndLen)(GDExtensionUninitializedStringNamePtr r_dest, const char *p_contents, GDExtensionInt p_size); + +/* INTERFACE: XMLParser Utilities */ + +/** + * @name xml_parser_open_buffer + * @since 4.1 + * + * Opens a raw XML buffer on an XMLParser instance. + * + * @param p_instance A pointer to an XMLParser object. + * @param p_buffer A pointer to the buffer. + * @param p_size The size of the buffer. + * + * @return A Godot error code (ex. OK, ERR_INVALID_DATA, etc). + * + * @see XMLParser::open_buffer() + */ +typedef GDExtensionInt (*GDExtensionInterfaceXmlParserOpenBuffer)(GDExtensionObjectPtr p_instance, const uint8_t *p_buffer, size_t p_size); + +/* INTERFACE: FileAccess Utilities */ + +/** + * @name file_access_store_buffer + * @since 4.1 + * + * Stores the given buffer using an instance of FileAccess. + * + * @param p_instance A pointer to a FileAccess object. + * @param p_src A pointer to the buffer. + * @param p_length The size of the buffer. + * + * @see FileAccess::store_buffer() + */ +typedef void (*GDExtensionInterfaceFileAccessStoreBuffer)(GDExtensionObjectPtr p_instance, const uint8_t *p_src, uint64_t p_length); + +/** + * @name file_access_get_buffer + * @since 4.1 + * + * Reads the next p_length bytes into the given buffer using an instance of FileAccess. + * + * @param p_instance A pointer to a FileAccess object. + * @param p_dst A pointer to the buffer to store the data. + * @param p_length The requested number of bytes to read. + * + * @return The actual number of bytes read (may be less than requested). + */ +typedef uint64_t (*GDExtensionInterfaceFileAccessGetBuffer)(GDExtensionConstObjectPtr p_instance, uint8_t *p_dst, uint64_t p_length); + +/* INTERFACE: WorkerThreadPool Utilities */ + +/** + * @name worker_thread_pool_add_native_group_task + * @since 4.1 + * + * Adds a group task to an instance of WorkerThreadPool. + * + * @param p_instance A pointer to a WorkerThreadPool object. + * @param p_func A pointer to a function to run in the thread pool. + * @param p_userdata A pointer to arbitrary data which will be passed to p_func. + * @param p_tasks The number of tasks needed in the group. + * @param p_high_priority Whether or not this is a high priority task. + * @param p_description A pointer to a String with the task description. + * + * @return The task group ID. + * + * @see WorkerThreadPool::add_group_task() + */ +typedef int64_t (*GDExtensionInterfaceWorkerThreadPoolAddNativeGroupTask)(GDExtensionObjectPtr p_instance, void (*p_func)(void *, uint32_t), void *p_userdata, int p_elements, int p_tasks, GDExtensionBool p_high_priority, GDExtensionConstStringPtr p_description); + +/** + * @name worker_thread_pool_add_native_task + * @since 4.1 + * + * Adds a task to an instance of WorkerThreadPool. + * + * @param p_instance A pointer to a WorkerThreadPool object. + * @param p_func A pointer to a function to run in the thread pool. + * @param p_userdata A pointer to arbitrary data which will be passed to p_func. + * @param p_high_priority Whether or not this is a high priority task. + * @param p_description A pointer to a String with the task description. + * + * @return The task ID. + */ +typedef int64_t (*GDExtensionInterfaceWorkerThreadPoolAddNativeTask)(GDExtensionObjectPtr p_instance, void (*p_func)(void *), void *p_userdata, GDExtensionBool p_high_priority, GDExtensionConstStringPtr p_description); + +/* INTERFACE: Packed Array */ + +/** + * @name packed_byte_array_operator_index + * @since 4.1 + * + * Gets a pointer to a byte in a PackedByteArray. + * + * @param p_self A pointer to a PackedByteArray object. + * @param p_index The index of the byte to get. + * + * @return A pointer to the requested byte. + */ +typedef uint8_t *(*GDExtensionInterfacePackedByteArrayOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionInt p_index); + +/** + * @name packed_byte_array_operator_index_const + * @since 4.1 + * + * Gets a const pointer to a byte in a PackedByteArray. + * + * @param p_self A const pointer to a PackedByteArray object. + * @param p_index The index of the byte to get. + * + * @return A const pointer to the requested byte. + */ +typedef const uint8_t *(*GDExtensionInterfacePackedByteArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index); + +/** + * @name packed_color_array_operator_index + * @since 4.1 + * + * Gets a pointer to a color in a PackedColorArray. + * + * @param p_self A pointer to a PackedColorArray object. + * @param p_index The index of the Color to get. + * + * @return A pointer to the requested Color. + */ +typedef GDExtensionTypePtr (*GDExtensionInterfacePackedColorArrayOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionInt p_index); + +/** + * @name packed_color_array_operator_index_const + * @since 4.1 + * + * Gets a const pointer to a color in a PackedColorArray. + * + * @param p_self A const pointer to a const PackedColorArray object. + * @param p_index The index of the Color to get. + * + * @return A const pointer to the requested Color. + */ +typedef GDExtensionTypePtr (*GDExtensionInterfacePackedColorArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index); + +/** + * @name packed_float32_array_operator_index + * @since 4.1 + * + * Gets a pointer to a 32-bit float in a PackedFloat32Array. + * + * @param p_self A pointer to a PackedFloat32Array object. + * @param p_index The index of the float to get. + * + * @return A pointer to the requested 32-bit float. + */ +typedef float *(*GDExtensionInterfacePackedFloat32ArrayOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionInt p_index); + +/** + * @name packed_float32_array_operator_index_const + * @since 4.1 + * + * Gets a const pointer to a 32-bit float in a PackedFloat32Array. + * + * @param p_self A const pointer to a PackedFloat32Array object. + * @param p_index The index of the float to get. + * + * @return A const pointer to the requested 32-bit float. + */ +typedef const float *(*GDExtensionInterfacePackedFloat32ArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index); + +/** + * @name packed_float64_array_operator_index + * @since 4.1 + * + * Gets a pointer to a 64-bit float in a PackedFloat64Array. + * + * @param p_self A pointer to a PackedFloat64Array object. + * @param p_index The index of the float to get. + * + * @return A pointer to the requested 64-bit float. + */ +typedef double *(*GDExtensionInterfacePackedFloat64ArrayOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionInt p_index); + +/** + * @name packed_float64_array_operator_index_const + * @since 4.1 + * + * Gets a const pointer to a 64-bit float in a PackedFloat64Array. + * + * @param p_self A const pointer to a PackedFloat64Array object. + * @param p_index The index of the float to get. + * + * @return A const pointer to the requested 64-bit float. + */ +typedef const double *(*GDExtensionInterfacePackedFloat64ArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index); + +/** + * @name packed_int32_array_operator_index + * @since 4.1 + * + * Gets a pointer to a 32-bit integer in a PackedInt32Array. + * + * @param p_self A pointer to a PackedInt32Array object. + * @param p_index The index of the integer to get. + * + * @return A pointer to the requested 32-bit integer. + */ +typedef int32_t *(*GDExtensionInterfacePackedInt32ArrayOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionInt p_index); + +/** + * @name packed_int32_array_operator_index_const + * @since 4.1 + * + * Gets a const pointer to a 32-bit integer in a PackedInt32Array. + * + * @param p_self A const pointer to a PackedInt32Array object. + * @param p_index The index of the integer to get. + * + * @return A const pointer to the requested 32-bit integer. + */ +typedef const int32_t *(*GDExtensionInterfacePackedInt32ArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index); + +/** + * @name packed_int64_array_operator_index + * @since 4.1 + * + * Gets a pointer to a 64-bit integer in a PackedInt64Array. + * + * @param p_self A pointer to a PackedInt64Array object. + * @param p_index The index of the integer to get. + * + * @return A pointer to the requested 64-bit integer. + */ +typedef int64_t *(*GDExtensionInterfacePackedInt64ArrayOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionInt p_index); + +/** + * @name packed_int64_array_operator_index_const + * @since 4.1 + * + * Gets a const pointer to a 64-bit integer in a PackedInt64Array. + * + * @param p_self A const pointer to a PackedInt64Array object. + * @param p_index The index of the integer to get. + * + * @return A const pointer to the requested 64-bit integer. + */ +typedef const int64_t *(*GDExtensionInterfacePackedInt64ArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index); + +/** + * @name packed_string_array_operator_index + * @since 4.1 + * + * Gets a pointer to a string in a PackedStringArray. + * + * @param p_self A pointer to a PackedStringArray object. + * @param p_index The index of the String to get. + * + * @return A pointer to the requested String. + */ +typedef GDExtensionStringPtr (*GDExtensionInterfacePackedStringArrayOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionInt p_index); + +/** + * @name packed_string_array_operator_index_const + * @since 4.1 + * + * Gets a const pointer to a string in a PackedStringArray. + * + * @param p_self A const pointer to a PackedStringArray object. + * @param p_index The index of the String to get. + * + * @return A const pointer to the requested String. + */ +typedef GDExtensionStringPtr (*GDExtensionInterfacePackedStringArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index); + +/** + * @name packed_vector2_array_operator_index + * @since 4.1 + * + * Gets a pointer to a Vector2 in a PackedVector2Array. + * + * @param p_self A pointer to a PackedVector2Array object. + * @param p_index The index of the Vector2 to get. + * + * @return A pointer to the requested Vector2. + */ +typedef GDExtensionTypePtr (*GDExtensionInterfacePackedVector2ArrayOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionInt p_index); + +/** + * @name packed_vector2_array_operator_index_const + * @since 4.1 + * + * Gets a const pointer to a Vector2 in a PackedVector2Array. + * + * @param p_self A const pointer to a PackedVector2Array object. + * @param p_index The index of the Vector2 to get. + * + * @return A const pointer to the requested Vector2. + */ +typedef GDExtensionTypePtr (*GDExtensionInterfacePackedVector2ArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index); + +/** + * @name packed_vector3_array_operator_index + * @since 4.1 + * + * Gets a pointer to a Vector3 in a PackedVector3Array. + * + * @param p_self A pointer to a PackedVector3Array object. + * @param p_index The index of the Vector3 to get. + * + * @return A pointer to the requested Vector3. + */ +typedef GDExtensionTypePtr (*GDExtensionInterfacePackedVector3ArrayOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionInt p_index); + +/** + * @name packed_vector3_array_operator_index_const + * @since 4.1 + * + * Gets a const pointer to a Vector3 in a PackedVector3Array. + * + * @param p_self A const pointer to a PackedVector3Array object. + * @param p_index The index of the Vector3 to get. + * + * @return A const pointer to the requested Vector3. + */ +typedef GDExtensionTypePtr (*GDExtensionInterfacePackedVector3ArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index); + +/** + * @name array_operator_index + * @since 4.1 + * + * Gets a pointer to a Variant in an Array. + * + * @param p_self A pointer to an Array object. + * @param p_index The index of the Variant to get. + * + * @return A pointer to the requested Variant. + */ +typedef GDExtensionVariantPtr (*GDExtensionInterfaceArrayOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionInt p_index); + +/** + * @name array_operator_index_const + * @since 4.1 + * + * Gets a const pointer to a Variant in an Array. + * + * @param p_self A const pointer to an Array object. + * @param p_index The index of the Variant to get. + * + * @return A const pointer to the requested Variant. + */ +typedef GDExtensionVariantPtr (*GDExtensionInterfaceArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index); + +/** + * @name array_ref + * @since 4.1 + * + * Sets an Array to be a reference to another Array object. + * + * @param p_self A pointer to the Array object to update. + * @param p_from A pointer to the Array object to reference. + */ +typedef void (*GDExtensionInterfaceArrayRef)(GDExtensionTypePtr p_self, GDExtensionConstTypePtr p_from); + +/** + * @name array_set_typed + * @since 4.1 + * + * Makes an Array into a typed Array. + * + * @param p_self A pointer to the Array. + * @param p_type The type of Variant the Array will store. + * @param p_class_name A pointer to a StringName with the name of the object (if p_type is GDEXTENSION_VARIANT_TYPE_OBJECT). + * @param p_script A pointer to a Script object (if p_type is GDEXTENSION_VARIANT_TYPE_OBJECT and the base class is extended by a script). + */ +typedef void (*GDExtensionInterfaceArraySetTyped)(GDExtensionTypePtr p_self, GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_class_name, GDExtensionConstVariantPtr p_script); + +/* INTERFACE: Dictionary */ + +/** + * @name dictionary_operator_index + * @since 4.1 + * + * Gets a pointer to a Variant in a Dictionary with the given key. + * + * @param p_self A pointer to a Dictionary object. + * @param p_key A pointer to a Variant representing the key. + * + * @return A pointer to a Variant representing the value at the given key. + */ +typedef GDExtensionVariantPtr (*GDExtensionInterfaceDictionaryOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionConstVariantPtr p_key); + +/** + * @name dictionary_operator_index_const + * @since 4.1 + * + * Gets a const pointer to a Variant in a Dictionary with the given key. + * + * @param p_self A const pointer to a Dictionary object. + * @param p_key A pointer to a Variant representing the key. + * + * @return A const pointer to a Variant representing the value at the given key. + */ +typedef GDExtensionVariantPtr (*GDExtensionInterfaceDictionaryOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionConstVariantPtr p_key); + +/* INTERFACE: Object */ + +/** + * @name object_method_bind_call + * @since 4.1 + * + * Calls a method on an Object. + * + * @param p_method_bind A pointer to the MethodBind representing the method on the Object's class. + * @param p_instance A pointer to the Object. + * @param p_args A pointer to a C array of Variants representing the arguments. + * @param p_arg_count The number of arguments. + * @param r_ret A pointer to Variant which will receive the return value. + * @param r_error A pointer to a GDExtensionCallError struct that will receive error information. + */ +typedef void (*GDExtensionInterfaceObjectMethodBindCall)(GDExtensionMethodBindPtr p_method_bind, GDExtensionObjectPtr p_instance, const GDExtensionConstVariantPtr *p_args, GDExtensionInt p_arg_count, GDExtensionUninitializedVariantPtr r_ret, GDExtensionCallError *r_error); + +/** + * @name object_method_bind_ptrcall + * @since 4.1 + * + * Calls a method on an Object (using a "ptrcall"). + * + * @param p_method_bind A pointer to the MethodBind representing the method on the Object's class. + * @param p_instance A pointer to the Object. + * @param p_args A pointer to a C array representing the arguments. + * @param r_ret A pointer to the Object that will receive the return value. + */ +typedef void (*GDExtensionInterfaceObjectMethodBindPtrcall)(GDExtensionMethodBindPtr p_method_bind, GDExtensionObjectPtr p_instance, const GDExtensionConstTypePtr *p_args, GDExtensionTypePtr r_ret); + +/** + * @name object_destroy + * @since 4.1 + * + * Destroys an Object. + * + * @param p_o A pointer to the Object. + */ +typedef void (*GDExtensionInterfaceObjectDestroy)(GDExtensionObjectPtr p_o); + +/** + * @name global_get_singleton + * @since 4.1 + * + * Gets a global singleton by name. + * + * @param p_name A pointer to a StringName with the singleton name. + * + * @return A pointer to the singleton Object. + */ +typedef GDExtensionObjectPtr (*GDExtensionInterfaceGlobalGetSingleton)(GDExtensionConstStringNamePtr p_name); + +/** + * @name object_get_instance_binding + * @since 4.1 + * + * Gets a pointer representing an Object's instance binding. + * + * @param p_o A pointer to the Object. + * @param p_library A token the library received by the GDExtension's entry point function. + * @param p_callbacks A pointer to a GDExtensionInstanceBindingCallbacks struct. + * + * @return + */ +typedef void *(*GDExtensionInterfaceObjectGetInstanceBinding)(GDExtensionObjectPtr p_o, void *p_token, const GDExtensionInstanceBindingCallbacks *p_callbacks); + +/** + * @name object_set_instance_binding + * @since 4.1 + * + * Sets an Object's instance binding. + * + * @param p_o A pointer to the Object. + * @param p_library A token the library received by the GDExtension's entry point function. + * @param p_binding A pointer to the instance binding. + * @param p_callbacks A pointer to a GDExtensionInstanceBindingCallbacks struct. + */ +typedef void (*GDExtensionInterfaceObjectSetInstanceBinding)(GDExtensionObjectPtr p_o, void *p_token, void *p_binding, const GDExtensionInstanceBindingCallbacks *p_callbacks); + +/** + * @name object_free_instance_binding + * @since 4.2 + * + * Free an Object's instance binding. + * + * @param p_o A pointer to the Object. + * @param p_library A token the library received by the GDExtension's entry point function. + */ +typedef void (*GDExtensionInterfaceObjectFreeInstanceBinding)(GDExtensionObjectPtr p_o, void *p_token); + +/** + * @name object_set_instance + * @since 4.1 + * + * Sets an extension class instance on a Object. + * + * @param p_o A pointer to the Object. + * @param p_classname A pointer to a StringName with the registered extension class's name. + * @param p_instance A pointer to the extension class instance. + */ +typedef void (*GDExtensionInterfaceObjectSetInstance)(GDExtensionObjectPtr p_o, GDExtensionConstStringNamePtr p_classname, GDExtensionClassInstancePtr p_instance); /* p_classname should be a registered extension class and should extend the p_o object's class. */ + +/** + * @name object_get_class_name + * @since 4.1 + * + * Gets the class name of an Object. + * + * @param p_object A pointer to the Object. + * @param p_library A pointer the library received by the GDExtension's entry point function. + * @param r_class_name A pointer to a String to receive the class name. + * + * @return true if successful in getting the class name; otherwise false. + */ +typedef GDExtensionBool (*GDExtensionInterfaceObjectGetClassName)(GDExtensionConstObjectPtr p_object, GDExtensionClassLibraryPtr p_library, GDExtensionUninitializedStringNamePtr r_class_name); + +/** + * @name object_cast_to + * @since 4.1 + * + * Casts an Object to a different type. + * + * @param p_object A pointer to the Object. + * @param p_class_tag A pointer uniquely identifying a built-in class in the ClassDB. + * + * @return Returns a pointer to the Object, or NULL if it can't be cast to the requested type. + */ +typedef GDExtensionObjectPtr (*GDExtensionInterfaceObjectCastTo)(GDExtensionConstObjectPtr p_object, void *p_class_tag); + +/** + * @name object_get_instance_from_id + * @since 4.1 + * + * Gets an Object by its instance ID. + * + * @param p_instance_id The instance ID. + * + * @return A pointer to the Object. + */ +typedef GDExtensionObjectPtr (*GDExtensionInterfaceObjectGetInstanceFromId)(GDObjectInstanceID p_instance_id); + +/** + * @name object_get_instance_id + * @since 4.1 + * + * Gets the instance ID from an Object. + * + * @param p_object A pointer to the Object. + * + * @return The instance ID. + */ +typedef GDObjectInstanceID (*GDExtensionInterfaceObjectGetInstanceId)(GDExtensionConstObjectPtr p_object); + +/** + * @name object_has_script_method + * @since 4.3 + * + * Checks if this object has a script with the given method. + * + * @param p_object A pointer to the Object. + * @param p_method A pointer to a StringName identifying the method. + * + * @returns true if the object has a script and that script has a method with the given name. Returns false if the object has no script. + */ +typedef GDExtensionBool (*GDExtensionInterfaceObjectHasScriptMethod)(GDExtensionConstObjectPtr p_object, GDExtensionConstStringNamePtr p_method); + +/** + * @name object_call_script_method + * @since 4.3 + * + * Call the given script method on this object. + * + * @param p_object A pointer to the Object. + * @param p_method A pointer to a StringName identifying the method. + * @param p_args A pointer to a C array of Variant. + * @param p_argument_count The number of arguments. + * @param r_return A pointer a Variant which will be assigned the return value. + * @param r_error A pointer the structure which will hold error information. + */ +typedef void (*GDExtensionInterfaceObjectCallScriptMethod)(GDExtensionObjectPtr p_object, GDExtensionConstStringNamePtr p_method, const GDExtensionConstVariantPtr *p_args, GDExtensionInt p_argument_count, GDExtensionUninitializedVariantPtr r_return, GDExtensionCallError *r_error); + +/* INTERFACE: Reference */ + +/** + * @name ref_get_object + * @since 4.1 + * + * Gets the Object from a reference. + * + * @param p_ref A pointer to the reference. + * + * @return A pointer to the Object from the reference or NULL. + */ +typedef GDExtensionObjectPtr (*GDExtensionInterfaceRefGetObject)(GDExtensionConstRefPtr p_ref); + +/** + * @name ref_set_object + * @since 4.1 + * + * Sets the Object referred to by a reference. + * + * @param p_ref A pointer to the reference. + * @param p_object A pointer to the Object to refer to. + */ +typedef void (*GDExtensionInterfaceRefSetObject)(GDExtensionRefPtr p_ref, GDExtensionObjectPtr p_object); + +/* INTERFACE: Script Instance */ + +/** + * @name script_instance_create + * @since 4.1 + * @deprecated in Godot 4.2. Use `script_instance_create3` instead. + * + * Creates a script instance that contains the given info and instance data. + * + * @param p_info A pointer to a GDExtensionScriptInstanceInfo struct. + * @param p_instance_data A pointer to a data representing the script instance in the GDExtension. This will be passed to all the function pointers on p_info. + * + * @return A pointer to a ScriptInstanceExtension object. + */ +typedef GDExtensionScriptInstancePtr (*GDExtensionInterfaceScriptInstanceCreate)(const GDExtensionScriptInstanceInfo *p_info, GDExtensionScriptInstanceDataPtr p_instance_data); + +/** + * @name script_instance_create2 + * @since 4.2 + * @deprecated in Godot 4.3. Use `script_instance_create3` instead. + * + * Creates a script instance that contains the given info and instance data. + * + * @param p_info A pointer to a GDExtensionScriptInstanceInfo2 struct. + * @param p_instance_data A pointer to a data representing the script instance in the GDExtension. This will be passed to all the function pointers on p_info. + * + * @return A pointer to a ScriptInstanceExtension object. + */ +typedef GDExtensionScriptInstancePtr (*GDExtensionInterfaceScriptInstanceCreate2)(const GDExtensionScriptInstanceInfo2 *p_info, GDExtensionScriptInstanceDataPtr p_instance_data); + +/** + * @name script_instance_create3 + * @since 4.3 + * + * Creates a script instance that contains the given info and instance data. + * + * @param p_info A pointer to a GDExtensionScriptInstanceInfo3 struct. + * @param p_instance_data A pointer to a data representing the script instance in the GDExtension. This will be passed to all the function pointers on p_info. + * + * @return A pointer to a ScriptInstanceExtension object. + */ +typedef GDExtensionScriptInstancePtr (*GDExtensionInterfaceScriptInstanceCreate3)(const GDExtensionScriptInstanceInfo3 *p_info, GDExtensionScriptInstanceDataPtr p_instance_data); + +/** + * @name placeholder_script_instance_create + * @since 4.2 + * + * Creates a placeholder script instance for a given script and instance. + * + * This interface is optional as a custom placeholder could also be created with script_instance_create(). + * + * @param p_language A pointer to a ScriptLanguage. + * @param p_script A pointer to a Script. + * @param p_owner A pointer to an Object. + * + * @return A pointer to a PlaceHolderScriptInstance object. + */ +typedef GDExtensionScriptInstancePtr (*GDExtensionInterfacePlaceHolderScriptInstanceCreate)(GDExtensionObjectPtr p_language, GDExtensionObjectPtr p_script, GDExtensionObjectPtr p_owner); + +/** + * @name placeholder_script_instance_update + * @since 4.2 + * + * Updates a placeholder script instance with the given properties and values. + * + * The passed in placeholder must be an instance of PlaceHolderScriptInstance + * such as the one returned by placeholder_script_instance_create(). + * + * @param p_placeholder A pointer to a PlaceHolderScriptInstance. + * @param p_properties A pointer to an Array of Dictionary representing PropertyInfo. + * @param p_values A pointer to a Dictionary mapping StringName to Variant values. + */ +typedef void (*GDExtensionInterfacePlaceHolderScriptInstanceUpdate)(GDExtensionScriptInstancePtr p_placeholder, GDExtensionConstTypePtr p_properties, GDExtensionConstTypePtr p_values); + +/** + * @name object_get_script_instance + * @since 4.2 + * + * Get the script instance data attached to this object. + * + * @param p_object A pointer to the Object. + * @param p_language A pointer to the language expected for this script instance. + * + * @return A GDExtensionScriptInstanceDataPtr that was attached to this object as part of script_instance_create. + */ +typedef GDExtensionScriptInstanceDataPtr (*GDExtensionInterfaceObjectGetScriptInstance)(GDExtensionConstObjectPtr p_object, GDExtensionObjectPtr p_language); + +/* INTERFACE: Callable */ + +/** + * @name callable_custom_create + * @since 4.2 + * @deprecated in Godot 4.3. Use `callable_custom_create2` instead. + * + * Creates a custom Callable object from a function pointer. + * + * Provided struct can be safely freed once the function returns. + * + * @param r_callable A pointer that will receive the new Callable. + * @param p_callable_custom_info The info required to construct a Callable. + */ +typedef void (*GDExtensionInterfaceCallableCustomCreate)(GDExtensionUninitializedTypePtr r_callable, GDExtensionCallableCustomInfo *p_callable_custom_info); + +/** + * @name callable_custom_create2 + * @since 4.3 + * + * Creates a custom Callable object from a function pointer. + * + * Provided struct can be safely freed once the function returns. + * + * @param r_callable A pointer that will receive the new Callable. + * @param p_callable_custom_info The info required to construct a Callable. + */ +typedef void (*GDExtensionInterfaceCallableCustomCreate2)(GDExtensionUninitializedTypePtr r_callable, GDExtensionCallableCustomInfo2 *p_callable_custom_info); + +/** + * @name callable_custom_get_userdata + * @since 4.2 + * + * Retrieves the userdata pointer from a custom Callable. + * + * If the Callable is not a custom Callable or the token does not match the one provided to callable_custom_create() via GDExtensionCallableCustomInfo then NULL will be returned. + * + * @param p_callable A pointer to a Callable. + * @param p_token A pointer to an address that uniquely identifies the GDExtension. + */ +typedef void *(*GDExtensionInterfaceCallableCustomGetUserData)(GDExtensionConstTypePtr p_callable, void *p_token); + +/* INTERFACE: ClassDB */ + +/** + * @name classdb_construct_object + * @since 4.1 + * + * Constructs an Object of the requested class. + * + * The passed class must be a built-in godot class, or an already-registered extension class. In both cases, object_set_instance() should be called to fully initialize the object. + * + * @param p_classname A pointer to a StringName with the class name. + * + * @return A pointer to the newly created Object. + */ +typedef GDExtensionObjectPtr (*GDExtensionInterfaceClassdbConstructObject)(GDExtensionConstStringNamePtr p_classname); + +/** + * @name classdb_get_method_bind + * @since 4.1 + * + * Gets a pointer to the MethodBind in ClassDB for the given class, method and hash. + * + * @param p_classname A pointer to a StringName with the class name. + * @param p_methodname A pointer to a StringName with the method name. + * @param p_hash A hash representing the function signature. + * + * @return A pointer to the MethodBind from ClassDB. + */ +typedef GDExtensionMethodBindPtr (*GDExtensionInterfaceClassdbGetMethodBind)(GDExtensionConstStringNamePtr p_classname, GDExtensionConstStringNamePtr p_methodname, GDExtensionInt p_hash); + +/** + * @name classdb_get_class_tag + * @since 4.1 + * + * Gets a pointer uniquely identifying the given built-in class in the ClassDB. + * + * @param p_classname A pointer to a StringName with the class name. + * + * @return A pointer uniquely identifying the built-in class in the ClassDB. + */ +typedef void *(*GDExtensionInterfaceClassdbGetClassTag)(GDExtensionConstStringNamePtr p_classname); + +/* INTERFACE: ClassDB Extension */ + +/** + * @name classdb_register_extension_class + * @since 4.1 + * @deprecated in Godot 4.2. Use `classdb_register_extension_class2` instead. + * + * Registers an extension class in the ClassDB. + * + * Provided struct can be safely freed once the function returns. + * + * @param p_library A pointer the library received by the GDExtension's entry point function. + * @param p_class_name A pointer to a StringName with the class name. + * @param p_parent_class_name A pointer to a StringName with the parent class name. + * @param p_extension_funcs A pointer to a GDExtensionClassCreationInfo struct. + */ +typedef void (*GDExtensionInterfaceClassdbRegisterExtensionClass)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, GDExtensionConstStringNamePtr p_parent_class_name, const GDExtensionClassCreationInfo *p_extension_funcs); + +/** + * @name classdb_register_extension_class2 + * @since 4.2 + * + * Registers an extension class in the ClassDB. + * + * Provided struct can be safely freed once the function returns. + * + * @param p_library A pointer the library received by the GDExtension's entry point function. + * @param p_class_name A pointer to a StringName with the class name. + * @param p_parent_class_name A pointer to a StringName with the parent class name. + * @param p_extension_funcs A pointer to a GDExtensionClassCreationInfo2 struct. + */ +typedef void (*GDExtensionInterfaceClassdbRegisterExtensionClass2)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, GDExtensionConstStringNamePtr p_parent_class_name, const GDExtensionClassCreationInfo2 *p_extension_funcs); + +/** + * @name classdb_register_extension_class3 + * @since 4.3 + * + * Registers an extension class in the ClassDB. + * + * Provided struct can be safely freed once the function returns. + * + * @param p_library A pointer the library received by the GDExtension's entry point function. + * @param p_class_name A pointer to a StringName with the class name. + * @param p_parent_class_name A pointer to a StringName with the parent class name. + * @param p_extension_funcs A pointer to a GDExtensionClassCreationInfo2 struct. + */ +typedef void (*GDExtensionInterfaceClassdbRegisterExtensionClass3)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, GDExtensionConstStringNamePtr p_parent_class_name, const GDExtensionClassCreationInfo3 *p_extension_funcs); + +/** + * @name classdb_register_extension_class_method + * @since 4.1 + * + * Registers a method on an extension class in the ClassDB. + * + * Provided struct can be safely freed once the function returns. + * + * @param p_library A pointer the library received by the GDExtension's entry point function. + * @param p_class_name A pointer to a StringName with the class name. + * @param p_method_info A pointer to a GDExtensionClassMethodInfo struct. + */ +typedef void (*GDExtensionInterfaceClassdbRegisterExtensionClassMethod)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, const GDExtensionClassMethodInfo *p_method_info); + +/** + * @name classdb_register_extension_class_virtual_method + * @since 4.3 + * + * Registers a virtual method on an extension class in ClassDB, that can be implemented by scripts or other extensions. + * + * Provided struct can be safely freed once the function returns. + * + * @param p_library A pointer the library received by the GDExtension's entry point function. + * @param p_class_name A pointer to a StringName with the class name. + * @param p_method_info A pointer to a GDExtensionClassMethodInfo struct. + */ +typedef void (*GDExtensionInterfaceClassdbRegisterExtensionClassVirtualMethod)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, const GDExtensionClassVirtualMethodInfo *p_method_info); + +/** + * @name classdb_register_extension_class_integer_constant + * @since 4.1 + * + * Registers an integer constant on an extension class in the ClassDB. + * + * @param p_library A pointer the library received by the GDExtension's entry point function. + * @param p_class_name A pointer to a StringName with the class name. + * @param p_enum_name A pointer to a StringName with the enum name. + * @param p_constant_name A pointer to a StringName with the constant name. + * @param p_constant_value The constant value. + * @param p_is_bitfield Whether or not this is a bit field. + */ +typedef void (*GDExtensionInterfaceClassdbRegisterExtensionClassIntegerConstant)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, GDExtensionConstStringNamePtr p_enum_name, GDExtensionConstStringNamePtr p_constant_name, GDExtensionInt p_constant_value, GDExtensionBool p_is_bitfield); + +/** + * @name classdb_register_extension_class_property + * @since 4.1 + * + * Registers a property on an extension class in the ClassDB. + * + * Provided struct can be safely freed once the function returns. + * + * @param p_library A pointer the library received by the GDExtension's entry point function. + * @param p_class_name A pointer to a StringName with the class name. + * @param p_info A pointer to a GDExtensionPropertyInfo struct. + * @param p_setter A pointer to a StringName with the name of the setter method. + * @param p_getter A pointer to a StringName with the name of the getter method. + */ +typedef void (*GDExtensionInterfaceClassdbRegisterExtensionClassProperty)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, const GDExtensionPropertyInfo *p_info, GDExtensionConstStringNamePtr p_setter, GDExtensionConstStringNamePtr p_getter); + +/** + * @name classdb_register_extension_class_property_indexed + * @since 4.2 + * + * Registers an indexed property on an extension class in the ClassDB. + * + * Provided struct can be safely freed once the function returns. + * + * @param p_library A pointer the library received by the GDExtension's entry point function. + * @param p_class_name A pointer to a StringName with the class name. + * @param p_info A pointer to a GDExtensionPropertyInfo struct. + * @param p_setter A pointer to a StringName with the name of the setter method. + * @param p_getter A pointer to a StringName with the name of the getter method. + * @param p_index The index to pass as the first argument to the getter and setter methods. + */ +typedef void (*GDExtensionInterfaceClassdbRegisterExtensionClassPropertyIndexed)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, const GDExtensionPropertyInfo *p_info, GDExtensionConstStringNamePtr p_setter, GDExtensionConstStringNamePtr p_getter, GDExtensionInt p_index); + +/** + * @name classdb_register_extension_class_property_group + * @since 4.1 + * + * Registers a property group on an extension class in the ClassDB. + * + * @param p_library A pointer the library received by the GDExtension's entry point function. + * @param p_class_name A pointer to a StringName with the class name. + * @param p_group_name A pointer to a String with the group name. + * @param p_prefix A pointer to a String with the prefix used by properties in this group. + */ +typedef void (*GDExtensionInterfaceClassdbRegisterExtensionClassPropertyGroup)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, GDExtensionConstStringPtr p_group_name, GDExtensionConstStringPtr p_prefix); + +/** + * @name classdb_register_extension_class_property_subgroup + * @since 4.1 + * + * Registers a property subgroup on an extension class in the ClassDB. + * + * @param p_library A pointer the library received by the GDExtension's entry point function. + * @param p_class_name A pointer to a StringName with the class name. + * @param p_subgroup_name A pointer to a String with the subgroup name. + * @param p_prefix A pointer to a String with the prefix used by properties in this subgroup. + */ +typedef void (*GDExtensionInterfaceClassdbRegisterExtensionClassPropertySubgroup)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, GDExtensionConstStringPtr p_subgroup_name, GDExtensionConstStringPtr p_prefix); + +/** + * @name classdb_register_extension_class_signal + * @since 4.1 + * + * Registers a signal on an extension class in the ClassDB. + * + * Provided structs can be safely freed once the function returns. + * + * @param p_library A pointer the library received by the GDExtension's entry point function. + * @param p_class_name A pointer to a StringName with the class name. + * @param p_signal_name A pointer to a StringName with the signal name. + * @param p_argument_info A pointer to a GDExtensionPropertyInfo struct. + * @param p_argument_count The number of arguments the signal receives. + */ +typedef void (*GDExtensionInterfaceClassdbRegisterExtensionClassSignal)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, GDExtensionConstStringNamePtr p_signal_name, const GDExtensionPropertyInfo *p_argument_info, GDExtensionInt p_argument_count); + +/** + * @name classdb_unregister_extension_class + * @since 4.1 + * + * Unregisters an extension class in the ClassDB. + * + * @param p_library A pointer the library received by the GDExtension's entry point function. + * @param p_class_name A pointer to a StringName with the class name. + */ +typedef void (*GDExtensionInterfaceClassdbUnregisterExtensionClass)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name); /* Unregistering a parent class before a class that inherits it will result in failure. Inheritors must be unregistered first. */ + +/** + * @name get_library_path + * @since 4.1 + * + * Gets the path to the current GDExtension library. + * + * @param p_library A pointer the library received by the GDExtension's entry point function. + * @param r_path A pointer to a String which will receive the path. + */ +typedef void (*GDExtensionInterfaceGetLibraryPath)(GDExtensionClassLibraryPtr p_library, GDExtensionUninitializedStringPtr r_path); + +/** + * @name editor_add_plugin + * @since 4.1 + * + * Adds an editor plugin. + * + * It's safe to call during initialization. + * + * @param p_class_name A pointer to a StringName with the name of a class (descending from EditorPlugin) which is already registered with ClassDB. + */ +typedef void (*GDExtensionInterfaceEditorAddPlugin)(GDExtensionConstStringNamePtr p_class_name); + +/** + * @name editor_remove_plugin + * @since 4.1 + * + * Removes an editor plugin. + * + * @param p_class_name A pointer to a StringName with the name of a class that was previously added as an editor plugin. + */ +typedef void (*GDExtensionInterfaceEditorRemovePlugin)(GDExtensionConstStringNamePtr p_class_name); + +#ifdef __cplusplus +} +#endif + +#endif // GDEXTENSION_INTERFACE_H diff --git a/src/init/c/util/Q8defs.h b/src/init/c/util/Q8defs.h deleted file mode 100644 index 47b5b6b..0000000 --- a/src/init/c/util/Q8defs.h +++ /dev/null @@ -1,629 +0,0 @@ -/* - Q8defs.h -- defines platform-specific parameters for standard headers - - This source code has been placed into the PUBLIC DOMAIN by its author. - - last edit: 1999/11/05 gwyn@arl.mil - - Several of the standard headers provided by Doug Gwyn make use - of these __Q8_* symbols. If you want to define other names of - the form __Q8_*, please coordinate them with gwyn@arl.mil, who - claims "dibs" on (first-come ownership of) that name space. - - Aside: Why "Q8"? That was used as a system external symbol - prefix in old CDC Fortran implementations, to avoid link-time - name-space collisions with user-defined symbols, on the - assumption that no user would ever think of using such a name. -*/ - -/* This header doesn't need an idempotency lock; there are no typedefs here. */ - -/* This header doesn't need C++ extern "C"; there are no declarations here. */ - -#define __Q8_TEST /* [undef to disable configuration checks] */ - -#define _SYS_INT_TYPES_H /* kludge to override Solaris header */ -#define _SYS_INT_LIMITS_H /* ditto */ - -/* - The following macros come in handy in many situations. -*/ - -/* splice arguments into one token */ -#ifdef __STDC__ -#define __Q8_1J(a,b) a ## b -#define __Q8_2J(a,b) __Q8_1J(a,b) -#else -#define __Q8_1J(a) a -#define __Q8_2J(a,b) __Q8_1J(a)b -#endif - -/* older versions of C didn't have certain type qualifiers */ -#ifdef __STDC__ -#define __Q8_CONST const -#else -#define __Q8_CONST -#endif - -#if __STDC_VERSION__ >= 199901 -#define __Q8_RESTRICT restrict -#else -#define __Q8_RESTRICT /* nothing */ -#endif - -/* older versions of C don't support function prototypes */ -#ifdef __STDC__ -#define __Q8_PARAMS(a) a -#else -#define __Q8_PARAMS(a) () -#endif -/* usage: return_type func_name __Q8_PARAMS((param_decls)); */ - -/* - The following is based on the MUVES "Va" (variable argument) package. - - created: 94/08/16 D A Gwyn - - The Va package provides portable support for functions taking - a variable number of arguments. It defines several macros - that work together to hide the differences between the old - UNIX facility and the new Standard C . - - Rather than describing each Va package macro separately, it is - best to give an example of the proper usage of the whole set of - macros. It should be easy to adapt this generic example to any - specific requirement. - - The example is for a function named Advise that has two - required arguments, the first being a printf-like format string - and the second a flag that indicates (when true) that an extra - "verbosity level" is provided as the third argument. Remaining - arguments are those, if any, associated with the format string. - The Advise function prints the formatted result on the standard - error output if and only if the verbosity level is given and is - greater than 0. It returns true unless it had trouble printing - on the standard error output stream. - - Any code that wants to invoke the Advise function must include - a proper declaration for it: - - #include // includes Va package - extern bool Advise( __Q8_T(const char *) __Q8_T(bool) __Q8_Dots ); - // alternatively: - // extern bool Advise __Q8_PARAMS(( const char *, bool, ... )); - - The implementation of the Advise function might be: - - #include - #include - #ifdef __STDC__ - #include - #else - #include - #endif - #include - - // VARARGS // not VARARGS2 - bool - Advise( __Q8_T( const char *format ) __Q8_T( bool verbose ) __Q8_AList ) - __Q8_Dcl - { - __Q8_D( const char * format ) - __Q8_D( bool verbose ) - __Q8_List( ap ) - register int verbosity; - register bool status; - - __Q8_Start( ap, verbose ) - __Q8_I( ap, char *, format ) // no "const" here - __Q8_I( ap, bool, verbose ) - - if ( verbose ) - verbosity = __Q8_Arg( ap, int ); - else - verbosity = 0; - - if ( verbosity > 0 ) - status = vfprintf( stderr, format, ap ) > 0; - else - status = true; - - __Q8_End( ap ) - return status; - } - - Note that several of these macros are reminiscent of the va_* - macros in or , but there are significant - differences. Proper usage of the "function-like" macros, in - particular, does not require semicolons; this is intentional, - in order to avoid warnings about "null statements" from certain - compilers and "lint". The easiest way to ensure correct usage - is to copy the above example and then make changes to the copy - as needed for the specific application. -*/ - -#ifdef __STDC__ - -#define __Q8_T(t) t, -#define __Q8_Dots ... -#define __Q8_AList ... -#define __Q8_D(d) /* nothing */ -#define __Q8_Dcl /* nothing */ -#define __Q8_List(ap) va_list ap; -#define __Q8_Start(ap, A0) va_start(ap, A0); -#define __Q8_I(ap, T, Ai) /* nothing */ -#define __Q8_Arg(ap, T) va_arg(ap, T) -#define __Q8_End(ap) va_end(ap); - -#else /* "classic" version of UNIX assumed */ - -#define __Q8_T(t) /* nothing */ -#define __Q8_Dots /* nothing */ -#define __Q8_AList va_alist -#define __Q8_D(d) d; -#define __Q8_Dcl va_dcl -#define __Q8_List(ap) va_list ap; -#define __Q8_Start(ap, A0) va_start(ap); -#define __Q8_I(ap, T, Ai) Ai = va_arg(ap, T); -#define __Q8_Arg(ap, T) va_arg(ap, T) -#define __Q8_End(ap) va_end(ap); - -#endif - -/* - The following are used to define macros in multiple headers. -*/ - -/* NOTE: The following must be spelled *exactly* like EOF in . */ -#define __Q8_EOF (-1) -/* XXX -- not currently used in the headers I provide. */ - -/* NOTE: The following must be spelled *exactly* like NULL in etc. */ -#if defined(_LP64) && !defined(__cplusplus) /* Why? */ -#define __Q8_NULL 0L -#else -#define __Q8_NULL 0 -#endif - -#define __Q8_WEOF ((wint_t)-1) - -/* - The following are used to typedef types in multiple headers. -*/ - -#define __Q8_MBSTATE_T int /* dummy; usually a struct */ -#define __Q8_WINT_T int /* this type works nearly everywhere */ -#define __Q8_FILE FILE /* must match */ - /* XXX -- At present, __Q8_FILE requires #including . */ -/* XXX -- the following are not currently used in the headers I provide. */ -#define __Q8_SIZE_T unsigned long /* this type works nearly everywhere */ -#define __Q8_WCHAR_T char /* for minimal implementations */ -/* XXX -- this is incomplete; these should be coupled with the following - parameter definitions, and their limits should be computed and defined. */ - -/* - The following defines parameters for supported types; - they are used mainly by . - - C:char S:short I:int L:long P:void* Q:long long M:max-width int. - D:ptrdiff_t A:sig_atomic_t Z:size_t W:wchar_t X:wint_t - G:long double - followed by W:width T:type U:is unsigned S:suffix for constant - F:printf/scanf length modifier - - TC:twos-complement OC:ones-complement SM:signed-magnitude - SC:"signed char" or "char" if signed - - These values depend strongly on the architecture and compiler; - the only combinations included here are the ones I use myself. - Please add your particular combination and e-mail me the edits. - - XXX -- system parameters really ought to be in a separate header. -*/ - -#if defined(__i386) /* Intel x86, 32-bit, Sun Solaris */ - -#define __Q8_TC -#define __Q8_SC /* signed */ char -#define __Q8_CW 8 -#define __Q8_SW 16 -#define __Q8_IW 32 -#define __Q8_LW 32 -#define __Q8_PW 32 -#define __Q8_DW 32 -#define __Q8_AW 32 -#undef __Q8_AU -#define __Q8_ZW 32 -#define __Q8_WW 32 -#undef __Q8_WU -#define __Q8_XW 32 -#undef __Q8_XU -#if __STDC_VERSION__ >= 199901 -#define __Q8_CF "hh" -#else -#undef __Q8_CF /* no known length modifier for character type */ -#endif -#define __Q8_QW 64 -#define __Q8_QT long long -#define __Q8_QS LL -#define __Q8_QF "ll" -#define __Q8_MW __Q8_QW -#define __Q8_MT __Q8_QT -#define __Q8_MS __Q8_QS -#define __Q8_MF __Q8_QF -#define __Q8_GT long double - -#elif defined(_M_IX86) /* Intel x86, 32-bit, Microsoft */ - -#define __Q8_TC -#define __Q8_SC signed char -#define __Q8_CW 8 -#define __Q8_SW 16 -#define __Q8_IW 32 -#define __Q8_LW 32 -#define __Q8_PW 32 -#define __Q8_DW 32 -#define __Q8_AW 32 -#undef __Q8_AU -#define __Q8_ZW 32 -#define __Q8_WW 32 -#undef __Q8_WU -#define __Q8_XW 32 -#undef __Q8_XU -#if __STDC_VERSION__ >= 199901 -#define __Q8_CF "hh" -#define __Q8_QW 64 -#define __Q8_QT long long -#define __Q8_QS LL -#define __Q8_QF "ll" -#else -#undef __Q8_CF /* no known length modifier for character type */ -#define __Q8_QW 64 -#define __Q8_QT __int64 -#define __Q8_QS i64 -#define __Q8_QF "I64" -#endif -#define __Q8_MW __Q8_QW -#define __Q8_MT __Q8_QT -#define __Q8_MS __Q8_QS -#define __Q8_MF __Q8_QF -#define __Q8_GT long double - -#elif defined(__sparc) /* SPARC, Sun Solaris */ - -#define __Q8_TC -#define __Q8_SC /* signed */ char -#define __Q8_CW 8 -#define __Q8_SW 16 -#define __Q8_IW 32 -#define __Q8_AW 32 -#undef __Q8_AU -#ifdef __sparcv9 /* 64-bit environment */ -#define __Q8_LW 64 -#else /* 32-bit environment */ -#define __Q8_LW 32 -#endif -#define __Q8_PW __Q8_LW -#define __Q8_DW __Q8_LW -#define __Q8_ZW __Q8_LW -#define __Q8_WW __Q8_LW -#undef __Q8_WU -#define __Q8_XW __Q8_LW -#undef __Q8_XU -#if __STDC_VERSION__ >= 199901 -#define __Q8_CF "hh" -#else -#undef __Q8_CF /* no known length modifier for character type */ -#endif -#define __Q8_QW 64 -#define __Q8_QT long long -#define __Q8_QS LL -#define __Q8_QF "ll" -#define __Q8_MW __Q8_QW -#define __Q8_MT __Q8_QT -#define __Q8_MS __Q8_QS -#define __Q8_MF __Q8_QF -#define __Q8_GT long double - -#elif defined(_TMS320C6000) /* TI TMS320C6xxx DSP, Code Composer */ - -#define __Q8_TC -#define __Q8_SC signed char -#define __Q8_CW 8 -#define __Q8_SW 16 -#define __Q8_IW 32 -#define __Q8_AW 32 -#undef __Q8_AU -#define __Q8_LW 40 -#define __Q8_PW 32 -#define __Q8_DW 32 -#define __Q8_ZW 32 -#define __Q8_WW 8 -#define __Q8_WU /* XXX -- check */ -#define __Q8_XW 32 -#undef __Q8_XU -#if __STDC_VERSION__ >= 199901 -#define __Q8_CF "hh" -#define __Q8_QW 64 -#define __Q8_QT long long -#define __Q8_QS LL -#define __Q8_QF "ll" -#define __Q8_MW __Q8_QW -#define __Q8_MT __Q8_QT -#define __Q8_MS __Q8_QS -#define __Q8_MF __Q8_QF -#else -#undef __Q8_CF /* no known length modifier for character type */ -#define __Q8_MW __Q8_LW -#define __Q8_MT long -#define __Q8_MS L -#define __Q8_MF "l" -#endif -#define __Q8_GT long double - -#elif defined(__vax) /* DEC VAX-11 */ - -#define __Q8_TC -#define __Q8_SC /* signed */ char -#define __Q8_CW 8 -#define __Q8_SW 16 -#define __Q8_IW 32 -#define __Q8_LW 32 -#define __Q8_PW 32 -#define __Q8_DW 32 -#define __Q8_AW 32 -#undef __Q8_AU -#define __Q8_ZW 32 -#define __Q8_WW 32 -#undef __Q8_WU -#define __Q8_XW 32 -#undef __Q8_XU -#if __STDC_VERSION__ >= 199901 -#define __Q8_CF "hh" -#define __Q8_QW 64 -#define __Q8_QT long long -#define __Q8_QS LL -#define __Q8_QF "ll" -#define __Q8_MW __Q8_QW -#define __Q8_MT __Q8_QT -#define __Q8_MS __Q8_QS -#define __Q8_MF __Q8_QF -#define __Q8_GT long double -#else -#undef __Q8_CF /* no known length modifier for character type */ -#define __Q8_MW 32 -#define __Q8_MT long -#define __Q8_MS L -#undef __Q8_GT /* long double not supported */ -#endif - -#elif defined(__pdp11) /* DEC PDP-11 */ - -#define __Q8_TC -#define __Q8_SC /* signed */ char -#define __Q8_CW 8 -#define __Q8_SW 16 -#define __Q8_IW 16 -#define __Q8_LW 32 -#define __Q8_PW 16 /* (violates section 5.2.4.1) */ -#define __Q8_DW 16 /* (violates section 5.2.4.1) */ -#define __Q8_AW 16 -#undef __Q8_AU -#define __Q8_ZW 16 -#define __Q8_WW 32 -#undef __Q8_WU -#define __Q8_XW 32 -#undef __Q8_XU -#if __STDC_VERSION__ >= 199901 -#define __Q8_CF "hh" -#define __Q8_QW 64 -#define __Q8_QT long long -#define __Q8_QS LL -#define __Q8_QF "ll" -#define __Q8_MW __Q8_QW -#define __Q8_MT __Q8_QT -#define __Q8_MS __Q8_QS -#define __Q8_MF __Q8_QF -#define __Q8_GT long double -#else -#undef __Q8_CF /* no known length modifier for character type */ -#define __Q8_MW 32 -#define __Q8_MT long -#define __Q8_MS L -#define __Q8_MF "l" -#undef __Q8_GT /* long double not supported */ -#endif - -#elif defined(__ORCAC__) /* Apple IIGS, large memory model */ - -/* #pragma optimize -1 /* enables all compiler optimizations */ - -#define __Q8_TC -#define __Q8_SC signed char -#define __Q8_CW 8 -#define __Q8_SW 16 -#define __Q8_IW 16 -#define __Q8_LW 32 -#define __Q8_PW 32 -#define __Q8_DW 32 -#define __Q8_AW 16 -#undef __Q8_AU -#define __Q8_ZW 32 /* XXX -- check */ -#define __Q8_WW 32 -#undef __Q8_WU -#if __STDC_VERSION__ >= 199901 -#define __Q8_CF "hh" -#define __Q8_QW 64 -#define __Q8_QT long long -#define __Q8_QS LL -#define __Q8_QF "ll" -#define __Q8_MW __Q8_QW -#define __Q8_MT __Q8_QT -#define __Q8_MS __Q8_QS -#define __Q8_MF __Q8_QF -#else -#undef __Q8_CF /* no known length modifier for character type */ -#define __Q8_MW 32 -#define __Q8_MT long -#define __Q8_MS L -#define __Q8_MF "l" -#endif -#define __Q8_GT long double - -#else - -#error "Q8defs.h: unknown CPU type" - -#endif - -#if defined(__Q8_TEST) - -/* sanity checks */ - -#if defined(__Q8_TC)+defined(__Q8_OC)+defined(__Q8_SM) != 1 -#error "Q8defs.h: representation improperly defined" -#endif - -#if __Q8_CW < 8 -#error "Q8defs.h: __Q8_CW improperly defined" -#endif - -#if __Q8_SW < __Q8_CW || __Q8_SW < 16 -#error "Q8defs.h: __Q8_SW improperly defined" -#endif - -#if __Q8_IW < __Q8_SW -#error "Q8defs.h: __Q8_IW improperly defined" -#endif - -#if __Q8_LW < __Q8_IW || __Q8_LW < 32 -#error "Q8defs.h: __Q8_LW improperly defined" -#endif - -#ifdef __Q8_PW -#if __Q8_PW < 16 || __Q8_PW < __Q8_CW || \ - __STDC_VERSION__ >= 199901 && __Q8_PW < 17 -#error "Q8defs.h: __Q8_PW improperly defined" -#endif -#endif - -#ifdef __Q8_DW -#if __Q8_DW < 16 || __Q8_DW < __Q8_CW || \ - __STDC_VERSION__ >= 199901 && __Q8_DW < 17 -#error "Q8defs.h: __Q8_DW improperly defined" -#endif -#endif - -#if __Q8_AW < __Q8_CW -#error "Q8defs.h: __Q8_AW improperly defined" -#endif - -#if __Q8_ZW < 16 || __Q8_ZW < __Q8_CW -#error "Q8defs.h: __Q8_ZW improperly defined" -#endif - -#if __Q8_WW < __Q8_CW -#error "Q8defs.h: __Q8_WW improperly defined" -#endif - -#if __Q8_XW < 16 || __Q8_XW < __Q8_CW -#error "Q8defs.h: __Q8_XW improperly defined" -#endif - -#ifdef __Q8_QT -#if __Q8_QW < __Q8_LW || __Q8_QW < 64 -#error "Q8defs.h: __Q8_QW improperly defined" -#endif -#elif __STDC_VERSION__ >= 199901 -#error "Q8defs.h: __Q8_QT not defined" -#endif - -#if __Q8_MW < __Q8_LW || defined(__Q8_QT) && __Q8_MW < __Q8_QW -#error "Q8defs.h: __Q8_MW improperly defined" -#endif - -#ifndef __Q8_MT -#error "Q8defs.h: __Q8_MT not defined" -#endif - -#endif /* defined(__Q8_TEST) */ - -/* limits for various types */ - -/* top signed values */ -#define __Q8_TI(w) (~(~0<<(w)-1)) -#define __Q8_TL (~(~0L<<__Q8_LW-1)) -#define __Q8_TQ (~(~__Q8_2J(0,__Q8_QS)<<__Q8_QW-1)) -#define __Q8_TM (~(~__Q8_2J(0,__Q8_MS)<<__Q8_MW-1)) - -/* upper unsigned values */ -#define __Q8_UI(w) (~0U>>__Q8_IW-(w)) -#define __Q8_UL (~0UL) -#define __Q8_UQ (~__Q8_2J(0U,__Q8_QS)) -#define __Q8_UM (~__Q8_2J(0U,__Q8_MS)) - -/* bottom signed values */ -#if defined(__Q8_TC) -#define __Q8_BI(w) (-__Q8_TI(w)-1) -#define __Q8_BL (-__Q8_TL-1) -#define __Q8_BQ (-__Q8_TQ-1) -#define __Q8_BM (-__Q8_TM-1) -#else /* defined(__Q8_OC) || defined(__Q8_SM) */ -#define __Q8_BI(w) (-__Q8_TI(w)) -#define __Q8_BL (-__Q8_TL) -#define __Q8_BQ (-__Q8_TQ) -#define __Q8_BM (-__Q8_TM) -#endif - -#if defined(__Q8_TEST) - -/* sanity checks */ - -#define __Q8_X1 1 -#define __Q8_X2 2u -#if __Q8_2J(__Q8_X1,__Q8_X2) != 12u -#error "Q8defs.h: __Q8_2J macro is broken" -#endif - -#if __Q8_TI(__Q8_CW) <= 0 || __Q8_BI(__Q8_CW) >= 0 || \ - __Q8_TI(__Q8_SW) <= 0 || __Q8_BI(__Q8_SW) >= 0 || \ - __Q8_TI(__Q8_IW) <= 0 || __Q8_BI(__Q8_IW) >= 0 || \ - __Q8_TI(__Q8_CW) <= __Q8_BI(__Q8_CW) || \ - __Q8_TI(__Q8_SW) <= __Q8_BI(__Q8_SW) || \ - __Q8_TI(__Q8_IW) <= __Q8_BI(__Q8_IW) -#error "Q8defs.h: __Q8_TI, __Q8_BI macros are broken" -#endif -#if __Q8_UI(__Q8_CW) <= 0 || __Q8_UI(__Q8_CW) <= __Q8_TI(__Q8_CW) || \ - __Q8_UI(__Q8_SW) <= 0 || __Q8_UI(__Q8_SW) <= __Q8_TI(__Q8_SW) || \ - __Q8_UI(__Q8_IW) <= 0 || __Q8_UI(__Q8_IW) <= __Q8_TI(__Q8_IW) -#error "Q8defs.h: __Q8_UI or __Q8_TI macro is broken" -#endif - -#if __Q8_TL <= 0 || __Q8_BL >= 0 || __Q8_TL <= __Q8_BL -#error "Q8defs.h: __Q8_TL, __Q8_BL macros are broken" -#endif -#if __Q8_UL <= 0 || __Q8_UL <= __Q8_TL -#error "Q8defs.h: __Q8_UL or __Q8_TL macro is broken" -#endif - -#ifdef __Q8_QT -#if __Q8_TQ <= 0 || __Q8_BQ >= 0 || __Q8_TQ <= __Q8_BQ -#error "Q8defs.h: __Q8_TQ, __Q8_BQ macros are broken" -#endif -#if __Q8_UQ <= 0 || __Q8_UQ <= __Q8_TQ -#if 0 /* XXX -- not working on Solaris */ -#error "Q8defs.h: __Q8_UQ or __Q8_TQ macro is broken" -#endif -#endif -#endif - -#if __Q8_TM <= 0 || __Q8_BM >= 0 || __Q8_TM <= __Q8_BM -#error "Q8defs.h: __Q8_TM, __Q8_BM macros are broken" -#endif -#if __Q8_UM <= 0 || __Q8_UM <= __Q8_TM -#if 0 /* XXX -- not working on Solaris */ -#error "Q8defs.h: __Q8_UM or __Q8_TM macro is broken" -#endif -#endif - -#endif /* defined(__Q8_TEST) */ diff --git a/src/init/c/util/inttypes.c b/src/init/c/util/inttypes.c deleted file mode 100644 index 32401ed..0000000 --- a/src/init/c/util/inttypes.c +++ /dev/null @@ -1,389 +0,0 @@ -/* - inttypes -- format conversion of integer types - (standard library functions declared by ) - - This source code has been placed into the PUBLIC DOMAIN by its author. - - last edit: 1999/11/05 gwyn@arl.mil - - Implements subclause 7.8.2 of ISO/IEC 9899:1999 (E). - - This particular implementation requires the matching . - It also assumes that character codes for A..Z and a..z are in - contiguous ascending order; this is true for ASCII but not EBCDIC. -*/ - -#include -#include -#include - -#include -#include /* defines various __Q8_* symbols */ -#include -#include - -/* helper macros: */ - -/* convert digit character to number, in any base */ -#define ToNumber(c) (isdigit(c) ? (c) - '0' : \ - isupper(c) ? (c) - 'A' + 10 : \ - islower(c) ? (c) - 'a' + 10 : \ - -1 /* "invalid" flag */ \ - ) -#define ToWNumber(c) (iswdigit(c) ? (c) - L'0' : \ - iswupper(c) ? (c) - L'A' + 10 : \ - iswlower(c) ? (c) - L'a' + 10 : \ - -1 /* "invalid" flag */ \ - ) - -/* validate converted digit character for specific base */ -#define valid(n, b) ((n) >= 0 && (n) < (b)) - -/* - 7.8.2 Functions for greatest-width integer types -*/ - -intmax_t -imaxabs(j) - intmax_t j; - { - return j >= 0 ? j : -j; - } - -imaxdiv_t -imaxdiv(numer, denom) - intmax_t numer, denom; - { - imaxdiv_t result; - - result.quot = numer / denom; - result.rem = numer % denom; - return result; - } - -intmax_t -strtoimax(nptr, endptr, base) - register __Q8_CONST char *__Q8_RESTRICT nptr; - char **__Q8_RESTRICT endptr; - register int base; - { - register uintmax_t accum; /* accumulates converted value */ - register int n; /* numeral from digit character */ - bool minus; /* set iff minus sign seen */ - bool toobig; /* set iff value overflows */ - - if ( endptr != NULL ) - *endptr = (char *)nptr; /* in case no conversion's performed */ - - if ( base < 0 || base == 1 || base > 36 ) - { - errno = EDOM; - return 0; /* unspecified behavior */ - } - - /* skip initial, possibly empty sequence of white-space characters */ - - while ( isspace(*nptr) ) - ++nptr; - - /* process subject sequence: */ - - /* optional sign */ - if ( (minus = *nptr == '-') || *nptr == '+' ) - ++nptr; - - if ( base == 0 ) - if ( *nptr == '0' ) - if ( nptr[1] == 'X' || nptr[1] == 'x' ) - base = 16; - else - base = 8; - else - base = 10; - - /* optional "0x" or "0X" for base 16 */ - - if ( base == 16 && *nptr == '0' && (nptr[1] == 'X' || nptr[1] == 'x') ) - nptr += 2; /* skip past this prefix */ - - /* check whether there is at least one valid digit */ - - n = ToNumber(*nptr); - ++nptr; - - if ( !valid(n, base) ) - return 0; /* subject seq. not of expected form */ - - accum = n; - - for ( toobig = false; n = ToNumber(*nptr), valid(n, base); ++nptr ) - if ( accum > INTMAX_MAX / base + 2 ) /* major wrap-around */ - toobig = true; /* but keep scanning */ - else - accum = base * accum + n; - - if ( endptr != NULL ) - *endptr = (char *)nptr; /* points to first not-valid-digit */ - -#ifdef __Q8_TC /* twos-complement representation */ - if ( minus ) - { - if ( accum > (uintmax_t)INTMAX_MAX + 1 ) - toobig = true; - } - else -#endif - if ( accum > (uintmax_t)INTMAX_MAX ) - toobig = true; - - if ( toobig ) - { - errno = ERANGE; - return minus ? INTMAX_MIN : INTMAX_MAX; - } - else - return (intmax_t)(minus ? -accum : accum); - } - -uintmax_t -strtoumax(nptr, endptr, base) - register __Q8_CONST char *__Q8_RESTRICT nptr; - char **__Q8_RESTRICT endptr; - register int base; - { - register uintmax_t accum; /* accumulates converted value */ - register uintmax_t next; /* for computing next value of accum */ - register int n; /* numeral from digit character */ - bool minus; /* set iff minus sign seen (yes!) */ - bool toobig; /* set iff value overflows */ - - if ( endptr != NULL ) - *endptr = (char *)nptr; /* in case no conversion's performed */ - - if ( base < 0 || base == 1 || base > 36 ) - { - errno = EDOM; - return 0; /* unspecified behavior */ - } - - /* skip initial, possibly empty sequence of white-space characters */ - - while ( isspace(*nptr) ) - ++nptr; - - /* process subject sequence: */ - - /* optional sign (yes!) */ - - if ( (minus = *nptr == '-') || *nptr == '+' ) - ++nptr; - - if ( base == 0 ) - if ( *nptr == '0' ) - if ( nptr[1] == 'X' || nptr[1] == 'x' ) - base = 16; - else - base = 8; - else - base = 10; - - /* optional "0x" or "0X" for base 16 */ - - if ( base == 16 && *nptr == '0' && (nptr[1] == 'X' || nptr[1] == 'x') ) - nptr += 2; /* skip past this prefix */ - - /* check whether there is at least one valid digit */ - - n = ToNumber(*nptr); - ++nptr; - - if ( !valid(n, base) ) - return 0; /* subject seq. not of expected form */ - - accum = n; - - for ( toobig = false; n = ToNumber(*nptr), valid(n, base); ++nptr ) - if ( accum > UINTMAX_MAX / base + 1 /* major wrap-around */ - || (next = base * accum + n) < accum /* minor wrap-around */ - ) - toobig = true; /* but keep scanning */ - else - accum = next; - - if ( endptr != NULL ) - *endptr = (char *)nptr; /* points to first not-valid-digit */ - - if ( toobig ) - { - errno = ERANGE; - return UINTMAX_MAX; - } - else - return minus ? -accum : accum; /* (yes!) */ - } - -intmax_t -wcstoimax(nptr, endptr, base) - register __Q8_CONST wchar_t *__Q8_RESTRICT nptr; - wchar_t **__Q8_RESTRICT endptr; - register int base; - { - register uintmax_t accum; /* accumulates converted value */ - register int n; /* numeral from digit character */ - bool minus; /* set iff minus sign seen */ - bool toobig; /* set iff value overflows */ - - if ( endptr != NULL ) - *endptr = (wchar_t *)nptr; /* in case no conv performed */ - - if ( base < 0 || base == 1 || base > 36 ) - { - errno = EDOM; - return 0; /* unspecified behavior */ - } - - /* skip initial, possibly empty sequence of white-space w.characters */ - - while ( iswspace(*nptr) ) - ++nptr; - - /* process subject sequence: */ - - /* optional sign */ - - if ( (minus = *nptr == L'-') || *nptr == L'+' ) - ++nptr; - - if ( base == 0 ) - if ( *nptr == L'0' ) - if ( nptr[1] == L'X' || nptr[1] == L'x' ) - base = 16; - else - base = 8; - else - base = 10; - - /* optional "0x" or "0X" for base 16 */ - - if ( base == 16 && *nptr == L'0' - && (nptr[1] == L'X' || nptr[1] == L'x') - ) - nptr += 2; /* skip past this prefix */ - - /* check whether there is at least one valid digit */ - - n = ToWNumber(*nptr); - ++nptr; - - if ( !valid(n, base) ) - return 0; /* subject seq. not of expected form */ - - accum = n; - - for ( toobig = false; n = ToWNumber(*nptr), valid(n, base); ++nptr ) - if ( accum > INTMAX_MAX / base + 2 ) /* major wrap-around */ - toobig = true; /* but keep scanning */ - else - accum = base * accum + n; - - if ( endptr != NULL ) - *endptr = (wchar_t *)nptr; /* -> first not-valid-digit */ - -#ifdef __Q8_TC /* twos-complement representation */ - if ( minus ) - { - if ( accum > (uintmax_t)INTMAX_MAX + 1 ) - toobig = true; - } - else -#endif - if ( accum > (uintmax_t)INTMAX_MAX ) - toobig = true; - - if ( toobig ) - { - errno = ERANGE; - return minus ? INTMAX_MIN : INTMAX_MAX; - } - else - return (intmax_t)(minus ? -accum : accum); - } - -uintmax_t -wcstoumax(nptr, endptr, base) - register __Q8_CONST wchar_t *__Q8_RESTRICT nptr; - wchar_t **__Q8_RESTRICT endptr; - register int base; - { - register uintmax_t accum; /* accumulates converted value */ - register uintmax_t next; /* for computing next value of accum */ - register int n; /* numeral from digit character */ - bool minus; /* set iff minus sign seen (yes!) */ - bool toobig; /* set iff value overflows */ - - if ( endptr != NULL ) - *endptr = (wchar_t *)nptr; /* in case no conv performed */ - - if ( base < 0 || base == 1 || base > 36 ) - { - errno = EDOM; - return 0; /* unspecified behavior */ - } - - /* skip initial, possibly empty sequence of white-space w.characters */ - - while ( iswspace(*nptr) ) - ++nptr; - - /* process subject sequence: */ - - /* optional sign */ - - if ( (minus = *nptr == L'-') || *nptr == L'+' ) - ++nptr; - - if ( base == 0 ) - if ( *nptr == L'0' ) - if ( nptr[1] == L'X' || nptr[1] == L'x' ) - base = 16; - else - base = 8; - else - base = 10; - - /* optional "0x" or "0X" for base 16 */ - - if ( base == 16 && *nptr == L'0' - && (nptr[1] == L'X' || nptr[1] == L'x') - ) - nptr += 2; /* skip past this prefix */ - - /* check whether there is at least one valid digit */ - - n = ToWNumber(*nptr); - ++nptr; - - if ( !valid(n, base) ) - return 0; /* subject seq. not of expected form */ - - accum = n; - - for ( toobig = false; n = ToWNumber(*nptr), valid(n, base); ++nptr ) - if ( accum > UINTMAX_MAX / base + 1 /* major wrap-around */ - || (next = base * accum + n) < accum /* minor wrap-around */ - ) - toobig = true; /* but keep scanning */ - else - accum = next; - - if ( endptr != NULL ) - *endptr = (wchar_t *)nptr; /* -> first not-valid-digit */ - - if ( toobig ) - { - errno = ERANGE; - return UINTMAX_MAX; - } - else - return minus ? -accum : accum; /* (yes!) */ - } diff --git a/src/init/c/util/inttypes.h b/src/init/c/util/inttypes.h deleted file mode 100644 index 2a9f4e1..0000000 --- a/src/init/c/util/inttypes.h +++ /dev/null @@ -1,757 +0,0 @@ -/* - inttypes.h -- format conversion of integer types - - This source code has been placed into the PUBLIC DOMAIN by its author. - - last edit: 1999/11/05 gwyn@arl.mil - - Implements subclause 7.8 of ISO/IEC 9899:1999 (E). - - This particular implementation requires the matching - and inttypes.c. - - This implementation is SELF-CONFIGURING, based on parameters defined - in . If you plan to include it in a C implementation, - it would be best to trim it down, with all the parameterized actions - already performed. -*/ - -#if !defined(_INTTYPES_H) && !defined(_INC_INTTYPES) /* usual */ -#define _INTTYPES_H /* idempotency lock (section 7.1.2) */ -#define _INC_INTTYPES - -#include /* defines various __Q8_* symbols */ - -#ifdef __cplusplus -extern "C" { -#endif - -/* - type defined by this header (only) -*/ - -typedef struct - { - intmax_t quot; /* member order must match function */ - intmax_t rem; - } imaxdiv_t; - -#if !defined(__cplusplus) || defined(__STDC_FORMAT_MACROS) - -/* figure out the type of wchar_t */ -#ifdef __Q8_WU - -#if __Q8_CW >= __Q8_WW -#define __Q8_WT unsigned char -#elif __Q8_SW >= __Q8_WW -#define __Q8_WT unsigned short -#elif __Q8_IW >= __Q8_WW -#define __Q8_WT unsigned int -#elif __Q8_LW >= __Q8_WW -#define __Q8_WT unsigned long -#elif __Q8_QW >= __Q8_WW -#define __Q8_WT unsigned __Q8_QT -#else -#define __Q8_WT unsigned __Q8_MT -#endif - -#define WCHAR_MIN 0 - -#else /* !defined(__Q8_WU) */ - -#if __Q8_CW >= __Q8_WW && defined(__Q8_SC) -#define __Q8_WT __Q8_SC -#elif __Q8_SW >= __Q8_WW -#define __Q8_WT short -#elif __Q8_IW >= __Q8_WW -#define __Q8_WT int -#elif __Q8_LW >= __Q8_WW -#define __Q8_WT long -#elif __Q8_QW >= __Q8_WW -#define __Q8_WT __Q8_QT -#else -#define __Q8_WT __Q8_MT -#endif - -#endif /* defined(__Q8_WU) */ - -/* - 7.8.1 Macros for format specifiers - - The optional 40-bit type is supported by the TMS320C6xxx DSP. - - Note that there was no length modifier for char type prior to C99. -*/ - -#if __Q8_CW == 8 && defined(__Q8_SC) -#define PRId8 "d" -#define PRIi8 "i" -#define PRIo8 "o" -#define PRIu8 "u" -#define PRIx8 "x" -#define PRIX8 "X" -#ifdef __Q8_CF -#define SCNd8 __Q8_CF"d" -#define SCNi8 __Q8_CF"i" -#define SCNo8 __Q8_CF"o" -#define SCNu8 __Q8_CF"u" -#define SCNx8 __Q8_CF"x" -#endif -#endif -#if __Q8_CW == 16 && defined(__Q8_SC) -#define PRId16 "d" -#define PRIi16 "i" -#define PRIo16 "o" -#define PRIu16 "u" -#define PRIx16 "x" -#define PRIX16 "X" -#ifdef __Q8_CF -#define SCNd16 __Q8_CF"d" -#define SCNi16 __Q8_CF"i" -#define SCNo16 __Q8_CF"o" -#define SCNu16 __Q8_CF"u" -#define SCNx16 __Q8_CF"x" -#endif -#elif __Q8_SW == 16 -#define PRId16 "d" -#define PRIi16 "i" -#define PRIo16 "o" -#define PRIu16 "u" -#define PRIx16 "x" -#define PRIX16 "X" -#define SCNd16 "hd" -#define SCNi16 "hi" -#define SCNo16 "ho" -#define SCNu16 "hu" -#define SCNx16 "hx" -#endif -#if __Q8_CW == 32 && defined(__Q8_SC) -#define PRId32 "d" -#define PRIi32 "i" -#define PRIo32 "o" -#define PRIu32 "u" -#define PRIx32 "x" -#define PRIX32 "X" -#ifdef __Q8_CF -#define SCNd32 __Q8_CF"d" -#define SCNi32 __Q8_CF"i" -#define SCNo32 __Q8_CF"o" -#define SCNu32 __Q8_CF"u" -#define SCNx32 __Q8_CF"x" -#endif -#elif __Q8_SW == 32 -#define PRId32 "d" -#define PRIi32 "i" -#define PRIo32 "o" -#define PRIu32 "u" -#define PRIx32 "x" -#define PRIX32 "X" -#define SCNd32 "hd" -#define SCNi32 "hi" -#define SCNo32 "ho" -#define SCNu32 "hu" -#define SCNx32 "hx" -#elif __Q8_IW == 32 -#define PRId32 "d" -#define PRIi32 "i" -#define PRIo32 "o" -#define PRIu32 "u" -#define PRIx32 "x" -#define PRIX32 "X" -#define SCNd32 "d" -#define SCNi32 "i" -#define SCNo32 "o" -#define SCNu32 "u" -#define SCNx32 "x" -#elif __Q8_LW == 32 -#define PRId32 "ld" -#define PRIi32 "li" -#define PRIo32 "lo" -#define PRIu32 "lu" -#define PRIx32 "lx" -#define PRIX32 "lX" -#define SCNd32 "ld" -#define SCNi32 "li" -#define SCNo32 "lo" -#define SCNu32 "lu" -#define SCNx32 "lx" -#endif -#if __Q8_CW == 40 && defined(__Q8_SC) -#define PRId40 "d" -#define PRIi40 "i" -#define PRIo40 "o" -#define PRIu40 "u" -#define PRIx40 "x" -#define PRIX40 "X" -#ifdef __Q8_CF -#define SCNd40 __Q8_CF"d" -#define SCNi40 __Q8_CF"i" -#define SCNo40 __Q8_CF"o" -#define SCNu40 __Q8_CF"u" -#define SCNx40 __Q8_CF"x" -#endif -#elif __Q8_SW == 40 -#define PRId40 "d" -#define PRIi40 "i" -#define PRIo40 "o" -#define PRIu40 "u" -#define PRIx40 "x" -#define PRIX40 "X" -#define SCNd40 "hd" -#define SCNi40 "hi" -#define SCNo40 "ho" -#define SCNu40 "hu" -#define SCNx40 "hx" -#elif __Q8_IW == 40 -#define PRId40 "d" -#define PRIi40 "i" -#define PRIo40 "o" -#define PRIu40 "u" -#define PRIx40 "x" -#define PRIX40 "X" -#define SCNd40 "d" -#define SCNi40 "i" -#define SCNo40 "o" -#define SCNu40 "u" -#define SCNx40 "x" -#elif __Q8_LW == 40 -#define PRId40 "ld" -#define PRIi40 "li" -#define PRIo40 "lo" -#define PRIu40 "lu" -#define PRIx40 "lx" -#define PRIX40 "lX" -#define SCNd40 "ld" -#define SCNi40 "li" -#define SCNo40 "lo" -#define SCNu40 "lu" -#define SCNx40 "lx" -#endif -#if __Q8_CW == 64 && defined(__Q8_SC) -#define PRId64 "d" -#define PRIi64 "i" -#define PRIo64 "o" -#define PRIu64 "u" -#define PRIx64 "x" -#define PRIX64 "X" -#ifdef __Q8_CF -#define SCNd64 __Q8_CF"d" -#define SCNi64 __Q8_CF"i" -#define SCNo64 __Q8_CF"o" -#define SCNu64 __Q8_CF"u" -#define SCNx64 __Q8_CF"x" -#endif -#elif __Q8_SW == 64 -#define PRId64 "d" -#define PRIi64 "i" -#define PRIo64 "o" -#define PRIu64 "u" -#define PRIx64 "x" -#define PRIX64 "X" -#define SCNd64 "hd" -#define SCNi64 "hi" -#define SCNo64 "ho" -#define SCNu64 "hu" -#define SCNx64 "hx" -#elif __Q8_IW == 64 -#define PRId64 "d" -#define PRIi64 "i" -#define PRIo64 "o" -#define PRIu64 "u" -#define PRIx64 "x" -#define PRIX64 "X" -#define SCNd64 "d" -#define SCNi64 "i" -#define SCNo64 "o" -#define SCNu64 "u" -#define SCNx64 "x" -#elif __Q8_LW == 64 -#define PRId64 "ld" -#define PRIi64 "li" -#define PRIo64 "lo" -#define PRIu64 "lu" -#define PRIx64 "lx" -#define PRIX64 "lX" -#define SCNd64 "ld" -#define SCNi64 "li" -#define SCNo64 "lo" -#define SCNu64 "lu" -#define SCNx64 "lx" -#elif __Q8_QW == 64 -#define PRId64 __Q8_QF"d" -#define PRIi64 __Q8_QF"i" -#define PRIo64 __Q8_QF"o" -#define PRIu64 __Q8_QF"u" -#define PRIx64 __Q8_QF"x" -#define PRIX64 __Q8_QF"X" -#define SCNd64 __Q8_QF"d" -#define SCNi64 __Q8_QF"i" -#define SCNo64 __Q8_QF"o" -#define SCNu64 __Q8_QF"u" -#define SCNx64 __Q8_QF"x" -#endif - -#if __Q8_CW < __Q8_IW && defined(__Q8_SC) -#define PRIdLEAST8 "d" -#define PRIiLEAST8 "i" -#define PRIoLEAST8 "o" -#define PRIuLEAST8 "u" -#define PRIxLEAST8 "x" -#define PRIXLEAST8 "X" -#ifdef __Q8_CF -#define SCNdLEAST8 __Q8_CF"d" -#define SCNiLEAST8 __Q8_CF"i" -#define SCNoLEAST8 __Q8_CF"o" -#define SCNuLEAST8 __Q8_CF"u" -#define SCNxLEAST8 __Q8_CF"x" -#endif -#elif __Q8_SW < __Q8_IW -#define PRIdLEAST8 "d" -#define PRIiLEAST8 "i" -#define PRIoLEAST8 "o" -#define PRIuLEAST8 "u" -#define PRIxLEAST8 "x" -#define PRIXLEAST8 "X" -#define SCNdLEAST8 "hd" -#define SCNiLEAST8 "hi" -#define SCNoLEAST8 "ho" -#define SCNuLEAST8 "hu" -#define SCNxLEAST8 "hx" -#else -#define PRIdLEAST8 "d" -#define PRIiLEAST8 "i" -#define PRIoLEAST8 "o" -#define PRIuLEAST8 "u" -#define PRIxLEAST8 "x" -#define PRIXLEAST8 "X" -#define SCNdLEAST8 "d" -#define SCNiLEAST8 "i" -#define SCNoLEAST8 "o" -#define SCNuLEAST8 "u" -#define SCNxLEAST8 "x" -#endif -#if __Q8_CW < __Q8_IW && __Q8_CW >= 16 && defined(__Q8_SC) -#define PRIdLEAST16 "d" -#define PRIiLEAST16 "i" -#define PRIoLEAST16 "o" -#define PRIuLEAST16 "u" -#define PRIxLEAST16 "x" -#define PRIXLEAST16 "X" -#ifdef __Q8_CF -#define SCNdLEAST16 __Q8_CF"d" -#define SCNiLEAST16 __Q8_CF"i" -#define SCNoLEAST16 __Q8_CF"o" -#define SCNuLEAST16 __Q8_CF"u" -#define SCNxLEAST16 __Q8_CF"x" -#endif -#elif __Q8_SW < __Q8_IW -#define PRIdLEAST16 "d" -#define PRIiLEAST16 "i" -#define PRIoLEAST16 "o" -#define PRIuLEAST16 "u" -#define PRIxLEAST16 "x" -#define PRIXLEAST16 "X" -#define SCNdLEAST16 "hd" -#define SCNiLEAST16 "hi" -#define SCNoLEAST16 "ho" -#define SCNuLEAST16 "hu" -#define SCNxLEAST16 "hx" -#else -#define PRIdLEAST16 "d" -#define PRIiLEAST16 "i" -#define PRIoLEAST16 "o" -#define PRIuLEAST16 "u" -#define PRIxLEAST16 "x" -#define PRIXLEAST16 "X" -#define SCNdLEAST16 "d" -#define SCNiLEAST16 "i" -#define SCNoLEAST16 "o" -#define SCNuLEAST16 "u" -#define SCNxLEAST16 "x" -#endif -#if __Q8_CW < __Q8_IW && __Q8_CW >= 32 && defined(__Q8_SC) -#define PRIdLEAST32 "d" -#define PRIiLEAST32 "i" -#define PRIoLEAST32 "o" -#define PRIuLEAST32 "u" -#define PRIxLEAST32 "x" -#define PRIXLEAST32 "X" -#ifdef __Q8_CF -#define SCNdLEAST32 __Q8_CF"d" -#define SCNiLEAST32 __Q8_CF"i" -#define SCNoLEAST32 __Q8_CF"o" -#define SCNuLEAST32 __Q8_CF"u" -#define SCNxLEAST32 __Q8_CF"x" -#endif -#elif __Q8_SW < __Q8_IW && __Q8_SW >= 32 -#define PRIdLEAST32 "d" -#define PRIiLEAST32 "i" -#define PRIoLEAST32 "o" -#define PRIuLEAST32 "u" -#define PRIxLEAST32 "x" -#define PRIXLEAST32 "X" -#define SCNdLEAST32 "hd" -#define SCNiLEAST32 "hi" -#define SCNoLEAST32 "ho" -#define SCNuLEAST32 "hu" -#define SCNx32 "hx" -#elif __Q8_IW >= 32 -#define PRIdLEAST32 "d" -#define PRIiLEAST32 "i" -#define PRIoLEAST32 "o" -#define PRIuLEAST32 "u" -#define PRIxLEAST32 "x" -#define PRIXLEAST32 "X" -#define SCNdLEAST32 "d" -#define SCNiLEAST32 "i" -#define SCNoLEAST32 "o" -#define SCNuLEAST32 "u" -#define SCNxLEAST32 "x" -#else -#define PRIdLEAST32 "ld" -#define PRIiLEAST32 "li" -#define PRIoLEAST32 "lo" -#define PRIuLEAST32 "lu" -#define PRIxLEAST32 "lx" -#define PRIXLEAST32 "lX" -#define SCNdLEAST32 "ld" -#define SCNiLEAST32 "li" -#define SCNoLEAST32 "lo" -#define SCNuLEAST32 "lu" -#define SCNxLEAST32 "lx" -#endif -#if __Q8_CW < __Q8_IW && __Q8_CW >= 40 && defined(__Q8_SC) -#define PRIdLEAST40 "d" -#define PRIiLEAST40 "i" -#define PRIoLEAST40 "o" -#define PRIuLEAST40 "u" -#define PRIxLEAST40 "x" -#define PRIXLEAST40 "X" -#ifdef __Q8_CF -#define SCNdLEAST40 __Q8_CF"d" -#define SCNiLEAST40 __Q8_CF"i" -#define SCNoLEAST40 __Q8_CF"o" -#define SCNuLEAST40 __Q8_CF"u" -#define SCNxLEAST40 __Q8_CF"x" -#endif -#elif __Q8_SW < __Q8_IW && __Q8_SW >= 40 -#define PRIdLEAST40 "d" -#define PRIiLEAST40 "i" -#define PRIoLEAST40 "o" -#define PRIuLEAST40 "u" -#define PRIxLEAST40 "x" -#define PRIXLEAST40 "X" -#define SCNdLEAST40 "hd" -#define SCNiLEAST40 "hi" -#define SCNoLEAST40 "ho" -#define SCNuLEAST40 "hu" -#define SCNxLEAST40 "hx" -#elif __Q8_IW >= 40 -#define PRIdLEAST40 "d" -#define PRIiLEAST40 "i" -#define PRIoLEAST40 "o" -#define PRIuLEAST40 "u" -#define PRIxLEAST40 "x" -#define PRIXLEAST40 "X" -#define SCNdLEAST40 "d" -#define SCNiLEAST40 "i" -#define SCNoLEAST40 "o" -#define SCNuLEAST40 "u" -#define SCNxLEAST40 "x" -#elif __Q8_LW >= 40 -#define PRIdLEAST40 "ld" -#define PRIiLEAST40 "li" -#define PRIoLEAST40 "lo" -#define PRIuLEAST40 "lu" -#define PRIxLEAST40 "lx" -#define PRIXLEAST40 "lX" -#define SCNdLEAST40 "ld" -#define SCNiLEAST40 "li" -#define SCNoLEAST40 "lo" -#define SCNuLEAST40 "lu" -#define SCNxLEAST40 "lx" -#elif __Q8_QW >= 40 /* (will be 0 if not defined) */ -#define PRIdLEAST40 __Q8_QF"d" -#define PRIiLEAST40 __Q8_QF"i" -#define PRIoLEAST40 __Q8_QF"o" -#define PRIuLEAST40 __Q8_QF"u" -#define PRIxLEAST40 __Q8_QF"x" -#define PRIXLEAST40 __Q8_QF"X" -#define SCNdLEAST40 __Q8_QF"d" -#define SCNiLEAST40 __Q8_QF"i" -#define SCNoLEAST40 __Q8_QF"o" -#define SCNuLEAST40 __Q8_QF"u" -#define SCNxLEAST40 __Q8_QF"x" -#endif -#if __Q8_CW < __Q8_IW && __Q8_CW >= 64 && defined(__Q8_SC) -#define PRIdLEAST64 "d" -#define PRIiLEAST64 "i" -#define PRIoLEAST64 "o" -#define PRIuLEAST64 "u" -#define PRIxLEAST64 "x" -#define PRIXLEAST64 "X" -#ifdef __Q8_CF -#define SCNdLEAST64 __Q8_CF"d" -#define SCNiLEAST64 __Q8_CF"i" -#define SCNoLEAST64 __Q8_CF"o" -#define SCNuLEAST64 __Q8_CF"u" -#define SCNxLEAST64 __Q8_CF"x" -#endif -#elif __Q8_SW < __Q8_IW && __Q8_SW >= 64 -#define PRIdLEAST64 "d" -#define PRIiLEAST64 "i" -#define PRIoLEAST64 "o" -#define PRIuLEAST64 "u" -#define PRIxLEAST64 "x" -#define PRIXLEAST64 "X" -#define SCNdLEAST64 "hd" -#define SCNiLEAST64 "hi" -#define SCNoLEAST64 "ho" -#define SCNuLEAST64 "hu" -#define SCNxLEAST64 "hx" -#elif __Q8_IW >= 64 -#define PRIdLEAST64 "d" -#define PRIiLEAST64 "i" -#define PRIoLEAST64 "o" -#define PRIuLEAST64 "u" -#define PRIxLEAST64 "x" -#define PRIXLEAST64 "X" -#define SCNdLEAST64 "d" -#define SCNiLEAST64 "i" -#define SCNoLEAST64 "o" -#define SCNuLEAST64 "u" -#define SCNxLEAST64 "x" -#elif __Q8_LW >= 64 -#define PRIdLEAST64 "ld" -#define PRIiLEAST64 "li" -#define PRIoLEAST64 "lo" -#define PRIuLEAST64 "lu" -#define PRIxLEAST64 "lx" -#define PRIXLEAST64 "lX" -#define SCNdLEAST64 "ld" -#define SCNiLEAST64 "li" -#define SCNoLEAST64 "lo" -#define SCNuLEAST64 "lu" -#define SCNxLEAST64 "lx" -#elif __Q8_QW >= 64 /* (will be 0 if not defined) */ -#define PRIdLEAST64 __Q8_QF"d" -#define PRIiLEAST64 __Q8_QF"i" -#define PRIoLEAST64 __Q8_QF"o" -#define PRIuLEAST64 __Q8_QF"u" -#define PRIxLEAST64 __Q8_QF"x" -#define PRIXLEAST64 __Q8_QF"X" -#define SCNdLEAST64 __Q8_QF"d" -#define SCNiLEAST64 __Q8_QF"i" -#define SCNoLEAST64 __Q8_QF"o" -#define SCNuLEAST64 __Q8_QF"u" -#define SCNxLEAST64 __Q8_QF"x" -#endif - -#define PRIdFAST8 "d" -#define PRIiFAST8 "i" -#define PRIoFAST8 "o" -#define PRIuFAST8 "u" -#define PRIxFAST8 "x" -#define PRIXFAST8 "X" -#define SCNdFAST8 "d" -#define SCNiFAST8 "i" -#define SCNoFAST8 "o" -#define SCNuFAST8 "u" -#define SCNxFAST8 "x" -#define PRIdFAST16 "d" -#define PRIiFAST16 "i" -#define PRIoFAST16 "o" -#define PRIuFAST16 "u" -#define PRIxFAST16 "x" -#define PRIXFAST16 "X" -#define SCNdFAST16 "d" -#define SCNiFAST16 "i" -#define SCNoFAST16 "o" -#define SCNuFAST16 "u" -#define SCNxFAST16 "x" -#if __Q8_IW >= 32 -#define PRIdFAST32 "d" -#define PRIiFAST32 "i" -#define PRIoFAST32 "o" -#define PRIuFAST32 "u" -#define PRIxFAST32 "x" -#define PRIXFAST32 "X" -#define SCNdFAST32 "d" -#define SCNiFAST32 "i" -#define SCNoFAST32 "o" -#define SCNuFAST32 "u" -#define SCNxFAST32 "x" -#else -#define PRIdFAST32 "ld" -#define PRIiFAST32 "li" -#define PRIoFAST32 "lo" -#define PRIuFAST32 "lu" -#define PRIxFAST32 "lx" -#define PRIXFAST32 "lX" -#define SCNdFAST32 "ld" -#define SCNiFAST32 "li" -#define SCNoFAST32 "lo" -#define SCNuFAST32 "lu" -#define SCNxFAST32 "lx" -#endif -#if __Q8_IW >= 40 -#define PRIdFAST40 "d" -#define PRIiFAST40 "i" -#define PRIoFAST40 "o" -#define PRIuFAST40 "u" -#define PRIxFAST40 "x" -#define PRIXFAST40 "X" -#define SCNdFAST40 "d" -#define SCNiFAST40 "i" -#define SCNoFAST40 "o" -#define SCNuFAST40 "u" -#define SCNxFAST40 "x" -#elif __Q8_LW >= 40 -#define PRIdFAST40 "ld" -#define PRIiFAST40 "li" -#define PRIoFAST40 "lo" -#define PRIuFAST40 "lu" -#define PRIxFAST40 "lx" -#define PRIXFAST40 "lX" -#define SCNdFAST40 "ld" -#define SCNiFAST40 "li" -#define SCNoFAST40 "lo" -#define SCNuFAST40 "lu" -#define SCNxFAST40 "lx" -#elif __Q8_QW >= 40 /* (will be 0 if not defined) */ -#define PRIdFAST40 __Q8_QF"d" -#define PRIiFAST40 __Q8_QF"i" -#define PRIoFAST40 __Q8_QF"o" -#define PRIuFAST40 __Q8_QF"u" -#define PRIxFAST40 __Q8_QF"x" -#define PRIXFAST40 __Q8_QF"X" -#define SCNdFAST40 __Q8_QF"d" -#define SCNiFAST40 __Q8_QF"i" -#define SCNoFAST40 __Q8_QF"o" -#define SCNuFAST40 __Q8_QF"u" -#define SCNxFAST40 __Q8_QF"x" -#endif -#if __Q8_IW >= 64 -#define PRIdFAST64 "d" -#define PRIiFAST64 "i" -#define PRIoFAST64 "o" -#define PRIuFAST64 "u" -#define PRIxFAST64 "x" -#define PRIXFAST64 "X" -#define SCNdFAST64 "d" -#define SCNiFAST64 "i" -#define SCNoFAST64 "o" -#define SCNuFAST64 "u" -#define SCNxFAST64 "x" -#elif __Q8_LW >= 64 -#define PRIdFAST64 "ld" -#define PRIiFAST64 "li" -#define PRIoFAST64 "lo" -#define PRIuFAST64 "lu" -#define PRIxFAST64 "lx" -#define PRIXFAST64 "lX" -#define SCNdFAST64 "ld" -#define SCNiFAST64 "li" -#define SCNoFAST64 "lo" -#define SCNuFAST64 "lu" -#define SCNxFAST64 "lx" -#elif __Q8_QW >= 64 /* (will be 0 if not defined) */ -#define PRIdFAST64 __Q8_QF"d" -#define PRIiFAST64 __Q8_QF"i" -#define PRIoFAST64 __Q8_QF"o" -#define PRIuFAST64 __Q8_QF"u" -#define PRIxFAST64 __Q8_QF"x" -#define PRIXFAST64 __Q8_QF"X" -#define SCNdFAST64 __Q8_QF"d" -#define SCNiFAST64 __Q8_QF"i" -#define SCNoFAST64 __Q8_QF"o" -#define SCNuFAST64 __Q8_QF"u" -#define SCNxFAST64 __Q8_QF"x" -#endif - -#define PRIdMAX __Q8_MF"d" -#define PRIiMAX __Q8_MF"i" -#define PRIoMAX __Q8_MF"o" -#define PRIuMAX __Q8_MF"u" -#define PRIxMAX __Q8_MF"x" -#define PRIXMAX __Q8_MF"X" -#define SCNdMAX __Q8_MF"d" -#define SCNiMAX __Q8_MF"i" -#define SCNoMAX __Q8_MF"o" -#define SCNuMAX __Q8_MF"u" -#define SCNxMAX __Q8_MF"x" - -#if defined(__Q8_PW) -#if __Q8_IW >= __Q8_PW -#define PRIdPTR "d" -#define PRIiPTR "i" -#define PRIoPTR "o" -#define PRIuPTR "u" -#define PRIxPTR "x" -#define PRIXPTR "X" -#define SCNdPTR "d" -#define SCNiPTR "i" -#define SCNoPTR "o" -#define SCNuPTR "u" -#define SCNxPTR "x" -#elif __Q8_LW >= __Q8_PW -#define PRIdPTR "ld" -#define PRIiPTR "li" -#define PRIoPTR "lo" -#define PRIuPTR "lu" -#define PRIxPTR "lx" -#define PRIXPTR "lX" -#define SCNdPTR "ld" -#define SCNiPTR "li" -#define SCNoPTR "lo" -#define SCNuPTR "lu" -#define SCNxPTR "lx" -#elif __Q8_QW >= __Q8_PW -#define PRIdPTR __Q8_QF"d" -#define PRIiPTR __Q8_QF"i" -#define PRIoPTR __Q8_QF"o" -#define PRIuPTR __Q8_QF"u" -#define PRIxPTR __Q8_QF"x" -#define PRIXPTR __Q8_QF"X" -#define SCNdPTR __Q8_QF"d" -#define SCNiPTR __Q8_QF"i" -#define SCNoPTR __Q8_QF"o" -#define SCNuPTR __Q8_QF"u" -#define SCNxPTR __Q8_QF"x" -#elif __Q8_MW >= __Q8_PW -#define PRIdPTR __Q8_MF"d" -#define PRIiPTR __Q8_MF"i" -#define PRIoPTR __Q8_MF"o" -#define PRIuPTR __Q8_MF"u" -#define PRIxPTR __Q8_MF"x" -#define PRIXPTR __Q8_MF"X" -#define SCNdPTR __Q8_MF"d" -#define SCNiPTR __Q8_MF"i" -#define SCNoPTR __Q8_MF"o" -#define SCNuPTR __Q8_MF"u" -#define SCNxPTR __Q8_MF"x" -#endif -#endif - -#endif /* !defined(__cplusplus) || defined(__STDC_FORMAT_MACROS) */ - -/* - 7.8.2 Functions for greatest-width integer types -*/ - -intmax_t imaxabs __Q8_PARAMS((intmax_t __j)); -imaxdiv_t imaxdiv __Q8_PARAMS((intmax_t __numer, intmax_t __denom)); -intmax_t strtoimax __Q8_PARAMS((__Q8_CONST char *__Q8_RESTRICT __nptr, - char **__Q8_RESTRICT __endptr, int __base)); -uintmax_t strtoumax __Q8_PARAMS((__Q8_CONST char *__Q8_RESTRICT __nptr, - char **__Q8_RESTRICT __endptr, int __base)); -intmax_t wcstoimax __Q8_PARAMS((__Q8_CONST __Q8_WT *__Q8_RESTRICT __nptr, - __Q8_WT **__Q8_RESTRICT __endptr, int __base)); -uintmax_t wcstoumax __Q8_PARAMS((__Q8_CONST __Q8_WT *__Q8_RESTRICT __nptr, - __Q8_WT **__Q8_RESTRICT __endptr, int __base)); - -#ifdef __cplusplus - } -#endif - -#endif /* !defined(_INTTYPES_H) && !defined(_INC_INTTYPES) */ diff --git a/src/init/c/util/iso646.h b/src/init/c/util/iso646.h deleted file mode 100644 index 2abfb32..0000000 --- a/src/init/c/util/iso646.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - -- macros for use in place of certain tokens that are - not expressible in the invariant subset of ISO 646:1991 - - This source code has been placed into the PUBLIC DOMAIN by its author. - - last edit: 1999/08/20 gwyn@arl.mil - - Implements subclause 7.9 of ISO/IEC 9899:1999 (E). - - Usage: ??=include - - Notes: The C standard has always required that the following - source trigraphs be supported in translation phase 1: - ??= mapped to # - ??( mapped to [ - ??/ mapped to \ - ??) mapped to ] - ??' mapped to ^ - ??< mapped to { - ??! mapped to | - ??> mapped to } - ??- mapped to ~ - - ISO/IEC 9899:1994 (ISO/IEC 9899:1990/Amendment 1) - and subsequently ISO/IEC 9899:1999, which require - conforming implementations to provide , - also require support in translation phases 3..4 - for the following preprocessing tokens: - %: alternate spelling for # - %:%: alternate spelling for ## - They also require support in translation phases 3..7 - for the following preprocessing tokens: - <: alternate spelling for [ - :> alternate spelling for ] - <% alternate spelling for { - %> alternate spelling for } - - The C standard also requires that the "difficult" - characters be somehow provided in both the basic source - and execution character sets, regardless of the - provision of trigraph, digraph, and macro alternatives - for these characters. (Thus, the alternate spellings - are intended to help programmers, not C implementors.) - - The 1999 revision of the C standard adds support for - international characters in identifiers via Universal - Character Names, but UCN equivalents are not allowed - for the aforementioned "difficult" characters. - - It is suggested that *all* C programmers avoid use of - the following identifiers in their programs, in case - somebody later needs to use in maintaining - the programs. - */ - -/* This header doesn't need an idempotency lock; there are no typedefs here. */ - -/* This header doesn't need C++ extern "C"; there are no declarations here. */ - -#define and && -#define and_eq &= -#define bitand & -#define bitor | -#define compl ~ -#define not ! -#define not_eq != -#define or || -#define or_eq |= -#define xor ^ -#define xor_eq ^= diff --git a/src/init/c/util/locale.c b/src/init/c/util/locale.c deleted file mode 100644 index fa88ef2..0000000 --- a/src/init/c/util/locale.c +++ /dev/null @@ -1,77 +0,0 @@ -/* - localeconv() -- numeric formatting convention inquiry - setlocale() -- locale control function - - This source code has been placed into the PUBLIC DOMAIN by its author. - - last edit: 1999/08/20 gwyn@arl.mil - - Implements subclauses 7.11.1.1 & 7.11.2.1 of ISO/IEC 9899:1999 (E). - - This is a minimal implementation for environments where - internationalization is not considered important. - - XXX -- UNTESTED -- XXX -*/ - -#include /* for CHAR_MAX */ - -#include - -static char empty[] = ""; - -static struct lconv c_lconv = /* lconv for "C" locale */ - { - /* WARNING: The following order must match the header! */ - ".", /* decimal_point */ - empty, /* thousands_sep */ - empty, /* grouping */ - empty, /* int_curr_symbol */ - empty, /* currency_symbol */ - empty, /* mon_decimal_point */ - empty, /* mon_thousands_sep */ - empty, /* mon_grouping */ - empty, /* positive_sign */ - empty, /* negative_sign */ - CHAR_MAX, /* int_frac_digits */ - CHAR_MAX, /* frac_digits */ - CHAR_MAX, /* p_cs_precedes */ - CHAR_MAX, /* p_sep_by_space */ - CHAR_MAX, /* n_cs_precedes */ - CHAR_MAX, /* n_sep_by_space */ - CHAR_MAX, /* p_sign_posn */ - CHAR_MAX, /* n_sign_posn */ - CHAR_MAX, /* int_p_cs_precedes */ - CHAR_MAX, /* int_p_sep_by_space */ - CHAR_MAX, /* int_n_cs_precedes */ - CHAR_MAX, /* int_n_sep_by_space */ - CHAR_MAX, /* int_p_sign_posn */ - CHAR_MAX, /* int_n_sign_posn */ - }; - -struct lconv * -localeconv() - { - return &c_lconv; - } - -char * -setlocale(category, locale) - int category; - const char *locale; - { - switch ( category ) - { - case LC_ALL: - case LC_COLLATE: - case LC_CTYPE: - case LC_MONETARY: - case LC_NUMERIC: - case LC_TIME: - return empty; /* native "" == "C" == "POSIX" */ - /* The string doesn't have to be the same as the argument. */ - - default: - return NULL; /* unsupported category */ - } - } diff --git a/src/init/c/util/locale.h b/src/init/c/util/locale.h deleted file mode 100644 index e7449f1..0000000 --- a/src/init/c/util/locale.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - -- definitions for internationalization functions - - This source code has been placed into the PUBLIC DOMAIN by its author. - - last edit: 1999/08/20 gwyn@arl.mil - - Implements subclause 7.11 of ISO/IEC 9899:1999 (E). - - The standard allows additional macro definitions starting with - "LC_" and an uppercase letter. - */ - -/* This header doesn't need an idempotency lock; there are no typedefs here. */ - -#include /* defines __Q8_NULL and __Q8_PARAMS */ - -#ifdef __cplusplus -extern "C" { -#endif - -struct lconv /* members are in usual UNIX order */ - { - /* The following are controlled by LC_NUMERIC: */ - char *decimal_point; - char *thousands_sep; - char *grouping; - /* The following are controlled by LC_MONETARY: */ - char *int_curr_symbol; - char *currency_symbol; - char *mon_decimal_point; - char *mon_thousands_sep; - char *mon_grouping; - char *positive_sign; - char *negative_sign; - char int_frac_digits; - char frac_digits; - char p_cs_precedes; - char p_sep_by_space; - char n_cs_precedes; - char n_sep_by_space; - char p_sign_posn; - char n_sign_posn; - char int_p_cs_precedes; - char int_p_sep_by_space; - char int_n_cs_precedes; - char int_n_sep_by_space; - char int_p_sign_posn; - char int_n_sign_posn; - }; - -/* The following have the usual UNIX values: */ -#define LC_CTYPE (0) -#define LC_NUMERIC (1) -#define LC_TIME (2) -#define LC_COLLATE (3) -#define LC_MONETARY (4) -#define LC_ALL (6) -/* other categories may be added here: */ -#define LC_MESSAGES (5) - -#ifndef NULL -#define NULL __Q8_NULL -#endif - -extern char *setlocale __Q8_PARAMS((int __category, - const char *__locale)); -extern struct lconv *localeconv __Q8_PARAMS((void)); - -#ifdef __cplusplus - } -#endif diff --git a/src/init/c/util/signal.c b/src/init/c/util/signal.c deleted file mode 100644 index 129a6e4..0000000 --- a/src/init/c/util/signal.c +++ /dev/null @@ -1,100 +0,0 @@ -/* - signal -- specify signal handling - raise -- send signal - - This source code has been placed into the PUBLIC DOMAIN by its author. - - last edit: 1999/08/20 gwyn@arl.mil - - Implements subclauses 7.14.1 & 7.14.2 of ISO/IEC 9899:1999 (E). - - These are minimally functional versions, solely for systems that don't - already provide signal() (such as the TMS320C6xxx DSP's compiler). - - XXX -- UNTESTED -- XXX -*/ - -#include -#include /* for abort() */ - -#include /* for __Q8_PARAMS */ -#include -#include - -#define NSIG (SIGTERM+1) /* max. supported signal number + 1 */ - -static void (*handler[NSIG])__Q8_PARAMS((int)); /* current handlers */ - -static bool inited = false; /* for initializing above */ - -/* dummy functions for unique address */ -void __sig_err(sig) int sig; { } -void __sig_ign(sig) int sig; { } - -/* - 7.14.1 -- specify signal handling -*/ - -void (* -signal(sig, func) - )__Q8_PARAMS((int)) /* returns previous handler */ - register int sig; - void (*func)__Q8_PARAMS((int)); - { - register void (*retval)__Q8_PARAMS((int)); /* previous handler */ - - if ( sig <= 0 || sig >= NSIG ) /* safety check */ - { - errno = EDOM; - return SIG_ERR; - } - - /* C language provides no good way to initialize handler[] */ - if ( !inited ) /* once only */ - { - register int i; - - for ( i = 0; i < NSIG; ++i ) - handler[i] = SIG_DFL; /* initialize */ - - inited = true; - } - - retval = handler[sig - 1]; /* previous state */ - handler[sig - 1] = func; /* new state */ - - return retval; /* previous handler */ - } - -/* - 7.14.2 -- send signal -*/ - -int -raise(sig) - int sig; - { - register void (*func)__Q8_PARAMS((int)); /* handler value */ - - if ( sig <= 0 || sig >= NSIG ) /* safety check */ - { - errno = EDOM; - return 1; /* indicate failure */ - } - - func = handler[sig - 1]; - - if ( func == SIG_IGN ) - return 0; /* indicate success */ - - if ( func == SIG_DFL ) - { - abort(); /* (an arbitrary decision) */ - return 1; /* just in case, indicate failure */ - } - - handler[sig - 1] = SIG_DFL; /* classic UNIX behavior */ - (*func)(sig); - - return 0; /* indicate success */ - } diff --git a/src/init/c/util/signal.h b/src/init/c/util/signal.h deleted file mode 100644 index 469b805..0000000 --- a/src/init/c/util/signal.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - signal.h -- signal handling - - This source code has been placed into the PUBLIC DOMAIN by its author. - - last edit: 1999/11/05 gwyn@arl.mil - - Implements subclause 7.14 of ISO/IEC 9899:1999 (E). - - This particular implementation requires the matching signal.c. - - This is a minimally functional version, solely for systems that don't - already provide (such as the TMS320C6xxx DSP's compiler). -*/ - -#if !defined(_SIGNAL_H) && !defined(_INC_SIGNAL) /* usual lock names */ -#define _SIGNAL_H /* idempotency lock (section 7.1.2) */ -#define _INC_SIGNAL - -#include /* defines __Q8_PARAMS */ - -#ifdef __cplusplus -extern "C" { -#endif - -/* atomic-access data type: */ - -typedef int sig_atomic_t; /* this type works nearly everywhere */ - -/* signal states: */ - -#define SIG_DFL ((void (*)__Q8_PARAMS((int)))0) /* default */ -#define SIG_ERR __sig_err /* error return from signal() */ -#define SIG_IGN __sig_ign /* ignore */ - -/* dummy functions for unique address */ -extern void __sig_err __Q8_PARAMS((int __sig)); -extern void __sig_ign __Q8_PARAMS((int __sig)); - -/* signal numbers (these are a subset of the traditional UNIX values): */ - -#define SIGINT (2) /* interactive attention signal */ -#define SIGILL (4) /* invalid function image */ -#define SIGABRT (6) /* abnormal termination */ -#define SIGFPE (8) /* erroneous arithmetic operation */ -#define SIGSEGV (11) /* invalid access to storage */ -#define SIGTERM (15) /* termination request */ -/* Note: SIGTERM is assumed by my signal.c to have the highest value. */ - -/* - 7.14.1 -- specify signal handling -*/ - -extern void (*signal __Q8_PARAMS((int __sig, void (*__func)(int)))) - __Q8_PARAMS((int)); - -/* - 7.14.2 -- send signal -*/ - -extern int raise __Q8_PARAMS((int __sig)); - -#ifdef __cplusplus - } -#endif - -#endif /* !defined(_SIGNAL_H) && !defined(_INC_SIGNAL) */ diff --git a/src/init/c/util/sitest.c b/src/init/c/util/sitest.c deleted file mode 100644 index b8ec355..0000000 --- a/src/init/c/util/sitest.c +++ /dev/null @@ -1,1521 +0,0 @@ -/* - sitest -- exercise features of C99 and - - This source code has been placed into the PUBLIC DOMAIN by its author. - - last edit: 1999/11/05 gwyn@arl.mil - - Tries to accommodate pre-C99 versions of . - - Takes advantage of __Q8_* symbols defined by a particular - implementation of , but doesn't require them. - - NOTE: This is not a thorough validation test of the facilities. -*/ - -#include -#include /* for CHAR_BIT */ -#include -#include /* for ptrdiff_t */ -#include -#include - -#include /* embeds */ -#include /* for sig_atomic_t */ -#if defined(INTMAX_MAX) /* has C99 features */ -#include -#endif - -#include /* test idempotency */ - -#if __STDC_VERSION__ >= 199901 -#ifndef __Q8_QT -#define __Q8_QT long long -#endif -#endif - -#ifdef PRIdMAX -#define HAVE_PRIdMAX -#ifndef __Q8_MT -#define __Q8_MT intmax_t -#endif -#else -#ifdef PRIdLEAST64 -#ifndef __Q8_MT -#define __Q8_MT int_least64_t -#endif -#define PRIdMAX PRIdLEAST64 -#else -#ifndef __Q8_MT -#define __Q8_MT long -#endif -#define PRIdMAX "ld" -#endif -#endif - -#ifdef PRIuMAX -#define HAVE_PRIuMAX -#define U__Q8_MT uintmax_t -#else -#ifdef PRIuLEAST64 -#define U__Q8_MT uint_least64_t -#define PRIuMAX PRIuLEAST64 -#else -#define U__Q8_MT unsigned long -#define PRIuMAX "lu" -#endif -#endif - -#define STR_SUB(s) # s -#define STRINGIZE(s) STR_SUB(s) /* extra level to expand argument */ - -#if defined(SCNo32) || defined(PRIo32) -static int32_t int32; -#endif -static int_least16_t intl16; -static uint_least16_t uintl16; -static uint_fast16_t uintf16; -static intmax_t intmax; -static uintmax_t uintmax; - -int -main() { - int status = 0; /* exit status to be returned */ - - /* features: */ - - printf("CHAR_BIT=%u\n", (unsigned)CHAR_BIT ); - printf("sizeof(char)=%u\n", (unsigned)sizeof(char)); /* s.b. 1 */ - printf("sizeof(short)=%u\n", (unsigned)sizeof(short)); - printf("sizeof(int)=%u\n", (unsigned)sizeof(int)); - printf("sizeof(long)=%u\n", (unsigned)sizeof(long)); -#ifdef __Q8_QT - printf("sizeof(long long)=%u\n", (unsigned)sizeof(__Q8_QT)); -#endif - printf("sizeof(intmax_t)=%u\n", (unsigned)sizeof(intmax_t)); - printf("sizeof(ptrdiff_t)=%u\n", (unsigned)sizeof(ptrdiff_t)); - printf("sizeof(size_t)=%u\n", (unsigned)sizeof(size_t)); - printf("sizeof(sig_atomic_t)=%u\n", (unsigned)sizeof(sig_atomic_t)); - printf("sizeof(wchar_t)=%u\n", (unsigned)sizeof(wchar_t)); -#if defined(WINT_MAX) || __STDC_VERSION__ >= 199901 - printf("sizeof(wint_t)=%u\n", (unsigned)sizeof(wint_t)); -#else - printf("*** wint_t isn't defined ***\n"); - status = EXIT_FAILURE; -#endif -#ifdef INT8_MAX - printf("sizeof(int8_t)=%u\n", (unsigned)sizeof(int8_t)); - printf("sizeof(uint8_t)=%u\n", (unsigned)sizeof(uint8_t)); -#endif -#ifdef INT9_MAX - printf("sizeof(int9_t)=%u\n", (unsigned)sizeof(int9_t)); - printf("sizeof(uint9_t)=%u\n", (unsigned)sizeof(uint9_t)); -#endif -#ifdef INT12_MAX - printf("sizeof(int12_t)=%u\n", (unsigned)sizeof(int12_t)); - printf("sizeof(uint12_t)=%u\n", (unsigned)sizeof(uint12_t)); -#endif -#ifdef INT16_MAX - printf("sizeof(int16_t)=%u\n", (unsigned)sizeof(int16_t)); - printf("sizeof(uint16_t)=%u\n", (unsigned)sizeof(uint16_t)); -#endif -#ifdef INT18_MAX - printf("sizeof(int18_t)=%u\n", (unsigned)sizeof(int18_t)); - printf("sizeof(uint18_t)=%u\n", (unsigned)sizeof(uint18_t)); -#endif -#ifdef INT24_MAX - printf("sizeof(int24_t)=%u\n", (unsigned)sizeof(int24_t)); - printf("sizeof(uint24_t)=%u\n", (unsigned)sizeof(uint24_t)); -#endif -#ifdef INT32_MAX - printf("sizeof(int32_t)=%u\n", (unsigned)sizeof(int32_t)); - printf("sizeof(uint32_t)=%u\n", (unsigned)sizeof(uint32_t)); -#endif -#ifdef INT36_MAX - printf("sizeof(int36_t)=%u\n", (unsigned)sizeof(int36_t)); - printf("sizeof(uint36_t)=%u\n", (unsigned)sizeof(uint36_t)); -#endif -#ifdef INT40_MAX - printf("sizeof(int40_t)=%u\n", (unsigned)sizeof(int40_t)); - printf("sizeof(uint40_t)=%u\n", (unsigned)sizeof(uint40_t)); -#endif -#ifdef INT48_MAX - printf("sizeof(int48_t)=%u\n", (unsigned)sizeof(int48_t)); - printf("sizeof(uint48_t)=%u\n", (unsigned)sizeof(uint48_t)); -#endif -#ifdef INT60_MAX - printf("sizeof(int60_t)=%u\n", (unsigned)sizeof(int60_t)); - printf("sizeof(uint60_t)=%u\n", (unsigned)sizeof(uint60_t)); -#endif -#ifdef INT64_MAX - printf("sizeof(int64_t)=%u\n", (unsigned)sizeof(int64_t)); - printf("sizeof(uint64_t)=%u\n", (unsigned)sizeof(uint64_t)); -#endif -#ifdef INT72_MAX - printf("sizeof(int72_t)=%u\n", (unsigned)sizeof(int72_t)); - printf("sizeof(uint72_t)=%u\n", (unsigned)sizeof(uint72_t)); -#endif -#ifdef INT128_MAX - printf("sizeof(int128_t)=%u\n", (unsigned)sizeof(int128_t)); - printf("sizeof(uint128_t)=%u\n", (unsigned)sizeof(uint128_t)); -#endif - printf("sizeof(int_least8_t)=%u\n", (unsigned)sizeof(int_least8_t)); - printf("sizeof(uint_least8_t)=%u\n", (unsigned)sizeof(uint_least8_t)); - printf("sizeof(int_least16_t)=%u\n", (unsigned)sizeof(int_least16_t)); - printf("sizeof(uint_least16_t)=%u\n", (unsigned)sizeof(uint_least16_t)); - printf("sizeof(int_least32_t)=%u\n", (unsigned)sizeof(int_least32_t)); - printf("sizeof(uint_least32_t)=%u\n", (unsigned)sizeof(uint_least32_t)); -#ifdef INT_LEAST64_MAX - printf("sizeof(int_least64_t)=%u\n", (unsigned)sizeof(int_least64_t)); - printf("sizeof(uint_least64_t)=%u\n", (unsigned)sizeof(uint_least64_t)); -#else - printf("*** uint_least64_t isn't defined ***\n"); - status = EXIT_FAILURE; -#endif -#ifdef INT_LEAST128_MAX - printf("sizeof(int_least128_t)=%u\n", (unsigned)sizeof(int_least128_t)); - printf("sizeof(uint_least128_t)=%u\n", - (unsigned)sizeof(uint_least128_t)); -#endif - printf("sizeof(int_fast8_t)=%u\n", (unsigned)sizeof(int_fast8_t)); - printf("sizeof(uint_fast8_t)=%u\n", (unsigned)sizeof(uint_fast8_t)); - printf("sizeof(int_fast16_t)=%u\n", (unsigned)sizeof(int_fast16_t)); - printf("sizeof(uint_fast16_t)=%u\n", (unsigned)sizeof(uint_fast16_t)); - printf("sizeof(int_fast32_t)=%u\n", (unsigned)sizeof(int_fast32_t)); - printf("sizeof(uint_fast32_t)=%u\n", (unsigned)sizeof(uint_fast32_t)); -#ifdef INT_FAST64_MAX - printf("sizeof(int_fast64_t)=%u\n", (unsigned)sizeof(int_fast64_t)); - printf("sizeof(uint_fast64_t)=%u\n", (unsigned)sizeof(uint_fast64_t)); -#else - printf("*** int_fast64_t isn't defined ***\n"); - status = EXIT_FAILURE; -#endif -#ifdef INT_FAST128_MAX - printf("sizeof(int_fast128_t)=%u\n", (unsigned)sizeof(int_fast128_t)); - printf("sizeof(uint_fast128_t)=%u\n", (unsigned)sizeof(uint_fast128_t)); -#endif -#if defined(INTPTR_MAX) - printf("sizeof(intptr_t)=%u\n", (unsigned)sizeof(intptr_t)); -#if defined(UINTPTR_MAX) - printf("sizeof(uintptr_t)=%u\n", (unsigned)sizeof(uintptr_t)); -#else - printf("*** intptr_t is defined but uintptr_t isn't ***\n"); - status = EXIT_FAILURE; -#endif -#elif defined(UINTPTR_MAX) - printf("sizeof(uintptr_t)=%u\n", (unsigned)sizeof(uintptr_t)); - printf("*** uintptr_t is defined but intptr_t isn't ***\n"); - status = EXIT_FAILURE; -#else - printf("*** neither intptr_t nor uintptr_t is defined ***\n"); - status = EXIT_FAILURE; -#endif -#ifdef INTMAX_MAX - printf("sizeof(intmax_t)=%u\n", (unsigned)sizeof(intmax_t)); - printf("sizeof(uintmax_t)=%u\n", (unsigned)sizeof(uintmax_t)); -#else - printf("*** intmax_t isn't defined ***\n"); - status = EXIT_FAILURE; -#endif - -#ifdef INT8_MAX - printf("INT8_MIN=%"PRIdMAX"\n", (__Q8_MT)INT8_MIN); - printf("INT8_MAX=%"PRIdMAX"\n", (__Q8_MT)INT8_MAX); - printf("UINT8_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT8_MAX); -#endif -#ifdef INT9_MAX - printf("INT9_MIN=%"PRIdMAX"\n", (__Q8_MT)INT9_MIN); - printf("INT9_MAX=%"PRIdMAX"\n", (__Q8_MT)INT9_MAX); - printf("UINT9_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT9_MAX); -#endif -#ifdef INT12_MAX - printf("INT12_MIN=%"PRIdMAX"\n", (__Q8_MT)INT12_MIN); - printf("INT12_MAX=%"PRIdMAX"\n", (__Q8_MT)INT12_MAX); - printf("UINT12_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT12_MAX); -#endif -#ifdef INT16_MAX - printf("INT16_MIN=%"PRIdMAX"\n", (__Q8_MT)INT16_MIN); - printf("INT16_MAX=%"PRIdMAX"\n", (__Q8_MT)INT16_MAX); - printf("UINT16_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT16_MAX); -#endif -#ifdef INT18_MAX - printf("INT18_MIN=%"PRIdMAX"\n", (__Q8_MT)INT18_MIN); - printf("INT18_MAX=%"PRIdMAX"\n", (__Q8_MT)INT18_MAX); - printf("UINT18_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT18_MAX); -#endif -#ifdef INT24_MAX - printf("INT24_MIN=%"PRIdMAX"\n", (__Q8_MT)INT24_MIN); - printf("INT24_MAX=%"PRIdMAX"\n", (__Q8_MT)INT24_MAX); - printf("UINT24_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT24_MAX); -#endif -#ifdef INT32_MAX - printf("INT32_MIN=%"PRIdMAX"\n", (__Q8_MT)INT32_MIN); - printf("INT32_MAX=%"PRIdMAX"\n", (__Q8_MT)INT32_MAX); - printf("UINT32_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT32_MAX); -#endif -#ifdef INT36_MAX - printf("INT36_MIN=%"PRIdMAX"\n", (__Q8_MT)INT36_MIN); - printf("INT36_MAX=%"PRIdMAX"\n", (__Q8_MT)INT36_MAX); - printf("UINT36_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT36_MAX); -#endif -#ifdef INT40_MAX - printf("INT40_MIN=%"PRIdMAX"\n", (__Q8_MT)INT40_MIN); - printf("INT40_MAX=%"PRIdMAX"\n", (__Q8_MT)INT40_MAX); - printf("UINT40_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT40_MAX); -#endif -#ifdef INT48_MAX - printf("INT48_MIN=%"PRIdMAX"\n", (__Q8_MT)INT48_MIN); - printf("INT48_MAX=%"PRIdMAX"\n", (__Q8_MT)INT48_MAX); - printf("UINT48_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT48_MAX); -#endif -#ifdef INT60_MAX - printf("INT60_MIN=%"PRIdMAX"\n", (__Q8_MT)INT60_MIN); - printf("INT60_MAX=%"PRIdMAX"\n", (__Q8_MT)INT60_MAX); - printf("UINT60_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT60_MAX); -#endif -#ifdef INT64_MAX - printf("INT64_MIN=%"PRIdMAX"\n", (__Q8_MT)INT64_MIN); - printf("INT64_MAX=%"PRIdMAX"\n", (__Q8_MT)INT64_MAX); - printf("UINT64_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT64_MAX); -#endif -#ifdef INT72_MAX - printf("INT72_MIN=%"PRIdMAX"\n", (__Q8_MT)INT72_MIN); - printf("INT72_MAX=%"PRIdMAX"\n", (__Q8_MT)INT72_MAX); - printf("UINT72_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT72_MAX); -#endif -#ifdef INT128_MAX - printf("INT128_MIN=%"PRIdMAX"\n", (__Q8_MT)INT128_MIN); - printf("INT128_MAX=%"PRIdMAX"\n", (__Q8_MT)INT128_MAX); - printf("UINT128_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT128_MAX); -#endif - printf("INT_LEAST8_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST8_MIN); - printf("INT_LEAST8_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST8_MAX); - printf("UINT_LEAST8_MAX=%"PRIuMAX"\n", - (U__Q8_MT)UINT_LEAST8_MAX); - printf("INT_LEAST16_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST16_MIN); - printf("INT_LEAST16_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST16_MAX); - printf("UINT_LEAST16_MAX=%"PRIuMAX"\n", - (U__Q8_MT)UINT_LEAST16_MAX); - printf("INT_LEAST32_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST32_MIN); - printf("INT_LEAST32_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST32_MAX); - printf("UINT_LEAST32_MAX=%"PRIuMAX"\n", - (U__Q8_MT)UINT_LEAST32_MAX); -#ifdef INT_LEAST64_MAX - printf("INT_LEAST64_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST64_MIN); - printf("INT_LEAST64_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST64_MAX); - printf("UINT_LEAST64_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT_LEAST64_MAX); -#endif -#ifdef INT_LEAST128_MAX - printf("INT_LEAST128_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST128_MIN); - printf("INT_LEAST128_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST128_MAX); - printf("UINT_LEAST128_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT_LEAST128_MAX); -#endif - printf("INT_FAST8_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_FAST8_MIN); - printf("INT_FAST8_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_FAST8_MAX); - printf("UINT_FAST8_MAX=%"PRIuMAX"\n", - (U__Q8_MT)UINT_FAST8_MAX); - printf("INT_FAST16_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_FAST16_MIN); - printf("INT_FAST16_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_FAST16_MAX); - printf("UINT_FAST16_MAX=%"PRIuMAX"\n", - (U__Q8_MT)UINT_FAST16_MAX); - printf("INT_FAST32_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_FAST32_MIN); - printf("INT_FAST32_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_FAST32_MAX); - printf("UINT_FAST32_MAX=%"PRIuMAX"\n", - (U__Q8_MT)UINT_FAST32_MAX); -#ifdef INT_FAST64_MAX - printf("INT_FAST64_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_FAST64_MIN); - printf("INT_FAST64_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_FAST64_MAX); - printf("UINT_FAST64_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT_FAST64_MAX); -#endif -#ifdef INT_FAST128_MAX - printf("INT_FAST128_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_FAST128_MIN); - printf("INT_FAST128_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_FAST128_MAX); - printf("UINT_FAST128_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT_FAST128_MAX); -#endif -#ifdef INTPTR_MAX - printf("INTPTR_MIN=%"PRIdMAX"\n", (__Q8_MT)INTPTR_MIN); - printf("INTPTR_MAX=%"PRIdMAX"\n", (__Q8_MT)INTPTR_MAX); -#endif -#ifdef UINTPTR_MAX - printf("UINTPTR_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINTPTR_MAX); -#endif -#ifdef INTMAX_MAX - printf("INTMAX_MIN=%"PRIdMAX"\n", (__Q8_MT)INTMAX_MIN); - printf("INTMAX_MAX=%"PRIdMAX"\n", (__Q8_MT)INTMAX_MAX); - printf("UINTMAX_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINTMAX_MAX); -#endif -#ifdef PTRDIFF_MAX - printf("PTRDIFF_MIN=%"PRIdMAX"\n", (__Q8_MT)PTRDIFF_MIN); - printf("PTRDIFF_MAX=%"PRIdMAX"\n", (__Q8_MT)PTRDIFF_MAX); -#endif -#ifdef SIG_ATOMIC_MAX -#if SIG_ATOMIC_MIN < 0 - printf("SIG_ATOMIC_MIN=%"PRIdMAX"\n", (__Q8_MT)SIG_ATOMIC_MIN); - printf("SIG_ATOMIC_MAX=%"PRIdMAX"\n", (__Q8_MT)SIG_ATOMIC_MAX); -#else - printf("SIG_ATOMIC_MIN=%"PRIuMAX"\n", (U__Q8_MT)SIG_ATOMIC_MIN); - printf("SIG_ATOMIC_MAX=%"PRIuMAX"\n", (U__Q8_MT)SIG_ATOMIC_MAX); -#endif -#endif -#ifdef SIZE_MAX - printf("SIZE_MAX=%"PRIuMAX"\n", (U__Q8_MT)SIZE_MAX); -#endif - -#ifdef WCHAR_MAX -#if WCHAR_MIN < 0 - printf("WCHAR_MIN=%"PRIdMAX"\n", (__Q8_MT)WCHAR_MIN); - printf("WCHAR_MAX=%"PRIdMAX"\n", (__Q8_MT)WCHAR_MAX); -#else - printf("WCHAR_MIN=%"PRIuMAX"\n", (U__Q8_MT)WCHAR_MIN); - printf("WCHAR_MAX=%"PRIuMAX"\n", (U__Q8_MT)WCHAR_MAX); -#endif -#endif -#ifdef WINT_MAX -#if WINT_MIN < 0 - printf("WINT_MIN=%"PRIdMAX"\n", (__Q8_MT)WINT_MIN); - printf("WINT_MAX=%"PRIdMAX"\n", (__Q8_MT)WINT_MAX); -#else - printf("WINT_MIN=%"PRIuMAX"\n", (U__Q8_MT)WINT_MIN); - printf("WINT_MAX=%"PRIuMAX"\n", (U__Q8_MT)WINT_MAX); -#endif -#endif - - /* - 7.18.4 Macros for integer constants - */ - - /* INTn_C for n=8 and 16 were at one point unimplementable - on most platforms, so they're treated as "optional": */ -#ifdef INT8_C - if ( INT8_C(-123) != -123 ) - printf("*** INT8_C(-123) produced %"PRIdMAX" ***\n", - (__Q8_MT)INT8_C(-123) - ); - if ( UINT8_C(123) != 123 ) - printf("*** UINT8_C(123) produced %"PRIuMAX" ***\n", - (U__Q8_MT)UINT8_C(123) - ); -#endif -#ifdef INT16_C - if ( INT16_C(-12345) != -12345 ) - printf("*** INT16_C(-12345) produced %"PRIdMAX" ***\n", - (__Q8_MT)INT16_C(-12345) - ); - if ( UINT16_C(12345) != 12345 ) - printf("*** UINT16_C(12345) produced %"PRIuMAX" ***\n", - (U__Q8_MT)UINT16_C(12345) - ); -#endif - if ( INT32_C(-123456789) != -123456789 ) - printf("*** INT32_C(-123456789) produced %"PRIdMAX" ***\n", - (__Q8_MT)INT32_C(-123456789) - ); - if ( UINT32_C(123456789) != 123456789 ) - printf("*** UINT32_C(123456789) produced %"PRIuMAX" ***\n", - (U__Q8_MT)UINT32_C(123456789) - ); -#ifdef INT_LEAST64_MAX - if ( INT64_C(-1234567890123456789) != -1234567890123456789 ) - printf("*** INT64_C(-1234567890123456789) produced %"PRIdMAX - " ***\n", - (__Q8_MT)INT64_C(-1234567890123456789) - ); - if ( UINT64_C(1234567890123456789) != 1234567890123456789 ) - printf("*** UINT64_C(1234567890123456789) produced %"PRIuMAX - " ***\n", - (U__Q8_MT)UINT64_C(1234567890123456789) - ); -#endif -#ifdef INTMAX_MAX - if ( INTMAX_C(-1234567890123456789) != -1234567890123456789 ) - printf("*** INTMAX_C(-1234567890123456789) produced %"PRIdMAX - " ***\n", - (__Q8_MT)INTMAX_C(-1234567890123456789) - ); - if ( UINTMAX_C(1234567890123456789) != 1234567890123456789 ) - printf("*** UINTMAX_C(1234567890123456789) produced %"PRIuMAX - " ***\n", - (U__Q8_MT)UINTMAX_C(1234567890123456789) - ); -#endif - - /* features: */ - -#if __STDC_VERSION__ >= 199901 - printf("sizeof(imaxdiv_t)=%u\n", (unsigned)sizeof(imaxdiv_t)); -#endif - - /* - 7.8.1 Macros for format specifiers - */ - - { - /* scanf these strings */ - static const char in_dn[] = "Z119bZ"; - static const char in_dmo[] = "Z-0119bZ"; - static const char in_dspx[] = "Z \t\n +0X119bZ"; - static const char in_dsmx[] = "Z \t\n -0x119bZ"; - static const char in_dsn[] = "Z \t\n 119bZ"; - static const char in_dp[] = "Z+119bZ"; - static const char in_dpx[] = "Z+0X119bz"; - - /* sprintf into this */ - static char buffer[1024]; - -#define SCAN(buf,fs,var,exp) if ( sscanf(buf, "Z%" fs, &var) != 1 ) \ - { \ - printf("*** " #fs "=" STR_SUB(fs) \ - " failed ***\n" \ - ); \ - status = EXIT_FAILURE; \ - } \ - else if ( var != (exp) ) \ - { \ - printf("*** " #fs "=" STR_SUB(fs) \ - " should be: " STR_SUB(exp) \ - ", was: %" fs " ***\n", var \ - ); \ - status = EXIT_FAILURE; \ - } \ - else /* for trailing semicolon */ - -#define PRINT(fs,var,exp) if ( sprintf(buffer, "%" fs, var ) <= 0 ) \ - { \ - printf("*** " #fs "=" STR_SUB(fs) \ - " failed ***\n" \ - ); \ - status = EXIT_FAILURE; \ - } \ - else if ( strcmp(buffer, STR_SUB(exp)) != 0 ) \ - { \ - printf("*** " #fs "=" STR_SUB(fs) \ - " should be: " STR_SUB(exp) \ - ", was: %s ***\n", buffer \ - ); \ - status = EXIT_FAILURE; \ - } \ - else /* for trailing semicolon */ - -#ifdef SCNo32 - SCAN(in_dn, SCNo32, int32, 9); -#endif -#ifdef PRIo32 - PRINT(PRIo32, int32, 11); -#endif - SCAN(in_dmo, SCNiLEAST16, intl16, -9); - SCAN(in_dspx, SCNdLEAST16, intl16, 0); - SCAN(in_dsmx, SCNiLEAST16, intl16, -4507); - PRINT(PRIdLEAST16, intl16, -4507); - PRINT(PRIiLEAST16, intl16, -4507); - SCAN(in_dsn, SCNxLEAST16, uintl16, 4507); - PRINT(PRIoLEAST16, uintl16, 10633); - PRINT(PRIuLEAST16, uintl16, 4507); - PRINT(PRIxLEAST16, uintl16, 119b); - PRINT(PRIXLEAST16, uintl16, 119B); - SCAN(in_dp, SCNxFAST16, uintf16, 4507); - PRINT(PRIxFAST16, uintf16, 119b); -#ifdef SCNdMAX - SCAN(in_dp, SCNdMAX, intmax, 119); -#endif -#ifdef PRIiMAX - PRINT(PRIiMAX, intmax, 119); -#endif -#ifdef SCNoMAX - SCAN(in_dpx, SCNoMAX, uintmax, 0); -#endif -#ifdef PRIxMAX - PRINT(PRIxMAX, uintmax, 0); -#endif - /* Obviously there should be a much larger battery of such tests. */ - } - -#if defined(INTMAX_MAX) /* has C99 features */ - /* - 7.8.2 Functions for greatest-width integer types - */ - - { - static struct - { - intmax_t input; - intmax_t expect; - } abs_data[] = - { -#ifdef INT8_MAX - INT8_MAX, INT8_MAX, - -INT8_MAX, INT8_MAX, - UINT8_MAX, UINT8_MAX, -#endif -#ifdef INT16_MAX - INT16_MAX, INT16_MAX, - -INT16_MAX, INT16_MAX, - UINT16_MAX, UINT16_MAX, -#endif -#ifdef INT32_MAX - INT32_MAX, INT32_MAX, - -INT32_MAX, INT32_MAX, -#ifdef INT_LEAST64_MAX /* else might support only 32 bits */ - UINT32_MAX, UINT32_MAX, -#endif -#endif -#ifdef INT64_MAX - INT64_MAX, INT64_MAX, - -INT64_MAX, INT64_MAX, -#endif - INT_LEAST8_MAX, INT_LEAST8_MAX, - -INT_LEAST8_MAX, INT_LEAST8_MAX, - UINT_LEAST8_MAX, UINT_LEAST8_MAX, - INT_LEAST16_MAX, INT_LEAST16_MAX, - -INT_LEAST16_MAX, INT_LEAST16_MAX, - UINT_LEAST16_MAX, UINT_LEAST16_MAX, - INT_LEAST32_MAX, INT_LEAST32_MAX, - -INT_LEAST32_MAX, INT_LEAST32_MAX, -#ifdef INT_LEAST64_MAX - UINT_LEAST32_MAX, UINT_LEAST32_MAX, - INT_LEAST64_MAX, INT_LEAST64_MAX, - -INT_LEAST64_MAX, INT_LEAST64_MAX, -#endif - INT_FAST8_MAX, INT_FAST8_MAX, - -INT_FAST8_MAX, INT_FAST8_MAX, - UINT_FAST8_MAX, UINT_FAST8_MAX, - INT_FAST16_MAX, INT_FAST16_MAX, - -INT_FAST16_MAX, INT_FAST16_MAX, - UINT_FAST16_MAX, UINT_FAST16_MAX, - INT_FAST32_MAX, INT_FAST32_MAX, - -INT_FAST32_MAX, INT_FAST32_MAX, -#ifdef INT_FAST64_MAX - UINT_FAST32_MAX, UINT_FAST32_MAX, - INT_FAST64_MAX, INT_FAST64_MAX, - -INT_FAST64_MAX, INT_FAST64_MAX, -#endif -#ifdef INTPTR_MAX - INTPTR_MAX, INTPTR_MAX, - -INTPTR_MAX, INTPTR_MAX, -#endif -#ifdef UINTPTR_MAX - UINTPTR_MAX, UINTPTR_MAX, -#endif - INTMAX_MAX, INTMAX_MAX, -#ifdef PTRDIFF_MAX - PTRDIFF_MAX, PTRDIFF_MAX, -#endif -#ifdef SIG_ATOMIC_MAX - SIG_ATOMIC_MAX, SIG_ATOMIC_MAX, -#if SIG_ATOMIC_MIN < 0 - -SIG_ATOMIC_MAX, SIG_ATOMIC_MAX, -#endif -#endif -#ifdef SIZE_MAX - SIZE_MAX, SIZE_MAX, -#endif -#ifdef WCHAR_MAX - WCHAR_MAX, WCHAR_MAX, -#if WCHAR_MIN < 0 - -WCHAR_MAX, WCHAR_MAX, -#endif -#endif -#ifdef WINT_MAX - WINT_MAX, WINT_MAX, -#if WINT_MIN < 0 - -WINT_MAX, WINT_MAX, -#endif -#endif - 127, 127, - -127, 127, - 128, 128, - -127-1, 128, - 255, 255, - -256+1, 255, - 256, 256, - -256, 256, - 32767, 32767, - -32767, 32767, - 32768, 32768, - -32767-1, 32768, - 65535, 65535, - -65536+1, 65535, - 65536, 65536, - -65536, 65536, - 2147483647, 2147483647, - -2147483647, 2147483647, - 2147483648, 2147483648, - -2147483647-1, 2147483648, -#ifdef INT_LEAST64_MAX /* else might support only 32 bits */ - 4294967295, 4294967295, - -4294967296+1, 4294967295, - 4294967296, 4294967296, - -4294967296, 4294967296, - 9223372036854775807, 9223372036854775807, - -9223372036854775807, 9223372036854775807, - 1234567890123456789, 1234567890123456789, - -1234567890123456789, 1234567890123456789, -#endif - 1, 1, - -1, 1, - 2, 2, - -2, 2, - 10, 10, - -10, 10, - 16, 16, - -16, 16, - /* Other test cases can be added here. */ - 0, 0 /* terminates the list */ - }, *adp = abs_data; - - do if ( (intmax = imaxabs(adp->input)) != adp->expect ) - { - printf("*** imaxabs(%"PRIdMAX") failed; should be: %" - PRIdMAX", was: %"PRIdMAX" ***\n", - adp->input, adp->expect, intmax - ); - status = EXIT_FAILURE; - } - while ( adp++->input != 0 ); - } - - { - imaxdiv_t result; - static struct - { - intmax_t numer; - intmax_t denom; - intmax_t exp_quot; - intmax_t exp_rem; - } div_data[] = - { - 0, 1, 0, 0, - 0, -1, 0, 0, - 0, 2, 0, 0, - 0, -2, 0, 0, - 0, 5, 0, 0, - 0, -5, 0, 0, - 1, 1, 1, 0, - 1, -1, -1, 0, - 1, 2, 0, 1, - 1, -2, 0, 1, - 1, 5, 0, 1, - 1, -5, 0, 1, - -1, 1, -1, 0, - -1, -1, 1, 0, - -1, 2, 0, -1, - -1, -2, 0, -1, - -1, 5, 0, -1, - -1, -5, 0, -1, - 2, 1, 2, 0, - 2, -1, -2, 0, - 2, 2, 1, 0, - 2, -2, -1, 0, - 2, 5, 0, 2, - 2, -5, 0, 2, - -2, 1, -2, 0, - -2, -1, 2, 0, - -2, 2, -1, 0, - -2, -2, 1, 0, - -2, 5, 0, -2, - -2, -5, 0, -2, - 17, 5, 3, 2, - -17, -5, 3, -2, - 17, -5, -3, 2, - -17, 5, -3, -2, - 2147483647, 1, 2147483647, 0, - -2147483647, 1, -2147483647, 0, - 2147483648, 1, 2147483648, 0, - -2147483647-1, 1, -2147483647-1, 0, - 2147483647, 2, 1073741823, 1, - -2147483647, 2, -1073741823, -1, - 2147483648, 2, 1073741824, 0, - -2147483647-1, 2, -1073741824, 0, -#ifdef INT_LEAST64_MAX /* else might support only 32 bits */ - 4294967295, 1, 4294967295, 0, - -4294967296+1, 1, -4294967296+1, 0, - 4294967296, 1, 4294967296, 0, - -4294967296, 1, -4294967296, 0, - 4294967295, -1, -4294967296+1, 0, - -4294967296+1, -1, 4294967295, 0, - 4294967296, -1, -4294967296, 0, - -4294967296, -1, 4294967296, 0, - 4294967295, 2, 2147483647, 1, - -4294967296+1, 2, -2147483647, -1, - 4294967296, 2, 2147483648, 0, - -4294967296, 2, -2147483647-1, 0, - 4294967295, 2147483647, 2, 1, - -4294967296+1, 2147483647, -2, -1, - 4294967296, 2147483647, 2, 2, - -4294967296, 2147483647, -2, -2, - 4294967295, -2147483647, -2, 1, - -4294967296+1, -2147483647, 2, -1, - 4294967296, -2147483647, -2, 2, - -4294967296, -2147483647, 2, -2, - 4294967295, 2147483648, 1, 2147483647, - -4294967296+1, 2147483648, -1, -2147483647, - 4294967296, 2147483648, 2, 0, - -4294967296, 2147483648, -2, 0, - 4294967295, -2147483647-1, -1, 2147483647, - -4294967296+1, -2147483647-1, 1, -2147483647, - 4294967296, -2147483647-1, -2, 0, - -4294967296, -2147483647-1, 2, 0, - 9223372036854775807, 1, 9223372036854775807, 0, - -9223372036854775807, 1, -9223372036854775807, 0, - 9223372036854775807, 2, 4611686018427387903, 1, - -9223372036854775807, 2, -4611686018427387903, -1, -#endif - /* There should be a much larger battery of such tests. */ - 0, 0, 0, 0 /* 0 denom terminates the list */ - }, *ddp; - - for ( ddp = div_data; ddp->denom != 0; ++ddp ) - if ( (result = imaxdiv(ddp->numer, ddp->denom)).quot - != ddp->exp_quot || result.rem != ddp->exp_rem - ) { - printf("*** imaxdiv(%"PRIdMAX",%"PRIdMAX - ") failed; should be: (%"PRIdMAX",%"PRIdMAX - "), was: (%"PRIdMAX",%"PRIdMAX") ***\n", - ddp->numer, ddp->denom, ddp->exp_quot, - ddp->exp_rem, result.quot, result.rem - ); - status = EXIT_FAILURE; - } - } - - { - char *endptr; - wchar_t *wendptr; - static char saved[64]; /* holds copy of input string */ - static wchar_t wnptr[64]; /* holds wide copy of test string */ - static int warned; /* "warned for null endptr" flag */ - register int i; - static struct - { - char * nptr; - int base; - intmax_t exp_val; - int exp_len; - } str_data[] = - { - "", 0, 0, 0, - "", 2, 0, 0, - "", 8, 0, 0, - "", 9, 0, 0, - "", 10, 0, 0, - "", 16, 0, 0, - "", 36, 0, 0, - "0", 0, 0, 1, - "0", 2, 0, 1, - "0", 8, 0, 1, - "0", 9, 0, 1, - "0", 10, 0, 1, - "0", 16, 0, 1, - "0", 36, 0, 1, - "+0", 0, 0, 2, - "+0", 2, 0, 2, - "+0", 8, 0, 2, - "+0", 9, 0, 2, - "+0", 10, 0, 2, - "+0", 16, 0, 2, - "+0", 36, 0, 2, - "-0", 0, 0, 2, - "-0", 2, 0, 2, - "-0", 8, 0, 2, - "-0", 9, 0, 2, - "-0", 10, 0, 2, - "-0", 16, 0, 2, - "-0", 36, 0, 2, - "Inf", 0, 0, 0, - "Inf", 2, 0, 0, - "Inf", 8, 0, 0, - "Inf", 9, 0, 0, - "Inf", 10, 0, 0, - "Inf", 16, 0, 0, - "Inf", 36, 24171, 3, - "+Inf", 0, 0, 0, - "+Inf", 2, 0, 0, - "+Inf", 8, 0, 0, - "+Inf", 9, 0, 0, - "+Inf", 10, 0, 0, - "+Inf", 16, 0, 0, - "+Inf", 36, 24171, 4, - "-Inf", 0, 0, 0, - "-Inf", 2, 0, 0, - "-Inf", 8, 0, 0, - "-Inf", 9, 0, 0, - "-Inf", 10, 0, 0, - "-Inf", 16, 0, 0, - "-Inf", 36, -24171, 4, - "inf", 0, 0, 0, - "inf", 2, 0, 0, - "inf", 8, 0, 0, - "inf", 9, 0, 0, - "inf", 10, 0, 0, - "inf", 16, 0, 0, - "inf", 36, 24171, 3, - "+inf", 0, 0, 0, - "+inf", 2, 0, 0, - "+inf", 8, 0, 0, - "+inf", 9, 0, 0, - "+inf", 10, 0, 0, - "+inf", 16, 0, 0, - "+inf", 36, 24171, 4, - "-inf", 0, 0, 0, - "-inf", 2, 0, 0, - "-inf", 8, 0, 0, - "-inf", 9, 0, 0, - "-inf", 10, 0, 0, - "-inf", 16, 0, 0, - "-inf", 36, -24171, 4, - "119b8Z", 0, 119, 3, - "119bZ", 0, 119, 3, - "-0119bZ", 0, -9, 4, - " \t\n 0X119bZ", 0, 4507, 10, - " \t\n +0X119bZ", 0, 4507, 11, - " \t\n -0x119bZ", 0, -4507, 11, - " \t\n 119bZ", 0, 119, 7, - "+119bZ", 0, 119, 4, - "+0X119bz", 0, 4507, 7, - "119b8Z", 2, 3, 2, - "119bZ", 2, 3, 2, - "-0119bZ", 2, -3, 4, - " \t\n 0X119bZ", 2, 0, 5, - " \t\n +0X119bZ", 2, 0, 6, - " \t\n -0x119bZ", 2, 0, 6, - " \t\n 119bZ", 2, 3, 6, - "+119bZ", 2, 3, 3, - "+0X119bz", 2, 0, 2, - "119b8Z", 8, 9, 2, - "119bZ", 8, 9, 2, - "-0119bZ", 8, -9, 4, - " \t\n 0X119bZ", 8, 0, 5, - " \t\n +0X119bZ", 8, 0, 6, - " \t\n -0x119bZ", 8, 0, 6, - " \t\n 119bZ", 8, 9, 6, - "+119bZ", 8, 9, 3, - "+0X119bz", 8, 0, 2, - "119b8Z", 9, 10, 2, - "119bZ", 9, 10, 2, - "-0119bZ", 9, -10, 4, - " \t\n 0X119bZ", 9, 0, 5, - " \t\n +0X119bZ", 9, 0, 6, - " \t\n -0x119bZ", 9, 0, 6, - " \t\n 119bZ", 9, 10, 6, - "+119bZ", 9, 10, 3, - "+0X119bz", 9, 0, 2, - "119b8Z", 10, 119, 3, - "119bZ", 10, 119, 3, - "-0119bZ", 10, -119, 5, - " \t\n 0X119bZ", 10, 0, 5, - " \t\n +0X119bZ", 10, 0, 6, - " \t\n -0x119bZ", 10, 0, 6, - " \t\n 119bZ", 10, 119, 7, - "+119bZ", 10, 119, 4, - "+0X119bz", 10, 0, 2, - "119b8Z", 16, 72120, 5, - "119bZ", 16, 4507, 4, - "-0119bZ", 16, -4507, 6, - " \t\n 0X119bZ", 16, 4507, 10, - " \t\n +0X119bZ", 16, 4507, 11, - " \t\n -0x119bZ", 16, -4507, 11, - " \t\n 119bZ", 16, 4507,8, - "+119bZ", 16, 4507, 5, - "+0X119bz", 16, 4507, 7, - "119b8Z", 36, 62580275, 6, - "119bZ", 36, 1738367, 5, - "-0119bZ", 36, -1738367, 7, - " \t\n 0X119bZ", 36, 1997122175, 11, - " \t\n +0X119bZ", 36, 1997122175, 12, - " \t\n -0x119bZ", 36, -1997122175, 12, - " \t\n 119bZ", 36, 1738367, 9, - "+119bZ", 36, 1738367, 6, - "+0X119bz", 36, 1997122175, 8, - /* There should be a much larger battery of such tests. */ - "127", 0, 127, 3, - "-127", 0, -127, 4, - "128", 0, 128, 3, - "-128", 0, -127-1, 4, - "255", 0, 255, 3, - "-255", 0, -255, 4, - "256", 0, 256, 3, - "-256", 0, -255-1, 4, - "32767", 0, 32767, 5, - "-32767", 0, -32767, 6, - "32768", 0, 32768, 5, - "-32768", 0, -32767-1, 6, - "65535", 0, 65535, 5, - "-65535", 0, -65536+1, 6, - "65536", 0, 65536, 5, - "-65536", 0, -65536, 6, - "2147483647", 0, 2147483647, 10, - "-2147483647", 0, -2147483647, 11, - "2147483648", 0, 2147483648, 10, - "-2147483648", 0, -2147483647-1, 11, - "4294967295", 0, 4294967295, 10, - "-4294967295", 0, -4294967296+1, 11, - "4294967296", 0, 4294967296, 10, - "-4294967296", 0, -4294967296, 11, - "9223372036854775807", 0, 9223372036854775807, 19, - "-9223372036854775807", 0, -9223372036854775807, 20, - "1234567890123456789", 0, 1234567890123456789, 19, - "-1234567890123456789", 0, -1234567890123456789, 20, - "1", 0, 1, 1, - "-1", 0, -1, 2, - "2", 0, 2, 1, - "-2", 0, -2, 2, - "10", 0, 10, 2, - "-10", 0, -10, 3, - "16", 0, 16, 2, - "-16", 0, -16, 3, - /* Other test cases can be added here. */ - NULL, 0, 0, 0 /* terminates the list */ - }, *sdp; - - for ( sdp = str_data; sdp->nptr != NULL ; ++sdp ) - { - /* - 7.8.2.3 The strtoimax and strtoumax functions - */ - - strcpy(saved, sdp->nptr); - - errno = 0; /* shouldn't be changed */ - - if ( (intmax = strtoimax(sdp->nptr, &endptr, sdp->base)) - != sdp->exp_val - ) { - int save = errno; - - printf("*** strtoimax(%s,,%d) failed; should be: %" - PRIdMAX", was: %"PRIdMAX" ***\n", sdp->nptr, - sdp->base, sdp->exp_val, intmax - ); - status = EXIT_FAILURE; - errno = save; - } - else if ( endptr != sdp->nptr + sdp->exp_len ) - { - int save = errno; - - printf("*** strtoimax(%s,,%d) returned wrong endptr" - " ***\n", sdp->nptr, sdp->base - ); - status = EXIT_FAILURE; - errno = save; - } - - if ( errno != 0 ) - { - printf("*** strtoimax modified errno ***\n"); - status = EXIT_FAILURE; - } - - if ( strcmp(sdp->nptr, saved) != 0 ) - { - printf("*** strtoimax modified its input ***\n"); - status = EXIT_FAILURE; - strcpy(saved, sdp->nptr); - } - - if ( sdp->exp_val >= 0 ) /* else some sign extension */ - { - errno = 0; /* shouldn't be changed */ - - if ( (uintmax = strtoumax(sdp->nptr, &endptr, sdp->base - ) - ) != sdp->exp_val - ) { - int save = errno; - - printf("*** strtoumax(%s,,%d) failed; " - "should be: %"PRIuMAX", was: %"PRIuMAX - " ***\n", sdp->nptr, sdp->base, - sdp->exp_val, uintmax - ); - status = EXIT_FAILURE; - errno = save; - } - else if ( endptr != sdp->nptr + sdp->exp_len ) - { - int save = errno; - - printf("*** strtoumax(%s,,%d) returned wrong " - "endptr ***\n", sdp->nptr, sdp->base - ); - status = EXIT_FAILURE; - errno = save; - } - - if ( errno != 0 ) - { - printf("*** strtoumax modified errno ***\n"); - status = EXIT_FAILURE; - } - - if ( strcmp(sdp->nptr, saved) != 0 ) - { - printf("*** strtoumax" - " modified its input ***\n" - ); - status = EXIT_FAILURE; - strcpy(saved, sdp->nptr); - } - } - - /* tests for null endptr */ - -#define WARN() if (!warned) warned = 1, printf("*** Using null endptr: ***\n") - - warned = 0; - errno = 0; /* shouldn't be changed */ - - if ( (intmax = strtoimax(sdp->nptr, (char **)NULL, sdp->base)) - != sdp->exp_val - ) { - int save = errno; - - WARN(); - printf("*** strtoimax(%s,NULL,%d) failed; " - "should be: %"PRIdMAX", was: %"PRIdMAX" ***\n", - sdp->nptr, sdp->base, sdp->exp_val, intmax - ); - status = EXIT_FAILURE; - errno = save; - } - - if ( errno != 0 ) - { - WARN(); - printf("*** strtoimax modified errno ***\n"); - status = EXIT_FAILURE; - } - - if ( strcmp(sdp->nptr, saved) != 0 ) - { - WARN(); - printf("*** strtoimax modified its input ***\n"); - status = EXIT_FAILURE; - strcpy(saved, sdp->nptr); - } - - if ( sdp->exp_val >= 0 ) /* else some sign extension */ - { - errno = 0; /* shouldn't be changed */ - - if ( (uintmax = strtoumax(sdp->nptr, (char **)NULL, - sdp->base - ) - ) != sdp->exp_val - ) { - int save = errno; - - WARN(); - printf("*** strtoumax(%s,NULL,%d) failed; " - "should be: %"PRIuMAX", was: %"PRIuMAX - " ***\n", sdp->nptr, sdp->base, - sdp->exp_val, uintmax - ); - status = EXIT_FAILURE; - errno = save; - } - - if ( errno != 0 ) - { - WARN(); - printf("*** strtoumax modified errno ***\n"); - status = EXIT_FAILURE; - } - - if ( strcmp(sdp->nptr, saved) != 0 ) - { - WARN(); - printf("*** strtoumax" - " modified its input ***\n" - ); - status = EXIT_FAILURE; - strcpy(saved, sdp->nptr); - } - } - - /* - 7.8.2.4 The wcstoimax and wcstoumax functions - */ - - for ( i = 0; i < 64; ++i ) - if ( (wnptr[i] = sdp->nptr[i]) == '\0' ) - break; - - errno = 0; /* shouldn't be changed */ - - if ( (intmax = wcstoimax(wnptr, &wendptr, sdp->base)) - != sdp->exp_val - ) { - int save = errno; - - printf("*** wcstoimax(%s,,%d) failed; should be: %" - PRIdMAX", was: %"PRIdMAX" ***\n", sdp->nptr, - sdp->base, sdp->exp_val, intmax - ); - status = EXIT_FAILURE; - errno = save; - } - else if ( wendptr != wnptr + sdp->exp_len ) - { - int save = errno; - - printf("*** wcstoimax(%s,,%d) returned wrong endptr" - " ***\n", sdp->nptr, sdp->base - ); - status = EXIT_FAILURE; - errno = save; - } - - if ( errno != 0 ) - { - printf("*** wcstoimax modified errno ***\n"); - status = EXIT_FAILURE; - } - - for ( i = 0; i < 64; ++i ) - if ( wnptr[i] != sdp->nptr[i] ) - { - printf("*** wcstoimax modified its input ***\n" - ); - status = EXIT_FAILURE; - - for ( ; i < 64; ++i ) - if ( (wnptr[i] = sdp->nptr[i]) == '\0' ) - break; - - break; - } - else if ( wnptr[i] == '\0' ) - break; - - if ( sdp->exp_val >= 0 ) /* else some sign extension */ - { - errno = 0; /* shouldn't be changed */ - - if ( (uintmax = wcstoumax(wnptr, &wendptr, sdp->base) - ) != sdp->exp_val - ) { - int save = errno; - - printf("*** wcstoumax(%s,,%d) failed; " - "should be: %"PRIuMAX", was: %"PRIuMAX - " ***\n", sdp->nptr, sdp->base, - sdp->exp_val, uintmax - ); - status = EXIT_FAILURE; - errno = save; - } - else if ( wendptr != wnptr + sdp->exp_len ) - { - int save = errno; - - printf("*** wcstoumax(%s,,%d) returned wrong " - "endptr ***\n", sdp->nptr, sdp->base - ); - status = EXIT_FAILURE; - errno = save; - } - - if ( errno != 0 ) - { - printf("*** wcstoumax modified errno ***\n"); - status = EXIT_FAILURE; - } - - for ( i = 0; i < 64; ++i ) - if ( wnptr[i] != sdp->nptr[i] ) - { - printf("*** wcstoumax" - " modified its input ***\n" - ); - status = EXIT_FAILURE; - - for ( ; i < 64; ++i ) - if ( (wnptr[i] = sdp->nptr[i]) - == '\0' - ) - break; - - break; - } - else if ( wnptr[i] == '\0' ) - break; - } - - /* tests for null endptr */ - - warned = 0; - errno = 0; /* shouldn't be changed */ - - if ( (intmax = wcstoimax(wnptr, (wchar_t **)NULL, sdp->base)) - != sdp->exp_val - ) { - int save = errno; - - WARN(); - printf("*** wcstoimax(%s,NULL,%d) failed; should be: %" - PRIdMAX", was: %"PRIdMAX" ***\n", sdp->nptr, - sdp->base, sdp->exp_val, intmax - ); - status = EXIT_FAILURE; - errno = save; - } - - if ( errno != 0 ) - { - WARN(); - printf("*** wcstoimax modified errno ***\n"); - status = EXIT_FAILURE; - } - - for ( i = 0; i < 64; ++i ) - if ( wnptr[i] != sdp->nptr[i] ) - { - WARN(); - printf("*** wcstoimax modified its input ***\n" - ); - status = EXIT_FAILURE; - - for ( ; i < 64; ++i ) - if ( (wnptr[i] = sdp->nptr[i]) - == '\0' - ) - break; - - break; - } - else if ( wnptr[i] == '\0' ) - break; - - if ( sdp->exp_val >= 0 ) /* else some sign extension */ - { - errno = 0; /* shouldn't be changed */ - - if ( (uintmax = wcstoumax(wnptr, (wchar_t **)NULL, - sdp->base - ) - ) != sdp->exp_val - ) { - int save = errno; - - WARN(); - printf("*** wcstoumax(%s,NULL,%d) failed; " - "should be: %"PRIuMAX", was: %"PRIuMAX - " ***\n", sdp->nptr, sdp->base, - sdp->exp_val, uintmax - ); - status = EXIT_FAILURE; - errno = save; - } - - if ( errno != 0 ) - { - WARN(); - printf("*** wcstoumax modified errno ***\n"); - status = EXIT_FAILURE; - } - - for ( i = 0; i < 64; ++i ) - if ( wnptr[i] != sdp->nptr[i] ) - { - WARN(); - printf("*** wcstoumax" - " modified its input ***\n" - ); - status = EXIT_FAILURE; - - for ( ; i < 64; ++i ) - if ( (wnptr[i] = sdp->nptr[i]) - == '\0' - ) - break; - - break; - } - else if ( wnptr[i] == '\0' ) - break; - } - } - - /* - 7.8.2.3 The strtoimax and strtoumax functions (continued) - */ - - if ( (intmax = strtoimax("1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890", - &endptr, 0 - ) - ) != INTMAX_MAX || errno != ERANGE - ) { - printf("*** strtoimax failed overflow test ***\n"); - status = EXIT_FAILURE; - } - - if ( (intmax = strtoimax("+1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890", - &endptr, 0 - ) - ) != INTMAX_MAX || errno != ERANGE - ) { - printf("*** strtoimax failed +overflow test ***\n"); - status = EXIT_FAILURE; - } - - if ( (intmax = strtoimax("-1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890", - &endptr, 0 - ) - ) != INTMAX_MIN || errno != ERANGE - ) { - printf("*** strtoimax failed -overflow test ***\n"); - status = EXIT_FAILURE; - } - - if ( (uintmax = strtoumax("1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890", - &endptr, 0 - ) - ) != UINTMAX_MAX || errno != ERANGE - ) { - printf("*** strtoumax failed overflow test ***\n"); - status = EXIT_FAILURE; - } - - if ( (uintmax = strtoumax("+1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890", - &endptr, 0 - ) - ) != UINTMAX_MAX || errno != ERANGE - ) { - printf("*** strtoumax failed +overflow test ***\n"); - status = EXIT_FAILURE; - } - - if ( (uintmax = strtoumax("-1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890", - &endptr, 0 - ) - ) != UINTMAX_MAX || errno != ERANGE - ) { - printf("*** strtoumax failed -overflow test ***\n"); - status = EXIT_FAILURE; - } - - /* - 7.8.2.4 The wcstoimax and wcstoumax functions (continued) - */ - - if ( (intmax = wcstoimax(L"1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890", - &wendptr, 0 - ) - ) != INTMAX_MAX || errno != ERANGE - ) { - printf("*** wcstoimax failed overflow test ***\n"); - status = EXIT_FAILURE; - } - - if ( (intmax = wcstoimax(L"+1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890", - &wendptr, 0 - ) - ) != INTMAX_MAX || errno != ERANGE - ) { - printf("*** wcstoimax failed +overflow test ***\n"); - status = EXIT_FAILURE; - } - - if ( (intmax = wcstoimax(L"-1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890", - &wendptr, 0 - ) - ) != INTMAX_MIN || errno != ERANGE - ) { - printf("*** wcstoimax failed -overflow test ***\n"); - status = EXIT_FAILURE; - } - - if ( (uintmax = wcstoumax(L"1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890", - &wendptr, 0 - ) - ) != UINTMAX_MAX || errno != ERANGE - ) { - printf("*** wcstoumax failed overflow test ***\n"); - status = EXIT_FAILURE; - } - - if ( (uintmax = wcstoumax(L"+1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890", - &wendptr, 0 - ) - ) != UINTMAX_MAX || errno != ERANGE - ) { - printf("*** wcstoumax failed +overflow test ***\n"); - status = EXIT_FAILURE; - } - - if ( (uintmax = wcstoumax(L"-1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890" - L"1234567890123456789012345678901234567890", - &wendptr, 0 - ) - ) != UINTMAX_MAX || errno != ERANGE - ) { - printf("*** wcstoumax failed -overflow test ***\n"); - status = EXIT_FAILURE; - } - } -#endif /* defined(INTMAX_MAX) */ - - if ( status != 0 ) - fprintf(stderr, "sitest failed; see stdout for details\n"); - - return status; - } diff --git a/src/init/c/util/stdbool.h b/src/init/c/util/stdbool.h deleted file mode 100644 index 178c3b7..0000000 --- a/src/init/c/util/stdbool.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - stdbool.h -- Boolean type and values - - This source code has been placed into the PUBLIC DOMAIN by its author. - - last edit: 1999/11/05 gwyn@arl.mil - - Implements subclause 7.16 of ISO/IEC 9899:1999 (E). -*/ - -#if !defined(_STDBOOL_H) && !defined(_INC_STDBOOL) /* usual lock names */ -#define _STDBOOL_H /* idempotency lock (section 7.1.2) */ -#define _INC_STDBOOL - -/* This header doesn't need C++ extern "C"; there are no declarations here. */ - -/* program is allowed to contain its own definitions, so ... */ -#undef bool -#undef true -#undef false -#undef __bool_true_false_are_defined - -#define bool _Bool -#define true 1 -#define false 0 -#define __bool_true_false_are_defined 1 - -#if __STDC_VERSION__ < 199901 -typedef int _Bool; /* not built into pre-C99 compilers */ -#endif - -#endif /* !defined(_STDBOOL_H) && !defined(_INC_STDBOOL) */ diff --git a/src/init/c/util/stdint.h b/src/init/c/util/stdint.h deleted file mode 100644 index cafa646..0000000 --- a/src/init/c/util/stdint.h +++ /dev/null @@ -1,692 +0,0 @@ -/* - stdint.h -- integer types - - This source code has been placed into the PUBLIC DOMAIN by its author. - - last edit: 1999/11/05 gwyn@arl.mil - - Implements subclause 7.18 of ISO/IEC 9899:1999 (E) + TC1. - - This particular implementation assumes that widths of the standard - integer types are powers of 2, and that there are no extended integer - types with intermediate widths. - - This implementation is SELF-CONFIGURING, based on parameters defined - in . If you plan to include this in a C implementation, - it would be best to trim it down, with all the parameterized decisions - already made. -*/ - -/* This header doesn't need an idempotency lock; there are no typedefs here. */ - -#include /* defines the __Q8_* symbols */ - -/* This header doesn't need C++ extern "C"; there are no declarations here. */ - -/* - 7.18.1.1 Exact-width integer types - - The optional 40-bit type is supported by the TMS320C6xxx DSP. -*/ - -#if __Q8_CW == 8 && defined(__Q8_SC) -typedef __Q8_SC int8_t; -typedef unsigned char uint8_t; -#endif -#if __Q8_CW == 16 && defined(__Q8_SC) -typedef __Q8_SC int16_t; -typedef unsigned char uint16_t; -#elif __Q8_SW == 16 -typedef short int16_t; -typedef unsigned short uint16_t; -#endif -#if __Q8_CW == 32 && defined(__Q8_SC) -typedef __Q8_SC int32_t; -typedef unsigned char uint32_t; -#elif __Q8_SW == 32 -typedef short int32_t; -typedef unsigned short uint32_t; -#elif __Q8_IW == 32 -typedef int int32_t; -typedef unsigned int uint32_t; -#elif __Q8_LW == 32 -typedef long int32_t; -typedef unsigned long uint32_t; -#endif -#if __Q8_CW == 40 && defined(__Q8_SC) -typedef __Q8_SC int40_t; -typedef unsigned char uint40_t; -#elif __Q8_SW == 40 -typedef short int40_t; -typedef unsigned short uint40_t; -#elif __Q8_IW == 40 -typedef int int40_t; -typedef unsigned int uint40_t; -#elif __Q8_LW == 40 -typedef long int40_t; -typedef unsigned long uint40_t; -#endif -#if __Q8_CW == 64 && defined(__Q8_SC) -typedef __Q8_SC int64_t; -typedef unsigned char uint64_t; -#elif __Q8_SW == 64 -typedef short int64_t; -typedef unsigned short uint64_t; -#elif __Q8_IW == 64 -typedef int int64_t; -typedef unsigned int uint64_t; -#elif __Q8_LW == 64 -typedef long int64_t; -typedef unsigned long uint64_t; -#elif __Q8_QW == 64 -typedef __Q8_QT int64_t; -typedef unsigned __Q8_QT uint64_t; -#endif - -/* - 7.18.1.2 Minimum-width integer types - - The optional 40-bit type is supported by the TMS320C6xxx DSP. - - Prefers type int over char or short char, due to a possible - problem constructing suitable integer constants for 7.18.4.1. -*/ - -#if __Q8_CW < __Q8_IW && defined(__Q8_SC) -typedef __Q8_SC int_least8_t; -typedef unsigned char uint_least8_t; -#elif __Q8_SW < __Q8_IW -typedef short int_least8_t; -typedef unsigned short uint_least8_t; -#else -typedef int int_least8_t; -typedef unsigned int uint_least8_t; -#endif -#if __Q8_CW < __Q8_IW && __Q8_CW >= 16 && defined(__Q8_SC) -typedef __Q8_SC int_least16_t; -typedef unsigned char uint_least16_t; -#elif __Q8_SW < __Q8_IW -typedef short int_least16_t; -typedef unsigned short uint_least16_t; -#else -typedef int int_least16_t; -typedef unsigned int uint_least16_t; -#endif -#if __Q8_CW < __Q8_IW && __Q8_CW >= 32 && defined(__Q8_SC) -typedef __Q8_SC int_least32_t; -typedef unsigned char uint_least32_t; -#elif __Q8_SW < __Q8_IW && __Q8_SW >= 32 -typedef short int_least32_t; -typedef unsigned short uint_least32_t; -#elif __Q8_IW >= 32 -typedef int int_least32_t; -typedef unsigned int uint_least32_t; -#else -typedef long int_least32_t; -typedef unsigned long uint_least32_t; -#endif -#if __Q8_CW < __Q8_IW && __Q8_CW >= 40 && defined(__Q8_SC) -typedef __Q8_SC int_least40_t; -typedef unsigned char uint_least40_t; -#elif __Q8_SW < __Q8_IW && __Q8_SW >= 40 -typedef short int_least40_t; -typedef unsigned short uint_least40_t; -#elif __Q8_IW >= 40 -typedef int int_least40_t; -typedef unsigned int uint_least40_t; -#elif __Q8_LW >= 40 -typedef long int_least40_t; -typedef unsigned long uint_least40_t; -#elif __Q8_QW >= 40 /* (will be 0 if not defined) */ -typedef __Q8_QT int_least40_t; -typedef unsigned __Q8_QT uint_least40_t; -#endif -#if __Q8_CW < __Q8_IW && __Q8_CW >= 64 && defined(__Q8_SC) -typedef __Q8_SC int_least64_t; -typedef unsigned char uint_least64_t; -#elif __Q8_SW < __Q8_IW && __Q8_SW >= 64 -typedef short int_least64_t; -typedef unsigned short uint_least64_t; -#elif __Q8_IW >= 64 -typedef int int_least64_t; -typedef unsigned int uint_least64_t; -#elif __Q8_LW >= 64 -typedef long int_least64_t; -typedef unsigned long uint_least64_t; -#elif __Q8_QW >= 64 /* (will be 0 if not defined) */ -typedef __Q8_QT int_least64_t; -typedef unsigned __Q8_QT uint_least64_t; -#endif - -/* - 7.18.1.3 Fastest minimum-width integer types - - The optional 40-bit type is supported by the TMS320C6xxx DSP. - - "Fastest" is hard to determine; if "int" qualifies, it is chosen. -*/ - -typedef int int_fast8_t; -typedef unsigned int uint_fast8_t; -typedef int int_fast16_t; -typedef unsigned int uint_fast16_t; -#if __Q8_IW >= 32 -typedef int int_fast32_t; -typedef unsigned int uint_fast32_t; -#else -typedef long int_fast32_t; -typedef unsigned long uint_fast32_t; -#endif -#if __Q8_IW >= 40 -typedef int int_fast40_t; -typedef unsigned int uint_fast40_t; -#elif __Q8_LW >= 40 -typedef long int_fast40_t; -typedef unsigned long uint_fast40_t; -#elif __Q8_QW >= 40 /* (will be 0 if not defined) */ -typedef __Q8_QT int_fast40_t; -typedef unsigned __Q8_QT uint_fast40_t; -#endif -#if __Q8_IW >= 64 -typedef int int_fast64_t; -typedef unsigned int uint_fast64_t; -#elif __Q8_LW >= 64 -typedef long int_fast64_t; -typedef unsigned long uint_fast64_t; -#elif __Q8_QW >= 64 /* (will be 0 if not defined) */ -typedef __Q8_QT int_fast64_t; -typedef unsigned __Q8_QT uint_fast64_t; -#endif - -/* - 7.18.1.4 Integer types capable of holding object pointers - - Theoretically, these tests might not work (e.g., the implementation - can limit the interconvertible type to one that is not the smallest - possible), but I'm unaware of any platform where they fail. -*/ - -#if defined(__Q8_PW) -#if __Q8_IW >= __Q8_PW -typedef int intptr_t; -typedef unsigned int uintptr_t; -#elif __Q8_LW >= __Q8_PW -typedef long intptr_t; -typedef unsigned long uintptr_t; -#elif __Q8_QW >= __Q8_PW -typedef __Q8_QT intptr_t; -typedef unsigned __Q8_QT uintptr_t; -#elif __Q8_MW >= __Q8_PW -typedef __Q8_MT intptr_t; -typedef unsigned __Q8_MT uintptr_t; -#endif -#endif - -/* - 7.18.1.5 Greatest-width integer types -*/ - -typedef __Q8_MT intmax_t; -typedef unsigned __Q8_MT uintmax_t; - -#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) - -/* - 7.18.2.1 Limits of exact-width integer types - - The optional 40-bit type is supported by the TMS320C6xxx DSP. -*/ - -#if __Q8_CW == 8 && defined(__Q8_SC) -#define INT8_MAX __Q8_TI(__Q8_CW) -#define INT8_MIN __Q8_BI(__Q8_CW) -#define UINT8_MAX __Q8_UI(__Q8_CW) -#endif -#if __Q8_CW == 16 && defined(__Q8_SC) -#define INT16_MAX __Q8_TI(__Q8_CW) -#define INT16_MIN __Q8_BI(__Q8_CW) -#define UINT16_MAX __Q8_UI(__Q8_CW) -#elif __Q8_SW == 16 -#define INT16_MAX __Q8_TI(__Q8_SW) -#define INT16_MIN __Q8_BI(__Q8_SW) -#define UINT16_MAX __Q8_UI(__Q8_SW) -#endif -#if __Q8_CW == 32 && defined(__Q8_SC) -#define INT32_MAX __Q8_TI(__Q8_CW) -#define INT32_MIN __Q8_BI(__Q8_CW) -#define UINT32_MAX __Q8_UI(__Q8_CW) -#elif __Q8_SW == 32 -#define INT32_MAX __Q8_TI(__Q8_SW) -#define INT32_MIN __Q8_BI(__Q8_SW) -#define UINT32_MAX __Q8_UI(__Q8_SW) -#elif __Q8_IW == 32 -#define INT32_MAX __Q8_TI(__Q8_IW) -#define INT32_MIN __Q8_BI(__Q8_IW) -#define UINT32_MAX __Q8_UI(__Q8_IW) -#elif __Q8_LW == 32 -#define INT32_MAX __Q8_TL -#define INT32_MIN __Q8_BL -#define UINT32_MAX __Q8_UL -#endif -#if __Q8_CW == 40 && defined(__Q8_SC) -#define INT40_MAX __Q8_TI(__Q8_CW) -#define INT40_MIN __Q8_BI(__Q8_CW) -#define UINT40_MAX __Q8_UI(__Q8_CW) -#elif __Q8_SW == 40 -#define INT40_MAX __Q8_TI(__Q8_SW) -#define INT40_MIN __Q8_BI(__Q8_SW) -#define UINT40_MAX __Q8_UI(__Q8_SW) -#elif __Q8_IW == 40 -#define INT40_MAX __Q8_TI(__Q8_IW) -#define INT40_MIN __Q8_BI(__Q8_IW) -#define UINT40_MAX __Q8_UI(__Q8_IW) -#elif __Q8_LW == 40 -#define INT40_MAX __Q8_TL -#define INT40_MIN __Q8_BL -#define UINT40_MAX __Q8_UL -#endif -#if __Q8_CW == 64 && defined(__Q8_SC) -#define INT64_MAX __Q8_TI(__Q8_CW) -#define INT64_MIN __Q8_BI(__Q8_CW) -#define UINT64_MAX __Q8_UI(__Q8_CW) -#elif __Q8_SW == 64 -#define INT64_MAX __Q8_TI(__Q8_SW) -#define INT64_MIN __Q8_BI(__Q8_SW) -#define UINT64_MAX __Q8_UI(__Q8_SW) -#elif __Q8_IW == 64 -#define INT64_MAX __Q8_TI(__Q8_IW) -#define INT64_MIN __Q8_BI(__Q8_IW) -#define UINT64_MAX __Q8_UI(__Q8_IW) -#elif __Q8_LW == 64 -#define INT64_MAX __Q8_TL -#define INT64_MIN __Q8_BL -#define UINT64_MAX __Q8_UL -#elif __Q8_QW == 64 -#define INT64_MAX __Q8_TQ -#define INT64_MIN __Q8_BQ -#define UINT64_MAX __Q8_UQ -#endif - -/* - 7.18.2.2 Limits of minimum-width integer types - - The optional 40-bit type is supported by the TMS320C6xxx DSP. -*/ -#if __Q8_CW < __Q8_IW && defined(__Q8_SC) -#define INT_LEAST8_MAX __Q8_TI(__Q8_CW) -#define INT_LEAST8_MIN __Q8_BI(__Q8_CW) -#define UINT_LEAST8_MAX __Q8_UI(__Q8_CW) -#elif __Q8_SW < __Q8_IW -#define INT_LEAST8_MAX __Q8_TI(__Q8_SW) -#define INT_LEAST8_MIN __Q8_BI(__Q8_SW) -#define UINT_LEAST8_MAX __Q8_UI(__Q8_SW) -#else -#define INT_LEAST8_MAX __Q8_TI(__Q8_IW) -#define INT_LEAST8_MIN __Q8_BI(__Q8_IW) -#define UINT_LEAST8_MAX __Q8_UI(__Q8_IW) -#endif -#if __Q8_CW < __Q8_IW && __Q8_CW >= 16 && defined(__Q8_SC) -#define INT_LEAST16_MAX __Q8_TI(__Q8_CW) -#define INT_LEAST16_MIN __Q8_BI(__Q8_CW) -#define UINT_LEAST16_MAX __Q8_UI(__Q8_CW) -#elif __Q8_SW < __Q8_IW -#define INT_LEAST16_MAX __Q8_TI(__Q8_SW) -#define INT_LEAST16_MIN __Q8_BI(__Q8_SW) -#define UINT_LEAST16_MAX __Q8_UI(__Q8_SW) -#else -#define INT_LEAST16_MAX __Q8_TI(__Q8_IW) -#define INT_LEAST16_MIN __Q8_BI(__Q8_IW) -#define UINT_LEAST16_MAX __Q8_UI(__Q8_IW) -#endif -#if __Q8_CW < __Q8_IW && __Q8_CW >= 32 && defined(__Q8_SC) -#define INT_LEAST32_MAX __Q8_TI(__Q8_CW) -#define INT_LEAST32_MIN __Q8_BI(__Q8_CW) -#define UINT_LEAST32_MAX __Q8_UI(__Q8_CW) -#elif __Q8_SW < __Q8_IW && __Q8_SW >= 32 -#define INT_LEAST32_MAX __Q8_TI(__Q8_SW) -#define INT_LEAST32_MIN __Q8_BI(__Q8_SW) -#define UINT_LEAST32_MAX __Q8_UI(__Q8_SW) -#elif __Q8_IW >= 32 -#define INT_LEAST32_MAX __Q8_TI(__Q8_IW) -#define INT_LEAST32_MIN __Q8_BI(__Q8_IW) -#define UINT_LEAST32_MAX __Q8_UI(__Q8_IW) -#else -#define INT_LEAST32_MAX __Q8_TL -#define INT_LEAST32_MIN __Q8_BL -#define UINT_LEAST32_MAX __Q8_UL -#endif -#if __Q8_CW < __Q8_IW && __Q8_CW >= 40 && defined(__Q8_SC) -#define INT_LEAST40_MAX __Q8_TI(__Q8_CW) -#define INT_LEAST40_MIN __Q8_BI(__Q8_CW) -#define UINT_LEAST40_MAX __Q8_UI(__Q8_CW) -#elif __Q8_SW < __Q8_IW && __Q8_SW >= 40 -#define INT_LEAST40_MAX __Q8_TI(__Q8_SW) -#define INT_LEAST40_MIN __Q8_BI(__Q8_SW) -#define UINT_LEAST40_MAX __Q8_UI(__Q8_SW) -#elif __Q8_IW >= 40 -#define INT_LEAST40_MAX __Q8_TI(__Q8_IW) -#define INT_LEAST40_MIN __Q8_BI(__Q8_IW) -#define UINT_LEAST40_MAX __Q8_UI(__Q8_IW) -#elif __Q8_LW >= 40 -#define INT_LEAST40_MAX __Q8_TL -#define INT_LEAST40_MIN __Q8_BL -#define UINT_LEAST40_MAX __Q8_UL -#elif __Q8_QW >= 40 /* (will be 0 if not defined) */ -#define INT_LEAST40_MAX __Q8_TQ -#define INT_LEAST40_MIN __Q8_BQ -#define UINT_LEAST40_MAX __Q8_UQ -#endif -#if __Q8_CW < __Q8_IW && __Q8_CW >= 64 && defined(__Q8_SC) -#define INT_LEAST64_MAX __Q8_TI(__Q8_CW) -#define INT_LEAST64_MIN __Q8_BI(__Q8_CW) -#define UINT_LEAST64_MAX __Q8_UI(__Q8_CW) -#elif __Q8_SW < __Q8_IW && __Q8_SW >= 64 -#define INT_LEAST64_MAX __Q8_TI(__Q8_SW) -#define INT_LEAST64_MIN __Q8_BI(__Q8_SW) -#define UINT_LEAST64_MAX __Q8_UI(__Q8_SW) -#elif __Q8_IW >= 64 -#define INT_LEAST64_MAX __Q8_TI(__Q8_IW) -#define INT_LEAST64_MIN __Q8_BI(__Q8_IW) -#define UINT_LEAST64_MAX __Q8_UI(__Q8_IW) -#elif __Q8_LW >= 64 -#define INT_LEAST64_MAX __Q8_TL -#define INT_LEAST64_MIN __Q8_BL -#define UINT_LEAST64_MAX __Q8_UL -#elif __Q8_QW >= 64 /* (will be 0 if not defined) */ -#define INT_LEAST64_MAX __Q8_TQ -#define INT_LEAST64_MIN __Q8_BQ -#define UINT_LEAST64_MAX __Q8_UQ -#endif - -/* - 7.18.2.3 Limits of fastest minimum-width integer types - - The optional 40-bit type is supported by the TMS320C6xxx DSP. -*/ - -#define INT_FAST8_MAX __Q8_TI(__Q8_IW) -#define INT_FAST8_MIN __Q8_BI(__Q8_IW) -#define UINT_FAST8_MAX __Q8_UI(__Q8_IW) -#define INT_FAST16_MAX __Q8_TI(__Q8_IW) -#define INT_FAST16_MIN __Q8_BI(__Q8_IW) -#define UINT_FAST16_MAX __Q8_UI(__Q8_IW) -#if __Q8_IW >= 32 -#define INT_FAST32_MAX __Q8_TI(__Q8_IW) -#define INT_FAST32_MIN __Q8_BI(__Q8_IW) -#define UINT_FAST32_MAX __Q8_UI(__Q8_IW) -#else -#define INT_FAST32_MAX __Q8_TL -#define INT_FAST32_MIN __Q8_BL -#define UINT_FAST32_MAX __Q8_UL -#endif -#if __Q8_IW >= 40 -#define INT_FAST40_MAX __Q8_TI(__Q8_IW) -#define INT_FAST40_MIN __Q8_BI(__Q8_IW) -#define UINT_FAST40_MAX __Q8_UI(__Q8_IW) -#elif __Q8_LW >= 40 -#define INT_FAST40_MAX __Q8_TL -#define INT_FAST40_MIN __Q8_BL -#define UINT_FAST40_MAX __Q8_UL -#elif __Q8_QW >= 40 /* (will be 0 if not defined) */ -#define INT_FAST40_MAX __Q8_TQ -#define INT_FAST40_MIN __Q8_BQ -#define UINT_FAST40_MAX __Q8_UQ -#endif -#if __Q8_IW >= 64 -#define INT_FAST64_MAX __Q8_TI(__Q8_IW) -#define INT_FAST64_MIN __Q8_BI(__Q8_IW) -#define UINT_FAST64_MAX __Q8_UI(__Q8_IW) -#elif __Q8_LW >= 64 -#define INT_FAST64_MAX __Q8_TL -#define INT_FAST64_MIN __Q8_BL -#define UINT_FAST64_MAX __Q8_UL -#elif __Q8_QW >= 64 /* (will be 0 if not defined) */ -#define INT_FAST64_MAX __Q8_TQ -#define INT_FAST64_MIN __Q8_BQ -#define UINT_FAST64_MAX __Q8_UQ -#endif - -/* - 7.18.2.4 Limits of integer types - capable of holding object pointers -*/ - -#if defined(__Q8_PW) -#if __Q8_IW >= __Q8_PW -#define INTPTR_MAX __Q8_TI(__Q8_IW) -#define INTPTR_MIN __Q8_BI(__Q8_IW) -#define UINTPTR_MAX __Q8_UI(__Q8_IW) -#elif __Q8_LW >= __Q8_PW -#define INTPTR_MAX __Q8_TL -#define INTPTR_MIN __Q8_BL -#define UINTPTR_MAX __Q8_UL -#elif __Q8_QW >= __Q8_PW -#define INTPTR_MAX __Q8_TQ -#define INTPTR_MIN __Q8_BQ -#define UINTPTR_MAX __Q8_UQ -#elif __Q8_MW >= __Q8_PW -#define INTPTR_MAX __Q8_TM -#define INTPTR_MIN __Q8_BM -#define UINTPTR_MAX __Q8_UM -#endif -#endif - -/* - 7.18.2.5 Limits of greatest-width integer types -*/ - -#define INTMAX_MAX __Q8_TM -#define INTMAX_MIN __Q8_BM -#define UINTMAX_MAX __Q8_UM - -/* - 7.18.3 Limits of other integer types - - XXX -- These ought to be moved into along with - the corresponding type definitions. -*/ - -#if __Q8_CW >= __Q8_DW && defined(__Q8_SC) -#define PTRDIFF_MAX __Q8_TI(__Q8_CW) -#define PTRDIFF_MIN __Q8_BI(__Q8_CW) -#elif __Q8_SW >= __Q8_DW -#define PTRDIFF_MAX __Q8_TI(__Q8_SW) -#define PTRDIFF_MIN __Q8_BI(__Q8_SW) -#elif __Q8_IW >= __Q8_DW -#define PTRDIFF_MAX __Q8_TI(__Q8_IW) -#define PTRDIFF_MIN __Q8_BI(__Q8_IW) -#elif __Q8_LW >= __Q8_DW -#define PTRDIFF_MAX __Q8_TL -#define PTRDIFF_MIN __Q8_BL -#elif __Q8_QW >= __Q8_DW -#define PTRDIFF_MAX __Q8_TQ -#define PTRDIFF_MIN __Q8_BQ -#else -#define PTRDIFF_MAX __Q8_TM -#define PTRDIFF_MIN __Q8_BM -#endif - -#ifdef __Q8_AU - -#if __Q8_CW >= __Q8_AW -#define SIG_ATOMIC_MAX __Q8_UI(__Q8_CW) -#elif __Q8_SW >= __Q8_AW -#define SIG_ATOMIC_MAX __Q8_UI(__Q8_SW) -#elif __Q8_IW >= __Q8_AW -#define SIG_ATOMIC_MAX __Q8_UI(__Q8_IW) -#elif __Q8_LW >= __Q8_AW -#define SIG_ATOMIC_MAX __Q8_UL -#elif __Q8_QW >= __Q8_AW -#define SIG_ATOMIC_MAX __Q8_UQ -#else -#define SIG_ATOMIC_MAX __Q8_UM -#endif - -#define SIG_ATOMIC_MIN 0 - -#else /* !defined(__Q8_AU) */ - -#if __Q8_CW >= __Q8_AW && defined(__Q8_SC) -#define SIG_ATOMIC_MAX __Q8_TI(__Q8_CW) -#define SIG_ATOMIC_MIN __Q8_BI(__Q8_CW) -#elif __Q8_SW >= __Q8_AW -#define SIG_ATOMIC_MAX __Q8_TI(__Q8_SW) -#define SIG_ATOMIC_MIN __Q8_BI(__Q8_SW) -#elif __Q8_IW >= __Q8_AW -#define SIG_ATOMIC_MAX __Q8_TI(__Q8_IW) -#define SIG_ATOMIC_MIN __Q8_BI(__Q8_IW) -#elif __Q8_LW >= __Q8_AW -#define SIG_ATOMIC_MAX __Q8_TL -#define SIG_ATOMIC_MIN __Q8_BL -#elif __Q8_QW >= __Q8_AW -#define SIG_ATOMIC_MAX __Q8_TQ -#define SIG_ATOMIC_MIN __Q8_BQ -#else -#define SIG_ATOMIC_MAX __Q8_TM -#define SIG_ATOMIC_MIN __Q8_BM -#endif - -#endif /* defined(__Q8_AU) */ - -#if __Q8_CW >= __Q8_ZW -#define SIZE_MAX __Q8_UI(__Q8_CW) -#elif __Q8_SW >= __Q8_ZW -#define SIZE_MAX __Q8_UI(__Q8_SW) -#elif __Q8_IW >= __Q8_ZW -#define SIZE_MAX __Q8_UI(__Q8_IW) -#elif __Q8_LW >= __Q8_ZW -#define SIZE_MAX __Q8_UL -#elif __Q8_QW >= __Q8_ZW -#define SIZE_MAX __Q8_UQ -#else -#define SIZE_MAX __Q8_UM -#endif - -#ifdef __Q8_WU - -#if __Q8_CW >= __Q8_WW -#define WCHAR_MAX __Q8_UI(__Q8_CW) -#elif __Q8_SW >= __Q8_WW -#define WCHAR_MAX __Q8_UI(__Q8_SW) -#elif __Q8_IW >= __Q8_WW -#define WCHAR_MAX __Q8_UI(__Q8_IW) -#elif __Q8_LW >= __Q8_WW -#define WCHAR_MAX __Q8_UL -#elif __Q8_QW >= __Q8_WW -#define WCHAR_MAX __Q8_UQ -#else -#define WCHAR_MAX __Q8_UM -#endif - -#define WCHAR_MIN 0 - -#else /* !defined(__Q8_WU) */ - -#if __Q8_CW >= __Q8_WW && defined(__Q8_SC) -#define WCHAR_MAX __Q8_TI(__Q8_CW) -#define WCHAR_MIN __Q8_BI(__Q8_CW) -#elif __Q8_SW >= __Q8_WW -#define WCHAR_MAX __Q8_TI(__Q8_SW) -#define WCHAR_MIN __Q8_BI(__Q8_SW) -#elif __Q8_IW >= __Q8_WW -#define WCHAR_MAX __Q8_TI(__Q8_IW) -#define WCHAR_MIN __Q8_BI(__Q8_IW) -#elif __Q8_LW >= __Q8_WW -#define WCHAR_MAX __Q8_TL -#define WCHAR_MIN __Q8_BL -#elif __Q8_QW >= __Q8_WW -#define WCHAR_MAX __Q8_TQ -#define WCHAR_MIN __Q8_BQ -#else -#define WCHAR_MAX __Q8_TM -#define WCHAR_MIN __Q8_BM -#endif - -#endif /* defined(__Q8_WU) */ - -#ifdef __Q8_XU - -#if __Q8_CW >= __Q8_XW -#define WINT_MAX __Q8_UI(__Q8_CW) -#elif __Q8_SW >= __Q8_XW -#define WINT_MAX __Q8_UI(__Q8_SW) -#elif __Q8_IW >= __Q8_XW -#define WINT_MAX __Q8_UI(__Q8_IW) -#elif __Q8_LW >= __Q8_XW -#define WINT_MAX __Q8_UL -#elif __Q8_QW >= __Q8_XW -#define WINT_MAX __Q8_UQ -#else -#define WINT_MAX __Q8_UM -#endif - -#define WINT_MIN 0 - -#else /* !defined(__Q8_XU) */ - -#if __Q8_CW >= __Q8_XW && defined(__Q8_SC) -#define WINT_MAX __Q8_TI(__Q8_CW) -#define WINT_MIN __Q8_BI(__Q8_CW) -#elif __Q8_SW >= __Q8_XW -#define WINT_MAX __Q8_TI(__Q8_SW) -#define WINT_MIN __Q8_BI(__Q8_SW) -#elif __Q8_IW >= __Q8_XW -#define WINT_MAX __Q8_TI(__Q8_IW) -#define WINT_MIN __Q8_BI(__Q8_IW) -#elif __Q8_LW >= __Q8_XW -#define WINT_MAX __Q8_TL -#define WINT_MIN __Q8_BL -#elif __Q8_QW >= __Q8_XW -#define WINT_MAX __Q8_TQ -#define WINT_MIN __Q8_BQ -#else -#define WINT_MAX __Q8_TM -#define WINT_MIN __Q8_BM -#endif - -#endif /* defined(__Q8_XU) */ - -#endif /* !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) */ - -#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) - -/* - 7.18.4.1 Macros for minimum-width integer constants - - The optional 40-bit type is supported by the TMS320C6xxx DSP. - - This spec was changed in ISO/IEC 9899:1999 TC1; in ISO/IEC - 9899:1999 as initially published, the expansion was required - to be an integer constant of precisely matching type, which - is impossible to accomplish for the shorter types on most - platforms, because C99 provides no standard way to designate - an integer constant with width less than that of type int. - TC1 changed this to require just an integer constant - *expression* with *promoted* type. - - The trick used to get the right type is due to Clive Feather. -*/ - -#define INT8_C(c) (INT_LEAST8_MAX-INT_LEAST8_MAX+(c)) -#define UINT8_C(c) (UINT_LEAST8_MAX-UINT_LEAST8_MAX+(c)) -#define INT16_C(c) (INT_LEAST16_MAX-INT_LEAST16_MAX+(c)) -#define UINT16_C(c) (UINT_LEAST16_MAX-UINT_LEAST16_MAX+(c)) -#define INT32_C(c) (INT_LEAST32_MAX-INT_LEAST32_MAX+(c)) -#define UINT32_C(c) (UINT_LEAST32_MAX-UINT_LEAST32_MAX+(c)) -#ifdef INT_LEAST40_MAX -#define INT40_C(c) (INT_LEAST40_MAX-INT_LEAST40_MAX+(c)) -#define UINT40_C(c) (UINT_LEAST40_MAX-UINT_LEAST40_MAX+(c)) -#endif -#ifdef INT_LEAST64_MAX -#define INT64_C(c) (INT_LEAST64_MAX-INT_LEAST64_MAX+(c)) -#define UINT64_C(c) (UINT_LEAST64_MAX-UINT_LEAST64_MAX+(c)) -#endif - -/* - 7.18.4.2 Macros for greatest-width integer constants -*/ - -#define INTMAX_C(c) (INTMAX_MAX-INTMAX_MAX+(c)) -#define UINTMAX_C(c) (UINTMAX_MAX-UINTMAX_MAX+(c)) - -#endif /* !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) */ diff --git a/src/init/c/util/wchar.c b/src/init/c/util/wchar.c deleted file mode 100644 index 95ed1d5..0000000 --- a/src/init/c/util/wchar.c +++ /dev/null @@ -1,1140 +0,0 @@ -/* - wchar -- extended multibyte and wide character utilities - - This source code has been placed into the PUBLIC DOMAIN by its author. - - last edit: 1999/11/05 gwyn@arl.mil - - Implements subclause 7.24 of ISO/IEC 9899:1999 (E). - - This is a minimal implementation for environments where - internationalization is not considered important. - - It supports an encoding where all char codes are mapped - to the *same* code values within a wchar_t or wint_t, - so long as no other wchar_t codes are used by the program. - - This implementation is already compatible with Clive - Feather's proposed changes detailed in WG14/N898 (DR#212). - - XXX -- UNTESTED -- XXX -*/ - -#include -#include -#include -#include -#include -#ifdef __STDC__ -#include -#else -#include -#endif - -#include /* defines several __Q8_* symbols */ -#include -#include - -#ifndef EILSEQ -#define EILSEQ ERANGE -#endif - -#ifndef MB_CUR_MAX -#define MB_CUR_MAX 1 -#endif - -/* helper functions: */ - -static char x_format[BUFSIZ]; -static char x_s[BUFSIZ]; - -static bool -shrink(src, dst) - register __Q8_CONST wchar_t * __Q8_RESTRICT src; - register char * __Q8_RESTRICT dst; - { - register int i; - - for ( i = 0; i < BUFSIZ; ++i ) - if ( (dst[i] = src[i]) == 0 ) - return true; - - errno = EDOM; - return false; /* doesn't fit into buffer */ - } - -static bool -expand(src, dst) - register __Q8_CONST char * __Q8_RESTRICT src; - register wchar_t * __Q8_RESTRICT dst; - { - register int i; - - for ( i = 0; i < BUFSIZ; ++i ) - if ( (dst[i] = src[i]) == 0 ) - return true; - - errno = EDOM; - return false; /* doesn't fit into buffer */ - } - -/* - 7.24.2 Formatted wide character input/output functions -*/ - -/* VARARGS */ -int -fwprintf(__Q8_T(__Q8_FILE * __Q8_RESTRICT stream) - __Q8_T(__Q8_CONST wchar_t * __Q8_RESTRICT format) - __Q8_AList - ) - __Q8_Dcl - { - __Q8_D(__Q8_FILE *stream) - __Q8_D(wchar_t *format) - __Q8_List( ap) - int ret; /* saved return value */ - - __Q8_Start(ap, format) - __Q8_I(ap, __Q8_FILE *, stream) - __Q8_I(ap, wchar_t *, format) - - ret = vfwprintf(stream, format, ap); - - __Q8_End( ap ) - return ret; - } - -/* VARARGS */ -int -fwscanf(__Q8_T(__Q8_FILE * __Q8_RESTRICT stream) - __Q8_T(__Q8_CONST wchar_t * __Q8_RESTRICT format) - __Q8_AList - )__Q8_Dcl - { - __Q8_D(__Q8_FILE *stream) - __Q8_D(wchar_t *format) - __Q8_List( ap) - int ret; /* saved return value */ - - __Q8_Start(ap, format) - __Q8_I(ap, __Q8_FILE *, stream) - __Q8_I(ap, wchar_t *, format) - - ret = vfwscanf(stream, format, ap); - - __Q8_End( ap ) - return ret; - } - -/* VARARGS */ -int -swprintf(__Q8_T(wchar_t * __Q8_RESTRICT s) - __Q8_T(size_t n) - __Q8_T(__Q8_CONST wchar_t * __Q8_RESTRICT format) - __Q8_AList - ) - __Q8_Dcl - { - __Q8_D(wchar_t *s) - __Q8_D(size_t n) - __Q8_D(wchar_t *format) - __Q8_List( ap) - int ret; /* saved return value */ - - __Q8_Start(ap, format) - __Q8_I(ap, wchar_t *, s) - __Q8_I(ap, size_t, n) - __Q8_I(ap, wchar_t *, format) - - ret = vswprintf(s, n, format, ap); - - __Q8_End( ap ) - return ret; - } - -/* VARARGS */ -int -swscanf(__Q8_T(__Q8_CONST wchar_t * __Q8_RESTRICT s) - __Q8_T(__Q8_CONST wchar_t * __Q8_RESTRICT format) - __Q8_AList - )__Q8_Dcl - { - __Q8_D(__Q8_CONST wchar_t *s) - __Q8_D(wchar_t *format) - __Q8_List( ap) - int ret; /* saved return value */ - - __Q8_Start(ap, format) - __Q8_I(ap, wchar_t *, s) - __Q8_I(ap, wchar_t *, format) - - ret = vswscanf(s, format, ap); - - __Q8_End( ap ) - return ret; - } - -int -vfwprintf(stream, format, arg) - __Q8_FILE * __Q8_RESTRICT stream; - __Q8_CONST wchar_t * __Q8_RESTRICT format; - va_list arg; - { - if ( ! shrink(format, x_format) ) - return -1; - - return vfprintf(stream, x_format, arg); - } - -int -vfwscanf(stream, format, arg) - __Q8_FILE * __Q8_RESTRICT stream; - __Q8_CONST wchar_t * __Q8_RESTRICT format; - va_list arg; - { - if ( ! shrink(format, x_format) ) - return -1; - - return vfscanf(stream, x_format, arg); - } - -int -vswprintf(s, n, format, arg) - wchar_t * __Q8_RESTRICT s; - size_t n; - __Q8_CONST wchar_t * __Q8_RESTRICT format; - va_list arg; - { - int ret; /* saved return value */ - - if ( n > sizeof x_s ) /* too dangerous to proceed */ - { - errno = EDOM; - return -1; - } - - if ( ! shrink(format, x_format) ) - return -1; - - ret = vsnprintf(x_s, n, x_format, arg); - - if ( ! expand(x_s, s) ) - return -1; - - return ret; - } - -int -vswscanf(s, format, arg) - __Q8_CONST wchar_t * __Q8_RESTRICT s; - __Q8_CONST wchar_t * __Q8_RESTRICT format; - va_list arg; - { - int ret; /* saved return value */ - - if ( ! shrink(format, x_format) ) - return -1; - - ret = vsscanf(x_s, x_format, arg); - - if ( ! expand(x_s, s) ) /* Risky Business */ - return -1; - - return ret; - } - -int -vwprintf(format, arg) - __Q8_CONST wchar_t * __Q8_RESTRICT format; - va_list arg; - { - return vfwprintf(stdout, format, arg); - } - -int -vwscanf(format, arg) - __Q8_CONST wchar_t * __Q8_RESTRICT format; - va_list arg; - { - return vfwscanf(stdin, format, arg); - } - -/* VARARGS */ -int -wprintf(__Q8_T(__Q8_CONST wchar_t * __Q8_RESTRICT format) - __Q8_AList - )__Q8_Dcl - { - __Q8_D(wchar_t *format) - __Q8_List( ap) - int ret; /* saved return value */ - - __Q8_Start(ap, format) - __Q8_I(ap, wchar_t *, format) - - ret = vwprintf(format, ap); - - __Q8_End( ap ) - return ret; - } - -/* VARARGS */ -int -wscanf(__Q8_T(__Q8_CONST wchar_t * __Q8_RESTRICT format) - __Q8_AList - ) __Q8_Dcl - { - __Q8_D(wchar_t *format) - __Q8_List( ap) - int ret; /* saved return value */ - - __Q8_Start(ap, format) - __Q8_I(ap, wchar_t *, format) - - ret = vwscanf(format, ap); - - __Q8_End( ap ) - return ret; - } - -/* - 7.24.3 Wide character input/output functions -*/ - -wint_t -fgetwc(stream) - __Q8_FILE *stream; - { - int ret; /* saved return value */ - - ret = getc(stream); /* faster than fgetc */ - return ret == EOF ? WEOF : ret; /* EOF, WEOF values may differ */ - } - -wchar_t * -fgetws(s, n, stream) - wchar_t * __Q8_RESTRICT s; - int n; - __Q8_FILE * __Q8_RESTRICT stream; - { - char *ret; /* saved return value */ - - if ( n > sizeof x_s ) /* too dangerous to proceed */ - { - errno = EDOM; - return NULL; - } - - ret = fgets(x_s, n, stream); - - if ( ! expand(x_s, s) ) - return NULL; - - return ret == x_s ? s : NULL; - } - -wint_t -fputwc(c, stream) - wchar_t c; - __Q8_FILE *stream; - { - int ret; /* saved return value */ - - ret = putc(c, stream); /* faster than fputc */ - return ret == EOF ? WEOF : ret; /* EOF, WEOF values may differ */ - } - -int -fputws(s, stream) - wchar_t * __Q8_RESTRICT s; - __Q8_FILE * __Q8_RESTRICT stream; - { - int ret; /* saved return value */ - - if ( ! shrink(s, x_s) ) - return -1; - - return fputs(x_s, stream); - } - -/*ARGSUSED*/ -int -fwide(stream, mode) - __Q8_FILE *stream; - int mode; - { - return -1; /* limited to byte orientation */ - } - -wint_t -getwc(stream) - __Q8_FILE *stream; - { - int ret; /* saved return value */ - - ret = getc(stream); /* faster than fgetc */ - return ret == EOF ? WEOF : ret; /* EOF, WEOF values may differ */ - } - -wint_t -getwchar() - { - int ret; /* saved return value */ - - ret = getchar(); /* faster than fgetchar */ - return ret == EOF ? WEOF : ret; /* EOF, WEOF values may differ */ - } - -wint_t -putwc(c, stream) - wchar_t c; - __Q8_FILE *stream; - { - int ret; /* saved return value */ - - ret = putc(c, stream); /* faster than fputc */ - return ret == EOF ? WEOF : ret; /* EOF, WEOF values may differ */ - } - -wint_t -putwchar(c) - wchar_t c; - { - int ret; /* saved return value */ - - ret = putchar(c); /* faster than fputchar */ - return ret == EOF ? WEOF : ret; /* EOF, WEOF values may differ */ - } - -wint_t -ungetwc(c, stream) - wchar_t c; - __Q8_FILE *stream; - { - int ret; /* saved return value */ - - ret = ungetc(c, stream); - return ret == EOF ? WEOF : ret; /* EOF, WEOF values may differ */ - } - -/* - 7.24.4 General wide string utilities -*/ - -double -wcstod(nptr, endptr) - __Q8_CONST wchar_t * __Q8_RESTRICT nptr; - wchar_t ** __Q8_RESTRICT endptr; - { - double ret; /* saved return value */ - char *x_end; - - if ( ! shrink(nptr, x_s) ) - return 0.0; - - ret = strtod(x_s, &x_end); - *endptr = (wchar_t *)nptr + (x_end - x_s); - return ret; - } - -float -wcstof(nptr, endptr) - __Q8_CONST wchar_t * __Q8_RESTRICT nptr; - wchar_t ** __Q8_RESTRICT endptr; - { - float ret; /* saved return value */ - char *x_end; - - if ( ! shrink(nptr, x_s) ) - return 0.0; - - ret = strtof(x_s, &x_end); - *endptr = (wchar_t *)nptr + (x_end - x_s); - return ret; - } - -#if !defined(__Q8_GT) -__Q8_GT -wcstold(nptr, endptr) - __Q8_CONST wchar_t * __Q8_RESTRICT nptr; - wchar_t ** __Q8_RESTRICT endptr; - { - __Q8_GT ret; /* saved return value */ - char *x_end; - - if ( ! shrink(nptr, x_s) ) - return 0.0; - - ret = strtold(x_s, &x_end); - *endptr = (wchar_t *)nptr + (x_end - x_s); - return ret; - } -#endif /* !defined(__Q8_GT) */ - -long -wcstol(nptr, endptr, base) - __Q8_CONST wchar_t * __Q8_RESTRICT nptr; - wchar_t ** __Q8_RESTRICT endptr; - int base; - { - long ret; /* saved return value */ - char *x_end; - - if ( ! shrink(nptr, x_s) ) - return 0; - - ret = strtol(x_s, &x_end, base); - *endptr = (wchar_t *)nptr + (x_end - x_s); - return ret; - } - -unsigned long -wcstoul(nptr, endptr, base) - __Q8_CONST wchar_t * __Q8_RESTRICT nptr; - wchar_t ** __Q8_RESTRICT endptr; - int base; - { - unsigned long ret; /* saved return value */ - char *x_end; - - if ( ! shrink(nptr, x_s) ) - return 0; - - ret = strtoul(x_s, &x_end, base); - *endptr = (wchar_t *)nptr + (x_end - x_s); - return ret; - } - -#if !defined(__Q8_QT) -__Q8_QT -wcstoll(nptr, endptr, base) - __Q8_CONST wchar_t * __Q8_RESTRICT nptr; - wchar_t ** __Q8_RESTRICT endptr; - int base; - { - __Q8_QT ret; /* saved return value */ - char *x_end; - - if ( ! shrink(nptr, x_s) ) - return 0; - - ret = strtoll(x_s, &x_end, base); - *endptr = (wchar_t *)nptr + (x_end - x_s); - return ret; - } - -unsigned __Q8_QT -wcstoull(nptr, endptr, base) - __Q8_CONST wchar_t * __Q8_RESTRICT nptr; - wchar_t ** __Q8_RESTRICT endptr; - int base; - { - unsigned __Q8_QT ret; /* saved return value */ - char *x_end; - - if ( ! shrink(nptr, x_s) ) - return 0; - - ret = strtoull(x_s, &x_end, base); - *endptr = (wchar_t *)nptr + (x_end - x_s); - return ret; - } -#endif /* !defined(__Q8_QT) */ - -/* The following don't map via shrink/expand because that's much too slow. */ - -wchar_t * -wcscpy(s1, s2) - register wchar_t * __Q8_RESTRICT s1; - register __Q8_CONST wchar_t * __Q8_RESTRICT s2; - { - wchar_t *orig_s1 = s1; - - if ( s1 == NULL || s2 == NULL ) - return orig_s1; /* robust */ - - while ( (*s1++ = *s2++) != 0 ) - ; - - return orig_s1; - } - -wchar_t * -wcsncpy(s1, s2, n) - register wchar_t * __Q8_RESTRICT s1; - register __Q8_CONST wchar_t * __Q8_RESTRICT s2; - register size_t n; - { - wchar_t *orig_s1 = s1; - - if ( s1 == NULL || s2 == NULL || n == 0 ) - return orig_s1; /* robust */ - - for ( ; n > 0; --n ) - if ( (*s1++ = *s2++) == 0 ) - { - --n; /* not really necessary */ - break; - } - - for ( ; n > 0; --n ) - *s1++ = 0; - - return orig_s1; - } - -wchar_t * -wmemcpy(s1, s2, n) - register wchar_t * __Q8_RESTRICT s1; - register __Q8_CONST wchar_t * __Q8_RESTRICT s2; - register size_t n; - { - wchar_t *orig_s1 = s1; - - if ( s1 == NULL || s2 == NULL || n == 0 ) - return orig_s1; /* robust */ - - for ( ; n > 0; --n ) - *s1++ = *s2++; - - return orig_s1; - } - -wchar_t * -wmemmove(s1, s2, n) - register wchar_t *s1; - register __Q8_CONST wchar_t *s2; - register size_t n; - { - wchar_t *orig_s1 = s1; - - if ( s1 == NULL || s2 == NULL || n == 0 ) - return orig_s1; /* robust */ - - /* XXX -- The following test works only within a flat address space! */ - if ( s2 >= s1 ) - for ( ; n > 0; --n ) - *s1++ = *s2++; - else { - s1 += n; - s2 += n; - - for ( ; n > 0; --n ) - *--s1 = *--s2; - } - - return orig_s1; - } - -wchar_t * -wcscat(s1, s2) - register wchar_t * __Q8_RESTRICT s1; - register __Q8_CONST wchar_t * __Q8_RESTRICT s2; - { - wchar_t *orig_s1 = s1; - - if ( s1 == NULL || s2 == NULL ) - return orig_s1; - - while ( *s1 != 0 ) - ++s1; - - while ( (*s1++ = *s2++) != 0 ) - ; - - return orig_s1; - } - -wchar_t * -wcsncat(s1, s2, n) - register wchar_t * __Q8_RESTRICT s1; - register __Q8_CONST wchar_t * __Q8_RESTRICT s2; - register size_t n; - { - wchar_t *orig_s1 = s1; - - if ( s1 == NULL || s2 == NULL || n == 0 ) - return orig_s1; /* robust */ - - while ( *s1 != 0 ) - ++s1; - - for ( ; n > 0; --n ) - if ( (*s1++ = *s2++) == 0 ) - return orig_s1; - - *s1 = 0; /* if orig. n == 0, this is redundant */ - return orig_s1; - } - -int -wcscmp(s1, s2) - register __Q8_CONST wchar_t *s1; - register __Q8_CONST wchar_t *s2; - { - if ( s1 == s2 ) - return 0; /* even for NULL pointers */ - - if ( (s1 != NULL) != (s2 != NULL) ) - return s2 == NULL ? 1 : -1; /* robust */ - - for ( ; *s1 == *s2; ++s1, ++s2 ) - if ( *s1 == 0 ) - return 0; - - return *s1 - *s2; - } - -int -wcscoll(s1, s2) - register __Q8_CONST wchar_t *s1; - register __Q8_CONST wchar_t *s2; - { - return wcscmp(s1, s2); - } - -int -wcsncmp(s1, s2, n) - register __Q8_CONST wchar_t *s1; - register __Q8_CONST wchar_t *s2; - size_t n; - { - if ( n == 0 || s1 == s2 ) - return 0; /* even for NULL pointers */ - - if ( (s1 != NULL) != (s2 != NULL) ) - return s2 == NULL ? 1 : -1; /* robust */ - - for ( ; n > 0; ++s1, ++s2, --n ) - if ( *s1 != *s2 ) - return *s1 - *s2; - else if ( *s1 == 0 ) - return 0; - - return 0; - } - -size_t -wcsxfrm(s1, s2, n) - register wchar_t * __Q8_RESTRICT s1; - register __Q8_CONST wchar_t * __Q8_RESTRICT s2; - register size_t n; - { - if ( s1 == NULL || s2 == NULL || n == 0 ) - { - if ( s1 != NULL ) - *s1 = 0; - - return 0; /* robust */ - } - - wcsncpy(s1, s2, n); - return wcslen(s1); /* not very efficient */ - } - -int -wmemcmp(s1, s2, n) - register __Q8_CONST wchar_t *s1; - register __Q8_CONST wchar_t *s2; - size_t n; - { - if ( n == 0 || s1 == s2 ) - return 0; /* even for NULL pointers */ - - if ( (s1 != NULL) != (s2 != NULL) ) - return s2 == NULL ? 1 : -1; /* robust */ - - for ( ; n > 0; ++s1, ++s2, --n ) - if ( *s1 != *s2 ) - return *s1 - *s2; - - return 0; - } - -wchar_t * -wcschr(s, c) - __Q8_CONST wchar_t *s; - wchar_t c; - { - if ( s != NULL ) - for ( ; *s != c; ++s ) - if ( *s == 0 ) - return NULL; - - return (wchar_t *)s; - } - -size_t -wcscspn(s1, s2) - __Q8_CONST wchar_t *s1; - __Q8_CONST wchar_t *s2; - { - register __Q8_CONST wchar_t *s1p; - register __Q8_CONST wchar_t *s2p; - - if ( s1 == NULL || s2 == NULL ) - return wcslen(s1); /* robust */ - - for ( s1p = s1; *s1p != 0 ; ++s1p ) - for ( s2p = s2; *s2p != 0; ++s2p ) - if ( *s2p == *s1p ) - return s1p - s1; - - return s1p - s1; - } - -wchar_t * -wcspbrk(s1, s2) - register __Q8_CONST wchar_t *s1; - __Q8_CONST wchar_t *s2; - { - register __Q8_CONST wchar_t *s2p; - - if ( s1 == NULL || s2 == NULL ) - return NULL; /* robust */ - - for ( ; *s1 != 0 ; ++s1 ) - for ( s2p = s2; *s2p != 0; ++s2p ) - if ( *s2p == *s1 ) - return (wchar_t *)s1; - - return NULL; - } - -wchar_t * -wcsrchr(s, c) - register __Q8_CONST wchar_t *s; - register wchar_t c; - { - register __Q8_CONST wchar_t *ret = NULL; - - if ( s != NULL ) - /* do-while is necessary to handle the case c==0 */ - do - if ( *s == c ) - ret = s; - while ( *s++ != 0 ); - - return (wchar_t *)ret; - } - -size_t -wcsspn(s1, s2) - __Q8_CONST wchar_t *s1; - __Q8_CONST wchar_t *s2; - { - register __Q8_CONST wchar_t *s1p; - register __Q8_CONST wchar_t *s2p; - - if ( s1 == NULL || s2 == NULL ) - return 0; /* robust */ - - for ( s1p = s1; *s1p != 0 ; ++s1p ) - for ( s2p = s2; *s2p != *s1p; ++s2p ) - if ( *s2p == 0 ) - return s1p - s1; - - return s1p - s1; - } - -/* - My usual strstr() (based on Sunday's variation of Boyer-Moore) - unfortunately requires an inordinately large shift table for - wide characters. In order not to trip you up should that - occasion arise, I substituted a fine-tuned brute-force search. - It's still much faster than most implementations one encounters. -*/ - -wchar_t * -wcsstr(s1, s2) - register __Q8_CONST wchar_t *s1; - __Q8_CONST wchar_t *s2; - { - register __Q8_CONST wchar_t *t; - register __Q8_CONST wchar_t *s2p = s2; - - if ( s2p == NULL || *s2p == 0 || s1 == NULL ) - return (wchar_t *)s1; /* robust special cases */ - - for ( ; *s1 != 0; ++s1 ) - { - if ( *s2p == *s1 ) /* quick initial-match test */ - { - /* Although it is tempting, we cannot omit the test - for 0 in the loop, because the match may occur - at the very end of s1[], in which case we'd keep - on going past the end of both arrays. - */ - for ( t = s1; *++s2p == *++t; ) - if ( *s2p == 0 ) /* match at end */ - return (wchar_t *)s1; - - if ( *s2p == 0 ) - return (wchar_t *)s1; /* match elsewhere */ - - s2p = s2; /* reset pattern for next iteration */ - } - } - - return NULL; /* no match (and s2 isn't empty) */ - } - -wchar_t * -wcstok(s1, s2, ptr) - register wchar_t * __Q8_RESTRICT s1; - __Q8_CONST wchar_t * __Q8_RESTRICT s2; - wchar_t ** __Q8_RESTRICT ptr; - { - register wchar_t *etok; - - if ( s1 != NULL ) - *ptr = s1; /* save for later continued use */ - else if ( (s1 = *ptr) == NULL ) /* try to continue scan */ - return NULL; /* no more tokens */ - - s1 += wcsspn(s1, s2); /* skip over separators */ - - if ( *s1 == 0 ) - return NULL; /* no more tokens; preserve ptr */ - - /* valid token starts at current s1 */ - - if ( (etok = wcspbrk(s1, s2)) == NULL ) /* find end of token */ - *ptr = NULL; /* this is the last token */ - else { - *etok = 0; /* terminate token wide string */ - *ptr = etok + 1; /* next time start just past token */ - } - - return s1; /* start of valid token */ - } - -wchar_t * -wmemchr(s, c, n) - register __Q8_CONST wchar_t *s; - register wchar_t c; - register size_t n; - { - if ( s != NULL ) - for ( ; n > 0; ++s, --n ) - if ( *s == c ) - return (wchar_t *)s; - - return NULL; - } - -size_t -wcslen(s) - register __Q8_CONST wchar_t *s; - { - __Q8_CONST wchar_t *orig_s = s; - - if ( s == NULL ) - return 0; - - while ( *s != 0 ) - ++s; - - return s - orig_s; - } - -wchar_t * -wmemset(s, c, n) - register wchar_t *s; - register wchar_t c; - register size_t n; - { - wchar_t *orig_s = s; - - if ( s != NULL ) - for ( ; n > 0; --n ) - *s++ = c; - - return orig_s; - } - -/* - 7.24.5 Wide character time conversion functions -*/ - -size_t -wcsftime(s, maxsize, format, timeptr) - wchar_t * __Q8_RESTRICT s; - size_t maxsize; - __Q8_CONST wchar_t * __Q8_RESTRICT format; - __Q8_CONST struct tm * __Q8_RESTRICT timeptr; - { - int ret; /* saved return value */ - - if ( maxsize > sizeof x_s ) /* too dangerous to proceed */ - { - errno = EDOM; - return 0; - } - - if ( ! shrink(format, x_format) ) - return 0; - - ret = strftime(x_s, maxsize, x_format, timeptr); - - if ( ! expand(x_s, s) ) - return 0; - - return ret; - } - -/* - 7.24.6 Extended multibyte/wide character conversion utilities - - In this *minimal implementation*, all single-byte values are valid, - except possibly for EOF on platforms where sizeof(char)==sizeof(int). -*/ - -wint_t -btowc(c) - int c; - { - if ( c == EOF || (unsigned char)c != (unsigned int)c ) /* knothole */ - return WEOF; - else - return (wint_t)(unsigned char)c; - } - -int -wctob(c) - wint_t c; - { /* knothole: */ - if ( c == WEOF || (unsigned char)c != (unsigned __Q8_MT)c ) - return EOF; - else - return (int)(unsigned char)c; - } - -int -mbsinit(ps) - __Q8_CONST mbstate_t *ps; - { - return 1; /* don't have shift states */ - } - -size_t -mbrlen(s, n, ps) - __Q8_CONST char * __Q8_RESTRICT s; - size_t n; - mbstate_t * __Q8_RESTRICT ps; - { - return mbrtowc((wchar_t *)NULL, s, n, ps); /* ps ignored */ - } - -size_t -mbrtowc(pwc, s, n, ps) - wchar_t * __Q8_RESTRICT pwc; - __Q8_CONST char * __Q8_RESTRICT s; - size_t n; - mbstate_t * __Q8_RESTRICT ps; /* ignored */ - { - if ( s == NULL ) - { - pwc = NULL; - s = (__Q8_CONST char *)""; - n = 1; - } - - if ( n == 0 ) - return (size_t)-2; - - if ( pwc != NULL ) - *pwc = (wchar_t)(unsigned char)*s; - - return *s == 0 ? 0 : 1; - } - -size_t -wcrtomb(s, wc, ps) - char * __Q8_RESTRICT s; - wchar_t wc; - mbstate_t * __Q8_RESTRICT ps; /* ignored */ - { - register int c; - char dummy; - - if ( s == NULL ) - { - s = &dummy; - wc = 0; - } - - if ( (c = wctob(wc)) == EOF ) - { - errno = EILSEQ; - return (size_t)-1; - } - - *(unsigned char *)s = (unsigned char)c; - return 1; - } - -size_t -mbsrtowcs(dst, src, len, ps) - wchar_t * __Q8_RESTRICT dst; - __Q8_CONST char ** __Q8_RESTRICT src; - size_t len; - mbstate_t * __Q8_RESTRICT ps; - { - register size_t ret; /* from mbrtowc */ - register size_t n = 0; /* # converted */ - - if ( src == NULL || *src == NULL ) /* undefined behavior */ - return 0; - - while ( n < len - && (ret = mbrtowc(dst, *src, dst == NULL ? MB_CUR_MAX : len - n, ps - ) /* ps ignored */ - ) != 0 - && ret != (size_t)-2 && ret != (size_t)-1 - ) { - ++dst; - - if ( *src != NULL ) - *src += ret; - - n += ret; - } - - if ( dst != NULL && n < len && ret == 0 ) - *src = (char *)NULL; - - return n; - } - -size_t -wcsrtombs(dst, src, len, ps) - char * __Q8_RESTRICT dst; - __Q8_CONST wchar_t ** __Q8_RESTRICT src; - size_t len; - mbstate_t * __Q8_RESTRICT ps; - { - register size_t ret; /* from mbrtowc */ - register size_t n = 0; /* # converted */ - - if ( src == NULL || *src == NULL ) /* undefined behavior */ - return 0; - - while ( n < len - && (ret = wcrtomb(dst, **src, ps)) != 0 /* ps ignored */ - && ret != (size_t)-2 && ret != (size_t)-1 - ) { - ++dst; - - if ( *src != NULL ) - *src += ret; - - n += ret; - } - - if ( dst != NULL && n < len && ret == 0 ) - *src = (wchar_t *)NULL; - - return n; - } diff --git a/src/init/c/util/wchar.h b/src/init/c/util/wchar.h deleted file mode 100644 index 629f1ac..0000000 --- a/src/init/c/util/wchar.h +++ /dev/null @@ -1,227 +0,0 @@ -/* - wchar.h -- extended multibyte and wide character utilities - - This source code has been placed into the PUBLIC DOMAIN by its author. - - last edit: 1999/08/20 gwyn@arl.mil - - Implements subclause 7.24 of ISO/IEC 9899:1999 (E). - - Unfortunately, it is NOT QUITE CONFORMING, because it #includes - to obtain the definitions for wchar_t and size_t, - for WCHAR_MIN and WCHAR_MAX, for FILE, and - for struct tm. If you plan to include this header in - a conforming C implementation, you must fix this. (FILE should - *not* be defined by this header, although it is needed in the - declarations!) -*/ - -#if !defined(_WCHAR_H) && !defined(_INC_WCHAR) /* usual lock names */ -#define _WCHAR_H /* idempotency lock (section 7.1.2) */ -#define _INC_WCHAR - -#include /* XXX -- for wchar_t and size_t */ -#include /* XXX -- for FILE (def of __Q8_FILE) */ -#include /* XXX -- for struct tm */ - -#include /* defines the __Q8_* symbols */ -#include /* XXX -- for WCHAR_MIN and WCHAR_MAX */ - -#ifdef __cplusplus -extern "C" { -#endif - -/* - 7.24.1 Introduction -*/ - -#ifndef __Q8_MBSTATE_T_DEFINED -#define __Q8_MBSTATE_T_DEFINED /* idempotency lock */ -typedef __Q8_MBSTATE_T mbstate_t; -#endif -#ifndef __Q8_SIZE_T_DEFINED -#define __Q8_SIZE_T_DEFINED /* idempotency lock */ -/* typedef __Q8_SIZE_T size_t; /* XXX -- conflicts with native hdrs */ -#endif -#ifndef __Q8_STRUCT_TM_DEFINED -#define __Q8_STRUCT_TM_DEFINED /* idempotency lock */ -/* XXX -- need to work on this */ -#endif -#ifndef __Q8_WCHAR_T_DEFINED -#define __Q8_WCHAR_T_DEFINED /* idempotency lock */ -/* typedef __Q8_WCHAR_T wchar_t; /* XXX -- conflicts with native hdrs */ -#endif -#ifndef __Q8_WINT_T_DEFINED -#define __Q8_WINT_T_DEFINED /* idempotency lock */ -typedef __Q8_WINT_T wint_t; -#endif - -#ifndef NULL /* to protect against native defs */ -#define NULL __Q8_NULL -#endif - -#if 0 /* XXX -- these __Q8_* symbols are not yet defined */ -#ifndef WCHAR_MAX /* to protect against native defs */ -#define WCHAR_MAX __Q8_WCHAR_MAX -#endif - -#ifndef WCHAR_MIN /* to protect against native defs */ -#define WCHAR_MIN __Q8_WCHAR_MIN -#endif -#endif /* XXX */ - -#ifndef WEOF /* to protect against native defs */ -#define WEOF __Q8_WEOF -#endif - -/* - 7.24.2 Formatted wide character input/output functions -*/ - -extern int fwprintf __Q8_PARAMS((__Q8_FILE * __Q8_RESTRICT __stream, - __Q8_CONST wchar_t * __Q8_RESTRICT __format, ...)); -extern int fwscanf __Q8_PARAMS((__Q8_FILE * __Q8_RESTRICT __stream, - __Q8_CONST wchar_t * __Q8_RESTRICT __format, ...)); -extern int swprintf __Q8_PARAMS((wchar_t * __Q8_RESTRICT __s, size_t __n, - __Q8_CONST wchar_t * __Q8_RESTRICT __format, ...)); -extern int swscanf __Q8_PARAMS((__Q8_CONST wchar_t * __Q8_RESTRICT __s, - __Q8_CONST wchar_t * __Q8_RESTRICT __format, ...)); -extern int vfwprintf __Q8_PARAMS((__Q8_FILE * __Q8_RESTRICT __stream, - __Q8_CONST wchar_t * __Q8_RESTRICT __format, - __va_list __arg)); -extern int vfwscanf __Q8_PARAMS((__Q8_FILE * __Q8_RESTRICT __stream, - __Q8_CONST wchar_t * __Q8_RESTRICT __format, - __va_list __arg)); -extern int vswprintf __Q8_PARAMS((wchar_t * __Q8_RESTRICT __s, size_t __n, - __Q8_CONST wchar_t * __Q8_RESTRICT __format, - __va_list __arg)); -extern int vswscanf __Q8_PARAMS((__Q8_CONST wchar_t * __Q8_RESTRICT __s, - __Q8_CONST wchar_t * __Q8_RESTRICT __format, - __va_list __arg)); -extern int vwprintf __Q8_PARAMS((__Q8_CONST wchar_t * __Q8_RESTRICT - __format, __va_list __arg)); -extern int vwscanf __Q8_PARAMS((__Q8_CONST wchar_t * __Q8_RESTRICT - __format, __va_list __arg)); -extern int wprintf __Q8_PARAMS((__Q8_CONST wchar_t * __Q8_RESTRICT - __format, ...)); -extern int wscanf __Q8_PARAMS((__Q8_CONST wchar_t * __Q8_RESTRICT - __format, ...)); - -/* - 7.24.3 Wide character input/output functions -*/ - -extern wint_t fgetwc __Q8_PARAMS((__Q8_FILE * __stream)); -extern wchar_t *fgetws __Q8_PARAMS((wchar_t * __Q8_RESTRICT __s, int __n, - __Q8_FILE * __Q8_RESTRICT __stream)); -extern wint_t fputwc __Q8_PARAMS((wchar_t __c, __Q8_FILE * __stream)); -extern int fputws __Q8_PARAMS((wchar_t * __Q8_RESTRICT __s, - __Q8_FILE * __Q8_RESTRICT __stream)); -extern int fwide __Q8_PARAMS((__Q8_FILE * __stream, int __mode)); -extern wint_t getwc __Q8_PARAMS((__Q8_FILE * __stream)); -extern wint_t getwchar __Q8_PARAMS((void)); -extern wint_t putwc __Q8_PARAMS((wchar_t __c, __Q8_FILE * __stream)); -extern wint_t putwchar __Q8_PARAMS((wchar_t __c)); -extern wint_t ungetwc __Q8_PARAMS((wint_t __c, __Q8_FILE * __stream)); - -/* - 7.24.4 General wide string utilities -*/ - -extern double wcstod __Q8_PARAMS((__Q8_CONST wchar_t * __Q8_RESTRICT __nptr, - wchar_t ** __Q8_RESTRICT __endptr)); -extern float wcstof __Q8_PARAMS((__Q8_CONST wchar_t * __Q8_RESTRICT __nptr, - wchar_t ** __Q8_RESTRICT __endptr)); -#ifdef __Q8_GT -extern __Q8_GT - wcstold __Q8_PARAMS((__Q8_CONST wchar_t * __Q8_RESTRICT __nptr, - wchar_t ** __Q8_RESTRICT __endptr)); -#endif -extern long wcstol __Q8_PARAMS((__Q8_CONST wchar_t * __Q8_RESTRICT __nptr, - wchar_t ** __Q8_RESTRICT __endptr, int __base)); -extern unsigned long - wcstoul __Q8_PARAMS((__Q8_CONST wchar_t * __Q8_RESTRICT __nptr, - wchar_t ** __Q8_RESTRICT __endptr, int __base)); -#ifdef __Q8_QT -extern __Q8_QT - wcstoll __Q8_PARAMS((__Q8_CONST wchar_t * __Q8_RESTRICT __nptr, - wchar_t ** __Q8_RESTRICT __endptr, int __base)); -extern unsigned __Q8_QT - wcstoull __Q8_PARAMS((__Q8_CONST wchar_t * __Q8_RESTRICT __nptr, - wchar_t ** __Q8_RESTRICT __endptr, int __base)); -#endif -extern wchar_t *wcscpy __Q8_PARAMS((wchar_t * __Q8_RESTRICT __s1, - __Q8_CONST wchar_t * __Q8_RESTRICT __s2)); -extern wchar_t *wcsncpy __Q8_PARAMS((wchar_t * __Q8_RESTRICT __s1, - __Q8_CONST wchar_t * __Q8_RESTRICT __s2, size_t __n)); -extern wchar_t *wmemcpy __Q8_PARAMS((wchar_t * __Q8_RESTRICT __s1, - __Q8_CONST wchar_t * __Q8_RESTRICT __s2, size_t __n)); -extern wchar_t *wmemmove __Q8_PARAMS((wchar_t * __s1, __Q8_CONST wchar_t * __s2, - size_t __n)); -extern wchar_t *wcscat __Q8_PARAMS((wchar_t * __Q8_RESTRICT __s1, - __Q8_CONST wchar_t * __Q8_RESTRICT __s2)); -extern wchar_t *wcsncat __Q8_PARAMS((wchar_t * __Q8_RESTRICT __s1, - __Q8_CONST wchar_t * __Q8_RESTRICT __s2, size_t __n)); -extern int wcscmp __Q8_PARAMS((__Q8_CONST wchar_t * __s1, - __Q8_CONST wchar_t * __s2)); -extern int wcscoll __Q8_PARAMS((__Q8_CONST wchar_t * __s1, - __Q8_CONST wchar_t * __s2)); -extern int wcsncmp __Q8_PARAMS((__Q8_CONST wchar_t * __s1, - __Q8_CONST wchar_t * __s2, size_t __n)); -extern size_t wcsxfrm __Q8_PARAMS((wchar_t * __Q8_RESTRICT __s1, - __Q8_CONST wchar_t * __Q8_RESTRICT __s2, size_t __n)); -extern int wmemcmp __Q8_PARAMS((__Q8_CONST wchar_t * __s1, - __Q8_CONST wchar_t * __s2, size_t __n)); -extern wchar_t *wcschr __Q8_PARAMS((__Q8_CONST wchar_t * __s, wchar_t __c)); -extern size_t wcscspn __Q8_PARAMS((__Q8_CONST wchar_t * __s1, - __Q8_CONST wchar_t * __s2)); -extern wchar_t *wcspbrk __Q8_PARAMS((__Q8_CONST wchar_t * __s1, - __Q8_CONST wchar_t * __s2)); -extern wchar_t *wcsrchr __Q8_PARAMS((__Q8_CONST wchar_t * __s, wchar_t __c)); -extern size_t wcsspn __Q8_PARAMS((__Q8_CONST wchar_t * __s1, - __Q8_CONST wchar_t * __s2)); -extern wchar_t *wcsstr __Q8_PARAMS((__Q8_CONST wchar_t * __s1, - __Q8_CONST wchar_t * __s2)); -extern wchar_t *wcstok __Q8_PARAMS((wchar_t * __Q8_RESTRICT __s1, - __Q8_CONST wchar_t * __Q8_RESTRICT __s2, - wchar_t ** __Q8_RESTRICT __ptr)); -extern wchar_t *wmemchr __Q8_PARAMS((__Q8_CONST wchar_t * __s, wchar_t __c, - size_t __n)); -extern size_t wcslen __Q8_PARAMS((__Q8_CONST wchar_t * __s)); -extern wchar_t *wmemset __Q8_PARAMS((wchar_t * __s, wchar_t __c, size_t __n)); - -/* - 7.24.5 Wide character time conversion functions -*/ - -extern size_t wcsftime __Q8_PARAMS((wchar_t * __Q8_RESTRICT __s, - size_t __maxsize, - __Q8_CONST wchar_t * __Q8_RESTRICT __format, - __Q8_CONST struct tm * __Q8_RESTRICT __timeptr)); - -/* - 7.24.6 Extended multibyte/wide character conversion utilities -*/ - -extern wint_t btowc __Q8_PARAMS((int __c)); -extern int wctob __Q8_PARAMS((wint_t __c)); -extern int mbsinit __Q8_PARAMS((__Q8_CONST mbstate_t *__ps)); -extern size_t mbrlen __Q8_PARAMS((__Q8_CONST char * __Q8_RESTRICT __s, - size_t __n, mbstate_t * __Q8_RESTRICT __ps)); -extern size_t mbrtowc __Q8_PARAMS((wchar_t * __Q8_RESTRICT __pwc, - __Q8_CONST char * __Q8_RESTRICT __s, size_t __n, - mbstate_t * __Q8_RESTRICT __ps)); -extern size_t wcrtomb __Q8_PARAMS((char * __Q8_RESTRICT __s, wchar_t __wc, - mbstate_t * __Q8_RESTRICT __ps)); -extern size_t mbsrtowcs __Q8_PARAMS((wchar_t * __Q8_RESTRICT __dst, - __Q8_CONST char ** __Q8_RESTRICT __src, size_t __len, - mbstate_t * __Q8_RESTRICT __ps)); -extern size_t wcsrtombs __Q8_PARAMS((char * __Q8_RESTRICT __dst, - __Q8_CONST wchar_t ** __Q8_RESTRICT __src, size_t __len, - mbstate_t * __Q8_RESTRICT __ps)); - -#ifdef __cplusplus - } -#endif - -#endif /* !defined(_WCHAR_H) && !defined(_INC_WCHAR) */ diff --git a/src/init/c/util/wctype.c b/src/init/c/util/wctype.c deleted file mode 100644 index e3ef300..0000000 --- a/src/init/c/util/wctype.c +++ /dev/null @@ -1,231 +0,0 @@ -/* - wctype -- wide character classification and mapping utilities - - This source code has been placed into the PUBLIC DOMAIN by its author. - - last edit: 1999/11/05 gwyn@arl.mil - - Implements subclause 7.25 of ISO/IEC 9899:1999 (E). - - This particular implementation requires the matching . - - This is a minimal implementation for environments where - internationalization is not considered important. - - It supports an encoding where all char codes are mapped - to the *same* code values within a wchar_t or wint_t, - so long as no other wchar_t codes are used by the program. - - XXX -- UNTESTED -- XXX -*/ - -#include -#include -#include - -#include /* defines __Q8_CONST and __Q8_PARAMS */ - -/* - 7.25.2 Wide character classification utilities -*/ - -int -iswalnum(wc) - wint_t wc; - { - return isalnum((int)(unsigned char)wc); - } - -int -iswalpha(wc) - wint_t wc; - { - return isalpha((int)(unsigned char)wc); - } - -int -iswblank(wc) - wint_t wc; - { - return isblank((int)(unsigned char)wc); - } - -int -iswcntrl(wc) - wint_t wc; - { - return iscntrl((int)(unsigned char)wc); - } - -int -iswdigit(wc) - wint_t wc; - { - return isdigit((int)(unsigned char)wc); - } - -int -iswgraph(wc) - wint_t wc; - { - return isgraph((int)(unsigned char)wc); - } - -int -iswlower(wc) - wint_t wc; - { - return islower((int)(unsigned char)wc); - } - -int -iswprint(wc) - wint_t wc; - { - return isprint((int)(unsigned char)wc); - } - -int -iswpunct(wc) - wint_t wc; - { - return ispunct((int)(unsigned char)wc); - } - -int -iswspace(wc) - wint_t wc; - { - return isspace((int)(unsigned char)wc); - } - -int -iswupper(wc) - wint_t wc; - { - return isupper((int)(unsigned char)wc); - } - -int -iswxdigit(wc) - wint_t wc; - { - return isxdigit((int)(unsigned char)wc); - } - -/* - wctype() usually encodes properties as ORed bit combinations; - for this *minimal implementation* I can take a lazy approach. -*/ - -static struct - { - __Q8_CONST char *name; - int (*func)__Q8_PARAMS((int)); - } cmap[] = - { - "alnum", iswalnum, - "alpha", iswalpha, - "blank", iswblank, - "cntrl", iswcntrl, - "digit", iswdigit, - "graph", iswgraph, - "lower", iswlower, - "print", iswprint, - "punct", iswpunct, - "space", iswspace, - "upper", iswupper, - "xdigit", iswxdigit - }; -#define NCMAP (sizeof cmap / sizeof cmap[0]) - -int -iswctype(wc, desc) - wint_t wc; - wctype_t desc; - { - register int i; - - if ( desc <= 0 || desc > NCMAP ) /* undefined behavior */ - { - errno = EDOM; - return 0; /* a form of not having the property */ - } - - return cmap[desc-1].func(wc); - } - -wctype_t /* returns map index + 1 */ -wctype(property) - __Q8_CONST char *property; - { - register int i; - - for ( i = 0; i < NCMAP; ++i ) - if ( strcmp(property, cmap[i].name) == 0 ) - return i+1; - - return 0; /* indicates "not valid" */ - } - -/* - 7.25.3 Wide character case mapping utilities -*/ - -wint_t -towlower(wc) - wint_t wc; - { - return tolower((int)(unsigned char)wc); - } - -wint_t -towupper(wc) - wint_t wc; - { - return toupper((int)(unsigned char)wc); - } - -/* - For this *minimal implementation* I can take a lazy approach. -*/ - -static struct - { - __Q8_CONST char *name; - int (*func)__Q8_PARAMS((int)); - } tmap[] = - { - "lower", towlower, - "upper", towupper - }; -#define NTMAP (sizeof tmap / sizeof tmap[0]) - -wint_t -iswctrans(wc, desc) - wint_t wc; - wctrans_t desc; - { - register int i; - - if ( desc <= 0 || desc > NTMAP ) /* undefined behavior */ - { - errno = EDOM; - return 0; /* a form of not having the property */ - } - - return tmap[desc-1].func(wc); - } - -wctrans_t /* returns map index + 1 */ -wctrans(property) - __Q8_CONST char *property; - { - register int i; - - for ( i = 0; i < NTMAP; ++i ) - if ( strcmp(property, tmap[i].name) == 0 ) - return i+1; - - return 0; /* indicates "not valid" */ - } diff --git a/src/init/c/util/wctype.h b/src/init/c/util/wctype.h deleted file mode 100644 index 75b929c..0000000 --- a/src/init/c/util/wctype.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - wctype.h -- wide character classification and mapping utilities - - This source code has been placed into the PUBLIC DOMAIN by its author. - - last edit: 1999/08/20 gwyn@arl.mil - - Implements subclause 7.25 of ISO/IEC 9899:1999 (E). -*/ - -#if !defined(_WCTYPE_H) && !defined(_INC_WCTYPE) /* usual lock names */ -#define _WCTYPE_H /* idempotency lock (section 7.1.2) */ -#define _INC_WCTYPE - -#include /* defines the __Q8_* symbols */ - -#ifdef __cplusplus -extern "C" { -#endif - -/* - 7.25.1 Introduction -*/ - -#ifndef __Q8_WINT_T_DEFINED -#define __Q8_WINT_T_DEFINED /* idempotency lock */ -typedef __Q8_WINT_T wint_t; -#endif -#ifndef __Q8_WCTRANS_T_DEFINED -#define __Q8_WCTRANS_T_DEFINED /* idempotency lock */ -typedef unsigned int wctrans_t; /* this type works nearly everywhere */ -#endif -#ifndef __Q8_WCTYPE_T_DEFINED -#define __Q8_WCTYPE_T_DEFINED /* idempotency lock */ -typedef int wctype_t; /* this type works nearly everywhere */ -#endif - -#ifndef WEOF /* to protect against native defs */ -#define WEOF __Q8_WEOF -#endif - -/* - 7.25.2 Wide character classification utilities -*/ - -extern int iswalnum __Q8_PARAMS((wint_t __wc)); -extern int iswalpha __Q8_PARAMS((wint_t __wc)); -extern int iswblank __Q8_PARAMS((wint_t __wc)); -extern int iswcntrl __Q8_PARAMS((wint_t __wc)); -extern int iswdigit __Q8_PARAMS((wint_t __wc)); -extern int iswgraph __Q8_PARAMS((wint_t __wc)); -extern int iswlower __Q8_PARAMS((wint_t __wc)); -extern int iswprint __Q8_PARAMS((wint_t __wc)); -extern int iswpunct __Q8_PARAMS((wint_t __wc)); -extern int iswspace __Q8_PARAMS((wint_t __wc)); -extern int iswupper __Q8_PARAMS((wint_t __wc)); -extern int iswxdigit __Q8_PARAMS((wint_t __wc)); -extern int iswctype __Q8_PARAMS((wint_t __wc, wctype_t __desc)); -extern wctype_t wctype __Q8_PARAMS((__Q8_CONST char *__property)); - -/* - 7.25.3 Wide character case mapping utilities -*/ - -extern wint_t towlower __Q8_PARAMS((wint_t __wc)); -extern wint_t towupper __Q8_PARAMS((wint_t __wc)); -extern wint_t towctrans __Q8_PARAMS((wint_t __wc, wctrans_t __desc)); -extern wctrans_t - wctrans __Q8_PARAMS((__Q8_CONST char *__property)); - -#ifdef __cplusplus - } -#endif - -#endif /* !defined(_WCTYPE_H) && !defined(_INC_WCTYPE) */ diff --git a/src/init/d/bind.d b/src/init/d/bind.d new file mode 100644 index 0000000..4b89630 --- /dev/null +++ b/src/init/d/bind.d @@ -0,0 +1,30 @@ +import godot; +// import godot.api.script; // for GodotScript! +// import godot.api.register; // for GodotNativeLibrary +// import godot.string; // for gs! + +import godot.node; + +// minimal class example with _ready method that will be invoked on creation +class init : GodotScript!Node { + @Property String name; + + // this method is a special godot entry point when object is added to the scene + @Method + void _ready() { + // 'gs' is a string wrapper that converts D string to godot string + // usually there is helper functions that takes regular D strings and do this for you + print(gs!"Hello ", name); + } +} + +// register classes, initialize and terminate D runtime, only one per plugin +mixin GodotNativeLibrary!( + // this is a name prefix of the plugin to be acessible inside godot + // it must match the prefix in .gdextension file: + // entry_symbol = "mydplugin_gdextension_entry" + "libsb_init", + + // here goes the list of classes you would like to expose in godot + init, +); diff --git a/src/main.c b/src/main.c index 8a9a69a..ca0b525 100644 --- a/src/main.c +++ b/src/main.c @@ -9,15 +9,15 @@ /* This file is included in the repository since using a Git submodule would * requried cloning the entire Godot source. */ -#include "./init/c/gdextension_interface.h" /* GDExtension header for Godot. */ +#include "gdextension_interface.h" /* GDExtension header for Godot. */ /* - int main() - { - printf("Starting./n"); - return(0); - } - */ +int main() +{ + printf("Starting./n"); + return(0); +} +*/ /* Boilerplate provided by examples. */ /* Some lines are over 80 characters. */ @@ -51,13 +51,12 @@ static StringName print_StringName; static GDExtensionPtrUtilityFunction print_function; -StringName string_name; -GDExtensionConstTypePtr constructor_arguments[1] = { &string_name }; - StringName construct_StringName_from_cstring(const char *text) { String string; string_new_with_utf8_chars(&string, text); + StringName string_name; + GDExtensionConstTypePtr constructor_arguments[1] = { &string }; construct_StringName_from_String(&string_name, constructor_arguments); destroy_String(&string); @@ -65,15 +64,14 @@ StringName construct_StringName_from_cstring(const char *text) { return string_name; } -Variant arg1; -GDExtensionConstVariantPtr args[1] = { &arg1 }; - void print(const char *text) { String string; string_new_with_utf8_chars(&string, text); + Variant arg1; construct_Variant_from_String(&arg1, &string); + GDExtensionConstVariantPtr args[1] = { &arg1 }; print_function(NULL, args, 1); variant_destroy(&arg1); @@ -106,15 +104,13 @@ void deinitialize(void *userdata, GDExtensionInitializationLevel p_level) { destroy_StringName(&print_StringName); } -/* libsb object; called by Godot when it reads the libsb.gdextension file that +/* librtr object; called by Godot when it reads the librtr.gdextension file that * provides a configuration using this name. */ - -GDExtensionBool libsb( - GDExtensionInterfaceGetProcAddress p_get_proc_address, - GDExtensionClassLibraryPtr p_library, - GDExtensionInitialization *r_initialization - ) -{ +GDExtensionBool librtr_extension_init( + GDExtensionInterfaceGetProcAddress p_get_proc_address, + GDExtensionClassLibraryPtr p_library, + GDExtensionInitialization *r_initialization +) { r_initialization->initialize = &initialize; r_initialization->deinitialize = &deinitialize; string_new_with_utf8_chars = (GDExtensionInterfaceStringNewWithUtf8Chars) p_get_proc_address("string_new_with_utf8_chars");