Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5ead9118b3 | |||
| c29465a97d | |||
| 4b20f8ca0e | |||
| f3062222cb | |||
| 703155affe | |||
| 90a3905f48 | |||
| 8c12868651 | |||
| 2966934cd8 | |||
| 9937546452 | |||
| 5d98bc89a1 | |||
| b8e270b962 | |||
| 3d1600ece6 | |||
| fe3af271e2 |
+8
-6
@@ -44,15 +44,17 @@ ReflowComments: true
|
|||||||
SpacesBeforeTrailingComments: 3
|
SpacesBeforeTrailingComments: 3
|
||||||
TabWidth: 8
|
TabWidth: 8
|
||||||
UseTab: AlignWithSpaces
|
UseTab: AlignWithSpaces
|
||||||
PenaltyReturnTypeOnItsOwnLine: 1000000
|
BreakAfterReturnType: Automatic
|
||||||
PenaltyExcessCharacter: 5
|
PenaltyBreakAssignment: 1000000
|
||||||
PenaltyBreakOpenParenthesis: 5
|
PenaltyReturnTypeOnItsOwnLine: 100000000
|
||||||
PenaltyBreakBeforeFirstCallParameter: 5
|
PenaltyExcessCharacter: 10000000
|
||||||
|
PenaltyBreakOpenParenthesis: 0
|
||||||
|
PenaltyBreakBeforeFirstCallParameter: 0
|
||||||
PenaltyIndentedWhitespace: 0
|
PenaltyIndentedWhitespace: 0
|
||||||
AttributeMacros:
|
AttributeMacros:
|
||||||
- FX_API
|
- FX_API
|
||||||
ForEachMacros:
|
ForEachMacros:
|
||||||
- fx_btree_foreach
|
- fx_btree_foreach
|
||||||
- fx_queue_foreach
|
- fx_queue_foreach
|
||||||
MacroBlockBegin: "FX_(TYPE|ASSEMBLY)_.*_BEGIN"
|
MacroBlockBegin: "FX_(TYPE|ASSEMBLY).*_BEGIN"
|
||||||
MacroBlockEnd: "FX_(TYPE|ASSEMBLY)_.*_END"
|
MacroBlockEnd: "FX_(TYPE|ASSEMBLY).*_END"
|
||||||
|
|||||||
+6
-7
@@ -1,12 +1,14 @@
|
|||||||
cmake_minimum_required(VERSION 3.25)
|
cmake_minimum_required(VERSION 3.25)
|
||||||
project(fx C ASM)
|
project(fx C ASM)
|
||||||
|
|
||||||
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake)
|
||||||
include (TestBigEndian)
|
include (TestBigEndian)
|
||||||
|
include(Templates)
|
||||||
|
include(Platform)
|
||||||
|
|
||||||
set(CMAKE_C_STANDARD 99)
|
set(CMAKE_C_STANDARD 99)
|
||||||
set(CMAKE_C_EXTENSIONS OFF)
|
set(CMAKE_C_EXTENSIONS OFF)
|
||||||
|
|
||||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake)
|
|
||||||
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
||||||
|
|
||||||
set(fx_source_root ${CMAKE_CURRENT_SOURCE_DIR})
|
set(fx_source_root ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
@@ -33,10 +35,9 @@ endif ()
|
|||||||
|
|
||||||
message(STATUS "Floating point support: ${fx_enable_floating_point}")
|
message(STATUS "Floating point support: ${fx_enable_floating_point}")
|
||||||
|
|
||||||
set(fx_system_name ${CMAKE_SYSTEM_NAME})
|
get_platform_details(
|
||||||
string(TOLOWER ${fx_system_name} fx_system_name)
|
SYSTEM fx_system_name
|
||||||
set(fx_system_arch ${CMAKE_SYSTEM_PROCESSOR})
|
PROCESSOR fx_system_arch)
|
||||||
string(TOLOWER ${fx_system_arch} fx_system_arch)
|
|
||||||
|
|
||||||
message(STATUS "Target system: ${fx_system_name}-${fx_system_arch}")
|
message(STATUS "Target system: ${fx_system_name}-${fx_system_arch}")
|
||||||
|
|
||||||
@@ -44,8 +45,6 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib)
|
|||||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib)
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib)
|
||||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin)
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin)
|
||||||
|
|
||||||
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Templates.cmake)
|
|
||||||
|
|
||||||
foreach (assembly ${fx_assemblies})
|
foreach (assembly ${fx_assemblies})
|
||||||
add_subdirectory(assemblies/${assembly})
|
add_subdirectory(assemblies/${assembly})
|
||||||
endforeach (assembly)
|
endforeach (assembly)
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include <fx/macros.h>
|
#include <fx/macros.h>
|
||||||
#include <fx/reflection/assembly.h>
|
#include <fx/reflection/assembly.h>
|
||||||
|
|
||||||
FX_ASSEMBLY_BEGIN()
|
FX_ASSEMBLY_BEGIN(fx_cmdline)
|
||||||
FX_ASSEMBLY_NAME("fx.cmdline");
|
FX_ASSEMBLY_NAME("fx.cmdline");
|
||||||
FX_ASSEMBLY_VERSION(1, 0, 0, 0);
|
FX_ASSEMBLY_VERSION(1, 0, 0, 0);
|
||||||
FX_ASSEMBLY_END()
|
FX_ASSEMBLY_END(fx_cmdline)
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include <fx/macros.h>
|
#include <fx/macros.h>
|
||||||
#include <fx/reflection/assembly.h>
|
#include <fx/reflection/assembly.h>
|
||||||
|
|
||||||
FX_ASSEMBLY_BEGIN()
|
FX_ASSEMBLY_BEGIN(fx_compression)
|
||||||
FX_ASSEMBLY_NAME("fx.compression");
|
FX_ASSEMBLY_NAME("fx.compression");
|
||||||
FX_ASSEMBLY_VERSION(1, 0, 0, 0);
|
FX_ASSEMBLY_VERSION(1, 0, 0, 0);
|
||||||
FX_ASSEMBLY_END()
|
FX_ASSEMBLY_END(fx_compression)
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include <fx/macros.h>
|
#include <fx/macros.h>
|
||||||
#include <fx/reflection/assembly.h>
|
#include <fx/reflection/assembly.h>
|
||||||
|
|
||||||
FX_ASSEMBLY_BEGIN()
|
FX_ASSEMBLY_BEGIN(fx_io)
|
||||||
FX_ASSEMBLY_NAME("fx.io");
|
FX_ASSEMBLY_NAME("fx.io");
|
||||||
FX_ASSEMBLY_VERSION(1, 0, 0, 0);
|
FX_ASSEMBLY_VERSION(1, 0, 0, 0);
|
||||||
FX_ASSEMBLY_END()
|
FX_ASSEMBLY_END(fx_io)
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include <fx/macros.h>
|
#include <fx/macros.h>
|
||||||
#include <fx/reflection/assembly.h>
|
#include <fx/reflection/assembly.h>
|
||||||
|
|
||||||
FX_ASSEMBLY_BEGIN()
|
FX_ASSEMBLY_BEGIN(fx_runtime)
|
||||||
FX_ASSEMBLY_NAME("fx.runtime");
|
FX_ASSEMBLY_NAME("fx.runtime");
|
||||||
FX_ASSEMBLY_VERSION(1, 0, 0, 0);
|
FX_ASSEMBLY_VERSION(1, 0, 0, 0);
|
||||||
FX_ASSEMBLY_EXPORT_TYPE("fx", "stream", fx_stream);
|
FX_ASSEMBLY_EXPORT_TYPE("fx", "stream", fx_stream);
|
||||||
@@ -9,4 +9,4 @@ FX_ASSEMBLY_BEGIN()
|
|||||||
FX_ASSEMBLY_EXPORT_TYPE("fx", "stringstream", fx_stringstream);
|
FX_ASSEMBLY_EXPORT_TYPE("fx", "stringstream", fx_stringstream);
|
||||||
FX_ASSEMBLY_EXPORT_TYPE("fx", "iterator", fx_iterator);
|
FX_ASSEMBLY_EXPORT_TYPE("fx", "iterator", fx_iterator);
|
||||||
FX_ASSEMBLY_EXPORT_TYPE("fx.reflection", "assembly", fx_assembly);
|
FX_ASSEMBLY_EXPORT_TYPE("fx.reflection", "assembly", fx_assembly);
|
||||||
FX_ASSEMBLY_END()
|
FX_ASSEMBLY_END(fx_runtime)
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include <fx/macros.h>
|
#include <fx/macros.h>
|
||||||
#include <fx/reflection/assembly.h>
|
#include <fx/reflection/assembly.h>
|
||||||
|
|
||||||
FX_ASSEMBLY_BEGIN()
|
FX_ASSEMBLY_BEGIN(fx_serial)
|
||||||
FX_ASSEMBLY_NAME("fx.serial");
|
FX_ASSEMBLY_NAME("fx.serial");
|
||||||
FX_ASSEMBLY_VERSION(1, 0, 0, 0);
|
FX_ASSEMBLY_VERSION(1, 0, 0, 0);
|
||||||
FX_ASSEMBLY_END()
|
FX_ASSEMBLY_END(fx_serial)
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include <fx/macros.h>
|
#include <fx/macros.h>
|
||||||
#include <fx/reflection/assembly.h>
|
#include <fx/reflection/assembly.h>
|
||||||
|
|
||||||
FX_ASSEMBLY_BEGIN()
|
FX_ASSEMBLY_BEGIN(fx_term)
|
||||||
FX_ASSEMBLY_NAME("fx.term");
|
FX_ASSEMBLY_NAME("fx.term");
|
||||||
FX_ASSEMBLY_VERSION(1, 0, 0, 0);
|
FX_ASSEMBLY_VERSION(1, 0, 0, 0);
|
||||||
FX_ASSEMBLY_END()
|
FX_ASSEMBLY_END(fx_term)
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
function(get_platform_details)
|
||||||
|
set(options)
|
||||||
|
set(one_value_args SYSTEM PROCESSOR)
|
||||||
|
set(multi_value_args
|
||||||
|
NAMESPACES
|
||||||
|
DEPENDENCIES
|
||||||
|
LIBS)
|
||||||
|
cmake_parse_arguments(PARSE_ARGV 0 arg
|
||||||
|
"${options}"
|
||||||
|
"${one_value_args}"
|
||||||
|
"${multi_value_args}")
|
||||||
|
|
||||||
|
set(system_name "")
|
||||||
|
|
||||||
|
if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
|
||||||
|
set(system_name "linux")
|
||||||
|
elseif ("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
|
||||||
|
set(system_name "apple")
|
||||||
|
elseif ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
|
||||||
|
set(system_name "win32")
|
||||||
|
else ()
|
||||||
|
message(FATAL_ERROR "Unsupported platform: ${CMAKE_SYSTEM_NAME}")
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
if ("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64")
|
||||||
|
set(system_arch "amd64")
|
||||||
|
elseif ("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "arm64")
|
||||||
|
set(system_arch "aarch64")
|
||||||
|
else ()
|
||||||
|
message(FATAL_ERROR "Unsupported architecture: ${CMAKE_SYSTEM_PROCESSOR}")
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
set(${arg_SYSTEM} ${system_name} PARENT_SCOPE)
|
||||||
|
set(${arg_PROCESSOR} ${system_arch} PARENT_SCOPE)
|
||||||
|
endfunction (get_platform_details)
|
||||||
|
|
||||||
@@ -45,6 +45,17 @@ function(add_fx_assembly)
|
|||||||
target_compile_definitions(${assembly_target_name} PRIVATE ${def})
|
target_compile_definitions(${assembly_target_name} PRIVATE ${def})
|
||||||
endforeach (def)
|
endforeach (def)
|
||||||
|
|
||||||
|
foreach (ns ${arg_NAMESPACES})
|
||||||
|
file(GLOB test_sources ${fx_source_root}/${ns}/test/*.c)
|
||||||
|
foreach (test_file ${test_sources})
|
||||||
|
get_filename_component(test_name ${test_file} NAME_WE)
|
||||||
|
set(test_name ${ns}-${test_name})
|
||||||
|
string(REPLACE "." "-" test_name ${test_name})
|
||||||
|
add_executable(${test_name} ${test_file})
|
||||||
|
target_link_libraries(${test_name} ${assembly_target_name})
|
||||||
|
endforeach (test_file)
|
||||||
|
endforeach (ns)
|
||||||
|
|
||||||
set_target_properties(${assembly_target_name} PROPERTIES
|
set_target_properties(${assembly_target_name} PROPERTIES
|
||||||
FOLDER "${assembly_name}")
|
FOLDER "${assembly_name}")
|
||||||
|
|
||||||
|
|||||||
+12
-12
@@ -486,16 +486,16 @@ static enum fx_status iterator_is_valid(const fx_iterator *obj)
|
|||||||
/*** CLASS DEFINITION *********************************************************/
|
/*** CLASS DEFINITION *********************************************************/
|
||||||
|
|
||||||
// ---- fx_array DEFINITION
|
// ---- fx_array DEFINITION
|
||||||
FX_TYPE_CLASS_DEFINITION_BEGIN(fx_array)
|
FX_TYPE_CLASS_BEGIN(fx_array)
|
||||||
FX_TYPE_CLASS_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
||||||
FX_INTERFACE_ENTRY(to_string) = array_to_string;
|
FX_INTERFACE_ENTRY(to_string) = array_to_string;
|
||||||
FX_TYPE_CLASS_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
|
||||||
|
|
||||||
FX_TYPE_CLASS_INTERFACE_BEGIN(fx_iterable, FX_TYPE_ITERABLE)
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_iterable, FX_TYPE_ITERABLE)
|
||||||
FX_INTERFACE_ENTRY(it_begin) = iterable_begin;
|
FX_INTERFACE_ENTRY(it_begin) = iterable_begin;
|
||||||
FX_INTERFACE_ENTRY(it_cbegin) = iterable_cbegin;
|
FX_INTERFACE_ENTRY(it_cbegin) = iterable_cbegin;
|
||||||
FX_TYPE_CLASS_INTERFACE_END(fx_iterable, FX_TYPE_ITERABLE)
|
FX_TYPE_VTABLE_INTERFACE_END(fx_iterable, FX_TYPE_ITERABLE)
|
||||||
FX_TYPE_CLASS_DEFINITION_END(fx_array)
|
FX_TYPE_CLASS_END(fx_array)
|
||||||
|
|
||||||
FX_TYPE_DEFINITION_BEGIN(fx_array)
|
FX_TYPE_DEFINITION_BEGIN(fx_array)
|
||||||
FX_TYPE_ID(0xe3c46da1, 0x5f37, 0x4e44, 0xb53b, 0xff5a6200191b);
|
FX_TYPE_ID(0xe3c46da1, 0x5f37, 0x4e44, 0xb53b, 0xff5a6200191b);
|
||||||
@@ -507,18 +507,18 @@ FX_TYPE_DEFINITION_BEGIN(fx_array)
|
|||||||
FX_TYPE_DEFINITION_END(fx_array)
|
FX_TYPE_DEFINITION_END(fx_array)
|
||||||
|
|
||||||
// ---- fx_array_iterator DEFINITION
|
// ---- fx_array_iterator DEFINITION
|
||||||
FX_TYPE_CLASS_DEFINITION_BEGIN(fx_array_iterator)
|
FX_TYPE_CLASS_BEGIN(fx_array_iterator)
|
||||||
FX_TYPE_CLASS_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
||||||
FX_INTERFACE_ENTRY(to_string) = NULL;
|
FX_INTERFACE_ENTRY(to_string) = NULL;
|
||||||
FX_TYPE_CLASS_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
|
||||||
|
|
||||||
FX_TYPE_CLASS_INTERFACE_BEGIN(fx_iterator, FX_TYPE_ITERATOR)
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_iterator, FX_TYPE_ITERATOR)
|
||||||
FX_INTERFACE_ENTRY(it_move_next) = iterator_move_next;
|
FX_INTERFACE_ENTRY(it_move_next) = iterator_move_next;
|
||||||
FX_INTERFACE_ENTRY(it_erase) = iterator_erase;
|
FX_INTERFACE_ENTRY(it_erase) = iterator_erase;
|
||||||
FX_INTERFACE_ENTRY(it_get_value) = iterator_get_value;
|
FX_INTERFACE_ENTRY(it_get_value) = iterator_get_value;
|
||||||
FX_INTERFACE_ENTRY(it_get_cvalue) = iterator_get_cvalue;
|
FX_INTERFACE_ENTRY(it_get_cvalue) = iterator_get_cvalue;
|
||||||
FX_TYPE_CLASS_INTERFACE_END(fx_iterator, FX_TYPE_ITERATOR)
|
FX_TYPE_VTABLE_INTERFACE_END(fx_iterator, FX_TYPE_ITERATOR)
|
||||||
FX_TYPE_CLASS_DEFINITION_END(fx_array_iterator)
|
FX_TYPE_CLASS_END(fx_array_iterator)
|
||||||
|
|
||||||
FX_TYPE_DEFINITION_BEGIN(fx_array_iterator)
|
FX_TYPE_DEFINITION_BEGIN(fx_array_iterator)
|
||||||
FX_TYPE_ID(0xe5e9e8b8, 0x14cb, 0x4192, 0x8138, 0xf45238a2ae73);
|
FX_TYPE_ID(0xe5e9e8b8, 0x14cb, 0x4192, 0x8138, 0xf45238a2ae73);
|
||||||
|
|||||||
@@ -23,11 +23,11 @@ static void bitbuffer_fini(fx_object *obj, void *priv)
|
|||||||
|
|
||||||
/*** CLASS DEFINITION *********************************************************/
|
/*** CLASS DEFINITION *********************************************************/
|
||||||
|
|
||||||
FX_TYPE_CLASS_DEFINITION_BEGIN(fx_bitbuffer)
|
FX_TYPE_CLASS_BEGIN(fx_bitbuffer)
|
||||||
FX_TYPE_CLASS_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
||||||
FX_INTERFACE_ENTRY(to_string) = NULL;
|
FX_INTERFACE_ENTRY(to_string) = NULL;
|
||||||
FX_TYPE_CLASS_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
|
||||||
FX_TYPE_CLASS_DEFINITION_END(fx_bitbuffer)
|
FX_TYPE_CLASS_END(fx_bitbuffer)
|
||||||
|
|
||||||
FX_TYPE_DEFINITION_BEGIN(fx_bitbuffer)
|
FX_TYPE_DEFINITION_BEGIN(fx_bitbuffer)
|
||||||
FX_TYPE_ID(0x628e33da, 0x3109, 0x4a5d, 0x98d5, 0xb0e4cb3ccb65);
|
FX_TYPE_ID(0x628e33da, 0x3109, 0x4a5d, 0x98d5, 0xb0e4cb3ccb65);
|
||||||
|
|||||||
@@ -343,11 +343,11 @@ static void bitmap_to_string(const fx_object *obj, fx_stream *out)
|
|||||||
|
|
||||||
/*** CLASS DEFINITION *********************************************************/
|
/*** CLASS DEFINITION *********************************************************/
|
||||||
|
|
||||||
FX_TYPE_CLASS_DEFINITION_BEGIN(fx_bitmap)
|
FX_TYPE_CLASS_BEGIN(fx_bitmap)
|
||||||
FX_TYPE_CLASS_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
||||||
FX_INTERFACE_ENTRY(to_string) = bitmap_to_string;
|
FX_INTERFACE_ENTRY(to_string) = bitmap_to_string;
|
||||||
FX_TYPE_CLASS_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
|
||||||
FX_TYPE_CLASS_DEFINITION_END(fx_bitmap)
|
FX_TYPE_CLASS_END(fx_bitmap)
|
||||||
|
|
||||||
FX_TYPE_DEFINITION_BEGIN(fx_bitmap)
|
FX_TYPE_DEFINITION_BEGIN(fx_bitmap)
|
||||||
FX_TYPE_ID(0xea115cef, 0x8a63, 0x445f, 0x9474, 0xba9309d5dde8);
|
FX_TYPE_ID(0xea115cef, 0x8a63, 0x445f, 0x9474, 0xba9309d5dde8);
|
||||||
|
|||||||
@@ -465,11 +465,11 @@ void buffer_fini(fx_object *obj, void *priv)
|
|||||||
|
|
||||||
/*** CLASS DEFINITION *********************************************************/
|
/*** CLASS DEFINITION *********************************************************/
|
||||||
|
|
||||||
FX_TYPE_CLASS_DEFINITION_BEGIN(fx_buffer)
|
FX_TYPE_CLASS_BEGIN(fx_buffer)
|
||||||
FX_TYPE_CLASS_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
||||||
FX_INTERFACE_ENTRY(to_string) = NULL;
|
FX_INTERFACE_ENTRY(to_string) = NULL;
|
||||||
FX_TYPE_CLASS_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
|
||||||
FX_TYPE_CLASS_DEFINITION_END(fx_buffer)
|
FX_TYPE_CLASS_END(fx_buffer)
|
||||||
|
|
||||||
FX_TYPE_DEFINITION_BEGIN(fx_buffer)
|
FX_TYPE_DEFINITION_BEGIN(fx_buffer)
|
||||||
FX_TYPE_ID(0x323e6858, 0x7a43, 0x4484, 0xa6fb, 0xe3d1e47ae637);
|
FX_TYPE_ID(0x323e6858, 0x7a43, 0x4484, 0xa6fb, 0xe3d1e47ae637);
|
||||||
|
|||||||
@@ -611,11 +611,11 @@ static void _datetime_to_string(const fx_object *obj, fx_stream *out)
|
|||||||
|
|
||||||
/*** CLASS DEFINITION *********************************************************/
|
/*** CLASS DEFINITION *********************************************************/
|
||||||
|
|
||||||
FX_TYPE_CLASS_DEFINITION_BEGIN(fx_datetime)
|
FX_TYPE_CLASS_BEGIN(fx_datetime)
|
||||||
FX_TYPE_CLASS_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
||||||
FX_INTERFACE_ENTRY(to_string) = _datetime_to_string;
|
FX_INTERFACE_ENTRY(to_string) = _datetime_to_string;
|
||||||
FX_TYPE_CLASS_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
|
||||||
FX_TYPE_CLASS_DEFINITION_END(fx_datetime)
|
FX_TYPE_CLASS_END(fx_datetime)
|
||||||
|
|
||||||
FX_TYPE_DEFINITION_BEGIN(fx_datetime)
|
FX_TYPE_DEFINITION_BEGIN(fx_datetime)
|
||||||
FX_TYPE_ID(0x06a6030b, 0x1e3c, 0x4be2, 0xbd23, 0xf34f4a8e68be);
|
FX_TYPE_ID(0x06a6030b, 0x1e3c, 0x4be2, 0xbd23, 0xf34f4a8e68be);
|
||||||
|
|||||||
+12
-12
@@ -690,16 +690,16 @@ static const fx_iterator_value iterator_get_cvalue(const fx_iterator *obj)
|
|||||||
/*** CLASS DEFINITION *********************************************************/
|
/*** CLASS DEFINITION *********************************************************/
|
||||||
|
|
||||||
// ---- fx_dict DEFINITION
|
// ---- fx_dict DEFINITION
|
||||||
FX_TYPE_CLASS_DEFINITION_BEGIN(fx_dict)
|
FX_TYPE_CLASS_BEGIN(fx_dict)
|
||||||
FX_TYPE_CLASS_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
||||||
FX_INTERFACE_ENTRY(to_string) = dict_to_string;
|
FX_INTERFACE_ENTRY(to_string) = dict_to_string;
|
||||||
FX_TYPE_CLASS_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
|
||||||
|
|
||||||
FX_TYPE_CLASS_INTERFACE_BEGIN(fx_iterable, FX_TYPE_ITERABLE)
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_iterable, FX_TYPE_ITERABLE)
|
||||||
FX_INTERFACE_ENTRY(it_begin) = iterable_begin;
|
FX_INTERFACE_ENTRY(it_begin) = iterable_begin;
|
||||||
FX_INTERFACE_ENTRY(it_cbegin) = iterable_cbegin;
|
FX_INTERFACE_ENTRY(it_cbegin) = iterable_cbegin;
|
||||||
FX_TYPE_CLASS_INTERFACE_END(fx_iterable, FX_TYPE_ITERABLE)
|
FX_TYPE_VTABLE_INTERFACE_END(fx_iterable, FX_TYPE_ITERABLE)
|
||||||
FX_TYPE_CLASS_DEFINITION_END(fx_dict)
|
FX_TYPE_CLASS_END(fx_dict)
|
||||||
|
|
||||||
FX_TYPE_DEFINITION_BEGIN(fx_dict)
|
FX_TYPE_DEFINITION_BEGIN(fx_dict)
|
||||||
FX_TYPE_ID(0xd2af61d9, 0xd0be, 0x4960, 0xbe3f, 0x509749814c10);
|
FX_TYPE_ID(0xd2af61d9, 0xd0be, 0x4960, 0xbe3f, 0x509749814c10);
|
||||||
@@ -711,18 +711,18 @@ FX_TYPE_DEFINITION_BEGIN(fx_dict)
|
|||||||
FX_TYPE_DEFINITION_END(fx_dict)
|
FX_TYPE_DEFINITION_END(fx_dict)
|
||||||
|
|
||||||
// ---- fx_dict_iterator DEFINITION
|
// ---- fx_dict_iterator DEFINITION
|
||||||
FX_TYPE_CLASS_DEFINITION_BEGIN(fx_dict_iterator)
|
FX_TYPE_CLASS_BEGIN(fx_dict_iterator)
|
||||||
FX_TYPE_CLASS_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
||||||
FX_INTERFACE_ENTRY(to_string) = NULL;
|
FX_INTERFACE_ENTRY(to_string) = NULL;
|
||||||
FX_TYPE_CLASS_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
|
||||||
|
|
||||||
FX_TYPE_CLASS_INTERFACE_BEGIN(fx_iterator, FX_TYPE_ITERATOR)
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_iterator, FX_TYPE_ITERATOR)
|
||||||
FX_INTERFACE_ENTRY(it_move_next) = iterator_move_next;
|
FX_INTERFACE_ENTRY(it_move_next) = iterator_move_next;
|
||||||
FX_INTERFACE_ENTRY(it_erase) = iterator_erase;
|
FX_INTERFACE_ENTRY(it_erase) = iterator_erase;
|
||||||
FX_INTERFACE_ENTRY(it_get_value) = iterator_get_value;
|
FX_INTERFACE_ENTRY(it_get_value) = iterator_get_value;
|
||||||
FX_INTERFACE_ENTRY(it_get_cvalue) = iterator_get_cvalue;
|
FX_INTERFACE_ENTRY(it_get_cvalue) = iterator_get_cvalue;
|
||||||
FX_TYPE_CLASS_INTERFACE_END(fx_iterator, FX_TYPE_ITERATOR)
|
FX_TYPE_VTABLE_INTERFACE_END(fx_iterator, FX_TYPE_ITERATOR)
|
||||||
FX_TYPE_CLASS_DEFINITION_END(fx_dict_iterator)
|
FX_TYPE_CLASS_END(fx_dict_iterator)
|
||||||
|
|
||||||
FX_TYPE_DEFINITION_BEGIN(fx_dict_iterator)
|
FX_TYPE_DEFINITION_BEGIN(fx_dict_iterator)
|
||||||
FX_TYPE_ID(0x9ea96701, 0x1713, 0x4a3e, 0xbf63, 0xdc856b456f3b);
|
FX_TYPE_ID(0x9ea96701, 0x1713, 0x4a3e, 0xbf63, 0xdc856b456f3b);
|
||||||
|
|||||||
+12
-12
@@ -607,16 +607,16 @@ static const fx_iterator_value iterator_get_cvalue(const fx_iterator *obj)
|
|||||||
/*** CLASS DEFINITION *********************************************************/
|
/*** CLASS DEFINITION *********************************************************/
|
||||||
|
|
||||||
// ---- fx_hashmap DEFINITION
|
// ---- fx_hashmap DEFINITION
|
||||||
FX_TYPE_CLASS_DEFINITION_BEGIN(fx_hashmap)
|
FX_TYPE_CLASS_BEGIN(fx_hashmap)
|
||||||
FX_TYPE_CLASS_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
||||||
FX_INTERFACE_ENTRY(to_string) = NULL;
|
FX_INTERFACE_ENTRY(to_string) = NULL;
|
||||||
FX_TYPE_CLASS_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
|
||||||
|
|
||||||
FX_TYPE_CLASS_INTERFACE_BEGIN(fx_iterable, FX_TYPE_ITERABLE)
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_iterable, FX_TYPE_ITERABLE)
|
||||||
FX_INTERFACE_ENTRY(it_begin) = fx_hashmap_begin;
|
FX_INTERFACE_ENTRY(it_begin) = fx_hashmap_begin;
|
||||||
FX_INTERFACE_ENTRY(it_cbegin) = fx_hashmap_cbegin;
|
FX_INTERFACE_ENTRY(it_cbegin) = fx_hashmap_cbegin;
|
||||||
FX_TYPE_CLASS_INTERFACE_END(fx_iterable, FX_TYPE_ITERABLE)
|
FX_TYPE_VTABLE_INTERFACE_END(fx_iterable, FX_TYPE_ITERABLE)
|
||||||
FX_TYPE_CLASS_DEFINITION_END(fx_hashmap)
|
FX_TYPE_CLASS_END(fx_hashmap)
|
||||||
|
|
||||||
FX_TYPE_DEFINITION_BEGIN(fx_hashmap)
|
FX_TYPE_DEFINITION_BEGIN(fx_hashmap)
|
||||||
FX_TYPE_ID(0x7bf5bcd1, 0x1ff3, 0x4e43, 0xbed8, 0x7c74f28348bf);
|
FX_TYPE_ID(0x7bf5bcd1, 0x1ff3, 0x4e43, 0xbed8, 0x7c74f28348bf);
|
||||||
@@ -628,18 +628,18 @@ FX_TYPE_DEFINITION_BEGIN(fx_hashmap)
|
|||||||
FX_TYPE_DEFINITION_END(fx_hashmap)
|
FX_TYPE_DEFINITION_END(fx_hashmap)
|
||||||
|
|
||||||
// ---- fx_hashmap_iterator DEFINITION
|
// ---- fx_hashmap_iterator DEFINITION
|
||||||
FX_TYPE_CLASS_DEFINITION_BEGIN(fx_hashmap_iterator)
|
FX_TYPE_CLASS_BEGIN(fx_hashmap_iterator)
|
||||||
FX_TYPE_CLASS_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
||||||
FX_INTERFACE_ENTRY(to_string) = NULL;
|
FX_INTERFACE_ENTRY(to_string) = NULL;
|
||||||
FX_TYPE_CLASS_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
|
||||||
|
|
||||||
FX_TYPE_CLASS_INTERFACE_BEGIN(fx_iterator, FX_TYPE_ITERATOR)
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_iterator, FX_TYPE_ITERATOR)
|
||||||
FX_INTERFACE_ENTRY(it_move_next) = iterator_move_next;
|
FX_INTERFACE_ENTRY(it_move_next) = iterator_move_next;
|
||||||
FX_INTERFACE_ENTRY(it_erase) = iterator_erase;
|
FX_INTERFACE_ENTRY(it_erase) = iterator_erase;
|
||||||
FX_INTERFACE_ENTRY(it_get_value) = iterator_get_value;
|
FX_INTERFACE_ENTRY(it_get_value) = iterator_get_value;
|
||||||
FX_INTERFACE_ENTRY(it_get_cvalue) = iterator_get_cvalue;
|
FX_INTERFACE_ENTRY(it_get_cvalue) = iterator_get_cvalue;
|
||||||
FX_TYPE_CLASS_INTERFACE_END(fx_iterator, FX_TYPE_ITERATOR)
|
FX_TYPE_VTABLE_INTERFACE_END(fx_iterator, FX_TYPE_ITERATOR)
|
||||||
FX_TYPE_CLASS_DEFINITION_END(fx_hashmap_iterator)
|
FX_TYPE_CLASS_END(fx_hashmap_iterator)
|
||||||
|
|
||||||
FX_TYPE_DEFINITION_BEGIN(fx_hashmap_iterator)
|
FX_TYPE_DEFINITION_BEGIN(fx_hashmap_iterator)
|
||||||
FX_TYPE_ID(0xd9658456, 0xdd80, 0x419a, 0xb23a, 0xb513013e6431);
|
FX_TYPE_ID(0xd9658456, 0xdd80, 0x419a, 0xb23a, 0xb513013e6431);
|
||||||
|
|||||||
@@ -30,8 +30,8 @@ FX_TYPE_CLASS_DECLARATION_END(fx_array)
|
|||||||
FX_TYPE_CLASS_DECLARATION_BEGIN(fx_array_iterator)
|
FX_TYPE_CLASS_DECLARATION_BEGIN(fx_array_iterator)
|
||||||
FX_TYPE_CLASS_DECLARATION_END(fx_array_iterator)
|
FX_TYPE_CLASS_DECLARATION_END(fx_array_iterator)
|
||||||
|
|
||||||
FX_API fx_type fx_array_get_type(void);
|
FX_API fx_type_id fx_array_get_type(void);
|
||||||
FX_API fx_type fx_array_iterator_get_type(void);
|
FX_API fx_type_id fx_array_iterator_get_type(void);
|
||||||
|
|
||||||
FX_TYPE_DEFAULT_CONSTRUCTOR(fx_array, FX_TYPE_ARRAY);
|
FX_TYPE_DEFAULT_CONSTRUCTOR(fx_array, FX_TYPE_ARRAY);
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ FX_DECLARE_TYPE(fx_bitmap);
|
|||||||
FX_TYPE_CLASS_DECLARATION_BEGIN(fx_bitmap)
|
FX_TYPE_CLASS_DECLARATION_BEGIN(fx_bitmap)
|
||||||
FX_TYPE_CLASS_DECLARATION_END(fx_bitmap)
|
FX_TYPE_CLASS_DECLARATION_END(fx_bitmap)
|
||||||
|
|
||||||
FX_API fx_type fx_bitmap_get_type(void);
|
FX_API fx_type_id fx_bitmap_get_type(void);
|
||||||
|
|
||||||
FX_API fx_bitmap *fx_bitmap_create(size_t nr_bits);
|
FX_API fx_bitmap *fx_bitmap_create(size_t nr_bits);
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ FX_DECLARE_TYPE(fx_buffer);
|
|||||||
FX_TYPE_CLASS_DECLARATION_BEGIN(fx_buffer)
|
FX_TYPE_CLASS_DECLARATION_BEGIN(fx_buffer)
|
||||||
FX_TYPE_CLASS_DECLARATION_END(fx_buffer)
|
FX_TYPE_CLASS_DECLARATION_END(fx_buffer)
|
||||||
|
|
||||||
FX_API fx_type fx_buffer_get_type(void);
|
FX_API fx_type_id fx_buffer_get_type(void);
|
||||||
|
|
||||||
FX_API fx_buffer *fx_buffer_create(size_t item_sz);
|
FX_API fx_buffer *fx_buffer_create(size_t item_sz);
|
||||||
FX_API fx_buffer *fx_buffer_create_from_bytes(const void *p, size_t len);
|
FX_API fx_buffer *fx_buffer_create_from_bytes(const void *p, size_t len);
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ typedef enum fx_datetime_format {
|
|||||||
FX_DATETIME_FORMAT_RFC3339 = 1,
|
FX_DATETIME_FORMAT_RFC3339 = 1,
|
||||||
} fx_datetime_format;
|
} fx_datetime_format;
|
||||||
|
|
||||||
FX_API fx_type fx_datetime_get_type(void);
|
FX_API fx_type_id fx_datetime_get_type(void);
|
||||||
|
|
||||||
FX_TYPE_DEFAULT_CONSTRUCTOR(fx_datetime, FX_TYPE_DATETIME);
|
FX_TYPE_DEFAULT_CONSTRUCTOR(fx_datetime, FX_TYPE_DATETIME);
|
||||||
|
|
||||||
|
|||||||
@@ -37,8 +37,8 @@ typedef struct fx_dict_item {
|
|||||||
fx_object *value;
|
fx_object *value;
|
||||||
} fx_dict_item;
|
} fx_dict_item;
|
||||||
|
|
||||||
FX_API fx_type fx_dict_get_type(void);
|
FX_API fx_type_id fx_dict_get_type(void);
|
||||||
FX_API fx_type fx_dict_iterator_get_type(void);
|
FX_API fx_type_id fx_dict_iterator_get_type(void);
|
||||||
|
|
||||||
FX_TYPE_DEFAULT_CONSTRUCTOR(fx_dict, FX_TYPE_DICT);
|
FX_TYPE_DEFAULT_CONSTRUCTOR(fx_dict, FX_TYPE_DICT);
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
#define FX_DS_HASHMAP_H_
|
#define FX_DS_HASHMAP_H_
|
||||||
|
|
||||||
#include <fx/bst.h>
|
#include <fx/bst.h>
|
||||||
|
#include <fx/iterator.h>
|
||||||
#include <fx/macros.h>
|
#include <fx/macros.h>
|
||||||
#include <fx/misc.h>
|
#include <fx/misc.h>
|
||||||
#include <fx/queue.h>
|
#include <fx/queue.h>
|
||||||
@@ -60,8 +61,8 @@ typedef struct fx_hashmap_item {
|
|||||||
fx_hashmap_value value;
|
fx_hashmap_value value;
|
||||||
} fx_hashmap_item;
|
} fx_hashmap_item;
|
||||||
|
|
||||||
FX_API fx_type fx_hashmap_get_type(void);
|
FX_API fx_type_id fx_hashmap_get_type(void);
|
||||||
FX_API fx_type fx_hashmap_iterator_get_type(void);
|
FX_API fx_type_id fx_hashmap_iterator_get_type(void);
|
||||||
|
|
||||||
FX_API fx_hashmap *fx_hashmap_create(
|
FX_API fx_hashmap *fx_hashmap_create(
|
||||||
fx_hashmap_key_destructor key_dtor,
|
fx_hashmap_key_destructor key_dtor,
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ FX_TYPE_CLASS_DECLARATION_END(fx_list_iterator)
|
|||||||
|
|
||||||
typedef struct fx_list_entry fx_list_entry;
|
typedef struct fx_list_entry fx_list_entry;
|
||||||
|
|
||||||
FX_API fx_type fx_list_get_type(void);
|
FX_API fx_type_id fx_list_get_type(void);
|
||||||
FX_API fx_type fx_list_iterator_get_type(void);
|
FX_API fx_type_id fx_list_iterator_get_type(void);
|
||||||
|
|
||||||
FX_TYPE_DEFAULT_CONSTRUCTOR(fx_list, FX_TYPE_LIST);
|
FX_TYPE_DEFAULT_CONSTRUCTOR(fx_list, FX_TYPE_LIST);
|
||||||
|
|
||||||
|
|||||||
@@ -30,8 +30,8 @@ typedef struct fx_tree_node {
|
|||||||
struct fx_queue_entry __q01;
|
struct fx_queue_entry __q01;
|
||||||
} fx_tree_node;
|
} fx_tree_node;
|
||||||
|
|
||||||
FX_API fx_type fx_tree_get_type(void);
|
FX_API fx_type_id fx_tree_get_type(void);
|
||||||
FX_API fx_type fx_tree_iterator_get_type(void);
|
FX_API fx_type_id fx_tree_iterator_get_type(void);
|
||||||
|
|
||||||
FX_TYPE_DEFAULT_CONSTRUCTOR(fx_tree, FX_TYPE_TREE);
|
FX_TYPE_DEFAULT_CONSTRUCTOR(fx_tree, FX_TYPE_TREE);
|
||||||
|
|
||||||
|
|||||||
+12
-12
@@ -507,16 +507,16 @@ static const fx_iterator_value iterator_get_cvalue(const fx_iterator *obj)
|
|||||||
/*** CLASS DEFINITION *********************************************************/
|
/*** CLASS DEFINITION *********************************************************/
|
||||||
|
|
||||||
// ---- fx_list DEFINITION
|
// ---- fx_list DEFINITION
|
||||||
FX_TYPE_CLASS_DEFINITION_BEGIN(fx_list)
|
FX_TYPE_CLASS_BEGIN(fx_list)
|
||||||
FX_TYPE_CLASS_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
||||||
FX_INTERFACE_ENTRY(to_string) = NULL;
|
FX_INTERFACE_ENTRY(to_string) = NULL;
|
||||||
FX_TYPE_CLASS_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
|
||||||
|
|
||||||
FX_TYPE_CLASS_INTERFACE_BEGIN(fx_iterable, FX_TYPE_ITERABLE)
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_iterable, FX_TYPE_ITERABLE)
|
||||||
FX_INTERFACE_ENTRY(it_begin) = fx_list_begin;
|
FX_INTERFACE_ENTRY(it_begin) = fx_list_begin;
|
||||||
FX_INTERFACE_ENTRY(it_cbegin) = fx_list_cbegin;
|
FX_INTERFACE_ENTRY(it_cbegin) = fx_list_cbegin;
|
||||||
FX_TYPE_CLASS_INTERFACE_END(fx_iterable, FX_TYPE_ITERABLE)
|
FX_TYPE_VTABLE_INTERFACE_END(fx_iterable, FX_TYPE_ITERABLE)
|
||||||
FX_TYPE_CLASS_DEFINITION_END(fx_list)
|
FX_TYPE_CLASS_END(fx_list)
|
||||||
|
|
||||||
FX_TYPE_DEFINITION_BEGIN(fx_list)
|
FX_TYPE_DEFINITION_BEGIN(fx_list)
|
||||||
FX_TYPE_ID(0x8730e66f, 0x0fd9, 0x4773, 0x9bbd, 0x6428f6e495eb);
|
FX_TYPE_ID(0x8730e66f, 0x0fd9, 0x4773, 0x9bbd, 0x6428f6e495eb);
|
||||||
@@ -528,18 +528,18 @@ FX_TYPE_DEFINITION_BEGIN(fx_list)
|
|||||||
FX_TYPE_DEFINITION_END(fx_list)
|
FX_TYPE_DEFINITION_END(fx_list)
|
||||||
|
|
||||||
// ---- fx_list_iterator DEFINITION
|
// ---- fx_list_iterator DEFINITION
|
||||||
FX_TYPE_CLASS_DEFINITION_BEGIN(fx_list_iterator)
|
FX_TYPE_CLASS_BEGIN(fx_list_iterator)
|
||||||
FX_TYPE_CLASS_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
||||||
FX_INTERFACE_ENTRY(to_string) = NULL;
|
FX_INTERFACE_ENTRY(to_string) = NULL;
|
||||||
FX_TYPE_CLASS_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
|
||||||
|
|
||||||
FX_TYPE_CLASS_INTERFACE_BEGIN(fx_iterator, FX_TYPE_ITERATOR)
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_iterator, FX_TYPE_ITERATOR)
|
||||||
FX_INTERFACE_ENTRY(it_move_next) = iterator_move_next;
|
FX_INTERFACE_ENTRY(it_move_next) = iterator_move_next;
|
||||||
FX_INTERFACE_ENTRY(it_erase) = iterator_erase;
|
FX_INTERFACE_ENTRY(it_erase) = iterator_erase;
|
||||||
FX_INTERFACE_ENTRY(it_get_value) = iterator_get_value;
|
FX_INTERFACE_ENTRY(it_get_value) = iterator_get_value;
|
||||||
FX_INTERFACE_ENTRY(it_get_cvalue) = iterator_get_cvalue;
|
FX_INTERFACE_ENTRY(it_get_cvalue) = iterator_get_cvalue;
|
||||||
FX_TYPE_CLASS_INTERFACE_END(fx_iterator, FX_TYPE_ITERATOR)
|
FX_TYPE_VTABLE_INTERFACE_END(fx_iterator, FX_TYPE_ITERATOR)
|
||||||
FX_TYPE_CLASS_DEFINITION_END(fx_list_iterator)
|
FX_TYPE_CLASS_END(fx_list_iterator)
|
||||||
|
|
||||||
FX_TYPE_DEFINITION_BEGIN(fx_list_iterator)
|
FX_TYPE_DEFINITION_BEGIN(fx_list_iterator)
|
||||||
FX_TYPE_ID(0xd9658456, 0xdd80, 0x419a, 0xb23a, 0xb513013e6431);
|
FX_TYPE_ID(0xd9658456, 0xdd80, 0x419a, 0xb23a, 0xb513013e6431);
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
#include <fx/ds/array.h>
|
#include <fx/collections/array.h>
|
||||||
#include <fx/ds/number.h>
|
#include <fx/int.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
fx_array *array = fx_array_create();
|
fx_array *array = fx_array_create();
|
||||||
fx_array_append(array, FX_RV_INT(32));
|
fx_array_append(array, fx_int_create(32));
|
||||||
fx_array_append(array, FX_RV_INT(64));
|
fx_array_append(array, fx_int_create(64));
|
||||||
fx_array_append(array, FX_RV_INT(128));
|
fx_array_append(array, fx_int_create(128));
|
||||||
|
|
||||||
fx_iterator *it = fx_iterator_begin(array);
|
fx_iterator *it = fx_iterator_begin(array);
|
||||||
fx_foreach_ptr(fx_object, obj, it)
|
fx_foreach_ptr(fx_object, obj, it)
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
#include <fx/ds/number.h>
|
#include <fx/double.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
fx_number *number = fx_number_create_float(6.8);
|
fx_double *d = fx_double_create(6.8);
|
||||||
|
|
||||||
|
printf("double=%lf\n", fx_double_get_value(d));
|
||||||
|
fx_double_unref(d);
|
||||||
|
|
||||||
printf("number=%zd\n", FX_NUMBER_IVAL(number));
|
|
||||||
fx_number_unref(number);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include <fx/ds/string.h>
|
#include <fx/string.h>
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#include <fx/core/stream.h>
|
#include <fx/stream.h>
|
||||||
#include <fx/core/stringstream.h>
|
#include <fx/string.h>
|
||||||
#include <fx/ds/string.h>
|
#include <fx/stringstream.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
int main(int argc, const char **argv)
|
int main(int argc, const char **argv)
|
||||||
|
|||||||
+14
-11
@@ -1,8 +1,9 @@
|
|||||||
#include <fx/core/bst.h>
|
#include <fx/bst.h>
|
||||||
#include <fx/core/iterator.h>
|
#include <fx/collections/dict.h>
|
||||||
#include <fx/ds/dict.h>
|
#include <fx/collections/tree.h>
|
||||||
#include <fx/ds/number.h>
|
#include <fx/int.h>
|
||||||
#include <fx/ds/tree.h>
|
#include <fx/iterator.h>
|
||||||
|
#include <inttypes.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#define NITEMS 16
|
#define NITEMS 16
|
||||||
@@ -23,18 +24,20 @@ FX_BST_DEFINE_SIMPLE_INSERT(struct bst_item, node, value, put_node)
|
|||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
fx_dict *dict = fx_dict_create();
|
fx_dict *dict = fx_dict_create();
|
||||||
fx_dict_put(dict, "hello", FX_RV_INT(32));
|
fx_dict_put(dict, "hello", fx_int_create(32));
|
||||||
fx_dict_put(dict, "world", FX_RV_INT(64));
|
fx_dict_put(dict, "world", fx_int_create(64));
|
||||||
fx_dict_put(dict, "more", FX_RV_INT(128));
|
fx_dict_put(dict, "more", fx_int_create(128));
|
||||||
fx_dict_put(dict, "other", FX_RV_INT(256));
|
fx_dict_put(dict, "other", fx_int_create(256));
|
||||||
|
|
||||||
fx_iterator *it = fx_iterator_begin(dict);
|
fx_iterator *it = fx_iterator_begin(dict);
|
||||||
|
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
fx_foreach(fx_dict_item *, item, it)
|
fx_foreach(fx_dict_item *, item, it)
|
||||||
{
|
{
|
||||||
printf("item %zu: %s=%d\n", i++, fx_string_get_cstr(item->key),
|
printf("item %zu: %s=%" PRIdPTR "\n",
|
||||||
fx_number_get_int(item->value));
|
i++,
|
||||||
|
fx_string_get_cstr(item->key),
|
||||||
|
fx_int_get_value(item->value));
|
||||||
}
|
}
|
||||||
|
|
||||||
fx_iterator_unref(it);
|
fx_iterator_unref(it);
|
||||||
|
|||||||
@@ -1,50 +0,0 @@
|
|||||||
#include <CuTest.h>
|
|
||||||
#include <fx/ds/string.h>
|
|
||||||
|
|
||||||
static void test_string_create(CuTest *tc)
|
|
||||||
{
|
|
||||||
fx_string *str = fx_string_create();
|
|
||||||
|
|
||||||
CuAssertPtrNotNull(tc, str);
|
|
||||||
CuAssertIntEquals(tc, 0, fx_string_get_size(str, FX_STRLEN_NORMAL));
|
|
||||||
CuAssertStrEquals(tc, "", fx_string_get_cstr(str));
|
|
||||||
|
|
||||||
fx_string_unref(str);
|
|
||||||
|
|
||||||
str = fx_string_create_from_c('A', 8);
|
|
||||||
|
|
||||||
CuAssertPtrNotNull(tc, str);
|
|
||||||
CuAssertIntEquals(tc, 8, fx_string_get_size(str, FX_STRLEN_NORMAL));
|
|
||||||
CuAssertStrEquals(tc, "AAAAAAAA", fx_string_get_cstr(str));
|
|
||||||
|
|
||||||
fx_string_unref(str);
|
|
||||||
|
|
||||||
str = fx_string_create_from_cstr("Hello, world!");
|
|
||||||
|
|
||||||
CuAssertPtrNotNull(tc, str);
|
|
||||||
CuAssertIntEquals(tc, 13, fx_string_get_size(str, FX_STRLEN_NORMAL));
|
|
||||||
CuAssertStrEquals(tc, "Hello, world!", fx_string_get_cstr(str));
|
|
||||||
|
|
||||||
fx_string_unref(str);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void test_string_length(CuTest *tc)
|
|
||||||
{
|
|
||||||
const char *cstr = "Hello, \033[91;1mworld!";
|
|
||||||
fx_string *s = fx_string_create_from_cstr(cstr);
|
|
||||||
|
|
||||||
CuAssertIntEquals(tc, 13, fx_string_get_size(s, FX_STRLEN_IGNORE_ESC));
|
|
||||||
CuAssertIntEquals(tc, 20, fx_string_get_size(s, FX_STRLEN_NORMAL));
|
|
||||||
|
|
||||||
fx_string_unref(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
CuSuite *get_all_tests(void)
|
|
||||||
{
|
|
||||||
CuSuite *suite = CuSuiteNew();
|
|
||||||
|
|
||||||
SUITE_ADD_TEST(suite, test_string_create);
|
|
||||||
SUITE_ADD_TEST(suite, test_string_length);
|
|
||||||
|
|
||||||
return suite;
|
|
||||||
}
|
|
||||||
+12
-12
@@ -348,16 +348,16 @@ static const fx_iterator_value iterator_get_cvalue(const fx_iterator *obj)
|
|||||||
/*** CLASS DEFINITION *********************************************************/
|
/*** CLASS DEFINITION *********************************************************/
|
||||||
|
|
||||||
// ---- fx_tree DEFINITION
|
// ---- fx_tree DEFINITION
|
||||||
FX_TYPE_CLASS_DEFINITION_BEGIN(fx_tree)
|
FX_TYPE_CLASS_BEGIN(fx_tree)
|
||||||
FX_TYPE_CLASS_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
||||||
FX_INTERFACE_ENTRY(to_string) = NULL;
|
FX_INTERFACE_ENTRY(to_string) = NULL;
|
||||||
FX_TYPE_CLASS_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
|
||||||
|
|
||||||
FX_TYPE_CLASS_INTERFACE_BEGIN(fx_iterable, FX_TYPE_ITERABLE)
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_iterable, FX_TYPE_ITERABLE)
|
||||||
FX_INTERFACE_ENTRY(it_begin) = fx_tree_begin;
|
FX_INTERFACE_ENTRY(it_begin) = fx_tree_begin;
|
||||||
FX_INTERFACE_ENTRY(it_cbegin) = fx_tree_cbegin;
|
FX_INTERFACE_ENTRY(it_cbegin) = fx_tree_cbegin;
|
||||||
FX_TYPE_CLASS_INTERFACE_END(fx_iterable, FX_TYPE_ITERABLE)
|
FX_TYPE_VTABLE_INTERFACE_END(fx_iterable, FX_TYPE_ITERABLE)
|
||||||
FX_TYPE_CLASS_DEFINITION_END(fx_tree)
|
FX_TYPE_CLASS_END(fx_tree)
|
||||||
|
|
||||||
FX_TYPE_DEFINITION_BEGIN(fx_tree)
|
FX_TYPE_DEFINITION_BEGIN(fx_tree)
|
||||||
FX_TYPE_ID(0x8d8fa36b, 0xc515, 0x4803, 0x8124, 0xfd704f01b8ae);
|
FX_TYPE_ID(0x8d8fa36b, 0xc515, 0x4803, 0x8124, 0xfd704f01b8ae);
|
||||||
@@ -369,18 +369,18 @@ FX_TYPE_DEFINITION_BEGIN(fx_tree)
|
|||||||
FX_TYPE_DEFINITION_END(fx_tree)
|
FX_TYPE_DEFINITION_END(fx_tree)
|
||||||
|
|
||||||
// ---- fx_tree_iterator DEFINITION
|
// ---- fx_tree_iterator DEFINITION
|
||||||
FX_TYPE_CLASS_DEFINITION_BEGIN(fx_tree_iterator)
|
FX_TYPE_CLASS_BEGIN(fx_tree_iterator)
|
||||||
FX_TYPE_CLASS_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
||||||
FX_INTERFACE_ENTRY(to_string) = NULL;
|
FX_INTERFACE_ENTRY(to_string) = NULL;
|
||||||
FX_TYPE_CLASS_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
|
||||||
|
|
||||||
FX_TYPE_CLASS_INTERFACE_BEGIN(fx_iterator, FX_TYPE_ITERATOR)
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_iterator, FX_TYPE_ITERATOR)
|
||||||
FX_INTERFACE_ENTRY(it_move_next) = iterator_move_next;
|
FX_INTERFACE_ENTRY(it_move_next) = iterator_move_next;
|
||||||
FX_INTERFACE_ENTRY(it_erase) = iterator_erase;
|
FX_INTERFACE_ENTRY(it_erase) = iterator_erase;
|
||||||
FX_INTERFACE_ENTRY(it_get_value) = iterator_get_value;
|
FX_INTERFACE_ENTRY(it_get_value) = iterator_get_value;
|
||||||
FX_INTERFACE_ENTRY(it_get_cvalue) = iterator_get_cvalue;
|
FX_INTERFACE_ENTRY(it_get_cvalue) = iterator_get_cvalue;
|
||||||
FX_TYPE_CLASS_INTERFACE_END(fx_iterator, FX_TYPE_ITERATOR)
|
FX_TYPE_VTABLE_INTERFACE_END(fx_iterator, FX_TYPE_ITERATOR)
|
||||||
FX_TYPE_CLASS_DEFINITION_END(fx_tree_iterator)
|
FX_TYPE_CLASS_END(fx_tree_iterator)
|
||||||
|
|
||||||
FX_TYPE_DEFINITION_BEGIN(fx_tree_iterator)
|
FX_TYPE_DEFINITION_BEGIN(fx_tree_iterator)
|
||||||
FX_TYPE_ID(0xb896e671, 0x84b2, 0x4892, 0xaf09, 0x407f305f4bf8);
|
FX_TYPE_ID(0xb896e671, 0x84b2, 0x4892, 0xaf09, 0x407f305f4bf8);
|
||||||
|
|||||||
@@ -162,7 +162,7 @@ static bool compressor_eof(const struct compressor_data *p)
|
|||||||
/*** PUBLIC FUNCTIONS *********************************************************/
|
/*** PUBLIC FUNCTIONS *********************************************************/
|
||||||
|
|
||||||
enum fx_status fx_compressor_get_buffer_size(
|
enum fx_status fx_compressor_get_buffer_size(
|
||||||
fx_type type,
|
fx_type_id type,
|
||||||
fx_compressor_mode mode,
|
fx_compressor_mode mode,
|
||||||
size_t *inbuf_size,
|
size_t *inbuf_size,
|
||||||
size_t *outbuf_size)
|
size_t *outbuf_size)
|
||||||
@@ -248,11 +248,11 @@ static void compressor_fini(fx_object *obj, void *priv)
|
|||||||
|
|
||||||
/*** CLASS DEFINITION *********************************************************/
|
/*** CLASS DEFINITION *********************************************************/
|
||||||
|
|
||||||
FX_TYPE_CLASS_DEFINITION_BEGIN(fx_compressor)
|
FX_TYPE_CLASS_BEGIN(fx_compressor)
|
||||||
FX_TYPE_CLASS_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
||||||
FX_INTERFACE_ENTRY(to_string) = NULL;
|
FX_INTERFACE_ENTRY(to_string) = NULL;
|
||||||
FX_TYPE_CLASS_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
|
||||||
FX_TYPE_CLASS_DEFINITION_END(fx_compressor)
|
FX_TYPE_CLASS_END(fx_compressor)
|
||||||
|
|
||||||
FX_TYPE_DEFINITION_BEGIN(fx_compressor)
|
FX_TYPE_DEFINITION_BEGIN(fx_compressor)
|
||||||
FX_TYPE_ID(0x452ee0f9, 0xfe12, 0x48a1, 0xb596, 0xad5b7a3940e7);
|
FX_TYPE_ID(0x452ee0f9, 0xfe12, 0x48a1, 0xb596, 0xad5b7a3940e7);
|
||||||
|
|||||||
@@ -782,7 +782,7 @@ static enum fx_status cstream_restore_cursor_position(
|
|||||||
|
|
||||||
enum fx_status fx_cstream_open(
|
enum fx_status fx_cstream_open(
|
||||||
fx_stream *endpoint,
|
fx_stream *endpoint,
|
||||||
fx_type compressor_type,
|
fx_type_id compressor_type,
|
||||||
fx_compressor_mode mode,
|
fx_compressor_mode mode,
|
||||||
fx_cstream **out)
|
fx_cstream **out)
|
||||||
{
|
{
|
||||||
@@ -989,12 +989,12 @@ static void cstream_fini(fx_object *obj, void *priv)
|
|||||||
|
|
||||||
/*** CLASS DEFINITION *********************************************************/
|
/*** CLASS DEFINITION *********************************************************/
|
||||||
|
|
||||||
FX_TYPE_CLASS_DEFINITION_BEGIN(fx_cstream)
|
FX_TYPE_CLASS_BEGIN(fx_cstream)
|
||||||
FX_TYPE_CLASS_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
||||||
FX_INTERFACE_ENTRY(to_string) = NULL;
|
FX_INTERFACE_ENTRY(to_string) = NULL;
|
||||||
FX_TYPE_CLASS_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
|
||||||
|
|
||||||
FX_TYPE_CLASS_INTERFACE_BEGIN(fx_stream, FX_TYPE_STREAM)
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_stream, FX_TYPE_STREAM)
|
||||||
FX_INTERFACE_ENTRY(s_close) = NULL;
|
FX_INTERFACE_ENTRY(s_close) = NULL;
|
||||||
FX_INTERFACE_ENTRY(s_seek) = NULL;
|
FX_INTERFACE_ENTRY(s_seek) = NULL;
|
||||||
FX_INTERFACE_ENTRY(s_tell) = NULL;
|
FX_INTERFACE_ENTRY(s_tell) = NULL;
|
||||||
@@ -1002,8 +1002,8 @@ FX_TYPE_CLASS_DEFINITION_BEGIN(fx_cstream)
|
|||||||
FX_INTERFACE_ENTRY(s_read) = fx_cstream_read;
|
FX_INTERFACE_ENTRY(s_read) = fx_cstream_read;
|
||||||
FX_INTERFACE_ENTRY(s_write) = fx_cstream_write;
|
FX_INTERFACE_ENTRY(s_write) = fx_cstream_write;
|
||||||
FX_INTERFACE_ENTRY(s_reserve) = NULL;
|
FX_INTERFACE_ENTRY(s_reserve) = NULL;
|
||||||
FX_TYPE_CLASS_INTERFACE_END(fx_stream, FX_TYPE_STREAM)
|
FX_TYPE_VTABLE_INTERFACE_END(fx_stream, FX_TYPE_STREAM)
|
||||||
FX_TYPE_CLASS_DEFINITION_END(fx_cstream)
|
FX_TYPE_CLASS_END(fx_cstream)
|
||||||
|
|
||||||
FX_TYPE_DEFINITION_BEGIN(fx_cstream)
|
FX_TYPE_DEFINITION_BEGIN(fx_cstream)
|
||||||
FX_TYPE_ID(0xe1e899b5, 0x6a3c, 0x4f9c, 0xafd0, 0xaab3f156615c);
|
FX_TYPE_ID(0xe1e899b5, 0x6a3c, 0x4f9c, 0xafd0, 0xaab3f156615c);
|
||||||
|
|||||||
@@ -361,12 +361,12 @@ static enum fx_status set_mode(
|
|||||||
|
|
||||||
/*** CLASS DEFINITION *********************************************************/
|
/*** CLASS DEFINITION *********************************************************/
|
||||||
|
|
||||||
FX_TYPE_CLASS_DEFINITION_BEGIN(fx_zstd_compressor)
|
FX_TYPE_CLASS_BEGIN(fx_zstd_compressor)
|
||||||
FX_TYPE_CLASS_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
||||||
FX_INTERFACE_ENTRY(to_string) = NULL;
|
FX_INTERFACE_ENTRY(to_string) = NULL;
|
||||||
FX_TYPE_CLASS_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
|
||||||
|
|
||||||
FX_TYPE_CLASS_INTERFACE_BEGIN(fx_compressor, FX_TYPE_COMPRESSOR)
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_compressor, FX_TYPE_COMPRESSOR)
|
||||||
FX_INTERFACE_ENTRY(c_buffer_size)
|
FX_INTERFACE_ENTRY(c_buffer_size)
|
||||||
= fx_zstd_compressor_get_buffer_size;
|
= fx_zstd_compressor_get_buffer_size;
|
||||||
FX_INTERFACE_ENTRY(c_compress) = compress;
|
FX_INTERFACE_ENTRY(c_compress) = compress;
|
||||||
@@ -374,8 +374,8 @@ FX_TYPE_CLASS_DEFINITION_BEGIN(fx_zstd_compressor)
|
|||||||
FX_INTERFACE_ENTRY(c_decompress) = decompress;
|
FX_INTERFACE_ENTRY(c_decompress) = decompress;
|
||||||
FX_INTERFACE_ENTRY(c_reset) = reset;
|
FX_INTERFACE_ENTRY(c_reset) = reset;
|
||||||
FX_INTERFACE_ENTRY(c_set_mode) = set_mode;
|
FX_INTERFACE_ENTRY(c_set_mode) = set_mode;
|
||||||
FX_TYPE_CLASS_INTERFACE_END(fx_compressor, FX_TYPE_COMPRESSOR)
|
FX_TYPE_VTABLE_INTERFACE_END(fx_compressor, FX_TYPE_COMPRESSOR)
|
||||||
FX_TYPE_CLASS_DEFINITION_END(fx_zstd_compressor)
|
FX_TYPE_CLASS_END(fx_zstd_compressor)
|
||||||
|
|
||||||
FX_TYPE_DEFINITION_BEGIN(fx_zstd_compressor)
|
FX_TYPE_DEFINITION_BEGIN(fx_zstd_compressor)
|
||||||
FX_TYPE_ID(0x51d437fc, 0xe789, 0x4105, 0xbac7, 0xe6b3f45df198);
|
FX_TYPE_ID(0x51d437fc, 0xe789, 0x4105, 0xbac7, 0xe6b3f45df198);
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ typedef struct fx_compressor_data {
|
|||||||
fx_ringbuffer *c_in, *c_out;
|
fx_ringbuffer *c_in, *c_out;
|
||||||
} fx_compressor_data;
|
} fx_compressor_data;
|
||||||
|
|
||||||
FX_API fx_type fx_compressor_get_type(void);
|
FX_API fx_type_id fx_compressor_get_type(void);
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
FX_API fx_status fx_compressor_create(
|
FX_API fx_status fx_compressor_create(
|
||||||
@@ -48,7 +48,7 @@ FX_API fx_status fx_compressor_create(
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
FX_API fx_status fx_compressor_get_buffer_size(
|
FX_API fx_status fx_compressor_get_buffer_size(
|
||||||
fx_type type,
|
fx_type_id type,
|
||||||
fx_compressor_mode mode,
|
fx_compressor_mode mode,
|
||||||
size_t *inbuf_size,
|
size_t *inbuf_size,
|
||||||
size_t *outbuf_size);
|
size_t *outbuf_size);
|
||||||
|
|||||||
@@ -16,11 +16,11 @@ FX_DECLARE_TYPE(fx_cstream);
|
|||||||
FX_TYPE_CLASS_DECLARATION_BEGIN(fx_cstream)
|
FX_TYPE_CLASS_DECLARATION_BEGIN(fx_cstream)
|
||||||
FX_TYPE_CLASS_DECLARATION_END(fx_cstream)
|
FX_TYPE_CLASS_DECLARATION_END(fx_cstream)
|
||||||
|
|
||||||
FX_API fx_type fx_cstream_get_type(void);
|
FX_API fx_type_id fx_cstream_get_type(void);
|
||||||
|
|
||||||
FX_API fx_status fx_cstream_open(
|
FX_API fx_status fx_cstream_open(
|
||||||
fx_stream *endpoint,
|
fx_stream *endpoint,
|
||||||
fx_type compressor_type,
|
fx_type_id compressor_type,
|
||||||
enum fx_compressor_mode mode,
|
enum fx_compressor_mode mode,
|
||||||
fx_cstream **out);
|
fx_cstream **out);
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ FX_DECLARE_TYPE(fx_zstd_compressor);
|
|||||||
FX_TYPE_CLASS_DECLARATION_BEGIN(fx_zstd_compressor)
|
FX_TYPE_CLASS_DECLARATION_BEGIN(fx_zstd_compressor)
|
||||||
FX_TYPE_CLASS_DECLARATION_END(fx_compressor)
|
FX_TYPE_CLASS_DECLARATION_END(fx_compressor)
|
||||||
|
|
||||||
FX_API fx_type fx_zstd_compressor_get_type(void);
|
FX_API fx_type_id fx_zstd_compressor_get_type(void);
|
||||||
|
|
||||||
FX_API fx_status fx_zstd_compressor_get_buffer_size(
|
FX_API fx_status fx_zstd_compressor_get_buffer_size(
|
||||||
fx_compressor_mode mode,
|
fx_compressor_mode mode,
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <fx/compress/compressor.h>
|
#include <fx/compression/compressor.h>
|
||||||
#include <fx/compress/cstream.h>
|
#include <fx/compression/cstream.h>
|
||||||
#include <fx/compress/zstd.h>
|
#include <fx/compression/zstd.h>
|
||||||
#include <fx/core/ringbuffer.h>
|
#include <fx/ringbuffer.h>
|
||||||
#include <fx/core/stream.h>
|
#include <fx/stream.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
@@ -48,9 +48,13 @@ int main(int argc, const char **argv)
|
|||||||
|
|
||||||
size_t nr_written = 0;
|
size_t nr_written = 0;
|
||||||
fx_status status = fx_cstream_write(
|
fx_status status = fx_cstream_write(
|
||||||
cstream, source, source_len, &nr_written);
|
cstream,
|
||||||
|
source,
|
||||||
|
source_len,
|
||||||
|
&nr_written);
|
||||||
if (!FX_OK(status)) {
|
if (!FX_OK(status)) {
|
||||||
fprintf(stderr, "write error: %s\n",
|
fprintf(stderr,
|
||||||
|
"write error: %s\n",
|
||||||
fx_status_description(status));
|
fx_status_description(status));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -59,14 +63,19 @@ int main(int argc, const char **argv)
|
|||||||
|
|
||||||
if (compressed) {
|
if (compressed) {
|
||||||
fx_cstream_end_compressed_section(
|
fx_cstream_end_compressed_section(
|
||||||
cstream, &nr_written_compressed, &nr_written);
|
cstream,
|
||||||
|
&nr_written_compressed,
|
||||||
|
&nr_written);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t tx_total = 0;
|
size_t tx_total = 0;
|
||||||
fx_cstream_tx_bytes(cstream, &tx_total);
|
fx_cstream_tx_bytes(cstream, &tx_total);
|
||||||
printf("iteration %d: wrote %zu (compressed) / %zu "
|
printf("iteration %d: wrote %zu (compressed) / %zu "
|
||||||
"(uncompressed) / %zu (total) bytes (%s)\n",
|
"(uncompressed) / %zu (total) bytes (%s)\n",
|
||||||
i, nr_written_compressed, nr_written, tx_total,
|
i,
|
||||||
|
nr_written_compressed,
|
||||||
|
nr_written,
|
||||||
|
tx_total,
|
||||||
compressed ? "compressed" : "uncompressed");
|
compressed ? "compressed" : "uncompressed");
|
||||||
|
|
||||||
compressed = !compressed;
|
compressed = !compressed;
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <fx/compress/compressor.h>
|
#include <fx/compression/compressor.h>
|
||||||
#include <fx/compress/cstream.h>
|
#include <fx/compression/cstream.h>
|
||||||
#include <fx/compress/zstd.h>
|
#include <fx/compression/zstd.h>
|
||||||
#include <fx/core/ringbuffer.h>
|
#include <fx/ringbuffer.h>
|
||||||
#include <fx/core/stream.h>
|
#include <fx/stream.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
@@ -37,10 +37,14 @@ int main(int argc, const char **argv)
|
|||||||
memset(buf, 0x0, sizeof buf);
|
memset(buf, 0x0, sizeof buf);
|
||||||
|
|
||||||
size_t nr_read = 0;
|
size_t nr_read = 0;
|
||||||
fx_status status
|
fx_status status = fx_cstream_read(
|
||||||
= fx_cstream_read(cstream, buf, sizeof buf - 1, &nr_read);
|
cstream,
|
||||||
|
buf,
|
||||||
|
sizeof buf - 1,
|
||||||
|
&nr_read);
|
||||||
if (!FX_OK(status)) {
|
if (!FX_OK(status)) {
|
||||||
fprintf(stderr, "write error: %s\n",
|
fprintf(stderr,
|
||||||
|
"write error: %s\n",
|
||||||
fx_status_description(status));
|
fx_status_description(status));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -52,14 +56,19 @@ int main(int argc, const char **argv)
|
|||||||
size_t nr_read_compressed = 0;
|
size_t nr_read_compressed = 0;
|
||||||
if (compressed) {
|
if (compressed) {
|
||||||
fx_cstream_end_compressed_section(
|
fx_cstream_end_compressed_section(
|
||||||
cstream, &nr_read_compressed, &nr_read);
|
cstream,
|
||||||
|
&nr_read_compressed,
|
||||||
|
&nr_read);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t tx_total = 0;
|
size_t tx_total = 0;
|
||||||
fx_cstream_tx_bytes(cstream, &tx_total);
|
fx_cstream_tx_bytes(cstream, &tx_total);
|
||||||
printf(" * iteration %d: read %zu (compressed) / %zu "
|
printf(" * iteration %d: read %zu (compressed) / %zu "
|
||||||
"(uncompressed) / %zu (total) bytes (%s)\n",
|
"(uncompressed) / %zu (total) bytes (%s)\n",
|
||||||
i, nr_read_compressed, nr_read, tx_total,
|
i,
|
||||||
|
nr_read_compressed,
|
||||||
|
nr_read,
|
||||||
|
tx_total,
|
||||||
compressed ? "compressed" : "uncompressed");
|
compressed ? "compressed" : "uncompressed");
|
||||||
printf("%s\n", buf);
|
printf("%s\n", buf);
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <fx/compress/compressor.h>
|
#include <fx/compression/compressor.h>
|
||||||
#include <fx/compress/zstd.h>
|
#include <fx/compression/zstd.h>
|
||||||
#include <fx/core/ringbuffer.h>
|
#include <fx/ringbuffer.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
@@ -12,8 +12,10 @@ int refill_input_buffer(FILE *fp, fx_ringbuffer *dest)
|
|||||||
while (1) {
|
while (1) {
|
||||||
void *buf;
|
void *buf;
|
||||||
size_t capacity;
|
size_t capacity;
|
||||||
fx_status status
|
fx_status status = fx_ringbuffer_open_write_buffer(
|
||||||
= fx_ringbuffer_open_write_buffer(dest, &buf, &capacity);
|
dest,
|
||||||
|
&buf,
|
||||||
|
&capacity);
|
||||||
if (status == FX_ERR_NO_SPACE) {
|
if (status == FX_ERR_NO_SPACE) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -43,8 +45,10 @@ int flush_output_buffer(FILE *fp, fx_ringbuffer *src)
|
|||||||
while (1) {
|
while (1) {
|
||||||
const void *buf;
|
const void *buf;
|
||||||
size_t capacity;
|
size_t capacity;
|
||||||
fx_status status
|
fx_status status = fx_ringbuffer_open_read_buffer(
|
||||||
= fx_ringbuffer_open_read_buffer(src, &buf, &capacity);
|
src,
|
||||||
|
&buf,
|
||||||
|
&capacity);
|
||||||
if (status == FX_ERR_NO_DATA) {
|
if (status == FX_ERR_NO_DATA) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -68,7 +72,9 @@ int flush_output_buffer(FILE *fp, fx_ringbuffer *src)
|
|||||||
int main(int argc, const char **argv)
|
int main(int argc, const char **argv)
|
||||||
{
|
{
|
||||||
if (argc < 4) {
|
if (argc < 4) {
|
||||||
fprintf(stderr, "usage: %s <C/D> <inpath> <outpath>\n", argv[0]);
|
fprintf(stderr,
|
||||||
|
"usage: %s <C/D> <inpath> <outpath>\n",
|
||||||
|
argv[0]);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,12 +102,15 @@ int main(int argc, const char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
fx_status status = FX_SUCCESS;
|
fx_status status = FX_SUCCESS;
|
||||||
fx_type compressor_type = FX_TYPE_ZSTD_COMPRESSOR;
|
fx_type_id compressor_type = FX_TYPE_ZSTD_COMPRESSOR;
|
||||||
fx_compressor *compressor = fx_object_create(compressor_type);
|
fx_compressor *compressor = fx_object_create(compressor_type);
|
||||||
|
|
||||||
size_t inbuf_size, outbuf_size;
|
size_t inbuf_size, outbuf_size;
|
||||||
fx_compressor_get_buffer_size(
|
fx_compressor_get_buffer_size(
|
||||||
compressor_type, mode, &inbuf_size, &outbuf_size);
|
compressor_type,
|
||||||
|
mode,
|
||||||
|
&inbuf_size,
|
||||||
|
&outbuf_size);
|
||||||
|
|
||||||
fx_ringbuffer *in = fx_ringbuffer_create(inbuf_size);
|
fx_ringbuffer *in = fx_ringbuffer_create(inbuf_size);
|
||||||
fx_ringbuffer *out = fx_ringbuffer_create(outbuf_size);
|
fx_ringbuffer *out = fx_ringbuffer_create(outbuf_size);
|
||||||
|
|||||||
@@ -1,21 +1,24 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <fx/compress/compressor.h>
|
#include <fx/compression/compressor.h>
|
||||||
#include <fx/compress/cstream.h>
|
#include <fx/compression/cstream.h>
|
||||||
#include <fx/compress/zstd.h>
|
#include <fx/compression/zstd.h>
|
||||||
#include <fx/core/ringbuffer.h>
|
#include <fx/ringbuffer.h>
|
||||||
#include <fx/core/stream.h>
|
#include <fx/stream.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#define BUF_SIZE 32
|
#define BUF_SIZE 32
|
||||||
|
|
||||||
static int compress(fx_type compressor_type, FILE *in, FILE *out)
|
static int compress(fx_type_id compressor_type, FILE *in, FILE *out)
|
||||||
{
|
{
|
||||||
fx_stream *out_stream = fx_stream_open_fp(out);
|
fx_stream *out_stream = fx_stream_open_fp(out);
|
||||||
|
|
||||||
fx_cstream *cstream;
|
fx_cstream *cstream;
|
||||||
fx_status status = fx_cstream_open(
|
fx_status status = fx_cstream_open(
|
||||||
out_stream, compressor_type, FX_COMPRESSOR_MODE_COMPRESS, &cstream);
|
out_stream,
|
||||||
|
compressor_type,
|
||||||
|
FX_COMPRESSOR_MODE_COMPRESS,
|
||||||
|
&cstream);
|
||||||
|
|
||||||
if (!FX_OK(status)) {
|
if (!FX_OK(status)) {
|
||||||
fprintf(stderr, "cannot initialise compressor\n");
|
fprintf(stderr, "cannot initialise compressor\n");
|
||||||
@@ -48,13 +51,16 @@ static int compress(fx_type compressor_type, FILE *in, FILE *out)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int decompress(fx_type compressor_type, FILE *in, FILE *out)
|
static int decompress(fx_type_id compressor_type, FILE *in, FILE *out)
|
||||||
{
|
{
|
||||||
fx_stream *in_stream = fx_stream_open_fp(in);
|
fx_stream *in_stream = fx_stream_open_fp(in);
|
||||||
|
|
||||||
fx_cstream *cstream;
|
fx_cstream *cstream;
|
||||||
fx_status status = fx_cstream_open(
|
fx_status status = fx_cstream_open(
|
||||||
in_stream, compressor_type, FX_COMPRESSOR_MODE_DECOMPRESS, &cstream);
|
in_stream,
|
||||||
|
compressor_type,
|
||||||
|
FX_COMPRESSOR_MODE_DECOMPRESS,
|
||||||
|
&cstream);
|
||||||
|
|
||||||
if (!FX_OK(status)) {
|
if (!FX_OK(status)) {
|
||||||
fprintf(stderr, "cannot initialise compressor\n");
|
fprintf(stderr, "cannot initialise compressor\n");
|
||||||
@@ -66,9 +72,14 @@ static int decompress(fx_type compressor_type, FILE *in, FILE *out)
|
|||||||
char buf[4096];
|
char buf[4096];
|
||||||
while (1) {
|
while (1) {
|
||||||
size_t r = 0;
|
size_t r = 0;
|
||||||
fx_status status = fx_cstream_read(cstream, buf, sizeof buf, &r);
|
fx_status status = fx_cstream_read(
|
||||||
|
cstream,
|
||||||
|
buf,
|
||||||
|
sizeof buf,
|
||||||
|
&r);
|
||||||
if (!FX_OK(status)) {
|
if (!FX_OK(status)) {
|
||||||
fprintf(stderr, "read error: %s\n",
|
fprintf(stderr,
|
||||||
|
"read error: %s\n",
|
||||||
fx_status_description(status));
|
fx_status_description(status));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -94,7 +105,9 @@ static int decompress(fx_type compressor_type, FILE *in, FILE *out)
|
|||||||
int main(int argc, const char **argv)
|
int main(int argc, const char **argv)
|
||||||
{
|
{
|
||||||
if (argc < 4) {
|
if (argc < 4) {
|
||||||
fprintf(stderr, "usage: %s <C/D> <inpath> <outpath>\n", argv[0]);
|
fprintf(stderr,
|
||||||
|
"usage: %s <C/D> <inpath> <outpath>\n",
|
||||||
|
argv[0]);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -45,8 +45,8 @@ typedef struct fx_directory_entry {
|
|||||||
fx_file_info info;
|
fx_file_info info;
|
||||||
} fx_directory_entry;
|
} fx_directory_entry;
|
||||||
|
|
||||||
FX_API fx_type fx_directory_get_type(void);
|
FX_API fx_type_id fx_directory_get_type(void);
|
||||||
FX_API fx_type fx_directory_iterator_get_type(void);
|
FX_API fx_type_id fx_directory_iterator_get_type(void);
|
||||||
|
|
||||||
FX_API fx_result fx_directory_open(
|
FX_API fx_result fx_directory_open(
|
||||||
fx_directory *root,
|
fx_directory *root,
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ typedef struct fx_file_info {
|
|||||||
size_t length;
|
size_t length;
|
||||||
} fx_file_info;
|
} fx_file_info;
|
||||||
|
|
||||||
FX_API fx_type fx_file_get_type(void);
|
FX_API fx_type_id fx_file_get_type(void);
|
||||||
|
|
||||||
FX_API fx_result fx_file_open(
|
FX_API fx_result fx_file_open(
|
||||||
FX_TYPE_FWDREF(fx_directory) * root,
|
FX_TYPE_FWDREF(fx_directory) * root,
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ FX_TYPE_CLASS_DECLARATION_END(fx_path)
|
|||||||
|
|
||||||
struct fx_file_info;
|
struct fx_file_info;
|
||||||
|
|
||||||
FX_API fx_type fx_path_get_type(void);
|
FX_API fx_type_id fx_path_get_type(void);
|
||||||
|
|
||||||
FX_TYPE_DEFAULT_CONSTRUCTOR(fx_path, FX_TYPE_PATH);
|
FX_TYPE_DEFAULT_CONSTRUCTOR(fx_path, FX_TYPE_PATH);
|
||||||
|
|
||||||
|
|||||||
@@ -709,16 +709,16 @@ static const fx_iterator_value iterator_get_cvalue(const fx_iterator *obj)
|
|||||||
/*** CLASS DEFINITION *********************************************************/
|
/*** CLASS DEFINITION *********************************************************/
|
||||||
|
|
||||||
// ---- fx_directory DEFINITION
|
// ---- fx_directory DEFINITION
|
||||||
FX_TYPE_CLASS_DEFINITION_BEGIN(fx_directory)
|
FX_TYPE_CLASS_BEGIN(fx_directory)
|
||||||
FX_TYPE_CLASS_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
||||||
FX_INTERFACE_ENTRY(to_string) = NULL;
|
FX_INTERFACE_ENTRY(to_string) = NULL;
|
||||||
FX_TYPE_CLASS_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
|
||||||
|
|
||||||
FX_TYPE_CLASS_INTERFACE_BEGIN(fx_iterable, FX_TYPE_ITERABLE)
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_iterable, FX_TYPE_ITERABLE)
|
||||||
FX_INTERFACE_ENTRY(it_begin) = iterator_begin;
|
FX_INTERFACE_ENTRY(it_begin) = iterator_begin;
|
||||||
FX_INTERFACE_ENTRY(it_cbegin) = iterator_cbegin;
|
FX_INTERFACE_ENTRY(it_cbegin) = iterator_cbegin;
|
||||||
FX_TYPE_CLASS_INTERFACE_END(fx_iterable, FX_TYPE_ITERABLE)
|
FX_TYPE_VTABLE_INTERFACE_END(fx_iterable, FX_TYPE_ITERABLE)
|
||||||
FX_TYPE_CLASS_DEFINITION_END(fx_directory)
|
FX_TYPE_CLASS_END(fx_directory)
|
||||||
|
|
||||||
FX_TYPE_DEFINITION_BEGIN(fx_directory)
|
FX_TYPE_DEFINITION_BEGIN(fx_directory)
|
||||||
FX_TYPE_ID(0x10d36546, 0x7f96, 0x464b, 0xbc4d, 0xe504b283fa45);
|
FX_TYPE_ID(0x10d36546, 0x7f96, 0x464b, 0xbc4d, 0xe504b283fa45);
|
||||||
@@ -730,18 +730,18 @@ FX_TYPE_DEFINITION_BEGIN(fx_directory)
|
|||||||
FX_TYPE_DEFINITION_END(fx_directory)
|
FX_TYPE_DEFINITION_END(fx_directory)
|
||||||
|
|
||||||
// ---- fx_directory_iterator DEFINITION
|
// ---- fx_directory_iterator DEFINITION
|
||||||
FX_TYPE_CLASS_DEFINITION_BEGIN(fx_directory_iterator)
|
FX_TYPE_CLASS_BEGIN(fx_directory_iterator)
|
||||||
FX_TYPE_CLASS_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
||||||
FX_INTERFACE_ENTRY(to_string) = NULL;
|
FX_INTERFACE_ENTRY(to_string) = NULL;
|
||||||
FX_TYPE_CLASS_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
|
||||||
|
|
||||||
FX_TYPE_CLASS_INTERFACE_BEGIN(fx_iterator, FX_TYPE_ITERATOR)
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_iterator, FX_TYPE_ITERATOR)
|
||||||
FX_INTERFACE_ENTRY(it_move_next) = iterator_move_next;
|
FX_INTERFACE_ENTRY(it_move_next) = iterator_move_next;
|
||||||
FX_INTERFACE_ENTRY(it_erase) = iterator_erase;
|
FX_INTERFACE_ENTRY(it_erase) = iterator_erase;
|
||||||
FX_INTERFACE_ENTRY(it_get_value) = iterator_get_value;
|
FX_INTERFACE_ENTRY(it_get_value) = iterator_get_value;
|
||||||
FX_INTERFACE_ENTRY(it_get_cvalue) = iterator_get_cvalue;
|
FX_INTERFACE_ENTRY(it_get_cvalue) = iterator_get_cvalue;
|
||||||
FX_TYPE_CLASS_INTERFACE_END(fx_iterator, FX_TYPE_ITERATOR)
|
FX_TYPE_VTABLE_INTERFACE_END(fx_iterator, FX_TYPE_ITERATOR)
|
||||||
FX_TYPE_CLASS_DEFINITION_END(fx_directory_iterator)
|
FX_TYPE_CLASS_END(fx_directory_iterator)
|
||||||
|
|
||||||
FX_TYPE_DEFINITION_BEGIN(fx_directory_iterator)
|
FX_TYPE_DEFINITION_BEGIN(fx_directory_iterator)
|
||||||
FX_TYPE_ID(0xc707fce6, 0xc895, 0x4925, 0x8700, 0xa60641dee0cc);
|
FX_TYPE_ID(0xc707fce6, 0xc895, 0x4925, 0x8700, 0xa60641dee0cc);
|
||||||
@@ -618,20 +618,20 @@ static void file_fini(fx_object *obj, void *priv)
|
|||||||
|
|
||||||
/*** CLASS DEFINITION *********************************************************/
|
/*** CLASS DEFINITION *********************************************************/
|
||||||
|
|
||||||
FX_TYPE_CLASS_DEFINITION_BEGIN(fx_file)
|
FX_TYPE_CLASS_BEGIN(fx_file)
|
||||||
FX_TYPE_CLASS_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
||||||
FX_INTERFACE_ENTRY(to_string) = NULL;
|
FX_INTERFACE_ENTRY(to_string) = NULL;
|
||||||
FX_TYPE_CLASS_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
|
||||||
|
|
||||||
FX_TYPE_CLASS_INTERFACE_BEGIN(fx_stream, FX_TYPE_STREAM)
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_stream, FX_TYPE_STREAM)
|
||||||
FX_INTERFACE_ENTRY(s_close) = stream_close;
|
FX_INTERFACE_ENTRY(s_close) = stream_close;
|
||||||
FX_INTERFACE_ENTRY(s_getc) = stream_getc;
|
FX_INTERFACE_ENTRY(s_getc) = stream_getc;
|
||||||
FX_INTERFACE_ENTRY(s_read) = stream_read;
|
FX_INTERFACE_ENTRY(s_read) = stream_read;
|
||||||
FX_INTERFACE_ENTRY(s_write) = stream_write;
|
FX_INTERFACE_ENTRY(s_write) = stream_write;
|
||||||
FX_INTERFACE_ENTRY(s_seek) = stream_seek;
|
FX_INTERFACE_ENTRY(s_seek) = stream_seek;
|
||||||
FX_INTERFACE_ENTRY(s_tell) = stream_tell;
|
FX_INTERFACE_ENTRY(s_tell) = stream_tell;
|
||||||
FX_TYPE_CLASS_INTERFACE_END(fx_stream, FX_TYPE_STREAM)
|
FX_TYPE_VTABLE_INTERFACE_END(fx_stream, FX_TYPE_STREAM)
|
||||||
FX_TYPE_CLASS_DEFINITION_END(fx_file)
|
FX_TYPE_CLASS_END(fx_file)
|
||||||
|
|
||||||
FX_TYPE_DEFINITION_BEGIN(fx_file)
|
FX_TYPE_DEFINITION_BEGIN(fx_file)
|
||||||
FX_TYPE_ID(0x495a73f6, 0xb8c3, 0x4e17, 0xb5f4, 0x6fc321f67c7b);
|
FX_TYPE_ID(0x495a73f6, 0xb8c3, 0x4e17, 0xb5f4, 0x6fc321f67c7b);
|
||||||
@@ -401,11 +401,11 @@ void path_to_string(const fx_object *obj, fx_stream *out)
|
|||||||
|
|
||||||
/*** CLASS DEFINITION *********************************************************/
|
/*** CLASS DEFINITION *********************************************************/
|
||||||
|
|
||||||
FX_TYPE_CLASS_DEFINITION_BEGIN(fx_path)
|
FX_TYPE_CLASS_BEGIN(fx_path)
|
||||||
FX_TYPE_CLASS_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
||||||
FX_INTERFACE_ENTRY(to_string) = path_to_string;
|
FX_INTERFACE_ENTRY(to_string) = path_to_string;
|
||||||
FX_TYPE_CLASS_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
|
||||||
FX_TYPE_CLASS_DEFINITION_END(fx_path)
|
FX_TYPE_CLASS_END(fx_path)
|
||||||
|
|
||||||
FX_TYPE_DEFINITION_BEGIN(fx_path)
|
FX_TYPE_DEFINITION_BEGIN(fx_path)
|
||||||
FX_TYPE_ID(0x56dc32eb, 0xea96, 0x46ed, 0x85d3, 0x760fa4ad61f4);
|
FX_TYPE_ID(0x56dc32eb, 0xea96, 0x46ed, 0x85d3, 0x760fa4ad61f4);
|
||||||
+12
-12
@@ -711,16 +711,16 @@ static const fx_iterator_value iterator_get_cvalue(const fx_iterator *obj)
|
|||||||
/*** CLASS DEFINITION *********************************************************/
|
/*** CLASS DEFINITION *********************************************************/
|
||||||
|
|
||||||
// ---- fx_directory DEFINITION
|
// ---- fx_directory DEFINITION
|
||||||
FX_TYPE_CLASS_DEFINITION_BEGIN(fx_directory)
|
FX_TYPE_CLASS_BEGIN(fx_directory)
|
||||||
FX_TYPE_CLASS_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
||||||
FX_INTERFACE_ENTRY(to_string) = NULL;
|
FX_INTERFACE_ENTRY(to_string) = NULL;
|
||||||
FX_TYPE_CLASS_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
|
||||||
|
|
||||||
FX_TYPE_CLASS_INTERFACE_BEGIN(fx_iterable, FX_TYPE_ITERABLE)
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_iterable, FX_TYPE_ITERABLE)
|
||||||
FX_INTERFACE_ENTRY(it_begin) = iterator_begin;
|
FX_INTERFACE_ENTRY(it_begin) = iterator_begin;
|
||||||
FX_INTERFACE_ENTRY(it_cbegin) = iterator_cbegin;
|
FX_INTERFACE_ENTRY(it_cbegin) = iterator_cbegin;
|
||||||
FX_TYPE_CLASS_INTERFACE_END(fx_iterable, FX_TYPE_ITERABLE)
|
FX_TYPE_VTABLE_INTERFACE_END(fx_iterable, FX_TYPE_ITERABLE)
|
||||||
FX_TYPE_CLASS_DEFINITION_END(fx_directory)
|
FX_TYPE_CLASS_END(fx_directory)
|
||||||
|
|
||||||
FX_TYPE_DEFINITION_BEGIN(fx_directory)
|
FX_TYPE_DEFINITION_BEGIN(fx_directory)
|
||||||
FX_TYPE_ID(0x10d36546, 0x7f96, 0x464b, 0xbc4d, 0xe504b283fa45);
|
FX_TYPE_ID(0x10d36546, 0x7f96, 0x464b, 0xbc4d, 0xe504b283fa45);
|
||||||
@@ -732,18 +732,18 @@ FX_TYPE_DEFINITION_BEGIN(fx_directory)
|
|||||||
FX_TYPE_DEFINITION_END(fx_directory)
|
FX_TYPE_DEFINITION_END(fx_directory)
|
||||||
|
|
||||||
// ---- fx_directory_iterator DEFINITION
|
// ---- fx_directory_iterator DEFINITION
|
||||||
FX_TYPE_CLASS_DEFINITION_BEGIN(fx_directory_iterator)
|
FX_TYPE_CLASS_BEGIN(fx_directory_iterator)
|
||||||
FX_TYPE_CLASS_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
||||||
FX_INTERFACE_ENTRY(to_string) = NULL;
|
FX_INTERFACE_ENTRY(to_string) = NULL;
|
||||||
FX_TYPE_CLASS_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
|
||||||
|
|
||||||
FX_TYPE_CLASS_INTERFACE_BEGIN(fx_iterator, FX_TYPE_ITERATOR)
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_iterator, FX_TYPE_ITERATOR)
|
||||||
FX_INTERFACE_ENTRY(it_move_next) = iterator_move_next;
|
FX_INTERFACE_ENTRY(it_move_next) = iterator_move_next;
|
||||||
FX_INTERFACE_ENTRY(it_erase) = iterator_erase;
|
FX_INTERFACE_ENTRY(it_erase) = iterator_erase;
|
||||||
FX_INTERFACE_ENTRY(it_get_value) = iterator_get_value;
|
FX_INTERFACE_ENTRY(it_get_value) = iterator_get_value;
|
||||||
FX_INTERFACE_ENTRY(it_get_cvalue) = iterator_get_cvalue;
|
FX_INTERFACE_ENTRY(it_get_cvalue) = iterator_get_cvalue;
|
||||||
FX_TYPE_CLASS_INTERFACE_END(fx_iterator, FX_TYPE_ITERATOR)
|
FX_TYPE_VTABLE_INTERFACE_END(fx_iterator, FX_TYPE_ITERATOR)
|
||||||
FX_TYPE_CLASS_DEFINITION_END(fx_directory_iterator)
|
FX_TYPE_CLASS_END(fx_directory_iterator)
|
||||||
|
|
||||||
FX_TYPE_DEFINITION_BEGIN(fx_directory_iterator)
|
FX_TYPE_DEFINITION_BEGIN(fx_directory_iterator)
|
||||||
FX_TYPE_ID(0xc707fce6, 0xc895, 0x4925, 0x8700, 0xa60641dee0cc);
|
FX_TYPE_ID(0xc707fce6, 0xc895, 0x4925, 0x8700, 0xa60641dee0cc);
|
||||||
|
|||||||
@@ -620,20 +620,20 @@ static void file_fini(fx_object *obj, void *priv)
|
|||||||
|
|
||||||
/*** CLASS DEFINITION *********************************************************/
|
/*** CLASS DEFINITION *********************************************************/
|
||||||
|
|
||||||
FX_TYPE_CLASS_DEFINITION_BEGIN(fx_file)
|
FX_TYPE_CLASS_BEGIN(fx_file)
|
||||||
FX_TYPE_CLASS_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
||||||
FX_INTERFACE_ENTRY(to_string) = NULL;
|
FX_INTERFACE_ENTRY(to_string) = NULL;
|
||||||
FX_TYPE_CLASS_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
|
||||||
|
|
||||||
FX_TYPE_CLASS_INTERFACE_BEGIN(fx_stream, FX_TYPE_STREAM)
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_stream, FX_TYPE_STREAM)
|
||||||
FX_INTERFACE_ENTRY(s_close) = stream_close;
|
FX_INTERFACE_ENTRY(s_close) = stream_close;
|
||||||
FX_INTERFACE_ENTRY(s_getc) = stream_getc;
|
FX_INTERFACE_ENTRY(s_getc) = stream_getc;
|
||||||
FX_INTERFACE_ENTRY(s_read) = stream_read;
|
FX_INTERFACE_ENTRY(s_read) = stream_read;
|
||||||
FX_INTERFACE_ENTRY(s_write) = stream_write;
|
FX_INTERFACE_ENTRY(s_write) = stream_write;
|
||||||
FX_INTERFACE_ENTRY(s_seek) = stream_seek;
|
FX_INTERFACE_ENTRY(s_seek) = stream_seek;
|
||||||
FX_INTERFACE_ENTRY(s_tell) = stream_tell;
|
FX_INTERFACE_ENTRY(s_tell) = stream_tell;
|
||||||
FX_TYPE_CLASS_INTERFACE_END(fx_stream, FX_TYPE_STREAM)
|
FX_TYPE_VTABLE_INTERFACE_END(fx_stream, FX_TYPE_STREAM)
|
||||||
FX_TYPE_CLASS_DEFINITION_END(fx_file)
|
FX_TYPE_CLASS_END(fx_file)
|
||||||
|
|
||||||
FX_TYPE_DEFINITION_BEGIN(fx_file)
|
FX_TYPE_DEFINITION_BEGIN(fx_file)
|
||||||
FX_TYPE_ID(0x495a73f6, 0xb8c3, 0x4e17, 0xb5f4, 0x6fc321f67c7b);
|
FX_TYPE_ID(0x495a73f6, 0xb8c3, 0x4e17, 0xb5f4, 0x6fc321f67c7b);
|
||||||
|
|||||||
@@ -401,11 +401,11 @@ void path_to_string(const fx_object *obj, fx_stream *out)
|
|||||||
|
|
||||||
/*** CLASS DEFINITION *********************************************************/
|
/*** CLASS DEFINITION *********************************************************/
|
||||||
|
|
||||||
FX_TYPE_CLASS_DEFINITION_BEGIN(fx_path)
|
FX_TYPE_CLASS_BEGIN(fx_path)
|
||||||
FX_TYPE_CLASS_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
||||||
FX_INTERFACE_ENTRY(to_string) = path_to_string;
|
FX_INTERFACE_ENTRY(to_string) = path_to_string;
|
||||||
FX_TYPE_CLASS_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
|
||||||
FX_TYPE_CLASS_DEFINITION_END(fx_path)
|
FX_TYPE_CLASS_END(fx_path)
|
||||||
|
|
||||||
FX_TYPE_DEFINITION_BEGIN(fx_path)
|
FX_TYPE_DEFINITION_BEGIN(fx_path)
|
||||||
FX_TYPE_ID(0x56dc32eb, 0xea96, 0x46ed, 0x85d3, 0x760fa4ad61f4);
|
FX_TYPE_ID(0x56dc32eb, 0xea96, 0x46ed, 0x85d3, 0x760fa4ad61f4);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#include <fx/core/stream.h>
|
|
||||||
#include <fx/io/file.h>
|
#include <fx/io/file.h>
|
||||||
#include <fx/io/path.h>
|
#include <fx/io/path.h>
|
||||||
|
#include <fx/stream.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
int main(int argc, const char **argv)
|
int main(int argc, const char **argv)
|
||||||
@@ -8,7 +8,10 @@ int main(int argc, const char **argv)
|
|||||||
fx_file *dest;
|
fx_file *dest;
|
||||||
fx_path *path = fx_path_create_from_cstr("data.txt");
|
fx_path *path = fx_path_create_from_cstr("data.txt");
|
||||||
fx_result result = fx_file_open(
|
fx_result result = fx_file_open(
|
||||||
NULL, path, FX_FILE_WRITE_ONLY | FX_FILE_CREATE, &dest);
|
NULL,
|
||||||
|
path,
|
||||||
|
FX_FILE_WRITE_ONLY | FX_FILE_CREATE,
|
||||||
|
&dest);
|
||||||
if (fx_result_is_error(result)) {
|
if (fx_result_is_error(result)) {
|
||||||
fx_throw(result);
|
fx_throw(result);
|
||||||
return -1;
|
return -1;
|
||||||
|
|||||||
@@ -1,35 +0,0 @@
|
|||||||
#include <CuTest.h>
|
|
||||||
#include <fx/core/stringstream.h>
|
|
||||||
#include <fx/io/path.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
void test_path_1(CuTest *tc)
|
|
||||||
{
|
|
||||||
fx_path *path = fx_path_create_from_cstr("C:\\hello\\world\\");
|
|
||||||
char buf[512];
|
|
||||||
fx_stringstream *str = fx_stringstream_create_with_buffer(buf, sizeof buf);
|
|
||||||
|
|
||||||
fx_object_to_string(path, str);
|
|
||||||
|
|
||||||
printf("%s\n", buf);
|
|
||||||
|
|
||||||
fx_path *path2 = fx_path_create_from_cstr("path1\\path2\\");
|
|
||||||
fx_path *path3 = fx_path_create_from_cstr("path3\\path4\\");
|
|
||||||
|
|
||||||
const fx_path *paths[] = {path, path2, path3};
|
|
||||||
|
|
||||||
fx_path *path4 = fx_path_join(paths, sizeof paths / sizeof paths[0]);
|
|
||||||
|
|
||||||
fx_stringstream_reset_with_buffer(str, buf, sizeof buf);
|
|
||||||
fx_object_to_string(path4, str);
|
|
||||||
printf("%s\n", buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
CuSuite *get_all_tests(void)
|
|
||||||
{
|
|
||||||
CuSuite *suite = CuSuiteNew();
|
|
||||||
|
|
||||||
SUITE_ADD_TEST(suite, test_path_1);
|
|
||||||
|
|
||||||
return suite;
|
|
||||||
}
|
|
||||||
@@ -35,7 +35,7 @@ struct map {
|
|||||||
|
|
||||||
struct type {
|
struct type {
|
||||||
struct map_item e_map_item;
|
struct map_item e_map_item;
|
||||||
fx_type e_type;
|
fx_type_id e_type;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct fx_assembly_p {
|
struct fx_assembly_p {
|
||||||
@@ -131,7 +131,7 @@ static void assembly_set_version(
|
|||||||
static void assembly_add_type(
|
static void assembly_add_type(
|
||||||
struct fx_assembly_p *asm,
|
struct fx_assembly_p *asm,
|
||||||
const char *full_name,
|
const char *full_name,
|
||||||
fx_type type_id)
|
fx_type_id type_id)
|
||||||
{
|
{
|
||||||
struct type *type = malloc(sizeof *type);
|
struct type *type = malloc(sizeof *type);
|
||||||
memset(type, 0x0, sizeof *type);
|
memset(type, 0x0, sizeof *type);
|
||||||
@@ -218,7 +218,7 @@ void fx_assembly_set_version(
|
|||||||
void fx_assembly_add_type(
|
void fx_assembly_add_type(
|
||||||
fx_assembly *asm,
|
fx_assembly *asm,
|
||||||
const char *full_name,
|
const char *full_name,
|
||||||
fx_type type_id)
|
fx_type_id type_id)
|
||||||
{
|
{
|
||||||
FX_CLASS_DISPATCH_STATIC_V(
|
FX_CLASS_DISPATCH_STATIC_V(
|
||||||
FX_REFLECTION_TYPE_ASSEMBLY,
|
FX_REFLECTION_TYPE_ASSEMBLY,
|
||||||
@@ -249,11 +249,11 @@ static void assembly_fini(fx_object *obj, void *priv)
|
|||||||
/*** CLASS DEFINITION *********************************************************/
|
/*** CLASS DEFINITION *********************************************************/
|
||||||
|
|
||||||
// ---- fx_string DEFINITION
|
// ---- fx_string DEFINITION
|
||||||
FX_TYPE_CLASS_DEFINITION_BEGIN(fx_assembly)
|
FX_TYPE_CLASS_BEGIN(fx_assembly)
|
||||||
FX_TYPE_CLASS_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
||||||
FX_INTERFACE_ENTRY(to_string) = NULL;
|
FX_INTERFACE_ENTRY(to_string) = NULL;
|
||||||
FX_TYPE_CLASS_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
|
||||||
FX_TYPE_CLASS_DEFINITION_END(fx_assembly)
|
FX_TYPE_CLASS_END(fx_assembly)
|
||||||
|
|
||||||
FX_TYPE_DEFINITION_BEGIN(fx_assembly)
|
FX_TYPE_DEFINITION_BEGIN(fx_assembly)
|
||||||
FX_TYPE_ID(0xf6690c30, 0x6642, 0x42f0, 0xb79f, 0xe2baf3684b1b);
|
FX_TYPE_ID(0xf6690c30, 0x6642, 0x42f0, 0xb79f, 0xe2baf3684b1b);
|
||||||
|
|||||||
@@ -1,86 +0,0 @@
|
|||||||
#include <fx/macros.h>
|
|
||||||
#include <fx/reflection/function.h>
|
|
||||||
#include <fx/string.h>
|
|
||||||
#include <fx/value.h>
|
|
||||||
#include <platform/callvm.h>
|
|
||||||
|
|
||||||
struct fx_function_context_p {
|
|
||||||
struct callvm ctx_vm;
|
|
||||||
};
|
|
||||||
|
|
||||||
/*** PRIVATE FUNCTIONS ********************************************************/
|
|
||||||
|
|
||||||
static fx_status function_context_reset(
|
|
||||||
const struct fx_function_context_p *func)
|
|
||||||
{
|
|
||||||
return FX_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
static fx_status function_context_push_arg(
|
|
||||||
const struct fx_function_context_p *func,
|
|
||||||
const fx_value *arg)
|
|
||||||
{
|
|
||||||
return FX_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*** PUBLIC FUNCTIONS *********************************************************/
|
|
||||||
|
|
||||||
FX_API fx_function *fx_function_context_create(void)
|
|
||||||
{
|
|
||||||
fx_function_context *ctx
|
|
||||||
= fx_object_create(FX_REFLECTION_TYPE_FUNCTION_CONTEXT);
|
|
||||||
if (!ctx) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct fx_function_context_p *p = fx_object_get_private(
|
|
||||||
ctx,
|
|
||||||
FX_REFLECTION_TYPE_FUNCTION_CONTEXT);
|
|
||||||
|
|
||||||
return ctx;
|
|
||||||
}
|
|
||||||
|
|
||||||
FX_API void fx_function_context_reset(fx_function_context *ctx)
|
|
||||||
{
|
|
||||||
FX_CLASS_DISPATCH_STATIC_V0(
|
|
||||||
FX_REFLECTION_TYPE_FUNCTION_CONTEXT,
|
|
||||||
function_context_reset,
|
|
||||||
ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
FX_API void fx_function_context_push_arg(
|
|
||||||
fx_function_context *ctx,
|
|
||||||
const fx_value *value)
|
|
||||||
{
|
|
||||||
FX_CLASS_DISPATCH_STATIC_V(
|
|
||||||
FX_REFLECTION_TYPE_FUNCTION_CONTEXT,
|
|
||||||
function_context_push_arg,
|
|
||||||
ctx,
|
|
||||||
value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*** VIRTUAL FUNCTIONS ********************************************************/
|
|
||||||
|
|
||||||
static void function_context_init(fx_object *obj, void *priv)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
static void function_context_fini(fx_object *obj, void *priv)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/*** CLASS DEFINITION *********************************************************/
|
|
||||||
|
|
||||||
FX_TYPE_CLASS_DEFINITION_BEGIN(fx_function_context)
|
|
||||||
FX_TYPE_CLASS_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
|
||||||
FX_INTERFACE_ENTRY(to_string) = NULL;
|
|
||||||
FX_TYPE_CLASS_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
|
|
||||||
FX_TYPE_CLASS_DEFINITION_END(fx_function_context)
|
|
||||||
|
|
||||||
FX_TYPE_DEFINITION_BEGIN(fx_function_context)
|
|
||||||
FX_TYPE_ID(0x97d98a1a, 0x6312, 0x409e, 0xb47d, 0xc5d80daf9e50);
|
|
||||||
FX_TYPE_CLASS(fx_function_context_class);
|
|
||||||
FX_TYPE_INSTANCE_PRIVATE(struct fx_function_context_p);
|
|
||||||
FX_TYPE_INSTANCE_INIT(function_context_init);
|
|
||||||
FX_TYPE_INSTANCE_FINI(function_context_fini);
|
|
||||||
FX_TYPE_DEFINITION_END(fx_function_context)
|
|
||||||
+87
-17
@@ -15,14 +15,51 @@ struct fx_function_p {
|
|||||||
* variable number of arguments, which may be handled differently by the
|
* variable number of arguments, which may be handled differently by the
|
||||||
* ABI */
|
* ABI */
|
||||||
size_t func_nr_args;
|
size_t func_nr_args;
|
||||||
|
|
||||||
|
fx_value *func_bound_args;
|
||||||
|
size_t func_nr_bound_args, func_max_bound_args;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*** PRIVATE FUNCTIONS ********************************************************/
|
/*** PRIVATE FUNCTIONS ********************************************************/
|
||||||
|
|
||||||
extern intptr_t fx_function_invoke_i(
|
static const char *function_get_name(const struct fx_function_p *func)
|
||||||
fx_function_impl impl,
|
{
|
||||||
const fx_value *args,
|
return func->func_name;
|
||||||
size_t nr_args);
|
}
|
||||||
|
|
||||||
|
static fx_status function_bind(
|
||||||
|
struct fx_function_p *func,
|
||||||
|
fx_value *args,
|
||||||
|
size_t nr_args)
|
||||||
|
{
|
||||||
|
if (func->func_nr_bound_args) {
|
||||||
|
fx_value_unset_array(
|
||||||
|
func->func_bound_args,
|
||||||
|
func->func_nr_bound_args);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!args || !nr_args) {
|
||||||
|
func->func_nr_bound_args = 0;
|
||||||
|
return FX_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nr_args > func->func_max_bound_args) {
|
||||||
|
fx_value *buf = realloc(
|
||||||
|
func->func_bound_args,
|
||||||
|
nr_args * sizeof *buf);
|
||||||
|
if (!buf) {
|
||||||
|
return FX_ERR_NO_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
func->func_bound_args = buf;
|
||||||
|
func->func_max_bound_args = nr_args;
|
||||||
|
}
|
||||||
|
|
||||||
|
fx_value_copy_array(func->func_bound_args, args, nr_args);
|
||||||
|
func->func_nr_bound_args = nr_args;
|
||||||
|
|
||||||
|
return FX_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
static fx_status function_invoke(
|
static fx_status function_invoke(
|
||||||
const struct fx_function_p *func,
|
const struct fx_function_p *func,
|
||||||
@@ -30,28 +67,37 @@ static fx_status function_invoke(
|
|||||||
size_t nr_args,
|
size_t nr_args,
|
||||||
fx_value *return_value)
|
fx_value *return_value)
|
||||||
{
|
{
|
||||||
if (nr_args < func->func_nr_args) {
|
size_t total_args = nr_args + func->func_nr_bound_args;
|
||||||
|
|
||||||
|
if (total_args < func->func_nr_args) {
|
||||||
return FX_ERR_INVALID_ARGUMENT;
|
return FX_ERR_INVALID_ARGUMENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nr_args > func->func_nr_args
|
if (total_args > func->func_nr_args
|
||||||
&& !(func->func_flags & FX_FUNCTION_F_VARARG)) {
|
&& !(func->func_flags & FX_FUNCTION_F_VARARG)) {
|
||||||
return FX_ERR_INVALID_ARGUMENT;
|
return FX_ERR_INVALID_ARGUMENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t nr_fixed_args = func->func_nr_args;
|
size_t nr_fixed_args = func->func_nr_args;
|
||||||
size_t nr_var_args = nr_args - nr_fixed_args;
|
size_t nr_var_args = total_args - nr_fixed_args;
|
||||||
|
|
||||||
struct callvm vm = {0};
|
struct callvm vm = {0};
|
||||||
callvm_reset(&vm, nr_fixed_args);
|
callvm_reset(&vm, nr_fixed_args);
|
||||||
|
|
||||||
|
for (size_t i = 0; i < func->func_nr_bound_args; i++) {
|
||||||
|
const fx_value *arg = &func->func_bound_args[i];
|
||||||
|
callvm_push(&vm, arg);
|
||||||
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < nr_args; i++) {
|
for (size_t i = 0; i < nr_args; i++) {
|
||||||
const fx_value *arg = &args[i];
|
const fx_value *arg = &args[i];
|
||||||
callvm_push(&vm, arg);
|
callvm_push(&vm, arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
*return_value
|
*return_value = callvm_invoke(
|
||||||
= callvm_invoke(&vm, func->func_impl, func->func_return_type);
|
&vm,
|
||||||
|
func->func_impl,
|
||||||
|
func->func_return_type);
|
||||||
|
|
||||||
callvm_reset(&vm, 0);
|
callvm_reset(&vm, 0);
|
||||||
return FX_SUCCESS;
|
return FX_SUCCESS;
|
||||||
@@ -59,7 +105,7 @@ static fx_status function_invoke(
|
|||||||
|
|
||||||
/*** PUBLIC FUNCTIONS *********************************************************/
|
/*** PUBLIC FUNCTIONS *********************************************************/
|
||||||
|
|
||||||
FX_API fx_function *fx_function_create(
|
fx_function *fx_function_create(
|
||||||
const char *name,
|
const char *name,
|
||||||
fx_function_flags flags,
|
fx_function_flags flags,
|
||||||
fx_function_impl impl,
|
fx_function_impl impl,
|
||||||
@@ -72,8 +118,13 @@ FX_API fx_function *fx_function_create(
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct fx_function_p *p
|
struct fx_function_p *p = fx_object_get_private(
|
||||||
= fx_object_get_private(func, FX_REFLECTION_TYPE_FUNCTION);
|
func,
|
||||||
|
FX_REFLECTION_TYPE_FUNCTION);
|
||||||
|
|
||||||
|
if (nr_args == 1 && args[0] == FX_VALUE_TYPE_NONE) {
|
||||||
|
nr_args = 0;
|
||||||
|
}
|
||||||
|
|
||||||
p->func_name = fx_strdup(name);
|
p->func_name = fx_strdup(name);
|
||||||
p->func_flags = flags;
|
p->func_flags = flags;
|
||||||
@@ -88,7 +139,25 @@ FX_API fx_function *fx_function_create(
|
|||||||
return func;
|
return func;
|
||||||
}
|
}
|
||||||
|
|
||||||
FX_API fx_status fx_function_invoke(
|
const char *fx_function_get_name(const fx_function *func)
|
||||||
|
{
|
||||||
|
FX_CLASS_DISPATCH_STATIC_0(
|
||||||
|
FX_REFLECTION_TYPE_FUNCTION,
|
||||||
|
function_get_name,
|
||||||
|
func);
|
||||||
|
}
|
||||||
|
|
||||||
|
fx_status fx_function_bind(fx_function *func, fx_value *args, size_t nr_args)
|
||||||
|
{
|
||||||
|
FX_CLASS_DISPATCH_STATIC(
|
||||||
|
FX_REFLECTION_TYPE_FUNCTION,
|
||||||
|
function_bind,
|
||||||
|
func,
|
||||||
|
args,
|
||||||
|
nr_args);
|
||||||
|
}
|
||||||
|
|
||||||
|
fx_status fx_function_invoke(
|
||||||
const fx_function *func,
|
const fx_function *func,
|
||||||
const fx_value *args,
|
const fx_value *args,
|
||||||
size_t nr_args,
|
size_t nr_args,
|
||||||
@@ -125,14 +194,15 @@ static void function_fini(fx_object *obj, void *priv)
|
|||||||
/*** CLASS DEFINITION
|
/*** CLASS DEFINITION
|
||||||
* *********************************************************/
|
* *********************************************************/
|
||||||
|
|
||||||
FX_TYPE_CLASS_DEFINITION_BEGIN(fx_function)
|
FX_TYPE_CLASS_BEGIN(fx_function)
|
||||||
FX_TYPE_CLASS_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
||||||
FX_INTERFACE_ENTRY(to_string) = NULL;
|
FX_INTERFACE_ENTRY(to_string) = NULL;
|
||||||
FX_TYPE_CLASS_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
|
||||||
FX_TYPE_CLASS_DEFINITION_END(fx_function)
|
FX_TYPE_CLASS_END(fx_function)
|
||||||
|
|
||||||
FX_TYPE_DEFINITION_BEGIN(fx_function)
|
FX_TYPE_DEFINITION_BEGIN(fx_function)
|
||||||
FX_TYPE_ID(0x09e40174, 0x7443, 0x486e, 0xad21, 0xcc9374762e7e);
|
FX_TYPE_ID(0x09e40174, 0x7443, 0x486e, 0xad21, 0xcc9374762e7e);
|
||||||
|
FX_TYPE_NAME("fx.reflection.function");
|
||||||
FX_TYPE_CLASS(fx_function_class);
|
FX_TYPE_CLASS(fx_function_class);
|
||||||
FX_TYPE_INSTANCE_PRIVATE(struct fx_function_p);
|
FX_TYPE_INSTANCE_PRIVATE(struct fx_function_p);
|
||||||
FX_TYPE_INSTANCE_INIT(function_init);
|
FX_TYPE_INSTANCE_INIT(function_init);
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ FX_DECLARE_TYPE(fx_assembly);
|
|||||||
FX_TYPE_CLASS_DECLARATION_BEGIN(fx_assembly)
|
FX_TYPE_CLASS_DECLARATION_BEGIN(fx_assembly)
|
||||||
FX_TYPE_CLASS_DECLARATION_END(fx_assembly)
|
FX_TYPE_CLASS_DECLARATION_END(fx_assembly)
|
||||||
|
|
||||||
FX_API fx_type fx_assembly_get_type();
|
FX_API fx_type_id fx_assembly_get_type();
|
||||||
|
|
||||||
FX_TYPE_DEFAULT_CONSTRUCTOR(fx_assembly, FX_REFLECTION_TYPE_ASSEMBLY);
|
FX_TYPE_DEFAULT_CONSTRUCTOR(fx_assembly, FX_REFLECTION_TYPE_ASSEMBLY);
|
||||||
|
|
||||||
@@ -27,11 +27,10 @@ FX_API void fx_assembly_set_version(
|
|||||||
FX_API void fx_assembly_add_type(
|
FX_API void fx_assembly_add_type(
|
||||||
fx_assembly *asm,
|
fx_assembly *asm,
|
||||||
const char *full_name,
|
const char *full_name,
|
||||||
fx_type type_id);
|
fx_type_id type_id);
|
||||||
|
|
||||||
FX_API void fx_assembly_dump(const fx_assembly *asm);
|
FX_API void fx_assembly_dump(const fx_assembly *asm);
|
||||||
|
|
||||||
FX_DECLS_END
|
FX_DECLS_END;
|
||||||
;
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -7,57 +7,26 @@
|
|||||||
|
|
||||||
FX_DECLS_BEGIN;
|
FX_DECLS_BEGIN;
|
||||||
|
|
||||||
#define FX_REFLECTION_TYPE_FUNCTION (fx_function_get_type())
|
#define FX_REFLECTION_TYPE_FUNCTION (fx_function_get_type())
|
||||||
#define FX_REFLECTION_TYPE_FUNCTION_CONTEXT (fx_function_context_get_type())
|
|
||||||
|
|
||||||
typedef enum fx_function_flags {
|
typedef enum fx_function_flags {
|
||||||
FX_FUNCTION_F_NONE = 0x00u,
|
FX_FUNCTION_F_NONE = 0x00u,
|
||||||
FX_FUNCTION_F_STATIC = 0x01u,
|
FX_FUNCTION_F_STATIC = 0x01u,
|
||||||
FX_FUNCTION_F_VIRTUAL = 0x02u,
|
FX_FUNCTION_F_VIRTUAL = 0x02u,
|
||||||
FX_FUNCTION_F_VARARG = 0x04u,
|
FX_FUNCTION_F_VARARG = 0x04u,
|
||||||
|
FX_FUNCTION_F_CONSTRUCTOR = 0x08u,
|
||||||
} fx_function_flags;
|
} fx_function_flags;
|
||||||
|
|
||||||
#if 0
|
|
||||||
#define FX_FUNCTION_VALUE(type) \
|
|
||||||
((fx_function_value) { \
|
|
||||||
.v_type = FX_FUNCTION_V_PRIMITIVE, \
|
|
||||||
.v_primitive = (type), \
|
|
||||||
})
|
|
||||||
|
|
||||||
typedef enum fx_function_value_type {
|
|
||||||
FX_FUNCTION_V_NONE = 0,
|
|
||||||
FX_FUNCTION_V_PRIMITIVE,
|
|
||||||
FX_FUNCTION_V_OBJECT,
|
|
||||||
} fx_function_value_type;
|
|
||||||
|
|
||||||
typedef struct fx_function_value {
|
|
||||||
fx_function_value_type v_type;
|
|
||||||
union {
|
|
||||||
fx_value_type v_primitive;
|
|
||||||
fx_type v_object;
|
|
||||||
};
|
|
||||||
} fx_function_value;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef void (*fx_function_impl)();
|
typedef void (*fx_function_impl)();
|
||||||
|
|
||||||
FX_DECLARE_TYPE(fx_function);
|
FX_DECLARE_TYPE(fx_function);
|
||||||
FX_DECLARE_TYPE(fx_function_context);
|
|
||||||
|
|
||||||
FX_TYPE_CLASS_DECLARATION_BEGIN(fx_function)
|
FX_TYPE_CLASS_DECLARATION_BEGIN(fx_function)
|
||||||
FX_TYPE_CLASS_DECLARATION_END(fx_function)
|
FX_TYPE_CLASS_DECLARATION_END(fx_function)
|
||||||
|
|
||||||
FX_TYPE_CLASS_DECLARATION_BEGIN(fx_function_context)
|
FX_API fx_type_id fx_function_get_type();
|
||||||
FX_TYPE_CLASS_DECLARATION_END(fx_function_context)
|
|
||||||
|
|
||||||
FX_API fx_type fx_function_get_type();
|
FX_API const char *fx_function_get_name(const fx_function *func);
|
||||||
FX_API fx_type fx_function_context_get_type();
|
|
||||||
|
|
||||||
FX_API fx_function_context *fx_function_context_create(void);
|
|
||||||
FX_API void fx_function_context_reset(fx_function_context *ctx);
|
|
||||||
FX_API void fx_function_context_push_arg(
|
|
||||||
fx_function_context *ctx,
|
|
||||||
const fx_value *value);
|
|
||||||
|
|
||||||
FX_API fx_function *fx_function_create(
|
FX_API fx_function *fx_function_create(
|
||||||
const char *name,
|
const char *name,
|
||||||
@@ -67,16 +36,12 @@ FX_API fx_function *fx_function_create(
|
|||||||
size_t nr_args,
|
size_t nr_args,
|
||||||
fx_value_type return_type);
|
fx_value_type return_type);
|
||||||
FX_API fx_status
|
FX_API fx_status
|
||||||
fx_function_bind(const fx_function *func, const fx_value *args, size_t nr_args);
|
fx_function_bind(fx_function *func, fx_value *args, size_t nr_args);
|
||||||
FX_API fx_status fx_function_invoke(
|
FX_API fx_status fx_function_invoke(
|
||||||
const fx_function *func,
|
const fx_function *func,
|
||||||
const fx_value *args,
|
const fx_value *args,
|
||||||
size_t nr_args,
|
size_t nr_args,
|
||||||
fx_value *return_value);
|
fx_value *return_value);
|
||||||
FX_API fx_status fx_function_invoke_with_context(
|
|
||||||
const fx_function *func,
|
|
||||||
const fx_function_context *ctx,
|
|
||||||
fx_value *return_value);
|
|
||||||
|
|
||||||
FX_DECLS_END;
|
FX_DECLS_END;
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
#ifndef FX_REFLECTION_TYPE_H_
|
||||||
|
#define FX_REFLECTION_TYPE_H_
|
||||||
|
|
||||||
|
#include <fx/macros.h>
|
||||||
|
#include <fx/reflection/function.h>
|
||||||
|
|
||||||
|
FX_DECLS_BEGIN;
|
||||||
|
|
||||||
|
struct fx_type_info;
|
||||||
|
|
||||||
|
#define FX_REFLECTION_TYPE_TYPE (fx_type_get_type())
|
||||||
|
|
||||||
|
FX_DECLARE_TYPE(fx_type);
|
||||||
|
|
||||||
|
FX_TYPE_CLASS_DECLARATION_BEGIN(fx_type)
|
||||||
|
FX_TYPE_CLASS_DECLARATION_END(fx_type)
|
||||||
|
|
||||||
|
FX_API fx_type_id fx_type_get_type();
|
||||||
|
|
||||||
|
FX_API const char *fx_type_get_name(const fx_type *ty);
|
||||||
|
FX_API const fx_function *fx_type_get_function(
|
||||||
|
const fx_type *ty,
|
||||||
|
const char *name);
|
||||||
|
|
||||||
|
FX_API const fx_type *fx_type_get_by_id(fx_type_id id);
|
||||||
|
FX_API const fx_type *fx_type_get_by_name(const char *name);
|
||||||
|
|
||||||
|
FX_API fx_type *__fx_type_create(struct fx_type_info *opaque);
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,99 @@
|
|||||||
|
#include <fx/macros.h>
|
||||||
|
#include <fx/reflection/type.h>
|
||||||
|
#include <fx/type.h>
|
||||||
|
|
||||||
|
struct fx_type_registration;
|
||||||
|
|
||||||
|
struct fx_type_p {
|
||||||
|
struct fx_type_info *ty_info;
|
||||||
|
};
|
||||||
|
|
||||||
|
/*** PRIVATE FUNCTIONS ********************************************************/
|
||||||
|
|
||||||
|
extern struct fx_type_info *fx_type_info_get_by_id(const union fx_type_id *key);
|
||||||
|
extern struct fx_type_info *fx_type_info_get_by_name(const char *name);
|
||||||
|
extern fx_function *fx_type_info_get_function_by_name(
|
||||||
|
const struct fx_type_info *ty,
|
||||||
|
const char *name);
|
||||||
|
|
||||||
|
static const char *type_get_name(const struct fx_type_p *ty)
|
||||||
|
{
|
||||||
|
return ty->ty_info->ty_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
const fx_function *type_get_function(
|
||||||
|
const struct fx_type_p *ty,
|
||||||
|
const char *name)
|
||||||
|
{
|
||||||
|
return fx_type_info_get_function_by_name(ty->ty_info, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*** PUBLIC FUNCTIONS *********************************************************/
|
||||||
|
|
||||||
|
fx_type *__fx_type_create(struct fx_type_info *type_info)
|
||||||
|
{
|
||||||
|
fx_type *out = fx_object_create(FX_REFLECTION_TYPE_TYPE);
|
||||||
|
if (!out) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct fx_type_p *p = fx_object_get_private(
|
||||||
|
out,
|
||||||
|
FX_REFLECTION_TYPE_TYPE);
|
||||||
|
p->ty_info = type_info;
|
||||||
|
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *fx_type_get_name(const fx_type *ty)
|
||||||
|
{
|
||||||
|
FX_CLASS_DISPATCH_STATIC_0(FX_REFLECTION_TYPE_TYPE, type_get_name, ty);
|
||||||
|
}
|
||||||
|
|
||||||
|
const fx_function *fx_type_get_function(const fx_type *ty, const char *name)
|
||||||
|
{
|
||||||
|
FX_CLASS_DISPATCH_STATIC(
|
||||||
|
FX_REFLECTION_TYPE_TYPE,
|
||||||
|
type_get_function,
|
||||||
|
ty,
|
||||||
|
name);
|
||||||
|
}
|
||||||
|
|
||||||
|
const fx_type *fx_type_get_by_id(fx_type_id id)
|
||||||
|
{
|
||||||
|
struct fx_type_info *ty = fx_type_info_get_by_id(id);
|
||||||
|
return ty ? ty->ty_metatype : NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
const fx_type *fx_type_get_by_name(const char *name)
|
||||||
|
{
|
||||||
|
struct fx_type_info *ty = fx_type_info_get_by_name(name);
|
||||||
|
return ty ? ty->ty_metatype : NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*** VIRTUAL FUNCTIONS ********************************************************/
|
||||||
|
|
||||||
|
static void type_init(fx_object *obj, void *priv)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
static void type_fini(fx_object *obj, void *priv)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/*** CLASS DEFINITION *********************************************************/
|
||||||
|
|
||||||
|
FX_TYPE_CLASS_BEGIN(fx_type)
|
||||||
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
||||||
|
FX_INTERFACE_ENTRY(to_string) = NULL;
|
||||||
|
FX_TYPE_VTABLE_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
|
||||||
|
FX_TYPE_CLASS_END(fx_type)
|
||||||
|
|
||||||
|
FX_TYPE_DEFINITION_BEGIN(fx_type)
|
||||||
|
FX_TYPE_ID(0xec8b2679, 0x5c73, 0x4ec9, 0xa04e, 0x3f72881b5b5a);
|
||||||
|
FX_TYPE_NAME("fx.reflection.type");
|
||||||
|
FX_TYPE_CLASS(fx_type_class);
|
||||||
|
FX_TYPE_INSTANCE_PRIVATE(struct fx_type_p);
|
||||||
|
FX_TYPE_INSTANCE_INIT(type_init);
|
||||||
|
FX_TYPE_INSTANCE_FINI(type_fini);
|
||||||
|
FX_TYPE_DEFINITION_END(fx_type)
|
||||||
+6
-6
@@ -31,16 +31,16 @@ static void bitcode_serial_ctx_fini(fx_object *obj, void *priv)
|
|||||||
|
|
||||||
/*** CLASS DEFINITION *********************************************************/
|
/*** CLASS DEFINITION *********************************************************/
|
||||||
|
|
||||||
FX_TYPE_CLASS_DEFINITION_BEGIN(fx_bitcode_serial_ctx)
|
FX_TYPE_CLASS_BEGIN(fx_bitcode_serial_ctx)
|
||||||
FX_TYPE_CLASS_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
||||||
FX_INTERFACE_ENTRY(to_string) = NULL;
|
FX_INTERFACE_ENTRY(to_string) = NULL;
|
||||||
FX_TYPE_CLASS_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
|
||||||
|
|
||||||
FX_TYPE_CLASS_INTERFACE_BEGIN(fx_serial_ctx, FX_TYPE_SERIAL_CTX)
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_serial_ctx, FX_TYPE_SERIAL_CTX)
|
||||||
FX_INTERFACE_ENTRY(s_serialise) = bitcode_serialise;
|
FX_INTERFACE_ENTRY(s_serialise) = bitcode_serialise;
|
||||||
FX_INTERFACE_ENTRY(s_deserialise) = bitcode_deserialise;
|
FX_INTERFACE_ENTRY(s_deserialise) = bitcode_deserialise;
|
||||||
FX_TYPE_CLASS_INTERFACE_END(fx_serial_ctx, FX_TYPE_SERIAL_CTX)
|
FX_TYPE_VTABLE_INTERFACE_END(fx_serial_ctx, FX_TYPE_SERIAL_CTX)
|
||||||
FX_TYPE_CLASS_DEFINITION_END(fx_bitcode_serial_ctx)
|
FX_TYPE_CLASS_END(fx_bitcode_serial_ctx)
|
||||||
|
|
||||||
FX_TYPE_DEFINITION_BEGIN(fx_bitcode_serial_ctx)
|
FX_TYPE_DEFINITION_BEGIN(fx_bitcode_serial_ctx)
|
||||||
FX_TYPE_ID(0xcdc8c462, 0xf2b3, 0x4193, 0x8cae, 0xc1e5ad9afcb8);
|
FX_TYPE_ID(0xcdc8c462, 0xf2b3, 0x4193, 0x8cae, 0xc1e5ad9afcb8);
|
||||||
|
|||||||
+4
-4
@@ -26,11 +26,11 @@ static void serial_ctx_fini(fx_object *obj, void *priv)
|
|||||||
|
|
||||||
/*** CLASS DEFINITION *********************************************************/
|
/*** CLASS DEFINITION *********************************************************/
|
||||||
|
|
||||||
FX_TYPE_CLASS_DEFINITION_BEGIN(fx_serial_ctx)
|
FX_TYPE_CLASS_BEGIN(fx_serial_ctx)
|
||||||
FX_TYPE_CLASS_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
||||||
FX_INTERFACE_ENTRY(to_string) = NULL;
|
FX_INTERFACE_ENTRY(to_string) = NULL;
|
||||||
FX_TYPE_CLASS_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
|
||||||
FX_TYPE_CLASS_DEFINITION_END(fx_serial_ctx)
|
FX_TYPE_CLASS_END(fx_serial_ctx)
|
||||||
|
|
||||||
FX_TYPE_DEFINITION_BEGIN(fx_serial_ctx)
|
FX_TYPE_DEFINITION_BEGIN(fx_serial_ctx)
|
||||||
FX_TYPE_ID(0xc7c1039a, 0xf397, 0x4fda, 0xb473, 0x4d86fec85384);
|
FX_TYPE_ID(0xc7c1039a, 0xf397, 0x4fda, 0xb473, 0x4d86fec85384);
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ FX_DECLARE_TYPE(fx_bitcode_serial_ctx);
|
|||||||
FX_TYPE_CLASS_DECLARATION_BEGIN(fx_bitcode_serial_ctx)
|
FX_TYPE_CLASS_DECLARATION_BEGIN(fx_bitcode_serial_ctx)
|
||||||
FX_TYPE_CLASS_DECLARATION_END(fx_bitcode_serial_ctx)
|
FX_TYPE_CLASS_DECLARATION_END(fx_bitcode_serial_ctx)
|
||||||
|
|
||||||
FX_API fx_type fx_bitcode_serial_ctx_get_type(void);
|
FX_API fx_type_id fx_bitcode_serial_ctx_get_type(void);
|
||||||
|
|
||||||
FX_TYPE_DEFAULT_CONSTRUCTOR(fx_bitcode_serial_ctx, FX_TYPE_BITCODE_SERIAL_CTX);
|
FX_TYPE_DEFAULT_CONSTRUCTOR(fx_bitcode_serial_ctx, FX_TYPE_BITCODE_SERIAL_CTX);
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ typedef struct fx_serial_ctx_data {
|
|||||||
fx_stream_buffer *ctx_streambuf;
|
fx_stream_buffer *ctx_streambuf;
|
||||||
} fx_serial_ctx_data;
|
} fx_serial_ctx_data;
|
||||||
|
|
||||||
FX_API fx_type fx_serial_ctx_get_type(void);
|
FX_API fx_type_id fx_serial_ctx_get_type(void);
|
||||||
|
|
||||||
FX_API fx_result fx_serial_ctx_serialise(
|
FX_API fx_result fx_serial_ctx_serialise(
|
||||||
fx_serial_ctx *ctx,
|
fx_serial_ctx *ctx,
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ FX_DECLARE_TYPE(fx_toml_serial_ctx);
|
|||||||
FX_TYPE_CLASS_DECLARATION_BEGIN(fx_toml_serial_ctx)
|
FX_TYPE_CLASS_DECLARATION_BEGIN(fx_toml_serial_ctx)
|
||||||
FX_TYPE_CLASS_DECLARATION_END(fx_toml_serial_ctx)
|
FX_TYPE_CLASS_DECLARATION_END(fx_toml_serial_ctx)
|
||||||
|
|
||||||
FX_API fx_type fx_toml_serial_ctx_get_type(void);
|
FX_API fx_type_id fx_toml_serial_ctx_get_type(void);
|
||||||
|
|
||||||
FX_TYPE_DEFAULT_CONSTRUCTOR(fx_toml_serial_ctx, FX_TYPE_TOML_SERIAL_CTX);
|
FX_TYPE_DEFAULT_CONSTRUCTOR(fx_toml_serial_ctx, FX_TYPE_TOML_SERIAL_CTX);
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
#include <fx/core/stream.h>
|
#include <fx/collections/array.h>
|
||||||
#include <fx/ds/array.h>
|
#include <fx/collections/dict.h>
|
||||||
#include <fx/ds/dict.h>
|
#include <fx/int.h>
|
||||||
#include <fx/ds/number.h>
|
#include <fx/serial/ctx.h>
|
||||||
#include <fx/ds/string.h>
|
#include <fx/serial/toml.h>
|
||||||
#include <fx/serial.h>
|
#include <fx/stream.h>
|
||||||
|
#include <fx/string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
@@ -13,9 +14,9 @@ int main(void)
|
|||||||
fx_dict *dict = fx_dict_create();
|
fx_dict *dict = fx_dict_create();
|
||||||
|
|
||||||
fx_array *array = fx_array_create();
|
fx_array *array = fx_array_create();
|
||||||
fx_array_append(array, FX_RV_INT(32));
|
fx_array_append(array, fx_int_create(32));
|
||||||
fx_array_append(array, FX_RV_INT(64));
|
fx_array_append(array, fx_int_create(64));
|
||||||
fx_array_append(array, FX_RV_INT(128));
|
fx_array_append(array, fx_int_create(128));
|
||||||
|
|
||||||
fx_dict_put(dict, "numbers", FX_RV(array));
|
fx_dict_put(dict, "numbers", FX_RV(array));
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
#include <fx/ds/array.h>
|
#include <fx/bool.h>
|
||||||
#include <fx/ds/datetime.h>
|
#include <fx/collections/array.h>
|
||||||
#include <fx/ds/dict.h>
|
#include <fx/collections/datetime.h>
|
||||||
#include <fx/ds/number.h>
|
#include <fx/collections/dict.h>
|
||||||
#include <fx/ds/string.h>
|
#include <fx/double.h>
|
||||||
#include <fx/serial.h>
|
#include <fx/int.h>
|
||||||
|
#include <fx/serial/ctx.h>
|
||||||
|
#include <fx/serial/toml.h>
|
||||||
|
#include <fx/string.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
|
||||||
void write_tagged_value(fx_object *data);
|
void write_tagged_value(fx_object *data);
|
||||||
@@ -50,50 +53,50 @@ void write_tagged_string(fx_string *data)
|
|||||||
fx_stream_write_cstr(fx_stdout, " }", NULL);
|
fx_stream_write_cstr(fx_stdout, " }", NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void write_tagged_integer(fx_number *data)
|
void write_tagged_integer(fx_int *data)
|
||||||
{
|
{
|
||||||
fx_stream_write_cstr(
|
fx_stream_write_cstr(
|
||||||
fx_stdout,
|
fx_stdout,
|
||||||
"{ \"type\": \"integer\", \"value\": \"",
|
"{ \"type\": \"integer\", \"value\": \"",
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
if (fx_number_is_inf_positive(data)) {
|
if (fx_int_is_inf_positive(data)) {
|
||||||
fx_stream_write_cstr(fx_stdout, "inf", NULL);
|
fx_stream_write_cstr(fx_stdout, "inf", NULL);
|
||||||
} else if (fx_number_is_inf_negative(data)) {
|
} else if (fx_int_is_inf_negative(data)) {
|
||||||
fx_stream_write_cstr(fx_stdout, "-inf", NULL);
|
fx_stream_write_cstr(fx_stdout, "-inf", NULL);
|
||||||
} else if (fx_number_is_nan_positive(data)) {
|
} else if (fx_int_is_nan_positive(data)) {
|
||||||
fx_stream_write_cstr(fx_stdout, "nan", NULL);
|
fx_stream_write_cstr(fx_stdout, "nan", NULL);
|
||||||
} else if (fx_number_is_nan_negative(data)) {
|
} else if (fx_int_is_nan_negative(data)) {
|
||||||
fx_stream_write_cstr(fx_stdout, "-nan", NULL);
|
fx_stream_write_cstr(fx_stdout, "-nan", NULL);
|
||||||
} else {
|
} else {
|
||||||
fx_stream_write_fmt(
|
fx_stream_write_fmt(
|
||||||
fx_stdout,
|
fx_stdout,
|
||||||
NULL,
|
NULL,
|
||||||
"%lld",
|
"%lld",
|
||||||
fx_number_get_longlong(data),
|
fx_int_get_value(data),
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
fx_stream_write_cstr(fx_stdout, "\" }", NULL);
|
fx_stream_write_cstr(fx_stdout, "\" }", NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void write_tagged_float(fx_number *data)
|
void write_tagged_float(fx_double *data)
|
||||||
{
|
{
|
||||||
fx_stream_write_cstr(
|
fx_stream_write_cstr(
|
||||||
fx_stdout,
|
fx_stdout,
|
||||||
"{ \"type\": \"float\", \"value\": \"",
|
"{ \"type\": \"float\", \"value\": \"",
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
if (fx_number_is_inf_positive(data)) {
|
if (fx_double_is_inf_positive(data)) {
|
||||||
fx_stream_write_cstr(fx_stdout, "inf", NULL);
|
fx_stream_write_cstr(fx_stdout, "inf", NULL);
|
||||||
} else if (fx_number_is_inf_negative(data)) {
|
} else if (fx_double_is_inf_negative(data)) {
|
||||||
fx_stream_write_cstr(fx_stdout, "-inf", NULL);
|
fx_stream_write_cstr(fx_stdout, "-inf", NULL);
|
||||||
} else if (fx_number_is_nan_positive(data)) {
|
} else if (fx_double_is_nan_positive(data)) {
|
||||||
fx_stream_write_cstr(fx_stdout, "nan", NULL);
|
fx_stream_write_cstr(fx_stdout, "nan", NULL);
|
||||||
} else if (fx_number_is_nan_negative(data)) {
|
} else if (fx_double_is_nan_negative(data)) {
|
||||||
fx_stream_write_cstr(fx_stdout, "-nan", NULL);
|
fx_stream_write_cstr(fx_stdout, "-nan", NULL);
|
||||||
} else {
|
} else {
|
||||||
double v = fx_number_get_double(data);
|
double v = fx_double_get_value(data);
|
||||||
if ((v <= 0.00000001 && v > 0) || (v >= -0.00000001 && v < 0)
|
if ((v <= 0.00000001 && v > 0) || (v >= -0.00000001 && v < 0)
|
||||||
|| (v >= 1000000000) || (v <= -1000000000)) {
|
|| (v >= 1000000000) || (v <= -1000000000)) {
|
||||||
fx_stream_write_fmt(fx_stdout, NULL, "%.15e", v, NULL);
|
fx_stream_write_fmt(fx_stdout, NULL, "%.15e", v, NULL);
|
||||||
@@ -105,14 +108,13 @@ void write_tagged_float(fx_number *data)
|
|||||||
fx_stream_write_cstr(fx_stdout, "\" }", NULL);
|
fx_stream_write_cstr(fx_stdout, "\" }", NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void write_tagged_bool(fx_number *data)
|
void write_tagged_bool(fx_bool *data)
|
||||||
{
|
{
|
||||||
int v = fx_number_get_int8(data);
|
|
||||||
fx_stream_write_fmt(
|
fx_stream_write_fmt(
|
||||||
fx_stdout,
|
fx_stdout,
|
||||||
NULL,
|
NULL,
|
||||||
"{ \"type\": \"bool\", \"value\": \"%s\" }",
|
"{ \"type\": \"bool\", \"value\": \"%s\" }",
|
||||||
(v > 0) ? "true" : "false",
|
fx_bool_get_value(data) ? "true" : "false",
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -197,30 +199,18 @@ void write_tagged_value(fx_object *data)
|
|||||||
{
|
{
|
||||||
if (fx_object_is_type(data, FX_TYPE_DICT)) {
|
if (fx_object_is_type(data, FX_TYPE_DICT)) {
|
||||||
write_tagged_dict(data);
|
write_tagged_dict(data);
|
||||||
|
|
||||||
} else if (fx_object_is_type(data, FX_TYPE_ARRAY)) {
|
} else if (fx_object_is_type(data, FX_TYPE_ARRAY)) {
|
||||||
write_tagged_array(data);
|
write_tagged_array(data);
|
||||||
|
|
||||||
} else if (fx_object_is_type(data, FX_TYPE_STRING)) {
|
} else if (fx_object_is_type(data, FX_TYPE_STRING)) {
|
||||||
write_tagged_string(data);
|
write_tagged_string(data);
|
||||||
|
|
||||||
} else if (fx_object_is_type(data, FX_TYPE_DATETIME)) {
|
} else if (fx_object_is_type(data, FX_TYPE_DATETIME)) {
|
||||||
write_tagged_datetime(data);
|
write_tagged_datetime(data);
|
||||||
|
} else if (fx_object_is_type(data, FX_TYPE_INT)) {
|
||||||
} else if (fx_object_is_type(data, FX_TYPE_NUMBER)) {
|
write_tagged_integer(data);
|
||||||
switch (fx_number_get_number_type(data)) {
|
} else if (fx_object_is_type(data, FX_TYPE_BOOL)) {
|
||||||
case FX_NUMBER_LONGLONG:
|
write_tagged_bool(data);
|
||||||
write_tagged_integer(data);
|
} else if (fx_object_is_type(data, FX_TYPE_DOUBLE)) {
|
||||||
break;
|
write_tagged_float(data);
|
||||||
case FX_NUMBER_INT8:
|
|
||||||
write_tagged_bool(data);
|
|
||||||
break;
|
|
||||||
case FX_NUMBER_DOUBLE:
|
|
||||||
write_tagged_float(data);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+6
-6
@@ -2322,16 +2322,16 @@ static void toml_serial_ctx_fini(fx_object *obj, void *priv)
|
|||||||
|
|
||||||
/*** CLASS DEFINITION *********************************************************/
|
/*** CLASS DEFINITION *********************************************************/
|
||||||
|
|
||||||
FX_TYPE_CLASS_DEFINITION_BEGIN(fx_toml_serial_ctx)
|
FX_TYPE_CLASS_BEGIN(fx_toml_serial_ctx)
|
||||||
FX_TYPE_CLASS_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
||||||
FX_INTERFACE_ENTRY(to_string) = NULL;
|
FX_INTERFACE_ENTRY(to_string) = NULL;
|
||||||
FX_TYPE_CLASS_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
|
||||||
|
|
||||||
FX_TYPE_CLASS_INTERFACE_BEGIN(fx_serial_ctx, FX_TYPE_SERIAL_CTX)
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_serial_ctx, FX_TYPE_SERIAL_CTX)
|
||||||
FX_INTERFACE_ENTRY(s_serialise) = toml_serialise;
|
FX_INTERFACE_ENTRY(s_serialise) = toml_serialise;
|
||||||
FX_INTERFACE_ENTRY(s_deserialise) = toml_deserialise;
|
FX_INTERFACE_ENTRY(s_deserialise) = toml_deserialise;
|
||||||
FX_TYPE_CLASS_INTERFACE_END(fx_serial_ctx, FX_TYPE_SERIAL_CTX)
|
FX_TYPE_VTABLE_INTERFACE_END(fx_serial_ctx, FX_TYPE_SERIAL_CTX)
|
||||||
FX_TYPE_CLASS_DEFINITION_END(fx_toml_serial_ctx)
|
FX_TYPE_CLASS_END(fx_toml_serial_ctx)
|
||||||
|
|
||||||
FX_TYPE_DEFINITION_BEGIN(fx_toml_serial_ctx)
|
FX_TYPE_DEFINITION_BEGIN(fx_toml_serial_ctx)
|
||||||
FX_TYPE_ID(0xaec8dca0, 0x131a, 0x4217, 0x916b, 0xaed15756601c);
|
FX_TYPE_ID(0xaec8dca0, 0x131a, 0x4217, 0x916b, 0xaed15756601c);
|
||||||
|
|||||||
+31
-13
@@ -1,4 +1,4 @@
|
|||||||
#include <fx/core/error.h>
|
#include <fx/error.h>
|
||||||
#include <fx/term/print.h>
|
#include <fx/term/print.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
@@ -17,21 +17,28 @@ static const fx_error_definition sample_errors[] = {
|
|||||||
FX_ERROR_DEFINITION(SAMPLE_OK, "OK", "Success"),
|
FX_ERROR_DEFINITION(SAMPLE_OK, "OK", "Success"),
|
||||||
FX_ERROR_DEFINITION(SAMPLE_ERR_IO_FAILURE, "IO_FAILURE", "I/O failure"),
|
FX_ERROR_DEFINITION(SAMPLE_ERR_IO_FAILURE, "IO_FAILURE", "I/O failure"),
|
||||||
FX_ERROR_DEFINITION_TEMPLATE(
|
FX_ERROR_DEFINITION_TEMPLATE(
|
||||||
SAMPLE_ERR_FILE_READ_FAILED, "FILE_READ_FAILED",
|
SAMPLE_ERR_FILE_READ_FAILED,
|
||||||
|
"FILE_READ_FAILED",
|
||||||
"Failed to read file @i[filepath]",
|
"Failed to read file @i[filepath]",
|
||||||
FX_ERROR_TEMPLATE_PARAM(
|
FX_ERROR_TEMPLATE_PARAM(
|
||||||
"filepath", FX_ERROR_TEMPLATE_PARAM_STRING, "%s")),
|
"filepath",
|
||||||
|
FX_ERROR_TEMPLATE_PARAM_STRING,
|
||||||
|
"%s")),
|
||||||
};
|
};
|
||||||
|
|
||||||
static const fx_error_msg sample_error_msg[] = {
|
static const fx_error_msg sample_error_msg[] = {
|
||||||
FX_ERROR_MSG_TEMPLATE(
|
FX_ERROR_MSG_TEMPLATE(
|
||||||
SAMPLE_MSG_A_TEMPLATED_MSG, "A templated message: @e[param1]",
|
SAMPLE_MSG_A_TEMPLATED_MSG,
|
||||||
|
"A templated message: @e[param1]",
|
||||||
FX_ERROR_TEMPLATE_PARAM(
|
FX_ERROR_TEMPLATE_PARAM(
|
||||||
"param1", FX_ERROR_TEMPLATE_PARAM_STRING, "%s")),
|
"param1",
|
||||||
|
FX_ERROR_TEMPLATE_PARAM_STRING,
|
||||||
|
"%s")),
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char *sample_code_to_string(
|
static const char *sample_code_to_string(
|
||||||
const struct fx_error_vendor *vendor, fx_error_status_code code)
|
const struct fx_error_vendor *vendor,
|
||||||
|
fx_error_status_code code)
|
||||||
{
|
{
|
||||||
switch (code) {
|
switch (code) {
|
||||||
case SAMPLE_OK:
|
case SAMPLE_OK:
|
||||||
@@ -56,15 +63,22 @@ static fx_error_vendor sample_vendor = {
|
|||||||
static fx_result error_return_3(void)
|
static fx_result error_return_3(void)
|
||||||
{
|
{
|
||||||
fx_result err = fx_error_with_string(
|
fx_result err = fx_error_with_string(
|
||||||
&sample_vendor, SAMPLE_ERR_IO_FAILURE,
|
&sample_vendor,
|
||||||
|
SAMPLE_ERR_IO_FAILURE,
|
||||||
"I/O failure while reading file");
|
"I/O failure while reading file");
|
||||||
|
|
||||||
fx_error_add_submsg_string(
|
fx_error_add_submsg_string(
|
||||||
err, FX_ERROR_SUBMSG_ERROR, "An @e{error} message");
|
err,
|
||||||
|
FX_ERROR_SUBMSG_ERROR,
|
||||||
|
"An @e{error} message");
|
||||||
fx_error_add_submsg_string(
|
fx_error_add_submsg_string(
|
||||||
err, FX_ERROR_SUBMSG_WARNING, "A @w{warning} message");
|
err,
|
||||||
|
FX_ERROR_SUBMSG_WARNING,
|
||||||
|
"A @w{warning} message");
|
||||||
fx_error_add_submsg_template(
|
fx_error_add_submsg_template(
|
||||||
err, FX_ERROR_SUBMSG_WARNING, SAMPLE_MSG_A_TEMPLATED_MSG,
|
err,
|
||||||
|
FX_ERROR_SUBMSG_WARNING,
|
||||||
|
SAMPLE_MSG_A_TEMPLATED_MSG,
|
||||||
FX_ERROR_PARAM("param1", "Hello!"));
|
FX_ERROR_PARAM("param1", "Hello!"));
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
@@ -105,10 +119,12 @@ static fx_result some_operation(void)
|
|||||||
fx_result result = error_return_2();
|
fx_result result = error_return_2();
|
||||||
if (fx_result_is_error(result)) {
|
if (fx_result_is_error(result)) {
|
||||||
fx_result err = fx_error_with_template(
|
fx_result err = fx_error_with_template(
|
||||||
&sample_vendor, SAMPLE_ERR_FILE_READ_FAILED,
|
&sample_vendor,
|
||||||
|
SAMPLE_ERR_FILE_READ_FAILED,
|
||||||
FX_ERROR_PARAM("filepath", "src/Manifest.json"));
|
FX_ERROR_PARAM("filepath", "src/Manifest.json"));
|
||||||
fx_error_add_submsg_string(
|
fx_error_add_submsg_string(
|
||||||
err, FX_ERROR_SUBMSG_INFO,
|
err,
|
||||||
|
FX_ERROR_SUBMSG_INFO,
|
||||||
"An @i{informational} message");
|
"An @i{informational} message");
|
||||||
|
|
||||||
fx_error_caused_by_fx_status(result, FX_ERR_IO_FAILURE);
|
fx_error_caused_by_fx_status(result, FX_ERR_IO_FAILURE);
|
||||||
@@ -122,7 +138,9 @@ static fx_result some_operation(void)
|
|||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
fx_set_error_report_function(fx_enhanced_error_reporter, FX_ERROR_REPORT_ALL);
|
fx_set_error_report_function(
|
||||||
|
fx_enhanced_error_reporter,
|
||||||
|
FX_ERROR_REPORT_ALL);
|
||||||
|
|
||||||
test(PARAM("Hello", 1), PARAM("Goodbye", 2));
|
test(PARAM("Hello", 1), PARAM("Goodbye", 2));
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#include <fx/term/tty.h>
|
#include <fx/string.h>
|
||||||
#include <fx/term/print.h>
|
#include <fx/term/print.h>
|
||||||
#include <fx/ds/string.h>
|
#include <fx/term/tty.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#define F_GREEN "[green]"
|
#define F_GREEN "[green]"
|
||||||
@@ -62,7 +62,7 @@ int main(void)
|
|||||||
size_t len = fx_string_get_size(str, FX_STRLEN_IGNORE_MOD);
|
size_t len = fx_string_get_size(str, FX_STRLEN_IGNORE_MOD);
|
||||||
printf("length = %zu\n", len);
|
printf("length = %zu\n", len);
|
||||||
|
|
||||||
fx_paragraph_format format = { 0 };
|
fx_paragraph_format format = {0};
|
||||||
format.p_left_margin = 5;
|
format.p_left_margin = 5;
|
||||||
format.p_right_margin = 5;
|
format.p_right_margin = 5;
|
||||||
format.p_flags = FX_PARAGRAPH_DOUBLE_LINE_BREAK;
|
format.p_flags = FX_PARAGRAPH_DOUBLE_LINE_BREAK;
|
||||||
@@ -72,8 +72,11 @@ int main(void)
|
|||||||
fx_i("An informational message\n\nWith multiple lines");
|
fx_i("An informational message\n\nWith multiple lines");
|
||||||
fx_warn("A warning message\nWith multiple lines");
|
fx_warn("A warning message\nWith multiple lines");
|
||||||
fx_err("An error message\nWith multiple lines");
|
fx_err("An error message\nWith multiple lines");
|
||||||
|
|
||||||
fx_printf("[red]formatting ignored: '%s'[reset]\n[dark_grey]dark text[reset]\n", "[blue]wow![reset]");
|
fx_printf(
|
||||||
|
"[red]formatting ignored: '%s'[reset]\n[dark_grey]dark "
|
||||||
|
"text[reset]\n",
|
||||||
|
"[blue]wow![reset]");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,11 +69,11 @@ static void bool_to_string(const fx_object *obj, fx_stream *out)
|
|||||||
|
|
||||||
/*** CLASS DEFINITION *********************************************************/
|
/*** CLASS DEFINITION *********************************************************/
|
||||||
|
|
||||||
FX_TYPE_CLASS_DEFINITION_BEGIN(fx_bool)
|
FX_TYPE_CLASS_BEGIN(fx_bool)
|
||||||
FX_TYPE_CLASS_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
||||||
FX_INTERFACE_ENTRY(to_string) = bool_to_string;
|
FX_INTERFACE_ENTRY(to_string) = bool_to_string;
|
||||||
FX_TYPE_CLASS_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
|
||||||
FX_TYPE_CLASS_DEFINITION_END(fx_bool)
|
FX_TYPE_CLASS_END(fx_bool)
|
||||||
|
|
||||||
FX_TYPE_DEFINITION_BEGIN(fx_bool)
|
FX_TYPE_DEFINITION_BEGIN(fx_bool)
|
||||||
FX_TYPE_ID(0x9c8453bf, 0xfc92, 0x4b0a, 0xbcaf, 0xd0c6cdba9310);
|
FX_TYPE_ID(0x9c8453bf, 0xfc92, 0x4b0a, 0xbcaf, 0xd0c6cdba9310);
|
||||||
|
|||||||
@@ -59,6 +59,7 @@
|
|||||||
|
|
||||||
#include <fx/bst.h>
|
#include <fx/bst.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#define MAX(a, b) ((a) > (b) ? (a) : (b))
|
#define MAX(a, b) ((a) > (b) ? (a) : (b))
|
||||||
#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||||
@@ -766,131 +767,3 @@ void fx_bst_move(
|
|||||||
|
|
||||||
memmove(dest, src, sizeof *src);
|
memmove(dest, src, sizeof *src);
|
||||||
}
|
}
|
||||||
|
|
||||||
fx_iterator *fx_bst_begin(struct fx_bst *tree)
|
|
||||||
{
|
|
||||||
fx_iterator *it_obj = fx_object_create(FX_TYPE_BST_ITERATOR);
|
|
||||||
if (!it_obj) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct fx_bst_iterator_p *it
|
|
||||||
= fx_object_get_private(it_obj, FX_TYPE_BST_ITERATOR);
|
|
||||||
int depth = 0;
|
|
||||||
|
|
||||||
it->_b = (struct fx_bst *)tree;
|
|
||||||
it->i = 0;
|
|
||||||
it->node = first_node(tree, &depth);
|
|
||||||
it->depth = depth;
|
|
||||||
|
|
||||||
return it_obj;
|
|
||||||
}
|
|
||||||
|
|
||||||
const fx_iterator *fx_bst_cbegin(const struct fx_bst *tree)
|
|
||||||
{
|
|
||||||
fx_iterator *it_obj = fx_object_create(FX_TYPE_BST_ITERATOR);
|
|
||||||
if (!it_obj) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct fx_bst_iterator_p *it
|
|
||||||
= fx_object_get_private(it_obj, FX_TYPE_BST_ITERATOR);
|
|
||||||
int depth = 0;
|
|
||||||
|
|
||||||
it->_b = (struct fx_bst *)tree;
|
|
||||||
it->i = 0;
|
|
||||||
it->node = first_node(tree, &depth);
|
|
||||||
it->depth = depth;
|
|
||||||
|
|
||||||
return it_obj;
|
|
||||||
}
|
|
||||||
|
|
||||||
static enum fx_status iterator_move_next(const fx_iterator *obj)
|
|
||||||
{
|
|
||||||
struct fx_bst_iterator_p *it
|
|
||||||
= fx_object_get_private(obj, FX_TYPE_BST_ITERATOR);
|
|
||||||
|
|
||||||
int depth_diff = 0;
|
|
||||||
struct fx_bst_node *next = next_node(it->node, &depth_diff);
|
|
||||||
|
|
||||||
if (!next) {
|
|
||||||
it->node = NULL;
|
|
||||||
it->depth = 0;
|
|
||||||
it->i++;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
it->node = next;
|
|
||||||
it->i++;
|
|
||||||
it->depth += depth_diff;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
static enum fx_status iterator_erase(fx_iterator *obj)
|
|
||||||
{
|
|
||||||
struct fx_bst_iterator_p *it
|
|
||||||
= fx_object_get_private(obj, FX_TYPE_BST_ITERATOR);
|
|
||||||
|
|
||||||
if (!it->node) {
|
|
||||||
return FX_ERR_OUT_OF_BOUNDS;
|
|
||||||
}
|
|
||||||
|
|
||||||
int depth_diff = 0;
|
|
||||||
struct fx_bst_node *next = next_node(it->node, &depth_diff);
|
|
||||||
|
|
||||||
fx_bst_delete(it->_b, it->node);
|
|
||||||
if (!next) {
|
|
||||||
it->node = NULL;
|
|
||||||
it->depth = 0;
|
|
||||||
} else {
|
|
||||||
it->node = next;
|
|
||||||
it->depth = 0;
|
|
||||||
|
|
||||||
struct fx_bst_node *cur = next->n_parent;
|
|
||||||
while (cur) {
|
|
||||||
it->depth++;
|
|
||||||
cur = cur->n_parent;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return FX_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
static fx_iterator_value iterator_get_value(fx_iterator *obj)
|
|
||||||
{
|
|
||||||
struct fx_bst_iterator_p *it
|
|
||||||
= fx_object_get_private(obj, FX_TYPE_BST_ITERATOR);
|
|
||||||
|
|
||||||
return FX_ITERATOR_VALUE_PTR(it->node);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const fx_iterator_value iterator_get_cvalue(const fx_iterator *obj)
|
|
||||||
{
|
|
||||||
struct fx_bst_iterator_p *it
|
|
||||||
= fx_object_get_private(obj, FX_TYPE_BST_ITERATOR);
|
|
||||||
|
|
||||||
return FX_ITERATOR_VALUE_CPTR(it->node);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*** CLASS DEFINITION *********************************************************/
|
|
||||||
|
|
||||||
// ---- fx_bst_iterator DEFINITION
|
|
||||||
FX_TYPE_CLASS_DEFINITION_BEGIN(fx_bst_iterator)
|
|
||||||
FX_TYPE_CLASS_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
|
||||||
FX_INTERFACE_ENTRY(to_string) = NULL;
|
|
||||||
FX_TYPE_CLASS_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
|
|
||||||
|
|
||||||
FX_TYPE_CLASS_INTERFACE_BEGIN(fx_iterator, FX_TYPE_ITERATOR)
|
|
||||||
FX_INTERFACE_ENTRY(it_move_next) = iterator_move_next;
|
|
||||||
FX_INTERFACE_ENTRY(it_erase) = iterator_erase;
|
|
||||||
FX_INTERFACE_ENTRY(it_get_value) = iterator_get_value;
|
|
||||||
FX_INTERFACE_ENTRY(it_get_cvalue) = iterator_get_cvalue;
|
|
||||||
FX_TYPE_CLASS_INTERFACE_END(fx_iterator, FX_TYPE_ITERATOR)
|
|
||||||
FX_TYPE_CLASS_DEFINITION_END(fx_bst_iterator)
|
|
||||||
|
|
||||||
FX_TYPE_DEFINITION_BEGIN(fx_bst_iterator)
|
|
||||||
FX_TYPE_ID(0x432779d7, 0xc03a, 0x48ea, 0xae8f, 0x12c666c767ae);
|
|
||||||
FX_TYPE_EXTENDS(FX_TYPE_ITERATOR);
|
|
||||||
FX_TYPE_CLASS(fx_bst_iterator_class);
|
|
||||||
FX_TYPE_INSTANCE_PRIVATE(struct fx_bst_iterator_p);
|
|
||||||
FX_TYPE_DEFINITION_END(fx_bst_iterator)
|
|
||||||
|
|||||||
+31
-18
@@ -7,14 +7,14 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
void *fx_class_get(fx_type id)
|
void *fx_class_get(fx_type_id id)
|
||||||
{
|
{
|
||||||
struct fx_type_registration *r = fx_type_get_registration(id);
|
struct fx_type_info *ty = fx_type_info_get_by_id(id);
|
||||||
if (!r) {
|
if (!ty) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return r->r_class;
|
return ty->ty_class;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *fx_class_get_name(const struct _fx_class *c)
|
const char *fx_class_get_name(const struct _fx_class *c)
|
||||||
@@ -25,10 +25,12 @@ const char *fx_class_get_name(const struct _fx_class *c)
|
|||||||
|
|
||||||
assert(c->c_magic == FX_CLASS_MAGIC);
|
assert(c->c_magic == FX_CLASS_MAGIC);
|
||||||
|
|
||||||
return c->c_type->r_info->t_name;
|
return c->c_type->ty_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *fx_class_get_interface(const struct _fx_class *c, const union fx_type *id)
|
void *fx_class_get_interface(
|
||||||
|
const struct _fx_class *c,
|
||||||
|
const union fx_type_id *id)
|
||||||
{
|
{
|
||||||
if (!c) {
|
if (!c) {
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -36,9 +38,10 @@ void *fx_class_get_interface(const struct _fx_class *c, const union fx_type *id)
|
|||||||
|
|
||||||
assert(c->c_magic == FX_CLASS_MAGIC);
|
assert(c->c_magic == FX_CLASS_MAGIC);
|
||||||
|
|
||||||
const struct fx_type_registration *type_reg = c->c_type;
|
const struct fx_type_info *type_reg = c->c_type;
|
||||||
struct fx_type_component *comp
|
struct fx_type_component *comp = fx_type_get_component(
|
||||||
= fx_type_get_component(&type_reg->r_components, id);
|
&type_reg->ty_components,
|
||||||
|
id);
|
||||||
|
|
||||||
if (!comp) {
|
if (!comp) {
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -48,28 +51,38 @@ void *fx_class_get_interface(const struct _fx_class *c, const union fx_type *id)
|
|||||||
}
|
}
|
||||||
|
|
||||||
fx_result fx_class_instantiate(
|
fx_result fx_class_instantiate(
|
||||||
struct fx_type_registration *type,
|
struct fx_type_info *type,
|
||||||
struct _fx_class **out_class)
|
struct _fx_class **out_class)
|
||||||
{
|
{
|
||||||
struct _fx_class *out = malloc(type->r_class_size);
|
struct _fx_class *out = malloc(type->ty_class_size);
|
||||||
if (!out) {
|
if (!out) {
|
||||||
return FX_RESULT_ERR(NO_MEMORY);
|
return FX_RESULT_ERR(NO_MEMORY);
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(out, 0x0, type->r_class_size);
|
memset(out, 0x0, type->ty_class_size);
|
||||||
|
|
||||||
out->c_magic = FX_CLASS_MAGIC;
|
out->c_magic = FX_CLASS_MAGIC;
|
||||||
out->c_type = type;
|
out->c_type = type;
|
||||||
|
|
||||||
struct fx_queue_entry *entry = fx_queue_first(&type->r_class_hierarchy);
|
struct fx_queue_entry *entry = fx_queue_first(
|
||||||
|
&type->ty_class_hierarchy);
|
||||||
while (entry) {
|
while (entry) {
|
||||||
struct fx_type_component *comp
|
struct fx_type_component *comp = fx_unbox(
|
||||||
= fx_unbox(struct fx_type_component, entry, c_entry);
|
struct fx_type_component,
|
||||||
const struct fx_type_info *class_info = comp->c_type->r_info;
|
entry,
|
||||||
|
c_entry);
|
||||||
|
const struct fx_type_info *class_info = comp->c_type;
|
||||||
void *class_data = (char *)out + comp->c_class_data_offset;
|
void *class_data = (char *)out + comp->c_class_data_offset;
|
||||||
|
struct fx_type_info *main_class_param = NULL;
|
||||||
|
if (class_info == type) {
|
||||||
|
main_class_param = type;
|
||||||
|
}
|
||||||
|
|
||||||
if (class_info->t_class_init) {
|
if (class_info->ty_class_init) {
|
||||||
class_info->t_class_init(out, class_data);
|
class_info->ty_class_init(
|
||||||
|
out,
|
||||||
|
main_class_param,
|
||||||
|
class_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
entry = fx_queue_next(entry);
|
entry = fx_queue_next(entry);
|
||||||
|
|||||||
+4
-3
@@ -5,14 +5,15 @@
|
|||||||
#include <fx/misc.h>
|
#include <fx/misc.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
struct fx_type_registration;
|
struct fx_type_info;
|
||||||
|
|
||||||
struct _fx_class {
|
struct _fx_class {
|
||||||
uint64_t c_magic;
|
uint64_t c_magic;
|
||||||
const struct fx_type_registration *c_type;
|
const struct fx_type_info *c_type;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern fx_result fx_class_instantiate(
|
extern fx_result fx_class_instantiate(
|
||||||
struct fx_type_registration *type, struct _fx_class **out);
|
struct fx_type_info *type,
|
||||||
|
struct _fx_class **out);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+4
-4
@@ -265,11 +265,11 @@ static void double_to_string(const fx_object *obj, fx_stream *out)
|
|||||||
|
|
||||||
/*** CLASS DEFINITION *********************************************************/
|
/*** CLASS DEFINITION *********************************************************/
|
||||||
|
|
||||||
FX_TYPE_CLASS_DEFINITION_BEGIN(fx_double)
|
FX_TYPE_CLASS_BEGIN(fx_double)
|
||||||
FX_TYPE_CLASS_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
||||||
FX_INTERFACE_ENTRY(to_string) = double_to_string;
|
FX_INTERFACE_ENTRY(to_string) = double_to_string;
|
||||||
FX_TYPE_CLASS_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
|
FX_TYPE_VTABLE_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
|
||||||
FX_TYPE_CLASS_DEFINITION_END(fx_double)
|
FX_TYPE_CLASS_END(fx_double)
|
||||||
|
|
||||||
FX_TYPE_DEFINITION_BEGIN(fx_double)
|
FX_TYPE_DEFINITION_BEGIN(fx_double)
|
||||||
FX_TYPE_ID(0x3b20f57a, 0x2ddf, 0x4682, 0x81c4, 0x4fe404a6524e);
|
FX_TYPE_ID(0x3b20f57a, 0x2ddf, 0x4682, 0x81c4, 0x4fe404a6524e);
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ FX_DECLARE_TYPE(fx_bool);
|
|||||||
FX_TYPE_CLASS_DECLARATION_BEGIN(fx_bool)
|
FX_TYPE_CLASS_DECLARATION_BEGIN(fx_bool)
|
||||||
FX_TYPE_CLASS_DECLARATION_END(fx_bool)
|
FX_TYPE_CLASS_DECLARATION_END(fx_bool)
|
||||||
|
|
||||||
FX_API fx_type fx_bool_get_type(void);
|
FX_API fx_type_id fx_bool_get_type(void);
|
||||||
|
|
||||||
FX_API fx_bool *fx_bool_create(bool value);
|
FX_API fx_bool *fx_bool_create(bool value);
|
||||||
|
|
||||||
|
|||||||
+14
-25
@@ -1,22 +1,16 @@
|
|||||||
#ifndef FX_CORE_BST_H_
|
#ifndef FX_CORE_BST_H_
|
||||||
#define FX_CORE_BST_H_
|
#define FX_CORE_BST_H_
|
||||||
|
|
||||||
#include <fx/iterator.h>
|
|
||||||
#include <fx/macros.h>
|
|
||||||
#include <fx/misc.h>
|
#include <fx/misc.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
FX_DECLS_BEGIN;
|
#ifdef __cplusplus
|
||||||
|
#define FX_DECLS_BEGIN extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
#define FX_BST_INIT {0}
|
#define FX_BST_INIT {0}
|
||||||
#define FX_TYPE_BST_ITERATOR (fx_bst_iterator_get_type())
|
|
||||||
|
|
||||||
FX_DECLARE_TYPE(fx_bst_iterator);
|
|
||||||
|
|
||||||
FX_TYPE_CLASS_DECLARATION_BEGIN(fx_bst_iterator)
|
|
||||||
FX_TYPE_CLASS_DECLARATION_END(fx_bst_iterator)
|
|
||||||
|
|
||||||
/* defines a simple node insertion function.
|
/* defines a simple node insertion function.
|
||||||
this function assumes that your nodes have simple integer keys that can be
|
this function assumes that your nodes have simple integer keys that can be
|
||||||
@@ -26,18 +20,18 @@ FX_TYPE_CLASS_DECLARATION_END(fx_bst_iterator)
|
|||||||
if you have a tree node type like this:
|
if you have a tree node type like this:
|
||||||
|
|
||||||
struct my_tree_node {
|
struct my_tree_node {
|
||||||
int key;
|
int key;
|
||||||
fx_bst_node base;
|
fx_bst_node base;
|
||||||
}
|
}
|
||||||
|
|
||||||
You would use the following call to generate an insert function for a tree
|
You would use the following call to generate an insert function for a tree
|
||||||
with this node type:
|
with this node type:
|
||||||
|
|
||||||
BST_DEFINE_SIMPLE_INSERT(
|
BST_DEFINE_SIMPLE_INSERT(
|
||||||
struct my_tree_node,
|
struct my_tree_node,
|
||||||
base,
|
base,
|
||||||
key,
|
key,
|
||||||
my_tree_node_insert);
|
my_tree_node_insert);
|
||||||
|
|
||||||
Which would emit a function defined like:
|
Which would emit a function defined like:
|
||||||
|
|
||||||
@@ -111,8 +105,8 @@ FX_TYPE_CLASS_DECLARATION_END(fx_bst_iterator)
|
|||||||
if you have a tree node type like this:
|
if you have a tree node type like this:
|
||||||
|
|
||||||
struct my_tree_node {
|
struct my_tree_node {
|
||||||
complex_key_t key;
|
complex_key_t key;
|
||||||
fx_bst_node base;
|
fx_bst_node base;
|
||||||
}
|
}
|
||||||
|
|
||||||
You would need to define a comparator function or macro with the following
|
You would need to define a comparator function or macro with the following
|
||||||
@@ -207,8 +201,8 @@ FX_TYPE_CLASS_DECLARATION_END(fx_bst_iterator)
|
|||||||
if you have a tree node type like this:
|
if you have a tree node type like this:
|
||||||
|
|
||||||
struct my_tree_node {
|
struct my_tree_node {
|
||||||
int key;
|
int key;
|
||||||
fx_bst_node base;
|
fx_bst_node base;
|
||||||
}
|
}
|
||||||
|
|
||||||
You would use the following call to generate a search function for a tree
|
You would use the following call to generate a search function for a tree
|
||||||
@@ -279,8 +273,6 @@ typedef struct fx_bst {
|
|||||||
fx_bst_node *bst_root;
|
fx_bst_node *bst_root;
|
||||||
} fx_bst;
|
} fx_bst;
|
||||||
|
|
||||||
FX_API fx_type fx_bst_iterator_get_type(void);
|
|
||||||
|
|
||||||
/* re-balance a binary tree after an insertion operation.
|
/* re-balance a binary tree after an insertion operation.
|
||||||
|
|
||||||
NOTE that, if you define an insertion function using BST_DEFINE_INSERT or
|
NOTE that, if you define an insertion function using BST_DEFINE_INSERT or
|
||||||
@@ -369,9 +361,6 @@ static inline unsigned short fx_bst_height(fx_bst_node *node)
|
|||||||
return node->n_height;
|
return node->n_height;
|
||||||
}
|
}
|
||||||
|
|
||||||
FX_API fx_iterator *fx_bst_begin(fx_bst *tree);
|
|
||||||
FX_API const fx_iterator *fx_bst_cbegin(const fx_bst *tree);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -8,8 +8,8 @@
|
|||||||
|
|
||||||
typedef struct _fx_class fx_class;
|
typedef struct _fx_class fx_class;
|
||||||
|
|
||||||
FX_API void *fx_class_get(fx_type id);
|
FX_API void *fx_class_get(fx_type_id id);
|
||||||
FX_API const char *fx_class_get_name(const fx_class *c);
|
FX_API const char *fx_class_get_name(const fx_class *c);
|
||||||
FX_API void *fx_class_get_interface(const fx_class *c, fx_type id);
|
FX_API void *fx_class_get_interface(const fx_class *c, fx_type_id id);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ FX_DECLARE_TYPE(fx_double);
|
|||||||
FX_TYPE_CLASS_DECLARATION_BEGIN(fx_double)
|
FX_TYPE_CLASS_DECLARATION_BEGIN(fx_double)
|
||||||
FX_TYPE_CLASS_DECLARATION_END(fx_double)
|
FX_TYPE_CLASS_DECLARATION_END(fx_double)
|
||||||
|
|
||||||
FX_API fx_type fx_double_get_type(void);
|
FX_API fx_type_id fx_double_get_type(void);
|
||||||
|
|
||||||
FX_API fx_double *fx_double_create(double value);
|
FX_API fx_double *fx_double_create(double value);
|
||||||
FX_API fx_double *fx_double_create_nan(void);
|
FX_API fx_double *fx_double_create_nan(void);
|
||||||
|
|||||||
+1
-1
@@ -12,7 +12,7 @@ FX_DECLARE_TYPE(fx_int);
|
|||||||
FX_TYPE_CLASS_DECLARATION_BEGIN(fx_int)
|
FX_TYPE_CLASS_DECLARATION_BEGIN(fx_int)
|
||||||
FX_TYPE_CLASS_DECLARATION_END(fx_int)
|
FX_TYPE_CLASS_DECLARATION_END(fx_int)
|
||||||
|
|
||||||
FX_API fx_type fx_int_get_type(void);
|
FX_API fx_type_id fx_int_get_type(void);
|
||||||
|
|
||||||
FX_API fx_int *fx_int_create(intptr_t value);
|
FX_API fx_int *fx_int_create(intptr_t value);
|
||||||
FX_API fx_int *fx_int_create_nan(void);
|
FX_API fx_int *fx_int_create_nan(void);
|
||||||
|
|||||||
@@ -61,8 +61,8 @@ FX_TYPE_CLASS_DECLARATION_BEGIN(fx_iterable)
|
|||||||
const fx_iterator *(*it_cbegin)(const fx_iterable *);
|
const fx_iterator *(*it_cbegin)(const fx_iterable *);
|
||||||
FX_TYPE_CLASS_DECLARATION_END(fx_iterable)
|
FX_TYPE_CLASS_DECLARATION_END(fx_iterable)
|
||||||
|
|
||||||
FX_API fx_type fx_iterator_get_type(void);
|
FX_API fx_type_id fx_iterator_get_type(void);
|
||||||
FX_API fx_type fx_iterable_get_type(void);
|
FX_API fx_type_id fx_iterable_get_type(void);
|
||||||
|
|
||||||
static inline const fx_iterator *fx_iterator_ref(const fx_iterator *p)
|
static inline const fx_iterator *fx_iterator_ref(const fx_iterator *p)
|
||||||
{
|
{
|
||||||
|
|||||||
+94
-45
@@ -5,6 +5,7 @@
|
|||||||
#include <fx/object.h>
|
#include <fx/object.h>
|
||||||
#include <fx/thread.h>
|
#include <fx/thread.h>
|
||||||
#include <fx/type.h>
|
#include <fx/type.h>
|
||||||
|
#include <fx/value.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#define __FX_IFACE_I0(p, x) p##x
|
#define __FX_IFACE_I0(p, x) p##x
|
||||||
@@ -12,12 +13,63 @@
|
|||||||
|
|
||||||
/* Type definitions macros (for use in .c source file) */
|
/* Type definitions macros (for use in .c source file) */
|
||||||
|
|
||||||
#define FX_TYPE_CLASS_DEFINITION_BEGIN(type_name) \
|
#define FX_TYPE_CLASS_BEGIN(type_name) \
|
||||||
static void type_name##_class_init(fx_class *p, void *d) \
|
static void type_name##_class_init( \
|
||||||
|
fx_class *p, \
|
||||||
|
fx_type_info *ty, \
|
||||||
|
void *d) \
|
||||||
{
|
{
|
||||||
#define FX_TYPE_CLASS_DEFINITION_END(type_name) }
|
#define FX_TYPE_CLASS_END(type_name) }
|
||||||
|
|
||||||
#define FX_TYPE_CLASS_INTERFACE_BEGIN(interface_name, interface_id) \
|
#define FX_TYPE_FUNCTIONALITY_BEGIN(type_name) \
|
||||||
|
static void type_name##_type_functionality_init(void *opaque) \
|
||||||
|
{
|
||||||
|
#define FX_TYPE_FUNCTIONALITY_END(type_name) }
|
||||||
|
#define FX_TYPE_CONSTRUCTOR(name, impl, flags, ...) \
|
||||||
|
do { \
|
||||||
|
if (ty) { \
|
||||||
|
fx_value_type args[] = {__VA_ARGS__}; \
|
||||||
|
fx_function *func = fx_function_create( \
|
||||||
|
name, \
|
||||||
|
FX_FUNCTION_F_CONSTRUCTOR \
|
||||||
|
| FX_FUNCTION_F_STATIC | (flags), \
|
||||||
|
(fx_function_impl)impl, \
|
||||||
|
args, \
|
||||||
|
sizeof args / sizeof args[0], \
|
||||||
|
FX_VALUE_TYPE_POINTER); \
|
||||||
|
fx_type_add_function(ty, func); \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
#define FX_TYPE_METHOD(return_type, name, impl, flags, ...) \
|
||||||
|
do { \
|
||||||
|
if (ty) { \
|
||||||
|
fx_value_type args[] = {__VA_ARGS__}; \
|
||||||
|
fx_function *func = fx_function_create( \
|
||||||
|
name, \
|
||||||
|
(flags), \
|
||||||
|
(fx_function_impl)impl, \
|
||||||
|
args, \
|
||||||
|
sizeof args / sizeof args[0], \
|
||||||
|
return_type); \
|
||||||
|
fx_type_add_function(ty, func); \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
#define FX_TYPE_FUNCTION(return_type, name, impl, ...) \
|
||||||
|
do { \
|
||||||
|
if (ty) { \
|
||||||
|
fx_value_type args[] = {__VA_ARGS__}; \
|
||||||
|
fx_function *func = fx_function_create( \
|
||||||
|
name, \
|
||||||
|
FX_FUNCTION_F_STATIC | (flags), \
|
||||||
|
(fx_function_impl)impl, \
|
||||||
|
args, \
|
||||||
|
sizeof args / sizeof args[0], \
|
||||||
|
return_type); \
|
||||||
|
fx_type_add_function(ty, func); \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define FX_TYPE_VTABLE_INTERFACE_BEGIN(interface_name, interface_id) \
|
||||||
interface_name##_class *__FX_IFACE_I1(iface, __LINE__) \
|
interface_name##_class *__FX_IFACE_I1(iface, __LINE__) \
|
||||||
= fx_class_get_interface(p, interface_id); \
|
= fx_class_get_interface(p, interface_id); \
|
||||||
if (!__FX_IFACE_I1(iface, __LINE__)) { \
|
if (!__FX_IFACE_I1(iface, __LINE__)) { \
|
||||||
@@ -30,18 +82,18 @@
|
|||||||
exit(-1); \
|
exit(-1); \
|
||||||
} else { \
|
} else { \
|
||||||
interface_name##_class *iface = __FX_IFACE_I1(iface, __LINE__);
|
interface_name##_class *iface = __FX_IFACE_I1(iface, __LINE__);
|
||||||
#define FX_TYPE_CLASS_INTERFACE_END(interface_name, interface_id) }
|
#define FX_TYPE_VTABLE_INTERFACE_END(interface_name, interface_id) }
|
||||||
#define FX_INTERFACE_ENTRY(slot) iface->slot
|
#define FX_INTERFACE_ENTRY(slot) iface->slot
|
||||||
|
|
||||||
#define FX_TYPE_DEFINITION_BEGIN(name) \
|
#define FX_TYPE_DEFINITION_BEGIN(name) \
|
||||||
static fx_type_info name##_type_info = {0}; \
|
static fx_type_info name##_type_info = {0}; \
|
||||||
static void name##_class_init(fx_class *, void *); \
|
static void name##_class_init(fx_class *, fx_type_info *, void *); \
|
||||||
static void name##_type_init(void) \
|
static void name##_type_init(void) \
|
||||||
{ \
|
{ \
|
||||||
fx_type_info *type_info = &name##_type_info; \
|
fx_type_info *type_info = &name##_type_info; \
|
||||||
unsigned int nr_vtables = 0; \
|
unsigned int nr_vtables = 0; \
|
||||||
type_info->t_name = #name; \
|
type_info->ty_name = #name; \
|
||||||
type_info->t_class_init = name##_class_init;
|
type_info->ty_class_init = name##_class_init;
|
||||||
#define FX_TYPE_DEFINITION_END(name) \
|
#define FX_TYPE_DEFINITION_END(name) \
|
||||||
fx_result result = fx_type_register(type_info); \
|
fx_result result = fx_type_register(type_info); \
|
||||||
if (fx_result_is_error(result)) { \
|
if (fx_result_is_error(result)) { \
|
||||||
@@ -52,7 +104,7 @@
|
|||||||
abort(); \
|
abort(); \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
fx_type name##_get_type(void) \
|
fx_type_id name##_get_type(void) \
|
||||||
{ \
|
{ \
|
||||||
static fx_once static_type_init = FX_ONCE_INIT; \
|
static fx_once static_type_init = FX_ONCE_INIT; \
|
||||||
\
|
\
|
||||||
@@ -60,39 +112,28 @@
|
|||||||
name##_type_init(); \
|
name##_type_init(); \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
return &name##_type_info.t_id; \
|
return &name##_type_info.ty_id; \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define FX_TYPE_ID(a, b, c, d, e) \
|
#define FX_TYPE_ID(a, b, c, d, e) \
|
||||||
fx_type_id_init(&type_info->t_id, a, b, c, d, e)
|
fx_type_id_init(&type_info->ty_id, a, b, c, d, e)
|
||||||
|
#define FX_TYPE_NAME(n) type_info->ty_name = (n)
|
||||||
#define FX_TYPE_EXTENDS(parent_id) \
|
#define FX_TYPE_EXTENDS(parent_id) \
|
||||||
fx_type_id_copy(parent_id, &type_info->t_parent_id)
|
fx_type_id_copy(parent_id, &type_info->ty_parent_id)
|
||||||
#define FX_TYPE_IMPLEMENTS(interface_id) \
|
#define FX_TYPE_IMPLEMENTS(interface_id) \
|
||||||
fx_type_id_copy( \
|
fx_type_id_copy( \
|
||||||
interface_id, \
|
interface_id, \
|
||||||
&type_info->t_interfaces[type_info->t_nr_interfaces++])
|
&type_info->ty_interfaces[type_info->ty_nr_interfaces++])
|
||||||
#define FX_TYPE_CLASS(class_struct) \
|
#define FX_TYPE_CLASS(class_struct) \
|
||||||
type_info->t_class_size = sizeof(class_struct)
|
type_info->ty_class_private_size = sizeof(class_struct)
|
||||||
#define FX_TYPE_FLAGS(flags) type_info->t_flags = (flags)
|
#define FX_TYPE_FLAGS(flags) type_info->ty_flags = (flags)
|
||||||
#define FX_TYPE_INSTANCE_INIT(func) type_info->t_instance_init = (func)
|
#define FX_TYPE_INSTANCE_INIT(func) type_info->ty_instance_init = (func)
|
||||||
#define FX_TYPE_INSTANCE_FINI(func) type_info->t_instance_fini = (func)
|
#define FX_TYPE_INSTANCE_FINI(func) type_info->ty_instance_fini = (func)
|
||||||
|
|
||||||
#if 0
|
|
||||||
#define FX_TYPE_VTABLE_BEGIN(vtable_struct, interface_id) \
|
|
||||||
vtable_struct __FX_IFACE_I1(iface, __LINE__) = {0}; \
|
|
||||||
{ \
|
|
||||||
vtable_struct *iface = &__FX_IFACE_I1(iface, __LINE__); \
|
|
||||||
type_info->t_vtables[nr_vtables].v_vtable = iface; \
|
|
||||||
type_info->t_vtables[nr_vtables].v_interface_id \
|
|
||||||
= interface_id; \
|
|
||||||
nr_vtables++;
|
|
||||||
#define FX_TYPE_VTABLE_END(vtable_struct, interface_id) }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define FX_TYPE_INSTANCE_PRIVATE(instance_struct) \
|
#define FX_TYPE_INSTANCE_PRIVATE(instance_struct) \
|
||||||
type_info->t_instance_private_size = sizeof(instance_struct)
|
type_info->ty_instance_private_size = sizeof(instance_struct)
|
||||||
#define FX_TYPE_INSTANCE_PROTECTED(instance_struct) \
|
#define FX_TYPE_INSTANCE_PROTECTED(instance_struct) \
|
||||||
type_info->t_instance_protected_size = sizeof(instance_struct)
|
type_info->ty_instance_protected_size = sizeof(instance_struct)
|
||||||
|
|
||||||
/* Type declaration macros (for use in .h header file) */
|
/* Type declaration macros (for use in .h header file) */
|
||||||
|
|
||||||
@@ -135,8 +176,9 @@
|
|||||||
object, \
|
object, \
|
||||||
...) \
|
...) \
|
||||||
do { \
|
do { \
|
||||||
type_name##_class *iface \
|
type_name##_class *iface = fx_object_get_interface( \
|
||||||
= fx_object_get_interface(object, type_id); \
|
object, \
|
||||||
|
type_id); \
|
||||||
if (iface && iface->func) { \
|
if (iface && iface->func) { \
|
||||||
return iface->func(object, __VA_ARGS__); \
|
return iface->func(object, __VA_ARGS__); \
|
||||||
} else { \
|
} else { \
|
||||||
@@ -150,8 +192,9 @@
|
|||||||
func, \
|
func, \
|
||||||
object) \
|
object) \
|
||||||
do { \
|
do { \
|
||||||
type_name##_class *iface \
|
type_name##_class *iface = fx_object_get_interface( \
|
||||||
= fx_object_get_interface(object, type_id); \
|
object, \
|
||||||
|
type_id); \
|
||||||
if (iface && iface->func) { \
|
if (iface && iface->func) { \
|
||||||
return iface->func(object); \
|
return iface->func(object); \
|
||||||
} else { \
|
} else { \
|
||||||
@@ -160,8 +203,9 @@
|
|||||||
} while (0)
|
} while (0)
|
||||||
#define FX_CLASS_DISPATCH_VIRTUAL_V(type_name, type_id, func, object, ...) \
|
#define FX_CLASS_DISPATCH_VIRTUAL_V(type_name, type_id, func, object, ...) \
|
||||||
do { \
|
do { \
|
||||||
type_name##_class *iface \
|
type_name##_class *iface = fx_object_get_interface( \
|
||||||
= fx_object_get_interface(object, type_id); \
|
object, \
|
||||||
|
type_id); \
|
||||||
if (iface && iface->func) { \
|
if (iface && iface->func) { \
|
||||||
iface->func(object, __VA_ARGS__); \
|
iface->func(object, __VA_ARGS__); \
|
||||||
return; \
|
return; \
|
||||||
@@ -169,8 +213,9 @@
|
|||||||
} while (0)
|
} while (0)
|
||||||
#define FX_CLASS_DISPATCH_VIRTUAL_V0(type_name, type_id, func, object) \
|
#define FX_CLASS_DISPATCH_VIRTUAL_V0(type_name, type_id, func, object) \
|
||||||
do { \
|
do { \
|
||||||
type_name##_class *iface \
|
type_name##_class *iface = fx_object_get_interface( \
|
||||||
= fx_object_get_interface(object, type_id); \
|
object, \
|
||||||
|
type_id); \
|
||||||
if (iface && iface->func) { \
|
if (iface && iface->func) { \
|
||||||
iface->func(object); \
|
iface->func(object); \
|
||||||
return; \
|
return; \
|
||||||
@@ -200,23 +245,27 @@
|
|||||||
func_name(priv); \
|
func_name(priv); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define FX_ASSEMBLY_BEGIN() \
|
#define FX_ASSEMBLY_BEGIN(id) \
|
||||||
const fx_assembly *__fx_assembly_get(void) \
|
const fx_assembly *id##_assembly_get(void) \
|
||||||
{ \
|
{ \
|
||||||
static fx_assembly *self = NULL; \
|
static fx_assembly *self = NULL; \
|
||||||
if (self) { \
|
if (self) { \
|
||||||
return self; \
|
return self; \
|
||||||
} \
|
} \
|
||||||
self = fx_assembly_create();
|
self = fx_assembly_create();
|
||||||
#define FX_ASSEMBLY_END() \
|
#define FX_ASSEMBLY_END(id) \
|
||||||
fx_assembly_dump(self); \
|
|
||||||
return self; \
|
return self; \
|
||||||
|
} \
|
||||||
|
const fx_assembly *__fx_assembly_get(void) \
|
||||||
|
{ \
|
||||||
|
return id##_assembly_get(); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define FX_ASSEMBLY_NAME(name) fx_assembly_set_name(self, name)
|
#define FX_ASSEMBLY_NAME(name) fx_assembly_set_name(self, name)
|
||||||
#define FX_ASSEMBLY_VERSION(major, minor, build, revision) \
|
#define FX_ASSEMBLY_VERSION(major, minor, build, revision) \
|
||||||
fx_assembly_set_version(self, major, minor, build, revision)
|
fx_assembly_set_version(self, major, minor, build, revision)
|
||||||
#define FX_ASSEMBLY_EXPORT_TYPE(namespace_name, type_name, type_id) \
|
#define FX_ASSEMBLY_EXPORT_TYPE(namespace_name, type_name, type_id) \
|
||||||
extern fx_type type_id##_get_type(void); \
|
extern fx_type_id type_id##_get_type(void); \
|
||||||
fx_assembly_add_type( \
|
fx_assembly_add_type( \
|
||||||
self, \
|
self, \
|
||||||
namespace_name "." type_name, \
|
namespace_name "." type_name, \
|
||||||
|
|||||||
@@ -0,0 +1,48 @@
|
|||||||
|
#ifndef FX_NAMEMAP_H_
|
||||||
|
#define FX_NAMEMAP_H_
|
||||||
|
|
||||||
|
#include <fx/bst.h>
|
||||||
|
#include <fx/misc.h>
|
||||||
|
#include <fx/queue.h>
|
||||||
|
|
||||||
|
#define FX_NAMEMAP_INIT ((fx_namemap) {0})
|
||||||
|
|
||||||
|
typedef struct fx_namemap {
|
||||||
|
fx_bst m_entries;
|
||||||
|
} fx_namemap;
|
||||||
|
|
||||||
|
struct __fx_namemap_entry {
|
||||||
|
int e_flags;
|
||||||
|
uint64_t e_hash;
|
||||||
|
void *e_bucket;
|
||||||
|
union {
|
||||||
|
fx_queue_entry e_entry;
|
||||||
|
fx_bst_node e_node;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct fx_namemap_entry {
|
||||||
|
struct __fx_namemap_entry e_opaque;
|
||||||
|
const char *e_name;
|
||||||
|
} fx_namemap_entry;
|
||||||
|
|
||||||
|
FX_API fx_status fx_namemap_cleanup(fx_namemap *map);
|
||||||
|
|
||||||
|
FX_API fx_status
|
||||||
|
fx_namemap_put(fx_namemap *map, const char *name, fx_namemap_entry *entry);
|
||||||
|
|
||||||
|
FX_API fx_namemap_entry *fx_namemap_get(
|
||||||
|
const fx_namemap *map,
|
||||||
|
const char *name);
|
||||||
|
|
||||||
|
FX_API fx_namemap_entry *fx_namemap_first(const fx_namemap *map);
|
||||||
|
FX_API fx_namemap_entry *fx_namemap_last(const fx_namemap *map);
|
||||||
|
|
||||||
|
FX_API fx_namemap_entry *fx_namemap_next(
|
||||||
|
const fx_namemap *map,
|
||||||
|
fx_namemap_entry *entry);
|
||||||
|
FX_API fx_namemap_entry *fx_namemap_prev(
|
||||||
|
const fx_namemap *map,
|
||||||
|
fx_namemap_entry *entry);
|
||||||
|
|
||||||
|
#endif
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user