first commit from linux

This commit is contained in:
2022-01-18 19:41:07 +03:00
parent 920ae8ca88
commit 749b5f1af1
82 changed files with 36040 additions and 4609 deletions

View File

@@ -1,240 +1,240 @@
# Удалите строку ниже, если вы хотите наследовать параметры .editorconfig из каталогов, расположенных выше в иерархии
root = true
# Файлы C#
[*.cs]
#### Основные параметры EditorConfig ####
# Отступы и интервалы
indent_size = 4
indent_style = space
tab_width = 4
# Предпочтения для новых строк
end_of_line = crlf
insert_final_newline = false
#### Рекомендации по написанию кода .NET ####
# Упорядочение Using
dotnet_separate_import_directive_groups = false
dotnet_sort_system_directives_first = true
file_header_template = unset
# Предпочтения для this. и Me.
dotnet_style_qualification_for_event = false
dotnet_style_qualification_for_field = false
dotnet_style_qualification_for_method = false
dotnet_style_qualification_for_property = false
# Параметры использования ключевых слов языка и типов BCL
dotnet_style_predefined_type_for_locals_parameters_members = true
dotnet_style_predefined_type_for_member_access = true
# Предпочтения для скобок
dotnet_style_parentheses_in_arithmetic_binary_operators = never_if_unnecessary
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity
dotnet_style_parentheses_in_other_operators = never_if_unnecessary
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity
# Предпочтения модификатора
dotnet_style_require_accessibility_modifiers = for_non_interface_members
# Выражения уровень предпочтения
dotnet_style_coalesce_expression = true
dotnet_style_collection_initializer = true
dotnet_style_explicit_tuple_names = true
dotnet_style_namespace_match_folder = true
dotnet_style_null_propagation = true
dotnet_style_object_initializer = true
dotnet_style_operator_placement_when_wrapping = beginning_of_line
dotnet_style_prefer_auto_properties = true:suggestion
dotnet_style_prefer_compound_assignment = true
dotnet_style_prefer_conditional_expression_over_assignment = true:suggestion
dotnet_style_prefer_conditional_expression_over_return = true:suggestion
dotnet_style_prefer_inferred_anonymous_type_member_names = true
dotnet_style_prefer_inferred_tuple_names = true
dotnet_style_prefer_is_null_check_over_reference_equality_method = true
dotnet_style_prefer_simplified_boolean_expressions = true
dotnet_style_prefer_simplified_interpolation = true
# Предпочтения для полей
dotnet_style_readonly_field = false:silent
# Настройки параметров
dotnet_code_quality_unused_parameters = non_public
# Параметры подавления
dotnet_remove_unnecessary_suppression_exclusions = none
# Предпочтения для новых строк
dotnet_style_allow_multiple_blank_lines_experimental = false
dotnet_style_allow_statement_immediately_after_block_experimental = true
#### Рекомендации по написанию кода C# ####
# Предпочтения var
csharp_style_var_elsewhere = true
csharp_style_var_for_built_in_types = false
csharp_style_var_when_type_is_apparent = true
# Члены, заданные выражениями
csharp_style_expression_bodied_accessors = true:suggestion
csharp_style_expression_bodied_constructors = true:suggestion
csharp_style_expression_bodied_indexers = true:suggestion
csharp_style_expression_bodied_lambdas = true:suggestion
csharp_style_expression_bodied_local_functions = true:suggestion
csharp_style_expression_bodied_methods = true:suggestion
csharp_style_expression_bodied_operators = true:suggestion
csharp_style_expression_bodied_properties = true:suggestion
# Настройки соответствия шаблонов
csharp_style_pattern_matching_over_as_with_null_check = true
csharp_style_pattern_matching_over_is_with_cast_check = true
csharp_style_prefer_not_pattern = true
csharp_style_prefer_pattern_matching = false
csharp_style_prefer_switch_expression = false
# Настройки проверки на null
csharp_style_conditional_delegate_call = true
# Предпочтения модификатора
csharp_prefer_static_local_function = false:silent
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async
# Предпочтения для блоков кода
csharp_prefer_braces = false:suggestion
csharp_prefer_simple_using_statement = true
csharp_style_namespace_declarations = file_scoped:suggestion
# Выражения уровень предпочтения
csharp_prefer_simple_default_expression = true:suggestion
csharp_style_deconstructed_variable_declaration = false
csharp_style_implicit_object_creation_when_type_is_apparent = true:silent
csharp_style_inlined_variable_declaration = true
csharp_style_pattern_local_over_anonymous_function = true
csharp_style_prefer_index_operator = false:suggestion
csharp_style_prefer_null_check_over_type_check = true:suggestion
csharp_style_prefer_range_operator = false:suggestion
csharp_style_throw_expression = true:suggestion
csharp_style_unused_value_assignment_preference = discard_variable:warning
csharp_style_unused_value_expression_statement_preference = unused_local_variable
# предпочтения для директивы using
csharp_using_directive_placement = outside_namespace
# Предпочтения для новых строк
csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = true
csharp_style_allow_blank_lines_between_consecutive_braces_experimental = false
csharp_style_allow_embedded_statements_on_same_line_experimental = true
#### Правила форматирования C# ####
# Предпочтения для новых строк
csharp_new_line_before_catch = true
csharp_new_line_before_else = true
csharp_new_line_before_finally = true
csharp_new_line_before_members_in_anonymous_types = true
csharp_new_line_before_members_in_object_initializers = true
csharp_new_line_before_open_brace = all
csharp_new_line_between_query_expression_clauses = true
# Предпочтения для отступов
csharp_indent_block_contents = true
csharp_indent_braces = false
csharp_indent_case_contents = true
csharp_indent_case_contents_when_block = true
csharp_indent_labels = one_less_than_current
csharp_indent_switch_labels = true
# Предпочтения для интервалов
csharp_space_after_cast = false
csharp_space_after_colon_in_inheritance_clause = true
csharp_space_after_comma = true
csharp_space_after_dot = false
csharp_space_after_keywords_in_control_flow_statements = true
csharp_space_after_semicolon_in_for_statement = true
csharp_space_around_binary_operators = before_and_after
csharp_space_around_declaration_statements = false
csharp_space_before_colon_in_inheritance_clause = true
csharp_space_before_comma = false
csharp_space_before_dot = false
csharp_space_before_open_square_brackets = false
csharp_space_before_semicolon_in_for_statement = false
csharp_space_between_empty_square_brackets = false
csharp_space_between_method_call_empty_parameter_list_parentheses = false
csharp_space_between_method_call_name_and_opening_parenthesis = false
csharp_space_between_method_call_parameter_list_parentheses = false
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
csharp_space_between_method_declaration_name_and_open_parenthesis = false
csharp_space_between_method_declaration_parameter_list_parentheses = false
csharp_space_between_parentheses = false
csharp_space_between_square_brackets = false
# Предпочтения переноса
csharp_preserve_single_line_blocks = true
csharp_preserve_single_line_statements = true
#### Стили именования ####
# Правила именования
dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion
dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface
dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i
dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.types_should_be_pascal_case.symbols = types
dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case
dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members
dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case
# Спецификации символов
dotnet_naming_symbols.interface.applicable_kinds = interface
dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.interface.required_modifiers =
dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum
dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.types.required_modifiers =
dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method
dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.non_field_members.required_modifiers =
# Стили именования
dotnet_naming_style.pascal_case.required_prefix =
dotnet_naming_style.pascal_case.required_suffix =
dotnet_naming_style.pascal_case.word_separator =
dotnet_naming_style.pascal_case.capitalization = pascal_case
dotnet_naming_style.begins_with_i.required_prefix = I
dotnet_naming_style.begins_with_i.required_suffix =
dotnet_naming_style.begins_with_i.word_separator =
dotnet_naming_style.begins_with_i.capitalization = pascal_case
csharp_style_prefer_local_over_anonymous_function = true:suggestion
[*.{cs,vb}]
dotnet_style_operator_placement_when_wrapping = beginning_of_line
tab_width = 4
indent_size = 4
dotnet_style_coalesce_expression = true:suggestion
dotnet_style_null_propagation = true:suggestion
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
dotnet_style_prefer_auto_properties = true:suggestion
dotnet_style_object_initializer = true:suggestion
dotnet_style_collection_initializer = true:suggestion
dotnet_style_prefer_simplified_boolean_expressions = true:suggestion
dotnet_style_prefer_conditional_expression_over_assignment = true:suggestion
dotnet_style_prefer_conditional_expression_over_return = true:suggestion
dotnet_style_explicit_tuple_names = true:suggestion
dotnet_style_prefer_inferred_tuple_names = true:suggestion
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
dotnet_style_prefer_compound_assignment = true:suggestion
dotnet_style_prefer_simplified_interpolation = true:suggestion
# Удалите строку ниже, если вы хотите наследовать параметры .editorconfig из каталогов, расположенных выше в иерархии
root = true
# Файлы C#
[*.cs]
#### Основные параметры EditorConfig ####
# Отступы и интервалы
indent_size = 4
indent_style = space
tab_width = 4
# Предпочтения для новых строк
end_of_line = crlf
insert_final_newline = false
#### Рекомендации по написанию кода .NET ####
# Упорядочение Using
dotnet_separate_import_directive_groups = false
dotnet_sort_system_directives_first = true
file_header_template = unset
# Предпочтения для this. и Me.
dotnet_style_qualification_for_event = false
dotnet_style_qualification_for_field = false
dotnet_style_qualification_for_method = false
dotnet_style_qualification_for_property = false
# Параметры использования ключевых слов языка и типов BCL
dotnet_style_predefined_type_for_locals_parameters_members = true
dotnet_style_predefined_type_for_member_access = true
# Предпочтения для скобок
dotnet_style_parentheses_in_arithmetic_binary_operators = never_if_unnecessary
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity
dotnet_style_parentheses_in_other_operators = never_if_unnecessary
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity
# Предпочтения модификатора
dotnet_style_require_accessibility_modifiers = for_non_interface_members
# Выражения уровень предпочтения
dotnet_style_coalesce_expression = true
dotnet_style_collection_initializer = true
dotnet_style_explicit_tuple_names = true
dotnet_style_namespace_match_folder = true
dotnet_style_null_propagation = true
dotnet_style_object_initializer = true
dotnet_style_operator_placement_when_wrapping = beginning_of_line
dotnet_style_prefer_auto_properties = true:suggestion
dotnet_style_prefer_compound_assignment = true
dotnet_style_prefer_conditional_expression_over_assignment = true:suggestion
dotnet_style_prefer_conditional_expression_over_return = true:suggestion
dotnet_style_prefer_inferred_anonymous_type_member_names = true
dotnet_style_prefer_inferred_tuple_names = true
dotnet_style_prefer_is_null_check_over_reference_equality_method = true
dotnet_style_prefer_simplified_boolean_expressions = true
dotnet_style_prefer_simplified_interpolation = true
# Предпочтения для полей
dotnet_style_readonly_field = false:silent
# Настройки параметров
dotnet_code_quality_unused_parameters = non_public
# Параметры подавления
dotnet_remove_unnecessary_suppression_exclusions = none
# Предпочтения для новых строк
dotnet_style_allow_multiple_blank_lines_experimental = false
dotnet_style_allow_statement_immediately_after_block_experimental = true
#### Рекомендации по написанию кода C# ####
# Предпочтения var
csharp_style_var_elsewhere = true
csharp_style_var_for_built_in_types = false
csharp_style_var_when_type_is_apparent = true
# Члены, заданные выражениями
csharp_style_expression_bodied_accessors = true:suggestion
csharp_style_expression_bodied_constructors = true:suggestion
csharp_style_expression_bodied_indexers = true:suggestion
csharp_style_expression_bodied_lambdas = true:suggestion
csharp_style_expression_bodied_local_functions = true:suggestion
csharp_style_expression_bodied_methods = true:suggestion
csharp_style_expression_bodied_operators = true:suggestion
csharp_style_expression_bodied_properties = true:suggestion
# Настройки соответствия шаблонов
csharp_style_pattern_matching_over_as_with_null_check = true
csharp_style_pattern_matching_over_is_with_cast_check = true
csharp_style_prefer_not_pattern = true
csharp_style_prefer_pattern_matching = false
csharp_style_prefer_switch_expression = false
# Настройки проверки на null
csharp_style_conditional_delegate_call = true
# Предпочтения модификатора
csharp_prefer_static_local_function = false:silent
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async
# Предпочтения для блоков кода
csharp_prefer_braces = false:suggestion
csharp_prefer_simple_using_statement = true
csharp_style_namespace_declarations = file_scoped:suggestion
# Выражения уровень предпочтения
csharp_prefer_simple_default_expression = true:suggestion
csharp_style_deconstructed_variable_declaration = false
csharp_style_implicit_object_creation_when_type_is_apparent = true:silent
csharp_style_inlined_variable_declaration = true
csharp_style_pattern_local_over_anonymous_function = true
csharp_style_prefer_index_operator = false:suggestion
csharp_style_prefer_null_check_over_type_check = true:suggestion
csharp_style_prefer_range_operator = false:suggestion
csharp_style_throw_expression = true:suggestion
csharp_style_unused_value_assignment_preference = discard_variable:warning
csharp_style_unused_value_expression_statement_preference = unused_local_variable
# предпочтения для директивы using
csharp_using_directive_placement = outside_namespace
# Предпочтения для новых строк
csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = true
csharp_style_allow_blank_lines_between_consecutive_braces_experimental = false
csharp_style_allow_embedded_statements_on_same_line_experimental = true
#### Правила форматирования C# ####
# Предпочтения для новых строк
csharp_new_line_before_catch = true
csharp_new_line_before_else = true
csharp_new_line_before_finally = true
csharp_new_line_before_members_in_anonymous_types = true
csharp_new_line_before_members_in_object_initializers = true
csharp_new_line_before_open_brace = all
csharp_new_line_between_query_expression_clauses = true
# Предпочтения для отступов
csharp_indent_block_contents = true
csharp_indent_braces = false
csharp_indent_case_contents = true
csharp_indent_case_contents_when_block = true
csharp_indent_labels = one_less_than_current
csharp_indent_switch_labels = true
# Предпочтения для интервалов
csharp_space_after_cast = false
csharp_space_after_colon_in_inheritance_clause = true
csharp_space_after_comma = true
csharp_space_after_dot = false
csharp_space_after_keywords_in_control_flow_statements = true
csharp_space_after_semicolon_in_for_statement = true
csharp_space_around_binary_operators = before_and_after
csharp_space_around_declaration_statements = false
csharp_space_before_colon_in_inheritance_clause = true
csharp_space_before_comma = false
csharp_space_before_dot = false
csharp_space_before_open_square_brackets = false
csharp_space_before_semicolon_in_for_statement = false
csharp_space_between_empty_square_brackets = false
csharp_space_between_method_call_empty_parameter_list_parentheses = false
csharp_space_between_method_call_name_and_opening_parenthesis = false
csharp_space_between_method_call_parameter_list_parentheses = false
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
csharp_space_between_method_declaration_name_and_open_parenthesis = false
csharp_space_between_method_declaration_parameter_list_parentheses = false
csharp_space_between_parentheses = false
csharp_space_between_square_brackets = false
# Предпочтения переноса
csharp_preserve_single_line_blocks = true
csharp_preserve_single_line_statements = true
#### Стили именования ####
# Правила именования
dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion
dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface
dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i
dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.types_should_be_pascal_case.symbols = types
dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case
dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members
dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case
# Спецификации символов
dotnet_naming_symbols.interface.applicable_kinds = interface
dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.interface.required_modifiers =
dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum
dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.types.required_modifiers =
dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method
dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.non_field_members.required_modifiers =
# Стили именования
dotnet_naming_style.pascal_case.required_prefix =
dotnet_naming_style.pascal_case.required_suffix =
dotnet_naming_style.pascal_case.word_separator =
dotnet_naming_style.pascal_case.capitalization = pascal_case
dotnet_naming_style.begins_with_i.required_prefix = I
dotnet_naming_style.begins_with_i.required_suffix =
dotnet_naming_style.begins_with_i.word_separator =
dotnet_naming_style.begins_with_i.capitalization = pascal_case
csharp_style_prefer_local_over_anonymous_function = true:suggestion
[*.{cs,vb}]
dotnet_style_operator_placement_when_wrapping = beginning_of_line
tab_width = 4
indent_size = 4
dotnet_style_coalesce_expression = true:suggestion
dotnet_style_null_propagation = true:suggestion
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
dotnet_style_prefer_auto_properties = true:suggestion
dotnet_style_object_initializer = true:suggestion
dotnet_style_collection_initializer = true:suggestion
dotnet_style_prefer_simplified_boolean_expressions = true:suggestion
dotnet_style_prefer_conditional_expression_over_assignment = true:suggestion
dotnet_style_prefer_conditional_expression_over_return = true:suggestion
dotnet_style_explicit_tuple_names = true:suggestion
dotnet_style_prefer_inferred_tuple_names = true:suggestion
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
dotnet_style_prefer_compound_assignment = true:suggestion
dotnet_style_prefer_simplified_interpolation = true:suggestion
dotnet_style_namespace_match_folder = true:suggestion

367
.gitignore vendored
View File

@@ -1,359 +1,8 @@
# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Mono auto generated files
mono_crash.*
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Ww][Ii][Nn]32/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
[Oo]ut/
[Ll]og/
[Ll]ogs/
# Visual Studio 2015/2017 cache/options directory
.vs/
.vshistory/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# Visual Studio 2017 auto generated files
Generated\ Files/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUnit
*.VisualState.xml
TestResult.xml
nunit-*.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
# ASP.NET Scaffolding
ScaffoldingReadMe.txt
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_h.h
*.ilk
*.meta
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Visual Studio Trace Files
*.e2e
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Coverlet is a free, cross platform Code Coverage Tool
coverage*.json
coverage*.xml
coverage*.info
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# NuGet Symbol Packages
*.snupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
*.appxbundle
*.appxupload
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!?*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
*- [Bb]ackup.rdl
*- [Bb]ackup ([0-9]).rdl
*- [Bb]ackup ([0-9][0-9]).rdl
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# CodeRush personal settings
.cr/personal
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
*.binlog
# NVidia Nsight GPU debugger configuration file
*.nvuser
# MFractors (Xamarin productivity tool) working folder
.mfractor/
# Local History for Visual Studio
.localhistory/
# BeatPulse healthcheck temp database
healthchecksdb
# Backup folder for Package Reference Convert tool in Visual Studio 2017
MigrationBackup/
# Ionide (cross platform F# VS Code tools) working folder
.ionide/
# Fody - auto-generated XML schema
FodyWeavers.xsd
*.user
[Bb]in/
[Oo]bj/
[Oo]ut/
[Ll]og/
[Ll]ogs/
.vs/
.vshistory/

26
.vscode/launch.json vendored Normal file
View File

@@ -0,0 +1,26 @@
{
"version": "0.2.0",
"configurations": [
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/TestProgram/bin/Debug/net6.0/TestProgram.dll",
"args": [],
"cwd": "${workspaceFolder}/TestProgram",
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
"console": "internalConsole",
"stopAtEntry": false
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach"
}
]
}

42
.vscode/tasks.json vendored Normal file
View File

@@ -0,0 +1,42 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/TestProgram/TestProgram.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "publish",
"command": "dotnet",
"type": "process",
"args": [
"publish",
"${workspaceFolder}/TestProgram/TestProgram.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "watch",
"command": "dotnet",
"type": "process",
"args": [
"watch",
"run",
"${workspaceFolder}/TestProgram/TestProgram.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
}
]
}

View File

@@ -1,38 +1,38 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.32014.148
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DTLib", "DTLib\DTLib.csproj", "{B620E5E9-800F-4B2D-B4A5-062E05DB704F}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestProgram", "TestProgram\TestProgram.csproj", "{72BA37EF-07EC-4D34-966A-20D5E83ADB32}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{6308F24E-A4FF-46B3-B72F-30E05DDCB1D5}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
.gitignore = .gitignore
README.md = README.md
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B620E5E9-800F-4B2D-B4A5-062E05DB704F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B620E5E9-800F-4B2D-B4A5-062E05DB704F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B620E5E9-800F-4B2D-B4A5-062E05DB704F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B620E5E9-800F-4B2D-B4A5-062E05DB704F}.Release|Any CPU.Build.0 = Release|Any CPU
{72BA37EF-07EC-4D34-966A-20D5E83ADB32}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{72BA37EF-07EC-4D34-966A-20D5E83ADB32}.Debug|Any CPU.Build.0 = Debug|Any CPU
{72BA37EF-07EC-4D34-966A-20D5E83ADB32}.Release|Any CPU.ActiveCfg = Release|Any CPU
{72BA37EF-07EC-4D34-966A-20D5E83ADB32}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {6D0413D6-AF96-46C3-9E67-858AE2482818}
EndGlobalSection
EndGlobal
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.32014.148
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DTLib", "DTLib\DTLib.csproj", "{B620E5E9-800F-4B2D-B4A5-062E05DB704F}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestProgram", "TestProgram\TestProgram.csproj", "{72BA37EF-07EC-4D34-966A-20D5E83ADB32}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{6308F24E-A4FF-46B3-B72F-30E05DDCB1D5}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
.gitignore = .gitignore
README.md = README.md
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B620E5E9-800F-4B2D-B4A5-062E05DB704F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B620E5E9-800F-4B2D-B4A5-062E05DB704F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B620E5E9-800F-4B2D-B4A5-062E05DB704F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B620E5E9-800F-4B2D-B4A5-062E05DB704F}.Release|Any CPU.Build.0 = Release|Any CPU
{72BA37EF-07EC-4D34-966A-20D5E83ADB32}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{72BA37EF-07EC-4D34-966A-20D5E83ADB32}.Debug|Any CPU.Build.0 = Debug|Any CPU
{72BA37EF-07EC-4D34-966A-20D5E83ADB32}.Release|Any CPU.ActiveCfg = Release|Any CPU
{72BA37EF-07EC-4D34-966A-20D5E83ADB32}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {6D0413D6-AF96-46C3-9E67-858AE2482818}
EndGlobalSection
EndGlobal

View File

@@ -1,70 +1,70 @@
namespace DTLib;
//
// вывод и ввод цветного текста в консоли
// работает медленнее чем хотелось бы
//
public static class ColoredConsole
{
// парсит название цвета в ConsoleColor
public static ConsoleColor ParseColor(string color) => color switch
{
//case "magneta":
"m" => ConsoleColor.Magenta,
//case "green":
"g" => ConsoleColor.Green,
//case "red":
"r" => ConsoleColor.Red,
//case "yellow":
"y" => ConsoleColor.Yellow,
//case "white":
"w" => ConsoleColor.White,
//case "blue":
"b" => ConsoleColor.Blue,
//case "cyan":
"c" => ConsoleColor.Cyan,
//case "h":
"h" or "gray" => ConsoleColor.Gray,
//case "black":
"black" => ConsoleColor.Black,
_ => throw new Exception($"ColoredConsole.ParseColor({color}) error: incorrect color"),
};
// вывод цветного текста
public static void Write(params string[] input)
{
if (input.Length == 1)
{
if (Console.ForegroundColor != ConsoleColor.Gray)
Console.ForegroundColor = ConsoleColor.Gray;
Console.Write(input[0]);
}
else if (input.Length % 2 == 0)
{
StringBuilder strB = new();
for (ushort i = 0; i < input.Length; i++)
{
ConsoleColor c = ParseColor(input[i]);
if (Console.ForegroundColor != c)
{
Console.Write(strB.ToString());
Console.ForegroundColor = c;
strB.Clear();
}
strB.Append(input[++i]);
}
if (strB.Length > 0)
Console.Write(strB.ToString());
}
else throw new Exception("ColoredConsole.Write() error: every text string must have color string before");
}
// ввод цветного текста
public static string Read(string color)
{
ConsoleColor c = ParseColor(color);
if (Console.ForegroundColor != c)
Console.ForegroundColor = c;
return Console.ReadLine();
}
}
namespace DTLib;
//
// вывод и ввод цветного текста в консоли
// работает медленнее чем хотелось бы
//
public static class ColoredConsole
{
// парсит название цвета в ConsoleColor
public static ConsoleColor ParseColor(string color) => color switch
{
//case "magneta":
"m" => ConsoleColor.Magenta,
//case "green":
"g" => ConsoleColor.Green,
//case "red":
"r" => ConsoleColor.Red,
//case "yellow":
"y" => ConsoleColor.Yellow,
//case "white":
"w" => ConsoleColor.White,
//case "blue":
"b" => ConsoleColor.Blue,
//case "cyan":
"c" => ConsoleColor.Cyan,
//case "h":
"h" or "gray" => ConsoleColor.Gray,
//case "black":
"black" => ConsoleColor.Black,
_ => throw new Exception($"ColoredConsole.ParseColor({color}) error: incorrect color"),
};
// вывод цветного текста
public static void Write(params string[] input)
{
if (input.Length == 1)
{
if (Console.ForegroundColor != ConsoleColor.Gray)
Console.ForegroundColor = ConsoleColor.Gray;
Console.Write(input[0]);
}
else if (input.Length % 2 == 0)
{
StringBuilder strB = new();
for (ushort i = 0; i < input.Length; i++)
{
ConsoleColor c = ParseColor(input[i]);
if (Console.ForegroundColor != c)
{
Console.Write(strB.ToString());
Console.ForegroundColor = c;
strB.Clear();
}
strB.Append(input[++i]);
}
if (strB.Length > 0)
Console.Write(strB.ToString());
}
else throw new Exception("ColoredConsole.Write() error: every text string must have color string before");
}
// ввод цветного текста
public static string Read(string color)
{
ConsoleColor c = ParseColor(color);
if (Console.ForegroundColor != c)
Console.ForegroundColor = c;
return Console.ReadLine();
}
}

View File

@@ -1,20 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>false</ImplicitUsings>
<Nullable>disable</Nullable>
<DebugType>portable</DebugType>
<AssemblyName>DTLib</AssemblyName>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<ProduceReferenceAssembly>False</ProduceReferenceAssembly>
</PropertyGroup>
<ItemGroup>
<Compile Remove="Experimental\**" />
<EmbeddedResource Remove="Experimental\**" />
<None Remove="Experimental\**" />
</ItemGroup>
<ItemGroup>
<Compile Include="Experimental\Tester.cs" />
</ItemGroup>
</Project>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>false</ImplicitUsings>
<Nullable>disable</Nullable>
<DebugType>portable</DebugType>
<AssemblyName>DTLib</AssemblyName>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<ProduceReferenceAssembly>False</ProduceReferenceAssembly>
</PropertyGroup>
<ItemGroup>
<Compile Remove="Experimental\**" />
<EmbeddedResource Remove="Experimental\**" />
<None Remove="Experimental\**" />
</ItemGroup>
<ItemGroup>
<Compile Include="Experimental\Tester.cs" />
</ItemGroup>
</Project>

View File

@@ -1,327 +1,327 @@
namespace DTLib.Dtsod;
// v21
// парсер теперь не может игнорировать комменты, потом починю
// теперь числовые значения конвертируются в правильный тип, а не в int64/uint64 (новый вариант switch из c#9.0 делал какую-то дичь)
// исправлены некоторые другие баги
public class DtsodV21 : Dictionary<string, dynamic>, IDtsod
{
public DtsodVersion Version { get; } = DtsodVersion.V21;
public IDictionary<string, dynamic> ToDictionary() => this;
readonly string Text;
//public Dictionary<string, dynamic> Values { get; set; }
public DtsodV21(string text)
{
Text = text;
foreach (KeyValuePair<string, dynamic> pair in Parse(text))
Add(pair.Key, pair.Value);
}
public DtsodV21(IDictionary<string, dynamic> rawDict)
{
Text = "";
foreach (KeyValuePair<string, dynamic> pair in rawDict)
Add(pair.Key, pair.Value);
}
// выдаёт Exception
public new dynamic this[string key]
{
get => TryGetValue(key, out dynamic value) ? value : throw new Exception($"Dtsod[{key}] key not found");
set
{
if (!TrySetValue(key, value)) throw new Exception($"Dtsod[{key}] key not found");
}
}
// не выдаёт KeyNotFoundException
public new bool TryGetValue(string key, out dynamic value)
{
try
{
value = base[key];
return true;
}
catch (KeyNotFoundException)
{
value = null;
return false;
}
}
public bool TrySetValue(string key, dynamic value)
{
try
{
base[key] = value;
return true;
}
catch (KeyNotFoundException)
{
return false;
}
}
public override string ToString() => Text;
enum ValueType
{
List,
Complex,
String,
Default
}
Dictionary<string, dynamic> Parse(string text)
{
Dictionary<string, dynamic> parsed = new();
int i = 0;
for (; i < text.Length; i++)
ReadName();
return parsed;
// СЛОМАНО
/*void ReadCommentLine()
{
for (; i < text.Length && text[i] != '\n'; i++) DebugNoTime("h", text[i].ToString());
}*/
void ReadName()
{
bool isListElem = false;
dynamic value;
StringBuilder defaultNameBuilder = new();
for (; i < text.Length; i++)
{
switch (text[i])
{
case ' ':
case '\t':
case '\r':
case '\n':
break;
case ':':
i++;
string name = defaultNameBuilder.ToString();
value = ReadValue();
// если value это null, эта строка выдавала ошибку
//DebugNoTime("c", $"parsed.Add({name}, {value} { value.GetType() })");
if (isListElem)
{
if (!parsed.ContainsKey(name))
parsed.Add(name, new List<dynamic>());
parsed[name].Add(value);
}
else
parsed.Add(name, value);
return;
// строка, начинающаяся с # будет считаться комментом
case '#':
//ReadCommentLine();
break;
case '}':
throw new Exception("Parse.ReadName() error: unexpected '}' at " + i + " char");
// если $ перед названием параметра поставить, значение value добавится в лист с названием name
case '$':
if (defaultNameBuilder.ToString().Length != 0)
throw new Exception("Parse.ReadName() error: unexpected '$' at " + i + " char");
isListElem = true;
break;
case ';':
throw new Exception("Parse.ReadName() error: unexpected ';' at " + i + " char");
default:
defaultNameBuilder.Append(text[i]);
break;
}
}
}
dynamic ReadValue()
{
ValueType type = ValueType.Default;
dynamic value = null;
string ReadString()
{
i++;
StringBuilder valueBuilder = new();
valueBuilder.Append('"');
for (; text[i] != '"' || text[i - 1] == '\\'; i++)
{
valueBuilder.Append(text[i]);
}
valueBuilder.Append('"');
type = ValueType.String;
return valueBuilder.ToString();
}
List<dynamic> ReadList()
{
i++;
List<dynamic> output = new();
StringBuilder valueBuilder = new();
for (; text[i] != ']'; i++)
{
switch (text[i])
{
case ' ':
case '\t':
case '\r':
case '\n':
break;
case ',':
ParseValueToRightType(valueBuilder.ToString());
output.Add(value);
valueBuilder.Clear();
break;
default:
valueBuilder.Append(text[i]);
break;
}
}
if (valueBuilder.Length > 0)
{
ParseValueToRightType(valueBuilder.ToString());
output.Add(value);
}
type = ValueType.List;
return output;
}
Dictionary<string, dynamic> ReadComplex()
{
StringBuilder valueBuilder = new();
int balance = 1;
i++;
for (; balance != 0; i++)
{
switch (text[i])
{
case '"':
valueBuilder.Append(ReadString());
break;
case '}':
balance--;
if (balance != 0)
valueBuilder.Append(text[i]);
break;
case '{':
balance++;
valueBuilder.Append(text[i]);
break;
default:
valueBuilder.Append(text[i]);
break;
}
}
i--; // i++ в for выполняется даже когда balance == 0, то есть text[i] получается == ;, что ломает всё
type = ValueType.Complex;
return Parse(valueBuilder.ToString());
}
void ParseValueToRightType(string stringValue)
{
switch (stringValue)
{
// bool
case "true":
case "false":
value = stringValue.ToBool();
break;
// null
case "null":
value = null;
break;
default:
if (stringValue.Contains('"'))
value = stringValue.Remove(stringValue.Length - 1).Remove(0, 1);
// double
else if (stringValue.Contains('.'))
value = stringValue.ToDouble();
// ushort; ulong; uint
else if (stringValue.Length > 2 && stringValue[stringValue.Length - 2] == 'u')
{
switch (stringValue[stringValue.Length - 1])
{
case 's':
value = stringValue.Remove(stringValue.Length - 2).ToUShort();
break;
case 'i':
value = stringValue.Remove(stringValue.Length - 2).ToUInt();
break;
case 'l':
value = stringValue.Remove(stringValue.Length - 2).ToULong();
break;
default:
throw new Exception($"Dtsod.Parse.ReadValue() error: value= wrong type <u{stringValue[stringValue.Length - 1]}>");
};
}
// short; long; int
else
switch (stringValue[stringValue.Length - 1])
{
case 's':
value = stringValue.Remove(stringValue.Length - 1).ToShort();
break;
case 'l':
value = stringValue.Remove(stringValue.Length - 1).ToLong();
break;
default:
value = stringValue.ToInt();
break;
}
break;
};
}
StringBuilder defaultValueBuilder = new();
for (; i < text.Length; i++)
{
switch (text[i])
{
case ' ':
case '\t':
case '\r':
case '\n':
break;
case '"':
value = ReadString();
break;
case ';':
switch (type)
{
case ValueType.String:
ParseValueToRightType(value);
break;
case ValueType.Default:
ParseValueToRightType(defaultValueBuilder.ToString());
break;
};
return value;
case '[':
value = ReadList();
break;
case '{':
value = ReadComplex();
break;
// строка, начинающаяся с # будет считаться комментом
case '#':
//ReadCommentLine();
break;
default:
defaultValueBuilder.Append(text[i]);
break;
}
}
throw new Exception("Dtsod.Parse.ReadValue error: wtf it's the end of function");
}
}
}
namespace DTLib.Dtsod;
// v21
// парсер теперь не может игнорировать комменты, потом починю
// теперь числовые значения конвертируются в правильный тип, а не в int64/uint64 (новый вариант switch из c#9.0 делал какую-то дичь)
// исправлены некоторые другие баги
public class DtsodV21 : Dictionary<string, dynamic>, IDtsod
{
public DtsodVersion Version { get; } = DtsodVersion.V21;
public IDictionary<string, dynamic> ToDictionary() => this;
readonly string Text;
//public Dictionary<string, dynamic> Values { get; set; }
public DtsodV21(string text)
{
Text = text;
foreach (KeyValuePair<string, dynamic> pair in Parse(text))
Add(pair.Key, pair.Value);
}
public DtsodV21(IDictionary<string, dynamic> rawDict)
{
Text = "";
foreach (KeyValuePair<string, dynamic> pair in rawDict)
Add(pair.Key, pair.Value);
}
// выдаёт Exception
public new dynamic this[string key]
{
get => TryGetValue(key, out dynamic value) ? value : throw new Exception($"Dtsod[{key}] key not found");
set
{
if (!TrySetValue(key, value)) throw new Exception($"Dtsod[{key}] key not found");
}
}
// не выдаёт KeyNotFoundException
public new bool TryGetValue(string key, out dynamic value)
{
try
{
value = base[key];
return true;
}
catch (KeyNotFoundException)
{
value = null;
return false;
}
}
public bool TrySetValue(string key, dynamic value)
{
try
{
base[key] = value;
return true;
}
catch (KeyNotFoundException)
{
return false;
}
}
public override string ToString() => Text;
enum ValueType
{
List,
Complex,
String,
Default
}
Dictionary<string, dynamic> Parse(string text)
{
Dictionary<string, dynamic> parsed = new();
int i = 0;
for (; i < text.Length; i++)
ReadName();
return parsed;
// СЛОМАНО
/*void ReadCommentLine()
{
for (; i < text.Length && text[i] != '\n'; i++) DebugNoTime("h", text[i].ToString());
}*/
void ReadName()
{
bool isListElem = false;
dynamic value;
StringBuilder defaultNameBuilder = new();
for (; i < text.Length; i++)
{
switch (text[i])
{
case ' ':
case '\t':
case '\r':
case '\n':
break;
case ':':
i++;
string name = defaultNameBuilder.ToString();
value = ReadValue();
// если value это null, эта строка выдавала ошибку
//DebugNoTime("c", $"parsed.Add({name}, {value} { value.GetType() })");
if (isListElem)
{
if (!parsed.ContainsKey(name))
parsed.Add(name, new List<dynamic>());
parsed[name].Add(value);
}
else
parsed.Add(name, value);
return;
// строка, начинающаяся с # будет считаться комментом
case '#':
//ReadCommentLine();
break;
case '}':
throw new Exception("Parse.ReadName() error: unexpected '}' at " + i + " char");
// если $ перед названием параметра поставить, значение value добавится в лист с названием name
case '$':
if (defaultNameBuilder.ToString().Length != 0)
throw new Exception("Parse.ReadName() error: unexpected '$' at " + i + " char");
isListElem = true;
break;
case ';':
throw new Exception("Parse.ReadName() error: unexpected ';' at " + i + " char");
default:
defaultNameBuilder.Append(text[i]);
break;
}
}
}
dynamic ReadValue()
{
ValueType type = ValueType.Default;
dynamic value = null;
string ReadString()
{
i++;
StringBuilder valueBuilder = new();
valueBuilder.Append('"');
for (; text[i] != '"' || text[i - 1] == '\\'; i++)
{
valueBuilder.Append(text[i]);
}
valueBuilder.Append('"');
type = ValueType.String;
return valueBuilder.ToString();
}
List<dynamic> ReadList()
{
i++;
List<dynamic> output = new();
StringBuilder valueBuilder = new();
for (; text[i] != ']'; i++)
{
switch (text[i])
{
case ' ':
case '\t':
case '\r':
case '\n':
break;
case ',':
ParseValueToRightType(valueBuilder.ToString());
output.Add(value);
valueBuilder.Clear();
break;
default:
valueBuilder.Append(text[i]);
break;
}
}
if (valueBuilder.Length > 0)
{
ParseValueToRightType(valueBuilder.ToString());
output.Add(value);
}
type = ValueType.List;
return output;
}
Dictionary<string, dynamic> ReadComplex()
{
StringBuilder valueBuilder = new();
int balance = 1;
i++;
for (; balance != 0; i++)
{
switch (text[i])
{
case '"':
valueBuilder.Append(ReadString());
break;
case '}':
balance--;
if (balance != 0)
valueBuilder.Append(text[i]);
break;
case '{':
balance++;
valueBuilder.Append(text[i]);
break;
default:
valueBuilder.Append(text[i]);
break;
}
}
i--; // i++ в for выполняется даже когда balance == 0, то есть text[i] получается == ;, что ломает всё
type = ValueType.Complex;
return Parse(valueBuilder.ToString());
}
void ParseValueToRightType(string stringValue)
{
switch (stringValue)
{
// bool
case "true":
case "false":
value = stringValue.ToBool();
break;
// null
case "null":
value = null;
break;
default:
if (stringValue.Contains('"'))
value = stringValue.Remove(stringValue.Length - 1).Remove(0, 1);
// double
else if (stringValue.Contains('.'))
value = stringValue.ToDouble();
// ushort; ulong; uint
else if (stringValue.Length > 2 && stringValue[stringValue.Length - 2] == 'u')
{
switch (stringValue[stringValue.Length - 1])
{
case 's':
value = stringValue.Remove(stringValue.Length - 2).ToUShort();
break;
case 'i':
value = stringValue.Remove(stringValue.Length - 2).ToUInt();
break;
case 'l':
value = stringValue.Remove(stringValue.Length - 2).ToULong();
break;
default:
throw new Exception($"Dtsod.Parse.ReadValue() error: value= wrong type <u{stringValue[stringValue.Length - 1]}>");
};
}
// short; long; int
else
switch (stringValue[stringValue.Length - 1])
{
case 's':
value = stringValue.Remove(stringValue.Length - 1).ToShort();
break;
case 'l':
value = stringValue.Remove(stringValue.Length - 1).ToLong();
break;
default:
value = stringValue.ToInt();
break;
}
break;
};
}
StringBuilder defaultValueBuilder = new();
for (; i < text.Length; i++)
{
switch (text[i])
{
case ' ':
case '\t':
case '\r':
case '\n':
break;
case '"':
value = ReadString();
break;
case ';':
switch (type)
{
case ValueType.String:
ParseValueToRightType(value);
break;
case ValueType.Default:
ParseValueToRightType(defaultValueBuilder.ToString());
break;
};
return value;
case '[':
value = ReadList();
break;
case '{':
value = ReadComplex();
break;
// строка, начинающаяся с # будет считаться комментом
case '#':
//ReadCommentLine();
break;
default:
defaultValueBuilder.Append(text[i]);
break;
}
}
throw new Exception("Dtsod.Parse.ReadValue error: wtf it's the end of function");
}
}
}

View File

@@ -1,445 +1,445 @@
namespace DTLib.Dtsod;
// v22
// метод ToString() теперь деконструирует объект в текст, а не возвращает параметр text из конструктора
// деконструкция листов не работает из-за костыльного определения типов данных
public class DtsodV22 : Dictionary<string, DtsodV22.ValueStruct>, IDtsod
{
public DtsodVersion Version { get; } = DtsodVersion.V22;
public IDictionary<string, dynamic> ToDictionary()
{
Dictionary<string, dynamic> newdict = new();
foreach (KeyValuePair<string, ValueStruct> pair in this)
newdict.Add(pair.Key, pair.Value.Value);
return newdict;
}
public struct ValueStruct
{
public dynamic Value;
public ValueTypes Type;
public bool IsList;
public ValueStruct(ValueTypes type, dynamic value, bool isList)
{
Value = value;
Type = type;
IsList = isList;
}
}
public enum ValueTypes
{
List,
Complex,
String,
Short,
Int,
Long,
UShort,
UInt,
ULong,
Double,
Null,
Bool,
Unknown
}
public DtsodV22() { }
public DtsodV22(string text)
{
foreach (KeyValuePair<string, ValueStruct> pair in Parse(text))
Add(pair.Key, pair.Value);
}
public DtsodV22(Dictionary<string, ValueStruct> dict)
{
foreach (KeyValuePair<string, ValueStruct> pair in dict)
Add(pair.Key, pair.Value);
}
// выдаёт Exception
public new dynamic this[string key]
{
get => TryGetValue(key, out dynamic value) ? value : throw new Exception($"Dtsod[{key}] key not found");
set
{
if (!TrySetValue(key, value)) throw new Exception($"Dtsod[{key}] key not found");
}
}
// не выдаёт KeyNotFoundException
public bool TryGetValue(string key, out dynamic value)
{
try
{
value = base[key].Value;
return true;
}
catch (KeyNotFoundException)
{
value = null;
return false;
}
}
public bool TrySetValue(string key, dynamic value)
{
try
{
bool isList = value is IList;
base[key] = new(base[key].Type, value, isList);
return true;
}
catch (KeyNotFoundException)
{ return false; }
}
DtsodV22 Parse(string text)
{
Dictionary<string, ValueStruct> parsed = new();
int i = 0;
for (; i < text.Length; i++)
ReadName();
return new DtsodV22(parsed);
// СЛОМАНО
/*void ReadCommentLine()
{
for (; i < text.Length && text[i] != '\n'; i++) Debug("h", text[i].ToString());
}*/
void ReadName()
{
bool isListElem = false;
dynamic value;
StringBuilder defaultNameBuilder = new();
for (; i < text.Length; i++)
{
switch (text[i])
{
case ' ':
case '\t':
case '\r':
case '\n':
break;
case ':':
i++;
string name = defaultNameBuilder.ToString();
value = ReadValue(out ValueTypes type, out bool isList);
if (isListElem)
{
if (!parsed.ContainsKey(name))
parsed.Add(name, new(type, new List<dynamic>(), isList));
parsed[name].Value.Add(value);
}
else parsed.Add(name, new(type, value, isList));
return;
// строка, начинающаяся с # будет считаться комментом
case '#':
//ReadCommentLine();
break;
case '}':
throw new Exception("Parse.ReadName() error: unexpected '}' at " + i + " char");
// если $ перед названием параметра поставить, значение value добавится в лист с названием name
case '$':
if (defaultNameBuilder.ToString().Length != 0)
throw new Exception("Parse.ReadName() error: unexpected '$' at " + i + " char");
isListElem = true;
break;
case ';':
throw new Exception("Parse.ReadName() error: unexpected ';' at " + i + " char");
default:
defaultNameBuilder.Append(text[i]);
break;
}
}
}
dynamic ReadValue(out ValueTypes outType, out bool isList)
{
ValueTypes type = ValueTypes.Unknown;
isList = false;
dynamic value = null;
string ReadString()
{
i++;
StringBuilder valueBuilder = new();
valueBuilder.Append('"');
for (; text[i] != '"' || text[i - 1] == '\\'; i++)
{
valueBuilder.Append(text[i]);
}
valueBuilder.Append('"');
type = ValueTypes.String;
return valueBuilder.ToString();
}
List<dynamic> ReadList()
{
i++;
List<dynamic> output = new();
StringBuilder valueBuilder = new();
for (; text[i] != ']'; i++)
{
switch (text[i])
{
case ' ':
case '\t':
case '\r':
case '\n':
break;
case ',':
ParseValueToRightType(valueBuilder.ToString());
output.Add(value);
valueBuilder.Clear();
break;
default:
valueBuilder.Append(text[i]);
break;
}
}
if (valueBuilder.Length > 0)
{
ParseValueToRightType(valueBuilder.ToString());
output.Add(value);
}
type = ValueTypes.List;
return output;
}
Dictionary<string, ValueStruct> ReadComplex()
{
StringBuilder valueBuilder = new();
int balance = 1;
i++;
for (; balance != 0; i++)
{
switch (text[i])
{
case '"':
valueBuilder.Append(ReadString());
break;
case '}':
balance--;
if (balance != 0)
valueBuilder.Append(text[i]);
break;
case '{':
balance++;
valueBuilder.Append(text[i]);
break;
default:
valueBuilder.Append(text[i]);
break;
}
}
i--; // i++ в for выполняется даже когда balance == 0, то есть text[i] получается == ;, что ломает всё
type = ValueTypes.Complex;
return Parse(valueBuilder.ToString());
}
void ParseValueToRightType(string stringValue)
{
switch (stringValue)
{
// bool
case "true":
case "false":
type = ValueTypes.Bool;
value = stringValue.ToBool();
break;
// null
case "null":
type = ValueTypes.Null;
value = null;
break;
default:
if (stringValue.Contains('"'))
{
type = ValueTypes.String;
value = stringValue.Remove(stringValue.Length - 1).Remove(0, 1);
}
// double
else if (stringValue.Contains('.'))
{
type = ValueTypes.Double;
value = stringValue.ToDouble();
}
// ushort; ulong; uint
else if (stringValue.Length > 2 && stringValue[stringValue.Length - 2] == 'u')
{
switch (stringValue[stringValue.Length - 1])
{
case 's':
type = ValueTypes.UShort;
value = stringValue.Remove(stringValue.Length - 2).ToUShort();
break;
case 'i':
type = ValueTypes.UInt;
value = stringValue.Remove(stringValue.Length - 2).ToUInt();
break;
case 'l':
type = ValueTypes.ULong;
value = stringValue.Remove(stringValue.Length - 2).ToULong();
break;
default:
throw new Exception($"Dtsod.Parse.ReadValue() error: value <{stringValue}> has wrong type");
};
}
// short; long; int
else
switch (stringValue[stringValue.Length - 1])
{
case 's':
type = ValueTypes.Short;
value = stringValue.Remove(stringValue.Length - 1).ToShort();
break;
case 'l':
type = ValueTypes.Long;
value = stringValue.Remove(stringValue.Length - 1).ToLong();
break;
default:
type = ValueTypes.Int;
value = stringValue.ToInt();
break;
}
break;
};
}
StringBuilder defaultValueBuilder = new();
for (; i < text.Length; i++)
{
switch (text[i])
{
case ' ':
case '\t':
case '\r':
case '\n':
break;
case '"':
value = ReadString();
break;
case '[':
value = ReadList();
break;
case '{':
value = ReadComplex();
break;
case ';':
switch (type)
{
case ValueTypes.String:
ParseValueToRightType(value);
break;
case ValueTypes.Unknown:
ParseValueToRightType(defaultValueBuilder.ToString());
break;
case ValueTypes.List:
isList = true;
break;
};
outType = type;
return value;
// строка, начинающаяся с # будет считаться комментом
case '#':
//ReadCommentLine();
break;
default:
defaultValueBuilder.Append(text[i]);
break;
}
}
throw new Exception("Dtsod.Parse.ReadValue error: wtf it's the end of function");
}
}
public override string ToString() => Deconstruct(this);
ushort tabCount = 0;
string Deconstruct(DtsodV22 dtsod)
{
StringBuilder outBuilder = new();
foreach (string key in dtsod.Keys)
{
outBuilder.Append('\t', tabCount);
outBuilder.Append(key);
outBuilder.Append(": ");
dtsod.TryGetValue(key, out ValueStruct value);
switch (value.Type)
{
case ValueTypes.List:
outBuilder.Append('[').Append(StringConverter.MergeToString((IEnumerable<object>)value.Value, ",")).Append(']');
//outBuilder.Append("\"list deconstruction is'nt implemented yet\"");
break;
case ValueTypes.Complex:
outBuilder.Append('\n');
outBuilder.Append('\t', tabCount);
outBuilder.Append("{\n");
tabCount++;
outBuilder.Append(Deconstruct(value.Value));
tabCount--;
outBuilder.Append('\t', tabCount);
outBuilder.Append('}');
break;
case ValueTypes.String:
outBuilder.Append('\"');
outBuilder.Append(value.Value.ToString());
outBuilder.Append('\"');
break;
case ValueTypes.Short:
outBuilder.Append(value.Value.ToString());
outBuilder.Append('s');
break;
case ValueTypes.Int:
outBuilder.Append(value.Value.ToString());
break;
case ValueTypes.Long:
outBuilder.Append(value.Value.ToString());
outBuilder.Append('l');
break;
case ValueTypes.UShort:
outBuilder.Append(value.Value.ToString());
outBuilder.Append("us");
break;
case ValueTypes.UInt:
outBuilder.Append(value.Value.ToString());
outBuilder.Append("ui");
break;
case ValueTypes.ULong:
outBuilder.Append(value.Value.ToString());
outBuilder.Append("ul");
break;
case ValueTypes.Double:
outBuilder.Append(value.Value.ToString(System.Globalization.CultureInfo.InvariantCulture));
break;
case ValueTypes.Null:
outBuilder.Append("null");
break;
case ValueTypes.Bool:
outBuilder.Append(value.Value.ToString().ToLower());
break;
default:
throw new Exception($"Dtsod.Deconstruct() error: unknown type: {value.Type}");
}
outBuilder.Append(";\n");
}
return outBuilder.ToString();
}
public void Add(KeyValuePair<string, ValueStruct> a) => Add(a.Key, a.Value);
public DtsodV22 Extend(DtsodV22 newPart)
{
foreach (KeyValuePair<string, ValueStruct> pair in newPart)
Add(pair.Key, pair.Value);
return this;
}
}
namespace DTLib.Dtsod;
// v22
// метод ToString() теперь деконструирует объект в текст, а не возвращает параметр text из конструктора
// деконструкция листов не работает из-за костыльного определения типов данных
public class DtsodV22 : Dictionary<string, DtsodV22.ValueStruct>, IDtsod
{
public DtsodVersion Version { get; } = DtsodVersion.V22;
public IDictionary<string, dynamic> ToDictionary()
{
Dictionary<string, dynamic> newdict = new();
foreach (KeyValuePair<string, ValueStruct> pair in this)
newdict.Add(pair.Key, pair.Value.Value);
return newdict;
}
public struct ValueStruct
{
public dynamic Value;
public ValueTypes Type;
public bool IsList;
public ValueStruct(ValueTypes type, dynamic value, bool isList)
{
Value = value;
Type = type;
IsList = isList;
}
}
public enum ValueTypes
{
List,
Complex,
String,
Short,
Int,
Long,
UShort,
UInt,
ULong,
Double,
Null,
Bool,
Unknown
}
public DtsodV22() { }
public DtsodV22(string text)
{
foreach (KeyValuePair<string, ValueStruct> pair in Parse(text))
Add(pair.Key, pair.Value);
}
public DtsodV22(Dictionary<string, ValueStruct> dict)
{
foreach (KeyValuePair<string, ValueStruct> pair in dict)
Add(pair.Key, pair.Value);
}
// выдаёт Exception
public new dynamic this[string key]
{
get => TryGetValue(key, out dynamic value) ? value : throw new Exception($"Dtsod[{key}] key not found");
set
{
if (!TrySetValue(key, value)) throw new Exception($"Dtsod[{key}] key not found");
}
}
// не выдаёт KeyNotFoundException
public bool TryGetValue(string key, out dynamic value)
{
try
{
value = base[key].Value;
return true;
}
catch (KeyNotFoundException)
{
value = null;
return false;
}
}
public bool TrySetValue(string key, dynamic value)
{
try
{
bool isList = value is IList;
base[key] = new(base[key].Type, value, isList);
return true;
}
catch (KeyNotFoundException)
{ return false; }
}
DtsodV22 Parse(string text)
{
Dictionary<string, ValueStruct> parsed = new();
int i = 0;
for (; i < text.Length; i++)
ReadName();
return new DtsodV22(parsed);
// СЛОМАНО
/*void ReadCommentLine()
{
for (; i < text.Length && text[i] != '\n'; i++) Debug("h", text[i].ToString());
}*/
void ReadName()
{
bool isListElem = false;
dynamic value;
StringBuilder defaultNameBuilder = new();
for (; i < text.Length; i++)
{
switch (text[i])
{
case ' ':
case '\t':
case '\r':
case '\n':
break;
case ':':
i++;
string name = defaultNameBuilder.ToString();
value = ReadValue(out ValueTypes type, out bool isList);
if (isListElem)
{
if (!parsed.ContainsKey(name))
parsed.Add(name, new(type, new List<dynamic>(), isList));
parsed[name].Value.Add(value);
}
else parsed.Add(name, new(type, value, isList));
return;
// строка, начинающаяся с # будет считаться комментом
case '#':
//ReadCommentLine();
break;
case '}':
throw new Exception("Parse.ReadName() error: unexpected '}' at " + i + " char");
// если $ перед названием параметра поставить, значение value добавится в лист с названием name
case '$':
if (defaultNameBuilder.ToString().Length != 0)
throw new Exception("Parse.ReadName() error: unexpected '$' at " + i + " char");
isListElem = true;
break;
case ';':
throw new Exception("Parse.ReadName() error: unexpected ';' at " + i + " char");
default:
defaultNameBuilder.Append(text[i]);
break;
}
}
}
dynamic ReadValue(out ValueTypes outType, out bool isList)
{
ValueTypes type = ValueTypes.Unknown;
isList = false;
dynamic value = null;
string ReadString()
{
i++;
StringBuilder valueBuilder = new();
valueBuilder.Append('"');
for (; text[i] != '"' || text[i - 1] == '\\'; i++)
{
valueBuilder.Append(text[i]);
}
valueBuilder.Append('"');
type = ValueTypes.String;
return valueBuilder.ToString();
}
List<dynamic> ReadList()
{
i++;
List<dynamic> output = new();
StringBuilder valueBuilder = new();
for (; text[i] != ']'; i++)
{
switch (text[i])
{
case ' ':
case '\t':
case '\r':
case '\n':
break;
case ',':
ParseValueToRightType(valueBuilder.ToString());
output.Add(value);
valueBuilder.Clear();
break;
default:
valueBuilder.Append(text[i]);
break;
}
}
if (valueBuilder.Length > 0)
{
ParseValueToRightType(valueBuilder.ToString());
output.Add(value);
}
type = ValueTypes.List;
return output;
}
Dictionary<string, ValueStruct> ReadComplex()
{
StringBuilder valueBuilder = new();
int balance = 1;
i++;
for (; balance != 0; i++)
{
switch (text[i])
{
case '"':
valueBuilder.Append(ReadString());
break;
case '}':
balance--;
if (balance != 0)
valueBuilder.Append(text[i]);
break;
case '{':
balance++;
valueBuilder.Append(text[i]);
break;
default:
valueBuilder.Append(text[i]);
break;
}
}
i--; // i++ в for выполняется даже когда balance == 0, то есть text[i] получается == ;, что ломает всё
type = ValueTypes.Complex;
return Parse(valueBuilder.ToString());
}
void ParseValueToRightType(string stringValue)
{
switch (stringValue)
{
// bool
case "true":
case "false":
type = ValueTypes.Bool;
value = stringValue.ToBool();
break;
// null
case "null":
type = ValueTypes.Null;
value = null;
break;
default:
if (stringValue.Contains('"'))
{
type = ValueTypes.String;
value = stringValue.Remove(stringValue.Length - 1).Remove(0, 1);
}
// double
else if (stringValue.Contains('.'))
{
type = ValueTypes.Double;
value = stringValue.ToDouble();
}
// ushort; ulong; uint
else if (stringValue.Length > 2 && stringValue[stringValue.Length - 2] == 'u')
{
switch (stringValue[stringValue.Length - 1])
{
case 's':
type = ValueTypes.UShort;
value = stringValue.Remove(stringValue.Length - 2).ToUShort();
break;
case 'i':
type = ValueTypes.UInt;
value = stringValue.Remove(stringValue.Length - 2).ToUInt();
break;
case 'l':
type = ValueTypes.ULong;
value = stringValue.Remove(stringValue.Length - 2).ToULong();
break;
default:
throw new Exception($"Dtsod.Parse.ReadValue() error: value <{stringValue}> has wrong type");
};
}
// short; long; int
else
switch (stringValue[stringValue.Length - 1])
{
case 's':
type = ValueTypes.Short;
value = stringValue.Remove(stringValue.Length - 1).ToShort();
break;
case 'l':
type = ValueTypes.Long;
value = stringValue.Remove(stringValue.Length - 1).ToLong();
break;
default:
type = ValueTypes.Int;
value = stringValue.ToInt();
break;
}
break;
};
}
StringBuilder defaultValueBuilder = new();
for (; i < text.Length; i++)
{
switch (text[i])
{
case ' ':
case '\t':
case '\r':
case '\n':
break;
case '"':
value = ReadString();
break;
case '[':
value = ReadList();
break;
case '{':
value = ReadComplex();
break;
case ';':
switch (type)
{
case ValueTypes.String:
ParseValueToRightType(value);
break;
case ValueTypes.Unknown:
ParseValueToRightType(defaultValueBuilder.ToString());
break;
case ValueTypes.List:
isList = true;
break;
};
outType = type;
return value;
// строка, начинающаяся с # будет считаться комментом
case '#':
//ReadCommentLine();
break;
default:
defaultValueBuilder.Append(text[i]);
break;
}
}
throw new Exception("Dtsod.Parse.ReadValue error: wtf it's the end of function");
}
}
public override string ToString() => Deconstruct(this);
ushort tabCount = 0;
string Deconstruct(DtsodV22 dtsod)
{
StringBuilder outBuilder = new();
foreach (string key in dtsod.Keys)
{
outBuilder.Append('\t', tabCount);
outBuilder.Append(key);
outBuilder.Append(": ");
dtsod.TryGetValue(key, out ValueStruct value);
switch (value.Type)
{
case ValueTypes.List:
outBuilder.Append('[').Append(StringConverter.MergeToString((IEnumerable<object>)value.Value, ",")).Append(']');
//outBuilder.Append("\"list deconstruction is'nt implemented yet\"");
break;
case ValueTypes.Complex:
outBuilder.Append('\n');
outBuilder.Append('\t', tabCount);
outBuilder.Append("{\n");
tabCount++;
outBuilder.Append(Deconstruct(value.Value));
tabCount--;
outBuilder.Append('\t', tabCount);
outBuilder.Append('}');
break;
case ValueTypes.String:
outBuilder.Append('\"');
outBuilder.Append(value.Value.ToString());
outBuilder.Append('\"');
break;
case ValueTypes.Short:
outBuilder.Append(value.Value.ToString());
outBuilder.Append('s');
break;
case ValueTypes.Int:
outBuilder.Append(value.Value.ToString());
break;
case ValueTypes.Long:
outBuilder.Append(value.Value.ToString());
outBuilder.Append('l');
break;
case ValueTypes.UShort:
outBuilder.Append(value.Value.ToString());
outBuilder.Append("us");
break;
case ValueTypes.UInt:
outBuilder.Append(value.Value.ToString());
outBuilder.Append("ui");
break;
case ValueTypes.ULong:
outBuilder.Append(value.Value.ToString());
outBuilder.Append("ul");
break;
case ValueTypes.Double:
outBuilder.Append(value.Value.ToString(System.Globalization.CultureInfo.InvariantCulture));
break;
case ValueTypes.Null:
outBuilder.Append("null");
break;
case ValueTypes.Bool:
outBuilder.Append(value.Value.ToString().ToLower());
break;
default:
throw new Exception($"Dtsod.Deconstruct() error: unknown type: {value.Type}");
}
outBuilder.Append(";\n");
}
return outBuilder.ToString();
}
public void Add(KeyValuePair<string, ValueStruct> a) => Add(a.Key, a.Value);
public DtsodV22 Extend(DtsodV22 newPart)
{
foreach (KeyValuePair<string, ValueStruct> pair in newPart)
Add(pair.Key, pair.Value);
return this;
}
}

View File

@@ -1,330 +1,330 @@
using System.Globalization;
using System.IO;
using System.Linq.Expressions;
namespace DTLib.Dtsod;
// v23
// в процессе создания v30 появились идеи по улучшению 20-ой серии
// новый парсер (опять)
// улучшена сериализация и десериализация листов
public class DtsodV23 : DtsodDict<string, dynamic>, IDtsod
{
public DtsodVersion Version { get; } = DtsodVersion.V30;
public IDictionary<string, dynamic> ToDictionary() => this;
public DtsodV23() : base() {}
public DtsodV23(IDictionary<string, dynamic> dict) : base(dict) {}
public DtsodV23(string serialized) => Append(Deserialize(serialized));
static DtsodV23 Deserialize(string _text)
{
char[] text = _text.ToArray();
char c;
int i = -1; // ++i в ReadName
StringBuilder b = new();
Dictionary<string, dynamic> output = new();
bool partOfDollarList = false;
while (i < text.Length)
{
string name = ReadName();
if (name == "") goto end;
dynamic value = ReadValue(out bool _);
if (partOfDollarList)
{
if (!output.TryGetValue(name, out var dollarList))
{
dollarList = new List<dynamic>();
output.Add(name, dollarList);
}
dollarList.Add(value);
}
else output.Add(name, value);
}
end:return new DtsodV23(output);
string ReadName()
{
while (i < text.Length - 1)
{
c = text[++i];
switch (c)
{
case ' ':
case '\t':
case '\r':
case '\n':
break;
case '#':
SkipComment();
break;
case ':':
string _name = b.ToString();
b.Clear();
return _name;
case '$':
partOfDollarList = true;
break;
case '=':
case '"':
case '\'':
case ';':
case '[':
case ']':
case '{':
case '}':
throw new Exception($"DtsodV23.Deserialize() error: unexpected {c}");
default:
b.Append(c);
break;
}
}
return b.Length == 0
? ""
: throw new Exception("DtsodV23.Deserialize.ReadName() error: end of text\ntext:\n" + text);
}
dynamic ReadValue(out bool endOfList)
{
endOfList = false;
void ReadString()
{
bool prevIsBackslash = false;
b.Append('"');
c = text[++i];
while (c != '"' || prevIsBackslash)
{
prevIsBackslash = c == '\\' && !prevIsBackslash;
b.Append(c);
if (++i >= text.Length) throw new Exception("DtsodV23.Deserialize() error: end of text\ntext:\n" + text);
c = text[i];
}
b.Append('"');
}
DtsodV23 ReadDtsod()
{
short bracketBalance = 1;
c = text[++i]; //пропускает начальный символ '{'
while (bracketBalance != 0)
{
switch (c)
{
case ' ':
case '\t':
case '\r':
case '\n':
break;
case '#':
SkipComment();
break;
case '{':
bracketBalance++;
b.Append(c);
break;
case '}':
bracketBalance--;
if (bracketBalance != 0)
b.Append(c);
break;
case '"':
ReadString();
break;
default:
b.Append(c);
break;
}
if (++i >= text.Length) throw new Exception("DtsodV23.Deserialize() error: end of text\ntext:\n" + text);
c = text[i];
}
var __text = b.ToString();
b.Clear();
return Deserialize(__text);
}
List<dynamic> ReadList()
{
List<dynamic> list = new();
while (true)
{
list.Add(ReadValue(out bool _eol));
if (_eol) break;
}
b.Clear();
return list;
}
dynamic ParseValue(string value_str)
{
switch (value_str)
{
case "true":
case "false":
return value_str.ToBool();
case "null":
return null;
default:
if (value_str.Contains('"'))
return value_str.Substring(1, value_str.Length - 2).Replace("\\\\","\\").Replace("\\\"","\"");
else if (value_str.Contains('\''))
return value_str[1];
else switch (value_str[value_str.Length - 1])
{
case 's':
return value_str[value_str.Length - 2] == 'u'
? value_str.Remove(value_str.Length - 2).ToUShort()
: value_str.Remove(value_str.Length - 1).ToShort();
case 'u':
return value_str.Remove(value_str.Length - 1).ToUInt();
case 'i':
return value_str[value_str.Length - 2] == 'u'
? value_str.Remove(value_str.Length - 2).ToUInt()
: value_str.Remove(value_str.Length - 1).ToInt();
case 'l':
return value_str[value_str.Length - 2] == 'u'
? value_str.Remove(value_str.Length - 2).ToULong()
: value_str.Remove(value_str.Length - 1).ToLong();
case 'b':
return value_str[value_str.Length - 2] == 's'
? value_str.Remove(value_str.Length - 2).ToSByte()
: value_str.Remove(value_str.Length - 1).ToByte();
case 'f':
return value_str.Remove(value_str.Length - 1).ToFloat();
case 'e':
return value_str[value_str.Length - 2] == 'd'
? value_str.Remove(value_str.Length - 2).ToDecimal()
: throw new Exception("can't parse value:" + value_str);
default:
if (value_str.Contains('.'))
return (object)(value_str.ToDouble());
else
{
try { return (object)(value_str.ToInt()); }
catch (FormatException)
{
Log("r", $"can't parse value: {value_str}");
return null;
}
}
}
};
}
while (i < text.Length - 1)
{
c = text[++i];
switch (c)
{
case ' ':
case '\t':
case '\r':
case '\n':
break;
case '#':
SkipComment();
break;
case '"':
ReadString();
break;
case '\'':
b.Append(c).Append(text[++i]);
c = text[++i];
if (c != '\'') throw new Exception("after <\'> should be char");
else b.Append(c);
break;
case ';':
case ',':
string str = b.ToString();
b.Clear();
return ParseValue(str);
case '[':
return ReadList();
case ']':
endOfList = true;
break;
case '{':
return ReadDtsod();
case '=':
case ':':
case '}':
case '$':
throw new Exception($"DtsodV23.Deserialize() error: unexpected {c}");
default:
b.Append(c);
break;
}
}
throw new Exception("DtsodV23.Deserialize.ReadValue() error: end of text\ntext:\n" + text);
}
void SkipComment()
{
while (text[i] != '\n')
if (++i >= text.Length) throw new Exception("DtsodV23.Deserialize() error: end of text\ntext:\n" + text);
}
}
internal static readonly Dictionary<Type, Action<dynamic, StringBuilder>> TypeSerializeFuncs = new()
{
{ typeof(bool), (val, b) => b.Append(val.ToString()) },
{ typeof(char), (val, b) => b.Append('\'').Append(val).Append('\'') },
{ typeof(string), (val, b) => b.Append('"').Append(val.Replace("\\","\\\\").Replace("\"", "\\\"")).Append('"') },
{ typeof(byte), (val, b) => b.Append(val.ToString()).Append('b') },
{ typeof(sbyte), (val, b) => b.Append(val.ToString()).Append("sb") },
{ typeof(short), (val, b) => b.Append(val.ToString()).Append('s') },
{ typeof(ushort), (val, b) => b.Append(val.ToString()).Append("us") },
{ typeof(int), (val, b) => b.Append(val.ToString()) },
{ typeof(uint), (val, b) => b.Append(val.ToString()).Append("ui") },
{ typeof(long), (val, b) => b.Append(val.ToString()).Append('l') },
{ typeof(ulong), (val, b) => b.Append(val.ToString()).Append("ul") },
{ typeof(float), (val, b) => b.Append(val.ToString(CultureInfo.InvariantCulture)).Append('f') },
{ typeof(double), (val, b) => b.Append(val.ToString(CultureInfo.InvariantCulture)) },
{ typeof(decimal), (val, b) => b.Append(val.ToString(CultureInfo.InvariantCulture)).Append("de") }
};
short tabscount = -1;
protected StringBuilder Serialize(DtsodV23 dtsod, StringBuilder b = null)
{
tabscount++;
if (b is null) b = new StringBuilder();
foreach (var pair in dtsod)
{
b.Append('\t', tabscount).Append(pair.Key).Append(": ");
SerializeType(pair.Value);
b.Append(";\n");
void SerializeType(dynamic value)
{
if (value is null) b.Append("null");
else if (value is IList _list)
{
b.Append('[');
foreach (object el in _list)
{
SerializeType(el);
b.Append(',');
}
b.Remove(b.Length - 1, 1).Append(']');
}
else if (value is DtsodV23 _dtsod)
{
b.Append("{\n");
Serialize(_dtsod, b);
b.Append('}');
}
else TypeSerializeFuncs[value.GetType()].Invoke(value, b);
}
}
tabscount--;
return b;
}
public override string ToString() => Serialize(this).ToString();
}
using System.Globalization;
using System.IO;
using System.Linq.Expressions;
namespace DTLib.Dtsod;
// v23
// в процессе создания v30 появились идеи по улучшению 20-ой серии
// новый парсер (опять)
// улучшена сериализация и десериализация листов
public class DtsodV23 : DtsodDict<string, dynamic>, IDtsod
{
public DtsodVersion Version { get; } = DtsodVersion.V30;
public IDictionary<string, dynamic> ToDictionary() => this;
public DtsodV23() : base() {}
public DtsodV23(IDictionary<string, dynamic> dict) : base(dict) {}
public DtsodV23(string serialized) => Append(Deserialize(serialized));
static DtsodV23 Deserialize(string _text)
{
char[] text = _text.ToArray();
char c;
int i = -1; // ++i в ReadName
StringBuilder b = new();
Dictionary<string, dynamic> output = new();
bool partOfDollarList = false;
while (i < text.Length)
{
string name = ReadName();
if (name == "") goto end;
dynamic value = ReadValue(out bool _);
if (partOfDollarList)
{
if (!output.TryGetValue(name, out var dollarList))
{
dollarList = new List<dynamic>();
output.Add(name, dollarList);
}
dollarList.Add(value);
}
else output.Add(name, value);
}
end:return new DtsodV23(output);
string ReadName()
{
while (i < text.Length - 1)
{
c = text[++i];
switch (c)
{
case ' ':
case '\t':
case '\r':
case '\n':
break;
case '#':
SkipComment();
break;
case ':':
string _name = b.ToString();
b.Clear();
return _name;
case '$':
partOfDollarList = true;
break;
case '=':
case '"':
case '\'':
case ';':
case '[':
case ']':
case '{':
case '}':
throw new Exception($"DtsodV23.Deserialize() error: unexpected {c}");
default:
b.Append(c);
break;
}
}
return b.Length == 0
? ""
: throw new Exception("DtsodV23.Deserialize.ReadName() error: end of text\ntext:\n" + text);
}
dynamic ReadValue(out bool endOfList)
{
endOfList = false;
void ReadString()
{
bool prevIsBackslash = false;
b.Append('"');
c = text[++i];
while (c != '"' || prevIsBackslash)
{
prevIsBackslash = c == '\\' && !prevIsBackslash;
b.Append(c);
if (++i >= text.Length) throw new Exception("DtsodV23.Deserialize() error: end of text\ntext:\n" + text);
c = text[i];
}
b.Append('"');
}
DtsodV23 ReadDtsod()
{
short bracketBalance = 1;
c = text[++i]; //пропускает начальный символ '{'
while (bracketBalance != 0)
{
switch (c)
{
case ' ':
case '\t':
case '\r':
case '\n':
break;
case '#':
SkipComment();
break;
case '{':
bracketBalance++;
b.Append(c);
break;
case '}':
bracketBalance--;
if (bracketBalance != 0)
b.Append(c);
break;
case '"':
ReadString();
break;
default:
b.Append(c);
break;
}
if (++i >= text.Length) throw new Exception("DtsodV23.Deserialize() error: end of text\ntext:\n" + text);
c = text[i];
}
var __text = b.ToString();
b.Clear();
return Deserialize(__text);
}
List<dynamic> ReadList()
{
List<dynamic> list = new();
while (true)
{
list.Add(ReadValue(out bool _eol));
if (_eol) break;
}
b.Clear();
return list;
}
dynamic ParseValue(string value_str)
{
switch (value_str)
{
case "true":
case "false":
return value_str.ToBool();
case "null":
return null;
default:
if (value_str.Contains('"'))
return value_str.Substring(1, value_str.Length - 2).Replace("\\\\","\\").Replace("\\\"","\"");
else if (value_str.Contains('\''))
return value_str[1];
else switch (value_str[value_str.Length - 1])
{
case 's':
return value_str[value_str.Length - 2] == 'u'
? value_str.Remove(value_str.Length - 2).ToUShort()
: value_str.Remove(value_str.Length - 1).ToShort();
case 'u':
return value_str.Remove(value_str.Length - 1).ToUInt();
case 'i':
return value_str[value_str.Length - 2] == 'u'
? value_str.Remove(value_str.Length - 2).ToUInt()
: value_str.Remove(value_str.Length - 1).ToInt();
case 'l':
return value_str[value_str.Length - 2] == 'u'
? value_str.Remove(value_str.Length - 2).ToULong()
: value_str.Remove(value_str.Length - 1).ToLong();
case 'b':
return value_str[value_str.Length - 2] == 's'
? value_str.Remove(value_str.Length - 2).ToSByte()
: value_str.Remove(value_str.Length - 1).ToByte();
case 'f':
return value_str.Remove(value_str.Length - 1).ToFloat();
case 'e':
return value_str[value_str.Length - 2] == 'd'
? value_str.Remove(value_str.Length - 2).ToDecimal()
: throw new Exception("can't parse value:" + value_str);
default:
if (value_str.Contains('.'))
return (object)(value_str.ToDouble());
else
{
try { return (object)(value_str.ToInt()); }
catch (FormatException)
{
Log("r", $"can't parse value: {value_str}");
return null;
}
}
}
};
}
while (i < text.Length - 1)
{
c = text[++i];
switch (c)
{
case ' ':
case '\t':
case '\r':
case '\n':
break;
case '#':
SkipComment();
break;
case '"':
ReadString();
break;
case '\'':
b.Append(c).Append(text[++i]);
c = text[++i];
if (c != '\'') throw new Exception("after <\'> should be char");
else b.Append(c);
break;
case ';':
case ',':
string str = b.ToString();
b.Clear();
return ParseValue(str);
case '[':
return ReadList();
case ']':
endOfList = true;
break;
case '{':
return ReadDtsod();
case '=':
case ':':
case '}':
case '$':
throw new Exception($"DtsodV23.Deserialize() error: unexpected {c}");
default:
b.Append(c);
break;
}
}
throw new Exception("DtsodV23.Deserialize.ReadValue() error: end of text\ntext:\n" + text);
}
void SkipComment()
{
while (text[i] != '\n')
if (++i >= text.Length) throw new Exception("DtsodV23.Deserialize() error: end of text\ntext:\n" + text);
}
}
internal static readonly Dictionary<Type, Action<dynamic, StringBuilder>> TypeSerializeFuncs = new()
{
{ typeof(bool), (val, b) => b.Append(val.ToString()) },
{ typeof(char), (val, b) => b.Append('\'').Append(val).Append('\'') },
{ typeof(string), (val, b) => b.Append('"').Append(val.Replace("\\","\\\\").Replace("\"", "\\\"")).Append('"') },
{ typeof(byte), (val, b) => b.Append(val.ToString()).Append('b') },
{ typeof(sbyte), (val, b) => b.Append(val.ToString()).Append("sb") },
{ typeof(short), (val, b) => b.Append(val.ToString()).Append('s') },
{ typeof(ushort), (val, b) => b.Append(val.ToString()).Append("us") },
{ typeof(int), (val, b) => b.Append(val.ToString()) },
{ typeof(uint), (val, b) => b.Append(val.ToString()).Append("ui") },
{ typeof(long), (val, b) => b.Append(val.ToString()).Append('l') },
{ typeof(ulong), (val, b) => b.Append(val.ToString()).Append("ul") },
{ typeof(float), (val, b) => b.Append(val.ToString(CultureInfo.InvariantCulture)).Append('f') },
{ typeof(double), (val, b) => b.Append(val.ToString(CultureInfo.InvariantCulture)) },
{ typeof(decimal), (val, b) => b.Append(val.ToString(CultureInfo.InvariantCulture)).Append("de") }
};
short tabscount = -1;
protected StringBuilder Serialize(DtsodV23 dtsod, StringBuilder b = null)
{
tabscount++;
if (b is null) b = new StringBuilder();
foreach (var pair in dtsod)
{
b.Append('\t', tabscount).Append(pair.Key).Append(": ");
SerializeType(pair.Value);
b.Append(";\n");
void SerializeType(dynamic value)
{
if (value is null) b.Append("null");
else if (value is IList _list)
{
b.Append('[');
foreach (object el in _list)
{
SerializeType(el);
b.Append(',');
}
b.Remove(b.Length - 1, 1).Append(']');
}
else if (value is DtsodV23 _dtsod)
{
b.Append("{\n");
Serialize(_dtsod, b);
b.Append('}');
}
else TypeSerializeFuncs[value.GetType()].Invoke(value, b);
}
}
tabscount--;
return b;
}
public override string ToString() => Serialize(this).ToString();
}

View File

@@ -1,9 +1,9 @@
namespace DTLib.Dtsod;
public enum DtsodVersion : byte
{
V21 = 21,
V22 = 22,
V23 = 23,
V30 = 30
}
namespace DTLib.Dtsod;
public enum DtsodVersion : byte
{
V21 = 21,
V22 = 22,
V23 = 23,
V30 = 30
}

View File

@@ -1,14 +1,14 @@
namespace DTLib.Dtsod;
public static class DtsodVersionConverter
{
public static IDtsod Convert(IDtsod src, DtsodVersion targetVersion)
=> targetVersion switch
{
DtsodVersion.V21 => new DtsodV21(src.ToDictionary()),
DtsodVersion.V22 => throw new NotImplementedException("Converting dtsods to V22 isn't implemented"),
DtsodVersion.V23 => new DtsodV23(src.ToDictionary()),
DtsodVersion.V30 => new DtsodV30(src.ToDictionary()),
_ => throw new Exception($"DtsodVersionConverter.Convert() error: unknown target version <{targetVersion}>"),
};
}
namespace DTLib.Dtsod;
public static class DtsodVersionConverter
{
public static IDtsod Convert(IDtsod src, DtsodVersion targetVersion)
=> targetVersion switch
{
DtsodVersion.V21 => new DtsodV21(src.ToDictionary()),
DtsodVersion.V22 => throw new NotImplementedException("Converting dtsods to V22 isn't implemented"),
DtsodVersion.V23 => new DtsodV23(src.ToDictionary()),
DtsodVersion.V30 => new DtsodV30(src.ToDictionary()),
_ => throw new Exception($"DtsodVersionConverter.Convert() error: unknown target version <{targetVersion}>"),
};
}

View File

@@ -1,8 +1,8 @@
namespace DTLib.Dtsod;
public interface IDtsod
{
public DtsodVersion Version { get; }
public IDictionary<string, dynamic> ToDictionary();
}
namespace DTLib.Dtsod;
public interface IDtsod
{
public DtsodVersion Version { get; }
public IDictionary<string, dynamic> ToDictionary();
}

View File

@@ -1,65 +1,65 @@
namespace DTLib.Dtsod;
public class DtsodDict<TKey, TVal> : IDictionary<TKey, TVal>
{
// да, вместо собственной реализации интерфейса это ссылки на Dictionary
readonly Dictionary<TKey, TVal> baseDict;
public DtsodDict() => baseDict = new();
public DtsodDict(IDictionary<TKey, TVal> srcDict) => baseDict = new(srcDict);
public virtual TVal this[TKey key]
{
get => TryGetValue(key, out TVal value) ? value : throw new Exception($"Dtsod[{key}] key not found");
set
{
if (!TrySetValue(key, value)) throw new KeyNotFoundException($"DtsodDict[{key}] key not found");
}
}
public virtual bool TryGetValue(TKey key, out TVal value) => baseDict.TryGetValue(key, out value);
public virtual bool TrySetValue(TKey key, TVal value)
{
if (ContainsKey(key))
{
baseDict[key] = value;
return true;
}
else return false;
}
public virtual void Append(ICollection<KeyValuePair<TKey, TVal>> anotherDtsod)
{
foreach (KeyValuePair<TKey, TVal> pair in anotherDtsod)
Add(pair.Key, pair.Value);
}
public virtual void Add(TKey key, TVal value) => baseDict.Add(key, value);
public virtual void Add(KeyValuePair<TKey, TVal> pair)
=> ((ICollection<KeyValuePair<TKey, TVal>>)baseDict).Add(pair);
public int Count => baseDict.Count;
public ICollection<TKey> Keys => baseDict.Keys;
public ICollection<TVal> Values => baseDict.Values;
public bool IsReadOnly { get; } = false;
public virtual void Clear() => baseDict.Clear();
public virtual bool ContainsKey(TKey key) => baseDict.ContainsKey(key);
bool ICollection<KeyValuePair<TKey, TVal>>.Contains(KeyValuePair<TKey, TVal> pair)
=> ((ICollection<KeyValuePair<TKey, TVal>>)baseDict).Contains(pair);
void ICollection<KeyValuePair<TKey, TVal>>.CopyTo(KeyValuePair<TKey, TVal>[] array, int arrayIndex)
=> ((ICollection<KeyValuePair<TKey, TVal>>)baseDict).CopyTo(array, arrayIndex);
public virtual bool Remove(TKey key) => baseDict.Remove(key);
bool ICollection<KeyValuePair<TKey, TVal>>.Remove(KeyValuePair<TKey, TVal> pair)
=> ((ICollection<KeyValuePair<TKey, TVal>>)baseDict).Remove(pair);
IEnumerator IEnumerable.GetEnumerator() => baseDict.GetEnumerator();
public IEnumerator<KeyValuePair<TKey, TVal>> GetEnumerator() => baseDict.GetEnumerator();
}
namespace DTLib.Dtsod;
public class DtsodDict<TKey, TVal> : IDictionary<TKey, TVal>
{
// да, вместо собственной реализации интерфейса это ссылки на Dictionary
readonly Dictionary<TKey, TVal> baseDict;
public DtsodDict() => baseDict = new();
public DtsodDict(IDictionary<TKey, TVal> srcDict) => baseDict = new(srcDict);
public virtual TVal this[TKey key]
{
get => TryGetValue(key, out TVal value) ? value : throw new Exception($"Dtsod[{key}] key not found");
set
{
if (!TrySetValue(key, value)) throw new KeyNotFoundException($"DtsodDict[{key}] key not found");
}
}
public virtual bool TryGetValue(TKey key, out TVal value) => baseDict.TryGetValue(key, out value);
public virtual bool TrySetValue(TKey key, TVal value)
{
if (ContainsKey(key))
{
baseDict[key] = value;
return true;
}
else return false;
}
public virtual void Append(ICollection<KeyValuePair<TKey, TVal>> anotherDtsod)
{
foreach (KeyValuePair<TKey, TVal> pair in anotherDtsod)
Add(pair.Key, pair.Value);
}
public virtual void Add(TKey key, TVal value) => baseDict.Add(key, value);
public virtual void Add(KeyValuePair<TKey, TVal> pair)
=> ((ICollection<KeyValuePair<TKey, TVal>>)baseDict).Add(pair);
public int Count => baseDict.Count;
public ICollection<TKey> Keys => baseDict.Keys;
public ICollection<TVal> Values => baseDict.Values;
public bool IsReadOnly { get; } = false;
public virtual void Clear() => baseDict.Clear();
public virtual bool ContainsKey(TKey key) => baseDict.ContainsKey(key);
bool ICollection<KeyValuePair<TKey, TVal>>.Contains(KeyValuePair<TKey, TVal> pair)
=> ((ICollection<KeyValuePair<TKey, TVal>>)baseDict).Contains(pair);
void ICollection<KeyValuePair<TKey, TVal>>.CopyTo(KeyValuePair<TKey, TVal>[] array, int arrayIndex)
=> ((ICollection<KeyValuePair<TKey, TVal>>)baseDict).CopyTo(array, arrayIndex);
public virtual bool Remove(TKey key) => baseDict.Remove(key);
bool ICollection<KeyValuePair<TKey, TVal>>.Remove(KeyValuePair<TKey, TVal> pair)
=> ((ICollection<KeyValuePair<TKey, TVal>>)baseDict).Remove(pair);
IEnumerator IEnumerable.GetEnumerator() => baseDict.GetEnumerator();
public IEnumerator<KeyValuePair<TKey, TVal>> GetEnumerator() => baseDict.GetEnumerator();
}

View File

@@ -1,7 +1,7 @@
namespace DTLib.Dtsod;
public class DtsodSerializableAttribute : Attribute
{
public DtsodVersion Version;
public DtsodSerializableAttribute(DtsodVersion ver) => Version = ver;
}
namespace DTLib.Dtsod;
public class DtsodSerializableAttribute : Attribute
{
public DtsodVersion Version;
public DtsodSerializableAttribute(DtsodVersion ver) => Version = ver;
}

View File

@@ -1,297 +1,297 @@
using System.Globalization;
namespace DTLib.Dtsod;
public class DtsodV30 : DtsodDict<string, dynamic>, IDtsod
{
public DtsodVersion Version { get; } = DtsodVersion.V30;
public IDictionary<string, dynamic> ToDictionary() => this;
public DtsodV30() : base() => UpdateLazy();
public DtsodV30(IDictionary<string, dynamic> dict) : base(dict) => UpdateLazy();
public DtsodV30(string serialized) : this() => Append(Deserialize(serialized));
static IDictionary<string, dynamic> Deserialize(string text)
{
char c;
int i = -1; // ++i в ReadType
StringBuilder b = new();
Type ReadType()
{
while (i < text.Length - 1)
{
c = text[++i];
switch (c)
{
case ' ':
case '\t':
case '\r':
case '\n':
break;
case '#':
SkipComment();
break;
case ':':
string _type = b.ToString();
b.Clear();
return TypeHelper.Instance.TypeFromString(_type);
case '=':
case '"':
case '\'':
case ';':
case '[':
case ']':
case '{':
case '}':
throw new Exception($"DtsodV30.Deserialize() error: unexpected {c}");
default:
b.Append(c);
break;
}
}
throw new Exception("DtsodV30.Deserialize.ReadType() error: end of text\ntext:\n" + text);
}
string ReadName()
{
while (i < text.Length - 1)
{
c = text[++i];
switch (c)
{
case ' ':
case '\t':
case '\r':
case '\n':
break;
case '#':
SkipComment();
break;
case '=':
string _name = b.ToString();
b.Clear();
return _name;
case ':':
case '"':
case '\'':
case ';':
case '[':
case ']':
case '{':
case '}':
throw new Exception($"DtsodV30.Deserialize() error: unexpected {c}");
default:
b.Append(c);
break;
}
}
throw new Exception("DtsodV30.Deserialize.ReadName() error: end of text\ntext:\n" + text);
}
object ReadValue(ref bool endoflist)
{
void ReadString()
{
c = text[++i]; //пропускает начальный символ '"'
while ((c != '"' && c != '\'') || (text[i - 1] == '\\' && text[i - 2] != '\\'))
{
b.Append(c);
if (++i >= text.Length) throw new Exception("DtsodV30.Deserialize() error: end of text\ntext:\n" + text);
c = text[i];
}
}
List<object> ReadList()
{
List<object> list = new();
bool _endoflist = false;
while (!_endoflist)
list.Add(CreateInstance(ReadType(), ReadValue(ref _endoflist)));
b.Clear();
return list;
}
IDictionary<string, dynamic> ReadDictionary()
{
short bracketBalance = 1;
c = text[++i]; //пропускает начальный символ '{'
while (bracketBalance != 0)
{
switch (c)
{
case ' ':
case '\t':
case '\r':
case '\n':
break;
case '#':
SkipComment();
break;
case '{':
bracketBalance++;
b.Append(c);
break;
case '}':
bracketBalance--;
if (bracketBalance != 0)
b.Append(c);
break;
case '"':
case '\'':
b.Append('"');
ReadString();
b.Append('"');
break;
default:
b.Append(c);
break;
}
if (++i >= text.Length) throw new Exception("DtsodV30.Deserialize() error: end of text\ntext:\n" + text);
c = text[i];
}
b.Clear();
return Deserialize(b.ToString());
}
while (i < text.Length-1)
{
c = text[++i];
switch (c)
{
case ' ':
case '\t':
case '\r':
case '\n':
break;
case '#':
SkipComment();
break;
case '"':
case '\'':
ReadString();
break;
case ';': // один параметр
case ',': // для листов
string str = b.ToString();
b.Clear();
return str == "null" ? null : str;
case '[':
return ReadList();
case ']':
endoflist = true;
goto case ',';
case '{':
return ReadDictionary();
case '=':
case ':':
case '}':
throw new Exception($"DtsodV30.Deserialize() error: unexpected {c}");
default:
b.Append(c);
break;
}
}
throw new Exception("DtsodV30.Deserialize.ReadValue() error: end of text\ntext:\n" + text);
}
void SkipComment()
{
while (text[i] != '\n')
if (++i >= text.Length) throw new Exception("DtsodV30.Deserialize() error: end of text\ntext:\n" + text);
}
object CreateInstance(Type type, object ctor_arg)
{
if (TypeHelper.Instance.BaseTypeConstructors.TryGetValue(type, out Func<string, dynamic> ctor))
return (object)ctor.Invoke((string)ctor_arg);
else if (type.CustomAttributes.Any(a => a.AttributeType == typeof(DtsodSerializableAttribute)))
return Activator.CreateInstance(type, ((IDictionary<string, object>)ctor_arg).Values.ToArray());
else if (typeof(ICollection).IsAssignableFrom(type))
{
var method_As = typeof(TypeHelper).GetMethod("As",
System.Reflection.BindingFlags.Static |
System.Reflection.BindingFlags.NonPublic)
.MakeGenericMethod(type.GetGenericArguments()[0]);
object collection = type.GetConstructor(Type.EmptyTypes).Invoke(null);
var method_Add = type.GetMethod("Add");
Log(method_Add.Name);
foreach (object el in (IEnumerable)ctor_arg)
{
var pel = method_As.Invoke(null, new object[] { el });
method_Add.Invoke(collection, new object[] { pel });
}
return collection;
}
else throw new Exception($"can't create instance of {type.FullName}");
}
Dictionary<string, dynamic> output = new();
Type type;
string name;
object value;
for (; i < text.Length; i++)
{
type = ReadType();
name = ReadName();
bool _ = false;
value = ReadValue(ref _);
output.Add(name, CreateInstance(type, value));
}
return output;
}
public override void Append(ICollection<KeyValuePair<string, dynamic>> anotherDtsod) => base.Append(anotherDtsod);//UpdateLazy();
public override void Add(string key, dynamic value) => base.Add(key, (object)value);//UpdateLazy();
protected static string Serialize(IDictionary<string, dynamic> dtsod, ushort tabsCount = 0)
{
StringBuilder b = new();
foreach (KeyValuePair<string, dynamic> pair in dtsod)
{
}
void SerializeObject(string name, dynamic inst)
{
Type type = inst.GetType();
b.Append(TypeHelper.Instance.TypeToString(type)).Append(':')
.Append(name).Append('=');
if (TypeHelper.Instance.BaseTypeNames.ContainsKey(type))
{
if (type == typeof(decimal) || type == typeof(double) || type == typeof(float))
b.Append(inst.ToString(CultureInfo.InvariantCulture));
else b.Append(inst.ToString());
}
else if (typeof(IDictionary<string, dynamic>).IsAssignableFrom(type))
b.Append("\n{\n").Append(Serialize(inst, tabsCount++)).Append("};\n");
else if (type.CustomAttributes.Any(a => a.AttributeType == typeof(DtsodSerializableAttribute)))
{
var props = type.GetProperties().Where(p => p.CustomAttributes.Any(a => a.AttributeType == typeof(DtsodSerializableAttribute)));
foreach (var prop in props)
{
var propval = prop.GetValue(inst);
}
}
else throw new Exception($"can't serialize type {type.FullName}");
}
return b.ToString();
}
protected Lazy<string> serialized;
protected void UpdateLazy() => serialized = new(() => Serialize(this));
public override string ToString() => serialized.Value;
}
using System.Globalization;
namespace DTLib.Dtsod;
public class DtsodV30 : DtsodDict<string, dynamic>, IDtsod
{
public DtsodVersion Version { get; } = DtsodVersion.V30;
public IDictionary<string, dynamic> ToDictionary() => this;
public DtsodV30() : base() => UpdateLazy();
public DtsodV30(IDictionary<string, dynamic> dict) : base(dict) => UpdateLazy();
public DtsodV30(string serialized) : this() => Append(Deserialize(serialized));
static IDictionary<string, dynamic> Deserialize(string text)
{
char c;
int i = -1; // ++i в ReadType
StringBuilder b = new();
Type ReadType()
{
while (i < text.Length - 1)
{
c = text[++i];
switch (c)
{
case ' ':
case '\t':
case '\r':
case '\n':
break;
case '#':
SkipComment();
break;
case ':':
string _type = b.ToString();
b.Clear();
return TypeHelper.Instance.TypeFromString(_type);
case '=':
case '"':
case '\'':
case ';':
case '[':
case ']':
case '{':
case '}':
throw new Exception($"DtsodV30.Deserialize() error: unexpected {c}");
default:
b.Append(c);
break;
}
}
throw new Exception("DtsodV30.Deserialize.ReadType() error: end of text\ntext:\n" + text);
}
string ReadName()
{
while (i < text.Length - 1)
{
c = text[++i];
switch (c)
{
case ' ':
case '\t':
case '\r':
case '\n':
break;
case '#':
SkipComment();
break;
case '=':
string _name = b.ToString();
b.Clear();
return _name;
case ':':
case '"':
case '\'':
case ';':
case '[':
case ']':
case '{':
case '}':
throw new Exception($"DtsodV30.Deserialize() error: unexpected {c}");
default:
b.Append(c);
break;
}
}
throw new Exception("DtsodV30.Deserialize.ReadName() error: end of text\ntext:\n" + text);
}
object ReadValue(ref bool endoflist)
{
void ReadString()
{
c = text[++i]; //пропускает начальный символ '"'
while ((c != '"' && c != '\'') || (text[i - 1] == '\\' && text[i - 2] != '\\'))
{
b.Append(c);
if (++i >= text.Length) throw new Exception("DtsodV30.Deserialize() error: end of text\ntext:\n" + text);
c = text[i];
}
}
List<object> ReadList()
{
List<object> list = new();
bool _endoflist = false;
while (!_endoflist)
list.Add(CreateInstance(ReadType(), ReadValue(ref _endoflist)));
b.Clear();
return list;
}
IDictionary<string, dynamic> ReadDictionary()
{
short bracketBalance = 1;
c = text[++i]; //пропускает начальный символ '{'
while (bracketBalance != 0)
{
switch (c)
{
case ' ':
case '\t':
case '\r':
case '\n':
break;
case '#':
SkipComment();
break;
case '{':
bracketBalance++;
b.Append(c);
break;
case '}':
bracketBalance--;
if (bracketBalance != 0)
b.Append(c);
break;
case '"':
case '\'':
b.Append('"');
ReadString();
b.Append('"');
break;
default:
b.Append(c);
break;
}
if (++i >= text.Length) throw new Exception("DtsodV30.Deserialize() error: end of text\ntext:\n" + text);
c = text[i];
}
b.Clear();
return Deserialize(b.ToString());
}
while (i < text.Length-1)
{
c = text[++i];
switch (c)
{
case ' ':
case '\t':
case '\r':
case '\n':
break;
case '#':
SkipComment();
break;
case '"':
case '\'':
ReadString();
break;
case ';': // один параметр
case ',': // для листов
string str = b.ToString();
b.Clear();
return str == "null" ? null : str;
case '[':
return ReadList();
case ']':
endoflist = true;
goto case ',';
case '{':
return ReadDictionary();
case '=':
case ':':
case '}':
throw new Exception($"DtsodV30.Deserialize() error: unexpected {c}");
default:
b.Append(c);
break;
}
}
throw new Exception("DtsodV30.Deserialize.ReadValue() error: end of text\ntext:\n" + text);
}
void SkipComment()
{
while (text[i] != '\n')
if (++i >= text.Length) throw new Exception("DtsodV30.Deserialize() error: end of text\ntext:\n" + text);
}
object CreateInstance(Type type, object ctor_arg)
{
if (TypeHelper.Instance.BaseTypeConstructors.TryGetValue(type, out Func<string, dynamic> ctor))
return (object)ctor.Invoke((string)ctor_arg);
else if (type.CustomAttributes.Any(a => a.AttributeType == typeof(DtsodSerializableAttribute)))
return Activator.CreateInstance(type, ((IDictionary<string, object>)ctor_arg).Values.ToArray());
else if (typeof(ICollection).IsAssignableFrom(type))
{
var method_As = typeof(TypeHelper).GetMethod("As",
System.Reflection.BindingFlags.Static |
System.Reflection.BindingFlags.NonPublic)
.MakeGenericMethod(type.GetGenericArguments()[0]);
object collection = type.GetConstructor(Type.EmptyTypes).Invoke(null);
var method_Add = type.GetMethod("Add");
Log(method_Add.Name);
foreach (object el in (IEnumerable)ctor_arg)
{
var pel = method_As.Invoke(null, new object[] { el });
method_Add.Invoke(collection, new object[] { pel });
}
return collection;
}
else throw new Exception($"can't create instance of {type.FullName}");
}
Dictionary<string, dynamic> output = new();
Type type;
string name;
object value;
for (; i < text.Length; i++)
{
type = ReadType();
name = ReadName();
bool _ = false;
value = ReadValue(ref _);
output.Add(name, CreateInstance(type, value));
}
return output;
}
public override void Append(ICollection<KeyValuePair<string, dynamic>> anotherDtsod) => base.Append(anotherDtsod);//UpdateLazy();
public override void Add(string key, dynamic value) => base.Add(key, (object)value);//UpdateLazy();
protected static string Serialize(IDictionary<string, dynamic> dtsod, ushort tabsCount = 0)
{
StringBuilder b = new();
foreach (KeyValuePair<string, dynamic> pair in dtsod)
{
}
void SerializeObject(string name, dynamic inst)
{
Type type = inst.GetType();
b.Append(TypeHelper.Instance.TypeToString(type)).Append(':')
.Append(name).Append('=');
if (TypeHelper.Instance.BaseTypeNames.ContainsKey(type))
{
if (type == typeof(decimal) || type == typeof(double) || type == typeof(float))
b.Append(inst.ToString(CultureInfo.InvariantCulture));
else b.Append(inst.ToString());
}
else if (typeof(IDictionary<string, dynamic>).IsAssignableFrom(type))
b.Append("\n{\n").Append(Serialize(inst, tabsCount++)).Append("};\n");
else if (type.CustomAttributes.Any(a => a.AttributeType == typeof(DtsodSerializableAttribute)))
{
var props = type.GetProperties().Where(p => p.CustomAttributes.Any(a => a.AttributeType == typeof(DtsodSerializableAttribute)));
foreach (var prop in props)
{
var propval = prop.GetValue(inst);
}
}
else throw new Exception($"can't serialize type {type.FullName}");
}
return b.ToString();
}
protected Lazy<string> serialized;
protected void UpdateLazy() => serialized = new(() => Serialize(this));
public override string ToString() => serialized.Value;
}

View File

@@ -1,114 +1,114 @@
namespace DTLib.Dtsod;
public class TypeHelper
{
static Lazy<TypeHelper> _inst = new();
public static TypeHelper Instance => _inst.Value;
internal readonly Dictionary<Type, Func<string, dynamic>> BaseTypeConstructors = new()
{
{ typeof(bool), (inp) => inp.ToBool() },
{ typeof(char), (inp) => inp.ToChar() },
{ typeof(string), (inp) => inp.ToString() },
{ typeof(byte), (inp) => inp.ToByte() },
{ typeof(sbyte), (inp) => inp.ToSByte() },
{ typeof(short), (inp) => inp.ToShort() },
{ typeof(ushort), (inp) => inp.ToUShort() },
{ typeof(int), (inp) => inp.ToInt() },
{ typeof(uint), (inp) => inp.ToUInt() },
{ typeof(long), (inp) => inp.ToLong() },
{ typeof(ulong), (inp) => inp.ToULong() },
{ typeof(float), (inp) => inp.ToFloat() },
{ typeof(double), (inp) => inp.ToDouble() },
{ typeof(decimal), (inp) => inp.ToDecimal() }
};
internal Dictionary<Type, string> BaseTypeNames = new()
{
{ typeof(bool), "bool" },
{ typeof(char), "char" },
{ typeof(string), "string" },
{ typeof(byte), "byte" },
{ typeof(sbyte), "sbyte" },
{ typeof(short), "short" },
{ typeof(ushort), "ushort" },
{ typeof(int), "int" },
{ typeof(uint), "uint" },
{ typeof(long), "long" },
{ typeof(ulong), "ulong" },
{ typeof(float), "float" },
{ typeof(double), "double" },
{ typeof(decimal), "decimal" }
};
private DtsodDict<string, Type> ST_extensions = new()
{
{ "List<bool>", typeof(List<bool>) },
{ "List<char>", typeof(List<char>) },
{ "List<string>", typeof(List<string>) },
{ "List<byte>", typeof(List<byte>) },
{ "List<sbyte>", typeof(List<sbyte>) },
{ "List<short>", typeof(List<short>) },
{ "List<ushort>", typeof(List<ushort>) },
{ "List<int>", typeof(List<int>) },
{ "List<uint>", typeof(List<uint>) },
{ "List<long>", typeof(List<long>) },
{ "List<ulong>", typeof(List<ulong>) },
{ "List<float>", typeof(List<float>) },
{ "List<double>", typeof(List<double>) },
{ "List<decimal>", typeof(List<decimal>) },
};
private DtsodDict<Type, string> TS_extensions = new()
{
{ typeof(List<bool>), "List<bool>" },
{ typeof(List<char>), "List<char>" },
{ typeof(List<string>), "List<string>" },
{ typeof(List<byte>), "List<byte>" },
{ typeof(List<sbyte>), "List<sbyte>" },
{ typeof(List<short>), "List<short>" },
{ typeof(List<ushort>), "List<ushort>" },
{ typeof(List<int>), "List<int>" },
{ typeof(List<uint>), "List<uint>" },
{ typeof(List<long>), "List<long>" },
{ typeof(List<ulong>), "List<ulong>" },
{ typeof(List<float>), "List<float>" },
{ typeof(List<double>), "List<double>" },
{ typeof(List<decimal>), "List<decimal>" },
};
public TypeHelper Extend(string name, Type type)
{
ST_extensions.Add(name, type);
TS_extensions.Add(type, name);
return this;
}
public string TypeToString(Type t) =>
BaseTypeNames.TryGetValue(t, out string name)
? name
: TS_extensions.TryGetValue(t, out name)
? name
: t.FullName;
public Type TypeFromString(string str) => str switch
{
"bool" => typeof(bool),
"char" => typeof(char),
"string" => typeof(string),
"byte" => typeof(byte),
"sbyte" => typeof(sbyte),
"short" => typeof(short),
"ushort" => typeof(ushort),
"int" => typeof(int),
"uint" => typeof(uint),
"long" => typeof(long),
"ulong" => typeof(ulong),
"float" => typeof(float),
"double" => typeof(double),
"decimal" => typeof(decimal),
_ => ST_extensions.TryGetValue(str, out var t)
? t
: Type.GetType(str, false)
?? throw new Exception($"DtsodV30.Deserialize.ParseType() error: type {str} doesn't exists")
};
static internal T As<T>(object inst) where T : class => inst as T;
}
namespace DTLib.Dtsod;
public class TypeHelper
{
static Lazy<TypeHelper> _inst = new();
public static TypeHelper Instance => _inst.Value;
internal readonly Dictionary<Type, Func<string, dynamic>> BaseTypeConstructors = new()
{
{ typeof(bool), (inp) => inp.ToBool() },
{ typeof(char), (inp) => inp.ToChar() },
{ typeof(string), (inp) => inp.ToString() },
{ typeof(byte), (inp) => inp.ToByte() },
{ typeof(sbyte), (inp) => inp.ToSByte() },
{ typeof(short), (inp) => inp.ToShort() },
{ typeof(ushort), (inp) => inp.ToUShort() },
{ typeof(int), (inp) => inp.ToInt() },
{ typeof(uint), (inp) => inp.ToUInt() },
{ typeof(long), (inp) => inp.ToLong() },
{ typeof(ulong), (inp) => inp.ToULong() },
{ typeof(float), (inp) => inp.ToFloat() },
{ typeof(double), (inp) => inp.ToDouble() },
{ typeof(decimal), (inp) => inp.ToDecimal() }
};
internal Dictionary<Type, string> BaseTypeNames = new()
{
{ typeof(bool), "bool" },
{ typeof(char), "char" },
{ typeof(string), "string" },
{ typeof(byte), "byte" },
{ typeof(sbyte), "sbyte" },
{ typeof(short), "short" },
{ typeof(ushort), "ushort" },
{ typeof(int), "int" },
{ typeof(uint), "uint" },
{ typeof(long), "long" },
{ typeof(ulong), "ulong" },
{ typeof(float), "float" },
{ typeof(double), "double" },
{ typeof(decimal), "decimal" }
};
private DtsodDict<string, Type> ST_extensions = new()
{
{ "List<bool>", typeof(List<bool>) },
{ "List<char>", typeof(List<char>) },
{ "List<string>", typeof(List<string>) },
{ "List<byte>", typeof(List<byte>) },
{ "List<sbyte>", typeof(List<sbyte>) },
{ "List<short>", typeof(List<short>) },
{ "List<ushort>", typeof(List<ushort>) },
{ "List<int>", typeof(List<int>) },
{ "List<uint>", typeof(List<uint>) },
{ "List<long>", typeof(List<long>) },
{ "List<ulong>", typeof(List<ulong>) },
{ "List<float>", typeof(List<float>) },
{ "List<double>", typeof(List<double>) },
{ "List<decimal>", typeof(List<decimal>) },
};
private DtsodDict<Type, string> TS_extensions = new()
{
{ typeof(List<bool>), "List<bool>" },
{ typeof(List<char>), "List<char>" },
{ typeof(List<string>), "List<string>" },
{ typeof(List<byte>), "List<byte>" },
{ typeof(List<sbyte>), "List<sbyte>" },
{ typeof(List<short>), "List<short>" },
{ typeof(List<ushort>), "List<ushort>" },
{ typeof(List<int>), "List<int>" },
{ typeof(List<uint>), "List<uint>" },
{ typeof(List<long>), "List<long>" },
{ typeof(List<ulong>), "List<ulong>" },
{ typeof(List<float>), "List<float>" },
{ typeof(List<double>), "List<double>" },
{ typeof(List<decimal>), "List<decimal>" },
};
public TypeHelper Extend(string name, Type type)
{
ST_extensions.Add(name, type);
TS_extensions.Add(type, name);
return this;
}
public string TypeToString(Type t) =>
BaseTypeNames.TryGetValue(t, out string name)
? name
: TS_extensions.TryGetValue(t, out name)
? name
: t.FullName;
public Type TypeFromString(string str) => str switch
{
"bool" => typeof(bool),
"char" => typeof(char),
"string" => typeof(string),
"byte" => typeof(byte),
"sbyte" => typeof(sbyte),
"short" => typeof(short),
"ushort" => typeof(ushort),
"int" => typeof(int),
"uint" => typeof(uint),
"long" => typeof(long),
"ulong" => typeof(ulong),
"float" => typeof(float),
"double" => typeof(double),
"decimal" => typeof(decimal),
_ => ST_extensions.TryGetValue(str, out var t)
? t
: Type.GetType(str, false)
?? throw new Exception($"DtsodV30.Deserialize.ParseType() error: type {str} doesn't exists")
};
static internal T As<T>(object inst) where T : class => inst as T;
}

View File

@@ -1,8 +1,8 @@
namespace DTLib;
// по идее это нужно, чтоб делать так: SomeEvent?.Invoke().Wait()
public delegate Task EventHandlerAsyncDelegate();
public delegate Task EventHandlerAsyncDelegate<T>(T e);
public delegate Task EventHandlerAsyncDelegate<T0, T1>(T0 e0, T1 e1);
public delegate Task EventHandlerAsyncDelegate<T0, T1, T2>(T0 e0, T1 e1, T2 e2);
public delegate Task EventHandlerAsyncDelegate<T0, T1, T2, T3>(T0 e0, T1 e1, T2 e2, T3 e3);
namespace DTLib;
// по идее это нужно, чтоб делать так: SomeEvent?.Invoke().Wait()
public delegate Task EventHandlerAsyncDelegate();
public delegate Task EventHandlerAsyncDelegate<T>(T e);
public delegate Task EventHandlerAsyncDelegate<T0, T1>(T0 e0, T1 e1);
public delegate Task EventHandlerAsyncDelegate<T0, T1, T2>(T0 e0, T1 e1, T2 e2);
public delegate Task EventHandlerAsyncDelegate<T0, T1, T2, T3>(T0 e0, T1 e1, T2 e2, T3 e3);

View File

@@ -1,70 +1,70 @@
using System;
using System.Collections.Generic;
using System.Threading;
namespace DTLib
{
public class CompressedArray
{
public class Array1D<T> where T : IComparable<T>
{
byte[] Description;
T[] Memory;
public Array1D() { }
public Array1D(T[] sourceArray) => CompressArray(sourceArray);
public void CompressArray(T[] sourceArray)
{
var listMem = new List<T>();
var listDesc = new List<byte>();
T prevElement = sourceArray[0];
listMem.Add(sourceArray[0]);
listDesc.Add(1);
byte repeats = 1;
for (int i = 1; i < sourceArray.Length; i++)
{
if (prevElement.CompareTo(sourceArray[i]) == 0)
repeats++;
else
{
listMem.Add(sourceArray[i]);
listDesc.Add(1);
if (repeats > 1)
{
listDesc[listDesc.Count - 2] = repeats;
repeats = 1;
}
}
prevElement = sourceArray[i];
}
Memory = listMem.ToArray();
Description = listDesc.ToArray();
ColoredConsole.Write("b", "listMem.Count: ", "c", listMem.Count.ToString(), "b", " listDesc.Count: ", "c", listDesc.Count + "\n");
for (short i = 0; i < listDesc.Count; i++)
{
ColoredConsole.Write("y", $"{Description[i]}:{Memory[i]}\n");
}
}
// блокирует обращение к памяти из нескольких потоков
Mutex storageUsing = new();
// возвращает элемент по индексу так, как если бы шло обращение к обычном массиву
public T GetElement(int index)
{
storageUsing.WaitOne();
T output = default;
int sum = 0;
for (int i = 0; i < Description.Length; i++)
{
if (sum < index)
sum += Description[i];
else output = sum == index ? Memory[i] : Memory[i - 1];
}
storageUsing.ReleaseMutex();
return output;
}
}
}
}
using System;
using System.Collections.Generic;
using System.Threading;
namespace DTLib
{
public class CompressedArray
{
public class Array1D<T> where T : IComparable<T>
{
byte[] Description;
T[] Memory;
public Array1D() { }
public Array1D(T[] sourceArray) => CompressArray(sourceArray);
public void CompressArray(T[] sourceArray)
{
var listMem = new List<T>();
var listDesc = new List<byte>();
T prevElement = sourceArray[0];
listMem.Add(sourceArray[0]);
listDesc.Add(1);
byte repeats = 1;
for (int i = 1; i < sourceArray.Length; i++)
{
if (prevElement.CompareTo(sourceArray[i]) == 0)
repeats++;
else
{
listMem.Add(sourceArray[i]);
listDesc.Add(1);
if (repeats > 1)
{
listDesc[listDesc.Count - 2] = repeats;
repeats = 1;
}
}
prevElement = sourceArray[i];
}
Memory = listMem.ToArray();
Description = listDesc.ToArray();
ColoredConsole.Write("b", "listMem.Count: ", "c", listMem.Count.ToString(), "b", " listDesc.Count: ", "c", listDesc.Count + "\n");
for (short i = 0; i < listDesc.Count; i++)
{
ColoredConsole.Write("y", $"{Description[i]}:{Memory[i]}\n");
}
}
// блокирует обращение к памяти из нескольких потоков
Mutex storageUsing = new();
// возвращает элемент по индексу так, как если бы шло обращение к обычном массиву
public T GetElement(int index)
{
storageUsing.WaitOne();
T output = default;
int sum = 0;
for (int i = 0; i < Description.Length; i++)
{
if (sum < index)
sum += Description[i];
else output = sum == index ? Memory[i] : Memory[i - 1];
}
storageUsing.ReleaseMutex();
return output;
}
}
}
}

View File

@@ -1,69 +1,69 @@
using DTLib.Dtsod;
using DTLib.Filesystem;
using System.Collections.Generic;
using static DTLib.PublicLog;
namespace DTLib.ConsoleGUI
{
public class Container : List<IDrawable>, IDrawable
{
public (ushort x, ushort y) AnchorPoint { get; set; }
public ushort Width { get; set; }
public ushort Height { get; set; }
public char[] Textmap { get; private set; }
public char[] Colormap { get; private set; }
public string Name { get; private set; }
public Container(string name, string layout_file)
{
Name=name;
ParseLayoutFile(layout_file);
}
void ParseLayoutFile(string layout_file)
{
DtsodV22 layout = new(File.ReadAllText(layout_file));
AnchorPoint=(layout[Name]["anchor"][0], layout[Name]["anchor"][1]);
Width=layout[Name]["width"];
Height=layout[Name]["height"];
foreach(string element_name in layout[Name]["children"].Keys)
{
switch(layout[Name]["children"][element_name]["type"])
{
case "label":
Add(new Label(element_name,
layout[Name]["children"][element_name]["resdir"]+$"\\{element_name}.textmap",
layout[Name]["children"][element_name]["resdir"]+$"\\{element_name}.colormap")
{
AnchorPoint=(layout[Name]["children"][element_name]["anchor"][0],
layout[Name]["children"][element_name]["anchor"][1])
});
break;
}
}
}
public void GenTextmap()
{
Textmap=new char[Width*Height];
for(int i = 0; i<Textmap.Length; i++)
Textmap[i]=' ';
foreach(IDrawable element in this)
{
element.GenTextmap();
Log("m", $"Length: {element.Textmap.Length} calculated: {element.Width*element.Height}\n");
for(ushort y = 0; y<element.Height; y++)
for(ushort x = 0; x<element.Width; x++)
{
//Textmap[(element.AnchorPoint.y + y) * Width + element.AnchorPoint.x + x] = element.Textmap[y * element.Width + x];
Textmap[(y)*Width+x]=element.Textmap[y*element.Width+x];
}
}
}
public void GenColormap()
{
}
}
}
using DTLib.Dtsod;
using DTLib.Filesystem;
using System.Collections.Generic;
using static DTLib.PublicLog;
namespace DTLib.ConsoleGUI
{
public class Container : List<IDrawable>, IDrawable
{
public (ushort x, ushort y) AnchorPoint { get; set; }
public ushort Width { get; set; }
public ushort Height { get; set; }
public char[] Textmap { get; private set; }
public char[] Colormap { get; private set; }
public string Name { get; private set; }
public Container(string name, string layout_file)
{
Name=name;
ParseLayoutFile(layout_file);
}
void ParseLayoutFile(string layout_file)
{
DtsodV22 layout = new(File.ReadAllText(layout_file));
AnchorPoint=(layout[Name]["anchor"][0], layout[Name]["anchor"][1]);
Width=layout[Name]["width"];
Height=layout[Name]["height"];
foreach(string element_name in layout[Name]["children"].Keys)
{
switch(layout[Name]["children"][element_name]["type"])
{
case "label":
Add(new Label(element_name,
layout[Name]["children"][element_name]["resdir"]+$"\\{element_name}.textmap",
layout[Name]["children"][element_name]["resdir"]+$"\\{element_name}.colormap")
{
AnchorPoint=(layout[Name]["children"][element_name]["anchor"][0],
layout[Name]["children"][element_name]["anchor"][1])
});
break;
}
}
}
public void GenTextmap()
{
Textmap=new char[Width*Height];
for(int i = 0; i<Textmap.Length; i++)
Textmap[i]=' ';
foreach(IDrawable element in this)
{
element.GenTextmap();
Log("m", $"Length: {element.Textmap.Length} calculated: {element.Width*element.Height}\n");
for(ushort y = 0; y<element.Height; y++)
for(ushort x = 0; x<element.Width; x++)
{
//Textmap[(element.AnchorPoint.y + y) * Width + element.AnchorPoint.x + x] = element.Textmap[y * element.Width + x];
Textmap[(y)*Width+x]=element.Textmap[y*element.Width+x];
}
}
}
public void GenColormap()
{
}
}
}

View File

@@ -1,16 +1,16 @@
namespace DTLib.ConsoleGUI
{
public class Control : Label
{
public new void GenColormap()
{
}
public new void GenTextmap()
{
}
}
}
namespace DTLib.ConsoleGUI
{
public class Control : Label
{
public new void GenColormap()
{
}
public new void GenTextmap()
{
}
}
}

View File

@@ -1,17 +1,17 @@
namespace DTLib.ConsoleGUI
{
public interface IDrawable
{
public (ushort x, ushort y) AnchorPoint { get; set; }
public ushort Width { get; }
public ushort Height { get; }
public char[] Textmap { get; }
public char[] Colormap { get; }
public string Name { get; }
public void GenTextmap();
public void GenColormap();
}
}
namespace DTLib.ConsoleGUI
{
public interface IDrawable
{
public (ushort x, ushort y) AnchorPoint { get; set; }
public ushort Width { get; }
public ushort Height { get; }
public char[] Textmap { get; }
public char[] Colormap { get; }
public string Name { get; }
public void GenTextmap();
public void GenColormap();
}
}

View File

@@ -1,35 +1,35 @@
using DTLib.Filesystem;
namespace DTLib.ConsoleGUI
{
public class Label : IDrawable
{
public (ushort x, ushort y) AnchorPoint { get; set; } = (0, 0);
public ushort Width { get; private set; }
public ushort Height { get; private set; }
public char[] Textmap { get; private set; }
public char[] Colormap { get; private set; }
public string TextmapFile { get; set; }
public string ColormapFile { get; set; }
public string Name { get; init; }
public Label() { }
public Label(string name, string textmapFile, string colormapFile)
{
TextmapFile=textmapFile;
ColormapFile=colormapFile;
Name=name;
}
public void GenColormap() => Colormap=File.ReadAllText(ColormapFile).ToCharArray();
public void GenTextmap()
{
Textmap=File.ReadAllText(TextmapFile).ToCharArray();
Width=12;
Height=3;
}
}
}
using DTLib.Filesystem;
namespace DTLib.ConsoleGUI
{
public class Label : IDrawable
{
public (ushort x, ushort y) AnchorPoint { get; set; } = (0, 0);
public ushort Width { get; private set; }
public ushort Height { get; private set; }
public char[] Textmap { get; private set; }
public char[] Colormap { get; private set; }
public string TextmapFile { get; set; }
public string ColormapFile { get; set; }
public string Name { get; init; }
public Label() { }
public Label(string name, string textmapFile, string colormapFile)
{
TextmapFile=textmapFile;
ColormapFile=colormapFile;
Name=name;
}
public void GenColormap() => Colormap=File.ReadAllText(ColormapFile).ToCharArray();
public void GenTextmap()
{
Textmap=File.ReadAllText(TextmapFile).ToCharArray();
Width=12;
Height=3;
}
}
}

View File

@@ -1,36 +1,36 @@
using DTLib.Filesystem;
using System;
using System.Text;
namespace DTLib.ConsoleGUI
{
//
// создание gui из текста в консоли
//
public class Window : Container
{
public Window(string layout_file) : base("window", layout_file)
{
Console.Clear();
Console.SetWindowSize(Width+1, Height+1);
Console.SetBufferSize(Width+1, Height+1);
Console.OutputEncoding=Encoding.Unicode;
Console.InputEncoding=Encoding.Unicode;
Console.CursorVisible=false;
}
// выводит все символы
public void RenderFile(string file)
{
Console.Clear();
Console.WriteLine(File.ReadAllText(file));
}
public void Render()
{
GenTextmap();
Console.WriteLine(SimpleConverter.MergeToString(Textmap));
}
}
}
using DTLib.Filesystem;
using System;
using System.Text;
namespace DTLib.ConsoleGUI
{
//
// создание gui из текста в консоли
//
public class Window : Container
{
public Window(string layout_file) : base("window", layout_file)
{
Console.Clear();
Console.SetWindowSize(Width+1, Height+1);
Console.SetBufferSize(Width+1, Height+1);
Console.OutputEncoding=Encoding.Unicode;
Console.InputEncoding=Encoding.Unicode;
Console.CursorVisible=false;
}
// выводит все символы
public void RenderFile(string file)
{
Console.Clear();
Console.WriteLine(File.ReadAllText(file));
}
public void Render()
{
GenTextmap();
Console.WriteLine(SimpleConverter.MergeToString(Textmap));
}
}
}

View File

@@ -1,186 +1,186 @@
using DTLib.Filesystem;
using System;
using System.Collections.Generic;
using System.Text;
namespace DTLib.ConsoleGUI
{
//
// создание gui из текста в консоли
//
public class WindowOld
{
public int WindowWidth { get; private set; }
public int WindowHeight { get; private set; }
public char[,] Text;
public char[,] nowText;
public char[,] TextColors;
public char[,] nowTextColors;
public Container WindowContainer;
public WindowOld(int windowWidth, int windowHeight)
{
WindowWidth=windowWidth;
WindowHeight=windowHeight;
Text=new char[windowWidth, windowHeight];
TextColors=new char[windowWidth, windowHeight];
nowText=TextColors;
nowTextColors=new char[windowWidth, windowHeight];
Console.WindowWidth=WindowWidth+1;
Console.WindowHeight=WindowHeight+1;
Console.BufferWidth=WindowWidth+1;
Console.BufferHeight=WindowHeight+1;
Console.OutputEncoding=Encoding.Unicode;
Console.InputEncoding=Encoding.Unicode;
Console.CursorVisible=false;
// заполнение массивов
for(sbyte y = 0; y<WindowHeight; y++)
{
for(sbyte x = 0; x<WindowWidth; x++)
{
Text[x, y]=' ';
TextColors[x, y]='w';
}
}
nowText=TextColors;
}
/*// считывает массив символов из файла
// ширина и высота текста должны быть как указанные при инициализации объекта этого класса
public void ReadFromFile(string path)
{
var r = new StreamReader(path, SimpleConverter.UTF8);
char[] s = new char[1];
// считывание текста
sbyte y = 0, x = 0;
r.Read(s, 0, 1);
while (!r.EndOfStream && y < WindowHeight)
{
if (x == WindowWidth)
{
r.Read(s, 0, 1);
x = 0;
y++;
}
else
{
Text[x, y] = s[0];
x++;
}
r.Read(s, 0, 1);
}
r.Read(s, 0, 1);
// считывание цвета
// если не находит цвет в файле, оставляет старый
if (s[0] == '\n')
{
r.Read(s, 0, 1);
y = 0;
x = 0;
while (!r.EndOfStream && y < WindowHeight)
{
if (x == WindowWidth)
{
r.Read(s, 0, 1);
x = 0;
y++;
}
else
{
TextColors[x, y] = s[0];
x++;
}
r.Read(s, 0, 1);
}
}
r.Close();
}*/
public void ResetCursor() => Console.SetCursorPosition(0, WindowHeight);
// заменяет символ выведенный, использовать после ShowAll()
public void ChangeChar(sbyte x, sbyte y, char ch)
{
Text[x, y]=ch;
nowText[x, y]=ch;
Console.SetCursorPosition(x, y);
ColoredConsole.Write(TextColors[x, y].ToString(), ch.ToString());
}
public void ChangeColor(sbyte x, sbyte y, char color)
{
TextColors[x, y]=color;
nowTextColors[x, y]=color;
Console.SetCursorPosition(x, y);
ColoredConsole.Write(color.ToString(), Text[x, y].ToString());
}
public void ChangeCharAndColor(sbyte x, sbyte y, char color, char ch)
{
Text[x, y]=ch;
nowText[x, y]=ch;
TextColors[x, y]=color;
nowTextColors[x, y]=color;
Console.SetCursorPosition(x, y);
ColoredConsole.Write(color.ToString(), ch.ToString());
}
public void ChangeLine(sbyte x, sbyte y, char color, string line)
{
Console.SetCursorPosition(x, y);
for(sbyte i = 0; i<line.Length; i++)
{
Text[x+i, y]=line[i];
nowText[x+i, y]=line[i];
TextColors[x+i, y]=color;
nowTextColors[x+i, y]=color;
}
ColoredConsole.Write(color.ToString(), line);
}
// выводит все символы
public void ShowAll()
{
var l = new List<string>();
for(sbyte y = 0; y<WindowHeight; y++)
{
for(sbyte x = 0; x<WindowWidth; x++)
{
l.Add(TextColors[x, y].ToString());
l.Add(Text[x, y].ToString());
nowText[x, y]=Text[x, y];
nowTextColors[x, y]=TextColors[x, y];
}
l.Add("w");
l.Add("\n");
}
ColoredConsole.Write(l.ToArray());
//Console.WriteLine();
}
public void UpdateAll()
{
for(sbyte y = 0; y<WindowHeight; y++)
{
for(sbyte x = 0; x<WindowWidth; x++)
{
Console.SetCursorPosition(x, y);
if(TextColors[x, y]!=nowTextColors[x, y]||Text[x, y]!=nowText[x, y])
{
ColoredConsole.Write(TextColors[x, y].ToString(), Text[x, y].ToString());
nowText[x, y]=Text[x, y];
nowTextColors[x, y]=TextColors[x, y];
}
}
Console.Write('\n');
}
}
public void RenderFile(string file)
{
Console.Clear();
Console.WriteLine(File.ReadAllText(file));
}
}
}
using DTLib.Filesystem;
using System;
using System.Collections.Generic;
using System.Text;
namespace DTLib.ConsoleGUI
{
//
// создание gui из текста в консоли
//
public class WindowOld
{
public int WindowWidth { get; private set; }
public int WindowHeight { get; private set; }
public char[,] Text;
public char[,] nowText;
public char[,] TextColors;
public char[,] nowTextColors;
public Container WindowContainer;
public WindowOld(int windowWidth, int windowHeight)
{
WindowWidth=windowWidth;
WindowHeight=windowHeight;
Text=new char[windowWidth, windowHeight];
TextColors=new char[windowWidth, windowHeight];
nowText=TextColors;
nowTextColors=new char[windowWidth, windowHeight];
Console.WindowWidth=WindowWidth+1;
Console.WindowHeight=WindowHeight+1;
Console.BufferWidth=WindowWidth+1;
Console.BufferHeight=WindowHeight+1;
Console.OutputEncoding=Encoding.Unicode;
Console.InputEncoding=Encoding.Unicode;
Console.CursorVisible=false;
// заполнение массивов
for(sbyte y = 0; y<WindowHeight; y++)
{
for(sbyte x = 0; x<WindowWidth; x++)
{
Text[x, y]=' ';
TextColors[x, y]='w';
}
}
nowText=TextColors;
}
/*// считывает массив символов из файла
// ширина и высота текста должны быть как указанные при инициализации объекта этого класса
public void ReadFromFile(string path)
{
var r = new StreamReader(path, SimpleConverter.UTF8);
char[] s = new char[1];
// считывание текста
sbyte y = 0, x = 0;
r.Read(s, 0, 1);
while (!r.EndOfStream && y < WindowHeight)
{
if (x == WindowWidth)
{
r.Read(s, 0, 1);
x = 0;
y++;
}
else
{
Text[x, y] = s[0];
x++;
}
r.Read(s, 0, 1);
}
r.Read(s, 0, 1);
// считывание цвета
// если не находит цвет в файле, оставляет старый
if (s[0] == '\n')
{
r.Read(s, 0, 1);
y = 0;
x = 0;
while (!r.EndOfStream && y < WindowHeight)
{
if (x == WindowWidth)
{
r.Read(s, 0, 1);
x = 0;
y++;
}
else
{
TextColors[x, y] = s[0];
x++;
}
r.Read(s, 0, 1);
}
}
r.Close();
}*/
public void ResetCursor() => Console.SetCursorPosition(0, WindowHeight);
// заменяет символ выведенный, использовать после ShowAll()
public void ChangeChar(sbyte x, sbyte y, char ch)
{
Text[x, y]=ch;
nowText[x, y]=ch;
Console.SetCursorPosition(x, y);
ColoredConsole.Write(TextColors[x, y].ToString(), ch.ToString());
}
public void ChangeColor(sbyte x, sbyte y, char color)
{
TextColors[x, y]=color;
nowTextColors[x, y]=color;
Console.SetCursorPosition(x, y);
ColoredConsole.Write(color.ToString(), Text[x, y].ToString());
}
public void ChangeCharAndColor(sbyte x, sbyte y, char color, char ch)
{
Text[x, y]=ch;
nowText[x, y]=ch;
TextColors[x, y]=color;
nowTextColors[x, y]=color;
Console.SetCursorPosition(x, y);
ColoredConsole.Write(color.ToString(), ch.ToString());
}
public void ChangeLine(sbyte x, sbyte y, char color, string line)
{
Console.SetCursorPosition(x, y);
for(sbyte i = 0; i<line.Length; i++)
{
Text[x+i, y]=line[i];
nowText[x+i, y]=line[i];
TextColors[x+i, y]=color;
nowTextColors[x+i, y]=color;
}
ColoredConsole.Write(color.ToString(), line);
}
// выводит все символы
public void ShowAll()
{
var l = new List<string>();
for(sbyte y = 0; y<WindowHeight; y++)
{
for(sbyte x = 0; x<WindowWidth; x++)
{
l.Add(TextColors[x, y].ToString());
l.Add(Text[x, y].ToString());
nowText[x, y]=Text[x, y];
nowTextColors[x, y]=TextColors[x, y];
}
l.Add("w");
l.Add("\n");
}
ColoredConsole.Write(l.ToArray());
//Console.WriteLine();
}
public void UpdateAll()
{
for(sbyte y = 0; y<WindowHeight; y++)
{
for(sbyte x = 0; x<WindowWidth; x++)
{
Console.SetCursorPosition(x, y);
if(TextColors[x, y]!=nowTextColors[x, y]||Text[x, y]!=nowText[x, y])
{
ColoredConsole.Write(TextColors[x, y].ToString(), Text[x, y].ToString());
nowText[x, y]=Text[x, y];
nowTextColors[x, y]=TextColors[x, y];
}
}
Console.Write('\n');
}
}
public void RenderFile(string file)
{
Console.Clear();
Console.WriteLine(File.ReadAllText(file));
}
}
}

View File

@@ -1,127 +1,127 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
namespace DTLib
{
public class MyDict<TKey, TVal>
{
object locker = new object();
List<TVal> values;
List<TKey> keys;
List<int> hashes;
int count;
public int Count
{
get
{
// lock (count)
lock (locker) return count;
}
}
public ReadOnlyCollection<TVal> Values
{
get
{
ReadOnlyCollectionBuilder<TVal> b;
lock (locker) b = new(values);
return b.ToReadOnlyCollection();
}
}
public ReadOnlyCollection<TKey> Keys
{
get
{
ReadOnlyCollectionBuilder<TKey> b;
lock (locker) b = new(keys);
return b.ToReadOnlyCollection();
}
}
public MyDict()
{
values = new();
keys = new();
hashes = new();
count = 0;
}
public MyDict(IList<TKey> _keys, IList<TVal> _values)
{
if (_keys.Count != _values.Count) throw new Exception("_keys.Count != _values.Count");
keys = (List<TKey>)_keys;
values = (List<TVal>)_values;
count = _keys.Count;
hashes = new();
for (int i = 0; i < count; i++)
hashes.Add(keys[i].GetHashCode());
}
public TVal this[TKey key]
{
get
{
lock (locker) return values[hashes.IndexOf(key.GetHashCode())];
}
set
{
lock (locker) values[hashes.IndexOf(key.GetHashCode())] = value;
}
}
public (TKey, TVal) GetByIndex(int index)
{
(TKey k, TVal v) output;
lock (locker)
{
output.k = keys[index];
output.v = values[index];
}
return output;
}
public void Add(TKey key, TVal val)
{
// lock (keys) lock (values) lock (count)
lock (locker)
{
keys.Add(key);
values.Add(val);
hashes.Add(key.GetHashCode());
count++;
}
}
public void Remove(TKey key)
{
var hash = key.GetHashCode();
lock (locker)
{
var num = hashes.IndexOf(hash);
keys.RemoveAt(num);
values.RemoveAt(num);
hashes.RemoveAt(num);
count--;
}
}
public void Clear()
{
lock (locker)
{
hashes.Clear();
keys.Clear();
values.Clear();
count = 0;
}
}
}
}
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
namespace DTLib
{
public class MyDict<TKey, TVal>
{
object locker = new object();
List<TVal> values;
List<TKey> keys;
List<int> hashes;
int count;
public int Count
{
get
{
// lock (count)
lock (locker) return count;
}
}
public ReadOnlyCollection<TVal> Values
{
get
{
ReadOnlyCollectionBuilder<TVal> b;
lock (locker) b = new(values);
return b.ToReadOnlyCollection();
}
}
public ReadOnlyCollection<TKey> Keys
{
get
{
ReadOnlyCollectionBuilder<TKey> b;
lock (locker) b = new(keys);
return b.ToReadOnlyCollection();
}
}
public MyDict()
{
values = new();
keys = new();
hashes = new();
count = 0;
}
public MyDict(IList<TKey> _keys, IList<TVal> _values)
{
if (_keys.Count != _values.Count) throw new Exception("_keys.Count != _values.Count");
keys = (List<TKey>)_keys;
values = (List<TVal>)_values;
count = _keys.Count;
hashes = new();
for (int i = 0; i < count; i++)
hashes.Add(keys[i].GetHashCode());
}
public TVal this[TKey key]
{
get
{
lock (locker) return values[hashes.IndexOf(key.GetHashCode())];
}
set
{
lock (locker) values[hashes.IndexOf(key.GetHashCode())] = value;
}
}
public (TKey, TVal) GetByIndex(int index)
{
(TKey k, TVal v) output;
lock (locker)
{
output.k = keys[index];
output.v = values[index];
}
return output;
}
public void Add(TKey key, TVal val)
{
// lock (keys) lock (values) lock (count)
lock (locker)
{
keys.Add(key);
values.Add(val);
hashes.Add(key.GetHashCode());
count++;
}
}
public void Remove(TKey key)
{
var hash = key.GetHashCode();
lock (locker)
{
var num = hashes.IndexOf(hash);
keys.RemoveAt(num);
values.RemoveAt(num);
hashes.RemoveAt(num);
count--;
}
}
public void Clear()
{
lock (locker)
{
hashes.Clear();
keys.Clear();
values.Clear();
count = 0;
}
}
}
}

View File

@@ -1,100 +1,100 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace DTLib.Reactive
{
public class ReactiveListener<T> : ReactiveProvider<T>
{
public ReactiveListener() { }
public ReactiveListener(ReactiveStream<T> stream) : base(stream) { }
public ReactiveListener(ICollection<ReactiveStream<T>> streams) : base(streams) { }
public event Action<ReactiveStream<T>, T> ElementAddedEvent;
void ElementAdded(ReactiveStream<T> stream, TimeSignedObject<T> e) => ElementAdded(stream, e.Value);
void ElementAdded(ReactiveStream<T> stream, T e) =>
Task.Run(() => ElementAddedEvent?.Invoke(stream, e));
public override void Join(ReactiveStream<T> stream)
{
base.Join(stream);
lock (Streams) stream.ElementAddedEvent += ElementAdded;
}
public override void Leave(ReactiveStream<T> stream)
{
base.Leave(stream);
lock (Streams) stream.ElementAddedEvent -= ElementAdded;
}
public T GetFirst()
{
if (Streams.Count == 0) throw new Exception("ReactiveListener is not connected to any streams");
TimeSignedObject<T> rezult = null;
foreach (ReactiveStream<T> stream in Streams)
if (stream.Count != 0)
{
TimeSignedObject<T> e = stream[0];
if (rezult is null) rezult = e;
else if (rezult.Time > e.Time) rezult = e;
}
return rezult.Value;
}
public T GetLast()
{
if (Streams.Count == 0) throw new Exception("ReactiveListener is not connected to any streams");
TimeSignedObject<T> rezult = null;
foreach (ReactiveStream<T> stream in Streams)
if (stream.Count != 0)
{
TimeSignedObject<T> e = stream[stream.Count - 1];
if (rezult is null) rezult = e;
else if (rezult.Time < e.Time) rezult = e;
}
return rezult.Value;
}
public T FindOne(Func<T, bool> condition)
{
if (Streams.Count == 0) throw new Exception("ReactiveListener is not connected to any streams");
foreach (ReactiveStream<T> stream in Streams)
foreach (TimeSignedObject<T> el in stream)
if (condition(el.Value))
return el.Value;
return default;
}
public TimeSignedObject<T> FindOne(Func<TimeSignedObject<T>, bool> condition)
{
if (Streams.Count == 0) throw new Exception("ReactiveListener is not connected to any streams");
foreach (ReactiveStream<T> stream in Streams)
foreach (TimeSignedObject<T> el in stream)
if (condition(el))
return el;
return default;
}
public List<T> FindAll(Func<T, bool> condition)
{
if (Streams.Count == 0) throw new Exception("ReactiveListener is not connected to any streams");
List<T> rezults = new();
foreach (ReactiveStream<T> stream in Streams)
foreach (TimeSignedObject<T> el in stream)
if (condition(el.Value))
rezults.Add(el.Value);
return rezults;
}
public List<TimeSignedObject<T>> FindAll(Func<TimeSignedObject<T>, bool> condition)
{
if (Streams.Count == 0) throw new Exception("ReactiveListener is not connected to any streams");
List<TimeSignedObject<T>> rezults = new();
foreach (ReactiveStream<T> stream in Streams)
foreach (TimeSignedObject<T> el in stream)
if (condition(el))
rezults.Add(el);
return rezults;
}
}
}
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace DTLib.Reactive
{
public class ReactiveListener<T> : ReactiveProvider<T>
{
public ReactiveListener() { }
public ReactiveListener(ReactiveStream<T> stream) : base(stream) { }
public ReactiveListener(ICollection<ReactiveStream<T>> streams) : base(streams) { }
public event Action<ReactiveStream<T>, T> ElementAddedEvent;
void ElementAdded(ReactiveStream<T> stream, TimeSignedObject<T> e) => ElementAdded(stream, e.Value);
void ElementAdded(ReactiveStream<T> stream, T e) =>
Task.Run(() => ElementAddedEvent?.Invoke(stream, e));
public override void Join(ReactiveStream<T> stream)
{
base.Join(stream);
lock (Streams) stream.ElementAddedEvent += ElementAdded;
}
public override void Leave(ReactiveStream<T> stream)
{
base.Leave(stream);
lock (Streams) stream.ElementAddedEvent -= ElementAdded;
}
public T GetFirst()
{
if (Streams.Count == 0) throw new Exception("ReactiveListener is not connected to any streams");
TimeSignedObject<T> rezult = null;
foreach (ReactiveStream<T> stream in Streams)
if (stream.Count != 0)
{
TimeSignedObject<T> e = stream[0];
if (rezult is null) rezult = e;
else if (rezult.Time > e.Time) rezult = e;
}
return rezult.Value;
}
public T GetLast()
{
if (Streams.Count == 0) throw new Exception("ReactiveListener is not connected to any streams");
TimeSignedObject<T> rezult = null;
foreach (ReactiveStream<T> stream in Streams)
if (stream.Count != 0)
{
TimeSignedObject<T> e = stream[stream.Count - 1];
if (rezult is null) rezult = e;
else if (rezult.Time < e.Time) rezult = e;
}
return rezult.Value;
}
public T FindOne(Func<T, bool> condition)
{
if (Streams.Count == 0) throw new Exception("ReactiveListener is not connected to any streams");
foreach (ReactiveStream<T> stream in Streams)
foreach (TimeSignedObject<T> el in stream)
if (condition(el.Value))
return el.Value;
return default;
}
public TimeSignedObject<T> FindOne(Func<TimeSignedObject<T>, bool> condition)
{
if (Streams.Count == 0) throw new Exception("ReactiveListener is not connected to any streams");
foreach (ReactiveStream<T> stream in Streams)
foreach (TimeSignedObject<T> el in stream)
if (condition(el))
return el;
return default;
}
public List<T> FindAll(Func<T, bool> condition)
{
if (Streams.Count == 0) throw new Exception("ReactiveListener is not connected to any streams");
List<T> rezults = new();
foreach (ReactiveStream<T> stream in Streams)
foreach (TimeSignedObject<T> el in stream)
if (condition(el.Value))
rezults.Add(el.Value);
return rezults;
}
public List<TimeSignedObject<T>> FindAll(Func<TimeSignedObject<T>, bool> condition)
{
if (Streams.Count == 0) throw new Exception("ReactiveListener is not connected to any streams");
List<TimeSignedObject<T>> rezults = new();
foreach (ReactiveStream<T> stream in Streams)
foreach (TimeSignedObject<T> el in stream)
if (condition(el))
rezults.Add(el);
return rezults;
}
}
}

View File

@@ -1,35 +1,35 @@
using System;
using System.Collections.Generic;
using System.Linq;
namespace DTLib.Reactive
{
public abstract class ReactiveProvider<T>
{
protected List<ReactiveStream<T>> Streams
{
get
{ lock (_streams) return _streams; }
set
{ lock (_streams) _streams = value; }
}
private List<ReactiveStream<T>> _streams = new();
public ReactiveProvider() { }
public ReactiveProvider(ReactiveStream<T> stream) => Streams.Add(stream);
public ReactiveProvider(ICollection<ReactiveStream<T>> streams) => Streams = streams.ToList();
public virtual void Join(ReactiveStream<T> stream)
{
if (IsConnetcedTo(stream)) throw new Exception("ReactiveListener is already connected to the stream");
Streams.Add(stream);
}
public virtual void Leave(ReactiveStream<T> stream)
{
if (!Streams.Remove(stream)) throw new Exception("ReactiveListener is not connected to the stream");
}
public bool IsConnetcedTo(ReactiveStream<T> stream) => Streams.Contains(stream);
}
}
using System;
using System.Collections.Generic;
using System.Linq;
namespace DTLib.Reactive
{
public abstract class ReactiveProvider<T>
{
protected List<ReactiveStream<T>> Streams
{
get
{ lock (_streams) return _streams; }
set
{ lock (_streams) _streams = value; }
}
private List<ReactiveStream<T>> _streams = new();
public ReactiveProvider() { }
public ReactiveProvider(ReactiveStream<T> stream) => Streams.Add(stream);
public ReactiveProvider(ICollection<ReactiveStream<T>> streams) => Streams = streams.ToList();
public virtual void Join(ReactiveStream<T> stream)
{
if (IsConnetcedTo(stream)) throw new Exception("ReactiveListener is already connected to the stream");
Streams.Add(stream);
}
public virtual void Leave(ReactiveStream<T> stream)
{
if (!Streams.Remove(stream)) throw new Exception("ReactiveListener is not connected to the stream");
}
public bool IsConnetcedTo(ReactiveStream<T> stream) => Streams.Contains(stream);
}
}

View File

@@ -1,18 +1,18 @@
using System.Collections.Generic;
namespace DTLib.Reactive
{
public class ReactiveSender<T> : ReactiveProvider<T>
{
public ReactiveSender() { }
public ReactiveSender(ReactiveStream<T> stream) : base(stream) { }
public ReactiveSender(ICollection<ReactiveStream<T>> streams) : base(streams) { }
public void Send(T e)
{
foreach (ReactiveStream<T> s in Streams)
s.Add(e);
}
}
}
using System.Collections.Generic;
namespace DTLib.Reactive
{
public class ReactiveSender<T> : ReactiveProvider<T>
{
public ReactiveSender() { }
public ReactiveSender(ReactiveStream<T> stream) : base(stream) { }
public ReactiveSender(ICollection<ReactiveStream<T>> streams) : base(streams) { }
public void Send(T e)
{
foreach (ReactiveStream<T> s in Streams)
s.Add(e);
}
}
}

View File

@@ -1,74 +1,74 @@
using System;
using System.Collections;
using System.Collections.Generic;
namespace DTLib.Reactive
{
public class ReactiveStream<T> : IEnumerable<TimeSignedObject<T>>, IList<TimeSignedObject<T>>
{
public ReactiveStream() { }
List<TimeSignedObject<T>> _storage = new();
List<TimeSignedObject<T>> Storage
{
get
{ lock (_storage) return _storage; }
}
public int Count => Storage.Count;
public TimeSignedObject<T> this[int index]
{
get => Storage[index];
set => throw new NotImplementedException();
}
public event Action<ReactiveStream<T>, TimeSignedObject<T>> ElementAddedEvent;
public void Add(TimeSignedObject<T> elem)
{
Storage.Add(elem);
ElementAddedEvent?.Invoke(this, elem);
}
public void Add(T elem) => Add(new TimeSignedObject<T>(elem));
public void Clear() => Storage.Clear();
public int IndexOf(TimeSignedObject<T> item) => Storage.IndexOf(item);
public bool Contains(TimeSignedObject<T> item) => Storage.Contains(item);
public IEnumerator<TimeSignedObject<T>> GetEnumerator() => new Enumerator(Storage);
IEnumerator IEnumerable.GetEnumerator() => new Enumerator(Storage);
struct Enumerator : IEnumerator<TimeSignedObject<T>>
{
public Enumerator(List<TimeSignedObject<T>> storage)
{
_storage = storage;
_index = storage.Count - 1;
}
List<TimeSignedObject<T>> _storage;
int _index;
public TimeSignedObject<T> Current => _storage[_index];
object IEnumerator.Current => Current;
public void Dispose() => _storage = null;
public bool MoveNext()
{
if (_index < 0)
return false;
_index--;
return true;
}
public void Reset() => _index = _storage.Count - 1;
}
bool ICollection<TimeSignedObject<T>>.IsReadOnly { get; } = false;
public void Insert(int index, TimeSignedObject<T> item) => throw new NotImplementedException();
public void RemoveAt(int index) => throw new NotImplementedException();
public void CopyTo(TimeSignedObject<T>[] array, int arrayIndex) => throw new NotImplementedException();
public bool Remove(TimeSignedObject<T> item) => throw new NotImplementedException();
}
using System;
using System.Collections;
using System.Collections.Generic;
namespace DTLib.Reactive
{
public class ReactiveStream<T> : IEnumerable<TimeSignedObject<T>>, IList<TimeSignedObject<T>>
{
public ReactiveStream() { }
List<TimeSignedObject<T>> _storage = new();
List<TimeSignedObject<T>> Storage
{
get
{ lock (_storage) return _storage; }
}
public int Count => Storage.Count;
public TimeSignedObject<T> this[int index]
{
get => Storage[index];
set => throw new NotImplementedException();
}
public event Action<ReactiveStream<T>, TimeSignedObject<T>> ElementAddedEvent;
public void Add(TimeSignedObject<T> elem)
{
Storage.Add(elem);
ElementAddedEvent?.Invoke(this, elem);
}
public void Add(T elem) => Add(new TimeSignedObject<T>(elem));
public void Clear() => Storage.Clear();
public int IndexOf(TimeSignedObject<T> item) => Storage.IndexOf(item);
public bool Contains(TimeSignedObject<T> item) => Storage.Contains(item);
public IEnumerator<TimeSignedObject<T>> GetEnumerator() => new Enumerator(Storage);
IEnumerator IEnumerable.GetEnumerator() => new Enumerator(Storage);
struct Enumerator : IEnumerator<TimeSignedObject<T>>
{
public Enumerator(List<TimeSignedObject<T>> storage)
{
_storage = storage;
_index = storage.Count - 1;
}
List<TimeSignedObject<T>> _storage;
int _index;
public TimeSignedObject<T> Current => _storage[_index];
object IEnumerator.Current => Current;
public void Dispose() => _storage = null;
public bool MoveNext()
{
if (_index < 0)
return false;
_index--;
return true;
}
public void Reset() => _index = _storage.Count - 1;
}
bool ICollection<TimeSignedObject<T>>.IsReadOnly { get; } = false;
public void Insert(int index, TimeSignedObject<T> item) => throw new NotImplementedException();
public void RemoveAt(int index) => throw new NotImplementedException();
public void CopyTo(TimeSignedObject<T>[] array, int arrayIndex) => throw new NotImplementedException();
public bool Remove(TimeSignedObject<T> item) => throw new NotImplementedException();
}
}

View File

@@ -1,16 +1,16 @@
using System;
namespace DTLib.Reactive
{
public class TimeSignedObject<T>
{
public T Value { get; init; }
public long Time { get; init; }
public TimeSignedObject(T value)
{
Value = value;
Time = DateTime.Now.Ticks;
}
}
}
using System;
namespace DTLib.Reactive
{
public class TimeSignedObject<T>
{
public T Value { get; init; }
public long Time { get; init; }
public TimeSignedObject(T value)
{
Value = value;
Time = DateTime.Now.Ticks;
}
}
}

View File

@@ -1,37 +1,37 @@
using System.Security.Cryptography;
namespace DTLib
{
//
// Вычисление псевдослучайного числа из множества параметров.
// Работает медленнее чем класс System.Random, но выдаёт более случайные значения
//
public class SecureRandom
{
private RNGCryptoServiceProvider crypt = new();
// получение массива случайных байтов
public byte[] GenBytes(uint length)
{
byte[] output = new byte[length];
crypt.GetNonZeroBytes(output);
return output;
}
// получение случайного числа от 0 до 2147483647
/*public int NextInt(uint from, int to)
{
int output = 0;
int rez = 0;
while (true)
{
rez = output * 10 + NextBytes(1)[0];
if (rez < to && rez > from)
{
output = rez;
return output;
}
}
}*/
}
}
using System.Security.Cryptography;
namespace DTLib
{
//
// Вычисление псевдослучайного числа из множества параметров.
// Работает медленнее чем класс System.Random, но выдаёт более случайные значения
//
public class SecureRandom
{
private RNGCryptoServiceProvider crypt = new();
// получение массива случайных байтов
public byte[] GenBytes(uint length)
{
byte[] output = new byte[length];
crypt.GetNonZeroBytes(output);
return output;
}
// получение случайного числа от 0 до 2147483647
/*public int NextInt(uint from, int to)
{
int output = 0;
int rez = 0;
while (true)
{
rez = output * 10 + NextBytes(1)[0];
if (rez < to && rez > from)
{
output = rez;
return output;
}
}
}*/
}
}

View File

@@ -1,16 +1,16 @@
using System.Diagnostics;
namespace DTLib.Experimental;
public static class Tester
{
public static void LogOperationTime(string op_name, int repeats, Action operation)
{
Stopwatch clock = new();
clock.Start();
for (int i = 0; i < repeats; i++)
operation();
clock.Stop();
LogNoTime("c",$"operation {op_name} took {clock.ElapsedTicks / repeats} ticks");
}
using System.Diagnostics;
namespace DTLib.Experimental;
public static class Tester
{
public static void LogOperationTime(string op_name, int repeats, Action operation)
{
Stopwatch clock = new();
clock.Start();
for (int i = 0; i < repeats; i++)
operation();
clock.Stop();
LogNoTime("c",$"operation {op_name} took {clock.ElapsedTicks / repeats} ticks");
}
}

View File

@@ -1,53 +1,53 @@
global using System;
global using System.Collections;
global using System.Collections.Generic;
global using System.Linq;
global using System.Text;
global using System.Threading.Tasks;
global using DTLib.Extensions;
global using DTLib.Filesystem;
global using static DTLib.PublicLog;
namespace DTLib.Extensions;
public static class BaseConverter
{
// сокращение конвертации
public static bool ToBool<T>(this T input) => Convert.ToBoolean(input);
public static char ToChar<T>(this T input) => Convert.ToChar(input);
public static byte ToByte<T>(this T input) => Convert.ToByte(input);
public static sbyte ToSByte<T>(this T input) => Convert.ToSByte(input);
public static short ToShort<T>(this T input) => Convert.ToInt16(input);
public static ushort ToUShort<T>(this T input) => Convert.ToUInt16(input);
public static int ToInt<T>(this T input) => Convert.ToInt32(input);
public static uint ToUInt<T>(this T input) => Convert.ToUInt32(input);
public static long ToLong<T>(this T input) => Convert.ToInt64(input);
public static ulong ToULong<T>(this T input) => Convert.ToUInt64(input);
public static float ToFloat(this string input) => float.Parse(input, System.Globalization.CultureInfo.InvariantCulture);
public static double ToDouble<T>(this T input) => Convert.ToDouble(input, System.Globalization.CultureInfo.InvariantCulture);
public static decimal ToDecimal<T>(this T input) => Convert.ToDecimal(input, System.Globalization.CultureInfo.InvariantCulture);
public static int ToInt(this byte[] bytes)
{
int output = 0;
for (ushort i = 0; i < bytes.Length; i++)
output = output * 256 + bytes[i];
return output;
}
public static byte[] ToBytes(this int num)
{
List<byte> output = new();
while (num != 0)
{
output.Add(ToByte(num % 256));
num = (num / 256).Truncate();
}
output.Reverse();
return output.ToArray();
}
// Math.Truncate принимает как decimal, так и doublе,
// из-за чего вызов метода так: Math.Truncate(10/3) выдаст ошибку "неоднозначный вызов"
public static int Truncate<T>(this T number) => Math.Truncate(number.ToDouble()).ToInt();
}
global using System;
global using System.Collections;
global using System.Collections.Generic;
global using System.Linq;
global using System.Text;
global using System.Threading.Tasks;
global using DTLib.Extensions;
global using DTLib.Filesystem;
global using static DTLib.PublicLog;
namespace DTLib.Extensions;
public static class BaseConverter
{
// сокращение конвертации
public static bool ToBool<T>(this T input) => Convert.ToBoolean(input);
public static char ToChar<T>(this T input) => Convert.ToChar(input);
public static byte ToByte<T>(this T input) => Convert.ToByte(input);
public static sbyte ToSByte<T>(this T input) => Convert.ToSByte(input);
public static short ToShort<T>(this T input) => Convert.ToInt16(input);
public static ushort ToUShort<T>(this T input) => Convert.ToUInt16(input);
public static int ToInt<T>(this T input) => Convert.ToInt32(input);
public static uint ToUInt<T>(this T input) => Convert.ToUInt32(input);
public static long ToLong<T>(this T input) => Convert.ToInt64(input);
public static ulong ToULong<T>(this T input) => Convert.ToUInt64(input);
public static float ToFloat(this string input) => float.Parse(input, System.Globalization.CultureInfo.InvariantCulture);
public static double ToDouble<T>(this T input) => Convert.ToDouble(input, System.Globalization.CultureInfo.InvariantCulture);
public static decimal ToDecimal<T>(this T input) => Convert.ToDecimal(input, System.Globalization.CultureInfo.InvariantCulture);
public static int ToInt(this byte[] bytes)
{
int output = 0;
for (ushort i = 0; i < bytes.Length; i++)
output = output * 256 + bytes[i];
return output;
}
public static byte[] ToBytes(this int num)
{
List<byte> output = new();
while (num != 0)
{
output.Add(ToByte(num % 256));
num = (num / 256).Truncate();
}
output.Reverse();
return output.ToArray();
}
// Math.Truncate принимает как decimal, так и doublе,
// из-за чего вызов метода так: Math.Truncate(10/3) выдаст ошибку "неоднозначный вызов"
public static int Truncate<T>(this T number) => Math.Truncate(number.ToDouble()).ToInt();
}

View File

@@ -1,38 +1,38 @@
namespace DTLib.Extensions;
public static class Collections
{
public static void ForEach<T>(this IEnumerable<T> en, Action<T> act)
{
foreach (T elem in en)
act(elem);
}
// массив в лист
public static List<T> ToList<T>(this T[] input)
{
var list = new List<T>();
list.AddRange(input);
return list;
}
// удаление нескольких элементов массива
public static T[] RemoveRange<T>(this T[] input, int startIndex, int count)
{
var list = input.ToList();
list.RemoveRange(startIndex, count);
return list.ToArray();
}
public static T[] RemoveRange<T>(this T[] input, int startIndex) => input.RemoveRange(startIndex, input.Length - startIndex);
// метод как у листов
public static bool Contains<T>(this T[] array, T value)
{
for (int i = 0; i < array.Length; i++)
if (array[i].Equals(value))
return true;
return false;
}
}
namespace DTLib.Extensions;
public static class Collections
{
public static void ForEach<T>(this IEnumerable<T> en, Action<T> act)
{
foreach (T elem in en)
act(elem);
}
// массив в лист
public static List<T> ToList<T>(this T[] input)
{
var list = new List<T>();
list.AddRange(input);
return list;
}
// удаление нескольких элементов массива
public static T[] RemoveRange<T>(this T[] input, int startIndex, int count)
{
var list = input.ToList();
list.RemoveRange(startIndex, count);
return list.ToArray();
}
public static T[] RemoveRange<T>(this T[] input, int startIndex) => input.RemoveRange(startIndex, input.Length - startIndex);
// метод как у листов
public static bool Contains<T>(this T[] array, T value)
{
for (int i = 0; i < array.Length; i++)
if (array[i].Equals(value))
return true;
return false;
}
}

View File

@@ -1,7 +1,7 @@
using System.ComponentModel;
// включает init и record из c# 9.0
namespace System.Runtime.CompilerServices;
[EditorBrowsable(EditorBrowsableState.Never)]
public class IsExternalInit { }
using System.ComponentModel;
// включает init и record из c# 9.0
namespace System.Runtime.CompilerServices;
[EditorBrowsable(EditorBrowsableState.Never)]
public class IsExternalInit { }

View File

@@ -1,21 +1,21 @@
namespace DTLib.Extensions;
public static class IfMethod
{
public static T If<T>(this T input, bool condition, Func<T, T> if_true, Func<T, T> if_false) =>
condition ? if_true(input) : if_false(input);
public static void If<T>(this T input, bool condition, Action<T> if_true, Action<T> if_false)
{
if (condition) if_true(input);
else if_false(input);
}
public static T If<T>(this T input, bool condition, Func<T, T> if_true) =>
condition ? if_true(input) : input;
public static void If<T>(this T input, bool condition, Action<T> if_true)
{
if (condition) if_true(input);
}
}
namespace DTLib.Extensions;
public static class IfMethod
{
public static T If<T>(this T input, bool condition, Func<T, T> if_true, Func<T, T> if_false) =>
condition ? if_true(input) : if_false(input);
public static void If<T>(this T input, bool condition, Action<T> if_true, Action<T> if_false)
{
if (condition) if_true(input);
else if_false(input);
}
public static T If<T>(this T input, bool condition, Func<T, T> if_true) =>
condition ? if_true(input) : input;
public static void If<T>(this T input, bool condition, Action<T> if_true)
{
if (condition) if_true(input);
}
}

View File

@@ -1,147 +1,147 @@
namespace DTLib.Extensions;
public static class StringConverter
{
public static Encoding UTF8 = new UTF8Encoding(false);
public static byte[] ToBytes(this string str) => UTF8.GetBytes(str);
public static string BytesToString(this byte[] bytes) => UTF8.GetString(bytes);
// хеш в виде массива байт в строку (хеш изначально не в кодировке UTF8, так что метод выше не работает с ним)
public static string HashToString(this byte[] hash)
{
var builder = new StringBuilder();
for (int i = 0; i < hash.Length; i++)
{
builder.Append(hash[i].ToString("x2"));
}
return builder.ToString();
}
// эти методы работают как надо, в отличии от стандартных, которые иногда дуркуют
public static bool StartsWith(this byte[] source, byte[] startsWith)
{
for (int i = 0; i < startsWith.Length; i++)
{
if (source[i] != startsWith[i])
return false;
}
return true;
}
public static bool EndsWith(this byte[] source, byte[] endsWith)
{
for (int i = 0; i < endsWith.Length; i++)
{
if (source[source.Length - endsWith.Length + i] != endsWith[i])
return false;
}
return true;
}
public static bool StartsWith(this string s, char c) => s[0] == c;
public static bool EndsWith(this string s, char c) => s[s.Length - 1] == c;
public static string MergeToString(params object[] parts)
{
StringBuilder builder = new();
for (int i = 0; i < parts.Length; i++)
builder.Append(parts[i].ToString());
return builder.ToString();
}
public static string MergeToString<T>(this IEnumerable<T> collection, string separator)
{
StringBuilder builder = new();
foreach (T elem in collection)
{
builder.Append(elem.ToString());
builder.Append(separator);
}
if (builder.Length == 0)
return "";
builder.Remove(builder.Length - separator.Length, separator.Length);
return builder.ToString();
}
public static string MergeToString<T>(this IEnumerable<T> collection)
{
StringBuilder builder = new();
foreach (T elem in collection)
builder.Append(elem.ToString());
return builder.ToString();
}
public static string Multiply(this string input, int howMany)
{
StringBuilder b = new();
for (int i = 0; i < howMany; i++)
b.Append(input);
return b.ToString();
}
public static string Multiply(this char input, int howMany)
{
StringBuilder b = new();
for (int i = 0; i < howMany; i++)
b.Append(input);
return b.ToString();
}
// делает что надо в отличии от String.Split(), который не убирает char c из начала
public static List<string> SplitToList(this string s, char c)
{
char[] ar = s.ToCharArray();
StringBuilder b = new();
List<string> o = new();
if (ar[0] != c)
b.Append(ar[0]);
for (int i = 1; i < ar.Length; i++)
if (ar[i] == c)
{
if (b.Length > 0)
o.Add(b.ToString());
b.Clear();
}
else b.Append(ar[i]);
if (b.Length > 0) o.Add(b.ToString());
return o;
}
// правильно реагирует на кавычки
public static List<string> SplitToList(this string s, char c, char quot)
{
List<string> output = new();
List<string> list = s.SplitToList(c);
bool q_open = false;
for (int i = 0; i < list.Count; i++)
{
string _s = list[i];
if (q_open)
{
if (_s.EndsWith(quot))
{
q_open = false;
_s = _s.Remove(_s.Length - 1);
}
output[output.Count - 1] += c + _s;
}
else if (_s.StartsWith(quot))
{
q_open = true;
_s = _s.Remove(0, 1);
}
output.Add(_s);
}
return output;
}
// разбивает на части указанной длины
public static List<string> SplitToList(this string s, int length)
{
List<string> parts = new();
int max = (s.Length / length).Truncate();
for (int i = 0; i < max; i++)
parts.Add(s.Substring(i * length, length));
if (max * length != s.Length) parts.Add(s.Substring(max * length, s.Length - max * length));
return parts;
}
}
namespace DTLib.Extensions;
public static class StringConverter
{
public static Encoding UTF8 = new UTF8Encoding(false);
public static byte[] ToBytes(this string str) => UTF8.GetBytes(str);
public static string BytesToString(this byte[] bytes) => UTF8.GetString(bytes);
// хеш в виде массива байт в строку (хеш изначально не в кодировке UTF8, так что метод выше не работает с ним)
public static string HashToString(this byte[] hash)
{
var builder = new StringBuilder();
for (int i = 0; i < hash.Length; i++)
{
builder.Append(hash[i].ToString("x2"));
}
return builder.ToString();
}
// эти методы работают как надо, в отличии от стандартных, которые иногда дуркуют
public static bool StartsWith(this byte[] source, byte[] startsWith)
{
for (int i = 0; i < startsWith.Length; i++)
{
if (source[i] != startsWith[i])
return false;
}
return true;
}
public static bool EndsWith(this byte[] source, byte[] endsWith)
{
for (int i = 0; i < endsWith.Length; i++)
{
if (source[source.Length - endsWith.Length + i] != endsWith[i])
return false;
}
return true;
}
public static bool StartsWith(this string s, char c) => s[0] == c;
public static bool EndsWith(this string s, char c) => s[s.Length - 1] == c;
public static string MergeToString(params object[] parts)
{
StringBuilder builder = new();
for (int i = 0; i < parts.Length; i++)
builder.Append(parts[i].ToString());
return builder.ToString();
}
public static string MergeToString<T>(this IEnumerable<T> collection, string separator)
{
StringBuilder builder = new();
foreach (T elem in collection)
{
builder.Append(elem.ToString());
builder.Append(separator);
}
if (builder.Length == 0)
return "";
builder.Remove(builder.Length - separator.Length, separator.Length);
return builder.ToString();
}
public static string MergeToString<T>(this IEnumerable<T> collection)
{
StringBuilder builder = new();
foreach (T elem in collection)
builder.Append(elem.ToString());
return builder.ToString();
}
public static string Multiply(this string input, int howMany)
{
StringBuilder b = new();
for (int i = 0; i < howMany; i++)
b.Append(input);
return b.ToString();
}
public static string Multiply(this char input, int howMany)
{
StringBuilder b = new();
for (int i = 0; i < howMany; i++)
b.Append(input);
return b.ToString();
}
// делает что надо в отличии от String.Split(), который не убирает char c из начала
public static List<string> SplitToList(this string s, char c)
{
char[] ar = s.ToCharArray();
StringBuilder b = new();
List<string> o = new();
if (ar[0] != c)
b.Append(ar[0]);
for (int i = 1; i < ar.Length; i++)
if (ar[i] == c)
{
if (b.Length > 0)
o.Add(b.ToString());
b.Clear();
}
else b.Append(ar[i]);
if (b.Length > 0) o.Add(b.ToString());
return o;
}
// правильно реагирует на кавычки
public static List<string> SplitToList(this string s, char c, char quot)
{
List<string> output = new();
List<string> list = s.SplitToList(c);
bool q_open = false;
for (int i = 0; i < list.Count; i++)
{
string _s = list[i];
if (q_open)
{
if (_s.EndsWith(quot))
{
q_open = false;
_s = _s.Remove(_s.Length - 1);
}
output[output.Count - 1] += c + _s;
}
else if (_s.StartsWith(quot))
{
q_open = true;
_s = _s.Remove(0, 1);
}
output.Add(_s);
}
return output;
}
// разбивает на части указанной длины
public static List<string> SplitToList(this string s, int length)
{
List<string> parts = new();
int max = (s.Length / length).Truncate();
for (int i = 0; i < max; i++)
parts.Add(s.Substring(i * length, length));
if (max * length != s.Length) parts.Add(s.Substring(max * length, s.Length - max * length));
return parts;
}
}

View File

@@ -1,120 +1,120 @@
namespace DTLib.Filesystem;
public static class Directory
{
public static bool Exists(string dir) => System.IO.Directory.Exists(dir);
// создает папку, если её не существует
public static void Create(string dir)
{
if (!Directory.Exists(dir))
{
// проверяет существование папки, в которой нужно создать dir
if (dir.Contains('\\') && !Directory.Exists(dir.Remove(dir.LastIndexOf('\\'))))
Create(dir.Remove(dir.LastIndexOf('\\')));
System.IO.Directory.CreateDirectory(dir);
}
}
// копирует все файлы и папки
public static void Copy(string source_dir, string new_dir, bool owerwrite = false)
{
Create(new_dir);
var subdirs = new List<string>();
List<string> files = GetAllFiles(source_dir, ref subdirs);
for (int i = 0; i < subdirs.Count; i++)
Create(subdirs[i].Replace(source_dir, new_dir));
for (int i = 0; i < files.Count; i++)
File.Copy(files[i], files[i].Replace(source_dir, new_dir), owerwrite);
}
// копирует все файлы и папки и выдаёт список конфликтующих файлов
public static void Copy(string source_dir, string new_dir, out List<string> conflicts, bool owerwrite = false)
{
conflicts = new List<string>();
var subdirs = new List<string>();
List<string> files = GetAllFiles(source_dir, ref subdirs);
Create(new_dir);
for (int i = 0; i < subdirs.Count; i++)
Create(subdirs[i].Replace(source_dir, new_dir));
for (int i = 0; i < files.Count; i++)
{
string newfile = files[i].Replace(source_dir, new_dir);
if (File.Exists(newfile))
conflicts.Add(newfile);
File.Copy(files[i], newfile, owerwrite);
}
}
// удаляет папку со всеми подпапками и файлами
public static void Delete(string dir)
{
var subdirs = new List<string>();
List<string> files = GetAllFiles(dir, ref subdirs);
for (int i = 0; i < files.Count; i++)
File.Delete(files[i]);
for (int i = subdirs.Count - 1; i >= 0; i--)
{
PublicLog.Log($"deleting {subdirs[i]}");
if (Directory.Exists(subdirs[i]))
System.IO.Directory.Delete(subdirs[i], true);
}
PublicLog.Log($"deleting {dir}");
if (Directory.Exists(dir))
System.IO.Directory.Delete(dir, true);
}
public static string[] GetFiles(string dir) => System.IO.Directory.GetFiles(dir);
public static string[] GetFiles(string dir, string searchPattern) => System.IO.Directory.GetFiles(dir, searchPattern);
public static string[] GetDirectories(string dir) => System.IO.Directory.GetDirectories(dir);
// выдает список всех файлов
public static List<string> GetAllFiles(string dir)
{
var all_files = new List<string>();
string[] cur_files = Directory.GetFiles(dir);
for (int i = 0; i < cur_files.Length; i++)
all_files.Add(cur_files[i]);
string[] cur_subdirs = Directory.GetDirectories(dir);
for (int i = 0; i < cur_subdirs.Length; i++)
all_files.AddRange(GetAllFiles(cur_subdirs[i]));
return all_files;
}
// выдает список всех файлов и подпапок в папке
public static List<string> GetAllFiles(string dir, ref List<string> all_subdirs)
{
var all_files = new List<string>();
string[] cur_files = Directory.GetFiles(dir);
for (int i = 0; i < cur_files.Length; i++)
all_files.Add(cur_files[i]);
string[] cur_subdirs = Directory.GetDirectories(dir);
for (int i = 0; i < cur_subdirs.Length; i++)
{
all_subdirs.Add(cur_subdirs[i]);
all_files.AddRange(GetAllFiles(cur_subdirs[i], ref all_subdirs));
}
return all_files;
}
public static string GetCurrent() => System.IO.Directory.GetCurrentDirectory();
public static void CreateSymlink(string sourceName, string symlinkName)
{
if (symlinkName.Contains("\\"))
Directory.Create(symlinkName.Remove(symlinkName.LastIndexOf('\\')));
if (!Symlink.CreateSymbolicLink(symlinkName, sourceName, Symlink.SymlinkTarget.Directory))
throw new InvalidOperationException($"some error occured while creating symlink\nDirectory.CreateSymlink({symlinkName}, {sourceName})");
}
// copies directory with symlinks instead of files
public static int SymCopy(string srcdir, string newdir)
{
List<string> files = Directory.GetAllFiles(srcdir);
if (!srcdir.EndsWith('\\')) srcdir += '\\';
if (!newdir.EndsWith('\\')) newdir += '\\';
int i = 0;
for (; i < files.Count; i++)
File.CreateSymlink(files[i], files[i].Replace(srcdir, newdir));
return i;
}
}
namespace DTLib.Filesystem;
public static class Directory
{
public static bool Exists(string dir) => System.IO.Directory.Exists(dir);
// создает папку, если её не существует
public static void Create(string dir)
{
if (!Directory.Exists(dir))
{
// проверяет существование папки, в которой нужно создать dir
if (dir.Contains('\\') && !Directory.Exists(dir.Remove(dir.LastIndexOf('\\'))))
Create(dir.Remove(dir.LastIndexOf('\\')));
System.IO.Directory.CreateDirectory(dir);
}
}
// копирует все файлы и папки
public static void Copy(string source_dir, string new_dir, bool owerwrite = false)
{
Create(new_dir);
var subdirs = new List<string>();
List<string> files = GetAllFiles(source_dir, ref subdirs);
for (int i = 0; i < subdirs.Count; i++)
Create(subdirs[i].Replace(source_dir, new_dir));
for (int i = 0; i < files.Count; i++)
File.Copy(files[i], files[i].Replace(source_dir, new_dir), owerwrite);
}
// копирует все файлы и папки и выдаёт список конфликтующих файлов
public static void Copy(string source_dir, string new_dir, out List<string> conflicts, bool owerwrite = false)
{
conflicts = new List<string>();
var subdirs = new List<string>();
List<string> files = GetAllFiles(source_dir, ref subdirs);
Create(new_dir);
for (int i = 0; i < subdirs.Count; i++)
Create(subdirs[i].Replace(source_dir, new_dir));
for (int i = 0; i < files.Count; i++)
{
string newfile = files[i].Replace(source_dir, new_dir);
if (File.Exists(newfile))
conflicts.Add(newfile);
File.Copy(files[i], newfile, owerwrite);
}
}
// удаляет папку со всеми подпапками и файлами
public static void Delete(string dir)
{
var subdirs = new List<string>();
List<string> files = GetAllFiles(dir, ref subdirs);
for (int i = 0; i < files.Count; i++)
File.Delete(files[i]);
for (int i = subdirs.Count - 1; i >= 0; i--)
{
PublicLog.Log($"deleting {subdirs[i]}");
if (Directory.Exists(subdirs[i]))
System.IO.Directory.Delete(subdirs[i], true);
}
PublicLog.Log($"deleting {dir}");
if (Directory.Exists(dir))
System.IO.Directory.Delete(dir, true);
}
public static string[] GetFiles(string dir) => System.IO.Directory.GetFiles(dir);
public static string[] GetFiles(string dir, string searchPattern) => System.IO.Directory.GetFiles(dir, searchPattern);
public static string[] GetDirectories(string dir) => System.IO.Directory.GetDirectories(dir);
// выдает список всех файлов
public static List<string> GetAllFiles(string dir)
{
var all_files = new List<string>();
string[] cur_files = Directory.GetFiles(dir);
for (int i = 0; i < cur_files.Length; i++)
all_files.Add(cur_files[i]);
string[] cur_subdirs = Directory.GetDirectories(dir);
for (int i = 0; i < cur_subdirs.Length; i++)
all_files.AddRange(GetAllFiles(cur_subdirs[i]));
return all_files;
}
// выдает список всех файлов и подпапок в папке
public static List<string> GetAllFiles(string dir, ref List<string> all_subdirs)
{
var all_files = new List<string>();
string[] cur_files = Directory.GetFiles(dir);
for (int i = 0; i < cur_files.Length; i++)
all_files.Add(cur_files[i]);
string[] cur_subdirs = Directory.GetDirectories(dir);
for (int i = 0; i < cur_subdirs.Length; i++)
{
all_subdirs.Add(cur_subdirs[i]);
all_files.AddRange(GetAllFiles(cur_subdirs[i], ref all_subdirs));
}
return all_files;
}
public static string GetCurrent() => System.IO.Directory.GetCurrentDirectory();
public static void CreateSymlink(string sourceName, string symlinkName)
{
if (symlinkName.Contains("\\"))
Directory.Create(symlinkName.Remove(symlinkName.LastIndexOf('\\')));
if (!Symlink.CreateSymbolicLink(symlinkName, sourceName, Symlink.SymlinkTarget.Directory))
throw new InvalidOperationException($"some error occured while creating symlink\nDirectory.CreateSymlink({symlinkName}, {sourceName})");
}
// copies directory with symlinks instead of files
public static int SymCopy(string srcdir, string newdir)
{
List<string> files = Directory.GetAllFiles(srcdir);
if (!srcdir.EndsWith('\\')) srcdir += '\\';
if (!newdir.EndsWith('\\')) newdir += '\\';
int i = 0;
for (; i < files.Count; i++)
File.CreateSymlink(files[i], files[i].Replace(srcdir, newdir));
return i;
}
}

View File

@@ -1,83 +1,83 @@
namespace DTLib.Filesystem;
public static class File
{
public static int GetSize(string file) => new System.IO.FileInfo(file).Length.ToInt();
public static bool Exists(string file) => System.IO.File.Exists(file);
// если файл не существует, создаёт файл, создаёт папки из его пути
public static void Create(string file, bool delete_old = false)
{
if (delete_old && File.Exists(file))
File.Delete(file);
if (!File.Exists(file))
{
if (file.Contains("\\"))
Directory.Create(file.Remove(file.LastIndexOf('\\')));
using System.IO.FileStream stream = System.IO.File.Create(file);
stream.Close();
}
}
public static void Copy(string srcPath, string newPath, bool replace = false)
{
if (!replace && Exists(newPath))
throw new Exception($"file <{newPath}> alredy exists");
Create(newPath);
WriteAllBytes(newPath, ReadAllBytes(srcPath));
}
public static void Delete(string file) => System.IO.File.Delete(file);
public static byte[] ReadAllBytes(string file)
{
using System.IO.FileStream stream = File.OpenRead(file);
int size = GetSize(file);
byte[] output = new byte[size];
stream.Read(output, 0, size);
stream.Close();
return output;
}
public static string ReadAllText(string file) => ReadAllBytes(file).BytesToString();
public static void WriteAllBytes(string file, byte[] content)
{
using System.IO.FileStream stream = File.OpenWrite(file);
stream.Write(content, 0, content.Length);
stream.Close();
}
public static void WriteAllText(string file, string content) => WriteAllBytes(file, content.ToBytes());
public static void AppendAllBytes(string file, byte[] content)
{
using System.IO.FileStream stream = File.OpenAppend(file);
stream.Write(content, 0, content.Length);
stream.Close();
}
public static void AppendAllText(string file, string content) => AppendAllBytes(file, content.ToBytes());
public static System.IO.FileStream OpenRead(string file) =>
Exists(file) ? System.IO.File.OpenRead(file) : throw new Exception($"file not found: <{file}>");
public static System.IO.FileStream OpenWrite(string file)
{
File.Create(file, true);
return System.IO.File.Open(file, System.IO.FileMode.OpenOrCreate);
}
public static System.IO.FileStream OpenAppend(string file)
{
File.Create(file);
return System.IO.File.Open(file, System.IO.FileMode.Append);
}
public static void CreateSymlink(string sourceName, string symlinkName)
{
if (symlinkName.Contains("\\"))
Directory.Create(symlinkName.Remove(symlinkName.LastIndexOf('\\')));
if (!Symlink.CreateSymbolicLink(symlinkName, sourceName, Symlink.SymlinkTarget.File))
throw new InvalidOperationException($"some error occured while creating symlink\nFile.CreateSymlink({symlinkName}, {sourceName})");
}
}
namespace DTLib.Filesystem;
public static class File
{
public static int GetSize(string file) => new System.IO.FileInfo(file).Length.ToInt();
public static bool Exists(string file) => System.IO.File.Exists(file);
// если файл не существует, создаёт файл, создаёт папки из его пути
public static void Create(string file, bool delete_old = false)
{
if (delete_old && File.Exists(file))
File.Delete(file);
if (!File.Exists(file))
{
if (file.Contains("\\"))
Directory.Create(file.Remove(file.LastIndexOf('\\')));
using System.IO.FileStream stream = System.IO.File.Create(file);
stream.Close();
}
}
public static void Copy(string srcPath, string newPath, bool replace = false)
{
if (!replace && Exists(newPath))
throw new Exception($"file <{newPath}> alredy exists");
Create(newPath);
WriteAllBytes(newPath, ReadAllBytes(srcPath));
}
public static void Delete(string file) => System.IO.File.Delete(file);
public static byte[] ReadAllBytes(string file)
{
using System.IO.FileStream stream = File.OpenRead(file);
int size = GetSize(file);
byte[] output = new byte[size];
stream.Read(output, 0, size);
stream.Close();
return output;
}
public static string ReadAllText(string file) => ReadAllBytes(file).BytesToString();
public static void WriteAllBytes(string file, byte[] content)
{
using System.IO.FileStream stream = File.OpenWrite(file);
stream.Write(content, 0, content.Length);
stream.Close();
}
public static void WriteAllText(string file, string content) => WriteAllBytes(file, content.ToBytes());
public static void AppendAllBytes(string file, byte[] content)
{
using System.IO.FileStream stream = File.OpenAppend(file);
stream.Write(content, 0, content.Length);
stream.Close();
}
public static void AppendAllText(string file, string content) => AppendAllBytes(file, content.ToBytes());
public static System.IO.FileStream OpenRead(string file) =>
Exists(file) ? System.IO.File.OpenRead(file) : throw new Exception($"file not found: <{file}>");
public static System.IO.FileStream OpenWrite(string file)
{
File.Create(file, true);
return System.IO.File.Open(file, System.IO.FileMode.OpenOrCreate);
}
public static System.IO.FileStream OpenAppend(string file)
{
File.Create(file);
return System.IO.File.Open(file, System.IO.FileMode.Append);
}
public static void CreateSymlink(string sourceName, string symlinkName)
{
if (symlinkName.Contains("\\"))
Directory.Create(symlinkName.Remove(symlinkName.LastIndexOf('\\')));
if (!Symlink.CreateSymbolicLink(symlinkName, sourceName, Symlink.SymlinkTarget.File))
throw new InvalidOperationException($"some error occured while creating symlink\nFile.CreateSymlink({symlinkName}, {sourceName})");
}
}

View File

@@ -1,65 +1,65 @@
namespace DTLib.Filesystem;
//
// некоторые старые методы, которые хорошо бы вырезать
//
public static class OldFilework
{
// записывает текст в файл и закрывает файл
/*public static void LogToFile(string logfile, string msg)
{
lock (new object())
{
File.AppendAllText(logfile, msg);
}
}*/
// чтение параметров из конфига
public static string ReadFromConfig(string configfile, string key)
{
lock (new object())
{
key += ": ";
using var reader = new System.IO.StreamReader(configfile);
while (!reader.EndOfStream)
{
string st = reader.ReadLine();
if (st.StartsWith(key))
{
string value = "";
for (int i = key.Length; i < st.Length; i++)
{
if (st[i] == '#')
return value;
if (st[i] == '%')
{
bool stop = false;
string placeholder = "";
i++;
while (!stop)
{
if (st[i] == '%')
{
stop = true;
value += ReadFromConfig(configfile, placeholder);
}
else
{
placeholder += st[i];
i++;
}
}
}
else
value += st[i];
}
reader.Close();
//if (value == "") throw new System.Exception($"ReadFromConfig({configfile}, {key}) error: key not found");
return value;
}
}
reader.Close();
throw new Exception($"ReadFromConfig({configfile}, {key}) error: key not found");
}
}
}
namespace DTLib.Filesystem;
//
// некоторые старые методы, которые хорошо бы вырезать
//
public static class OldFilework
{
// записывает текст в файл и закрывает файл
/*public static void LogToFile(string logfile, string msg)
{
lock (new object())
{
File.AppendAllText(logfile, msg);
}
}*/
// чтение параметров из конфига
public static string ReadFromConfig(string configfile, string key)
{
lock (new object())
{
key += ": ";
using var reader = new System.IO.StreamReader(configfile);
while (!reader.EndOfStream)
{
string st = reader.ReadLine();
if (st.StartsWith(key))
{
string value = "";
for (int i = key.Length; i < st.Length; i++)
{
if (st[i] == '#')
return value;
if (st[i] == '%')
{
bool stop = false;
string placeholder = "";
i++;
while (!stop)
{
if (st[i] == '%')
{
stop = true;
value += ReadFromConfig(configfile, placeholder);
}
else
{
placeholder += st[i];
i++;
}
}
}
else
value += st[i];
}
reader.Close();
//if (value == "") throw new System.Exception($"ReadFromConfig({configfile}, {key}) error: key not found");
return value;
}
}
reader.Close();
throw new Exception($"ReadFromConfig({configfile}, {key}) error: key not found");
}
}
}

20
DTLib/Filesystem/Path.cs Normal file
View File

@@ -0,0 +1,20 @@
namespace DTLib.Filesystem;
static public class Path
{
public static string CorrectSeparator(string path)
{
if (System.IO.Path.PathSeparator == '\\')
{
if (path.Contains('/'))
path = path.Replace('/', '\\');
}
else if (System.IO.Path.PathSeparator == '/')
{
if (path.Contains('\\'))
path = path.Replace('\\', '/');
}
return path;
}
}

View File

@@ -1,15 +1,15 @@
using System.Runtime.InteropServices;
namespace DTLib.Filesystem;
internal class Symlink
{
[DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
internal static extern bool CreateSymbolicLink(string symlinkName, string sourceName, SymlinkTarget type);
internal enum SymlinkTarget
{
File,
Directory
}
}
using System.Runtime.InteropServices;
namespace DTLib.Filesystem;
internal class Symlink
{
[DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
internal static extern bool CreateSymbolicLink(string symlinkName, string sourceName, SymlinkTarget type);
internal enum SymlinkTarget
{
File,
Directory
}
}

View File

@@ -1,57 +1,57 @@
using System.Security.Cryptography;
namespace DTLib;
//
// хеширует массивы байтов алшоритмом SHA256 и файлы алгоримом XXHash32
//
public class Hasher
{
readonly HashAlgorithm sha256 = SHA256.Create();
readonly HashAlgorithm xxh32 = XXHash32.Create();
public Hasher() { }
// хеш массива
public byte[] Hash(byte[] input) => sha256.ComputeHash(input);
// хеш из двух массивов
public byte[] Hash(byte[] input, byte[] salt)
{
var rez = new List<byte>();
rez.AddRange(input);
rez.AddRange(salt);
return sha256.ComputeHash(rez.ToArray());
}
// хеш двух массивов зацикленный
public byte[] HashCycled(byte[] input, byte[] salt, ushort cycles)
{
for (uint i = 0; i < cycles; i++)
{
input = Hash(input, salt);
}
return input;
}
// хеш зацикленный
public byte[] HashCycled(byte[] input, ushort cycles)
{
for (uint i = 0; i < cycles; i++)
{
input = Hash(input);
}
return input;
}
// хеш файла
public byte[] HashFile(string filename)
{
using System.IO.FileStream fileStream = File.OpenRead(filename);
//var then = DateTime.Now.Hour * 3600 + DateTime.Now.Minute * 60 + DateTime.Now.Second;
byte[] hash = xxh32.ComputeHash(fileStream);
//var now = DateTime.Now.Hour * 3600 + DateTime.Now.Minute * 60 + DateTime.Now.Second;
//PublicLog.Log($"xxh32 hash: {hash.HashToString()} time: {now - then}");
fileStream.Close();
return hash;
}
}
using System.Security.Cryptography;
namespace DTLib;
//
// хеширует массивы байтов алшоритмом SHA256 и файлы алгоримом XXHash32
//
public class Hasher
{
readonly HashAlgorithm sha256 = SHA256.Create();
readonly HashAlgorithm xxh32 = XXHash32.Create();
public Hasher() { }
// хеш массива
public byte[] Hash(byte[] input) => sha256.ComputeHash(input);
// хеш из двух массивов
public byte[] Hash(byte[] input, byte[] salt)
{
var rez = new List<byte>();
rez.AddRange(input);
rez.AddRange(salt);
return sha256.ComputeHash(rez.ToArray());
}
// хеш двух массивов зацикленный
public byte[] HashCycled(byte[] input, byte[] salt, ushort cycles)
{
for (uint i = 0; i < cycles; i++)
{
input = Hash(input, salt);
}
return input;
}
// хеш зацикленный
public byte[] HashCycled(byte[] input, ushort cycles)
{
for (uint i = 0; i < cycles; i++)
{
input = Hash(input);
}
return input;
}
// хеш файла
public byte[] HashFile(string filename)
{
using System.IO.FileStream fileStream = File.OpenRead(filename);
//var then = DateTime.Now.Hour * 3600 + DateTime.Now.Minute * 60 + DateTime.Now.Second;
byte[] hash = xxh32.ComputeHash(fileStream);
//var now = DateTime.Now.Hour * 3600 + DateTime.Now.Minute * 60 + DateTime.Now.Second;
//PublicLog.Log($"xxh32 hash: {hash.HashToString()} time: {now - then}");
fileStream.Close();
return hash;
}
}

View File

@@ -1,34 +1,34 @@
namespace DTLib.Loggers;
// вывод лога в консоль и файл
public class AsyncLogger : BaseLogger
{
public AsyncLogger(string logfile) : base(logfile) { }
public AsyncLogger(string dir, string programName) : base(dir, programName) { }
readonly object consolelocker = new();
public override void Log(params string[] msg)
{
lock (statelocker) if (!IsEnabled) return;
// добавление даты
if (msg.Length == 1) msg[0] = "[" + DateTime.Now.ToString() + "]: " + msg[0];
else msg[1] = "[" + DateTime.Now.ToString() + "]: " + msg[1];
// перенос строки
msg[msg.Length - 1] += '\n';
// вывод в консоль
lock (consolelocker)
ColoredConsole.Write(msg);
// вывод в файл
if (msg.Length == 1)
lock (Logfile) File.AppendAllText(Logfile, msg[0]);
else
{
StringBuilder strB = new();
for (ushort i = 0; i < msg.Length; i++)
strB.Append(msg[++i]);
lock (Logfile) File.AppendAllText(Logfile, strB.ToString());
}
}
public void LogAsync(params string[] msg) => Task.Run(() => Log(msg));
}
namespace DTLib.Loggers;
// вывод лога в консоль и файл
public class AsyncLogger : BaseLogger
{
public AsyncLogger(string logfile) : base(logfile) { }
public AsyncLogger(string dir, string programName) : base(dir, programName) { }
readonly object consolelocker = new();
public override void Log(params string[] msg)
{
lock (statelocker) if (!IsEnabled) return;
// добавление даты
if (msg.Length == 1) msg[0] = "[" + DateTime.Now.ToString() + "]: " + msg[0];
else msg[1] = "[" + DateTime.Now.ToString() + "]: " + msg[1];
// перенос строки
msg[msg.Length - 1] += '\n';
// вывод в консоль
lock (consolelocker)
ColoredConsole.Write(msg);
// вывод в файл
if (msg.Length == 1)
lock (Logfile) File.AppendAllText(Logfile, msg[0]);
else
{
StringBuilder strB = new();
for (ushort i = 0; i < msg.Length; i++)
strB.Append(msg[++i]);
lock (Logfile) File.AppendAllText(Logfile, strB.ToString());
}
}
public void LogAsync(params string[] msg) => Task.Run(() => Log(msg));
}

View File

@@ -1,19 +1,19 @@
namespace DTLib.Loggers;
public abstract class BaseLogger
{
public string Logfile { get; init; }
public BaseLogger() { }
public BaseLogger(string logfile) => (Logfile, WriteToFile) = (logfile,true);
public BaseLogger(string dir, string programName)
: this($"{dir}\\{programName}_{DateTime.Now}.log".Replace(':', '-').Replace(' ', '_')) { }
public bool IsEnabled { get; private set; } = false;
public bool WriteToFile { get; private set; } = false;
protected readonly object statelocker = new();
public void Disable() { lock (statelocker) IsEnabled = false; }
public void Enable() { lock (statelocker) IsEnabled = true; }
public abstract void Log(params string[] msg);
}
namespace DTLib.Loggers;
public abstract class BaseLogger
{
public string Logfile { get; init; }
public BaseLogger() { }
public BaseLogger(string logfile) => (Logfile, WriteToFile) = (logfile,true);
public BaseLogger(string dir, string programName)
: this($"{dir}\\{programName}_{DateTime.Now}.log".Replace(':', '-').Replace(' ', '_')) { }
public bool IsEnabled { get; private set; } = false;
public bool WriteToFile { get; private set; } = false;
protected readonly object statelocker = new();
public void Disable() { lock (statelocker) IsEnabled = false; }
public void Enable() { lock (statelocker) IsEnabled = true; }
public abstract void Log(params string[] msg);
}

View File

@@ -1,37 +1,37 @@
namespace DTLib.Loggers;
// вывод лога в консоль и файл
public class DefaultLogger : BaseLogger
{
public DefaultLogger() => Logfile = "";
public DefaultLogger(string logfile) : base(logfile) { }
public DefaultLogger(string dir, string programName) : base(dir, programName) { }
public override void Log(params string[] msg)
{
lock (Logfile) if (!IsEnabled) return;
if (msg.Length == 1) msg[0] = "[" + DateTime.Now.ToString() + "]: " + msg[0];
else msg[1] = "[" + DateTime.Now.ToString() + "]: " + msg[1];
LogNoTime(msg);
}
public void LogNoTime(params string[] msg)
{
lock (Logfile) if (!IsEnabled) return;
msg[msg.Length - 1] += '\n';
ColoredConsole.Write(msg);
if (WriteToFile)
{
if (msg.Length == 1)
lock (Logfile) File.AppendAllText(Logfile, msg[0]);
else
{
StringBuilder strB = new();
for (ushort i = 0; i < msg.Length; i++)
strB.Append(msg[++i]);
lock (Logfile) File.AppendAllText(Logfile, strB.ToString());
}
}
}
}
namespace DTLib.Loggers;
// вывод лога в консоль и файл
public class DefaultLogger : BaseLogger
{
public DefaultLogger() => Logfile = "";
public DefaultLogger(string logfile) : base(logfile) { }
public DefaultLogger(string dir, string programName) : base(dir, programName) { }
public override void Log(params string[] msg)
{
lock (Logfile) if (!IsEnabled) return;
if (msg.Length == 1) msg[0] = "[" + DateTime.Now.ToString() + "]: " + msg[0];
else msg[1] = "[" + DateTime.Now.ToString() + "]: " + msg[1];
LogNoTime(msg);
}
public void LogNoTime(params string[] msg)
{
lock (Logfile) if (!IsEnabled) return;
msg[msg.Length - 1] += '\n';
ColoredConsole.Write(msg);
if (WriteToFile)
{
if (msg.Length == 1)
lock (Logfile) File.AppendAllText(Logfile, msg[0]);
else
{
StringBuilder strB = new();
for (ushort i = 0; i < msg.Length; i++)
strB.Append(msg[++i]);
lock (Logfile) File.AppendAllText(Logfile, strB.ToString());
}
}
}
}

View File

@@ -1,206 +1,206 @@
using System.Net.Sockets;
using DTLib.Dtsod;
namespace DTLib.Network;
//
// передача файлов по сети
//
public class FSP
{
Socket MainSocket { get; init; }
public static bool debug = false;
public FSP(Socket _mainSocket) => MainSocket = _mainSocket;
public uint BytesDownloaded = 0;
public uint BytesUploaded = 0;
public uint Filesize = 0;
// скачивает файл с помощью FSP протокола
public void DownloadFile(string filePath_server, string filePath_client)
{
lock (MainSocket)
{
Debug("b", $"requesting file download: {filePath_server}");
MainSocket.SendPackage("requesting file download".ToBytes());
MainSocket.SendPackage(filePath_server.ToBytes());
}
DownloadFile(filePath_client);
}
public void DownloadFile(string filePath_client)
{
using System.IO.Stream fileStream = File.OpenWrite(filePath_client);
Download_SharedCode(fileStream, true);
fileStream.Close();
Debug("g", $" downloaded {BytesDownloaded} of {Filesize} bytes");
}
public byte[] DownloadFileToMemory(string filePath_server)
{
lock (MainSocket)
{
Debug("b", $"requesting file download: {filePath_server}");
MainSocket.SendPackage("requesting file download".ToBytes());
MainSocket.SendPackage(filePath_server.ToBytes());
}
return DownloadFileToMemory();
}
public byte[] DownloadFileToMemory()
{
using var fileStream = new System.IO.MemoryStream();
Download_SharedCode(fileStream, false);
byte[] output = fileStream.GetBuffer();
fileStream.Close();
Debug("g", $" downloaded {BytesDownloaded} of {Filesize} bytes");
return output;
}
void Download_SharedCode(System.IO.Stream fileStream, bool requiresFlushing)
{
lock (MainSocket)
{
BytesDownloaded = 0;
Filesize = MainSocket.GetPackage().BytesToString().ToUInt();
MainSocket.SendPackage("ready".ToBytes());
int packagesCount = 0;
byte[] buffer = new byte[5120];
int fullPackagesCount = (Filesize / buffer.Length).Truncate();
// получение полных пакетов файла
for (byte n = 0; packagesCount < fullPackagesCount; packagesCount++)
{
buffer = MainSocket.GetPackage();
BytesDownloaded += (uint)buffer.Length;
fileStream.Write(buffer, 0, buffer.Length);
if (requiresFlushing)
{
if (n == 100)
{
fileStream.Flush();
n = 0;
}
else
n++;
}
}
// получение остатка
if ((Filesize - fileStream.Position) > 0)
{
MainSocket.SendPackage("remain request".ToBytes());
buffer = MainSocket.GetPackage();
BytesDownloaded += (uint)buffer.Length;
fileStream.Write(buffer, 0, buffer.Length);
}
}
if (requiresFlushing)
fileStream.Flush();
}
// отдаёт файл с помощью FSP протокола
public void UploadFile(string filePath)
{
BytesUploaded = 0;
Debug("b", $"uploading file {filePath}");
using System.IO.FileStream fileStream = File.OpenRead(filePath);
Filesize = File.GetSize(filePath).ToUInt();
lock (MainSocket)
{
MainSocket.SendPackage(Filesize.ToString().ToBytes());
MainSocket.GetAnswer("ready");
byte[] buffer = new byte[5120];
int packagesCount = 0;
int fullPackagesCount = (Filesize / buffer.Length).Truncate();
// отправка полных пакетов файла
for (; packagesCount < fullPackagesCount; packagesCount++)
{
fileStream.Read(buffer, 0, buffer.Length);
MainSocket.SendPackage(buffer);
BytesUploaded += (uint)buffer.Length;
}
// отправка остатка
if ((Filesize - fileStream.Position) > 0)
{
MainSocket.GetAnswer("remain request");
buffer = new byte[(Filesize - fileStream.Position).ToInt()];
fileStream.Read(buffer, 0, buffer.Length);
MainSocket.SendPackage(buffer);
BytesUploaded += (uint)buffer.Length;
}
}
fileStream.Close();
Debug("g", $" uploaded {BytesUploaded} of {Filesize} bytes");
}
public void DownloadByManifest(string dirOnServer, string dirOnClient, bool overwrite = false, bool delete_excess = false)
{
if (!dirOnClient.EndsWith("\\"))
dirOnClient += "\\";
if (!dirOnServer.EndsWith("\\"))
dirOnServer += "\\";
Debug("b", "downloading manifest <", "c", dirOnServer + "manifest.dtsod", "b", ">");
var manifest = new DtsodV22(DownloadFileToMemory(dirOnServer + "manifest.dtsod").BytesToString());
Debug("g", $"found {manifest.Values.Count} files in manifest");
var hasher = new Hasher();
foreach (string fileOnServer in manifest.Keys)
{
string fileOnClient = dirOnClient + fileOnServer;
Debug("b", "file <", "c", fileOnClient, "b", ">... ");
if (!File.Exists(fileOnClient))
{
DebugNoTime("y", "doesn't exist");
DownloadFile(dirOnServer + fileOnServer, fileOnClient);
}
else if (overwrite && hasher.HashFile(fileOnClient).HashToString() != manifest[fileOnServer])
{
DebugNoTime("y", "outdated");
DownloadFile(dirOnServer + fileOnServer, fileOnClient);
}
else
DebugNoTime("g", "without changes");
}
// удаление лишних файлов
if (delete_excess)
{
foreach (string file in Directory.GetAllFiles(dirOnClient))
{
if (!manifest.ContainsKey(file.Remove(0, dirOnClient.Length)))
{
Debug("y", $"deleting excess file: {file}");
File.Delete(file);
}
}
}
}
public static void CreateManifest(string dir)
{
if (!dir.EndsWith("\\"))
dir += "\\";
Log($"b", $"creating manifest of {dir}");
StringBuilder manifestBuilder = new();
Hasher hasher = new();
if (Directory.GetFiles(dir).Contains(dir + "manifest.dtsod"))
File.Delete(dir + "manifest.dtsod");
foreach (string _file in Directory.GetAllFiles(dir))
{
string file = _file.Remove(0, dir.Length);
manifestBuilder.Append(file);
manifestBuilder.Append(": \"");
byte[] hash = hasher.HashFile(dir + file);
manifestBuilder.Append(hash.HashToString());
manifestBuilder.Append("\";\n");
}
Debug($"g", $" manifest of {dir} created");
File.WriteAllText(dir + "manifest.dtsod", manifestBuilder.ToString());
}
static void Debug(params string[] msg)
{
if (debug) Log(msg);
}
static void DebugNoTime(params string[] msg)
{
if (debug) LogNoTime(msg);
}
}
using System.Net.Sockets;
using DTLib.Dtsod;
namespace DTLib.Network;
//
// передача файлов по сети
//
public class FSP
{
Socket MainSocket { get; init; }
public static bool debug = false;
public FSP(Socket _mainSocket) => MainSocket = _mainSocket;
public uint BytesDownloaded = 0;
public uint BytesUploaded = 0;
public uint Filesize = 0;
// скачивает файл с помощью FSP протокола
public void DownloadFile(string filePath_server, string filePath_client)
{
lock (MainSocket)
{
Debug("b", $"requesting file download: {filePath_server}");
MainSocket.SendPackage("requesting file download".ToBytes());
MainSocket.SendPackage(filePath_server.ToBytes());
}
DownloadFile(filePath_client);
}
public void DownloadFile(string filePath_client)
{
using System.IO.Stream fileStream = File.OpenWrite(filePath_client);
Download_SharedCode(fileStream, true);
fileStream.Close();
Debug("g", $" downloaded {BytesDownloaded} of {Filesize} bytes");
}
public byte[] DownloadFileToMemory(string filePath_server)
{
lock (MainSocket)
{
Debug("b", $"requesting file download: {filePath_server}");
MainSocket.SendPackage("requesting file download".ToBytes());
MainSocket.SendPackage(filePath_server.ToBytes());
}
return DownloadFileToMemory();
}
public byte[] DownloadFileToMemory()
{
using var fileStream = new System.IO.MemoryStream();
Download_SharedCode(fileStream, false);
byte[] output = fileStream.GetBuffer();
fileStream.Close();
Debug("g", $" downloaded {BytesDownloaded} of {Filesize} bytes");
return output;
}
void Download_SharedCode(System.IO.Stream fileStream, bool requiresFlushing)
{
lock (MainSocket)
{
BytesDownloaded = 0;
Filesize = MainSocket.GetPackage().BytesToString().ToUInt();
MainSocket.SendPackage("ready".ToBytes());
int packagesCount = 0;
byte[] buffer = new byte[5120];
int fullPackagesCount = (Filesize / buffer.Length).Truncate();
// получение полных пакетов файла
for (byte n = 0; packagesCount < fullPackagesCount; packagesCount++)
{
buffer = MainSocket.GetPackage();
BytesDownloaded += (uint)buffer.Length;
fileStream.Write(buffer, 0, buffer.Length);
if (requiresFlushing)
{
if (n == 100)
{
fileStream.Flush();
n = 0;
}
else
n++;
}
}
// получение остатка
if ((Filesize - fileStream.Position) > 0)
{
MainSocket.SendPackage("remain request".ToBytes());
buffer = MainSocket.GetPackage();
BytesDownloaded += (uint)buffer.Length;
fileStream.Write(buffer, 0, buffer.Length);
}
}
if (requiresFlushing)
fileStream.Flush();
}
// отдаёт файл с помощью FSP протокола
public void UploadFile(string filePath)
{
BytesUploaded = 0;
Debug("b", $"uploading file {filePath}");
using System.IO.FileStream fileStream = File.OpenRead(filePath);
Filesize = File.GetSize(filePath).ToUInt();
lock (MainSocket)
{
MainSocket.SendPackage(Filesize.ToString().ToBytes());
MainSocket.GetAnswer("ready");
byte[] buffer = new byte[5120];
int packagesCount = 0;
int fullPackagesCount = (Filesize / buffer.Length).Truncate();
// отправка полных пакетов файла
for (; packagesCount < fullPackagesCount; packagesCount++)
{
fileStream.Read(buffer, 0, buffer.Length);
MainSocket.SendPackage(buffer);
BytesUploaded += (uint)buffer.Length;
}
// отправка остатка
if ((Filesize - fileStream.Position) > 0)
{
MainSocket.GetAnswer("remain request");
buffer = new byte[(Filesize - fileStream.Position).ToInt()];
fileStream.Read(buffer, 0, buffer.Length);
MainSocket.SendPackage(buffer);
BytesUploaded += (uint)buffer.Length;
}
}
fileStream.Close();
Debug("g", $" uploaded {BytesUploaded} of {Filesize} bytes");
}
public void DownloadByManifest(string dirOnServer, string dirOnClient, bool overwrite = false, bool delete_excess = false)
{
if (!dirOnClient.EndsWith("\\"))
dirOnClient += "\\";
if (!dirOnServer.EndsWith("\\"))
dirOnServer += "\\";
Debug("b", "downloading manifest <", "c", dirOnServer + "manifest.dtsod", "b", ">");
var manifest = new DtsodV22(DownloadFileToMemory(dirOnServer + "manifest.dtsod").BytesToString());
Debug("g", $"found {manifest.Values.Count} files in manifest");
var hasher = new Hasher();
foreach (string fileOnServer in manifest.Keys)
{
string fileOnClient = dirOnClient + fileOnServer;
Debug("b", "file <", "c", fileOnClient, "b", ">... ");
if (!File.Exists(fileOnClient))
{
DebugNoTime("y", "doesn't exist");
DownloadFile(dirOnServer + fileOnServer, fileOnClient);
}
else if (overwrite && hasher.HashFile(fileOnClient).HashToString() != manifest[fileOnServer])
{
DebugNoTime("y", "outdated");
DownloadFile(dirOnServer + fileOnServer, fileOnClient);
}
else
DebugNoTime("g", "without changes");
}
// удаление лишних файлов
if (delete_excess)
{
foreach (string file in Directory.GetAllFiles(dirOnClient))
{
if (!manifest.ContainsKey(file.Remove(0, dirOnClient.Length)))
{
Debug("y", $"deleting excess file: {file}");
File.Delete(file);
}
}
}
}
public static void CreateManifest(string dir)
{
if (!dir.EndsWith("\\"))
dir += "\\";
Log($"b", $"creating manifest of {dir}");
StringBuilder manifestBuilder = new();
Hasher hasher = new();
if (Directory.GetFiles(dir).Contains(dir + "manifest.dtsod"))
File.Delete(dir + "manifest.dtsod");
foreach (string _file in Directory.GetAllFiles(dir))
{
string file = _file.Remove(0, dir.Length);
manifestBuilder.Append(file);
manifestBuilder.Append(": \"");
byte[] hash = hasher.HashFile(dir + file);
manifestBuilder.Append(hash.HashToString());
manifestBuilder.Append("\";\n");
}
Debug($"g", $" manifest of {dir} created");
File.WriteAllText(dir + "manifest.dtsod", manifestBuilder.ToString());
}
static void Debug(params string[] msg)
{
if (debug) Log(msg);
}
static void DebugNoTime(params string[] msg)
{
if (debug) LogNoTime(msg);
}
}

View File

@@ -1,32 +1,32 @@
using System.Diagnostics;
using System.Net.Http;
namespace DTLib.Network;
//
// пара почти никогда не используемых методов
//
public static class OldNetwork
{
// получает с сайта публичный ip
public static string GetPublicIP() => new HttpClient().GetStringAsync("https://ifconfig.me/ip").GetAwaiter().GetResult();
// пингует айпи с помощью встроенной в винду проги, возвращает задержку
public static string PingIP(string address)
{
var proc = new Process();
proc.StartInfo.FileName = "cmd.exe";
proc.StartInfo.Arguments = "/c @echo off & chcp 65001 >nul & ping -n 5 " + address;
proc.StartInfo.CreateNoWindow = true;
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.RedirectStandardOutput = true;
proc.Start();
System.IO.StreamReader outStream = proc.StandardOutput;
string rezult = outStream.ReadToEnd();
rezult = rezult.Remove(0, rezult.LastIndexOf('=') + 2);
return rezult.Remove(rezult.Length - 4);
}
}
using System.Diagnostics;
using System.Net.Http;
namespace DTLib.Network;
//
// пара почти никогда не используемых методов
//
public static class OldNetwork
{
// получает с сайта публичный ip
public static string GetPublicIP() => new HttpClient().GetStringAsync("https://ifconfig.me/ip").GetAwaiter().GetResult();
// пингует айпи с помощью встроенной в винду проги, возвращает задержку
public static string PingIP(string address)
{
var proc = new Process();
proc.StartInfo.FileName = "cmd.exe";
proc.StartInfo.Arguments = "/c @echo off & chcp 65001 >nul & ping -n 5 " + address;
proc.StartInfo.CreateNoWindow = true;
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.RedirectStandardOutput = true;
proc.Start();
System.IO.StreamReader outStream = proc.StandardOutput;
string rezult = outStream.ReadToEnd();
rezult = rezult.Remove(0, rezult.LastIndexOf('=') + 2);
return rezult.Remove(rezult.Length - 4);
}
}

View File

@@ -1,67 +1,67 @@
using System.Net.Sockets;
using System.Threading;
namespace DTLib.Network;
//
// отправка/получение пакетов
//
public static class Package
{
// принимает пакет
public static byte[] GetPackage(this Socket socket)
{
int packageSize = 0;
byte[] data = new byte[2];
// цикл выполняется пока не пройдёт 2000 мс
for (ushort s = 0; s < 400; s += 1)
{
if (packageSize == 0 && socket.Available >= 2)
{
socket.Receive(data, data.Length, 0);
packageSize = data.ToInt();
}
if (packageSize != 0 && socket.Available >= packageSize)
{
data = new byte[packageSize];
socket.Receive(data, data.Length, 0);
return data;
}
else
Thread.Sleep(5);
}
throw new Exception($"GetPackage() error: timeout. socket.Available={socket.Available}");
}
// отправляет пакет
public static void SendPackage(this Socket socket, byte[] data)
{
if (data.Length > 65536)
throw new Exception($"SendPackage() error: package is too big ({data.Length} bytes)");
if (data.Length == 0)
throw new Exception($"SendPackage() error: package has zero size");
var list = new List<byte>();
byte[] packageSize = data.Length.ToBytes();
if (packageSize.Length == 1)
list.Add(0);
list.AddRange(packageSize);
list.AddRange(data);
socket.Send(list.ToArray());
}
public static void SendPackage(this Socket socket, string data) => SendPackage(socket, data.ToBytes());
// получает пакет и выбрасывает исключение, если пакет не соответствует образцу
public static void GetAnswer(this Socket socket, string answer)
{
string rec = socket.GetPackage().BytesToString();
if (rec != answer)
throw new Exception($"GetAnswer() error: invalid answer: <{rec}>");
}
public static byte[] RequestPackage(this Socket socket, byte[] request)
{
socket.SendPackage(request);
return socket.GetPackage();
}
public static byte[] RequestPackage(this Socket socket, string request) => socket.RequestPackage(request.ToBytes());
}
using System.Net.Sockets;
using System.Threading;
namespace DTLib.Network;
//
// отправка/получение пакетов
//
public static class Package
{
// принимает пакет
public static byte[] GetPackage(this Socket socket)
{
int packageSize = 0;
byte[] data = new byte[2];
// цикл выполняется пока не пройдёт 2000 мс
for (ushort s = 0; s < 400; s += 1)
{
if (packageSize == 0 && socket.Available >= 2)
{
socket.Receive(data, data.Length, 0);
packageSize = data.ToInt();
}
if (packageSize != 0 && socket.Available >= packageSize)
{
data = new byte[packageSize];
socket.Receive(data, data.Length, 0);
return data;
}
else
Thread.Sleep(5);
}
throw new Exception($"GetPackage() error: timeout. socket.Available={socket.Available}");
}
// отправляет пакет
public static void SendPackage(this Socket socket, byte[] data)
{
if (data.Length > 65536)
throw new Exception($"SendPackage() error: package is too big ({data.Length} bytes)");
if (data.Length == 0)
throw new Exception($"SendPackage() error: package has zero size");
var list = new List<byte>();
byte[] packageSize = data.Length.ToBytes();
if (packageSize.Length == 1)
list.Add(0);
list.AddRange(packageSize);
list.AddRange(data);
socket.Send(list.ToArray());
}
public static void SendPackage(this Socket socket, string data) => SendPackage(socket, data.ToBytes());
// получает пакет и выбрасывает исключение, если пакет не соответствует образцу
public static void GetAnswer(this Socket socket, string answer)
{
string rec = socket.GetPackage().BytesToString();
if (rec != answer)
throw new Exception($"GetAnswer() error: invalid answer: <{rec}>");
}
public static byte[] RequestPackage(this Socket socket, byte[] request)
{
socket.SendPackage(request);
return socket.GetPackage();
}
public static byte[] RequestPackage(this Socket socket, string request) => socket.RequestPackage(request.ToBytes());
}

View File

@@ -1,15 +1,15 @@
namespace DTLib;
//
// вывод логов со всех классов в библиотеке
//
public static class PublicLog
{
public delegate void LogDelegate(params string[] msg);
// вот к этому объекту подключайте методы для вывода логов
public static event LogDelegate LogEvent;
public static void Log(params string[] msg) => LogEvent?.Invoke(msg);
public static event LogDelegate LogNoTimeEvent;
public static void LogNoTime(params string[] msg) => LogNoTimeEvent?.Invoke(msg);
}
namespace DTLib;
//
// вывод логов со всех классов в библиотеке
//
public static class PublicLog
{
public delegate void LogDelegate(params string[] msg);
// вот к этому объекту подключайте методы для вывода логов
public static event LogDelegate LogEvent;
public static void Log(params string[] msg) => LogEvent?.Invoke(msg);
public static event LogDelegate LogNoTimeEvent;
public static void LogNoTime(params string[] msg) => LogNoTimeEvent?.Invoke(msg);
}

View File

@@ -1,39 +1,39 @@
using System.Threading;
namespace DTLib;
//
// простой и понятный класс для выполнения каких-либо действий в отдельном потоке раз в некоторое время
//
public class Timer
{
Task TimerTask;
bool Repeat;
CancellationTokenSource кансель = new();
// таймер сразу запускается
public Timer(bool repeat, int delay, Action method)
{
Repeat = repeat;
TimerTask = new Task(() =>
{
do
{
if (кансель.Token.IsCancellationRequested)
return;
Task.Delay(delay).Wait();
method();
} while (Repeat);
});
}
public void Start() => TimerTask.Start();
// завершение потока
public void Stop()
{
Repeat = false;
кансель.Cancel();
}
}
using System.Threading;
namespace DTLib;
//
// простой и понятный класс для выполнения каких-либо действий в отдельном потоке раз в некоторое время
//
public class Timer
{
Task TimerTask;
bool Repeat;
CancellationTokenSource кансель = new();
// таймер сразу запускается
public Timer(bool repeat, int delay, Action method)
{
Repeat = repeat;
TimerTask = new Task(() =>
{
do
{
if (кансель.Token.IsCancellationRequested)
return;
Task.Delay(delay).Wait();
method();
} while (Repeat);
});
}
public void Start() => TimerTask.Start();
// завершение потока
public void Stop()
{
Repeat = false;
кансель.Cancel();
}
}

View File

@@ -1,173 +1,173 @@
using System.Security.Cryptography;
namespace DTLib;
// честно взятый с гитхаба алгоритм хеширования
// выдаёт хеш в виде массива четырёх байтов
sealed class XXHash32 : HashAlgorithm
{
private const uint PRIME32_1 = 2654435761U;
private const uint PRIME32_2 = 2246822519U;
private const uint PRIME32_3 = 3266489917U;
private const uint PRIME32_4 = 668265263U;
private const uint PRIME32_5 = 374761393U;
private static readonly Func<byte[], int, uint> FuncGetLittleEndianUInt32;
private static readonly Func<uint, uint> FuncGetFinalHashUInt32;
private uint _Seed32;
private uint _ACC32_1;
private uint _ACC32_2;
private uint _ACC32_3;
private uint _ACC32_4;
private uint _Hash32;
private int _RemainingLength;
private long _TotalLength = 0;
private int _CurrentIndex;
private byte[] _CurrentArray;
static XXHash32()
{
if (BitConverter.IsLittleEndian)
{
FuncGetLittleEndianUInt32 = new Func<byte[], int, uint>((x, i) =>
{
unsafe
{
fixed (byte* array = x)
{
return *(uint*)(array + i);
}
}
});
FuncGetFinalHashUInt32 = new Func<uint, uint>(i => (i & 0x000000FFU) << 24 | (i & 0x0000FF00U) << 8 | (i & 0x00FF0000U) >> 8 | (i & 0xFF000000U) >> 24);
}
else
{
FuncGetLittleEndianUInt32 = new Func<byte[], int, uint>((x, i) =>
{
unsafe
{
fixed (byte* array = x)
{
return (uint)(array[i++] | (array[i++] << 8) | (array[i++] << 16) | (array[i] << 24));
}
}
});
FuncGetFinalHashUInt32 = new Func<uint, uint>(i => i);
}
}
/// Creates an instance of <see cref="XXHash32"/> class by default seed(0).
/// <returns></returns>
public static new XXHash32 Create() => new();
/// Initializes a new instance of the <see cref="XXHash32"/> class by default seed(0).
public XXHash32() => Initialize(0);
/// Initializes a new instance of the <see cref="XXHash32"/> class, and sets the <see cref="Seed"/> to the specified value.
/// <param name="seed">Represent the seed to be used for xxHash32 computing.</param>
public XXHash32(uint seed) => Initialize(seed);
/// Gets the <see cref="uint"/> value of the computed hash code.
/// <exception cref="InvalidOperationException">Hash computation has not yet completed.</exception>
public uint HashUInt32 => State == 0 ? _Hash32 : throw new InvalidOperationException("Hash computation has not yet completed.");
/// Gets or sets the value of seed used by xxHash32 algorithm.
/// <exception cref="InvalidOperationException">Hash computation has not yet completed.</exception>
public uint Seed
{
get => _Seed32;
set
{
if (value != _Seed32)
{
if (State != 0)
throw new InvalidOperationException("Hash computation has not yet completed.");
_Seed32 = value;
Initialize();
}
}
}
/// Initializes this instance for new hash computing.
public override void Initialize()
{
_ACC32_1 = _Seed32 + PRIME32_1 + PRIME32_2;
_ACC32_2 = _Seed32 + PRIME32_2;
_ACC32_3 = _Seed32 + 0;
_ACC32_4 = _Seed32 - PRIME32_1;
}
/// Routes data written to the object into the hash algorithm for computing the hash.
/// <param name="array">The input to compute the hash code for.</param>
/// <param name="ibStart">The offset into the byte array from which to begin using data.</param>
/// <param name="cbSize">The number of bytes in the byte array to use as data.</param>
protected override void HashCore(byte[] array, int ibStart, int cbSize)
{
if (State != 1)
State = 1;
int size = cbSize - ibStart;
_RemainingLength = size & 15;
if (cbSize >= 16)
{
int limit = size - _RemainingLength;
do
{
_ACC32_1 = Round32(_ACC32_1, FuncGetLittleEndianUInt32(array, ibStart));
ibStart += 4;
_ACC32_2 = Round32(_ACC32_2, FuncGetLittleEndianUInt32(array, ibStart));
ibStart += 4;
_ACC32_3 = Round32(_ACC32_3, FuncGetLittleEndianUInt32(array, ibStart));
ibStart += 4;
_ACC32_4 = Round32(_ACC32_4, FuncGetLittleEndianUInt32(array, ibStart));
ibStart += 4;
} while (ibStart < limit);
}
_TotalLength += cbSize;
if (_RemainingLength != 0)
{
_CurrentArray = array;
_CurrentIndex = ibStart;
}
}
/// Finalizes the hash computation after the last data is processed by the cryptographic stream object.
/// <returns>The computed hash code.</returns>
protected override byte[] HashFinal()
{
_Hash32 = _TotalLength >= 16
? RotateLeft32(_ACC32_1, 1) + RotateLeft32(_ACC32_2, 7) + RotateLeft32(_ACC32_3, 12) + RotateLeft32(_ACC32_4, 18)
: _Seed32 + PRIME32_5;
_Hash32 += (uint)_TotalLength;
while (_RemainingLength >= 4)
{
_Hash32 = RotateLeft32(_Hash32 + FuncGetLittleEndianUInt32(_CurrentArray, _CurrentIndex) * PRIME32_3, 17) * PRIME32_4;
_CurrentIndex += 4;
_RemainingLength -= 4;
}
unsafe
{
fixed (byte* arrayPtr = _CurrentArray)
{
while (_RemainingLength-- >= 1)
{
_Hash32 = RotateLeft32(_Hash32 + arrayPtr[_CurrentIndex++] * PRIME32_5, 11) * PRIME32_1;
}
}
}
_Hash32 = (_Hash32 ^ (_Hash32 >> 15)) * PRIME32_2;
_Hash32 = (_Hash32 ^ (_Hash32 >> 13)) * PRIME32_3;
_Hash32 ^= _Hash32 >> 16;
_TotalLength = State = 0;
return BitConverter.GetBytes(FuncGetFinalHashUInt32(_Hash32));
}
private static uint Round32(uint input, uint value) => RotateLeft32(input + (value * PRIME32_2), 13) * PRIME32_1;
private static uint RotateLeft32(uint value, int count) => (value << count) | (value >> (32 - count));
private void Initialize(uint seed)
{
HashSizeValue = 32;
_Seed32 = seed;
Initialize();
}
}
using System.Security.Cryptography;
namespace DTLib;
// честно взятый с гитхаба алгоритм хеширования
// выдаёт хеш в виде массива четырёх байтов
sealed class XXHash32 : HashAlgorithm
{
private const uint PRIME32_1 = 2654435761U;
private const uint PRIME32_2 = 2246822519U;
private const uint PRIME32_3 = 3266489917U;
private const uint PRIME32_4 = 668265263U;
private const uint PRIME32_5 = 374761393U;
private static readonly Func<byte[], int, uint> FuncGetLittleEndianUInt32;
private static readonly Func<uint, uint> FuncGetFinalHashUInt32;
private uint _Seed32;
private uint _ACC32_1;
private uint _ACC32_2;
private uint _ACC32_3;
private uint _ACC32_4;
private uint _Hash32;
private int _RemainingLength;
private long _TotalLength = 0;
private int _CurrentIndex;
private byte[] _CurrentArray;
static XXHash32()
{
if (BitConverter.IsLittleEndian)
{
FuncGetLittleEndianUInt32 = new Func<byte[], int, uint>((x, i) =>
{
unsafe
{
fixed (byte* array = x)
{
return *(uint*)(array + i);
}
}
});
FuncGetFinalHashUInt32 = new Func<uint, uint>(i => (i & 0x000000FFU) << 24 | (i & 0x0000FF00U) << 8 | (i & 0x00FF0000U) >> 8 | (i & 0xFF000000U) >> 24);
}
else
{
FuncGetLittleEndianUInt32 = new Func<byte[], int, uint>((x, i) =>
{
unsafe
{
fixed (byte* array = x)
{
return (uint)(array[i++] | (array[i++] << 8) | (array[i++] << 16) | (array[i] << 24));
}
}
});
FuncGetFinalHashUInt32 = new Func<uint, uint>(i => i);
}
}
/// Creates an instance of <see cref="XXHash32"/> class by default seed(0).
/// <returns></returns>
public static new XXHash32 Create() => new();
/// Initializes a new instance of the <see cref="XXHash32"/> class by default seed(0).
public XXHash32() => Initialize(0);
/// Initializes a new instance of the <see cref="XXHash32"/> class, and sets the <see cref="Seed"/> to the specified value.
/// <param name="seed">Represent the seed to be used for xxHash32 computing.</param>
public XXHash32(uint seed) => Initialize(seed);
/// Gets the <see cref="uint"/> value of the computed hash code.
/// <exception cref="InvalidOperationException">Hash computation has not yet completed.</exception>
public uint HashUInt32 => State == 0 ? _Hash32 : throw new InvalidOperationException("Hash computation has not yet completed.");
/// Gets or sets the value of seed used by xxHash32 algorithm.
/// <exception cref="InvalidOperationException">Hash computation has not yet completed.</exception>
public uint Seed
{
get => _Seed32;
set
{
if (value != _Seed32)
{
if (State != 0)
throw new InvalidOperationException("Hash computation has not yet completed.");
_Seed32 = value;
Initialize();
}
}
}
/// Initializes this instance for new hash computing.
public override void Initialize()
{
_ACC32_1 = _Seed32 + PRIME32_1 + PRIME32_2;
_ACC32_2 = _Seed32 + PRIME32_2;
_ACC32_3 = _Seed32 + 0;
_ACC32_4 = _Seed32 - PRIME32_1;
}
/// Routes data written to the object into the hash algorithm for computing the hash.
/// <param name="array">The input to compute the hash code for.</param>
/// <param name="ibStart">The offset into the byte array from which to begin using data.</param>
/// <param name="cbSize">The number of bytes in the byte array to use as data.</param>
protected override void HashCore(byte[] array, int ibStart, int cbSize)
{
if (State != 1)
State = 1;
int size = cbSize - ibStart;
_RemainingLength = size & 15;
if (cbSize >= 16)
{
int limit = size - _RemainingLength;
do
{
_ACC32_1 = Round32(_ACC32_1, FuncGetLittleEndianUInt32(array, ibStart));
ibStart += 4;
_ACC32_2 = Round32(_ACC32_2, FuncGetLittleEndianUInt32(array, ibStart));
ibStart += 4;
_ACC32_3 = Round32(_ACC32_3, FuncGetLittleEndianUInt32(array, ibStart));
ibStart += 4;
_ACC32_4 = Round32(_ACC32_4, FuncGetLittleEndianUInt32(array, ibStart));
ibStart += 4;
} while (ibStart < limit);
}
_TotalLength += cbSize;
if (_RemainingLength != 0)
{
_CurrentArray = array;
_CurrentIndex = ibStart;
}
}
/// Finalizes the hash computation after the last data is processed by the cryptographic stream object.
/// <returns>The computed hash code.</returns>
protected override byte[] HashFinal()
{
_Hash32 = _TotalLength >= 16
? RotateLeft32(_ACC32_1, 1) + RotateLeft32(_ACC32_2, 7) + RotateLeft32(_ACC32_3, 12) + RotateLeft32(_ACC32_4, 18)
: _Seed32 + PRIME32_5;
_Hash32 += (uint)_TotalLength;
while (_RemainingLength >= 4)
{
_Hash32 = RotateLeft32(_Hash32 + FuncGetLittleEndianUInt32(_CurrentArray, _CurrentIndex) * PRIME32_3, 17) * PRIME32_4;
_CurrentIndex += 4;
_RemainingLength -= 4;
}
unsafe
{
fixed (byte* arrayPtr = _CurrentArray)
{
while (_RemainingLength-- >= 1)
{
_Hash32 = RotateLeft32(_Hash32 + arrayPtr[_CurrentIndex++] * PRIME32_5, 11) * PRIME32_1;
}
}
}
_Hash32 = (_Hash32 ^ (_Hash32 >> 15)) * PRIME32_2;
_Hash32 = (_Hash32 ^ (_Hash32 >> 13)) * PRIME32_3;
_Hash32 ^= _Hash32 >> 16;
_TotalLength = State = 0;
return BitConverter.GetBytes(FuncGetFinalHashUInt32(_Hash32));
}
private static uint Round32(uint input, uint value) => RotateLeft32(input + (value * PRIME32_2), 13) * PRIME32_1;
private static uint RotateLeft32(uint value, int count) => (value << count) | (value >> (32 - count));
private void Initialize(uint seed)
{
HashSizeValue = 32;
_Seed32 = seed;
Initialize();
}
}

16
DtsodC/.vscode/c_cpp_properties.json vendored Normal file
View File

@@ -0,0 +1,16 @@
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "gnu17",
"cppStandard": "gnu++14",
"intelliSenseMode": "linux-gcc-x64"
}
],
"version": 4
}

11
DtsodC/.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,11 @@
{
"files.associations": {
"*.h": "c",
"cstdint": "c",
"limits": "c",
"cstdio": "c",
"cwchar": "c"
},
"C_Cpp.default.defines": [],
"C_Cpp.intelliSenseCacheSize": 10
}

BIN
DtsodC/GPATH Normal file

Binary file not shown.

BIN
DtsodC/GRTAGS Normal file

Binary file not shown.

BIN
DtsodC/GTAGS Normal file

Binary file not shown.

48
DtsodC/Makefile Normal file
View File

@@ -0,0 +1,48 @@
SRC_LIB=src/autosize_array/Autoarr.c src/throw.c src/strict_types.c
SRC_COM=src/test.c
all: clear_c std_build test
clear_c:
clear
clear:
@echo "\e[36m-----------------[clear]-------------------\e[0m"
rm bin/*.com
# using sdlib
STDARGS=-D STDLIB
std_build: std_build_test
std_build_lib:
@echo "\e[36m-------------[std_build_lib]---------------\e[0m"
gcc $(STDARGS) $(SRC_LIB) -o bin/dtsodc_test_STD.dll
std_build_test:
@echo "\e[36m-------------[std_build_test]---------------\e[0m"
gcc $(STDARGS) $(SRC_LIB) $(SRC_COM) -o bin/dtsodc_test_STD.com
std_test: std_build_test
@echo "\e[36m----------------[std_test]------------------\e[0m"
bin/dtsodc_test_STD.com
# using cosmopolitan
COSMARGS_PRE=-g -O -static -fno-pie -no-pie -mno-red-zone -nostdlib -nostdinc -D COSMOPOLITAN
COSMARGS_POST=-Wl,--oformat=binary -Wl,--gc-sections -Wl,-z,max-page-size=0x1000 -fuse-ld=bfd -Wl,-T,cosmopolitan/ape.lds \
-include cosmopolitan/cosmopolitan.h cosmopolitan/crt.o ./cosmopolitan/ape-no-modify-self.o cosmopolitan/cosmopolitan.a
build: build_test
build_lib:
@echo "\e[36m----------------[build_lib]-----------------\e[0m"
gcc $(COSMARGS_PRE) $(SRC_LIB) $(COSMARGS_POST) -o bin/dtsodc_test.dll
build_test:
@echo "\e[36m----------------[build_test]----------------\e[0m"
gcc $(COSMARGS_PRE) $(SRC_LIB) $(SRC_COM) $(COSMARGS_POST) -o bin/dtsodc_test.com
test: build_test
@echo "\e[36m-----------------[test]----------------\e[0m"
bin/dtsodc_test.com

Binary file not shown.

343
DtsodC/cosmopolitan/ape.lds Normal file
View File

@@ -0,0 +1,343 @@
ENTRY(_start)
PHDRS {
Head PT_LOAD FLAGS(5);
Rom PT_LOAD FLAGS(5);
Ram PT_LOAD FLAGS(6);
stack PT_GNU_STACK FLAGS(6);
}
SECTIONS {
.head SEGMENT_START("text-segment", 0x400000) : AT(0x2000) {
HIDDEN(_base = .);
KEEP(*(.head))
KEEP(*(.text.head))
. = ALIGN(8);
HIDDEN(ape_phdrs = .);
KEEP(*(.elf.phdrs))
HIDDEN(ape_phdrs_end = .);
. = ALIGN(8);
HIDDEN(ape_note = .);
KEEP(*(.note.openbsd.ident))
KEEP(*(.note.netbsd.ident))
HIDDEN(ape_note_end = .);
KEEP(*(.pe.header))
HIDDEN(ape_pe_sections = .);
KEEP(*(.pe.sections))
HIDDEN(ape_pe_sections_end = .);
KEEP(*(.macho))
. = ALIGN(8);
HIDDEN(ape_macho_end = .);
KEEP(*(.ape.pad.head))
. = ALIGN(((255 & 4) == 4) || ((255 & 2) == 2) ? 0x1000 : 16);
HIDDEN(_ehead = .);
} :Head
.text . : {
*(.text.real)
KEEP(*(SORT_BY_NAME(.sort.text.real.*)))
HIDDEN(_ereal = .);
. += 1;
*(.start)
KEEP(*(.initprologue))
KEEP(*(SORT_BY_NAME(.init.*)))
KEEP(*(.init))
KEEP(*(.initepilogue))
KEEP(*(.pltprologue))
*(.plt)
KEEP(*(.pltepilogue))
KEEP(*(.pltgotprologue))
*(.plt.got)
KEEP(*(.pltgotepilogue))
*(.text.startup .text.startup.*)
*(.text.exit .text.exit.*)
*(.text.unlikely .text.*_unlikely .text.unlikely.*)
*(SORT_BY_ALIGNMENT(.text.antiquity))
*(SORT_BY_ALIGNMENT(.text.antiquity.*))
KEEP(*(.textwindowsprologue))
*(.text.windows)
KEEP(*(.textwindowsepilogue))
*(SORT_BY_ALIGNMENT(.text.modernity))
*(SORT_BY_ALIGNMENT(.text.modernity.*))
*(SORT_BY_ALIGNMENT(.text.hot))
*(SORT_BY_ALIGNMENT(.text.hot.*))
KEEP(*(.keep.text))
*(.text .stub .text.*)
KEEP(*(SORT_BY_NAME(.sort.text.*)))
KEEP(*(.ape.pad.test));
*(.test.unlikely)
*(.test .test.*)
KEEP(*(.ape.pad.privileged));
. += . > 0 ? 1 : 0;
HIDDEN(__privileged_start = .);
. += . > 0 ? 1 : 0;
*(.privileged)
HIDDEN(__privileged_end = .);
. += . > 0 ? 1 : 0;
KEEP(*(.ape.pad.rodata));
*(.rodata .rodata.*)
*(.ubsan.types)
*(.ubsan.data)
KEEP(*(.commentprologue))
KEEP(*(.comment))
KEEP(*(.commentepilogue))
KEEP(*(.idata.ro));
KEEP(*(SORT_BY_NAME(.idata.ro.*)))
. = ALIGN(8);
PROVIDE_HIDDEN(__init_array_start = .);
KEEP(*(SORT_BY_INIT_PRIORITY(.init_array.*)
SORT_BY_INIT_PRIORITY(.ctors.*)))
KEEP(*(.ctors))
KEEP(*(.init_array))
KEEP(*(.preinit_array))
PROVIDE_HIDDEN(__init_array_end = .);
. = ALIGN(8);
PROVIDE_HIDDEN(__fini_array_start = .);
KEEP(*(SORT_BY_INIT_PRIORITY(.fini_array.*)
SORT_BY_INIT_PRIORITY(.dtors.*)))
KEEP(*(.dtors))
PROVIDE_HIDDEN(__fini_array_end = .);
KEEP(*(.initroprologue))
KEEP(*(SORT_BY_NAME(.initro.*)))
KEEP(*(.initroepilogue))
KEEP(*(SORT_BY_NAME(.sort.rodata.*)))
KEEP(*(.ape.pad.text))
. = ALIGN(0x1000);
HIDDEN(_etext = .);
PROVIDE_HIDDEN(etext = .);
} :Rom
.data . : {
KEEP(*(.dataprologue))
*(.data .data.*)
KEEP(*(SORT_BY_NAME(.sort.data.*)))
. += . > 0 ? 1 : 0;
KEEP(*(.gotprologue))
*(.got)
KEEP(*(.gotepilogue))
KEEP(*(.gotpltprologue))
*(.got.plt)
KEEP(*(.gotpltepilogue))
. = ALIGN(8);
KEEP(*(SORT_BY_NAME(.piro.relo.sort.*)))
PROVIDE_HIDDEN(__relo_end = .);
. = ALIGN(8);
KEEP(*(SORT_BY_NAME(.piro.data.sort.*)))
KEEP(*(.piro.pad.data))
. = ALIGN(0x1000);
HIDDEN(_edata = .);
PROVIDE_HIDDEN(edata = .);
} :Ram
.zip . : {
KEEP(*(SORT_BY_NAME(.zip.*)))
HIDDEN(_ezip = .);
}
.bss ALIGN(8) : {
KEEP(*(SORT_BY_NAME(.piro.bss.init.*)))
*(.piro.bss)
KEEP(*(SORT_BY_NAME(.piro.bss.sort.*)))
HIDDEN(__piro_end = .);
. += . > 0 ? 1 : 0;
*(SORT_BY_ALIGNMENT(.bss))
*(SORT_BY_ALIGNMENT(.bss.*))
*(COMMON)
KEEP(*(SORT_BY_NAME(.sort.bss.*)))
. = ALIGN(0x10000);
HIDDEN(_end = .);
PROVIDE_HIDDEN(end = .);
}
.shstrtab : { *(.shstrtab) }
.strtab : { *(.strtab) }
.symtab : { *(.symtab) }
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
.stab.excl 0 : { *(.stab.excl) }
.stab.exclstr 0 : { *(.stab.exclstr) }
.stab.index 0 : { *(.stab.index) }
.stab.indexstr 0 : { *(.stab.indexstr) }
.comment 0 : { *(.comment) }
.debug 0 : { *(.debug) }
.line 0 : { *(.line) }
.debug_srcinfo 0 : { *(.debug_srcinfo) }
.debug_sfnames 0 : { *(.debug_sfnames) }
.debug_aranges 0 : { *(.debug_aranges) }
.debug_pubnames 0 : { *(.debug_pubnames) }
.debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
.debug_abbrev 0 : { *(.debug_abbrev) }
.debug_line 0 : { *(.debug_line .debug_line.* .debug_line_end ) }
.debug_frame 0 : { *(.debug_frame) }
.debug_str 0 : { *(.debug_str) }
.debug_loc 0 : { *(.debug_loc) }
.debug_macinfo 0 : { *(.debug_macinfo) }
.debug_weaknames 0 : { *(.debug_weaknames) }
.debug_funcnames 0 : { *(.debug_funcnames) }
.debug_typenames 0 : { *(.debug_typenames) }
.debug_varnames 0 : { *(.debug_varnames) }
.debug_pubtypes 0 : { *(.debug_pubtypes) }
.debug_ranges 0 : { *(.debug_ranges) }
.debug_macro 0 : { *(.debug_macro) }
.debug_addr 0 : { *(.debug_addr) }
.gnu.attributes 0 : { KEEP(*(.gnu.attributes)) }
.GCC.command.line 0 : { *(.GCC.command.line) }
/DISCARD/ : {
*(__mcount_loc)
*(.discard)
*(.yoink)
*(.*)
}
}
HIDDEN(ape_elf_entry = (_start)); HIDDEN(ape_elf_entry_bcs0 = (((((((_start) >> ((0)*8)) >> 0)&0x7) + 0x30) << 24) | ((((((_start) >> ((0)*8)) >> 3)&0x7) + 0x30) << 16) | (((((((_start) >> ((0)*8))&0xff) >> 6)&0x7) + 0x30) << 8) | 0x5c)); HIDDEN(ape_elf_entry_bcs1 = (((((((_start) >> ((1)*8)) >> 0)&0x7) + 0x30) << 24) | ((((((_start) >> ((1)*8)) >> 3)&0x7) + 0x30) << 16) | (((((((_start) >> ((1)*8))&0xff) >> 6)&0x7) + 0x30) << 8) | 0x5c)); HIDDEN(ape_elf_entry_bcs2 = (((((((_start) >> ((2)*8)) >> 0)&0x7) + 0x30) << 24) | ((((((_start) >> ((2)*8)) >> 3)&0x7) + 0x30) << 16) | (((((((_start) >> ((2)*8))&0xff) >> 6)&0x7) + 0x30) << 8) | 0x5c)); HIDDEN(ape_elf_entry_bcs3 = (((((((_start) >> ((3)*8)) >> 0)&0x7) + 0x30) << 24) | ((((((_start) >> ((3)*8)) >> 3)&0x7) + 0x30) << 16) | (((((((_start) >> ((3)*8))&0xff) >> 6)&0x7) + 0x30) << 8) | 0x5c)); HIDDEN(ape_elf_entry_bcs4 = (((((((_start) >> ((4)*8)) >> 0)&0x7) + 0x30) << 24) | ((((((_start) >> ((4)*8)) >> 3)&0x7) + 0x30) << 16) | (((((((_start) >> ((4)*8))&0xff) >> 6)&0x7) + 0x30) << 8) | 0x5c)); HIDDEN(ape_elf_entry_bcs5 = (((((((_start) >> ((5)*8)) >> 0)&0x7) + 0x30) << 24) | ((((((_start) >> ((5)*8)) >> 3)&0x7) + 0x30) << 16) | (((((((_start) >> ((5)*8))&0xff) >> 6)&0x7) + 0x30) << 8) | 0x5c)); HIDDEN(ape_elf_entry_bcs6 = (((((((_start) >> ((6)*8)) >> 0)&0x7) + 0x30) << 24) | ((((((_start) >> ((6)*8)) >> 3)&0x7) + 0x30) << 16) | (((((((_start) >> ((6)*8))&0xff) >> 6)&0x7) + 0x30) << 8) | 0x5c)); HIDDEN(ape_elf_entry_bcs7 = (((((((_start) >> ((7)*8)) >> 0)&0x7) + 0x30) << 24) | ((((((_start) >> ((7)*8)) >> 3)&0x7) + 0x30) << 16) | (((((((_start) >> ((7)*8))&0xff) >> 6)&0x7) + 0x30) << 8) | 0x5c));
HIDDEN(ape_elf_phoff = (((ape_phdrs) - (0x400000)))); HIDDEN(ape_elf_phoff_bcs0 = (((((((((ape_phdrs) - (0x400000))) >> ((0)*8)) >> 0)&0x7) + 0x30) << 24) | ((((((((ape_phdrs) - (0x400000))) >> ((0)*8)) >> 3)&0x7) + 0x30) << 16) | (((((((((ape_phdrs) - (0x400000))) >> ((0)*8))&0xff) >> 6)&0x7) + 0x30) << 8) | 0x5c)); HIDDEN(ape_elf_phoff_bcs1 = (((((((((ape_phdrs) - (0x400000))) >> ((1)*8)) >> 0)&0x7) + 0x30) << 24) | ((((((((ape_phdrs) - (0x400000))) >> ((1)*8)) >> 3)&0x7) + 0x30) << 16) | (((((((((ape_phdrs) - (0x400000))) >> ((1)*8))&0xff) >> 6)&0x7) + 0x30) << 8) | 0x5c)); HIDDEN(ape_elf_phoff_bcs2 = (((((((((ape_phdrs) - (0x400000))) >> ((2)*8)) >> 0)&0x7) + 0x30) << 24) | ((((((((ape_phdrs) - (0x400000))) >> ((2)*8)) >> 3)&0x7) + 0x30) << 16) | (((((((((ape_phdrs) - (0x400000))) >> ((2)*8))&0xff) >> 6)&0x7) + 0x30) << 8) | 0x5c)); HIDDEN(ape_elf_phoff_bcs3 = (((((((((ape_phdrs) - (0x400000))) >> ((3)*8)) >> 0)&0x7) + 0x30) << 24) | ((((((((ape_phdrs) - (0x400000))) >> ((3)*8)) >> 3)&0x7) + 0x30) << 16) | (((((((((ape_phdrs) - (0x400000))) >> ((3)*8))&0xff) >> 6)&0x7) + 0x30) << 8) | 0x5c)); HIDDEN(ape_elf_phoff_bcs4 = (((((((((ape_phdrs) - (0x400000))) >> ((4)*8)) >> 0)&0x7) + 0x30) << 24) | ((((((((ape_phdrs) - (0x400000))) >> ((4)*8)) >> 3)&0x7) + 0x30) << 16) | (((((((((ape_phdrs) - (0x400000))) >> ((4)*8))&0xff) >> 6)&0x7) + 0x30) << 8) | 0x5c)); HIDDEN(ape_elf_phoff_bcs5 = (((((((((ape_phdrs) - (0x400000))) >> ((5)*8)) >> 0)&0x7) + 0x30) << 24) | ((((((((ape_phdrs) - (0x400000))) >> ((5)*8)) >> 3)&0x7) + 0x30) << 16) | (((((((((ape_phdrs) - (0x400000))) >> ((5)*8))&0xff) >> 6)&0x7) + 0x30) << 8) | 0x5c)); HIDDEN(ape_elf_phoff_bcs6 = (((((((((ape_phdrs) - (0x400000))) >> ((6)*8)) >> 0)&0x7) + 0x30) << 24) | ((((((((ape_phdrs) - (0x400000))) >> ((6)*8)) >> 3)&0x7) + 0x30) << 16) | (((((((((ape_phdrs) - (0x400000))) >> ((6)*8))&0xff) >> 6)&0x7) + 0x30) << 8) | 0x5c)); HIDDEN(ape_elf_phoff_bcs7 = (((((((((ape_phdrs) - (0x400000))) >> ((7)*8)) >> 0)&0x7) + 0x30) << 24) | ((((((((ape_phdrs) - (0x400000))) >> ((7)*8)) >> 3)&0x7) + 0x30) << 16) | (((((((((ape_phdrs) - (0x400000))) >> ((7)*8))&0xff) >> 6)&0x7) + 0x30) << 8) | 0x5c));
HIDDEN(ape_elf_shoff = (0)); HIDDEN(ape_elf_shoff_bcs0 = (((((((0) >> ((0)*8)) >> 0)&0x7) + 0x30) << 24) | ((((((0) >> ((0)*8)) >> 3)&0x7) + 0x30) << 16) | (((((((0) >> ((0)*8))&0xff) >> 6)&0x7) + 0x30) << 8) | 0x5c)); HIDDEN(ape_elf_shoff_bcs1 = (((((((0) >> ((1)*8)) >> 0)&0x7) + 0x30) << 24) | ((((((0) >> ((1)*8)) >> 3)&0x7) + 0x30) << 16) | (((((((0) >> ((1)*8))&0xff) >> 6)&0x7) + 0x30) << 8) | 0x5c)); HIDDEN(ape_elf_shoff_bcs2 = (((((((0) >> ((2)*8)) >> 0)&0x7) + 0x30) << 24) | ((((((0) >> ((2)*8)) >> 3)&0x7) + 0x30) << 16) | (((((((0) >> ((2)*8))&0xff) >> 6)&0x7) + 0x30) << 8) | 0x5c)); HIDDEN(ape_elf_shoff_bcs3 = (((((((0) >> ((3)*8)) >> 0)&0x7) + 0x30) << 24) | ((((((0) >> ((3)*8)) >> 3)&0x7) + 0x30) << 16) | (((((((0) >> ((3)*8))&0xff) >> 6)&0x7) + 0x30) << 8) | 0x5c)); HIDDEN(ape_elf_shoff_bcs4 = (((((((0) >> ((4)*8)) >> 0)&0x7) + 0x30) << 24) | ((((((0) >> ((4)*8)) >> 3)&0x7) + 0x30) << 16) | (((((((0) >> ((4)*8))&0xff) >> 6)&0x7) + 0x30) << 8) | 0x5c)); HIDDEN(ape_elf_shoff_bcs5 = (((((((0) >> ((5)*8)) >> 0)&0x7) + 0x30) << 24) | ((((((0) >> ((5)*8)) >> 3)&0x7) + 0x30) << 16) | (((((((0) >> ((5)*8))&0xff) >> 6)&0x7) + 0x30) << 8) | 0x5c)); HIDDEN(ape_elf_shoff_bcs6 = (((((((0) >> ((6)*8)) >> 0)&0x7) + 0x30) << 24) | ((((((0) >> ((6)*8)) >> 3)&0x7) + 0x30) << 16) | (((((((0) >> ((6)*8))&0xff) >> 6)&0x7) + 0x30) << 8) | 0x5c)); HIDDEN(ape_elf_shoff_bcs7 = (((((((0) >> ((7)*8)) >> 0)&0x7) + 0x30) << 24) | ((((((0) >> ((7)*8)) >> 3)&0x7) + 0x30) << 16) | (((((((0) >> ((7)*8))&0xff) >> 6)&0x7) + 0x30) << 8) | 0x5c));
HIDDEN(ape_elf_phnum = ((ape_phdrs_end - ape_phdrs) / 56)); HIDDEN(ape_elf_phnum_bcs0 = ((((((((ape_phdrs_end - ape_phdrs) / 56) >> ((0)*8)) >> 0)&0x7) + 0x30) << 24) | (((((((ape_phdrs_end - ape_phdrs) / 56) >> ((0)*8)) >> 3)&0x7) + 0x30) << 16) | ((((((((ape_phdrs_end - ape_phdrs) / 56) >> ((0)*8))&0xff) >> 6)&0x7) + 0x30) << 8) | 0x5c)); HIDDEN(ape_elf_phnum_bcs1 = ((((((((ape_phdrs_end - ape_phdrs) / 56) >> ((1)*8)) >> 0)&0x7) + 0x30) << 24) | (((((((ape_phdrs_end - ape_phdrs) / 56) >> ((1)*8)) >> 3)&0x7) + 0x30) << 16) | ((((((((ape_phdrs_end - ape_phdrs) / 56) >> ((1)*8))&0xff) >> 6)&0x7) + 0x30) << 8) | 0x5c)); HIDDEN(ape_elf_phnum_bcs2 = ((((((((ape_phdrs_end - ape_phdrs) / 56) >> ((2)*8)) >> 0)&0x7) + 0x30) << 24) | (((((((ape_phdrs_end - ape_phdrs) / 56) >> ((2)*8)) >> 3)&0x7) + 0x30) << 16) | ((((((((ape_phdrs_end - ape_phdrs) / 56) >> ((2)*8))&0xff) >> 6)&0x7) + 0x30) << 8) | 0x5c)); HIDDEN(ape_elf_phnum_bcs3 = ((((((((ape_phdrs_end - ape_phdrs) / 56) >> ((3)*8)) >> 0)&0x7) + 0x30) << 24) | (((((((ape_phdrs_end - ape_phdrs) / 56) >> ((3)*8)) >> 3)&0x7) + 0x30) << 16) | ((((((((ape_phdrs_end - ape_phdrs) / 56) >> ((3)*8))&0xff) >> 6)&0x7) + 0x30) << 8) | 0x5c));
HIDDEN(ape_elf_shnum = (0)); HIDDEN(ape_elf_shnum_bcs0 = (((((((0) >> ((0)*8)) >> 0)&0x7) + 0x30) << 24) | ((((((0) >> ((0)*8)) >> 3)&0x7) + 0x30) << 16) | (((((((0) >> ((0)*8))&0xff) >> 6)&0x7) + 0x30) << 8) | 0x5c)); HIDDEN(ape_elf_shnum_bcs1 = (((((((0) >> ((1)*8)) >> 0)&0x7) + 0x30) << 24) | ((((((0) >> ((1)*8)) >> 3)&0x7) + 0x30) << 16) | (((((((0) >> ((1)*8))&0xff) >> 6)&0x7) + 0x30) << 8) | 0x5c)); HIDDEN(ape_elf_shnum_bcs2 = (((((((0) >> ((2)*8)) >> 0)&0x7) + 0x30) << 24) | ((((((0) >> ((2)*8)) >> 3)&0x7) + 0x30) << 16) | (((((((0) >> ((2)*8))&0xff) >> 6)&0x7) + 0x30) << 8) | 0x5c)); HIDDEN(ape_elf_shnum_bcs3 = (((((((0) >> ((3)*8)) >> 0)&0x7) + 0x30) << 24) | ((((((0) >> ((3)*8)) >> 3)&0x7) + 0x30) << 16) | (((((((0) >> ((3)*8))&0xff) >> 6)&0x7) + 0x30) << 8) | 0x5c));
HIDDEN(ape_elf_shstrndx = (0)); HIDDEN(ape_elf_shstrndx_bcs0 = (((((((0) >> ((0)*8)) >> 0)&0x7) + 0x30) << 24) | ((((((0) >> ((0)*8)) >> 3)&0x7) + 0x30) << 16) | (((((((0) >> ((0)*8))&0xff) >> 6)&0x7) + 0x30) << 8) | 0x5c)); HIDDEN(ape_elf_shstrndx_bcs1 = (((((((0) >> ((1)*8)) >> 0)&0x7) + 0x30) << 24) | ((((((0) >> ((1)*8)) >> 3)&0x7) + 0x30) << 16) | (((((((0) >> ((1)*8))&0xff) >> 6)&0x7) + 0x30) << 8) | 0x5c)); HIDDEN(ape_elf_shstrndx_bcs2 = (((((((0) >> ((2)*8)) >> 0)&0x7) + 0x30) << 24) | ((((((0) >> ((2)*8)) >> 3)&0x7) + 0x30) << 16) | (((((((0) >> ((2)*8))&0xff) >> 6)&0x7) + 0x30) << 8) | 0x5c)); HIDDEN(ape_elf_shstrndx_bcs3 = (((((((0) >> ((3)*8)) >> 0)&0x7) + 0x30) << 24) | ((((((0) >> ((3)*8)) >> 3)&0x7) + 0x30) << 16) | (((((((0) >> ((3)*8))&0xff) >> 6)&0x7) + 0x30) << 8) | 0x5c));
HIDDEN(__privileged_addr = ((__privileged_start) & -(0x1000)));
HIDDEN(__privileged_size = ((((__privileged_end) + (0x1000)-1) & -(0x1000)) -
((__privileged_start) & -(0x1000))));
HIDDEN(ape_rom_offset = 0);
HIDDEN(ape_rom_vaddr = ADDR(.head));
HIDDEN(ape_rom_paddr = LOADADDR(.head));
HIDDEN(ape_rom_filesz = LOADADDR(.data) - ape_rom_paddr);
HIDDEN(ape_rom_memsz = ADDR(.data) - ADDR(.head));
HIDDEN(ape_rom_align = 0x1000);
HIDDEN(ape_rom_rva = ((ape_rom_vaddr) - (0x400000)));
HIDDEN(ape_ram_offset = ape_rom_offset + ape_rom_filesz);
HIDDEN(ape_ram_vaddr = ADDR(.data));
HIDDEN(ape_ram_paddr = LOADADDR(.data));
HIDDEN(ape_ram_filesz = SIZEOF(.data));
HIDDEN(ape_ram_memsz = ADDR(.bss) + SIZEOF(.bss) - ape_ram_vaddr);
HIDDEN(ape_ram_align = 0x1000);
HIDDEN(ape_ram_rva = ((ape_ram_vaddr) - (0x400000)));
HIDDEN(ape_stack_offset = ape_ram_offset + ape_ram_filesz);
HIDDEN(ape_stack_vaddr = 0x700000000000 - 0x100000);
HIDDEN(ape_stack_paddr = ape_ram_paddr + ape_ram_filesz);
HIDDEN(ape_stack_filesz = 0);
HIDDEN(ape_stack_memsz = 0x100000);
HIDDEN(ape_stack_align = 16);
HIDDEN(ape_note_offset = ape_rom_offset + (ape_note - ape_rom_vaddr));
HIDDEN(ape_note_vaddr = ape_note);
HIDDEN(ape_note_paddr = ape_rom_paddr + ape_note_offset);
HIDDEN(ape_note_filesz = ape_note_end - ape_note);
HIDDEN(ape_note_memsz = ape_note_filesz);
HIDDEN(ape_note_align = 8);
HIDDEN(ape_text_offset = ape_rom_offset + LOADADDR(.text) - ape_rom_paddr);
HIDDEN(ape_text_paddr = LOADADDR(.text));
HIDDEN(ape_text_vaddr = ADDR(.text));
HIDDEN(ape_text_filesz = SIZEOF(.text));
HIDDEN(ape_text_memsz = SIZEOF(.text));
HIDDEN(ape_text_align = 0x1000);
HIDDEN(ape_text_rva = ((ape_text_vaddr) - (0x400000)));
HIDDEN(ape_data_offset = ape_ram_offset + LOADADDR(.data) - ape_ram_paddr);
HIDDEN(ape_data_paddr = LOADADDR(.data));
HIDDEN(ape_data_vaddr = ADDR(.data));
HIDDEN(ape_data_filesz = SIZEOF(.data));
HIDDEN(ape_data_memsz = SIZEOF(.data));
HIDDEN(ape_data_align = 0x1000);
HIDDEN(ape_data_rva = ((ape_data_vaddr) - (0x400000)));
HIDDEN(ape_bss_offset = ape_ram_offset + LOADADDR(.bss) - ape_ram_paddr);
HIDDEN(ape_bss_paddr = LOADADDR(.bss));
HIDDEN(ape_bss_vaddr = ADDR(.bss));
HIDDEN(ape_bss_filesz = 0);
HIDDEN(ape_bss_memsz = SIZEOF(.bss));
HIDDEN(ape_bss_align = 0x1000);
HIDDEN(ape_macho_dd_skip_bcs0 = ((((ape_macho) - (0x400000)) / 8) < 10000 ? 0x20202020 : (((ape_macho) - (0x400000)) / 8) < 100000 ? 0x30202020 + (((((ape_macho) - (0x400000)) / 8) / 10000 % 10) << 24) : (((ape_macho) - (0x400000)) / 8) < 1000000 ? 0x30302020 + (((((ape_macho) - (0x400000)) / 8) / 10000 % 10) << 24) + (((((ape_macho) - (0x400000)) / 8) / 100000 % 10) << 16) : (((ape_macho) - (0x400000)) / 8) < 10000000 ? 0x30303020 + (((((ape_macho) - (0x400000)) / 8) / 10000 % 10) << 24) + (((((ape_macho) - (0x400000)) / 8) / 100000 % 10) << 16) + (((((ape_macho) - (0x400000)) / 8) / 1000000 % 10) << 8) : (((ape_macho) - (0x400000)) / 8) < 100000000 ? 0x30303030 + (((((ape_macho) - (0x400000)) / 8) / 10000 % 10) << 24) + (((((ape_macho) - (0x400000)) / 8) / 100000 % 10) << 16) + (((((ape_macho) - (0x400000)) / 8) / 1000000 % 10) << 8) + (((((ape_macho) - (0x400000)) / 8) / 10000000 % 10) << 0) : 0xffffffffffffffff)); HIDDEN(ape_macho_dd_skip_bcs1 = ((((ape_macho) - (0x400000)) / 8) == 0 ? 0x20202030 : (((ape_macho) - (0x400000)) / 8) < 10 ? 0x30202020 + (((((ape_macho) - (0x400000)) / 8) % 10) << 24) : (((ape_macho) - (0x400000)) / 8) < 100 ? 0x30302020 + (((((ape_macho) - (0x400000)) / 8) % 10) << 24) + (((((ape_macho) - (0x400000)) / 8) / 10 % 10) << 16) : (((ape_macho) - (0x400000)) / 8) < 1000 ? 0x30303020 + (((((ape_macho) - (0x400000)) / 8) % 10) << 24) + (((((ape_macho) - (0x400000)) / 8) / 10 % 10) << 16) + (((((ape_macho) - (0x400000)) / 8) / 100 % 10) << 8) : 0x30303030 + (((((ape_macho) - (0x400000)) / 8) % 10) << 24) + (((((ape_macho) - (0x400000)) / 8) / 10 % 10) << 16) + (((((ape_macho) - (0x400000)) / 8) / 100 % 10) << 8) + (((((ape_macho) - (0x400000)) / 8) / 1000 % 10) << 0)));
HIDDEN(ape_macho_dd_count_bcs0 = (((ape_macho_end - ape_macho) / 8) < 10000 ? 0x20202020 : ((ape_macho_end - ape_macho) / 8) < 100000 ? 0x30202020 + ((((ape_macho_end - ape_macho) / 8) / 10000 % 10) << 24) : ((ape_macho_end - ape_macho) / 8) < 1000000 ? 0x30302020 + ((((ape_macho_end - ape_macho) / 8) / 10000 % 10) << 24) + ((((ape_macho_end - ape_macho) / 8) / 100000 % 10) << 16) : ((ape_macho_end - ape_macho) / 8) < 10000000 ? 0x30303020 + ((((ape_macho_end - ape_macho) / 8) / 10000 % 10) << 24) + ((((ape_macho_end - ape_macho) / 8) / 100000 % 10) << 16) + ((((ape_macho_end - ape_macho) / 8) / 1000000 % 10) << 8) : ((ape_macho_end - ape_macho) / 8) < 100000000 ? 0x30303030 + ((((ape_macho_end - ape_macho) / 8) / 10000 % 10) << 24) + ((((ape_macho_end - ape_macho) / 8) / 100000 % 10) << 16) + ((((ape_macho_end - ape_macho) / 8) / 1000000 % 10) << 8) + ((((ape_macho_end - ape_macho) / 8) / 10000000 % 10) << 0) : 0xffffffffffffffff)); HIDDEN(ape_macho_dd_count_bcs1 = (((ape_macho_end - ape_macho) / 8) == 0 ? 0x20202030 : ((ape_macho_end - ape_macho) / 8) < 10 ? 0x30202020 + ((((ape_macho_end - ape_macho) / 8) % 10) << 24) : ((ape_macho_end - ape_macho) / 8) < 100 ? 0x30302020 + ((((ape_macho_end - ape_macho) / 8) % 10) << 24) + ((((ape_macho_end - ape_macho) / 8) / 10 % 10) << 16) : ((ape_macho_end - ape_macho) / 8) < 1000 ? 0x30303020 + ((((ape_macho_end - ape_macho) / 8) % 10) << 24) + ((((ape_macho_end - ape_macho) / 8) / 10 % 10) << 16) + ((((ape_macho_end - ape_macho) / 8) / 100 % 10) << 8) : 0x30303030 + ((((ape_macho_end - ape_macho) / 8) % 10) << 24) + ((((ape_macho_end - ape_macho) / 8) / 10 % 10) << 16) + ((((ape_macho_end - ape_macho) / 8) / 100 % 10) << 8) + ((((ape_macho_end - ape_macho) / 8) / 1000 % 10) << 0)));
HIDDEN(ape_pe_offset = (ape_pe - ape_mz)); HIDDEN(ape_pe_offset_bcs0 = (((((((ape_pe - ape_mz) >> ((0)*8)) >> 0)&0x7) + 0x30) << 24) | ((((((ape_pe - ape_mz) >> ((0)*8)) >> 3)&0x7) + 0x30) << 16) | (((((((ape_pe - ape_mz) >> ((0)*8))&0xff) >> 6)&0x7) + 0x30) << 8) | 0x5c)); HIDDEN(ape_pe_offset_bcs1 = (((((((ape_pe - ape_mz) >> ((1)*8)) >> 0)&0x7) + 0x30) << 24) | ((((((ape_pe - ape_mz) >> ((1)*8)) >> 3)&0x7) + 0x30) << 16) | (((((((ape_pe - ape_mz) >> ((1)*8))&0xff) >> 6)&0x7) + 0x30) << 8) | 0x5c)); HIDDEN(ape_pe_offset_bcs2 = (((((((ape_pe - ape_mz) >> ((2)*8)) >> 0)&0x7) + 0x30) << 24) | ((((((ape_pe - ape_mz) >> ((2)*8)) >> 3)&0x7) + 0x30) << 16) | (((((((ape_pe - ape_mz) >> ((2)*8))&0xff) >> 6)&0x7) + 0x30) << 8) | 0x5c)); HIDDEN(ape_pe_offset_bcs3 = (((((((ape_pe - ape_mz) >> ((3)*8)) >> 0)&0x7) + 0x30) << 24) | ((((((ape_pe - ape_mz) >> ((3)*8)) >> 3)&0x7) + 0x30) << 16) | (((((((ape_pe - ape_mz) >> ((3)*8))&0xff) >> 6)&0x7) + 0x30) << 8) | 0x5c));
HIDDEN(ape_pe_optsz = ape_pe_sections - (ape_pe + 24));
HIDDEN(ape_pe_shnum = (ape_pe_sections_end - ape_pe_sections) / 40);
HIDDEN(ape_pe_base = 0x400000);
HIDDEN(ape_idata = (((255 & 4) == 4) && !DEFINED(EfiMain)) ? ((ape_idata_iat) - (0x400000)) : 0);
HIDDEN(ape_idata_iatsize = (((255 & 4) == 4) && !DEFINED(EfiMain)) ? ape_idata_iatend - ape_idata_iat : 0);
HIDDEN(ape_idata = (((255 & 4) == 4) && !DEFINED(EfiMain)) ? ((ape_idata_idt) - (0x400000)) : 0);
HIDDEN(ape_idata_idtsize = (((255 & 4) == 4) && !DEFINED(EfiMain)) ? ape_idata_idtend - ape_idata_idt : 0);
HIDDEN(v_ntversion = (((255 & 4) == 4) && !DEFINED(EfiMain)) ? 6 : 1);
HIDDEN(v_ntdllchar = (((255 & 4) == 4) && !DEFINED(EfiMain)) ? 288 : 0);
HIDDEN(v_ntsubversion = (((255 & 4) == 4) && !DEFINED(EfiMain)) ? 6 : 5);
HIDDEN(v_ntsubsystem = ((((255 & 4) == 4) && !DEFINED(EfiMain))
? (DEFINED(GetMessage)
? 2
: 3)
: 10));
HIDDEN(ape_pe_entry = (((255 & 4) == 4) && !DEFINED(EfiMain)) ? WinMain : EfiMain);
HIDDEN(v_ape_realsectors =
(((((((_edata) - (0x400000))) + (4096)-1) & -(4096))) > (0x70000 - 0x2000) ? (0x70000 - 0x2000) : ((((((_edata) - (0x400000))) + (4096)-1) & -(4096)))) / 512);
HIDDEN(v_ape_realpages = v_ape_realsectors / (4096 / 512));
HIDDEN(v_ape_highsectors =
((((((_edata) - (0x400000))) + (512)-1) & -(512)) / 512) - v_ape_realsectors);
HIDDEN(v_zip_cdoffset = DEFINED(__zip_start) ? __zip_start - 0x400000 : 0);;
HIDDEN(v_zip_cdirsize = DEFINED(__zip_start) ? __zip_end - __zip_start : 0);;
ASSERT(v_zip_cdirsize % (((46 + 248) + (2)-1) & -(2)) == 0, "bad zip cdir");
HIDDEN(v_zip_records = DEFINED(__zip_start) ? v_zip_cdirsize / (((46 + 248) + (2)-1) & -(2)) : 0);;
HIDDEN(v_zip_commentsize = DEFINED(__zip_start) ? _ezip - __zip_end - 22 : 0);;
HIDDEN(ape_uuid1 = 88172645463325252);
HIDDEN(ape_uuid2 = 88172645463325252);
ape_uuid1 = ((ape_uuid1 | (ape_bss_align >> 12)) - (ape_uuid1 & (ape_bss_align >> 12))); ape_uuid1 = ((ape_uuid1 | (ape_bss_align << 25)) - (ape_uuid1 & (ape_bss_align << 25))); ape_uuid1 = ((ape_uuid1 | (ape_bss_align >> 27)) - (ape_uuid1 & (ape_bss_align >> 27))); ape_uuid1 = (ape_uuid1 + (ape_bss_align >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_bss_align >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_bss_align >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_bss_align >> 030) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = ((ape_uuid2 | (ape_bss_align >> 12)) - (ape_uuid2 & (ape_bss_align >> 12))); ape_uuid2 = ((ape_uuid2 | (ape_bss_align << 25)) - (ape_uuid2 & (ape_bss_align << 25))); ape_uuid2 = ((ape_uuid2 | (ape_bss_align >> 27)) - (ape_uuid2 & (ape_bss_align >> 27))); ape_uuid2 = (ape_uuid2 + (ape_bss_align >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_bss_align >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_bss_align >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_bss_align >> 030) & 0xFF) * 0x9e3779b9925d4c17;
ape_uuid1 = ((ape_uuid1 | (ape_bss_filesz >> 12)) - (ape_uuid1 & (ape_bss_filesz >> 12))); ape_uuid1 = ((ape_uuid1 | (ape_bss_filesz << 25)) - (ape_uuid1 & (ape_bss_filesz << 25))); ape_uuid1 = ((ape_uuid1 | (ape_bss_filesz >> 27)) - (ape_uuid1 & (ape_bss_filesz >> 27))); ape_uuid1 = (ape_uuid1 + (ape_bss_filesz >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_bss_filesz >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_bss_filesz >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_bss_filesz >> 030) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = ((ape_uuid2 | (ape_bss_filesz >> 12)) - (ape_uuid2 & (ape_bss_filesz >> 12))); ape_uuid2 = ((ape_uuid2 | (ape_bss_filesz << 25)) - (ape_uuid2 & (ape_bss_filesz << 25))); ape_uuid2 = ((ape_uuid2 | (ape_bss_filesz >> 27)) - (ape_uuid2 & (ape_bss_filesz >> 27))); ape_uuid2 = (ape_uuid2 + (ape_bss_filesz >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_bss_filesz >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_bss_filesz >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_bss_filesz >> 030) & 0xFF) * 0x9e3779b9925d4c17;
ape_uuid1 = ((ape_uuid1 | (ape_bss_memsz >> 12)) - (ape_uuid1 & (ape_bss_memsz >> 12))); ape_uuid1 = ((ape_uuid1 | (ape_bss_memsz << 25)) - (ape_uuid1 & (ape_bss_memsz << 25))); ape_uuid1 = ((ape_uuid1 | (ape_bss_memsz >> 27)) - (ape_uuid1 & (ape_bss_memsz >> 27))); ape_uuid1 = (ape_uuid1 + (ape_bss_memsz >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_bss_memsz >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_bss_memsz >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_bss_memsz >> 030) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = ((ape_uuid2 | (ape_bss_memsz >> 12)) - (ape_uuid2 & (ape_bss_memsz >> 12))); ape_uuid2 = ((ape_uuid2 | (ape_bss_memsz << 25)) - (ape_uuid2 & (ape_bss_memsz << 25))); ape_uuid2 = ((ape_uuid2 | (ape_bss_memsz >> 27)) - (ape_uuid2 & (ape_bss_memsz >> 27))); ape_uuid2 = (ape_uuid2 + (ape_bss_memsz >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_bss_memsz >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_bss_memsz >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_bss_memsz >> 030) & 0xFF) * 0x9e3779b9925d4c17;
ape_uuid1 = ((ape_uuid1 | (ape_bss_offset >> 12)) - (ape_uuid1 & (ape_bss_offset >> 12))); ape_uuid1 = ((ape_uuid1 | (ape_bss_offset << 25)) - (ape_uuid1 & (ape_bss_offset << 25))); ape_uuid1 = ((ape_uuid1 | (ape_bss_offset >> 27)) - (ape_uuid1 & (ape_bss_offset >> 27))); ape_uuid1 = (ape_uuid1 + (ape_bss_offset >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_bss_offset >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_bss_offset >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_bss_offset >> 030) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = ((ape_uuid2 | (ape_bss_offset >> 12)) - (ape_uuid2 & (ape_bss_offset >> 12))); ape_uuid2 = ((ape_uuid2 | (ape_bss_offset << 25)) - (ape_uuid2 & (ape_bss_offset << 25))); ape_uuid2 = ((ape_uuid2 | (ape_bss_offset >> 27)) - (ape_uuid2 & (ape_bss_offset >> 27))); ape_uuid2 = (ape_uuid2 + (ape_bss_offset >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_bss_offset >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_bss_offset >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_bss_offset >> 030) & 0xFF) * 0x9e3779b9925d4c17;
ape_uuid1 = ((ape_uuid1 | (ape_bss_paddr >> 12)) - (ape_uuid1 & (ape_bss_paddr >> 12))); ape_uuid1 = ((ape_uuid1 | (ape_bss_paddr << 25)) - (ape_uuid1 & (ape_bss_paddr << 25))); ape_uuid1 = ((ape_uuid1 | (ape_bss_paddr >> 27)) - (ape_uuid1 & (ape_bss_paddr >> 27))); ape_uuid1 = (ape_uuid1 + (ape_bss_paddr >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_bss_paddr >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_bss_paddr >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_bss_paddr >> 030) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = ((ape_uuid2 | (ape_bss_paddr >> 12)) - (ape_uuid2 & (ape_bss_paddr >> 12))); ape_uuid2 = ((ape_uuid2 | (ape_bss_paddr << 25)) - (ape_uuid2 & (ape_bss_paddr << 25))); ape_uuid2 = ((ape_uuid2 | (ape_bss_paddr >> 27)) - (ape_uuid2 & (ape_bss_paddr >> 27))); ape_uuid2 = (ape_uuid2 + (ape_bss_paddr >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_bss_paddr >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_bss_paddr >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_bss_paddr >> 030) & 0xFF) * 0x9e3779b9925d4c17;
ape_uuid1 = ((ape_uuid1 | (ape_data_filesz >> 12)) - (ape_uuid1 & (ape_data_filesz >> 12))); ape_uuid1 = ((ape_uuid1 | (ape_data_filesz << 25)) - (ape_uuid1 & (ape_data_filesz << 25))); ape_uuid1 = ((ape_uuid1 | (ape_data_filesz >> 27)) - (ape_uuid1 & (ape_data_filesz >> 27))); ape_uuid1 = (ape_uuid1 + (ape_data_filesz >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_data_filesz >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_data_filesz >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_data_filesz >> 030) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = ((ape_uuid2 | (ape_data_filesz >> 12)) - (ape_uuid2 & (ape_data_filesz >> 12))); ape_uuid2 = ((ape_uuid2 | (ape_data_filesz << 25)) - (ape_uuid2 & (ape_data_filesz << 25))); ape_uuid2 = ((ape_uuid2 | (ape_data_filesz >> 27)) - (ape_uuid2 & (ape_data_filesz >> 27))); ape_uuid2 = (ape_uuid2 + (ape_data_filesz >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_data_filesz >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_data_filesz >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_data_filesz >> 030) & 0xFF) * 0x9e3779b9925d4c17;
ape_uuid1 = ((ape_uuid1 | (ape_data_memsz >> 12)) - (ape_uuid1 & (ape_data_memsz >> 12))); ape_uuid1 = ((ape_uuid1 | (ape_data_memsz << 25)) - (ape_uuid1 & (ape_data_memsz << 25))); ape_uuid1 = ((ape_uuid1 | (ape_data_memsz >> 27)) - (ape_uuid1 & (ape_data_memsz >> 27))); ape_uuid1 = (ape_uuid1 + (ape_data_memsz >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_data_memsz >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_data_memsz >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_data_memsz >> 030) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = ((ape_uuid2 | (ape_data_memsz >> 12)) - (ape_uuid2 & (ape_data_memsz >> 12))); ape_uuid2 = ((ape_uuid2 | (ape_data_memsz << 25)) - (ape_uuid2 & (ape_data_memsz << 25))); ape_uuid2 = ((ape_uuid2 | (ape_data_memsz >> 27)) - (ape_uuid2 & (ape_data_memsz >> 27))); ape_uuid2 = (ape_uuid2 + (ape_data_memsz >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_data_memsz >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_data_memsz >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_data_memsz >> 030) & 0xFF) * 0x9e3779b9925d4c17;
ape_uuid1 = ((ape_uuid1 | (ape_data_offset >> 12)) - (ape_uuid1 & (ape_data_offset >> 12))); ape_uuid1 = ((ape_uuid1 | (ape_data_offset << 25)) - (ape_uuid1 & (ape_data_offset << 25))); ape_uuid1 = ((ape_uuid1 | (ape_data_offset >> 27)) - (ape_uuid1 & (ape_data_offset >> 27))); ape_uuid1 = (ape_uuid1 + (ape_data_offset >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_data_offset >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_data_offset >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_data_offset >> 030) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = ((ape_uuid2 | (ape_data_offset >> 12)) - (ape_uuid2 & (ape_data_offset >> 12))); ape_uuid2 = ((ape_uuid2 | (ape_data_offset << 25)) - (ape_uuid2 & (ape_data_offset << 25))); ape_uuid2 = ((ape_uuid2 | (ape_data_offset >> 27)) - (ape_uuid2 & (ape_data_offset >> 27))); ape_uuid2 = (ape_uuid2 + (ape_data_offset >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_data_offset >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_data_offset >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_data_offset >> 030) & 0xFF) * 0x9e3779b9925d4c17;
ape_uuid1 = ((ape_uuid1 | (ape_data_paddr >> 12)) - (ape_uuid1 & (ape_data_paddr >> 12))); ape_uuid1 = ((ape_uuid1 | (ape_data_paddr << 25)) - (ape_uuid1 & (ape_data_paddr << 25))); ape_uuid1 = ((ape_uuid1 | (ape_data_paddr >> 27)) - (ape_uuid1 & (ape_data_paddr >> 27))); ape_uuid1 = (ape_uuid1 + (ape_data_paddr >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_data_paddr >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_data_paddr >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_data_paddr >> 030) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = ((ape_uuid2 | (ape_data_paddr >> 12)) - (ape_uuid2 & (ape_data_paddr >> 12))); ape_uuid2 = ((ape_uuid2 | (ape_data_paddr << 25)) - (ape_uuid2 & (ape_data_paddr << 25))); ape_uuid2 = ((ape_uuid2 | (ape_data_paddr >> 27)) - (ape_uuid2 & (ape_data_paddr >> 27))); ape_uuid2 = (ape_uuid2 + (ape_data_paddr >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_data_paddr >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_data_paddr >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_data_paddr >> 030) & 0xFF) * 0x9e3779b9925d4c17;
ape_uuid1 = ((ape_uuid1 | (ape_data_rva >> 12)) - (ape_uuid1 & (ape_data_rva >> 12))); ape_uuid1 = ((ape_uuid1 | (ape_data_rva << 25)) - (ape_uuid1 & (ape_data_rva << 25))); ape_uuid1 = ((ape_uuid1 | (ape_data_rva >> 27)) - (ape_uuid1 & (ape_data_rva >> 27))); ape_uuid1 = (ape_uuid1 + (ape_data_rva >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_data_rva >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_data_rva >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_data_rva >> 030) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = ((ape_uuid2 | (ape_data_rva >> 12)) - (ape_uuid2 & (ape_data_rva >> 12))); ape_uuid2 = ((ape_uuid2 | (ape_data_rva << 25)) - (ape_uuid2 & (ape_data_rva << 25))); ape_uuid2 = ((ape_uuid2 | (ape_data_rva >> 27)) - (ape_uuid2 & (ape_data_rva >> 27))); ape_uuid2 = (ape_uuid2 + (ape_data_rva >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_data_rva >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_data_rva >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_data_rva >> 030) & 0xFF) * 0x9e3779b9925d4c17;
ape_uuid1 = ((ape_uuid1 | (ape_data_vaddr >> 12)) - (ape_uuid1 & (ape_data_vaddr >> 12))); ape_uuid1 = ((ape_uuid1 | (ape_data_vaddr << 25)) - (ape_uuid1 & (ape_data_vaddr << 25))); ape_uuid1 = ((ape_uuid1 | (ape_data_vaddr >> 27)) - (ape_uuid1 & (ape_data_vaddr >> 27))); ape_uuid1 = (ape_uuid1 + (ape_data_vaddr >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_data_vaddr >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_data_vaddr >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_data_vaddr >> 030) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = ((ape_uuid2 | (ape_data_vaddr >> 12)) - (ape_uuid2 & (ape_data_vaddr >> 12))); ape_uuid2 = ((ape_uuid2 | (ape_data_vaddr << 25)) - (ape_uuid2 & (ape_data_vaddr << 25))); ape_uuid2 = ((ape_uuid2 | (ape_data_vaddr >> 27)) - (ape_uuid2 & (ape_data_vaddr >> 27))); ape_uuid2 = (ape_uuid2 + (ape_data_vaddr >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_data_vaddr >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_data_vaddr >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_data_vaddr >> 030) & 0xFF) * 0x9e3779b9925d4c17;
ape_uuid1 = ((ape_uuid1 | (ape_elf_entry >> 12)) - (ape_uuid1 & (ape_elf_entry >> 12))); ape_uuid1 = ((ape_uuid1 | (ape_elf_entry << 25)) - (ape_uuid1 & (ape_elf_entry << 25))); ape_uuid1 = ((ape_uuid1 | (ape_elf_entry >> 27)) - (ape_uuid1 & (ape_elf_entry >> 27))); ape_uuid1 = (ape_uuid1 + (ape_elf_entry >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_elf_entry >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_elf_entry >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_elf_entry >> 030) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = ((ape_uuid2 | (ape_elf_entry >> 12)) - (ape_uuid2 & (ape_elf_entry >> 12))); ape_uuid2 = ((ape_uuid2 | (ape_elf_entry << 25)) - (ape_uuid2 & (ape_elf_entry << 25))); ape_uuid2 = ((ape_uuid2 | (ape_elf_entry >> 27)) - (ape_uuid2 & (ape_elf_entry >> 27))); ape_uuid2 = (ape_uuid2 + (ape_elf_entry >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_elf_entry >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_elf_entry >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_elf_entry >> 030) & 0xFF) * 0x9e3779b9925d4c17;
ape_uuid1 = ((ape_uuid1 | (ape_elf_phnum >> 12)) - (ape_uuid1 & (ape_elf_phnum >> 12))); ape_uuid1 = ((ape_uuid1 | (ape_elf_phnum << 25)) - (ape_uuid1 & (ape_elf_phnum << 25))); ape_uuid1 = ((ape_uuid1 | (ape_elf_phnum >> 27)) - (ape_uuid1 & (ape_elf_phnum >> 27))); ape_uuid1 = (ape_uuid1 + (ape_elf_phnum >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_elf_phnum >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_elf_phnum >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_elf_phnum >> 030) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = ((ape_uuid2 | (ape_elf_phnum >> 12)) - (ape_uuid2 & (ape_elf_phnum >> 12))); ape_uuid2 = ((ape_uuid2 | (ape_elf_phnum << 25)) - (ape_uuid2 & (ape_elf_phnum << 25))); ape_uuid2 = ((ape_uuid2 | (ape_elf_phnum >> 27)) - (ape_uuid2 & (ape_elf_phnum >> 27))); ape_uuid2 = (ape_uuid2 + (ape_elf_phnum >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_elf_phnum >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_elf_phnum >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_elf_phnum >> 030) & 0xFF) * 0x9e3779b9925d4c17;
ape_uuid1 = ((ape_uuid1 | (ape_elf_phoff >> 12)) - (ape_uuid1 & (ape_elf_phoff >> 12))); ape_uuid1 = ((ape_uuid1 | (ape_elf_phoff << 25)) - (ape_uuid1 & (ape_elf_phoff << 25))); ape_uuid1 = ((ape_uuid1 | (ape_elf_phoff >> 27)) - (ape_uuid1 & (ape_elf_phoff >> 27))); ape_uuid1 = (ape_uuid1 + (ape_elf_phoff >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_elf_phoff >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_elf_phoff >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_elf_phoff >> 030) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = ((ape_uuid2 | (ape_elf_phoff >> 12)) - (ape_uuid2 & (ape_elf_phoff >> 12))); ape_uuid2 = ((ape_uuid2 | (ape_elf_phoff << 25)) - (ape_uuid2 & (ape_elf_phoff << 25))); ape_uuid2 = ((ape_uuid2 | (ape_elf_phoff >> 27)) - (ape_uuid2 & (ape_elf_phoff >> 27))); ape_uuid2 = (ape_uuid2 + (ape_elf_phoff >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_elf_phoff >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_elf_phoff >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_elf_phoff >> 030) & 0xFF) * 0x9e3779b9925d4c17;
ape_uuid1 = ((ape_uuid1 | (ape_elf_shnum >> 12)) - (ape_uuid1 & (ape_elf_shnum >> 12))); ape_uuid1 = ((ape_uuid1 | (ape_elf_shnum << 25)) - (ape_uuid1 & (ape_elf_shnum << 25))); ape_uuid1 = ((ape_uuid1 | (ape_elf_shnum >> 27)) - (ape_uuid1 & (ape_elf_shnum >> 27))); ape_uuid1 = (ape_uuid1 + (ape_elf_shnum >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_elf_shnum >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_elf_shnum >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_elf_shnum >> 030) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = ((ape_uuid2 | (ape_elf_shnum >> 12)) - (ape_uuid2 & (ape_elf_shnum >> 12))); ape_uuid2 = ((ape_uuid2 | (ape_elf_shnum << 25)) - (ape_uuid2 & (ape_elf_shnum << 25))); ape_uuid2 = ((ape_uuid2 | (ape_elf_shnum >> 27)) - (ape_uuid2 & (ape_elf_shnum >> 27))); ape_uuid2 = (ape_uuid2 + (ape_elf_shnum >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_elf_shnum >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_elf_shnum >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_elf_shnum >> 030) & 0xFF) * 0x9e3779b9925d4c17;
ape_uuid1 = ((ape_uuid1 | (ape_elf_shoff >> 12)) - (ape_uuid1 & (ape_elf_shoff >> 12))); ape_uuid1 = ((ape_uuid1 | (ape_elf_shoff << 25)) - (ape_uuid1 & (ape_elf_shoff << 25))); ape_uuid1 = ((ape_uuid1 | (ape_elf_shoff >> 27)) - (ape_uuid1 & (ape_elf_shoff >> 27))); ape_uuid1 = (ape_uuid1 + (ape_elf_shoff >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_elf_shoff >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_elf_shoff >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_elf_shoff >> 030) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = ((ape_uuid2 | (ape_elf_shoff >> 12)) - (ape_uuid2 & (ape_elf_shoff >> 12))); ape_uuid2 = ((ape_uuid2 | (ape_elf_shoff << 25)) - (ape_uuid2 & (ape_elf_shoff << 25))); ape_uuid2 = ((ape_uuid2 | (ape_elf_shoff >> 27)) - (ape_uuid2 & (ape_elf_shoff >> 27))); ape_uuid2 = (ape_uuid2 + (ape_elf_shoff >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_elf_shoff >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_elf_shoff >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_elf_shoff >> 030) & 0xFF) * 0x9e3779b9925d4c17;
ape_uuid1 = ((ape_uuid1 | (ape_elf_shstrndx >> 12)) - (ape_uuid1 & (ape_elf_shstrndx >> 12))); ape_uuid1 = ((ape_uuid1 | (ape_elf_shstrndx << 25)) - (ape_uuid1 & (ape_elf_shstrndx << 25))); ape_uuid1 = ((ape_uuid1 | (ape_elf_shstrndx >> 27)) - (ape_uuid1 & (ape_elf_shstrndx >> 27))); ape_uuid1 = (ape_uuid1 + (ape_elf_shstrndx >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_elf_shstrndx >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_elf_shstrndx >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_elf_shstrndx >> 030) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = ((ape_uuid2 | (ape_elf_shstrndx >> 12)) - (ape_uuid2 & (ape_elf_shstrndx >> 12))); ape_uuid2 = ((ape_uuid2 | (ape_elf_shstrndx << 25)) - (ape_uuid2 & (ape_elf_shstrndx << 25))); ape_uuid2 = ((ape_uuid2 | (ape_elf_shstrndx >> 27)) - (ape_uuid2 & (ape_elf_shstrndx >> 27))); ape_uuid2 = (ape_uuid2 + (ape_elf_shstrndx >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_elf_shstrndx >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_elf_shstrndx >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_elf_shstrndx >> 030) & 0xFF) * 0x9e3779b9925d4c17;
ape_uuid1 = ((ape_uuid1 | (ape_macho_end >> 12)) - (ape_uuid1 & (ape_macho_end >> 12))); ape_uuid1 = ((ape_uuid1 | (ape_macho_end << 25)) - (ape_uuid1 & (ape_macho_end << 25))); ape_uuid1 = ((ape_uuid1 | (ape_macho_end >> 27)) - (ape_uuid1 & (ape_macho_end >> 27))); ape_uuid1 = (ape_uuid1 + (ape_macho_end >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_macho_end >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_macho_end >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_macho_end >> 030) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = ((ape_uuid2 | (ape_macho_end >> 12)) - (ape_uuid2 & (ape_macho_end >> 12))); ape_uuid2 = ((ape_uuid2 | (ape_macho_end << 25)) - (ape_uuid2 & (ape_macho_end << 25))); ape_uuid2 = ((ape_uuid2 | (ape_macho_end >> 27)) - (ape_uuid2 & (ape_macho_end >> 27))); ape_uuid2 = (ape_uuid2 + (ape_macho_end >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_macho_end >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_macho_end >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_macho_end >> 030) & 0xFF) * 0x9e3779b9925d4c17;
ape_uuid1 = ((ape_uuid1 | (ape_note >> 12)) - (ape_uuid1 & (ape_note >> 12))); ape_uuid1 = ((ape_uuid1 | (ape_note << 25)) - (ape_uuid1 & (ape_note << 25))); ape_uuid1 = ((ape_uuid1 | (ape_note >> 27)) - (ape_uuid1 & (ape_note >> 27))); ape_uuid1 = (ape_uuid1 + (ape_note >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_note >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_note >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_note >> 030) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = ((ape_uuid2 | (ape_note >> 12)) - (ape_uuid2 & (ape_note >> 12))); ape_uuid2 = ((ape_uuid2 | (ape_note << 25)) - (ape_uuid2 & (ape_note << 25))); ape_uuid2 = ((ape_uuid2 | (ape_note >> 27)) - (ape_uuid2 & (ape_note >> 27))); ape_uuid2 = (ape_uuid2 + (ape_note >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_note >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_note >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_note >> 030) & 0xFF) * 0x9e3779b9925d4c17;
ape_uuid1 = ((ape_uuid1 | (ape_note_align >> 12)) - (ape_uuid1 & (ape_note_align >> 12))); ape_uuid1 = ((ape_uuid1 | (ape_note_align << 25)) - (ape_uuid1 & (ape_note_align << 25))); ape_uuid1 = ((ape_uuid1 | (ape_note_align >> 27)) - (ape_uuid1 & (ape_note_align >> 27))); ape_uuid1 = (ape_uuid1 + (ape_note_align >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_note_align >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_note_align >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_note_align >> 030) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = ((ape_uuid2 | (ape_note_align >> 12)) - (ape_uuid2 & (ape_note_align >> 12))); ape_uuid2 = ((ape_uuid2 | (ape_note_align << 25)) - (ape_uuid2 & (ape_note_align << 25))); ape_uuid2 = ((ape_uuid2 | (ape_note_align >> 27)) - (ape_uuid2 & (ape_note_align >> 27))); ape_uuid2 = (ape_uuid2 + (ape_note_align >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_note_align >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_note_align >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_note_align >> 030) & 0xFF) * 0x9e3779b9925d4c17;
ape_uuid1 = ((ape_uuid1 | (ape_note_end >> 12)) - (ape_uuid1 & (ape_note_end >> 12))); ape_uuid1 = ((ape_uuid1 | (ape_note_end << 25)) - (ape_uuid1 & (ape_note_end << 25))); ape_uuid1 = ((ape_uuid1 | (ape_note_end >> 27)) - (ape_uuid1 & (ape_note_end >> 27))); ape_uuid1 = (ape_uuid1 + (ape_note_end >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_note_end >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_note_end >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_note_end >> 030) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = ((ape_uuid2 | (ape_note_end >> 12)) - (ape_uuid2 & (ape_note_end >> 12))); ape_uuid2 = ((ape_uuid2 | (ape_note_end << 25)) - (ape_uuid2 & (ape_note_end << 25))); ape_uuid2 = ((ape_uuid2 | (ape_note_end >> 27)) - (ape_uuid2 & (ape_note_end >> 27))); ape_uuid2 = (ape_uuid2 + (ape_note_end >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_note_end >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_note_end >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_note_end >> 030) & 0xFF) * 0x9e3779b9925d4c17;
ape_uuid1 = ((ape_uuid1 | (ape_note_filesz >> 12)) - (ape_uuid1 & (ape_note_filesz >> 12))); ape_uuid1 = ((ape_uuid1 | (ape_note_filesz << 25)) - (ape_uuid1 & (ape_note_filesz << 25))); ape_uuid1 = ((ape_uuid1 | (ape_note_filesz >> 27)) - (ape_uuid1 & (ape_note_filesz >> 27))); ape_uuid1 = (ape_uuid1 + (ape_note_filesz >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_note_filesz >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_note_filesz >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_note_filesz >> 030) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = ((ape_uuid2 | (ape_note_filesz >> 12)) - (ape_uuid2 & (ape_note_filesz >> 12))); ape_uuid2 = ((ape_uuid2 | (ape_note_filesz << 25)) - (ape_uuid2 & (ape_note_filesz << 25))); ape_uuid2 = ((ape_uuid2 | (ape_note_filesz >> 27)) - (ape_uuid2 & (ape_note_filesz >> 27))); ape_uuid2 = (ape_uuid2 + (ape_note_filesz >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_note_filesz >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_note_filesz >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_note_filesz >> 030) & 0xFF) * 0x9e3779b9925d4c17;
ape_uuid1 = ((ape_uuid1 | (ape_note_memsz >> 12)) - (ape_uuid1 & (ape_note_memsz >> 12))); ape_uuid1 = ((ape_uuid1 | (ape_note_memsz << 25)) - (ape_uuid1 & (ape_note_memsz << 25))); ape_uuid1 = ((ape_uuid1 | (ape_note_memsz >> 27)) - (ape_uuid1 & (ape_note_memsz >> 27))); ape_uuid1 = (ape_uuid1 + (ape_note_memsz >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_note_memsz >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_note_memsz >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_note_memsz >> 030) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = ((ape_uuid2 | (ape_note_memsz >> 12)) - (ape_uuid2 & (ape_note_memsz >> 12))); ape_uuid2 = ((ape_uuid2 | (ape_note_memsz << 25)) - (ape_uuid2 & (ape_note_memsz << 25))); ape_uuid2 = ((ape_uuid2 | (ape_note_memsz >> 27)) - (ape_uuid2 & (ape_note_memsz >> 27))); ape_uuid2 = (ape_uuid2 + (ape_note_memsz >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_note_memsz >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_note_memsz >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_note_memsz >> 030) & 0xFF) * 0x9e3779b9925d4c17;
ape_uuid1 = ((ape_uuid1 | (ape_note_offset >> 12)) - (ape_uuid1 & (ape_note_offset >> 12))); ape_uuid1 = ((ape_uuid1 | (ape_note_offset << 25)) - (ape_uuid1 & (ape_note_offset << 25))); ape_uuid1 = ((ape_uuid1 | (ape_note_offset >> 27)) - (ape_uuid1 & (ape_note_offset >> 27))); ape_uuid1 = (ape_uuid1 + (ape_note_offset >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_note_offset >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_note_offset >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_note_offset >> 030) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = ((ape_uuid2 | (ape_note_offset >> 12)) - (ape_uuid2 & (ape_note_offset >> 12))); ape_uuid2 = ((ape_uuid2 | (ape_note_offset << 25)) - (ape_uuid2 & (ape_note_offset << 25))); ape_uuid2 = ((ape_uuid2 | (ape_note_offset >> 27)) - (ape_uuid2 & (ape_note_offset >> 27))); ape_uuid2 = (ape_uuid2 + (ape_note_offset >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_note_offset >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_note_offset >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_note_offset >> 030) & 0xFF) * 0x9e3779b9925d4c17;
ape_uuid1 = ((ape_uuid1 | (ape_note_paddr >> 12)) - (ape_uuid1 & (ape_note_paddr >> 12))); ape_uuid1 = ((ape_uuid1 | (ape_note_paddr << 25)) - (ape_uuid1 & (ape_note_paddr << 25))); ape_uuid1 = ((ape_uuid1 | (ape_note_paddr >> 27)) - (ape_uuid1 & (ape_note_paddr >> 27))); ape_uuid1 = (ape_uuid1 + (ape_note_paddr >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_note_paddr >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_note_paddr >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_note_paddr >> 030) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = ((ape_uuid2 | (ape_note_paddr >> 12)) - (ape_uuid2 & (ape_note_paddr >> 12))); ape_uuid2 = ((ape_uuid2 | (ape_note_paddr << 25)) - (ape_uuid2 & (ape_note_paddr << 25))); ape_uuid2 = ((ape_uuid2 | (ape_note_paddr >> 27)) - (ape_uuid2 & (ape_note_paddr >> 27))); ape_uuid2 = (ape_uuid2 + (ape_note_paddr >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_note_paddr >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_note_paddr >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_note_paddr >> 030) & 0xFF) * 0x9e3779b9925d4c17;
ape_uuid1 = ((ape_uuid1 | (ape_note_vaddr >> 12)) - (ape_uuid1 & (ape_note_vaddr >> 12))); ape_uuid1 = ((ape_uuid1 | (ape_note_vaddr << 25)) - (ape_uuid1 & (ape_note_vaddr << 25))); ape_uuid1 = ((ape_uuid1 | (ape_note_vaddr >> 27)) - (ape_uuid1 & (ape_note_vaddr >> 27))); ape_uuid1 = (ape_uuid1 + (ape_note_vaddr >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_note_vaddr >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_note_vaddr >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_note_vaddr >> 030) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = ((ape_uuid2 | (ape_note_vaddr >> 12)) - (ape_uuid2 & (ape_note_vaddr >> 12))); ape_uuid2 = ((ape_uuid2 | (ape_note_vaddr << 25)) - (ape_uuid2 & (ape_note_vaddr << 25))); ape_uuid2 = ((ape_uuid2 | (ape_note_vaddr >> 27)) - (ape_uuid2 & (ape_note_vaddr >> 27))); ape_uuid2 = (ape_uuid2 + (ape_note_vaddr >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_note_vaddr >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_note_vaddr >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_note_vaddr >> 030) & 0xFF) * 0x9e3779b9925d4c17;
ape_uuid1 = ((ape_uuid1 | (ape_ram_align >> 12)) - (ape_uuid1 & (ape_ram_align >> 12))); ape_uuid1 = ((ape_uuid1 | (ape_ram_align << 25)) - (ape_uuid1 & (ape_ram_align << 25))); ape_uuid1 = ((ape_uuid1 | (ape_ram_align >> 27)) - (ape_uuid1 & (ape_ram_align >> 27))); ape_uuid1 = (ape_uuid1 + (ape_ram_align >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_ram_align >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_ram_align >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_ram_align >> 030) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = ((ape_uuid2 | (ape_ram_align >> 12)) - (ape_uuid2 & (ape_ram_align >> 12))); ape_uuid2 = ((ape_uuid2 | (ape_ram_align << 25)) - (ape_uuid2 & (ape_ram_align << 25))); ape_uuid2 = ((ape_uuid2 | (ape_ram_align >> 27)) - (ape_uuid2 & (ape_ram_align >> 27))); ape_uuid2 = (ape_uuid2 + (ape_ram_align >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_ram_align >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_ram_align >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_ram_align >> 030) & 0xFF) * 0x9e3779b9925d4c17;
ape_uuid1 = ((ape_uuid1 | (ape_ram_filesz >> 12)) - (ape_uuid1 & (ape_ram_filesz >> 12))); ape_uuid1 = ((ape_uuid1 | (ape_ram_filesz << 25)) - (ape_uuid1 & (ape_ram_filesz << 25))); ape_uuid1 = ((ape_uuid1 | (ape_ram_filesz >> 27)) - (ape_uuid1 & (ape_ram_filesz >> 27))); ape_uuid1 = (ape_uuid1 + (ape_ram_filesz >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_ram_filesz >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_ram_filesz >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_ram_filesz >> 030) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = ((ape_uuid2 | (ape_ram_filesz >> 12)) - (ape_uuid2 & (ape_ram_filesz >> 12))); ape_uuid2 = ((ape_uuid2 | (ape_ram_filesz << 25)) - (ape_uuid2 & (ape_ram_filesz << 25))); ape_uuid2 = ((ape_uuid2 | (ape_ram_filesz >> 27)) - (ape_uuid2 & (ape_ram_filesz >> 27))); ape_uuid2 = (ape_uuid2 + (ape_ram_filesz >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_ram_filesz >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_ram_filesz >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_ram_filesz >> 030) & 0xFF) * 0x9e3779b9925d4c17;
ape_uuid1 = ((ape_uuid1 | (ape_ram_memsz >> 12)) - (ape_uuid1 & (ape_ram_memsz >> 12))); ape_uuid1 = ((ape_uuid1 | (ape_ram_memsz << 25)) - (ape_uuid1 & (ape_ram_memsz << 25))); ape_uuid1 = ((ape_uuid1 | (ape_ram_memsz >> 27)) - (ape_uuid1 & (ape_ram_memsz >> 27))); ape_uuid1 = (ape_uuid1 + (ape_ram_memsz >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_ram_memsz >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_ram_memsz >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_ram_memsz >> 030) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = ((ape_uuid2 | (ape_ram_memsz >> 12)) - (ape_uuid2 & (ape_ram_memsz >> 12))); ape_uuid2 = ((ape_uuid2 | (ape_ram_memsz << 25)) - (ape_uuid2 & (ape_ram_memsz << 25))); ape_uuid2 = ((ape_uuid2 | (ape_ram_memsz >> 27)) - (ape_uuid2 & (ape_ram_memsz >> 27))); ape_uuid2 = (ape_uuid2 + (ape_ram_memsz >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_ram_memsz >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_ram_memsz >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_ram_memsz >> 030) & 0xFF) * 0x9e3779b9925d4c17;
ape_uuid1 = ((ape_uuid1 | (ape_ram_offset >> 12)) - (ape_uuid1 & (ape_ram_offset >> 12))); ape_uuid1 = ((ape_uuid1 | (ape_ram_offset << 25)) - (ape_uuid1 & (ape_ram_offset << 25))); ape_uuid1 = ((ape_uuid1 | (ape_ram_offset >> 27)) - (ape_uuid1 & (ape_ram_offset >> 27))); ape_uuid1 = (ape_uuid1 + (ape_ram_offset >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_ram_offset >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_ram_offset >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_ram_offset >> 030) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = ((ape_uuid2 | (ape_ram_offset >> 12)) - (ape_uuid2 & (ape_ram_offset >> 12))); ape_uuid2 = ((ape_uuid2 | (ape_ram_offset << 25)) - (ape_uuid2 & (ape_ram_offset << 25))); ape_uuid2 = ((ape_uuid2 | (ape_ram_offset >> 27)) - (ape_uuid2 & (ape_ram_offset >> 27))); ape_uuid2 = (ape_uuid2 + (ape_ram_offset >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_ram_offset >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_ram_offset >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_ram_offset >> 030) & 0xFF) * 0x9e3779b9925d4c17;
ape_uuid1 = ((ape_uuid1 | (ape_ram_paddr >> 12)) - (ape_uuid1 & (ape_ram_paddr >> 12))); ape_uuid1 = ((ape_uuid1 | (ape_ram_paddr << 25)) - (ape_uuid1 & (ape_ram_paddr << 25))); ape_uuid1 = ((ape_uuid1 | (ape_ram_paddr >> 27)) - (ape_uuid1 & (ape_ram_paddr >> 27))); ape_uuid1 = (ape_uuid1 + (ape_ram_paddr >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_ram_paddr >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_ram_paddr >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_ram_paddr >> 030) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = ((ape_uuid2 | (ape_ram_paddr >> 12)) - (ape_uuid2 & (ape_ram_paddr >> 12))); ape_uuid2 = ((ape_uuid2 | (ape_ram_paddr << 25)) - (ape_uuid2 & (ape_ram_paddr << 25))); ape_uuid2 = ((ape_uuid2 | (ape_ram_paddr >> 27)) - (ape_uuid2 & (ape_ram_paddr >> 27))); ape_uuid2 = (ape_uuid2 + (ape_ram_paddr >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_ram_paddr >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_ram_paddr >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_ram_paddr >> 030) & 0xFF) * 0x9e3779b9925d4c17;
ape_uuid1 = ((ape_uuid1 | (ape_ram_rva >> 12)) - (ape_uuid1 & (ape_ram_rva >> 12))); ape_uuid1 = ((ape_uuid1 | (ape_ram_rva << 25)) - (ape_uuid1 & (ape_ram_rva << 25))); ape_uuid1 = ((ape_uuid1 | (ape_ram_rva >> 27)) - (ape_uuid1 & (ape_ram_rva >> 27))); ape_uuid1 = (ape_uuid1 + (ape_ram_rva >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_ram_rva >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_ram_rva >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_ram_rva >> 030) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = ((ape_uuid2 | (ape_ram_rva >> 12)) - (ape_uuid2 & (ape_ram_rva >> 12))); ape_uuid2 = ((ape_uuid2 | (ape_ram_rva << 25)) - (ape_uuid2 & (ape_ram_rva << 25))); ape_uuid2 = ((ape_uuid2 | (ape_ram_rva >> 27)) - (ape_uuid2 & (ape_ram_rva >> 27))); ape_uuid2 = (ape_uuid2 + (ape_ram_rva >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_ram_rva >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_ram_rva >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_ram_rva >> 030) & 0xFF) * 0x9e3779b9925d4c17;
ape_uuid1 = ((ape_uuid1 | (ape_ram_vaddr >> 12)) - (ape_uuid1 & (ape_ram_vaddr >> 12))); ape_uuid1 = ((ape_uuid1 | (ape_ram_vaddr << 25)) - (ape_uuid1 & (ape_ram_vaddr << 25))); ape_uuid1 = ((ape_uuid1 | (ape_ram_vaddr >> 27)) - (ape_uuid1 & (ape_ram_vaddr >> 27))); ape_uuid1 = (ape_uuid1 + (ape_ram_vaddr >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_ram_vaddr >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_ram_vaddr >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_ram_vaddr >> 030) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = ((ape_uuid2 | (ape_ram_vaddr >> 12)) - (ape_uuid2 & (ape_ram_vaddr >> 12))); ape_uuid2 = ((ape_uuid2 | (ape_ram_vaddr << 25)) - (ape_uuid2 & (ape_ram_vaddr << 25))); ape_uuid2 = ((ape_uuid2 | (ape_ram_vaddr >> 27)) - (ape_uuid2 & (ape_ram_vaddr >> 27))); ape_uuid2 = (ape_uuid2 + (ape_ram_vaddr >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_ram_vaddr >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_ram_vaddr >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_ram_vaddr >> 030) & 0xFF) * 0x9e3779b9925d4c17;
ape_uuid1 = ((ape_uuid1 | (ape_rom_align >> 12)) - (ape_uuid1 & (ape_rom_align >> 12))); ape_uuid1 = ((ape_uuid1 | (ape_rom_align << 25)) - (ape_uuid1 & (ape_rom_align << 25))); ape_uuid1 = ((ape_uuid1 | (ape_rom_align >> 27)) - (ape_uuid1 & (ape_rom_align >> 27))); ape_uuid1 = (ape_uuid1 + (ape_rom_align >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_rom_align >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_rom_align >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_rom_align >> 030) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = ((ape_uuid2 | (ape_rom_align >> 12)) - (ape_uuid2 & (ape_rom_align >> 12))); ape_uuid2 = ((ape_uuid2 | (ape_rom_align << 25)) - (ape_uuid2 & (ape_rom_align << 25))); ape_uuid2 = ((ape_uuid2 | (ape_rom_align >> 27)) - (ape_uuid2 & (ape_rom_align >> 27))); ape_uuid2 = (ape_uuid2 + (ape_rom_align >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_rom_align >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_rom_align >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_rom_align >> 030) & 0xFF) * 0x9e3779b9925d4c17;
ape_uuid1 = ((ape_uuid1 | (ape_rom_filesz >> 12)) - (ape_uuid1 & (ape_rom_filesz >> 12))); ape_uuid1 = ((ape_uuid1 | (ape_rom_filesz << 25)) - (ape_uuid1 & (ape_rom_filesz << 25))); ape_uuid1 = ((ape_uuid1 | (ape_rom_filesz >> 27)) - (ape_uuid1 & (ape_rom_filesz >> 27))); ape_uuid1 = (ape_uuid1 + (ape_rom_filesz >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_rom_filesz >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_rom_filesz >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_rom_filesz >> 030) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = ((ape_uuid2 | (ape_rom_filesz >> 12)) - (ape_uuid2 & (ape_rom_filesz >> 12))); ape_uuid2 = ((ape_uuid2 | (ape_rom_filesz << 25)) - (ape_uuid2 & (ape_rom_filesz << 25))); ape_uuid2 = ((ape_uuid2 | (ape_rom_filesz >> 27)) - (ape_uuid2 & (ape_rom_filesz >> 27))); ape_uuid2 = (ape_uuid2 + (ape_rom_filesz >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_rom_filesz >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_rom_filesz >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_rom_filesz >> 030) & 0xFF) * 0x9e3779b9925d4c17;
ape_uuid1 = ((ape_uuid1 | (ape_rom_memsz >> 12)) - (ape_uuid1 & (ape_rom_memsz >> 12))); ape_uuid1 = ((ape_uuid1 | (ape_rom_memsz << 25)) - (ape_uuid1 & (ape_rom_memsz << 25))); ape_uuid1 = ((ape_uuid1 | (ape_rom_memsz >> 27)) - (ape_uuid1 & (ape_rom_memsz >> 27))); ape_uuid1 = (ape_uuid1 + (ape_rom_memsz >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_rom_memsz >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_rom_memsz >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_rom_memsz >> 030) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = ((ape_uuid2 | (ape_rom_memsz >> 12)) - (ape_uuid2 & (ape_rom_memsz >> 12))); ape_uuid2 = ((ape_uuid2 | (ape_rom_memsz << 25)) - (ape_uuid2 & (ape_rom_memsz << 25))); ape_uuid2 = ((ape_uuid2 | (ape_rom_memsz >> 27)) - (ape_uuid2 & (ape_rom_memsz >> 27))); ape_uuid2 = (ape_uuid2 + (ape_rom_memsz >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_rom_memsz >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_rom_memsz >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_rom_memsz >> 030) & 0xFF) * 0x9e3779b9925d4c17;
ape_uuid1 = ((ape_uuid1 | (ape_rom_offset >> 12)) - (ape_uuid1 & (ape_rom_offset >> 12))); ape_uuid1 = ((ape_uuid1 | (ape_rom_offset << 25)) - (ape_uuid1 & (ape_rom_offset << 25))); ape_uuid1 = ((ape_uuid1 | (ape_rom_offset >> 27)) - (ape_uuid1 & (ape_rom_offset >> 27))); ape_uuid1 = (ape_uuid1 + (ape_rom_offset >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_rom_offset >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_rom_offset >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_rom_offset >> 030) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = ((ape_uuid2 | (ape_rom_offset >> 12)) - (ape_uuid2 & (ape_rom_offset >> 12))); ape_uuid2 = ((ape_uuid2 | (ape_rom_offset << 25)) - (ape_uuid2 & (ape_rom_offset << 25))); ape_uuid2 = ((ape_uuid2 | (ape_rom_offset >> 27)) - (ape_uuid2 & (ape_rom_offset >> 27))); ape_uuid2 = (ape_uuid2 + (ape_rom_offset >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_rom_offset >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_rom_offset >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_rom_offset >> 030) & 0xFF) * 0x9e3779b9925d4c17;
ape_uuid1 = ((ape_uuid1 | (ape_rom_paddr >> 12)) - (ape_uuid1 & (ape_rom_paddr >> 12))); ape_uuid1 = ((ape_uuid1 | (ape_rom_paddr << 25)) - (ape_uuid1 & (ape_rom_paddr << 25))); ape_uuid1 = ((ape_uuid1 | (ape_rom_paddr >> 27)) - (ape_uuid1 & (ape_rom_paddr >> 27))); ape_uuid1 = (ape_uuid1 + (ape_rom_paddr >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_rom_paddr >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_rom_paddr >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_rom_paddr >> 030) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = ((ape_uuid2 | (ape_rom_paddr >> 12)) - (ape_uuid2 & (ape_rom_paddr >> 12))); ape_uuid2 = ((ape_uuid2 | (ape_rom_paddr << 25)) - (ape_uuid2 & (ape_rom_paddr << 25))); ape_uuid2 = ((ape_uuid2 | (ape_rom_paddr >> 27)) - (ape_uuid2 & (ape_rom_paddr >> 27))); ape_uuid2 = (ape_uuid2 + (ape_rom_paddr >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_rom_paddr >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_rom_paddr >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_rom_paddr >> 030) & 0xFF) * 0x9e3779b9925d4c17;
ape_uuid1 = ((ape_uuid1 | (ape_rom_rva >> 12)) - (ape_uuid1 & (ape_rom_rva >> 12))); ape_uuid1 = ((ape_uuid1 | (ape_rom_rva << 25)) - (ape_uuid1 & (ape_rom_rva << 25))); ape_uuid1 = ((ape_uuid1 | (ape_rom_rva >> 27)) - (ape_uuid1 & (ape_rom_rva >> 27))); ape_uuid1 = (ape_uuid1 + (ape_rom_rva >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_rom_rva >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_rom_rva >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_rom_rva >> 030) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = ((ape_uuid2 | (ape_rom_rva >> 12)) - (ape_uuid2 & (ape_rom_rva >> 12))); ape_uuid2 = ((ape_uuid2 | (ape_rom_rva << 25)) - (ape_uuid2 & (ape_rom_rva << 25))); ape_uuid2 = ((ape_uuid2 | (ape_rom_rva >> 27)) - (ape_uuid2 & (ape_rom_rva >> 27))); ape_uuid2 = (ape_uuid2 + (ape_rom_rva >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_rom_rva >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_rom_rva >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_rom_rva >> 030) & 0xFF) * 0x9e3779b9925d4c17;
ape_uuid1 = ((ape_uuid1 | (ape_rom_vaddr >> 12)) - (ape_uuid1 & (ape_rom_vaddr >> 12))); ape_uuid1 = ((ape_uuid1 | (ape_rom_vaddr << 25)) - (ape_uuid1 & (ape_rom_vaddr << 25))); ape_uuid1 = ((ape_uuid1 | (ape_rom_vaddr >> 27)) - (ape_uuid1 & (ape_rom_vaddr >> 27))); ape_uuid1 = (ape_uuid1 + (ape_rom_vaddr >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_rom_vaddr >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_rom_vaddr >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_rom_vaddr >> 030) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = ((ape_uuid2 | (ape_rom_vaddr >> 12)) - (ape_uuid2 & (ape_rom_vaddr >> 12))); ape_uuid2 = ((ape_uuid2 | (ape_rom_vaddr << 25)) - (ape_uuid2 & (ape_rom_vaddr << 25))); ape_uuid2 = ((ape_uuid2 | (ape_rom_vaddr >> 27)) - (ape_uuid2 & (ape_rom_vaddr >> 27))); ape_uuid2 = (ape_uuid2 + (ape_rom_vaddr >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_rom_vaddr >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_rom_vaddr >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_rom_vaddr >> 030) & 0xFF) * 0x9e3779b9925d4c17;
ape_uuid1 = ((ape_uuid1 | (ape_text_align >> 12)) - (ape_uuid1 & (ape_text_align >> 12))); ape_uuid1 = ((ape_uuid1 | (ape_text_align << 25)) - (ape_uuid1 & (ape_text_align << 25))); ape_uuid1 = ((ape_uuid1 | (ape_text_align >> 27)) - (ape_uuid1 & (ape_text_align >> 27))); ape_uuid1 = (ape_uuid1 + (ape_text_align >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_text_align >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_text_align >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_text_align >> 030) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = ((ape_uuid2 | (ape_text_align >> 12)) - (ape_uuid2 & (ape_text_align >> 12))); ape_uuid2 = ((ape_uuid2 | (ape_text_align << 25)) - (ape_uuid2 & (ape_text_align << 25))); ape_uuid2 = ((ape_uuid2 | (ape_text_align >> 27)) - (ape_uuid2 & (ape_text_align >> 27))); ape_uuid2 = (ape_uuid2 + (ape_text_align >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_text_align >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_text_align >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_text_align >> 030) & 0xFF) * 0x9e3779b9925d4c17;
ape_uuid1 = ((ape_uuid1 | (ape_text_filesz >> 12)) - (ape_uuid1 & (ape_text_filesz >> 12))); ape_uuid1 = ((ape_uuid1 | (ape_text_filesz << 25)) - (ape_uuid1 & (ape_text_filesz << 25))); ape_uuid1 = ((ape_uuid1 | (ape_text_filesz >> 27)) - (ape_uuid1 & (ape_text_filesz >> 27))); ape_uuid1 = (ape_uuid1 + (ape_text_filesz >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_text_filesz >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_text_filesz >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_text_filesz >> 030) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = ((ape_uuid2 | (ape_text_filesz >> 12)) - (ape_uuid2 & (ape_text_filesz >> 12))); ape_uuid2 = ((ape_uuid2 | (ape_text_filesz << 25)) - (ape_uuid2 & (ape_text_filesz << 25))); ape_uuid2 = ((ape_uuid2 | (ape_text_filesz >> 27)) - (ape_uuid2 & (ape_text_filesz >> 27))); ape_uuid2 = (ape_uuid2 + (ape_text_filesz >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_text_filesz >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_text_filesz >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_text_filesz >> 030) & 0xFF) * 0x9e3779b9925d4c17;
ape_uuid1 = ((ape_uuid1 | (ape_text_memsz >> 12)) - (ape_uuid1 & (ape_text_memsz >> 12))); ape_uuid1 = ((ape_uuid1 | (ape_text_memsz << 25)) - (ape_uuid1 & (ape_text_memsz << 25))); ape_uuid1 = ((ape_uuid1 | (ape_text_memsz >> 27)) - (ape_uuid1 & (ape_text_memsz >> 27))); ape_uuid1 = (ape_uuid1 + (ape_text_memsz >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_text_memsz >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_text_memsz >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_text_memsz >> 030) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = ((ape_uuid2 | (ape_text_memsz >> 12)) - (ape_uuid2 & (ape_text_memsz >> 12))); ape_uuid2 = ((ape_uuid2 | (ape_text_memsz << 25)) - (ape_uuid2 & (ape_text_memsz << 25))); ape_uuid2 = ((ape_uuid2 | (ape_text_memsz >> 27)) - (ape_uuid2 & (ape_text_memsz >> 27))); ape_uuid2 = (ape_uuid2 + (ape_text_memsz >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_text_memsz >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_text_memsz >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_text_memsz >> 030) & 0xFF) * 0x9e3779b9925d4c17;
ape_uuid1 = ((ape_uuid1 | (ape_text_offset >> 12)) - (ape_uuid1 & (ape_text_offset >> 12))); ape_uuid1 = ((ape_uuid1 | (ape_text_offset << 25)) - (ape_uuid1 & (ape_text_offset << 25))); ape_uuid1 = ((ape_uuid1 | (ape_text_offset >> 27)) - (ape_uuid1 & (ape_text_offset >> 27))); ape_uuid1 = (ape_uuid1 + (ape_text_offset >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_text_offset >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_text_offset >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_text_offset >> 030) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = ((ape_uuid2 | (ape_text_offset >> 12)) - (ape_uuid2 & (ape_text_offset >> 12))); ape_uuid2 = ((ape_uuid2 | (ape_text_offset << 25)) - (ape_uuid2 & (ape_text_offset << 25))); ape_uuid2 = ((ape_uuid2 | (ape_text_offset >> 27)) - (ape_uuid2 & (ape_text_offset >> 27))); ape_uuid2 = (ape_uuid2 + (ape_text_offset >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_text_offset >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_text_offset >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_text_offset >> 030) & 0xFF) * 0x9e3779b9925d4c17;
ape_uuid1 = ((ape_uuid1 | (ape_text_paddr >> 12)) - (ape_uuid1 & (ape_text_paddr >> 12))); ape_uuid1 = ((ape_uuid1 | (ape_text_paddr << 25)) - (ape_uuid1 & (ape_text_paddr << 25))); ape_uuid1 = ((ape_uuid1 | (ape_text_paddr >> 27)) - (ape_uuid1 & (ape_text_paddr >> 27))); ape_uuid1 = (ape_uuid1 + (ape_text_paddr >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_text_paddr >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_text_paddr >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_text_paddr >> 030) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = ((ape_uuid2 | (ape_text_paddr >> 12)) - (ape_uuid2 & (ape_text_paddr >> 12))); ape_uuid2 = ((ape_uuid2 | (ape_text_paddr << 25)) - (ape_uuid2 & (ape_text_paddr << 25))); ape_uuid2 = ((ape_uuid2 | (ape_text_paddr >> 27)) - (ape_uuid2 & (ape_text_paddr >> 27))); ape_uuid2 = (ape_uuid2 + (ape_text_paddr >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_text_paddr >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_text_paddr >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_text_paddr >> 030) & 0xFF) * 0x9e3779b9925d4c17;
ape_uuid1 = ((ape_uuid1 | (ape_text_rva >> 12)) - (ape_uuid1 & (ape_text_rva >> 12))); ape_uuid1 = ((ape_uuid1 | (ape_text_rva << 25)) - (ape_uuid1 & (ape_text_rva << 25))); ape_uuid1 = ((ape_uuid1 | (ape_text_rva >> 27)) - (ape_uuid1 & (ape_text_rva >> 27))); ape_uuid1 = (ape_uuid1 + (ape_text_rva >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_text_rva >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_text_rva >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_text_rva >> 030) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = ((ape_uuid2 | (ape_text_rva >> 12)) - (ape_uuid2 & (ape_text_rva >> 12))); ape_uuid2 = ((ape_uuid2 | (ape_text_rva << 25)) - (ape_uuid2 & (ape_text_rva << 25))); ape_uuid2 = ((ape_uuid2 | (ape_text_rva >> 27)) - (ape_uuid2 & (ape_text_rva >> 27))); ape_uuid2 = (ape_uuid2 + (ape_text_rva >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_text_rva >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_text_rva >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_text_rva >> 030) & 0xFF) * 0x9e3779b9925d4c17;
ape_uuid1 = ((ape_uuid1 | (ape_text_vaddr >> 12)) - (ape_uuid1 & (ape_text_vaddr >> 12))); ape_uuid1 = ((ape_uuid1 | (ape_text_vaddr << 25)) - (ape_uuid1 & (ape_text_vaddr << 25))); ape_uuid1 = ((ape_uuid1 | (ape_text_vaddr >> 27)) - (ape_uuid1 & (ape_text_vaddr >> 27))); ape_uuid1 = (ape_uuid1 + (ape_text_vaddr >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_text_vaddr >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_text_vaddr >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_text_vaddr >> 030) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = ((ape_uuid2 | (ape_text_vaddr >> 12)) - (ape_uuid2 & (ape_text_vaddr >> 12))); ape_uuid2 = ((ape_uuid2 | (ape_text_vaddr << 25)) - (ape_uuid2 & (ape_text_vaddr << 25))); ape_uuid2 = ((ape_uuid2 | (ape_text_vaddr >> 27)) - (ape_uuid2 & (ape_text_vaddr >> 27))); ape_uuid2 = (ape_uuid2 + (ape_text_vaddr >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_text_vaddr >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_text_vaddr >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_text_vaddr >> 030) & 0xFF) * 0x9e3779b9925d4c17;
ape_uuid1 = ((ape_uuid1 | (ADDR(.bss) >> 12)) - (ape_uuid1 & (ADDR(.bss) >> 12))); ape_uuid1 = ((ape_uuid1 | (ADDR(.bss) << 25)) - (ape_uuid1 & (ADDR(.bss) << 25))); ape_uuid1 = ((ape_uuid1 | (ADDR(.bss) >> 27)) - (ape_uuid1 & (ADDR(.bss) >> 27))); ape_uuid1 = (ape_uuid1 + (ADDR(.bss) >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ADDR(.bss) >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ADDR(.bss) >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ADDR(.bss) >> 030) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = ((ape_uuid2 | (ADDR(.bss) >> 12)) - (ape_uuid2 & (ADDR(.bss) >> 12))); ape_uuid2 = ((ape_uuid2 | (ADDR(.bss) << 25)) - (ape_uuid2 & (ADDR(.bss) << 25))); ape_uuid2 = ((ape_uuid2 | (ADDR(.bss) >> 27)) - (ape_uuid2 & (ADDR(.bss) >> 27))); ape_uuid2 = (ape_uuid2 + (ADDR(.bss) >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ADDR(.bss) >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ADDR(.bss) >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ADDR(.bss) >> 030) & 0xFF) * 0x9e3779b9925d4c17;
ape_uuid1 = ((ape_uuid1 | (_start >> 12)) - (ape_uuid1 & (_start >> 12))); ape_uuid1 = ((ape_uuid1 | (_start << 25)) - (ape_uuid1 & (_start << 25))); ape_uuid1 = ((ape_uuid1 | (_start >> 27)) - (ape_uuid1 & (_start >> 27))); ape_uuid1 = (ape_uuid1 + (_start >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (_start >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (_start >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (_start >> 030) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = ((ape_uuid2 | (_start >> 12)) - (ape_uuid2 & (_start >> 12))); ape_uuid2 = ((ape_uuid2 | (_start << 25)) - (ape_uuid2 & (_start << 25))); ape_uuid2 = ((ape_uuid2 | (_start >> 27)) - (ape_uuid2 & (_start >> 27))); ape_uuid2 = (ape_uuid2 + (_start >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (_start >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (_start >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (_start >> 030) & 0xFF) * 0x9e3779b9925d4c17;
ape_uuid1 = ((ape_uuid1 | (ape_phdrs >> 12)) - (ape_uuid1 & (ape_phdrs >> 12))); ape_uuid1 = ((ape_uuid1 | (ape_phdrs << 25)) - (ape_uuid1 & (ape_phdrs << 25))); ape_uuid1 = ((ape_uuid1 | (ape_phdrs >> 27)) - (ape_uuid1 & (ape_phdrs >> 27))); ape_uuid1 = (ape_uuid1 + (ape_phdrs >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_phdrs >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_phdrs >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_phdrs >> 030) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = ((ape_uuid2 | (ape_phdrs >> 12)) - (ape_uuid2 & (ape_phdrs >> 12))); ape_uuid2 = ((ape_uuid2 | (ape_phdrs << 25)) - (ape_uuid2 & (ape_phdrs << 25))); ape_uuid2 = ((ape_uuid2 | (ape_phdrs >> 27)) - (ape_uuid2 & (ape_phdrs >> 27))); ape_uuid2 = (ape_uuid2 + (ape_phdrs >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_phdrs >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_phdrs >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_phdrs >> 030) & 0xFF) * 0x9e3779b9925d4c17;
ape_uuid1 = ((ape_uuid1 | (v_ape_realsectors >> 12)) - (ape_uuid1 & (v_ape_realsectors >> 12))); ape_uuid1 = ((ape_uuid1 | (v_ape_realsectors << 25)) - (ape_uuid1 & (v_ape_realsectors << 25))); ape_uuid1 = ((ape_uuid1 | (v_ape_realsectors >> 27)) - (ape_uuid1 & (v_ape_realsectors >> 27))); ape_uuid1 = (ape_uuid1 + (v_ape_realsectors >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (v_ape_realsectors >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (v_ape_realsectors >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (v_ape_realsectors >> 030) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = ((ape_uuid2 | (v_ape_realsectors >> 12)) - (ape_uuid2 & (v_ape_realsectors >> 12))); ape_uuid2 = ((ape_uuid2 | (v_ape_realsectors << 25)) - (ape_uuid2 & (v_ape_realsectors << 25))); ape_uuid2 = ((ape_uuid2 | (v_ape_realsectors >> 27)) - (ape_uuid2 & (v_ape_realsectors >> 27))); ape_uuid2 = (ape_uuid2 + (v_ape_realsectors >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (v_ape_realsectors >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (v_ape_realsectors >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (v_ape_realsectors >> 030) & 0xFF) * 0x9e3779b9925d4c17;
ape_uuid1 = ((ape_uuid1 | (ape_macho >> 12)) - (ape_uuid1 & (ape_macho >> 12))); ape_uuid1 = ((ape_uuid1 | (ape_macho << 25)) - (ape_uuid1 & (ape_macho << 25))); ape_uuid1 = ((ape_uuid1 | (ape_macho >> 27)) - (ape_uuid1 & (ape_macho >> 27))); ape_uuid1 = (ape_uuid1 + (ape_macho >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_macho >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_macho >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_macho >> 030) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = ((ape_uuid2 | (ape_macho >> 12)) - (ape_uuid2 & (ape_macho >> 12))); ape_uuid2 = ((ape_uuid2 | (ape_macho << 25)) - (ape_uuid2 & (ape_macho << 25))); ape_uuid2 = ((ape_uuid2 | (ape_macho >> 27)) - (ape_uuid2 & (ape_macho >> 27))); ape_uuid2 = (ape_uuid2 + (ape_macho >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_macho >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_macho >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_macho >> 030) & 0xFF) * 0x9e3779b9925d4c17;
ape_uuid1 = ((ape_uuid1 | (ape_mz >> 12)) - (ape_uuid1 & (ape_mz >> 12))); ape_uuid1 = ((ape_uuid1 | (ape_mz << 25)) - (ape_uuid1 & (ape_mz << 25))); ape_uuid1 = ((ape_uuid1 | (ape_mz >> 27)) - (ape_uuid1 & (ape_mz >> 27))); ape_uuid1 = (ape_uuid1 + (ape_mz >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_mz >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_mz >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_mz >> 030) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = ((ape_uuid2 | (ape_mz >> 12)) - (ape_uuid2 & (ape_mz >> 12))); ape_uuid2 = ((ape_uuid2 | (ape_mz << 25)) - (ape_uuid2 & (ape_mz << 25))); ape_uuid2 = ((ape_uuid2 | (ape_mz >> 27)) - (ape_uuid2 & (ape_mz >> 27))); ape_uuid2 = (ape_uuid2 + (ape_mz >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_mz >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_mz >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_mz >> 030) & 0xFF) * 0x9e3779b9925d4c17;
ape_uuid1 = ((ape_uuid1 | (ape_pe >> 12)) - (ape_uuid1 & (ape_pe >> 12))); ape_uuid1 = ((ape_uuid1 | (ape_pe << 25)) - (ape_uuid1 & (ape_pe << 25))); ape_uuid1 = ((ape_uuid1 | (ape_pe >> 27)) - (ape_uuid1 & (ape_pe >> 27))); ape_uuid1 = (ape_uuid1 + (ape_pe >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_pe >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_pe >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_pe >> 030) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = ((ape_uuid2 | (ape_pe >> 12)) - (ape_uuid2 & (ape_pe >> 12))); ape_uuid2 = ((ape_uuid2 | (ape_pe << 25)) - (ape_uuid2 & (ape_pe << 25))); ape_uuid2 = ((ape_uuid2 | (ape_pe >> 27)) - (ape_uuid2 & (ape_pe >> 27))); ape_uuid2 = (ape_uuid2 + (ape_pe >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_pe >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_pe >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_pe >> 030) & 0xFF) * 0x9e3779b9925d4c17;
ape_uuid1 = ((ape_uuid1 | (ape_pe_offset >> 12)) - (ape_uuid1 & (ape_pe_offset >> 12))); ape_uuid1 = ((ape_uuid1 | (ape_pe_offset << 25)) - (ape_uuid1 & (ape_pe_offset << 25))); ape_uuid1 = ((ape_uuid1 | (ape_pe_offset >> 27)) - (ape_uuid1 & (ape_pe_offset >> 27))); ape_uuid1 = (ape_uuid1 + (ape_pe_offset >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_pe_offset >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_pe_offset >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_pe_offset >> 030) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = ((ape_uuid2 | (ape_pe_offset >> 12)) - (ape_uuid2 & (ape_pe_offset >> 12))); ape_uuid2 = ((ape_uuid2 | (ape_pe_offset << 25)) - (ape_uuid2 & (ape_pe_offset << 25))); ape_uuid2 = ((ape_uuid2 | (ape_pe_offset >> 27)) - (ape_uuid2 & (ape_pe_offset >> 27))); ape_uuid2 = (ape_uuid2 + (ape_pe_offset >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_pe_offset >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_pe_offset >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_pe_offset >> 030) & 0xFF) * 0x9e3779b9925d4c17;
ape_uuid1 = ((ape_uuid1 | (ape_pe_optsz >> 12)) - (ape_uuid1 & (ape_pe_optsz >> 12))); ape_uuid1 = ((ape_uuid1 | (ape_pe_optsz << 25)) - (ape_uuid1 & (ape_pe_optsz << 25))); ape_uuid1 = ((ape_uuid1 | (ape_pe_optsz >> 27)) - (ape_uuid1 & (ape_pe_optsz >> 27))); ape_uuid1 = (ape_uuid1 + (ape_pe_optsz >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_pe_optsz >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_pe_optsz >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_pe_optsz >> 030) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = ((ape_uuid2 | (ape_pe_optsz >> 12)) - (ape_uuid2 & (ape_pe_optsz >> 12))); ape_uuid2 = ((ape_uuid2 | (ape_pe_optsz << 25)) - (ape_uuid2 & (ape_pe_optsz << 25))); ape_uuid2 = ((ape_uuid2 | (ape_pe_optsz >> 27)) - (ape_uuid2 & (ape_pe_optsz >> 27))); ape_uuid2 = (ape_uuid2 + (ape_pe_optsz >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_pe_optsz >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_pe_optsz >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_pe_optsz >> 030) & 0xFF) * 0x9e3779b9925d4c17;
ape_uuid1 = ((ape_uuid1 | (ape_pe_sections >> 12)) - (ape_uuid1 & (ape_pe_sections >> 12))); ape_uuid1 = ((ape_uuid1 | (ape_pe_sections << 25)) - (ape_uuid1 & (ape_pe_sections << 25))); ape_uuid1 = ((ape_uuid1 | (ape_pe_sections >> 27)) - (ape_uuid1 & (ape_pe_sections >> 27))); ape_uuid1 = (ape_uuid1 + (ape_pe_sections >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_pe_sections >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_pe_sections >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_pe_sections >> 030) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = ((ape_uuid2 | (ape_pe_sections >> 12)) - (ape_uuid2 & (ape_pe_sections >> 12))); ape_uuid2 = ((ape_uuid2 | (ape_pe_sections << 25)) - (ape_uuid2 & (ape_pe_sections << 25))); ape_uuid2 = ((ape_uuid2 | (ape_pe_sections >> 27)) - (ape_uuid2 & (ape_pe_sections >> 27))); ape_uuid2 = (ape_uuid2 + (ape_pe_sections >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_pe_sections >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_pe_sections >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_pe_sections >> 030) & 0xFF) * 0x9e3779b9925d4c17;
ape_uuid1 = ((ape_uuid1 | (ape_pe_sections_end >> 12)) - (ape_uuid1 & (ape_pe_sections_end >> 12))); ape_uuid1 = ((ape_uuid1 | (ape_pe_sections_end << 25)) - (ape_uuid1 & (ape_pe_sections_end << 25))); ape_uuid1 = ((ape_uuid1 | (ape_pe_sections_end >> 27)) - (ape_uuid1 & (ape_pe_sections_end >> 27))); ape_uuid1 = (ape_uuid1 + (ape_pe_sections_end >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_pe_sections_end >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_pe_sections_end >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_pe_sections_end >> 030) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = ((ape_uuid2 | (ape_pe_sections_end >> 12)) - (ape_uuid2 & (ape_pe_sections_end >> 12))); ape_uuid2 = ((ape_uuid2 | (ape_pe_sections_end << 25)) - (ape_uuid2 & (ape_pe_sections_end << 25))); ape_uuid2 = ((ape_uuid2 | (ape_pe_sections_end >> 27)) - (ape_uuid2 & (ape_pe_sections_end >> 27))); ape_uuid2 = (ape_uuid2 + (ape_pe_sections_end >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_pe_sections_end >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_pe_sections_end >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_pe_sections_end >> 030) & 0xFF) * 0x9e3779b9925d4c17;
ape_uuid1 = ((ape_uuid1 | (ape_pe_shnum >> 12)) - (ape_uuid1 & (ape_pe_shnum >> 12))); ape_uuid1 = ((ape_uuid1 | (ape_pe_shnum << 25)) - (ape_uuid1 & (ape_pe_shnum << 25))); ape_uuid1 = ((ape_uuid1 | (ape_pe_shnum >> 27)) - (ape_uuid1 & (ape_pe_shnum >> 27))); ape_uuid1 = (ape_uuid1 + (ape_pe_shnum >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_pe_shnum >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_pe_shnum >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_pe_shnum >> 030) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = ((ape_uuid2 | (ape_pe_shnum >> 12)) - (ape_uuid2 & (ape_pe_shnum >> 12))); ape_uuid2 = ((ape_uuid2 | (ape_pe_shnum << 25)) - (ape_uuid2 & (ape_pe_shnum << 25))); ape_uuid2 = ((ape_uuid2 | (ape_pe_shnum >> 27)) - (ape_uuid2 & (ape_pe_shnum >> 27))); ape_uuid2 = (ape_uuid2 + (ape_pe_shnum >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_pe_shnum >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_pe_shnum >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_pe_shnum >> 030) & 0xFF) * 0x9e3779b9925d4c17;
ape_uuid1 = ((ape_uuid1 | (ape_phdrs_end >> 12)) - (ape_uuid1 & (ape_phdrs_end >> 12))); ape_uuid1 = ((ape_uuid1 | (ape_phdrs_end << 25)) - (ape_uuid1 & (ape_phdrs_end << 25))); ape_uuid1 = ((ape_uuid1 | (ape_phdrs_end >> 27)) - (ape_uuid1 & (ape_phdrs_end >> 27))); ape_uuid1 = (ape_uuid1 + (ape_phdrs_end >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_phdrs_end >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_phdrs_end >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (ape_phdrs_end >> 030) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = ((ape_uuid2 | (ape_phdrs_end >> 12)) - (ape_uuid2 & (ape_phdrs_end >> 12))); ape_uuid2 = ((ape_uuid2 | (ape_phdrs_end << 25)) - (ape_uuid2 & (ape_phdrs_end << 25))); ape_uuid2 = ((ape_uuid2 | (ape_phdrs_end >> 27)) - (ape_uuid2 & (ape_phdrs_end >> 27))); ape_uuid2 = (ape_uuid2 + (ape_phdrs_end >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_phdrs_end >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_phdrs_end >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (ape_phdrs_end >> 030) & 0xFF) * 0x9e3779b9925d4c17;
ape_uuid1 = ((ape_uuid1 | (WinMain >> 12)) - (ape_uuid1 & (WinMain >> 12))); ape_uuid1 = ((ape_uuid1 | (WinMain << 25)) - (ape_uuid1 & (WinMain << 25))); ape_uuid1 = ((ape_uuid1 | (WinMain >> 27)) - (ape_uuid1 & (WinMain >> 27))); ape_uuid1 = (ape_uuid1 + (WinMain >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (WinMain >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (WinMain >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid1 = (ape_uuid1 + (WinMain >> 030) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = ((ape_uuid2 | (WinMain >> 12)) - (ape_uuid2 & (WinMain >> 12))); ape_uuid2 = ((ape_uuid2 | (WinMain << 25)) - (ape_uuid2 & (WinMain << 25))); ape_uuid2 = ((ape_uuid2 | (WinMain >> 27)) - (ape_uuid2 & (WinMain >> 27))); ape_uuid2 = (ape_uuid2 + (WinMain >> 000) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (WinMain >> 010) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (WinMain >> 020) & 0xFF) * 0x9e3779b9925d4c17; ape_uuid2 = (ape_uuid2 + (WinMain >> 030) & 0xFF) * 0x9e3779b9925d4c17;
ASSERT(DEFINED(ape_mz) ? ape_mz == 0x400000 : 1, "linker panic");
ASSERT((DEFINED(__init_bss_end) ? __init_bss_end : 0) % 8 == 0,
"__init_bss misalign");
ASSERT(((DEFINED(__init_rodata_end) ? __init_rodata_end : 0) %
8 == 0),
"__init_rodata misalign");
ASSERT((!DEFINED(ape_grub) ? 1 : ((ape_grub) - (0x400000)) < 8192),
"grub stub needs to be in first 8kb of image");
ASSERT(DEFINED(_start) || DEFINED(_start16),
"please link a _start() or _start16() entrypoint");
ASSERT(!DEFINED(_start16) || ((_end) - (0x400000 - 0x2000)) < 65536,
"ape won't support non-tiny real mode programs");

BIN
DtsodC/cosmopolitan/ape.o Normal file

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

BIN
DtsodC/cosmopolitan/crt.o Normal file

Binary file not shown.

6
DtsodC/src/DtsodV24.c Normal file
View File

@@ -0,0 +1,6 @@
#if COSMOPOLITAN
#include "../cosmopolitan/cosmopolitan.h"
#else
#include "stdio.h"
#endif

6
DtsodC/src/DtsodV24.h Normal file
View File

@@ -0,0 +1,6 @@
#if COSMOPOLITAN
#include "../cosmopolitan/cosmopolitan.h"
#else
#include "stdio.h"
#endif

View File

@@ -0,0 +1,60 @@
#ifndef STDLIB
#include "../../cosmopolitan/cosmopolitan.h"
#else
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#endif
#include "Autoarr.h"
Autoarr* Autoarr_create(uint16 max_block_count, uint16 max_block_length, strict_type type){
Autoarr* rezult=malloc(sizeof(Autoarr));
rezult->type=type;
rezult->max_block_length=max_block_length;
rezult->curr_block_length=0;
rezult->max_block_count=max_block_count;
rezult->block_count=0;
rezult->values=malloc(rezult->max_block_count*GetTypeSize(type));
return rezult;
}
uint32 Autoarr_length(Autoarr *a){
return (uint32)((a->block_count-1)*a->max_block_length+a->curr_block_length);
}
uint32 Autoarr_max_length(Autoarr *a){
return a->max_block_count*a->max_block_length;
}
void __Autoarr_add_block(Autoarr *autoarr){
if (autoarr->block_count>=autoarr->max_block_count)
throwerr(ERR_MAXLENGTH);
if (autoarr->curr_block_length==(autoarr->max_block_length|0))
autoarr->curr_block_length=0;
else if (autoarr->curr_block_length>0)
throwerr(ERR_NOTFULL);
*(autoarr->values+autoarr->block_count)=malloc(autoarr->max_block_length*GetTypeSize(autoarr->type));
autoarr->block_count++;
}
void Autoarr_add(Autoarr *autoarr, void *element){
if(Autoarr_length(autoarr)<Autoarr_max_length(autoarr))
throwerr(ERR_MAXLENGTH);
if (autoarr->curr_block_length==autoarr->max_block_length)
__Autoarr_add_block(autoarr);
AssignVoidToVoid((autoarr->values+autoarr->block_count-1)+autoarr->curr_block_length, element, autoarr->type);
}
void Autoarr_set(Autoarr *autoarr, uint32 index, void *element){
}
void Autoarr_remove(Autoarr *autoarr, uint32 index){
}
void Autoarr_removeRange(Autoarr *autoarr, uint32 startIndex, uint32 length){
}

View File

@@ -0,0 +1,40 @@
#ifndef STDLIB
#include "../../cosmopolitan/cosmopolitan.h"
#else
#include <stdint.h>
#endif
#include "../strict_types.h"
#include "../err_t.h"
typedef struct Autoarr{
void** values;
strict_type type;
uint16 max_block_length;
uint16 curr_block_length;
uint16 block_count;
uint16 max_block_count;
} Autoarr;
typedef Autoarr Autoarr;
Autoarr* Autoarr_create(uint16 max_length, uint16 max_block_length, strict_type type);
uint32 Autoarr_length(Autoarr *a);
uint32 Autoarr_max_length(Autoarr *a);
void Autoarr_add(Autoarr *autoarr, void *element);
void Autoarr_set(Autoarr *autoarr, uint32 index, void *element);
void Autoarr_remove(Autoarr *autoarr, uint32 index);
void Autoarr_removeRange(Autoarr *autoarr, uint32 startIndex, uint32 length);
int8 Autoarr_get_int8(Autoarr *autoarr, uint32 index);
uint8 Autoarr_get_uint8(Autoarr *autoarr, uint32 index);
int16 Autoarr_get_int16(Autoarr *autoarr, uint32 index);
uint16 Autoarr_get_uint16(Autoarr *autoarr, uint32 index);
int32 Autoarr_get_int32(Autoarr *autoarr, uint32 index);
uint32 Autoarr_get_uint32(Autoarr *autoarr, uint32 index);
int64 Autoarr_get_int64(Autoarr *autoarr, uint32 index);
uint64 Autoarr_get_uint64(Autoarr *autoarr, uint32 index);

9
DtsodC/src/err_t.h Normal file
View File

@@ -0,0 +1,9 @@
#ifndef __ERR_AUTOARR_DEFINED
#define __ERR_AUTOARR_DEFINED
typedef enum err_t {
SUCCESS, ERR_MAXLENGTH, ERR_WRONGTYPE, ERR_WRONGINDEX, ERR_NOTFULL
} err_t;
void throwstr(const char* errmesg);
void throwerr(err_t err);
#endif

39
DtsodC/src/strict_types.c Normal file
View File

@@ -0,0 +1,39 @@
#ifndef STDLIB
#include "../cosmopolitan/cosmopolitan.h"
#else
#include "stdint.h"
#endif
#include "strict_types.h"
#include "err_t.h"
int8 GetTypeSize(strict_type type){
int8 type_size=0;
switch (type)
{
case Int8: type_size=8; break;
case Uint8: type_size=8; break;
case Int16: type_size=16; break;
case Uint16: type_size=16; break;
case Int32: type_size=32; break;
case Uint32: type_size=32; break;
case Int64: type_size=64; break;
case Uint64: type_size=64; break;
default: throwerr(ERR_WRONGTYPE);
}
return type_size;
}
void AssignVoidToVoid(void* a, void*b, strict_type type){
switch (type)
{
case Int8: *((int8*)a)=*((int8*)b); break;
case Uint8: *((uint8*)a)=*((uint8*)b); break;
case Int16: *((int16*)a)=*((int16*)b); break;
case Uint16: *((uint16*)a)=*((uint16*)b); break;
case Int32: *((int32*)a)=*((int32*)b); break;
case Uint32: *((uint32*)a)=*((uint32*)b); break;
case Int64: *((int64*)a)=*((int64*)b); break;
case Uint64: *((uint64*)a)=*((uint64*)b); break;
default: throwerr(ERR_WRONGTYPE);
}
}

26
DtsodC/src/strict_types.h Normal file
View File

@@ -0,0 +1,26 @@
#ifndef STDLIB
#include "../cosmopolitan/cosmopolitan.h"
#else
#include "stdint.h"
#endif
#include "err_t.h"
typedef int8_t int8;
typedef uint8_t uint8;
typedef int16_t int16;
typedef uint16_t uint16;
typedef int32_t int32;
typedef uint32_t uint32;
typedef int64_t int64;
typedef uint64_t uint64;
#ifndef __STRICT_TYPES_DEFINED
#define __STRICT_TYPES_DEFINED
typedef enum strict_type{
Int8, Int16, Int32, Int64, Uint8, Uint16, Uint32, Uint64
} strict_type;
int8 GetTypeSize(strict_type type);
void AssignVoidToVoid(void* a, void*b, strict_type type);
#endif

45
DtsodC/src/test.c Normal file
View File

@@ -0,0 +1,45 @@
#ifndef STDLIB
#include "../cosmopolitan/cosmopolitan.h"
#else
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <locale.h>
#include <uchar.h>
#include <wchar.h>
#include <sys/stat.h>
#include <time.h>
#endif
#include "strict_types.h"
#include "autosize_array/Autoarr.h"
void nsleep(long miliseconds) {
struct timespec ts = {10, miliseconds * 1000000L};
nanosleep(&ts, NULL);
}
int8 main(){
printf("\e[32mdtsod parser in c language!\n");
dsleep(0.5);
//Autoarr* ar=Autoarr_create(100,10,Int8);
//Autoarr_add_int8(&ar,-1);
//printf("ar[0]==%d",Autoarr_get_int8(&ar,0));
//free(ar);
//setlocale(LC_ALL, "en-US.Unicode");
/*struct stat st;
FILE* f1 = fopen("1.gui","r");
FILE* f2 = fopen("2.gui","r");
fstat(fileno(f1), &st);
size_t size = st.st_size;
char page1[size];
fread(page1, 8, size, f1);
char page2[size];
fread(page2, 8, size, f2);
printf("\e[31m\n");
for (int64 i = 0; i<100000; i++){
nsleep(10000L);
if(i%2==0) printf("%s", page1);
else printf("%s", page2);
}*/
printf("\e[32m\n");
//getc(stdin);
return 0;
}

17
DtsodC/src/throw.c Normal file
View File

@@ -0,0 +1,17 @@
#ifndef STDLIB
#include "../cosmopolitan/cosmopolitan.h"
#else
#include <stdio.h>
#include <stdlib.h>
#endif
#include "err_t.h"
void throwstr(const char* errmesg){
printf("\e[31mthrowed error: %s\e[0m\n",errmesg);
exit(1);
}
void throwerr(err_t err){
printf("\e[31mthrowed error: err_t:%d\e[0m\n",err);
exit(err);
}

View File

@@ -1,2 +1,2 @@
# DTLib
library for all my projects
# DTLib
library for all my projects

View File

@@ -1,89 +1,89 @@
using System.Threading;
using DTLib.Dtsod;
using DTLib.Experimental;
using static TestProgram.Program;
namespace TestProgram.DtsodV2X;
public static class TestDtsodV23
{
public static void TestAll()
{
TestBaseTypes();
TestLists();
TestComplexes();
TestReSerialization();
TestSpeed();
TestMemoryConsumption();
}
public static void TestBaseTypes()
{
Info.Log("b", "[TestDtsodV23/TestBaseTypes]");
DtsodV23 dtsod = new(File.ReadAllText("DtsodV2X\\base_types.dtsod"));
foreach (var pair in dtsod)
Info.LogNoTime("b", pair.Value.GetType().Name + ' ', "w", pair.Key + ' ', "c", pair.Value.ToString());
Info.Log("g", "[test completed]");
}
public static void TestLists()
{
Info.Log("b", "[TestDtsodV23/TestLists]");
DtsodV23 dtsod = new(File.ReadAllText("DtsodV2X\\lists.dtsod"));
foreach (var pair in dtsod)
{
Info.LogNoTime("b", pair.Value.GetType().Name + ' ', "w", pair.Key, "c",
$" count: {pair.Value.Count}");
foreach (var el in pair.Value)
Info.LogNoTime("b", '\t'+el.GetType().Name + ' ', "c", el.ToString());
}
Info.Log("g", "[test completed]");
}
public static void TestComplexes()
{
Info.Log("b", "[TestDtsodV23/TestComplexes]");
DtsodV23 dtsod = new(File.ReadAllText("DtsodV2X\\complexes.dtsod"));
foreach (var pair in dtsod)
{
Info.LogNoTime("b", pair.Value.GetType().Name + ' ', "w", pair.Key,
"b", " length: ", "c", pair.Value.Keys.Count.ToString() + "\n\t",
"y", pair.Value.ToString().Replace("\n","\n\t"));
}
Info.Log("g", "[test completed]");
}
public static void TestReSerialization()
{
Info.Log("b", "[TestDtsodV23/TestReSerialization]");
DtsodV23 dtsod = new DtsodV23(new DtsodV23(new DtsodV23(
new DtsodV23(File.ReadAllText("DtsodV2X\\complexes.dtsod")).ToString()).ToString()).ToString());
Info.Log("y", dtsod.ToString());
Info.Log("g", "[test completed]");
}
public static void TestSpeed()
{
Info.Log("b", "[TestDtsodV23/TestSpeed]");
IDtsod dtsod=null;
string text = File.ReadAllText("DtsodV2X\\messages.dtsod");
Tester.LogOperationTime("V21 deserialization",100,()=>dtsod=new DtsodV21(text));
Tester.LogOperationTime("V21 serialization", 100, () => _=dtsod.ToString());
Tester.LogOperationTime("V23 deserialization", 100, () => dtsod = new DtsodV23(text));
Tester.LogOperationTime("V23 serialization", 100, () => _ = dtsod.ToString());
Info.Log("g", "[test completed]");
}
public static void TestMemoryConsumption()
{
Info.Log("b", "[TestDtsodV23/TestMemoryConsumption]");
string text = File.ReadAllText("DtsodV2X\\messages.dtsod");
var a = GC.GetTotalMemory(true);
DtsodV23[] dtsods = new DtsodV23[100];
for (int i = 0; i < dtsods.Length; i++)
dtsods[i] = new(text);
var b = GC.GetTotalMemory(true);
Info.Log("b", "at the start: ","c",$"{a/1024} kb\n",
"b", "at the end: ", "c", $"{b / 1024} kb\n{dtsods.Count()}","b"," dtsods initialized");
Info.Log("g", "[test completed]");
}
}
using System.Threading;
using DTLib.Dtsod;
using DTLib.Experimental;
using static TestProgram.Program;
namespace TestProgram.DtsodV2X;
public static class TestDtsodV23
{
public static void TestAll()
{
TestBaseTypes();
TestLists();
TestComplexes();
TestReSerialization();
TestSpeed();
TestMemoryConsumption();
}
public static void TestBaseTypes()
{
Info.Log("b", "[TestDtsodV23/TestBaseTypes]");
DtsodV23 dtsod = new(File.ReadAllText("DtsodV2X\\base_types.dtsod"));
foreach (var pair in dtsod)
Info.LogNoTime("b", pair.Value.GetType().Name + ' ', "w", pair.Key + ' ', "c", pair.Value.ToString());
Info.Log("g", "[test completed]");
}
public static void TestLists()
{
Info.Log("b", "[TestDtsodV23/TestLists]");
DtsodV23 dtsod = new(File.ReadAllText("DtsodV2X\\lists.dtsod"));
foreach (var pair in dtsod)
{
Info.LogNoTime("b", pair.Value.GetType().Name + ' ', "w", pair.Key, "c",
$" count: {pair.Value.Count}");
foreach (var el in pair.Value)
Info.LogNoTime("b", '\t'+el.GetType().Name + ' ', "c", el.ToString());
}
Info.Log("g", "[test completed]");
}
public static void TestComplexes()
{
Info.Log("b", "[TestDtsodV23/TestComplexes]");
DtsodV23 dtsod = new(File.ReadAllText("DtsodV2X\\complexes.dtsod"));
foreach (var pair in dtsod)
{
Info.LogNoTime("b", pair.Value.GetType().Name + ' ', "w", pair.Key,
"b", " length: ", "c", pair.Value.Keys.Count.ToString() + "\n\t",
"y", pair.Value.ToString().Replace("\n","\n\t"));
}
Info.Log("g", "[test completed]");
}
public static void TestReSerialization()
{
Info.Log("b", "[TestDtsodV23/TestReSerialization]");
DtsodV23 dtsod = new DtsodV23(new DtsodV23(new DtsodV23(
new DtsodV23(File.ReadAllText("DtsodV2X\\complexes.dtsod")).ToString()).ToString()).ToString());
Info.Log("y", dtsod.ToString());
Info.Log("g", "[test completed]");
}
public static void TestSpeed()
{
Info.Log("b", "[TestDtsodV23/TestSpeed]");
IDtsod dtsod=null;
string text = File.ReadAllText("DtsodV2X\\messages.dtsod");
Tester.LogOperationTime("V21 deserialization",100,()=>dtsod=new DtsodV21(text));
Tester.LogOperationTime("V21 serialization", 100, () => _=dtsod.ToString());
Tester.LogOperationTime("V23 deserialization", 100, () => dtsod = new DtsodV23(text));
Tester.LogOperationTime("V23 serialization", 100, () => _ = dtsod.ToString());
Info.Log("g", "[test completed]");
}
public static void TestMemoryConsumption()
{
Info.Log("b", "[TestDtsodV23/TestMemoryConsumption]");
string text = File.ReadAllText("DtsodV2X\\messages.dtsod");
var a = GC.GetTotalMemory(true);
DtsodV23[] dtsods = new DtsodV23[100];
for (int i = 0; i < dtsods.Length; i++)
dtsods[i] = new(text);
var b = GC.GetTotalMemory(true);
Info.Log("b", "at the start: ","c",$"{a/1024} kb\n",
"b", "at the end: ", "c", $"{b / 1024} kb\n{dtsods.Count()}","b"," dtsods initialized");
Info.Log("g", "[test completed]");
}
}

View File

@@ -1,14 +1,14 @@
bool: false;
char: 'v';
byte: 255b;
sbyte: -125sb;
short: 14003s;
ushort: 32025us;
int: -2515;
uint: 0u;
long: -29863854396l;
ulong: 87659057946ul;
float: 39.944f;
double: 965.557;
decimal: -84.20de;
string: "_$\"\\\\'''\n\ta ûûû000;2;=:%d;```";
bool: false;
char: 'v';
byte: 255b;
sbyte: -125sb;
short: 14003s;
ushort: 32025us;
int: -2515;
uint: 0u;
long: -29863854396l;
ulong: 87659057946ul;
float: 39.944f;
double: 965.557;
decimal: -84.20de;
string: "_$\"\\\\'''\n\ta ûûû000;2;=:%d;```";

View File

@@ -1,4 +1,4 @@
chars: ['a','b','c'];
uints: [10,20,30,0,0];
floats: [8.2,5.225,-0.9993];
chars: ['a','b','c'];
uints: [10,20,30,0,0];
floats: [8.2,5.225,-0.9993];
strings:["aaa","bbb","ccc"];

View File

@@ -1,14 +1,14 @@
bool:b=false;
char:c='v';
string:s="hello";
byte:by=255;
sbyte:sb=-125;
short:sh=14003;
ushort:us=32025;
int:i=-2515;
uint:ui=0;
long:l=-29863854396;
ulong:ul=87659057946;
float:f=39.944;
double:do=965.557;
bool:b=false;
char:c='v';
string:s="hello";
byte:by=255;
sbyte:sb=-125;
short:sh=14003;
ushort:us=32025;
int:i=-2515;
uint:ui=0;
long:l=-29863854396;
ulong:ul=87659057946;
float:f=39.944;
double:do=965.557;
decimal:de=-84.20;

View File

@@ -1 +1 @@
List<string>:list=[string:"a",string:"b"];
List<string>:list=[string:"a",string:"b"];

View File

@@ -1,36 +1,36 @@
global using System;
global using System.Collections;
global using System.Collections.Generic;
global using System.Linq;
global using System.Text;
global using System.Threading.Tasks;
global using DTLib;
global using DTLib.Extensions;
global using DTLib.Filesystem;
using DTLib.Dtsod;
using DTLib.Loggers;
using TestProgram.DtsodV2X;
namespace TestProgram;
static class Program
{
public static DefaultLogger Info = new();
static public void Main()
{
Info.Enable();
PublicLog.LogEvent += Info.Log;
PublicLog.LogNoTimeEvent += Info.LogNoTime;
Console.OutputEncoding = Encoding.UTF8;
Console.InputEncoding = Encoding.UTF8;
Console.Title="tester";
try
{
TestDtsodV23.TestAll();
}
catch (Exception ex)
{ Info.Log("r", ex.ToString()); }
Console.ResetColor();
}
global using System;
global using System.Collections;
global using System.Collections.Generic;
global using System.Linq;
global using System.Text;
global using System.Threading.Tasks;
global using DTLib;
global using DTLib.Extensions;
global using DTLib.Filesystem;
using DTLib.Dtsod;
using DTLib.Loggers;
using TestProgram.DtsodV2X;
namespace TestProgram;
static class Program
{
public static DefaultLogger Info = new();
static public void Main()
{
Info.Enable();
PublicLog.LogEvent += Info.Log;
PublicLog.LogNoTimeEvent += Info.LogNoTime;
Console.OutputEncoding = Encoding.UTF8;
Console.InputEncoding = Encoding.UTF8;
Console.Title="tester";
try
{
TestDtsodV23.TestAll();
}
catch (Exception ex)
{ Info.Log("r", ex.ToString()); }
Console.ResetColor();
}
}

View File

@@ -1,24 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>false</ImplicitUsings>
<Nullable>disable</Nullable>
<DebugType>portable</DebugType>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<StartupObject>TestProgram.Program</StartupObject>
<ProduceReferenceAssembly>False</ProduceReferenceAssembly>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\DTLib\DTLib.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="DtsodV2X\*">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="DtsodV30\*">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>false</ImplicitUsings>
<Nullable>disable</Nullable>
<DebugType>portable</DebugType>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<StartupObject>TestProgram.Program</StartupObject>
<ProduceReferenceAssembly>False</ProduceReferenceAssembly>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\DTLib\DTLib.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="DtsodV2X\*">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="DtsodV30\*">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>