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

367
.gitignore vendored
View File

@@ -1,359 +1,8 @@
# User-specific files *.user
*.rsuser [Bb]in/
*.suo [Oo]bj/
*.user [Oo]ut/
*.userosscache [Ll]og/
*.sln.docstates [Ll]ogs/
.vs/
# User-specific files (MonoDevelop/Xamarin Studio) .vshistory/
*.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

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,14 +1,14 @@
bool:b=false; bool:b=false;
char:c='v'; char:c='v';
string:s="hello"; string:s="hello";
byte:by=255; byte:by=255;
sbyte:sb=-125; sbyte:sb=-125;
short:sh=14003; short:sh=14003;
ushort:us=32025; ushort:us=32025;
int:i=-2515; int:i=-2515;
uint:ui=0; uint:ui=0;
long:l=-29863854396; long:l=-29863854396;
ulong:ul=87659057946; ulong:ul=87659057946;
float:f=39.944; float:f=39.944;
double:do=965.557; double:do=965.557;
decimal:de=-84.20; 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;
global using System.Collections; global using System.Collections;
global using System.Collections.Generic; global using System.Collections.Generic;
global using System.Linq; global using System.Linq;
global using System.Text; global using System.Text;
global using System.Threading.Tasks; global using System.Threading.Tasks;
global using DTLib; global using DTLib;
global using DTLib.Extensions; global using DTLib.Extensions;
global using DTLib.Filesystem; global using DTLib.Filesystem;
using DTLib.Dtsod; using DTLib.Dtsod;
using DTLib.Loggers; using DTLib.Loggers;
using TestProgram.DtsodV2X; using TestProgram.DtsodV2X;
namespace TestProgram; namespace TestProgram;
static class Program static class Program
{ {
public static DefaultLogger Info = new(); public static DefaultLogger Info = new();
static public void Main() static public void Main()
{ {
Info.Enable(); Info.Enable();
PublicLog.LogEvent += Info.Log; PublicLog.LogEvent += Info.Log;
PublicLog.LogNoTimeEvent += Info.LogNoTime; PublicLog.LogNoTimeEvent += Info.LogNoTime;
Console.OutputEncoding = Encoding.UTF8; Console.OutputEncoding = Encoding.UTF8;
Console.InputEncoding = Encoding.UTF8; Console.InputEncoding = Encoding.UTF8;
Console.Title="tester"; Console.Title="tester";
try try
{ {
TestDtsodV23.TestAll(); TestDtsodV23.TestAll();
} }
catch (Exception ex) catch (Exception ex)
{ Info.Log("r", ex.ToString()); } { Info.Log("r", ex.ToString()); }
Console.ResetColor(); Console.ResetColor();
} }
} }

View File

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