diff --git a/.devcontainer/All/Dockerfile.All b/.devcontainer/All/Dockerfile.All index eb5a866b62..aa4c634c91 100644 --- a/.devcontainer/All/Dockerfile.All +++ b/.devcontainer/All/Dockerfile.All @@ -1 +1 @@ -FROM ghcr.io/nanoframework/dev-container-all:v2.57 +FROM ghcr.io/nanoframework/dev-container-all:v3.0 diff --git a/.devcontainer/AzureRTOS/Dockerfile.AzureRTOS b/.devcontainer/AzureRTOS/Dockerfile.AzureRTOS index f35fb4349d..a493cf45c2 100644 --- a/.devcontainer/AzureRTOS/Dockerfile.AzureRTOS +++ b/.devcontainer/AzureRTOS/Dockerfile.AzureRTOS @@ -1 +1 @@ -FROM ghcr.io/nanoframework/dev-container-azure-rtos:v1.34 +FROM ghcr.io/nanoframework/dev-container-azure-rtos:v3.0 diff --git a/.devcontainer/ChibiOS/Dockerfile.ChibiOS b/.devcontainer/ChibiOS/Dockerfile.ChibiOS index f635962e5d..0c528fff5c 100644 --- a/.devcontainer/ChibiOS/Dockerfile.ChibiOS +++ b/.devcontainer/ChibiOS/Dockerfile.ChibiOS @@ -1 +1 @@ -FROM ghcr.io/nanoframework/dev-container-chibios:v1.35 +FROM ghcr.io/nanoframework/dev-container-chibios:v3.0 diff --git a/.devcontainer/ESP32/Dockerfile.ESP32 b/.devcontainer/ESP32/Dockerfile.ESP32 index c9bc9d668b..b1bf2af4b9 100644 --- a/.devcontainer/ESP32/Dockerfile.ESP32 +++ b/.devcontainer/ESP32/Dockerfile.ESP32 @@ -1 +1 @@ -FROM ghcr.io/nanoframework/dev-container-esp32:v2.37 +FROM ghcr.io/nanoframework/dev-container-esp32:v3.0 diff --git a/.devcontainer/FreeRTOS-NXP/Dockerfile.FreeRTOS-NXP b/.devcontainer/FreeRTOS-NXP/Dockerfile.FreeRTOS-NXP index 151e8af502..0123dbcc52 100644 --- a/.devcontainer/FreeRTOS-NXP/Dockerfile.FreeRTOS-NXP +++ b/.devcontainer/FreeRTOS-NXP/Dockerfile.FreeRTOS-NXP @@ -1 +1 @@ -FROM ghcr.io/nanoframework/dev-container-freertos-nxp:v1.07 +FROM ghcr.io/nanoframework/dev-container-freertos-nxp:v3.0 diff --git a/.devcontainer/TI/Dockerfile.TI b/.devcontainer/TI/Dockerfile.TI index da57956e29..599c1872d5 100644 --- a/.devcontainer/TI/Dockerfile.TI +++ b/.devcontainer/TI/Dockerfile.TI @@ -1 +1 @@ -FROM ghcr.io/nanoframework/dev-container-ti:v1.27 +FROM ghcr.io/nanoframework/dev-container-ti:v3.0 diff --git a/CMake/Modules/AzureRTOS_EFM32GG11_GCC_options.cmake b/CMake/Modules/AzureRTOS_EFM32GG11_GCC_options.cmake index 0e60b8b219..7375984035 100644 --- a/CMake/Modules/AzureRTOS_EFM32GG11_GCC_options.cmake +++ b/CMake/Modules/AzureRTOS_EFM32GG11_GCC_options.cmake @@ -62,7 +62,7 @@ macro(nf_set_link_options) # set optimization linker flags for RELEASE and MinSizeRel if(CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "MinSizeRel") - set_property(TARGET ${NFSLO_TARGET} APPEND_STRING PROPERTY LINK_FLAGS " -Os -flto -fuse-linker-plugin ") + set_property(TARGET ${NFSLO_TARGET} APPEND_STRING PROPERTY LINK_FLAGS " -Os") endif() # request specs from newlib nano diff --git a/CMake/Modules/FindNF_CoreCLR.cmake b/CMake/Modules/FindNF_CoreCLR.cmake index f415d8b4da..3020e385a8 100644 --- a/CMake/Modules/FindNF_CoreCLR.cmake +++ b/CMake/Modules/FindNF_CoreCLR.cmake @@ -49,6 +49,7 @@ set(NF_CoreCLR_SRCS CLR_RT_HeapBlock_Delegate.cpp CLR_RT_HeapBlock_Delegate_List.cpp CLR_RT_HeapBlock_Finalizer.cpp + CLR_RT_HeapBlock_GenericInstance.cpp CLR_RT_HeapBlock_Lock.cpp CLR_RT_HeapBlock_LockRequest.cpp CLR_RT_HeapBlock_Node.cpp @@ -129,7 +130,6 @@ set(NF_CoreCLR_SRCS # Runtime.Native nf_rt_native.cpp nf_rt_native_nanoFramework_Runtime_Hardware_SystemInfo.cpp - nf_rt_native_nanoFramework_Runtime_Native_GC.cpp nf_rt_native_nanoFramework_Runtime_Native_ExecutionConstraint.cpp nf_rt_native_nanoFramework_Runtime_Native_Power.cpp nf_rt_native_nanoFramework_Runtime_Native_Rtc_stubs.cpp diff --git a/CMake/Modules/TI_SimpleLink_CC13X2_GCC_options.cmake b/CMake/Modules/TI_SimpleLink_CC13X2_GCC_options.cmake index 75cb9cf33b..dbb3f376f9 100644 --- a/CMake/Modules/TI_SimpleLink_CC13X2_GCC_options.cmake +++ b/CMake/Modules/TI_SimpleLink_CC13X2_GCC_options.cmake @@ -51,7 +51,7 @@ macro(nf_set_link_options) # set optimization linker flags for RELEASE and MinSizeRel if(CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "MinSizeRel") - set_property(TARGET ${NFSLO_TARGET} APPEND_STRING PROPERTY LINK_FLAGS " -Os -flto -fuse-linker-plugin ") + set_property(TARGET ${NFSLO_TARGET} APPEND_STRING PROPERTY LINK_FLAGS " -Os ") endif() # request specs from newlib nano diff --git a/CMake/binutils.AzureRTOS.cmake b/CMake/binutils.AzureRTOS.cmake index fa0e98e116..6e2be07abf 100644 --- a/CMake/binutils.AzureRTOS.cmake +++ b/CMake/binutils.AzureRTOS.cmake @@ -4,14 +4,13 @@ # include(binutils.common) -# include(ChibiOS_HAL) function(nf_set_optimization_options target) target_compile_options(${target} PRIVATE $<$:-Og -ggdb> - $<$:-O3 -flto> - $<$:-Os -flto> + $<$:-O3> + $<$:-Os> $<$:-Os -femit-class-debug-always -ggdb> ) diff --git a/CMake/binutils.TI_SimpleLink.cmake b/CMake/binutils.TI_SimpleLink.cmake index 44095e48f4..118b4da02d 100644 --- a/CMake/binutils.TI_SimpleLink.cmake +++ b/CMake/binutils.TI_SimpleLink.cmake @@ -13,8 +13,8 @@ function(nf_set_optimization_options target) # debug compile options: -Og (optimize for debugging) and -ggdb (produce debug symbols specifically for gdb) target_compile_options(${target} PRIVATE $<$:-Og -ggdb> - $<$:-O3 -flto> - $<$:-Os -flto> + $<$:-O3> + $<$:-Os> $<$:-Os -ggdb> ) diff --git a/InteropAssemblies/CLR_RT_InteropAssembliesTable.cpp.in b/InteropAssemblies/CLR_RT_InteropAssembliesTable.cpp.in index 46428092cb..145f6b75b5 100644 --- a/InteropAssemblies/CLR_RT_InteropAssembliesTable.cpp.in +++ b/InteropAssemblies/CLR_RT_InteropAssembliesTable.cpp.in @@ -19,7 +19,7 @@ const CLR_RT_NativeAssemblyData *g_CLR_InteropAssembliesNativeData[] = &g_CLR_AssemblyNative_mscorlib, &g_CLR_AssemblyNative_nanoFramework_Runtime_Native, @CLR_RT_NativeAssemblyDataTableEntries@ - NULL + nullptr }; const uint16_t g_CLR_InteropAssembliesCount = (@CLR_RT_NativeAssembliesCount@ + 2); diff --git a/azure-pipelines-nightly.yml b/azure-pipelines-nightly.yml index 27574b31cd..16a0be3807 100644 --- a/azure-pipelines-nightly.yml +++ b/azure-pipelines-nightly.yml @@ -283,18 +283,18 @@ jobs: NeedsSRECORD: false CMakePreset: ORGPAL_PALX - ST_NUCLEO64_F091RC: - TargetBoard: ST_NUCLEO64_F091RC - TargetSeries: "stm32f0xx" - BuildOptions: - NeedsDFU: false - NeedsSRECORD: true - CMakePreset: ST_NUCLEO64_F091RC + # ST_NUCLEO64_F091RC: + # TargetBoard: ST_NUCLEO64_F091RC + # TargetSeries: "stm32f0xx" + # BuildOptions: + # NeedsDFU: false + # NeedsSRECORD: true + # CMakePreset: ST_NUCLEO64_F091RC variables: DOTNET_NOLOGO: true # creates a counter and assigns it to the revision variable - REVISION: $[counter('STM32_1_12_4_versioncounter', 0)] + REVISION: $[counter('STM32_2_0_0_versioncounter', 0)] HelperPackageVersion: $[counter('HelperPackageVersioncounter', 0)] TargetPlatform: "stm32" @@ -582,7 +582,7 @@ jobs: variables: DOTNET_NOLOGO: true # creates a counter and assigns it to the revision variable - REVISION: $[counter('ESP32_1_12_4_versioncounter', 0)] + REVISION: $[counter('ESP32_2_0_0_versioncounter', 0)] IDF_PATH: "D:/a/1/s/esp-idf" PIP_CACHE_DIR: $(Pipeline.Workspace)/.pip TargetPlatform: "esp32" @@ -665,7 +665,7 @@ jobs: variables: DOTNET_NOLOGO: true # creates a counter and assigns it to the revision variable - REVISION: $[counter('TI_1_12_4_versioncounter', 0)] + REVISION: $[counter('TI_2_0_0_versioncounter', 0)] HelperPackageVersion: $[counter('HelperPackageVersioncounter', 0)] TargetPlatform: "ti_simplelink" @@ -717,7 +717,7 @@ jobs: variables: # creates a counter and assigns it to the revision variable - REVISION: $[counter('AZURERTOS_1_12_4_versioncounter', 0)] + REVISION: $[counter('AZURERTOS_2_0_0_versioncounter', 0)] HelperPackageVersion: $[counter('HelperPackageVersioncounter', 0)] TargetPlatform: "efm32" diff --git a/azure-pipelines-templates/check-mdp-for-build.yml b/azure-pipelines-templates/check-mdp-for-build.yml new file mode 100644 index 0000000000..d7219214e5 --- /dev/null +++ b/azure-pipelines-templates/check-mdp-for-build.yml @@ -0,0 +1,93 @@ +# Copyright (c) .NET Foundation and Contributors +# See LICENSE file in the project root for full license information. + +steps: + - task: PowerShell@2 + displayName: Check MDP for build + condition: ne(variables['System.PullRequest.PullRequestId'], '') + inputs: + failOnStderr: false + targetType: "inline" + script: | + + # compute authorization header in format "AUTHORIZATION: basic 'encoded token'" + # 'encoded token' is the Base64 of the string "nfbot:personal-token" + $auth = "basic $([System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes("nfbot:$(GitHubToken)")))" + + # find PR + "Getting PR#$env:System_PullRequest_PullRequestNumber details..." | Write-Host -ForegroundColor White -NoNewline + $pr = Invoke-WebRequest "https://api.github.com/repos/$env:Build_Repository_Name/pulls/$env:System_PullRequest_PullRequestNumber" | ConvertFrom-Json + + if($($pr.number) -eq "$env:System_PullRequest_PullRequestNumber") + { + '##[command] OK' | Write-Host -ForegroundColor Green + } + + # grab PR commit message + $prCommitMessage = $($pr.body) + + # look for test prompt in PR commit message + # pattern is "[build with MDP buildId NNN]" + + if($prCommitMessage -match "\[build with MDP buildId (\d+)\]") + { + $buildId = $matches[1] + "AZDO build ID found: $buildId" | Write-Host -ForegroundColor White + + echo "##vso[task.setvariable variable=MDP_BUILDID]$buildId" + } + else + { + "No build ID found" | Write-Host -ForegroundColor Red + } + env: + GITHUB_TOKEN: $(GitHubToken) + + - task: DownloadPipelineArtifact@2 + condition: >- + and( + eq(variables['DownloadMDP'], true), + ne(variables['MDP_BUILDID'], '') + ) + displayName: Download MDP + inputs: + buildType: specific + project: 'metadata-processor' + definition: '43' + buildVersionToDownload: specific + allowFailedBuilds: true + pipelineId: $(MDP_BUILDID) + artifactName: 'deployables' + targetPath: '$(Pipeline.Workspace)/mdp' + itemPattern: '*.MsBuildTask.dll' + + - task: PowerShell@2 + condition: >- + and( + succeeded(), + eq(variables['DownloadMDP'], true), + ne(variables['MDP_BUILDID'], '') + ) + displayName: Copy MDP to build tool + inputs: + targetType: 'inline' + script: | + # Find which VS version is installed + $VsWherePath = "${env:PROGRAMFILES(X86)}\Microsoft Visual Studio\Installer\vswhere.exe" + + Write-Output "VsWherePath is: $VsWherePath" + + $VsInstance = & $VsWherePath -latest -property displayName + + Write-Output "Latest VS is: $VsInstance" + + # copy MDP file to msbuild location + $VsPath = & $VSWherePath -latest -property installationPath + + Write-Debug "Copy MDP DLL to msbuild location" + + $msbuildPath = $VsPath + "\MSBuild" + + $extensionPath = $msbuildPath + "\nanoFramework\v1.0" + + Copy-Item -Path "$env:Pipeline_Workspace\mdp\*" -Destination $extensionPath -Force -Verbose diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 6a54667d94..39c692575b 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -78,7 +78,7 @@ jobs: { # this is a release prep so NO build echo "##vso[task.setvariable variable=SKIP_BUILD;isOutput=true]true" - + Write-Host "##[command] Release preparation, skipping build." } else @@ -86,26 +86,52 @@ jobs: # get commit details, if this is a PR if($env:System_PullRequest_PullRequestId -ne $null) { - Write-Host "##[command] **This is a PR build**" + Write-Host "**This is a PR build**" + + # compute authorization header in format "AUTHORIZATION: basic 'encoded token'" + # 'encoded token' is the Base64 of the string "nfbot:personal-token" + $auth = "basic $([System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes("nfbot:$(GitHubToken)")))" $commit = Invoke-RestMethod -Uri "https://api.github.com/repos/nanoframework/nf-interpreter/commits/$(Build.SourceVersion)" -ContentType "application/json" -Method GET if( ($commit.commit.author.name -eq "nfbot") -and ($commit.commit.message -like "*[version update]*") ) { - Write-Host "##[command] **version update commit, skipping build**" - echo "##vso[task.setvariable variable=SKIP_BUILD;isOutput=true]true" + Write-Host "**version update commit, skipping build**" + echo "##vso[task.setvariable variable=SKIP_BUILD;isOutput=true]true" } else { - echo "##vso[task.setvariable variable=SKIP_BUILD;isOutput=true]false" + echo "##vso[task.setvariable variable=SKIP_BUILD;isOutput=true]false" } + # find PR + "Getting PR #$env:System_PullRequest_PullRequestNumber details..." | Write-Host -ForegroundColor White -NoNewline + $pr = Invoke-WebRequest "https://api.github.com/repos/$env:Build_Repository_Name/pulls/$env:System_PullRequest_PullRequestNumber" | ConvertFrom-Json + + if($($pr.number) -eq "$env:System_PullRequest_PullRequestNumber") + { + 'OK' | Write-Host -ForegroundColor Green + } + + # grab PR commit message + $prCommitMessage = $($pr.body) + + # debug output + # echo "=====`r`n$($prCommitMessage)`r`n=====" + # check if Unit Tests for mscorlib should be run - if(($commit.commit.message -like "*[run mscorlib tests]*") -or ($commit.commit.message -match "Tested against nanoframework/CoreLibrary#(\d+)")) + if(($prCommitMessage -like "*[run mscorlib tests]*") -or ($prCommitMessage -match "Tested against nanoframework/CoreLibrary#(\d+)")) { - Write-Host "##[command] **mscorlib tests are to be runned**" + Write-Host "##[command] >> mscorlib tests are to be run" echo "##vso[task.setvariable variable=RUN_MSCORLIB_TESTS;isOutput=true]true" } + + # check if should use specific MDP for mscorlib + if($prCommitMessage -match "\[build with MDP buildId (\d+)\]") + { + Write-Host "##[command] >> Using specific MDP for mscorlib build" + echo "##vso[task.setvariable variable=USE_SPECIFIC_MDP;isOutput=true]true" + } } else { @@ -409,7 +435,7 @@ jobs: variables: DOTNET_NOLOGO: true # creates a counter and assigns it to the revision variable - REVISION: $[counter('STM32_1_12_4_versioncounter', 0)] + REVISION: $[counter('STM32_2_0_0_versioncounter', 0)] HelperPackageVersion: $[counter('HelperPackageVersioncounter', 0)] TargetPlatform: "stm32" @@ -524,7 +550,7 @@ jobs: variables: DOTNET_NOLOGO: true # creates a counter and assigns it to the revision variable - REVISION: $[counter('ESP32_1_12_4_versioncounter', 0)] + REVISION: $[counter('ESP32_2_0_0_versioncounter', 0)] IDF_PATH: "D:/a/1/s/esp-idf" PIP_CACHE_DIR: $(Pipeline.Workspace)/.pip TargetPlatform: "esp32" @@ -612,7 +638,7 @@ jobs: variables: DOTNET_NOLOGO: true # creates a counter and assigns it to the revision variable - REVISION: $[counter('NXP_1_12_4_versioncounter', 0)] + REVISION: $[counter('NXP_2_0_0_versioncounter', 0)] GIT_LFS_SKIP_SMUDGE: 1 TargetPlatform: "freertos" @@ -691,7 +717,7 @@ jobs: variables: DOTNET_NOLOGO: true # creates a counter and assigns it to the revision variable - REVISION: $[counter('TI_1_12_4_versioncounter', 0)] + REVISION: $[counter('TI_2_0_0_versioncounter', 0)] HelperPackageVersion: $[counter('HelperPackageVersioncounter', 0)] TargetPlatform: "ti_simplelink" @@ -763,7 +789,7 @@ jobs: variables: # creates a counter and assigns it to the revision variable - REVISION: $[counter('AZURERTOS_1_12_4_versioncounter', 0)] + REVISION: $[counter('AZURERTOS_2_0_0_versioncounter', 0)] HelperPackageVersion: $[counter('HelperPackageVersioncounter', 0)] TargetPlatform: "efm32" @@ -815,7 +841,7 @@ jobs: value: true # creates a counter and assigns it to the revision variable - name: REVISION - value: $[counter('WIN32_1_12_4_versioncounter', 0)] + value: $[counter('WIN32_2_0_0_versioncounter', 0)] - name: LITTLEFS_PATH value: "D:/a/1/s/littlefs" @@ -1237,6 +1263,7 @@ jobs: dependsOn: - Build_nanoCLR_CLI + - Check_Build_Options pool: vmImage: "windows-latest" @@ -1246,6 +1273,7 @@ jobs: solution: "nanoFramework.CoreLibrary.sln" buildPlatform: "Any CPU" buildConfiguration: "Release" + DownloadMDP: $[ dependencies.Check_Build_Options.outputs['BuildOptions.USE_SPECIFIC_MDP'] ] steps: - checkout: self @@ -1271,6 +1299,9 @@ jobs: displayName: Install .NET nanoFramework MSBuild components inputs: GitHubToken: $(GitHubToken) + UsePreview: true + + - template: azure-pipelines-templates/check-mdp-for-build.yml - template: azure-pipelines-templates/install-nuget.yml@templates diff --git a/src/CLR/CorLib/corlib_native.cpp b/src/CLR/CorLib/corlib_native.cpp index 886a6b2cf0..f05e5fd438 100644 --- a/src/CLR/CorLib/corlib_native.cpp +++ b/src/CLR/CorLib/corlib_native.cpp @@ -1,1514 +1,1523 @@ -// -// Copyright (c) .NET Foundation and Contributors -// See LICENSE file in the project root for full license information. -// -#include "CorLib.h" - -// clang-format off - -#if (NANOCLR_REFLECTION == TRUE) - -static const CLR_RT_MethodHandler method_lookup[] = -{ - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - Library_corlib_native_System_Globalization_CultureInfo::get_CurrentUICultureInternal___STATIC__SystemGlobalizationCultureInfo, - Library_corlib_native_System_Globalization_CultureInfo::set_CurrentUICultureInternal___STATIC__VOID__SystemGlobalizationCultureInfo, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - Library_corlib_native_System_Reflection_FieldInfo::SetValue___VOID__OBJECT__OBJECT, - NULL, - Library_corlib_native_System_Reflection_FieldInfo::GetCustomAttributesNative___SZARRAY_OBJECT__BOOLEAN, - NULL, - Library_corlib_native_System_Type::get_DeclaringType___SystemType, - NULL, - NULL, - NULL, - NULL, - Library_corlib_native_System_Type::GetMethod___SystemReflectionMethodInfo__STRING__SystemReflectionBindingFlags, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - Library_corlib_native_System_Type::IsInstanceOfType___BOOLEAN__OBJECT, - NULL, - Library_corlib_native_System_Type::InvokeMember___OBJECT__STRING__SystemReflectionBindingFlags__SystemReflectionBinder__OBJECT__SZARRAY_OBJECT, - Library_corlib_native_System_Type::GetConstructor___SystemReflectionConstructorInfo__SZARRAY_SystemType, - Library_corlib_native_System_Type::GetConstructors___SZARRAY_SystemReflectionConstructorInfo, - Library_corlib_native_System_Type::GetMethod___SystemReflectionMethodInfo__STRING__SZARRAY_SystemType, - Library_corlib_native_System_Type::GetMethod___SystemReflectionMethodInfo__STRING, - NULL, - NULL, - NULL, - Library_corlib_native_System_Type::get_IsNotPublic___BOOLEAN, - Library_corlib_native_System_Type::get_IsPublic___BOOLEAN, - Library_corlib_native_System_Type::get_IsClass___BOOLEAN, - Library_corlib_native_System_Type::get_IsInterface___BOOLEAN, - Library_corlib_native_System_Type::get_IsValueType___BOOLEAN, - Library_corlib_native_System_Type::get_IsAbstract___BOOLEAN, - Library_corlib_native_System_Type::get_IsEnum___BOOLEAN, - Library_corlib_native_System_Type::get_IsSerializable___BOOLEAN, - Library_corlib_native_System_Type::get_IsArray___BOOLEAN, - NULL, - NULL, - Library_corlib_native_System_Type::GetTypeInternal___STATIC__SystemType__STRING__STRING__BOOLEAN__SZARRAY_I4, - Library_corlib_native_System_Type::GetTypeFromHandle___STATIC__SystemType__SystemRuntimeTypeHandle, - NULL, - NULL, - Library_corlib_native_System_Object::Equals___BOOLEAN__OBJECT, - Library_corlib_native_System_Object::GetHashCode___I4, - NULL, - Library_corlib_native_System_Object::GetType___SystemType, - Library_corlib_native_System_Object::MemberwiseClone___OBJECT, - NULL, - Library_corlib_native_System_Object::ReferenceEquals___STATIC__BOOLEAN__OBJECT__OBJECT, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - Library_corlib_native_System_String::CompareTo___I4__OBJECT, - NULL, - Library_corlib_native_System_String::get_Chars___CHAR__I4, - NULL, - Library_corlib_native_System_String::ToCharArray___SZARRAY_CHAR, - Library_corlib_native_System_String::ToCharArray___SZARRAY_CHAR__I4__I4, - Library_corlib_native_System_String::get_Length___I4, - Library_corlib_native_System_String::Split___SZARRAY_STRING__SZARRAY_CHAR, - Library_corlib_native_System_String::Split___SZARRAY_STRING__SZARRAY_CHAR__I4, - Library_corlib_native_System_String::Substring___STRING__I4, - Library_corlib_native_System_String::Substring___STRING__I4__I4, - Library_corlib_native_System_String::Trim___STRING__SZARRAY_CHAR, - Library_corlib_native_System_String::TrimStart___STRING__SZARRAY_CHAR, - Library_corlib_native_System_String::TrimEnd___STRING__SZARRAY_CHAR, - Library_corlib_native_System_String::_ctor___VOID__SZARRAY_CHAR__I4__I4, - Library_corlib_native_System_String::_ctor___VOID__SZARRAY_CHAR, - Library_corlib_native_System_String::_ctor___VOID__CHAR__I4, - Library_corlib_native_System_String::CompareTo___I4__STRING, - Library_corlib_native_System_String::IndexOf___I4__CHAR, - Library_corlib_native_System_String::IndexOf___I4__CHAR__I4, - Library_corlib_native_System_String::IndexOf___I4__CHAR__I4__I4, - Library_corlib_native_System_String::IndexOfAny___I4__SZARRAY_CHAR, - Library_corlib_native_System_String::IndexOfAny___I4__SZARRAY_CHAR__I4, - Library_corlib_native_System_String::IndexOfAny___I4__SZARRAY_CHAR__I4__I4, - Library_corlib_native_System_String::IndexOf___I4__STRING, - Library_corlib_native_System_String::IndexOf___I4__STRING__I4, - Library_corlib_native_System_String::IndexOf___I4__STRING__I4__I4, - Library_corlib_native_System_String::LastIndexOf___I4__CHAR, - Library_corlib_native_System_String::LastIndexOf___I4__CHAR__I4, - Library_corlib_native_System_String::LastIndexOf___I4__CHAR__I4__I4, - Library_corlib_native_System_String::LastIndexOfAny___I4__SZARRAY_CHAR, - Library_corlib_native_System_String::LastIndexOfAny___I4__SZARRAY_CHAR__I4, - Library_corlib_native_System_String::LastIndexOfAny___I4__SZARRAY_CHAR__I4__I4, - Library_corlib_native_System_String::LastIndexOf___I4__STRING, - Library_corlib_native_System_String::LastIndexOf___I4__STRING__I4, - Library_corlib_native_System_String::LastIndexOf___I4__STRING__I4__I4, - Library_corlib_native_System_String::ToLower___STRING, - Library_corlib_native_System_String::ToUpper___STRING, - Library_corlib_native_System_String::Trim___STRING, - NULL, - NULL, - NULL, - NULL, - NULL, - Library_corlib_native_System_String::Equals___STATIC__BOOLEAN__STRING__STRING, - Library_corlib_native_System_String::op_Equality___STATIC__BOOLEAN__STRING__STRING, - Library_corlib_native_System_String::op_Inequality___STATIC__BOOLEAN__STRING__STRING, - Library_corlib_native_System_String::Compare___STATIC__I4__STRING__STRING, - NULL, - NULL, - NULL, - NULL, - Library_corlib_native_System_String::Concat___STATIC__STRING__STRING__STRING, - Library_corlib_native_System_String::Concat___STATIC__STRING__STRING__STRING__STRING, - Library_corlib_native_System_String::Concat___STATIC__STRING__STRING__STRING__STRING__STRING, - Library_corlib_native_System_String::Concat___STATIC__STRING__SZARRAY_STRING, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - Library_corlib_native_System_Exception::get_StackTrace___STRING, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - Library_corlib_native_System_Array::System_Collections_IList_get_Item___OBJECT__I4, - Library_corlib_native_System_Array::System_Collections_IList_set_Item___VOID__I4__OBJECT, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - Library_corlib_native_System_Array::get_Length___I4, - NULL, - NULL, - Library_corlib_native_System_Array::CreateInstance___STATIC__SystemArray__SystemType__I4, - NULL, - Library_corlib_native_System_Array::Copy___STATIC__VOID__SystemArray__I4__SystemArray__I4__I4, - Library_corlib_native_System_Array::Clear___STATIC__VOID__SystemArray__I4__I4, - NULL, - NULL, - NULL, - NULL, - NULL, - Library_corlib_native_System_Array::TrySzIndexOf___STATIC__BOOLEAN__SystemArray__I4__I4__OBJECT__BYREF_I4, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - Library_corlib_native_System_BitConverter::get_IsLittleEndian___STATIC__BOOLEAN, - Library_corlib_native_System_BitConverter::DoubleToInt64Bits___STATIC__I8__R8, - Library_corlib_native_System_BitConverter::GetBytes___STATIC__SZARRAY_U1__BOOLEAN, - Library_corlib_native_System_BitConverter::GetBytes___STATIC__SZARRAY_U1__CHAR, - Library_corlib_native_System_BitConverter::GetBytes___STATIC__SZARRAY_U1__R8, - Library_corlib_native_System_BitConverter::GetBytes___STATIC__SZARRAY_U1__R4, - Library_corlib_native_System_BitConverter::GetBytes___STATIC__SZARRAY_U1__I4, - Library_corlib_native_System_BitConverter::GetBytes___STATIC__SZARRAY_U1__I8, - Library_corlib_native_System_BitConverter::GetBytes___STATIC__SZARRAY_U1__I2, - Library_corlib_native_System_BitConverter::GetBytes___STATIC__SZARRAY_U1__U4, - Library_corlib_native_System_BitConverter::GetBytes___STATIC__SZARRAY_U1__U8, - Library_corlib_native_System_BitConverter::GetBytes___STATIC__SZARRAY_U1__U2, - Library_corlib_native_System_BitConverter::Int64BitsToDouble___STATIC__R8__I8, - Library_corlib_native_System_BitConverter::ToBoolean___STATIC__BOOLEAN__SZARRAY_U1__I4, - Library_corlib_native_System_BitConverter::ToChar___STATIC__CHAR__SZARRAY_U1__I4, - Library_corlib_native_System_BitConverter::ToDouble___STATIC__R8__SZARRAY_U1__I4, - Library_corlib_native_System_BitConverter::ToInt16___STATIC__I2__SZARRAY_U1__I4, - Library_corlib_native_System_BitConverter::ToInt32___STATIC__I4__SZARRAY_U1__I4, - Library_corlib_native_System_BitConverter::ToInt64___STATIC__I8__SZARRAY_U1__I4, - Library_corlib_native_System_BitConverter::ToSingle___STATIC__R4__SZARRAY_U1__I4, - Library_corlib_native_System_BitConverter::ToString___STATIC__STRING__SZARRAY_U1, - Library_corlib_native_System_BitConverter::ToString___STATIC__STRING__SZARRAY_U1__I4, - Library_corlib_native_System_BitConverter::ToString___STATIC__STRING__SZARRAY_U1__I4__I4, - Library_corlib_native_System_BitConverter::ToUInt16___STATIC__U2__SZARRAY_U1__I4, - Library_corlib_native_System_BitConverter::ToUInt32___STATIC__U4__SZARRAY_U1__I4, - Library_corlib_native_System_BitConverter::ToUInt64___STATIC__U8__SZARRAY_U1__I4, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - Library_corlib_native_System_Collections_ArrayList::get_Item___OBJECT__I4, - Library_corlib_native_System_Collections_ArrayList::set_Item___VOID__I4__OBJECT, - Library_corlib_native_System_Collections_ArrayList::Add___I4__OBJECT, - NULL, - Library_corlib_native_System_Collections_ArrayList::Clear___VOID, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - Library_corlib_native_System_Collections_ArrayList::Insert___VOID__I4__OBJECT, - NULL, - Library_corlib_native_System_Collections_ArrayList::RemoveAt___VOID__I4, - NULL, - NULL, - NULL, - Library_corlib_native_System_Collections_ArrayList::SetCapacity___VOID__I4, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - Library_corlib_native_System_Double::CompareTo___STATIC__I4__R8__R8, - Library_corlib_native_System_Double::IsInfinity___STATIC__BOOLEAN__R8, - Library_corlib_native_System_Double::IsNaN___STATIC__BOOLEAN__R8, - Library_corlib_native_System_Double::IsNegativeInfinity___STATIC__BOOLEAN__R8, - Library_corlib_native_System_Double::IsPositiveInfinity___STATIC__BOOLEAN__R8, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - Library_corlib_native_System_TimeSpan::Equals___BOOLEAN__OBJECT, - Library_corlib_native_System_TimeSpan::ToString___STRING, - NULL, - NULL, - Library_corlib_native_System_TimeSpan::_ctor___VOID__I4__I4__I4, - Library_corlib_native_System_TimeSpan::_ctor___VOID__I4__I4__I4__I4, - Library_corlib_native_System_TimeSpan::_ctor___VOID__I4__I4__I4__I4__I4, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - Library_corlib_native_System_TimeSpan::CompareTo___I4__OBJECT, - NULL, - NULL, - NULL, - Library_corlib_native_System_TimeSpan::Compare___STATIC__I4__SystemTimeSpan__SystemTimeSpan, - Library_corlib_native_System_TimeSpan::Equals___STATIC__BOOLEAN__SystemTimeSpan__SystemTimeSpan, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - Library_corlib_native_System_DateTime::_ctor___VOID__I4__I4__I4__I4__I4__I4__I4, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - Library_corlib_native_System_DateTime::GetDateTimePart___I4__SystemDateTimeDateTimePart, - NULL, - Library_corlib_native_System_DateTime::DaysInMonth___STATIC__I4__I4__I4, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - Library_corlib_native_System_DateTime::GetUtcNowAsTicks___STATIC__I8, - Library_corlib_native_System_DateTime::GetTodayAsTicks___STATIC__I8, - NULL, - Library_corlib_native_System_Convert::NativeToInt64___STATIC__I8__STRING__BOOLEAN__I8__I8__I4__BOOLEAN__BYREF_BOOLEAN, - Library_corlib_native_System_Convert::NativeToDouble___STATIC__R8__STRING__BOOLEAN__BYREF_BOOLEAN, - Library_corlib_native_System_Convert::NativeToDateTime___STATIC__VOID__STRING__BOOLEAN__BYREF_BOOLEAN__BYREF_SystemDateTime, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - Library_corlib_native_System_Convert::ToBase64String___STATIC__STRING__SZARRAY_U1__I4__I4__BOOLEAN, - Library_corlib_native_System_Convert::FromBase64String___STATIC__SZARRAY_U1__STRING, - NULL, - Library_corlib_native_System_Delegate::Equals___BOOLEAN__OBJECT, - Library_corlib_native_System_Delegate::GetInvocationList___SZARRAY_SystemDelegate, - Library_corlib_native_System_Delegate::get_Method___SystemReflectionMethodInfo, - Library_corlib_native_System_Delegate::get_Target___OBJECT, - NULL, - Library_corlib_native_System_Delegate::Combine___STATIC__SystemDelegate__SystemDelegate__SystemDelegate, - Library_corlib_native_System_Delegate::Remove___STATIC__SystemDelegate__SystemDelegate__SystemDelegate, - Library_corlib_native_System_Delegate::op_Equality___STATIC__BOOLEAN__SystemDelegate__SystemDelegate, - Library_corlib_native_System_Delegate::op_Inequality___STATIC__BOOLEAN__SystemDelegate__SystemDelegate, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - Library_corlib_native_System_Diagnostics_Debug::WriteLineNative___STATIC__VOID__STRING__BOOLEAN, - Library_corlib_native_System_Diagnostics_Debugger::get_IsAttached___STATIC__BOOLEAN, - Library_corlib_native_System_Diagnostics_Debugger::Break___STATIC__VOID, - NULL, - NULL, - NULL, - NULL, - Library_corlib_native_System_Reflection_Assembly::get_FullName___STRING, - Library_corlib_native_System_Reflection_Assembly::GetType___SystemType__STRING, - NULL, - Library_corlib_native_System_Reflection_Assembly::GetTypes___SZARRAY_SystemType, - Library_corlib_native_System_Reflection_Assembly::GetVersion___VOID__BYREF_I4__BYREF_I4__BYREF_I4__BYREF_I4, - NULL, - NULL, - Library_corlib_native_System_Reflection_Assembly::GetManifestResourceNames___SZARRAY_STRING, - NULL, - Library_corlib_native_System_Reflection_Assembly::GetExecutingAssembly___STATIC__SystemReflectionAssembly, - NULL, - NULL, - NULL, - NULL, - Library_corlib_native_System_Reflection_Assembly::LoadInternal___STATIC__SystemReflectionAssembly__STRING__BOOLEAN__I4__I4__I4__I4, - Library_corlib_native_System_Reflection_Assembly::Load___STATIC__SystemReflectionAssembly__SZARRAY_U1, - NULL, - Library_corlib_native_System_Enum::HasFlag___BOOLEAN__SystemEnum, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - Library_corlib_native_System_GC::AnyPendingFinalizers___STATIC__BOOLEAN, - NULL, - Library_corlib_native_System_GC::SuppressFinalize___STATIC__VOID__OBJECT, - Library_corlib_native_System_GC::ReRegisterForFinalize___STATIC__VOID__OBJECT, - Library_corlib_native_System_Globalization_DateTimeFormat::FormatDigits___STATIC__STRING__I4__I4, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - Library_corlib_native_System_Guid::GenerateNewGuid___STATIC__SZARRAY_U1, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - Library_corlib_native_System_MathInternal::Abs___STATIC__I4__I4, - NULL, - NULL, - NULL, - NULL, - Library_corlib_native_System_MulticastDelegate::op_Equality___STATIC__BOOLEAN__SystemMulticastDelegate__SystemMulticastDelegate, - Library_corlib_native_System_MulticastDelegate::op_Inequality___STATIC__BOOLEAN__SystemMulticastDelegate__SystemMulticastDelegate, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - Library_corlib_native_System_Number::FormatNative___STATIC__STRING__OBJECT__BOOLEAN__STRING__STRING__STRING__STRING__SZARRAY_I4, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - Library_corlib_native_System_Random::Next___I4, - Library_corlib_native_System_Random::Next___I4__I4, - Library_corlib_native_System_Random::NextDouble___R8, - Library_corlib_native_System_Random::NextBytes___VOID__SZARRAY_U1, - Library_corlib_native_System_Random::_ctor___VOID, - Library_corlib_native_System_Random::_ctor___VOID__I4, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - Library_corlib_native_System_Reflection_ConstructorInfo::GetCustomAttributes___SZARRAY_OBJECT__BOOLEAN, - Library_corlib_native_System_Reflection_ConstructorInfo::Invoke___OBJECT__SZARRAY_OBJECT, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - Library_corlib_native_System_Reflection_MethodBase::get_Name___STRING, - Library_corlib_native_System_Reflection_MethodBase::get_DeclaringType___SystemType, - Library_corlib_native_System_Reflection_MethodBase::get_IsPublic___BOOLEAN, - Library_corlib_native_System_Reflection_MethodBase::get_IsStatic___BOOLEAN, - Library_corlib_native_System_Reflection_MethodBase::get_IsFinal___BOOLEAN, - Library_corlib_native_System_Reflection_MethodBase::get_IsVirtual___BOOLEAN, - Library_corlib_native_System_Reflection_MethodBase::get_IsAbstract___BOOLEAN, - Library_corlib_native_System_Reflection_MethodBase::Invoke___OBJECT__OBJECT__SZARRAY_OBJECT, - Library_corlib_native_System_Reflection_MethodBase::GetParametersNative___SZARRAY_SystemReflectionParameterInfo, - NULL, - NULL, - NULL, - NULL, - Library_corlib_native_System_Reflection_PropertyInfo::GetValue___OBJECT__OBJECT__SZARRAY_OBJECT, - Library_corlib_native_System_Reflection_PropertyInfo::SetValue___VOID__OBJECT__OBJECT__SZARRAY_OBJECT, - NULL, - NULL, - NULL, - Library_corlib_native_System_Reflection_RuntimeFieldInfo::get_Name___STRING, - Library_corlib_native_System_Reflection_RuntimeFieldInfo::get_DeclaringType___SystemType, - Library_corlib_native_System_Reflection_RuntimeFieldInfo::get_FieldType___SystemType, - Library_corlib_native_System_Reflection_RuntimeFieldInfo::GetValue___OBJECT__OBJECT, - NULL, - Library_corlib_native_System_Reflection_RuntimeMethodInfo::get_ReturnType___SystemType, - NULL, - NULL, - Library_corlib_native_System_Reflection_RuntimeMethodInfo::GetCustomAttributesNative___SZARRAY_OBJECT__BOOLEAN, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - Library_corlib_native_System_Runtime_CompilerServices_RuntimeHelpers::InitializeArray___STATIC__VOID__SystemArray__SystemRuntimeFieldHandle, - Library_corlib_native_System_Runtime_CompilerServices_RuntimeHelpers::GetObjectValue___STATIC__OBJECT__OBJECT, - Library_corlib_native_System_Runtime_CompilerServices_RuntimeHelpers::RunClassConstructor___STATIC__VOID__SystemRuntimeTypeHandle, - Library_corlib_native_System_Runtime_CompilerServices_RuntimeHelpers::get_OffsetToStringData___STATIC__I4, - Library_corlib_native_System_Runtime_Remoting_RemotingServices::IsTransparentProxy___STATIC__BOOLEAN__OBJECT, - NULL, - NULL, - NULL, - NULL, - NULL, - Library_corlib_native_System_RuntimeType::get_Assembly___SystemReflectionAssembly, - Library_corlib_native_System_RuntimeType::get_Name___STRING, - Library_corlib_native_System_RuntimeType::get_FullName___STRING, - NULL, - Library_corlib_native_System_RuntimeType::get_BaseType___SystemType, - Library_corlib_native_System_RuntimeType::GetMethods___SZARRAY_SystemReflectionMethodInfo__SystemReflectionBindingFlags, - Library_corlib_native_System_RuntimeType::GetField___SystemReflectionFieldInfo__STRING__SystemReflectionBindingFlags, - Library_corlib_native_System_RuntimeType::GetFields___SZARRAY_SystemReflectionFieldInfo__SystemReflectionBindingFlags, - Library_corlib_native_System_RuntimeType::GetInterfaces___SZARRAY_SystemType, - Library_corlib_native_System_RuntimeType::GetElementType___SystemType, - NULL, - Library_corlib_native_System_RuntimeType::GetCustomAttributesNative___SZARRAY_OBJECT__BOOLEAN, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - Library_corlib_native_System_Threading_AutoResetEvent::_ctor___VOID__BOOLEAN, - Library_corlib_native_System_Threading_AutoResetEvent::Reset___BOOLEAN, - Library_corlib_native_System_Threading_AutoResetEvent::Set___BOOLEAN, - Library_corlib_native_System_Threading_Interlocked::Increment___STATIC__I4__BYREF_I4, - Library_corlib_native_System_Threading_Interlocked::Decrement___STATIC__I4__BYREF_I4, - Library_corlib_native_System_Threading_Interlocked::Exchange___STATIC__I4__BYREF_I4__I4, - Library_corlib_native_System_Threading_Interlocked::CompareExchange___STATIC__I4__BYREF_I4__I4__I4, - Library_corlib_native_System_Threading_ManualResetEvent::_ctor___VOID__BOOLEAN, - Library_corlib_native_System_Threading_ManualResetEvent::Reset___BOOLEAN, - Library_corlib_native_System_Threading_ManualResetEvent::Set___BOOLEAN, - Library_corlib_native_System_Threading_Monitor::Enter___STATIC__VOID__OBJECT, - Library_corlib_native_System_Threading_Monitor::Exit___STATIC__VOID__OBJECT, - Library_corlib_native_System_Threading_SpinWait::SpinOnce___VOID, - Library_corlib_native_System_Threading_SpinWait::SpinUntil___STATIC__VOID__SystemTimeSpan, - Library_corlib_native_System_Threading_SpinWait::SpinUntil___STATIC__VOID__I4, - Library_corlib_native_System_Threading_Thread::_ctor___VOID__SystemThreadingThreadStart, - Library_corlib_native_System_Threading_Thread::Start___VOID, - Library_corlib_native_System_Threading_Thread::Abort___VOID, - Library_corlib_native_System_Threading_Thread::Suspend___VOID, - Library_corlib_native_System_Threading_Thread::Resume___VOID, - Library_corlib_native_System_Threading_Thread::get_Priority___SystemThreadingThreadPriority, - Library_corlib_native_System_Threading_Thread::set_Priority___VOID__SystemThreadingThreadPriority, - Library_corlib_native_System_Threading_Thread::get_ManagedThreadId___I4, - Library_corlib_native_System_Threading_Thread::get_IsAlive___BOOLEAN, - Library_corlib_native_System_Threading_Thread::Join___VOID, - Library_corlib_native_System_Threading_Thread::Join___BOOLEAN__I4, - Library_corlib_native_System_Threading_Thread::Join___BOOLEAN__SystemTimeSpan, - Library_corlib_native_System_Threading_Thread::get_ThreadState___SystemThreadingThreadState, - Library_corlib_native_System_Threading_Thread::Sleep___STATIC__VOID__I4, - NULL, - Library_corlib_native_System_Threading_Thread::SpinWait___STATIC__VOID__I4, - Library_corlib_native_System_Threading_Thread::get_CurrentThread___STATIC__SystemThreadingThread, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - Library_corlib_native_System_Threading_Timer::Dispose___VOID, - Library_corlib_native_System_Threading_Timer::_ctor___VOID__SystemThreadingTimerCallback__OBJECT__I4__I4, - Library_corlib_native_System_Threading_Timer::_ctor___VOID__SystemThreadingTimerCallback__OBJECT__SystemTimeSpan__SystemTimeSpan, - Library_corlib_native_System_Threading_Timer::Change___BOOLEAN__I4__I4, - Library_corlib_native_System_Threading_Timer::Change___BOOLEAN__SystemTimeSpan__SystemTimeSpan, - NULL, - NULL, - NULL, - NULL, - Library_corlib_native_System_Threading_WaitHandle::WaitOne___BOOLEAN__I4__BOOLEAN, - NULL, - NULL, - Library_corlib_native_System_Threading_WaitHandle::WaitMultiple___STATIC__I4__SZARRAY_SystemThreadingWaitHandle__I4__BOOLEAN__BOOLEAN, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - Library_corlib_native_System_ValueType::Equals___BOOLEAN__OBJECT, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - Library_corlib_native_System_WeakReference::get_IsAlive___BOOLEAN, - Library_corlib_native_System_WeakReference::get_Target___OBJECT, - Library_corlib_native_System_WeakReference::set_Target___VOID__OBJECT, - Library_corlib_native_System_WeakReference::_ctor___VOID__OBJECT, -}; - -#elif (NANOCLR_REFLECTION == FALSE) - -static const CLR_RT_MethodHandler method_lookup[] = -{ - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - Library_corlib_native_System_Globalization_CultureInfo::get_CurrentUICultureInternal___STATIC__SystemGlobalizationCultureInfo, - Library_corlib_native_System_Globalization_CultureInfo::set_CurrentUICultureInternal___STATIC__VOID__SystemGlobalizationCultureInfo, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - Library_corlib_native_System_Object::Equals___BOOLEAN__OBJECT, - Library_corlib_native_System_Object::GetHashCode___I4, - NULL, - Library_corlib_native_System_Object::MemberwiseClone___OBJECT, - NULL, - Library_corlib_native_System_Object::ReferenceEquals___STATIC__BOOLEAN__OBJECT__OBJECT, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - Library_corlib_native_System_String::CompareTo___I4__OBJECT, - NULL, - Library_corlib_native_System_String::get_Chars___CHAR__I4, - NULL, - Library_corlib_native_System_String::ToCharArray___SZARRAY_CHAR, - Library_corlib_native_System_String::ToCharArray___SZARRAY_CHAR__I4__I4, - Library_corlib_native_System_String::get_Length___I4, - Library_corlib_native_System_String::Split___SZARRAY_STRING__SZARRAY_CHAR, - Library_corlib_native_System_String::Split___SZARRAY_STRING__SZARRAY_CHAR__I4, - Library_corlib_native_System_String::Substring___STRING__I4, - Library_corlib_native_System_String::Substring___STRING__I4__I4, - Library_corlib_native_System_String::Trim___STRING__SZARRAY_CHAR, - Library_corlib_native_System_String::TrimStart___STRING__SZARRAY_CHAR, - Library_corlib_native_System_String::TrimEnd___STRING__SZARRAY_CHAR, - Library_corlib_native_System_String::_ctor___VOID__SZARRAY_CHAR__I4__I4, - Library_corlib_native_System_String::_ctor___VOID__SZARRAY_CHAR, - Library_corlib_native_System_String::_ctor___VOID__CHAR__I4, - Library_corlib_native_System_String::CompareTo___I4__STRING, - Library_corlib_native_System_String::IndexOf___I4__CHAR, - Library_corlib_native_System_String::IndexOf___I4__CHAR__I4, - Library_corlib_native_System_String::IndexOf___I4__CHAR__I4__I4, - Library_corlib_native_System_String::IndexOfAny___I4__SZARRAY_CHAR, - Library_corlib_native_System_String::IndexOfAny___I4__SZARRAY_CHAR__I4, - Library_corlib_native_System_String::IndexOfAny___I4__SZARRAY_CHAR__I4__I4, - Library_corlib_native_System_String::IndexOf___I4__STRING, - Library_corlib_native_System_String::IndexOf___I4__STRING__I4, - Library_corlib_native_System_String::IndexOf___I4__STRING__I4__I4, - Library_corlib_native_System_String::LastIndexOf___I4__CHAR, - Library_corlib_native_System_String::LastIndexOf___I4__CHAR__I4, - Library_corlib_native_System_String::LastIndexOf___I4__CHAR__I4__I4, - Library_corlib_native_System_String::LastIndexOfAny___I4__SZARRAY_CHAR, - Library_corlib_native_System_String::LastIndexOfAny___I4__SZARRAY_CHAR__I4, - Library_corlib_native_System_String::LastIndexOfAny___I4__SZARRAY_CHAR__I4__I4, - Library_corlib_native_System_String::LastIndexOf___I4__STRING, - Library_corlib_native_System_String::LastIndexOf___I4__STRING__I4, - Library_corlib_native_System_String::LastIndexOf___I4__STRING__I4__I4, - Library_corlib_native_System_String::ToLower___STRING, - Library_corlib_native_System_String::ToUpper___STRING, - Library_corlib_native_System_String::Trim___STRING, - NULL, - NULL, - NULL, - NULL, - NULL, - Library_corlib_native_System_String::Equals___STATIC__BOOLEAN__STRING__STRING, - Library_corlib_native_System_String::op_Equality___STATIC__BOOLEAN__STRING__STRING, - Library_corlib_native_System_String::op_Inequality___STATIC__BOOLEAN__STRING__STRING, - Library_corlib_native_System_String::Compare___STATIC__I4__STRING__STRING, - NULL, - NULL, - NULL, - NULL, - Library_corlib_native_System_String::Concat___STATIC__STRING__STRING__STRING, - Library_corlib_native_System_String::Concat___STATIC__STRING__STRING__STRING__STRING, - Library_corlib_native_System_String::Concat___STATIC__STRING__STRING__STRING__STRING__STRING, - Library_corlib_native_System_String::Concat___STATIC__STRING__SZARRAY_STRING, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - Library_corlib_native_System_Exception::get_StackTrace___STRING, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - Library_corlib_native_System_Array::System_Collections_IList_get_Item___OBJECT__I4, - Library_corlib_native_System_Array::System_Collections_IList_set_Item___VOID__I4__OBJECT, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - Library_corlib_native_System_Array::get_Length___I4, - NULL, - NULL, - NULL, - Library_corlib_native_System_Array::Copy___STATIC__VOID__SystemArray__I4__SystemArray__I4__I4, - Library_corlib_native_System_Array::Clear___STATIC__VOID__SystemArray__I4__I4, - NULL, - NULL, - NULL, - NULL, - NULL, - Library_corlib_native_System_Array::TrySzIndexOf___STATIC__BOOLEAN__SystemArray__I4__I4__OBJECT__BYREF_I4, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - Library_corlib_native_System_BitConverter::get_IsLittleEndian___STATIC__BOOLEAN, - Library_corlib_native_System_BitConverter::DoubleToInt64Bits___STATIC__I8__R8, - Library_corlib_native_System_BitConverter::GetBytes___STATIC__SZARRAY_U1__BOOLEAN, - Library_corlib_native_System_BitConverter::GetBytes___STATIC__SZARRAY_U1__CHAR, - Library_corlib_native_System_BitConverter::GetBytes___STATIC__SZARRAY_U1__R8, - Library_corlib_native_System_BitConverter::GetBytes___STATIC__SZARRAY_U1__R4, - Library_corlib_native_System_BitConverter::GetBytes___STATIC__SZARRAY_U1__I4, - Library_corlib_native_System_BitConverter::GetBytes___STATIC__SZARRAY_U1__I8, - Library_corlib_native_System_BitConverter::GetBytes___STATIC__SZARRAY_U1__I2, - Library_corlib_native_System_BitConverter::GetBytes___STATIC__SZARRAY_U1__U4, - Library_corlib_native_System_BitConverter::GetBytes___STATIC__SZARRAY_U1__U8, - Library_corlib_native_System_BitConverter::GetBytes___STATIC__SZARRAY_U1__U2, - Library_corlib_native_System_BitConverter::Int64BitsToDouble___STATIC__R8__I8, - Library_corlib_native_System_BitConverter::ToBoolean___STATIC__BOOLEAN__SZARRAY_U1__I4, - Library_corlib_native_System_BitConverter::ToChar___STATIC__CHAR__SZARRAY_U1__I4, - Library_corlib_native_System_BitConverter::ToDouble___STATIC__R8__SZARRAY_U1__I4, - Library_corlib_native_System_BitConverter::ToInt16___STATIC__I2__SZARRAY_U1__I4, - Library_corlib_native_System_BitConverter::ToInt32___STATIC__I4__SZARRAY_U1__I4, - Library_corlib_native_System_BitConverter::ToInt64___STATIC__I8__SZARRAY_U1__I4, - Library_corlib_native_System_BitConverter::ToSingle___STATIC__R4__SZARRAY_U1__I4, - Library_corlib_native_System_BitConverter::ToString___STATIC__STRING__SZARRAY_U1, - Library_corlib_native_System_BitConverter::ToString___STATIC__STRING__SZARRAY_U1__I4, - Library_corlib_native_System_BitConverter::ToString___STATIC__STRING__SZARRAY_U1__I4__I4, - Library_corlib_native_System_BitConverter::ToUInt16___STATIC__U2__SZARRAY_U1__I4, - Library_corlib_native_System_BitConverter::ToUInt32___STATIC__U4__SZARRAY_U1__I4, - Library_corlib_native_System_BitConverter::ToUInt64___STATIC__U8__SZARRAY_U1__I4, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - Library_corlib_native_System_Collections_ArrayList::get_Item___OBJECT__I4, - Library_corlib_native_System_Collections_ArrayList::set_Item___VOID__I4__OBJECT, - Library_corlib_native_System_Collections_ArrayList::Add___I4__OBJECT, - NULL, - Library_corlib_native_System_Collections_ArrayList::Clear___VOID, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - Library_corlib_native_System_Collections_ArrayList::Insert___VOID__I4__OBJECT, - NULL, - Library_corlib_native_System_Collections_ArrayList::RemoveAt___VOID__I4, - NULL, - Library_corlib_native_System_Collections_ArrayList::SetCapacity___VOID__I4, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - Library_corlib_native_System_Double::CompareTo___STATIC__I4__R8__R8, - Library_corlib_native_System_Double::IsInfinity___STATIC__BOOLEAN__R8, - Library_corlib_native_System_Double::IsNaN___STATIC__BOOLEAN__R8, - Library_corlib_native_System_Double::IsNegativeInfinity___STATIC__BOOLEAN__R8, - Library_corlib_native_System_Double::IsPositiveInfinity___STATIC__BOOLEAN__R8, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - Library_corlib_native_System_TimeSpan::Equals___BOOLEAN__OBJECT, - Library_corlib_native_System_TimeSpan::ToString___STRING, - NULL, - NULL, - Library_corlib_native_System_TimeSpan::_ctor___VOID__I4__I4__I4, - Library_corlib_native_System_TimeSpan::_ctor___VOID__I4__I4__I4__I4, - Library_corlib_native_System_TimeSpan::_ctor___VOID__I4__I4__I4__I4__I4, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - Library_corlib_native_System_TimeSpan::CompareTo___I4__OBJECT, - NULL, - NULL, - NULL, - Library_corlib_native_System_TimeSpan::Compare___STATIC__I4__SystemTimeSpan__SystemTimeSpan, - Library_corlib_native_System_TimeSpan::Equals___STATIC__BOOLEAN__SystemTimeSpan__SystemTimeSpan, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - Library_corlib_native_System_DateTime::_ctor___VOID__I4__I4__I4__I4__I4__I4__I4, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - Library_corlib_native_System_DateTime::GetDateTimePart___I4__SystemDateTimeDateTimePart, - NULL, - Library_corlib_native_System_DateTime::DaysInMonth___STATIC__I4__I4__I4, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - Library_corlib_native_System_DateTime::GetUtcNowAsTicks___STATIC__I8, - Library_corlib_native_System_DateTime::GetTodayAsTicks___STATIC__I8, - NULL, - Library_corlib_native_System_Convert::NativeToInt64___STATIC__I8__STRING__BOOLEAN__I8__I8__I4__BOOLEAN__BYREF_BOOLEAN, - Library_corlib_native_System_Convert::NativeToDouble___STATIC__R8__STRING__BOOLEAN__BYREF_BOOLEAN, - Library_corlib_native_System_Convert::NativeToDateTime___STATIC__VOID__STRING__BOOLEAN__BYREF_BOOLEAN__BYREF_SystemDateTime, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - Library_corlib_native_System_Convert::ToBase64String___STATIC__STRING__SZARRAY_U1__I4__I4__BOOLEAN, - Library_corlib_native_System_Convert::FromBase64String___STATIC__SZARRAY_U1__STRING, - NULL, - Library_corlib_native_System_Delegate::Equals___BOOLEAN__OBJECT, - NULL, - Library_corlib_native_System_Delegate::Combine___STATIC__SystemDelegate__SystemDelegate__SystemDelegate, - Library_corlib_native_System_Delegate::Remove___STATIC__SystemDelegate__SystemDelegate__SystemDelegate, - Library_corlib_native_System_Delegate::op_Equality___STATIC__BOOLEAN__SystemDelegate__SystemDelegate, - Library_corlib_native_System_Delegate::op_Inequality___STATIC__BOOLEAN__SystemDelegate__SystemDelegate, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - Library_corlib_native_System_Diagnostics_Debug::WriteLineNative___STATIC__VOID__STRING__BOOLEAN, - Library_corlib_native_System_Diagnostics_Debugger::get_IsAttached___STATIC__BOOLEAN, - Library_corlib_native_System_Diagnostics_Debugger::Break___STATIC__VOID, - NULL, - Library_corlib_native_System_Enum::HasFlag___BOOLEAN__SystemEnum, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - Library_corlib_native_System_GC::AnyPendingFinalizers___STATIC__BOOLEAN, - NULL, - Library_corlib_native_System_GC::SuppressFinalize___STATIC__VOID__OBJECT, - Library_corlib_native_System_GC::ReRegisterForFinalize___STATIC__VOID__OBJECT, - Library_corlib_native_System_Globalization_DateTimeFormat::FormatDigits___STATIC__STRING__I4__I4, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - Library_corlib_native_System_Guid::GenerateNewGuid___STATIC__SZARRAY_U1, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - Library_corlib_native_System_MathInternal::Abs___STATIC__I4__I4, - NULL, - NULL, - NULL, - NULL, - Library_corlib_native_System_MulticastDelegate::op_Equality___STATIC__BOOLEAN__SystemMulticastDelegate__SystemMulticastDelegate, - Library_corlib_native_System_MulticastDelegate::op_Inequality___STATIC__BOOLEAN__SystemMulticastDelegate__SystemMulticastDelegate, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - Library_corlib_native_System_Number::FormatNative___STATIC__STRING__OBJECT__BOOLEAN__STRING__STRING__STRING__STRING__SZARRAY_I4, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - Library_corlib_native_System_Random::Next___I4, - Library_corlib_native_System_Random::Next___I4__I4, - Library_corlib_native_System_Random::NextDouble___R8, - Library_corlib_native_System_Random::NextBytes___VOID__SZARRAY_U1, - Library_corlib_native_System_Random::_ctor___VOID, - Library_corlib_native_System_Random::_ctor___VOID__I4, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - Library_corlib_native_System_Runtime_CompilerServices_RuntimeHelpers::InitializeArray___STATIC__VOID__SystemArray__SystemRuntimeFieldHandle, - Library_corlib_native_System_Runtime_CompilerServices_RuntimeHelpers::GetObjectValue___STATIC__OBJECT__OBJECT, - Library_corlib_native_System_Runtime_CompilerServices_RuntimeHelpers::RunClassConstructor___STATIC__VOID__SystemRuntimeTypeHandle, - Library_corlib_native_System_Runtime_CompilerServices_RuntimeHelpers::get_OffsetToStringData___STATIC__I4, - Library_corlib_native_System_Runtime_Remoting_RemotingServices::IsTransparentProxy___STATIC__BOOLEAN__OBJECT, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - Library_corlib_native_System_Threading_AutoResetEvent::_ctor___VOID__BOOLEAN, - Library_corlib_native_System_Threading_AutoResetEvent::Reset___BOOLEAN, - Library_corlib_native_System_Threading_AutoResetEvent::Set___BOOLEAN, - Library_corlib_native_System_Threading_Interlocked::Increment___STATIC__I4__BYREF_I4, - Library_corlib_native_System_Threading_Interlocked::Decrement___STATIC__I4__BYREF_I4, - Library_corlib_native_System_Threading_Interlocked::Exchange___STATIC__I4__BYREF_I4__I4, - Library_corlib_native_System_Threading_Interlocked::CompareExchange___STATIC__I4__BYREF_I4__I4__I4, - Library_corlib_native_System_Threading_ManualResetEvent::_ctor___VOID__BOOLEAN, - Library_corlib_native_System_Threading_ManualResetEvent::Reset___BOOLEAN, - Library_corlib_native_System_Threading_ManualResetEvent::Set___BOOLEAN, - Library_corlib_native_System_Threading_Monitor::Enter___STATIC__VOID__OBJECT, - Library_corlib_native_System_Threading_Monitor::Exit___STATIC__VOID__OBJECT, - Library_corlib_native_System_Threading_Thread::_ctor___VOID__SystemThreadingThreadStart, - Library_corlib_native_System_Threading_Thread::Start___VOID, - Library_corlib_native_System_Threading_Thread::Abort___VOID, - Library_corlib_native_System_Threading_Thread::Suspend___VOID, - Library_corlib_native_System_Threading_Thread::Resume___VOID, - Library_corlib_native_System_Threading_Thread::get_Priority___SystemThreadingThreadPriority, - Library_corlib_native_System_Threading_Thread::set_Priority___VOID__SystemThreadingThreadPriority, - Library_corlib_native_System_Threading_Thread::get_ManagedThreadId___I4, - Library_corlib_native_System_Threading_Thread::get_IsAlive___BOOLEAN, - Library_corlib_native_System_Threading_Thread::Join___VOID, - Library_corlib_native_System_Threading_Thread::Join___BOOLEAN__I4, - Library_corlib_native_System_Threading_Thread::Join___BOOLEAN__SystemTimeSpan, - Library_corlib_native_System_Threading_Thread::get_ThreadState___SystemThreadingThreadState, - Library_corlib_native_System_Threading_Thread::Sleep___STATIC__VOID__I4, - NULL, - Library_corlib_native_System_Threading_Thread::SpinWait___STATIC__VOID__I4, - Library_corlib_native_System_Threading_Thread::get_CurrentThread___STATIC__SystemThreadingThread, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - Library_corlib_native_System_Threading_Timer::Dispose___VOID, - Library_corlib_native_System_Threading_Timer::_ctor___VOID__SystemThreadingTimerCallback__OBJECT__I4__I4, - Library_corlib_native_System_Threading_Timer::_ctor___VOID__SystemThreadingTimerCallback__OBJECT__SystemTimeSpan__SystemTimeSpan, - Library_corlib_native_System_Threading_Timer::Change___BOOLEAN__I4__I4, - Library_corlib_native_System_Threading_Timer::Change___BOOLEAN__SystemTimeSpan__SystemTimeSpan, - NULL, - NULL, - NULL, - NULL, - Library_corlib_native_System_Threading_WaitHandle::WaitOne___BOOLEAN__I4__BOOLEAN, - NULL, - NULL, - Library_corlib_native_System_Threading_WaitHandle::WaitMultiple___STATIC__I4__SZARRAY_SystemThreadingWaitHandle__I4__BOOLEAN__BOOLEAN, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - Library_corlib_native_System_ValueType::Equals___BOOLEAN__OBJECT, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - Library_corlib_native_System_WeakReference::get_IsAlive___BOOLEAN, - Library_corlib_native_System_WeakReference::get_Target___OBJECT, - Library_corlib_native_System_WeakReference::set_Target___VOID__OBJECT, - Library_corlib_native_System_WeakReference::_ctor___VOID__OBJECT, -}; - -#else -#error "NANOCLR_REFLECTION has to be define either TRUE or FALSE. Check the build options." -#endif - -const CLR_RT_NativeAssemblyData g_CLR_AssemblyNative_mscorlib = -{ - "mscorlib", - -#if (NANOCLR_REFLECTION == TRUE) - - 0x1549C856, - -#elif (NANOCLR_REFLECTION == FALSE) - - 0xF0208DC0, - -#else -#error "NANOCLR_REFLECTION has to be define either TRUE or FALSE. Check the build options." -#endif - - method_lookup, - { 100, 5, 0, 24 } -}; - -// clang-format on +// +// Copyright (c) .NET Foundation and Contributors +// See LICENSE file in the project root for full license information. +// +#include "CorLib.h" + +// clang-format off + +#if (NANOCLR_REFLECTION == TRUE) + +static const CLR_RT_MethodHandler method_lookup[] = +{ + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + Library_corlib_native_System_Globalization_CultureInfo::get_CurrentUICultureInternal___STATIC__SystemGlobalizationCultureInfo, + Library_corlib_native_System_Globalization_CultureInfo::set_CurrentUICultureInternal___STATIC__VOID__SystemGlobalizationCultureInfo, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + Library_corlib_native_System_Reflection_FieldInfo::SetValue___VOID__OBJECT__OBJECT, + nullptr, + Library_corlib_native_System_Reflection_FieldInfo::GetCustomAttributesNative___SZARRAY_OBJECT__BOOLEAN, + nullptr, + Library_corlib_native_System_Type::get_DeclaringType___SystemType, + nullptr, + nullptr, + nullptr, + nullptr, + Library_corlib_native_System_Type::GetMethod___SystemReflectionMethodInfo__STRING__SystemReflectionBindingFlags, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + Library_corlib_native_System_Type::IsInstanceOfType___BOOLEAN__OBJECT, + nullptr, + Library_corlib_native_System_Type::InvokeMember___OBJECT__STRING__SystemReflectionBindingFlags__SystemReflectionBinder__OBJECT__SZARRAY_OBJECT, + Library_corlib_native_System_Type::GetConstructor___SystemReflectionConstructorInfo__SZARRAY_SystemType, + Library_corlib_native_System_Type::GetConstructors___SZARRAY_SystemReflectionConstructorInfo, + Library_corlib_native_System_Type::GetMethod___SystemReflectionMethodInfo__STRING__SZARRAY_SystemType, + Library_corlib_native_System_Type::GetMethod___SystemReflectionMethodInfo__STRING, + nullptr, + nullptr, + nullptr, + Library_corlib_native_System_Type::get_IsNotPublic___BOOLEAN, + Library_corlib_native_System_Type::get_IsPublic___BOOLEAN, + Library_corlib_native_System_Type::get_IsClass___BOOLEAN, + Library_corlib_native_System_Type::get_IsInterface___BOOLEAN, + Library_corlib_native_System_Type::get_IsValueType___BOOLEAN, + Library_corlib_native_System_Type::get_IsAbstract___BOOLEAN, + Library_corlib_native_System_Type::get_IsEnum___BOOLEAN, + Library_corlib_native_System_Type::get_IsSerializable___BOOLEAN, + Library_corlib_native_System_Type::get_IsArray___BOOLEAN, + nullptr, + nullptr, + Library_corlib_native_System_Type::GetTypeInternal___STATIC__SystemType__STRING__STRING__BOOLEAN__SZARRAY_I4, + Library_corlib_native_System_Type::GetTypeFromHandle___STATIC__SystemType__SystemRuntimeTypeHandle, + nullptr, + nullptr, + Library_corlib_native_System_Object::Equals___BOOLEAN__OBJECT, + Library_corlib_native_System_Object::GetHashCode___I4, + nullptr, + Library_corlib_native_System_Object::GetType___SystemType, + Library_corlib_native_System_Object::MemberwiseClone___OBJECT, + nullptr, + Library_corlib_native_System_Object::ReferenceEquals___STATIC__BOOLEAN__OBJECT__OBJECT, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + Library_corlib_native_System_String::CompareTo___I4__OBJECT, + nullptr, + Library_corlib_native_System_String::get_Chars___CHAR__I4, + nullptr, + Library_corlib_native_System_String::ToCharArray___SZARRAY_CHAR, + Library_corlib_native_System_String::ToCharArray___SZARRAY_CHAR__I4__I4, + Library_corlib_native_System_String::get_Length___I4, + Library_corlib_native_System_String::Split___SZARRAY_STRING__SZARRAY_CHAR, + Library_corlib_native_System_String::Split___SZARRAY_STRING__SZARRAY_CHAR__I4, + Library_corlib_native_System_String::Substring___STRING__I4, + Library_corlib_native_System_String::Substring___STRING__I4__I4, + Library_corlib_native_System_String::Trim___STRING__SZARRAY_CHAR, + Library_corlib_native_System_String::TrimStart___STRING__SZARRAY_CHAR, + Library_corlib_native_System_String::TrimEnd___STRING__SZARRAY_CHAR, + Library_corlib_native_System_String::_ctor___VOID__SZARRAY_CHAR__I4__I4, + Library_corlib_native_System_String::_ctor___VOID__SZARRAY_CHAR, + Library_corlib_native_System_String::_ctor___VOID__CHAR__I4, + Library_corlib_native_System_String::CompareTo___I4__STRING, + Library_corlib_native_System_String::IndexOf___I4__CHAR, + Library_corlib_native_System_String::IndexOf___I4__CHAR__I4, + Library_corlib_native_System_String::IndexOf___I4__CHAR__I4__I4, + Library_corlib_native_System_String::IndexOfAny___I4__SZARRAY_CHAR, + Library_corlib_native_System_String::IndexOfAny___I4__SZARRAY_CHAR__I4, + Library_corlib_native_System_String::IndexOfAny___I4__SZARRAY_CHAR__I4__I4, + Library_corlib_native_System_String::IndexOf___I4__STRING, + Library_corlib_native_System_String::IndexOf___I4__STRING__I4, + Library_corlib_native_System_String::IndexOf___I4__STRING__I4__I4, + Library_corlib_native_System_String::LastIndexOf___I4__CHAR, + Library_corlib_native_System_String::LastIndexOf___I4__CHAR__I4, + Library_corlib_native_System_String::LastIndexOf___I4__CHAR__I4__I4, + Library_corlib_native_System_String::LastIndexOfAny___I4__SZARRAY_CHAR, + Library_corlib_native_System_String::LastIndexOfAny___I4__SZARRAY_CHAR__I4, + Library_corlib_native_System_String::LastIndexOfAny___I4__SZARRAY_CHAR__I4__I4, + Library_corlib_native_System_String::LastIndexOf___I4__STRING, + Library_corlib_native_System_String::LastIndexOf___I4__STRING__I4, + Library_corlib_native_System_String::LastIndexOf___I4__STRING__I4__I4, + Library_corlib_native_System_String::ToLower___STRING, + Library_corlib_native_System_String::ToUpper___STRING, + Library_corlib_native_System_String::Trim___STRING, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + Library_corlib_native_System_String::Equals___STATIC__BOOLEAN__STRING__STRING, + Library_corlib_native_System_String::op_Equality___STATIC__BOOLEAN__STRING__STRING, + Library_corlib_native_System_String::op_Inequality___STATIC__BOOLEAN__STRING__STRING, + Library_corlib_native_System_String::Compare___STATIC__I4__STRING__STRING, + nullptr, + nullptr, + nullptr, + nullptr, + Library_corlib_native_System_String::Concat___STATIC__STRING__STRING__STRING, + Library_corlib_native_System_String::Concat___STATIC__STRING__STRING__STRING__STRING, + Library_corlib_native_System_String::Concat___STATIC__STRING__STRING__STRING__STRING__STRING, + Library_corlib_native_System_String::Concat___STATIC__STRING__SZARRAY_STRING, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + Library_corlib_native_System_Exception::get_StackTrace___STRING, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + Library_corlib_native_System_Array::System_Collections_IList_get_Item___OBJECT__I4, + Library_corlib_native_System_Array::System_Collections_IList_set_Item___VOID__I4__OBJECT, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + Library_corlib_native_System_Array::get_Length___I4, + nullptr, + nullptr, + Library_corlib_native_System_Array::CreateInstance___STATIC__SystemArray__SystemType__I4, + nullptr, + Library_corlib_native_System_Array::Copy___STATIC__VOID__SystemArray__I4__SystemArray__I4__I4, + Library_corlib_native_System_Array::Clear___STATIC__VOID__SystemArray__I4__I4, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + Library_corlib_native_System_Array::TrySzIndexOf___STATIC__BOOLEAN__SystemArray__I4__I4__OBJECT__BYREF_I4, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + Library_corlib_native_System_BitConverter::get_IsLittleEndian___STATIC__BOOLEAN, + Library_corlib_native_System_BitConverter::DoubleToInt64Bits___STATIC__I8__R8, + Library_corlib_native_System_BitConverter::GetBytes___STATIC__SZARRAY_U1__BOOLEAN, + Library_corlib_native_System_BitConverter::GetBytes___STATIC__SZARRAY_U1__CHAR, + Library_corlib_native_System_BitConverter::GetBytes___STATIC__SZARRAY_U1__R8, + Library_corlib_native_System_BitConverter::GetBytes___STATIC__SZARRAY_U1__R4, + Library_corlib_native_System_BitConverter::GetBytes___STATIC__SZARRAY_U1__I4, + Library_corlib_native_System_BitConverter::GetBytes___STATIC__SZARRAY_U1__I8, + Library_corlib_native_System_BitConverter::GetBytes___STATIC__SZARRAY_U1__I2, + Library_corlib_native_System_BitConverter::GetBytes___STATIC__SZARRAY_U1__U4, + Library_corlib_native_System_BitConverter::GetBytes___STATIC__SZARRAY_U1__U8, + Library_corlib_native_System_BitConverter::GetBytes___STATIC__SZARRAY_U1__U2, + Library_corlib_native_System_BitConverter::Int64BitsToDouble___STATIC__R8__I8, + Library_corlib_native_System_BitConverter::ToBoolean___STATIC__BOOLEAN__SZARRAY_U1__I4, + Library_corlib_native_System_BitConverter::ToChar___STATIC__CHAR__SZARRAY_U1__I4, + Library_corlib_native_System_BitConverter::ToDouble___STATIC__R8__SZARRAY_U1__I4, + Library_corlib_native_System_BitConverter::ToInt16___STATIC__I2__SZARRAY_U1__I4, + Library_corlib_native_System_BitConverter::ToInt32___STATIC__I4__SZARRAY_U1__I4, + Library_corlib_native_System_BitConverter::ToInt64___STATIC__I8__SZARRAY_U1__I4, + Library_corlib_native_System_BitConverter::ToSingle___STATIC__R4__SZARRAY_U1__I4, + Library_corlib_native_System_BitConverter::ToString___STATIC__STRING__SZARRAY_U1, + Library_corlib_native_System_BitConverter::ToString___STATIC__STRING__SZARRAY_U1__I4, + Library_corlib_native_System_BitConverter::ToString___STATIC__STRING__SZARRAY_U1__I4__I4, + Library_corlib_native_System_BitConverter::ToUInt16___STATIC__U2__SZARRAY_U1__I4, + Library_corlib_native_System_BitConverter::ToUInt32___STATIC__U4__SZARRAY_U1__I4, + Library_corlib_native_System_BitConverter::ToUInt64___STATIC__U8__SZARRAY_U1__I4, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + Library_corlib_native_System_Collections_ArrayList::get_Item___OBJECT__I4, + Library_corlib_native_System_Collections_ArrayList::set_Item___VOID__I4__OBJECT, + Library_corlib_native_System_Collections_ArrayList::Add___I4__OBJECT, + nullptr, + Library_corlib_native_System_Collections_ArrayList::Clear___VOID, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + Library_corlib_native_System_Collections_ArrayList::Insert___VOID__I4__OBJECT, + nullptr, + Library_corlib_native_System_Collections_ArrayList::RemoveAt___VOID__I4, + nullptr, + nullptr, + nullptr, + Library_corlib_native_System_Collections_ArrayList::SetCapacity___VOID__I4, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + Library_corlib_native_System_Double::CompareTo___STATIC__I4__R8__R8, + Library_corlib_native_System_Double::IsInfinity___STATIC__BOOLEAN__R8, + Library_corlib_native_System_Double::IsNaN___STATIC__BOOLEAN__R8, + Library_corlib_native_System_Double::IsNegativeInfinity___STATIC__BOOLEAN__R8, + Library_corlib_native_System_Double::IsPositiveInfinity___STATIC__BOOLEAN__R8, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + Library_corlib_native_System_TimeSpan::Equals___BOOLEAN__OBJECT, + Library_corlib_native_System_TimeSpan::ToString___STRING, + nullptr, + nullptr, + Library_corlib_native_System_TimeSpan::_ctor___VOID__I4__I4__I4, + Library_corlib_native_System_TimeSpan::_ctor___VOID__I4__I4__I4__I4, + Library_corlib_native_System_TimeSpan::_ctor___VOID__I4__I4__I4__I4__I4, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + Library_corlib_native_System_TimeSpan::CompareTo___I4__OBJECT, + nullptr, + nullptr, + nullptr, + Library_corlib_native_System_TimeSpan::Compare___STATIC__I4__SystemTimeSpan__SystemTimeSpan, + Library_corlib_native_System_TimeSpan::Equals___STATIC__BOOLEAN__SystemTimeSpan__SystemTimeSpan, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + Library_corlib_native_System_DateTime::_ctor___VOID__I4__I4__I4__I4__I4__I4__I4, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + Library_corlib_native_System_DateTime::GetDateTimePart___I4__SystemDateTimeDateTimePart, + nullptr, + Library_corlib_native_System_DateTime::DaysInMonth___STATIC__I4__I4__I4, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + Library_corlib_native_System_DateTime::GetUtcNowAsTicks___STATIC__I8, + Library_corlib_native_System_DateTime::GetTodayAsTicks___STATIC__I8, + nullptr, + Library_corlib_native_System_Convert::NativeToInt64___STATIC__I8__STRING__BOOLEAN__I8__I8__I4__BOOLEAN__BYREF_BOOLEAN, + Library_corlib_native_System_Convert::NativeToDouble___STATIC__R8__STRING__BOOLEAN__BYREF_BOOLEAN, + Library_corlib_native_System_Convert::NativeToDateTime___STATIC__VOID__STRING__BOOLEAN__BYREF_BOOLEAN__BYREF_SystemDateTime, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + Library_corlib_native_System_Convert::ToBase64String___STATIC__STRING__SZARRAY_U1__I4__I4__BOOLEAN, + Library_corlib_native_System_Convert::FromBase64String___STATIC__SZARRAY_U1__STRING, + nullptr, + Library_corlib_native_System_Delegate::Equals___BOOLEAN__OBJECT, + Library_corlib_native_System_Delegate::GetInvocationList___SZARRAY_SystemDelegate, + Library_corlib_native_System_Delegate::get_Method___SystemReflectionMethodInfo, + Library_corlib_native_System_Delegate::get_Target___OBJECT, + nullptr, + Library_corlib_native_System_Delegate::Combine___STATIC__SystemDelegate__SystemDelegate__SystemDelegate, + Library_corlib_native_System_Delegate::Remove___STATIC__SystemDelegate__SystemDelegate__SystemDelegate, + Library_corlib_native_System_Delegate::op_Equality___STATIC__BOOLEAN__SystemDelegate__SystemDelegate, + Library_corlib_native_System_Delegate::op_Inequality___STATIC__BOOLEAN__SystemDelegate__SystemDelegate, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + Library_corlib_native_System_Diagnostics_Debug::WriteLineNative___STATIC__VOID__STRING__BOOLEAN, + Library_corlib_native_System_Diagnostics_Debugger::get_IsAttached___STATIC__BOOLEAN, + Library_corlib_native_System_Diagnostics_Debugger::Break___STATIC__VOID, + nullptr, + nullptr, + nullptr, + nullptr, + Library_corlib_native_System_Reflection_Assembly::get_FullName___STRING, + Library_corlib_native_System_Reflection_Assembly::GetType___SystemType__STRING, + nullptr, + Library_corlib_native_System_Reflection_Assembly::GetTypes___SZARRAY_SystemType, + Library_corlib_native_System_Reflection_Assembly::GetVersion___VOID__BYREF_I4__BYREF_I4__BYREF_I4__BYREF_I4, + nullptr, + nullptr, + Library_corlib_native_System_Reflection_Assembly::GetManifestResourceNames___SZARRAY_STRING, + nullptr, + Library_corlib_native_System_Reflection_Assembly::GetExecutingAssembly___STATIC__SystemReflectionAssembly, + nullptr, + nullptr, + nullptr, + nullptr, + Library_corlib_native_System_Reflection_Assembly::LoadInternal___STATIC__SystemReflectionAssembly__STRING__BOOLEAN__I4__I4__I4__I4, + Library_corlib_native_System_Reflection_Assembly::Load___STATIC__SystemReflectionAssembly__SZARRAY_U1, + nullptr, + Library_corlib_native_System_Enum::HasFlag___BOOLEAN__SystemEnum, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + Library_corlib_native_System_GC::EnableGCMessages___STATIC__VOID__BOOLEAN, + nullptr, + Library_corlib_native_System_GC::ReRegisterForFinalize___STATIC__VOID__OBJECT, + nullptr, + Library_corlib_native_System_GC::SuppressFinalize___STATIC__VOID__OBJECT, + nullptr, + Library_corlib_native_System_GC::AnyPendingFinalizers___STATIC__BOOLEAN, + Library_corlib_native_System_GC::Run___STATIC__U4__BOOLEAN, + Library_corlib_native_System_Globalization_DateTimeFormat::FormatDigits___STATIC__STRING__I4__I4, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + Library_corlib_native_System_Guid::GenerateNewGuid___STATIC__SZARRAY_U1, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + Library_corlib_native_System_MathInternal::Abs___STATIC__I4__I4, + nullptr, + nullptr, + nullptr, + nullptr, + Library_corlib_native_System_MulticastDelegate::op_Equality___STATIC__BOOLEAN__SystemMulticastDelegate__SystemMulticastDelegate, + Library_corlib_native_System_MulticastDelegate::op_Inequality___STATIC__BOOLEAN__SystemMulticastDelegate__SystemMulticastDelegate, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + Library_corlib_native_System_Number::FormatNative___STATIC__STRING__OBJECT__BOOLEAN__STRING__STRING__STRING__STRING__SZARRAY_I4, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + Library_corlib_native_System_Random::Next___I4, + Library_corlib_native_System_Random::Next___I4__I4, + Library_corlib_native_System_Random::NextDouble___R8, + Library_corlib_native_System_Random::NextBytes___VOID__SZARRAY_U1, + Library_corlib_native_System_Random::_ctor___VOID, + Library_corlib_native_System_Random::_ctor___VOID__I4, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + Library_corlib_native_System_Reflection_ConstructorInfo::GetCustomAttributes___SZARRAY_OBJECT__BOOLEAN, + Library_corlib_native_System_Reflection_ConstructorInfo::Invoke___OBJECT__SZARRAY_OBJECT, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + Library_corlib_native_System_Reflection_MethodBase::get_Name___STRING, + Library_corlib_native_System_Reflection_MethodBase::get_DeclaringType___SystemType, + Library_corlib_native_System_Reflection_MethodBase::get_IsPublic___BOOLEAN, + Library_corlib_native_System_Reflection_MethodBase::get_IsStatic___BOOLEAN, + Library_corlib_native_System_Reflection_MethodBase::get_IsFinal___BOOLEAN, + Library_corlib_native_System_Reflection_MethodBase::get_IsVirtual___BOOLEAN, + Library_corlib_native_System_Reflection_MethodBase::get_IsAbstract___BOOLEAN, + Library_corlib_native_System_Reflection_MethodBase::Invoke___OBJECT__OBJECT__SZARRAY_OBJECT, + Library_corlib_native_System_Reflection_MethodBase::GetParametersNative___SZARRAY_SystemReflectionParameterInfo, + nullptr, + nullptr, + nullptr, + nullptr, + Library_corlib_native_System_Reflection_PropertyInfo::GetValue___OBJECT__OBJECT__SZARRAY_OBJECT, + Library_corlib_native_System_Reflection_PropertyInfo::SetValue___VOID__OBJECT__OBJECT__SZARRAY_OBJECT, + nullptr, + nullptr, + nullptr, + Library_corlib_native_System_Reflection_RuntimeFieldInfo::get_Name___STRING, + Library_corlib_native_System_Reflection_RuntimeFieldInfo::get_DeclaringType___SystemType, + Library_corlib_native_System_Reflection_RuntimeFieldInfo::get_FieldType___SystemType, + Library_corlib_native_System_Reflection_RuntimeFieldInfo::GetValue___OBJECT__OBJECT, + nullptr, + Library_corlib_native_System_Reflection_RuntimeMethodInfo::get_ReturnType___SystemType, + nullptr, + nullptr, + Library_corlib_native_System_Reflection_RuntimeMethodInfo::GetCustomAttributesNative___SZARRAY_OBJECT__BOOLEAN, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + Library_corlib_native_System_Runtime_CompilerServices_RuntimeHelpers::InitializeArray___STATIC__VOID__SystemArray__SystemRuntimeFieldHandle, + Library_corlib_native_System_Runtime_CompilerServices_RuntimeHelpers::GetObjectValue___STATIC__OBJECT__OBJECT, + Library_corlib_native_System_Runtime_CompilerServices_RuntimeHelpers::RunClassConstructor___STATIC__VOID__SystemRuntimeTypeHandle, + Library_corlib_native_System_Runtime_CompilerServices_RuntimeHelpers::get_OffsetToStringData___STATIC__I4, + Library_corlib_native_System_Runtime_Remoting_RemotingServices::IsTransparentProxy___STATIC__BOOLEAN__OBJECT, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + Library_corlib_native_System_RuntimeType::get_Assembly___SystemReflectionAssembly, + Library_corlib_native_System_RuntimeType::get_Name___STRING, + Library_corlib_native_System_RuntimeType::get_FullName___STRING, + nullptr, + Library_corlib_native_System_RuntimeType::get_BaseType___SystemType, + Library_corlib_native_System_RuntimeType::GetMethods___SZARRAY_SystemReflectionMethodInfo__SystemReflectionBindingFlags, + Library_corlib_native_System_RuntimeType::GetField___SystemReflectionFieldInfo__STRING__SystemReflectionBindingFlags, + Library_corlib_native_System_RuntimeType::GetFields___SZARRAY_SystemReflectionFieldInfo__SystemReflectionBindingFlags, + Library_corlib_native_System_RuntimeType::GetInterfaces___SZARRAY_SystemType, + Library_corlib_native_System_RuntimeType::GetElementType___SystemType, + nullptr, + Library_corlib_native_System_RuntimeType::GetCustomAttributesNative___SZARRAY_OBJECT__BOOLEAN, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + Library_corlib_native_System_Threading_AutoResetEvent::_ctor___VOID__BOOLEAN, + Library_corlib_native_System_Threading_AutoResetEvent::Reset___BOOLEAN, + Library_corlib_native_System_Threading_AutoResetEvent::Set___BOOLEAN, + Library_corlib_native_System_Threading_Interlocked::Increment___STATIC__I4__BYREF_I4, + Library_corlib_native_System_Threading_Interlocked::Decrement___STATIC__I4__BYREF_I4, + Library_corlib_native_System_Threading_Interlocked::Exchange___STATIC__I4__BYREF_I4__I4, + Library_corlib_native_System_Threading_Interlocked::CompareExchange___STATIC__I4__BYREF_I4__I4__I4, + Library_corlib_native_System_Threading_ManualResetEvent::_ctor___VOID__BOOLEAN, + Library_corlib_native_System_Threading_ManualResetEvent::Reset___BOOLEAN, + Library_corlib_native_System_Threading_ManualResetEvent::Set___BOOLEAN, + Library_corlib_native_System_Threading_Monitor::Enter___STATIC__VOID__OBJECT, + Library_corlib_native_System_Threading_Monitor::Exit___STATIC__VOID__OBJECT, + Library_corlib_native_System_Threading_SpinWait::SpinOnce___VOID, + Library_corlib_native_System_Threading_SpinWait::SpinUntil___STATIC__VOID__SystemTimeSpan, + Library_corlib_native_System_Threading_SpinWait::SpinUntil___STATIC__VOID__I4, + Library_corlib_native_System_Threading_Thread::_ctor___VOID__SystemThreadingThreadStart, + Library_corlib_native_System_Threading_Thread::Start___VOID, + Library_corlib_native_System_Threading_Thread::Abort___VOID, + Library_corlib_native_System_Threading_Thread::Suspend___VOID, + Library_corlib_native_System_Threading_Thread::Resume___VOID, + Library_corlib_native_System_Threading_Thread::get_Priority___SystemThreadingThreadPriority, + Library_corlib_native_System_Threading_Thread::set_Priority___VOID__SystemThreadingThreadPriority, + Library_corlib_native_System_Threading_Thread::get_ManagedThreadId___I4, + Library_corlib_native_System_Threading_Thread::get_IsAlive___BOOLEAN, + Library_corlib_native_System_Threading_Thread::Join___VOID, + Library_corlib_native_System_Threading_Thread::Join___BOOLEAN__I4, + Library_corlib_native_System_Threading_Thread::Join___BOOLEAN__SystemTimeSpan, + Library_corlib_native_System_Threading_Thread::get_ThreadState___SystemThreadingThreadState, + Library_corlib_native_System_Threading_Thread::Sleep___STATIC__VOID__I4, + nullptr, + Library_corlib_native_System_Threading_Thread::SpinWait___STATIC__VOID__I4, + Library_corlib_native_System_Threading_Thread::get_CurrentThread___STATIC__SystemThreadingThread, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + Library_corlib_native_System_Threading_Timer::Dispose___VOID, + Library_corlib_native_System_Threading_Timer::_ctor___VOID__SystemThreadingTimerCallback__OBJECT__I4__I4, + Library_corlib_native_System_Threading_Timer::_ctor___VOID__SystemThreadingTimerCallback__OBJECT__SystemTimeSpan__SystemTimeSpan, + Library_corlib_native_System_Threading_Timer::Change___BOOLEAN__I4__I4, + Library_corlib_native_System_Threading_Timer::Change___BOOLEAN__SystemTimeSpan__SystemTimeSpan, + nullptr, + nullptr, + nullptr, + nullptr, + Library_corlib_native_System_Threading_WaitHandle::WaitOne___BOOLEAN__I4__BOOLEAN, + nullptr, + nullptr, + Library_corlib_native_System_Threading_WaitHandle::WaitMultiple___STATIC__I4__SZARRAY_SystemThreadingWaitHandle__I4__BOOLEAN__BOOLEAN, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + Library_corlib_native_System_ValueType::Equals___BOOLEAN__OBJECT, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + Library_corlib_native_System_WeakReference::get_IsAlive___BOOLEAN, + Library_corlib_native_System_WeakReference::get_Target___OBJECT, + Library_corlib_native_System_WeakReference::set_Target___VOID__OBJECT, + Library_corlib_native_System_WeakReference::_ctor___VOID__OBJECT, +}; + +#elif (NANOCLR_REFLECTION == FALSE) + +static const CLR_RT_MethodHandler method_lookup[] = +{ + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + Library_corlib_native_System_Globalization_CultureInfo::get_CurrentUICultureInternal___STATIC__SystemGlobalizationCultureInfo, + Library_corlib_native_System_Globalization_CultureInfo::set_CurrentUICultureInternal___STATIC__VOID__SystemGlobalizationCultureInfo, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + Library_corlib_native_System_Object::Equals___BOOLEAN__OBJECT, + Library_corlib_native_System_Object::GetHashCode___I4, + nullptr, + Library_corlib_native_System_Object::MemberwiseClone___OBJECT, + nullptr, + Library_corlib_native_System_Object::ReferenceEquals___STATIC__BOOLEAN__OBJECT__OBJECT, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + Library_corlib_native_System_String::CompareTo___I4__OBJECT, + nullptr, + Library_corlib_native_System_String::get_Chars___CHAR__I4, + nullptr, + Library_corlib_native_System_String::ToCharArray___SZARRAY_CHAR, + Library_corlib_native_System_String::ToCharArray___SZARRAY_CHAR__I4__I4, + Library_corlib_native_System_String::get_Length___I4, + Library_corlib_native_System_String::Split___SZARRAY_STRING__SZARRAY_CHAR, + Library_corlib_native_System_String::Split___SZARRAY_STRING__SZARRAY_CHAR__I4, + Library_corlib_native_System_String::Substring___STRING__I4, + Library_corlib_native_System_String::Substring___STRING__I4__I4, + Library_corlib_native_System_String::Trim___STRING__SZARRAY_CHAR, + Library_corlib_native_System_String::TrimStart___STRING__SZARRAY_CHAR, + Library_corlib_native_System_String::TrimEnd___STRING__SZARRAY_CHAR, + Library_corlib_native_System_String::_ctor___VOID__SZARRAY_CHAR__I4__I4, + Library_corlib_native_System_String::_ctor___VOID__SZARRAY_CHAR, + Library_corlib_native_System_String::_ctor___VOID__CHAR__I4, + Library_corlib_native_System_String::CompareTo___I4__STRING, + Library_corlib_native_System_String::IndexOf___I4__CHAR, + Library_corlib_native_System_String::IndexOf___I4__CHAR__I4, + Library_corlib_native_System_String::IndexOf___I4__CHAR__I4__I4, + Library_corlib_native_System_String::IndexOfAny___I4__SZARRAY_CHAR, + Library_corlib_native_System_String::IndexOfAny___I4__SZARRAY_CHAR__I4, + Library_corlib_native_System_String::IndexOfAny___I4__SZARRAY_CHAR__I4__I4, + Library_corlib_native_System_String::IndexOf___I4__STRING, + Library_corlib_native_System_String::IndexOf___I4__STRING__I4, + Library_corlib_native_System_String::IndexOf___I4__STRING__I4__I4, + Library_corlib_native_System_String::LastIndexOf___I4__CHAR, + Library_corlib_native_System_String::LastIndexOf___I4__CHAR__I4, + Library_corlib_native_System_String::LastIndexOf___I4__CHAR__I4__I4, + Library_corlib_native_System_String::LastIndexOfAny___I4__SZARRAY_CHAR, + Library_corlib_native_System_String::LastIndexOfAny___I4__SZARRAY_CHAR__I4, + Library_corlib_native_System_String::LastIndexOfAny___I4__SZARRAY_CHAR__I4__I4, + Library_corlib_native_System_String::LastIndexOf___I4__STRING, + Library_corlib_native_System_String::LastIndexOf___I4__STRING__I4, + Library_corlib_native_System_String::LastIndexOf___I4__STRING__I4__I4, + Library_corlib_native_System_String::ToLower___STRING, + Library_corlib_native_System_String::ToUpper___STRING, + Library_corlib_native_System_String::Trim___STRING, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + Library_corlib_native_System_String::Equals___STATIC__BOOLEAN__STRING__STRING, + Library_corlib_native_System_String::op_Equality___STATIC__BOOLEAN__STRING__STRING, + Library_corlib_native_System_String::op_Inequality___STATIC__BOOLEAN__STRING__STRING, + Library_corlib_native_System_String::Compare___STATIC__I4__STRING__STRING, + nullptr, + nullptr, + nullptr, + nullptr, + Library_corlib_native_System_String::Concat___STATIC__STRING__STRING__STRING, + Library_corlib_native_System_String::Concat___STATIC__STRING__STRING__STRING__STRING, + Library_corlib_native_System_String::Concat___STATIC__STRING__STRING__STRING__STRING__STRING, + Library_corlib_native_System_String::Concat___STATIC__STRING__SZARRAY_STRING, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + Library_corlib_native_System_Exception::get_StackTrace___STRING, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + Library_corlib_native_System_Array::System_Collections_IList_get_Item___OBJECT__I4, + Library_corlib_native_System_Array::System_Collections_IList_set_Item___VOID__I4__OBJECT, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + Library_corlib_native_System_Array::get_Length___I4, + nullptr, + nullptr, + nullptr, + Library_corlib_native_System_Array::Copy___STATIC__VOID__SystemArray__I4__SystemArray__I4__I4, + Library_corlib_native_System_Array::Clear___STATIC__VOID__SystemArray__I4__I4, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + Library_corlib_native_System_Array::TrySzIndexOf___STATIC__BOOLEAN__SystemArray__I4__I4__OBJECT__BYREF_I4, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + Library_corlib_native_System_BitConverter::get_IsLittleEndian___STATIC__BOOLEAN, + Library_corlib_native_System_BitConverter::DoubleToInt64Bits___STATIC__I8__R8, + Library_corlib_native_System_BitConverter::GetBytes___STATIC__SZARRAY_U1__BOOLEAN, + Library_corlib_native_System_BitConverter::GetBytes___STATIC__SZARRAY_U1__CHAR, + Library_corlib_native_System_BitConverter::GetBytes___STATIC__SZARRAY_U1__R8, + Library_corlib_native_System_BitConverter::GetBytes___STATIC__SZARRAY_U1__R4, + Library_corlib_native_System_BitConverter::GetBytes___STATIC__SZARRAY_U1__I4, + Library_corlib_native_System_BitConverter::GetBytes___STATIC__SZARRAY_U1__I8, + Library_corlib_native_System_BitConverter::GetBytes___STATIC__SZARRAY_U1__I2, + Library_corlib_native_System_BitConverter::GetBytes___STATIC__SZARRAY_U1__U4, + Library_corlib_native_System_BitConverter::GetBytes___STATIC__SZARRAY_U1__U8, + Library_corlib_native_System_BitConverter::GetBytes___STATIC__SZARRAY_U1__U2, + Library_corlib_native_System_BitConverter::Int64BitsToDouble___STATIC__R8__I8, + Library_corlib_native_System_BitConverter::ToBoolean___STATIC__BOOLEAN__SZARRAY_U1__I4, + Library_corlib_native_System_BitConverter::ToChar___STATIC__CHAR__SZARRAY_U1__I4, + Library_corlib_native_System_BitConverter::ToDouble___STATIC__R8__SZARRAY_U1__I4, + Library_corlib_native_System_BitConverter::ToInt16___STATIC__I2__SZARRAY_U1__I4, + Library_corlib_native_System_BitConverter::ToInt32___STATIC__I4__SZARRAY_U1__I4, + Library_corlib_native_System_BitConverter::ToInt64___STATIC__I8__SZARRAY_U1__I4, + Library_corlib_native_System_BitConverter::ToSingle___STATIC__R4__SZARRAY_U1__I4, + Library_corlib_native_System_BitConverter::ToString___STATIC__STRING__SZARRAY_U1, + Library_corlib_native_System_BitConverter::ToString___STATIC__STRING__SZARRAY_U1__I4, + Library_corlib_native_System_BitConverter::ToString___STATIC__STRING__SZARRAY_U1__I4__I4, + Library_corlib_native_System_BitConverter::ToUInt16___STATIC__U2__SZARRAY_U1__I4, + Library_corlib_native_System_BitConverter::ToUInt32___STATIC__U4__SZARRAY_U1__I4, + Library_corlib_native_System_BitConverter::ToUInt64___STATIC__U8__SZARRAY_U1__I4, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + Library_corlib_native_System_Collections_ArrayList::get_Item___OBJECT__I4, + Library_corlib_native_System_Collections_ArrayList::set_Item___VOID__I4__OBJECT, + Library_corlib_native_System_Collections_ArrayList::Add___I4__OBJECT, + nullptr, + Library_corlib_native_System_Collections_ArrayList::Clear___VOID, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + Library_corlib_native_System_Collections_ArrayList::Insert___VOID__I4__OBJECT, + nullptr, + Library_corlib_native_System_Collections_ArrayList::RemoveAt___VOID__I4, + nullptr, + Library_corlib_native_System_Collections_ArrayList::SetCapacity___VOID__I4, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + Library_corlib_native_System_Double::CompareTo___STATIC__I4__R8__R8, + Library_corlib_native_System_Double::IsInfinity___STATIC__BOOLEAN__R8, + Library_corlib_native_System_Double::IsNaN___STATIC__BOOLEAN__R8, + Library_corlib_native_System_Double::IsNegativeInfinity___STATIC__BOOLEAN__R8, + Library_corlib_native_System_Double::IsPositiveInfinity___STATIC__BOOLEAN__R8, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + Library_corlib_native_System_TimeSpan::Equals___BOOLEAN__OBJECT, + Library_corlib_native_System_TimeSpan::ToString___STRING, + nullptr, + nullptr, + Library_corlib_native_System_TimeSpan::_ctor___VOID__I4__I4__I4, + Library_corlib_native_System_TimeSpan::_ctor___VOID__I4__I4__I4__I4, + Library_corlib_native_System_TimeSpan::_ctor___VOID__I4__I4__I4__I4__I4, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + Library_corlib_native_System_TimeSpan::CompareTo___I4__OBJECT, + nullptr, + nullptr, + nullptr, + Library_corlib_native_System_TimeSpan::Compare___STATIC__I4__SystemTimeSpan__SystemTimeSpan, + Library_corlib_native_System_TimeSpan::Equals___STATIC__BOOLEAN__SystemTimeSpan__SystemTimeSpan, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + Library_corlib_native_System_DateTime::_ctor___VOID__I4__I4__I4__I4__I4__I4__I4, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + Library_corlib_native_System_DateTime::GetDateTimePart___I4__SystemDateTimeDateTimePart, + nullptr, + Library_corlib_native_System_DateTime::DaysInMonth___STATIC__I4__I4__I4, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + Library_corlib_native_System_DateTime::GetUtcNowAsTicks___STATIC__I8, + Library_corlib_native_System_DateTime::GetTodayAsTicks___STATIC__I8, + nullptr, + Library_corlib_native_System_Convert::NativeToInt64___STATIC__I8__STRING__BOOLEAN__I8__I8__I4__BOOLEAN__BYREF_BOOLEAN, + Library_corlib_native_System_Convert::NativeToDouble___STATIC__R8__STRING__BOOLEAN__BYREF_BOOLEAN, + Library_corlib_native_System_Convert::NativeToDateTime___STATIC__VOID__STRING__BOOLEAN__BYREF_BOOLEAN__BYREF_SystemDateTime, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + Library_corlib_native_System_Convert::ToBase64String___STATIC__STRING__SZARRAY_U1__I4__I4__BOOLEAN, + Library_corlib_native_System_Convert::FromBase64String___STATIC__SZARRAY_U1__STRING, + nullptr, + Library_corlib_native_System_Delegate::Equals___BOOLEAN__OBJECT, + nullptr, + Library_corlib_native_System_Delegate::Combine___STATIC__SystemDelegate__SystemDelegate__SystemDelegate, + Library_corlib_native_System_Delegate::Remove___STATIC__SystemDelegate__SystemDelegate__SystemDelegate, + Library_corlib_native_System_Delegate::op_Equality___STATIC__BOOLEAN__SystemDelegate__SystemDelegate, + Library_corlib_native_System_Delegate::op_Inequality___STATIC__BOOLEAN__SystemDelegate__SystemDelegate, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + Library_corlib_native_System_Diagnostics_Debug::WriteLineNative___STATIC__VOID__STRING__BOOLEAN, + Library_corlib_native_System_Diagnostics_Debugger::get_IsAttached___STATIC__BOOLEAN, + Library_corlib_native_System_Diagnostics_Debugger::Break___STATIC__VOID, + nullptr, + Library_corlib_native_System_Enum::HasFlag___BOOLEAN__SystemEnum, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + Library_corlib_native_System_GC::EnableGCMessages___STATIC__VOID__BOOLEAN, + nullptr, + Library_corlib_native_System_GC::ReRegisterForFinalize___STATIC__VOID__OBJECT, + nullptr, + Library_corlib_native_System_GC::SuppressFinalize___STATIC__VOID__OBJECT, + nullptr, + Library_corlib_native_System_GC::AnyPendingFinalizers___STATIC__BOOLEAN, + Library_corlib_native_System_GC::Run___STATIC__U4__BOOLEAN, + Library_corlib_native_System_Globalization_DateTimeFormat::FormatDigits___STATIC__STRING__I4__I4, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + Library_corlib_native_System_Guid::GenerateNewGuid___STATIC__SZARRAY_U1, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + Library_corlib_native_System_MathInternal::Abs___STATIC__I4__I4, + nullptr, + nullptr, + nullptr, + nullptr, + Library_corlib_native_System_MulticastDelegate::op_Equality___STATIC__BOOLEAN__SystemMulticastDelegate__SystemMulticastDelegate, + Library_corlib_native_System_MulticastDelegate::op_Inequality___STATIC__BOOLEAN__SystemMulticastDelegate__SystemMulticastDelegate, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + Library_corlib_native_System_Number::FormatNative___STATIC__STRING__OBJECT__BOOLEAN__STRING__STRING__STRING__STRING__SZARRAY_I4, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + Library_corlib_native_System_Random::Next___I4, + Library_corlib_native_System_Random::Next___I4__I4, + Library_corlib_native_System_Random::NextDouble___R8, + Library_corlib_native_System_Random::NextBytes___VOID__SZARRAY_U1, + Library_corlib_native_System_Random::_ctor___VOID, + Library_corlib_native_System_Random::_ctor___VOID__I4, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + Library_corlib_native_System_Runtime_CompilerServices_RuntimeHelpers::InitializeArray___STATIC__VOID__SystemArray__SystemRuntimeFieldHandle, + Library_corlib_native_System_Runtime_CompilerServices_RuntimeHelpers::GetObjectValue___STATIC__OBJECT__OBJECT, + Library_corlib_native_System_Runtime_CompilerServices_RuntimeHelpers::RunClassConstructor___STATIC__VOID__SystemRuntimeTypeHandle, + Library_corlib_native_System_Runtime_CompilerServices_RuntimeHelpers::get_OffsetToStringData___STATIC__I4, + Library_corlib_native_System_Runtime_Remoting_RemotingServices::IsTransparentProxy___STATIC__BOOLEAN__OBJECT, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + Library_corlib_native_System_Threading_AutoResetEvent::_ctor___VOID__BOOLEAN, + Library_corlib_native_System_Threading_AutoResetEvent::Reset___BOOLEAN, + Library_corlib_native_System_Threading_AutoResetEvent::Set___BOOLEAN, + Library_corlib_native_System_Threading_Interlocked::Increment___STATIC__I4__BYREF_I4, + Library_corlib_native_System_Threading_Interlocked::Decrement___STATIC__I4__BYREF_I4, + Library_corlib_native_System_Threading_Interlocked::Exchange___STATIC__I4__BYREF_I4__I4, + Library_corlib_native_System_Threading_Interlocked::CompareExchange___STATIC__I4__BYREF_I4__I4__I4, + Library_corlib_native_System_Threading_ManualResetEvent::_ctor___VOID__BOOLEAN, + Library_corlib_native_System_Threading_ManualResetEvent::Reset___BOOLEAN, + Library_corlib_native_System_Threading_ManualResetEvent::Set___BOOLEAN, + Library_corlib_native_System_Threading_Monitor::Enter___STATIC__VOID__OBJECT, + Library_corlib_native_System_Threading_Monitor::Exit___STATIC__VOID__OBJECT, + Library_corlib_native_System_Threading_Thread::_ctor___VOID__SystemThreadingThreadStart, + Library_corlib_native_System_Threading_Thread::Start___VOID, + Library_corlib_native_System_Threading_Thread::Abort___VOID, + Library_corlib_native_System_Threading_Thread::Suspend___VOID, + Library_corlib_native_System_Threading_Thread::Resume___VOID, + Library_corlib_native_System_Threading_Thread::get_Priority___SystemThreadingThreadPriority, + Library_corlib_native_System_Threading_Thread::set_Priority___VOID__SystemThreadingThreadPriority, + Library_corlib_native_System_Threading_Thread::get_ManagedThreadId___I4, + Library_corlib_native_System_Threading_Thread::get_IsAlive___BOOLEAN, + Library_corlib_native_System_Threading_Thread::Join___VOID, + Library_corlib_native_System_Threading_Thread::Join___BOOLEAN__I4, + Library_corlib_native_System_Threading_Thread::Join___BOOLEAN__SystemTimeSpan, + Library_corlib_native_System_Threading_Thread::get_ThreadState___SystemThreadingThreadState, + Library_corlib_native_System_Threading_Thread::Sleep___STATIC__VOID__I4, + nullptr, + Library_corlib_native_System_Threading_Thread::SpinWait___STATIC__VOID__I4, + Library_corlib_native_System_Threading_Thread::get_CurrentThread___STATIC__SystemThreadingThread, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + Library_corlib_native_System_Threading_Timer::Dispose___VOID, + Library_corlib_native_System_Threading_Timer::_ctor___VOID__SystemThreadingTimerCallback__OBJECT__I4__I4, + Library_corlib_native_System_Threading_Timer::_ctor___VOID__SystemThreadingTimerCallback__OBJECT__SystemTimeSpan__SystemTimeSpan, + Library_corlib_native_System_Threading_Timer::Change___BOOLEAN__I4__I4, + Library_corlib_native_System_Threading_Timer::Change___BOOLEAN__SystemTimeSpan__SystemTimeSpan, + nullptr, + nullptr, + nullptr, + nullptr, + Library_corlib_native_System_Threading_WaitHandle::WaitOne___BOOLEAN__I4__BOOLEAN, + nullptr, + nullptr, + Library_corlib_native_System_Threading_WaitHandle::WaitMultiple___STATIC__I4__SZARRAY_SystemThreadingWaitHandle__I4__BOOLEAN__BOOLEAN, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + Library_corlib_native_System_ValueType::Equals___BOOLEAN__OBJECT, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + Library_corlib_native_System_WeakReference::get_IsAlive___BOOLEAN, + Library_corlib_native_System_WeakReference::get_Target___OBJECT, + Library_corlib_native_System_WeakReference::set_Target___VOID__OBJECT, + Library_corlib_native_System_WeakReference::_ctor___VOID__OBJECT, +}; + +#else +#error "NANOCLR_REFLECTION has to be define either TRUE or FALSE. Check the build options." +#endif + +const CLR_RT_NativeAssemblyData g_CLR_AssemblyNative_mscorlib = +{ + "mscorlib", + +#if (NANOCLR_REFLECTION == TRUE) + + 0x4E06901B, + +#elif (NANOCLR_REFLECTION == FALSE) + + 0xB9FA421B, +, + +#else +#error "NANOCLR_REFLECTION has to be define either TRUE or FALSE. Check the build options." +#endif + + method_lookup, + { 100, 22, 0, 0 } +}; + +// clang-format on diff --git a/src/CLR/CorLib/corlib_native.h b/src/CLR/CorLib/corlib_native.h index f9ae91938b..a133cf247d 100644 --- a/src/CLR/CorLib/corlib_native.h +++ b/src/CLR/CorLib/corlib_native.h @@ -595,9 +595,11 @@ struct Library_corlib_native_System_EventArgs struct Library_corlib_native_System_GC { - NANOCLR_NATIVE_DECLARE(AnyPendingFinalizers___STATIC__BOOLEAN); - NANOCLR_NATIVE_DECLARE(SuppressFinalize___STATIC__VOID__OBJECT); + NANOCLR_NATIVE_DECLARE(EnableGCMessages___STATIC__VOID__BOOLEAN); NANOCLR_NATIVE_DECLARE(ReRegisterForFinalize___STATIC__VOID__OBJECT); + NANOCLR_NATIVE_DECLARE(SuppressFinalize___STATIC__VOID__OBJECT); + NANOCLR_NATIVE_DECLARE(AnyPendingFinalizers___STATIC__BOOLEAN); + NANOCLR_NATIVE_DECLARE(Run___STATIC__U4__BOOLEAN); //--// }; @@ -609,13 +611,6 @@ struct Library_corlib_native_System_Globalization_DateTimeFormat //--// }; -struct Library_corlib_native_System_UInt32 -{ - static const int FIELD__m_value = 1; - - //--// -}; - struct Library_corlib_native_System_Int16 { static const int FIELD__m_value = 1; @@ -659,16 +654,16 @@ struct Library_corlib_native_System_Number static bool ValidateFormatChar(char *formatChar, bool isInteger); static bool GetFormatSpec(char *format, bool isInteger, char *formatChar, int *precision); static int DoPrintfOnDataType(char *buffer, char *formatStr, CLR_RT_HeapBlock *value); - static bool IsSignedIntegerDataType(CLR_DataType dataType); - static bool IsUnsignedIntegerDataType(CLR_DataType dataType); - static bool IsIntegerDataType(CLR_DataType dataType); + static bool IsSignedIntegerDataType(NanoCLRDataType dataType); + static bool IsUnsignedIntegerDataType(NanoCLRDataType dataType); + static bool IsIntegerDataType(NanoCLRDataType dataType); static int GetStrLen(char *buffer); static int GetDotIndex(char *buffer, int bufferContentLength); static void RoundUpNumStr(char *buffer, int *bufferContentLength); static int ReplaceNegativeSign(char *buffer, int bufferContentLength, char *negativeSign); static int ReplaceDecimalSeparator(char *buffer, int bufferContentLength, char *decimalSeparator); static int InsertGroupSeparators(char *buffer, int bufferContentLength, int groupSize, char *groupSep); - static const char *GetPrintfLengthModifier(CLR_DataType dataType); + static const char *GetPrintfLengthModifier(NanoCLRDataType dataType); static int Format_G( char *buffer, CLR_RT_HeapBlock *value, @@ -795,20 +790,6 @@ struct Library_corlib_native_System_Reflection_RuntimeMethodInfo //--// }; -struct Library_corlib_native_System_Runtime_CompilerServices_NullableAttribute -{ - static const int FIELD__NullableFlags = 1; - - //--// -}; - -struct Library_corlib_native_System_Runtime_CompilerServices_NullableContextAttribute -{ - static const int FIELD__Flag = 1; - - //--// -}; - struct Library_corlib_native_System_Runtime_CompilerServices_RuntimeHelpers { NANOCLR_NATIVE_DECLARE(InitializeArray___STATIC__VOID__SystemArray__SystemRuntimeFieldHandle); @@ -1014,6 +995,13 @@ struct Library_corlib_native_System_Threading_WaitHandle bool fWaitAll); }; +struct Library_corlib_native_System_UInt32 +{ + static const int FIELD__m_value = 1; + + //--// +}; + struct Library_corlib_native_System_UInt64 { static const int FIELD__m_value = 1; diff --git a/src/CLR/CorLib/corlib_native_System_AppDomain.cpp b/src/CLR/CorLib/corlib_native_System_AppDomain.cpp index 5510462787..890e728ab4 100644 --- a/src/CLR/CorLib/corlib_native_System_AppDomain.cpp +++ b/src/CLR/CorLib/corlib_native_System_AppDomain.cpp @@ -13,7 +13,7 @@ HRESULT Library_corlib_native_System_AppDomain::GetAssemblies___SZARRAY_SystemRe NATIVE_PROFILE_CLR_CORE(); NANOCLR_HEADER(); - CLR_RT_AppDomain *appDomainSav = NULL; + CLR_RT_AppDomain *appDomainSav = nullptr; CLR_RT_AppDomain *appDomain; NANOCLR_CHECK_HRESULT(GetAppDomain(stack.ThisRef(), appDomain, appDomainSav, true)); @@ -37,7 +37,7 @@ HRESULT Library_corlib_native_System_AppDomain:: CLR_RT_AppDomain *appDomainSav; CLR_RT_AppDomain *appDomain; CLR_RT_Assembly *assembly; - CLR_RT_Assembly_Index idx; + CLR_RT_Assembly_Index index; bool fVersion; CLR_INT16 maj, min, build, rev; const char *szAssembly; @@ -71,7 +71,7 @@ HRESULT Library_corlib_native_System_AppDomain:: } else { - assembly = g_CLR_RT_TypeSystem.FindAssembly(szAssembly, NULL, false); + assembly = g_CLR_RT_TypeSystem.FindAssembly(szAssembly, nullptr, false); FAULT_ON_NULL_HR(assembly, CLR_E_INVALID_PARAMETER); } @@ -81,12 +81,12 @@ HRESULT Library_corlib_native_System_AppDomain:: CLR_RT_HeapBlock &top = stack.PushValue(); CLR_RT_HeapBlock *hbObj; - idx.Set(assembly->m_idx); + index.Set(assembly->m_index); - NANOCLR_CHECK_HRESULT(g_CLR_RT_ExecutionEngine.NewObjectFromIndex(top, g_CLR_RT_WellKnownTypes.m_Assembly)); + NANOCLR_CHECK_HRESULT(g_CLR_RT_ExecutionEngine.NewObjectFromIndex(top, g_CLR_RT_WellKnownTypes.Assembly)); hbObj = top.Dereference(); - hbObj->SetReflection(idx); + hbObj->SetReflection(index); } NANOCLR_CLEANUP(); @@ -101,10 +101,10 @@ HRESULT Library_corlib_native_System_AppDomain::CreateDomain___STATIC__SystemApp NATIVE_PROFILE_CLR_CORE(); NANOCLR_HEADER(); - CLR_RT_AppDomain *appDomain = NULL; + CLR_RT_AppDomain *appDomain = nullptr; CLR_RT_HeapBlock &pArgs = stack.Arg0(); CLR_RT_HeapBlock res; - res.SetObjectReference(NULL); + res.SetObjectReference(nullptr); CLR_RT_ProtectFromGC gc(res); const char *szName; @@ -117,7 +117,7 @@ HRESULT Library_corlib_native_System_AppDomain::CreateDomain___STATIC__SystemApp NANOCLR_CHECK_HRESULT(appDomain->LoadAssembly(g_CLR_RT_TypeSystem.m_assemblyMscorlib)); // load Runtime.Native - if (g_CLR_RT_TypeSystem.m_assemblyNative != NULL) + if (g_CLR_RT_TypeSystem.m_assemblyNative != nullptr) { NANOCLR_CHECK_HRESULT(appDomain->LoadAssembly(g_CLR_RT_TypeSystem.m_assemblyNative)); } @@ -226,7 +226,7 @@ HRESULT Library_corlib_native_System_AppDomain::GetAppDomain( } _ASSERTE(obj->DataType() == DATATYPE_CLASS); - _ASSERTE(obj->ObjectCls().m_data == g_CLR_RT_WellKnownTypes.m_AppDomain.m_data); + _ASSERTE(obj->ObjectCls().m_data == g_CLR_RT_WellKnownTypes.AppDomain.m_data); src = CLR_RT_ObjectToEvent_Source::ExtractInstance(obj[FIELD___appDomain]); FAULT_ON_NULL(src); @@ -246,7 +246,7 @@ HRESULT Library_corlib_native_System_AppDomain::GetAppDomain( NANOCLR_NOCLEANUP(); } -#else //#if defined(NANOCLR_APPDOMAINS) +#else // #if defined(NANOCLR_APPDOMAINS) #if (NANOCLR_REFLECTION == TRUE) @@ -259,7 +259,7 @@ HRESULT Library_corlib_native_System_AppDomain::GetAssemblies___SZARRAY_SystemRe CLR_RT_HeapBlock &top = stack.PushValueAndClear(); int count = 0; - CLR_RT_HeapBlock *pArray = NULL; + CLR_RT_HeapBlock *pArray = nullptr; for (int pass = 0; pass < 2; pass++) { @@ -272,14 +272,14 @@ HRESULT Library_corlib_native_System_AppDomain::GetAssemblies___SZARRAY_SystemRe else { CLR_RT_HeapBlock *hbObj; - CLR_RT_Assembly_Index idx; - idx.Set(pASSM->m_idx); + CLR_RT_Assembly_Index index; + index.Set(pASSM->assemblyIndex); NANOCLR_CHECK_HRESULT( - g_CLR_RT_ExecutionEngine.NewObjectFromIndex(*pArray, g_CLR_RT_WellKnownTypes.m_Assembly)); + g_CLR_RT_ExecutionEngine.NewObjectFromIndex(*pArray, g_CLR_RT_WellKnownTypes.Assembly)); hbObj = pArray->Dereference(); - hbObj->SetReflection(idx); + hbObj->SetReflection(index); pArray++; } @@ -288,8 +288,7 @@ HRESULT Library_corlib_native_System_AppDomain::GetAssemblies___SZARRAY_SystemRe if (pass == 0) { - NANOCLR_CHECK_HRESULT( - CLR_RT_HeapBlock_Array::CreateInstance(top, count, g_CLR_RT_WellKnownTypes.m_Assembly)); + NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_Array::CreateInstance(top, count, g_CLR_RT_WellKnownTypes.Assembly)); pArray = (CLR_RT_HeapBlock *)top.DereferenceArray()->GetFirstElement(); } @@ -331,4 +330,4 @@ HRESULT Library_corlib_native_System_AppDomain::Unload___STATIC__VOID__SystemApp #endif // NANOCLR_REFLECTION -#endif //#if defined(NANOCLR_APPDOMAINS) +#endif // #if defined(NANOCLR_APPDOMAINS) diff --git a/src/CLR/CorLib/corlib_native_System_BitConverter.cpp b/src/CLR/CorLib/corlib_native_System_BitConverter.cpp index 0dc00004e6..abeae90255 100644 --- a/src/CLR/CorLib/corlib_native_System_BitConverter.cpp +++ b/src/CLR/CorLib/corlib_native_System_BitConverter.cpp @@ -63,7 +63,7 @@ HRESULT Library_corlib_native_System_BitConverter::GetBytes___STATIC__SZARRAY_U1 bool input = stack.Arg0().NumericByRefConst().u1 != 0; NANOCLR_CHECK_HRESULT( - CLR_RT_HeapBlock_Array::CreateInstance(stack.PushValueAndClear(), 1, g_CLR_RT_WellKnownTypes.m_UInt8)); + CLR_RT_HeapBlock_Array::CreateInstance(stack.PushValueAndClear(), 1, g_CLR_RT_WellKnownTypes.UInt8)); { unsigned char *p = stack.TopValue().DereferenceArray()->GetFirstElement(); *reinterpret_cast(p) = input; @@ -79,7 +79,7 @@ HRESULT Library_corlib_native_System_BitConverter::GetBytes___STATIC__SZARRAY_U1 wchar_t input = stack.Arg0().NumericByRefConst().u2; NANOCLR_CHECK_HRESULT( - CLR_RT_HeapBlock_Array::CreateInstance(stack.PushValueAndClear(), 2, g_CLR_RT_WellKnownTypes.m_UInt8)); + CLR_RT_HeapBlock_Array::CreateInstance(stack.PushValueAndClear(), 2, g_CLR_RT_WellKnownTypes.UInt8)); { unsigned char *p = stack.TopValue().DereferenceArray()->GetFirstElement(); *reinterpret_cast(p) = input; @@ -99,7 +99,7 @@ HRESULT Library_corlib_native_System_BitConverter::GetBytes___STATIC__SZARRAY_U1 #endif NANOCLR_CHECK_HRESULT( - CLR_RT_HeapBlock_Array::CreateInstance(stack.PushValueAndClear(), 8, g_CLR_RT_WellKnownTypes.m_UInt8)); + CLR_RT_HeapBlock_Array::CreateInstance(stack.PushValueAndClear(), 8, g_CLR_RT_WellKnownTypes.UInt8)); { unsigned char *p = stack.TopValue().DereferenceArray()->GetFirstElement(); #if !defined(NANOCLR_EMULATED_FLOATINGPOINT) @@ -123,7 +123,7 @@ HRESULT Library_corlib_native_System_BitConverter::GetBytes___STATIC__SZARRAY_U1 #endif NANOCLR_CHECK_HRESULT( - CLR_RT_HeapBlock_Array::CreateInstance(stack.PushValueAndClear(), 4, g_CLR_RT_WellKnownTypes.m_UInt8)); + CLR_RT_HeapBlock_Array::CreateInstance(stack.PushValueAndClear(), 4, g_CLR_RT_WellKnownTypes.UInt8)); { unsigned char *p = stack.TopValue().DereferenceArray()->GetFirstElement(); #if !defined(NANOCLR_EMULATED_FLOATINGPOINT) @@ -143,7 +143,7 @@ HRESULT Library_corlib_native_System_BitConverter::GetBytes___STATIC__SZARRAY_U1 int input = stack.Arg0().NumericByRefConst().s4; NANOCLR_CHECK_HRESULT( - CLR_RT_HeapBlock_Array::CreateInstance(stack.PushValueAndClear(), 4, g_CLR_RT_WellKnownTypes.m_UInt8)); + CLR_RT_HeapBlock_Array::CreateInstance(stack.PushValueAndClear(), 4, g_CLR_RT_WellKnownTypes.UInt8)); { unsigned char *p = stack.TopValue().DereferenceArray()->GetFirstElement(); *reinterpret_cast(p) = input; @@ -159,7 +159,7 @@ HRESULT Library_corlib_native_System_BitConverter::GetBytes___STATIC__SZARRAY_U1 __int64 input = stack.Arg0().NumericByRefConst().s8; NANOCLR_CHECK_HRESULT( - CLR_RT_HeapBlock_Array::CreateInstance(stack.PushValueAndClear(), 8, g_CLR_RT_WellKnownTypes.m_UInt8)); + CLR_RT_HeapBlock_Array::CreateInstance(stack.PushValueAndClear(), 8, g_CLR_RT_WellKnownTypes.UInt8)); { unsigned char *p = stack.TopValue().DereferenceArray()->GetFirstElement(); *reinterpret_cast<__int64 *>(p) = input; @@ -175,7 +175,7 @@ HRESULT Library_corlib_native_System_BitConverter::GetBytes___STATIC__SZARRAY_U1 short input = stack.Arg0().NumericByRefConst().s2; NANOCLR_CHECK_HRESULT( - CLR_RT_HeapBlock_Array::CreateInstance(stack.PushValueAndClear(), 2, g_CLR_RT_WellKnownTypes.m_UInt8)); + CLR_RT_HeapBlock_Array::CreateInstance(stack.PushValueAndClear(), 2, g_CLR_RT_WellKnownTypes.UInt8)); { unsigned char *p = stack.TopValue().DereferenceArray()->GetFirstElement(); *reinterpret_cast(p) = input; @@ -191,7 +191,7 @@ HRESULT Library_corlib_native_System_BitConverter::GetBytes___STATIC__SZARRAY_U1 unsigned int input = stack.Arg0().NumericByRefConst().u4; NANOCLR_CHECK_HRESULT( - CLR_RT_HeapBlock_Array::CreateInstance(stack.PushValueAndClear(), 4, g_CLR_RT_WellKnownTypes.m_UInt8)); + CLR_RT_HeapBlock_Array::CreateInstance(stack.PushValueAndClear(), 4, g_CLR_RT_WellKnownTypes.UInt8)); { unsigned char *p = stack.TopValue().DereferenceArray()->GetFirstElement(); *reinterpret_cast(p) = input; @@ -207,7 +207,7 @@ HRESULT Library_corlib_native_System_BitConverter::GetBytes___STATIC__SZARRAY_U1 unsigned __int64 input = stack.Arg0().NumericByRefConst().u8; NANOCLR_CHECK_HRESULT( - CLR_RT_HeapBlock_Array::CreateInstance(stack.PushValueAndClear(), 8, g_CLR_RT_WellKnownTypes.m_UInt8)); + CLR_RT_HeapBlock_Array::CreateInstance(stack.PushValueAndClear(), 8, g_CLR_RT_WellKnownTypes.UInt8)); { unsigned char *p = stack.TopValue().DereferenceArray()->GetFirstElement(); *reinterpret_cast(p) = input; @@ -223,7 +223,7 @@ HRESULT Library_corlib_native_System_BitConverter::GetBytes___STATIC__SZARRAY_U1 unsigned short input = stack.Arg0().NumericByRefConst().u2; NANOCLR_CHECK_HRESULT( - CLR_RT_HeapBlock_Array::CreateInstance(stack.PushValueAndClear(), 2, g_CLR_RT_WellKnownTypes.m_UInt8)); + CLR_RT_HeapBlock_Array::CreateInstance(stack.PushValueAndClear(), 2, g_CLR_RT_WellKnownTypes.UInt8)); { unsigned char *p = stack.TopValue().DereferenceArray()->GetFirstElement(); *reinterpret_cast(p) = input; @@ -252,7 +252,7 @@ HRESULT Library_corlib_native_System_BitConverter::ToBoolean___STATIC__BOOLEAN__ NATIVE_PROFILE_CLR_CORE(); NANOCLR_HEADER(); - unsigned char *p = NULL; + unsigned char *p = nullptr; unsigned char b = 0; int index = 0; bool res = false; @@ -277,7 +277,7 @@ HRESULT Library_corlib_native_System_BitConverter::ToChar___STATIC__CHAR__SZARRA NATIVE_PROFILE_CLR_CORE(); NANOCLR_HEADER(); - unsigned char *p = NULL; + unsigned char *p = nullptr; int index = 0; wchar_t value = 0; unsigned char *pValue = (unsigned char *)(&value); @@ -306,7 +306,7 @@ HRESULT Library_corlib_native_System_BitConverter::ToDouble___STATIC__R8__SZARRA NATIVE_PROFILE_CLR_CORE(); NANOCLR_HEADER(); - unsigned char *p = NULL; + unsigned char *p = nullptr; int index = 0; double value = 0; @@ -337,7 +337,7 @@ HRESULT Library_corlib_native_System_BitConverter::ToSingle___STATIC__R4__SZARRA NATIVE_PROFILE_CLR_CORE(); NANOCLR_HEADER(); - unsigned char *p = NULL; + unsigned char *p = nullptr; int index = 0; float value = 0; unsigned char *pValue = (unsigned char *)(&value); @@ -368,7 +368,7 @@ HRESULT Library_corlib_native_System_BitConverter::ToInt16___STATIC__I2__SZARRAY NATIVE_PROFILE_CLR_CORE(); NANOCLR_HEADER(); - unsigned char *p = NULL; + unsigned char *p = nullptr; int index = 0; signed short value = 0; unsigned char *pValue = (unsigned char *)(&value); @@ -398,7 +398,7 @@ HRESULT Library_corlib_native_System_BitConverter::ToInt32___STATIC__I4__SZARRAY NATIVE_PROFILE_CLR_CORE(); NANOCLR_HEADER(); - unsigned char *p = NULL; + unsigned char *p = nullptr; int index = 0; signed int value = 0; @@ -429,7 +429,7 @@ HRESULT Library_corlib_native_System_BitConverter::ToInt64___STATIC__I8__SZARRAY NATIVE_PROFILE_CLR_CORE(); NANOCLR_HEADER(); - unsigned char *p = NULL; + unsigned char *p = nullptr; int index = 0; CLR_INT64 value = 0; @@ -460,7 +460,7 @@ HRESULT Library_corlib_native_System_BitConverter::ToUInt16___STATIC__U2__SZARRA NATIVE_PROFILE_CLR_CORE(); NANOCLR_HEADER(); - unsigned char *p = NULL; + unsigned char *p = nullptr; int index = 0; CLR_UINT16 value = 0; unsigned char *pValue = (unsigned char *)(&value); @@ -489,7 +489,7 @@ HRESULT Library_corlib_native_System_BitConverter::ToUInt32___STATIC__U4__SZARRA NATIVE_PROFILE_CLR_CORE(); NANOCLR_HEADER(); - unsigned char *p = NULL; + unsigned char *p = nullptr; int index = 0; CLR_UINT32 value = 0; unsigned char *pValue = (unsigned char *)(&value); @@ -518,7 +518,7 @@ HRESULT Library_corlib_native_System_BitConverter::ToUInt64___STATIC__U8__SZARRA NATIVE_PROFILE_CLR_CORE(); NANOCLR_HEADER(); - unsigned char *p = NULL; + unsigned char *p = nullptr; int index = 0; CLR_UINT64 value = 0; unsigned char *pValue = (unsigned char *)(&value); diff --git a/src/CLR/CorLib/corlib_native_System_Convert.cpp b/src/CLR/CorLib/corlib_native_System_Convert.cpp index 3cf215e47f..d30592ede1 100644 --- a/src/CLR/CorLib/corlib_native_System_Convert.cpp +++ b/src/CLR/CorLib/corlib_native_System_Convert.cpp @@ -58,7 +58,8 @@ HRESULT Library_corlib_native_System_Convert:: { str++; } - endptr = NULL; + + endptr = nullptr; #if (SUPPORT_ANY_BASE_CONVERSION == TRUE) // support for conversion from any base @@ -526,7 +527,7 @@ HRESULT Library_corlib_native_System_Convert:: CLR_INT64 *pTicks; char *str = (char *)stack.Arg0().RecoverString(); - char *conversionResult = NULL; + char *conversionResult = nullptr; // char *str = (char *)"1999-10-31 10:00:00Z"; uint64_t ticks; @@ -538,25 +539,25 @@ HRESULT Library_corlib_native_System_Convert:: // try 'u' Universal time with sortable format (yyyy-MM-dd' 'HH:mm:ss) conversionResult = Nano_strptime(str, "%Y-%m-%d %H:%M:%SZ", &ticks); - if (conversionResult == NULL) + if (conversionResult == nullptr) { // try 'o/O' Round Trip ISO 8601 compatible (yyyy-MM-ddTHH:mm:ss.fffffff) conversionResult = Nano_strptime(str, "%Y-%m-%dT%H:%M:%S.%f", &ticks); } - if (conversionResult == NULL) + if (conversionResult == nullptr) { // try 'o/O' Round Trip ISO 8601 compatible (yyyy-MM-ddTHH:mm:ss) conversionResult = Nano_strptime(str, "%Y-%m-%dT%H:%M:%S", &ticks); } - if (conversionResult == NULL) + if (conversionResult == nullptr) { // try 'r/R' RFC 1123 date (ddd, dd MMM yyyy HH:mm:ss) conversionResult = Nano_strptime(str, "%a, %d %b %Y %H:%M:%S", &ticks); } - if (conversionResult == NULL) + if (conversionResult == nullptr) { // failed to parse string @@ -592,10 +593,10 @@ HRESULT Library_corlib_native_System_Convert::ToBase64String___STATIC__STRING__S #if (SUPPORT_ANY_BASE_CONVERSION == TRUE) size_t outputLength; - unsigned char *outArray = NULL; - char *outArrayWitLineBreak = NULL; - unsigned char *inArrayPointer = NULL; - size_t lineBreakCount; + unsigned char *outArray = nullptr; + char *outArrayWitLineBreak = nullptr; + uint8_t *inArrayPointer = nullptr; + uint8_t lineBreakCount; uint16_t offsetIndex = 0; size_t count = 0; int result; @@ -617,7 +618,7 @@ HRESULT Library_corlib_native_System_Convert::ToBase64String___STATIC__STRING__S outArray = (unsigned char *)platform_malloc(outputLength + 1); // check if have allocation - if (outArray == NULL) + if (outArray == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_OUT_OF_MEMORY); } @@ -696,7 +697,7 @@ HRESULT Library_corlib_native_System_Convert::ToBase64String___STATIC__STRING__S // need to free memory from arrays platform_free((void *)outArray); - if (outArrayWitLineBreak != NULL) + if (outArrayWitLineBreak != nullptr) { platform_free((void *)outArrayWitLineBreak); } @@ -716,9 +717,9 @@ HRESULT Library_corlib_native_System_Convert::FromBase64String___STATIC__SZARRAY #if (SUPPORT_ANY_BASE_CONVERSION == TRUE) - CLR_RT_HeapBlock_String *inString = NULL; + CLR_RT_HeapBlock_String *inString = nullptr; size_t outputLength; - unsigned char *outArray = NULL; + unsigned char *outArray = nullptr; CLR_UINT8 *returnArray; int result; size_t length; @@ -736,7 +737,7 @@ HRESULT Library_corlib_native_System_Convert::FromBase64String___STATIC__SZARRAY // alloc output array outArray = (unsigned char *)platform_malloc(outputLength + 1); // check malloc success - if (outArray == NULL) + if (outArray == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_OUT_OF_MEMORY); } @@ -760,10 +761,8 @@ HRESULT Library_corlib_native_System_Convert::FromBase64String___STATIC__SZARRAY // create heap block array instance with appropriate size (the length of the output array) // and type (byte which is uint8_t) - NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_Array::CreateInstance( - stack.PushValueAndClear(), - outputLength, - g_CLR_RT_WellKnownTypes.m_UInt8)); + NANOCLR_CHECK_HRESULT( + CLR_RT_HeapBlock_Array::CreateInstance(stack.PushValueAndClear(), outputLength, g_CLR_RT_WellKnownTypes.UInt8)); // get a pointer to the array in the heap block array just created returnArray = stack.TopValue().DereferenceArray()->GetFirstElement(); @@ -962,7 +961,7 @@ char *Library_corlib_native_System_Convert::Nano_strptime(const char *buf, const literal: if (c != *bufPointer++) { - return NULL; + return nullptr; } break; @@ -984,7 +983,7 @@ char *Library_corlib_native_System_Convert::Nano_strptime(const char *buf, const // no match if (i == 7) { - return NULL; + return nullptr; } st.wDayOfWeek = i; @@ -1008,7 +1007,7 @@ char *Library_corlib_native_System_Convert::Nano_strptime(const char *buf, const // no match if (i == 12) { - return NULL; + return nullptr; } st.wMonth = i + 1; @@ -1019,7 +1018,7 @@ char *Library_corlib_native_System_Convert::Nano_strptime(const char *buf, const case 'd': if (!(nano_conv_num(&bufPointer, &value, 1, 31))) { - return NULL; + return nullptr; } st.wDay = value; break; @@ -1028,7 +1027,7 @@ char *Library_corlib_native_System_Convert::Nano_strptime(const char *buf, const case 'H': if (!(nano_conv_num(&bufPointer, &value, 0, 23))) { - return NULL; + return nullptr; } st.wHour = value; break; @@ -1037,7 +1036,7 @@ char *Library_corlib_native_System_Convert::Nano_strptime(const char *buf, const case 'M': if (!(nano_conv_num(&bufPointer, &value, 0, 59))) { - return NULL; + return nullptr; } st.wMinute = value; break; @@ -1046,7 +1045,7 @@ char *Library_corlib_native_System_Convert::Nano_strptime(const char *buf, const case 'm': if (!(nano_conv_num(&bufPointer, &value, 1, 12))) { - return NULL; + return nullptr; } st.wMonth = value; break; @@ -1055,7 +1054,7 @@ char *Library_corlib_native_System_Convert::Nano_strptime(const char *buf, const case 'S': if (!(nano_conv_num(&bufPointer, &value, 0, 59))) { - return NULL; + return nullptr; } st.wSecond = value; break; @@ -1064,7 +1063,7 @@ char *Library_corlib_native_System_Convert::Nano_strptime(const char *buf, const case 'Y': if (!(nano_conv_num(&bufPointer, &value, 0, 9999))) { - return NULL; + return nullptr; } st.wYear = value; @@ -1074,7 +1073,7 @@ char *Library_corlib_native_System_Convert::Nano_strptime(const char *buf, const case 'f': if (!(nano_conv_num(&bufPointer, &value, 0, 9999999))) { - return NULL; + return nullptr; } extraTicks = value; @@ -1092,7 +1091,7 @@ char *Library_corlib_native_System_Convert::Nano_strptime(const char *buf, const // Unknown/unsupported conversion default: - return NULL; + return nullptr; } } diff --git a/src/CLR/CorLib/corlib_native_System_DateTime.cpp b/src/CLR/CorLib/corlib_native_System_DateTime.cpp index 2be3d6b4ff..9ebd28aef3 100644 --- a/src/CLR/CorLib/corlib_native_System_DateTime.cpp +++ b/src/CLR/CorLib/corlib_native_System_DateTime.cpp @@ -197,7 +197,7 @@ CLR_INT64 *Library_corlib_native_System_DateTime::GetValuePtr(CLR_RT_HeapBlock & { NATIVE_PROFILE_CLR_CORE(); CLR_RT_HeapBlock *obj = &ref; - CLR_DataType dt = obj->DataType(); + NanoCLRDataType dt = obj->DataType(); if (dt == DATATYPE_OBJECT || dt == DATATYPE_BYREF) { @@ -205,7 +205,7 @@ CLR_INT64 *Library_corlib_native_System_DateTime::GetValuePtr(CLR_RT_HeapBlock & if (!obj) { - return NULL; + return nullptr; } dt = obj->DataType(); @@ -219,7 +219,7 @@ CLR_INT64 *Library_corlib_native_System_DateTime::GetValuePtr(CLR_RT_HeapBlock & if (!obj) { - return NULL; + return nullptr; } dt = obj->DataType(); @@ -235,12 +235,12 @@ CLR_INT64 *Library_corlib_native_System_DateTime::GetValuePtr(CLR_RT_HeapBlock & return (CLR_INT64 *)&obj->NumericByRef().s8; } - if (dt == DATATYPE_VALUETYPE && obj->ObjectCls().m_data == g_CLR_RT_WellKnownTypes.m_DateTime.m_data) + if (dt == DATATYPE_VALUETYPE && obj->ObjectCls().data == g_CLR_RT_WellKnownTypes.DateTime.data) { return (CLR_INT64 *)&obj[FIELD___ticks].NumericByRef().s8; } - return NULL; + return nullptr; } bool Library_corlib_native_System_DateTime::Expand(CLR_RT_StackFrame &stack, SYSTEMTIME &st) diff --git a/src/CLR/CorLib/corlib_native_System_Delegate.cpp b/src/CLR/CorLib/corlib_native_System_Delegate.cpp index 2b4fd16f90..627e34cb85 100644 --- a/src/CLR/CorLib/corlib_native_System_Delegate.cpp +++ b/src/CLR/CorLib/corlib_native_System_Delegate.cpp @@ -26,7 +26,7 @@ HRESULT Library_corlib_native_System_Delegate::GetInvocationList___SZARRAY_Syste CLR_RT_HeapBlock_Delegate_List *lst = (CLR_RT_HeapBlock_Delegate_List *)dlg; int delegatesCount = 0; - CLR_RT_HeapBlock *returnArray = NULL; + CLR_RT_HeapBlock *returnArray = nullptr; // put the return array on the stack CLR_RT_HeapBlock &top = stack.PushValueAndClear(); @@ -45,7 +45,7 @@ HRESULT Library_corlib_native_System_Delegate::GetInvocationList___SZARRAY_Syste // create the result array NANOCLR_CHECK_HRESULT( - CLR_RT_HeapBlock_Array::CreateInstance(top, delegatesCount, g_CLR_RT_WellKnownTypes.m_Delegate)); + CLR_RT_HeapBlock_Array::CreateInstance(top, delegatesCount, g_CLR_RT_WellKnownTypes.Delegate)); if (delegatesCount > 0) { @@ -62,7 +62,7 @@ HRESULT Library_corlib_native_System_Delegate::GetInvocationList___SZARRAY_Syste // create an instance of delegate NANOCLR_CHECK_HRESULT( - g_CLR_RT_ExecutionEngine.NewObjectFromIndex(*returnArray, g_CLR_RT_WellKnownTypes.m_Delegate)); + g_CLR_RT_ExecutionEngine.NewObjectFromIndex(*returnArray, g_CLR_RT_WellKnownTypes.Delegate)); // fetch delegate from list dlg = ptr[i].DereferenceDelegate(); @@ -76,7 +76,7 @@ HRESULT Library_corlib_native_System_Delegate::GetInvocationList___SZARRAY_Syste { // create an instance of delegate NANOCLR_CHECK_HRESULT( - g_CLR_RT_ExecutionEngine.NewObjectFromIndex(*returnArray, g_CLR_RT_WellKnownTypes.m_Delegate)); + g_CLR_RT_ExecutionEngine.NewObjectFromIndex(*returnArray, g_CLR_RT_WellKnownTypes.Delegate)); // set delegate reference to return element returnArray->SetObjectReference(dlg); } @@ -100,7 +100,7 @@ HRESULT Library_corlib_native_System_Delegate::get_Method___SystemReflectionMeth CLR_RT_HeapBlock &top = stack.PushValue(); CLR_RT_HeapBlock *hbObj; - NANOCLR_CHECK_HRESULT(g_CLR_RT_ExecutionEngine.NewObjectFromIndex(top, g_CLR_RT_WellKnownTypes.m_MethodInfo)); + NANOCLR_CHECK_HRESULT(g_CLR_RT_ExecutionEngine.NewObjectFromIndex(top, g_CLR_RT_WellKnownTypes.MethodInfo)); hbObj = top.Dereference(); hbObj->SetReflection(dlg->DelegateFtn()); @@ -190,7 +190,7 @@ CLR_RT_HeapBlock_Delegate *Library_corlib_native_System_Delegate::GetLastDelegat if (lst->m_length == 0) { - dlg = NULL; + dlg = nullptr; } else { diff --git a/src/CLR/CorLib/corlib_native_System_Exception.cpp b/src/CLR/CorLib/corlib_native_System_Exception.cpp index 5288973970..a6246732ca 100644 --- a/src/CLR/CorLib/corlib_native_System_Exception.cpp +++ b/src/CLR/CorLib/corlib_native_System_Exception.cpp @@ -13,21 +13,21 @@ struct ExceptionLookup static const ExceptionLookup c_ExceptionLookup[] = { #define EL(hr, fld) {hr, &g_CLR_RT_WellKnownTypes.fld} - EL(CLR_E_APPDOMAIN_EXITED, m_AppDomainUnloadedException), - EL(CLR_E_INVALID_PARAMETER, m_ArgumentException), - EL(CLR_E_ARGUMENT_NULL, m_ArgumentNullException), - EL(CLR_E_OUT_OF_RANGE, m_ArgumentOutOfRangeException), - EL(CLR_E_INDEX_OUT_OF_RANGE, m_IndexOutOfRangeException), - EL(CLR_E_INVALID_CAST, m_InvalidCastException), - EL(CLR_E_FORMAT_EXCEPTION, m_FormatException), - EL(CLR_E_INVALID_OPERATION, m_InvalidOperationException), - EL(CLR_E_NOT_SUPPORTED, m_NotSupportedException), - EL(CLR_E_NOTIMPL, m_NotImplementedException), - EL(CLR_E_NULL_REFERENCE, m_NullReferenceException), - EL(CLR_E_OUT_OF_MEMORY, m_OutOfMemoryException), - EL(CLR_E_TIMEOUT, m_TimeoutException), - EL(CLR_E_OBJECT_DISPOSED, m_ObjectDisposedException), - EL(CLR_E_WATCHDOG_TIMEOUT, m_WatchdogException), + EL(CLR_E_APPDOMAIN_EXITED, AppDomainUnloadedException), + EL(CLR_E_INVALID_PARAMETER, ArgumentException), + EL(CLR_E_ARGUMENT_NULL, ArgumentNullException), + EL(CLR_E_OUT_OF_RANGE, ArgumentOutOfRangeException), + EL(CLR_E_INDEX_OUT_OF_RANGE, IndexOutOfRangeException), + EL(CLR_E_INVALID_CAST, InvalidCastException), + EL(CLR_E_FORMAT_EXCEPTION, FormatException), + EL(CLR_E_INVALID_OPERATION, InvalidOperationException), + EL(CLR_E_NOT_SUPPORTED, NotSupportedException), + EL(CLR_E_NOTIMPL, NotImplementedException), + EL(CLR_E_NULL_REFERENCE, NullReferenceException), + EL(CLR_E_OUT_OF_MEMORY, OutOfMemoryException), + EL(CLR_E_TIMEOUT, TimeoutException), + EL(CLR_E_OBJECT_DISPOSED, ObjectDisposedException), + EL(CLR_E_WATCHDOG_TIMEOUT, WatchdogException), #undef EL }; @@ -50,7 +50,7 @@ HRESULT Library_corlib_native_System_Exception::get_StackTrace___STRING(CLR_RT_S CLR_RT_HeapBlock tmpArray; CLR_RT_HeapBlock *pThis; - tmpArray.SetObjectReference(NULL); + tmpArray.SetObjectReference(nullptr); CLR_RT_ProtectFromGC gc(tmpArray); pThis = stack.This(); @@ -66,9 +66,11 @@ HRESULT Library_corlib_native_System_Exception::get_StackTrace___STRING(CLR_RT_S } if (depth == 0) - NANOCLR_SET_AND_LEAVE(stack.SetResult_String(NULL)); + { + NANOCLR_SET_AND_LEAVE(stack.SetResult_String(nullptr)); + } - NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_Array::CreateInstance(tmpArray, depth, g_CLR_RT_WellKnownTypes.m_String)); + NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_Array::CreateInstance(tmpArray, depth, g_CLR_RT_WellKnownTypes.String)); pStackTrace = (StackTrace *)pArray->GetFirstElement(); pBlkString = (CLR_RT_HeapBlock *)tmpArray.DereferenceArray()->GetFirstElement(); @@ -78,7 +80,7 @@ HRESULT Library_corlib_native_System_Exception::get_StackTrace___STRING(CLR_RT_S strName = &buf[0]; iName = MAXSTRLEN(buf) - 2; - NANOCLR_CHECK_HRESULT(g_CLR_RT_TypeSystem.BuildMethodName(pStackTrace->m_md, strName, iName)); + NANOCLR_CHECK_HRESULT(g_CLR_RT_TypeSystem.BuildMethodName(pStackTrace->m_md, nullptr, strName, iName)); memcpy(strName, "\r\n\0", 3); @@ -119,7 +121,7 @@ HRESULT Library_corlib_native_System_Exception::CreateInstance( CLR_RT_HeapBlock *obj; - _ASSERTE(CLR_RT_ExecutionEngine::IsInstanceOf(cls, g_CLR_RT_WellKnownTypes.m_Exception)); + _ASSERTE(CLR_RT_ExecutionEngine::IsInstanceOf(cls, g_CLR_RT_WellKnownTypes.Exception)); if (FAILED(hr = g_CLR_RT_ExecutionEngine.NewObjectFromIndex(ref, cls))) { @@ -155,7 +157,7 @@ HRESULT Library_corlib_native_System_Exception::CreateInstance( CLR_RT_StackFrame *stack) { NATIVE_PROFILE_CLR_CORE(); - CLR_RT_TypeDef_Index *cls = &g_CLR_RT_WellKnownTypes.m_Exception; + CLR_RT_TypeDef_Index *cls = &g_CLR_RT_WellKnownTypes.Exception; _ASSERTE(FAILED(hrIn)); @@ -185,7 +187,7 @@ HRESULT Library_corlib_native_System_Exception::SetStackTrace(CLR_RT_HeapBlock & if (stack) { - if (CLR_RT_ExecutionEngine::IsInstanceOf(ref, g_CLR_RT_WellKnownTypes.m_Exception) == false) + if (CLR_RT_ExecutionEngine::IsInstanceOf(ref, g_CLR_RT_WellKnownTypes.Exception) == false) { NANOCLR_SET_AND_LEAVE(CLR_E_WRONG_TYPE); } @@ -203,10 +205,8 @@ HRESULT Library_corlib_native_System_Exception::SetStackTrace(CLR_RT_HeapBlock & (void)array; // create an empty array for the stack trace - NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_Array::CreateInstance( - obj[FIELD___stackTrace], - depth, - g_CLR_RT_WellKnownTypes.m_UInt8)); + NANOCLR_CHECK_HRESULT( + CLR_RT_HeapBlock_Array::CreateInstance(obj[FIELD___stackTrace], depth, g_CLR_RT_WellKnownTypes.UInt8)); } else { @@ -222,7 +222,7 @@ HRESULT Library_corlib_native_System_Exception::SetStackTrace(CLR_RT_HeapBlock & NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_Array::CreateInstance( obj[FIELD___stackTrace], depth * sizeof(StackTrace), - g_CLR_RT_WellKnownTypes.m_UInt8)); + g_CLR_RT_WellKnownTypes.UInt8)); // get a pointer to the array array = obj[FIELD___stackTrace].DereferenceArray(); @@ -254,7 +254,7 @@ HRESULT Library_corlib_native_System_Exception::SetStackTrace(CLR_RT_HeapBlock & // create an empty array for the stack trace NANOCLR_CHECK_HRESULT( - CLR_RT_HeapBlock_Array::CreateInstance(obj[FIELD___stackTrace], depth, g_CLR_RT_WellKnownTypes.m_UInt8)); + CLR_RT_HeapBlock_Array::CreateInstance(obj[FIELD___stackTrace], depth, g_CLR_RT_WellKnownTypes.UInt8)); #endif } @@ -265,7 +265,7 @@ HRESULT Library_corlib_native_System_Exception::SetStackTrace(CLR_RT_HeapBlock & CLR_RT_HeapBlock *Library_corlib_native_System_Exception::GetTarget(CLR_RT_HeapBlock &ref) { NATIVE_PROFILE_CLR_CORE(); - return CLR_RT_ExecutionEngine::IsInstanceOf(ref, g_CLR_RT_WellKnownTypes.m_Exception) ? ref.Dereference() : NULL; + return CLR_RT_ExecutionEngine::IsInstanceOf(ref, g_CLR_RT_WellKnownTypes.Exception) ? ref.Dereference() : nullptr; } Library_corlib_native_System_Exception::StackTrace *Library_corlib_native_System_Exception::GetStackTrace( @@ -287,5 +287,5 @@ Library_corlib_native_System_Exception::StackTrace *Library_corlib_native_System depth = 0; - return NULL; + return nullptr; } diff --git a/src/CLR/CorLib/corlib_native_System_GC.cpp b/src/CLR/CorLib/corlib_native_System_GC.cpp index 41cf8bf61c..d2d4b9fe48 100644 --- a/src/CLR/CorLib/corlib_native_System_GC.cpp +++ b/src/CLR/CorLib/corlib_native_System_GC.cpp @@ -1,54 +1,97 @@ -// +// // Copyright (c) .NET Foundation and Contributors // Portions Copyright (c) Microsoft Corporation. All rights reserved. // See LICENSE file in the project root for full license information. // #include "CorLib.h" -HRESULT Library_corlib_native_System_GC::AnyPendingFinalizers___STATIC__BOOLEAN(CLR_RT_StackFrame &stack) +HRESULT Library_corlib_native_System_GC::EnableGCMessages___STATIC__VOID__BOOLEAN(CLR_RT_StackFrame &stack) { NATIVE_PROFILE_CLR_CORE(); + NANOCLR_HEADER(); - stack.SetResult_Boolean( - g_CLR_RT_ExecutionEngine.m_finalizersPending.IsEmpty() == false || - (g_CLR_RT_ExecutionEngine.m_finalizerThread != NULL && - !g_CLR_RT_ExecutionEngine.m_finalizerThread->CanThreadBeReused())); +#if defined(NANOCLR_TRACE_MEMORY_STATS) + s_CLR_RT_fTrace_MemoryStats = stack.Arg0().NumericByRefConst().u1 != 0 ? c_CLR_RT_Trace_Info : c_CLR_RT_Trace_None; +#else + (void)stack; +#endif NANOCLR_NOCLEANUP_NOLABEL(); } -HRESULT Library_corlib_native_System_GC::SuppressFinalize___STATIC__VOID__OBJECT(CLR_RT_StackFrame &stack) +HRESULT Library_corlib_native_System_GC::ReRegisterForFinalize___STATIC__VOID__OBJECT(CLR_RT_StackFrame &stack) { NATIVE_PROFILE_CLR_CORE(); NANOCLR_HEADER(); + CLR_RT_TypeDescriptor desc{}; CLR_RT_HeapBlock *pObj = stack.Arg0().Dereference(); FAULT_ON_NULL(pObj); CLR_RT_HeapBlock_Finalizer::SuppressFinalize(pObj); + NANOCLR_CHECK_HRESULT(desc.InitializeFromObject(stack.Arg0())); + + if (desc.m_handlerCls.HasFinalizer()) + { + NANOCLR_CHECK_HRESULT( + CLR_RT_HeapBlock_Finalizer::CreateInstance(stack.Arg0().Dereference(), desc.m_handlerCls)); + } + NANOCLR_NOCLEANUP(); } -HRESULT Library_corlib_native_System_GC::ReRegisterForFinalize___STATIC__VOID__OBJECT(CLR_RT_StackFrame &stack) +HRESULT Library_corlib_native_System_GC::SuppressFinalize___STATIC__VOID__OBJECT(CLR_RT_StackFrame &stack) { NATIVE_PROFILE_CLR_CORE(); NANOCLR_HEADER(); - CLR_RT_TypeDescriptor desc{}; CLR_RT_HeapBlock *pObj = stack.Arg0().Dereference(); FAULT_ON_NULL(pObj); CLR_RT_HeapBlock_Finalizer::SuppressFinalize(pObj); - NANOCLR_CHECK_HRESULT(desc.InitializeFromObject(stack.Arg0())); + NANOCLR_NOCLEANUP(); +} - if (desc.m_handlerCls.HasFinalizer()) +HRESULT Library_corlib_native_System_GC::AnyPendingFinalizers___STATIC__BOOLEAN(CLR_RT_StackFrame &stack) +{ + NATIVE_PROFILE_CLR_CORE(); + NANOCLR_HEADER(); + + stack.SetResult_Boolean( + g_CLR_RT_ExecutionEngine.m_finalizersPending.IsEmpty() == false || + (g_CLR_RT_ExecutionEngine.m_finalizerThread != nullptr && + !g_CLR_RT_ExecutionEngine.m_finalizerThread->CanThreadBeReused())); + + NANOCLR_NOCLEANUP_NOLABEL(); +} + +HRESULT Library_corlib_native_System_GC::Run___STATIC__U4__BOOLEAN(CLR_RT_StackFrame &stack) +{ + NATIVE_PROFILE_CLR_CORE(); + + NANOCLR_HEADER(); + +#if defined(NANOCLR_GC_VERBOSE) + if (s_CLR_RT_fTrace_GC >= c_CLR_RT_Trace_Info) { - NANOCLR_CHECK_HRESULT( - CLR_RT_HeapBlock_Finalizer::CreateInstance(stack.Arg0().Dereference(), desc.m_handlerCls)); + CLR_Debug::Printf(" Memory: Debug.GC.\r\n"); } +#endif - NANOCLR_NOCLEANUP(); + stack.SetResult_I4(g_CLR_RT_ExecutionEngine.PerformGarbageCollection()); + + if (stack.Arg0().NumericByRefConst().u1) + { + // + // Decrement the number of GC, otherwise the outer loop may request another compaction. + // + g_CLR_RT_GarbageCollector.m_numberOfGarbageCollections--; + + g_CLR_RT_ExecutionEngine.PerformHeapCompaction(); + } + + NANOCLR_NOCLEANUP_NOLABEL(); } diff --git a/src/CLR/CorLib/corlib_native_System_Guid.cpp b/src/CLR/CorLib/corlib_native_System_Guid.cpp index cac42f7c49..064991d42d 100644 --- a/src/CLR/CorLib/corlib_native_System_Guid.cpp +++ b/src/CLR/CorLib/corlib_native_System_Guid.cpp @@ -11,24 +11,23 @@ // Based on the version 4 GUID (random) // http://guid.one/guid/make - -HRESULT Library_corlib_native_System_Guid::GenerateNewGuid___STATIC__SZARRAY_U1( CLR_RT_StackFrame& stack ) +HRESULT Library_corlib_native_System_Guid::GenerateNewGuid___STATIC__SZARRAY_U1(CLR_RT_StackFrame &stack) { NANOCLR_HEADER(); - CLR_RT_Random rand; - CLR_UINT8* buf; - CLR_RT_HeapBlock& top = stack.PushValueAndClear(); - + CLR_RT_Random rand; + CLR_UINT8 *buf; + CLR_RT_HeapBlock &top = stack.PushValueAndClear(); + // Create a array of 16 bytes on top of stack to return - NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_Array::CreateInstance( top, 16, g_CLR_RT_WellKnownTypes.m_UInt8 )); + NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_Array::CreateInstance(top, 16, g_CLR_RT_WellKnownTypes.UInt8)); buf = top.DereferenceArray()->GetFirstElement(); rand.Initialize(); - rand.NextBytes(buf, 16); // fill with random numbers + rand.NextBytes(buf, 16); // fill with random numbers + + buf[7] = (buf[7] & 0x0f) | 0x40; // Set verion + buf[9] = (buf[7] & 0x3f) | 0x80; // Set variant - buf[7] = (buf[7] & 0x0f) | 0x40; // Set verion - buf[9] = (buf[7] & 0x3f) | 0x80; // Set variant - NANOCLR_NOCLEANUP(); } diff --git a/src/CLR/CorLib/corlib_native_System_Number.cpp b/src/CLR/CorLib/corlib_native_System_Number.cpp index 34a9939a03..d00db8d3be 100644 --- a/src/CLR/CorLib/corlib_native_System_Number.cpp +++ b/src/CLR/CorLib/corlib_native_System_Number.cpp @@ -16,7 +16,7 @@ bool Library_corlib_native_System_Number::ParseFormat(char *format, char *format bool ret = true; // parse received format - if (format != NULL && format[0] != 0) + if (format != nullptr && format[0] != 0) { *formatChar = format[0]; *precision = -1; @@ -83,7 +83,7 @@ int Library_corlib_native_System_Number::DoPrintfOnDataType(char *buffer, char * { int ret = -1; - CLR_DataType dataType = value->DataType(); + NanoCLRDataType dataType = value->DataType(); switch (dataType) { @@ -133,7 +133,7 @@ int Library_corlib_native_System_Number::DoPrintfOnDataType(char *buffer, char * return ret; } -const char *Library_corlib_native_System_Number::GetPrintfLengthModifier(CLR_DataType dataType) +const char *Library_corlib_native_System_Number::GetPrintfLengthModifier(NanoCLRDataType dataType) { const char *ret = (dataType == DATATYPE_I1 || dataType == DATATYPE_U1) ? "" : (dataType == DATATYPE_I2 || dataType == DATATYPE_U2) ? "" @@ -143,21 +143,21 @@ const char *Library_corlib_native_System_Number::GetPrintfLengthModifier(CLR_Dat return ret; } -bool Library_corlib_native_System_Number::IsSignedIntegerDataType(CLR_DataType dataType) +bool Library_corlib_native_System_Number::IsSignedIntegerDataType(NanoCLRDataType dataType) { bool ret = (dataType == DATATYPE_I1 || dataType == DATATYPE_I2 || dataType == DATATYPE_I4 || dataType == DATATYPE_I8); return ret; } -bool Library_corlib_native_System_Number::IsUnsignedIntegerDataType(CLR_DataType dataType) +bool Library_corlib_native_System_Number::IsUnsignedIntegerDataType(NanoCLRDataType dataType) { bool ret = (dataType == DATATYPE_U1 || dataType == DATATYPE_U2 || dataType == DATATYPE_U4 || dataType == DATATYPE_U8); return ret; } -bool Library_corlib_native_System_Number::IsIntegerDataType(CLR_DataType dataType) +bool Library_corlib_native_System_Number::IsIntegerDataType(NanoCLRDataType dataType) { bool ret = IsSignedIntegerDataType(dataType) || IsUnsignedIntegerDataType(dataType); return ret; @@ -328,7 +328,7 @@ int Library_corlib_native_System_Number::Format_G( { int ret = -1; - CLR_DataType dataType = value->DataType(); + NanoCLRDataType dataType = value->DataType(); bool isIntegerDataType = IsIntegerDataType(dataType); @@ -590,7 +590,7 @@ int Library_corlib_native_System_Number::Format_D( { int ret = -1; - CLR_DataType dataType = value->DataType(); + NanoCLRDataType dataType = value->DataType(); if (precision == -1) { @@ -631,7 +631,7 @@ int Library_corlib_native_System_Number::Format_X(char *buffer, CLR_RT_HeapBlock { int ret = -1; - CLR_DataType dataType = value->DataType(); + NanoCLRDataType dataType = value->DataType(); // set max width for the conversion int maxWidth = 0; @@ -701,7 +701,7 @@ int Library_corlib_native_System_Number::Format_F( // NF at the moment } - CLR_DataType dataType = value->DataType(); + NanoCLRDataType dataType = value->DataType(); bool isIntegerDataType = IsIntegerDataType(dataType); @@ -815,7 +815,7 @@ int Library_corlib_native_System_Number::Format_E(char *buffer, CLR_RT_HeapBlock // force extra precision to account for rounding errors precision = requestedPrecision + 1; - CLR_DataType dataType = value->DataType(); + NanoCLRDataType dataType = value->DataType(); char formatStr[FORMAT_FMTSTR_BUFFER_SIZE]; double copyValue = 0.0; diff --git a/src/CLR/CorLib/corlib_native_System_Object.cpp b/src/CLR/CorLib/corlib_native_System_Object.cpp index 1649352946..cb67b1c16d 100644 --- a/src/CLR/CorLib/corlib_native_System_Object.cpp +++ b/src/CLR/CorLib/corlib_native_System_Object.cpp @@ -35,7 +35,7 @@ HRESULT Library_corlib_native_System_Object::GetType___SystemType(CLR_RT_StackFr NANOCLR_HEADER(); CLR_RT_TypeDescriptor desc{}; - CLR_RT_ReflectionDef_Index idx; + CLR_RT_ReflectionDef_Index index; CLR_RT_HeapBlock &arg0 = stack.Arg0(); CLR_RT_HeapBlock *pObj; @@ -45,23 +45,23 @@ HRESULT Library_corlib_native_System_Object::GetType___SystemType(CLR_RT_StackFr if (pObj && arg0.DataType() == DATATYPE_REFLECTION) { - idx.m_kind = REFLECTION_TYPE; - idx.m_levels = 0; - idx.m_data.m_type.m_data = desc.m_handlerCls.m_data; + index.kind = REFLECTION_TYPE; + index.levels = 0; + index.data.type.data = desc.m_handlerCls.data; } else { - idx = desc.m_reflex; + index = desc.m_reflex; } { CLR_RT_HeapBlock &top = stack.PushValue(); CLR_RT_HeapBlock *hbObj; - NANOCLR_CHECK_HRESULT(g_CLR_RT_ExecutionEngine.NewObjectFromIndex(top, g_CLR_RT_WellKnownTypes.m_TypeStatic)); + NANOCLR_CHECK_HRESULT(g_CLR_RT_ExecutionEngine.NewObjectFromIndex(top, g_CLR_RT_WellKnownTypes.TypeStatic)); hbObj = top.Dereference(); - hbObj->SetReflection(idx); + hbObj->SetReflection(index); } NANOCLR_NOCLEANUP(); diff --git a/src/CLR/CorLib/corlib_native_System_Random.cpp b/src/CLR/CorLib/corlib_native_System_Random.cpp index 4720d003df..6a67771531 100644 --- a/src/CLR/CorLib/corlib_native_System_Random.cpp +++ b/src/CLR/CorLib/corlib_native_System_Random.cpp @@ -115,8 +115,12 @@ HRESULT Library_corlib_native_System_Random::GetRandom(CLR_RT_StackFrame &stack, if (create) { - NANOCLR_CHECK_HRESULT( - CLR_RT_HeapBlock_BinaryBlob::CreateInstance(pThis[FIELD___random], sizeof(CLR_RT_Random), NULL, NULL, 0)); + NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_BinaryBlob::CreateInstance( + pThis[FIELD___random], + sizeof(CLR_RT_Random), + nullptr, + nullptr, + 0)); } rand = (CLR_RT_Random *)pThis[FIELD___random].DereferenceBinaryBlob()->GetData(); diff --git a/src/CLR/CorLib/corlib_native_System_Reflection_Assembly.cpp b/src/CLR/CorLib/corlib_native_System_Reflection_Assembly.cpp index daebabd07b..d43ca996ee 100644 --- a/src/CLR/CorLib/corlib_native_System_Reflection_Assembly.cpp +++ b/src/CLR/CorLib/corlib_native_System_Reflection_Assembly.cpp @@ -19,23 +19,22 @@ HRESULT Library_corlib_native_System_Reflection_Assembly::get_FullName___STRING( NANOCLR_CHECK_HRESULT(GetTypeDescriptor(*hbAsm, instance)); - assm = instance.m_assm; - header = assm->m_header; + assm = instance.assembly; + header = assm->header; - if (hal_strlen_s(assm->m_szName) > NANOCLR_MAX_ASSEMBLY_NAME) + if (hal_strlen_s(assm->name) > NANOCLR_MAX_ASSEMBLY_NAME) { NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER); } - snprintf( + sprintf( buffer, - ARRAYSIZE(buffer), "%s, Version=%d.%d.%d.%d", - assm->m_szName, - header->version.iMajorVersion, - header->version.iMinorVersion, - header->version.iBuildNumber, - header->version.iRevisionNumber); + assm->name, + header->version.majorVersion, + header->version.minorVersion, + header->version.buildNumber, + header->version.revisionNumber); stack.SetResult_String(buffer); @@ -62,10 +61,9 @@ HRESULT Library_corlib_native_System_Reflection_Assembly::GetType___SystemType__ hbRef = &stack.PushValueAndClear(); - if (g_CLR_RT_TypeSystem.FindTypeDef(szClass, assm.m_assm, td)) + if (g_CLR_RT_TypeSystem.FindTypeDef(szClass, assm.assembly, td)) { - NANOCLR_CHECK_HRESULT( - g_CLR_RT_ExecutionEngine.NewObjectFromIndex(*hbRef, g_CLR_RT_WellKnownTypes.m_TypeStatic)); + NANOCLR_CHECK_HRESULT(g_CLR_RT_ExecutionEngine.NewObjectFromIndex(*hbRef, g_CLR_RT_WellKnownTypes.TypeStatic)); hbObj = hbRef->Dereference(); hbObj->SetReflection(td); @@ -85,27 +83,27 @@ HRESULT Library_corlib_native_System_Reflection_Assembly::GetTypes___SZARRAY_Sys NANOCLR_CHECK_HRESULT(GetTypeDescriptor(*hbAsm, assm)); { - CLR_RT_Assembly *pASSM = assm.m_assm; - CLR_UINT32 num = pASSM->m_pTablesSize[TBL_TypeDef]; + CLR_RT_Assembly *pASSM = assm.assembly; + CLR_UINT32 num = pASSM->tablesSize[TBL_TypeDef]; CLR_RT_HeapBlock &top = stack.PushValue(); CLR_RT_HeapBlock *hbObj; - NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_Array::CreateInstance(top, num, g_CLR_RT_WellKnownTypes.m_TypeStatic)); + NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_Array::CreateInstance(top, num, g_CLR_RT_WellKnownTypes.TypeStatic)); if (num) { - CLR_RT_HeapBlock *pArray = (CLR_RT_HeapBlock *)top.DereferenceArray()->GetFirstElement(); + auto *pArray = (CLR_RT_HeapBlock *)top.DereferenceArray()->GetFirstElement(); for (CLR_UINT32 i = 0; i < num; i++, pArray++) { - CLR_RT_TypeDef_Index idx; - idx.Set(pASSM->m_idx, i); + CLR_RT_TypeDef_Index index; + index.Set(pASSM->assemblyIndex, i); NANOCLR_CHECK_HRESULT( - g_CLR_RT_ExecutionEngine.NewObjectFromIndex(*pArray, g_CLR_RT_WellKnownTypes.m_TypeStatic)); + g_CLR_RT_ExecutionEngine.NewObjectFromIndex(*pArray, g_CLR_RT_WellKnownTypes.TypeStatic)); hbObj = pArray->Dereference(); - hbObj->SetReflection(idx); + hbObj->SetReflection(index); } } } @@ -120,7 +118,7 @@ HRESULT Library_corlib_native_System_Reflection_Assembly::GetVersion___VOID__BYR NANOCLR_HEADER(); CLR_RT_StackFrame *caller = stack.Caller(); - if (caller == NULL) + if (caller == nullptr) { NANOCLR_SET_AND_LEAVE(S_OK); } @@ -131,13 +129,13 @@ HRESULT Library_corlib_native_System_Reflection_Assembly::GetVersion___VOID__BYR NANOCLR_CHECK_HRESULT(GetTypeDescriptor(*hbAsm, assm)); - const CLR_RECORD_VERSION &version = assm.m_assm->m_header->version; + const CLR_RECORD_VERSION &version = assm.assembly->header->version; - // we do not check for the reference not to be NULL because this is an internal method - stack.Arg1().Dereference()->NumericByRef().s4 = version.iMajorVersion; - stack.Arg2().Dereference()->NumericByRef().s4 = version.iMinorVersion; - stack.Arg3().Dereference()->NumericByRef().s4 = version.iBuildNumber; - stack.Arg4().Dereference()->NumericByRef().s4 = version.iRevisionNumber; + // we do not check for the reference not to be nullptr because this is an internal method + stack.Arg1().Dereference()->NumericByRef().s4 = version.majorVersion; + stack.Arg2().Dereference()->NumericByRef().s4 = version.minorVersion; + stack.Arg3().Dereference()->NumericByRef().s4 = version.buildNumber; + stack.Arg4().Dereference()->NumericByRef().s4 = version.revisionNumber; } NANOCLR_NOCLEANUP(); } @@ -154,20 +152,21 @@ HRESULT Library_corlib_native_System_Reflection_Assembly::GetManifestResourceNam NANOCLR_CHECK_HRESULT(GetTypeDescriptor(*hbAsm, assm)); { - CLR_RT_Assembly *pAssm = assm.m_assm; + CLR_RT_Assembly *pAssm = assm.assembly; CLR_RT_HeapBlock &result = stack.PushValue(); NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_Array::CreateInstance( result, - pAssm->m_pTablesSize[TBL_ResourcesFiles], - g_CLR_RT_WellKnownTypes.m_String)); + pAssm->tablesSize[TBL_ResourcesFiles], + g_CLR_RT_WellKnownTypes.String)); { - CLR_RT_HeapBlock *pArray = (CLR_RT_HeapBlock *)result.Array()->GetFirstElement(); + auto *pArray = (CLR_RT_HeapBlock *)result.Array()->GetFirstElement(); - for (int idxResourceFile = 0; idxResourceFile < pAssm->m_pTablesSize[TBL_ResourcesFiles]; idxResourceFile++) + for (int indexResourceFile = 0; indexResourceFile < pAssm->tablesSize[TBL_ResourcesFiles]; + indexResourceFile++) { - const CLR_RECORD_RESOURCE_FILE *resourceFile = pAssm->GetResourceFile(idxResourceFile); + const CLR_RECORD_RESOURCE_FILE *resourceFile = pAssm->GetResourceFile(indexResourceFile); NANOCLR_CHECK_HRESULT( CLR_RT_HeapBlock_String::CreateInstance(*pArray, pAssm->GetString(resourceFile->name))); @@ -190,17 +189,17 @@ HRESULT Library_corlib_native_System_Reflection_Assembly::GetExecutingAssembly__ CLR_RT_HeapBlock *hbObj; CLR_RT_StackFrame *caller = stack.Caller(); - if (caller == NULL) + if (caller == nullptr) NANOCLR_SET_AND_LEAVE(S_OK); { - CLR_RT_Assembly_Index idx; - idx.Set(caller->MethodCall().m_assm->m_idx); + CLR_RT_Assembly_Index index; + index.Set(caller->MethodCall().assembly->assemblyIndex); - NANOCLR_CHECK_HRESULT(g_CLR_RT_ExecutionEngine.NewObjectFromIndex(top, g_CLR_RT_WellKnownTypes.m_Assembly)); + NANOCLR_CHECK_HRESULT(g_CLR_RT_ExecutionEngine.NewObjectFromIndex(top, g_CLR_RT_WellKnownTypes.Assembly)); hbObj = top.Dereference(); - hbObj->SetReflection(idx); + hbObj->SetReflection(index); } NANOCLR_NOCLEANUP(); @@ -219,7 +218,7 @@ HRESULT Library_corlib_native_System_Reflection_Assembly:: CLR_RT_HeapBlock *hbObj; CLR_RT_Assembly *assembly; const char *szAssembly; - CLR_RT_Assembly_Index idx; + CLR_RT_Assembly_Index index; bool fVersion; CLR_INT16 maj, min, build, rev; CLR_RT_HeapBlock &top = stack.PushValueAndClear(); @@ -241,33 +240,33 @@ HRESULT Library_corlib_native_System_Reflection_Assembly:: { CLR_RECORD_VERSION ver; - ver.iMajorVersion = (CLR_UINT16)maj; - ver.iMinorVersion = (CLR_UINT16)min; - ver.iBuildNumber = (CLR_UINT16)build; - ver.iRevisionNumber = (CLR_UINT16)rev; + ver.majorVersion = (CLR_UINT16)maj; + ver.minorVersion = (CLR_UINT16)min; + ver.buildNumber = (CLR_UINT16)build; + ver.revisionNumber = (CLR_UINT16)rev; assembly = g_CLR_RT_TypeSystem.FindAssembly(szAssembly, &ver, true); FAULT_ON_NULL_HR(assembly, CLR_E_INVALID_PARAMETER); } else { - assembly = g_CLR_RT_TypeSystem.FindAssembly(szAssembly, NULL, false); + assembly = g_CLR_RT_TypeSystem.FindAssembly(szAssembly, nullptr, false); FAULT_ON_NULL_HR(assembly, CLR_E_INVALID_PARAMETER); } #if defined(NANOCLR_APPDOMAINS) NANOCLR_CHECK_HRESULT(appDomain->LoadAssembly(assembly)); #endif - idx.Set(assembly->m_idx); + index.Set(assembly->assemblyIndex); - NANOCLR_CHECK_HRESULT(g_CLR_RT_ExecutionEngine.NewObjectFromIndex(top, g_CLR_RT_WellKnownTypes.m_Assembly)); + NANOCLR_CHECK_HRESULT(g_CLR_RT_ExecutionEngine.NewObjectFromIndex(top, g_CLR_RT_WellKnownTypes.Assembly)); hbObj = top.Dereference(); - hbObj->SetReflection(idx); + hbObj->SetReflection(index); NANOCLR_CLEANUP(); - // Avoid exception handling in common case. Just return NULL on failure. + // Avoid exception handling in common case. Just return nullptr on failure. // Managed code decides to throw the exception or not. hr = S_OK; @@ -280,8 +279,8 @@ HRESULT Library_corlib_native_System_Reflection_Assembly::Load___STATIC__SystemR NATIVE_PROFILE_CLR_CORE(); NANOCLR_HEADER(); - CLR_RT_HeapBlock_Array *array = NULL; - CLR_RT_Assembly *assm = NULL; + CLR_RT_HeapBlock_Array *array = nullptr; + CLR_RT_Assembly *assm = nullptr; CLR_RT_HeapBlock *hbObj; CLR_RECORD_ASSEMBLY *header; CLR_RT_Assembly_Index assemblyIndex; @@ -306,17 +305,9 @@ HRESULT Library_corlib_native_System_Reflection_Assembly::Load___STATIC__SystemR { if (header->GoodAssembly()) { - // - // Sorry, you'll have to reboot to load this assembly. - // - if (header->flags & CLR_RECORD_ASSEMBLY::c_Flags_NeedReboot) - { - NANOCLR_SET_AND_LEAVE(CLR_E_BUSY); - } - NANOCLR_CHECK_HRESULT(CLR_RT_Assembly::CreateInstance(header, assm)); - assm->m_pFile = array; + assm->file = array; g_CLR_RT_TypeSystem.Link(assm); @@ -324,7 +315,7 @@ HRESULT Library_corlib_native_System_Reflection_Assembly::Load___STATIC__SystemR NANOCLR_CHECK_HRESULT(g_CLR_RT_TypeSystem.PrepareForExecution()); CLR_RT_MethodDef_Index idx; - idx.Set(assm->m_idx, 0); + idx.Set(assm->assemblyIndex, 0); if (assm->FindNextStaticConstructor(idx)) { @@ -341,7 +332,7 @@ HRESULT Library_corlib_native_System_Reflection_Assembly::Load___STATIC__SystemR } // push assembly index onto the eval stack - stack.PushValueU4(assm->m_idx); + stack.PushValueU4(assm->assemblyIndex); } else { @@ -356,7 +347,7 @@ HRESULT Library_corlib_native_System_Reflection_Assembly::Load___STATIC__SystemR while (eventResult) { - if (assm->m_flags & CLR_RT_Assembly::StaticConstructorsExecuted) + if (assm->flags & CLR_RT_Assembly::StaticConstructorsExecuted) { // static constructors executed, we are good here break; @@ -381,7 +372,7 @@ HRESULT Library_corlib_native_System_Reflection_Assembly::Load___STATIC__SystemR stack.PopValue(); NANOCLR_CHECK_HRESULT( - g_CLR_RT_ExecutionEngine.NewObjectFromIndex(stack.PushValue(), g_CLR_RT_WellKnownTypes.m_Assembly)); + g_CLR_RT_ExecutionEngine.NewObjectFromIndex(stack.PushValue(), g_CLR_RT_WellKnownTypes.Assembly)); hbObj = stack.TopValue().Dereference(); hbObj->SetReflection(assemblyIndex); diff --git a/src/CLR/CorLib/corlib_native_System_Reflection_ConstructorInfo.cpp b/src/CLR/CorLib/corlib_native_System_Reflection_ConstructorInfo.cpp index 384ae2fd76..3764fda8c6 100644 --- a/src/CLR/CorLib/corlib_native_System_Reflection_ConstructorInfo.cpp +++ b/src/CLR/CorLib/corlib_native_System_Reflection_ConstructorInfo.cpp @@ -24,10 +24,10 @@ HRESULT Library_corlib_native_System_Reflection_ConstructorInfo::Invoke___OBJECT CLR_RT_HeapBlock *thisRef = stack.ThisRef().Dereference(); CLR_RT_MethodDef_Instance md{}; CLR_RT_HeapBlock_Array *pArray = stack.Arg1().DereferenceArray(); - CLR_RT_HeapBlock *args = NULL; - int numArgs = 0; + CLR_RT_HeapBlock *args = nullptr; + int ArgumentsCount = 0; - if (md.InitializeFromIndex(thisRef->ReflectionDataConst().m_data.m_method) == false) + if (md.InitializeFromIndex(thisRef->ReflectionDataConst().data.method) == false) NANOCLR_SET_AND_LEAVE(CLR_E_NULL_REFERENCE); if (stack.m_customState == 0) @@ -37,10 +37,10 @@ HRESULT Library_corlib_native_System_Reflection_ConstructorInfo::Invoke___OBJECT if (pArray) { args = (CLR_RT_HeapBlock *)pArray->GetFirstElement(); - numArgs = pArray->m_numOfElements; + ArgumentsCount = pArray->m_numOfElements; } - NANOCLR_CHECK_HRESULT(stack.MakeCall(md, NULL, args, numArgs)); + NANOCLR_CHECK_HRESULT(stack.MakeCall(md, nullptr, args, ArgumentsCount)); } NANOCLR_NOCLEANUP(); diff --git a/src/CLR/CorLib/corlib_native_System_Reflection_FieldInfo.cpp b/src/CLR/CorLib/corlib_native_System_Reflection_FieldInfo.cpp index 326c4d035f..dc94df6c3a 100644 --- a/src/CLR/CorLib/corlib_native_System_Reflection_FieldInfo.cpp +++ b/src/CLR/CorLib/corlib_native_System_Reflection_FieldInfo.cpp @@ -25,7 +25,7 @@ HRESULT Library_corlib_native_System_Reflection_FieldInfo::SetValue___VOID__OBJE NANOCLR_CHECK_HRESULT(Library_corlib_native_System_Reflection_FieldInfo::Initialize(stack, instFD, instTD, obj)); - fd = instFD.m_target; + fd = instFD.target; if (fd->flags & CLR_RECORD_FIELDDEF::FD_NoReflection) // don't allow reflection for fields with NoReflection attribute @@ -36,20 +36,29 @@ HRESULT Library_corlib_native_System_Reflection_FieldInfo::SetValue___VOID__OBJE NANOCLR_CHECK_HRESULT(instTDescObj.InitializeFromFieldDefinition(instFD)); // make sure the right side object is of the same type as the left side - if (NULL != val.Dereference() && !CLR_RT_ExecutionEngine::IsInstanceOf(val, instTDescObj.m_handlerCls)) + if (nullptr != val.Dereference() && !CLR_RT_ExecutionEngine::IsInstanceOf(val, instTDescObj.m_handlerCls)) + { NANOCLR_SET_AND_LEAVE(CLR_E_WRONG_TYPE); + } fValueType = obj->IsAValueType(); + if (fValueType || (c_CLR_RT_DataTypeLookup[obj->DataType()].m_flags & CLR_RT_DataTypeLookup::c_OptimizedValueType)) { - if (val.Dereference() == NULL || !val.Dereference()->IsBoxed()) + if (val.Dereference() == nullptr || !val.Dereference()->IsBoxed()) + { NANOCLR_SET_AND_LEAVE(CLR_E_WRONG_TYPE); + } if (fValueType) { - _ASSERTE(NULL != obj->Dereference()); - if (NULL == obj->Dereference()) + _ASSERTE(nullptr != obj->Dereference()); + + if (nullptr == obj->Dereference()) + { NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER); + } + instTDField.InitializeFromIndex(obj->Dereference()->ObjectCls()); } else @@ -67,7 +76,7 @@ HRESULT Library_corlib_native_System_Reflection_FieldInfo::SetValue___VOID__OBJE if (srcObj.IsTransparentProxy()) { _ASSERTE(srcObj.DataType() == DATATYPE_OBJECT); - _ASSERTE(srcObj.Dereference() != NULL && srcObj.Dereference()->DataType() == DATATYPE_TRANSPARENT_PROXY); + _ASSERTE(srcObj.Dereference() != nullptr && srcObj.Dereference()->DataType() == DATATYPE_TRANSPARENT_PROXY); NANOCLR_CHECK_HRESULT(srcObj.Dereference()->TransparentProxyValidate()); NANOCLR_CHECK_HRESULT(srcObj.Dereference()->TransparentProxyAppDomain()->MarshalObject(val, val)); @@ -107,12 +116,14 @@ HRESULT Library_corlib_native_System_Reflection_FieldInfo::Initialize( NANOCLR_SET_AND_LEAVE(CLR_E_WRONG_TYPE); } - if (instFD.m_target->flags & CLR_RECORD_FIELDDEF::FD_Static) + if (instFD.target->flags & CLR_RECORD_FIELDDEF::FD_Static) { obj = CLR_RT_ExecutionEngine::AccessStaticField(instFD); - if (obj == NULL) + if (obj == nullptr) + { NANOCLR_SET_AND_LEAVE(CLR_E_WRONG_TYPE); + } } else { @@ -123,7 +134,7 @@ HRESULT Library_corlib_native_System_Reflection_FieldInfo::Initialize( NANOCLR_SET_AND_LEAVE(CLR_E_WRONG_TYPE); } - obj = &obj[instFD.CrossReference().m_offset]; + obj = &obj[instFD.CrossReference().offset]; } NANOCLR_NOCLEANUP(); @@ -135,7 +146,7 @@ HRESULT Library_corlib_native_System_Reflection_FieldInfo::GetCustomAttributesNa NANOCLR_HEADER(); CLR_RT_HeapBlock *callerField; - CLR_RT_HeapBlock *returnArray = NULL; + CLR_RT_HeapBlock *returnArray = nullptr; CLR_RT_FieldDef_Instance fieldDefinition; int count = 0; @@ -156,7 +167,7 @@ HRESULT Library_corlib_native_System_Reflection_FieldInfo::GetCustomAttributesNa // the return array has two positions for each attribute: // 1st: the attribute type - // 2nd: the constructor parameters or NULL, if the attribute has no constructor + // 2nd: the constructor parameters or nullptr, if the attribute has no constructor // 1st pass: count attributes do @@ -173,7 +184,7 @@ HRESULT Library_corlib_native_System_Reflection_FieldInfo::GetCustomAttributesNa // create the result array // (2 positions for each attribute) NANOCLR_CHECK_HRESULT( - CLR_RT_HeapBlock_Array::CreateInstance(top, (count * 2), g_CLR_RT_WellKnownTypes.m_Object)); + CLR_RT_HeapBlock_Array::CreateInstance(top, (count * 2), g_CLR_RT_WellKnownTypes.Object)); // use this to skip to the 2nd pass if no attribute was found if (count == 0) diff --git a/src/CLR/CorLib/corlib_native_System_Reflection_MethodBase.cpp b/src/CLR/CorLib/corlib_native_System_Reflection_MethodBase.cpp index 44ad2fcd15..19651b81bc 100644 --- a/src/CLR/CorLib/corlib_native_System_Reflection_MethodBase.cpp +++ b/src/CLR/CorLib/corlib_native_System_Reflection_MethodBase.cpp @@ -18,7 +18,7 @@ HRESULT Library_corlib_native_System_Reflection_MethodBase::get_Name___STRING(CL NANOCLR_CHECK_HRESULT(GetMethodDescriptor(stack, *hbMeth, md)); - NANOCLR_SET_AND_LEAVE(CLR_RT_HeapBlock_String::CreateInstance(stack.PushValue(), md.m_target->name, md.m_assm)); + NANOCLR_SET_AND_LEAVE(CLR_RT_HeapBlock_String::CreateInstance(stack.PushValue(), md.target->name, md.assembly)); NANOCLR_NOCLEANUP(); } @@ -41,7 +41,7 @@ HRESULT Library_corlib_native_System_Reflection_MethodBase::get_DeclaringType___ CLR_RT_HeapBlock &top = stack.PushValue(); CLR_RT_HeapBlock *hbObj; - NANOCLR_CHECK_HRESULT(g_CLR_RT_ExecutionEngine.NewObjectFromIndex(top, g_CLR_RT_WellKnownTypes.m_TypeStatic)); + NANOCLR_CHECK_HRESULT(g_CLR_RT_ExecutionEngine.NewObjectFromIndex(top, g_CLR_RT_WellKnownTypes.TypeStatic)); hbObj = top.Dereference(); hbObj->SetReflection(cls); @@ -111,13 +111,13 @@ HRESULT Library_corlib_native_System_Reflection_MethodBase::Invoke___OBJECT__OBJ CLR_RT_MethodDef_Instance md; const CLR_RECORD_METHODDEF *mdR; CLR_RT_HeapBlock_Array *pArray = stack.Arg2().DereferenceArray(); - CLR_RT_HeapBlock *args = NULL; - int numArgs = 0; + CLR_RT_HeapBlock *args = nullptr; + int argumentsCount = 0; CLR_RT_HeapBlock *hbMeth = stack.This(); NANOCLR_CHECK_HRESULT(GetMethodDescriptor(stack, *hbMeth, md)); - mdR = md.m_target; + mdR = md.target; if (stack.m_customState == 0) { @@ -126,25 +126,25 @@ HRESULT Library_corlib_native_System_Reflection_MethodBase::Invoke___OBJECT__OBJ if (pArray) { args = (CLR_RT_HeapBlock *)pArray->GetFirstElement(); - numArgs = pArray->m_numOfElements; + argumentsCount = pArray->m_numOfElements; } - NANOCLR_CHECK_HRESULT(stack.MakeCall(md, &obj, args, numArgs)); + NANOCLR_CHECK_HRESULT(stack.MakeCall(md, &obj, args, argumentsCount)); } else { - if (mdR->retVal != DATATYPE_VOID) + if (mdR->retValDataType != DATATYPE_VOID) { - if (mdR->retVal < DATATYPE_I4) + if (mdR->retValDataType < DATATYPE_I4) { - stack.TopValue().ChangeDataType(mdR->retVal); + stack.TopValue().ChangeDataType(mdR->retValDataType); } NANOCLR_CHECK_HRESULT(stack.TopValue().PerformBoxingIfNeeded()); } else { - stack.SetResult_Object(NULL); + stack.SetResult_Object(nullptr); } } @@ -178,7 +178,7 @@ HRESULT Library_corlib_native_System_Reflection_MethodBase::CheckFlags( NANOCLR_CHECK_HRESULT(GetMethodDescriptor(stack, *hbMeth, md)); - if ((md.m_target->flags & mask) == flag) + if ((md.target->flags & mask) == flag) { fRes = true; } @@ -211,11 +211,11 @@ HRESULT Library_corlib_native_System_Reflection_MethodBase::GetParametersNative_ CLR_RT_HeapBlock *hbMethodInfo = stack.This(); - idx.m_data = hbMethodInfo[FIELD___token].NumericByRef().u4; + idx.data = hbMethodInfo[FIELD___token].NumericByRef().u4; inst.InitializeFromIndex(idx); // 1st pass: get the number of parameters - sigParser.Initialize_MethodSignature(inst.m_assm, inst.m_target); + sigParser.Initialize_MethodSignature(inst.assembly, inst.target); // discard return value sigParser.Advance(paramElement); @@ -236,7 +236,7 @@ HRESULT Library_corlib_native_System_Reflection_MethodBase::GetParametersNative_ paramInfoElement = (CLR_RT_HeapBlock *)top.DereferenceArray()->GetFirstElement(); // 2nd pass: get the actual type of each parameter - sigParser.Initialize_MethodSignature(inst.m_assm, inst.m_target); + sigParser.Initialize_MethodSignature(inst.assembly, inst.target); // discard return value sigParser.Advance(paramElement); @@ -254,14 +254,14 @@ HRESULT Library_corlib_native_System_Reflection_MethodBase::GetParametersNative_ // create a new instance of the parameter type NANOCLR_CHECK_HRESULT( - g_CLR_RT_ExecutionEngine.NewObjectFromIndex(paraTypeHB, g_CLR_RT_WellKnownTypes.m_TypeStatic)); + g_CLR_RT_ExecutionEngine.NewObjectFromIndex(paraTypeHB, g_CLR_RT_WellKnownTypes.TypeStatic)); hbObj = paraTypeHB.Dereference(); - hbObj->SetReflection(paramElement.m_cls); + hbObj->SetReflection(paramElement.Class); // deal with array types - if (paramElement.m_levels > 0) + if (paramElement.Levels > 0) { - hbObj->ReflectionData().m_levels = (CLR_UINT16)paramElement.m_levels; + hbObj->ReflectionData().levels = (CLR_UINT16)paramElement.Levels; } // move pointer to the next element diff --git a/src/CLR/CorLib/corlib_native_System_Reflection_RuntimeFieldInfo.cpp b/src/CLR/CorLib/corlib_native_System_Reflection_RuntimeFieldInfo.cpp index e7e3336038..588c834a29 100644 --- a/src/CLR/CorLib/corlib_native_System_Reflection_RuntimeFieldInfo.cpp +++ b/src/CLR/CorLib/corlib_native_System_Reflection_RuntimeFieldInfo.cpp @@ -15,7 +15,7 @@ HRESULT Library_corlib_native_System_Reflection_RuntimeFieldInfo::get_Name___STR if (GetFieldDescriptor(stack, *hbField, fd) == false) NANOCLR_SET_AND_LEAVE(CLR_E_NULL_REFERENCE); - NANOCLR_SET_AND_LEAVE(CLR_RT_HeapBlock_String::CreateInstance(stack.PushValue(), fd.m_target->name, fd.m_assm)); + NANOCLR_SET_AND_LEAVE(CLR_RT_HeapBlock_String::CreateInstance(stack.PushValue(), fd.target->name, fd.assembly)); NANOCLR_NOCLEANUP(); } @@ -40,7 +40,7 @@ HRESULT Library_corlib_native_System_Reflection_RuntimeFieldInfo::get_DeclaringT CLR_RT_HeapBlock &top = stack.PushValue(); CLR_RT_HeapBlock *hbObj; - NANOCLR_CHECK_HRESULT(g_CLR_RT_ExecutionEngine.NewObjectFromIndex(top, g_CLR_RT_WellKnownTypes.m_TypeStatic)); + NANOCLR_CHECK_HRESULT(g_CLR_RT_ExecutionEngine.NewObjectFromIndex(top, g_CLR_RT_WellKnownTypes.TypeStatic)); hbObj = top.Dereference(); hbObj->SetReflection(cls); @@ -67,7 +67,7 @@ HRESULT Library_corlib_native_System_Reflection_RuntimeFieldInfo::get_FieldType_ CLR_RT_HeapBlock &top = stack.PushValue(); CLR_RT_HeapBlock *hbObj; - NANOCLR_CHECK_HRESULT(g_CLR_RT_ExecutionEngine.NewObjectFromIndex(top, g_CLR_RT_WellKnownTypes.m_TypeStatic)); + NANOCLR_CHECK_HRESULT(g_CLR_RT_ExecutionEngine.NewObjectFromIndex(top, g_CLR_RT_WellKnownTypes.TypeStatic)); hbObj = top.Dereference(); hbObj->SetReflection(desc.m_handlerCls); } @@ -88,7 +88,7 @@ HRESULT Library_corlib_native_System_Reflection_RuntimeFieldInfo::GetValue___OBJ NANOCLR_CHECK_HRESULT(Library_corlib_native_System_Reflection_FieldInfo::Initialize(stack, instFD, instTD, obj)); - fd = instFD.m_target; + fd = instFD.target; if (fd->flags & CLR_RECORD_FIELDDEF::FD_NoReflection) // don't allow reflection for fields with NoReflection attribute { @@ -108,7 +108,7 @@ HRESULT Library_corlib_native_System_Reflection_RuntimeFieldInfo::GetValue___OBJ argObj = argObj->Dereference(); - _ASSERTE(argObj != NULL && argObj->DataType() == DATATYPE_TRANSPARENT_PROXY); + _ASSERTE(argObj != nullptr && argObj->DataType() == DATATYPE_TRANSPARENT_PROXY); NANOCLR_CHECK_HRESULT(argObj->TransparentProxyValidate()); diff --git a/src/CLR/CorLib/corlib_native_System_Reflection_RuntimeMethodInfo.cpp b/src/CLR/CorLib/corlib_native_System_Reflection_RuntimeMethodInfo.cpp index 285871c34f..6cf73be7ef 100644 --- a/src/CLR/CorLib/corlib_native_System_Reflection_RuntimeMethodInfo.cpp +++ b/src/CLR/CorLib/corlib_native_System_Reflection_RuntimeMethodInfo.cpp @@ -17,7 +17,7 @@ HRESULT Library_corlib_native_System_Reflection_RuntimeMethodInfo::get_ReturnTyp NANOCLR_CHECK_HRESULT(Library_corlib_native_System_Reflection_MethodBase::GetMethodDescriptor(stack, *hbMeth, md)); - parser.Initialize_MethodSignature(md.m_assm, md.m_target); + parser.Initialize_MethodSignature(md.assembly, md.target); NANOCLR_CHECK_HRESULT(desc.InitializeFromSignatureParser(parser)); @@ -25,7 +25,7 @@ HRESULT Library_corlib_native_System_Reflection_RuntimeMethodInfo::get_ReturnTyp CLR_RT_HeapBlock &top = stack.PushValue(); CLR_RT_HeapBlock *hbObj; - NANOCLR_CHECK_HRESULT(g_CLR_RT_ExecutionEngine.NewObjectFromIndex(top, g_CLR_RT_WellKnownTypes.m_TypeStatic)); + NANOCLR_CHECK_HRESULT(g_CLR_RT_ExecutionEngine.NewObjectFromIndex(top, g_CLR_RT_WellKnownTypes.TypeStatic)); hbObj = top.Dereference(); hbObj->SetReflection(desc.m_reflex); } @@ -39,7 +39,7 @@ HRESULT Library_corlib_native_System_Reflection_RuntimeMethodInfo::GetCustomAttr NATIVE_PROFILE_CLR_CORE(); NANOCLR_HEADER(); - CLR_RT_HeapBlock *returnArray = NULL; + CLR_RT_HeapBlock *returnArray = nullptr; CLR_RT_MethodDef_Instance methodDefinition; CLR_RT_HeapBlock *callerMethod; int count = 0; @@ -61,7 +61,7 @@ HRESULT Library_corlib_native_System_Reflection_RuntimeMethodInfo::GetCustomAttr // the return array has two positions for each attribute: // 1st: the attribute type - // 2nd: the constructor parameters or NULL, if the attribute has no constructor + // 2nd: the constructor parameters or nullptr, if the attribute has no constructor // 1st pass: count attributes do @@ -78,7 +78,7 @@ HRESULT Library_corlib_native_System_Reflection_RuntimeMethodInfo::GetCustomAttr // create the result array // (2 positions for each attribute) NANOCLR_CHECK_HRESULT( - CLR_RT_HeapBlock_Array::CreateInstance(top, (count * 2), g_CLR_RT_WellKnownTypes.m_Object)); + CLR_RT_HeapBlock_Array::CreateInstance(top, (count * 2), g_CLR_RT_WellKnownTypes.Object)); // use this to skip to the 2nd pass if no attribute was found if (count == 0) diff --git a/src/CLR/CorLib/corlib_native_System_RuntimeType.cpp b/src/CLR/CorLib/corlib_native_System_RuntimeType.cpp index 8ae8dfe34f..8bb6f14d8e 100644 --- a/src/CLR/CorLib/corlib_native_System_RuntimeType.cpp +++ b/src/CLR/CorLib/corlib_native_System_RuntimeType.cpp @@ -13,17 +13,17 @@ HRESULT Library_corlib_native_System_RuntimeType::get_Assembly___SystemReflectio CLR_RT_TypeDef_Instance td; CLR_RT_HeapBlock *hbType = stack.This(); - NANOCLR_CHECK_HRESULT(GetTypeDescriptor(*hbType, td, NULL)); + NANOCLR_CHECK_HRESULT(GetTypeDescriptor(*hbType, td, nullptr)); { - CLR_RT_Assembly_Index idx{}; - idx.Set(td.Assembly()); + CLR_RT_Assembly_Index index{}; + index.Set(td.Assembly()); CLR_RT_HeapBlock &top = stack.PushValue(); CLR_RT_HeapBlock *hbObj; - NANOCLR_CHECK_HRESULT(g_CLR_RT_ExecutionEngine.NewObjectFromIndex(top, g_CLR_RT_WellKnownTypes.m_Assembly)); + NANOCLR_CHECK_HRESULT(g_CLR_RT_ExecutionEngine.NewObjectFromIndex(top, g_CLR_RT_WellKnownTypes.Assembly)); hbObj = top.Dereference(); - hbObj->SetReflection(idx); + hbObj->SetReflection(index); } NANOCLR_NOCLEANUP(); @@ -67,15 +67,15 @@ HRESULT Library_corlib_native_System_RuntimeType::get_BaseType___SystemType(CLR_ { CLR_RT_HeapBlock *hbObj; - NANOCLR_CHECK_HRESULT(g_CLR_RT_ExecutionEngine.NewObjectFromIndex(top, g_CLR_RT_WellKnownTypes.m_TypeStatic)); + NANOCLR_CHECK_HRESULT(g_CLR_RT_ExecutionEngine.NewObjectFromIndex(top, g_CLR_RT_WellKnownTypes.TypeStatic)); hbObj = top.Dereference(); - hbObj->SetReflection(g_CLR_RT_WellKnownTypes.m_Array); + hbObj->SetReflection(g_CLR_RT_WellKnownTypes.Array); } else if (td.SwitchToParent()) { CLR_RT_HeapBlock *hbObj; - NANOCLR_CHECK_HRESULT(g_CLR_RT_ExecutionEngine.NewObjectFromIndex(top, g_CLR_RT_WellKnownTypes.m_TypeStatic)); + NANOCLR_CHECK_HRESULT(g_CLR_RT_ExecutionEngine.NewObjectFromIndex(top, g_CLR_RT_WellKnownTypes.TypeStatic)); hbObj = top.Dereference(); hbObj->SetReflection(td); } @@ -87,7 +87,13 @@ HRESULT Library_corlib_native_System_RuntimeType:: GetMethods___SZARRAY_SystemReflectionMethodInfo__SystemReflectionBindingFlags(CLR_RT_StackFrame &stack) { NATIVE_PROFILE_CLR_CORE(); - return Library_corlib_native_System_Type::GetMethods(stack, NULL, stack.Arg1().NumericByRef().s4, NULL, 0, true); + return Library_corlib_native_System_Type::GetMethods( + stack, + nullptr, + stack.Arg1().NumericByRef().s4, + nullptr, + 0, + true); } HRESULT Library_corlib_native_System_RuntimeType:: @@ -105,7 +111,7 @@ HRESULT Library_corlib_native_System_RuntimeType:: GetFields___SZARRAY_SystemReflectionFieldInfo__SystemReflectionBindingFlags(CLR_RT_StackFrame &stack) { NATIVE_PROFILE_CLR_CORE(); - return Library_corlib_native_System_Type::GetFields(stack, NULL, stack.Arg1().NumericByRef().s4, true); + return Library_corlib_native_System_Type::GetFields(stack, nullptr, stack.Arg1().NumericByRef().s4, true); } HRESULT Library_corlib_native_System_RuntimeType::GetInterfaces___SZARRAY_SystemType(CLR_RT_StackFrame &stack) @@ -115,7 +121,7 @@ HRESULT Library_corlib_native_System_RuntimeType::GetInterfaces___SZARRAY_System CLR_RT_TypeDef_Instance td; CLR_RT_HeapBlock &top = stack.PushValueAndClear(); - CLR_RT_HeapBlock *ptr = NULL; + CLR_RT_HeapBlock *ptr = nullptr; CLR_RT_HeapBlock *hbType = stack.This(); int count = 0; @@ -128,7 +134,7 @@ HRESULT Library_corlib_native_System_RuntimeType::GetInterfaces___SZARRAY_System { // Scan the list of interfaces. CLR_RT_SignatureParser parser{}; - parser.Initialize_Interfaces(td.m_assm, td.m_target); + parser.Initialize_Interfaces(td.assembly, td.target); CLR_RT_SignatureParser::Element res; // 1. pass count @@ -146,9 +152,9 @@ HRESULT Library_corlib_native_System_RuntimeType::GetInterfaces___SZARRAY_System NANOCLR_CHECK_HRESULT(parser.Advance(res)); NANOCLR_CHECK_HRESULT( - g_CLR_RT_ExecutionEngine.NewObjectFromIndex(*ptr, g_CLR_RT_WellKnownTypes.m_TypeStatic)); + g_CLR_RT_ExecutionEngine.NewObjectFromIndex(*ptr, g_CLR_RT_WellKnownTypes.TypeStatic)); hbObj = ptr->Dereference(); - hbObj->SetReflection(res.m_cls); + hbObj->SetReflection(res.Class); ptr++; count--; @@ -166,7 +172,7 @@ HRESULT Library_corlib_native_System_RuntimeType::GetInterfaces___SZARRAY_System { // create the result array NANOCLR_CHECK_HRESULT( - CLR_RT_HeapBlock_Array::CreateInstance(top, count, g_CLR_RT_WellKnownTypes.m_TypeStatic)); + CLR_RT_HeapBlock_Array::CreateInstance(top, count, g_CLR_RT_WellKnownTypes.TypeStatic)); // don't need the second pass if nothing found if (count == 0) break; @@ -194,7 +200,7 @@ HRESULT Library_corlib_native_System_RuntimeType::GetElementType___SystemType(CL { CLR_RT_HeapBlock *hbObj; - NANOCLR_CHECK_HRESULT(g_CLR_RT_ExecutionEngine.NewObjectFromIndex(top, g_CLR_RT_WellKnownTypes.m_TypeStatic)); + NANOCLR_CHECK_HRESULT(g_CLR_RT_ExecutionEngine.NewObjectFromIndex(top, g_CLR_RT_WellKnownTypes.TypeStatic)); hbObj = top.Dereference(); hbObj->SetReflection(descSub.m_reflex); } @@ -226,7 +232,7 @@ HRESULT Library_corlib_native_System_RuntimeType::GetTypeDescriptor( if (levels > 0) { - inst.InitializeFromIndex(g_CLR_RT_WellKnownTypes.m_Array); + inst.InitializeFromIndex(g_CLR_RT_WellKnownTypes.Array); } NANOCLR_NOCLEANUP(); @@ -263,8 +269,8 @@ HRESULT Library_corlib_native_System_RuntimeType::GetCustomAttributesNative___SZ NATIVE_PROFILE_CLR_CORE(); NANOCLR_HEADER(); - CLR_RT_HeapBlock *returnArray = NULL; - CLR_RT_HeapBlock *callerType = NULL; + CLR_RT_HeapBlock *returnArray = nullptr; + CLR_RT_HeapBlock *callerType = nullptr; CLR_RT_TypeDef_Instance typeDefinition; int count = 0; @@ -282,7 +288,7 @@ HRESULT Library_corlib_native_System_RuntimeType::GetCustomAttributesNative___SZ // the return array has two positions for each attribute: // 1st: the attribute type - // 2nd: the constructor parameters or NULL, if the attribute has no constructor + // 2nd: the constructor parameters or nullptr, if the attribute has no constructor // 1st pass: count attributes do @@ -299,7 +305,7 @@ HRESULT Library_corlib_native_System_RuntimeType::GetCustomAttributesNative___SZ // create the result array // (2 positions for each attribute) NANOCLR_CHECK_HRESULT( - CLR_RT_HeapBlock_Array::CreateInstance(top, (count * 2), g_CLR_RT_WellKnownTypes.m_Object)); + CLR_RT_HeapBlock_Array::CreateInstance(top, (count * 2), g_CLR_RT_WellKnownTypes.Object)); // use this to skip the 2nd pass if no attribute was found if (count == 0) @@ -352,7 +358,7 @@ HRESULT Library_corlib_native_System_RuntimeType::GetCustomAttributes( // parse next attribute, if there is another NANOCLR_CHECK_HRESULT(parser.Next(val)); - if (val == NULL) + if (val == nullptr) { break; } @@ -369,8 +375,8 @@ HRESULT Library_corlib_native_System_RuntimeType::GetCustomAttributes( // no parameters for the constructor returnArray++; - // set next position to NULL - returnArray->SetObjectReference(NULL); + // set next position to nullptr + returnArray->SetObjectReference(nullptr); } else if (val->m_mode == CLR_RT_AttributeParser::Value::c_ConstructorArgument) { @@ -379,7 +385,7 @@ HRESULT Library_corlib_native_System_RuntimeType::GetCustomAttributes( // get the type for the class object // the assembly has to be the instance type CLR_RT_MethodDef_Index md{}; - md.Set(instanceTypeDef.m_assm->m_idx, parser.m_mdIdx.Method()); + md.Set(instanceTypeDef.assembly->assemblyIndex, parser.m_mdIndex.Method()); CLR_RT_MethodDef_Instance mdInst{}; mdInst.InitializeFromIndex(md); diff --git a/src/CLR/CorLib/corlib_native_System_Runtime_CompilerServices_RuntimeHelpers.cpp b/src/CLR/CorLib/corlib_native_System_Runtime_CompilerServices_RuntimeHelpers.cpp index cdd8a371eb..83ac08b5b8 100644 --- a/src/CLR/CorLib/corlib_native_System_Runtime_CompilerServices_RuntimeHelpers.cpp +++ b/src/CLR/CorLib/corlib_native_System_Runtime_CompilerServices_RuntimeHelpers.cpp @@ -25,14 +25,13 @@ HRESULT Library_corlib_native_System_Runtime_CompilerServices_RuntimeHelpers:: NANOCLR_SET_AND_LEAVE(CLR_E_WRONG_TYPE); } - if ((inst.m_target->flags & CLR_RECORD_FIELDDEF::FD_HasFieldRVA) == 0 || - inst.m_target->defaultValue == CLR_EmptyIndex) + if ((inst.target->flags & CLR_RECORD_FIELDDEF::FD_HasFieldRVA) == 0 || inst.target->defaultValue == CLR_EmptyIndex) { NANOCLR_SET_AND_LEAVE(CLR_E_WRONG_TYPE); } { - CLR_PMETADATA ptrSrc = inst.m_assm->GetSignature(inst.m_target->defaultValue); + CLR_PMETADATA ptrSrc = inst.assembly->GetSignature(inst.target->defaultValue); CLR_UINT32 lenSrc; NANOCLR_READ_UNALIGNED_UINT16(lenSrc, ptrSrc); diff --git a/src/CLR/CorLib/corlib_native_System_String.cpp b/src/CLR/CorLib/corlib_native_System_String.cpp index 908cbd3516..059c7132eb 100644 --- a/src/CLR/CorLib/corlib_native_System_String.cpp +++ b/src/CLR/CorLib/corlib_native_System_String.cpp @@ -206,10 +206,10 @@ HRESULT Library_corlib_native_System_String::_ctor___VOID__CHAR__I4(CLR_RT_Stack { CLR_RT_HeapBlock tmp; - tmp.SetObjectReference(NULL); + tmp.SetObjectReference(nullptr); CLR_RT_ProtectFromGC gc(tmp); - NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_Array::CreateInstance(tmp, len, g_CLR_RT_WellKnownTypes.m_Char)); + NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_Array::CreateInstance(tmp, len, g_CLR_RT_WellKnownTypes.Char)); { CLR_RT_HeapBlock_Array *tmpArray = tmp.DereferenceArray(); @@ -450,7 +450,7 @@ HRESULT Library_corlib_native_System_String::Trim___STRING(CLR_RT_StackFrame &st NATIVE_PROFILE_CLR_CORE(); NANOCLR_HEADER(); - NANOCLR_SET_AND_LEAVE(Trim(stack, NULL, true, true)); + NANOCLR_SET_AND_LEAVE(Trim(stack, nullptr, true, true)); NANOCLR_NOCLEANUP(); } @@ -605,8 +605,8 @@ HRESULT Library_corlib_native_System_String::IndexOf(CLR_RT_StackFrame &stack, i if (!szText) szText = ""; pos = -1; - pString = NULL; - pChars = NULL; + pString = nullptr; + pChars = nullptr; if (mode & c_IndexOf__SingleChar) { @@ -864,7 +864,7 @@ HRESULT Library_corlib_native_System_String::ChangeCase(CLR_RT_StackFrame &stack CLR_RT_HeapBlock_Array *arrayTmp; CLR_RT_HeapBlock refTmp; - refTmp.SetObjectReference(NULL); + refTmp.SetObjectReference(nullptr); CLR_RT_ProtectFromGC gc(refTmp); NANOCLR_CHECK_HRESULT(ConvertToCharArray(stack, refTmp, arrayTmp, 0, -1)); @@ -905,7 +905,7 @@ HRESULT Library_corlib_native_System_String::Substring(CLR_RT_StackFrame &stack, CLR_RT_HeapBlock_Array *arrayTmp; CLR_RT_HeapBlock refTmp; - refTmp.SetObjectReference(NULL); + refTmp.SetObjectReference(nullptr); CLR_RT_ProtectFromGC gc(refTmp); NANOCLR_CHECK_HRESULT(ConvertToCharArray(stack, refTmp, arrayTmp, 0, -1)); @@ -946,7 +946,7 @@ HRESULT Library_corlib_native_System_String::Trim( CLR_RT_HeapBlock refTmp; CLR_RT_HeapBlock_Array *arrayTmp; - refTmp.SetObjectReference(NULL); + refTmp.SetObjectReference(nullptr); CLR_RT_ProtectFromGC gc(refTmp); NANOCLR_CHECK_HRESULT(ConvertToCharArray(stack, refTmp, arrayTmp, 0, -1)); @@ -1035,7 +1035,7 @@ HRESULT Library_corlib_native_System_String::Split(CLR_RT_StackFrame &stack, CLR { CLR_RT_HeapBlock &refTarget = stack.PushValue(); - NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_Array::CreateInstance(refTarget, 0, g_CLR_RT_WellKnownTypes.m_String)); + NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_Array::CreateInstance(refTarget, 0, g_CLR_RT_WellKnownTypes.String)); arrayDst = refTarget.DereferenceArray(); } @@ -1043,7 +1043,7 @@ HRESULT Library_corlib_native_System_String::Split(CLR_RT_StackFrame &stack, CLR { arrayChars = chars.DereferenceArray(); - if (arrayChars != NULL && arrayChars->m_numOfElements > 0) + if (arrayChars != nullptr && arrayChars->m_numOfElements > 0) { pChars = (CLR_UINT16 *)arrayChars->GetFirstElement(); cChars = arrayChars->m_numOfElements; @@ -1054,12 +1054,12 @@ HRESULT Library_corlib_native_System_String::Split(CLR_RT_StackFrame &stack, CLR cChars = ARRAYSIZE(c_WhiteSpaces); } - arrayDst = NULL; + arrayDst = nullptr; { CLR_RT_HeapBlock refSrc; - refSrc.SetObjectReference(NULL); + refSrc.SetObjectReference(nullptr); CLR_RT_ProtectFromGC gc(refSrc); NANOCLR_CHECK_HRESULT(ConvertToCharArray(stack, refSrc, arraySrc, 0, -1)); @@ -1120,7 +1120,7 @@ HRESULT Library_corlib_native_System_String::Split(CLR_RT_StackFrame &stack, CLR CLR_RT_HeapBlock &refTarget = stack.PushValue(); NANOCLR_CHECK_HRESULT( - CLR_RT_HeapBlock_Array::CreateInstance(refTarget, count, g_CLR_RT_WellKnownTypes.m_String)); + CLR_RT_HeapBlock_Array::CreateInstance(refTarget, count, g_CLR_RT_WellKnownTypes.String)); arrayDst = refTarget.DereferenceArray(); } @@ -1140,7 +1140,7 @@ HRESULT Library_corlib_native_System_String::Concat(CLR_RT_StackFrame &stack, CL CLR_RT_HeapBlock *ptrSrc; const char *szTextSrc; - char *szTextDst = NULL; + char *szTextDst = nullptr; CLR_UINT32 totLen; CLR_UINT32 len; @@ -1152,7 +1152,7 @@ HRESULT Library_corlib_native_System_String::Concat(CLR_RT_StackFrame &stack, CL for (int iStr = 0; iStr < num; iStr++) { - if (ptrSrc->Dereference() != NULL && ptrSrc->Dereference()->DataType() == DATATYPE_STRING) + if (ptrSrc->Dereference() != nullptr && ptrSrc->Dereference()->DataType() == DATATYPE_STRING) { szTextSrc = ptrSrc->RecoverString(); @@ -1218,7 +1218,7 @@ HRESULT Library_corlib_native_System_String::ConvertToCharArray( if (CLR_RT_HeapBlock_Array::CheckRange(startIndex, length, totLength) == false) NANOCLR_SET_AND_LEAVE(CLR_E_OUT_OF_RANGE); - NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_Array::CreateInstance(ref, length, g_CLR_RT_WellKnownTypes.m_Char)); + NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_Array::CreateInstance(ref, length, g_CLR_RT_WellKnownTypes.Char)); array = ref.DereferenceArray(); diff --git a/src/CLR/CorLib/corlib_native_System_Threading_Monitor.cpp b/src/CLR/CorLib/corlib_native_System_Threading_Monitor.cpp index 502a1f699d..4e801ed427 100644 --- a/src/CLR/CorLib/corlib_native_System_Threading_Monitor.cpp +++ b/src/CLR/CorLib/corlib_native_System_Threading_Monitor.cpp @@ -10,9 +10,9 @@ HRESULT Library_corlib_native_System_Threading_Monitor::Enter___STATIC__VOID__OB NATIVE_PROFILE_CLR_CORE(); NANOCLR_HEADER(); - CLR_RT_StackFrame *caller = NULL; + CLR_RT_StackFrame *caller = nullptr; - if (stack.Arg0().Dereference() == NULL) + if (stack.Arg0().Dereference() == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_ARGUMENT_NULL); } @@ -50,9 +50,9 @@ HRESULT Library_corlib_native_System_Threading_Monitor::Exit___STATIC__VOID__OBJ NATIVE_PROFILE_CLR_CORE(); NANOCLR_HEADER(); - CLR_RT_StackFrame *caller = NULL; + CLR_RT_StackFrame *caller = nullptr; - if (stack.Arg0().Dereference() == NULL) + if (stack.Arg0().Dereference() == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_ARGUMENT_NULL); } diff --git a/src/CLR/CorLib/corlib_native_System_Threading_Thread.cpp b/src/CLR/CorLib/corlib_native_System_Threading_Thread.cpp index 51d77369da..75cc747dba 100644 --- a/src/CLR/CorLib/corlib_native_System_Threading_Thread.cpp +++ b/src/CLR/CorLib/corlib_native_System_Threading_Thread.cpp @@ -48,7 +48,7 @@ HRESULT Library_corlib_native_System_Threading_Thread::Start___VOID(CLR_RT_Stack // Don't start twice... // NANOCLR_CHECK_HRESULT(GetThread(stack, th, false, false)); - if (th != NULL) + if (th != nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER); } @@ -168,7 +168,7 @@ HRESULT Library_corlib_native_System_Threading_Thread::get_Priority___SystemThre pri = pThis[FIELD___priority].NumericByRef().s4; // Here we check consistency of values stored in C# and internal thread objects. - // Get thread associated with C# thread object. It might be NULL if thread was not started. + // Get thread associated with C# thread object. It might be nullptr if thread was not started. NANOCLR_CHECK_HRESULT(GetThread(stack, th, false, false)); // If thread was started, then we use priority from the CLR_RT_Thread. @@ -177,7 +177,7 @@ HRESULT Library_corlib_native_System_Threading_Thread::get_Priority___SystemThre // 2. Sub-thread with different priority may have been created in // Library_spot_native_Microsoft_SPOT_ExecutionConstraint::Install___STATIC__VOID__I4__I4 - if (th != NULL) + if (th != nullptr) { pri = th->GetThreadPriority(); @@ -272,7 +272,7 @@ HRESULT Library_corlib_native_System_Threading_Thread::get_IsAlive___BOOLEAN(CLR GetThread(stack, th, false, false); - stack.SetResult_Boolean(th != NULL && th->m_status != CLR_RT_Thread::TH_S_Terminated); + stack.SetResult_Boolean(th != nullptr && th->m_status != CLR_RT_Thread::TH_S_Terminated); NANOCLR_NOCLEANUP_NOLABEL(); } @@ -331,7 +331,7 @@ HRESULT Library_corlib_native_System_Threading_Thread::get_ThreadState___SystemT NANOCLR_CHECK_HRESULT(GetThread(stack, th, false, false)); - if (th == NULL) + if (th == nullptr) { val = 8; // Unstarted } @@ -449,7 +449,7 @@ HRESULT Library_corlib_native_System_Threading_Thread::get_CurrentThread___STATI // If we are a thread spawned by the debugger to perform evaluations, // return the thread object that correspond to thread that has focus in debugger. thread = thread->m_realThread; -#endif //#if defined(NANOCLR_ENABLE_SOURCELEVELDEBUGGING) +#endif // #if defined(NANOCLR_ENABLE_SOURCELEVELDEBUGGING) // Find an existing managed thread, if it exists // making sure to only return the managed object association with the current appdomain @@ -458,7 +458,7 @@ HRESULT Library_corlib_native_System_Threading_Thread::get_CurrentThread___STATI { CLR_RT_HeapBlock *pManagedThread = src->m_objectPtr; bool fFound = false; - _ASSERTE(pManagedThread != NULL); + _ASSERTE(pManagedThread != nullptr); #if defined(NANOCLR_APPDOMAINS) { @@ -488,7 +488,7 @@ HRESULT Library_corlib_native_System_Threading_Thread::get_CurrentThread___STATI // for the data before the thread is started. Once the thread is started, they are copied over to the unmanaged // thread object and no longer used. The managed object is then used simply as a wrapper for the unmanaged thread. // Therefore, it is safe to simply make another managed thread here. - NANOCLR_CHECK_HRESULT(g_CLR_RT_ExecutionEngine.NewObjectFromIndex(top, g_CLR_RT_WellKnownTypes.m_Thread)); + NANOCLR_CHECK_HRESULT(g_CLR_RT_ExecutionEngine.NewObjectFromIndex(top, g_CLR_RT_WellKnownTypes.Thread)); pRes = top.Dereference(); @@ -567,8 +567,8 @@ HRESULT Library_corlib_native_System_Threading_Thread::GetThread( NANOCLR_HEADER(); CLR_RT_ObjectToEvent_Source *src = GetThreadReference(stack); - th = (src == NULL) ? NULL : (CLR_RT_Thread *)src->m_eventPtr; - if (th == NULL) + th = (src == nullptr) ? nullptr : (CLR_RT_Thread *)src->m_eventPtr; + if (th == nullptr) { if (mustBeStarted) { diff --git a/src/CLR/CorLib/corlib_native_System_TimeSpan.cpp b/src/CLR/CorLib/corlib_native_System_TimeSpan.cpp index 3c53c9f6d9..474a05e9c7 100644 --- a/src/CLR/CorLib/corlib_native_System_TimeSpan.cpp +++ b/src/CLR/CorLib/corlib_native_System_TimeSpan.cpp @@ -199,7 +199,7 @@ CLR_INT64 *Library_corlib_native_System_TimeSpan::GetValuePtr(CLR_RT_HeapBlock & { NATIVE_PROFILE_CLR_CORE(); CLR_RT_HeapBlock *obj = &ref; - CLR_DataType dt = obj->DataType(); + NanoCLRDataType dt = obj->DataType(); if (dt == DATATYPE_OBJECT || dt == DATATYPE_BYREF) { @@ -207,7 +207,7 @@ CLR_INT64 *Library_corlib_native_System_TimeSpan::GetValuePtr(CLR_RT_HeapBlock & if (!obj) { - return NULL; + return nullptr; } dt = obj->DataType(); @@ -223,10 +223,10 @@ CLR_INT64 *Library_corlib_native_System_TimeSpan::GetValuePtr(CLR_RT_HeapBlock & return (CLR_INT64 *)&obj->NumericByRef().s8; } - if (dt == DATATYPE_VALUETYPE && obj->ObjectCls().m_data == g_CLR_RT_WellKnownTypes.m_TimeSpan.m_data) + if (dt == DATATYPE_VALUETYPE && obj->ObjectCls().data == g_CLR_RT_WellKnownTypes.TimeSpan.data) { return (CLR_INT64 *)&obj[FIELD___ticks].NumericByRef().s8; } - return NULL; + return nullptr; } diff --git a/src/CLR/CorLib/corlib_native_System_Type.cpp b/src/CLR/CorLib/corlib_native_System_Type.cpp index 2feac0c178..2263f6fe02 100644 --- a/src/CLR/CorLib/corlib_native_System_Type.cpp +++ b/src/CLR/CorLib/corlib_native_System_Type.cpp @@ -19,12 +19,12 @@ HRESULT Library_corlib_native_System_Type::get_DeclaringType___SystemType(CLR_RT NANOCLR_CHECK_HRESULT(Library_corlib_native_System_RuntimeType::GetTypeDescriptor(*hbType, td)); - if (td.m_target->enclosingType != CLR_EmptyIndex) + if (td.target->HasValidEnclosingType()) { CLR_RT_HeapBlock *hbObj; - td.Set(td.Assembly(), td.m_target->enclosingType); + td.Set(td.Assembly(), td.target->EnclosingTypeIndex()); - NANOCLR_CHECK_HRESULT(g_CLR_RT_ExecutionEngine.NewObjectFromIndex(top, g_CLR_RT_WellKnownTypes.m_TypeStatic)); + NANOCLR_CHECK_HRESULT(g_CLR_RT_ExecutionEngine.NewObjectFromIndex(top, g_CLR_RT_WellKnownTypes.TypeStatic)); hbObj = top.Dereference(); hbObj->SetReflection(td); } @@ -41,7 +41,7 @@ HRESULT Library_corlib_native_System_Type::GetMethod___SystemReflectionMethodInf const char *szText = stack.Arg1().RecoverString(); FAULT_ON_NULL(szText); - NANOCLR_SET_AND_LEAVE(GetMethods(stack, szText, stack.Arg2().NumericByRef().s4, NULL, 0, false)); + NANOCLR_SET_AND_LEAVE(GetMethods(stack, szText, stack.Arg2().NumericByRef().s4, nullptr, 0, false)); NANOCLR_NOCLEANUP(); } @@ -94,7 +94,7 @@ HRESULT Library_corlib_native_System_Type::GetConstructor___SystemReflectionCons NANOCLR_SET_AND_LEAVE(GetMethods( stack, - NULL, + nullptr, c_BindingFlags_CreateInstance | c_BindingFlags_Instance | c_BindingFlags_Public | c_BindingFlags_NonPublic, pParams, iParams, @@ -110,9 +110,9 @@ HRESULT Library_corlib_native_System_Type::GetConstructors___SZARRAY_SystemRefle NANOCLR_SET_AND_LEAVE(GetMethods( stack, - NULL, + nullptr, c_BindingFlags_CreateInstance | c_BindingFlags_Instance | c_BindingFlags_Public, - NULL, + nullptr, 0, true)); @@ -136,7 +136,7 @@ HRESULT Library_corlib_native_System_Type::GetMethod___SystemReflectionMethodInf } else { - pParams = NULL; + pParams = nullptr; iParams = 0; } @@ -156,7 +156,7 @@ HRESULT Library_corlib_native_System_Type::GetMethod___SystemReflectionMethodInf const char *szText = stack.Arg1().RecoverString(); FAULT_ON_NULL(szText); - NANOCLR_SET_AND_LEAVE(GetMethods(stack, szText, c_BindingFlags_DefaultLookup, NULL, 0, false)); + NANOCLR_SET_AND_LEAVE(GetMethods(stack, szText, c_BindingFlags_DefaultLookup, nullptr, 0, false)); NANOCLR_NOCLEANUP(); } @@ -255,7 +255,7 @@ HRESULT Library_corlib_native_System_Type::get_IsArray___BOOLEAN(CLR_RT_StackFra NANOCLR_CHECK_HRESULT(Library_corlib_native_System_RuntimeType::GetTypeDescriptor(*hbType, td)); - stack.SetResult_Boolean(td.m_data == g_CLR_RT_WellKnownTypes.m_Array.m_data); + stack.SetResult_Boolean(td.data == g_CLR_RT_WellKnownTypes.Array.data); NANOCLR_NOCLEANUP(); } @@ -290,10 +290,10 @@ HRESULT Library_corlib_native_System_Type::GetTypeInternal___STATIC__SystemType_ FAULT_ON_NULL(verArray); ver = (CLR_INT32 *)verArray->GetFirstElement(); - version.iMajorVersion = ver[0]; - version.iMinorVersion = ver[1]; - version.iBuildNumber = ver[2]; - version.iRevisionNumber = ver[3]; + version.majorVersion = ver[0]; + version.minorVersion = ver[1]; + version.buildNumber = ver[2]; + version.revisionNumber = ver[3]; } else { @@ -302,11 +302,11 @@ HRESULT Library_corlib_native_System_Type::GetTypeInternal___STATIC__SystemType_ if (szAssembly) { - assm = g_CLR_RT_TypeSystem.FindAssembly(szAssembly, fVersion ? &version : NULL, fVersion); + assm = g_CLR_RT_TypeSystem.FindAssembly(szAssembly, fVersion ? &version : nullptr, fVersion); } else { - assm = NULL; + assm = nullptr; } if (g_CLR_RT_TypeSystem.FindTypeDef(szClass, assm, td)) @@ -318,7 +318,7 @@ HRESULT Library_corlib_native_System_Type::GetTypeInternal___STATIC__SystemType_ if (!g_CLR_RT_ExecutionEngine.GetCurrentAppDomain()->FindAppDomainAssembly(inst.m_assm)) NANOCLR_SET_AND_LEAVE(S_OK); #endif - NANOCLR_CHECK_HRESULT(g_CLR_RT_ExecutionEngine.NewObjectFromIndex(top, g_CLR_RT_WellKnownTypes.m_TypeStatic)); + NANOCLR_CHECK_HRESULT(g_CLR_RT_ExecutionEngine.NewObjectFromIndex(top, g_CLR_RT_WellKnownTypes.TypeStatic)); hbObj = top.Dereference(); hbObj->SetReflection(td); } @@ -334,8 +334,7 @@ HRESULT Library_corlib_native_System_Type::GetTypeInternal___STATIC__SystemType_ if (!g_CLR_RT_ExecutionEngine.GetCurrentAppDomain()->FindAppDomainAssembly(inst.m_assm)) NANOCLR_SET_AND_LEAVE(S_OK); #endif - NANOCLR_CHECK_HRESULT( - g_CLR_RT_ExecutionEngine.NewObjectFromIndex(top, g_CLR_RT_WellKnownTypes.m_TypeStatic)); + NANOCLR_CHECK_HRESULT(g_CLR_RT_ExecutionEngine.NewObjectFromIndex(top, g_CLR_RT_WellKnownTypes.TypeStatic)); hbObj = top.Dereference(); hbObj->SetReflection(reflex); } @@ -354,7 +353,7 @@ HRESULT Library_corlib_native_System_Type::GetTypeFromHandle___STATIC__SystemTyp CLR_RT_HeapBlock &top = stack.PushValue(); CLR_RT_HeapBlock *hbObj; - NANOCLR_CHECK_HRESULT(g_CLR_RT_ExecutionEngine.NewObjectFromIndex(top, g_CLR_RT_WellKnownTypes.m_TypeStatic)); + NANOCLR_CHECK_HRESULT(g_CLR_RT_ExecutionEngine.NewObjectFromIndex(top, g_CLR_RT_WellKnownTypes.TypeStatic)); hbObj = top.Dereference(); hbObj->Assign(pThis); // RuntimeTypeHandle and Type have the same representation. @@ -374,7 +373,7 @@ HRESULT Library_corlib_native_System_Type::CheckFlags(CLR_RT_StackFrame &stack, NANOCLR_CHECK_HRESULT(Library_corlib_native_System_RuntimeType::GetTypeDescriptor(*hbType, td)); - if ((td.m_target->flags & mask) == flag) + if ((td.target->flags & mask) == flag) { fRes = true; } @@ -425,12 +424,12 @@ HRESULT Library_corlib_native_System_Type::GetFields( do { - CLR_RT_Assembly *assm = td.m_assm; - const CLR_RECORD_TYPEDEF *tdR = td.m_target; - const CLR_RECORD_FIELDDEF *fd = td.m_assm->GetFieldDef(tdR->sFields_First); - int iTot = tdR->iFields_Num + tdR->sFields_Num; + CLR_RT_Assembly *assm = td.assembly; + const CLR_RECORD_TYPEDEF *tdR = td.target; + const CLR_RECORD_FIELDDEF *fd = td.assembly->GetFieldDef(tdR->firstStaticField); + int iTot = tdR->instanceFieldsCount + tdR->staticFieldsCount; int i; - CLR_RT_FieldDef_Index idx; + CLR_RT_FieldDef_Index index; for (i = 0; i < iTot; i++, fd++) { @@ -468,25 +467,29 @@ HRESULT Library_corlib_native_System_Type::GetFields( if (bindingFlags & c_BindingFlags_IgnoreCase) { // If strings are not eqaul - continue - if (szText != NULL && hal_stricmp(fieldName, szText)) + if (szText != nullptr && hal_stricmp(fieldName, szText)) + { continue; + } } else // Case sensitive compare { // If strings are not eqaul - continue - if (szText != NULL && strcmp(fieldName, szText)) + if (szText != nullptr && strcmp(fieldName, szText)) + { continue; + } } - idx.Set(td.Assembly(), i + tdR->sFields_First); + index.Set(td.Assembly(), i + tdR->firstStaticField); if (!fAllMatches) { CLR_RT_HeapBlock *hbObj; NANOCLR_CHECK_HRESULT( - g_CLR_RT_ExecutionEngine.NewObjectFromIndex(top, g_CLR_RT_WellKnownTypes.m_FieldInfo)); + g_CLR_RT_ExecutionEngine.NewObjectFromIndex(top, g_CLR_RT_WellKnownTypes.FieldInfo)); hbObj = top.Dereference(); - hbObj->SetReflection(idx); + hbObj->SetReflection(index); NANOCLR_SET_AND_LEAVE(S_OK); } @@ -495,9 +498,9 @@ HRESULT Library_corlib_native_System_Type::GetFields( CLR_RT_HeapBlock *elem = (CLR_RT_HeapBlock *)top.DereferenceArray()->GetElement(iField); CLR_RT_HeapBlock *hbObj; NANOCLR_CHECK_HRESULT( - g_CLR_RT_ExecutionEngine.NewObjectFromIndex(*elem, g_CLR_RT_WellKnownTypes.m_FieldInfo)); + g_CLR_RT_ExecutionEngine.NewObjectFromIndex(*elem, g_CLR_RT_WellKnownTypes.FieldInfo)); hbObj = elem->Dereference(); - NANOCLR_CHECK_HRESULT(hbObj->SetReflection(idx)); + NANOCLR_CHECK_HRESULT(hbObj->SetReflection(index)); } iField++; @@ -513,7 +516,7 @@ HRESULT Library_corlib_native_System_Type::GetFields( NANOCLR_SET_AND_LEAVE(S_OK); NANOCLR_CHECK_HRESULT( - CLR_RT_HeapBlock_Array::CreateInstance(top, iField, g_CLR_RT_WellKnownTypes.m_FieldInfo)); + CLR_RT_HeapBlock_Array::CreateInstance(top, iField, g_CLR_RT_WellKnownTypes.FieldInfo)); } } } @@ -562,10 +565,10 @@ HRESULT Library_corlib_native_System_Type::GetMethods( do { - CLR_RT_Assembly *assm = td.m_assm; - const CLR_RECORD_TYPEDEF *tdR = td.m_target; - const CLR_RECORD_METHODDEF *md = assm->GetMethodDef(tdR->methods_First); - int iTot = tdR->sMethods_Num + tdR->iMethods_Num + tdR->vMethods_Num; + CLR_RT_Assembly *assm = td.assembly; + const CLR_RECORD_TYPEDEF *tdR = td.target; + const CLR_RECORD_METHODDEF *md = assm->GetMethodDef(tdR->firstMethod); + int iTot = tdR->staticMethodCount + tdR->instanceMethodCount + tdR->virtualMethodCount; int i; if (staticInstanceOnly) @@ -632,7 +635,7 @@ HRESULT Library_corlib_native_System_Type::GetMethods( continue; } - if (szText != NULL && !strcmp(assm->GetString(md->name), szText) == false) + if (szText != nullptr && !strcmp(assm->GetString(md->name), szText) == false) { continue; } @@ -657,10 +660,10 @@ HRESULT Library_corlib_native_System_Type::GetMethods( } } - CLR_RT_MethodDef_Index idx{}; - idx.Set(td.Assembly(), i + tdR->methods_First); + CLR_RT_MethodDef_Index index{}; + index.Set(td.Assembly(), i + tdR->firstMethod); CLR_RT_MethodDef_Instance inst2{}; - inst2.InitializeFromIndex(idx); + inst2.InitializeFromIndex(index); if (fAllMatches) { @@ -669,12 +672,12 @@ HRESULT Library_corlib_native_System_Type::GetMethods( CLR_RT_HeapBlock *elem = (CLR_RT_HeapBlock *)top.DereferenceArray()->GetElement(iMethod); CLR_RT_HeapBlock *hbObj; NANOCLR_CHECK_HRESULT( - g_CLR_RT_ExecutionEngine.NewObjectFromIndex(*elem, g_CLR_RT_WellKnownTypes.m_MethodInfo)); + g_CLR_RT_ExecutionEngine.NewObjectFromIndex(*elem, g_CLR_RT_WellKnownTypes.MethodInfo)); hbObj = elem->Dereference(); - NANOCLR_CHECK_HRESULT(hbObj->SetReflection(idx)); + NANOCLR_CHECK_HRESULT(hbObj->SetReflection(index)); // store token for type - hbObj[MethodBase::FIELD___token].NumericByRef().u4 = idx.m_data; + hbObj[MethodBase::FIELD___token].NumericByRef().u4 = index.data; } iMethod++; @@ -686,9 +689,9 @@ HRESULT Library_corlib_native_System_Type::GetMethods( if (NANOCLR_INDEX_IS_VALID(inst)) { CLR_RT_SignatureParser parserLeft{}; - parserLeft.Initialize_MethodSignature(inst.m_assm, inst.m_target); + parserLeft.Initialize_MethodSignature(&inst); CLR_RT_SignatureParser parserRight{}; - parserRight.Initialize_MethodSignature(inst2.m_assm, inst2.m_target); + parserRight.Initialize_MethodSignature(&inst2); CLR_RT_SignatureParser::Element resLeft; CLR_RT_SignatureParser::Element resRight; @@ -720,10 +723,18 @@ HRESULT Library_corlib_native_System_Type::GetMethods( NANOCLR_CHECK_HRESULT(parserLeft.Advance(resLeft)); NANOCLR_CHECK_HRESULT(parserRight.Advance(resRight)); - bool fRightBetterMatchT = - CLR_RT_TypeSystem::MatchSignatureElement(resLeft, resRight, true); - bool fLeftBetterMatchT = - CLR_RT_TypeSystem::MatchSignatureElement(resRight, resLeft, true); + bool fRightBetterMatchT = CLR_RT_TypeSystem::MatchSignatureElement( + resLeft, + resRight, + parserLeft, + parserRight, + true); + bool fLeftBetterMatchT = CLR_RT_TypeSystem::MatchSignatureElement( + resRight, + resLeft, + parserLeft, + parserRight, + true); // If fLeftBetterMatchT && fRightBetterMatchT, one is assignable from the other, they // must be the same @@ -759,15 +770,15 @@ HRESULT Library_corlib_native_System_Type::GetMethods( } } - inst.InitializeFromIndex(idx); + inst.InitializeFromIndex(index); NANOCLR_CHECK_HRESULT( - g_CLR_RT_ExecutionEngine.NewObjectFromIndex(top, g_CLR_RT_WellKnownTypes.m_MethodInfo)); + g_CLR_RT_ExecutionEngine.NewObjectFromIndex(top, g_CLR_RT_WellKnownTypes.MethodInfo)); hbObj = top.Dereference(); hbObj->SetReflection(inst); // store token for type - hbObj[MethodBase::FIELD___token].NumericByRef().u4 = inst.m_data; + hbObj[MethodBase::FIELD___token].NumericByRef().u4 = inst.data; } } @@ -786,7 +797,7 @@ HRESULT Library_corlib_native_System_Type::GetMethods( } NANOCLR_CHECK_HRESULT( - CLR_RT_HeapBlock_Array::CreateInstance(top, iMethod, g_CLR_RT_WellKnownTypes.m_MethodInfo)); + CLR_RT_HeapBlock_Array::CreateInstance(top, iMethod, g_CLR_RT_WellKnownTypes.MethodInfo)); } } diff --git a/src/CLR/CorLib/corlib_native_System_WeakReference.cpp b/src/CLR/CorLib/corlib_native_System_WeakReference.cpp index 52fd73eb6e..7920ad7ca6 100644 --- a/src/CLR/CorLib/corlib_native_System_WeakReference.cpp +++ b/src/CLR/CorLib/corlib_native_System_WeakReference.cpp @@ -74,7 +74,7 @@ void CLR_RT_HeapBlock_WeakReference::RecoverObjects(CLR_RT_DblLinkedList &lstHea weak->InsertInPriorityOrder(); - weak = NULL; + weak = nullptr; } } @@ -111,9 +111,9 @@ HRESULT CLR_RT_HeapBlock_WeakReference::GetTarget(CLR_RT_HeapBlock &targetRefere if (CLR_RT_BinaryFormatter::SerializationEnabled()) { - targetReference.SetObjectReference(NULL); + targetReference.SetObjectReference(nullptr); - if (m_targetDirect == NULL && m_targetSerialized != NULL) + if (m_targetDirect == nullptr && m_targetSerialized != nullptr) { if (m_identity.m_flags & CLR_RT_HeapBlock_WeakReference::WR_ArrayOfBytes) { @@ -125,15 +125,15 @@ HRESULT CLR_RT_HeapBlock_WeakReference::GetTarget(CLR_RT_HeapBlock &targetRefere CLR_RT_HeapBlock output; input.SetObjectReference(m_targetSerialized); - output.SetObjectReference(NULL); + output.SetObjectReference(nullptr); { CLR_RT_ProtectFromGC gcInput(input); CLR_RT_ProtectFromGC gcOutput(output); - if (FAILED(CLR_RT_BinaryFormatter::Deserialize(output, input, NULL, 0))) + if (FAILED(CLR_RT_BinaryFormatter::Deserialize(output, input, nullptr, 0))) { - output.SetObjectReference(NULL); + output.SetObjectReference(nullptr); } } @@ -175,7 +175,7 @@ HRESULT Library_corlib_native_System_WeakReference::get_IsAlive___BOOLEAN(CLR_RT weak = (CLR_RT_HeapBlock_WeakReference *)stack.This(); FAULT_ON_NULL(weak); - stack.SetResult_Boolean(weak->m_targetDirect != NULL); + stack.SetResult_Boolean(weak->m_targetDirect != nullptr); NANOCLR_NOCLEANUP(); } diff --git a/src/CLR/Core/CLR_RT_DblLinkedList.cpp b/src/CLR/Core/CLR_RT_DblLinkedList.cpp index df1183fa1b..e9d65ef132 100644 --- a/src/CLR/Core/CLR_RT_DblLinkedList.cpp +++ b/src/CLR/Core/CLR_RT_DblLinkedList.cpp @@ -11,7 +11,7 @@ void CLR_RT_DblLinkedList::DblLinkedList_Initialize() { NATIVE_PROFILE_CLR_CORE(); m_first = Tail(); - m_null = NULL; + m_null = nullptr; m_last = Head(); } @@ -74,8 +74,10 @@ void CLR_RT_DblLinkedList::ValidateList() { NATIVE_PROFILE_CLR_CORE(); - if (m_null != NULL) + if (m_null != nullptr) + { NANOCLR_DEBUG_STOP(); + } CLR_RT_HeapBlock_Node *prev = Head(); CLR_RT_HeapBlock_Node *node = prev->Next(); diff --git a/src/CLR/Core/CLR_RT_HeapBlock.cpp b/src/CLR/Core/CLR_RT_HeapBlock.cpp index 1fb0a71cbb..9a167f438b 100644 --- a/src/CLR/Core/CLR_RT_HeapBlock.cpp +++ b/src/CLR/Core/CLR_RT_HeapBlock.cpp @@ -225,9 +225,9 @@ HRESULT CLR_RT_HeapBlock::SetReflection(const CLR_RT_Assembly_Index &assm) NANOCLR_HEADER(); m_id.raw = CLR_RT_HEAPBLOCK_RAW_ID(DATATYPE_REFLECTION, 0, 1); - m_data.reflection.m_kind = REFLECTION_ASSEMBLY; - m_data.reflection.m_levels = 0; - m_data.reflection.m_data.m_assm = assm; + m_data.reflection.kind = REFLECTION_ASSEMBLY; + m_data.reflection.levels = 0; + m_data.reflection.data.assembly = assm; NANOCLR_NOCLEANUP_NOLABEL(); } @@ -253,9 +253,9 @@ HRESULT CLR_RT_HeapBlock::SetReflection(const CLR_RT_TypeDef_Index &cls) NANOCLR_HEADER(); m_id.raw = CLR_RT_HEAPBLOCK_RAW_ID(DATATYPE_REFLECTION, 0, 1); - m_data.reflection.m_kind = REFLECTION_TYPE; - m_data.reflection.m_levels = 0; - m_data.reflection.m_data.m_type = cls; + m_data.reflection.kind = REFLECTION_TYPE; + m_data.reflection.levels = 0; + m_data.reflection.data.type = cls; NANOCLR_NOCLEANUP_NOLABEL(); } @@ -266,9 +266,9 @@ HRESULT CLR_RT_HeapBlock::SetReflection(const CLR_RT_FieldDef_Index &fd) NANOCLR_HEADER(); m_id.raw = CLR_RT_HEAPBLOCK_RAW_ID(DATATYPE_REFLECTION, 0, 1); - m_data.reflection.m_kind = REFLECTION_FIELD; - m_data.reflection.m_levels = 0; - m_data.reflection.m_data.m_field = fd; + m_data.reflection.kind = REFLECTION_FIELD; + m_data.reflection.levels = 0; + m_data.reflection.data.field = fd; NANOCLR_NOCLEANUP_NOLABEL(); } @@ -286,10 +286,35 @@ HRESULT CLR_RT_HeapBlock::SetReflection(const CLR_RT_MethodDef_Index &md) } m_id.raw = CLR_RT_HEAPBLOCK_RAW_ID(DATATYPE_REFLECTION, 0, 1); - m_data.reflection.m_kind = - (inst.m_target->flags & CLR_RECORD_METHODDEF::MD_Constructor) ? REFLECTION_CONSTRUCTOR : REFLECTION_METHOD; - m_data.reflection.m_levels = 0; - m_data.reflection.m_data.m_method = md; + m_data.reflection.kind = + (inst.target->flags & CLR_RECORD_METHODDEF::MD_Constructor) ? REFLECTION_CONSTRUCTOR : REFLECTION_METHOD; + m_data.reflection.levels = 0; + m_data.reflection.data.method = md; + + NANOCLR_NOCLEANUP(); +} + +HRESULT CLR_RT_HeapBlock::SetReflection(const CLR_RT_GenericParam_Index &gp) +{ + NATIVE_PROFILE_CLR_CORE(); + NANOCLR_HEADER(); + + CLR_RT_GenericParam_Instance genericParam; + CLR_RT_TypeDef_Index typeDef; + + if (genericParam.InitializeFromIndex(gp) == false) + { + NANOCLR_SET_AND_LEAVE(CLR_E_WRONG_TYPE); + } + + // grab the type definition from the generic param + typeDef = genericParam.CrossReference().classTypeDef; + + m_id.raw = CLR_RT_HEAPBLOCK_RAW_ID(DATATYPE_REFLECTION, 0, 1); + m_data.reflection.levels = 0; + m_data.reflection.kind = REFLECTION_TYPE; + // set the type definition in the reflection block + m_data.reflection.data.type.Set(typeDef.Assembly(), typeDef.Type()); NANOCLR_NOCLEANUP(); } @@ -307,8 +332,25 @@ HRESULT CLR_RT_HeapBlock::SetObjectCls(const CLR_RT_TypeDef_Index &cls) } m_data.objectHeader.cls = cls; + m_data.objectHeader.lock = nullptr; - m_data.objectHeader.lock = NULL; + NANOCLR_NOCLEANUP(); +} + +HRESULT CLR_RT_HeapBlock::SetGenericInstanceObject(const CLR_RT_TypeSpec_Index &genericType) +{ + NATIVE_PROFILE_CLR_CORE(); + NANOCLR_HEADER(); + + CLR_RT_TypeSpec_Instance instance; + + if (instance.InitializeFromIndex(genericType) == false) + { + NANOCLR_SET_AND_LEAVE(CLR_E_FAIL); + } + + m_data.genericInstance.genericType = genericType; + m_data.genericInstance.ptr = nullptr; NANOCLR_NOCLEANUP(); } @@ -386,7 +428,7 @@ HRESULT CLR_RT_HeapBlock::LoadFromReference(CLR_RT_HeapBlock &ref) CLR_RT_HeapBlock tmp; CLR_RT_HeapBlock *obj; - CLR_DataType dt = ref.DataType(); + NanoCLRDataType dt = ref.DataType(); if (dt == DATATYPE_ARRAY_BYREF) { @@ -464,7 +506,7 @@ HRESULT CLR_RT_HeapBlock::LoadFromReference(CLR_RT_HeapBlock &ref) NANOCLR_SET_AND_LEAVE(CLR_E_TYPE_UNAVAILABLE); } - if (inst.m_target->dataType != DATATYPE_VALUETYPE) // It's a boxed primitive/enum type. + if (inst.target->dataType != DATATYPE_VALUETYPE) // It's a boxed primitive/enum type. { obj = &objT[1]; } @@ -492,7 +534,7 @@ HRESULT CLR_RT_HeapBlock::StoreToReference(CLR_RT_HeapBlock &ref, int size) NANOCLR_HEADER(); CLR_RT_HeapBlock *obj; - CLR_DataType dt = ref.DataType(); + NanoCLRDataType dt = ref.DataType(); if (dt == DATATYPE_ARRAY_BYREF) { @@ -505,7 +547,7 @@ HRESULT CLR_RT_HeapBlock::StoreToReference(CLR_RT_HeapBlock &ref, int size) CLR_INT32 sizeArray = array->m_sizeOfElement; // - // Cannot copy NULL reference to a primitive type array. + // Cannot copy nullptr reference to a primitive type array. // obj = FixBoxingReference(); FAULT_ON_NULL(obj); @@ -528,7 +570,7 @@ HRESULT CLR_RT_HeapBlock::StoreToReference(CLR_RT_HeapBlock &ref, int size) #if defined(_DEBUG) { - CLR_DataType dtElem = (CLR_DataType)array->m_typeOfElement; + NanoCLRDataType dtElem = (NanoCLRDataType)array->m_typeOfElement; CLR_RT_HeapBlock blk; blk.Assign(*this); @@ -737,7 +779,7 @@ void CLR_RT_HeapBlock::AssignAndPinReferencedObject(const CLR_RT_HeapBlock &valu // This code is called only if "fixed" keyword is present in the managed code. Executed on assignment to "fixed" // pointer. First check if there is object referenced by the local var. We unpin it, since the reference is // replaced. - if ((m_data.objectReference.ptr != NULL && m_id.type.dataType == DATATYPE_ARRAY_BYREF) || + if ((m_data.objectReference.ptr != nullptr && m_id.type.dataType == DATATYPE_ARRAY_BYREF) || m_id.type.dataType == DATATYPE_BYREF) { // Unpin the object that has been pointed by local variable. @@ -757,7 +799,7 @@ void CLR_RT_HeapBlock::AssignAndPinReferencedObject(const CLR_RT_HeapBlock &valu } // Pin the object referenced by local variable. - if ((m_data.objectReference.ptr != NULL && m_id.type.dataType == DATATYPE_ARRAY_BYREF) || + if ((m_data.objectReference.ptr != nullptr && m_id.type.dataType == DATATYPE_ARRAY_BYREF) || m_id.type.dataType == DATATYPE_BYREF) { m_data.objectReference.ptr->Pin(); @@ -802,7 +844,7 @@ HRESULT CLR_RT_HeapBlock::PerformBoxing(const CLR_RT_TypeDef_Instance &cls) CLR_RT_HeapBlock tmp; CLR_RT_HeapBlock *obj = this; - CLR_DataType dt = obj->DataType(); + NanoCLRDataType dt = obj->DataType(); // // System.DateTime and System.TimeSpan are real value types, so sometimes they are passed by reference. @@ -826,7 +868,7 @@ HRESULT CLR_RT_HeapBlock::PerformBoxing(const CLR_RT_TypeDef_Instance &cls) } { - CLR_DataType dataType = (CLR_DataType)cls.m_target->dataType; + NanoCLRDataType dataType = (NanoCLRDataType)cls.target->dataType; const CLR_RT_DataTypeLookup &dtl = c_CLR_RT_DataTypeLookup[dataType]; if (dtl.m_flags & CLR_RT_DataTypeLookup::c_OptimizedValueType) @@ -898,7 +940,7 @@ HRESULT CLR_RT_HeapBlock::PerformUnboxing(const CLR_RT_TypeDef_Instance &cls) if (this->DataType() != DATATYPE_OBJECT) { - NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_CAST); + NANOCLR_SET_AND_LEAVE(CLR_E_WRONG_TYPE); } // Finds the object that keeps the boxed type. @@ -908,17 +950,17 @@ HRESULT CLR_RT_HeapBlock::PerformUnboxing(const CLR_RT_TypeDef_Instance &cls) // Validates that src keeps something boxed and the boxed value is VALUE type. if (src->IsBoxed() == false || src->DataType() != DATATYPE_VALUETYPE) { - NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_CAST); + NANOCLR_SET_AND_LEAVE(CLR_E_WRONG_TYPE); } // Validates the type of data kept by object corresponds to type in cls. // If typedef indexes are the same, then skip and go to assigment of objects. - if (src->ObjectCls().m_data != cls.m_data) + if (src->ObjectCls().data != cls.data) { // The typedef indexes are different, but src and cls may have identical basic data type. // Need to check it. If identical - the unboxing is allowed. // This "if" compares underlying type in object and cls. Should be equal in order to continue. - if (!(src->DataSize() > 1 && (src[1].DataType() == cls.m_target->dataType))) + if (!(src->DataSize() > 1 && (src[1].DataType() == cls.target->dataType))) { // No luck. The types in src object and specified by cls are different. Need to throw exceptioin. NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_CAST); @@ -933,14 +975,14 @@ HRESULT CLR_RT_HeapBlock::PerformUnboxing(const CLR_RT_TypeDef_Instance &cls) CLR_RT_TypeDef_Instance &inst = srcTypeDes.m_handlerCls; - if (inst.m_data == g_CLR_RT_WellKnownTypes.m_Guid.m_data) + if (inst.data == g_CLR_RT_WellKnownTypes.Guid.data) { // can't cast GUID class to anything else except another GUID NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_CAST); } } - if (cls.m_target->dataType == DATATYPE_VALUETYPE) + if (cls.target->dataType == DATATYPE_VALUETYPE) { NANOCLR_CHECK_HRESULT(g_CLR_RT_ExecutionEngine.CloneObject(*this, *this)); @@ -950,7 +992,7 @@ HRESULT CLR_RT_HeapBlock::PerformUnboxing(const CLR_RT_TypeDef_Instance &cls) { this->Assign(src[1]); - this->ChangeDataType(cls.m_target->dataType); + this->ChangeDataType(cls.target->dataType); } NANOCLR_NOCLEANUP(); @@ -973,9 +1015,11 @@ CLR_RT_HeapBlock *CLR_RT_HeapBlock::FixBoxingReference() CLR_RT_TypeDef_Instance inst{}; if (!inst.InitializeFromIndex(src->ObjectCls())) - return NULL; + { + return nullptr; + } - if (inst.m_target->dataType != DATATYPE_VALUETYPE) // It's a boxed primitive/enum type. + if (inst.target->dataType != DATATYPE_VALUETYPE) // It's a boxed primitive/enum type. { return &src[1]; } @@ -993,7 +1037,7 @@ bool CLR_RT_HeapBlock::IsZero() const switch (DataType()) { case DATATYPE_OBJECT: - return (m_data.objectReference.ptr == NULL); + return (m_data.objectReference.ptr == nullptr); case DATATYPE_I8: case DATATYPE_U8: @@ -1161,7 +1205,7 @@ CLR_UINT32 CLR_RT_HeapBlock::GetHashCode(CLR_RT_HeapBlock *ptr, bool fRecurse, C // DATATYPE_I8 // DATATYPE_U8 // DATATYPE_R8 - if (fRecurse && cls.m_target->dataType <= DATATYPE_R8) + if (fRecurse && cls.target->dataType <= DATATYPE_R8) { // pass the 1st field which is the one holding the actual value crc ^= GetHashCode(&ptr[CLR_RT_HeapBlock::HB_Object_Fields_Offset], false, crc); @@ -1173,7 +1217,7 @@ CLR_UINT32 CLR_RT_HeapBlock::GetHashCode(CLR_RT_HeapBlock *ptr, bool fRecurse, C if (fRecurse) { - int totFields = cls.CrossReference().m_totalFields; + int totFields = cls.CrossReference().totalFields; if (totFields > 0) { @@ -1266,13 +1310,13 @@ bool CLR_RT_HeapBlock::ObjectsEqual( return true; } - CLR_DataType leftDataType = pArgLeft.DataType(); - CLR_DataType rightDataType = pArgRight.DataType(); + NanoCLRDataType leftDataType = pArgLeft.DataType(); + NanoCLRDataType rightDataType = pArgRight.DataType(); switch (leftDataType) { case DATATYPE_VALUETYPE: - if (pArgLeft.ObjectCls().m_data == pArgRight.ObjectCls().m_data) + if (pArgLeft.ObjectCls().data == pArgRight.ObjectCls().data) { const CLR_RT_HeapBlock *objLeft = &pArgLeft; const CLR_RT_HeapBlock *objRight = &pArgRight; @@ -1397,13 +1441,13 @@ bool CLR_RT_HeapBlock::ObjectsEqual( if (rightObj->DataType() == DATATYPE_VALUETYPE) { CLR_RT_TypeDef_Instance inst{}; - CLR_RT_HeapBlock *obj = NULL; + CLR_RT_HeapBlock *obj = nullptr; if (!inst.InitializeFromIndex(rightObj->ObjectCls())) { } - if (inst.m_target->dataType != DATATYPE_VALUETYPE) + if (inst.target->dataType != DATATYPE_VALUETYPE) { // boxed primitive or enum type obj = &rightObj[1]; @@ -1418,7 +1462,7 @@ bool CLR_RT_HeapBlock::ObjectsEqual( } else { - if (rightObj == NULL) + if (rightObj == nullptr) { return false; } @@ -1463,7 +1507,7 @@ static const CLR_RT_HeapBlock *FixReflectionForType(const CLR_RT_HeapBlock &src, NATIVE_PROFILE_CLR_CORE(); const CLR_RT_ReflectionDef_Index &rd = src.ReflectionDataConst(); - if (rd.m_kind == REFLECTION_TYPE) + if (rd.kind == REFLECTION_TYPE) { CLR_RT_TypeDef_Instance inst{}; CLR_UINT32 levels; @@ -1474,7 +1518,7 @@ static const CLR_RT_HeapBlock *FixReflectionForType(const CLR_RT_HeapBlock &src, CLR_RT_ReflectionDef_Index &rd2 = tmp.ReflectionData(); - rd2.InitializeFromHash(inst.CrossReference().m_hash); + rd2.InitializeFromHash(inst.CrossReference().hash); return &tmp; } @@ -1590,8 +1634,8 @@ static inline int CompareValues_Pointers(const CLR_RT_HeapBlock *left, const CLR CLR_INT32 CLR_RT_HeapBlock::Compare_Values(const CLR_RT_HeapBlock &left, const CLR_RT_HeapBlock &right, bool fSigned) { NATIVE_PROFILE_CLR_CORE(); - CLR_DataType leftDataType = left.DataType(); - CLR_DataType rightDataType = right.DataType(); + NanoCLRDataType leftDataType = left.DataType(); + NanoCLRDataType rightDataType = right.DataType(); if (leftDataType == rightDataType) { @@ -1608,11 +1652,11 @@ CLR_INT32 CLR_RT_HeapBlock::Compare_Values(const CLR_RT_HeapBlock &left, const C if (!leftObj) { - return !rightObj ? 0 : -1; // NULL references always compare smaller than non-NULL ones. + return !rightObj ? 0 : -1; // nullptr references always compare smaller than non-nullptr ones. } else if (!rightObj) { - return 1; // NULL references always compare smaller than non-NULL ones. + return 1; // nullptr references always compare smaller than non-nullptr ones. } return Compare_Values(*leftObj, *rightObj, fSigned); @@ -1647,11 +1691,11 @@ CLR_INT32 CLR_RT_HeapBlock::Compare_Values(const CLR_RT_HeapBlock &left, const C if (!leftLen) { - return !rightLen ? 0 : -1; // NULL references always compare smaller than non-NULL ones. + return !rightLen ? 0 : -1; // nullptr references always compare smaller than non-nullptr ones. } else // rightLen != 0 for sure. { - return 1; // NULL references always compare smaller than non-NULL ones. + return 1; // nullptr references always compare smaller than non-nullptr ones. } } @@ -1659,8 +1703,8 @@ CLR_INT32 CLR_RT_HeapBlock::Compare_Values(const CLR_RT_HeapBlock &left, const C { CLR_RT_HeapBlock_Delegate *leftDlg = (CLR_RT_HeapBlock_Delegate *)&left; CLR_RT_HeapBlock_Delegate *rightDlg = (CLR_RT_HeapBlock_Delegate *)&right; - CLR_UINT32 leftData = leftDlg->DelegateFtn().m_data; - CLR_UINT32 rightData = rightDlg->DelegateFtn().m_data; + CLR_UINT32 leftData = leftDlg->DelegateFtn().data; + CLR_UINT32 rightData = rightDlg->DelegateFtn().data; if (leftData > rightData) return 1; @@ -1683,7 +1727,7 @@ CLR_INT32 CLR_RT_HeapBlock::Compare_Values(const CLR_RT_HeapBlock &left, const C CLR_RT_HeapBlock hbLeft; CLR_RT_HeapBlock hbRight; - if (left.ReflectionDataConst().m_kind != right.ReflectionDataConst().m_kind) + if (left.ReflectionDataConst().kind != right.ReflectionDataConst().kind) { ptrLeft = FixReflectionForType(left, hbLeft); ptrRight = FixReflectionForType(right, hbRight); @@ -1803,7 +1847,7 @@ CLR_INT32 CLR_RT_HeapBlock::Compare_Values(const CLR_RT_HeapBlock &left, const C if (!rightObj) { - return 1; // NULL references always compare smaller than non-NULL ones. + return 1; // nullptr references always compare smaller than non-nullptr ones. } return Compare_Values(left, *rightObj, fSigned); @@ -1815,7 +1859,7 @@ CLR_INT32 CLR_RT_HeapBlock::Compare_Values(const CLR_RT_HeapBlock &left, const C if (!leftObj) { - return -1; // NULL references always compare smaller than non-NULL ones. + return -1; // nullptr references always compare smaller than non-nullptr ones. } return Compare_Values(*leftObj, right, fSigned); @@ -1921,7 +1965,7 @@ HRESULT CLR_RT_HeapBlock::NumericAdd(const CLR_RT_HeapBlock &right) // Adding of value to array reference is like advancing the index in array. case DATATYPE_ARRAY_BYREF: { - // Retrieve refernced array. Test if it is not NULL + // Retrieve refernced array. Test if it is not nullptr CLR_RT_HeapBlock_Array *array = m_data.arrayReference.array; FAULT_ON_NULL(array); // Advance current index. C# on pointer operations multiplies the offset by object size. We need to reverse @@ -2008,7 +2052,7 @@ HRESULT CLR_RT_HeapBlock::NumericSub(const CLR_RT_HeapBlock &right) // Substructing of value to array reference is like decreasing the index in array. case DATATYPE_ARRAY_BYREF: { - // Retrieve refernced array. Test if it is not NULL + // Retrieve refernced array. Test if it is not nullptr CLR_RT_HeapBlock_Array *array = m_data.arrayReference.array; FAULT_ON_NULL(array); // Advance current index. C# on pointer operations multiplies the offset by object size. We need to reverse @@ -2445,7 +2489,7 @@ HRESULT CLR_RT_HeapBlock::TransparentProxyValidate() const CLR_RT_AppDomain *appDomain = TransparentProxyAppDomain(); CLR_RT_HeapBlock *obj = TransparentProxyDereference(); - if (appDomain == NULL || !appDomain->IsLoaded()) + if (appDomain == nullptr || !appDomain->IsLoaded()) NANOCLR_SET_AND_LEAVE(CLR_E_APPDOMAIN_EXITED); FAULT_ON_NULL(obj); diff --git a/src/CLR/Core/CLR_RT_HeapBlock_Array.cpp b/src/CLR/Core/CLR_RT_HeapBlock_Array.cpp index 1c53239e64..7190963a25 100644 --- a/src/CLR/Core/CLR_RT_HeapBlock_Array.cpp +++ b/src/CLR/Core/CLR_RT_HeapBlock_Array.cpp @@ -19,23 +19,23 @@ HRESULT CLR_RT_HeapBlock_Array::CreateInstance( CLR_RT_TypeDef_Index cls; CLR_RT_TypeDef_Instance inst{}; - reference.SetObjectReference(NULL); + reference.SetObjectReference(nullptr); if ((CLR_INT32)length < 0) NANOCLR_SET_AND_LEAVE(CLR_E_OUT_OF_RANGE); - if (reflex.m_kind != REFLECTION_TYPE) + if (reflex.kind != REFLECTION_TYPE) { NANOCLR_SET_AND_LEAVE(CLR_E_WRONG_TYPE); } - if (reflex.m_levels == 1) + if (reflex.levels == 1) { - cls = reflex.m_data.m_type; + cls = reflex.data.type; } else { - cls = g_CLR_RT_WellKnownTypes.m_Array; + cls = g_CLR_RT_WellKnownTypes.Array; } if (inst.InitializeFromIndex(cls) == false) @@ -44,7 +44,7 @@ HRESULT CLR_RT_HeapBlock_Array::CreateInstance( } else { - CLR_DataType dt = (CLR_DataType)inst.m_target->dataType; + NanoCLRDataType dt = (NanoCLRDataType)inst.target->dataType; const CLR_RT_DataTypeLookup &dtl = c_CLR_RT_DataTypeLookup[dt]; if (dtl.m_sizeInBytes == CLR_RT_DataTypeLookup::c_NA) @@ -73,9 +73,9 @@ HRESULT CLR_RT_HeapBlock_Array::CreateInstance( CLR_RT_ReflectionDef_Index reflex; - reflex.m_kind = REFLECTION_TYPE; - reflex.m_levels = 1; - reflex.m_data.m_type = cls; + reflex.kind = REFLECTION_TYPE; + reflex.levels = 1; + reflex.data.type = cls; NANOCLR_SET_AND_LEAVE(CreateInstance(reference, length, reflex)); @@ -110,7 +110,7 @@ HRESULT CLR_RT_HeapBlock_Array::CreateInstance( NANOCLR_SET_AND_LEAVE(CLR_E_WRONG_TYPE); } - ref.ReflectionData().m_levels++; + ref.ReflectionData().levels++; NANOCLR_SET_AND_LEAVE(CreateInstance(reference, length, ref.ReflectionData())); @@ -129,8 +129,8 @@ HRESULT CLR_RT_HeapBlock_Array::ClearElements(int index, int length) if (m_fReference) { - CLR_DataType dt = (CLR_DataType)m_typeOfElement; - bool fAllocate = (reflex.m_levels == 1 && dt == DATATYPE_VALUETYPE); + NanoCLRDataType dt = (NanoCLRDataType)m_typeOfElement; + bool fAllocate = (reflex.levels == 1 && dt == DATATYPE_VALUETYPE); CLR_RT_HeapBlock *ptr = (CLR_RT_HeapBlock *)data; switch (dt) @@ -152,7 +152,7 @@ HRESULT CLR_RT_HeapBlock_Array::ClearElements(int index, int length) if (fAllocate) { - NANOCLR_CHECK_HRESULT(g_CLR_RT_ExecutionEngine.NewObjectFromIndex(*ptr, reflex.m_data.m_type)); + NANOCLR_CHECK_HRESULT(g_CLR_RT_ExecutionEngine.NewObjectFromIndex(*ptr, reflex.data.type)); } ptr++; @@ -375,7 +375,7 @@ HRESULT CLR_RT_HeapBlock_Array::Copy( for (int i = 0; i < length; i++, ptrSrc++, ptrDst++) { - if (ptrSrc->DataType() == DATATYPE_OBJECT && ptrSrc->Dereference() == NULL) + if (ptrSrc->DataType() == DATATYPE_OBJECT && ptrSrc->Dereference() == nullptr) { ; } @@ -399,7 +399,7 @@ HRESULT CLR_RT_HeapBlock_Array::Copy( CLR_RT_HeapBlock ref; CLR_RT_HeapBlock elem; - elem.SetObjectReference(NULL); + elem.SetObjectReference(nullptr); CLR_RT_ProtectFromGC gc(elem); NANOCLR_CHECK_HRESULT(descDst.InitializeFromObject(*arrayDst)); @@ -410,7 +410,7 @@ HRESULT CLR_RT_HeapBlock_Array::Copy( ref.InitializeArrayReferenceDirect(*arraySrc, indexSrc++); NANOCLR_CHECK_HRESULT(elem.LoadFromReference(ref)); - if (elem.DataType() == DATATYPE_OBJECT && elem.Dereference() == NULL) + if (elem.DataType() == DATATYPE_OBJECT && elem.Dereference() == nullptr) { ; } diff --git a/src/CLR/Core/CLR_RT_HeapBlock_ArrayList.cpp b/src/CLR/Core/CLR_RT_HeapBlock_ArrayList.cpp index b89c9b8d99..5c9cd65968 100644 --- a/src/CLR/Core/CLR_RT_HeapBlock_ArrayList.cpp +++ b/src/CLR/Core/CLR_RT_HeapBlock_ArrayList.cpp @@ -148,7 +148,7 @@ HRESULT CLR_RT_HeapBlock_ArrayList::RemoveAt(CLR_INT32 index) size--; - ((CLR_RT_HeapBlock *)items->GetElement(size))->SetObjectReference(NULL); + ((CLR_RT_HeapBlock *)items->GetElement(size))->SetObjectReference(nullptr); SetSize(size); @@ -180,7 +180,7 @@ HRESULT CLR_RT_HeapBlock_ArrayList::SetCapacity(CLR_UINT32 newCapacity) } NANOCLR_CHECK_HRESULT( - CLR_RT_HeapBlock_Array::CreateInstance(newItemsHB, newCapacity, g_CLR_RT_WellKnownTypes.m_Object)); + CLR_RT_HeapBlock_Array::CreateInstance(newItemsHB, newCapacity, g_CLR_RT_WellKnownTypes.Object)); newItems = newItemsHB.DereferenceArray(); diff --git a/src/CLR/Core/CLR_RT_HeapBlock_BinaryBlob.cpp b/src/CLR/Core/CLR_RT_HeapBlock_BinaryBlob.cpp index 874003f016..fecabed004 100644 --- a/src/CLR/Core/CLR_RT_HeapBlock_BinaryBlob.cpp +++ b/src/CLR/Core/CLR_RT_HeapBlock_BinaryBlob.cpp @@ -23,7 +23,7 @@ HRESULT CLR_RT_HeapBlock_BinaryBlob::CreateInstance( reference.SetObjectReference(obj); obj->SetBinaryBlobHandlers(mark, relocate); - obj->m_assembly = NULL; + obj->m_assembly = nullptr; NANOCLR_NOCLEANUP(); } @@ -52,7 +52,7 @@ CLR_RT_HeapBlock_BinaryBlob *CLR_RT_HeapBlock_BinaryBlob::Allocate(CLR_UINT32 le if (obj) { - obj->SetBinaryBlobHandlers(NULL, NULL); + obj->SetBinaryBlobHandlers(nullptr, nullptr); } return obj; @@ -61,7 +61,7 @@ CLR_RT_HeapBlock_BinaryBlob *CLR_RT_HeapBlock_BinaryBlob::Allocate(CLR_UINT32 le void CLR_RT_HeapBlock_BinaryBlob::Release(bool fEvent) { NATIVE_PROFILE_CLR_CORE(); - SetBinaryBlobHandlers(NULL, NULL); + SetBinaryBlobHandlers(nullptr, nullptr); if (fEvent) g_CLR_RT_EventCache.Append_Node(this); diff --git a/src/CLR/Core/CLR_RT_HeapBlock_Delegate.cpp b/src/CLR/Core/CLR_RT_HeapBlock_Delegate.cpp index 9e7c1bfb7a..f5b2d5629f 100644 --- a/src/CLR/Core/CLR_RT_HeapBlock_Delegate.cpp +++ b/src/CLR/Core/CLR_RT_HeapBlock_Delegate.cpp @@ -1,4 +1,4 @@ -// +// // Copyright (c) .NET Foundation and Contributors // Portions Copyright (c) Microsoft Corporation. All rights reserved. // See LICENSE file in the project root for full license information. @@ -15,7 +15,7 @@ HRESULT CLR_RT_HeapBlock_Delegate::CreateInstance( NATIVE_PROFILE_CLR_CORE(); NANOCLR_HEADER(); - reference.SetObjectReference(NULL); + reference.SetObjectReference(nullptr); CLR_UINT32 length = 0; @@ -55,7 +55,7 @@ HRESULT CLR_RT_HeapBlock_Delegate::CreateInstance( dlg->m_numOfStackFrames = length; #endif - dlg->m_object.SetObjectReference(NULL); + dlg->m_object.SetObjectReference(nullptr); #if defined(NANOCLR_APPDOMAINS) dlg->m_appDomain = g_CLR_RT_ExecutionEngine.GetCurrentAppDomain(); diff --git a/src/CLR/Core/CLR_RT_HeapBlock_Delegate_List.cpp b/src/CLR/Core/CLR_RT_HeapBlock_Delegate_List.cpp index 41603109c1..36401d8494 100644 --- a/src/CLR/Core/CLR_RT_HeapBlock_Delegate_List.cpp +++ b/src/CLR/Core/CLR_RT_HeapBlock_Delegate_List.cpp @@ -73,7 +73,7 @@ HRESULT CLR_RT_HeapBlock_Delegate_List::Change( CLR_UINT32 num = 0; - reference.SetObjectReference(NULL); + reference.SetObjectReference(nullptr); if (delegateSrc.DataType() != DATATYPE_OBJECT || delegateTarget.DataType() != DATATYPE_OBJECT) { @@ -82,7 +82,7 @@ HRESULT CLR_RT_HeapBlock_Delegate_List::Change( dlg = delegateTarget.DereferenceDelegate(); - if (dlg == NULL) + if (dlg == nullptr) { reference.SetObjectReference(delegateSrc.DereferenceDelegate()); NANOCLR_SET_AND_LEAVE(S_OK); @@ -101,7 +101,7 @@ HRESULT CLR_RT_HeapBlock_Delegate_List::Change( for (num = 0; num < dlgListDst->m_length; num++, newDlgs++) { if (newDlgs->DataType() == DATATYPE_OBJECT && - newDlgs->DereferenceDelegate() != NULL) // The delegate could have been GC'ed. + newDlgs->DereferenceDelegate() != nullptr) // The delegate could have been GC'ed. { NANOCLR_CHECK_HRESULT(Change(reference, intermediate, *newDlgs, fCombine, fWeak)); @@ -112,9 +112,9 @@ HRESULT CLR_RT_HeapBlock_Delegate_List::Change( else { dlgListSrc = delegateSrc.DereferenceDelegateList(); - if (dlgListSrc == NULL) + if (dlgListSrc == nullptr) { - oldDlgs = NULL; + oldDlgs = nullptr; oldNum = 0; } else @@ -158,7 +158,7 @@ HRESULT CLR_RT_HeapBlock_Delegate_List::Change( CLR_RT_HeapBlock_Delegate *ptr = newDlgs->DereferenceDelegate(); if (ptr) { - if (ptr->DelegateFtn().m_data == dlg->DelegateFtn().m_data && + if (ptr->DelegateFtn().data == dlg->DelegateFtn().data && ptr->m_object.Dereference() == dlg->m_object.Dereference()) { break; @@ -180,7 +180,7 @@ HRESULT CLR_RT_HeapBlock_Delegate_List::Change( if (oldNum == 1) { - reference.SetObjectReference(NULL); // Oops, empty delegate... + reference.SetObjectReference(nullptr); // Oops, empty delegate... NANOCLR_SET_AND_LEAVE(S_OK); } diff --git a/src/CLR/Core/CLR_RT_HeapBlock_Finalizer.cpp b/src/CLR/Core/CLR_RT_HeapBlock_Finalizer.cpp index 74d77b9489..fcadfa96f8 100644 --- a/src/CLR/Core/CLR_RT_HeapBlock_Finalizer.cpp +++ b/src/CLR/Core/CLR_RT_HeapBlock_Finalizer.cpp @@ -16,11 +16,11 @@ HRESULT CLR_RT_HeapBlock_Finalizer::CreateInstance(CLR_RT_HeapBlock *object, con do { - if (inst2.m_target->flags & CLR_RECORD_TYPEDEF::TD_HasFinalizer) + if (inst2.target->flags & CLR_RECORD_TYPEDEF::TD_HasFinalizer) { - int pos = inst2.m_target->methods_First; - int end = pos + inst2.m_target->vMethods_Num + inst2.m_target->iMethods_Num; - const CLR_RECORD_METHODDEF *md = inst2.m_assm->GetMethodDef(pos); + int pos = inst2.target->firstMethod; + int end = pos + inst2.target->virtualMethodCount + inst2.target->instanceMethodCount; + const CLR_RECORD_METHODDEF *md = inst2.assembly->GetMethodDef(pos); for (; pos < end; pos++, md++) { diff --git a/src/CLR/Core/CLR_RT_HeapBlock_GenericInstance.cpp b/src/CLR/Core/CLR_RT_HeapBlock_GenericInstance.cpp new file mode 100644 index 0000000000..aeae267dc0 --- /dev/null +++ b/src/CLR/Core/CLR_RT_HeapBlock_GenericInstance.cpp @@ -0,0 +1,88 @@ +// +// Copyright (c) .NET Foundation and Contributors +// Portions Copyright (c) Microsoft Corporation. All rights reserved. +// See LICENSE file in the project root for full license information. +// + +#include "Core.h" + +//////////////////////////////////////////////////////////////////////////////////////////////////// + +HRESULT CLR_RT_HeapBlock_GenericInstance::CreateInstance( + CLR_RT_HeapBlock &reference, + const CLR_RT_TypeSpec_Index &tsIndex) +{ + NATIVE_PROFILE_CLR_CORE(); + NANOCLR_HEADER(); + + (void)reference; + (void)tsIndex; + + // reference.SetObjectReference( nullptr ); + + // CLR_UINT32 length = 0; + + // #if defined(NANOCLR_DELEGATE_PRESERVE_STACK) + // if(call) + // { + // NANOCLR_FOREACH_NODE_BACKWARD__DIRECT(CLR_RT_StackFrame,ptr,call) + // { + // length++; + // } + // NANOCLR_FOREACH_NODE_BACKWARD_END(); + // } + + // // + // // Limit depth to three callers. + // // + // if(length > 3) length = 3; + // #else + // (void)call; + // #endif + + // CLR_UINT32 totLength = (CLR_UINT32)(sizeof(CLR_RT_HeapBlock_Delegate) + length * + // sizeof(CLR_RT_MethodDef_Index)); + + // CLR_RT_HeapBlock_Delegate* dlg = + // (CLR_RT_HeapBlock_Delegate*)g_CLR_RT_ExecutionEngine.ExtractHeapBytesForObjects( DATATYPE_DELEGATE_HEAD, 0, + // totLength ); CHECK_ALLOCATION(dlg); + + // reference.SetObjectReference( dlg ); + + // dlg->ClearData(); + // dlg->m_cls.Clear(); + // dlg->m_ftn = ftn; + // #if defined(NANOCLR_DELEGATE_PRESERVE_STACK) + // dlg->m_numOfStackFrames = length; + // #endif + + // dlg->m_object.SetObjectReference( nullptr ); + + // #if defined(NANOCLR_APPDOMAINS) + // dlg->m_appDomain = g_CLR_RT_ExecutionEngine.GetCurrentAppDomain(); + // #endif + + // #if defined(NANOCLR_DELEGATE_PRESERVE_STACK) + // if(call) + // { + // CLR_RT_MethodDef_Index* callStack = dlg->GetStackFrames(); + + // NANOCLR_FOREACH_NODE_BACKWARD__DIRECT(CLR_RT_StackFrame,ptr,call) + // { + // if(length-- == 0) break; + + // *callStack++ = ptr->m_call; + // } + // NANOCLR_FOREACH_NODE_BACKWARD_END(); + // } + // #endif + + // NANOCLR_NOCLEANUP(); + NANOCLR_NOCLEANUP_NOLABEL(); +} + +void CLR_RT_HeapBlock_GenericInstance::Relocate() +{ + NATIVE_PROFILE_CLR_CORE(); + // m_object.Relocate__HeapBlock(); +} diff --git a/src/CLR/Core/CLR_RT_HeapBlock_Lock.cpp b/src/CLR/Core/CLR_RT_HeapBlock_Lock.cpp index b46c5835d8..4cb2ef96e5 100644 --- a/src/CLR/Core/CLR_RT_HeapBlock_Lock.cpp +++ b/src/CLR/Core/CLR_RT_HeapBlock_Lock.cpp @@ -138,7 +138,7 @@ void CLR_RT_HeapBlock_Lock::ChangeOwner() { case DATATYPE_VALUETYPE: case DATATYPE_CLASS: - ptr->SetObjectLock(NULL); + ptr->SetObjectLock(nullptr); break; default: diff --git a/src/CLR/Core/CLR_RT_HeapBlock_Queue.cpp b/src/CLR/Core/CLR_RT_HeapBlock_Queue.cpp index d1779be283..4750349146 100644 --- a/src/CLR/Core/CLR_RT_HeapBlock_Queue.cpp +++ b/src/CLR/Core/CLR_RT_HeapBlock_Queue.cpp @@ -25,7 +25,7 @@ HRESULT CLR_RT_HeapBlock_Queue::Dequeue(CLR_RT_HeapBlock *&value) value = removed->Dereference(); - removed->SetObjectReference(NULL); + removed->SetObjectReference(nullptr); SetHead((head + 1) % array->m_numOfElements); @@ -59,7 +59,7 @@ HRESULT CLR_RT_HeapBlock_Queue::Enqueue(CLR_RT_HeapBlock *value) capacity *= 2; NANOCLR_CHECK_HRESULT( - CLR_RT_HeapBlock_Array::CreateInstance(newArrayHB, capacity, g_CLR_RT_WellKnownTypes.m_Object)); + CLR_RT_HeapBlock_Array::CreateInstance(newArrayHB, capacity, g_CLR_RT_WellKnownTypes.Object)); array = newArrayHB.DereferenceArray(); diff --git a/src/CLR/Core/CLR_RT_HeapBlock_Stack.cpp b/src/CLR/Core/CLR_RT_HeapBlock_Stack.cpp index f679e2945c..e337ac79db 100644 --- a/src/CLR/Core/CLR_RT_HeapBlock_Stack.cpp +++ b/src/CLR/Core/CLR_RT_HeapBlock_Stack.cpp @@ -26,7 +26,7 @@ HRESULT CLR_RT_HeapBlock_Stack::Pop(CLR_RT_HeapBlock *&value) value = removed->Dereference(); - removed->SetObjectReference(NULL); + removed->SetObjectReference(nullptr); SetSize(size - 1); @@ -58,11 +58,11 @@ HRESULT CLR_RT_HeapBlock_Stack::Push(CLR_RT_HeapBlock *value) capacity *= 2; NANOCLR_CHECK_HRESULT( - CLR_RT_HeapBlock_Array::CreateInstance(newArrayHB, capacity, g_CLR_RT_WellKnownTypes.m_Object)); + CLR_RT_HeapBlock_Array::CreateInstance(newArrayHB, capacity, g_CLR_RT_WellKnownTypes.Object)); newArray = newArrayHB.DereferenceArray(); - memcpy(newArray->GetElement(size), array->GetFirstElement(), size * sizeof(struct CLR_RT_HeapBlock)); + memcpy(newArray->GetElement(size), array->GetFirstElement(), size * sizeof(CLR_RT_HeapBlock)); SetArray(newArray); array = newArray; diff --git a/src/CLR/Core/CLR_RT_HeapBlock_String.cpp b/src/CLR/Core/CLR_RT_HeapBlock_String.cpp index 796def9dd9..4e5d2ff0c4 100644 --- a/src/CLR/Core/CLR_RT_HeapBlock_String.cpp +++ b/src/CLR/Core/CLR_RT_HeapBlock_String.cpp @@ -15,7 +15,7 @@ CLR_RT_HeapBlock_String *CLR_RT_HeapBlock_String::CreateInstance(CLR_RT_HeapBloc CLR_UINT32 totLength = sizeof(CLR_RT_HeapBlock_String) + length + 1; CLR_RT_HeapBlock_String *str; - reference.SetObjectReference(NULL); + reference.SetObjectReference(nullptr); str = (CLR_RT_HeapBlock_String *)g_CLR_RT_ExecutionEngine.ExtractHeapBytesForObjects(DATATYPE_STRING, 0, totLength); if (str) @@ -30,7 +30,7 @@ CLR_RT_HeapBlock_String *CLR_RT_HeapBlock_String::CreateInstance(CLR_RT_HeapBloc #if defined(NANOCLR_NO_ASSEMBLY_STRINGS) str->SetStringText(szText); #else - str->SetStringText(szText, NULL); + str->SetStringText(szText, nullptr); #endif // store reference to the storage area @@ -88,7 +88,7 @@ HRESULT CLR_RT_HeapBlock_String::CreateInstance(CLR_RT_HeapBlock &reference, con CLR_RT_HeapBlock_String *str; - reference.SetObjectReference(NULL); + reference.SetObjectReference(nullptr); // get heap block for the string object // only the header is required as we're just pointing to the string stored in the assembly diff --git a/src/CLR/Core/CLR_RT_HeapBlock_Timer.cpp b/src/CLR/Core/CLR_RT_HeapBlock_Timer.cpp index bc0219b744..7b1db7e760 100644 --- a/src/CLR/Core/CLR_RT_HeapBlock_Timer.cpp +++ b/src/CLR/Core/CLR_RT_HeapBlock_Timer.cpp @@ -12,7 +12,7 @@ HRESULT CLR_RT_HeapBlock_Timer::CreateInstance(CLR_UINT32 flags, CLR_RT_HeapBloc NATIVE_PROFILE_CLR_CORE(); NANOCLR_HEADER(); - CLR_RT_HeapBlock_Timer *timer = NULL; + CLR_RT_HeapBlock_Timer *timer = nullptr; // // Create a request and stop the calling thread. @@ -99,9 +99,9 @@ void CLR_RT_HeapBlock_Timer::SpawnTimer(CLR_RT_Thread *th) CLR_RT_HeapBlock_Delegate *delegate = callback->DereferenceDelegate(); CLR_RT_ProtectFromGC gc(*managedTimer); - _ASSERTE(delegate != NULL); + _ASSERTE(delegate != nullptr); - if (delegate == NULL) + if (delegate == nullptr) { return; } @@ -115,12 +115,12 @@ void CLR_RT_HeapBlock_Timer::SpawnTimer(CLR_RT_Thread *th) if (SUCCEEDED(th->PushThreadProcDelegate(delegate))) { CLR_RT_StackFrame *stack = th->FirstFrame(); - if (stack->Next() != NULL) + if (stack->Next() != nullptr) { - int numArgs = stack->m_call.m_target->numArgs; - if (numArgs > 0) + int ArgumentsCount = stack->m_call.target->argumentsCount; + if (ArgumentsCount > 0) { - stack->m_arguments[numArgs - 1].Assign(*state); + stack->m_arguments[ArgumentsCount - 1].Assign(*state); } } @@ -245,7 +245,7 @@ HRESULT CLR_RT_HeapBlock_Timer::ConfigureObject(CLR_RT_StackFrame &stack, CLR_UI if (flags & CLR_RT_HeapBlock_Timer::c_ACTION_Create) { - FAULT_ON_NULL_ARG(args[0].DereferenceDelegate()); + FAULT_ON_NULL(args[0].DereferenceDelegate()); NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_Timer::CreateInstance( 0, diff --git a/src/CLR/Core/CLR_RT_HeapBlock_WaitForObject.cpp b/src/CLR/Core/CLR_RT_HeapBlock_WaitForObject.cpp index 903c312da8..4f0fd28e13 100644 --- a/src/CLR/Core/CLR_RT_HeapBlock_WaitForObject.cpp +++ b/src/CLR/Core/CLR_RT_HeapBlock_WaitForObject.cpp @@ -29,9 +29,12 @@ HRESULT CLR_RT_HeapBlock_WaitForObject::CreateInstance( _ASSERTE(sizeof(CLR_RT_HeapBlock_WaitForObject) % 4 == 0); + CLR_UINT32 totLength = (CLR_UINT32)(sizeof(CLR_RT_HeapBlock_WaitForObject) + cObjects * sizeof(struct CLR_RT_HeapBlock)); - + + _ASSERTE(sizeof(CLR_RT_HeapBlock_WaitForObject) % 4 == 0); + CLR_RT_HeapBlock_WaitForObject *wait = EVENTCACHE_EXTRACT_NODE_AS_BYTES( g_CLR_RT_EventCache, CLR_RT_HeapBlock_WaitForObject, @@ -94,7 +97,7 @@ bool CLR_RT_HeapBlock_WaitForObject::TryWaitForSignal( for (CLR_UINT32 i = 0; i < cObjects; i++) { obj = blk->Dereference(); - _ASSERTE(obj != NULL); + _ASSERTE(obj != nullptr); if (phase == 0) { @@ -124,7 +127,7 @@ bool CLR_RT_HeapBlock_WaitForObject::TryWaitForSignal( for (CLR_UINT32 i = 0; i < cObjects; i++) { obj = blk->Dereference(); - _ASSERTE(obj != NULL); + _ASSERTE(obj != nullptr); if (obj->IsFlagSet(CLR_RT_HeapBlock::HB_Signaled)) { diff --git a/src/CLR/Core/CLR_RT_HeapCluster.cpp b/src/CLR/Core/CLR_RT_HeapCluster.cpp index 45d30668aa..701e6f5012 100644 --- a/src/CLR/Core/CLR_RT_HeapCluster.cpp +++ b/src/CLR/Core/CLR_RT_HeapCluster.cpp @@ -28,15 +28,15 @@ void CLR_RT_HeapCluster::HeapCluster_Initialize(CLR_UINT32 size, CLR_UINT32 bloc { CLR_RT_HeapBlock_WeakReference *weak = (CLR_RT_HeapBlock_WeakReference *)(ptr); - if (weak->DataSize() == CONVERTFROMSIZETOHEAPBLOCKS(sizeof(*weak)) && weak->m_targetSerialized != NULL && + if (weak->DataSize() == CONVERTFROMSIZETOHEAPBLOCKS(sizeof(*weak)) && weak->m_targetSerialized != nullptr && (weak->m_identity.m_flags & CLR_RT_HeapBlock_WeakReference::WR_SurviveBoot)) { - weak->SetNext(NULL); - weak->SetPrev(NULL); + weak->SetNext(nullptr); + weak->SetPrev(nullptr); weak->m_identity.m_flags &= ~CLR_RT_HeapBlock_WeakReference::WR_Persisted; - weak->m_targetDirect = NULL; + weak->m_targetDirect = nullptr; weak->MarkAlive(); @@ -79,7 +79,7 @@ void CLR_RT_HeapCluster::HeapCluster_Initialize(CLR_UINT32 size, CLR_UINT32 bloc CLR_RT_HeapBlock *CLR_RT_HeapCluster::ExtractBlocks(CLR_UINT32 dataType, CLR_UINT32 flags, CLR_UINT32 length) { NATIVE_PROFILE_CLR_CORE(); - CLR_RT_HeapBlock_Node *res = NULL; + CLR_RT_HeapBlock_Node *res = nullptr; CLR_UINT32 available = 0; m_freeList.ValidateList(); @@ -109,10 +109,10 @@ CLR_RT_HeapBlock *CLR_RT_HeapCluster::ExtractBlocks(CLR_UINT32 dataType, CLR_UIN res = ptr; // sanity checks for out of bounds - if ((void *)res < (void *)s_CLR_RT_Heap.m_location || - (void *)res >= (void *)(s_CLR_RT_Heap.m_location + s_CLR_RT_Heap.m_size)) + if ((void *)res < (void *)s_CLR_RT_Heap.location || + (void *)res >= (void *)(s_CLR_RT_Heap.location + s_CLR_RT_Heap.size)) { - return NULL; + return nullptr; } break; @@ -129,12 +129,12 @@ CLR_RT_HeapBlock *CLR_RT_HeapCluster::ExtractBlocks(CLR_UINT32 dataType, CLR_UIN available -= length; // sanity checks for out of bounds - if (((void *)next < (void *)s_CLR_RT_Heap.m_location) || - (void *)next >= (void *)(s_CLR_RT_Heap.m_location + s_CLR_RT_Heap.m_size) || - (void *)prev < (void *)s_CLR_RT_Heap.m_location || - (void *)prev >= (void *)(s_CLR_RT_Heap.m_location + s_CLR_RT_Heap.m_size)) + if (((void *)next < (void *)s_CLR_RT_Heap.location) || + (void *)next >= (void *)(s_CLR_RT_Heap.location + s_CLR_RT_Heap.size) || + (void *)prev < (void *)s_CLR_RT_Heap.location || + (void *)prev >= (void *)(s_CLR_RT_Heap.location + s_CLR_RT_Heap.size)) { - return NULL; + return nullptr; } if (available != 0) @@ -146,10 +146,10 @@ CLR_RT_HeapBlock *CLR_RT_HeapCluster::ExtractBlocks(CLR_UINT32 dataType, CLR_UIN res += available; // sanity checks for out of bounds - if ((void *)res < (void *)s_CLR_RT_Heap.m_location || - (void *)res >= (void *)(s_CLR_RT_Heap.m_location + s_CLR_RT_Heap.m_size)) + if ((void *)res < (void *)s_CLR_RT_Heap.location || + (void *)res >= (void *)(s_CLR_RT_Heap.location + s_CLR_RT_Heap.size)) { - return NULL; + return nullptr; } } else @@ -157,10 +157,10 @@ CLR_RT_HeapBlock *CLR_RT_HeapCluster::ExtractBlocks(CLR_UINT32 dataType, CLR_UIN CLR_RT_HeapBlock_Node *ptr = &res[length]; // sanity checks for out of bounds - if ((void *)ptr < (void *)s_CLR_RT_Heap.m_location || - (void *)ptr >= (void *)(s_CLR_RT_Heap.m_location + s_CLR_RT_Heap.m_size)) + if ((void *)ptr < (void *)s_CLR_RT_Heap.location || + (void *)ptr >= (void *)(s_CLR_RT_Heap.location + s_CLR_RT_Heap.size)) { - return NULL; + return nullptr; } // @@ -214,7 +214,7 @@ void CLR_RT_HeapCluster::RecoverFromGC() // Open the free list. // CLR_RT_HeapBlock_Node *last = m_freeList.Head(); - last->SetPrev(NULL); + last->SetPrev(nullptr); while (ptr < end) { @@ -285,7 +285,7 @@ void CLR_RT_HeapCluster::RecoverFromGC() // last->SetNext(m_freeList.Tail()); m_freeList.Tail()->SetPrev(last); - m_freeList.Tail()->SetNext(NULL); + m_freeList.Tail()->SetNext(nullptr); } CLR_RT_HeapBlock_Node *CLR_RT_HeapCluster::InsertInOrder(CLR_RT_HeapBlock_Node *node, CLR_UINT32 size) diff --git a/src/CLR/Core/CLR_RT_Interop.cpp b/src/CLR/Core/CLR_RT_Interop.cpp index 7bd5be5836..90386e23c4 100644 --- a/src/CLR/Core/CLR_RT_Interop.cpp +++ b/src/CLR/Core/CLR_RT_Interop.cpp @@ -1,4 +1,4 @@ -// +// // Copyright (c) .NET Foundation and Contributors // Portions Copyright (c) Microsoft Corporation. All rights reserved. // See LICENSE file in the project root for full license information. @@ -146,7 +146,7 @@ HRESULT Interop_Marshal_LPCSTR(const CLR_RT_StackFrame &stackFrame, unsigned int NANOCLR_SET_AND_LEAVE(CLR_E_WRONG_TYPE); } - // Checks that the string was actually present in managed code, not a NULL reference to sting. + // Checks that the string was actually present in managed code, not a nullptr reference to sting. param = stackFrame.ArgN(paramIndex).RecoverString(); FAULT_ON_NULL(param); @@ -165,7 +165,7 @@ HRESULT Interop_Marshal_UNSUPPORTED_TYPE( UNSUPPORTED_TYPE ¶m) { NATIVE_PROFILE_CLR_CORE(); - param = NULL; + param = nullptr; return S_OK; } @@ -202,7 +202,7 @@ static HRESULT Interop_Marshal_NUMERIC_ARRAY( NATIVE_PROFILE_CLR_CORE(); NANOCLR_HEADER(); - CLR_RT_HeapBlock_Array *pHeapBlockArray = NULL; + CLR_RT_HeapBlock_Array *pHeapBlockArray = nullptr; if (stackFrame.ArgN(paramIndex).DataType() != DATATYPE_OBJECT) { @@ -808,7 +808,7 @@ HRESULT Interop_Marshal_UNSUPPORTED_TYPE_ByRef( NATIVE_PROFILE_CLR_CORE(); NANOCLR_HEADER(); NANOCLR_CHECK_HRESULT(((CLR_RT_HeapBlock *)pHeapBlock)->LoadFromReference(stackFrame.ArgN(paramIndex))); - pParam = NULL; + pParam = nullptr; NANOCLR_NOCLEANUP(); } @@ -978,7 +978,7 @@ signed __int64 &Interop_Marshal_GetField_double(CLR_RT_HeapBlock *pThis, unsigne #endif UNSUPPORTED_TYPE &Interop_Marshal_GetField_UNSUPPORTED_TYPE(CLR_RT_HeapBlock *pThis, unsigned int fieldIndex) { - return (UNSUPPORTED_TYPE &)(*((UNSUPPORTED_TYPE *)NULL)); + return (UNSUPPORTED_TYPE &)(*((UNSUPPORTED_TYPE *)nullptr)); } #ifdef __GNUC__ #pragma GCC diagnostic pop diff --git a/src/CLR/Core/CLR_RT_Memory.cpp b/src/CLR/Core/CLR_RT_Memory.cpp index cc59b1d200..c8e3500f27 100644 --- a/src/CLR/Core/CLR_RT_Memory.cpp +++ b/src/CLR/Core/CLR_RT_Memory.cpp @@ -22,11 +22,11 @@ static size_t s_PreHeapInitIndex = 0; void CLR_RT_Memory::Reset() { NATIVE_PROFILE_CLR_CORE(); - ::HeapLocation(s_CLR_RT_Heap.m_location, s_CLR_RT_Heap.m_size); + ::HeapLocation(s_CLR_RT_Heap.location, s_CLR_RT_Heap.size); // adjust GC thresholds - g_CLR_RT_GarbageCollector.c_memoryThreshold = (CLR_UINT32)(s_CLR_RT_Heap.m_size * HEAP_SIZE_THRESHOLD_RATIO); - g_CLR_RT_GarbageCollector.c_memoryThreshold2 = (CLR_UINT32)(s_CLR_RT_Heap.m_size * HEAP_SIZE_THRESHOLD_UPPER_RATIO); + g_CLR_RT_GarbageCollector.c_memoryThreshold = (CLR_UINT32)(s_CLR_RT_Heap.size * HEAP_SIZE_THRESHOLD_RATIO); + g_CLR_RT_GarbageCollector.c_memoryThreshold2 = (CLR_UINT32)(s_CLR_RT_Heap.size * HEAP_SIZE_THRESHOLD_UPPER_RATIO); #if defined(NANOCLR_TRACE_MALLOC) s_TotalAllocated = 0; @@ -38,14 +38,14 @@ void *CLR_RT_Memory::SubtractFromSystem(size_t len) NATIVE_PROFILE_CLR_CORE(); len = ROUNDTOMULTIPLE(len, uintptr_t); - if (len <= s_CLR_RT_Heap.m_size) + if (len <= s_CLR_RT_Heap.size) { - s_CLR_RT_Heap.m_size -= (uintptr_t)len; + s_CLR_RT_Heap.size -= (uintptr_t)len; - return &s_CLR_RT_Heap.m_location[s_CLR_RT_Heap.m_size]; + return &s_CLR_RT_Heap.location[s_CLR_RT_Heap.size]; } - return NULL; + return nullptr; } //--// @@ -64,7 +64,7 @@ void CLR_RT_Memory::Release(void *ptr) NATIVE_PROFILE_CLR_CORE(); // CLR heap not initialized yet, return (this is not an error condition because we allow pre - if (s_CLR_RT_Heap.m_size == 0) + if (s_CLR_RT_Heap.size == 0) { return; } @@ -125,9 +125,9 @@ void *CLR_RT_Memory::Allocate(size_t len, CLR_UINT32 flags) { NATIVE_PROFILE_CLR_CORE(); - if (s_CLR_RT_Heap.m_size == 0) + if (s_CLR_RT_Heap.size == 0) { - unsigned char *heapStart = NULL; + unsigned char *heapStart = nullptr; unsigned int heapSize = 0; ::HeapLocation(heapStart, heapSize); @@ -135,7 +135,7 @@ void *CLR_RT_Memory::Allocate(size_t len, CLR_UINT32 flags) if (len > heapSize) { ASSERT(false); - return NULL; + return nullptr; } // use the current index to prevent heap thrashing before initialization @@ -178,7 +178,7 @@ void *CLR_RT_Memory::Allocate(size_t len, CLR_UINT32 flags) return res; } - return NULL; + return nullptr; } void *CLR_RT_Memory::Allocate_And_Erase(size_t len, CLR_UINT32 flags) @@ -198,8 +198,11 @@ void *CLR_RT_Memory::ReAllocate(void *ptr, size_t len) // allocate always as an event but do not run GC on failure void *p = CLR_RT_Memory::Allocate(len, CLR_RT_HeapBlock::HB_Event | CLR_RT_HeapBlock::HB_NoGcOnFailedAllocation); + if (!p) - return NULL; + { + return nullptr; + } if (ptr) { diff --git a/src/CLR/Core/CLR_RT_ObjectToEvent_Source.cpp b/src/CLR/Core/CLR_RT_ObjectToEvent_Source.cpp index 7e7efb9059..2e64d6209a 100644 --- a/src/CLR/Core/CLR_RT_ObjectToEvent_Source.cpp +++ b/src/CLR/Core/CLR_RT_ObjectToEvent_Source.cpp @@ -35,7 +35,9 @@ CLR_RT_ObjectToEvent_Source *CLR_RT_ObjectToEvent_Source::ExtractInstance(CLR_RT { NATIVE_PROFILE_CLR_CORE(); if (reference.IsAReferenceOfThisType(DATATYPE_OBJECT_TO_EVENT) == false) - return NULL; + { + return nullptr; + } return (CLR_RT_ObjectToEvent_Source *)reference.Dereference(); } @@ -54,7 +56,7 @@ void CLR_RT_ObjectToEvent_Source::Detach() NATIVE_PROFILE_CLR_CORE(); if (m_referencePtr) { - m_referencePtr->SetObjectReference(NULL); + m_referencePtr->SetObjectReference(nullptr); } g_CLR_RT_EventCache.Append_Node(this); diff --git a/src/CLR/Core/CLR_RT_StackFrame.cpp b/src/CLR/Core/CLR_RT_StackFrame.cpp index 59bb94f05c..c2691bc1dc 100644 --- a/src/CLR/Core/CLR_RT_StackFrame.cpp +++ b/src/CLR/Core/CLR_RT_StackFrame.cpp @@ -31,10 +31,10 @@ HRESULT CLR_RT_StackFrame::Push(CLR_RT_Thread *th, const CLR_RT_MethodDef_Instan } #endif - assm = callInstPtr->m_assm; - md = callInstPtr->m_target; + assm = callInstPtr->assembly; + md = callInstPtr->target; - sizeLocals = md->numLocals; + sizeLocals = md->localsCount; #ifndef NANOCLR_NO_IL_INLINE sizeEvalStack = md->lengthEvalStack + CLR_RT_StackFrame::c_OverheadForNewObjOrInteropMethod + 1; #else @@ -109,17 +109,17 @@ HRESULT CLR_RT_StackFrame::Push(CLR_RT_Thread *th, const CLR_RT_MethodDef_Instan stack->m_evalStack; // CLR_RT_HeapBlock* m_evalStackPos; // EVENT HEAP - NO RELOCATION - stack->m_evalStackEnd = stack->m_evalStack + - sizeEvalStack; // CLR_RT_HeapBlock* m_evalStackEnd; // EVENT HEAP - NO RELOCATION - - stack->m_arguments = NULL; // CLR_RT_HeapBlock* m_arguments; // EVENT HEAP - NO RELOCATION - - // - // union - // { - stack->m_customState = 0; // CLR_UINT32 m_customState; - // void* m_customPointer; - // }; - // + sizeEvalStack; // CLR_RT_HeapBlock* m_evalStackEnd; // EVENT HEAP - NO RELOCATION - + stack->m_arguments = nullptr; // CLR_RT_HeapBlock* m_arguments; // EVENT HEAP - NO RELOCATION - + // + // union + // { + stack->m_customState = 0; // CLR_UINT32 m_customState; + // void* m_customPointer; + // }; + // #ifndef NANOCLR_NO_IL_INLINE - stack->m_inlineFrame = NULL; + stack->m_inlineFrame = nullptr; #endif #if defined(NANOCLR_PROFILE_NEW_CALLS) stack->m_callchain.Enter(stack); // CLR_PROF_CounterCallChain m_callchain; @@ -141,25 +141,25 @@ HRESULT CLR_RT_StackFrame::Push(CLR_RT_Thread *th, const CLR_RT_MethodDef_Instan stack->m_nativeMethod = (CLR_RT_MethodHandler)CLR_RT_Thread::Execute_DelegateInvoke; stack->m_flags = CLR_RT_StackFrame::c_MethodKind_Native; - stack->m_IPstart = NULL; + stack->m_IPstart = nullptr; } - else if (assm->m_nativeCode && (impl = assm->m_nativeCode[stack->m_call.Method()]) != NULL) + else if (assm->nativeCode && (impl = assm->nativeCode[stack->m_call.Method()]) != nullptr) { stack->m_nativeMethod = impl; stack->m_flags = CLR_RT_StackFrame::c_MethodKind_Native; - stack->m_IPstart = NULL; - stack->m_IP = NULL; + stack->m_IPstart = nullptr; + stack->m_IP = nullptr; } else { stack->m_nativeMethod = (CLR_RT_MethodHandler)CLR_RT_Thread::Execute_IL; - if (md->RVA == CLR_EmptyIndex) + if (md->rva == CLR_EmptyIndex) NANOCLR_SET_AND_LEAVE(CLR_E_NOT_SUPPORTED); stack->m_flags = CLR_RT_StackFrame::c_MethodKind_Interpreted; - stack->m_IPstart = assm->GetByteCode(md->RVA); + stack->m_IPstart = assm->GetByteCode(md->rva); stack->m_IP = stack->m_IPstart; } @@ -180,20 +180,24 @@ HRESULT CLR_RT_StackFrame::Push(CLR_RT_Thread *th, const CLR_RT_MethodDef_Instan #endif } - if (md->numLocals) + if (md->localsCount) { - NANOCLR_CHECK_HRESULT(g_CLR_RT_ExecutionEngine.InitializeLocals(stack->m_locals, assm, md)); + NANOCLR_CHECK_HRESULT(g_CLR_RT_ExecutionEngine.InitializeLocals(stack->m_locals, callInst)); } { - CLR_UINT32 flags = md->flags & (md->MD_Synchronized | md->MD_GloballySynchronized); + CLR_UINT32 syncFlags = md->flags & (md->MD_Synchronized | md->MD_GloballySynchronized); - if (flags) + if (syncFlags) { - if (flags & md->MD_Synchronized) + if (syncFlags & md->MD_Synchronized) + { stack->m_flags |= c_NeedToSynchronize; - if (flags & md->MD_GloballySynchronized) + } + if (syncFlags & md->MD_GloballySynchronized) + { stack->m_flags |= c_NeedToSynchronizeGlobally; + } } } @@ -208,7 +212,7 @@ HRESULT CLR_RT_StackFrame::Push(CLR_RT_Thread *th, const CLR_RT_MethodDef_Instan } if (stack->m_owningThread->m_fHasJMCStepper || (stack->m_flags & c_HasBreakpoint) || - (caller->Prev() != NULL && (caller->m_flags & c_HasBreakpoint))) + (caller->Prev() != nullptr && (caller->m_flags & c_HasBreakpoint))) { g_CLR_RT_ExecutionEngine.Breakpoint_StackFrame_Push( stack, @@ -219,7 +223,7 @@ HRESULT CLR_RT_StackFrame::Push(CLR_RT_Thread *th, const CLR_RT_MethodDef_Instan //--// - if (caller->Prev() != NULL && caller->m_nativeMethod == stack->m_nativeMethod) + if (caller->Prev() != nullptr && caller->m_nativeMethod == stack->m_nativeMethod) { if (stack->m_flags & CLR_RT_StackFrame::c_ProcessSynchronize) { @@ -247,7 +251,7 @@ HRESULT CLR_RT_StackFrame::Push(CLR_RT_Thread *th, const CLR_RT_MethodDef_Instan // // Everything is set up correctly, pop the operands. // - stack->m_arguments = &caller->m_evalStackPos[-md->numArgs]; + stack->m_arguments = &caller->m_evalStackPos[-md->argumentsCount]; caller->m_evalStackPos = stack->m_arguments; @@ -276,26 +280,26 @@ bool CLR_RT_StackFrame::PushInline( CLR_RT_MethodDef_Instance &calleeInst, CLR_RT_HeapBlock *pThis) { - const CLR_RECORD_METHODDEF *md = calleeInst.m_target; + const CLR_RECORD_METHODDEF *md = calleeInst.target; - if ((m_inlineFrame != NULL) || // We can only support one inline at a time per stack call - (m_evalStackEnd - evalPos) <= (md->numArgs + md->numLocals + md->lengthEvalStack + + if ((m_inlineFrame != nullptr) || // We can only support one inline at a time per stack call + (m_evalStackEnd - evalPos) <= (md->argumentsCount + md->localsCount + md->lengthEvalStack + 2) || // We must have enough space on the current stack for the inline method (m_nativeMethod != (CLR_RT_MethodHandler)CLR_RT_Thread::Execute_IL) || // We only support IL inlining (md->flags & ~CLR_RECORD_METHODDEF::MD_HasExceptionHandlers) >= CLR_RECORD_METHODDEF::MD_Constructor || // Do not try to inline constructors, etc because they require // special processing (0 != (md->flags & CLR_RECORD_METHODDEF::MD_Static)) || // Static methods also requires special processing - (calleeInst.m_assm->m_nativeCode != NULL && (calleeInst.m_assm->m_nativeCode[calleeInst.Method()] != - NULL)) || // Make sure the callee is not an internal method - (md->RVA == CLR_EmptyIndex) || // Make sure we have a valid IP address for the method + (calleeInst.assembly->nativeCode != nullptr && (calleeInst.assembly->nativeCode[calleeInst.Method()] != + nullptr)) || // Make sure the callee is not an internal method + (md->rva == CLR_EmptyIndex) || // Make sure we have a valid IP address for the method !g_CLR_RT_EventCache.GetInlineFrameBuffer( &m_inlineFrame)) // Make sure we have an extra slot in the inline cache { return false; } - CLR_PMETADATA ipTmp = calleeInst.m_assm->GetByteCode(md->RVA); + CLR_PMETADATA ipTmp = calleeInst.assembly->GetByteCode(md->rva); #if defined(PLATFORM_WINDOWS_EMULATOR) if (s_CLR_RT_fTrace_SimulateSpeed > c_CLR_RT_Trace_None) @@ -319,11 +323,11 @@ bool CLR_RT_StackFrame::PushInline( // increment the evalPos pointer so that we don't corrupt the real stack evalPos++; - assm = calleeInst.m_assm; + assm = calleeInst.assembly; ip = ipTmp; m_arguments = pThis; - m_locals = &m_evalStackEnd[-md->numLocals]; + m_locals = &m_evalStackEnd[-md->localsCount]; m_call = calleeInst; m_evalStackEnd = m_locals; m_evalStack = evalPos; @@ -331,14 +335,14 @@ bool CLR_RT_StackFrame::PushInline( m_IPstart = ip; m_IP = ip; - if (md->numLocals) + if (md->localsCount) { - g_CLR_RT_ExecutionEngine.InitializeLocals(m_locals, calleeInst.m_assm, md); + g_CLR_RT_ExecutionEngine.InitializeLocals(m_locals, calleeInst); } m_flags |= CLR_RT_StackFrame::c_MethodKind_Inlined; - if (md->retVal != DATATYPE_VOID) + if (md->retValDataType != DATATYPE_VOID) { m_flags |= CLR_RT_StackFrame::c_InlineMethodHasReturnValue; } @@ -374,7 +378,7 @@ void CLR_RT_StackFrame::PopInline() if (m_flags & CLR_RT_StackFrame::c_InlineMethodHasReturnValue) { - if (m_owningThread->m_currentException.Dereference() == NULL) + if (m_owningThread->m_currentException.Dereference() == nullptr) { CLR_RT_HeapBlock &dst = PushValueAndAssign(src); @@ -383,7 +387,7 @@ void CLR_RT_StackFrame::PopInline() } g_CLR_RT_EventCache.FreeInlineBuffer(m_inlineFrame); - m_inlineFrame = NULL; + m_inlineFrame = nullptr; m_flags &= ~(CLR_RT_StackFrame::c_MethodKind_Inlined | CLR_RT_StackFrame::c_InlineMethodHasReturnValue); #if defined(NANOCLR_ENABLE_SOURCELEVELDEBUGGING) @@ -399,7 +403,7 @@ void CLR_RT_StackFrame::RestoreFromInlineStack() { m_arguments = m_inlineFrame->m_frame.m_args; m_locals = m_inlineFrame->m_frame.m_locals; - m_evalStackEnd += m_call.m_target->numLocals; + m_evalStackEnd += m_call.target->localsCount; m_call = m_inlineFrame->m_frame.m_call; m_IP = m_inlineFrame->m_frame.m_IP; m_IPstart = m_inlineFrame->m_frame.m_IPStart; @@ -416,7 +420,7 @@ void CLR_RT_StackFrame::RestoreStack(CLR_RT_InlineFrame &frame) m_IPstart = frame.m_IPStart; m_evalStack = frame.m_evalStack; m_evalStackPos = frame.m_evalPos; - m_evalStackEnd -= m_call.m_target->numLocals; + m_evalStackEnd -= m_call.target->localsCount; } void CLR_RT_StackFrame::SaveStack(CLR_RT_InlineFrame &frame) @@ -441,7 +445,7 @@ HRESULT CLR_RT_StackFrame::PopAppDomainTransition() CLR_RT_HeapBlock exception; CLR_RT_StackFrame *caller = this->Caller(); - exception.SetObjectReference(NULL); + exception.SetObjectReference(nullptr); if (m_flags & CLR_RT_StackFrame::c_AppDomainInjectException) { @@ -450,17 +454,17 @@ HRESULT CLR_RT_StackFrame::PopAppDomainTransition() _ASSERTE(m_owningThread->m_flags & CLR_RT_Thread::TH_F_Aborted); _ASSERTE(m_owningThread->m_flags & CLR_RT_Thread::TH_F_ContainsDoomedAppDomain); - _ASSERTE(m_owningThread->m_currentException.Dereference() != NULL); + _ASSERTE(m_owningThread->m_currentException.Dereference() != nullptr); _ASSERTE( m_owningThread->m_currentException.Dereference()->ObjectCls().m_data == - g_CLR_RT_WellKnownTypes.m_ThreadAbortException.m_data); + g_CLR_RT_WellKnownTypes.ThreadAbortException.m_data); _ASSERTE(!m_appDomain->IsLoaded()); m_owningThread->m_flags &= ~(CLR_RT_Thread::TH_F_Aborted | CLR_RT_Thread::TH_F_ContainsDoomedAppDomain); hr = CLR_E_APPDOMAIN_EXITED; } - else if (m_owningThread->m_currentException.Dereference() == NULL) + else if (m_owningThread->m_currentException.Dereference() == nullptr) { _ASSERTE((m_flags & CLR_RT_StackFrame::c_AppDomainInjectException) == 0); @@ -474,7 +478,7 @@ HRESULT CLR_RT_StackFrame::PopAppDomainTransition() } else { - int cArgs = m_call.m_target->numArgs; + int cArgs = m_call.m_target->ArgumentsCount; // First marshal the ref parameters NANOCLR_CHECK_HRESULT( @@ -485,7 +489,7 @@ HRESULT CLR_RT_StackFrame::PopAppDomainTransition() } // Now, push the return, if any. - if (m_call.m_target->retVal != DATATYPE_VOID) + if (m_call.m_target->RetVal != DATATYPE_VOID) { CLR_RT_HeapBlock &dst = caller->PushValueAndClear(); CLR_RT_HeapBlock &src = this->TopValue(); @@ -528,8 +532,8 @@ HRESULT CLR_RT_StackFrame::PushAppDomainTransition( NATIVE_PROFILE_CLR_CORE(); NANOCLR_HEADER(); - CLR_RT_StackFrame *frame = NULL; - int cArgs = callInst.m_target->numArgs; + CLR_RT_StackFrame *frame = nullptr; + int cArgs = callInst.m_target->ArgumentsCount; CLR_RT_HeapBlock *proxy; _ASSERTE(pThis->IsTransparentProxy()); @@ -567,14 +571,14 @@ HRESULT CLR_RT_StackFrame::MakeCall( NATIVE_PROFILE_CLR_CORE(); NANOCLR_HEADER(); - const CLR_RECORD_METHODDEF *mdR = md.m_target; + const CLR_RECORD_METHODDEF *mdR = md.target; bool fStatic = (mdR->flags & CLR_RECORD_METHODDEF::MD_Static) != 0; - int numArgs = mdR->numArgs; + int ArgumentsCount = mdR->argumentsCount; int argsOffset = 0; CLR_RT_StackFrame *stackSub; CLR_RT_HeapBlock tmp; - tmp.SetObjectReference(NULL); + tmp.SetObjectReference(nullptr); CLR_RT_ProtectFromGC gc(tmp); if (mdR->flags & CLR_RECORD_METHODDEF::MD_Constructor) @@ -582,7 +586,7 @@ HRESULT CLR_RT_StackFrame::MakeCall( CLR_RT_TypeDef_Instance owner{}; owner.InitializeFromMethod(md); - _ASSERTE(obj == NULL); + _ASSERTE(obj == nullptr); _SIDE_ASSERTE(owner.InitializeFromMethod(md)); @@ -599,11 +603,11 @@ HRESULT CLR_RT_StackFrame::MakeCall( if (!fStatic) { FAULT_ON_NULL(obj); - numArgs--; + ArgumentsCount--; argsOffset = 1; } - if (numArgs != nArgs) + if (ArgumentsCount != nArgs) NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER); // @@ -626,7 +630,7 @@ HRESULT CLR_RT_StackFrame::MakeCall( md.InitializeFromIndex(mdReal); - mdR = md.m_target; + mdR = md.target; } #if defined(NANOCLR_APPDOMAINS) @@ -642,7 +646,7 @@ HRESULT CLR_RT_StackFrame::MakeCall( else #endif { - NANOCLR_CHECK_HRESULT(CLR_RT_StackFrame::Push(m_owningThread, md, md.m_target->numArgs)); + NANOCLR_CHECK_HRESULT(CLR_RT_StackFrame::Push(m_owningThread, md, md.target->argumentsCount)); stackSub = m_owningThread->CurrentFrame(); @@ -651,9 +655,9 @@ HRESULT CLR_RT_StackFrame::MakeCall( stackSub->m_arguments[0].Assign(*obj); } - if (numArgs) + if (ArgumentsCount) { - memcpy(&stackSub->m_arguments[argsOffset], args, sizeof(struct CLR_RT_HeapBlock) * numArgs); + memcpy(&stackSub->m_arguments[argsOffset], args, sizeof(struct CLR_RT_HeapBlock) * ArgumentsCount); } } @@ -669,22 +673,22 @@ HRESULT CLR_RT_StackFrame::FixCall() NATIVE_PROFILE_CLR_CORE(); NANOCLR_HEADER(); - const CLR_RECORD_METHODDEF *target = m_call.m_target; - CLR_UINT8 numArgs = target->numArgs; + const CLR_RECORD_METHODDEF *target = m_call.target; + CLR_UINT8 ArgumentsCount = target->argumentsCount; // // The copy of ValueTypes is delayed as much as possible. // // If an argument is a ValueType, now it's a good time to clone it. // - if (numArgs) + if (ArgumentsCount) { - CLR_RT_SignatureParser parser{}; - parser.Initialize_MethodSignature(m_call.m_assm, target); + CLR_RT_SignatureParser parser; + parser.Initialize_MethodSignature(&m_call); CLR_RT_SignatureParser::Element res; CLR_RT_HeapBlock *args = m_arguments; - if (parser.m_flags & PIMAGE_CEE_CS_CALLCONV_HASTHIS) + if (parser.Flags & PIMAGE_CEE_CS_CALLCONV_HASTHIS) { args++; } @@ -698,14 +702,14 @@ HRESULT CLR_RT_StackFrame::FixCall() { NANOCLR_CHECK_HRESULT(parser.Advance(res)); - if (res.m_levels > 0) + if (res.Levels > 0) continue; // Array, no need to fix. if (args->DataType() == DATATYPE_OBJECT) { - CLR_RT_TypeDef_Instance inst{}; - inst.InitializeFromIndex(res.m_cls); - CLR_DataType dtT = (CLR_DataType)inst.m_target->dataType; + CLR_RT_TypeDef_Instance inst; + inst.InitializeFromIndex(res.Class); + NanoCLRDataType dtT = (NanoCLRDataType)inst.target->dataType; const CLR_RT_DataTypeLookup &dtl = c_CLR_RT_DataTypeLookup[dtT]; if (dtl.m_flags & (CLR_RT_DataTypeLookup::c_OptimizedValueType | CLR_RT_DataTypeLookup::c_ValueType)) @@ -718,7 +722,7 @@ HRESULT CLR_RT_StackFrame::FixCall() // It's a boxed primitive/enum type. args->Assign(*value); } - else if (args->Dereference()->ObjectCls().m_data == res.m_cls.m_data) + else if (args->Dereference()->ObjectCls().data == res.Class.data) { if (args->Dereference()->IsBoxed()) { @@ -732,7 +736,7 @@ HRESULT CLR_RT_StackFrame::FixCall() } } - if (res.m_dt == DATATYPE_VALUETYPE && res.m_fByRef == false) + if (res.DataType == DATATYPE_VALUETYPE && res.IsByRef == false) { if (args->IsAReferenceOfThisType(DATATYPE_VALUETYPE)) { @@ -779,18 +783,18 @@ HRESULT CLR_RT_StackFrame::HandleSynchronized(bool fAcquire, bool fGlobal) // // Create an private object to implement global locks. // - NANOCLR_CHECK_HRESULT(g_CLR_RT_ExecutionEngine.NewObjectFromIndex(*obj, g_CLR_RT_WellKnownTypes.m_Object)); + NANOCLR_CHECK_HRESULT(g_CLR_RT_ExecutionEngine.NewObjectFromIndex(*obj, g_CLR_RT_WellKnownTypes.Object)); *ppGlobalLock = obj->Dereference(); } } - else if (m_call.m_target->flags & CLR_RECORD_METHODDEF::MD_Static) + else if (m_call.target->flags & CLR_RECORD_METHODDEF::MD_Static) { - CLR_RT_TypeDef_Index idx; + CLR_RT_TypeDef_Index index; - idx.Set(m_call.Assembly(), m_call.CrossReference().GetOwner()); + index.Set(m_call.Assembly(), m_call.CrossReference().GetOwner()); - refType.SetReflection(idx); + refType.SetReflection(index); obj = &refType; } @@ -878,7 +882,7 @@ void CLR_RT_StackFrame::Pop() CLR_RT_StackFrame *caller = Caller(); - if (caller->Prev() != NULL) + if (caller->Prev() != nullptr) { #if defined(NANOCLR_ENABLE_SOURCELEVELDEBUGGING) if (caller->m_flags & CLR_RT_StackFrame::c_HasBreakpoint) @@ -934,9 +938,9 @@ void CLR_RT_StackFrame::Pop() // // Push the return, if any. // - if (m_call.m_target->retVal != DATATYPE_VOID) + if (m_call.target->retValDataType != DATATYPE_VOID) { - if (m_owningThread->m_currentException.Dereference() == NULL) + if (m_owningThread->m_currentException.Dereference() == nullptr) { CLR_RT_HeapBlock &src = this->TopValue(); CLR_RT_HeapBlock &dst = caller->PushValueAndAssign(src); @@ -950,27 +954,27 @@ void CLR_RT_StackFrame::Pop() #if defined(NANOCLR_ENABLE_SOURCELEVELDEBUGGING) else { - int idx = m_owningThread->m_scratchPad; + int index = m_owningThread->m_scratchPad; - if (idx >= 0) + if (index >= 0) { CLR_RT_HeapBlock_Array *array = g_CLR_RT_ExecutionEngine.m_scratchPadArray; - if (array && array->m_numOfElements > (CLR_UINT32)idx) + if (array && array->m_numOfElements > (CLR_UINT32)index) { - CLR_RT_HeapBlock *dst = (CLR_RT_HeapBlock *)array->GetElement((CLR_UINT32)idx); + CLR_RT_HeapBlock *dst = (CLR_RT_HeapBlock *)array->GetElement((CLR_UINT32)index); CLR_RT_HeapBlock *exception = m_owningThread->m_currentException.Dereference(); - dst->SetObjectReference(NULL); + dst->SetObjectReference(nullptr); - if (exception != NULL) + if (exception != nullptr) { dst->SetObjectReference(exception); } - else if (m_call.m_target->retVal != DATATYPE_VOID) + else if (m_call.target->retValDataType != DATATYPE_VOID) { - CLR_RT_SignatureParser sig{}; - sig.Initialize_MethodSignature(this->m_call.m_assm, this->m_call.m_target); + CLR_RT_SignatureParser sig; + sig.Initialize_MethodSignature(&this->m_call); CLR_RT_SignatureParser::Element res; CLR_RT_TypeDescriptor desc{}; @@ -980,15 +984,15 @@ void CLR_RT_StackFrame::Pop() // Box to the return value type _SIDE_ASSERTE(SUCCEEDED(sig.Advance(res))); - _SIDE_ASSERTE(SUCCEEDED(desc.InitializeFromType(res.m_cls))); + _SIDE_ASSERTE(SUCCEEDED(desc.InitializeFromType(res.Class))); if (c_CLR_RT_DataTypeLookup[this->DataType()].m_flags & CLR_RT_DataTypeLookup::c_OptimizedValueType || - desc.m_handlerCls.m_target->IsEnum()) + desc.m_handlerCls.target->IsEnum()) { if (FAILED(dst->PerformBoxing(desc.m_handlerCls))) { - dst->SetObjectReference(NULL); + dst->SetObjectReference(nullptr); } } } @@ -1001,7 +1005,7 @@ void CLR_RT_StackFrame::Pop() // We could be jumping outside of a nested exception handler. // - m_owningThread->PopEH(this, NULL); + m_owningThread->PopEH(this, nullptr); // // If this StackFrame owns a SubThread, kill it. @@ -1020,7 +1024,7 @@ void CLR_RT_StackFrame::Pop() //--// -void CLR_RT_StackFrame::SetResult(CLR_INT32 val, CLR_DataType dataType) +void CLR_RT_StackFrame::SetResult(CLR_INT32 val, NanoCLRDataType dataType) { NATIVE_PROFILE_CLR_CORE(); CLR_RT_HeapBlock &top = PushValue(); @@ -1242,39 +1246,39 @@ void CLR_RT_StackFrame::Relocate() #ifndef NANOCLR_NO_IL_INLINE if (m_inlineFrame) { - CLR_RT_GarbageCollector::Heap_Relocate((void **)&m_inlineFrame->m_frame.m_call.m_assm); - CLR_RT_GarbageCollector::Heap_Relocate((void **)&m_inlineFrame->m_frame.m_call.m_target); + CLR_RT_GarbageCollector::Heap_Relocate((void **)&m_inlineFrame->m_frame.m_call.assembly); + CLR_RT_GarbageCollector::Heap_Relocate((void **)&m_inlineFrame->m_frame.m_call.target); CLR_RT_GarbageCollector::Heap_Relocate((void **)&m_inlineFrame->m_frame.m_IPStart); CLR_RT_GarbageCollector::Heap_Relocate((void **)&m_inlineFrame->m_frame.m_IP); - CLR_RT_GarbageCollector::Heap_Relocate((void **)&m_call.m_assm); - CLR_RT_GarbageCollector::Heap_Relocate((void **)&m_call.m_target); + CLR_RT_GarbageCollector::Heap_Relocate((void **)&m_call.assembly); + CLR_RT_GarbageCollector::Heap_Relocate((void **)&m_call.target); CLR_RT_GarbageCollector::Heap_Relocate((void **)&m_nativeMethod); CLR_RT_GarbageCollector::Heap_Relocate((void **)&m_IPstart); CLR_RT_GarbageCollector::Heap_Relocate((void **)&m_IP); CLR_RT_GarbageCollector::Heap_Relocate( m_inlineFrame->m_frame.m_args, - m_inlineFrame->m_frame.m_call.m_target->numArgs); + m_inlineFrame->m_frame.m_call.target->argumentsCount); CLR_RT_GarbageCollector::Heap_Relocate( m_inlineFrame->m_frame.m_locals, - m_inlineFrame->m_frame.m_call.m_target->numLocals); + m_inlineFrame->m_frame.m_call.target->localsCount); CLR_RT_GarbageCollector::Heap_Relocate( m_inlineFrame->m_frame.m_evalStack, (int)(m_evalStackPos - m_inlineFrame->m_frame.m_evalStack)); - CLR_RT_GarbageCollector::Heap_Relocate(m_locals, m_call.m_target->numLocals); + CLR_RT_GarbageCollector::Heap_Relocate(m_locals, m_call.target->localsCount); } else #endif { - CLR_RT_GarbageCollector::Heap_Relocate((void **)&m_call.m_assm); - CLR_RT_GarbageCollector::Heap_Relocate((void **)&m_call.m_target); + CLR_RT_GarbageCollector::Heap_Relocate((void **)&m_call.assembly); + CLR_RT_GarbageCollector::Heap_Relocate((void **)&m_call.target); CLR_RT_GarbageCollector::Heap_Relocate((void **)&m_nativeMethod); CLR_RT_GarbageCollector::Heap_Relocate((void **)&m_IPstart); CLR_RT_GarbageCollector::Heap_Relocate((void **)&m_IP); - CLR_RT_GarbageCollector::Heap_Relocate(m_arguments, m_call.m_target->numArgs); - CLR_RT_GarbageCollector::Heap_Relocate(m_locals, m_call.m_target->numLocals); + CLR_RT_GarbageCollector::Heap_Relocate(m_arguments, m_call.target->argumentsCount); + CLR_RT_GarbageCollector::Heap_Relocate(m_locals, m_call.target->localsCount); CLR_RT_GarbageCollector::Heap_Relocate(m_evalStack, TopValuePosition()); } } @@ -1286,7 +1290,7 @@ HRESULT CLR_RT_StackFrame::NotImplementedStub() NATIVE_PROFILE_CLR_CORE(); NANOCLR_HEADER(); - if (m_call.m_target->retVal != DATATYPE_VOID) + if (m_call.target->retValDataType != DATATYPE_VOID) { SetResult_I4(0); } diff --git a/src/CLR/Core/CLR_RT_SystemAssembliesTable.cpp b/src/CLR/Core/CLR_RT_SystemAssembliesTable.cpp index 1f52d28342..ea8e841019 100644 --- a/src/CLR/Core/CLR_RT_SystemAssembliesTable.cpp +++ b/src/CLR/Core/CLR_RT_SystemAssembliesTable.cpp @@ -1,4 +1,4 @@ -// +// // Copyright (c) .NET Foundation and Contributors // Portions Copyright (c) Microsoft Corporation. All rights reserved. // See LICENSE file in the project root for full license information. @@ -9,23 +9,23 @@ static const CLR_RT_NativeAssemblyData *LookUpAssemblyNativeDataByName( const CLR_RT_NativeAssemblyData **pAssembliesNativeData, const char *lpszAssemblyName) { - // Just sanity check to avoid crash in strcmp if name is NULL. - if (lpszAssemblyName == NULL) + // Just sanity check to avoid crash in strcmp if name is nullptr. + if (lpszAssemblyName == nullptr) { - return NULL; + return nullptr; } // Loops in all entries and looks for the CLR_RT_NativeAssemblyData with name same as lpszAssemblyName for (int i = 0; pAssembliesNativeData[i]; i++) { - if (i < g_CLR_InteropAssembliesCount && pAssembliesNativeData[i] != NULL && + if (i < g_CLR_InteropAssembliesCount && pAssembliesNativeData[i] != nullptr && 0 == strcmp(lpszAssemblyName, pAssembliesNativeData[i]->m_szAssemblyName)) { return pAssembliesNativeData[i]; } } - return NULL; + return nullptr; } const CLR_RT_NativeAssemblyData *GetAssemblyNativeData(const char *lpszAssemblyName) diff --git a/src/CLR/Core/CLR_RT_UnicodeHelper.cpp b/src/CLR/Core/CLR_RT_UnicodeHelper.cpp index ba5057c107..f00e0159d5 100644 --- a/src/CLR/Core/CLR_RT_UnicodeHelper.cpp +++ b/src/CLR/Core/CLR_RT_UnicodeHelper.cpp @@ -516,13 +516,13 @@ void CLR_RT_UnicodeHelper::ConvertToUTF8(const std::wstring &src, std::string &d char *szBuf; int iSize; - iSize = ::WideCharToMultiByte(CP_UTF8, 0, src.c_str(), -1, NULL, 0, NULL, NULL); + iSize = ::WideCharToMultiByte(CP_UTF8, 0, src.c_str(), -1, nullptr, 0, nullptr, nullptr); if (iSize > 0) { szBuf = new char[iSize]; - iSize = ::WideCharToMultiByte(CP_UTF8, 0, src.c_str(), -1, szBuf, iSize, NULL, NULL); + iSize = ::WideCharToMultiByte(CP_UTF8, 0, src.c_str(), -1, szBuf, iSize, nullptr, nullptr); if (iSize > 0) { dst = szBuf; @@ -544,7 +544,7 @@ void CLR_RT_UnicodeHelper::ConvertFromUTF8(const std::string &src, std::wstring wchar_t *szBuf; int iSize; - iSize = ::MultiByteToWideChar(CP_UTF8, 0, src.c_str(), -1, NULL, 0); + iSize = ::MultiByteToWideChar(CP_UTF8, 0, src.c_str(), -1, nullptr, 0); if (iSize > 0) { @@ -569,7 +569,7 @@ void CLR_RT_UnicodeHelper::ConvertFromUTF8(const std::string &src, std::wstring UnicodeString::UnicodeString() { - m_wCharArray = NULL; + m_wCharArray = nullptr; m_length = 0; } @@ -614,10 +614,10 @@ HRESULT UnicodeString::Assign(const char *string) void UnicodeString::Release() { - if (m_wCharArray != NULL) + if (m_wCharArray != nullptr) { CLR_RT_Memory::Release(m_wCharArray); } - m_wCharArray = NULL; + m_wCharArray = nullptr; } diff --git a/src/CLR/Core/Cache.cpp b/src/CLR/Core/Cache.cpp index d6481832b5..1b3bdf5ad6 100644 --- a/src/CLR/Core/Cache.cpp +++ b/src/CLR/Core/Cache.cpp @@ -107,7 +107,7 @@ bool CLR_RT_EventCache::VirtualMethodTable::FindVirtualMethod( if (m_list_freeItems.IsEmpty()) { en = (LookupEntry *)m_list_inUse.LastNode(); - if (en->Prev() == NULL) + if (en->Prev() == nullptr) { // // No node to steal, return. @@ -190,7 +190,7 @@ void CLR_RT_EventCache::VirtualMethodTable::Callback_Reassign( void CLR_RT_EventCache::VirtualMethodTable::Initialize() { NATIVE_PROFILE_CLR_CORE(); - CLR_UINT32 idx; + CLR_UINT32 index; m_entries = (Link *)&g_scratchVirtualMethodTableLink[0]; m_entriesMRU = (Link *)&g_scratchVirtualMethodTableLinkMRU[0]; @@ -199,24 +199,24 @@ void CLR_RT_EventCache::VirtualMethodTable::Initialize() // // Link all the entries to themselves => no elements in the lists. // - for (idx = 0; idx < LinkArraySize(); idx++) + for (index = 0; index < LinkArraySize(); index++) { - Link &lnk = m_entries[idx]; + Link &lnk = m_entries[index]; - lnk.m_next = idx; - lnk.m_prev = idx; + lnk.m_next = index; + lnk.m_prev = index; } // // Link all the entries to the following one => all the elements are in the MRU list. // _ASSERTE(LinkMRUArraySize() < 0xFFFF); - for (idx = 0; idx < LinkMRUArraySize(); idx++) + for (index = 0; index < LinkMRUArraySize(); index++) { - Link &lnk = m_entriesMRU[idx]; + Link &lnk = m_entriesMRU[index]; - lnk.m_next = idx == LinkMRUArraySize() - 1 ? 0 : idx + 1; - lnk.m_prev = idx == 0 ? (CLR_UINT16)LinkMRUArraySize() - 1 : idx - 1; + lnk.m_next = index == LinkMRUArraySize() - 1 ? 0 : index + 1; + lnk.m_prev = index == 0 ? (CLR_UINT16)LinkMRUArraySize() - 1 : index - 1; } } @@ -227,10 +227,10 @@ bool CLR_RT_EventCache::VirtualMethodTable::FindVirtualMethod( { NATIVE_PROFILE_CLR_CORE(); Payload::Key key; - CLR_UINT32 idx; - CLR_UINT32 idxHead; - CLR_UINT32 clsData = cls.m_data; - CLR_UINT32 mdVirtualData = mdVirtual.m_data; + CLR_UINT32 index; + CLR_UINT32 indexHead; + CLR_UINT32 clsData = cls.data; + CLR_UINT32 mdVirtualData = mdVirtual.data; #if defined(VIRTUAL_DEVICE) bool fVerify = false; @@ -245,9 +245,9 @@ bool CLR_RT_EventCache::VirtualMethodTable::FindVirtualMethod( // // Shortcut for terminal virtual methods. // - if (clsData == instCLS.m_data) + if (clsData == instCLS.data) { - if ((instMD.m_target->flags & CLR_RECORD_METHODDEF::MD_Abstract) == 0) + if ((instMD.target->flags & CLR_RECORD_METHODDEF::MD_Abstract) == 0) { md = mdVirtual; @@ -260,7 +260,7 @@ bool CLR_RT_EventCache::VirtualMethodTable::FindVirtualMethod( if (cls.Assembly() == mdVirtual.Assembly()) { CLR_RT_Assembly *assm = g_CLR_RT_TypeSystem.m_assemblies[mdVirtual.Assembly() - 1]; - CLR_IDX owner = assm->m_pCrossReference_MethodDef[mdVirtual.Method()].GetOwner(); + CLR_INDEX owner = assm->crossReferenceMethodDef[mdVirtual.Method()].GetOwner(); if (cls.Type() == owner) { @@ -269,9 +269,9 @@ bool CLR_RT_EventCache::VirtualMethodTable::FindVirtualMethod( { CLR_Debug::Printf( "INTERNAL ERROR: Shortcut for terminal virtual methods failed: CLS:%08x:%08x => %08x\r\n", - cls.m_data, - mdVirtual.m_data, - md.m_data); + cls.data, + mdVirtual.data, + md.data); ::DebugBreak(); } #endif @@ -287,26 +287,27 @@ bool CLR_RT_EventCache::VirtualMethodTable::FindVirtualMethod( { CLR_Debug::Printf( "INTERNAL ERROR: Shortcut for terminal virtual methods failed: CLS:%08x:%08x\r\n", - cls.m_data, - mdVirtual.m_data); + cls.data, + mdVirtual.data); ::DebugBreak(); } #endif - key.m_mdVirtual.m_data = mdVirtualData; - key.m_cls.m_data = clsData; + key.m_mdVirtual.data = mdVirtualData; + key.m_cls.data = clsData; - idxHead = (SUPPORT_ComputeCRC(&key, sizeof(key), 0) % (LinkArraySize() - PayloadArraySize())) + PayloadArraySize(); + indexHead = + (SUPPORT_ComputeCRC(&key, sizeof(key), 0) % (LinkArraySize() - PayloadArraySize())) + PayloadArraySize(); - for (idx = m_entries[idxHead].m_next;; idx = m_entries[idx].m_next) + for (index = m_entries[indexHead].m_next;; index = m_entries[index].m_next) { - if (idx != idxHead) + if (index != indexHead) { - Payload &res = m_payloads[idx]; + Payload &res = m_payloads[index]; - if (res.m_key.m_mdVirtual.m_data != mdVirtualData) + if (res.m_key.m_mdVirtual.data != mdVirtualData) continue; - if (res.m_key.m_cls.m_data != clsData) + if (res.m_key.m_cls.data != clsData) continue; md = res.m_md; @@ -318,9 +319,9 @@ bool CLR_RT_EventCache::VirtualMethodTable::FindVirtualMethod( if (g_CLR_RT_TypeSystem.FindVirtualMethodDef(cls, mdVirtual, md) == false) return false; - idx = GetNewEntry(); + index = GetNewEntry(); - Payload &res = m_payloads[idx]; + Payload &res = m_payloads[index]; res.m_md = md; res.m_key = key; @@ -329,20 +330,20 @@ bool CLR_RT_EventCache::VirtualMethodTable::FindVirtualMethod( } } - MoveEntryToTop(m_entries, idxHead, idx); - MoveEntryToTop(m_entriesMRU, LinkMRUArraySize() - 1, idx); + MoveEntryToTop(m_entries, indexHead, index); + MoveEntryToTop(m_entriesMRU, LinkMRUArraySize() - 1, index); return true; } -void CLR_RT_EventCache::VirtualMethodTable::MoveEntryToTop(Link *entries, CLR_UINT32 slot, CLR_UINT32 idx) +void CLR_RT_EventCache::VirtualMethodTable::MoveEntryToTop(Link *entries, CLR_UINT32 slot, CLR_UINT32 index) { NATIVE_PROFILE_CLR_CORE(); Link &list = entries[slot]; - if (list.m_next != idx) + if (list.m_next != index) { - Link &node = entries[idx]; + Link &node = entries[index]; CLR_UINT32 next; CLR_UINT32 prev; @@ -363,8 +364,8 @@ void CLR_RT_EventCache::VirtualMethodTable::MoveEntryToTop(Link *entries, CLR_UI node.m_next = next; node.m_prev = slot; - list.m_next = idx; - entries[next].m_prev = idx; + list.m_next = index; + entries[next].m_prev = index; } } @@ -400,7 +401,7 @@ void CLR_RT_EventCache::EventCache_Initialize() { m_inlineBufferStart[i].m_pNext = &m_inlineBufferStart[i + 1]; } - m_inlineBufferStart[num].m_pNext = NULL; + m_inlineBufferStart[num].m_pNext = nullptr; #endif } @@ -453,7 +454,7 @@ CLR_RT_HeapBlock *CLR_RT_EventCache::Extract_Node_Slow(CLR_UINT32 dataType, CLR_ { NATIVE_PROFILE_CLR_CORE(); CLR_RT_HeapBlock_Node *node; - CLR_RT_HeapBlock_Node *best = NULL; + CLR_RT_HeapBlock_Node *best = nullptr; CLR_UINT32 bestSize = 0; NANOCLR_FOREACH_NODE(CLR_RT_HeapBlock_Node, ptr, m_events[0].m_blocks) @@ -608,7 +609,7 @@ bool CLR_RT_EventCache::FindVirtualMethod( #ifndef NANOCLR_NO_IL_INLINE bool CLR_RT_EventCache::GetInlineFrameBuffer(CLR_RT_InlineBuffer **ppBuffer) { - if (m_inlineBufferStart != NULL) + if (m_inlineBufferStart != nullptr) { *ppBuffer = m_inlineBufferStart; @@ -617,7 +618,7 @@ bool CLR_RT_EventCache::GetInlineFrameBuffer(CLR_RT_InlineBuffer **ppBuffer) return true; } - *ppBuffer = NULL; + *ppBuffer = nullptr; return false; } diff --git a/src/CLR/Core/Checks.cpp b/src/CLR/Core/Checks.cpp index 45e15d1cf1..6a9ca300a7 100644 --- a/src/CLR/Core/Checks.cpp +++ b/src/CLR/Core/Checks.cpp @@ -1,4 +1,4 @@ -// +// // Copyright (c) .NET Foundation and Contributors // Portions Copyright (c) Microsoft Corporation. All rights reserved. // See LICENSE file in the project root for full license information. @@ -7,6 +7,25 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// +HRESULT CLR_Checks::VerifyStackOK(const CLR_RT_StackFrame &stack, const CLR_RT_HeapBlock *top, const int num) +{ + NANOCLR_HEADER(); + + // Check if stack has enough space for num elements + if (top + num > stack.m_evalStackEnd) + { + NANOCLR_SET_AND_LEAVE(CLR_E_STACK_OVERFLOW); + } + + // Check if top is within stack bounds + if (top < stack.m_evalStack || top >= stack.m_evalStackEnd) + { + NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER); + } + + NANOCLR_NOCLEANUP(); +} + HRESULT CLR_Checks::VerifyObject(CLR_RT_HeapBlock &top) { NATIVE_PROFILE_CLR_CORE(); @@ -16,12 +35,12 @@ HRESULT CLR_Checks::VerifyObject(CLR_RT_HeapBlock &top) { case DATATYPE_OBJECT: case DATATYPE_BYREF: - if (top.Dereference() != NULL) + if (top.Dereference() != nullptr) NANOCLR_SET_AND_LEAVE(S_OK); break; case DATATYPE_ARRAY_BYREF: - if (top.DereferenceArray() != NULL) + if (top.DereferenceArray() != nullptr) NANOCLR_SET_AND_LEAVE(S_OK); break; @@ -47,7 +66,7 @@ HRESULT CLR_Checks::VerifyArrayReference(CLR_RT_HeapBlock &ref) } array = ref.DereferenceArray(); - if (array == NULL) + if (array == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_NULL_REFERENCE); } diff --git a/src/CLR/Core/Core.vcxproj b/src/CLR/Core/Core.vcxproj index a6f9d31efa..82f11f5d08 100644 --- a/src/CLR/Core/Core.vcxproj +++ b/src/CLR/Core/Core.vcxproj @@ -30,6 +30,7 @@ + diff --git a/src/CLR/Core/Core.vcxproj.filters b/src/CLR/Core/Core.vcxproj.filters index 7d06c9313d..98d55a48e7 100644 --- a/src/CLR/Core/Core.vcxproj.filters +++ b/src/CLR/Core/Core.vcxproj.filters @@ -141,6 +141,9 @@ Source Files + + Source Files + diff --git a/src/CLR/Core/Execution.cpp b/src/CLR/Core/Execution.cpp index 376787090d..2192853454 100644 --- a/src/CLR/Core/Execution.cpp +++ b/src/CLR/Core/Execution.cpp @@ -91,29 +91,29 @@ HRESULT CLR_RT_ExecutionEngine::ExecutionEngine_Initialize() // CLR_RT_Thread* m_cctorThread; // #if !defined(NANOCLR_APPDOMAINS) - m_globalLock = NULL; // CLR_RT_HeapBlock* m_globalLock; - m_outOfMemoryException = NULL; // CLR_RT_HeapBlock* m_outOfMemoryException; + m_globalLock = nullptr; // CLR_RT_HeapBlock* m_globalLock; + m_outOfMemoryException = nullptr; // CLR_RT_HeapBlock* m_outOfMemoryException; #endif - m_currentUICulture = NULL; // CLR_RT_HeapBlock* m_currentUICulture; + m_currentUICulture = nullptr; // CLR_RT_HeapBlock* m_currentUICulture; CLR_RT_HeapBlock_EndPoint::HandlerMethod_Initialize(); CLR_RT_HeapBlock_NativeEventDispatcher::HandlerMethod_Initialize(); - m_interruptThread = NULL; // CLR_RT_Thread m_interruptThread; + m_interruptThread = nullptr; // CLR_RT_Thread m_interruptThread; #if defined(NANOCLR_ENABLE_SOURCELEVELDEBUGGING) - m_scratchPadArray = NULL; // CLR_RT_HeapBlock_Array* m_scratchPadArray; -#endif // #if defined(NANOCLR_ENABLE_SOURCELEVELDEBUGGING) + m_scratchPadArray = nullptr; // CLR_RT_HeapBlock_Array* m_scratchPadArray; +#endif // #if defined(NANOCLR_ENABLE_SOURCELEVELDEBUGGING) #if defined(NANOCLR_APPDOMAINS) m_appDomains.DblLinkedList_Initialize(); // CLR_RT_DblLinkedList m_appDomains; - m_appDomainCurrent = NULL; // CLR_AppDomainCurrent* m_appDomainCurrent; + m_appDomainCurrent = nullptr; // CLR_AppDomainCurrent* m_appDomainCurrent; m_appDomainIdNext = c_AppDomainId_Invalid + 1; // int m_appDomainIdNext; #endif - m_currentThread = NULL; + m_currentThread = nullptr; m_GlobalExecutionCounter = 0; @@ -162,8 +162,8 @@ HRESULT CLR_RT_ExecutionEngine::AllocateHeaps() const CLR_UINT32 c_HeapClusterSize = sizeof(struct CLR_RT_HeapBlock) * CLR_RT_HeapBlock::HB_MaxSize; - CLR_UINT8 *heapFirstFree = s_CLR_RT_Heap.m_location; - CLR_UINT32 heapFree = s_CLR_RT_Heap.m_size; + CLR_UINT8 *heapFirstFree = s_CLR_RT_Heap.location; + CLR_UINT32 heapFree = s_CLR_RT_Heap.size; CLR_INT32 i = 0; CLR_UINT32 blockSize = 1; @@ -248,7 +248,7 @@ void CLR_RT_ExecutionEngine::ExecutionEngine_Cleanup() m_fShuttingDown = true; #if defined(NANOCLR_ENABLE_SOURCELEVELDEBUGGING) - m_scratchPadArray = NULL; + m_scratchPadArray = nullptr; m_breakpointsNum = 0; CLR_DBG_Debugger::DeleteInstance(); @@ -264,21 +264,21 @@ void CLR_RT_ExecutionEngine::ExecutionEngine_Cleanup() m_finalizersAlive.DblLinkedList_PushToCache(); m_finalizersPending.DblLinkedList_PushToCache(); - m_finalizerThread = NULL; - m_cctorThread = NULL; - m_timerThread = NULL; + m_finalizerThread = nullptr; + m_cctorThread = nullptr; + m_timerThread = nullptr; g_CLR_RT_TypeSystem.TypeSystem_Cleanup(); g_CLR_RT_EventCache.EventCache_Cleanup(); #if !defined(NANOCLR_APPDOMAINS) - m_globalLock = NULL; + m_globalLock = nullptr; #endif CLR_RT_HeapBlock_EndPoint::HandlerMethod_CleanUp(); CLR_RT_HeapBlock_NativeEventDispatcher::HandlerMethod_CleanUp(); - m_interruptThread = NULL; + m_interruptThread = nullptr; m_heap.DblLinkedList_Initialize(); } @@ -345,11 +345,11 @@ void CLR_RT_ExecutionEngine::LoadDownloadedAssemblies() if (header->GoodAssembly()) { - CLR_RT_Assembly *assm = NULL; + CLR_RT_Assembly *assm = nullptr; if (SUCCEEDED(CLR_RT_Assembly::CreateInstance(header, assm))) { - assm->m_pFile = weak->m_targetSerialized; + assm->file = weak->m_targetSerialized; g_CLR_RT_TypeSystem.Link(assm); } @@ -362,14 +362,14 @@ void CLR_RT_ExecutionEngine::LoadDownloadedAssemblies() NANOCLR_FOREACH_ASSEMBLY(g_CLR_RT_TypeSystem) { - if (pASSM->m_pFile) + if (pASSM->file) { // // For those assemblies that failed to load (missing dependency?), clean up. // - if ((pASSM->m_flags & CLR_RT_Assembly::ResolutionCompleted) == 0) + if ((pASSM->flags & CLR_RT_Assembly::ResolutionCompleted) == 0) { - pASSM->m_pFile = NULL; + pASSM->file = nullptr; pASSM->DestroyInstance(); } @@ -405,7 +405,7 @@ CLR_UINT32 CLR_RT_ExecutionEngine::PerformGarbageCollection() m_heapState = c_HeapState_Normal; - m_lastHcUsed = NULL; + m_lastHcUsed = nullptr; #if !defined(BUILD_RTM) || defined(VIRTUAL_DEVICE) if (m_fPerformHeapCompaction) @@ -430,7 +430,7 @@ void CLR_RT_ExecutionEngine::PerformHeapCompaction() CLR_EE_CLR(Compaction_Pending); - m_lastHcUsed = NULL; + m_lastHcUsed = nullptr; } void CLR_RT_ExecutionEngine::Relocate() @@ -584,23 +584,23 @@ HRESULT CLR_RT_ExecutionEngine::CreateEntryPointArgs(CLR_RT_HeapBlock &argsBlk, CLR_RT_HeapBlock_Array *array; CLR_UINT32 iArg; - wchar_t *szArgNext = NULL; + wchar_t *szArgNext = nullptr; wchar_t *szArg = szCommandLineArgs; const wchar_t *sep = L" "; - wchar_t *context = NULL; + wchar_t *context = nullptr; szArg = wcstok_s(szArg, sep, &context); - while (szArg != NULL) + while (szArg != nullptr) { std::wstring arg = szArg; args.insert(args.end(), arg); - szArg = wcstok_s(NULL, sep, &context); + szArg = wcstok_s(nullptr, sep, &context); } NANOCLR_CHECK_HRESULT( - CLR_RT_HeapBlock_Array::CreateInstance(argsBlk, (CLR_UINT32)args.size(), g_CLR_RT_WellKnownTypes.m_String)); + CLR_RT_HeapBlock_Array::CreateInstance(argsBlk, (CLR_UINT32)args.size(), g_CLR_RT_WellKnownTypes.String)); array = argsBlk.Array(); iArg = 0; @@ -626,7 +626,7 @@ HRESULT CLR_RT_ExecutionEngine::Execute(wchar_t *entryPointArgs, int maxContextS NANOCLR_HEADER(); CLR_RT_HeapBlock ref; - CLR_RT_Thread *thMain = NULL; + CLR_RT_Thread *thMain = nullptr; if (NANOCLR_INDEX_IS_INVALID(g_CLR_RT_TypeSystem.m_entryPoint)) { @@ -642,7 +642,7 @@ HRESULT CLR_RT_ExecutionEngine::Execute(wchar_t *entryPointArgs, int maxContextS CLR_EE_DBG_SET_MASK(StateProgramRunning, StateMask); #endif // #if defined(NANOCLR_ENABLE_SOURCELEVELDEBUGGING) - NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_Delegate::CreateInstance(ref, g_CLR_RT_TypeSystem.m_entryPoint, NULL)); + NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_Delegate::CreateInstance(ref, g_CLR_RT_TypeSystem.m_entryPoint, nullptr)); { CLR_RT_ProtectFromGC gc(ref); @@ -653,13 +653,13 @@ HRESULT CLR_RT_ExecutionEngine::Execute(wchar_t *entryPointArgs, int maxContextS { CLR_RT_StackFrame *stack = thMain->CurrentFrame(); - if (stack->m_call.m_target->numArgs > 0) + if (stack->m_call.target->argumentsCount > 0) { // Main entrypoint takes an optional String[] parameter. - // Set the arg to NULL, if that's the case. + // Set the arg to nullptr, if that's the case. #if defined(VIRTUAL_DEVICE) - if (entryPointArgs != NULL) + if (entryPointArgs != nullptr) { NANOCLR_CHECK_HRESULT(CreateEntryPointArgs(stack->m_arguments[0], entryPointArgs)); } @@ -669,7 +669,7 @@ HRESULT CLR_RT_ExecutionEngine::Execute(wchar_t *entryPointArgs, int maxContextS #endif { NANOCLR_CHECK_HRESULT( - CLR_RT_HeapBlock_Array::CreateInstance(stack->m_arguments[0], 0, g_CLR_RT_WellKnownTypes.m_String)); + CLR_RT_HeapBlock_Array::CreateInstance(stack->m_arguments[0], 0, g_CLR_RT_WellKnownTypes.String)); } } } @@ -677,7 +677,7 @@ HRESULT CLR_RT_ExecutionEngine::Execute(wchar_t *entryPointArgs, int maxContextS // To debug static constructors, the thread should be created after the entrypoint thread. NANOCLR_CHECK_HRESULT(WaitForDebugger()); - // m_cctorThread is NULL before call and inialized by the SpawnStaticConstructor + // m_cctorThread is nullptr before call and inialized by the SpawnStaticConstructor SpawnStaticConstructor(m_cctorThread); while (true) @@ -761,7 +761,7 @@ HRESULT CLR_RT_ExecutionEngine::Execute(wchar_t *entryPointArgs, int maxContextS #endif // By skipping the whole CLRStartup routine, the Monitor_Program_Exit message never gets sent to clients. - CLR_EE_DBG_EVENT_BROADCAST(CLR_DBG_Commands::c_Monitor_ProgramExit, 0, NULL, WP_Flags_c_NonCritical); + CLR_EE_DBG_EVENT_BROADCAST(CLR_DBG_Commands::c_Monitor_ProgramExit, 0, nullptr, WP_Flags_c_NonCritical); WaitForDebugger(); #endif @@ -772,9 +772,9 @@ bool CLR_RT_ExecutionEngine::EnsureSystemThread(CLR_RT_Thread *&thread, int prio { NATIVE_PROFILE_CLR_CORE(); - if (thread == NULL) + if (thread == nullptr) { - return SUCCEEDED(NewThread(thread, NULL, priority, -1, CLR_RT_Thread::TH_F_System)); + return SUCCEEDED(NewThread(thread, nullptr, priority, -1, CLR_RT_Thread::TH_F_System)); } else { @@ -816,27 +816,27 @@ void CLR_RT_ExecutionEngine::StaticConstructorTerminationCallback(void *arg) bool CLR_RT_ExecutionEngine::SpawnStaticConstructorHelper( CLR_RT_AppDomain *appDomain, CLR_RT_AppDomainAssembly *appDomainAssembly, - const CLR_RT_MethodDef_Index &idx) + const CLR_RT_MethodDef_Index &index) { NATIVE_PROFILE_CLR_CORE(); - CLR_RT_MethodDef_Index idxNext; + CLR_RT_MethodDef_Index indexNext; - _ASSERTE(m_cctorThread != NULL); + _ASSERTE(m_cctorThread != nullptr); //_ASSERTE(m_cctorThread->CanThreadBeReused()); - idxNext.m_data = idx.m_data; + indexNext.m_data = index.m_data; - _ASSERTE(appDomainAssembly != NULL); + _ASSERTE(appDomainAssembly != nullptr); // find next method with static constructor - if (appDomainAssembly->m_assembly->FindNextStaticConstructor(idxNext)) + if (appDomainAssembly->m_assembly->FindNextStaticConstructor(indexNext)) { CLR_RT_HeapBlock_Delegate *dlg; CLR_RT_HeapBlock refDlg; - refDlg.SetObjectReference(NULL); + refDlg.SetObjectReference(nullptr); CLR_RT_ProtectFromGC gc(refDlg); - if (SUCCEEDED(CLR_RT_HeapBlock_Delegate::CreateInstance(refDlg, idxNext, NULL))) + if (SUCCEEDED(CLR_RT_HeapBlock_Delegate::CreateInstance(refDlg, indexNext, nullptr))) { dlg = refDlg.DereferenceDelegate(); dlg->m_appDomain = appDomain; @@ -857,34 +857,34 @@ bool CLR_RT_ExecutionEngine::SpawnStaticConstructorHelper( void CLR_RT_ExecutionEngine::SpawnStaticConstructor(CLR_RT_Thread *&pCctorThread) { NATIVE_PROFILE_CLR_CORE(); - CLR_RT_HeapBlock_Delegate *dlg = NULL; + CLR_RT_HeapBlock_Delegate *dlg = nullptr; if (!EnsureSystemThread(pCctorThread, ThreadPriority::System_Highest)) return; dlg = pCctorThread->m_dlg; - if (dlg != NULL) + if (dlg != nullptr) { CLR_RT_AppDomainAssembly *appDomainAssembly; - CLR_RT_MethodDef_Index idx = dlg->DelegateFtn(); + CLR_RT_MethodDef_Index index = dlg->DelegateFtn(); CLR_RT_MethodDef_Instance inst; - // Find next static constructor for given idx - _ASSERTE(NANOCLR_INDEX_IS_VALID(idx)); - _SIDE_ASSERTE(inst.InitializeFromIndex(idx)); + // Find next static constructor for given index + _ASSERTE(NANOCLR_INDEX_IS_VALID(index)); + _SIDE_ASSERTE(inst.InitializeFromIndex(index)); appDomainAssembly = dlg->m_appDomain->FindAppDomainAssembly(inst.m_assm); - _ASSERTE(appDomainAssembly != NULL); + _ASSERTE(appDomainAssembly != nullptr); _ASSERTE(appDomainAssembly->m_assembly == inst.m_assm); - // This is ok if idx is no longer valid. SpawnStaticConstructorHelper will call FindNextStaticConstructor + // This is ok if index is no longer valid. SpawnStaticConstructorHelper will call FindNextStaticConstructor // which will fail - idx.m_data++; + index.m_data++; // This is not the first static constructor run in this appDomain - if (SpawnStaticConstructorHelper(dlg->m_appDomain, appDomainAssembly, idx)) + if (SpawnStaticConstructorHelper(dlg->m_appDomain, appDomainAssembly, index)) return; } @@ -898,8 +898,8 @@ void CLR_RT_ExecutionEngine::SpawnStaticConstructor(CLR_RT_Thread *&pCctorThread // Find an AppDomainAssembly that does not have it's static constructor bit set... if ((appDomainAssembly->m_flags & CLR_RT_AppDomainAssembly::StaticConstructorsExecuted) == 0) { - CLR_RT_MethodDef_Index idx; - idx.Set(assembly->m_idx, 0); + CLR_RT_MethodDef_Index index; + index.Set(assembly->m_index, 0); #ifdef DEBUG @@ -909,12 +909,12 @@ void CLR_RT_ExecutionEngine::SpawnStaticConstructor(CLR_RT_Thread *&pCctorThread { CLR_RT_AppDomainAssembly *appDomainAssemblyRef = appDomain->FindAppDomainAssembly(ar->m_target); - _ASSERTE(appDomainAssemblyRef != NULL); + _ASSERTE(appDomainAssemblyRef != nullptr); _ASSERTE(appDomainAssemblyRef->m_flags & CLR_RT_AppDomainAssembly::StaticConstructorsExecuted); } #endif - if (SpawnStaticConstructorHelper(appDomain, appDomainAssembly, idx)) + if (SpawnStaticConstructorHelper(appDomain, appDomainAssembly, index)) return; } } @@ -929,28 +929,30 @@ void CLR_RT_ExecutionEngine::SpawnStaticConstructor(CLR_RT_Thread *&pCctorThread } #else // NANOCLR_APPDOMAINS -bool CLR_RT_ExecutionEngine::SpawnStaticConstructorHelper(CLR_RT_Assembly *assembly, const CLR_RT_MethodDef_Index &idx) +bool CLR_RT_ExecutionEngine::SpawnStaticConstructorHelper( + CLR_RT_Assembly *assembly, + const CLR_RT_MethodDef_Index &index) { NATIVE_PROFILE_CLR_CORE(); - CLR_RT_MethodDef_Index idxNext; + CLR_RT_MethodDef_Index indexNext; - _ASSERTE(m_cctorThread != NULL); + _ASSERTE(m_cctorThread != nullptr); _ASSERTE(m_cctorThread->CanThreadBeReused()); - idxNext.m_data = idx.m_data; + indexNext.data = index.data; - _ASSERTE(assembly != NULL); + _ASSERTE(assembly != nullptr); // find next method with static constructor - if (assembly->FindNextStaticConstructor(idxNext)) + if (assembly->FindNextStaticConstructor(indexNext)) { CLR_RT_HeapBlock_Delegate *dlg; CLR_RT_HeapBlock refDlg; - refDlg.SetObjectReference(NULL); + refDlg.SetObjectReference(nullptr); CLR_RT_ProtectFromGC gc(refDlg); - if (SUCCEEDED(CLR_RT_HeapBlock_Delegate::CreateInstance(refDlg, idxNext, NULL))) + if (SUCCEEDED(CLR_RT_HeapBlock_Delegate::CreateInstance(refDlg, indexNext, nullptr))) { dlg = refDlg.DereferenceDelegate(); @@ -963,34 +965,34 @@ bool CLR_RT_ExecutionEngine::SpawnStaticConstructorHelper(CLR_RT_Assembly *assem } } - assembly->m_flags |= CLR_RT_Assembly::StaticConstructorsExecuted; + assembly->flags |= CLR_RT_Assembly::StaticConstructorsExecuted; return false; } void CLR_RT_ExecutionEngine::SpawnStaticConstructor(CLR_RT_Thread *&pCctorThread) { NATIVE_PROFILE_CLR_CORE(); - CLR_RT_HeapBlock_Delegate *dlg = NULL; + CLR_RT_HeapBlock_Delegate *dlg = nullptr; if (!EnsureSystemThread(pCctorThread, ThreadPriority::System_Highest)) return; dlg = pCctorThread->m_dlg; - if (dlg != NULL) + if (dlg != nullptr) { - CLR_RT_MethodDef_Index idx = dlg->DelegateFtn(); + CLR_RT_MethodDef_Index index = dlg->DelegateFtn(); CLR_RT_MethodDef_Instance inst{}; - // Find next static constructor for given idx - _ASSERTE(NANOCLR_INDEX_IS_VALID(idx)); - _SIDE_ASSERTE(inst.InitializeFromIndex(idx)); + // Find next static constructor for given index + _ASSERTE(NANOCLR_INDEX_IS_VALID(index)); + _SIDE_ASSERTE(inst.InitializeFromIndex(index)); - // This is ok if idx is no longer valid. SpawnStaticConstructorHelper will call FindNextStaticConstructor + // This is ok if index is no longer valid. SpawnStaticConstructorHelper will call FindNextStaticConstructor // which will fail - idx.m_data++; + index.data++; - if (SpawnStaticConstructorHelper(inst.m_assm, idx)) + if (SpawnStaticConstructorHelper(inst.assembly, index)) return; } @@ -998,24 +1000,24 @@ void CLR_RT_ExecutionEngine::SpawnStaticConstructor(CLR_RT_Thread *&pCctorThread NANOCLR_FOREACH_ASSEMBLY(g_CLR_RT_TypeSystem) { // Find an AppDomainAssembly that does not have it's static constructor bit set... - if ((pASSM->m_flags & CLR_RT_Assembly::StaticConstructorsExecuted) == 0) + if ((pASSM->flags & CLR_RT_Assembly::StaticConstructorsExecuted) == 0) { - CLR_RT_MethodDef_Index idx; - idx.Set(pASSM->m_idx, 0); + CLR_RT_MethodDef_Index index; + index.Set(pASSM->assemblyIndex, 0); bool fDepedenciesRun = true; // Check that all dependent assemblies have had static constructors run. - CLR_RT_AssemblyRef_CrossReference *ar = pASSM->m_pCrossReference_AssemblyRef; - for (int i = 0; i < pASSM->m_pTablesSize[TBL_AssemblyRef]; i++, ar++) + CLR_RT_AssemblyRef_CrossReference *ar = pASSM->crossReferenceAssemblyRef; + for (int i = 0; i < pASSM->tablesSize[TBL_AssemblyRef]; i++, ar++) { - if ((ar->m_target->m_flags & CLR_RT_Assembly::StaticConstructorsExecuted) == 0) + if ((ar->target->flags & CLR_RT_Assembly::StaticConstructorsExecuted) == 0) { fDepedenciesRun = true; break; } } - if (fDepedenciesRun && SpawnStaticConstructorHelper(pASSM, idx)) + if (fDepedenciesRun && SpawnStaticConstructorHelper(pASSM, index)) return; } } @@ -1040,11 +1042,11 @@ void CLR_RT_ExecutionEngine::SpawnFinalizer() CLR_RT_HeapBlock_Finalizer *fin = (CLR_RT_HeapBlock_Finalizer *)m_finalizersPending.FirstNode(); - if (fin->Next() != NULL) + if (fin->Next() != nullptr) { CLR_RT_HeapBlock delegate; - delegate.SetObjectReference(NULL); + delegate.SetObjectReference(nullptr); CLR_RT_ProtectFromGC gc(delegate); #if defined(NANOCLR_APPDOMAINS) @@ -1053,7 +1055,7 @@ void CLR_RT_ExecutionEngine::SpawnFinalizer() if (EnsureSystemThread(m_finalizerThread, ThreadPriority::BelowNormal)) { - if (SUCCEEDED(CLR_RT_HeapBlock_Delegate::CreateInstance(delegate, fin->m_md, NULL))) + if (SUCCEEDED(CLR_RT_HeapBlock_Delegate::CreateInstance(delegate, fin->m_md, nullptr))) { CLR_RT_HeapBlock_Delegate *dlg = delegate.DereferenceDelegate(); @@ -1088,26 +1090,26 @@ void CLR_RT_ExecutionEngine::UpdateToLowestExecutionCounter(CLR_RT_Thread *pThre pThread->m_executionCounter = m_GlobalExecutionCounter - 1; } -void CLR_RT_ExecutionEngine::RetrieveCurrentMethod(CLR_UINT32 &assmIdx, CLR_UINT32 &methodIdx) +void CLR_RT_ExecutionEngine::RetrieveCurrentMethod(CLR_UINT32 &assmIndex, CLR_UINT32 &methodIndex) { - assmIdx = 0; - methodIdx = 0; + assmIndex = 0; + methodIndex = 0; - if (m_currentThread != NULL) + if (m_currentThread != nullptr) { CLR_RT_StackFrame *stack = m_currentThread->CurrentFrame(); if (stack) { - assmIdx = stack->m_call.Assembly(); - methodIdx = stack->m_call.Method(); + assmIndex = stack->m_call.Assembly(); + methodIndex = stack->m_call.Method(); } } } -void CLR_RetrieveCurrentMethod(CLR_UINT32 &assmIdx, CLR_UINT32 &methodIdx) +void CLR_RetrieveCurrentMethod(CLR_UINT32 &assmIndex, CLR_UINT32 &methodIndex) { - g_CLR_RT_ExecutionEngine.RetrieveCurrentMethod(assmIdx, methodIdx); + g_CLR_RT_ExecutionEngine.RetrieveCurrentMethod(assmIndex, methodIndex); } void CLR_SoftReboot() @@ -1117,7 +1119,7 @@ void CLR_SoftReboot() void CLR_DebuggerBreak() { - if (g_CLR_RT_ExecutionEngine.m_currentThread != NULL) + if (g_CLR_RT_ExecutionEngine.m_currentThread != nullptr) { CLR_RT_HeapBlock *obj = g_CLR_RT_ExecutionEngine.m_currentThread->m_currentException.Dereference(); @@ -1125,11 +1127,11 @@ void CLR_DebuggerBreak() /// Only inject the exception once -- if the dereference is not null then the exception is already set on the /// current thread /// - if (obj == NULL) + if (obj == nullptr) { Library_corlib_native_System_Exception::CreateInstance( g_CLR_RT_ExecutionEngine.m_currentThread->m_currentException, - g_CLR_RT_WellKnownTypes.m_WatchdogException, + g_CLR_RT_WellKnownTypes.WatchdogException, CLR_E_WATCHDOG_TIMEOUT, g_CLR_RT_ExecutionEngine.m_currentThread->CurrentFrame()); } @@ -1181,11 +1183,11 @@ HRESULT CLR_RT_ExecutionEngine::ScheduleThreads(int maxContextSwitch) } #endif // #if defined(NANOCLR_ENABLE_SOURCELEVELDEBUGGING) - CLR_RT_Thread *th = NULL; + CLR_RT_Thread *th = nullptr; // If a static constructor thread exists, we should be running it. // What about func-eval? - if (m_cctorThread == NULL) + if (m_cctorThread == nullptr) { // This is normal case execution. Looks for first ready thread. th = (CLR_RT_Thread *)m_threadsReady.FirstNode(); @@ -1206,9 +1208,9 @@ HRESULT CLR_RT_ExecutionEngine::ScheduleThreads(int maxContextSwitch) } } - // If th->Next() is NULL, then there are no Ready to run threads in the system. + // If th->Next() is nullptr, then there are no Ready to run threads in the system. // In this case we spawn finalizer and make finalizer thread as ready one. - if (th->Next() == NULL) + if (th->Next() == nullptr) { g_CLR_RT_ExecutionEngine.SpawnFinalizer(); @@ -1226,7 +1228,7 @@ HRESULT CLR_RT_ExecutionEngine::ScheduleThreads(int maxContextSwitch) } // If there is ready thread - decrease m_executionCounter for this (th) thread. - if (th->Next() != NULL) + if (th->Next() != nullptr) { // The value to update m_executionCounter for each run. See comment for GetQuantumDebit for possible values int debitForEachRun = th->GetQuantumDebit(); @@ -1435,11 +1437,11 @@ void CLR_RT_ExecutionEngine::InsertThreadRoundRobin(CLR_RT_DblLinkedList &thread thTarget->m_waitForEvents = 0; thTarget->m_waitForEvents_Timeout = TIMEOUT_INFINITE; - if (thTarget->m_waitForObject != NULL) + if (thTarget->m_waitForObject != nullptr) { g_CLR_RT_EventCache.Append_Node(thTarget->m_waitForObject); - thTarget->m_waitForObject = NULL; + thTarget->m_waitForObject = nullptr; } threads.InsertBeforeNode(th, thTarget); @@ -1470,7 +1472,7 @@ HRESULT CLR_RT_ExecutionEngine::NewThread( { thRes->DestroyInstance(); - thRes = NULL; + thRes = nullptr; } } @@ -1490,14 +1492,16 @@ CLR_RT_HeapBlock *CLR_RT_ExecutionEngine::ExtractHeapBlocksForArray( const CLR_RT_ReflectionDef_Index &reflex) { NATIVE_PROFILE_CLR_CORE(); - CLR_DataType dt = (CLR_DataType)inst.m_target->dataType; + NanoCLRDataType dt = (NanoCLRDataType)inst.target->dataType; const CLR_RT_DataTypeLookup &dtl = c_CLR_RT_DataTypeLookup[dt]; CLR_UINT32 totLength = (CLR_UINT32)(sizeof(CLR_RT_HeapBlock_Array) + length * dtl.m_sizeInBytes); CLR_UINT32 lengthHB = CONVERTFROMSIZETOHEAPBLOCKS(totLength); if (lengthHB > CLR_RT_HeapBlock::HB_MaxSize) - return NULL; + { + return nullptr; + } CLR_RT_HeapBlock_Array *pArray = (CLR_RT_HeapBlock_Array *)ExtractHeapBlocks(m_heap, DATATYPE_SZARRAY, 0, lengthHB); @@ -1525,8 +1529,11 @@ CLR_RT_HeapBlock *CLR_RT_ExecutionEngine::ExtractHeapBlocksForClassOrValueTypes( CLR_UINT32 length) { NATIVE_PROFILE_CLR_CORE(); + if (length > CLR_RT_HeapBlock::HB_MaxSize) - return NULL; + { + return nullptr; + } _ASSERTE(dataType == DATATYPE_CLASS || dataType == DATATYPE_VALUETYPE); @@ -1545,6 +1552,33 @@ CLR_RT_HeapBlock *CLR_RT_ExecutionEngine::ExtractHeapBlocksForClassOrValueTypes( return hb; } +CLR_RT_HeapBlock *CLR_RT_ExecutionEngine::ExtractHeapBlocksForGenericInstance( + CLR_UINT32 flags, + const CLR_RT_TypeSpec_Index &genericType, + CLR_UINT32 length) +{ + NATIVE_PROFILE_CLR_CORE(); + + if (length > CLR_RT_HeapBlock::HB_MaxSize) + { + return nullptr; + } + + flags = flags | CLR_RT_HeapBlock::HB_InitializeToZero; + CLR_RT_HeapBlock *hb = ExtractHeapBlocks(m_heap, DATATYPE_GENERICINST, flags, length); + + if (hb) + { + hb->SetGenericInstanceObject(genericType); + +#if defined(NANOCLR_PROFILE_NEW_ALLOCATIONS) + g_CLR_PRF_Profiler.TrackObjectCreation(hb); +#endif + } + + return hb; +} + CLR_RT_HeapBlock *CLR_RT_ExecutionEngine::ExtractHeapBytesForObjects( CLR_UINT32 dataType, CLR_UINT32 flags, @@ -1560,8 +1594,11 @@ CLR_RT_HeapBlock *CLR_RT_ExecutionEngine::ExtractHeapBlocksForObjects( CLR_UINT32 length) { NATIVE_PROFILE_CLR_CORE(); + if (length > CLR_RT_HeapBlock::HB_MaxSize) - return NULL; + { + return nullptr; + } _ASSERTE(dataType != DATATYPE_CLASS && dataType != DATATYPE_VALUETYPE && dataType != DATATYPE_SZARRAY); @@ -1587,8 +1624,11 @@ CLR_RT_HeapBlock_Node *CLR_RT_ExecutionEngine::ExtractHeapBlocksForEvents( CLR_UINT32 length) { NATIVE_PROFILE_CLR_CORE(); + if (length > CLR_RT_HeapBlock::HB_MaxSize) - return NULL; + { + return nullptr; + } flags |= CLR_RT_HeapBlock::HB_Alive | CLR_RT_HeapBlock::HB_Event; @@ -1625,9 +1665,9 @@ CLR_RT_HeapBlock *CLR_RT_ExecutionEngine::ExtractHeapBlocks( #endif // Getting here during a GC is possible, since the watchdog ISR may now require - // dynamic memory allocation for logging. Returning NULL means the watchdog log will + // dynamic memory allocation for logging. Returning nullptr means the watchdog log will // be lost, but without major restructuring there is not much we can do. - return NULL; + return nullptr; } #endif @@ -1658,7 +1698,7 @@ CLR_RT_HeapBlock *CLR_RT_ExecutionEngine::ExtractHeapBlocks( } else { - if (m_lastHcUsed != NULL) + if (m_lastHcUsed != nullptr) { hb = m_lastHcUsed->ExtractBlocks(dataType, flags, length); if (hb) @@ -1688,12 +1728,12 @@ CLR_RT_HeapBlock *CLR_RT_ExecutionEngine::ExtractHeapBlocks( NANOCLR_FOREACH_NODE_END(); } - m_lastHcUsed = NULL; + m_lastHcUsed = nullptr; } if (flags & CLR_RT_HeapBlock::HB_NoGcOnFailedAllocation) { - return NULL; + return nullptr; } switch (phase) @@ -1720,7 +1760,7 @@ CLR_RT_HeapBlock *CLR_RT_ExecutionEngine::ExtractHeapBlocks( if (g_CLR_RT_GarbageCollector.m_freeBytes >= (length * sizeof(struct CLR_RT_HeapBlock))) { // A compaction probably would have saved this OOM - // Compaction will occur for Bitmaps, Arrays, etc. if this function returns NULL, so lets not + // Compaction will occur for Bitmaps, Arrays, etc. if this function returns nullptr, so lets not // through an assert here // Throw the OOM, and schedule a compaction at a safe point @@ -1751,7 +1791,7 @@ CLR_RT_HeapBlock *CLR_RT_ExecutionEngine::ExtractHeapBlocks( #endif } - return NULL; + return nullptr; } } } @@ -1761,7 +1801,7 @@ CLR_RT_HeapBlock *CLR_RT_ExecutionEngine::AccessStaticField(const CLR_RT_FieldDe NATIVE_PROFILE_CLR_CORE(); CLR_RT_FieldDef_Instance inst; - if (inst.InitializeFromIndex(fd) && inst.m_target->flags & CLR_RECORD_FIELDDEF::FD_Static) + if (inst.InitializeFromIndex(fd) && inst.target->flags & CLR_RECORD_FIELDDEF::FD_Static) { #if defined(NANOCLR_APPDOMAINS) { @@ -1774,11 +1814,11 @@ CLR_RT_HeapBlock *CLR_RT_ExecutionEngine::AccessStaticField(const CLR_RT_FieldDe } } #else - return &inst.m_assm->m_pStaticFields[inst.CrossReference().m_offset]; + return &inst.assembly->staticFields[inst.CrossReference().offset]; #endif } - return NULL; + return nullptr; } HRESULT CLR_RT_ExecutionEngine::InitializeReference(CLR_RT_HeapBlock &ref, CLR_RT_SignatureParser &parser) @@ -1793,13 +1833,13 @@ HRESULT CLR_RT_ExecutionEngine::InitializeReference(CLR_RT_HeapBlock &ref, CLR_R NANOCLR_HEADER(); CLR_RT_SignatureParser::Element res; - CLR_DataType dt; + NanoCLRDataType dt; NANOCLR_CHECK_HRESULT(parser.Advance(res)); - dt = res.m_dt; + dt = res.DataType; - if (res.m_levels > 0) // Array + if (res.Levels > 0) // Array { dt = DATATYPE_OBJECT; } @@ -1808,11 +1848,11 @@ HRESULT CLR_RT_ExecutionEngine::InitializeReference(CLR_RT_HeapBlock &ref, CLR_R if (dt == DATATYPE_VALUETYPE) { CLR_RT_TypeDef_Instance inst{}; - inst.InitializeFromIndex(res.m_cls); + inst.InitializeFromIndex(res.Class); - if ((inst.m_target->flags & CLR_RECORD_TYPEDEF::TD_Semantics_Mask) == CLR_RECORD_TYPEDEF::TD_Semantics_Enum) + if ((inst.target->flags & CLR_RECORD_TYPEDEF::TD_Semantics_Mask) == CLR_RECORD_TYPEDEF::TD_Semantics_Enum) { - dt = (CLR_DataType)inst.m_target->dataType; + dt = (NanoCLRDataType)inst.target->dataType; } else { @@ -1854,8 +1894,7 @@ HRESULT CLR_RT_ExecutionEngine::InitializeReference( HRESULT CLR_RT_ExecutionEngine::InitializeLocals( CLR_RT_HeapBlock *locals, - CLR_RT_Assembly *assm, - const CLR_RECORD_METHODDEF *md) + const CLR_RT_MethodDef_Instance &methodDefInstance) { NATIVE_PROFILE_CLR_CORE(); // @@ -1866,21 +1905,23 @@ HRESULT CLR_RT_ExecutionEngine::InitializeLocals( NANOCLR_HEADER(); - CLR_PMETADATA sig = assm->GetSignature(md->locals); - CLR_UINT32 count = md->numLocals; + CLR_RT_Assembly *assembly = methodDefInstance.assembly; + const CLR_RECORD_METHODDEF *methodDef = methodDefInstance.target; + CLR_PMETADATA sig = assembly->GetSignature(methodDef->locals); + CLR_UINT32 count = methodDef->localsCount; bool fZeroed = false; while (count) { - CLR_DataType dt = DATATYPE_VOID; + NanoCLRDataType dt = DATATYPE_VOID; CLR_RT_TypeDef_Index cls; + CLR_RT_TypeSpec_Index typeSpecIndex; CLR_UINT32 levels = 0; - CLR_DataType dtModifier = DATATYPE_VOID; + NanoCLRDataType dtModifier = DATATYPE_VOID; while (true) { dt = CLR_UncompressElementType(sig); - switch (dt) { case DATATYPE_TYPE_PINNED: @@ -1898,58 +1939,85 @@ HRESULT CLR_RT_ExecutionEngine::InitializeLocals( case DATATYPE_VALUETYPE: { CLR_UINT32 tk = CLR_TkFromStream(sig); - CLR_UINT32 idx = CLR_DataFromTk(tk); + CLR_UINT32 index = CLR_DataFromTk(tk); switch (CLR_TypeFromTk(tk)) { - case TBL_TypeSpec: - { - CLR_RT_SignatureParser sub{}; - sub.Initialize_TypeSpec(assm, assm->GetTypeSpec(idx)); - CLR_RT_SignatureParser::Element res; - - NANOCLR_CHECK_HRESULT(sub.Advance(res)); - - cls = res.m_cls; - levels += res.m_levels; - } - break; - case TBL_TypeRef: - cls = assm->m_pCrossReference_TypeRef[idx].m_target; + cls = assembly->crossReferenceTypeRef[index].target; break; case TBL_TypeDef: - cls.Set(assm->m_idx, idx); + cls.Set(assembly->assemblyIndex, index); break; default: NANOCLR_SET_AND_LEAVE(CLR_E_WRONG_TYPE); } + + goto done; } + + case DATATYPE_GENERICINST: + // need to rewind the signature so that the ELEMENT_TYPE is present + // otherwise the comparison won't be possible + sig--; + + if (!assembly->FindTypeSpec(sig, typeSpecIndex)) + { + NANOCLR_SET_AND_LEAVE(CLR_E_WRONG_TYPE); + } goto done; + case DATATYPE_VAR: + { + CLR_INT8 genericParamPosition = *sig++; + + methodDefInstance.assembly + ->FindGenericParamAtTypeSpec(methodDefInstance, genericParamPosition, cls, dt); + + goto done; + } + + case DATATYPE_MVAR: + { + CLR_UINT8 genericParamPosition = *sig++; + + CLR_RT_GenericParam_Index gpIndex; + + assembly->FindGenericParamAtMethodDef(methodDefInstance, genericParamPosition, gpIndex); + + CLR_RT_GenericParam_CrossReference gp = + assembly->crossReferenceGenericParam[gpIndex.GenericParam()]; + + cls = gp.classTypeDef; + dt = gp.dataType; + + goto done; + } + default: { const CLR_RT_TypeDef_Index *cls2 = c_CLR_RT_DataTypeLookup[dt].m_cls; - if (cls2 == NULL) + if (cls2 == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_WRONG_TYPE); } cls = *cls2; - } + goto done; + } } } done: if (levels > 0) // Array or reference { - locals->SetObjectReference(NULL); + locals->SetObjectReference(nullptr); - // If local varialb has DATATYPE_TYPE_PINNED, we mark heap block as + // If local variable has DATATYPE_TYPE_PINNED, we mark heap block as if (dtModifier == DATATYPE_TYPE_PINNED) { locals->Pin(); @@ -1962,9 +2030,9 @@ HRESULT CLR_RT_ExecutionEngine::InitializeLocals( CLR_RT_TypeDef_Instance inst{}; inst.InitializeFromIndex(cls); - if (inst.m_target->dataType != DATATYPE_VALUETYPE) + if (inst.target->dataType != DATATYPE_VALUETYPE) { - locals->SetDataId(CLR_RT_HEAPBLOCK_RAW_ID(inst.m_target->dataType, CLR_RT_HeapBlock::HB_Alive, 1)); + locals->SetDataId(CLR_RT_HEAPBLOCK_RAW_ID(inst.target->dataType, CLR_RT_HeapBlock::HB_Alive, 1)); locals->ClearData(); } else @@ -1990,6 +2058,13 @@ HRESULT CLR_RT_ExecutionEngine::InitializeLocals( NANOCLR_CHECK_HRESULT(NewObject(*locals, inst)); } } + else if (dt == DATATYPE_GENERICINST) + { + // locals for generic instances are always OBJECT type + dt = DATATYPE_OBJECT; + locals->SetDataId(CLR_RT_HEAPBLOCK_RAW_ID(dt, CLR_RT_HeapBlock::HB_Alive, 1)); + locals->ClearData(); + } else { if (c_CLR_RT_DataTypeLookup[dt].m_flags & CLR_RT_DataTypeLookup::c_Reference) @@ -2031,14 +2106,14 @@ HRESULT CLR_RT_ExecutionEngine::NewObject(CLR_RT_HeapBlock &reference, const CLR NATIVE_PROFILE_CLR_CORE(); NANOCLR_HEADER(); - reference.SetObjectReference(NULL); + reference.SetObjectReference(nullptr); - CLR_DataType dt = (CLR_DataType)inst.m_target->dataType; + NanoCLRDataType dt = (NanoCLRDataType)inst.target->dataType; // // You cannot create an array this way. // - if (inst.m_data == g_CLR_RT_WellKnownTypes.m_Array.m_data) + if (inst.data == g_CLR_RT_WellKnownTypes.Array.data) { NANOCLR_SET_AND_LEAVE(CLR_E_WRONG_TYPE); } @@ -2075,16 +2150,16 @@ HRESULT CLR_RT_ExecutionEngine::NewObject(CLR_RT_HeapBlock &reference, const CLR case DATATYPE_CLASS: case DATATYPE_VALUETYPE: { - int clsFields = inst.m_target->iFields_Num; - int totFields = inst.CrossReference().m_totalFields + CLR_RT_HeapBlock::HB_Object_Fields_Offset; + int clsFields = inst.target->instanceFieldsCount; + int totFields = inst.CrossReference().totalFields + CLR_RT_HeapBlock::HB_Object_Fields_Offset; CLR_RT_HeapBlock *obj = ExtractHeapBlocksForClassOrValueTypes(dt, 0, inst, totFields); CHECK_ALLOCATION(obj); reference.SetObjectReference(obj); { - const CLR_RECORD_FIELDDEF *target = NULL; - CLR_RT_Assembly *assm = NULL; + const CLR_RECORD_FIELDDEF *target = nullptr; + CLR_RT_Assembly *assm = nullptr; CLR_RT_TypeDef_Instance instSub = inst; NANOCLR_CHECK_HRESULT(obj->SetObjectCls(inst)); @@ -2103,14 +2178,14 @@ HRESULT CLR_RT_ExecutionEngine::NewObject(CLR_RT_HeapBlock &reference, const CLR if (instSub.SwitchToParent() == false) NANOCLR_SET_AND_LEAVE(CLR_E_FAIL); - clsFields = instSub.m_target->iFields_Num; - target = NULL; + clsFields = instSub.target->instanceFieldsCount; + target = nullptr; } - if (target == NULL) + if (target == nullptr) { - assm = instSub.m_assm; - target = assm->GetFieldDef(instSub.m_target->iFields_First + clsFields); + assm = instSub.assembly; + target = assm->GetFieldDef(instSub.target->firstInstanceField + clsFields); } obj--; @@ -2128,6 +2203,9 @@ HRESULT CLR_RT_ExecutionEngine::NewObject(CLR_RT_HeapBlock &reference, const CLR } break; + case DATATYPE_GENERICINST: + break; + default: NANOCLR_SET_AND_LEAVE(CLR_E_WRONG_TYPE); } @@ -2153,17 +2231,105 @@ HRESULT CLR_RT_ExecutionEngine::NewObject(CLR_RT_HeapBlock &reference, CLR_UINT3 //--// +HRESULT CLR_RT_ExecutionEngine::NewGenericInstanceObject( + CLR_RT_HeapBlock &reference, + const CLR_RT_TypeDef_Instance &typeDef, + const CLR_RT_TypeSpec_Index &genericType) +{ + NATIVE_PROFILE_CLR_CORE(); + NANOCLR_HEADER(); + + CLR_RT_TypeSpec_Instance inst; + + if (inst.InitializeFromIndex(genericType) == false) + { + NANOCLR_SET_AND_LEAVE(CLR_E_WRONG_TYPE); + } + + NANOCLR_SET_AND_LEAVE(NewGenericInstanceObject(reference, typeDef, inst)); + + NANOCLR_NOCLEANUP(); +} + +HRESULT CLR_RT_ExecutionEngine::NewGenericInstanceObject( + CLR_RT_HeapBlock &reference, + const CLR_RT_TypeDef_Instance &instance, + CLR_RT_TypeSpec_Instance &genericInstance) +{ + NATIVE_PROFILE_CLR_CORE(); + NANOCLR_HEADER(); + + const CLR_RECORD_FIELDDEF *target = nullptr; + CLR_RT_Assembly *assm = nullptr; + CLR_RT_TypeDef_Instance instSub = instance; + + reference.SetObjectReference(nullptr); + + int clsFields = instance.target->instanceFieldsCount; + int totFields = instance.CrossReference().totalFields + CLR_RT_HeapBlock::HB_Object_Fields_Offset; + + CLR_RT_HeapBlock_GenericInstance *genericInst; + + genericInst = + (CLR_RT_HeapBlock_GenericInstance *)ExtractHeapBlocksForGenericInstance(0, genericInstance, totFields); + CHECK_ALLOCATION(genericInst); + + reference.SetObjectReference(genericInst); + + // + // Initialize field types, from last to first. + // + // We do the decrement BEFORE the comparison because we want to stop short of the first field, the + // object descriptor (already initialized). + // + genericInst += totFields; + while (--totFields > 0) + { + while (clsFields == 0) + { + if (instSub.SwitchToParent() == false) + { + NANOCLR_SET_AND_LEAVE(CLR_E_FAIL); + } + + clsFields = instSub.target->instanceFieldsCount; + target = nullptr; + } + + if (target == nullptr) + { + assm = instSub.assembly; + target = assm->GetFieldDef(instSub.target->firstInstanceField + clsFields); + } + + genericInst--; + target--; + clsFields--; + + NANOCLR_CHECK_HRESULT(InitializeReference(*genericInst, target, assm)); + } + + if (instance.HasFinalizer()) + { + NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_Finalizer::CreateInstance(reference.Dereference(), instance)); + } + + NANOCLR_NOCLEANUP(); +} + +//--// + HRESULT CLR_RT_ExecutionEngine::CloneObject(CLR_RT_HeapBlock &reference, const CLR_RT_HeapBlock &source) { NATIVE_PROFILE_CLR_CORE(); NANOCLR_HEADER(); const CLR_RT_HeapBlock *obj = &source; - CLR_DataType dt; + NanoCLRDataType dt; while (true) { - dt = (CLR_DataType)obj->DataType(); + dt = (NanoCLRDataType)obj->DataType(); if (dt == DATATYPE_BYREF || dt == DATATYPE_OBJECT) { @@ -2219,11 +2385,11 @@ HRESULT CLR_RT_ExecutionEngine::CopyValueType(CLR_RT_HeapBlock *destination, con if (destination != source) { const CLR_RT_TypeDef_Index &cls = source->ObjectCls(); - if (cls.m_data == destination->ObjectCls().m_data) + if (cls.data == destination->ObjectCls().data) { CLR_RT_TypeDef_Instance inst{}; inst.InitializeFromIndex(cls); - CLR_UINT32 totFields = inst.CrossReference().m_totalFields; + CLR_UINT32 totFields = inst.CrossReference().totalFields; if (source->IsBoxed()) destination->Box(); @@ -2262,7 +2428,7 @@ HRESULT CLR_RT_ExecutionEngine::NewArrayList(CLR_RT_HeapBlock &ref, int size, CL int count = size; int capacity = size < minCapacity ? minCapacity : size; - NANOCLR_CHECK_HRESULT(NewObjectFromIndex(ref, g_CLR_RT_WellKnownTypes.m_ArrayList)); + NANOCLR_CHECK_HRESULT(NewObjectFromIndex(ref, g_CLR_RT_WellKnownTypes.ArrayList)); NANOCLR_CHECK_HRESULT(CLR_RT_ArrayListHelper::PrepareArrayList(ref, count, capacity)); NANOCLR_CHECK_HRESULT(CLR_RT_ArrayListHelper::ExtractArrayFromArrayList(ref, array, count, capacity)); @@ -2284,7 +2450,7 @@ HRESULT CLR_RT_ExecutionEngine::FindFieldDef( do { - if (local.m_assm->FindFieldDef(local.m_target, szText, NULL, 0, res)) + if (local.assembly->FindFieldDef(local.target, szText, nullptr, 0, res)) NANOCLR_SET_AND_LEAVE(S_OK); } while (local.SwitchToParent()); @@ -2326,27 +2492,30 @@ HRESULT CLR_RT_ExecutionEngine::FindField(CLR_RT_HeapBlock &reference, const cha NANOCLR_HEADER(); CLR_RT_FieldDef_Instance inst; - CLR_RT_FieldDef_Index idx; + CLR_RT_FieldDef_Index index; CLR_RT_HeapBlock *res; - field = NULL; + field = nullptr; - NANOCLR_CHECK_HRESULT(FindFieldDef(reference, szText, idx)); + NANOCLR_CHECK_HRESULT(FindFieldDef(reference, szText, index)); - inst.InitializeFromIndex(idx); + inst.InitializeFromIndex(index); - if (inst.m_target->flags & CLR_RECORD_FIELDDEF::FD_Static) + if (inst.target->flags & CLR_RECORD_FIELDDEF::FD_Static) { - res = CLR_RT_ExecutionEngine::AccessStaticField(idx); - if (res == NULL) + res = CLR_RT_ExecutionEngine::AccessStaticField(index); + + if (res == nullptr) + { NANOCLR_SET_AND_LEAVE(CLR_E_WRONG_TYPE); + } } else { res = reference.Dereference(); FAULT_ON_NULL(res); - res += inst.CrossReference().m_offset; + res += inst.CrossReference().offset; } field = res; @@ -2407,7 +2576,7 @@ CLR_RT_HeapBlock_Lock *CLR_RT_ExecutionEngine::FindLockObject(CLR_RT_DblLinkedLi } NANOCLR_FOREACH_NODE_END(); - return NULL; + return nullptr; } CLR_RT_HeapBlock_Lock *CLR_RT_ExecutionEngine::FindLockObject(CLR_RT_HeapBlock &object) @@ -2723,7 +2892,7 @@ void CLR_RT_ExecutionEngine::CheckThreads(CLR_INT64 &timeoutMin, CLR_RT_DblLinke { (void)Library_corlib_native_System_Exception::CreateInstance( th->m_currentException, - g_CLR_RT_WellKnownTypes.m_ConstraintException, + g_CLR_RT_WellKnownTypes.ConstraintException, S_OK, th->CurrentFrame()); @@ -2771,7 +2940,7 @@ HRESULT CLR_RT_ExecutionEngine::LockObject( lock = FindLockObject(reference); - if (lock == NULL) + if (lock == nullptr) { NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_Lock::CreateInstance(lock, sth->m_owningThread, reference)); } @@ -2884,7 +3053,7 @@ bool CLR_RT_ExecutionEngine::IsInstanceOf( CLR_RT_TypeDef_Instance &instTarget = descTarget.m_handlerCls; bool fArray = false; - while (desc.m_reflex.m_levels > 0 && descTarget.m_reflex.m_levels > 0) + while (desc.m_reflex.levels > 0 && descTarget.m_reflex.levels > 0) { desc.GetElementType(desc); descTarget.GetElementType(descTarget); @@ -2893,35 +3062,33 @@ bool CLR_RT_ExecutionEngine::IsInstanceOf( } // only check reflection levels if this is not an array - if (!fArray && desc.m_reflex.m_levels < descTarget.m_reflex.m_levels) + if (!fArray && desc.m_reflex.levels < descTarget.m_reflex.levels) { return false; } - if (desc.m_reflex.m_levels > descTarget.m_reflex.m_levels) + if (desc.m_reflex.levels > descTarget.m_reflex.levels) { - if (descTarget.m_reflex.m_levels == 0 && !isInstInstruction) + if (descTarget.m_reflex.levels == 0 && !isInstInstruction) { // // Casting from [] to System.Array or System.Object is always allowed. // - if (inst.m_data == g_CLR_RT_WellKnownTypes.m_Array.m_data || - inst.m_data == g_CLR_RT_WellKnownTypes.m_Object.m_data || - inst.m_data == g_CLR_RT_WellKnownTypes.m_IList.m_data || - inst.m_data == g_CLR_RT_WellKnownTypes.m_ICloneable.m_data) + if (inst.data == g_CLR_RT_WellKnownTypes.Array.data || inst.data == g_CLR_RT_WellKnownTypes.Object.data || + inst.data == g_CLR_RT_WellKnownTypes.IList.data || inst.data == g_CLR_RT_WellKnownTypes.ICloneable.data) { return true; } } - if (inst.m_target->dataType != instTarget.m_target->dataType) + if (inst.target->dataType != instTarget.target->dataType) { return false; } } - CLR_UINT32 semantic = (inst.m_target->flags & CLR_RECORD_TYPEDEF::TD_Semantics_Mask); - CLR_UINT32 semanticTarget = (instTarget.m_target->flags & CLR_RECORD_TYPEDEF::TD_Semantics_Mask); + CLR_UINT32 semantic = (inst.target->flags & CLR_RECORD_TYPEDEF::TD_Semantics_Mask); + CLR_UINT32 semanticTarget = (instTarget.target->flags & CLR_RECORD_TYPEDEF::TD_Semantics_Mask); if (fArray) { @@ -2933,7 +3100,7 @@ bool CLR_RT_ExecutionEngine::IsInstanceOf( do { - if (inst.m_data == instTarget.m_data) + if (inst.data == instTarget.data) { return true; } @@ -2941,10 +3108,10 @@ bool CLR_RT_ExecutionEngine::IsInstanceOf( // // Scan the list of interfaces. // - if (semanticTarget == CLR_RECORD_TYPEDEF::TD_Semantics_Interface && inst.m_target->interfaces != CLR_EmptyIndex) + if (semanticTarget == CLR_RECORD_TYPEDEF::TD_Semantics_Interface && inst.target->interfaces != CLR_EmptyIndex) { CLR_RT_SignatureParser parser{}; - parser.Initialize_Interfaces(inst.m_assm, inst.m_target); + parser.Initialize_Interfaces(inst.assembly, inst.target); CLR_RT_SignatureParser::Element res; while (parser.Available() > 0) @@ -2952,7 +3119,7 @@ bool CLR_RT_ExecutionEngine::IsInstanceOf( if (FAILED(parser.Advance(res))) break; - if (res.m_cls.m_data == instTarget.m_data) + if (res.Class.data == instTarget.data) { return true; } @@ -3011,7 +3178,7 @@ bool CLR_RT_ExecutionEngine::IsInstanceOf( // // Shortcut for identity. // - if (desc.m_handlerCls.m_data == clsTarget.m_data) + if (desc.m_handlerCls.data == clsTarget.data) return true; if (FAILED(descTarget.InitializeFromType(clsTarget))) @@ -3039,7 +3206,7 @@ HRESULT CLR_RT_ExecutionEngine::CastToType( NATIVE_PROFILE_CLR_CORE(); NANOCLR_HEADER(); - if (ref.DataType() == DATATYPE_OBJECT && ref.Dereference() == NULL) + if (ref.DataType() == DATATYPE_OBJECT && ref.Dereference() == nullptr) { ; } @@ -3054,7 +3221,7 @@ HRESULT CLR_RT_ExecutionEngine::CastToType( NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_CAST); } - ref.SetObjectReference(NULL); + ref.SetObjectReference(nullptr); } NANOCLR_NOCLEANUP(); @@ -3157,7 +3324,7 @@ void CLR_RT_ExecutionEngine::InstallBreakpoints(CLR_DBG_Commands::Debugging_Exec { CLR_RT_Memory::Release(m_breakpoints); - m_breakpoints = NULL; + m_breakpoints = nullptr; m_breakpointsNum = 0; } @@ -3225,8 +3392,11 @@ void CLR_RT_ExecutionEngine::StopOnBreakpoint( CLR_PMETADATA ip) { NATIVE_PROFILE_CLR_CORE(); - if (ip == NULL) + + if (ip == nullptr) + { ip = stack->m_IP; + } def.m_depth = stack->m_depth; def.m_md = stack->m_call; @@ -3276,14 +3446,14 @@ void CLR_RT_ExecutionEngine::Breakpoint_System_Event( { CLR_DBG_Commands::Debugging_Execution_BreakpointDef &def = m_breakpoints[pos]; - if (stack != NULL) + if (stack != nullptr) { - _ASSERTE(FIMPLIES(th != NULL, th == stack->m_owningThread)); + _ASSERTE(FIMPLIES(th != nullptr, th == stack->m_owningThread)); th = stack->m_owningThread; } - if (th == NULL || (def.m_pid == th->m_pid) || + if (th == nullptr || (def.m_pid == th->m_pid) || def.m_pid == CLR_DBG_Commands::Debugging_Execution_BreakpointDef::c_PID_ANY) { if (def.m_flags & event) @@ -3291,7 +3461,7 @@ void CLR_RT_ExecutionEngine::Breakpoint_System_Event( hit.m_id = def.m_id; hit.m_flags = event; - if (stack != NULL) + if (stack != nullptr) { StopOnBreakpoint(hit, stack, ip); } @@ -3325,8 +3495,8 @@ void CLR_RT_ExecutionEngine::Breakpoint_Assemblies_Loaded() hit, CLR_DBG_Commands::Debugging_Execution_BreakpointDef::c_ASSEMBLIES_LOADED, m_currentThread, - NULL, - NULL); + nullptr, + nullptr); } void CLR_RT_ExecutionEngine::Breakpoint_Threads_Prepare(CLR_RT_DblLinkedList &threads) @@ -3419,7 +3589,7 @@ void CLR_RT_ExecutionEngine::Breakpoint_Thread_Terminated(CLR_RT_Thread *th) evt |= CLR_DBG_Commands::Debugging_Execution_BreakpointDef::c_EVAL_COMPLETE; } - Breakpoint_System_Event(hit, evt, th, NULL, NULL); + Breakpoint_System_Event(hit, evt, th, nullptr, nullptr); } void CLR_RT_ExecutionEngine::Breakpoint_Thread_Created(CLR_RT_Thread *th) @@ -3428,7 +3598,12 @@ void CLR_RT_ExecutionEngine::Breakpoint_Thread_Created(CLR_RT_Thread *th) CLR_DBG_Commands::Debugging_Execution_BreakpointDef hit; NANOCLR_CLEAR(hit); - Breakpoint_System_Event(hit, CLR_DBG_Commands::Debugging_Execution_BreakpointDef::c_THREAD_CREATED, th, NULL, NULL); + Breakpoint_System_Event( + hit, + CLR_DBG_Commands::Debugging_Execution_BreakpointDef::c_THREAD_CREATED, + th, + nullptr, + nullptr); } //--// @@ -3491,7 +3666,7 @@ void CLR_RT_ExecutionEngine::Breakpoint_StackFrame_Push(CLR_RT_StackFrame *stack hit.m_flags = CLR_DBG_Commands::Debugging_Execution_BreakpointDef::c_STEP_IN; hit.m_depthExceptionHandler = reason; - StopOnBreakpoint(hit, stack, NULL); + StopOnBreakpoint(hit, stack, nullptr); } } } @@ -3545,7 +3720,7 @@ void CLR_RT_ExecutionEngine::Breakpoint_StackFrame_Pop(CLR_RT_StackFrame *stack, CLR_DBG_Commands::Debugging_Execution_BreakpointDef::c_DEPTH_STEP_RETURN; } - StopOnBreakpoint(hit, (stepEH) ? stack : caller, NULL); + StopOnBreakpoint(hit, (stepEH) ? stack : caller, nullptr); } } } @@ -3591,7 +3766,7 @@ void CLR_RT_ExecutionEngine::Breakpoint_StackFrame_Step(CLR_RT_StackFrame *stack void CLR_RT_ExecutionEngine::Breakpoint_StackFrame_Hard(CLR_RT_StackFrame *stack, CLR_PMETADATA ip) { NATIVE_PROFILE_CLR_CORE(); - if (stack->Prev() != NULL && ip != NULL) + if (stack->Prev() != nullptr && ip != nullptr) { CLR_UINT32 IPoffset = (CLR_UINT32)(ip - stack->m_IPstart); @@ -3604,7 +3779,7 @@ void CLR_RT_ExecutionEngine::Breakpoint_StackFrame_Hard(CLR_RT_StackFrame *stack if (def.m_pid == stack->m_owningThread->m_pid || def.m_pid == CLR_DBG_Commands::Debugging_Execution_BreakpointDef::c_PID_ANY) { - if (def.m_md.m_data == stack->m_call.m_data && def.m_IP == IPoffset) + if (def.m_md.data == stack->m_call.data && def.m_IP == IPoffset) { CLR_DBG_Commands::Debugging_Execution_BreakpointDef hit = def; @@ -3624,7 +3799,7 @@ void CLR_RT_ExecutionEngine::Breakpoint_StackFrame_Break(CLR_RT_StackFrame *stac CLR_DBG_Commands::Debugging_Execution_BreakpointDef hit; NANOCLR_CLEAR(hit); - Breakpoint_System_Event(hit, CLR_DBG_Commands::Debugging_Execution_BreakpointDef::c_BREAK, NULL, stack, NULL); + Breakpoint_System_Event(hit, CLR_DBG_Commands::Debugging_Execution_BreakpointDef::c_BREAK, nullptr, stack, nullptr); } //--// @@ -3639,7 +3814,7 @@ void CLR_RT_ExecutionEngine::Breakpoint_Exception(CLR_RT_StackFrame *stack, CLR_ Breakpoint_System_Event( hit, CLR_DBG_Commands::Debugging_Execution_BreakpointDef::c_EXCEPTION_THROWN, - NULL, + nullptr, stack, ip); } @@ -3657,8 +3832,8 @@ void CLR_RT_ExecutionEngine::Breakpoint_Exception_Uncaught(CLR_RT_Thread *th) hit, CLR_DBG_Commands::Debugging_Execution_BreakpointDef::c_EXCEPTION_THROWN, th, - NULL, - NULL); + nullptr, + nullptr); } void CLR_RT_ExecutionEngine::Breakpoint_Exception_Intercepted(CLR_RT_StackFrame *stack) @@ -3671,7 +3846,7 @@ void CLR_RT_ExecutionEngine::Breakpoint_Exception_Intercepted(CLR_RT_StackFrame hit.m_depthExceptionHandler = stack->m_depth; - Breakpoint_System_Event(hit, event, NULL, stack, NULL); + Breakpoint_System_Event(hit, event, nullptr, stack, nullptr); } #endif // #if defined(NANOCLR_ENABLE_SOURCELEVELDEBUGGING) diff --git a/src/CLR/Core/FileStream/FileStream.cpp b/src/CLR/Core/FileStream/FileStream.cpp index bde7ba205f..2d52e942c5 100644 --- a/src/CLR/Core/FileStream/FileStream.cpp +++ b/src/CLR/Core/FileStream/FileStream.cpp @@ -1,4 +1,4 @@ -// +// // Copyright (c) .NET Foundation and Contributors // Portions Copyright (c) Microsoft Corporation. All rights reserved. // See LICENSE file in the project root for full license information. @@ -33,7 +33,7 @@ HRESULT CLR_RT_FileStream::CreateInstance(CLR_RT_HeapBlock &ref, const char *pat NANOCLR_CHECK_HRESULT(CLR_RT_FileStream::SplitFilePath(path, rootName, rootNameLength, relativePath)); // Retrieve appropriate driver that handles this root name - if ((driver = FileSystemVolumeList::FindVolume(rootName, rootNameLength)) == NULL) + if ((driver = FileSystemVolumeList::FindVolume(rootName, rootNameLength)) == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_DRIVER); } @@ -62,7 +62,7 @@ HRESULT CLR_RT_FileStream::CreateInstance(CLR_RT_HeapBlock &ref, const char *pat } NANOCLR_CHECK_HRESULT( - CLR_RT_HeapBlock_BinaryBlob::CreateInstance(ref, blobSize, NULL, CLR_RT_FileStream::RelocationHandler, 0)); + CLR_RT_HeapBlock_BinaryBlob::CreateInstance(ref, blobSize, nullptr, CLR_RT_FileStream::RelocationHandler, 0)); blob = ref.DereferenceBinaryBlob(); fs = (CLR_RT_FileStream *)blob->GetData(); @@ -86,7 +86,7 @@ HRESULT CLR_RT_FileStream::CreateInstance(CLR_RT_HeapBlock &ref, const char *pat } // I/O is asynchronous from a HAL level or HW buffer: the runtime will just handle the existing memory case DRIVER_BUFFERED_IO: - if ((sdd->inputBuffer == NULL && sdd->canRead) || (sdd->outputBuffer == NULL && sdd->canWrite)) + if ((sdd->inputBuffer == nullptr && sdd->canRead) || (sdd->outputBuffer == nullptr && sdd->canWrite)) { NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_DRIVER); } diff --git a/src/CLR/Core/GarbageCollector.cpp b/src/CLR/Core/GarbageCollector.cpp index dcffa71e9a..8a3386c164 100644 --- a/src/CLR/Core/GarbageCollector.cpp +++ b/src/CLR/Core/GarbageCollector.cpp @@ -7,7 +7,7 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// -CLR_RT_ProtectFromGC *CLR_RT_ProtectFromGC::s_first = NULL; +CLR_RT_ProtectFromGC *CLR_RT_ProtectFromGC::s_first = nullptr; void CLR_RT_ProtectFromGC::Initialize(CLR_RT_HeapBlock &ref) { @@ -16,7 +16,7 @@ void CLR_RT_ProtectFromGC::Initialize(CLR_RT_HeapBlock &ref) s_first = this; m_data = (void **)&ref; - m_fpn = NULL; + m_fpn = nullptr; if (ref.IsForcedAlive()) { @@ -85,7 +85,7 @@ void CLR_RT_ProtectFromGC::InvokeAll() #if defined(NANOCLR_TRACE_EARLYCOLLECTION) -CLR_RT_AssertEarlyCollection *CLR_RT_AssertEarlyCollection::s_first = NULL; +CLR_RT_AssertEarlyCollection *CLR_RT_AssertEarlyCollection::s_first = nullptr; CLR_RT_AssertEarlyCollection::CLR_RT_AssertEarlyCollection(CLR_RT_HeapBlock *ptr) { @@ -105,7 +105,7 @@ CLR_RT_AssertEarlyCollection::~CLR_RT_AssertEarlyCollection() void CLR_RT_AssertEarlyCollection::Cancel() { NATIVE_PROFILE_CLR_CORE(); - m_ptr = NULL; + m_ptr = nullptr; } void CLR_RT_AssertEarlyCollection::CheckAll(CLR_RT_HeapBlock *ptr) @@ -214,7 +214,7 @@ CLR_UINT32 CLR_RT_GarbageCollector::ExecuteGarbageCollection() { CLR_RT_HeapBlock_Array *arr = (CLR_RT_HeapBlock_Array *)ptr; - if (arr != NULL) + if (arr != nullptr) { dt = arr->m_typeOfElement; @@ -294,7 +294,7 @@ CLR_UINT32 CLR_RT_GarbageCollector::ExecuteGarbageCollection() g_CLR_PRF_Profiler.RecordGarbageCollectionEnd(); #endif - return m_freeBytes; + return m_totalBytes - m_freeBytes; } //--// @@ -365,7 +365,7 @@ void CLR_RT_GarbageCollector::Mark() // Call global markers. // #if defined(NANOCLR_VALIDATE_APPDOMAIN_ISOLATION) - (void)g_CLR_RT_ExecutionEngine.SetCurrentAppDomain(NULL); + (void)g_CLR_RT_ExecutionEngine.SetCurrentAppDomain(nullptr); #endif CLR_RT_ProtectFromGC::InvokeAll(); @@ -415,7 +415,7 @@ void CLR_RT_GarbageCollector::Mark() CheckSingleBlock_Force(g_CLR_RT_ExecutionEngine.m_currentUICulture); #if defined(NANOCLR_VALIDATE_APPDOMAIN_ISOLATION) - (void)g_CLR_RT_ExecutionEngine.SetCurrentAppDomain(NULL); + (void)g_CLR_RT_ExecutionEngine.SetCurrentAppDomain(nullptr); #endif // NANOCLR_VALIDATE_APPDOMAIN_ISOLATION #if defined(NANOCLR_ENABLE_SOURCELEVELDEBUGGING) @@ -477,8 +477,8 @@ void CLR_RT_GarbageCollector::Mark() CLR_RT_Memory::Release(markStackT); } - m_markStackList = NULL; - m_markStack = NULL; + m_markStackList = nullptr; + m_markStack = nullptr; #if defined(NANOCLR_VALIDATE_APPDOMAIN_ISOLATION) (void)g_CLR_RT_ExecutionEngine.SetCurrentAppDomain(appDomainSav); @@ -514,7 +514,7 @@ void CLR_RT_GarbageCollector::MarkWeak() } else { - weak->m_targetDirect = NULL; + weak->m_targetDirect = nullptr; } } } @@ -554,7 +554,7 @@ void CLR_RT_GarbageCollector::Sweep() // // Found a dead delegate, kill it!! // - dlgs->SetObjectReference(NULL); + dlgs->SetObjectReference(nullptr); continue; } @@ -623,7 +623,7 @@ void CLR_RT_GarbageCollector::CheckMemoryPressure() weak, g_CLR_RT_ExecutionEngine.m_weakReferences) { - if (weak->m_targetSerialized && weak->m_targetDirect == NULL) + if (weak->m_targetSerialized && weak->m_targetDirect == nullptr) { #if defined(NANOCLR_GC_VERBOSE) && !defined(BUILD_RTM) @@ -642,7 +642,7 @@ void CLR_RT_GarbageCollector::CheckMemoryPressure() { val.InitializeFromHash(weak->m_identity.m_selectorHash); - if (inst.InitializeFromReflection(val, NULL)) + if (inst.InitializeFromReflection(val, nullptr)) { g_CLR_RT_TypeSystem.BuildTypeName(inst, szBuffer, iBuffer); rgBuffer[MAXSTRLEN(rgBuffer)] = 0; @@ -698,17 +698,17 @@ void CLR_RT_GarbageCollector::Assembly_Mark() { NATIVE_PROFILE_CLR_CORE(); #if defined(NANOCLR_VALIDATE_APPDOMAIN_ISOLATION) - (void)g_CLR_RT_ExecutionEngine.SetCurrentAppDomain(NULL); + (void)g_CLR_RT_ExecutionEngine.SetCurrentAppDomain(nullptr); #endif NANOCLR_FOREACH_ASSEMBLY(g_CLR_RT_TypeSystem) { #if !defined(NANOCLR_APPDOMAINS) - CheckMultipleBlocks(pASSM->m_pStaticFields, pASSM->m_iStaticFields); + CheckMultipleBlocks(pASSM->staticFields, pASSM->staticFieldsCount); #endif - CheckSingleBlock(&pASSM->m_pFile); + CheckSingleBlock(&pASSM->file); } NANOCLR_FOREACH_ASSEMBLY_END(); } @@ -752,17 +752,17 @@ void CLR_RT_GarbageCollector::Thread_Mark(CLR_RT_Thread *th) { CheckMultipleBlocks( stack->m_inlineFrame->m_frame.m_args, - stack->m_inlineFrame->m_frame.m_call.m_target->numArgs); + stack->m_inlineFrame->m_frame.m_call.target->argumentsCount); CheckMultipleBlocks( stack->m_inlineFrame->m_frame.m_locals, - stack->m_inlineFrame->m_frame.m_call.m_target->numLocals); + stack->m_inlineFrame->m_frame.m_call.target->localsCount); CheckMultipleBlocks( stack->m_inlineFrame->m_frame.m_evalStack, (int)(stack->m_inlineFrame->m_frame.m_evalPos - stack->m_inlineFrame->m_frame.m_evalStack)); } #endif - CheckMultipleBlocks(stack->m_arguments, stack->m_call.m_target->numArgs); - CheckMultipleBlocks(stack->m_locals, stack->m_call.m_target->numLocals); + CheckMultipleBlocks(stack->m_arguments, stack->m_call.target->argumentsCount); + CheckMultipleBlocks(stack->m_locals, stack->m_call.target->localsCount); CheckMultipleBlocks(stack->m_evalStack, stack->TopValuePosition()); } NANOCLR_FOREACH_NODE_END(); diff --git a/src/CLR/Core/GarbageCollector_Compaction.cpp b/src/CLR/Core/GarbageCollector_Compaction.cpp index 799a191162..d662b4f89b 100644 --- a/src/CLR/Core/GarbageCollector_Compaction.cpp +++ b/src/CLR/Core/GarbageCollector_Compaction.cpp @@ -93,9 +93,9 @@ void CLR_RT_GarbageCollector::Heap_Compact() TestPointers_PopulateOld(); - CLR_RT_HeapCluster *freeRegion_hc = NULL; - - CLR_RT_HeapBlock_Node *freeRegion = NULL; + CLR_RT_HeapCluster *freeRegion_hc = nullptr; + ; + CLR_RT_HeapBlock_Node *freeRegion = nullptr; CLR_RT_HeapCluster *currentSource_hc = (CLR_RT_HeapCluster *)g_CLR_RT_ExecutionEngine.m_heap.FirstNode(); while (currentSource_hc->Next()) @@ -126,7 +126,7 @@ void CLR_RT_GarbageCollector::Heap_Compact() break; } - freeRegion = NULL; + freeRegion = nullptr; freeRegion_hc = freeRegion_hcNext; } @@ -158,11 +158,11 @@ void CLR_RT_GarbageCollector::Heap_Compact() break; } - ////////////////////////////////////////////////////// - // - // At this point, we have at least ONE movable block. - // - ////////////////////////////////////////////////////// + ////////////////////////////////////////////////////// + // + // At this point, we have at least ONE movable block. + // + ////////////////////////////////////////////////////// #if NANOCLR_VALIDATE_HEAP >= NANOCLR_VALIDATE_HEAP_4_CompactionPlus if (IsBlockInFreeList(g_CLR_RT_ExecutionEngine.m_heap, freeRegion, true) == false) @@ -313,12 +313,11 @@ void CLR_RT_GarbageCollector::Heap_Compact() freeRegion = freeRegion->Next(); } - if (freeRegion->Next() == NULL) + if (freeRegion->Next() == nullptr) { - freeRegion = NULL; + freeRegion = nullptr; freeRegion_hc = (CLR_RT_HeapCluster *)freeRegion_hc->Next(); - while (true) { CLR_RT_HeapCluster *freeRegion_hcNext = (CLR_RT_HeapCluster *)freeRegion_hc->Next(); @@ -329,12 +328,12 @@ void CLR_RT_GarbageCollector::Heap_Compact() freeRegion = freeRegion_hc->m_freeList.FirstNode(); - if (freeRegion != NULL && freeRegion->Next()) + if (freeRegion != nullptr && freeRegion->Next()) { break; } - freeRegion = NULL; + freeRegion = nullptr; freeRegion_hc = freeRegion_hcNext; } @@ -447,7 +446,7 @@ void CLR_RT_GarbageCollector::Heap_Relocate() TestPointers_Remap(); - Heap_Relocate_Pass(NULL); + Heap_Relocate_Pass(nullptr); #if defined(NANOCLR_PROFILE_NEW_ALLOCATIONS) g_CLR_PRF_Profiler.TrackObjectRelocation(); @@ -481,12 +480,19 @@ void CLR_RT_GarbageCollector::Heap_Relocate_Pass(RelocateFtn ftn) NANOCLR_FOREACH_NODE(CLR_RT_HeapCluster, hc, g_CLR_RT_ExecutionEngine.m_heap) { CLR_RT_HeapBlock_Node *ptr = hc->m_payloadStart; - CLR_RT_HeapBlock_Node const *end = hc->m_payloadEnd; + CLR_RT_HeapBlock_Node *end = hc->m_payloadEnd; + + // check pointers + _ASSERTE(ptr >= (void *)s_CLR_RT_Heap.location); + _ASSERTE(ptr < (void *)(s_CLR_RT_Heap.location + s_CLR_RT_Heap.size)); + _ASSERTE(end >= (void *)s_CLR_RT_Heap.location); + _ASSERTE(end <= (void *)(s_CLR_RT_Heap.location + s_CLR_RT_Heap.size)); while (ptr < end) { // check pointer - _ASSERTE(ptr >= hc->m_payloadStart && ptr <= hc->m_payloadEnd); + _ASSERTE(ptr >= (void *)s_CLR_RT_Heap.location); + _ASSERTE(ptr < (void *)(s_CLR_RT_Heap.location + s_CLR_RT_Heap.size)); CLR_RT_HEAPBLOCK_RELOCATE(ptr); @@ -581,6 +587,8 @@ void CLR_RT_GarbageCollector::Heap_Relocate(void **ref) else { destinationAddress = (void *)(dst + relocCurrent.m_offset); + _ASSERTE(destinationAddress >= (void *)s_CLR_RT_Heap.location); + _ASSERTE(destinationAddress < (void *)(s_CLR_RT_Heap.location + s_CLR_RT_Heap.size)); #if defined(NANOCLR_PROFILE_NEW_ALLOCATIONS) g_CLR_PRF_Profiler.TrackObjectRelocation(*ref, destinationAddress); diff --git a/src/CLR/Core/GarbageCollector_ComputeReachabilityGraph.cpp b/src/CLR/Core/GarbageCollector_ComputeReachabilityGraph.cpp index f3588e800b..f7c945360d 100644 --- a/src/CLR/Core/GarbageCollector_ComputeReachabilityGraph.cpp +++ b/src/CLR/Core/GarbageCollector_ComputeReachabilityGraph.cpp @@ -19,10 +19,10 @@ void CLR_RT_GarbageCollector::MarkStack::Initialize(MarkStackElement *ptr, size_ // // Empty element to act a sentinel. // - ptr->ptr = NULL; + ptr->ptr = nullptr; ptr->num = 0; #if defined(NANOCLR_VALIDATE_APPDOMAIN_ISOLATION) - ptr->appDomain = NULL; + ptr->appDomain = nullptr; #endif } @@ -32,7 +32,7 @@ bool CLR_RT_GarbageCollector::ComputeReachabilityGraphForSingleBlock(CLR_RT_Heap { NATIVE_PROFILE_CLR_CORE(); CLR_RT_HeapBlock *obj = *ptr; - if (obj == NULL || obj->IsAlive()) + if (obj == nullptr || obj->IsAlive()) return true; return ComputeReachabilityGraphForMultipleBlocks(obj, 1); @@ -58,7 +58,7 @@ bool CLR_RT_GarbageCollector::ComputeReachabilityGraphForMultipleBlocks(CLR_RT_H COMPUTEREACHABILITY_LOADSTATE(); { - CLR_RT_HeapBlock *sub = NULL; + CLR_RT_HeapBlock *sub = nullptr; while (true) { @@ -71,7 +71,7 @@ bool CLR_RT_GarbageCollector::ComputeReachabilityGraphForMultipleBlocks(CLR_RT_H MarkStack *stackNext = (MarkStack *)stackList->Prev(); // finished with this MarkStack - if (stackNext->Prev() == NULL) + if (stackNext->Prev() == nullptr) { // finished marking break; @@ -104,7 +104,7 @@ bool CLR_RT_GarbageCollector::ComputeReachabilityGraphForMultipleBlocks(CLR_RT_H { MarkStack *stackNext = (MarkStack *)stackList->Next(); - if (stackNext->Next() != NULL) + if (stackNext->Next() != nullptr) { COMPUTEREACHABILITY_SAVESTATE(); g_CLR_RT_GarbageCollector.m_markStack = stackNext; @@ -113,7 +113,7 @@ bool CLR_RT_GarbageCollector::ComputeReachabilityGraphForMultipleBlocks(CLR_RT_H else { // try to allocate another stack list... - stackNext = NULL; + stackNext = nullptr; // If there was no space for GC last time, don't bother trying to allocate again if (!g_CLR_RT_GarbageCollector.m_fOutOfStackSpaceForGC) @@ -147,7 +147,7 @@ bool CLR_RT_GarbageCollector::ComputeReachabilityGraphForMultipleBlocks(CLR_RT_H } } - if (stackNext == NULL) + if (stackNext == nullptr) { // Out of stack support space // Set the failure flag and continue, ignoring lst, num @@ -155,7 +155,7 @@ bool CLR_RT_GarbageCollector::ComputeReachabilityGraphForMultipleBlocks(CLR_RT_H g_CLR_RT_GarbageCollector.m_fOutOfStackSpaceForGC = true; - lst = NULL; + lst = nullptr; num = 0; continue; } @@ -174,7 +174,7 @@ bool CLR_RT_GarbageCollector::ComputeReachabilityGraphForMultipleBlocks(CLR_RT_H { - lst = NULL; + lst = nullptr; num = 0; CLR_RT_HeapBlock::Debug_CheckPointer(ptr); @@ -200,7 +200,7 @@ bool CLR_RT_GarbageCollector::ComputeReachabilityGraphForMultipleBlocks(CLR_RT_H if (!appDomain->IsLoaded()) { // If the AppDomain is unloading, we no longer need to keep the reference around - ptr->SetTransparentProxyReference(NULL, NULL); + ptr->SetTransparentProxyReference(nullptr, nullptr); } else { @@ -264,7 +264,7 @@ bool CLR_RT_GarbageCollector::ComputeReachabilityGraphForMultipleBlocks(CLR_RT_H #ifdef BUILD_RTM blob->BinaryBlobMarkingHandler(); #else - _ASSERTE(blob->BinaryBlobMarkingHandler() == NULL); + _ASSERTE(blob->BinaryBlobMarkingHandler() == nullptr); #endif } break; @@ -300,7 +300,7 @@ bool CLR_RT_GarbageCollector::ComputeReachabilityGraphForMultipleBlocks(CLR_RT_H num = 1; } - sub = NULL; + sub = nullptr; } } } diff --git a/src/CLR/Core/GarbageCollector_Info.cpp b/src/CLR/Core/GarbageCollector_Info.cpp index e543c7ac4f..17222a342c 100644 --- a/src/CLR/Core/GarbageCollector_Info.cpp +++ b/src/CLR/Core/GarbageCollector_Info.cpp @@ -270,8 +270,8 @@ bool CLR_RT_GarbageCollector::TestPointers_PopulateOld_Worker(void **ref) ptr->oldRef = ref; ptr->oldPtr = dst; - ptr->newRef = NULL; - ptr->newPtr = NULL; + ptr->newRef = nullptr; + ptr->newPtr = nullptr; ptr->data = *dst; diff --git a/src/CLR/Core/Interpreter.cpp b/src/CLR/Core/Interpreter.cpp index ebd83089d2..eeddbb2395 100644 --- a/src/CLR/Core/Interpreter.cpp +++ b/src/CLR/Core/Interpreter.cpp @@ -1,4 +1,4 @@ -// +// // Copyright (c) .NET Foundation and Contributors // Portions Copyright (c) Microsoft Corporation. All rights reserved. // See LICENSE file in the project root for full license information. @@ -82,7 +82,7 @@ bool CLR_RT_HeapBlock::InitObject() { NATIVE_PROFILE_CLR_CORE(); CLR_RT_HeapBlock *obj = this; - CLR_DataType dt = obj->DataType(); + NanoCLRDataType dt = obj->DataType(); const CLR_RT_DataTypeLookup &dtl = c_CLR_RT_DataTypeLookup[dt]; if (dtl.m_flags & CLR_RT_DataTypeLookup::c_OptimizedValueType) @@ -112,7 +112,7 @@ bool CLR_RT_HeapBlock::InitObject() if (ptr->InitObject() == false) return false; - obj->SetObjectReference(NULL); + obj->SetObjectReference(nullptr); } return true; @@ -120,12 +120,12 @@ bool CLR_RT_HeapBlock::InitObject() //////////////////////////////////////////////////////////////////////////////////////////////////// -HRESULT CLR_RT_HeapBlock::Convert_Internal(CLR_DataType et) +HRESULT CLR_RT_HeapBlock::Convert_Internal(NanoCLRDataType et) { NATIVE_PROFILE_CLR_CORE(); NANOCLR_HEADER(); - CLR_DataType dt = DataType(); + NanoCLRDataType dt = DataType(); const CLR_RT_DataTypeLookup &dtlSrc = c_CLR_RT_DataTypeLookup[dt]; const CLR_RT_DataTypeLookup &dtlDst = c_CLR_RT_DataTypeLookup[et]; int scaleIn; @@ -424,17 +424,17 @@ bool CLR_RT_Thread::FindEhBlock( bool onlyFinallys) { NATIVE_PROFILE_CLR_CORE(); - CLR_RT_Assembly *assm = stack->m_call.m_assm; - CLR_RT_ExceptionHandler *ptrEhExt = NULL; - const CLR_RECORD_EH *ptrEh = NULL; + CLR_RT_Assembly *assm = stack->m_call.assembly; + CLR_RT_ExceptionHandler *ptrEhExt = nullptr; + const CLR_RECORD_EH *ptrEh = nullptr; CLR_UINT32 numEh = 0; - // FROM is always non-NULL and indicates the current IP + // FROM is always non-nullptr and indicates the current IP _ASSERTE(from); - // onlyFinallys is false when we're searching for a handler for an exception, and to should be NULL - _ASSERTE(FIMPLIES(!onlyFinallys, to == NULL)); - // onlyFinallys is true in Phase2, endfinally, leave, etc. to is NULL when we want to leave outside of the current - // stack frame, or non-NULL and pointing to an IL instruction that we are going to when finally's, if any, are + // onlyFinallys is false when we're searching for a handler for an exception, and to should be nullptr + _ASSERTE(FIMPLIES(!onlyFinallys, to == nullptr)); + // onlyFinallys is true in Phase2, endfinally, leave, etc. to is nullptr when we want to leave outside of the current + // stack frame, or non-nullptr and pointing to an IL instruction that we are going to when finally's, if any, are // processed. #if defined(NANOCLR_TRACE_EXCEPTIONS) @@ -443,13 +443,13 @@ bool CLR_RT_Thread::FindEhBlock( if (!onlyFinallys || s_CLR_RT_fTrace_Exceptions >= c_CLR_RT_Trace_Obnoxious) { CLR_Debug::Printf("Unwinding at "); - CLR_RT_DUMP::METHOD(stack->m_call); + CLR_RT_DUMP::METHOD(stack->m_call, nullptr); CLR_Debug::Printf(" [IP: %04x - %d]\r\n", (size_t)stack->m_IP, (stack->m_IP - stack->m_IPstart)); } } #endif - if (stack->m_call.m_target->flags & CLR_RECORD_METHODDEF::MD_HasExceptionHandlers) + if (stack->m_call.target->flags & CLR_RECORD_METHODDEF::MD_HasExceptionHandlers) { switch (stack->m_flags & CLR_RT_StackFrame::c_MethodKind_Mask) { @@ -476,7 +476,7 @@ bool CLR_RT_Thread::FindEhBlock( return false; } - ptrEhExt = NULL; + ptrEhExt = nullptr; } break; @@ -499,7 +499,7 @@ bool CLR_RT_Thread::FindEhBlock( #if defined(NANOCLR_TRACE_EXCEPTIONS) if (CLR_EE_DBG_IS_NOT(NoStackTraceInExceptions) && s_CLR_RT_fTrace_Exceptions >= c_CLR_RT_Trace_Annoying) { - if (to == NULL || s_CLR_RT_fTrace_Exceptions >= c_CLR_RT_Trace_Obnoxious) + if (to == nullptr || s_CLR_RT_fTrace_Exceptions >= c_CLR_RT_Trace_Obnoxious) { CLR_Debug::Printf( "Checking EH: %04X-%04X => %04X\r\n", @@ -594,7 +594,7 @@ bool CLR_RT_Thread::FindEhBlock( #if defined(NANOCLR_TRACE_EXCEPTIONS) if (CLR_EE_DBG_IS_NOT(NoStackTraceInExceptions) && s_CLR_RT_fTrace_Exceptions >= c_CLR_RT_Trace_Annoying) { - if (to == NULL || s_CLR_RT_fTrace_Exceptions >= c_CLR_RT_Trace_Obnoxious) + if (to == nullptr || s_CLR_RT_fTrace_Exceptions >= c_CLR_RT_Trace_Obnoxious) { CLR_Debug::Printf("No match\r\n"); } @@ -619,7 +619,7 @@ HRESULT CLR_RT_Thread::Execute() g_CLR_RT_ExecutionEngine.m_currentThread = this; - if (m_currentException.Dereference() != NULL) + if (m_currentException.Dereference() != nullptr) { hr = CLR_E_PROCESS_EXCEPTION; } @@ -661,19 +661,27 @@ HRESULT CLR_RT_Thread::Execute() default: // Allocate a new exception. stack = CurrentFrame(); - if (stack->Prev() != NULL) + if (stack->Prev() != nullptr) { -#if defined(NANOCLR_TRACE_INSTRUCTIONS) && defined(PLATFORM_WINDOWS_EMULATOR) +#if defined(NANOCLR_TRACE_EXCEPTIONS) && defined(VIRTUAL_DEVICE) for (int i = 0; i < ARRAYSIZE(s_track); i++) { - BackTrackExecution &track = s_track[(s_trackPos + i) % ARRAYSIZE(s_track)]; + BackTrackExecution &track = s_track[(s_trackPos + i - 1) % ARRAYSIZE(s_track)]; - CLR_Debug::Printf(" %3d ", track.m_depth); + // check if there is a valid stack information + if (track.m_assm != nullptr) + { + CLR_Debug::Printf(" %3d ", track.m_depth); - CLR_RT_MethodDef_Instance inst; - inst.InitializeFromIndex(track.m_call); + CLR_RT_MethodDef_Instance inst; + inst.InitializeFromIndex(track.m_call); - // track.m_assm->DumpOpcodeDirect( inst, track.m_IP, track.m_IPstart, track.m_pid ); + track.m_assm->DumpOpcodeDirect(inst, track.m_IP, track.m_IPstart, track.m_pid); + } + else + { + break; + } } CLR_Debug::Printf("\r\n"); @@ -702,7 +710,7 @@ HRESULT CLR_RT_Thread::Execute() break; #endif // #if defined(NANOCLR_ENABLE_SOURCELEVELDEBUGGING) - if (m_currentException.Dereference() != NULL) + if (m_currentException.Dereference() != nullptr) { break; } @@ -718,7 +726,7 @@ HRESULT CLR_RT_Thread::Execute() g_CLR_RT_ExecutionEngine.m_currentThread = currentThreadSav; - ::Events_SetBoolTimer(NULL, 0); + ::Events_SetBoolTimer(nullptr, 0); NANOCLR_CLEANUP_END(); } @@ -739,7 +747,7 @@ HRESULT CLR_RT_Thread::Execute_Inner() } #endif - if (stack->Prev() == NULL) + if (stack->Prev() == nullptr) { m_status = CLR_RT_Thread::TH_S_Terminated; @@ -844,7 +852,7 @@ HRESULT CLR_RT_Thread::Execute_Inner() } // check for exception injected by native code - if (m_currentException.Dereference() != NULL) + if (m_currentException.Dereference() != nullptr) { hr = CLR_E_PROCESS_EXCEPTION; } @@ -852,7 +860,7 @@ HRESULT CLR_RT_Thread::Execute_Inner() // The inner loop may push or pop more stack frames stack = CurrentFrame(); - if (stack->Prev() == NULL) + if (stack->Prev() == nullptr) { m_status = CLR_RT_Thread::TH_S_Terminated; @@ -932,7 +940,7 @@ HRESULT CLR_RT_Thread::Execute_DelegateInvoke(CLR_RT_StackFrame &stackArg) dlg = ptr->DereferenceDelegate(); FAULT_ON_NULL(dlg); - md = stack->m_call.m_target; + md = stack->m_call.target; switch (dlg->DataType()) { @@ -963,7 +971,7 @@ HRESULT CLR_RT_Thread::Execute_DelegateInvoke(CLR_RT_StackFrame &stackArg) dlg = array[stack->m_customState++].DereferenceDelegate(); - if (dlg == NULL || dlg->DataType() != DATATYPE_DELEGATE_HEAD) + if (dlg == nullptr || dlg->DataType() != DATATYPE_DELEGATE_HEAD) continue; break; @@ -977,10 +985,13 @@ HRESULT CLR_RT_Thread::Execute_DelegateInvoke(CLR_RT_StackFrame &stackArg) CLR_RT_ProtectFromGC gc(*dlg); CLR_RT_MethodDef_Instance inst{}; inst.InitializeFromIndex(dlg->DelegateFtn()); - bool fStaticMethod = (inst.m_target->flags & CLR_RECORD_METHODDEF::MD_Static) != 0; + bool fStaticMethod = (inst.target->flags & CLR_RECORD_METHODDEF::MD_Static) != 0; - NANOCLR_CHECK_HRESULT( - stack->MakeCall(inst, fStaticMethod ? NULL : &dlg->m_object, &stack->m_arguments[1], md->numArgs - 1)); + NANOCLR_CHECK_HRESULT(stack->MakeCall( + inst, + fStaticMethod ? nullptr : &dlg->m_object, + &stack->m_arguments[1], + md->argumentsCount - 1)); } NANOCLR_NOCLEANUP(); @@ -994,7 +1005,7 @@ HRESULT CLR_RT_Thread::Execute_IL(CLR_RT_StackFrame &stackArg) CLR_RT_StackFrame *stack = &stackArg; CLR_RT_Thread *th = stack->m_owningThread; - CLR_RT_Assembly *assm = stack->m_call.m_assm; + CLR_RT_Assembly *assm = stack->m_call.assembly; CLR_RT_HeapBlock *evalPos; CLR_PMETADATA ip; bool fCondition; @@ -1332,7 +1343,7 @@ HRESULT CLR_RT_Thread::Execute_IL(CLR_RT_StackFrame &stackArg) evalPos++; CHECKSTACK(stack, evalPos); - evalPos[0].SetObjectReference(NULL); + evalPos[0].SetObjectReference(nullptr); break; } @@ -2094,17 +2105,20 @@ HRESULT CLR_RT_Thread::Execute_IL(CLR_RT_StackFrame &stackArg) CLR_RT_MethodDef_Instance calleeInst{}; if (calleeInst.ResolveToken(arg, assm) == false) + { NANOCLR_SET_AND_LEAVE(CLR_E_WRONG_TYPE); + } + CLR_RT_TypeDef_Index cls; CLR_RT_HeapBlock *pThis; #if defined(NANOCLR_APPDOMAINS) bool fAppDomainTransition = false; #endif - pThis = &evalPos[1 - calleeInst.m_target->numArgs]; // Point to the first arg, 'this' if an instance - // method + pThis = &evalPos[1 - calleeInst.target->argumentsCount]; // Point to the first arg, 'this' if an + // instance method - if (calleeInst.m_target->flags & CLR_RECORD_METHODDEF::MD_DelegateInvoke) + if (calleeInst.target->flags & CLR_RECORD_METHODDEF::MD_DelegateInvoke) { CLR_RT_HeapBlock_Delegate *dlg = pThis->DereferenceDelegate(); FAULT_ON_NULL(dlg); @@ -2113,7 +2127,7 @@ HRESULT CLR_RT_Thread::Execute_IL(CLR_RT_StackFrame &stackArg) { calleeInst.InitializeFromIndex(dlg->DelegateFtn()); - if ((calleeInst.m_target->flags & CLR_RECORD_METHODDEF::MD_Static) == 0) + if ((calleeInst.target->flags & CLR_RECORD_METHODDEF::MD_Static) == 0) { pThis->Assign(dlg->m_object); @@ -2126,7 +2140,7 @@ HRESULT CLR_RT_Thread::Execute_IL(CLR_RT_StackFrame &stackArg) memmove( &pThis[0], &pThis[1], - calleeInst.m_target->numArgs * sizeof(struct CLR_RT_HeapBlock)); + calleeInst.target->argumentsCount * sizeof(struct CLR_RT_HeapBlock)); evalPos--; } @@ -2142,11 +2156,11 @@ HRESULT CLR_RT_Thread::Execute_IL(CLR_RT_StackFrame &stackArg) { CLR_RT_MethodDef_Index calleeReal; - if ((calleeInst.m_target->flags & CLR_RECORD_METHODDEF::MD_Static) == 0) + if ((calleeInst.target->flags & CLR_RECORD_METHODDEF::MD_Static) == 0) { // Instance method, pThis[ 0 ] is valid - if (op == CEE_CALL && pThis[0].Dereference() == NULL) + if (op == CEE_CALL && pThis[0].Dereference() == nullptr) { // CALL on a null instance is allowed, and should not throw a NullReferenceException on // the call although a NullReferenceException is likely to be thrown soon thereafter if @@ -2157,11 +2171,11 @@ HRESULT CLR_RT_Thread::Execute_IL(CLR_RT_StackFrame &stackArg) NANOCLR_CHECK_HRESULT(CLR_RT_TypeDescriptor::ExtractTypeIndexFromObject(pThis[0], cls)); // This test is for performance reasons. c# emits a callvirt on all instance methods to - // make sure that a NullReferenceException is thrown if 'this' is NULL. However, if the + // make sure that a NullReferenceException is thrown if 'this' is nullptr. However, if the // instance method isn't virtual we don't need to do the more expensive virtual method // lookup. if (op == CEE_CALLVIRT && - (calleeInst.m_target->flags & + (calleeInst.target->flags & (CLR_RECORD_METHODDEF::MD_Abstract | CLR_RECORD_METHODDEF::MD_Virtual))) { if (g_CLR_RT_EventCache.FindVirtualMethod(cls, calleeInst, calleeReal) == false) @@ -2184,7 +2198,7 @@ HRESULT CLR_RT_Thread::Execute_IL(CLR_RT_StackFrame &stackArg) { WRITEBACK(stack, evalPos, ip, fDirty); - _ASSERTE(FIMPLIES(pThis->DataType() == DATATYPE_OBJECT, pThis->Dereference() != NULL)); + _ASSERTE(FIMPLIES(pThis->DataType() == DATATYPE_OBJECT, pThis->Dereference() != nullptr)); NANOCLR_CHECK_HRESULT( CLR_RT_StackFrame::PushAppDomainTransition(th, calleeInst, &pThis[0], &pThis[1])); } @@ -2217,7 +2231,7 @@ HRESULT CLR_RT_Thread::Execute_IL(CLR_RT_StackFrame &stackArg) stack->PopInline(); ip = stack->m_IP; - assm = stack->m_call.m_assm; + assm = stack->m_call.assembly; evalPos = stack->m_evalStackPos - 1; fDirty = true; @@ -2275,13 +2289,13 @@ HRESULT CLR_RT_Thread::Execute_IL(CLR_RT_StackFrame &stackArg) CLR_RT_TypeDef_Instance type{}; CLR_RT_TypeDef_Index cls; - if (type.ResolveToken(arg, assm) == false) + if (type.ResolveToken(arg, assm, &stack->m_call) == false) NANOCLR_SET_AND_LEAVE(CLR_E_WRONG_TYPE); NANOCLR_CHECK_HRESULT(CLR_RT_TypeDescriptor::ExtractTypeIndexFromObject(evalPos[0], cls)); // Check this is an object of the requested type. - if (type.m_data != cls.m_data) + if (type.data != cls.data) { NANOCLR_SET_AND_LEAVE(CLR_E_WRONG_TYPE); } @@ -2327,7 +2341,10 @@ HRESULT CLR_RT_Thread::Execute_IL(CLR_RT_StackFrame &stackArg) CLR_RT_MethodDef_Instance calleeInst{}; if (calleeInst.ResolveToken(arg, assm) == false) + { NANOCLR_SET_AND_LEAVE(CLR_E_WRONG_TYPE); + } + CLR_RT_TypeDef_Instance cls{}; CLR_RT_HeapBlock *top; CLR_INT32 changes; @@ -2338,13 +2355,13 @@ HRESULT CLR_RT_Thread::Execute_IL(CLR_RT_StackFrame &stackArg) WRITEBACK(stack, evalPos, ip, fDirty); - if (cls.m_target->IsDelegate()) + if (cls.target->IsDelegate()) { // // Special case for delegates. LDFTN or LDVIRTFTN have already created the delegate object, just // check that... // - changes = -calleeInst.m_target->numArgs; + changes = -calleeInst.target->argumentsCount; NANOCLR_CHECK_HRESULT(CLR_Checks::VerifyStackOK( *stack, stack->m_evalStackPos, @@ -2360,7 +2377,7 @@ HRESULT CLR_RT_Thread::Execute_IL(CLR_RT_StackFrame &stackArg) CLR_RT_HeapBlock_Delegate *dlg = top[1].DereferenceDelegate(); - if (dlg == NULL) + if (dlg == nullptr) { NANOCLR_CHECK_HRESULT(CLR_E_NULL_REFERENCE); } @@ -2374,7 +2391,7 @@ HRESULT CLR_RT_Thread::Execute_IL(CLR_RT_StackFrame &stackArg) NANOCLR_SET_AND_LEAVE(CLR_E_WRONG_TYPE); } - if ((dlgInst.m_target->flags & CLR_RECORD_METHODDEF::MD_Static) == 0) + if ((dlgInst.target->flags & CLR_RECORD_METHODDEF::MD_Static) == 0) { dlg->m_object.Assign(top[0]); } @@ -2383,7 +2400,7 @@ HRESULT CLR_RT_Thread::Execute_IL(CLR_RT_StackFrame &stackArg) } else { - changes = calleeInst.m_target->numArgs; + changes = calleeInst.target->argumentsCount; NANOCLR_CHECK_HRESULT(CLR_Checks::VerifyStackOK( *stack, stack->m_evalStackPos, @@ -2400,13 +2417,21 @@ HRESULT CLR_RT_Thread::Execute_IL(CLR_RT_StackFrame &stackArg) top[0].Assign(top[-1]); top--; } - top->SetObjectReference(NULL); + top->SetObjectReference(nullptr); // Stack: ... ... -> ... // ^ // Top points here. - NANOCLR_CHECK_HRESULT(g_CLR_RT_ExecutionEngine.NewObject(top[0], cls)); + if (calleeInst.genericType == nullptr) + { + NANOCLR_CHECK_HRESULT(g_CLR_RT_ExecutionEngine.NewObject(top[0], cls)); + } + else + { + NANOCLR_CHECK_HRESULT(g_CLR_RT_ExecutionEngine + .NewGenericInstanceObject(top[0], cls, *calleeInst.genericType)); + } // // This is to flag the fact that we need to copy back the 'this' pointer into our stack. @@ -2423,7 +2448,7 @@ HRESULT CLR_RT_Thread::Execute_IL(CLR_RT_StackFrame &stackArg) // // See CLR_RT_StackFrame::Pop() // - if ((cls.m_target->flags & CLR_RECORD_TYPEDEF::TD_Semantics_Mask) == + if ((cls.target->flags & CLR_RECORD_TYPEDEF::TD_Semantics_Mask) == CLR_RECORD_TYPEDEF::TD_Semantics_ValueType) { if (top[0].DataType() == DATATYPE_OBJECT) @@ -2440,7 +2465,7 @@ HRESULT CLR_RT_Thread::Execute_IL(CLR_RT_StackFrame &stackArg) // top = stack->m_evalStackPos++; - changes = calleeInst.m_target->numArgs; + changes = calleeInst.target->argumentsCount; while (--changes > 0) { top[0].Assign(top[-1]); @@ -2507,7 +2532,7 @@ HRESULT CLR_RT_Thread::Execute_IL(CLR_RT_StackFrame &stackArg) if (fieldInst.ResolveToken(arg, assm) == false) NANOCLR_SET_AND_LEAVE(CLR_E_WRONG_TYPE); CLR_RT_HeapBlock *obj = &evalPos[0]; - CLR_DataType dt = obj->DataType(); + NanoCLRDataType dt = obj->DataType(); NANOCLR_CHECK_HRESULT(CLR_RT_TypeDescriptor::ExtractObjectAndDataType(obj, dt)); @@ -2515,7 +2540,7 @@ HRESULT CLR_RT_Thread::Execute_IL(CLR_RT_StackFrame &stackArg) { case DATATYPE_CLASS: case DATATYPE_VALUETYPE: - evalPos[0].Assign(obj[fieldInst.CrossReference().m_offset]); + evalPos[0].Assign(obj[fieldInst.CrossReference().offset]); goto Execute_LoadAndPromote; case DATATYPE_DATETIME: case DATATYPE_TIMESPAN: @@ -2557,7 +2582,7 @@ HRESULT CLR_RT_Thread::Execute_IL(CLR_RT_StackFrame &stackArg) if (fieldInst.ResolveToken(arg, assm) == false) NANOCLR_SET_AND_LEAVE(CLR_E_WRONG_TYPE); CLR_RT_HeapBlock *obj = &evalPos[0]; - CLR_DataType dt = obj->DataType(); + NanoCLRDataType dt = obj->DataType(); NANOCLR_CHECK_HRESULT(CLR_RT_TypeDescriptor::ExtractObjectAndDataType(obj, dt)); @@ -2566,7 +2591,7 @@ HRESULT CLR_RT_Thread::Execute_IL(CLR_RT_StackFrame &stackArg) #endif if (dt == DATATYPE_CLASS || dt == DATATYPE_VALUETYPE) { - evalPos[0].SetReference(obj[fieldInst.CrossReference().m_offset]); + evalPos[0].SetReference(obj[fieldInst.CrossReference().offset]); } else if (dt == DATATYPE_DATETIME || dt == DATATYPE_TIMESPAN) // Special case. { @@ -2592,9 +2617,12 @@ HRESULT CLR_RT_Thread::Execute_IL(CLR_RT_StackFrame &stackArg) CLR_RT_FieldDef_Instance fieldInst; if (fieldInst.ResolveToken(arg, assm) == false) + { NANOCLR_SET_AND_LEAVE(CLR_E_WRONG_TYPE); + } + CLR_RT_HeapBlock *obj = &evalPos[1]; - CLR_DataType dt = obj->DataType(); + NanoCLRDataType dt = obj->DataType(); NANOCLR_CHECK_HRESULT(CLR_RT_TypeDescriptor::ExtractObjectAndDataType(obj, dt)); @@ -2602,7 +2630,8 @@ HRESULT CLR_RT_Thread::Execute_IL(CLR_RT_StackFrame &stackArg) { case DATATYPE_CLASS: case DATATYPE_VALUETYPE: - obj[fieldInst.CrossReference().m_offset].AssignAndPreserveType(evalPos[2]); + case DATATYPE_GENERICINST: + obj[fieldInst.CrossReference().offset].AssignAndPreserveType(evalPos[2]); break; case DATATYPE_DATETIME: // Special case. case DATATYPE_TIMESPAN: // Special case. @@ -2642,11 +2671,16 @@ HRESULT CLR_RT_Thread::Execute_IL(CLR_RT_StackFrame &stackArg) CLR_RT_FieldDef_Instance field; if (field.ResolveToken(arg, assm) == false) + { NANOCLR_SET_AND_LEAVE(CLR_E_WRONG_TYPE); + } CLR_RT_HeapBlock *ptr = CLR_RT_ExecutionEngine::AccessStaticField(field); - if (ptr == NULL) + + if (ptr == nullptr) + { NANOCLR_SET_AND_LEAVE(CLR_E_WRONG_TYPE); + } evalPos++; CHECKSTACK(stack, evalPos); @@ -2668,8 +2702,11 @@ HRESULT CLR_RT_Thread::Execute_IL(CLR_RT_StackFrame &stackArg) NANOCLR_SET_AND_LEAVE(CLR_E_WRONG_TYPE); CLR_RT_HeapBlock *ptr = CLR_RT_ExecutionEngine::AccessStaticField(field); - if (ptr == NULL) + + if (ptr == nullptr) + { NANOCLR_SET_AND_LEAVE(CLR_E_WRONG_TYPE); + } evalPos++; CHECKSTACK(stack, evalPos); @@ -2690,8 +2727,11 @@ HRESULT CLR_RT_Thread::Execute_IL(CLR_RT_StackFrame &stackArg) NANOCLR_SET_AND_LEAVE(CLR_E_WRONG_TYPE); CLR_RT_HeapBlock *ptr = CLR_RT_ExecutionEngine::AccessStaticField(field); - if (ptr == NULL) + + if (ptr == nullptr) + { NANOCLR_SET_AND_LEAVE(CLR_E_WRONG_TYPE); + } evalPos--; CHECKSTACK(stack, evalPos); @@ -2708,8 +2748,10 @@ HRESULT CLR_RT_Thread::Execute_IL(CLR_RT_StackFrame &stackArg) FETCH_ARG_COMPRESSED_TYPETOKEN(arg, ip); CLR_RT_TypeDef_Instance typeInst{}; - if (typeInst.ResolveToken(arg, assm) == false) + if (typeInst.ResolveToken(arg, assm, &stack->m_call) == false) + { NANOCLR_SET_AND_LEAVE(CLR_E_WRONG_TYPE); + } UPDATESTACK(stack, evalPos); @@ -2737,14 +2779,14 @@ HRESULT CLR_RT_Thread::Execute_IL(CLR_RT_StackFrame &stackArg) // castclass typeTok. CLR_RT_TypeDef_Instance typeInst{}; - if (typeInst.ResolveToken(arg, assm) == false) + if (typeInst.ResolveToken(arg, assm, &stack->m_call) == false) NANOCLR_SET_AND_LEAVE(CLR_E_WRONG_TYPE); UPDATESTACK(stack, evalPos); - if (((typeInst.m_target->flags & CLR_RECORD_TYPEDEF::TD_Semantics_Mask) == + if (((typeInst.target->flags & CLR_RECORD_TYPEDEF::TD_Semantics_Mask) == CLR_RECORD_TYPEDEF::TD_Semantics_ValueType) || - ((typeInst.m_target->flags & CLR_RECORD_TYPEDEF::TD_Semantics_Mask) == + ((typeInst.target->flags & CLR_RECORD_TYPEDEF::TD_Semantics_Mask) == CLR_RECORD_TYPEDEF::TD_Semantics_Enum)) { //"unbox" @@ -2895,13 +2937,13 @@ HRESULT CLR_RT_Thread::Execute_IL(CLR_RT_StackFrame &stackArg) CLR_RT_TypeDef_Instance type{}; CLR_RT_TypeDef_Index cls; - if (!type.ResolveToken(arg, assm)) + if (!type.ResolveToken(arg, assm, &stack->m_call)) NANOCLR_SET_AND_LEAVE(CLR_E_WRONG_TYPE); NANOCLR_CHECK_HRESULT(CLR_RT_TypeDescriptor::ExtractTypeIndexFromObject(evalPos[0], cls)); // Check this is an object of the requested type. - if (type.m_data != cls.m_data) + if (type.data != cls.data) NANOCLR_SET_AND_LEAVE(CLR_E_WRONG_TYPE); UPDATESTACK(stack, evalPos); @@ -3080,7 +3122,7 @@ HRESULT CLR_RT_Thread::Execute_IL(CLR_RT_StackFrame &stackArg) evalPos++; CHECKSTACK(stack, evalPos); - evalPos[0].SetObjectReference(NULL); + evalPos[0].SetObjectReference(nullptr); switch (CLR_TypeFromTk(arg)) { @@ -3098,7 +3140,7 @@ HRESULT CLR_RT_Thread::Execute_IL(CLR_RT_StackFrame &stackArg) case TBL_TypeDef: { CLR_RT_TypeDef_Instance cls{}; - if (cls.ResolveToken(arg, assm) == false) + if (cls.ResolveToken(arg, assm, &stack->m_call) == false) NANOCLR_SET_AND_LEAVE(CLR_E_WRONG_TYPE); evalPos[0].SetReflection(cls); @@ -3127,6 +3169,18 @@ HRESULT CLR_RT_Thread::Execute_IL(CLR_RT_StackFrame &stackArg) } break; + case TBL_GenericParam: + { + CLR_RT_GenericParam_Instance param; + if (param.ResolveToken(arg, assm) == false) + { + NANOCLR_SET_AND_LEAVE(CLR_E_WRONG_TYPE); + } + + evalPos[0].SetReflection(param); + } + break; + default: NANOCLR_SET_AND_LEAVE(CLR_E_WRONG_TYPE); break; @@ -3143,7 +3197,7 @@ HRESULT CLR_RT_Thread::Execute_IL(CLR_RT_StackFrame &stackArg) NANOCLR_CHECK_HRESULT(th->ProcessException_EndFinally()); - _ASSERTE(th->m_currentException.Dereference() == NULL); + _ASSERTE(th->m_currentException.Dereference() == nullptr); stack = th->CurrentFrame(); goto Execute_Reload; } @@ -3178,7 +3232,7 @@ HRESULT CLR_RT_Thread::Execute_IL(CLR_RT_StackFrame &stackArg) _ASSERTE(us); us->m_stack = stack; - us->m_exception = NULL; + us->m_exception = nullptr; us->m_ip = ipLeave; us->m_currentBlockStart = eh.m_handlerStart; us->m_currentBlockEnd = eh.m_handlerEnd; @@ -3192,11 +3246,11 @@ HRESULT CLR_RT_Thread::Execute_IL(CLR_RT_StackFrame &stackArg) if (th->m_flags & CLR_RT_Thread::TH_F_Aborted) { - _ASSERTE(th->m_currentException.Dereference() == NULL); + _ASSERTE(th->m_currentException.Dereference() == nullptr); (void)Library_corlib_native_System_Exception::CreateInstance( th->m_currentException, - g_CLR_RT_WellKnownTypes.m_ThreadAbortException, + g_CLR_RT_WellKnownTypes.ThreadAbortException, S_OK, stack); @@ -3355,18 +3409,18 @@ HRESULT CLR_RT_Thread::Execute_IL(CLR_RT_StackFrame &stackArg) FETCH_ARG_COMPRESSED_TYPETOKEN(arg, ip); CLR_RT_TypeDef_Instance clsInst{}; - if (clsInst.ResolveToken(arg, assm) == false) + if (clsInst.ResolveToken(arg, assm, &stack->m_call) == false) NANOCLR_SET_AND_LEAVE(CLR_E_WRONG_TYPE); CLR_INT32 len; - if (clsInst.m_target->dataType) + if (clsInst.target->dataType) { len = sizeof(struct CLR_RT_HeapBlock); } else { - len = (CLR_RT_HeapBlock::HB_Object_Fields_Offset + clsInst.CrossReference().m_totalFields) * - sizeof(struct CLR_RT_HeapBlock); + len = (CLR_RT_HeapBlock::HB_Object_Fields_Offset + clsInst.CrossReference().totalFields) * + sizeof(CLR_RT_HeapBlock); } evalPos++; @@ -3599,7 +3653,7 @@ HRESULT CLR_RT_Thread::Execute_IL(CLR_RT_StackFrame &stackArg) { stack->m_flags |= CLR_RT_StackFrame::c_ExecutingIL; - assm = stack->m_call.m_assm; + assm = stack->m_call.assembly; READCACHE(stack, evalPos, ip, fDirty); continue; diff --git a/src/CLR/Core/InterruptHandler/InterruptHandler.cpp b/src/CLR/Core/InterruptHandler/InterruptHandler.cpp index 1879a658dc..e6def459be 100644 --- a/src/CLR/Core/InterruptHandler/InterruptHandler.cpp +++ b/src/CLR/Core/InterruptHandler/InterruptHandler.cpp @@ -45,9 +45,9 @@ HRESULT CLR_HW_Hardware::SpawnDispatcher() interrupt = (CLR_RT_ApplicationInterrupt *)m_interruptData.m_applicationQueue.FirstValidNode(); - if ((interrupt == NULL) || !g_CLR_RT_ExecutionEngine.EnsureSystemThread( - g_CLR_RT_ExecutionEngine.m_interruptThread, - ThreadPriority::System_Highest)) + if ((interrupt == nullptr) || !g_CLR_RT_ExecutionEngine.EnsureSystemThread( + g_CLR_RT_ExecutionEngine.m_interruptThread, + ThreadPriority::System_Highest)) { return S_OK; } @@ -91,7 +91,7 @@ HRESULT CLR_HW_Hardware::TransferAllInterruptsToApplicationQueue() GLOBAL_UNLOCK(); } - if (rec == NULL) + if (rec == nullptr) break; CLR_RT_ApplicationInterrupt *queueRec = (CLR_RT_ApplicationInterrupt *)CLR_RT_Memory::Allocate_And_Erase( diff --git a/src/CLR/Core/NativeEventDispatcher/NativeEventDispatcher.cpp b/src/CLR/Core/NativeEventDispatcher/NativeEventDispatcher.cpp index 58289fc881..322fdf8d2c 100644 --- a/src/CLR/Core/NativeEventDispatcher/NativeEventDispatcher.cpp +++ b/src/CLR/Core/NativeEventDispatcher/NativeEventDispatcher.cpp @@ -1,4 +1,4 @@ -// +// // Copyright (c) .NET Foundation and Contributors // Portions Copyright (c) Microsoft Corporation. All rights reserved. // See LICENSE file in the project root for full license information. @@ -38,10 +38,10 @@ void CLR_RT_HeapBlock_NativeEventDispatcher::HandlerMethod_CleanUp() CLR_RT_HeapBlock_NativeEventDispatcher *event; - while (NULL != (event = (CLR_RT_HeapBlock_NativeEventDispatcher *) - CLR_RT_HeapBlock_NativeEventDispatcher::eventList.FirstValidNode())) + while (nullptr != (event = (CLR_RT_HeapBlock_NativeEventDispatcher *) + CLR_RT_HeapBlock_NativeEventDispatcher::eventList.FirstValidNode())) { - if (event->driverMethods != NULL) + if (event->driverMethods != nullptr) { event->driverMethods->cleanupProcessor(event); } @@ -56,7 +56,7 @@ HRESULT CLR_RT_HeapBlock_NativeEventDispatcher::CreateInstance(CLR_RT_HeapBlock NATIVE_PROFILE_CLR_IOPORT(); NANOCLR_HEADER(); - CLR_RT_HeapBlock_NativeEventDispatcher *event = NULL; + CLR_RT_HeapBlock_NativeEventDispatcher *event = nullptr; event = EVENTCACHE_EXTRACT_NODE(g_CLR_RT_EventCache, CLR_RT_HeapBlock_NativeEventDispatcher, DATATYPE_IO_PORT); CHECK_ALLOCATION(event); @@ -72,11 +72,11 @@ HRESULT CLR_RT_HeapBlock_NativeEventDispatcher::CreateInstance(CLR_RT_HeapBlock NANOCLR_CHECK_HRESULT(CLR_RT_ObjectToEvent_Source::CreateInstance(event, owner, eventRef)); } - // Set pointer to driver custom data to NULL. It initialized later by users of + // Set pointer to driver custom data to nullptr. It initialized later by users of // CLR_RT_HeapBlock_NativeEventDispatcher - event->pDrvCustomData = NULL; - // Set pointers to drivers methods to NULL. - event->driverMethods = NULL; + event->pDrvCustomData = nullptr; + // Set pointers to drivers methods to nullptr. + event->driverMethods = nullptr; NANOCLR_CLEANUP(); @@ -160,7 +160,7 @@ void CLR_RT_HeapBlock_NativeEventDispatcher::RemoveFromHALQueue() for (CLR_UINT32 curElem = 0; curElem < elemCount; curElem++) { // Retrieve the element ( actually remove it from the queue ) - CLR_HW_Hardware::HalInterruptRecord *testRec = NULL; + CLR_HW_Hardware::HalInterruptRecord *testRec = nullptr; GLOBAL_LOCK(); testRec = g_CLR_HW_Hardware.m_interruptData.m_HalQueue.Pop(); GLOBAL_UNLOCK(); @@ -170,7 +170,7 @@ void CLR_RT_HeapBlock_NativeEventDispatcher::RemoveFromHALQueue() if (testRec->m_context != this) { // If it is different from this instance of CLR_RT_HeapBlock_NativeEventDispatcher, thin push it back - CLR_HW_Hardware::HalInterruptRecord *newRec = NULL; + CLR_HW_Hardware::HalInterruptRecord *newRec = nullptr; GLOBAL_LOCK(); newRec = g_CLR_HW_Hardware.m_interruptData.m_HalQueue.Push(); GLOBAL_UNLOCK(); @@ -186,7 +186,7 @@ void CLR_RT_HeapBlock_NativeEventDispatcher::SaveToHALQueue(uint32_t data1, uint CLR_HW_Hardware::HalInterruptRecord *rec = g_CLR_HW_Hardware.m_interruptData.m_HalQueue.Push(); - if (rec == NULL) + if (rec == nullptr) { // remove the oldest interrupt to make room for the newest g_CLR_HW_Hardware.m_interruptData.m_HalQueue.Pop(); @@ -242,7 +242,7 @@ HRESULT CLR_RT_HeapBlock_NativeEventDispatcher::StartDispatch( args = stackTop->m_arguments; - if ((stackTop->m_call.m_target->flags & CLR_RECORD_METHODDEF::MD_Static) == 0) + if ((stackTop->m_call.target->flags & CLR_RECORD_METHODDEF::MD_Static) == 0) { ++args; } @@ -299,7 +299,7 @@ HRESULT CLR_RT_HeapBlock_NativeEventDispatcher::RecoverManagedObject(CLR_RT_Heap } NANOCLR_FOREACH_NODE_END(); - event = NULL; + event = nullptr; NANOCLR_SET_AND_LEAVE(CLR_E_PIN_DEAD); diff --git a/src/CLR/Core/RPC/CLR_RT_HeapBlock_EndPoint.cpp b/src/CLR/Core/RPC/CLR_RT_HeapBlock_EndPoint.cpp index f15dec8663..3f3e5e4b83 100644 --- a/src/CLR/Core/RPC/CLR_RT_HeapBlock_EndPoint.cpp +++ b/src/CLR/Core/RPC/CLR_RT_HeapBlock_EndPoint.cpp @@ -36,7 +36,7 @@ CLR_RT_HeapBlock_EndPoint *CLR_RT_HeapBlock_EndPoint::FindEndPoint(const CLR_RT_ } NANOCLR_FOREACH_NODE_END(); - return NULL; + return nullptr; } bool CLR_RT_HeapBlock_EndPoint::Port::Compare(const CLR_RT_HeapBlock_EndPoint::Port &port) @@ -53,7 +53,7 @@ HRESULT CLR_RT_HeapBlock_EndPoint::CreateInstance( { NANOCLR_HEADER(); - CLR_RT_HeapBlock_EndPoint *endPoint = NULL; + CLR_RT_HeapBlock_EndPoint *endPoint = nullptr; // // Create a request and stop the calling thread. @@ -134,5 +134,5 @@ CLR_RT_HeapBlock_EndPoint::Message *CLR_RT_HeapBlock_EndPoint::FindMessage(CLR_U } NANOCLR_FOREACH_NODE_END(); - return NULL; + return nullptr; } diff --git a/src/CLR/Core/RPC/RPC_stub.cpp b/src/CLR/Core/RPC/RPC_stub.cpp index 911841f4f1..062b445202 100644 --- a/src/CLR/Core/RPC/RPC_stub.cpp +++ b/src/CLR/Core/RPC/RPC_stub.cpp @@ -23,7 +23,7 @@ __nfweak CLR_RT_HeapBlock_EndPoint *CLR_RT_HeapBlock_EndPoint::FindEndPoint(cons { (void)port; - return NULL; + return nullptr; } __nfweak bool CLR_RT_HeapBlock_EndPoint::Port::Compare(const CLR_RT_HeapBlock_EndPoint::Port &port) @@ -75,5 +75,5 @@ __nfweak CLR_RT_HeapBlock_EndPoint::Message *CLR_RT_HeapBlock_EndPoint::FindMess (void)cmd; (void)seq; - return NULL; + return nullptr; } diff --git a/src/CLR/Core/Serialization/BinaryFormatter.cpp b/src/CLR/Core/Serialization/BinaryFormatter.cpp index 08f8a1bf86..b03d818085 100644 --- a/src/CLR/Core/Serialization/BinaryFormatter.cpp +++ b/src/CLR/Core/Serialization/BinaryFormatter.cpp @@ -25,8 +25,10 @@ CLR_RT_HeapBlock *CLR_RT_BinaryFormatter::TypeHandler::FixDereference(CLR_RT_Hea CLR_RT_HeapBlock *CLR_RT_BinaryFormatter::TypeHandler::FixNull(CLR_RT_HeapBlock *v) { NATIVE_PROFILE_CLR_SERIALIZATION(); - if (v && v->DataType() == DATATYPE_OBJECT && v->Dereference() == NULL) - return NULL; + if (v && v->DataType() == DATATYPE_OBJECT && v->Dereference() == nullptr) + { + return nullptr; + } return v; } @@ -65,8 +67,8 @@ HRESULT CLR_RT_BinaryFormatter::TypeHandler::SetValue(CLR_RT_HeapBlock *v) NATIVE_PROFILE_CLR_SERIALIZATION(); NANOCLR_HEADER(); - m_value = NULL; - m_type = NULL; + m_value = nullptr; + m_type = nullptr; v = TypeHandler::FixNull(v); if (v) @@ -94,7 +96,7 @@ HRESULT CLR_RT_BinaryFormatter::TypeHandler::SetValue(CLR_RT_HeapBlock *v) #endif - if ((m_type->m_handlerCls.m_target->flags & CLR_RECORD_TYPEDEF::TD_Serializable) == 0) + if ((m_type->m_handlerCls.target->flags & CLR_RECORD_TYPEDEF::TD_Serializable) == 0) { #if defined(NANOCLR_APPDOMAINS) @@ -110,8 +112,8 @@ HRESULT CLR_RT_BinaryFormatter::TypeHandler::SetValue(CLR_RT_HeapBlock *v) NANOCLR_SET_AND_LEAVE(CLR_E_APPDOMAIN_MARSHAL_EXCEPTION); } #endif - m_value = NULL; - m_type = NULL; + m_value = nullptr; + m_type = nullptr; } } @@ -132,9 +134,9 @@ int CLR_RT_BinaryFormatter::TypeHandler::SignatureRequirements() res &= ~c_Signature_Length; } - m_typeForced = NULL; + m_typeForced = nullptr; - if (m_typeExpected != NULL) + if (m_typeExpected != nullptr) { switch (m_typeExpected->m_flags) { @@ -153,7 +155,7 @@ int CLR_RT_BinaryFormatter::TypeHandler::SignatureRequirements() if (m_typeExpected->m_flags & CLR_RT_DataTypeLookup::c_Array) { - sub.InitializeFromType(m_typeExpected->m_reflex.m_data.m_type); + sub.InitializeFromType(m_typeExpected->m_reflex.data.type); td = ⊂ } @@ -162,7 +164,7 @@ int CLR_RT_BinaryFormatter::TypeHandler::SignatureRequirements() td = m_typeExpected; } - if (td->m_handlerCls.m_target->flags & CLR_RECORD_TYPEDEF::TD_Sealed) + if (td->m_handlerCls.target->flags & CLR_RECORD_TYPEDEF::TD_Sealed) { res &= ~c_Signature_Type; break; @@ -195,10 +197,10 @@ bool CLR_RT_BinaryFormatter::TypeHandler::CompareTypes(CLR_RT_TypeDescriptor *le return memcmp(left, right, sizeof(*left)) == 0; } -CLR_DataType CLR_RT_BinaryFormatter::TypeHandler::GetDataType(CLR_RT_TypeDescriptor *type) +NanoCLRDataType CLR_RT_BinaryFormatter::TypeHandler::GetDataType(CLR_RT_TypeDescriptor *type) { NATIVE_PROFILE_CLR_SERIALIZATION(); - return (CLR_DataType)type->m_handlerCls.m_target->dataType; + return (NanoCLRDataType)type->m_handlerCls.target->dataType; } CLR_UINT32 CLR_RT_BinaryFormatter::TypeHandler::GetSizeOfType(CLR_RT_TypeDescriptor *type) @@ -220,7 +222,7 @@ HRESULT CLR_RT_BinaryFormatter::TypeHandler::EmitSignature(int &res) NATIVE_PROFILE_CLR_SERIALIZATION(); NANOCLR_HEADER(); - CLR_UINT32 idx; + CLR_UINT32 index; int mask = SignatureRequirements(); if ((mask & c_Signature_Type) == 0) @@ -244,7 +246,7 @@ HRESULT CLR_RT_BinaryFormatter::TypeHandler::EmitSignature(int &res) } } - if (m_value == NULL) + if (m_value == nullptr) { if (mask == 0) { @@ -314,8 +316,8 @@ HRESULT CLR_RT_BinaryFormatter::TypeHandler::EmitSignature(int &res) } #endif - idx = m_bf->SearchDuplicate(m_value); - if (idx != (CLR_UINT32)-1) + index = m_bf->SearchDuplicate(m_value); + if (index != (CLR_UINT32)-1) { // // No duplicates allowed for fixed-type objects. @@ -326,7 +328,7 @@ HRESULT CLR_RT_BinaryFormatter::TypeHandler::EmitSignature(int &res) } NANOCLR_CHECK_HRESULT(m_bf->WriteBits(TE_L1_Duplicate, TE_L1)); - NANOCLR_CHECK_HRESULT(m_bf->WriteCompressedUnsigned(idx)); + NANOCLR_CHECK_HRESULT(m_bf->WriteCompressedUnsigned(index)); res = c_Action_None; NANOCLR_SET_AND_LEAVE(S_OK); @@ -363,7 +365,7 @@ HRESULT CLR_RT_BinaryFormatter::TypeHandler::EmitSignature_Inner( if (value && value->DataType() == DATATYPE_REFLECTION) { - switch (value->ReflectionDataConst().m_kind) + switch (value->ReflectionDataConst().kind) { case REFLECTION_TYPE: case REFLECTION_TYPE_DELAYED: @@ -412,12 +414,12 @@ HRESULT CLR_RT_BinaryFormatter::TypeHandler::EmitSignature_Inner( if ((mask & c_Signature_Type) != 0) { - NANOCLR_CHECK_HRESULT(m_bf->WriteBits((CLR_UINT32)type->m_reflex.m_levels, TE_ArrayDepth)); + NANOCLR_CHECK_HRESULT(m_bf->WriteBits((CLR_UINT32)type->m_reflex.levels, TE_ArrayDepth)); CLR_RT_TypeDescriptor typeSub; - typeSub.InitializeFromType(type->m_reflex.m_data.m_type); + typeSub.InitializeFromType(type->m_reflex.data.type); - NANOCLR_CHECK_HRESULT(EmitSignature_Inner(c_Signature_Header | c_Signature_Type, &typeSub, NULL)); + NANOCLR_CHECK_HRESULT(EmitSignature_Inner(c_Signature_Header | c_Signature_Type, &typeSub, nullptr)); } sizeReal = value->DereferenceArray()->m_numOfElements; @@ -486,7 +488,7 @@ HRESULT CLR_RT_BinaryFormatter::TypeHandler::EmitSignature_Inner( if ((mask & c_Signature_Type) != 0) { - NANOCLR_SET_AND_LEAVE(m_bf->WriteType(type->m_handlerCls.CrossReference().m_hash)); + NANOCLR_SET_AND_LEAVE(m_bf->WriteType(type->m_handlerCls.CrossReference().hash)); } } @@ -502,8 +504,8 @@ HRESULT CLR_RT_BinaryFormatter::TypeHandler::ReadSignature(int &res) int mask = SignatureRequirements(); - m_value = NULL; - m_type = NULL; + m_value = nullptr; + m_type = nullptr; memset(&m_value_tmp, 0, sizeof(struct CLR_RT_HeapBlock)); if (m_typeForced) @@ -535,12 +537,12 @@ HRESULT CLR_RT_BinaryFormatter::TypeHandler::ReadSignature(int &res) if (levelOne == TE_L1_Duplicate) { CLR_RT_HeapBlock *dup; - CLR_UINT32 idx; + CLR_UINT32 index; - NANOCLR_CHECK_HRESULT(m_bf->ReadCompressedUnsigned(idx)); + NANOCLR_CHECK_HRESULT(m_bf->ReadCompressedUnsigned(index)); - dup = m_bf->GetDuplicate(idx); - if (dup == NULL) + dup = m_bf->GetDuplicate(index); + if (dup == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_SERIALIZATION_VIOLATION); } @@ -559,12 +561,12 @@ HRESULT CLR_RT_BinaryFormatter::TypeHandler::ReadSignature(int &res) { if ((mask & c_Signature_Type) != 0) { - CLR_RT_ReflectionDef_Index idx; + CLR_RT_ReflectionDef_Index index; - NANOCLR_CHECK_HRESULT(m_bf->ReadType(idx)); + NANOCLR_CHECK_HRESULT(m_bf->ReadType(index)); m_type = &m_type_tmp; - NANOCLR_CHECK_HRESULT(m_type->InitializeFromReflection(idx)); + NANOCLR_CHECK_HRESULT(m_type->InitializeFromReflection(index)); } } else @@ -595,12 +597,12 @@ HRESULT CLR_RT_BinaryFormatter::TypeHandler::ReadSignature(int &res) if (levelOne == TE_L1_Reference) { - CLR_RT_ReflectionDef_Index idx; + CLR_RT_ReflectionDef_Index index; - NANOCLR_CHECK_HRESULT(m_bf->ReadType(idx)); + NANOCLR_CHECK_HRESULT(m_bf->ReadType(index)); m_type = &m_type_tmp; - NANOCLR_CHECK_HRESULT(m_type->InitializeFromReflection(idx)); + NANOCLR_CHECK_HRESULT(m_type->InitializeFromReflection(index)); } else if (levelOne == TE_L1_Other) { @@ -626,7 +628,7 @@ HRESULT CLR_RT_BinaryFormatter::TypeHandler::ReadSignature(int &res) NANOCLR_SET_AND_LEAVE(CLR_E_SERIALIZATION_BADSTREAM); } - m_type->m_reflex.m_levels = depth; + m_type->m_reflex.levels = depth; m_type->ConvertToArray(); } } @@ -635,7 +637,7 @@ HRESULT CLR_RT_BinaryFormatter::TypeHandler::ReadSignature(int &res) if ((mask & c_Signature_Type) != 0) { m_type = &m_type_tmp; - NANOCLR_CHECK_HRESULT(m_type->InitializeFromType(g_CLR_RT_WellKnownTypes.m_ArrayList)); + NANOCLR_CHECK_HRESULT(m_type->InitializeFromType(g_CLR_RT_WellKnownTypes.ArrayList)); } } else if (levelTwo == TE_L2_Other) @@ -644,7 +646,7 @@ HRESULT CLR_RT_BinaryFormatter::TypeHandler::ReadSignature(int &res) if (levelThree == TE_L3_Type) { m_type = &m_type_tmp; - NANOCLR_CHECK_HRESULT(m_type->InitializeFromType(g_CLR_RT_WellKnownTypes.m_Type)); + NANOCLR_CHECK_HRESULT(m_type->InitializeFromType(g_CLR_RT_WellKnownTypes.Type)); } #if defined(NANOCLR_APPDOMAINS) else if (levelThree == TE_L3_Reflection) @@ -733,7 +735,7 @@ HRESULT CLR_RT_BinaryFormatter::TypeHandler::ReadSignature(int &res) { CLR_RT_TypeDescriptor sub; - if (m_type->m_reflex.m_levels != 1) + if (m_type->m_reflex.levels != 1) { // // Only simple arrays can have variable size. @@ -741,7 +743,7 @@ HRESULT CLR_RT_BinaryFormatter::TypeHandler::ReadSignature(int &res) NANOCLR_SET_AND_LEAVE(CLR_E_WRONG_TYPE); } - sub.InitializeFromType(m_type->m_reflex.m_data.m_type); + sub.InitializeFromType(m_type->m_reflex.data.type); len = m_hints._arraySize; @@ -790,11 +792,11 @@ HRESULT CLR_RT_BinaryFormatter::TypeHandler::ReadSignature(int &res) if (m_type->m_handlerCls.IsATypeHandler()) { - CLR_RT_ReflectionDef_Index idx; + CLR_RT_ReflectionDef_Index index; - NANOCLR_CHECK_HRESULT(m_bf->ReadType(idx)); + NANOCLR_CHECK_HRESULT(m_bf->ReadType(index)); - NANOCLR_CHECK_HRESULT(m_value->SetReflection(idx)); + NANOCLR_CHECK_HRESULT(m_value->SetReflection(index)); res = c_Action_None; NANOCLR_SET_AND_LEAVE(S_OK); @@ -834,7 +836,7 @@ HRESULT CLR_RT_BinaryFormatter::TypeHandler::EmitValue(int &res) if (value->DataType() == DATATYPE_REFLECTION) { - switch (value->ReflectionDataConst().m_kind) + switch (value->ReflectionDataConst().kind) { case REFLECTION_TYPE: case REFLECTION_TYPE_DELAYED: @@ -862,7 +864,7 @@ HRESULT CLR_RT_BinaryFormatter::TypeHandler::EmitValue(int &res) NANOCLR_SET_AND_LEAVE(S_OK); } - if (m_type->m_handlerCls.m_data == g_CLR_RT_WellKnownTypes.m_DateTime.m_data) + if (m_type->m_handlerCls.data == g_CLR_RT_WellKnownTypes.DateTime.data) { CLR_INT64 *pVal = Library_corlib_native_System_DateTime::GetValuePtr(*value); FAULT_ON_NULL(pVal); @@ -871,7 +873,7 @@ HRESULT CLR_RT_BinaryFormatter::TypeHandler::EmitValue(int &res) bits = 64; fSigned = false; } - else if (m_type->m_handlerCls.m_data == g_CLR_RT_WellKnownTypes.m_TimeSpan.m_data) + else if (m_type->m_handlerCls.data == g_CLR_RT_WellKnownTypes.TimeSpan.data) { CLR_INT64 *pVal = Library_corlib_native_System_TimeSpan::GetValuePtr(*value); FAULT_ON_NULL(pVal); @@ -956,7 +958,7 @@ HRESULT CLR_RT_BinaryFormatter::TypeHandler::EmitValue(int &res) if (fSigned) { - CLR_INT64 valS = (CLR_INT64)val; + auto valS = (CLR_INT64)val; if (m_hints._scale != 0) valS /= (CLR_INT64)m_hints._scale; @@ -975,7 +977,7 @@ HRESULT CLR_RT_BinaryFormatter::TypeHandler::EmitValue(int &res) } else { - CLR_UINT64 valU = (CLR_UINT64)val; + auto valU = (CLR_UINT64)val; if (m_hints._scale != 0) valU /= (CLR_UINT64)m_hints._scale; @@ -1006,12 +1008,12 @@ HRESULT CLR_RT_BinaryFormatter::TypeHandler::ReadValue(int &res) NATIVE_PROFILE_CLR_SERIALIZATION(); NANOCLR_HEADER(); - CLR_UINT64 *dst; + CLR_UINT64 *dst = nullptr; CLR_UINT64 val; CLR_UINT32 bits; bool fSigned; - if (m_type->m_handlerCls.m_data == g_CLR_RT_WellKnownTypes.m_DateTime.m_data) + if (m_type->m_handlerCls.data == g_CLR_RT_WellKnownTypes.DateTime.data) { CLR_INT64 *pVal = Library_corlib_native_System_DateTime::GetValuePtr(*m_value); FAULT_ON_NULL(pVal); @@ -1020,7 +1022,7 @@ HRESULT CLR_RT_BinaryFormatter::TypeHandler::ReadValue(int &res) bits = 64; fSigned = false; } - else if (m_type->m_handlerCls.m_data == g_CLR_RT_WellKnownTypes.m_TimeSpan.m_data) + else if (m_type->m_handlerCls.data == g_CLR_RT_WellKnownTypes.TimeSpan.data) { CLR_INT64 *pVal = Library_corlib_native_System_TimeSpan::GetValuePtr(*m_value); FAULT_ON_NULL(pVal); @@ -1041,16 +1043,16 @@ HRESULT CLR_RT_BinaryFormatter::TypeHandler::ReadValue(int &res) if (len == 0xFFFFFFFF) { - m_value->SetObjectReference(NULL); + m_value->SetObjectReference(nullptr); } else { CLR_RT_HeapBlock_String *str = CLR_RT_HeapBlock_String::CreateInstance(*m_value, len); CHECK_ALLOCATION(str); - char *dst1 = (char *)str->StringText(); + auto dstString = (char *)str->StringText(); - NANOCLR_CHECK_HRESULT(m_bf->ReadArray((CLR_UINT8 *)dst1, len)); - dst1[len] = 0; + NANOCLR_CHECK_HRESULT(m_bf->ReadArray((CLR_UINT8 *)dstString, len)); + dstString[len] = 0; } res = c_Action_None; @@ -1146,13 +1148,13 @@ HRESULT CLR_RT_BinaryFormatter::State::CreateInstance( CLR_RT_TypeDescriptor *pDesc; SerializationHintsAttribute hintsTmp{}; - if (type && CLR_RT_ReflectionDef_Index::Convert(*type, inst, NULL)) + if (type && CLR_RT_ReflectionDef_Index::Convert(*type, inst, nullptr)) { NANOCLR_CHECK_HRESULT(desc.InitializeFromType(inst)); pDesc = &desc; - if (hints == NULL) + if (hints == nullptr) { hints = &hintsTmp; @@ -1163,7 +1165,7 @@ HRESULT CLR_RT_BinaryFormatter::State::CreateInstance( } else { - pDesc = NULL; + pDesc = nullptr; } NANOCLR_SET_AND_LEAVE(CreateInstance(parent, hints, pDesc)); @@ -1179,7 +1181,7 @@ HRESULT CLR_RT_BinaryFormatter::State::CreateInstance( NATIVE_PROFILE_CLR_SERIALIZATION(); NANOCLR_HEADER(); - State *ptr = EVENTCACHE_EXTRACT_NODE_INITTOZERO(g_CLR_RT_EventCache, State, DATATYPE_SERIALIZER_STATE); + auto *ptr = EVENTCACHE_EXTRACT_NODE_INITTOZERO(g_CLR_RT_EventCache, State, DATATYPE_SERIALIZER_STATE); CHECK_ALLOCATION(ptr); @@ -1207,14 +1209,14 @@ HRESULT CLR_RT_BinaryFormatter::State::FindHints(SerializationHintsAttribute &hi NANOCLR_CLEAR(hints); - if (cls.m_target->flags & CLR_RECORD_TYPEDEF::TD_HasAttributes) + if (cls.target->flags & CLR_RECORD_TYPEDEF::TD_HasAttributes) { CLR_RT_TypeDef_Instance inst{}; - inst.InitializeFromIndex(g_CLR_RT_WellKnownTypes.m_SerializationHintsAttribute); + inst.InitializeFromIndex(g_CLR_RT_WellKnownTypes.SerializationHintsAttribute); CLR_RT_AttributeEnumerator en{}; en.Initialize(cls); - if (en.MatchNext(&inst, NULL)) + if (en.MatchNext(&inst, nullptr)) { CLR_RT_AttributeParser parser{}; @@ -1226,8 +1228,10 @@ HRESULT CLR_RT_BinaryFormatter::State::FindHints(SerializationHintsAttribute &hi NANOCLR_CHECK_HRESULT(parser.Next(val)); - if (val == NULL) + if (val == nullptr) + { break; + } } } } @@ -1244,14 +1248,14 @@ HRESULT CLR_RT_BinaryFormatter::State::FindHints( NANOCLR_CLEAR(hints); - if (fld.m_target->flags & CLR_RECORD_FIELDDEF::FD_HasAttributes) + if (fld.target->flags & CLR_RECORD_FIELDDEF::FD_HasAttributes) { CLR_RT_TypeDef_Instance inst{}; - inst.InitializeFromIndex(g_CLR_RT_WellKnownTypes.m_SerializationHintsAttribute); + inst.InitializeFromIndex(g_CLR_RT_WellKnownTypes.SerializationHintsAttribute); CLR_RT_AttributeEnumerator en{}; en.Initialize(fld); - if (en.MatchNext(&inst, NULL)) + if (en.MatchNext(&inst, nullptr)) { CLR_RT_AttributeParser parser{}; @@ -1263,7 +1267,7 @@ HRESULT CLR_RT_BinaryFormatter::State::FindHints( NANOCLR_CHECK_HRESULT(parser.Next(val)); - if (val == NULL) + if (val == nullptr) { break; } @@ -1295,8 +1299,8 @@ HRESULT CLR_RT_BinaryFormatter::State::AssignAndFixBoxing(CLR_RT_HeapBlock &dst) NANOCLR_HEADER(); CLR_RT_HeapBlock *src = m_value.m_value; - CLR_DataType dt = dst.DataType(); - CLR_DataType dt2 = (dt == DATATYPE_ARRAY_BYREF) ? (CLR_DataType)dst.DereferenceArray()->m_typeOfElement : dt; + NanoCLRDataType dt = dst.DataType(); + NanoCLRDataType dt2 = (dt == DATATYPE_ARRAY_BYREF) ? (NanoCLRDataType)dst.DereferenceArray()->m_typeOfElement : dt; if (c_CLR_RT_DataTypeLookup[dt2].m_flags & CLR_RT_DataTypeLookup::c_OptimizedValueType) { @@ -1306,7 +1310,7 @@ HRESULT CLR_RT_BinaryFormatter::State::AssignAndFixBoxing(CLR_RT_HeapBlock &dst) src = TypeHandler::FixNull(src); } - if (src == NULL || + if (src == nullptr || (c_CLR_RT_DataTypeLookup[src->DataType()].m_flags & CLR_RT_DataTypeLookup::c_OptimizedValueType) == 0) { NANOCLR_SET_AND_LEAVE(CLR_E_WRONG_TYPE); @@ -1339,30 +1343,30 @@ HRESULT CLR_RT_BinaryFormatter::State::AssignAndFixBoxing(CLR_RT_HeapBlock &dst) else if (src->DataType() == DATATYPE_REFLECTION) { const CLR_RT_ReflectionDef_Index *reflex; - const CLR_RT_TypeDef_Index *cls = NULL; + const CLR_RT_TypeDef_Index *cls; CLR_RT_HeapBlock *pDst = &dst; reflex = &(src->ReflectionDataConst()); - switch (reflex->m_kind) + switch (reflex->kind) { case REFLECTION_ASSEMBLY: - cls = &g_CLR_RT_WellKnownTypes.m_Assembly; + cls = &g_CLR_RT_WellKnownTypes.Assembly; break; case REFLECTION_TYPE: - cls = &g_CLR_RT_WellKnownTypes.m_Type; + cls = &g_CLR_RT_WellKnownTypes.Type; break; case REFLECTION_TYPE_DELAYED: - cls = &g_CLR_RT_WellKnownTypes.m_Type; + cls = &g_CLR_RT_WellKnownTypes.Type; break; case REFLECTION_CONSTRUCTOR: - cls = &g_CLR_RT_WellKnownTypes.m_ConstructorInfo; + cls = &g_CLR_RT_WellKnownTypes.ConstructorInfo; break; case REFLECTION_METHOD: - cls = &g_CLR_RT_WellKnownTypes.m_MethodInfo; + cls = &g_CLR_RT_WellKnownTypes.MethodInfo; break; case REFLECTION_FIELD: - cls = &g_CLR_RT_WellKnownTypes.m_FieldInfo; + cls = &g_CLR_RT_WellKnownTypes.FieldInfo; break; default: @@ -1401,7 +1405,7 @@ HRESULT CLR_RT_BinaryFormatter::State::AssignAndFixBoxing(CLR_RT_HeapBlock &dst) else { src = &m_value.m_value_tmp; - src->SetObjectReference(NULL); + src->SetObjectReference(nullptr); } } @@ -1422,8 +1426,8 @@ HRESULT CLR_RT_BinaryFormatter::State::GetValue() NATIVE_PROFILE_CLR_SERIALIZATION(); NANOCLR_HEADER(); - State *prev = (State *)Prev(); - if (prev->Prev() == NULL) + auto *prev = (State *)Prev(); + if (prev->Prev() == nullptr) { NANOCLR_SET_AND_LEAVE(m_value.SetValue(&m_parent->m_value)); } @@ -1455,9 +1459,9 @@ HRESULT CLR_RT_BinaryFormatter::State::SetValueAndDestroyInstance() if (m_parent->m_fDeserialize) { - State *prev = (State *)Prev(); + auto *prev = (State *)Prev(); - if (prev->Prev() == NULL) + if (prev->Prev() == nullptr) { NANOCLR_CHECK_HRESULT(AssignAndFixBoxing(m_parent->m_value)); } @@ -1505,8 +1509,8 @@ HRESULT CLR_RT_BinaryFormatter::State::Advance() { if (m_parent->m_flags & CLR_RT_BinaryFormatter::c_Flags_Marshal) { - CLR_RT_TypeDef_Index idx; - idx.Clear(); + CLR_RT_TypeDef_Index index; + index.Clear(); CLR_RT_HeapBlock *value = m_value.m_value; if (value && value->DataType() == DATATYPE_REFLECTION) @@ -1514,7 +1518,7 @@ HRESULT CLR_RT_BinaryFormatter::State::Advance() switch (value->ReflectionDataConst().m_kind) { case REFLECTION_TYPE: - idx.m_data = value->ReflectionDataConst().m_data.m_type.m_data; + index.m_data = value->ReflectionDataConst().m_data.m_type.m_data; break; case REFLECTION_TYPE_DELAYED: // should this be allowed for appdomain+marshaling??? @@ -1544,7 +1548,7 @@ HRESULT CLR_RT_BinaryFormatter::State::Advance() _ASSERTE(false); } - idx.Set(inst.Assembly(), inst.CrossReference().GetOwner()); + index.Set(inst.Assembly(), inst.CrossReference().GetOwner()); } break; case REFLECTION_FIELD: @@ -1559,19 +1563,20 @@ HRESULT CLR_RT_BinaryFormatter::State::Advance() NANOCLR_CHECK_HRESULT(desc.InitializeFromFieldDefinition(inst)); - idx = desc.m_handlerCls; + index = desc.m_handlerCls; } break; } } else if (m_value.m_type) { - idx = m_value.m_type->m_handlerCls; + index = m_value.m_type->m_handlerCls; } - if (idx.m_data != 0) + if (index.m_data != 0) { - NANOCLR_CHECK_HRESULT(g_CLR_RT_ExecutionEngine.GetCurrentAppDomain()->VerifyTypeIsLoaded(idx)); + NANOCLR_CHECK_HRESULT( + g_CLR_RT_ExecutionEngine.GetCurrentAppDomain()->VerifyTypeIsLoaded(index)); } } } @@ -1605,7 +1610,7 @@ HRESULT CLR_RT_BinaryFormatter::State::Advance() m_fields_NeedProcessing = true; m_fields_CurrentClass = m_value.m_type->m_handlerCls; m_fields_CurrentField = 0; - m_fields_Pointer = NULL; + m_fields_Pointer = nullptr; break; } @@ -1624,7 +1629,7 @@ HRESULT CLR_RT_BinaryFormatter::State::Advance() m_array_LastPos, capacity)); - m_array_ExpectedType = NULL; + m_array_ExpectedType = nullptr; } else { @@ -1665,17 +1670,17 @@ HRESULT CLR_RT_BinaryFormatter::State::AdvanceToTheNextField() while (NANOCLR_INDEX_IS_VALID(m_fields_CurrentClass)) { - if (m_fields_CurrentField < m_fields_CurrentClass.m_target->iFields_Num) + if (m_fields_CurrentField < m_fields_CurrentClass.target->instanceFieldsCount) { - int offset = m_fields_CurrentClass.m_target->iFields_First + m_fields_CurrentField++; - CLR_RT_FieldDef_Index idx; - idx.Set(m_fields_CurrentClass.Assembly(), offset); + int offset = m_fields_CurrentClass.target->firstInstanceField + m_fields_CurrentField++; + CLR_RT_FieldDef_Index index; + index.Set(m_fields_CurrentClass.Assembly(), offset); CLR_RT_FieldDef_Instance inst; - inst.InitializeFromIndex(idx); + inst.InitializeFromIndex(index); - m_fields_Pointer = m_value.m_value->Dereference() + inst.CrossReference().m_offset; + m_fields_Pointer = m_value.m_value->Dereference() + inst.CrossReference().offset; - if ((inst.m_target->flags & CLR_RECORD_FIELDDEF::FD_NotSerialized) == 0) + if ((inst.target->flags & CLR_RECORD_FIELDDEF::FD_NotSerialized) == 0) { SerializationHintsAttribute hints; CLR_RT_TypeDescriptor desc{}; @@ -1760,7 +1765,7 @@ HRESULT CLR_RT_BinaryFormatter::State::AdvanceToTheNextElement() } else { - hints = NULL; + hints = nullptr; } NANOCLR_SET_AND_LEAVE(State::CreateInstance(m_parent, hints, m_array_ExpectedType)); @@ -1778,14 +1783,14 @@ HRESULT CLR_RT_BinaryFormatter::CreateInstance(CLR_UINT8 *buf, int len, CLR_RT_B NATIVE_PROFILE_CLR_SERIALIZATION(); NANOCLR_HEADER(); - CLR_RT_BinaryFormatter *ptr = + auto *ptr = EVENTCACHE_EXTRACT_NODE(g_CLR_RT_EventCache, CLR_RT_BinaryFormatter, DATATYPE_SERIALIZER_HEAD); res = ptr; CHECK_ALLOCATION(ptr); - ptr->m_stream = NULL; // CLR_RT_HeapBlock_MemoryStream* m_stream; - ptr->m_idx = 0; // CLR_UINT32 m_idx; + ptr->m_stream = nullptr; // CLR_RT_HeapBlock_MemoryStream* m_stream; + ptr->m_index = 0; // CLR_UINT32 m_index; ptr->m_lastTypeRead = 0; // CLR_UINT32 m_lastTypeRead; ptr->m_duplicates .DblLinkedList_Initialize(); // CLR_RT_DblLinkedList m_duplicates; // EVENT HEAP - NO @@ -1793,8 +1798,8 @@ HRESULT CLR_RT_BinaryFormatter::CreateInstance(CLR_UINT8 *buf, int len, CLR_RT_B ptr->m_states.DblLinkedList_Initialize(); // CLR_RT_DblLinkedList m_states; // EVENT HEAP - // NO RELOCATION - list of CLR_RT_BinaryFormatter::State // - ptr->m_fDeserialize = (buf != NULL); // bool m_fDeserialize; - ptr->m_value.SetObjectReference(NULL); // CLR_RT_HeapBlock m_value; + ptr->m_fDeserialize = (buf != nullptr); // bool m_fDeserialize; + ptr->m_value.SetObjectReference(nullptr); // CLR_RT_HeapBlock m_value; ptr->m_value_desc.TypeDescriptor_Initialize(); // CLR_RT_TypeDescriptor m_value_desc; NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_MemoryStream::CreateInstance(ptr->m_stream, buf, len)); @@ -1820,9 +1825,12 @@ HRESULT CLR_RT_BinaryFormatter::Advance() while (true) { - State *top = (State *)m_states.LastNode(); - if (top->Prev() == NULL) + auto *top = (State *)m_states.LastNode(); + + if (top->Prev() == nullptr) + { break; + } NANOCLR_CHECK_HRESULT(top->Advance()); } @@ -1835,9 +1843,9 @@ HRESULT CLR_RT_BinaryFormatter::Advance() void CLR_RT_BinaryFormatter::PrepareForGC(void *data) { NATIVE_PROFILE_CLR_SERIALIZATION(); - if (data != NULL) + if (data != nullptr) { - CLR_RT_BinaryFormatter *bf = (CLR_RT_BinaryFormatter *)data; + auto *bf = (CLR_RT_BinaryFormatter *)data; g_CLR_RT_GarbageCollector.CheckSingleBlock_Force(&bf->m_value); @@ -1857,7 +1865,7 @@ HRESULT CLR_RT_BinaryFormatter::Serialize(CLR_RT_HeapBlock &refData, CLR_RT_Heap CLR_RT_HeapBlock cls; CLR_UINT32 flags = 0; - cls.SetObjectReference(NULL); + cls.SetObjectReference(nullptr); // unbox reflection types CLR_RT_HeapBlock *pObj = &object; @@ -1872,14 +1880,14 @@ HRESULT CLR_RT_BinaryFormatter::Serialize(CLR_RT_HeapBlock &refData, CLR_RT_Heap } } - CLR_RT_BinaryFormatter *bf = NULL; + CLR_RT_BinaryFormatter *bf = nullptr; CLR_RT_ProtectFromGC pgc((void **)&bf, CLR_RT_BinaryFormatter::PrepareForGC); - refData.SetObjectReference(NULL); + refData.SetObjectReference(nullptr); - NANOCLR_CHECK_HRESULT(CLR_RT_BinaryFormatter::CreateInstance(NULL, 0, bf)); + NANOCLR_CHECK_HRESULT(CLR_RT_BinaryFormatter::CreateInstance(nullptr, 0, bf)); - NANOCLR_CHECK_HRESULT(State::CreateInstance(bf, NULL, &cls)); + NANOCLR_CHECK_HRESULT(State::CreateInstance(bf, nullptr, &cls)); bf->m_flags = flags; bf->m_value.Assign(object); @@ -1894,7 +1902,7 @@ HRESULT CLR_RT_BinaryFormatter::Serialize(CLR_RT_HeapBlock &refData, CLR_RT_Heap { bf->DestroyInstance(); - bf = NULL; + bf = nullptr; } NANOCLR_CLEANUP_END(); @@ -1910,7 +1918,7 @@ HRESULT CLR_RT_BinaryFormatter::Deserialize( NANOCLR_HEADER(); CLR_RT_HeapBlock cls; - cls.SetObjectReference(NULL); + cls.SetObjectReference(nullptr); // unbox reflection types CLR_RT_HeapBlock *pObj = &object; @@ -1927,9 +1935,9 @@ HRESULT CLR_RT_BinaryFormatter::Deserialize( CLR_RT_HeapBlock_Array *array = object.DereferenceArray(); - refData.SetObjectReference(NULL); + refData.SetObjectReference(nullptr); - if (array != NULL) + if (array != nullptr) { NANOCLR_SET_AND_LEAVE(CLR_RT_BinaryFormatter::Deserialize( refData, @@ -1954,14 +1962,14 @@ HRESULT CLR_RT_BinaryFormatter::Deserialize( NATIVE_PROFILE_CLR_SERIALIZATION(); NANOCLR_HEADER(); - CLR_RT_BinaryFormatter *bf = NULL; + CLR_RT_BinaryFormatter *bf = nullptr; CLR_RT_ProtectFromGC pgc((void **)&bf, CLR_RT_BinaryFormatter::PrepareForGC); - refData.SetObjectReference(NULL); + refData.SetObjectReference(nullptr); NANOCLR_CHECK_HRESULT(CLR_RT_BinaryFormatter::CreateInstance(data, size, bf)); - NANOCLR_CHECK_HRESULT(State::CreateInstance(bf, NULL, cls)); + NANOCLR_CHECK_HRESULT(State::CreateInstance(bf, nullptr, cls)); bf->m_flags = flags; @@ -1980,7 +1988,7 @@ HRESULT CLR_RT_BinaryFormatter::Deserialize( bf->DestroyInstance(); - bf = NULL; + bf = nullptr; } NANOCLR_CLEANUP_END(); @@ -1993,7 +2001,7 @@ HRESULT CLR_RT_BinaryFormatter::TrackDuplicate(CLR_RT_HeapBlock *object) NATIVE_PROFILE_CLR_SERIALIZATION(); NANOCLR_HEADER(); - DuplicateTracker *ptr = + auto *ptr = EVENTCACHE_EXTRACT_NODE(g_CLR_RT_EventCache, DuplicateTracker, DATATYPE_SERIALIZER_DUPLICATE); CHECK_ALLOCATION(ptr); @@ -2001,7 +2009,7 @@ HRESULT CLR_RT_BinaryFormatter::TrackDuplicate(CLR_RT_HeapBlock *object) m_duplicates.LinkAtBack(ptr); ptr->m_ptr = TypeHandler::FixDereference(object); - ptr->m_idx = m_idx++; + ptr->m_index = m_index++; NANOCLR_NOCLEANUP(); } @@ -2015,7 +2023,7 @@ CLR_UINT32 CLR_RT_BinaryFormatter::SearchDuplicate(CLR_RT_HeapBlock *object) { if (ptr->m_ptr == object) { - return ptr->m_idx; + return ptr->m_index; } } NANOCLR_FOREACH_NODE_END(); @@ -2023,19 +2031,19 @@ CLR_UINT32 CLR_RT_BinaryFormatter::SearchDuplicate(CLR_RT_HeapBlock *object) return (CLR_UINT32)-1; } -CLR_RT_HeapBlock *CLR_RT_BinaryFormatter::GetDuplicate(CLR_UINT32 idx) +CLR_RT_HeapBlock *CLR_RT_BinaryFormatter::GetDuplicate(CLR_UINT32 index) { NATIVE_PROFILE_CLR_SERIALIZATION(); NANOCLR_FOREACH_NODE(DuplicateTracker, ptr, m_duplicates) { - if (ptr->m_idx == idx) + if (ptr->m_index == index) { return ptr->m_ptr; } } NANOCLR_FOREACH_NODE_END(); - return NULL; + return nullptr; } //--//--// diff --git a/src/CLR/Core/Serialization/BinaryFormatter_stub.cpp b/src/CLR/Core/Serialization/BinaryFormatter_stub.cpp index f0fb10be81..642ec7b6ce 100644 --- a/src/CLR/Core/Serialization/BinaryFormatter_stub.cpp +++ b/src/CLR/Core/Serialization/BinaryFormatter_stub.cpp @@ -16,7 +16,7 @@ __nfweak CLR_RT_HeapBlock *CLR_RT_BinaryFormatter::TypeHandler::FixDereference(C (void)v; NATIVE_PROFILE_CLR_SERIALIZATION(); - return NULL; + return nullptr; } __nfweak CLR_RT_HeapBlock *CLR_RT_BinaryFormatter::TypeHandler::FixNull(CLR_RT_HeapBlock *v) @@ -24,7 +24,7 @@ __nfweak CLR_RT_HeapBlock *CLR_RT_BinaryFormatter::TypeHandler::FixNull(CLR_RT_H (void)v; NATIVE_PROFILE_CLR_SERIALIZATION(); - return NULL; + return nullptr; } //--// @@ -69,12 +69,12 @@ __nfweak bool CLR_RT_BinaryFormatter::TypeHandler::CompareTypes( return true; } -__nfweak CLR_DataType CLR_RT_BinaryFormatter::TypeHandler::GetDataType(CLR_RT_TypeDescriptor *type) +__nfweak NanoCLRDataType CLR_RT_BinaryFormatter::TypeHandler::GetDataType(CLR_RT_TypeDescriptor *type) { (void)type; NATIVE_PROFILE_CLR_SERIALIZATION(); - return (CLR_DataType)0; + return (NanoCLRDataType)0; } __nfweak CLR_UINT32 CLR_RT_BinaryFormatter::TypeHandler::GetSizeOfType(CLR_RT_TypeDescriptor *type) @@ -348,12 +348,12 @@ __nfweak CLR_UINT32 CLR_RT_BinaryFormatter::SearchDuplicate(CLR_RT_HeapBlock *ob return (CLR_UINT32)-1; } -__nfweak CLR_RT_HeapBlock *CLR_RT_BinaryFormatter::GetDuplicate(CLR_UINT32 idx) +__nfweak CLR_RT_HeapBlock *CLR_RT_BinaryFormatter::GetDuplicate(CLR_UINT32 index) { - (void)idx; + (void)index; NATIVE_PROFILE_CLR_SERIALIZATION(); - return NULL; + return nullptr; } //--//--// diff --git a/src/CLR/Core/Streams.cpp b/src/CLR/Core/Streams.cpp index 7ebb0126f2..9374f162fa 100644 --- a/src/CLR/Core/Streams.cpp +++ b/src/CLR/Core/Streams.cpp @@ -29,7 +29,7 @@ void CLR_RT_HeapBlock_MemoryStream::DeleteInstance(CLR_RT_HeapBlock_MemoryStream g_CLR_RT_EventCache.Append_Node(stream); - stream = NULL; + stream = nullptr; } } @@ -95,7 +95,7 @@ HRESULT CLR_RT_HeapBlock_MemoryStream::ToArray(CLR_RT_HeapBlock &ref) } NANOCLR_FOREACH_NODE_END(); - NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_Array::CreateInstance(ref, tot, g_CLR_RT_WellKnownTypes.m_UInt8)); + NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_Array::CreateInstance(ref, tot, g_CLR_RT_WellKnownTypes.UInt8)); array = ref.DereferenceArray(); buf = array->GetFirstElement(); @@ -203,7 +203,7 @@ HRESULT CLR_RT_HeapBlock_MemoryStream::ReadBits(CLR_UINT32 &res, CLR_UINT32 bits { m_current = (Buffer *)m_current->Next(); - if (m_current->Next() == NULL) + if (m_current->Next() == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_OUT_OF_RANGE); } diff --git a/src/CLR/Core/StringTable.cpp b/src/CLR/Core/StringTable.cpp index f642682e7e..bfde9d4dea 100644 --- a/src/CLR/Core/StringTable.cpp +++ b/src/CLR/Core/StringTable.cpp @@ -39,13 +39,13 @@ void CLR_RT_Assembly::InitString(std::map &map) NATIVE_PROFILE_CLR_CORE(); const CLR_STRING *array = c_CLR_StringTable_Lookup; size_t len = c_CLR_StringTable_Size; - CLR_STRING idx = 0xFFFF; + CLR_STRING index = 0xFFFF; map.clear(); while (len-- > 0) { - map[&c_CLR_StringTable_Data[*array++]] = idx--; + map[&c_CLR_StringTable_Data[*array++]] = index--; } } diff --git a/src/CLR/Core/Thread.cpp b/src/CLR/Core/Thread.cpp index 7d8ad0d32e..c752ec5ac2 100644 --- a/src/CLR/Core/Thread.cpp +++ b/src/CLR/Core/Thread.cpp @@ -1,4 +1,4 @@ -// +// // Copyright (c) .NET Foundation and Contributors // Portions Copyright (c) Microsoft Corporation. All rights reserved. // See LICENSE file in the project root for full license information. @@ -46,8 +46,11 @@ void CLR_RT_SubThread::DestroyInstance(CLR_RT_Thread *th, CLR_RT_SubThread *sthB while (true) { CLR_RT_SubThread *sth = th->CurrentSubThread(); - if (sth->Prev() == NULL) + + if (sth->Prev() == nullptr) + { break; + } // // Release all the frames for this subthread. @@ -55,11 +58,16 @@ void CLR_RT_SubThread::DestroyInstance(CLR_RT_Thread *th, CLR_RT_SubThread *sthB while (true) { CLR_RT_StackFrame *stack = th->CurrentFrame(); - if (stack->Prev() == NULL) + + if (stack->Prev() == nullptr) + { break; + } if (stack == sth->m_owningStackFrame) + { break; + } stack->Pop(); } @@ -76,7 +84,7 @@ void CLR_RT_SubThread::DestroyInstance(CLR_RT_Thread *th, CLR_RT_SubThread *sthB // // Release all the lock requests. // - g_CLR_RT_ExecutionEngine.DeleteLockRequests(NULL, sth); + g_CLR_RT_ExecutionEngine.DeleteLockRequests(nullptr, sth); if (sth == sthBase && (flags & CLR_RT_SubThread::MODE_IncludeSelf) == 0) break; @@ -149,7 +157,7 @@ HRESULT CLR_RT_Thread::PushThreadProcDelegate(CLR_RT_HeapBlock_Delegate *pDelega CLR_RT_AppDomain *appDomainSav = g_CLR_RT_ExecutionEngine.SetCurrentAppDomain(pDelegate->m_appDomain); #endif - if (pDelegate == NULL || pDelegate->DataType() != DATATYPE_DELEGATE_HEAD || + if (pDelegate == nullptr || pDelegate->DataType() != DATATYPE_DELEGATE_HEAD || inst.InitializeFromIndex(pDelegate->DelegateFtn()) == false) { NANOCLR_SET_AND_LEAVE(CLR_E_WRONG_TYPE); @@ -171,9 +179,9 @@ HRESULT CLR_RT_Thread::PushThreadProcDelegate(CLR_RT_HeapBlock_Delegate *pDelega this->m_dlg = pDelegate; this->m_status = TH_S_Ready; - NANOCLR_CHECK_HRESULT(CLR_RT_StackFrame::Push(this, inst, inst.m_target->numArgs)); + NANOCLR_CHECK_HRESULT(CLR_RT_StackFrame::Push(this, inst, inst.target->argumentsCount)); - if ((inst.m_target->flags & CLR_RECORD_METHODDEF::MD_Static) == 0) + if ((inst.target->flags & CLR_RECORD_METHODDEF::MD_Static) == 0) { CLR_RT_StackFrame *stackTop = this->CurrentFrame(); @@ -208,22 +216,22 @@ HRESULT CLR_RT_Thread::CreateInstance(int pid, int priority, CLR_RT_Thread *&th, th->Initialize(); - th->m_pid = pid; // int m_pid; - th->m_status = TH_S_Unstarted; // CLR_UINT32 m_status; - th->m_flags = flags; // CLR_UINT32 m_flags; - th->m_executionCounter = 0; // int m_executionCounter; - th->m_timeQuantumExpired = false; // bool m_timeQuantumExpired; - // - th->m_dlg = NULL; // CLR_RT_HeapBlock_Delegate* m_dlg; - th->m_currentException.SetObjectReference(NULL); // CLR_RT_HeapBlock m_currentException; - // UnwindStack m_nestedExceptions[c_MaxStackUnwindDepth]; - th->m_nestedExceptionsPos = 0; // int m_nestedExceptionsPos; + th->m_pid = pid; // int m_pid; + th->m_status = TH_S_Unstarted; // CLR_UINT32 m_status; + th->m_flags = flags; // CLR_UINT32 m_flags; + th->m_executionCounter = 0; // int m_executionCounter; + th->m_timeQuantumExpired = false; // bool m_timeQuantumExpired; + // + th->m_dlg = nullptr; // CLR_RT_HeapBlock_Delegate* m_dlg; + th->m_currentException.SetObjectReference(nullptr); // CLR_RT_HeapBlock m_currentException; + // UnwindStack m_nestedExceptions[c_MaxStackUnwindDepth]; + th->m_nestedExceptionsPos = 0; // int m_nestedExceptionsPos; // // //--// // - th->m_terminationCallback = NULL; // ThreadTerminationCallback m_terminationCallback; - th->m_terminationParameter = NULL; // void* m_terminationParameter; + th->m_terminationCallback = nullptr; // ThreadTerminationCallback m_terminationCallback; + th->m_terminationParameter = nullptr; // void* m_terminationParameter; // th->m_waitForEvents = 0; // CLR_UINT32 m_waitForEvents; th->m_waitForEvents_Timeout = TIMEOUT_INFINITE; // CLR_INT64 m_waitForEvents_Timeout; @@ -231,7 +239,7 @@ HRESULT CLR_RT_Thread::CreateInstance(int pid, int priority, CLR_RT_Thread *&th, // th->m_locks.DblLinkedList_Initialize(); // CLR_RT_DblLinkedList m_locks; th->m_lockRequestsCount = 0; // CLR_UINT32 m_lockRequestsCount; - th->m_waitForObject = NULL; + th->m_waitForObject = nullptr; // th->m_stackFrames.DblLinkedList_Initialize(); // CLR_RT_DblLinkedList m_stackFrames; // @@ -249,11 +257,11 @@ HRESULT CLR_RT_Thread::CreateInstance(int pid, int priority, CLR_RT_Thread *&th, // If debugger creates managed thread for function evaluation, then m_realThread points to the thread that has // focus in debugger th->m_realThread = th; // CLR_RT_Thread* m_realThread -#endif // #if defined(NANOCLR_ENABLE_SOURCELEVELDEBUGGING) +#endif // NANOCLR_ENABLE_SOURCELEVELDEBUGGING //--// - NANOCLR_CHECK_HRESULT(CLR_RT_SubThread::CreateInstance(th, NULL, priority, sth)); + NANOCLR_CHECK_HRESULT(CLR_RT_SubThread::CreateInstance(th, nullptr, priority, sth)); #if defined(NANOCLR_ENABLE_SOURCELEVELDEBUGGING) if (g_CLR_RT_ExecutionEngine.m_breakpointsNum) @@ -263,7 +271,7 @@ HRESULT CLR_RT_Thread::CreateInstance(int pid, int priority, CLR_RT_Thread *&th, // g_CLR_RT_ExecutionEngine.Breakpoint_Thread_Created(th); } -#endif // #if defined(NANOCLR_ENABLE_SOURCELEVELDEBUGGING) +#endif // NANOCLR_ENABLE_SOURCELEVELDEBUGGING } NANOCLR_NOCLEANUP(); @@ -318,13 +326,24 @@ bool CLR_RT_Thread::ReleaseWhenDeadEx() return false; if (this == g_CLR_RT_ExecutionEngine.m_finalizerThread) - g_CLR_RT_ExecutionEngine.m_finalizerThread = NULL; + { + g_CLR_RT_ExecutionEngine.m_finalizerThread = nullptr; + } + if (this == g_CLR_RT_ExecutionEngine.m_interruptThread) - g_CLR_RT_ExecutionEngine.m_interruptThread = NULL; + { + g_CLR_RT_ExecutionEngine.m_interruptThread = nullptr; + } + if (this == g_CLR_RT_ExecutionEngine.m_timerThread) - g_CLR_RT_ExecutionEngine.m_timerThread = NULL; + { + g_CLR_RT_ExecutionEngine.m_timerThread = nullptr; + } + if (this == g_CLR_RT_ExecutionEngine.m_cctorThread) - g_CLR_RT_ExecutionEngine.m_cctorThread = NULL; + { + g_CLR_RT_ExecutionEngine.m_cctorThread = nullptr; + } return ReleaseWhenDead(); } @@ -384,7 +403,7 @@ HRESULT CLR_RT_Thread::Terminate() // between the start and end of killing the thread, a GC gets run. (void)Library_corlib_native_System_Exception::CreateInstance( m_currentException, - g_CLR_RT_WellKnownTypes.m_ThreadAbortException, + g_CLR_RT_WellKnownTypes.ThreadAbortException, S_OK, CurrentFrame()); @@ -405,7 +424,7 @@ HRESULT CLR_RT_Thread::Abort() { (void)Library_corlib_native_System_Exception::CreateInstance( m_currentException, - g_CLR_RT_WellKnownTypes.m_ThreadAbortException, + g_CLR_RT_WellKnownTypes.ThreadAbortException, S_OK, CurrentFrame()); @@ -442,14 +461,14 @@ void CLR_RT_Thread::OnThreadTerminated() // // Release all the subthreads. // - CLR_RT_SubThread::DestroyInstance(this, NULL, 0); + CLR_RT_SubThread::DestroyInstance(this, nullptr, 0); #if defined(NANOCLR_ENABLE_SOURCELEVELDEBUGGING) if (g_CLR_RT_ExecutionEngine.m_breakpointsNum) { g_CLR_RT_ExecutionEngine.Breakpoint_Thread_Terminated(this); } -#endif // #if defined(NANOCLR_ENABLE_SOURCELEVELDEBUGGING) +#endif // NANOCLR_ENABLE_SOURCELEVELDEBUGGING } void CLR_RT_Thread::Passivate() @@ -465,10 +484,10 @@ void CLR_RT_Thread::Passivate() //--// - if (m_waitForObject != NULL) + if (m_waitForObject != nullptr) { g_CLR_RT_EventCache.Append_Node(m_waitForObject); - m_waitForObject = NULL; + m_waitForObject = nullptr; } //--// @@ -483,7 +502,7 @@ void CLR_RT_Thread::Passivate() m_status = CLR_RT_Thread::TH_S_Unstarted; } - m_currentException.SetObjectReference(NULL); // Reset exception flag. + m_currentException.SetObjectReference(nullptr); // Reset exception flag. // // If the thread is associated with a timer, advance the state of the timer. @@ -491,7 +510,7 @@ void CLR_RT_Thread::Passivate() if (m_terminationCallback) { ThreadTerminationCallback terminationCallback = m_terminationCallback; - m_terminationCallback = NULL; + m_terminationCallback = nullptr; terminationCallback(m_terminationParameter); } @@ -499,7 +518,7 @@ void CLR_RT_Thread::Passivate() if (m_status == CLR_RT_Thread::TH_S_Terminated || m_status == CLR_RT_Thread::TH_S_Unstarted) { // This is used by Static constructor thread. - m_dlg = NULL; + m_dlg = nullptr; } ReleaseWhenDeadEx(); @@ -592,16 +611,16 @@ void CLR_RT_Thread::DumpStack() void CLR_RT_Thread::ProcessException_FilterPseudoFrameCopyVars(CLR_RT_StackFrame *to, CLR_RT_StackFrame *from) { NATIVE_PROFILE_CLR_CORE(); - CLR_UINT8 numArgs = from->m_call.m_target->numArgs; + CLR_UINT8 ArgumentsCount = from->m_call.target->argumentsCount; - if (numArgs) + if (ArgumentsCount) { - memcpy(to->m_arguments, from->m_arguments, sizeof(struct CLR_RT_HeapBlock) * numArgs); + memcpy(to->m_arguments, from->m_arguments, sizeof(CLR_RT_HeapBlock) * ArgumentsCount); } - if (from->m_call.m_target->numLocals) + if (from->m_call.target->localsCount) { - memcpy(to->m_locals, from->m_locals, sizeof(struct CLR_RT_HeapBlock) * from->m_call.m_target->numLocals); + memcpy(to->m_locals, from->m_locals, sizeof(CLR_RT_HeapBlock) * from->m_call.target->localsCount); } } @@ -622,7 +641,7 @@ HRESULT CLR_RT_Thread::ProcessException_EndFilter() ProcessException_FilterPseudoFrameCopyVars(us.m_handlerStack, stack); // Clear the stack variable so Pop doesn't remove us from the UnwindStack. - us.m_stack = NULL; + us.m_stack = nullptr; #if defined(NANOCLR_ENABLE_SOURCELEVELDEBUGGING) if (CLR_EE_DBG_IS_NOT(NoStackTraceInExceptions)) @@ -680,7 +699,7 @@ HRESULT CLR_RT_Thread::ProcessException_EndFilter() // Swap results around. ProcessException must return a success code in Thread::Execute and set m_currentException to // continue processing. Execute_IL must get a FAILED hr in order to break outside of the execution loop. - if (m_currentException.Dereference() == NULL) + if (m_currentException.Dereference() == nullptr) { // Return S_OK because exception handling is complete or handling is in-flight and needs to execute IL to // continue. @@ -712,7 +731,7 @@ HRESULT CLR_RT_Thread::ProcessException_EndFinally() if (FindEhBlock(stack, stack->m_IP - 1, ipLeave, eh, true)) { us.m_stack = stack; - us.m_exception = NULL; + us.m_exception = nullptr; us.m_ip = ipLeave; us.m_currentBlockStart = eh.m_handlerStart; us.m_currentBlockEnd = eh.m_handlerEnd; @@ -747,7 +766,7 @@ HRESULT CLR_RT_Thread::ProcessException_EndFinally() // Similar to EndFilter, we need to swap the return codes around. Thread::Execute needs a success code or the // thread will be aborted. ExecuteIL needs a failure code or we'll continue to execute IL when we possibly // shouldn't. - if (m_currentException.Dereference() == NULL) + if (m_currentException.Dereference() == nullptr) { // Return S_OK because exception handling is complete or handling is in-flight and needs to execute IL to // continue. @@ -794,7 +813,7 @@ HRESULT CLR_RT_Thread::ProcessException_Phase1() } // Search for a willing catch handler. - while (stack->Caller() != NULL) + while (stack->Caller() != nullptr) { #if defined(NANOCLR_ENABLE_SOURCELEVELDEBUGGING) @@ -802,8 +821,8 @@ HRESULT CLR_RT_Thread::ProcessException_Phase1() us.GetPhase() < UnwindStack::p_1_SearchingForHandler_2_SentUsersChance && stack->m_IP) { // We have a debugger attached and we need to send some messages before we start searching. - // These messages should only get sent when the search reaches managed code. Stack::Push sets m_IP to NULL - // for native code, so therefore we need IP to be non-NULL + // These messages should only get sent when the search reaches managed code. Stack::Push sets m_IP to nullptr + // for native code, so therefore we need IP to be non-nullptr us.m_handlerStack = stack; @@ -812,7 +831,7 @@ HRESULT CLR_RT_Thread::ProcessException_Phase1() g_CLR_RT_ExecutionEngine.Breakpoint_Exception( stack, CLR_DBG_Commands::Debugging_Execution_BreakpointDef::c_DEPTH_EXCEPTION_FIRST_CHANCE, - NULL); + nullptr); us.SetPhase(UnwindStack::p_1_SearchingForHandler_1_SentFirstChance); // Break out here, because of synchronization issues (false positives) with JMC checking. @@ -830,7 +849,7 @@ HRESULT CLR_RT_Thread::ProcessException_Phase1() g_CLR_RT_ExecutionEngine.Breakpoint_Exception( stack, CLR_DBG_Commands::Debugging_Execution_BreakpointDef::c_DEPTH_EXCEPTION_USERS_CHANCE, - NULL); + nullptr); us.SetPhase(UnwindStack::p_1_SearchingForHandler_2_SentUsersChance); if (CLR_EE_DBG_IS(Stopped)) { @@ -838,15 +857,15 @@ HRESULT CLR_RT_Thread::ProcessException_Phase1() } } } -#endif // #if defined(NANOCLR_ENABLE_SOURCELEVELDEBUGGING) +#endif // NANOCLR_ENABLE_SOURCELEVELDEBUGGING - if (stack->m_call.m_target->flags & CLR_RECORD_METHODDEF::MD_HasExceptionHandlers) + if (stack->m_call.target->flags & CLR_RECORD_METHODDEF::MD_HasExceptionHandlers) { CLR_PMETADATA ip; if (us.m_ip) { - ip = us.m_ip; // Use the IP set by endfilter - us.m_ip = NULL; // Reset to prevent catch block & PopEH issues via 'leave' or 'endfinally' + ip = us.m_ip; // Use the IP set by endfilter + us.m_ip = nullptr; // Reset to prevent catch block & PopEH issues via 'leave' or 'endfinally' } else { @@ -855,7 +874,7 @@ HRESULT CLR_RT_Thread::ProcessException_Phase1() if (ip) // No IP? Either out of memory during allocation of stack frame or native method. { - if (FindEhBlock(stack, ip, NULL, eh, false)) + if (FindEhBlock(stack, ip, nullptr, eh, false)) { // There are two cases here: // 1. We found a catch block... in this case, we want to break out and go to phase 2. // 2. We found a filter... in this case, we want to duplicate the stack and execute the filter. @@ -875,7 +894,7 @@ HRESULT CLR_RT_Thread::ProcessException_Phase1() if (eh.IsFilter()) { - CLR_RT_StackFrame *newStack = NULL; + CLR_RT_StackFrame *newStack = nullptr; // Store the IP range that we're currently executing so leave/PopEH doesn't accidentally pop the // filter off. @@ -883,7 +902,7 @@ HRESULT CLR_RT_Thread::ProcessException_Phase1() us.m_currentBlockEnd = eh.m_handlerStart; // Create a pseudo-frame at the top of the stack so the filter can call other functions. - CLR_UINT8 numArgs = stack->m_call.m_target->numArgs; + CLR_UINT8 ArgumentsCount = stack->m_call.target->argumentsCount; #if defined(NANOCLR_ENABLE_SOURCELEVELDEBUGGING) if (CLR_EE_DBG_IS_NOT(NoStackTraceInExceptions)) @@ -894,7 +913,7 @@ HRESULT CLR_RT_Thread::ProcessException_Phase1() } #endif - hr = CLR_RT_StackFrame::Push(stack->m_owningThread, stack->m_call, numArgs); + hr = CLR_RT_StackFrame::Push(stack->m_owningThread, stack->m_call, ArgumentsCount); #if defined(NANOCLR_ENABLE_SOURCELEVELDEBUGGING) if (CLR_EE_DBG_IS_NOT(NoStackTraceInExceptions) && !fBreakpointsDisabledSav) @@ -916,20 +935,20 @@ HRESULT CLR_RT_Thread::ProcessException_Phase1() us.m_stack = newStack; // Copy local variables and arguments so the filter has access to them. - if (numArgs) + if (ArgumentsCount) { memcpy( newStack->m_arguments, stack->m_arguments, - sizeof(struct CLR_RT_HeapBlock) * numArgs); + sizeof(CLR_RT_HeapBlock) * ArgumentsCount); } - if (stack->m_call.m_target->numLocals) + if (stack->m_call.target->localsCount) { memcpy( newStack->m_locals, stack->m_locals, - sizeof(struct CLR_RT_HeapBlock) * stack->m_call.m_target->numLocals); + sizeof(CLR_RT_HeapBlock) * stack->m_call.target->localsCount); } newStack->PushValueAndAssign(m_currentException); @@ -938,7 +957,7 @@ HRESULT CLR_RT_Thread::ProcessException_Phase1() newStack->m_IP = eh.m_userFilterStart; // We are willing to execute IL again so clear the m_currentException flag. - m_currentException.SetObjectReference(NULL); + m_currentException.SetObjectReference(nullptr); #if defined(NANOCLR_ENABLE_SOURCELEVELDEBUGGING) if (CLR_EE_DBG_IS_NOT(NoStackTraceInExceptions)) @@ -984,7 +1003,7 @@ HRESULT CLR_RT_Thread::ProcessException_Phase1() // Both of these shouldn't be set at once because of the two-pass handling mechanism. if (stack->m_flags & CLR_RT_StackFrame::c_AppDomainTransition) { - us.m_handlerStack = NULL; + us.m_handlerStack = nullptr; us.SetPhase(UnwindStack::p_2_RunningFinallys_0); #if defined(NANOCLR_ENABLE_SOURCELEVELDEBUGGING) @@ -1007,13 +1026,13 @@ HRESULT CLR_RT_Thread::ProcessException_Phase1() } if (stack->m_flags & CLR_RT_StackFrame::c_PseudoStackFrameForFilter) { - us.m_handlerStack = NULL; + us.m_handlerStack = nullptr; us.SetPhase(UnwindStack::p_2_RunningFinallys_0); NANOCLR_SET_AND_LEAVE(CLR_E_PROCESS_EXCEPTION); } #ifndef NANOCLR_NO_IL_INLINE - if (stack->m_inlineFrame != NULL && tmpInline.m_IP == NULL) + if (stack->m_inlineFrame != nullptr && tmpInline.m_IP == nullptr) { stack->SaveStack(tmpInline); stack->RestoreFromInlineStack(); @@ -1023,7 +1042,7 @@ HRESULT CLR_RT_Thread::ProcessException_Phase1() if (tmpInline.m_IP) { stack->RestoreStack(tmpInline); - tmpInline.m_IP = NULL; + tmpInline.m_IP = nullptr; } #else { @@ -1033,7 +1052,7 @@ HRESULT CLR_RT_Thread::ProcessException_Phase1() } } - us.m_handlerStack = NULL; + us.m_handlerStack = nullptr; us.SetPhase(UnwindStack::p_2_RunningFinallys_0); #if defined(NANOCLR_ENABLE_SOURCELEVELDEBUGGING) @@ -1092,7 +1111,7 @@ HRESULT CLR_RT_Thread::ProcessException_Phase2() CLR_RT_ExceptionHandler eh; // Unwind the stack, running finally's as we go - while (iterStack->Caller() != NULL) + while (iterStack->Caller() != nullptr) { #if defined(NANOCLR_ENABLE_SOURCELEVELDEBUGGING) @@ -1105,7 +1124,7 @@ HRESULT CLR_RT_Thread::ProcessException_Phase2() iterStack->ResetStack(); // We are willing to execute IL again so clear the m_currentException flag. - m_currentException.SetObjectReference(NULL); + m_currentException.SetObjectReference(nullptr); // CPDE better reset the IP, or there are going to be issues. iterStack->m_flags |= CLR_RT_StackFrame::c_InvalidIP; @@ -1119,30 +1138,30 @@ HRESULT CLR_RT_Thread::ProcessException_Phase2() else #endif { - if (iterStack->m_call.m_target->flags & CLR_RECORD_METHODDEF::MD_HasExceptionHandlers) + if (iterStack->m_call.target->flags & CLR_RECORD_METHODDEF::MD_HasExceptionHandlers) { // No IP? Either out of memory during allocation of iterStack frame or native method. if (iterStack->m_IP) { // handlerBlockStart is used to not execute finally's who's protected blocks contain the handler - // itself. NULL is used when we're not in the handler stack frame to make it work in the case of + // itself. nullptr is used when we're not in the handler stack frame to make it work in the case of // recursive functions with filtered handlers. if (FindEhBlock( iterStack, iterStack->m_IP, - (us.m_handlerStack == iterStack) ? us.m_handlerBlockStart : NULL, + (us.m_handlerStack == iterStack) ? us.m_handlerBlockStart : nullptr, eh, true)) { // We have a finally block to process us.m_stack = iterStack; - us.m_ip = NULL; + us.m_ip = nullptr; us.m_currentBlockStart = eh.m_handlerStart; us.m_currentBlockEnd = eh.m_handlerEnd; us.SetPhase(UnwindStack::p_2_RunningFinallys_0); - m_currentException.SetObjectReference(NULL); // Reset exception flag. + m_currentException.SetObjectReference(nullptr); // Reset exception flag. iterStack->ResetStack(); iterStack->m_IP = eh.m_handlerStart; @@ -1152,7 +1171,7 @@ HRESULT CLR_RT_Thread::ProcessException_Phase2() if (CLR_EE_DBG_IS_NOT(NoStackTraceInExceptions)) { #ifndef NANOCLR_NO_IL_INLINE - if (iterStack->m_inlineFrame == NULL) + if (iterStack->m_inlineFrame == nullptr) #endif { g_CLR_RT_ExecutionEngine.Breakpoint_StackFrame_Pop(iterStack, true); @@ -1166,7 +1185,8 @@ HRESULT CLR_RT_Thread::ProcessException_Phase2() if (iterStack == us.m_handlerStack) { #ifndef NANOCLR_NO_IL_INLINE - if (iterStack->m_inlineFrame == NULL || 0 == (us.m_flags & UnwindStack::c_MagicCatchForInline)) + if (iterStack->m_inlineFrame == nullptr || + 0 == (us.m_flags & UnwindStack::c_MagicCatchForInline)) #endif { // We've popped off all stack frames above the target. @@ -1186,13 +1206,13 @@ HRESULT CLR_RT_Thread::ProcessException_Phase2() iterStack->PushValue().SetObjectReference(us.m_exception); // We are willing to execute IL again so clear the m_currentException flag. - m_currentException.SetObjectReference(NULL); + m_currentException.SetObjectReference(nullptr); #if defined(NANOCLR_ENABLE_SOURCELEVELDEBUGGING) if (CLR_EE_DBG_IS_NOT(NoStackTraceInExceptions)) { #ifndef NANOCLR_NO_IL_INLINE - if (iterStack->m_inlineFrame == NULL) + if (iterStack->m_inlineFrame == nullptr) #endif { g_CLR_RT_ExecutionEngine.Breakpoint_StackFrame_Pop(iterStack, true); @@ -1229,7 +1249,7 @@ HRESULT CLR_RT_Thread::ProcessException_Phase2() // Set IP so we can resume looking for the next filter. otherUnwindStack.m_ip = otherUnwindStack.m_currentBlockStart; - otherUnwindStack.m_stack = NULL; // Prevent Pop from taking this handler off the stack. + otherUnwindStack.m_stack = nullptr; // Prevent Pop from taking this handler off the stack. #if defined(NANOCLR_ENABLE_SOURCELEVELDEBUGGING) if (CLR_EE_DBG_IS_NOT(NoStackTraceInExceptions)) @@ -1303,7 +1323,7 @@ HRESULT CLR_RT_Thread::ProcessException_Phase2() } #endif - us.m_stack = NULL; // Don't pop off the handler when we pop this stack frame + us.m_stack = nullptr; // Don't pop off the handler when we pop this stack frame #if defined(NANOCLR_ENABLE_SOURCELEVELDEBUGGING) if (CLR_EE_DBG_IS_NOT(NoStackTraceInExceptions)) @@ -1368,7 +1388,7 @@ HRESULT CLR_RT_Thread::ProcessException() NATIVE_PROFILE_CLR_CORE(); NANOCLR_HEADER(); CLR_RT_StackFrame *stack = CurrentFrame(); - UnwindStack *us = NULL; + UnwindStack *us = nullptr; // If the exception was thrown in the middle of an IL instruction, // back up the pointer to point to the executing instruction, not the next one. @@ -1394,11 +1414,11 @@ HRESULT CLR_RT_Thread::ProcessException() else { // Signal that we need a new handler pushed on the stack. - us = NULL; + us = nullptr; } } - if (us == NULL) + if (us == nullptr) { // Push a new handler on the unwind stack that will last until its handler gets executed or // something out-of-band forces the stack frame to get popped. diff --git a/src/CLR/Core/TypeSystem.cpp b/src/CLR/Core/TypeSystem.cpp index 6f686278e1..1f9dc82ee2 100644 --- a/src/CLR/Core/TypeSystem.cpp +++ b/src/CLR/Core/TypeSystem.cpp @@ -4,6 +4,7 @@ // See LICENSE file in the project root for full license information. // #include "stdafx.h" +#include #include "Core.h" #include "corhdr_private.h" @@ -12,8 +13,8 @@ #define ITERATE_THROUGH_RECORDS(assm, i, tblName, tblNameUC) \ const CLR_RECORD_##tblNameUC *src = (const CLR_RECORD_##tblNameUC *)assm->GetTable(TBL_##tblName); \ - CLR_RT_##tblName##_CrossReference *dst = assm->m_pCrossReference_##tblName; \ - for (i = 0; i < assm->m_pTablesSize[TBL_##tblName]; i++, src++, dst++) + CLR_RT_##tblName##_CrossReference *dst = assm->crossReference##tblName; \ + for (i = 0; i < assm->tablesSize[TBL_##tblName]; i++, src++, dst++) //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -77,31 +78,31 @@ bool s_CLR_RT_fTimeWarp = false; void CLR_RT_ReflectionDef_Index::Clear() { NATIVE_PROFILE_CLR_CORE(); - m_kind = REFLECTION_INVALID; - m_levels = 0; - m_data.m_raw = 0; + kind = REFLECTION_INVALID; + levels = 0; + data.raw = 0; } CLR_UINT32 CLR_RT_ReflectionDef_Index::GetTypeHash() const { NATIVE_PROFILE_CLR_CORE(); - switch (m_kind) + switch (kind) { case REFLECTION_TYPE: { CLR_RT_TypeDef_Instance inst{}; - if (m_levels != 0) + if (levels != 0) return 0; - if (!inst.InitializeFromIndex(m_data.m_type)) + if (!inst.InitializeFromIndex(data.type)) return 0; - return inst.CrossReference().m_hash; + return inst.CrossReference().hash; } case REFLECTION_TYPE_DELAYED: - return m_data.m_raw; + return data.raw; } return 0; @@ -110,28 +111,28 @@ CLR_UINT32 CLR_RT_ReflectionDef_Index::GetTypeHash() const void CLR_RT_ReflectionDef_Index::InitializeFromHash(CLR_UINT32 hash) { NATIVE_PROFILE_CLR_CORE(); - m_kind = REFLECTION_TYPE_DELAYED; - m_levels = 0; - m_data.m_raw = hash; + kind = REFLECTION_TYPE_DELAYED; + levels = 0; + data.raw = hash; } CLR_UINT64 CLR_RT_ReflectionDef_Index::GetRawData() const { NATIVE_PROFILE_CLR_CORE(); - CLR_UINT64 data; - _ASSERTE(sizeof(data) == sizeof(*this)); + CLR_UINT64 dataRaw; + _ASSERTE(sizeof(dataRaw) == sizeof(*this)); - memcpy(&data, this, sizeof(data)); + memcpy(&dataRaw, this, sizeof(dataRaw)); - return data; + return dataRaw; } -void CLR_RT_ReflectionDef_Index::SetRawData(CLR_UINT64 data) +void CLR_RT_ReflectionDef_Index::SetRawData(CLR_UINT64 dataRaw) { NATIVE_PROFILE_CLR_CORE(); - _ASSERTE(sizeof(data) == sizeof(*this)); + _ASSERTE(sizeof(dataRaw) == sizeof(*this)); - memcpy(this, &data, sizeof(data)); + memcpy(this, &dataRaw, sizeof(dataRaw)); } bool CLR_RT_ReflectionDef_Index::Convert(CLR_RT_HeapBlock &ref, CLR_RT_Assembly_Instance &inst) @@ -139,7 +140,7 @@ bool CLR_RT_ReflectionDef_Index::Convert(CLR_RT_HeapBlock &ref, CLR_RT_Assembly_ NATIVE_PROFILE_CLR_CORE(); if (ref.DataType() == DATATYPE_REFLECTION) { - return inst.InitializeFromIndex(ref.ReflectionDataConst().m_data.m_assm); + return inst.InitializeFromIndex(ref.ReflectionDataConst().data.assembly); } return false; @@ -161,11 +162,11 @@ bool CLR_RT_ReflectionDef_Index::Convert(CLR_RT_HeapBlock &ref, CLR_RT_MethodDef NATIVE_PROFILE_CLR_CORE(); if (ref.DataType() == DATATYPE_REFLECTION) { - switch (ref.ReflectionData().m_kind) + switch (ref.ReflectionData().kind) { case REFLECTION_CONSTRUCTOR: case REFLECTION_METHOD: - return inst.InitializeFromIndex(ref.ReflectionDataConst().m_data.m_method); + return inst.InitializeFromIndex(ref.ReflectionDataConst().data.method); } } @@ -175,9 +176,9 @@ bool CLR_RT_ReflectionDef_Index::Convert(CLR_RT_HeapBlock &ref, CLR_RT_MethodDef bool CLR_RT_ReflectionDef_Index::Convert(CLR_RT_HeapBlock &ref, CLR_RT_FieldDef_Instance &inst) { NATIVE_PROFILE_CLR_CORE(); - if (ref.DataType() == DATATYPE_REFLECTION && ref.ReflectionData().m_kind == REFLECTION_FIELD) + if (ref.DataType() == DATATYPE_REFLECTION && ref.ReflectionData().kind == REFLECTION_FIELD) { - return inst.InitializeFromIndex(ref.ReflectionDataConst().m_data.m_field); + return inst.InitializeFromIndex(ref.ReflectionDataConst().data.field); } return false; @@ -199,18 +200,20 @@ bool CLR_RT_ReflectionDef_Index::Convert(CLR_RT_HeapBlock &ref, CLR_UINT32 &hash void CLR_RT_SignatureParser::Initialize_TypeSpec(CLR_RT_Assembly *assm, const CLR_RECORD_TYPESPEC *ts) { NATIVE_PROFILE_CLR_CORE(); - Initialize_TypeSpec(assm, assm->GetSignature(ts->sig)); + Initialize_TypeSpec(assm, assm->GetSignature(ts->signature)); } void CLR_RT_SignatureParser::Initialize_TypeSpec(CLR_RT_Assembly *assm, CLR_PMETADATA ts) { NATIVE_PROFILE_CLR_CORE(); - m_assm = assm; - m_sig = ts; + Assembly = assm; + Signature = ts; - m_type = CLR_RT_SignatureParser::c_TypeSpec; - m_flags = 0; - m_count = 1; + Type = CLR_RT_SignatureParser::c_TypeSpec; + Flags = 0; + ParamCount = 1; + GenParamCount = 0; + IsGenericInst = false; } //--// @@ -222,57 +225,169 @@ void CLR_RT_SignatureParser::Initialize_Interfaces(CLR_RT_Assembly *assm, const { CLR_PMETADATA sig = assm->GetSignature(td->interfaces); - m_count = (*sig++); - m_sig = sig; + ParamCount = (*sig++); + Signature = sig; } else { - m_count = 0; - m_sig = NULL; + ParamCount = 0; + Signature = nullptr; } - m_type = CLR_RT_SignatureParser::c_Interfaces; - m_flags = 0; + Type = CLR_RT_SignatureParser::c_Interfaces; + Flags = 0; + + Assembly = assm; - m_assm = assm; + GenParamCount = 0; + IsGenericInst = false; } //--// +void CLR_RT_SignatureParser::Initialize_FieldSignature(CLR_RT_Assembly *assm, CLR_PMETADATA fd) +{ + NATIVE_PROFILE_CLR_CORE(); + + Type = CLR_RT_SignatureParser::c_Field; + + Method = 0xFFFF; + + Flags = (*fd++); + + ParamCount = 1; + + Assembly = assm; + Signature = fd; + + GenParamCount = 0; + IsGenericInst = false; +} + void CLR_RT_SignatureParser::Initialize_FieldDef(CLR_RT_Assembly *assm, const CLR_RECORD_FIELDDEF *fd) { NATIVE_PROFILE_CLR_CORE(); - Initialize_FieldDef(assm, assm->GetSignature(fd->sig)); + + Initialize_FieldDef(assm, assm->GetSignature(fd->signature)); } void CLR_RT_SignatureParser::Initialize_FieldDef(CLR_RT_Assembly *assm, CLR_PMETADATA fd) { NATIVE_PROFILE_CLR_CORE(); - m_type = CLR_RT_SignatureParser::c_Field; - m_flags = (*fd++); - m_count = 1; + Type = CLR_RT_SignatureParser::c_Field; + Flags = (*fd++); + ParamCount = 1; - m_assm = assm; - m_sig = fd; + Assembly = assm; + Signature = fd; + + GenParamCount = 0; + IsGenericInst = false; } //--// +void CLR_RT_SignatureParser::Initialize_MethodSignature(CLR_RT_MethodDef_Instance *md) +{ + NATIVE_PROFILE_CLR_CORE(); + + Method = md->Method(); + + Initialize_MethodSignature(md->assembly, md->assembly->GetSignature(md->target->signature)); +} void CLR_RT_SignatureParser::Initialize_MethodSignature(CLR_RT_Assembly *assm, const CLR_RECORD_METHODDEF *md) { NATIVE_PROFILE_CLR_CORE(); - Initialize_MethodSignature(assm, assm->GetSignature(md->sig)); + + Method = 0xFFFF; + + Initialize_MethodSignature(assm, assm->GetSignature(md->signature)); } void CLR_RT_SignatureParser::Initialize_MethodSignature(CLR_RT_Assembly *assm, CLR_PMETADATA md) { NATIVE_PROFILE_CLR_CORE(); - m_type = CLR_RT_SignatureParser::c_Method; - m_flags = (*md++); - m_count = (*md++) + 1; - m_assm = assm; - m_sig = md; + Type = CLR_RT_SignatureParser::c_Method; + + Flags = (*md++); + + if ((Flags & PIMAGE_CEE_CS_CALLCONV_GENERIC) == PIMAGE_CEE_CS_CALLCONV_GENERIC) + { + // is generic instance, has generic parameters count + GenParamCount = (*md++); + } + else + { + GenParamCount = 0; + } + + ParamCount = (*md++) + 1; + + Assembly = assm; + Signature = md; + + IsGenericInst = false; +} + +void CLR_RT_SignatureParser::Initialize_MethodSignature(CLR_RT_MethodSpec_Instance *ms) +{ + NATIVE_PROFILE_CLR_CORE(); + + Method = ms->Method(); + + Signature = ms->assembly->GetSignature(ms->target->instantiation); + + Type = CLR_RT_SignatureParser::c_MethodSpec; + + Flags = (*Signature++); + + if (Flags != PIMAGE_CEE_CS_CALLCONV_GENERICINST) + { + // call is wrong + return; + } + + ParamCount = (*Signature++); + + Assembly = ms->assembly; + + GenParamCount = ParamCount; + + IsGenericInst = false; +} + +//--// + +bool CLR_RT_SignatureParser::Initialize_GenericParamTypeSignature( + CLR_RT_Assembly *assm, + const CLR_RECORD_GENERICPARAM *gp) +{ + NATIVE_PROFILE_CLR_CORE(); + + Type = CLR_RT_SignatureParser::c_GenericParamType; + + Assembly = assm; + + // need to check for valid signature + if (gp->signature != 0xFFFF) + { + Signature = assm->GetSignature(gp->signature); + ParamCount = 1; + } + else + { + // can't process... + return false; + } + + Flags = 0; + + GenParamCount = 0; + IsGenericInst = false; + + // done here + return true; } //--// @@ -286,12 +401,15 @@ void CLR_RT_SignatureParser::Initialize_MethodLocals(CLR_RT_Assembly *assm, cons // If you change this method, change "CLR_RT_ExecutionEngine::InitializeLocals" too. // - m_assm = assm; - m_sig = assm->GetSignature(md->locals); + Assembly = assm; + Signature = assm->GetSignature(md->locals); - m_type = CLR_RT_SignatureParser::c_Locals; - m_flags = 0; - m_count = md->numLocals; + Type = CLR_RT_SignatureParser::c_Locals; + Flags = 0; + ParamCount = md->localsCount; + + GenParamCount = 0; + IsGenericInst = false; } //--// @@ -299,11 +417,14 @@ void CLR_RT_SignatureParser::Initialize_MethodLocals(CLR_RT_Assembly *assm, cons void CLR_RT_SignatureParser::Initialize_Objects(CLR_RT_HeapBlock *lst, int count, bool fTypes) { NATIVE_PROFILE_CLR_CORE(); - m_lst = lst; + ObjectList = lst; + + Type = CLR_RT_SignatureParser::c_Object; + Flags = fTypes ? 1 : 0; + ParamCount = count; - m_type = CLR_RT_SignatureParser::c_Object; - m_flags = fTypes ? 1 : 0; - m_count = count; + GenParamCount = 0; + IsGenericInst = false; } //--// @@ -319,36 +440,38 @@ HRESULT CLR_RT_SignatureParser::Advance(Element &res) NANOCLR_HEADER(); - _ASSERTE(m_count > 0); + _ASSERTE(ParamCount > 0); - m_count--; + ParamCount--; - res.m_fByRef = false; - res.m_levels = 0; + res.IsByRef = false; + res.Levels = 0; + res.GenericParamPosition = 0xFFFF; + res.Class.Clear(); - switch (m_type) + switch (Type) { case c_Interfaces: { CLR_RT_TypeDef_Instance cls{}; - res.m_dt = DATATYPE_CLASS; + res.DataType = DATATYPE_CLASS; - if (cls.ResolveToken(CLR_TkFromStream(m_sig), m_assm) == false) + if (cls.ResolveToken(CLR_TkFromStream(Signature), Assembly) == false) { NANOCLR_SET_AND_LEAVE(CLR_E_WRONG_TYPE); } - res.m_cls = cls; + res.Class = cls; } break; case c_Object: { CLR_RT_TypeDescriptor desc{}; - CLR_RT_HeapBlock *ptr = m_lst++; + CLR_RT_HeapBlock *ptr = ObjectList++; - if (m_flags) + if (Flags) { // Reflection types are now boxed, so unbox first if (ptr->DataType() == DATATYPE_OBJECT) @@ -368,7 +491,7 @@ HRESULT CLR_RT_SignatureParser::Advance(Element &res) { case DATATYPE_BYREF: case DATATYPE_ARRAY_BYREF: - res.m_fByRef = true; + res.IsByRef = true; break; default: @@ -379,18 +502,18 @@ HRESULT CLR_RT_SignatureParser::Advance(Element &res) NANOCLR_CHECK_HRESULT(desc.InitializeFromObject(*ptr)); } - desc.m_handlerCls.InitializeFromIndex(desc.m_reflex.m_data.m_type); + desc.m_handlerCls.InitializeFromIndex(desc.m_reflex.data.type); - res.m_levels = desc.m_reflex.m_levels; - res.m_dt = (CLR_DataType)desc.m_handlerCls.m_target->dataType; - res.m_cls = desc.m_reflex.m_data.m_type; + res.Levels = desc.m_reflex.levels; + res.DataType = (NanoCLRDataType)desc.m_handlerCls.target->dataType; + res.Class = desc.m_reflex.data.type; // // Special case for Object types. // - if (res.m_cls.m_data == g_CLR_RT_WellKnownTypes.m_Object.m_data) + if (res.Class.data == g_CLR_RT_WellKnownTypes.Object.data) { - res.m_dt = DATATYPE_OBJECT; + res.DataType = DATATYPE_OBJECT; } } break; @@ -398,70 +521,123 @@ HRESULT CLR_RT_SignatureParser::Advance(Element &res) default: while (true) { - res.m_dt = CLR_UncompressElementType(m_sig); + res.DataType = CLR_UncompressElementType(Signature); - switch (res.m_dt) + switch (res.DataType) { case DATATYPE_BYREF: - if (res.m_fByRef) + if (res.IsByRef) { NANOCLR_SET_AND_LEAVE(CLR_E_WRONG_TYPE); } - res.m_fByRef = true; + res.IsByRef = true; break; case DATATYPE_SZARRAY: - res.m_levels++; + res.Levels++; break; case DATATYPE_CLASS: case DATATYPE_VALUETYPE: { - CLR_UINT32 tk = CLR_TkFromStream(m_sig); + parse_type: + CLR_UINT32 tk = CLR_TkFromStream(Signature); + CLR_UINT32 index = CLR_DataFromTk(tk); - if (CLR_TypeFromTk(tk) == TBL_TypeSpec) + switch (CLR_TypeFromTk(tk)) { - CLR_RT_SignatureParser sub{}; - sub.Initialize_TypeSpec(m_assm, m_assm->GetTypeSpec(CLR_DataFromTk(tk))); - int extraLevels = res.m_levels; + case TBL_TypeSpec: + { + CLR_RT_SignatureParser sub{}; + sub.Initialize_TypeSpec(Assembly, Assembly->GetTypeSpec(index)); + CLR_RT_SignatureParser::Element dummyElement; + int extraLevels = res.Levels; - NANOCLR_CHECK_HRESULT(sub.Advance(res)); + NANOCLR_CHECK_HRESULT(sub.Advance(dummyElement)); - res.m_levels += extraLevels; - } - else - { - CLR_RT_TypeDef_Instance cls{}; + res.Levels += extraLevels; + } + break; + + case TBL_TypeRef: + res.Class = Assembly->crossReferenceTypeRef[index].target; + break; - if (cls.ResolveToken(tk, m_assm) == false) + case TBL_TypeDef: { - NANOCLR_SET_AND_LEAVE(CLR_E_WRONG_TYPE); + CLR_RT_TypeDef_Instance cls; + + if (cls.ResolveToken(tk, Assembly) == false) + { + NANOCLR_SET_AND_LEAVE(CLR_E_WRONG_TYPE); + } + + res.Class = cls; + break; } - res.m_cls = cls; + default: + NANOCLR_SET_AND_LEAVE(CLR_E_WRONG_TYPE); + } + + if (IsGenericInst) + { + // get generic arguments count + GenParamCount = (int)*Signature++; + + // need to update the parser counter too + ParamCount = GenParamCount; } NANOCLR_SET_AND_LEAVE(S_OK); } case DATATYPE_OBJECT: - res.m_cls = g_CLR_RT_WellKnownTypes.m_Object; - + res.Class = g_CLR_RT_WellKnownTypes.Object; NANOCLR_SET_AND_LEAVE(S_OK); case DATATYPE_VOID: - res.m_cls = g_CLR_RT_WellKnownTypes.m_Void; + res.Class = g_CLR_RT_WellKnownTypes.n_Void; + NANOCLR_SET_AND_LEAVE(S_OK); + case DATATYPE_GENERICINST: + { + // set flag for GENERICINST + IsGenericInst = true; + + // get data type + auto dt = (NanoCLRDataType)*Signature++; + + // sanity check + if (dt == DATATYPE_CLASS || dt == DATATYPE_VALUETYPE) + { + // parse type + goto parse_type; + } + else + { + NANOCLR_SET_AND_LEAVE(CLR_E_WRONG_TYPE); + } + + break; + } + + case DATATYPE_VAR: + res.GenericParamPosition = (int)*Signature++; + NANOCLR_SET_AND_LEAVE(S_OK); + + case DATATYPE_MVAR: + res.GenericParamPosition = (int)*Signature++; NANOCLR_SET_AND_LEAVE(S_OK); default: { - const CLR_RT_TypeDef_Index *cls = c_CLR_RT_DataTypeLookup[res.m_dt].m_cls; + const CLR_RT_TypeDef_Index *cls = c_CLR_RT_DataTypeLookup[res.DataType].m_cls; if (cls) { - res.m_cls = *cls; + res.Class = *cls; NANOCLR_SET_AND_LEAVE(S_OK); } else @@ -479,77 +655,87 @@ HRESULT CLR_RT_SignatureParser::Advance(Element &res) //////////////////////////////////////////////////////////////////////////////////////////////////// -bool CLR_RT_Assembly_Instance::InitializeFromIndex(const CLR_RT_Assembly_Index &idx) +bool CLR_RT_Assembly_Instance::InitializeFromIndex(const CLR_RT_Assembly_Index &index) { NATIVE_PROFILE_CLR_CORE(); - if (NANOCLR_INDEX_IS_VALID(idx)) + if (NANOCLR_INDEX_IS_VALID(index)) { - m_data = idx.m_data; - m_assm = g_CLR_RT_TypeSystem.m_assemblies[Assembly() - 1]; + data = index.data; + assembly = g_CLR_RT_TypeSystem.m_assemblies[Assembly() - 1]; return true; } - m_data = 0; - m_assm = NULL; + data = 0; + assembly = nullptr; return false; } -void CLR_RT_Assembly_Instance::Clear() +void CLR_RT_Assembly_Instance::ClearInstance() { NATIVE_PROFILE_CLR_CORE(); CLR_RT_Assembly_Index::Clear(); - m_assm = NULL; + assembly = nullptr; } ////////////////////////////// -bool CLR_RT_TypeSpec_Instance::InitializeFromIndex(const CLR_RT_TypeSpec_Index &idx) +bool CLR_RT_TypeSpec_Instance::InitializeFromIndex(const CLR_RT_TypeSpec_Index &index) { NATIVE_PROFILE_CLR_CORE(); - if (NANOCLR_INDEX_IS_VALID(idx)) + if (NANOCLR_INDEX_IS_VALID(index)) { - m_data = idx.m_data; - m_assm = g_CLR_RT_TypeSystem.m_assemblies[Assembly() - 1]; - m_target = m_assm->GetSignature(m_assm->GetTypeSpec(TypeSpec())->sig); + data = index.data; + assembly = g_CLR_RT_TypeSystem.m_assemblies[Assembly() - 1]; + target = assembly->GetTypeSpec(TypeSpec()); + + CLR_RT_SignatureParser parser; + parser.Initialize_TypeSpec(assembly, assembly->GetTypeSpec(index.TypeSpec())); + + CLR_RT_SignatureParser::Element element; + + // get type + parser.Advance(element); + + typeDefIndex = element.Class.Type(); return true; } - m_data = 0; - m_assm = NULL; - m_target = NULL; + data = 0; + assembly = nullptr; + target = nullptr; return false; } -void CLR_RT_TypeSpec_Instance::Clear() +void CLR_RT_TypeSpec_Instance::ClearInstance() { NATIVE_PROFILE_CLR_CORE(); CLR_RT_TypeSpec_Index::Clear(); - m_assm = NULL; - m_target = NULL; + assembly = nullptr; + target = nullptr; } -bool CLR_RT_TypeSpec_Instance::ResolveToken(CLR_UINT32 tk, CLR_RT_Assembly *assm) +bool CLR_RT_TypeSpec_Instance::ResolveToken(CLR_UINT32 token, CLR_RT_Assembly *assm) { NATIVE_PROFILE_CLR_CORE(); - if (assm && CLR_TypeFromTk(tk) == TBL_TypeSpec) + if (assm && CLR_TypeFromTk(token) == TBL_TypeSpec) { - CLR_UINT32 idx = CLR_DataFromTk(tk); + CLR_UINT32 index = CLR_DataFromTk(token); - Set(assm->m_idx, idx); + Set(assm->assemblyIndex, index); - m_assm = assm; - m_target = assm->GetSignature(assm->GetTypeSpec(idx)->sig); + assembly = assm; + target = assm->GetTypeSpec(index); return true; } - Clear(); + ClearInstance(); return false; } @@ -560,26 +746,26 @@ bool CLR_RT_TypeDef_Instance::InitializeFromReflection(const CLR_RT_ReflectionDe { NATIVE_PROFILE_CLR_CORE(); CLR_RT_TypeDef_Index cls; - const CLR_RT_TypeDef_Index *ptr = NULL; + const CLR_RT_TypeDef_Index *ptr = nullptr; if (levels) - *levels = reflex.m_levels; + *levels = reflex.levels; - switch (reflex.m_kind) + switch (reflex.kind) { case REFLECTION_TYPE: - if (reflex.m_levels > 0 && levels == NULL) + if (reflex.levels > 0 && levels == nullptr) { - ptr = &g_CLR_RT_WellKnownTypes.m_Array; + ptr = &g_CLR_RT_WellKnownTypes.Array; } else { - ptr = &reflex.m_data.m_type; + ptr = &reflex.data.type; } break; case REFLECTION_TYPE_DELAYED: - if (g_CLR_RT_TypeSystem.FindTypeDef(reflex.m_data.m_raw, cls)) + if (g_CLR_RT_TypeSystem.FindTypeDef(reflex.data.raw, cls)) { ptr = &cls; } @@ -589,21 +775,25 @@ bool CLR_RT_TypeDef_Instance::InitializeFromReflection(const CLR_RT_ReflectionDe return ptr ? InitializeFromIndex(*ptr) : false; } -bool CLR_RT_TypeDef_Instance::InitializeFromIndex(const CLR_RT_TypeDef_Index &idx) +bool CLR_RT_TypeDef_Instance::InitializeFromIndex(const CLR_RT_TypeDef_Index &index) { NATIVE_PROFILE_CLR_CORE(); - if (NANOCLR_INDEX_IS_VALID(idx)) + if (NANOCLR_INDEX_IS_VALID(index)) { - m_data = idx.m_data; - m_assm = g_CLR_RT_TypeSystem.m_assemblies[Assembly() - 1]; - m_target = m_assm->GetTypeDef(Type()); + data = index.data; + assembly = g_CLR_RT_TypeSystem.m_assemblies[Assembly() - 1]; + target = assembly->GetTypeDef(Type()); + +#if defined(NANOCLR_INSTANCE_NAMES) + name = assembly->GetString(target->name); +#endif return true; } - m_data = 0; - m_assm = NULL; - m_target = NULL; + data = 0; + assembly = nullptr; + target = nullptr; return false; } @@ -613,18 +803,45 @@ bool CLR_RT_TypeDef_Instance::InitializeFromMethod(const CLR_RT_MethodDef_Instan NATIVE_PROFILE_CLR_CORE(); if (NANOCLR_INDEX_IS_VALID(md)) { - CLR_IDX idxAssm = md.Assembly(); - CLR_IDX idxType = md.CrossReference().GetOwner(); + CLR_INDEX indexAssm = md.Assembly(); + CLR_INDEX indexType = md.CrossReference().GetOwner(); - Set(idxAssm, idxType); + Set(indexAssm, indexType); + + assembly = g_CLR_RT_TypeSystem.m_assemblies[indexAssm - 1]; + target = assembly->GetTypeDef(indexType); + +#if defined(NANOCLR_INSTANCE_NAMES) + name = assembly->GetString(target->name); +#endif + return true; + } - m_assm = g_CLR_RT_TypeSystem.m_assemblies[idxAssm - 1]; - m_target = m_assm->GetTypeDef(idxType); + ClearInstance(); + return false; +} + +bool CLR_RT_TypeDef_Instance::InitializeFromMethod(const CLR_RT_MethodSpec_Instance &ms) +{ + NATIVE_PROFILE_CLR_CORE(); + if (NANOCLR_INDEX_IS_VALID(ms)) + { + CLR_INDEX indexAssm = ms.Assembly(); + // CLR_INDEX indexType = ms.CrossReference().GetOwner(); + + // Set(indexAssm, indexType); + + assembly = g_CLR_RT_TypeSystem.m_assemblies[indexAssm - 1]; + // m_target = m_assm->GetTypeDef(indexType); + +#if defined(NANOCLR_INSTANCE_NAMES) + name = assembly->GetString(target->name); +#endif return true; } - Clear(); + ClearInstance(); return false; } @@ -634,16 +851,16 @@ bool CLR_RT_TypeDef_Instance::InitializeFromField(const CLR_RT_FieldDef_Instance NATIVE_PROFILE_CLR_CORE(); if (NANOCLR_INDEX_IS_VALID(fd)) { - CLR_RT_Assembly *assm = fd.m_assm; - const CLR_RECORD_TYPEDEF *td = (const CLR_RECORD_TYPEDEF *)assm->GetTable(TBL_TypeDef); - CLR_IDX idxField = fd.Field(); - int i = assm->m_pTablesSize[TBL_TypeDef]; + CLR_RT_Assembly const *assm = fd.assembly; + auto *td = (const CLR_RECORD_TYPEDEF *)assm->GetTable(TBL_TypeDef); + CLR_INDEX indexField = fd.Field(); + int i = assm->tablesSize[TBL_TypeDef]; - if (fd.m_target->flags & CLR_RECORD_FIELDDEF::FD_Static) + if (fd.target->flags & CLR_RECORD_FIELDDEF::FD_Static) { for (; i; i--, td++) { - if (td->sFields_First <= idxField && idxField < td->sFields_First + td->sFields_Num) + if (td->firstStaticField <= indexField && indexField < td->firstStaticField + td->staticFieldsCount) { break; } @@ -653,7 +870,8 @@ bool CLR_RT_TypeDef_Instance::InitializeFromField(const CLR_RT_FieldDef_Instance { for (; i; i--, td++) { - if (td->iFields_First <= idxField && idxField < td->iFields_First + td->iFields_Num) + if (td->firstInstanceField <= indexField && + indexField < td->firstInstanceField + td->instanceFieldsCount) { break; } @@ -662,19 +880,22 @@ bool CLR_RT_TypeDef_Instance::InitializeFromField(const CLR_RT_FieldDef_Instance if (i) { - CLR_IDX idxAssm = fd.Assembly(); - CLR_IDX idxType = assm->m_pTablesSize[TBL_TypeDef] - i; + CLR_INDEX indexAssm = fd.Assembly(); + CLR_INDEX indexType = assm->tablesSize[TBL_TypeDef] - i; - Set(idxAssm, idxType); + Set(indexAssm, indexType); - m_assm = g_CLR_RT_TypeSystem.m_assemblies[idxAssm - 1]; - m_target = m_assm->GetTypeDef(idxType); + assembly = g_CLR_RT_TypeSystem.m_assemblies[indexAssm - 1]; + target = assembly->GetTypeDef(indexType); +#if defined(NANOCLR_INSTANCE_NAMES) + name = assembly->GetString(target->name); +#endif return true; } } - Clear(); + ClearInstance(); return false; } @@ -682,47 +903,154 @@ bool CLR_RT_TypeDef_Instance::InitializeFromField(const CLR_RT_FieldDef_Instance bool CLR_RT_TypeDef_Instance::IsATypeHandler() { NATIVE_PROFILE_CLR_CORE(); - return (m_data == g_CLR_RT_WellKnownTypes.m_Type.m_data || m_data == g_CLR_RT_WellKnownTypes.m_TypeStatic.m_data); + return (data == g_CLR_RT_WellKnownTypes.Type.data || data == g_CLR_RT_WellKnownTypes.TypeStatic.data); } -void CLR_RT_TypeDef_Instance::Clear() +void CLR_RT_TypeDef_Instance::ClearInstance() { NATIVE_PROFILE_CLR_CORE(); CLR_RT_TypeDef_Index::Clear(); - m_assm = NULL; - m_target = NULL; + assembly = nullptr; + target = nullptr; } -bool CLR_RT_TypeDef_Instance::ResolveToken(CLR_UINT32 tk, CLR_RT_Assembly *assm) +// if type token is not generic, we are going to resolve from the assembly else from the heapblock that may contains +// generic parameter +bool CLR_RT_TypeDef_Instance::ResolveToken( + CLR_UINT32 tk, + CLR_RT_Assembly *assm, + const CLR_RT_MethodDef_Instance *caller) { NATIVE_PROFILE_CLR_CORE(); if (assm) { - CLR_UINT32 idx = CLR_DataFromTk(tk); + CLR_UINT32 index = CLR_DataFromTk(tk); switch (CLR_TypeFromTk(tk)) { case TBL_TypeRef: - m_data = assm->m_pCrossReference_TypeRef[idx].m_target.m_data; - m_assm = g_CLR_RT_TypeSystem.m_assemblies[Assembly() - 1]; - m_target = m_assm->GetTypeDef(Type()); + data = assm->crossReferenceTypeRef[index].target.data; + assembly = g_CLR_RT_TypeSystem.m_assemblies[Assembly() - 1]; + target = assembly->GetTypeDef(Type()); + +#if defined(NANOCLR_INSTANCE_NAMES) + name = assembly->GetString(target->name); +#endif + return true; case TBL_TypeDef: - Set(assm->m_idx, idx); + Set(assm->assemblyIndex, index); + + assembly = assm; + target = assm->GetTypeDef(index); + +#if defined(NANOCLR_INSTANCE_NAMES) + name = assembly->GetString(target->name); +#endif + + return true; + + case TBL_GenericParam: + { + CLR_RT_GenericParam_CrossReference gp = assm->crossReferenceGenericParam[index]; + + Set(gp.classTypeDef.Assembly(), gp.classTypeDef.Type()); + + assembly = g_CLR_RT_TypeSystem.m_assemblies[gp.classTypeDef.Assembly() - 1]; + target = assembly->GetTypeDef(gp.classTypeDef.Type()); + +#if defined(NANOCLR_INSTANCE_NAMES) + name = assembly->GetString(target->name); +#endif + + return true; + } + + case TBL_TypeSpec: + { + const CLR_RECORD_TYPESPEC *ts = assm->GetTypeSpec(index); + + CLR_RT_SignatureParser parser; + parser.Initialize_TypeSpec(assm, ts); + + CLR_RT_SignatureParser::Element element; + + // advance signature: get parameter + parser.Advance(element); + + // store parameter position + auto genericParamPosition = (CLR_INT8)element.GenericParamPosition; + + switch (element.DataType) + { + case DATATYPE_VAR: + { + CLR_RT_TypeDef_Index typeDef; + NanoCLRDataType dataType; + + caller->assembly->FindGenericParamAtTypeSpec(*caller, genericParamPosition, typeDef, dataType); + + data = typeDef.data; + assembly = g_CLR_RT_TypeSystem.m_assemblies[typeDef.Assembly() - 1]; + target = assembly->GetTypeDef(typeDef.Type()); + } + break; + + case DATATYPE_MVAR: + { + CLR_RT_GenericParam_Index gpIndex; + + caller->assembly->FindGenericParamAtMethodDef(*caller, genericParamPosition, gpIndex); + + CLR_RT_GenericParam_CrossReference gp = + caller->assembly->crossReferenceGenericParam[gpIndex.GenericParam()]; + + // get TypeDef instance from generic parameter index + data = gp.classTypeDef.data; + assembly = g_CLR_RT_TypeSystem.m_assemblies[gp.classTypeDef.Assembly() - 1]; + target = assembly->GetTypeDef(gp.classTypeDef.Type()); + } + break; + + default: + return false; + } + +#if defined(NANOCLR_INSTANCE_NAMES) + name = assembly->GetString(target->name); +#endif - m_assm = assm; - m_target = assm->GetTypeDef(idx); return true; + } default: + //// handle generic type from provided data + // if (sampleData != nullptr) + //{ + // CLR_RT_TypeDescriptor::ExtractTypeIndexFromObject(*sampleData, *this); + // m_assm = g_CLR_RT_TypeSystem.m_assemblies[Assembly() - 1]; + // m_target = m_assm->GetTypeDef(Type()); + // } + // else + //{ + // m_data = g_CLR_RT_WellKnownTypes.Object.m_data; + // m_assm = g_CLR_RT_TypeSystem.m_assemblies[g_CLR_RT_WellKnownTypes.Object.Assembly() - 1]; + // m_target = m_assm->GetTypeDef(g_CLR_RT_WellKnownTypes.Object.Type()); + // } + +#if defined(NANOCLR_INSTANCE_NAMES) + name = assembly->GetString(target->name); +#endif + + return true; // the remaining data types aren't to be handled break; } } - Clear(); + ClearInstance(); return false; } @@ -734,29 +1062,32 @@ bool CLR_RT_TypeDef_Instance::SwitchToParent() NATIVE_PROFILE_CLR_CORE(); if (NANOCLR_INDEX_IS_VALID(*this)) { - CLR_IDX extends = m_target->extends; - - if (extends != CLR_EmptyIndex) + if (target->HasValidExtendsType()) { CLR_RT_TypeDef_Index tmp; const CLR_RT_TypeDef_Index *cls; - if (extends & 0x8000) // TypeRef + switch (target->Extends()) { - cls = &m_assm->m_pCrossReference_TypeRef[extends & 0x7FFF].m_target; - } - else - { - tmp.Set(Assembly(), extends); + case TBL_TypeDef: + tmp.Set(Assembly(), target->ExtendsIndex()); + cls = &tmp; + break; - cls = &tmp; + case TBL_TypeRef: + cls = &assembly->crossReferenceTypeRef[target->ExtendsIndex()].target; + break; + + // all others are not supported + default: + return false; } return InitializeFromIndex(*cls); } } - Clear(); + ClearInstance(); return false; } @@ -765,37 +1096,43 @@ bool CLR_RT_TypeDef_Instance::HasFinalizer() const { NATIVE_PROFILE_CLR_CORE(); return NANOCLR_INDEX_IS_VALID(*this) && - (CrossReference().m_flags & CLR_RT_TypeDef_CrossReference::TD_CR_HasFinalizer); + (CrossReference().flags & CLR_RT_TypeDef_CrossReference::TD_CR_HasFinalizer); } ////////////////////////////// -bool CLR_RT_FieldDef_Instance::InitializeFromIndex(const CLR_RT_FieldDef_Index &idx) +bool CLR_RT_FieldDef_Instance::InitializeFromIndex(const CLR_RT_FieldDef_Index &index) { NATIVE_PROFILE_CLR_CORE(); - if (NANOCLR_INDEX_IS_VALID(idx)) + if (NANOCLR_INDEX_IS_VALID(index)) { - m_data = idx.m_data; - m_assm = g_CLR_RT_TypeSystem.m_assemblies[Assembly() - 1]; - m_target = m_assm->GetFieldDef(Field()); + data = index.data; + assembly = g_CLR_RT_TypeSystem.m_assemblies[Assembly() - 1]; + target = assembly->GetFieldDef(Field()); + genericType = nullptr; +#if defined(NANOCLR_INSTANCE_NAMES) + name = assembly->GetString(target->name); +#endif return true; } - m_data = 0; - m_assm = NULL; - m_target = NULL; + data = 0; + assembly = nullptr; + target = nullptr; + genericType = nullptr; return false; } -void CLR_RT_FieldDef_Instance::Clear() +void CLR_RT_FieldDef_Instance::ClearInstance() { NATIVE_PROFILE_CLR_CORE(); CLR_RT_FieldDef_Index::Clear(); - m_assm = NULL; - m_target = NULL; + assembly = nullptr; + target = nullptr; + genericType = nullptr; } bool CLR_RT_FieldDef_Instance::ResolveToken(CLR_UINT32 tk, CLR_RT_Assembly *assm) @@ -803,21 +1140,68 @@ bool CLR_RT_FieldDef_Instance::ResolveToken(CLR_UINT32 tk, CLR_RT_Assembly *assm NATIVE_PROFILE_CLR_CORE(); if (assm) { - CLR_UINT32 idx = CLR_DataFromTk(tk); + CLR_UINT32 index = CLR_DataFromTk(tk); switch (CLR_TypeFromTk(tk)) { case TBL_FieldRef: - m_data = assm->m_pCrossReference_FieldRef[idx].m_target.m_data; - m_assm = g_CLR_RT_TypeSystem.m_assemblies[Assembly() - 1]; - m_target = m_assm->GetFieldDef(Field()); - return true; + { + const CLR_RECORD_FIELDREF *fr = assm->GetFieldRef(index); + + switch (fr->Owner()) + { + case TBL_TypeRef: + data = assm->crossReferenceFieldRef[index].target.data; + assembly = g_CLR_RT_TypeSystem.m_assemblies[Assembly() - 1]; + target = assembly->GetFieldDef(Field()); + + // invalidate generic type + genericType = nullptr; + break; + + case TBL_TypeSpec: + { + genericType = &assm->crossReferenceFieldRef[index].genericType; + + const CLR_RECORD_TYPESPEC *ts = assm->GetTypeSpec(genericType->TypeSpec()); + + CLR_RT_FieldDef_Index field; + + if (!assm->FindFieldDef(ts, assm->GetString(fr->name), assm, fr->signature, field)) + { + return false; + } + + Set(assm->assemblyIndex, field.Field()); + + assembly = assm; + target = assembly->GetFieldDef(Field()); + + break; + } + default: + // shouldn't be here + return false; + } + +#if defined(NANOCLR_INSTANCE_NAMES) + name = assembly->GetString(target->name); +#endif + return true; + } case TBL_FieldDef: - Set(assm->m_idx, idx); + Set(assm->assemblyIndex, index); + + assembly = assm; + target = assembly->GetFieldDef(index); - m_assm = assm; - m_target = m_assm->GetFieldDef(idx); + // invalidate generic type + genericType = nullptr; + +#if defined(NANOCLR_INSTANCE_NAMES) + name = assembly->GetString(target->name); +#endif return true; default: @@ -826,39 +1210,45 @@ bool CLR_RT_FieldDef_Instance::ResolveToken(CLR_UINT32 tk, CLR_RT_Assembly *assm } } - Clear(); + ClearInstance(); return false; } ////////////////////////////// -bool CLR_RT_MethodDef_Instance::InitializeFromIndex(const CLR_RT_MethodDef_Index &idx) +bool CLR_RT_MethodDef_Instance::InitializeFromIndex(const CLR_RT_MethodDef_Index &index) { NATIVE_PROFILE_CLR_CORE(); - if (NANOCLR_INDEX_IS_VALID(idx)) + if (NANOCLR_INDEX_IS_VALID(index)) { - m_data = idx.m_data; - m_assm = g_CLR_RT_TypeSystem.m_assemblies[Assembly() - 1]; - m_target = m_assm->GetMethodDef(Method()); + data = index.data; + assembly = g_CLR_RT_TypeSystem.m_assemblies[Assembly() - 1]; + target = assembly->GetMethodDef(Method()); + genericType = nullptr; +#if defined(NANOCLR_INSTANCE_NAMES) + name = assembly->GetString(target->name); +#endif return true; } - m_data = 0; - m_assm = NULL; - m_target = NULL; + data = 0; + assembly = nullptr; + target = nullptr; + genericType = nullptr; return false; } -void CLR_RT_MethodDef_Instance::Clear() +void CLR_RT_MethodDef_Instance::ClearInstance() { NATIVE_PROFILE_CLR_CORE(); CLR_RT_MethodDef_Index::Clear(); - m_assm = NULL; - m_target = NULL; + assembly = nullptr; + target = nullptr; + genericType = nullptr; } bool CLR_RT_MethodDef_Instance::ResolveToken(CLR_UINT32 tk, CLR_RT_Assembly *assm) @@ -866,46 +1256,266 @@ bool CLR_RT_MethodDef_Instance::ResolveToken(CLR_UINT32 tk, CLR_RT_Assembly *ass NATIVE_PROFILE_CLR_CORE(); if (assm) { - CLR_UINT32 idx = CLR_DataFromTk(tk); + CLR_UINT32 index = CLR_DataFromTk(tk); switch (CLR_TypeFromTk(tk)) { case TBL_MethodRef: - m_data = assm->m_pCrossReference_MethodRef[idx].m_target.m_data; - m_assm = g_CLR_RT_TypeSystem.m_assemblies[Assembly() - 1]; - m_target = m_assm->GetMethodDef(Method()); + { + const CLR_RECORD_METHODREF *mr = assm->GetMethodRef(index); + + if (mr->Owner() == TBL_TypeSpec) + { + // owner is TypeSpec + + genericType = &assm->crossReferenceMethodRef[index].genericType; + + const CLR_RECORD_TYPESPEC *ts = assm->GetTypeSpec(genericType->TypeSpec()); + + CLR_RT_MethodDef_Index method; + + if (!assm->FindMethodDef(ts, assm->GetString(mr->name), assm, mr->signature, method)) + { + return false; + } + + Set(assm->assemblyIndex, method.Method()); + + assembly = assm; + target = assembly->GetMethodDef(method.Method()); + } + else + { + // owner is TypeRef + + // get data for MethodRef (from index) + data = assm->crossReferenceMethodRef[index].target.data; + // get assembly for this type ref + assembly = g_CLR_RT_TypeSystem.m_assemblies[Assembly() - 1]; + // grab the MethodDef + target = assembly->GetMethodDef(Method()); + + // invalidate GenericType + genericType = nullptr; + } + +#if defined(NANOCLR_INSTANCE_NAMES) + name = assembly->GetString(target->name); +#endif return true; + } case TBL_MethodDef: - Set(assm->m_idx, idx); + Set(assm->assemblyIndex, index); + + assembly = assm; + target = assembly->GetMethodDef(index); + + // invalidate generic type + genericType = nullptr; + +#if defined(NANOCLR_INSTANCE_NAMES) + name = assembly->GetString(target->name); +#endif + return true; + + case TBL_MethodSpec: + { + assembly = assm; + + const CLR_RECORD_METHODSPEC *ms = assembly->GetMethodSpec(index); + + CLR_RT_MethodSpec_Index msIndex; + msIndex.Set(assembly->assemblyIndex, index); + + switch (ms->MethodKind()) + { + case TBL_MethodDef: + Set(assembly->assemblyIndex, ms->MethodIndex()); + assembly = assm; + target = assembly->GetMethodDef(ms->MethodIndex()); + break; + + case TBL_MethodRef: + data = assm->crossReferenceMethodRef[ms->MethodIndex()].target.data; + assembly = g_CLR_RT_TypeSystem.m_assemblies[Assembly() - 1]; + target = assembly->GetMethodDef(Method()); + + break; + + default: + // shouldn't be here + return false; + } + + // get generic type + genericType = &assembly->crossReferenceTypeSpec[ms->container].genericType; - m_assm = assm; - m_target = m_assm->GetMethodDef(idx); +#if defined(NANOCLR_INSTANCE_NAMES) + name = assembly->GetString(target->name); +#endif return true; + } + case TBL_TypeSpec: + { + CLR_RT_MethodSpec_Index methodSpec; + assm->FindMethodSpecFromTypeSpec(index, methodSpec); + + const CLR_RECORD_METHODSPEC *ms = assm->GetMethodSpec(index); + + switch (ms->MethodKind()) + { + case TBL_MethodDef: + Set(assm->assemblyIndex, ms->MethodIndex()); + + assembly = assm; + target = assembly->GetMethodDef(ms->MethodIndex()); + +#if defined(NANOCLR_INSTANCE_NAMES) + name = assembly->GetString(target->name); +#endif + return true; + + case TBL_MethodRef: + data = assm->crossReferenceMethodRef[ms->MethodIndex()].target.data; + assembly = g_CLR_RT_TypeSystem.m_assemblies[Assembly() - 1]; + target = assembly->GetMethodDef(Method()); + +#if defined(NANOCLR_INSTANCE_NAMES) + name = assembly->GetString(target->name); +#endif + + return true; + + default: + // shouldn't be here + return false; + } + break; + + // get generic type + genericType = &assembly->crossReferenceTypeSpec[ms->container].genericType; +#if defined(NANOCLR_INSTANCE_NAMES) + name = assembly->GetString(target->name); +#endif + return true; + } default: // the remaining data types aren't to be handled break; } } - Clear(); + ClearInstance(); + + return false; +} + +////////////////////////////// + +bool CLR_RT_GenericParam_Instance::InitializeFromIndex(const CLR_RT_GenericParam_Index &index) +{ + NATIVE_PROFILE_CLR_CORE(); + + if (NANOCLR_INDEX_IS_VALID(index)) + { + data = index.data; + assembly = g_CLR_RT_TypeSystem.m_assemblies[Assembly() - 1]; + target = assembly->GetGenericParam(GenericParam()); + +#if defined(NANOCLR_INSTANCE_NAMES) + name = assembly->GetString(target->name); +#endif + + return true; + } + + data = 0; + assembly = nullptr; + target = nullptr; + + return false; +} + +void CLR_RT_GenericParam_Instance::ClearInstance() +{ + NATIVE_PROFILE_CLR_CORE(); + CLR_RT_GenericParam_Index::Clear(); + + assembly = nullptr; + target = nullptr; +} + +bool CLR_RT_GenericParam_Instance::ResolveToken(CLR_UINT32 tk, CLR_RT_Assembly *assm) +{ + NATIVE_PROFILE_CLR_CORE(); + if (assm) + { + CLR_UINT32 index = CLR_DataFromTk(tk); + + CLR_RT_GenericParam_Index genericParamIndex; + genericParamIndex.Set(assm->assemblyIndex, index); + + // get generic type + data = genericParamIndex.data; + assembly = assm; + target = assembly->GetGenericParam(index); + +#if defined(NANOCLR_INSTANCE_NAMES) + name = assembly->GetString(target->name); +#endif + return true; + } + + ClearInstance(); return false; } //////////////////////////////////////////////////////////////////////////////////////////////////// +bool CLR_RT_MethodSpec_Instance::InitializeFromIndex(const CLR_RT_MethodSpec_Index &index) +{ + NATIVE_PROFILE_CLR_CORE(); + + if (NANOCLR_INDEX_IS_VALID(index)) + { + data = index.data; + assembly = g_CLR_RT_TypeSystem.m_assemblies[Assembly() - 1]; + target = assembly->GetMethodSpec(Method()); + + return true; + } + + data = 0; + assembly = nullptr; + target = nullptr; + + return false; +} + +void CLR_RT_MethodSpec_Instance::ClearInstance() +{ + NATIVE_PROFILE_CLR_CORE(); + CLR_RT_MethodSpec_Index::Clear(); + + assembly = nullptr; + target = nullptr; +} + +//////////////////////////////////////////////////////////////////////////////////////////////////// + void CLR_RT_TypeDescriptor::TypeDescriptor_Initialize() { NATIVE_PROFILE_CLR_CORE(); - m_flags = 0; // CLR_UINT32 m_flags; - m_handlerCls.Clear(); // CLR_RT_TypeDef_Instance m_handlerCls; - // - m_reflex.Clear(); // CLR_RT_ReflectionDef_Index m_reflex; + m_flags = 0; + m_handlerCls.ClearInstance(); + m_handlerGenericType.ClearInstance(); + m_reflex.Clear(); } -HRESULT CLR_RT_TypeDescriptor::InitializeFromDataType(CLR_DataType dt) +HRESULT CLR_RT_TypeDescriptor::InitializeFromDataType(NanoCLRDataType dt) { NATIVE_PROFILE_CLR_CORE(); NANOCLR_HEADER(); @@ -927,9 +1537,9 @@ HRESULT CLR_RT_TypeDescriptor::InitializeFromDataType(CLR_DataType dt) NANOCLR_SET_AND_LEAVE(CLR_E_WRONG_TYPE); } - m_reflex.m_kind = REFLECTION_TYPE; - m_reflex.m_levels = 0; - m_reflex.m_data.m_type = *dtl.m_cls; + m_reflex.kind = REFLECTION_TYPE; + m_reflex.levels = 0; + m_reflex.data.type = *dtl.m_cls; } else { @@ -937,6 +1547,8 @@ HRESULT CLR_RT_TypeDescriptor::InitializeFromDataType(CLR_DataType dt) } } + m_handlerGenericType.ClearInstance(); + NANOCLR_NOCLEANUP(); } @@ -957,7 +1569,7 @@ HRESULT CLR_RT_TypeDescriptor::InitializeFromReflection(const CLR_RT_ReflectionD if (levels) { - m_reflex.m_levels = levels; + m_reflex.levels = levels; ConvertToArray(); } @@ -978,7 +1590,7 @@ HRESULT CLR_RT_TypeDescriptor::InitializeFromTypeSpec(const CLR_RT_TypeSpec_Inde NANOCLR_SET_AND_LEAVE(CLR_E_WRONG_TYPE); } - parser.Initialize_TypeSpec(inst.m_assm, inst.m_target); + parser.Initialize_TypeSpec(inst.assembly, inst.target); NANOCLR_SET_AND_LEAVE(InitializeFromSignatureParser(parser)); @@ -996,17 +1608,17 @@ HRESULT CLR_RT_TypeDescriptor::InitializeFromType(const CLR_RT_TypeDef_Index &cl } else { - const CLR_RT_DataTypeLookup &dtl = c_CLR_RT_DataTypeLookup[m_handlerCls.m_target->dataType]; + const CLR_RT_DataTypeLookup &dtl = c_CLR_RT_DataTypeLookup[m_handlerCls.target->dataType]; m_flags = dtl.m_flags & CLR_RT_DataTypeLookup::c_SemanticMask; - m_reflex.m_kind = REFLECTION_TYPE; - m_reflex.m_levels = 0; - m_reflex.m_data.m_type = m_handlerCls; + m_reflex.kind = REFLECTION_TYPE; + m_reflex.levels = 0; + m_reflex.data.type = m_handlerCls; if (m_flags == CLR_RT_DataTypeLookup::c_Primitive) { - if ((m_handlerCls.m_target->flags & CLR_RECORD_TYPEDEF::TD_Semantics_Mask) == + if ((m_handlerCls.target->flags & CLR_RECORD_TYPEDEF::TD_Semantics_Mask) == CLR_RECORD_TYPEDEF::TD_Semantics_Enum) { m_flags = CLR_RT_DataTypeLookup::c_Enum; @@ -1014,7 +1626,7 @@ HRESULT CLR_RT_TypeDescriptor::InitializeFromType(const CLR_RT_TypeDef_Index &cl } else { - switch (m_handlerCls.m_target->flags & CLR_RECORD_TYPEDEF::TD_Semantics_Mask) + switch (m_handlerCls.target->flags & CLR_RECORD_TYPEDEF::TD_Semantics_Mask) { case CLR_RECORD_TYPEDEF::TD_Semantics_ValueType: m_flags = CLR_RT_DataTypeLookup::c_ValueType; @@ -1031,17 +1643,41 @@ HRESULT CLR_RT_TypeDescriptor::InitializeFromType(const CLR_RT_TypeDef_Index &cl } } - if (m_handlerCls.m_data == g_CLR_RT_WellKnownTypes.m_Array.m_data) + if (m_handlerCls.data == g_CLR_RT_WellKnownTypes.Array.data) { m_flags |= CLR_RT_DataTypeLookup::c_Array; } - if (m_handlerCls.m_data == g_CLR_RT_WellKnownTypes.m_ArrayList.m_data) + if (m_handlerCls.data == g_CLR_RT_WellKnownTypes.ArrayList.data) { m_flags |= CLR_RT_DataTypeLookup::c_ArrayList; } } + m_handlerGenericType.ClearInstance(); + + NANOCLR_NOCLEANUP(); +} + +HRESULT CLR_RT_TypeDescriptor::InitializeFromGenericType(const CLR_RT_TypeSpec_Index &genericType) +{ + NATIVE_PROFILE_CLR_CORE(); + NANOCLR_HEADER(); + + if (m_handlerGenericType.InitializeFromIndex(genericType) == false) + { + NANOCLR_SET_AND_LEAVE(CLR_E_WRONG_TYPE); + } + else + { + m_flags = CLR_RT_DataTypeLookup::c_ManagedType | CLR_RT_DataTypeLookup::c_GenericInstance; + + m_reflex.kind = REFLECTION_GENERICTYPE; + m_reflex.data.genericType = m_handlerGenericType; + } + + m_handlerCls.ClearInstance(); + NANOCLR_NOCLEANUP(); } @@ -1051,7 +1687,7 @@ HRESULT CLR_RT_TypeDescriptor::InitializeFromFieldDefinition(const CLR_RT_FieldD NANOCLR_HEADER(); CLR_RT_SignatureParser parser{}; - parser.Initialize_FieldDef(fd.m_assm, fd.m_target); + parser.Initialize_FieldDef(fd.assembly, fd.target); NANOCLR_SET_AND_LEAVE(InitializeFromSignatureParser(parser)); @@ -1072,11 +1708,18 @@ HRESULT CLR_RT_TypeDescriptor::InitializeFromSignatureParser(CLR_RT_SignaturePar NANOCLR_CHECK_HRESULT(parser.Advance(res)); - NANOCLR_CHECK_HRESULT(InitializeFromType(res.m_cls)); + if (res.DataType == DATATYPE_GENERICINST) + { + NANOCLR_CHECK_HRESULT(InitializeFromGenericType(res.TypeSpec)); + } + else + { + NANOCLR_CHECK_HRESULT(InitializeFromType(res.Class)); + } - if (res.m_levels) + if (res.Levels) { - m_reflex.m_levels = res.m_levels; + m_reflex.levels = res.Levels; ConvertToArray(); } @@ -1090,11 +1733,11 @@ HRESULT CLR_RT_TypeDescriptor::InitializeFromObject(const CLR_RT_HeapBlock &ref) NANOCLR_HEADER(); const CLR_RT_HeapBlock *obj = &ref; - CLR_DataType dt; + NanoCLRDataType dt; while (true) { - dt = (CLR_DataType)obj->DataType(); + dt = (NanoCLRDataType)obj->DataType(); if (dt == DATATYPE_BYREF || dt == DATATYPE_OBJECT) { @@ -1115,14 +1758,15 @@ HRESULT CLR_RT_TypeDescriptor::InitializeFromObject(const CLR_RT_HeapBlock &ref) } { - const CLR_RT_TypeDef_Index *cls = NULL; - const CLR_RT_ReflectionDef_Index *reflex = NULL; + const CLR_RT_TypeDef_Index *cls = nullptr; + const CLR_RT_ReflectionDef_Index *reflex = nullptr; + const CLR_RT_TypeSpec_Index *genericType = nullptr; switch (dt) { case DATATYPE_SZARRAY: reflex = &obj->ReflectionDataConst(); - cls = &reflex->m_data.m_type; + cls = &reflex->data.type; break; case DATATYPE_VALUETYPE: @@ -1132,18 +1776,18 @@ HRESULT CLR_RT_TypeDescriptor::InitializeFromObject(const CLR_RT_HeapBlock &ref) case DATATYPE_DELEGATE_HEAD: { - CLR_RT_HeapBlock_Delegate *dlg = (CLR_RT_HeapBlock_Delegate *)obj; + auto *dlg = (const CLR_RT_HeapBlock_Delegate *)obj; - cls = NANOCLR_INDEX_IS_VALID(dlg->m_cls) ? &dlg->m_cls : &g_CLR_RT_WellKnownTypes.m_Delegate; + cls = NANOCLR_INDEX_IS_VALID(dlg->m_cls) ? &dlg->m_cls : &g_CLR_RT_WellKnownTypes.Delegate; } break; case DATATYPE_DELEGATELIST_HEAD: { - CLR_RT_HeapBlock_Delegate_List *dlgLst = (CLR_RT_HeapBlock_Delegate_List *)obj; + auto *dlgLst = (const CLR_RT_HeapBlock_Delegate_List *)obj; - cls = NANOCLR_INDEX_IS_VALID(dlgLst->m_cls) ? &dlgLst->m_cls - : &g_CLR_RT_WellKnownTypes.m_MulticastDelegate; + cls = + NANOCLR_INDEX_IS_VALID(dlgLst->m_cls) ? &dlgLst->m_cls : &g_CLR_RT_WellKnownTypes.MulticastDelegate; } break; @@ -1151,7 +1795,7 @@ HRESULT CLR_RT_TypeDescriptor::InitializeFromObject(const CLR_RT_HeapBlock &ref) case DATATYPE_WEAKCLASS: { - cls = &g_CLR_RT_WellKnownTypes.m_WeakReference; + cls = &g_CLR_RT_WellKnownTypes.WeakReference; } break; @@ -1160,25 +1804,25 @@ HRESULT CLR_RT_TypeDescriptor::InitializeFromObject(const CLR_RT_HeapBlock &ref) case DATATYPE_REFLECTION: reflex = &(obj->ReflectionDataConst()); - switch (reflex->m_kind) + switch (reflex->kind) { case REFLECTION_ASSEMBLY: - cls = &g_CLR_RT_WellKnownTypes.m_Assembly; + cls = &g_CLR_RT_WellKnownTypes.Assembly; break; case REFLECTION_TYPE: - cls = &g_CLR_RT_WellKnownTypes.m_Type; + cls = &g_CLR_RT_WellKnownTypes.Type; break; case REFLECTION_TYPE_DELAYED: - cls = &g_CLR_RT_WellKnownTypes.m_Type; + cls = &g_CLR_RT_WellKnownTypes.Type; break; case REFLECTION_CONSTRUCTOR: - cls = &g_CLR_RT_WellKnownTypes.m_ConstructorInfo; + cls = &g_CLR_RT_WellKnownTypes.ConstructorInfo; break; case REFLECTION_METHOD: - cls = &g_CLR_RT_WellKnownTypes.m_MethodInfo; + cls = &g_CLR_RT_WellKnownTypes.MethodInfo; break; case REFLECTION_FIELD: - cls = &g_CLR_RT_WellKnownTypes.m_FieldInfo; + cls = &g_CLR_RT_WellKnownTypes.FieldInfo; break; } @@ -1199,10 +1843,14 @@ HRESULT CLR_RT_TypeDescriptor::InitializeFromObject(const CLR_RT_HeapBlock &ref) } reflex = &array->ReflectionDataConst(); - cls = &reflex->m_data.m_type; + cls = &reflex->data.type; } break; + case DATATYPE_GENERICINST: + genericType = &obj->ObjectGenericType(); + break; + //--// default: @@ -1219,6 +1867,11 @@ HRESULT CLR_RT_TypeDescriptor::InitializeFromObject(const CLR_RT_HeapBlock &ref) m_reflex = *reflex; } + if (genericType) + { + NANOCLR_CHECK_HRESULT(InitializeFromGenericType(*genericType)); + } + if (dt == DATATYPE_SZARRAY) { ConvertToArray(); @@ -1236,7 +1889,7 @@ void CLR_RT_TypeDescriptor::ConvertToArray() m_flags &= CLR_RT_DataTypeLookup::c_SemanticMask; m_flags |= CLR_RT_DataTypeLookup::c_Array; - m_handlerCls.InitializeFromIndex(g_CLR_RT_WellKnownTypes.m_Array); + m_handlerCls.InitializeFromIndex(g_CLR_RT_WellKnownTypes.Array); } bool CLR_RT_TypeDescriptor::ShouldEmitHash() @@ -1253,7 +1906,7 @@ bool CLR_RT_TypeDescriptor::ShouldEmitHash() return false; } - if (m_handlerCls.CrossReference().m_hash != 0) + if (m_handlerCls.CrossReference().hash != 0) { return true; } @@ -1264,18 +1917,18 @@ bool CLR_RT_TypeDescriptor::ShouldEmitHash() bool CLR_RT_TypeDescriptor::GetElementType(CLR_RT_TypeDescriptor &sub) { NATIVE_PROFILE_CLR_CORE(); - switch (m_reflex.m_levels) + switch (m_reflex.levels) { case 0: return false; case 1: - sub.InitializeFromType(m_reflex.m_data.m_type); + sub.InitializeFromType(m_reflex.data.type); break; default: sub = *this; - sub.m_reflex.m_levels--; + sub.m_reflex.levels--; break; } @@ -1284,7 +1937,7 @@ bool CLR_RT_TypeDescriptor::GetElementType(CLR_RT_TypeDescriptor &sub) //////////////////////////////////////// -HRESULT CLR_RT_TypeDescriptor::ExtractObjectAndDataType(CLR_RT_HeapBlock *&ref, CLR_DataType &dt) +HRESULT CLR_RT_TypeDescriptor::ExtractObjectAndDataType(CLR_RT_HeapBlock *&ref, NanoCLRDataType &dt) { NATIVE_PROFILE_CLR_CORE(); @@ -1292,7 +1945,7 @@ HRESULT CLR_RT_TypeDescriptor::ExtractObjectAndDataType(CLR_RT_HeapBlock *&ref, while (true) { - dt = (CLR_DataType)ref->DataType(); + dt = (NanoCLRDataType)ref->DataType(); if (dt == DATATYPE_BYREF || dt == DATATYPE_OBJECT) { @@ -1314,8 +1967,8 @@ HRESULT CLR_RT_TypeDescriptor::ExtractTypeIndexFromObject(const CLR_RT_HeapBlock NANOCLR_HEADER(); - CLR_RT_HeapBlock *obj = (CLR_RT_HeapBlock *)&ref; - CLR_DataType dt; + auto *obj = (CLR_RT_HeapBlock *)&ref; + NanoCLRDataType dt; NANOCLR_CHECK_HRESULT(CLR_RT_TypeDescriptor::ExtractObjectAndDataType(obj, dt)); @@ -1343,8 +1996,17 @@ HRESULT CLR_RT_TypeDescriptor::ExtractTypeIndexFromObject(const CLR_RT_HeapBlock NANOCLR_CHECK_HRESULT(desc.InitializeFromObject(ref)) - // If desc.InitializeFromObject( ref ) call succeded, then we use m_handlerCls for res - res = desc.m_handlerCls; + // If desc.InitializeFromObject( ref ) call succeed, then we need to find out what to call + + if (desc.GetDataType() == DATATYPE_GENERICINST) + { + res.Set(desc.m_handlerGenericType.Assembly(), desc.m_handlerGenericType.typeDefIndex); + } + else + { + // use m_handlerCls for res + res = desc.m_handlerCls; + } if (NANOCLR_INDEX_IS_INVALID(res)) { @@ -1359,19 +2021,21 @@ HRESULT CLR_RT_TypeDescriptor::ExtractTypeIndexFromObject(const CLR_RT_HeapBlock /////////////////////////////////////////////////////////////////////////////////////////////////// -// -// Keep this string less than 8-character long (including terminator) because it's stuffed into an 8-byte structure. -// -static const char c_MARKER_ASSEMBLY_V1[] = "NFMRK1"; +// Keep these strings less than 8-character long (including terminator) because it's stuffed into an 8-byte structure. +// static const char c_MARKER_ASSEMBLY_V1[] = "NFMRK1"; +static const char c_MARKER_ASSEMBLY_V2[] = "NFMRK2"; bool CLR_RECORD_ASSEMBLY::ValidateMarker() const { NATIVE_PROFILE_CLR_CORE(); // compare the marker - return memcmp(marker, c_MARKER_ASSEMBLY_V1, sizeof(c_MARKER_ASSEMBLY_V1)) == 0; + return memcmp(marker, c_MARKER_ASSEMBLY_V2, sizeof(c_MARKER_ASSEMBLY_V2)) == 0; } +/// @brief Check for valid assembly header (CRC32 of header, string table version and marker) +/// +/// @return Check result bool CLR_RECORD_ASSEMBLY::GoodHeader() const { NATIVE_PROFILE_CLR_CORE(); @@ -1380,7 +2044,6 @@ bool CLR_RECORD_ASSEMBLY::GoodHeader() const if (SUPPORT_ComputeCRC(&header, sizeof(header), 0) != this->headerCRC) { - // check for a wrong version of the marker return false; } @@ -1392,11 +2055,17 @@ bool CLR_RECORD_ASSEMBLY::GoodHeader() const return ValidateMarker(); } +/// @brief Check for valid assembly (header and CRC32 of assembly content) +/// +/// @return bool Check result bool CLR_RECORD_ASSEMBLY::GoodAssembly() const { NATIVE_PROFILE_CLR_CORE(); if (!GoodHeader()) + { return false; + } + return SUPPORT_ComputeCRC(&this[1], this->TotalSize() - sizeof(*this), 0) == this->assemblyCRC; } @@ -1405,7 +2074,7 @@ bool CLR_RECORD_ASSEMBLY::GoodAssembly() const void CLR_RECORD_ASSEMBLY::ComputeCRC() { NATIVE_PROFILE_CLR_CORE(); - memcpy(marker, c_MARKER_ASSEMBLY_V1, sizeof(marker)); + memcpy(marker, c_MARKER_ASSEMBLY_V2, sizeof(c_MARKER_ASSEMBLY_V2)); headerCRC = 0; assemblyCRC = SUPPORT_ComputeCRC(&this[1], this->TotalSize() - sizeof(*this), 0); @@ -1442,14 +2111,8 @@ CLR_PMETADATA CLR_RECORD_EH::ExtractEhFromByteCode(CLR_PMETADATA ipEnd, const CL CLR_UINT32 CLR_RECORD_EH::GetToken() const { NATIVE_PROFILE_CLR_CORE(); - if (classToken & 0x8000) - { - return CLR_TkFromType(TBL_TypeRef, classToken & 0x7FFF); - } - else - { - return CLR_TkFromType(TBL_TypeDef, classToken); - } + + return CLR_UncompressTypeToken(classToken); } //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -1474,13 +2137,13 @@ bool CLR_RT_ExceptionHandler::ConvertFromEH( break; case CLR_RECORD_EH::EH_CatchAll: - m_typeFilter = g_CLR_RT_WellKnownTypes.m_Object; + m_typeFilter = g_CLR_RT_WellKnownTypes.Object; break; case CLR_RECORD_EH::EH_Catch: { CLR_RT_TypeDef_Instance cls{}; - if (cls.ResolveToken(eh.GetToken(), owner.m_assm) == false) + if (cls.ResolveToken(eh.GetToken(), owner.assembly) == false) return false; m_typeFilter = cls; } @@ -1490,7 +2153,7 @@ bool CLR_RT_ExceptionHandler::ConvertFromEH( return false; } - if (owner.m_target->RVA == CLR_EmptyIndex) + if (owner.target->rva == CLR_EmptyIndex) return false; m_ehType = eh.mode; @@ -1506,7 +2169,7 @@ bool CLR_RT_ExceptionHandler::ConvertFromEH( bool CLR_RT_Assembly::IsSameAssembly(const CLR_RT_Assembly &assm) const { - if (m_header->headerCRC == assm.m_header->headerCRC && m_header->assemblyCRC == assm.m_header->assemblyCRC) + if (header->headerCRC == assm.header->headerCRC && header->assemblyCRC == assm.header->assemblyCRC) { return true; } @@ -1514,69 +2177,108 @@ bool CLR_RT_Assembly::IsSameAssembly(const CLR_RT_Assembly &assm) const return false; } -void CLR_RT_Assembly::Assembly_Initialize(CLR_RT_Assembly::Offsets &offsets) +void CLR_RT_Assembly::AssemblyInitialize(CLR_RT_Assembly::Offsets &offsets) { NATIVE_PROFILE_CLR_CORE(); - CLR_UINT8 *buffer = (CLR_UINT8 *)this; + auto *buffer = (CLR_UINT8 *)this; int i; - m_szName = GetString(m_header->assemblyName); + name = GetString(header->assemblyName); //--// - buffer += offsets.iBase; - m_pCrossReference_AssemblyRef = (CLR_RT_AssemblyRef_CrossReference *)buffer; - buffer += offsets.iAssemblyRef; - m_pCrossReference_TypeRef = (CLR_RT_TypeRef_CrossReference *)buffer; - buffer += offsets.iTypeRef; - m_pCrossReference_FieldRef = (CLR_RT_FieldRef_CrossReference *)buffer; - buffer += offsets.iFieldRef; - m_pCrossReference_MethodRef = (CLR_RT_MethodRef_CrossReference *)buffer; - buffer += offsets.iMethodRef; - m_pCrossReference_TypeDef = (CLR_RT_TypeDef_CrossReference *)buffer; - buffer += offsets.iTypeDef; - m_pCrossReference_FieldDef = (CLR_RT_FieldDef_CrossReference *)buffer; - buffer += offsets.iFieldDef; - m_pCrossReference_MethodDef = (CLR_RT_MethodDef_CrossReference *)buffer; - buffer += offsets.iMethodDef; + buffer += offsets.base; + crossReferenceAssemblyRef = (CLR_RT_AssemblyRef_CrossReference *)buffer; + buffer += offsets.assemblyRef; + crossReferenceTypeRef = (CLR_RT_TypeRef_CrossReference *)buffer; + buffer += offsets.typeRef; + crossReferenceFieldRef = (CLR_RT_FieldRef_CrossReference *)buffer; + buffer += offsets.fieldRef; + crossReferenceMethodRef = (CLR_RT_MethodRef_CrossReference *)buffer; + buffer += offsets.methodRef; + crossReferenceTypeDef = (CLR_RT_TypeDef_CrossReference *)buffer; + buffer += offsets.typeDef; + crossReferenceFieldDef = (CLR_RT_FieldDef_CrossReference *)buffer; + buffer += offsets.fieldDef; + crossReferenceMethodDef = (CLR_RT_MethodDef_CrossReference *)buffer; + buffer += offsets.methodDef; + crossReferenceGenericParam = (CLR_RT_GenericParam_CrossReference *)buffer; + buffer += offsets.genericParam; + crossReferenceMethodSpec = (CLR_RT_MethodSpec_CrossReference *)buffer; + buffer += offsets.methodSpec; + crossReferenceTypeSpec = (CLR_RT_TypeSpec_CrossReference *)buffer; + buffer += offsets.typeSpec; #if !defined(NANOCLR_APPDOMAINS) - m_pStaticFields = (CLR_RT_HeapBlock *)buffer; - buffer += offsets.iStaticFields; + staticFields = (CLR_RT_HeapBlock *)buffer; + buffer += offsets.staticFieldsCount; - memset(m_pStaticFields, 0, offsets.iStaticFields); + memset(staticFields, 0, offsets.staticFieldsCount); #endif //--// { - ITERATE_THROUGH_RECORDS(this, i, TypeDef, TYPEDEF) + const auto *src = (const CLR_RECORD_TYPEDEF *)this->GetTable(TBL_TypeDef); + CLR_RT_TypeDef_CrossReference *dst = this->crossReferenceTypeDef; + for (i = 0; i < this->tablesSize[TBL_TypeDef]; i++, src++, dst++) + { + dst->flags = 0; + dst->totalFields = 0; + dst->hash = 0; + } + } + + { + auto *src = (const CLR_RECORD_FIELDDEF *)this->GetTable(TBL_FieldDef); + CLR_RT_FieldDef_CrossReference *dst = this->crossReferenceFieldDef; + for (i = 0; i < this->tablesSize[TBL_FieldDef]; i++, src++, dst++) + { + dst->offset = CLR_EmptyIndex; + } + } + + { + auto *src = (const CLR_RECORD_METHODDEF *)this->GetTable(TBL_MethodDef); + CLR_RT_MethodDef_CrossReference *dst = this->crossReferenceMethodDef; + for (i = 0; i < this->tablesSize[TBL_MethodDef]; i++, src++, dst++) + { + dst->data = CLR_EmptyIndex; + } + } + + { + auto *src = (const CLR_RECORD_GENERICPARAM *)this->GetTable(TBL_GenericParam); + CLR_RT_GenericParam_CrossReference *dst = this->crossReferenceGenericParam; + for (i = 0; i < this->tablesSize[TBL_GenericParam]; i++, src++, dst++) { - dst->m_flags = 0; - dst->m_totalFields = 0; - dst->m_hash = 0; + dst->data = CLR_EmptyIndex; } } { - ITERATE_THROUGH_RECORDS(this, i, FieldDef, FIELDDEF) + auto *src = (const CLR_RECORD_METHODSPEC *)this->GetTable(TBL_MethodSpec); + CLR_RT_MethodSpec_CrossReference *dst = this->crossReferenceMethodSpec; + for (i = 0; i < this->tablesSize[TBL_MethodSpec]; i++, src++, dst++) { - dst->m_offset = CLR_EmptyIndex; + dst->data = CLR_EmptyIndex; } } { - ITERATE_THROUGH_RECORDS(this, i, MethodDef, METHODDEF) + auto *src = (const CLR_RECORD_TYPESPEC *)this->GetTable(TBL_TypeSpec); + CLR_RT_TypeSpec_CrossReference *dst = this->crossReferenceTypeSpec; + for (i = 0; i < this->tablesSize[TBL_TypeSpec]; i++, src++, dst++) { - dst->m_data = CLR_EmptyIndex; + dst->genericType.data = 0; } } #if defined(NANOCLR_ENABLE_SOURCELEVELDEBUGGING) { - m_pDebuggingInfo_MethodDef = (CLR_RT_MethodDef_DebuggingInfo *)buffer; - buffer += offsets.iDebuggingInfoMethods; + debuggingInfoMethodDef = (CLR_RT_MethodDef_DebuggingInfo *)buffer; + buffer += offsets.debuggingInfoMethods; - memset(m_pDebuggingInfo_MethodDef, 0, offsets.iDebuggingInfoMethods); + memset(debuggingInfoMethodDef, 0, offsets.debuggingInfoMethods); } #endif // #if defined(NANOCLR_ENABLE_SOURCELEVELDEBUGGING) } @@ -1590,48 +2292,48 @@ HRESULT CLR_RT_Assembly::CreateInstance(const CLR_RECORD_ASSEMBLY *header, CLR_R NANOCLR_HEADER(); CLR_UINT8 buf[sizeof(CLR_RT_Assembly)]; - CLR_RT_Assembly *skeleton = (CLR_RT_Assembly *)buf; + auto *skeleton = (CLR_RT_Assembly *)buf; NANOCLR_CLEAR(*skeleton); if (header->GoodAssembly() == false) + { NANOCLR_MSG_SET_AND_LEAVE(CLR_E_FAIL, L"Failed in type system: assembly is not good.\n"); + } - skeleton->m_header = header; + skeleton->header = header; - // // Compute overall size for assembly data structure. - // { - for (uint32_t i = 0; i < ARRAYSIZE(skeleton->m_pTablesSize) - 1; i++) + for (uint32_t i = 0; i < ARRAYSIZE(skeleton->tablesSize) - 1; i++) { - skeleton->m_pTablesSize[i] = header->SizeOfTable((CLR_TABLESENUM)i); + skeleton->tablesSize[i] = header->SizeOfTable((NanoCLRTable)i); } - skeleton->m_pTablesSize[TBL_AssemblyRef] /= sizeof(CLR_RECORD_ASSEMBLYREF); - skeleton->m_pTablesSize[TBL_TypeRef] /= sizeof(CLR_RECORD_TYPEREF); - skeleton->m_pTablesSize[TBL_FieldRef] /= sizeof(CLR_RECORD_FIELDREF); - skeleton->m_pTablesSize[TBL_MethodRef] /= sizeof(CLR_RECORD_METHODREF); - skeleton->m_pTablesSize[TBL_TypeDef] /= sizeof(CLR_RECORD_TYPEDEF); - skeleton->m_pTablesSize[TBL_FieldDef] /= sizeof(CLR_RECORD_FIELDDEF); - skeleton->m_pTablesSize[TBL_MethodDef] /= sizeof(CLR_RECORD_METHODDEF); - skeleton->m_pTablesSize[TBL_Attributes] /= sizeof(CLR_RECORD_ATTRIBUTE); - skeleton->m_pTablesSize[TBL_TypeSpec] /= sizeof(CLR_RECORD_TYPESPEC); - skeleton->m_pTablesSize[TBL_Resources] /= sizeof(CLR_RECORD_RESOURCE); - skeleton->m_pTablesSize[TBL_ResourcesFiles] /= sizeof(CLR_RECORD_RESOURCE_FILE); + skeleton->tablesSize[TBL_AssemblyRef] /= sizeof(CLR_RECORD_ASSEMBLYREF); + skeleton->tablesSize[TBL_TypeRef] /= sizeof(CLR_RECORD_TYPEREF); + skeleton->tablesSize[TBL_FieldRef] /= sizeof(CLR_RECORD_FIELDREF); + skeleton->tablesSize[TBL_MethodRef] /= sizeof(CLR_RECORD_METHODREF); + skeleton->tablesSize[TBL_TypeDef] /= sizeof(CLR_RECORD_TYPEDEF); + skeleton->tablesSize[TBL_FieldDef] /= sizeof(CLR_RECORD_FIELDDEF); + skeleton->tablesSize[TBL_MethodDef] /= sizeof(CLR_RECORD_METHODDEF); + skeleton->tablesSize[TBL_GenericParam] /= sizeof(CLR_RECORD_GENERICPARAM); + skeleton->tablesSize[TBL_MethodSpec] /= sizeof(CLR_RECORD_METHODSPEC); + skeleton->tablesSize[TBL_TypeSpec] /= sizeof(CLR_RECORD_TYPESPEC); + skeleton->tablesSize[TBL_Attributes] /= sizeof(CLR_RECORD_ATTRIBUTE); + skeleton->tablesSize[TBL_Resources] /= sizeof(CLR_RECORD_RESOURCE); + skeleton->tablesSize[TBL_ResourcesFiles] /= sizeof(CLR_RECORD_RESOURCE_FILE); } //--// - // // Count static fields. - // { - const CLR_RECORD_TYPEDEF *src = (const CLR_RECORD_TYPEDEF *)skeleton->GetTable(TBL_TypeDef); + auto *src = (const CLR_RECORD_TYPEDEF *)skeleton->GetTable(TBL_TypeDef); - for (int i = 0; i < skeleton->m_pTablesSize[TBL_TypeDef]; i++, src++) + for (int i = 0; i < skeleton->tablesSize[TBL_TypeDef]; i++, src++) { - skeleton->m_iStaticFields += src->sFields_Num; + skeleton->staticFieldsCount += src->staticFieldsCount; } } @@ -1640,50 +2342,60 @@ HRESULT CLR_RT_Assembly::CreateInstance(const CLR_RECORD_ASSEMBLY *header, CLR_R { CLR_RT_Assembly::Offsets offsets; - offsets.iBase = ROUNDTOMULTIPLE(sizeof(CLR_RT_Assembly), CLR_UINT32); - offsets.iAssemblyRef = ROUNDTOMULTIPLE( - skeleton->m_pTablesSize[TBL_AssemblyRef] * sizeof(CLR_RT_AssemblyRef_CrossReference), + offsets.base = ROUNDTOMULTIPLE(sizeof(CLR_RT_Assembly), CLR_UINT32); + + offsets.assemblyRef = ROUNDTOMULTIPLE( + skeleton->tablesSize[TBL_AssemblyRef] * sizeof(CLR_RT_AssemblyRef_CrossReference), CLR_UINT32); - offsets.iTypeRef = - ROUNDTOMULTIPLE(skeleton->m_pTablesSize[TBL_TypeRef] * sizeof(CLR_RT_TypeRef_CrossReference), CLR_UINT32); - offsets.iFieldRef = - ROUNDTOMULTIPLE(skeleton->m_pTablesSize[TBL_FieldRef] * sizeof(CLR_RT_FieldRef_CrossReference), CLR_UINT32); - offsets.iMethodRef = ROUNDTOMULTIPLE( - skeleton->m_pTablesSize[TBL_MethodRef] * sizeof(CLR_RT_MethodRef_CrossReference), + + offsets.typeRef = + ROUNDTOMULTIPLE(skeleton->tablesSize[TBL_TypeRef] * sizeof(CLR_RT_TypeRef_CrossReference), CLR_UINT32); + + offsets.fieldRef = + ROUNDTOMULTIPLE(skeleton->tablesSize[TBL_FieldRef] * sizeof(CLR_RT_FieldRef_CrossReference), CLR_UINT32); + + offsets.methodRef = + ROUNDTOMULTIPLE(skeleton->tablesSize[TBL_MethodRef] * sizeof(CLR_RT_MethodRef_CrossReference), CLR_UINT32); + + offsets.typeDef = + ROUNDTOMULTIPLE(skeleton->tablesSize[TBL_TypeDef] * sizeof(CLR_RT_TypeDef_CrossReference), CLR_UINT32); + + offsets.fieldDef = + ROUNDTOMULTIPLE(skeleton->tablesSize[TBL_FieldDef] * sizeof(CLR_RT_FieldDef_CrossReference), CLR_UINT32); + + offsets.methodDef = + ROUNDTOMULTIPLE(skeleton->tablesSize[TBL_MethodDef] * sizeof(CLR_RT_MethodDef_CrossReference), CLR_UINT32); + + offsets.genericParam = ROUNDTOMULTIPLE( + skeleton->tablesSize[TBL_GenericParam] * sizeof(CLR_RT_GenericParam_CrossReference), CLR_UINT32); - offsets.iTypeDef = - ROUNDTOMULTIPLE(skeleton->m_pTablesSize[TBL_TypeDef] * sizeof(CLR_RT_TypeDef_CrossReference), CLR_UINT32); - offsets.iFieldDef = - ROUNDTOMULTIPLE(skeleton->m_pTablesSize[TBL_FieldDef] * sizeof(CLR_RT_FieldDef_CrossReference), CLR_UINT32); - offsets.iMethodDef = ROUNDTOMULTIPLE( - skeleton->m_pTablesSize[TBL_MethodDef] * sizeof(CLR_RT_MethodDef_CrossReference), + + offsets.methodSpec = ROUNDTOMULTIPLE( + skeleton->tablesSize[TBL_MethodSpec] * sizeof(CLR_RT_MethodSpec_CrossReference), CLR_UINT32); - if (skeleton->m_header->numOfPatchedMethods > 0) - { - NANOCLR_SET_AND_LEAVE(CLR_E_ASSM_PATCHING_NOT_SUPPORTED); - } + offsets.typeSpec = + ROUNDTOMULTIPLE(skeleton->tablesSize[TBL_TypeSpec] * sizeof(CLR_RT_TypeSpec_CrossReference), CLR_UINT32); #if !defined(NANOCLR_APPDOMAINS) - offsets.iStaticFields = - ROUNDTOMULTIPLE(skeleton->m_iStaticFields * sizeof(struct CLR_RT_HeapBlock), CLR_UINT32); + offsets.staticFieldsCount = ROUNDTOMULTIPLE(skeleton->staticFieldsCount * sizeof(CLR_RT_HeapBlock), CLR_UINT32); #endif #if defined(NANOCLR_ENABLE_SOURCELEVELDEBUGGING) - offsets.iDebuggingInfoMethods = ROUNDTOMULTIPLE( - skeleton->m_pTablesSize[TBL_MethodDef] * sizeof(CLR_RT_MethodDef_DebuggingInfo), - CLR_UINT32); + offsets.debuggingInfoMethods = + ROUNDTOMULTIPLE(skeleton->tablesSize[TBL_MethodDef] * sizeof(CLR_RT_MethodDef_DebuggingInfo), CLR_UINT32); #endif // #if defined(NANOCLR_ENABLE_SOURCELEVELDEBUGGING) - size_t iTotalRamSize = offsets.iBase + offsets.iAssemblyRef + offsets.iTypeRef + offsets.iFieldRef + - offsets.iMethodRef + offsets.iTypeDef + offsets.iFieldDef + offsets.iMethodDef; + size_t iTotalRamSize = offsets.base + offsets.assemblyRef + offsets.typeRef + offsets.fieldRef + + offsets.methodRef + offsets.typeDef + offsets.fieldDef + offsets.methodDef + + offsets.genericParam + offsets.methodSpec + offsets.typeSpec; #if !defined(NANOCLR_APPDOMAINS) - iTotalRamSize += offsets.iStaticFields; + iTotalRamSize += offsets.staticFieldsCount; #endif #if defined(NANOCLR_ENABLE_SOURCELEVELDEBUGGING) - iTotalRamSize += offsets.iDebuggingInfoMethods; + iTotalRamSize += offsets.debuggingInfoMethods; #endif // #if defined(NANOCLR_ENABLE_SOURCELEVELDEBUGGING) //--// @@ -1707,24 +2419,25 @@ HRESULT CLR_RT_Assembly::CreateInstance(const CLR_RECORD_ASSEMBLY *header, CLR_R memcpy(&dst[1], &src[1], sizeof(*assm) - sizeof(struct CLR_RT_HeapBlock)); } - assm->Assembly_Initialize(offsets); + assm->AssemblyInitialize(offsets); #if !defined(BUILD_RTM) CLR_Debug::Printf( " Assembly: %s (%d.%d.%d.%d) ", - assm->m_szName, - header->version.iMajorVersion, - header->version.iMinorVersion, - header->version.iBuildNumber, - header->version.iRevisionNumber); + assm->name, + header->version.majorVersion, + header->version.minorVersion, + header->version.buildNumber, + header->version.revisionNumber); if (s_CLR_RT_fTrace_AssemblyOverhead >= c_CLR_RT_Trace_Info) { size_t iMetaData = header->SizeOfTable(TBL_AssemblyRef) + header->SizeOfTable(TBL_TypeRef) + header->SizeOfTable(TBL_FieldRef) + header->SizeOfTable(TBL_MethodRef) + header->SizeOfTable(TBL_TypeDef) + header->SizeOfTable(TBL_FieldDef) + - header->SizeOfTable(TBL_MethodDef) + header->SizeOfTable(TBL_Attributes) + - header->SizeOfTable(TBL_TypeSpec) + header->SizeOfTable(TBL_Signatures); + header->SizeOfTable(TBL_MethodDef) + header->SizeOfTable(TBL_GenericParam) + + header->SizeOfTable(TBL_MethodSpec) + header->SizeOfTable(TBL_TypeSpec) + + header->SizeOfTable(TBL_Attributes) + header->SizeOfTable(TBL_Signatures); CLR_Debug::Printf(" (%d RAM - %d ROM - %d METADATA)", iTotalRamSize, header->TotalSize(), iMetaData); @@ -1741,62 +2454,86 @@ HRESULT CLR_RT_Assembly::CreateInstance(const CLR_RECORD_ASSEMBLY *header, CLR_R #endif CLR_Debug::Printf("\r\n\r\n"); + CLR_Debug::Printf(" (%d RAM - %d ROM - %d METADATA)", iTotalRamSize, header->TotalSize(), iMetaData); + +#if defined(NANOCLR_GC_VERBOSE) + if (s_CLR_RT_fTrace_Memory >= c_CLR_RT_Trace_Info) + { +#ifdef _WIN64 + + CLR_Debug::Printf(" @ 0x%016" PRIxPTR "", (uintptr_t)assm); +#else + CLR_Debug::Printf(" @ 0x%08 PRIxPTR ", (uintptr_t)assm); +#endif + } +#endif + CLR_Debug::Printf("\r\n\r\n"); + CLR_Debug::Printf( - " AssemblyRef = %8d bytes (%8d elements)\r\n", - offsets.iAssemblyRef, - skeleton->m_pTablesSize[TBL_AssemblyRef]); + " AssemblyRef = %6d bytes (%5d elements)\r\n", + offsets.assemblyRef, + skeleton->tablesSize[TBL_AssemblyRef]); CLR_Debug::Printf( - " TypeRef = %8d bytes (%8d elements)\r\n", - offsets.iTypeRef, - skeleton->m_pTablesSize[TBL_TypeRef]); + " TypeRef = %6d bytes (%5d elements)\r\n", + offsets.typeRef, + skeleton->tablesSize[TBL_TypeRef]); CLR_Debug::Printf( - " FieldRef = %8d bytes (%8d elements)\r\n", - offsets.iFieldRef, - skeleton->m_pTablesSize[TBL_FieldRef]); + " FieldRef = %6d bytes (%5d elements)\r\n", + offsets.fieldRef, + skeleton->tablesSize[TBL_FieldRef]); CLR_Debug::Printf( - " MethodRef = %8d bytes (%8d elements)\r\n", - offsets.iMethodRef, - skeleton->m_pTablesSize[TBL_MethodRef]); + " MethodRef = %6d bytes (%5d elements)\r\n", + offsets.methodRef, + skeleton->tablesSize[TBL_MethodRef]); CLR_Debug::Printf( - " TypeDef = %8d bytes (%8d elements)\r\n", - offsets.iTypeDef, - skeleton->m_pTablesSize[TBL_TypeDef]); + " TypeDef = %6d bytes (%5d elements)\r\n", + offsets.typeDef, + skeleton->tablesSize[TBL_TypeDef]); CLR_Debug::Printf( - " FieldDef = %8d bytes (%8d elements)\r\n", - offsets.iFieldDef, - skeleton->m_pTablesSize[TBL_FieldDef]); + " FieldDef = %6d bytes (%5d elements)\r\n", + offsets.fieldDef, + skeleton->tablesSize[TBL_FieldDef]); CLR_Debug::Printf( - " MethodDef = %8d bytes (%8d elements)\r\n", - offsets.iMethodDef, - skeleton->m_pTablesSize[TBL_MethodDef]); + " MethodDef = %6d bytes (%5d elements)\r\n", + offsets.methodDef, + skeleton->tablesSize[TBL_MethodDef]); + CLR_Debug::Printf( + " GenericParam = %6d bytes (%5d elements)\r\n", + offsets.genericParam, + skeleton->tablesSize[TBL_GenericParam]); + CLR_Debug::Printf( + " MethodSpec = %6d bytes (%5d elements)\r\n", + offsets.methodSpec, + skeleton->tablesSize[TBL_MethodSpec]); + #if !defined(NANOCLR_APPDOMAINS) CLR_Debug::Printf( - " StaticFields = %8d bytes (%8d elements)\r\n", - offsets.iStaticFields, - skeleton->m_iStaticFields); + " StaticFields = %6d bytes (%5d elements)\r\n", + offsets.staticFieldsCount, + skeleton->staticFieldsCount); #endif CLR_Debug::Printf("\r\n"); CLR_Debug::Printf( - " Attributes = %8d bytes (%8d elements)\r\n", - skeleton->m_pTablesSize[TBL_Attributes] * sizeof(CLR_RECORD_ATTRIBUTE), - skeleton->m_pTablesSize[TBL_Attributes]); + " Attributes = %6d bytes (%5d elements)\r\n", + skeleton->tablesSize[TBL_Attributes] * sizeof(CLR_RECORD_ATTRIBUTE), + skeleton->tablesSize[TBL_Attributes]); CLR_Debug::Printf( - " TypeSpec = %8d bytes (%8d elements)\r\n", - skeleton->m_pTablesSize[TBL_TypeSpec] * sizeof(CLR_RECORD_TYPESPEC), - skeleton->m_pTablesSize[TBL_TypeSpec]); + " TypeSpec = %6d bytes (%5d elements)\r\n", + skeleton->tablesSize[TBL_TypeSpec] * sizeof(CLR_RECORD_TYPESPEC), + skeleton->tablesSize[TBL_TypeSpec]); CLR_Debug::Printf( - " Resources = %8d bytes (%8d elements)\r\n", - skeleton->m_pTablesSize[TBL_Resources] * sizeof(CLR_RECORD_RESOURCE), - skeleton->m_pTablesSize[TBL_Resources]); + " Resources = %6d bytes (%5d elements)\r\n", + skeleton->tablesSize[TBL_Resources] * sizeof(CLR_RECORD_RESOURCE), + skeleton->tablesSize[TBL_Resources]); CLR_Debug::Printf( - " Resources Files = %8d bytes (%8d elements)\r\n", - skeleton->m_pTablesSize[TBL_ResourcesFiles] * sizeof(CLR_RECORD_RESOURCE), - skeleton->m_pTablesSize[TBL_ResourcesFiles]); - CLR_Debug::Printf(" Resources Data = %8d bytes\r\n", skeleton->m_pTablesSize[TBL_ResourcesData]); - CLR_Debug::Printf(" Strings = %8d bytes\r\n", skeleton->m_pTablesSize[TBL_Strings]); - CLR_Debug::Printf(" Signatures = %8d bytes\r\n", skeleton->m_pTablesSize[TBL_Signatures]); - CLR_Debug::Printf(" ByteCode = %8d bytes\r\n", skeleton->m_pTablesSize[TBL_ByteCode]); + " Resources Files = %6d bytes (%5d elements)\r\n", + skeleton->tablesSize[TBL_ResourcesFiles] * sizeof(CLR_RECORD_RESOURCE), + skeleton->tablesSize[TBL_ResourcesFiles]); + CLR_Debug::Printf(" Resources Data = %6d bytes\r\n", skeleton->tablesSize[TBL_ResourcesData]); + CLR_Debug::Printf(" Strings = %6d bytes\r\n", skeleton->tablesSize[TBL_Strings]); + CLR_Debug::Printf(" Signatures = %6d bytes\r\n", skeleton->tablesSize[TBL_Signatures]); + CLR_Debug::Printf(" ByteCode = %6d bytes\r\n", skeleton->tablesSize[TBL_ByteCode]); CLR_Debug::Printf("\r\n\r\n"); } #endif @@ -1818,18 +2555,18 @@ HRESULT CLR_RT_Assembly::CreateInstance( NANOCLR_CHECK_HRESULT(CLR_RT_Assembly::CreateInstance(header, assm)); - if (szName != NULL) + if (szName != nullptr) { CLR_RT_UnicodeHelper::ConvertToUTF8(szName, strPath); - assm->m_strPath = new std::string(strPath); + assm->path = new std::string(strPath); } NANOCLR_NOCLEANUP(); } #endif -bool CLR_RT_Assembly::Resolve_AssemblyRef(bool fOutput) +bool CLR_RT_Assembly::ResolveAssemblyRef(bool fOutput) { #ifdef BUILD_RTM (void)fOutput; @@ -1843,30 +2580,30 @@ bool CLR_RT_Assembly::Resolve_AssemblyRef(bool fOutput) { const char *szName = GetString(src->name); - if (dst->m_target == NULL) + if (dst->target == nullptr) { CLR_RT_Assembly *target = g_CLR_RT_TypeSystem.FindAssembly(szName, &src->version, false); - if (target == NULL || (target->m_flags & CLR_RT_Assembly::Resolved) == 0) + if (target == nullptr || (target->flags & CLR_RT_Assembly::Resolved) == 0) { #if !defined(BUILD_RTM) if (fOutput) { CLR_Debug::Printf( "Assembly: %s (%d.%d.%d.%d)", - m_szName, - m_header->version.iMajorVersion, - m_header->version.iMinorVersion, - m_header->version.iBuildNumber, - m_header->version.iRevisionNumber); + name, + header->version.majorVersion, + header->version.minorVersion, + header->version.buildNumber, + header->version.revisionNumber); CLR_Debug::Printf( " needs assembly '%s' (%d.%d.%d.%d)\r\n", szName, - src->version.iMajorVersion, - src->version.iMinorVersion, - src->version.iBuildNumber, - src->version.iRevisionNumber); + src->version.majorVersion, + src->version.minorVersion, + src->version.buildNumber, + src->version.revisionNumber); } #endif @@ -1874,7 +2611,18 @@ bool CLR_RT_Assembly::Resolve_AssemblyRef(bool fOutput) } else { - dst->m_target = target; + dst->target = target; + +#ifdef NANOCLR_TRACE_TYPE_RESOLUTION + CLR_Debug::Printf( + "\r\nResolved assembly: %s (%d.%d.%d.%d) [%04X]\r\n", + name, + header->version.majorVersion, + header->version.minorVersion, + header->version.buildNumber, + header->version.revisionNumber, + target->assemblyIndex - 1); +#endif } } } @@ -1885,23 +2633,23 @@ bool CLR_RT_Assembly::Resolve_AssemblyRef(bool fOutput) void CLR_RT_Assembly::DestroyInstance() { NATIVE_PROFILE_CLR_CORE(); - if (m_idx) + if (assemblyIndex) { - g_CLR_RT_TypeSystem.m_assemblies[m_idx - 1] = NULL; + g_CLR_RT_TypeSystem.m_assemblies[assemblyIndex - 1] = nullptr; } #if defined(VIRTUAL_DEVICE) - if (this->m_strPath != NULL) + if (this->path != nullptr) { - delete this->m_strPath; - this->m_strPath = NULL; + delete this->path; + this->path = nullptr; } #endif // check if header has to be freed (in case the assembly lives in RAM) - if ((this->m_flags & CLR_RT_Assembly::FreeOnDestroy) != 0) + if ((this->flags & CLR_RT_Assembly::FreeOnDestroy) != 0) { - platform_free((void *)this->m_header); + platform_free((void *)this->header); } //--// @@ -1910,20 +2658,25 @@ void CLR_RT_Assembly::DestroyInstance() } //--// -HRESULT CLR_RT_Assembly::Resolve_TypeRef() +HRESULT CLR_RT_Assembly::ResolveTypeRef() { NATIVE_PROFILE_CLR_CORE(); NANOCLR_HEADER(); +#ifdef NANOCLR_TRACE_TYPE_RESOLUTION + CLR_Debug::Printf(" Resolving TypeRef...\r\n"); +#endif + int i; ITERATE_THROUGH_RECORDS(this, i, TypeRef, TYPEREF) { + // TODO check typedef if (src->scope & 0x8000) // Flag for TypeRef { CLR_RT_TypeDef_Instance inst{}; - if (inst.InitializeFromIndex(m_pCrossReference_TypeRef[src->scope & 0x7FFF].m_target) == false) + if (inst.InitializeFromIndex(crossReferenceTypeRef[src->scope & 0x7FFF].target) == false) { #if !defined(BUILD_RTM) CLR_Debug::Printf("Resolve: unknown scope: %08x\r\n", src->scope); @@ -1932,12 +2685,13 @@ HRESULT CLR_RT_Assembly::Resolve_TypeRef() #if defined(VIRTUAL_DEVICE) NANOCLR_CHARMSG_SET_AND_LEAVE(CLR_E_FAIL, "Resolve: unknown scope: %08x\r\n", src->scope); #else - NANOCLR_MSG1_SET_AND_LEAVE(CLR_E_FAIL, L"Resolve: unknown scope: %08x\r\n", src->scope); + NANOCLR_MSG1_SET_AND_LEAVE(CLR_E_FAIL, L"Resolve: unknown scope: %08x\r\n", src->Scope); #endif } const char *szName = GetString(src->name); - if (inst.m_assm->FindTypeDef(szName, inst.Type(), dst->m_target) == false) + + if (inst.assembly->FindTypeDef(szName, inst.Type(), dst->target) == false) { #if !defined(BUILD_RTM) CLR_Debug::Printf("Resolve: unknown type: %s\r\n", szName); @@ -1949,71 +2703,460 @@ HRESULT CLR_RT_Assembly::Resolve_TypeRef() NANOCLR_MSG1_SET_AND_LEAVE(CLR_E_FAIL, L"Resolve: unknown type: %s\r\n", szName); #endif } +#ifdef NANOCLR_TRACE_TYPE_RESOLUTION + else + { + CLR_Debug::Printf(" [%04X] '%s' in current assembly\r\n", i, szName); + } +#endif } else { - CLR_RT_Assembly *assm = m_pCrossReference_AssemblyRef[src->scope].m_target; - if (assm == NULL) + CLR_RT_Assembly *assm = crossReferenceAssemblyRef[src->scope].target; + if (assm == nullptr) { NANOCLR_MSG_SET_AND_LEAVE(CLR_E_FAIL, L"Resolve: assm is null\n"); } const char *szNameSpace = GetString(src->nameSpace); const char *szName = GetString(src->name); - if (assm->FindTypeDef(szName, szNameSpace, dst->m_target) == false) + + if (assm->FindTypeDef(szName, szNameSpace, dst->target) == false) { #if !defined(BUILD_RTM) CLR_Debug::Printf("Resolve: unknown type: %s.%s\r\n", szNameSpace, szName); #endif #if defined(VIRTUAL_DEVICE) - NANOCLR_CHARMSG_SET_AND_LEAVE(CLR_E_FAIL, "Resolve: unknown type: %s.%s\r\n", szNameSpace, szName); + NANOCLR_CHARMSG_SET_AND_LEAVE(CLR_E_FAIL, "Resolve: unknown type: %s\r\n", szName); #else NANOCLR_MSG1_SET_AND_LEAVE(CLR_E_FAIL, L"Resolve: unknown type: %s\r\n", szName); #endif } +#ifdef NANOCLR_TRACE_TYPE_RESOLUTION + else + { + CLR_Debug::Printf(" [%04X] '%s.%s' from '%s'\r\n", i, szNameSpace, szName, assm->name); + } +#endif } } NANOCLR_NOCLEANUP(); } -HRESULT CLR_RT_Assembly::Resolve_FieldRef() +HRESULT CLR_RT_Assembly::ResolveFieldRef() { NATIVE_PROFILE_CLR_CORE(); NANOCLR_HEADER(); +#ifdef NANOCLR_TRACE_TYPE_RESOLUTION + bool outputHint = false; +#endif + int i; ITERATE_THROUGH_RECORDS(this, i, FieldRef, FIELDREF) { - CLR_RT_TypeDef_Instance inst{}; +#ifdef NANOCLR_TRACE_TYPE_RESOLUTION + if (!outputHint) + { + CLR_Debug::Printf(" Resolving FieldRef...\r\n"); + outputHint = true; + } +#endif + CLR_RT_TypeDef_Index typeDef; + typeDef.Clear(); + + CLR_RT_TypeDef_Instance typeDefInstance; + + CLR_RT_TypeSpec_Index typeSpec; + typeSpec.Clear(); + + CLR_RT_TypeSpec_Instance typeSpecInstance; + + const char *fieldName = GetString(src->name); + + switch (src->Owner()) + { + + case TBL_TypeRef: + typeDef = crossReferenceTypeRef[src->OwnerIndex()].target; + break; + + // case CLR_MemberRefParent::MRP_TypeDef: + // typeDef.Set(this->m_index, CLR_GetIndexFromMemberRefParent(src->container)); + // break; + // + // case CLR_MemberRefParent::MRP_MethodDef: + // dst->m_target.Set(this->m_index, CLR_GetIndexFromMemberRefParent(src->container)); + // fGot = true; + // break; + + case TBL_TypeSpec: + typeSpec.Set(this->assemblyIndex, src->OwnerIndex()); + break; + + default: +#if !defined(BUILD_RTM) + CLR_Debug::Printf( + "Unknown or unsupported TypeRefOrSpec when resolving FieldRef %08x '%s'\r\n", + src->encodedOwner, + fieldName); +#endif + +#if defined(VIRTUAL_DEVICE) + NANOCLR_CHARMSG_SET_AND_LEAVE( + CLR_E_FAIL, + "Unknown or unsupported TypeRefOrSpec when resolving FieldRef %08x '%s'\r\n", + src->encodedOwner, + fieldName); +#else + NANOCLR_MSG1_SET_AND_LEAVE( + CLR_E_FAIL, + L"Unknown or unsupported TypeRefOrSpec when resolving FieldRef %08x '%s'\r\n", + src->encodedOwner, + fieldName); +#endif + } + + if (NANOCLR_INDEX_IS_VALID(typeSpec)) + { + if (typeSpecInstance.InitializeFromIndex(typeSpec) == false) + { +#if !defined(BUILD_RTM) + CLR_Debug::Printf("Unknown scope when resolving FieldRef: %08x '%s'\r\n", src->encodedOwner, fieldName); +#endif + +#if defined(VIRTUAL_DEVICE) + NANOCLR_CHARMSG_SET_AND_LEAVE( + CLR_E_FAIL, + "Unknown scope when resolving FieldRef: %08x '%s'\r\n", + src->encodedOwner, + fieldName); +#else + NANOCLR_MSG1_SET_AND_LEAVE( + CLR_E_FAIL, + L"Unknown scope when resolving FieldRef: %08x '%s'\r\n", + src->encodedOwner, + fieldName); +#endif + } + + if (!typeSpecInstance.assembly + ->FindFieldDef(typeSpecInstance.target, fieldName, this, src->signature, dst->target)) + { +#if !defined(BUILD_RTM) + CLR_Debug::Printf("Unknown FieldRef: %s.%s.%s\r\n", "???", "???", fieldName); +#endif + +#if defined(VIRTUAL_DEVICE) + NANOCLR_CHARMSG_SET_AND_LEAVE(CLR_E_FAIL, "Unknown FieldRef: %s.%s.%s\r\n", "???", "???", fieldName); +#else + NANOCLR_MSG1_SET_AND_LEAVE(CLR_E_FAIL, L"Unknown FieldRef: %s.%s.%s\r\n", "???", "???", fieldName); +#endif + } +#ifdef NANOCLR_TRACE_TYPE_RESOLUTION + else + { + char rgBuffer[512]; + char *szBuffer = rgBuffer; + size_t iBuffer = MAXSTRLEN(rgBuffer); + + g_CLR_RT_TypeSystem.BuildTypeName(typeSpecInstance, szBuffer, iBuffer); + rgBuffer[MAXSTRLEN(rgBuffer)] = 0; + + CLR_Debug::Printf(" [%04X] Resolving '%s' from '%s'\r\n", i, fieldName, rgBuffer); + } +#endif + + // set TypeSpec + dst->genericType.data = typeSpec.data; + } + else if (NANOCLR_INDEX_IS_VALID(typeDef)) + { + if (typeDefInstance.InitializeFromIndex(crossReferenceTypeRef[src->OwnerIndex()].target) == false) + { +#if !defined(BUILD_RTM) + CLR_Debug::Printf("Unknown scope when resolving FieldRef: %08x\r\n", src->encodedOwner); +#endif + + NANOCLR_SET_AND_LEAVE(CLR_E_FAIL); + } + +#if defined(VIRTUAL_DEVICE) && defined(DEBUG_RESOLUTION) + const CLR_RECORD_TYPEDEF *qTD = typeDefInstance.m_target; + CLR_RT_Assembly *qASSM = typeDefInstance.m_assm; + + CLR_Debug::Printf( + "Unknown scope when resolving FieldRef: %s.%s.%s\r\n", + qASSM->GetString(qTD->NameSpace), + qASSM->GetString(qTD->Name), + name); +#endif + + if (typeDefInstance.assembly + ->FindFieldDef(typeDefInstance.target, fieldName, this, src->signature, dst->target) == false) + { +#if !defined(BUILD_RTM) + CLR_Debug::Printf("Unknown FieldRef: %s\r\n", fieldName); +#endif + +#if defined(VIRTUAL_DEVICE) + NANOCLR_CHARMSG_SET_AND_LEAVE(CLR_E_FAIL, "Unknown FieldRef: %s\r\n", fieldName); +#else + NANOCLR_MSG1_SET_AND_LEAVE(CLR_E_FAIL, L"Unknown FieldRef: %s\r\n", fieldName); +#endif + } +#ifdef NANOCLR_TRACE_TYPE_RESOLUTION + else + { + char rgBuffer[512]; + char *szBuffer = rgBuffer; + size_t iBuffer = MAXSTRLEN(rgBuffer); + + g_CLR_RT_TypeSystem.BuildTypeName(typeDefInstance, szBuffer, iBuffer); + rgBuffer[MAXSTRLEN(rgBuffer)] = 0; + + CLR_Debug::Printf(" [%04X] Resolving '%s' from '%s'\r\n", i, fieldName, rgBuffer); + } +#endif + + // invalidate GenericType + dst->genericType.data = CLR_EmptyToken; + } + } + + NANOCLR_NOCLEANUP(); +} + +HRESULT CLR_RT_Assembly::ResolveMethodRef() +{ + NATIVE_PROFILE_CLR_CORE(); + NANOCLR_HEADER(); + +#ifdef NANOCLR_TRACE_TYPE_RESOLUTION + bool outputHint = false; +#endif + + int i; + + ITERATE_THROUGH_RECORDS(this, i, MethodRef, METHODREF) + { +#ifdef NANOCLR_TRACE_TYPE_RESOLUTION + if (!outputHint) + { + CLR_Debug::Printf(" Resolving MethodRef...\r\n"); + outputHint = true; + } +#endif + + CLR_RT_TypeDef_Index typeDef; + typeDef.Clear(); + + CLR_RT_TypeDef_Instance typeDefInstance; + + CLR_RT_TypeSpec_Index typeSpec; + typeSpec.Clear(); + + CLR_RT_TypeSpec_Instance typeSpecInstance; + + bool fGot = false; + const char *methodName = GetString(src->name); + + switch (src->Owner()) + { + case TBL_TypeRef: + typeDef = crossReferenceTypeRef[src->OwnerIndex()].target; + break; + + // case CLR_MemberRefParent::MRP_TypeDef: + // typeDef.Set(this->m_index, CLR_GetIndexFromMemberRefParent(src->container)); + // break; + // + // case CLR_MemberRefParent::MRP_MethodDef: + // dst->m_target.Set(this->m_index, CLR_GetIndexFromMemberRefParent(src->container)); + // fGot = true; + // break; + + case TBL_TypeSpec: + typeSpec.Set(this->assemblyIndex, src->OwnerIndex()); + break; + + default: +#if !defined(BUILD_RTM) + CLR_Debug::Printf( + "Unknown or unsupported TypeRefOrSpec when resolving MethodRef %08x '%s'\r\n", + src->encodedOwner, + methodName); +#endif + +#if defined(VIRTUAL_DEVICE) + NANOCLR_CHARMSG_SET_AND_LEAVE( + CLR_E_FAIL, + "Unknown or unsupported TypeRefOrSpec when resolving MethodRef %08x '%s'\r\n", + src->encodedOwner, + methodName); +#else + NANOCLR_MSG1_SET_AND_LEAVE( + CLR_E_FAIL, + L"Unknown or unsupported TypeRefOrSpec when resolving MethodRef %08x '%s'\r\n", + src->encodedOwner, + methodName); +#endif + } + + if (NANOCLR_INDEX_IS_VALID(typeSpec)) + { + if (typeSpecInstance.InitializeFromIndex(typeSpec) == false) + { +#if !defined(BUILD_RTM) + CLR_Debug::Printf("Unknown scope when resolving MethodRef: %08x '%s'\r\n", src->encodedOwner); +#endif + +#if defined(VIRTUAL_DEVICE) + NANOCLR_CHARMSG_SET_AND_LEAVE( + CLR_E_FAIL, + "Unknown scope when resolving MethodRef: %08x\r\n", + src->encodedOwner, + methodName); +#else + NANOCLR_MSG1_SET_AND_LEAVE( + CLR_E_FAIL, + L"Unknown scope when resolving MethodRef: %08x\r\n", + src->encodedOwner, + methodName); +#endif + } + + if (typeSpecInstance.assembly + ->FindMethodDef(typeSpecInstance.target, methodName, this, src->signature, dst->target)) + { + fGot = true; + + // set TypeSpec + dst->genericType.data = typeSpec.data; + } + + if (fGot == false) + { +#if !defined(BUILD_RTM) + CLR_Debug::Printf("Unknown MethodRef: %s.%s.%s\r\n", "???", "???", methodName); +#endif + +#if defined(VIRTUAL_DEVICE) + NANOCLR_CHARMSG_SET_AND_LEAVE(CLR_E_FAIL, "Unknown MethodRef: %s.%s.%s\r\n", "???", "???", methodName); +#else + NANOCLR_MSG1_SET_AND_LEAVE(CLR_E_FAIL, L"Unknown MethodRef: %s.%s.%s\r\n", "???", "???", methodName); +#endif + } +#ifdef NANOCLR_TRACE_TYPE_RESOLUTION + else + { + char rgBuffer[512]; + char *szBuffer = rgBuffer; + size_t iBuffer = MAXSTRLEN(rgBuffer); + + g_CLR_RT_TypeSystem.BuildTypeName(typeSpecInstance, szBuffer, iBuffer); + rgBuffer[MAXSTRLEN(rgBuffer)] = 0; - if (inst.InitializeFromIndex(m_pCrossReference_TypeRef[src->container].m_target) == false) + CLR_Debug::Printf(" [%04X] Resolving '%s' from '%s'\r\n", i, methodName, rgBuffer); + } +#endif + } + else if (NANOCLR_INDEX_IS_VALID(typeDef)) { + if (typeDefInstance.InitializeFromIndex(typeDef) == false) + { #if !defined(BUILD_RTM) - CLR_Debug::Printf("Resolve Field: unknown scope: %08x\r\n", src->container); + CLR_Debug::Printf( + "Unknown scope when resolving MethodRef: %08x '%s'\r\n", + src->encodedOwner, + methodName); #endif #if defined(VIRTUAL_DEVICE) - NANOCLR_CHARMSG_SET_AND_LEAVE(CLR_E_FAIL, "Resolve Field: unknown scope: %08x\r\n", src->container); + NANOCLR_CHARMSG_SET_AND_LEAVE( + CLR_E_FAIL, + "Unknown scope when resolving MethodRef: %08x '%s'\r\n", + src->encodedOwner, + methodName); #else - NANOCLR_MSG1_SET_AND_LEAVE(CLR_E_FAIL, L"Resolve Field: unknown scope: %08x\r\n", src->container); + NANOCLR_MSG1_SET_AND_LEAVE( + CLR_E_FAIL, + L"Unknown scope when resolving MethodRef: %08x '%s'\r\n", + src->encodedOwner, + methodName); #endif - } + } - const char *szName = GetString(src->name); +#if defined(VIRTUAL_DEVICE) && defined(DEBUG_RESOLUTION) + const CLR_RECORD_TYPEDEF *qTD = typeDefInstance.m_target; + CLR_RT_Assembly *qASSM = typeDefInstance.m_assm; - if (inst.m_assm->FindFieldDef(inst.m_target, szName, this, src->sig, dst->m_target) == false) - { -#if !defined(BUILD_RTM) - CLR_Debug::Printf("Resolve: unknown field: %s\r\n", szName); + CLR_Debug::Printf( + "Unknown scope when resolving MethodRef: %s.%s.%s\r\n", + qASSM->GetString(qTD->NameSpace), + qASSM->GetString(qTD->Name), + methodName); #endif + while (NANOCLR_INDEX_IS_VALID(typeDefInstance)) + { + if (typeDefInstance.assembly + ->FindMethodDef(typeDefInstance.target, methodName, this, src->signature, dst->target)) + { + fGot = true; + + // invalidate GenericType + dst->genericType.data = CLR_EmptyToken; + + break; + } + + typeDefInstance.SwitchToParent(); + } + + if (fGot == false) + { +#if !defined(BUILD_RTM) + const CLR_RECORD_TYPEDEF *qTD = typeDefInstance.target; + CLR_RT_Assembly *qASSM = typeDefInstance.assembly; + + CLR_Debug::Printf( + "Unknown MethodRef: %s.%s.%s\r\n", + qASSM->GetString(qTD->nameSpace), + qASSM->GetString(qTD->name), + methodName); +#endif #if defined(VIRTUAL_DEVICE) - NANOCLR_CHARMSG_SET_AND_LEAVE(CLR_E_FAIL, "Resolve: unknown field: %s\r\n", szName); + NANOCLR_CHARMSG_SET_AND_LEAVE( + CLR_E_FAIL, + "Unknown MethodRef: %s.%s.%s\r\n", + qASSM->GetString(qTD->nameSpace), + qASSM->GetString(qTD->name), + methodName); #else - NANOCLR_MSG1_SET_AND_LEAVE(CLR_E_FAIL, L"Resolve: unknown field: %s\r\n", szName); + NANOCLR_MSG1_SET_AND_LEAVE( + CLR_E_FAIL, + L"Unknown MethodRef: %s.%s.%s\r\n", + qASSM->GetString(qTD->NameSpace), + qASSM->GetString(qTD->Name), + methodName); +#endif + } +#ifdef NANOCLR_TRACE_TYPE_RESOLUTION + else + { + char rgBuffer[512]; + char *szBuffer = rgBuffer; + size_t iBuffer = MAXSTRLEN(rgBuffer); + + g_CLR_RT_TypeSystem.BuildTypeName(typeDefInstance, szBuffer, iBuffer); + rgBuffer[MAXSTRLEN(rgBuffer)] = 0; + + CLR_Debug::Printf(" [%04X] Resolving '%s' from '%s'\r\n", i, methodName, rgBuffer); + } #endif } } @@ -2021,77 +3164,56 @@ HRESULT CLR_RT_Assembly::Resolve_FieldRef() NANOCLR_NOCLEANUP(); } -HRESULT CLR_RT_Assembly::Resolve_MethodRef() +HRESULT CLR_RT_Assembly::ResolveTypeSpec() { NATIVE_PROFILE_CLR_CORE(); NANOCLR_HEADER(); +#ifdef NANOCLR_TRACE_TYPE_RESOLUTION + bool outputHint = false; +#endif + int i; - ITERATE_THROUGH_RECORDS(this, i, MethodRef, METHODREF) + ITERATE_THROUGH_RECORDS(this, i, TypeSpec, TYPESPEC) { - CLR_RT_TypeDef_Instance inst{}; - - if (inst.InitializeFromIndex(m_pCrossReference_TypeRef[src->container].m_target) == false) +#ifdef NANOCLR_TRACE_TYPE_RESOLUTION + if (!outputHint) { -#if !defined(BUILD_RTM) - CLR_Debug::Printf("Resolve Field: unknown scope: %08x\r\n", src->container); -#endif - -#if defined(VIRTUAL_DEVICE) - NANOCLR_CHARMSG_SET_AND_LEAVE(CLR_E_FAIL, "Resolve Field: unknown scope: %08x\r\n", src->container); -#else - NANOCLR_MSG1_SET_AND_LEAVE(CLR_E_FAIL, L"Resolve Field: unknown scope: %08x\r\n", src->container); -#endif + CLR_Debug::Printf(" Resolving TypeSpec...\r\n"); + outputHint = true; } +#endif - const char *name = GetString(src->name); - bool fGot = false; - - while (NANOCLR_INDEX_IS_VALID(inst)) - { - if (inst.m_assm->FindMethodDef(inst.m_target, name, this, src->sig, dst->m_target)) - { - fGot = true; - break; - } + dst->genericType.Set(assemblyIndex, i); - inst.SwitchToParent(); - } + CLR_RT_TypeSpec_Instance inst; - if (fGot == false) + if (inst.InitializeFromIndex(dst->genericType) == false) { - inst.InitializeFromIndex(m_pCrossReference_TypeRef[src->container].m_target); - #if !defined(BUILD_RTM) - const CLR_RECORD_TYPEDEF *qTD = inst.m_target; - CLR_RT_Assembly *qASSM = inst.m_assm; - - CLR_Debug::Printf( - "Resolve: unknown method: %s.%s.%s\r\n", - qASSM->GetString(qTD->nameSpace), - qASSM->GetString(qTD->name), - name); -#endif - -#if defined(VIRTUAL_DEVICE) - NANOCLR_CHARMSG_SET_AND_LEAVE(CLR_E_FAIL, "Resolve: unknown method: %s\r\n", name); -#else - NANOCLR_MSG1_SET_AND_LEAVE(CLR_E_FAIL, L"Resolve: unknown method: %s\r\n", name); + CLR_Debug::Printf("Resolve TypeSpec: can't create TypeSpec instance: %08x\r\n", src->signature); #endif + NANOCLR_SET_AND_LEAVE(CLR_E_FAIL); + } +#ifdef NANOCLR_TRACE_TYPE_RESOLUTION + else + { + CLR_Debug::Printf(" [%04X]\r\n", i); } +#endif } NANOCLR_NOCLEANUP(); } -void CLR_RT_Assembly::Resolve_Link() +void CLR_RT_Assembly::ResolveLink() { NATIVE_PROFILE_CLR_CORE(); int iStaticFields = 0; - int idxType; + int indexType; - ITERATE_THROUGH_RECORDS(this, idxType, TypeDef, TYPEDEF) + ITERATE_THROUGH_RECORDS(this, indexType, TypeDef, TYPEDEF) { int num; int i; @@ -2100,13 +3222,13 @@ void CLR_RT_Assembly::Resolve_Link() // Link static fields. // { - CLR_RT_FieldDef_CrossReference *fd = &m_pCrossReference_FieldDef[src->sFields_First]; + CLR_RT_FieldDef_CrossReference *fd = &crossReferenceFieldDef[src->firstStaticField]; - num = src->sFields_Num; + num = src->staticFieldsCount; for (; num; num--, fd++) { - fd->m_offset = iStaticFields++; + fd->offset = iStaticFields++; } } @@ -2114,42 +3236,42 @@ void CLR_RT_Assembly::Resolve_Link() // Link instance fields. // { - CLR_RT_TypeDef_Index idx{}; - idx.Set(m_idx, idxType); + CLR_RT_TypeDef_Index index{}; + index.Set(assemblyIndex, indexType); CLR_RT_TypeDef_Instance inst{}; - inst.InitializeFromIndex(idx); - CLR_IDX tot = 0; + inst.InitializeFromIndex(index); + CLR_INDEX tot = 0; do { - if (inst.m_target->flags & CLR_RECORD_TYPEDEF::TD_HasFinalizer) + if (inst.target->flags & CLR_RECORD_TYPEDEF::TD_HasFinalizer) { - dst->m_flags |= CLR_RT_TypeDef_CrossReference::TD_CR_HasFinalizer; + dst->flags |= CLR_RT_TypeDef_CrossReference::TD_CR_HasFinalizer; } #if defined(NANOCLR_APPDOMAINS) - if (inst.m_data == g_CLR_RT_WellKnownTypes.m_MarshalByRefObject.m_data) + if (inst.m_data == g_CLR_RT_WellKnownTypes.MarshalByRefObject.m_data) { dst->m_flags |= CLR_RT_TypeDef_CrossReference::TD_CR_IsMarshalByRefObject; } #endif - tot += inst.m_target->iFields_Num; + tot += inst.target->instanceFieldsCount; } while (inst.SwitchToParent()); - dst->m_totalFields = tot; + dst->totalFields = tot; //--// - CLR_RT_FieldDef_CrossReference *fd = &m_pCrossReference_FieldDef[src->iFields_First]; + CLR_RT_FieldDef_CrossReference *fd = &crossReferenceFieldDef[src->firstInstanceField]; - num = src->iFields_Num; + num = src->instanceFieldsCount; i = tot - num + CLR_RT_HeapBlock::HB_Object_Fields_Offset; // Take into account the offset from the // beginning of the object. for (; num; num--, i++, fd++) { - fd->m_offset = i; + fd->offset = i; } } @@ -2157,13 +3279,56 @@ void CLR_RT_Assembly::Resolve_Link() // Link methods. // { - CLR_RT_MethodDef_CrossReference *md = &m_pCrossReference_MethodDef[src->methods_First]; + CLR_RT_MethodDef_CrossReference *md = &crossReferenceMethodDef[src->firstMethod]; - num = src->vMethods_Num + src->iMethods_Num + src->sMethods_Num; + num = src->virtualMethodCount + src->instanceMethodCount + src->staticMethodCount; for (; num; num--, md++) { - md->m_data = idxType; + md->data = indexType; + } + } + + // + // Link generic parameters, if any + // + { + if (src->genericParamCount) + { + CLR_RT_GenericParam_CrossReference *gp = &crossReferenceGenericParam[src->firstGenericParam]; + + // get generic parameter count for stop condition + int count = src->genericParamCount; + CLR_UINT16 indexGenericParam = src->firstGenericParam; + + for (; count; count--, gp++, indexGenericParam++) + { + gp->m_target.Set(assemblyIndex, indexGenericParam); + + gp->data = indexType; + gp->typeOrMethodDef = TBL_TypeDef; + + CLR_RT_SignatureParser sub; + if (sub.Initialize_GenericParamTypeSignature(this, GetGenericParam(indexGenericParam))) + { + CLR_RT_SignatureParser::Element res; + + // get generic param type + sub.Advance(res); + + gp->dataType = res.DataType; + gp->classTypeDef = res.Class; + } + else + { + gp->dataType = DATATYPE_VOID; + + CLR_RT_TypeDef_Index td; + td.Clear(); + + gp->classTypeDef = td; + } + } } } } @@ -2178,7 +3343,7 @@ HRESULT CLR_RT_AppDomain::CreateInstance(const char *szName, CLR_RT_AppDomain *& NATIVE_PROFILE_CLR_CORE(); NANOCLR_HEADER(); CLR_RT_HeapBlock name; - name.SetObjectReference(NULL); + name.SetObjectReference(nullptr); CLR_RT_ProtectFromGC gc(name); if (!szName || szName[0] == '\0') @@ -2244,10 +3409,10 @@ void CLR_RT_AppDomain::AppDomain_Initialize() m_state = CLR_RT_AppDomain::AppDomainState_Loaded; m_id = g_CLR_RT_ExecutionEngine.m_appDomainIdNext++; - m_globalLock = NULL; - m_strName = NULL; - m_outOfMemoryException = NULL; - m_appDomainAssemblyLastAccess = NULL; + m_globalLock = nullptr; + m_strName = nullptr; + m_outOfMemoryException = nullptr; + m_appDomainAssemblyLastAccess = nullptr; } void CLR_RT_AppDomain::AppDomain_Uninitialize() @@ -2276,13 +3441,13 @@ HRESULT CLR_RT_AppDomain::LoadAssembly(CLR_RT_Assembly *assm) NANOCLR_HEADER(); CLR_RT_AppDomain *appDomainSav = g_CLR_RT_ExecutionEngine.SetCurrentAppDomain(this); - CLR_RT_AppDomainAssembly *appDomainAssembly = NULL; + CLR_RT_AppDomainAssembly *appDomainAssembly = nullptr; int i; FAULT_ON_NULL(assm); // check to make sure the assembly is not already loaded - if (FindAppDomainAssembly(assm) != NULL) + if (FindAppDomainAssembly(assm) != nullptr) NANOCLR_SET_AND_LEAVE(S_OK); #if defined(NANOCLR_ENABLE_SOURCELEVELDEBUGGING) @@ -2301,14 +3466,14 @@ HRESULT CLR_RT_AppDomain::LoadAssembly(CLR_RT_Assembly *assm) // Preemptively allocate an out of memory exception. // We can never get into a case where an out of memory exception cannot be thrown. - if (m_outOfMemoryException == NULL) + if (m_outOfMemoryException == nullptr) { _ASSERTE(!strcmp(assm->m_szName, "mscorlib")); // always the first assembly to be loaded CLR_RT_HeapBlock exception; NANOCLR_CHECK_HRESULT( - g_CLR_RT_ExecutionEngine.NewObjectFromIndex(exception, g_CLR_RT_WellKnownTypes.m_OutOfMemoryException)); + g_CLR_RT_ExecutionEngine.NewObjectFromIndex(exception, g_CLR_RT_WellKnownTypes.OutOfMemoryException)); m_outOfMemoryException = exception.Dereference(); } @@ -2335,7 +3500,7 @@ HRESULT CLR_RT_AppDomain::GetManagedObject(CLR_RT_HeapBlock &res) CLR_RT_AppDomain *appDomainSav = g_CLR_RT_ExecutionEngine.SetCurrentAppDomain(this); - res.SetObjectReference(NULL); + res.SetObjectReference(nullptr); // Check if a managed object is already present, and use it NANOCLR_FOREACH_NODE(CLR_RT_ObjectToEvent_Source, ref, m_references) @@ -2344,7 +3509,7 @@ HRESULT CLR_RT_AppDomain::GetManagedObject(CLR_RT_HeapBlock &res) _ASSERTE(FIMPLIES(obj, obj->DataType() == DATATYPE_CLASS || obj->DataType() == DATATYPE_VALUETYPE)); - if (obj && obj->ObjectCls().m_data == g_CLR_RT_WellKnownTypes.m_AppDomain.m_data) + if (obj && obj->ObjectCls().m_data == g_CLR_RT_WellKnownTypes.AppDomain.m_data) { // managed appDomain is found. Use it. res.SetObjectReference(ref->m_objectPtr); @@ -2359,7 +3524,7 @@ HRESULT CLR_RT_AppDomain::GetManagedObject(CLR_RT_HeapBlock &res) CLR_RT_HeapBlock *pRes; CLR_RT_ProtectFromGC gc(res); - NANOCLR_CHECK_HRESULT(g_CLR_RT_ExecutionEngine.NewObjectFromIndex(res, g_CLR_RT_WellKnownTypes.m_AppDomain)); + NANOCLR_CHECK_HRESULT(g_CLR_RT_ExecutionEngine.NewObjectFromIndex(res, g_CLR_RT_WellKnownTypes.AppDomain)); pRes = res.Dereference(); @@ -2381,7 +3546,7 @@ HRESULT CLR_RT_AppDomain::GetManagedObject(CLR_RT_HeapBlock &res) CLR_RT_AppDomainAssembly *CLR_RT_AppDomain::FindAppDomainAssembly(CLR_RT_Assembly *assm) { NATIVE_PROFILE_CLR_CORE(); - if (m_appDomainAssemblyLastAccess != NULL && m_appDomainAssemblyLastAccess->m_assembly == assm) + if (m_appDomainAssemblyLastAccess != nullptr && m_appDomainAssemblyLastAccess->m_assembly == assm) { return m_appDomainAssemblyLastAccess; } @@ -2397,7 +3562,7 @@ CLR_RT_AppDomainAssembly *CLR_RT_AppDomain::FindAppDomainAssembly(CLR_RT_Assembl } NANOCLR_FOREACH_NODE_END(); - return NULL; + return nullptr; } void CLR_RT_AppDomain::Relocate() @@ -2408,14 +3573,14 @@ void CLR_RT_AppDomain::Relocate() CLR_RT_GarbageCollector::Heap_Relocate((void **)&m_outOfMemoryException); } -HRESULT CLR_RT_AppDomain::VerifyTypeIsLoaded(const CLR_RT_TypeDef_Index &idx) +HRESULT CLR_RT_AppDomain::VerifyTypeIsLoaded(const CLR_RT_TypeDef_Index &index) { NATIVE_PROFILE_CLR_CORE(); NANOCLR_HEADER(); CLR_RT_TypeDef_Instance inst; - if (!inst.InitializeFromIndex(idx)) + if (!inst.InitializeFromIndex(index)) NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER); if (!FindAppDomainAssembly(inst.m_assm)) NANOCLR_SET_AND_LEAVE(CLR_E_APPDOMAIN_MARSHAL_EXCEPTION); @@ -2429,14 +3594,14 @@ HRESULT CLR_RT_AppDomain::MarshalObject(CLR_RT_HeapBlock &src, CLR_RT_HeapBlock NANOCLR_HEADER(); // This function marshals an object from appDomainSrc to 'this' AppDomain - // If appDomainSrc == NULL, this uses the current AppDomain + // If appDomainSrc == nullptr, this uses the current AppDomain CLR_RT_AppDomain *appDomainDst = this; - CLR_RT_HeapBlock *proxySrc = NULL; - CLR_RT_HeapBlock *mbroSrc = NULL; + CLR_RT_HeapBlock *proxySrc = nullptr; + CLR_RT_HeapBlock *mbroSrc = nullptr; bool fSimpleAssign = false; - CLR_RT_TypeDef_Index idxVerify = g_CLR_RT_WellKnownTypes.m_Object; - CLR_DataType dtSrc = src.DataType(); + CLR_RT_TypeDef_Index indexVerify = g_CLR_RT_WellKnownTypes.Object; + NanoCLRDataType dtSrc = src.DataType(); CLR_RT_AppDomain *appDomainSav = g_CLR_RT_ExecutionEngine.GetCurrentAppDomain(); if (!appDomainSrc) @@ -2456,7 +3621,7 @@ HRESULT CLR_RT_AppDomain::MarshalObject(CLR_RT_HeapBlock &src, CLR_RT_HeapBlock // fSimpleAssign = (appDomainSrc == appDomainDst); fSimpleAssign = fSimpleAssign || (dtSrc <= DATATYPE_LAST_PRIMITIVE_TO_MARSHAL); - fSimpleAssign = fSimpleAssign || (dtSrc == DATATYPE_OBJECT && src.Dereference() == NULL); + fSimpleAssign = fSimpleAssign || (dtSrc == DATATYPE_OBJECT && src.Dereference() == nullptr); #if !defined(NANOCLR_NO_ASSEMBLY_STRINGS) fSimpleAssign = fSimpleAssign || (dtSrc == DATATYPE_STRING && !src.StringAssembly()); @@ -2476,7 +3641,7 @@ HRESULT CLR_RT_AppDomain::MarshalObject(CLR_RT_HeapBlock &src, CLR_RT_HeapBlock NANOCLR_CHECK_HRESULT(proxySrc->TransparentProxyValidate()); - idxVerify = proxySrc->TransparentProxyDereference()->ObjectCls(); + indexVerify = proxySrc->TransparentProxyDereference()->ObjectCls(); if (proxySrc->TransparentProxyAppDomain() != appDomainDst) { @@ -2495,7 +3660,7 @@ HRESULT CLR_RT_AppDomain::MarshalObject(CLR_RT_HeapBlock &src, CLR_RT_HeapBlock if ((inst.CrossReference().m_flags & CLR_RT_TypeDef_CrossReference::TD_CR_IsMarshalByRefObject) != 0) { - idxVerify = inst; + indexVerify = inst; mbroSrc = ptr; } @@ -2506,13 +3671,13 @@ HRESULT CLR_RT_AppDomain::MarshalObject(CLR_RT_HeapBlock &src, CLR_RT_HeapBlock } } - NANOCLR_CHECK_HRESULT(appDomainDst->VerifyTypeIsLoaded(idxVerify)); + NANOCLR_CHECK_HRESULT(appDomainDst->VerifyTypeIsLoaded(indexVerify)); if (fSimpleAssign) { dst.Assign(src); } - else if (proxySrc != NULL) + else if (proxySrc != nullptr) { // src is OBJECT->TRANSPARENT_PROXY->CLASS, and we are marshalling into 'this' appDomain // dst is OBJECT->CLASS @@ -2520,7 +3685,7 @@ HRESULT CLR_RT_AppDomain::MarshalObject(CLR_RT_HeapBlock &src, CLR_RT_HeapBlock dst.SetObjectReference(proxySrc->TransparentProxyDereference()); } - else if (mbroSrc != NULL) + else if (mbroSrc != nullptr) { // src is a MarshalByRefObject that we are marshalling outside of its AppDomain // src is OBJECT->CLASS @@ -2537,7 +3702,7 @@ HRESULT CLR_RT_AppDomain::MarshalObject(CLR_RT_HeapBlock &src, CLR_RT_HeapBlock else { CLR_RT_HeapBlock blk; - blk.SetObjectReference(NULL); + blk.SetObjectReference(nullptr); CLR_RT_ProtectFromGC gc(blk); bool fNoCompaction = CLR_EE_DBG_IS(NoCompaction); @@ -2547,10 +3712,10 @@ HRESULT CLR_RT_AppDomain::MarshalObject(CLR_RT_HeapBlock &src, CLR_RT_HeapBlock CLR_EE_DBG_SET(NoCompaction); NANOCLR_CHECK_HRESULT( - CLR_RT_BinaryFormatter::Serialize(blk, src, NULL, CLR_RT_BinaryFormatter::c_Flags_Marshal)); + CLR_RT_BinaryFormatter::Serialize(blk, src, nullptr, CLR_RT_BinaryFormatter::c_Flags_Marshal)); (void)g_CLR_RT_ExecutionEngine.SetCurrentAppDomain(appDomainDst); - hr = CLR_RT_BinaryFormatter::Deserialize(dst, blk, NULL, CLR_RT_BinaryFormatter::c_Flags_Marshal); + hr = CLR_RT_BinaryFormatter::Deserialize(dst, blk, nullptr, CLR_RT_BinaryFormatter::c_Flags_Marshal); CLR_EE_DBG_RESTORE(NoCompaction, fNoCompaction); } @@ -2577,8 +3742,8 @@ HRESULT CLR_RT_AppDomain::MarshalParameters( while (count-- > 0) { - CLR_DataType dtSrc = src->DataType(); - CLR_DataType dtDst = dst->DataType(); + NanoCLRDataType dtSrc = src->DataType(); + NanoCLRDataType dtDst = dst->DataType(); if (dtSrc == DATATYPE_BYREF || dtSrc == DATATYPE_ARRAY_BYREF) { @@ -2603,7 +3768,7 @@ HRESULT CLR_RT_AppDomain::MarshalParameters( } else //! fOnReturn { - CLR_RT_HeapBlock *dstPtr = NULL; + CLR_RT_HeapBlock *dstPtr = nullptr; if (dtSrc == DATATYPE_BYREF) { @@ -2649,7 +3814,7 @@ HRESULT CLR_RT_AppDomain::GetAssemblies(CLR_RT_HeapBlock &ref) NANOCLR_HEADER(); int count = 0; - CLR_RT_HeapBlock *pArray = NULL; + CLR_RT_HeapBlock *pArray = nullptr; for (int pass = 0; pass < 2; pass++) { @@ -2662,14 +3827,14 @@ HRESULT CLR_RT_AppDomain::GetAssemblies(CLR_RT_HeapBlock &ref) else { CLR_RT_HeapBlock *hbObj; - CLR_RT_Assembly_Index idx; - idx.Set(pASSM->m_idx); + CLR_RT_Assembly_Index index; + index.Set(pASSM->m_index); NANOCLR_CHECK_HRESULT( - g_CLR_RT_ExecutionEngine.NewObjectFromIndex(*pArray, g_CLR_RT_WellKnownTypes.m_Assembly)); + g_CLR_RT_ExecutionEngine.NewObjectFromIndex(*pArray, g_CLR_RT_WellKnownTypes.Assembly)); hbObj = pArray->Dereference(); - hbObj->SetReflection(idx); + hbObj->SetReflection(index); pArray++; } @@ -2679,7 +3844,7 @@ HRESULT CLR_RT_AppDomain::GetAssemblies(CLR_RT_HeapBlock &ref) if (pass == 0) { NANOCLR_CHECK_HRESULT( - CLR_RT_HeapBlock_Array::CreateInstance(ref, count, g_CLR_RT_WellKnownTypes.m_Assembly)); + CLR_RT_HeapBlock_Array::CreateInstance(ref, count, g_CLR_RT_WellKnownTypes.Assembly)); pArray = (CLR_RT_HeapBlock *)ref.DereferenceArray()->GetFirstElement(); } @@ -2795,93 +3960,100 @@ struct TypeIndexLookup CLR_RT_TypeDef_Index *ptr; }; +// clang-format off + static const TypeIndexLookup c_TypeIndexLookup[] = { -#define TIL(ns, nm, fld) {ns, nm, &g_CLR_RT_WellKnownTypes.fld} - TIL("System", "Boolean", m_Boolean), - TIL("System", "Char", m_Char), - TIL("System", "SByte", m_Int8), - TIL("System", "Byte", m_UInt8), - TIL("System", "Int16", m_Int16), - TIL("System", "UInt16", m_UInt16), - TIL("System", "Int32", m_Int32), - TIL("System", "UInt32", m_UInt32), - TIL("System", "Int64", m_Int64), - TIL("System", "UInt64", m_UInt64), - TIL("System", "Single", m_Single), - TIL("System", "Double", m_Double), - TIL("System", "DateTime", m_DateTime), - TIL("System", "TimeSpan", m_TimeSpan), - TIL("System", "String", m_String), - - TIL("System", "Void", m_Void), - TIL("System", "Object", m_Object), - TIL("System", "ValueType", m_ValueType), - TIL("System", "Enum", m_Enum), - - TIL("System", "AppDomainUnloadedException", m_AppDomainUnloadedException), - TIL("System", "ArgumentNullException", m_ArgumentNullException), - TIL("System", "ArgumentException", m_ArgumentException), - TIL("System", "ArgumentOutOfRangeException", m_ArgumentOutOfRangeException), - TIL("System", "Exception", m_Exception), - TIL("System", "IndexOutOfRangeException", m_IndexOutOfRangeException), - TIL("System", "InvalidCastException", m_InvalidCastException), - TIL("System", "FormatException", m_FormatException), - TIL("System", "InvalidOperationException", m_InvalidOperationException), - TIL("System", "NotSupportedException", m_NotSupportedException), - TIL("System", "NotImplementedException", m_NotImplementedException), - TIL("System", "NullReferenceException", m_NullReferenceException), - TIL("System", "OutOfMemoryException", m_OutOfMemoryException), - TIL("System", "TimeoutException", m_TimeoutException), - TIL("System", "ObjectDisposedException", m_ObjectDisposedException), - TIL("System.Threading", "ThreadAbortException", m_ThreadAbortException), - TIL("nanoFramework.Runtime.Native", "ConstraintException", m_ConstraintException), - - TIL("System", "Delegate", m_Delegate), - TIL("System", "MulticastDelegate", m_MulticastDelegate), - - TIL("System", "Array", m_Array), - TIL("System.Collections", "ArrayList", m_ArrayList), - TIL("System", "ICloneable", m_ICloneable), - TIL("System.Collections", "IList", m_IList), - - TIL("System.Reflection", "Assembly", m_Assembly), - TIL("System", "Type", m_TypeStatic), - TIL("System", "RuntimeType", m_Type), - TIL("System.Reflection", "RuntimeConstructorInfo", m_ConstructorInfo), - TIL("System.Reflection", "RuntimeMethodInfo", m_MethodInfo), - TIL("System.Reflection", "RuntimeFieldInfo", m_FieldInfo), - - TIL("System", "WeakReference", m_WeakReference), - - TIL("System", "Guid", m_Guid), - - TIL("nanoFramework.UI", "Bitmap", m_Bitmap), - TIL("nanoFramework.UI", "Font", m_Font), - TIL("nanoFramework.Touch", "TouchEvent", m_TouchEvent), - TIL("nanoFramework.Touch", "TouchInput", m_TouchInput), - - TIL("System.Net.NetworkInformation", "NetworkInterface", m_NetworkInterface), - TIL("System.Net.NetworkInformation", "Wireless80211Configuration", m_Wireless80211Configuration), - TIL("System.Net.NetworkInformation", "WirelessAPConfiguration", m_WirelessAPConfiguration), - TIL("System.Net.NetworkInformation", "WirelessAPStation", m_WirelessAPStation), +#define TIL(ns, nm, fld) \ + { \ + ns, nm, &g_CLR_RT_WellKnownTypes.fld \ + } + TIL("System", "Boolean", Boolean), + TIL("System", "Char", Char), + TIL("System", "SByte", Int8), + TIL("System", "Byte", UInt8), + TIL("System", "Int16", Int16), + TIL("System", "UInt16", UInt16), + TIL("System", "Int32", Int32), + TIL("System", "UInt32", UInt32), + TIL("System", "Int64", Int64), + TIL("System", "UInt64", UInt64), + TIL("System", "Single", Single), + TIL("System", "Double", Double), + TIL("System", "DateTime", DateTime), + TIL("System", "TimeSpan", TimeSpan), + TIL("System", "String", String), + + TIL("System", "Void", n_Void), + TIL("System", "Object", Object), + TIL("System", "ValueType", ValueType), + TIL("System", "Enum", Enum), + + TIL("System", "AppDomainUnloadedException", AppDomainUnloadedException), + TIL("System", "ArgumentNullException", ArgumentNullException), + TIL("System", "ArgumentException", ArgumentException), + TIL("System", "ArgumentOutOfRangeException", ArgumentOutOfRangeException), + TIL("System", "Exception", Exception), + TIL("System", "IndexOutOfRangeException", IndexOutOfRangeException), + TIL("System", "InvalidCastException", InvalidCastException), + TIL("System", "FormatException", FormatException), + TIL("System", "InvalidOperationException", InvalidOperationException), + TIL("System", "NotSupportedException", NotSupportedException), + TIL("System", "NotImplementedException", NotImplementedException), + TIL("System", "NullReferenceException", NullReferenceException), + TIL("System", "OutOfMemoryException", OutOfMemoryException), + TIL("System", "TimeoutException", TimeoutException), + TIL("System", "ObjectDisposedException", ObjectDisposedException), + TIL("System.Threading", "ThreadAbortException", ThreadAbortException), + TIL("nanoFramework.Runtime.Native", "ConstraintException", ConstraintException), + + TIL("System", "Delegate", Delegate), + TIL("System", "MulticastDelegate", MulticastDelegate), + + TIL("System", "Array", Array), + TIL("System.Collections", "ArrayList", ArrayList), + TIL("System", "ICloneable", ICloneable), + TIL("System.Collections", "IList", IList), + + TIL("System.Reflection", "Assembly", Assembly), + TIL("System", "Type", TypeStatic), + TIL("System", "RuntimeType", Type), + TIL("System.Reflection", "RuntimeConstructorInfo", ConstructorInfo), + TIL("System.Reflection", "RuntimeMethodInfo", MethodInfo), + TIL("System.Reflection", "RuntimeFieldInfo", FieldInfo), + + TIL("System", "WeakReference", WeakReference), + + TIL("System", "Guid", Guid), + + TIL("nanoFramework.UI", "Bitmap", Bitmap), + TIL("nanoFramework.UI", "Font", Font), + TIL("nanoFramework.Touch", "TouchEvent", TouchEvent), + TIL("nanoFramework.Touch", "TouchInput", TouchInput), + + TIL("System.Net.NetworkInformation", "NetworkInterface", NetworkInterface), + TIL("System.Net.NetworkInformation", "Wireless80211Configuration", Wireless80211Configuration), + TIL("System.Net.NetworkInformation", "WirelessAPConfiguration", WirelessAPConfiguration), + TIL("System.Net.NetworkInformation", "WirelessAPStation", WirelessAPStation), #if defined(NANOCLR_APPDOMAINS) - TIL("System", "AppDomain", m_AppDomain), - TIL("System", "MarshalByRefObject", m_MarshalByRefObject), + TIL("System", "AppDomain", m_AppDomain), + TIL("System", "MarshalByRefObject", m_MarshalByRefObject), #endif - TIL("System.Threading", "Thread", m_Thread), - TIL("System.Resources", "ResourceManager", m_ResourceManager), + TIL("System.Threading", "Thread", Thread), + TIL("System.Resources", "ResourceManager", ResourceManager), - TIL("System.Net.Sockets", "SocketException", m_SocketException), + TIL("System.Net.Sockets", "SocketException", SocketException), - TIL("System.Device.I2c", "I2cTransferResult", m_I2cTransferResult), + TIL("System.Device.I2c", "I2cTransferResult", I2cTransferResult), - TIL("nanoFramework.Hardware.Esp32.Rmt", "RmtCommand", m_RmtCommand), + TIL("nanoFramework.Hardware.Esp32.Rmt", "RmtCommand", RmtCommand), #undef TIL }; +// clang-format on + //--// struct MethodIndexLookup @@ -2894,16 +4066,20 @@ struct MethodIndexLookup static const MethodIndexLookup c_MethodIndexLookup[] = { #define MIL(nm, type, method) {nm, &g_CLR_RT_WellKnownTypes.type, &g_CLR_RT_WellKnownMethods.method} - MIL("GetObjectFromId", m_ResourceManager, m_ResourceManager_GetObjectFromId), - MIL("GetObjectChunkFromId", m_ResourceManager, m_ResourceManager_GetObjectChunkFromId), + // clang-format off + + MIL("GetObjectFromId", ResourceManager, m_ResourceManager_GetObjectFromId), + MIL("GetObjectChunkFromId", ResourceManager, m_ResourceManager_GetObjectChunkFromId), + +// clang-format on #undef MIL }; -void CLR_RT_Assembly::Resolve_TypeDef() +void CLR_RT_Assembly::ResolveTypeDef() { NATIVE_PROFILE_CLR_CORE(); - const TypeIndexLookup *tilOuterClass = NULL; + const TypeIndexLookup *tilOuterClass = nullptr; const TypeIndexLookup *til = c_TypeIndexLookup; for (size_t i = 0; i < ARRAYSIZE(c_TypeIndexLookup); i++, til++) @@ -2912,7 +4088,7 @@ void CLR_RT_Assembly::Resolve_TypeDef() if (NANOCLR_INDEX_IS_INVALID(dst)) { - if (til->nameSpace == NULL) + if (til->nameSpace == nullptr) { if (tilOuterClass) { @@ -2925,42 +4101,63 @@ void CLR_RT_Assembly::Resolve_TypeDef() } } - if (til->nameSpace != NULL) + if (til->nameSpace != nullptr) { tilOuterClass = til; } + +#ifdef NANOCLR_TRACE_TYPE_RESOLUTION + else + { + CLR_Debug::Printf(" [%04X] '%s.%s'\r\n", i, til->nameSpace, til->name); + } +#endif } } -void CLR_RT_Assembly::Resolve_MethodDef() +void CLR_RT_Assembly::ResolveMethodDef() { NATIVE_PROFILE_CLR_CORE(); const CLR_RECORD_METHODDEF *md = GetMethodDef(0); - for (int i = 0; i < m_pTablesSize[TBL_MethodDef]; i++, md++) +#ifdef NANOCLR_TRACE_TYPE_RESOLUTION + bool outputHint = false; +#endif + + for (int indexMethod = 0; indexMethod < tablesSize[TBL_MethodDef]; indexMethod++, md++) { +#ifdef NANOCLR_TRACE_TYPE_RESOLUTION + if (!outputHint) + { + CLR_Debug::Printf(" Resolving MethodDef...\r\n"); + outputHint = true; + } +#endif + const MethodIndexLookup *mil = c_MethodIndexLookup; - CLR_RT_MethodDef_Index idx; - idx.Set(m_idx, i); + CLR_RT_MethodDef_Index index; + index.Set(assemblyIndex, indexMethod); + + const char *methodName = GetString(md->name); // Check for wellKnownMethods - for (size_t m = 0; m < ARRAYSIZE(c_MethodIndexLookup); m++, mil++) + for (size_t ii = 0; ii < ARRAYSIZE(c_MethodIndexLookup); ii++, mil++) { - CLR_RT_TypeDef_Index &idxType = *mil->type; - CLR_RT_MethodDef_Index &idxMethod = *mil->method; + CLR_RT_TypeDef_Index &indexType = *mil->type; + CLR_RT_MethodDef_Index &mIndex = *mil->method; - if (NANOCLR_INDEX_IS_VALID(idxType) && NANOCLR_INDEX_IS_INVALID(idxMethod)) + if (NANOCLR_INDEX_IS_VALID(indexType) && NANOCLR_INDEX_IS_INVALID(mIndex)) { CLR_RT_TypeDef_Instance instType{}; - _SIDE_ASSERTE(instType.InitializeFromIndex(idxType)); + _SIDE_ASSERTE(instType.InitializeFromIndex(indexType)); - if (instType.m_assm == this) + if (instType.assembly == this) { - if (!strcmp(GetString(md->name), mil->name)) + if (!strcmp(methodName, mil->name)) { - idxMethod.m_data = idx.m_data; + mIndex.data = index.data; } } } @@ -2968,25 +4165,68 @@ void CLR_RT_Assembly::Resolve_MethodDef() if (md->flags & CLR_RECORD_METHODDEF::MD_EntryPoint) { - g_CLR_RT_TypeSystem.m_entryPoint = idx; + g_CLR_RT_TypeSystem.m_entryPoint = index; + } + + // link generic parameters + if (md->genericParamCount) + { + CLR_RT_GenericParam_CrossReference *gp = &crossReferenceGenericParam[md->firstGenericParam]; + + // get generic parameter count for stop condition + int num = md->genericParamCount; + CLR_UINT16 indexGenericParam = md->firstGenericParam; + + for (; num; num--, gp++, indexGenericParam++) + { + gp->m_target.Set(assemblyIndex, indexGenericParam); + + gp->data = indexMethod; + gp->typeOrMethodDef = TBL_MethodDef; + + CLR_RT_SignatureParser sub; + if (sub.Initialize_GenericParamTypeSignature(this, GetGenericParam(indexGenericParam))) + { + CLR_RT_SignatureParser::Element res; + + // get generic param type + sub.Advance(res); + + gp->dataType = res.DataType; + gp->classTypeDef = res.Class; + } + else + { + gp->dataType = DATATYPE_VOID; + + CLR_RT_TypeDef_Index td; + td.Clear(); + + gp->classTypeDef = td; + } + } } + +#ifdef NANOCLR_TRACE_TYPE_RESOLUTION + CLR_Debug::Printf(" [%04X] Resolving '%s'\r\n", indexMethod, methodName); +#endif } } -HRESULT CLR_RT_Assembly::Resolve_AllocateStaticFields(CLR_RT_HeapBlock *pStaticFields) +HRESULT CLR_RT_Assembly::ResolveAllocateStaticFields(CLR_RT_HeapBlock *pStaticFields) { NATIVE_PROFILE_CLR_CORE(); NANOCLR_HEADER(); const CLR_RECORD_FIELDDEF *fd = GetFieldDef(0); - for (int i = 0; i < m_pTablesSize[TBL_FieldDef]; i++, fd++) + for (int i = 0; i < tablesSize[TBL_FieldDef]; i++, fd++) { if (fd->flags & CLR_RECORD_FIELDDEF::FD_Static) { - CLR_RT_FieldDef_CrossReference &res = m_pCrossReference_FieldDef[i]; + CLR_RT_FieldDef_CrossReference &res = crossReferenceFieldDef[i]; - NANOCLR_CHECK_HRESULT(g_CLR_RT_ExecutionEngine.InitializeReference(pStaticFields[res.m_offset], fd, this)); + NANOCLR_CHECK_HRESULT(g_CLR_RT_ExecutionEngine.InitializeReference(pStaticFields[res.offset], fd, this)); } } @@ -2998,7 +4238,7 @@ HRESULT CLR_RT_Assembly::PrepareForExecution() NATIVE_PROFILE_CLR_CORE(); NANOCLR_HEADER(); - if ((m_flags & CLR_RT_Assembly::PreparingForExecution) != 0) + if ((flags & CLR_RT_Assembly::PreparingForExecution) != 0) { // Circular dependency _ASSERTE(false); @@ -3006,33 +4246,22 @@ HRESULT CLR_RT_Assembly::PrepareForExecution() NANOCLR_MSG_SET_AND_LEAVE(CLR_E_FAIL, L"Failed to prepare type system for execution\n"); } - if ((m_flags & CLR_RT_Assembly::PreparedForExecution) == 0) + if ((flags & CLR_RT_Assembly::PreparedForExecution) == 0) { int i; - m_flags |= CLR_RT_Assembly::PreparingForExecution; + flags |= CLR_RT_Assembly::PreparingForExecution; ITERATE_THROUGH_RECORDS(this, i, AssemblyRef, ASSEMBLYREF) { - _ASSERTE(dst->m_target != NULL); + _ASSERTE(dst->target != nullptr); - if (dst->m_target != NULL) + if (dst->target != nullptr) { - NANOCLR_CHECK_HRESULT(dst->m_target->PrepareForExecution()); + NANOCLR_CHECK_HRESULT(dst->target->PrepareForExecution()); } } - if (m_header->patchEntryOffset != 0xFFFFFFFF) - { - CLR_PMETADATA ptr = GetResourceData(m_header->patchEntryOffset); - -#if defined(VIRTUAL_DEVICE) - CLR_Debug::Printf("Simulating jump into patch code...\r\n"); -#else - ((void (*)())ptr)(); -#endif - } - #if defined(NANOCLR_APPDOMAINS) // Temporary solution. All Assemblies get added to the current AppDomain // Which assemblies get loaded at boot, and when assemblies get added to AppDomain at runtime is @@ -3045,8 +4274,8 @@ HRESULT CLR_RT_Assembly::PrepareForExecution() NANOCLR_CLEANUP(); // Only try once. If this fails, then what? - m_flags |= CLR_RT_Assembly::PreparedForExecution; - m_flags &= ~CLR_RT_Assembly::PreparingForExecution; + flags |= CLR_RT_Assembly::PreparedForExecution; + flags &= ~CLR_RT_Assembly::PreparingForExecution; NANOCLR_CLEANUP_END(); } @@ -3056,97 +4285,254 @@ HRESULT CLR_RT_Assembly::PrepareForExecution() CLR_UINT32 CLR_RT_Assembly::ComputeAssemblyHash() { NATIVE_PROFILE_CLR_CORE(); - return m_header->ComputeAssemblyHash(m_szName, m_header->version); + return header->ComputeAssemblyHash(name, header->version); } CLR_UINT32 CLR_RT_Assembly::ComputeAssemblyHash(const CLR_RECORD_ASSEMBLYREF *ar) { NATIVE_PROFILE_CLR_CORE(); - return m_header->ComputeAssemblyHash(GetString(ar->name), ar->version); + return header->ComputeAssemblyHash(GetString(ar->name), ar->version); } //--// -bool CLR_RT_Assembly::FindTypeDef(const char *name, const char *nameSpace, CLR_RT_TypeDef_Index &idx) +bool CLR_RT_Assembly::FindTypeDef(const char *typeName, const char *nameSpace, CLR_RT_TypeDef_Index &index) { NATIVE_PROFILE_CLR_CORE(); const CLR_RECORD_TYPEDEF *target = GetTypeDef(0); - int tblSize = m_pTablesSize[TBL_TypeDef]; + int tblSize = tablesSize[TBL_TypeDef]; + bool isNestedType = false; + std::string extractedNamespace; + + // Check if typeName contains '/' + const char *slashPos = strchr(typeName, '/'); + if (slashPos != nullptr) + { + // Extract the type name from the '/' to the end of the string + const char *extractedTypeName = slashPos + 1; + + // Extract the enclosed type name from the '/' backwards to the '.' before + const char *dotPos = strrchr(typeName, '.'); + std::string enclosedTypeName; + + if (dotPos != nullptr) + { + enclosedTypeName.assign(dotPos + 1, slashPos); + // Extract the namespace from the beginning of the string to that '.' + extractedNamespace.assign(typeName, dotPos - typeName); + } + else + { + enclosedTypeName.assign(typeName, slashPos); + extractedNamespace.clear(); + } + + // Use the extracted values for further processing + typeName = extractedTypeName; + nameSpace = extractedNamespace.c_str(); + + // set flag to indicate that this is a nested type + isNestedType = true; + } for (int i = 0; i < tblSize; i++, target++) { - if (target->enclosingType == CLR_EmptyIndex) + if (isNestedType) + { + // check if this is a nested type + if (target->HasValidEnclosingType()) + { + const char *szName = GetString(target->name); + + // for nested types, there is no namespace encoded in the type + // looking at the type name only, does look a bit flaky but it will have to work for now + if (!strcmp(szName, typeName)) + { + index.Set(assemblyIndex, i); + return true; + } + } + } + else if (!target->HasValidEnclosingType()) { const char *szNameSpace = GetString(target->nameSpace); const char *szName = GetString(target->name); - if (!strcmp(szName, name) && !strcmp(szNameSpace, nameSpace)) + if (!strcmp(szName, typeName) && !strcmp(szNameSpace, nameSpace)) { - idx.Set(m_idx, i); - + index.Set(assemblyIndex, i); return true; } } } - idx.Clear(); - + index.Clear(); return false; } -bool CLR_RT_Assembly::FindTypeDef(const char *name, CLR_IDX scope, CLR_RT_TypeDef_Index &idx) +bool CLR_RT_Assembly::FindTypeDef(const char *typeName, CLR_INDEX scope, CLR_RT_TypeDef_Index &index) { NATIVE_PROFILE_CLR_CORE(); const CLR_RECORD_TYPEDEF *target = GetTypeDef(0); - int tblSize = m_pTablesSize[TBL_TypeDef]; + int tblSize = tablesSize[TBL_TypeDef]; for (int i = 0; i < tblSize; i++, target++) { - if (target->enclosingType == scope) + if (!target->HasValidEnclosingType()) + { + continue; + } + + CLR_INDEX enclosingTypeIndex = target->EnclosingTypeIndex(); + + if (enclosingTypeIndex == scope) { const char *szName = GetString(target->name); - if (!strcmp(szName, name)) + if (!strcmp(szName, typeName)) { - idx.Set(m_idx, i); + index.Set(assemblyIndex, i); return true; } } } - idx.Clear(); + index.Clear(); return false; } -bool CLR_RT_Assembly::FindTypeDef(CLR_UINT32 hash, CLR_RT_TypeDef_Index &idx) +bool CLR_RT_Assembly::FindTypeDef(CLR_UINT32 hash, CLR_RT_TypeDef_Index &index) { NATIVE_PROFILE_CLR_CORE(); - CLR_RT_TypeDef_CrossReference *p = m_pCrossReference_TypeDef; - CLR_UINT32 tblSize = m_pTablesSize[TBL_TypeDef]; + CLR_RT_TypeDef_CrossReference *p = crossReferenceTypeDef; + CLR_UINT32 tblSize = tablesSize[TBL_TypeDef]; CLR_UINT32 i; for (i = 0; i < tblSize; i++, p++) { - if (p->m_hash == hash) + if (p->hash == hash) break; } if (i != tblSize) { - idx.Set(m_idx, i); + index.Set(assemblyIndex, i); + + return true; + } + else + { + index.Clear(); + + return false; + } +} + +bool CLR_RT_Assembly::FindGenericParam(CLR_INDEX typeSpecIndex, CLR_RT_GenericParam_Index &index) +{ + NATIVE_PROFILE_CLR_CORE(); + const CLR_RECORD_GENERICPARAM *gp = this->GetGenericParam(0); + int tblSize = this->tablesSize[TBL_GenericParam]; + + for (int i = 0; i < tblSize; i++, gp++) + { + CLR_RT_SignatureParser parserLeft; + parserLeft.Initialize_GenericParamTypeSignature(this, gp); + + CLR_RT_SignatureParser parserRight; + parserRight.Initialize_TypeSpec(this, this->GetTypeSpec(typeSpecIndex)); + + if (CLR_RT_TypeSystem::MatchSignature(parserLeft, parserRight)) + { + + return true; + } + } + + index.Clear(); + + return false; +} + +bool CLR_RT_Assembly::FindGenericParamAtTypeSpec( + CLR_RT_MethodDef_Instance md, + CLR_UINT32 genericParameterPosition, + CLR_RT_TypeDef_Index &index, + NanoCLRDataType &dataType) +{ + NATIVE_PROFILE_CLR_CORE(); + + CLR_RT_SignatureParser parser; + parser.Initialize_TypeSpec(md.assembly, md.assembly->GetTypeSpec(md.genericType->TypeSpec())); + + CLR_RT_SignatureParser::Element element; + + // get type + parser.Advance(element); + + for (uint32_t i = 0; i <= genericParameterPosition; i++) + { + if (FAILED(parser.Advance(element))) + { + return false; + } + } + + index = element.Class; + dataType = element.DataType; + + return true; +} + +bool CLR_RT_Assembly::FindGenericParamAtMethodDef( + CLR_RT_MethodDef_Instance md, + CLR_UINT32 genericParameterPosition, + CLR_RT_GenericParam_Index &index) +{ + NATIVE_PROFILE_CLR_CORE(); + + CLR_INDEX paramIndex = GetMethodDef(md.Method())->firstGenericParam; + + // sanity check for valid parameter index + if (paramIndex != CLR_EmptyIndex) + { + paramIndex += genericParameterPosition; + + index.Set(assemblyIndex, paramIndex); return true; } else { - idx.Clear(); + index.Clear(); return false; } } +bool CLR_RT_Assembly::FindMethodSpecFromTypeSpec(CLR_INDEX typeSpecIndex, CLR_RT_MethodSpec_Index &index) +{ + NATIVE_PROFILE_CLR_CORE(); + const CLR_RECORD_METHODSPEC *ms = this->GetMethodSpec(0); + int tblSize = this->tablesSize[TBL_MethodSpec]; + + for (int i = 0; i < tblSize; i++, ms++) + { + if (ms->container == typeSpecIndex) + { + index.Set(assemblyIndex, i); + + return true; + } + } + + index.Clear(); + + return false; +} + //--// static bool local_FindFieldDef( @@ -3155,7 +4541,7 @@ static bool local_FindFieldDef( CLR_UINT32 num, const char *szText, CLR_RT_Assembly *base, - CLR_IDX sig, + CLR_INDEX sig, CLR_RT_FieldDef_Index &res) { NATIVE_PROFILE_CLR_CORE(); @@ -3175,10 +4561,12 @@ static bool local_FindFieldDef( parserRight.Initialize_FieldDef(base, base->GetSignature(sig)); if (CLR_RT_TypeSystem::MatchSignature(parserLeft, parserRight) == false) + { continue; + } } - res.Set(assm->m_idx, first + i); + res.Set(assm->assemblyIndex, first + i); return true; } @@ -3191,39 +4579,89 @@ static bool local_FindFieldDef( bool CLR_RT_Assembly::FindFieldDef( const CLR_RECORD_TYPEDEF *td, - const char *name, + const char *fieldName, CLR_RT_Assembly *base, - CLR_IDX sig, - CLR_RT_FieldDef_Index &idx) + CLR_INDEX sig, + CLR_RT_FieldDef_Index &index) { NATIVE_PROFILE_CLR_CORE(); - if (local_FindFieldDef(this, td->iFields_First, td->iFields_Num, name, base, sig, idx)) + + if (local_FindFieldDef(this, td->firstInstanceField, td->instanceFieldsCount, fieldName, base, sig, index)) + { return true; - if (local_FindFieldDef(this, td->sFields_First, td->sFields_Num, name, base, sig, idx)) + } + + if (local_FindFieldDef(this, td->firstStaticField, td->staticFieldsCount, fieldName, base, sig, index)) + { return true; + } + + index.Clear(); + + return false; +} + +bool CLR_RT_Assembly::FindFieldDef( + const CLR_RECORD_TYPESPEC *ts, + const char *fieldName, + CLR_RT_Assembly *base, + CLR_SIG sig, + CLR_RT_FieldDef_Index &index) +{ + (void)ts; + + NATIVE_PROFILE_CLR_CORE(); + + const CLR_RECORD_FIELDDEF *fd = GetFieldDef(0); + + for (int i = 0; i < tablesSize[TBL_FieldDef]; i++, fd++) + { + const char *tempFieldName = GetString(fd->name); + + if (!strcmp(fieldName, tempFieldName)) + { + if (base) + { + CLR_RT_SignatureParser parserLeft; + parserLeft.Initialize_FieldDef(this, fd); + + CLR_RT_SignatureParser parserRight; + parserRight.Initialize_FieldSignature(base, base->GetSignature(sig)); + + if (CLR_RT_TypeSystem::MatchSignature(parserLeft, parserRight) == false) + { + continue; + } + } + + index.Set(assemblyIndex, i); + + return true; + } + } - idx.Clear(); + index.Clear(); return false; } bool CLR_RT_Assembly::FindMethodDef( const CLR_RECORD_TYPEDEF *td, - const char *name, + const char *methodName, CLR_RT_Assembly *base, CLR_SIG sig, - CLR_RT_MethodDef_Index &idx) + CLR_RT_MethodDef_Index &index) { NATIVE_PROFILE_CLR_CORE(); int i; - int num = td->vMethods_Num + td->iMethods_Num + td->sMethods_Num; - const CLR_RECORD_METHODDEF *md = GetMethodDef(td->methods_First); + int num = td->virtualMethodCount + td->instanceMethodCount + td->staticMethodCount; + const CLR_RECORD_METHODDEF *md = GetMethodDef(td->firstMethod); for (i = 0; i < num; i++, md++) { - const char *methodName = GetString(md->name); + const char *tempMethodName = GetString(md->name); - if (!strcmp(methodName, name)) + if (!strcmp(methodName, tempMethodName)) { bool fMatch = true; @@ -3239,44 +4677,98 @@ bool CLR_RT_Assembly::FindMethodDef( if (fMatch) { - idx.Set(m_idx, i + td->methods_First); + index.Set(assemblyIndex, i + td->firstMethod); return true; } } } - idx.Clear(); + index.Clear(); + + return false; +} + +bool CLR_RT_Assembly::FindMethodDef( + const CLR_RECORD_TYPESPEC *ts, + const char *methodName, + CLR_RT_Assembly *base, + CLR_SIG sig, + CLR_RT_MethodDef_Index &index) +{ + NATIVE_PROFILE_CLR_CORE(); + + CLR_RT_TypeSpec_Index tsIndex; + base->FindTypeSpec(base->GetSignature(ts->signature), tsIndex); + + CLR_RT_TypeSpec_Instance tsInstance; + tsInstance.InitializeFromIndex(tsIndex); + + auto *td = (const CLR_RECORD_TYPEDEF *)base->GetTable(TBL_TypeDef); + td += tsInstance.typeDefIndex; + + return CLR_RT_Assembly::FindMethodDef(td, methodName, base, sig, index); +} + +bool CLR_RT_Assembly::FindTypeSpec(CLR_PMETADATA sig, CLR_RT_TypeSpec_Index &index) +{ + NATIVE_PROFILE_CLR_CORE(); + + for (int i = 0; i < tablesSize[TBL_TypeSpec]; i++) + { + const CLR_RECORD_TYPESPEC *ts = GetTypeSpec(i); + + CLR_RT_SignatureParser parserLeft; + parserLeft.Initialize_TypeSpec(this, sig); + CLR_RT_SignatureParser parserRight; + parserRight.Initialize_TypeSpec(this, ts); + + if (CLR_RT_TypeSystem::MatchSignature(parserLeft, parserRight)) + { + // found it! + // set TypeSpec index + index.Set(this->assemblyIndex, i); + + // need to advance the signature to consume it + while (parserLeft.Signature != sig) + { + sig++; + } + + return true; + } + } + index.Clear(); return false; } //////////////////////////////////////////////////////////////////////////////////////////////////// -bool CLR_RT_Assembly::FindMethodBoundaries(CLR_IDX i, CLR_OFFSET &start, CLR_OFFSET &end) +bool CLR_RT_Assembly::FindMethodBoundaries(CLR_INDEX i, CLR_OFFSET &start, CLR_OFFSET &end) { NATIVE_PROFILE_CLR_CORE(); const CLR_RECORD_METHODDEF *p = GetMethodDef(i); - if (p->RVA == CLR_EmptyIndex) + if (p->rva == CLR_EmptyIndex) return false; - start = p->RVA; + start = p->rva; while (true) { p++; i++; - if (i == m_pTablesSize[TBL_MethodDef]) + if (i == tablesSize[TBL_MethodDef]) { - end = m_pTablesSize[TBL_ByteCode]; + end = tablesSize[TBL_ByteCode]; break; } - if (p->RVA != CLR_EmptyIndex) + if (p->rva != CLR_EmptyIndex) { - end = p->RVA; + end = p->rva; break; } } @@ -3284,16 +4776,16 @@ bool CLR_RT_Assembly::FindMethodBoundaries(CLR_IDX i, CLR_OFFSET &start, CLR_OFF return true; } -bool CLR_RT_Assembly::FindNextStaticConstructor(CLR_RT_MethodDef_Index &idx) +bool CLR_RT_Assembly::FindNextStaticConstructor(CLR_RT_MethodDef_Index &index) { NATIVE_PROFILE_CLR_CORE(); - _ASSERTE(m_idx == idx.Assembly()); + _ASSERTE(assemblyIndex == index.Assembly()); - for (int i = idx.Method(); i < m_pTablesSize[TBL_MethodDef]; i++) + for (int i = index.Method(); i < tablesSize[TBL_MethodDef]; i++) { const CLR_RECORD_METHODDEF *md = GetMethodDef(i); - idx.Set(m_idx, i); + index.Set(assemblyIndex, i); if (md->flags & CLR_RECORD_METHODDEF::MD_StaticConstructor) { @@ -3301,56 +4793,56 @@ bool CLR_RT_Assembly::FindNextStaticConstructor(CLR_RT_MethodDef_Index &idx) } } - idx.Clear(); + index.Clear(); return false; } //////////////////////////////////////////////////////////////////////////////////////////////////// -HRESULT CLR_RT_Assembly::Resolve_ComputeHashes() +HRESULT CLR_RT_Assembly::ResolveComputeHashes() { NATIVE_PROFILE_CLR_CORE(); NANOCLR_HEADER(); const CLR_RECORD_TYPEDEF *src = GetTypeDef(0); - CLR_RT_TypeDef_CrossReference *dst = m_pCrossReference_TypeDef; + CLR_RT_TypeDef_CrossReference *dst = crossReferenceTypeDef; - for (int i = 0; i < m_pTablesSize[TBL_TypeDef]; i++, src++, dst++) + for (int i = 0; i < tablesSize[TBL_TypeDef]; i++, src++, dst++) { - CLR_RT_TypeDef_Index idx{}; - idx.Set(m_idx, i); + CLR_RT_TypeDef_Index index{}; + index.Set(assemblyIndex, i); CLR_RT_TypeDef_Instance inst{}; - inst.InitializeFromIndex(idx); - CLR_UINT32 hash = ComputeHashForName(idx, 0); + inst.InitializeFromIndex(index); + CLR_UINT32 hash = ComputeHashForName(index, 0); while (NANOCLR_INDEX_IS_VALID(inst)) { - const CLR_RECORD_TYPEDEF *target = inst.m_target; - const CLR_RECORD_FIELDDEF *fd = inst.m_assm->GetFieldDef(target->iFields_First); + const CLR_RECORD_TYPEDEF *target = inst.target; + const CLR_RECORD_FIELDDEF *fd = inst.assembly->GetFieldDef(target->firstInstanceField); - for (int j = 0; j < target->iFields_Num; j++, fd++) + for (int j = 0; j < target->instanceFieldsCount; j++, fd++) { if ((fd->flags & CLR_RECORD_FIELDDEF::FD_NotSerialized) == 0) { CLR_RT_SignatureParser parser{}; - parser.Initialize_FieldDef(inst.m_assm, fd); + parser.Initialize_FieldDef(inst.assembly, fd); CLR_RT_SignatureParser::Element res; NANOCLR_CHECK_HRESULT(parser.Advance(res)); - while (res.m_levels-- > 0) + while (res.Levels-- > 0) { hash = ComputeHashForType(DATATYPE_SZARRAY, hash); } - hash = ComputeHashForType(res.m_dt, hash); + hash = ComputeHashForType(res.DataType, hash); - if ((res.m_dt == DATATYPE_VALUETYPE) || (res.m_dt == DATATYPE_CLASS)) + if ((res.DataType == DATATYPE_VALUETYPE) || (res.DataType == DATATYPE_CLASS)) { - hash = ComputeHashForName(res.m_cls, hash); + hash = ComputeHashForName(res.Class, hash); } - const char *fieldName = inst.m_assm->GetString(fd->name); + const char *fieldName = inst.assembly->GetString(fd->name); hash = SUPPORT_ComputeCRC(fieldName, (CLR_UINT32)hal_strlen_s(fieldName), hash); } @@ -3359,7 +4851,7 @@ HRESULT CLR_RT_Assembly::Resolve_ComputeHashes() inst.SwitchToParent(); } - dst->m_hash = hash ? hash : 0xFFFFFFFF; // Don't allow zero as an hash value!! + dst->hash = hash ? hash : 0xFFFFFFFF; // Don't allow zero as an hash value!! } NANOCLR_NOCLEANUP(); @@ -3379,10 +4871,10 @@ CLR_UINT32 CLR_RT_Assembly::ComputeHashForName(const CLR_RT_TypeDef_Index &td, C return hashPost; } -CLR_UINT32 CLR_RT_Assembly::ComputeHashForType(CLR_DataType et, CLR_UINT32 hash) +CLR_UINT32 CLR_RT_Assembly::ComputeHashForType(NanoCLRDataType et, CLR_UINT32 hash) { NATIVE_PROFILE_CLR_CORE(); - CLR_UINT8 val = (CLR_UINT8)CLR_RT_TypeSystem::MapDataTypeToElementType(et); + auto val = (CLR_UINT8)CLR_RT_TypeSystem::MapDataTypeToElementType(et); CLR_UINT32 hashPost = SUPPORT_ComputeCRC(&val, sizeof(val), hash); @@ -3405,7 +4897,7 @@ CLR_RT_HeapBlock *CLR_RT_Assembly::GetStaticField(const int index) #else - return &m_pStaticFields[index]; + return &staticFields[index]; #endif } @@ -3417,13 +4909,13 @@ void CLR_RT_Assembly::Relocate() NATIVE_PROFILE_CLR_CORE(); #if !defined(NANOCLR_APPDOMAINS) - CLR_RT_GarbageCollector::Heap_Relocate(m_pStaticFields, m_iStaticFields); + CLR_RT_GarbageCollector::Heap_Relocate(staticFields, staticFieldsCount); #endif - CLR_RT_GarbageCollector::Heap_Relocate((void **)&m_header); - CLR_RT_GarbageCollector::Heap_Relocate((void **)&m_szName); - CLR_RT_GarbageCollector::Heap_Relocate((void **)&m_pFile); - CLR_RT_GarbageCollector::Heap_Relocate((void **)&m_nativeCode); + CLR_RT_GarbageCollector::Heap_Relocate((void **)&header); + CLR_RT_GarbageCollector::Heap_Relocate((void **)&name); + CLR_RT_GarbageCollector::Heap_Relocate((void **)&file); + CLR_RT_GarbageCollector::Heap_Relocate((void **)&nativeCode); } //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -3442,7 +4934,7 @@ void CLR_RT_TypeSystem::TypeSystem_Cleanup() { pASSM->DestroyInstance(); - *ppASSM = NULL; + *ppASSM = nullptr; } NANOCLR_FOREACH_ASSEMBLY_END(); @@ -3458,12 +4950,12 @@ void CLR_RT_TypeSystem::Link(CLR_RT_Assembly *assm) { *ppASSM = assm; - assm->m_idx = idx; + assm->assemblyIndex = index; PostLinkageProcessing(assm); - if (m_assembliesMax < idx) - m_assembliesMax = idx; + if (m_assembliesMax < index) + m_assembliesMax = index; return; } @@ -3473,11 +4965,11 @@ void CLR_RT_TypeSystem::Link(CLR_RT_Assembly *assm) void CLR_RT_TypeSystem::PostLinkageProcessing(CLR_RT_Assembly *assm) { NATIVE_PROFILE_CLR_CORE(); - if (!strcmp(assm->m_szName, "mscorlib")) + if (!strcmp(assm->name, "mscorlib")) { m_assemblyMscorlib = assm; } - if (!strcmp(assm->m_szName, "nanoFramework.Runtime.Native")) + if (!strcmp(assm->name, "nanoFramework.Runtime.Native")) { m_assemblyNative = assm; } @@ -3489,17 +4981,17 @@ CLR_RT_Assembly *CLR_RT_TypeSystem::FindAssembly(const char *szName, const CLR_R NANOCLR_FOREACH_ASSEMBLY(*this) { - if (!strcmp(pASSM->m_szName, szName)) + if (!strcmp(pASSM->name, szName)) { // if there is no version information, anything goes - if (NULL == ver) + if (nullptr == ver) { return pASSM; } // exact match requested: must take into accoutn all numbers in the version else if (fExact) { - if (0 == memcmp(&pASSM->m_header->version, ver, sizeof(*ver))) + if (0 == memcmp(&pASSM->header->version, ver, sizeof(*ver))) { return pASSM; } @@ -3508,8 +5000,8 @@ CLR_RT_Assembly *CLR_RT_TypeSystem::FindAssembly(const char *szName, const CLR_R // we will enforce only the first two number because (by convention) // only the minor field is required to be bumped when native assemblies change CRC else if ( - ver->iMajorVersion == pASSM->m_header->version.iMajorVersion && - ver->iMinorVersion == pASSM->m_header->version.iMinorVersion) + ver->majorVersion == pASSM->header->version.majorVersion && + ver->minorVersion == pASSM->header->version.minorVersion) { return pASSM; } @@ -3517,7 +5009,7 @@ CLR_RT_Assembly *CLR_RT_TypeSystem::FindAssembly(const char *szName, const CLR_R } NANOCLR_FOREACH_ASSEMBLY_END(); - return NULL; + return nullptr; } bool CLR_RT_TypeSystem::FindTypeDef( @@ -3587,8 +5079,8 @@ bool CLR_RT_TypeSystem::FindTypeDef(const char *szClass, CLR_RT_Assembly *assm, if (hal_strlen_s(szClass) < ARRAYSIZE(rgNamespace)) { const char *szPtr = szClass; - const char *szPtr_LastDot = NULL; - const char *szPtr_FirstSubType = NULL; + const char *szPtr_LastDot = nullptr; + const char *szPtr_FirstSubType = nullptr; char c; size_t len; @@ -3641,10 +5133,14 @@ bool CLR_RT_TypeSystem::FindTypeDef(const char *szClass, CLR_RT_Assembly *assm, { c = szPtr_FirstSubType[0]; if (!c) + { break; + } if (c == '+') + { break; + } szPtr_FirstSubType++; } @@ -3654,7 +5150,7 @@ bool CLR_RT_TypeSystem::FindTypeDef(const char *szClass, CLR_RT_Assembly *assm, inst.InitializeFromIndex(res); - if (inst.m_assm->FindTypeDef(rgName, res.Type(), res) == false) + if (inst.assembly->FindTypeDef(rgName, res.Type(), res) == false) { return false; } @@ -3686,8 +5182,8 @@ bool CLR_RT_TypeSystem::FindTypeDef(const char *szClass, CLR_RT_Assembly *assm, if (hal_strlen_s(szClass) < ARRAYSIZE(rgNamespace)) { const char *szPtr = szClass; - const char *szPtr_LastDot = NULL; - const char *szPtr_FirstSubType = NULL; + const char *szPtr_LastDot = nullptr; + const char *szPtr_FirstSubType = nullptr; char c; size_t len; bool arrayType = false; @@ -3763,7 +5259,7 @@ bool CLR_RT_TypeSystem::FindTypeDef(const char *szClass, CLR_RT_Assembly *assm, inst.InitializeFromIndex(res); - if (inst.m_assm->FindTypeDef(rgName, res.Type(), res) == false) + if (inst.assembly->FindTypeDef(rgName, res.Type(), res) == false) { return false; } @@ -3771,10 +5267,10 @@ bool CLR_RT_TypeSystem::FindTypeDef(const char *szClass, CLR_RT_Assembly *assm, } while (c == '+'); } - reflex.m_kind = REFLECTION_TYPE; + reflex.kind = REFLECTION_TYPE; // make sure this works for multidimensional arrays. - reflex.m_levels = arrayType ? 1 : 0; - reflex.m_data.m_type = res; + reflex.levels = arrayType ? 1 : 0; + reflex.data.type = res; return true; } } @@ -3793,8 +5289,8 @@ int CompareResource(const void *p1, const void *p2) { NATIVE_PROFILE_CLR_CORE(); - const CLR_RECORD_RESOURCE *resource1 = (const CLR_RECORD_RESOURCE *)p1; - const CLR_RECORD_RESOURCE *resource2 = (const CLR_RECORD_RESOURCE *)p2; + auto *resource1 = (const CLR_RECORD_RESOURCE *)p1; + auto *resource2 = (const CLR_RECORD_RESOURCE *)p2; return (int)resource1->id - (int)resource2->id; } @@ -3802,16 +5298,16 @@ int HRESULT CLR_RT_TypeSystem::LocateResourceFile( CLR_RT_Assembly_Instance assm, const char *name, - CLR_INT32 &idxResourceFile) + CLR_INT32 &indexResourceFile) { NATIVE_PROFILE_CLR_CORE(); NANOCLR_HEADER(); - CLR_RT_Assembly *pAssm = assm.m_assm; + CLR_RT_Assembly *pAssm = assm.assembly; - for (idxResourceFile = 0; idxResourceFile < pAssm->m_pTablesSize[TBL_ResourcesFiles]; idxResourceFile++) + for (indexResourceFile = 0; indexResourceFile < pAssm->tablesSize[TBL_ResourcesFiles]; indexResourceFile++) { - const CLR_RECORD_RESOURCE_FILE *resourceFile = pAssm->GetResourceFile(idxResourceFile); + const CLR_RECORD_RESOURCE_FILE *resourceFile = pAssm->GetResourceFile(indexResourceFile); if (!strcmp(pAssm->GetString(resourceFile->name), name)) { @@ -3819,14 +5315,14 @@ HRESULT CLR_RT_TypeSystem::LocateResourceFile( } } - idxResourceFile = -1; + indexResourceFile = -1; NANOCLR_NOCLEANUP(); } HRESULT CLR_RT_TypeSystem::LocateResource( CLR_RT_Assembly_Instance assm, - CLR_INT32 idxResourceFile, + CLR_INT32 indexResourceFile, CLR_INT16 id, const CLR_RECORD_RESOURCE *&res, CLR_UINT32 &size) @@ -3834,19 +5330,19 @@ HRESULT CLR_RT_TypeSystem::LocateResource( NATIVE_PROFILE_CLR_CORE(); NANOCLR_HEADER(); - CLR_RT_Assembly *pAssm = assm.m_assm; + CLR_RT_Assembly *pAssm = assm.assembly; const CLR_RECORD_RESOURCE_FILE *resourceFile; CLR_RECORD_RESOURCE resourceT; const CLR_RECORD_RESOURCE *resNext; const CLR_RECORD_RESOURCE *resZero; - res = NULL; + res = nullptr; size = 0; - if (idxResourceFile < 0 || idxResourceFile >= pAssm->m_pTablesSize[TBL_ResourcesFiles]) + if (indexResourceFile < 0 || indexResourceFile >= pAssm->tablesSize[TBL_ResourcesFiles]) NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER); - resourceFile = pAssm->GetResourceFile(idxResourceFile); + resourceFile = pAssm->GetResourceFile(indexResourceFile); _ASSERTE(resourceFile->numberOfResources > 0); @@ -3857,11 +5353,11 @@ HRESULT CLR_RT_TypeSystem::LocateResource( res = (const CLR_RECORD_RESOURCE *) bsearch(&resourceT, resZero, resourceFile->numberOfResources, sizeof(CLR_RECORD_RESOURCE), CompareResource); - if (res != NULL) + if (res != nullptr) { // compute size here... // assert not the last resource - _ASSERTE(res + 1 <= pAssm->GetResource(pAssm->m_pTablesSize[TBL_Resources] - 1)); + _ASSERTE(res + 1 <= pAssm->GetResource(pAssm->tablesSize[TBL_Resources] - 1)); resNext = res + 1; size = resNext->offset - res->offset; @@ -3887,29 +5383,30 @@ HRESULT CLR_RT_TypeSystem::ResolveAll() NANOCLR_FOREACH_ASSEMBLY(*this) { - if ((pASSM->m_flags & CLR_RT_Assembly::Resolved) == 0) + if ((pASSM->flags & CLR_RT_Assembly::Resolved) == 0) { fNeedResolution = true; - if (pASSM->Resolve_AssemblyRef(fOutput)) + if (pASSM->ResolveAssemblyRef(fOutput)) { fGot = true; - pASSM->m_flags |= CLR_RT_Assembly::Resolved; + pASSM->flags |= CLR_RT_Assembly::Resolved; - NANOCLR_CHECK_HRESULT(pASSM->Resolve_TypeRef()); - NANOCLR_CHECK_HRESULT(pASSM->Resolve_FieldRef()); - NANOCLR_CHECK_HRESULT(pASSM->Resolve_MethodRef()); - /********************/ pASSM->Resolve_TypeDef(); - /********************/ pASSM->Resolve_MethodDef(); - /********************/ pASSM->Resolve_Link(); - NANOCLR_CHECK_HRESULT(pASSM->Resolve_ComputeHashes()); + NANOCLR_CHECK_HRESULT(pASSM->ResolveTypeRef()); + NANOCLR_CHECK_HRESULT(pASSM->ResolveFieldRef()); + NANOCLR_CHECK_HRESULT(pASSM->ResolveMethodRef()); + /********************/ pASSM->ResolveTypeDef(); + /********************/ pASSM->ResolveMethodDef(); + NANOCLR_CHECK_HRESULT(pASSM->ResolveTypeSpec()); + /********************/ pASSM->ResolveLink(); + NANOCLR_CHECK_HRESULT(pASSM->ResolveComputeHashes()); #if !defined(NANOCLR_APPDOMAINS) - NANOCLR_CHECK_HRESULT(pASSM->Resolve_AllocateStaticFields(pASSM->m_pStaticFields)); + NANOCLR_CHECK_HRESULT(pASSM->ResolveAllocateStaticFields(pASSM->staticFields)); #endif - pASSM->m_flags |= CLR_RT_Assembly::ResolutionCompleted; + pASSM->flags |= CLR_RT_Assembly::ResolutionCompleted; } } } @@ -3954,63 +5451,65 @@ HRESULT CLR_RT_TypeSystem::ResolveAll() NANOCLR_FOREACH_ASSEMBLY(*this) { - offsets.iBase += ROUNDTOMULTIPLE(sizeof(CLR_RT_Assembly), CLR_UINT32); - offsets.iAssemblyRef += ROUNDTOMULTIPLE( - pASSM->m_pTablesSize[TBL_AssemblyRef] * sizeof(CLR_RT_AssemblyRef_CrossReference), - CLR_UINT32); - offsets.iTypeRef += ROUNDTOMULTIPLE( - pASSM->m_pTablesSize[TBL_TypeRef] * sizeof(CLR_RT_TypeRef_CrossReference), + offsets.base += ROUNDTOMULTIPLE(sizeof(CLR_RT_Assembly), CLR_UINT32); + offsets.assemblyRef += ROUNDTOMULTIPLE( + pASSM->tablesSize[TBL_AssemblyRef] * sizeof(CLR_RT_AssemblyRef_CrossReference), CLR_UINT32); - offsets.iFieldRef += ROUNDTOMULTIPLE( - pASSM->m_pTablesSize[TBL_FieldRef] * sizeof(CLR_RT_FieldRef_CrossReference), + offsets.typeRef += + ROUNDTOMULTIPLE(pASSM->tablesSize[TBL_TypeRef] * sizeof(CLR_RT_TypeRef_CrossReference), CLR_UINT32); + offsets.fieldRef += ROUNDTOMULTIPLE( + pASSM->tablesSize[TBL_FieldRef] * sizeof(CLR_RT_FieldRef_CrossReference), CLR_UINT32); - offsets.iMethodRef += ROUNDTOMULTIPLE( - pASSM->m_pTablesSize[TBL_MethodRef] * sizeof(CLR_RT_MethodRef_CrossReference), + offsets.methodRef += ROUNDTOMULTIPLE( + pASSM->tablesSize[TBL_MethodRef] * sizeof(CLR_RT_MethodRef_CrossReference), CLR_UINT32); - offsets.iTypeDef += ROUNDTOMULTIPLE( - pASSM->m_pTablesSize[TBL_TypeDef] * sizeof(CLR_RT_TypeDef_CrossReference), + offsets.typeDef += + ROUNDTOMULTIPLE(pASSM->tablesSize[TBL_TypeDef] * sizeof(CLR_RT_TypeDef_CrossReference), CLR_UINT32); + offsets.fieldDef += ROUNDTOMULTIPLE( + pASSM->tablesSize[TBL_FieldDef] * sizeof(CLR_RT_FieldDef_CrossReference), CLR_UINT32); - offsets.iFieldDef += ROUNDTOMULTIPLE( - pASSM->m_pTablesSize[TBL_FieldDef] * sizeof(CLR_RT_FieldDef_CrossReference), + offsets.methodDef += ROUNDTOMULTIPLE( + pASSM->tablesSize[TBL_MethodDef] * sizeof(CLR_RT_MethodDef_CrossReference), CLR_UINT32); - offsets.iMethodDef += ROUNDTOMULTIPLE( - pASSM->m_pTablesSize[TBL_MethodDef] * sizeof(CLR_RT_MethodDef_CrossReference), + offsets.genericParam += ROUNDTOMULTIPLE( + pASSM->tablesSize[TBL_GenericParam] * sizeof(CLR_RT_GenericParam_CrossReference), CLR_UINT32); #if !defined(NANOCLR_APPDOMAINS) - offsets.iStaticFields += - ROUNDTOMULTIPLE(pASSM->m_iStaticFields * sizeof(struct CLR_RT_HeapBlock), CLR_UINT32); + offsets.staticFieldsCount += + ROUNDTOMULTIPLE(pASSM->staticFieldsCount * sizeof(CLR_RT_HeapBlock), CLR_UINT32); #endif #if defined(NANOCLR_ENABLE_SOURCELEVELDEBUGGING) - offsets.iDebuggingInfoMethods += ROUNDTOMULTIPLE( - pASSM->m_pTablesSize[TBL_MethodDef] * sizeof(CLR_RT_MethodDef_DebuggingInfo), + offsets.debuggingInfoMethods += ROUNDTOMULTIPLE( + pASSM->tablesSize[TBL_MethodDef] * sizeof(CLR_RT_MethodDef_DebuggingInfo), CLR_UINT32); #endif // #if defined(NANOCLR_ENABLE_SOURCELEVELDEBUGGING) - iMetaData += pASSM->m_header->SizeOfTable(TBL_AssemblyRef) + pASSM->m_header->SizeOfTable(TBL_TypeRef) + - pASSM->m_header->SizeOfTable(TBL_FieldRef) + pASSM->m_header->SizeOfTable(TBL_MethodRef) + - pASSM->m_header->SizeOfTable(TBL_TypeDef) + pASSM->m_header->SizeOfTable(TBL_FieldDef) + - pASSM->m_header->SizeOfTable(TBL_MethodDef) + - pASSM->m_header->SizeOfTable(TBL_Attributes) + pASSM->m_header->SizeOfTable(TBL_TypeSpec) + - pASSM->m_header->SizeOfTable(TBL_Signatures); + iMetaData += pASSM->header->SizeOfTable(TBL_AssemblyRef) + pASSM->header->SizeOfTable(TBL_TypeRef) + + pASSM->header->SizeOfTable(TBL_FieldRef) + pASSM->header->SizeOfTable(TBL_MethodRef) + + pASSM->header->SizeOfTable(TBL_TypeDef) + pASSM->header->SizeOfTable(TBL_FieldDef) + + pASSM->header->SizeOfTable(TBL_MethodDef) + pASSM->header->SizeOfTable(TBL_GenericParam) + + pASSM->header->SizeOfTable(TBL_TypeSpec) + pASSM->header->SizeOfTable(TBL_Attributes) + + pASSM->header->SizeOfTable(TBL_Signatures); for (int tbl = 0; tbl < TBL_Max; tbl++) { - pTablesSize[tbl] += pASSM->m_pTablesSize[tbl]; + pTablesSize[tbl] += pASSM->tablesSize[tbl]; } - iTotalRomSize += pASSM->m_header->TotalSize(); + iTotalRomSize += pASSM->header->TotalSize(); - iStaticFields += pASSM->m_iStaticFields; + iStaticFields += pASSM->staticFieldsCount; } NANOCLR_FOREACH_ASSEMBLY_END(); - iTotalRamSize = offsets.iBase + offsets.iAssemblyRef + offsets.iTypeRef + offsets.iFieldRef + - offsets.iMethodRef + offsets.iTypeDef + offsets.iFieldDef + offsets.iMethodDef; + iTotalRamSize = offsets.base + offsets.assemblyRef + offsets.typeRef + offsets.fieldRef + + offsets.methodRef + offsets.typeDef + offsets.fieldDef + offsets.methodDef + + offsets.genericParam; #if !defined(NANOCLR_APPDOMAINS) - iTotalRamSize += offsets.iStaticFields; + iTotalRamSize += offsets.staticFieldsCount; #endif CLR_Debug::Printf( @@ -4020,65 +5519,76 @@ HRESULT CLR_RT_TypeSystem::ResolveAll() iMetaData); CLR_Debug::Printf( - " AssemblyRef = %8d bytes (%8d elements)\r\n", - offsets.iAssemblyRef, + " AssemblyRef = %6d bytes (%5d elements)\r\n", + offsets.assemblyRef, pTablesSize[TBL_AssemblyRef]); CLR_Debug::Printf( - " TypeRef = %8d bytes (%8d elements)\r\n", - offsets.iTypeRef, + " TypeRef = %6d bytes (%5d elements)\r\n", + offsets.typeRef, pTablesSize[TBL_TypeRef]); CLR_Debug::Printf( - " FieldRef = %8d bytes (%8d elements)\r\n", - offsets.iFieldRef, + " FieldRef = %6d bytes (%5d elements)\r\n", + offsets.fieldRef, pTablesSize[TBL_FieldRef]); CLR_Debug::Printf( - " MethodRef = %8d bytes (%8d elements)\r\n", - offsets.iMethodRef, + " MethodRef = %6d bytes (%5d elements)\r\n", + offsets.methodRef, pTablesSize[TBL_MethodRef]); CLR_Debug::Printf( - " TypeDef = %8d bytes (%8d elements)\r\n", - offsets.iTypeDef, + " TypeDef = %6d bytes (%5d elements)\r\n", + offsets.typeDef, pTablesSize[TBL_TypeDef]); CLR_Debug::Printf( - " FieldDef = %8d bytes (%8d elements)\r\n", - offsets.iFieldDef, + " FieldDef = %6d bytes (%5d elements)\r\n", + offsets.fieldDef, pTablesSize[TBL_FieldDef]); CLR_Debug::Printf( - " MethodDef = %8d bytes (%8d elements)\r\n", - offsets.iMethodDef, + " MethodDef = %6d bytes (%5d elements)\r\n", + offsets.methodDef, pTablesSize[TBL_MethodDef]); + CLR_Debug::Printf( + " GenericParam = %6d bytes (%5d elements)\r\n", + offsets.genericParam, + pTablesSize[TBL_GenericParam]); + CLR_Debug::Printf( + " MethodSpec = %6d bytes (%5d elements)\r\n", + offsets.methodSpec, + pTablesSize[TBL_MethodSpec]); #if !defined(NANOCLR_APPDOMAINS) - CLR_Debug::Printf(" StaticFields = %8d bytes (%8d elements)\r\n", offsets.iStaticFields, iStaticFields); + CLR_Debug::Printf( + " StaticFields = %6d bytes (%5d elements)\r\n", + offsets.staticFieldsCount, + iStaticFields); #endif CLR_Debug::Printf("\r\n"); #if defined(NANOCLR_ENABLE_SOURCELEVELDEBUGGING) - CLR_Debug::Printf(" DebuggingInfo = %8d bytes\r\n", offsets.iDebuggingInfoMethods); + CLR_Debug::Printf(" DebuggingInfo = %6d bytes\r\n", offsets.debuggingInfoMethods); CLR_Debug::Printf("\r\n"); #endif // #if defined(NANOCLR_ENABLE_SOURCELEVELDEBUGGING) CLR_Debug::Printf( - " Attributes = %8d bytes (%8d elements)\r\n", + " Attributes = %6d bytes (%5d elements)\r\n", pTablesSize[TBL_Attributes] * sizeof(CLR_RECORD_ATTRIBUTE), pTablesSize[TBL_Attributes]); CLR_Debug::Printf( - " TypeSpec = %8d bytes (%8d elements)\r\n", + " TypeSpec = %6d bytes (%5d elements)\r\n", pTablesSize[TBL_TypeSpec] * sizeof(CLR_RECORD_TYPESPEC), pTablesSize[TBL_TypeSpec]); CLR_Debug::Printf( - " Resources Files = %8d bytes (%8d elements)\r\n", + " Resources Files = %6d bytes (%5d elements)\r\n", pTablesSize[TBL_ResourcesFiles] * sizeof(CLR_RECORD_RESOURCE_FILE), pTablesSize[TBL_ResourcesFiles]); CLR_Debug::Printf( - " Resources = %8d bytes (%8d elements)\r\n", + " Resources = %6d bytes (%5d elements)\r\n", pTablesSize[TBL_Resources] * sizeof(CLR_RECORD_RESOURCE), pTablesSize[TBL_Resources]); - CLR_Debug::Printf(" Resources Data = %8d bytes\r\n", pTablesSize[TBL_ResourcesData]); - CLR_Debug::Printf(" Strings = %8d bytes\r\n", pTablesSize[TBL_Strings]); - CLR_Debug::Printf(" Signatures = %8d bytes\r\n", pTablesSize[TBL_Signatures]); - CLR_Debug::Printf(" ByteCode = %8d bytes\r\n", pTablesSize[TBL_ByteCode]); + CLR_Debug::Printf(" Resources Data = %6d bytes\r\n", pTablesSize[TBL_ResourcesData]); + CLR_Debug::Printf(" Strings = %6d bytes\r\n", pTablesSize[TBL_Strings]); + CLR_Debug::Printf(" Signatures = %6d bytes\r\n", pTablesSize[TBL_Signatures]); + CLR_Debug::Printf(" ByteCode = %6d bytes\r\n", pTablesSize[TBL_ByteCode]); CLR_Debug::Printf("\r\n\r\n"); } } @@ -4095,7 +5605,7 @@ HRESULT CLR_RT_TypeSystem::PrepareForExecutionHelper(const char *szAssembly) NANOCLR_FOREACH_ASSEMBLY(*this) { - if (!strcmp(szAssembly, pASSM->m_szName)) + if (!strcmp(szAssembly, pASSM->name)) { NANOCLR_CHECK_HRESULT(pASSM->PrepareForExecution()); } @@ -4120,12 +5630,12 @@ HRESULT CLR_RT_TypeSystem::PrepareForExecution() // Preemptively create an out of memory exception. // We can never get into a case where an out of memory exception cannot be thrown. - if (g_CLR_RT_ExecutionEngine.m_outOfMemoryException == NULL) + if (g_CLR_RT_ExecutionEngine.m_outOfMemoryException == nullptr) { CLR_RT_HeapBlock exception; NANOCLR_CHECK_HRESULT( - g_CLR_RT_ExecutionEngine.NewObjectFromIndex(exception, g_CLR_RT_WellKnownTypes.m_OutOfMemoryException)); + g_CLR_RT_ExecutionEngine.NewObjectFromIndex(exception, g_CLR_RT_WellKnownTypes.OutOfMemoryException)); g_CLR_RT_ExecutionEngine.m_outOfMemoryException = exception.Dereference(); } @@ -4159,10 +5669,16 @@ HRESULT CLR_RT_TypeSystem::PrepareForExecution() bool CLR_RT_TypeSystem::MatchSignature(CLR_RT_SignatureParser &parserLeft, CLR_RT_SignatureParser &parserRight) { NATIVE_PROFILE_CLR_CORE(); - if (parserLeft.m_type != parserRight.m_type) + + if (parserLeft.Type != parserRight.Type) + { return false; - if (parserLeft.m_flags != parserRight.m_flags) + } + + if (parserLeft.Flags != parserRight.Flags) + { return false; + } return MatchSignatureDirect(parserLeft, parserRight, false); } @@ -4179,20 +5695,31 @@ bool CLR_RT_TypeSystem::MatchSignatureDirect( int iAvailRight = parserRight.Available(); if (iAvailLeft != iAvailRight) + { return false; + } if (!iAvailLeft) + { return true; + } CLR_RT_SignatureParser::Element resLeft; if (FAILED(parserLeft.Advance(resLeft))) + { return false; + } + CLR_RT_SignatureParser::Element resRight; if (FAILED(parserRight.Advance(resRight))) + { return false; + } - if (!MatchSignatureElement(resLeft, resRight, fIsInstanceOfOK)) + if (!MatchSignatureElement(resLeft, resRight, parserLeft, parserRight, fIsInstanceOfOK)) + { return false; + } } return true; @@ -4201,42 +5728,103 @@ bool CLR_RT_TypeSystem::MatchSignatureDirect( bool CLR_RT_TypeSystem::MatchSignatureElement( CLR_RT_SignatureParser::Element &resLeft, CLR_RT_SignatureParser::Element &resRight, + CLR_RT_SignatureParser &parserLeft, + CLR_RT_SignatureParser &parserRight, bool fIsInstanceOfOK) { NATIVE_PROFILE_CLR_CORE(); if (fIsInstanceOfOK) { - CLR_RT_ReflectionDef_Index idxLeft; + CLR_RT_ReflectionDef_Index indexLeft; CLR_RT_TypeDescriptor descLeft; - CLR_RT_ReflectionDef_Index idxRight; + CLR_RT_ReflectionDef_Index indexRight; CLR_RT_TypeDescriptor descRight; - idxLeft.m_kind = REFLECTION_TYPE; - idxLeft.m_levels = resLeft.m_levels; - idxLeft.m_data.m_type = resLeft.m_cls; + indexLeft.kind = REFLECTION_TYPE; + indexLeft.levels = resLeft.Levels; + indexLeft.data.type = resLeft.Class; - idxRight.m_kind = REFLECTION_TYPE; - idxRight.m_levels = resRight.m_levels; - idxRight.m_data.m_type = resRight.m_cls; + indexRight.kind = REFLECTION_TYPE; + indexRight.levels = resRight.Levels; + indexRight.data.type = resRight.Class; - if (FAILED(descLeft.InitializeFromReflection(idxLeft))) + if (FAILED(descLeft.InitializeFromReflection(indexLeft))) + { return false; - if (FAILED(descRight.InitializeFromReflection(idxRight))) + } + + if (FAILED(descRight.InitializeFromReflection(indexRight))) + { return false; + } if (!CLR_RT_ExecutionEngine::IsInstanceOf(descRight, descLeft, false)) + { return false; + } } else { - if (resLeft.m_fByRef != resRight.m_fByRef) + if (resLeft.IsByRef != resRight.IsByRef) + { + return false; + } + + if (resLeft.Levels != resRight.Levels) + { + return false; + } + + if (resLeft.DataType != resRight.DataType) + { + return false; + } + + if (resLeft.Class.data != resRight.Class.data) + { return false; - if (resLeft.m_levels != resRight.m_levels) + } + + if ((resLeft.DataType == DATATYPE_MVAR && resRight.DataType == DATATYPE_MVAR) && + (resLeft.GenericParamPosition != resRight.GenericParamPosition)) + { return false; - if (resLeft.m_dt != resRight.m_dt) + } + + if ((resLeft.DataType == DATATYPE_VAR && resRight.DataType == DATATYPE_VAR) && + (resLeft.GenericParamPosition != resRight.GenericParamPosition)) + { return false; - if (resLeft.m_cls.m_data != resRight.m_cls.m_data) + } + + if (parserLeft.IsGenericInst != parserRight.IsGenericInst) + { return false; + } + + if (parserLeft.IsGenericInst || parserRight.IsGenericInst) + { + if (resLeft.GenericParamPosition == 0xFFFF && resRight.GenericParamPosition == 0xFFFF) + { + // need to check if type of generic parameters match, if there are more + if (parserLeft.ParamCount > 0 && parserRight.ParamCount > 0) + { + if (FAILED(parserLeft.Advance(resLeft)) || FAILED(parserRight.Advance(resRight))) + { + return false; + } + } + + if (resLeft.DataType != resRight.DataType) + { + return false; + } + } + else if (resLeft.GenericParamPosition != resRight.GenericParamPosition) + { + return false; + } + } } return true; @@ -4264,6 +5852,51 @@ HRESULT CLR_RT_TypeSystem::QueueStringToBuffer(char *&szBuffer, size_t &iBuffer, NANOCLR_NOCLEANUP(); } +HRESULT CLR_RT_TypeSystem::BuildTypeName(const CLR_RT_TypeSpec_Index &typeIndex, char *&szBuffer, size_t &iBuffer) +{ + NATIVE_PROFILE_CLR_CORE(); + NANOCLR_HEADER(); + + CLR_RT_TypeSpec_Instance instance; + + if (instance.InitializeFromIndex(typeIndex) == false) + { + NANOCLR_SET_AND_LEAVE(CLR_E_WRONG_TYPE); + } + + CLR_RT_SignatureParser parser; + parser.Initialize_TypeSpec(instance.assembly, instance.assembly->GetTypeSpec(typeIndex.TypeSpec())); + + CLR_RT_SignatureParser::Element element; + + // get type + parser.Advance(element); + + CLR_RT_TypeDef_Index typeDef; + typeDef.data = element.Class.data; + + BuildTypeName(typeDef, szBuffer, iBuffer); + + NANOCLR_CHECK_HRESULT(QueueStringToBuffer(szBuffer, iBuffer, "<")); + + for (int i = 0; i < parser.GenParamCount; i++) + { + parser.Advance(element); + +#if defined(VIRTUAL_DEVICE) + NANOCLR_CHECK_HRESULT(QueueStringToBuffer(szBuffer, iBuffer, c_CLR_RT_DataTypeLookup[element.DataType].m_name)); +#endif + if (i + 1 < parser.GenParamCount) + { + NANOCLR_CHECK_HRESULT(QueueStringToBuffer(szBuffer, iBuffer, ",")); + } + } + + CLR_SafeSprintf(szBuffer, iBuffer, ">"); + + NANOCLR_NOCLEANUP(); +} + HRESULT CLR_RT_TypeSystem::BuildTypeName(const CLR_RT_TypeDef_Index &cls, char *&szBuffer, size_t &iBuffer) { NATIVE_PROFILE_CLR_CORE(); @@ -4288,14 +5921,14 @@ HRESULT CLR_RT_TypeSystem::BuildTypeName( if (inst.InitializeFromIndex(cls) == false) NANOCLR_SET_AND_LEAVE(CLR_E_WRONG_TYPE); - assm = inst.m_assm; - td = inst.m_target; + assm = inst.assembly; + td = inst.target; fFullName = flags & CLR_RT_TypeSystem::TYPENAME_FLAGS_FULL; - if (fFullName && td->enclosingType != CLR_EmptyIndex) + if (fFullName && td->HasValidEnclosingType()) { CLR_RT_TypeDef_Index clsSub; - clsSub.Set(inst.Assembly(), td->enclosingType); + clsSub.Set(inst.Assembly(), td->EnclosingTypeIndex()); NANOCLR_CHECK_HRESULT(BuildTypeName(clsSub, szBuffer, iBuffer, flags, 0)); @@ -4326,7 +5959,11 @@ HRESULT CLR_RT_TypeSystem::BuildTypeName( NANOCLR_NOCLEANUP(); } -HRESULT CLR_RT_TypeSystem::BuildMethodName(const CLR_RT_MethodDef_Index &md, char *&szBuffer, size_t &iBuffer) +HRESULT CLR_RT_TypeSystem::BuildMethodName( + const CLR_RT_MethodDef_Index &md, + const CLR_RT_TypeSpec_Index *genericType, + char *&szBuffer, + size_t &iBuffer) { NATIVE_PROFILE_CLR_CORE(); NANOCLR_HEADER(); @@ -4335,13 +5972,54 @@ HRESULT CLR_RT_TypeSystem::BuildMethodName(const CLR_RT_MethodDef_Index &md, cha CLR_RT_TypeDef_Instance instOwner{}; if (inst.InitializeFromIndex(md) == false) + { NANOCLR_SET_AND_LEAVE(CLR_E_WRONG_TYPE); + } + if (instOwner.InitializeFromMethod(inst) == false) + { NANOCLR_SET_AND_LEAVE(CLR_E_WRONG_TYPE); + } - NANOCLR_CHECK_HRESULT(BuildTypeName(instOwner, szBuffer, iBuffer)); + if (genericType == nullptr) + { + NANOCLR_CHECK_HRESULT(BuildTypeName(instOwner, szBuffer, iBuffer)); + + CLR_SafeSprintf(szBuffer, iBuffer, "::%s", inst.assembly->GetString(inst.target->name)); + } + else + { + CLR_RT_SignatureParser parser; + parser.Initialize_TypeSpec(inst.assembly, inst.assembly->GetTypeSpec(genericType->TypeSpec())); + + CLR_RT_SignatureParser::Element element; + + // get type + parser.Advance(element); + + CLR_RT_TypeDef_Index typeDef; + typeDef.data = element.Class.data; + + BuildTypeName(typeDef, szBuffer, iBuffer); + + NANOCLR_CHECK_HRESULT(QueueStringToBuffer(szBuffer, iBuffer, "<")); + + for (int i = 0; i < parser.GenParamCount; i++) + { + parser.Advance(element); + +#if defined(VIRTUAL_DEVICE) + NANOCLR_CHECK_HRESULT( + QueueStringToBuffer(szBuffer, iBuffer, c_CLR_RT_DataTypeLookup[element.DataType].m_name)); +#endif + if (i + 1 < parser.GenParamCount) + { + NANOCLR_CHECK_HRESULT(QueueStringToBuffer(szBuffer, iBuffer, ",")); + } + } - CLR_SafeSprintf(szBuffer, iBuffer, "::%s", inst.m_assm->GetString(inst.m_target->name)); + CLR_SafeSprintf(szBuffer, iBuffer, ">::%s", inst.assembly->GetString(inst.target->name)); + } NANOCLR_NOCLEANUP(); } @@ -4355,13 +6033,173 @@ HRESULT CLR_RT_TypeSystem::BuildFieldName(const CLR_RT_FieldDef_Index &fd, char CLR_RT_TypeDef_Instance instOwner{}; if (inst.InitializeFromIndex(fd) == false) + { NANOCLR_SET_AND_LEAVE(CLR_E_WRONG_TYPE); + } + if (instOwner.InitializeFromField(inst) == false) + { NANOCLR_SET_AND_LEAVE(CLR_E_WRONG_TYPE); + } NANOCLR_CHECK_HRESULT(BuildTypeName(instOwner, szBuffer, iBuffer)); - CLR_SafeSprintf(szBuffer, iBuffer, "::%s", inst.m_assm->GetString(inst.m_target->name)); + CLR_SafeSprintf(szBuffer, iBuffer, "::%s", inst.assembly->GetString(inst.target->name)); + + NANOCLR_NOCLEANUP(); +} + +HRESULT CLR_RT_TypeSystem::BuildMethodRefName(const CLR_RT_MethodRef_Index &method, char *&szBuffer, size_t &iBuffer) +{ + NATIVE_PROFILE_CLR_CORE(); + NANOCLR_HEADER(); + + CLR_RT_Assembly *assembly = g_CLR_RT_TypeSystem.m_assemblies[method.Assembly() - 1]; + + const CLR_RT_MethodRef_CrossReference memberCrossRef = assembly->crossReferenceMethodRef[method.Method()]; + const CLR_RECORD_METHODREF *methodRef = assembly->GetMethodRef(method.Method()); + + if (memberCrossRef.genericType.data == CLR_EmptyToken) + { + // this is a MethodRef belonging to another assembly + + CLR_RT_MethodDef_Instance mdInstance; + mdInstance.data = memberCrossRef.target.data; + mdInstance.assembly = g_CLR_RT_TypeSystem.m_assemblies[mdInstance.Assembly() - 1]; + mdInstance.target = mdInstance.assembly->GetMethodDef(mdInstance.Method()); + + CLR_RT_TypeDef_Index typeOwner; + typeOwner.Set( + mdInstance.Assembly(), + mdInstance.assembly->crossReferenceMethodDef[mdInstance.Method()].GetOwner()); + + NANOCLR_CHECK_HRESULT(BuildTypeName(typeOwner, szBuffer, iBuffer)); + + CLR_SafeSprintf(szBuffer, iBuffer, "::%s", mdInstance.assembly->GetString(mdInstance.target->name)); + } + else + { + // this is a MethodRef for a generic type + + CLR_RT_SignatureParser parser; + parser.Initialize_TypeSpec(assembly, assembly->GetTypeSpec(memberCrossRef.genericType.TypeSpec())); + + CLR_RT_SignatureParser::Element element; + + // get type + parser.Advance(element); + + CLR_RT_TypeDef_Index typeDef; + typeDef.data = element.Class.data; + + BuildTypeName(typeDef, szBuffer, iBuffer); + + CLR_SafeSprintf(szBuffer, iBuffer, "<"); + + for (int i = 0; i < parser.GenParamCount; i++) + { + parser.Advance(element); + +#if defined(VIRTUAL_DEVICE) + CLR_SafeSprintf(szBuffer, iBuffer, c_CLR_RT_DataTypeLookup[element.DataType].m_name); +#endif + + if (i + 1 < parser.GenParamCount) + { + CLR_SafeSprintf(szBuffer, iBuffer, ","); + } + } + + CLR_SafeSprintf(szBuffer, iBuffer, ">::%s", assembly->GetString(methodRef->name)); + } + + NANOCLR_NOCLEANUP(); +} + +HRESULT CLR_RT_TypeSystem::BuildMethodSpecName(const CLR_RT_MethodSpec_Index &ms, char *&szBuffer, size_t &iBuffer) +{ + NATIVE_PROFILE_CLR_CORE(); + NANOCLR_HEADER(); + + CLR_RT_MethodSpec_Instance inst; + const CLR_RECORD_METHODSPEC *msRecord; + CLR_RT_SignatureParser parser; + CLR_RT_SignatureParser::Element element; + CLR_RT_TypeDef_Index typeDef; + CLR_RT_TypeDef_Instance instOwner; + CLR_RT_Assembly *assembly; + + if (inst.InitializeFromIndex(ms) == false) + { + NANOCLR_SET_AND_LEAVE(CLR_E_WRONG_TYPE); + } + + assembly = g_CLR_RT_TypeSystem.m_assemblies[ms.Assembly() - 1]; + + msRecord = inst.assembly->GetMethodSpec(ms.Method()); + + parser.Initialize_TypeSpec(inst.assembly, inst.assembly->GetTypeSpec(msRecord->container)); + + // get type + parser.Advance(element); + + typeDef.data = element.Class.data; + + if (instOwner.InitializeFromIndex(typeDef) == false) + { + NANOCLR_SET_AND_LEAVE(CLR_E_WRONG_TYPE); + } + + BuildTypeName(typeDef, szBuffer, iBuffer); + + CLR_SafeSprintf(szBuffer, iBuffer, "<"); + + parser.Initialize_MethodSignature(&inst); + + for (int i = 0; i < parser.GenParamCount; i++) + { + parser.Advance(element); + +#if defined(VIRTUAL_DEVICE) + NANOCLR_CHECK_HRESULT(QueueStringToBuffer(szBuffer, iBuffer, c_CLR_RT_DataTypeLookup[element.DataType].m_name)); +#endif + + if (i + 1 < parser.GenParamCount) + { + NANOCLR_CHECK_HRESULT(QueueStringToBuffer(szBuffer, iBuffer, ",")); + } + } + + CLR_SafeSprintf(szBuffer, iBuffer, ">::"); + + switch (msRecord->MethodKind()) + { + case TBL_MethodDef: + { + const CLR_RECORD_METHODDEF *md = assembly->GetMethodDef(msRecord->MethodIndex()); + CLR_SafeSprintf(szBuffer, iBuffer, "%s", assembly->GetString(md->name)); + break; + } + case TBL_MethodRef: + { + const CLR_RT_MethodRef_CrossReference memberCrossRef = + assembly->crossReferenceMethodRef[msRecord->MethodIndex()]; + + CLR_RT_MethodDef_Instance mdInstance; + mdInstance.data = memberCrossRef.target.data; + mdInstance.assembly = g_CLR_RT_TypeSystem.m_assemblies[mdInstance.Assembly() - 1]; + mdInstance.target = mdInstance.assembly->GetMethodDef(mdInstance.Method()); + + CLR_SafeSprintf( + szBuffer, + iBuffer, + "%s", + mdInstance.assembly->GetString(mdInstance.CrossReference().GetOwner())); + break; + } + default: + NANOCLR_SET_AND_LEAVE(CLR_E_WRONG_TYPE); + } NANOCLR_NOCLEANUP(); } @@ -4371,20 +6209,19 @@ HRESULT CLR_RT_TypeSystem::BuildFieldName(const CLR_RT_FieldDef_Index &fd, char bool CLR_RT_TypeSystem::FindVirtualMethodDef( const CLR_RT_TypeDef_Index &cls, const CLR_RT_MethodDef_Index &calleeMD, - CLR_RT_MethodDef_Index &idx) + CLR_RT_MethodDef_Index &index) { NATIVE_PROFILE_CLR_CORE(); CLR_RT_MethodDef_Instance calleeInst{}; if (calleeInst.InitializeFromIndex(calleeMD)) { - const char *calleeName = calleeInst.m_assm->GetString(calleeInst.m_target->name); + const char *calleeName = calleeInst.assembly->GetString(calleeInst.target->name); CLR_RT_TypeDef_Instance inst{}; inst.InitializeFromMethod(calleeInst); - if ((inst.m_target->flags & CLR_RECORD_TYPEDEF::TD_Semantics_Mask) == - CLR_RECORD_TYPEDEF::TD_Semantics_Interface) + if ((inst.target->flags & CLR_RECORD_TYPEDEF::TD_Semantics_Mask) == CLR_RECORD_TYPEDEF::TD_Semantics_Interface) { // // It's an interface method, it could be that the class is implementing explicitly the method. @@ -4403,15 +6240,15 @@ bool CLR_RT_TypeSystem::FindVirtualMethodDef( QueueStringToBuffer(szBuffer, iBuffer, "."); QueueStringToBuffer(szBuffer, iBuffer, calleeName); - if (FindVirtualMethodDef(cls, calleeMD, rgBuffer, idx)) + if (FindVirtualMethodDef(cls, calleeMD, rgBuffer, index)) return true; } - if (FindVirtualMethodDef(cls, calleeMD, calleeName, idx)) + if (FindVirtualMethodDef(cls, calleeMD, calleeName, index)) return true; } - idx.Clear(); + index.Clear(); return false; } @@ -4420,7 +6257,7 @@ bool CLR_RT_TypeSystem::FindVirtualMethodDef( const CLR_RT_TypeDef_Index &cls, const CLR_RT_MethodDef_Index &calleeMD, const char *calleeName, - CLR_RT_MethodDef_Index &idx) + CLR_RT_MethodDef_Index &index) { NATIVE_PROFILE_CLR_CORE(); CLR_RT_TypeDef_Instance clsInst{}; @@ -4428,40 +6265,40 @@ bool CLR_RT_TypeSystem::FindVirtualMethodDef( CLR_RT_MethodDef_Instance calleeInst{}; calleeInst.InitializeFromIndex(calleeMD); - CLR_RT_Assembly *calleeAssm = calleeInst.m_assm; - const CLR_RECORD_METHODDEF *calleeMDR = calleeInst.m_target; - CLR_UINT8 calleeNumArgs = calleeMDR->numArgs; + const CLR_RECORD_METHODDEF *calleeMDR = calleeInst.target; + CLR_UINT8 calleeArgumentsCount = calleeMDR->argumentsCount; while (NANOCLR_INDEX_IS_VALID(clsInst)) { - CLR_RT_Assembly *targetAssm = clsInst.m_assm; - const CLR_RECORD_TYPEDEF *targetTDR = clsInst.m_target; - const CLR_RECORD_METHODDEF *targetMDR = targetAssm->GetMethodDef(targetTDR->methods_First); - int num = targetTDR->vMethods_Num + targetTDR->iMethods_Num; + CLR_RT_Assembly *targetAssm = clsInst.assembly; + const CLR_RECORD_TYPEDEF *targetTDR = clsInst.target; + const CLR_RECORD_METHODDEF *targetMDR = targetAssm->GetMethodDef(targetTDR->firstMethod); + int num = targetTDR->virtualMethodCount + targetTDR->instanceMethodCount; for (int i = 0; i < num; i++, targetMDR++) { if (targetMDR == calleeMDR) { // Shortcut for identity. - idx = calleeInst; + index = calleeInst; return true; } - if (targetMDR->numArgs == calleeNumArgs && (targetMDR->flags & CLR_RECORD_METHODDEF::MD_Abstract) == 0) + if (targetMDR->argumentsCount == calleeArgumentsCount && + (targetMDR->flags & CLR_RECORD_METHODDEF::MD_Abstract) == 0) { const char *targetName = targetAssm->GetString(targetMDR->name); if (!strcmp(targetName, calleeName)) { CLR_RT_SignatureParser parserLeft{}; - parserLeft.Initialize_MethodSignature(calleeAssm, calleeMDR); + parserLeft.Initialize_MethodSignature(&calleeInst); CLR_RT_SignatureParser parserRight{}; parserRight.Initialize_MethodSignature(targetAssm, targetMDR); if (CLR_RT_TypeSystem::MatchSignature(parserLeft, parserRight)) { - idx.Set(targetAssm->m_idx, i + targetTDR->methods_First); + index.Set(targetAssm->assemblyIndex, i + targetTDR->firstMethod); return true; } @@ -4472,12 +6309,12 @@ bool CLR_RT_TypeSystem::FindVirtualMethodDef( clsInst.SwitchToParent(); } - idx.Clear(); + index.Clear(); return false; } -CLR_DataType CLR_RT_TypeSystem::MapElementTypeToDataType(CLR_UINT32 et) +NanoCLRDataType CLR_RT_TypeSystem::MapElementTypeToDataType(CLR_UINT32 et) { NATIVE_PROFILE_CLR_CORE(); const CLR_RT_DataTypeLookup *ptr = c_CLR_RT_DataTypeLookup; @@ -4485,7 +6322,7 @@ CLR_DataType CLR_RT_TypeSystem::MapElementTypeToDataType(CLR_UINT32 et) for (CLR_UINT32 num = 0; num < DATATYPE_FIRST_INVALID; num++, ptr++) { if (ptr->m_convertToElementType == et) - return (CLR_DataType)num; + return (NanoCLRDataType)num; } if (et == ELEMENT_TYPE_I) @@ -4496,7 +6333,7 @@ CLR_DataType CLR_RT_TypeSystem::MapElementTypeToDataType(CLR_UINT32 et) return DATATYPE_FIRST_INVALID; } -CLR_UINT32 CLR_RT_TypeSystem::MapDataTypeToElementType(CLR_DataType dt) +CLR_UINT32 CLR_RT_TypeSystem::MapDataTypeToElementType(NanoCLRDataType dt) { NATIVE_PROFILE_CLR_CORE(); return c_CLR_RT_DataTypeLookup[dt].m_convertToElementType; @@ -4508,7 +6345,7 @@ void CLR_RT_AttributeEnumerator::Initialize(CLR_RT_Assembly *assm) { NATIVE_PROFILE_CLR_CORE(); m_assm = assm; // CLR_RT_Assembly* m_assm; - m_ptr = NULL; // const CLR_RECORD_ATTRIBUTE* m_ptr; + m_ptr = nullptr; // const CLR_RECORD_ATTRIBUTE* m_ptr; m_num = 0; // int m_num; // CLR_RECORD_ATTRIBUTE m_data; m_match.Clear(); // CLR_RT_MethodDef_Index m_match; @@ -4518,27 +6355,27 @@ void CLR_RT_AttributeEnumerator::Initialize(const CLR_RT_TypeDef_Instance &inst) { NATIVE_PROFILE_CLR_CORE(); m_data.ownerType = TBL_TypeDef; - m_data.ownerIdx = inst.Type(); + m_data.ownerIndex = inst.Type(); - Initialize(inst.m_assm); + Initialize(inst.assembly); } void CLR_RT_AttributeEnumerator::Initialize(const CLR_RT_FieldDef_Instance &inst) { NATIVE_PROFILE_CLR_CORE(); m_data.ownerType = TBL_FieldDef; - m_data.ownerIdx = inst.Field(); + m_data.ownerIndex = inst.Field(); - Initialize(inst.m_assm); + Initialize(inst.assembly); } void CLR_RT_AttributeEnumerator::Initialize(const CLR_RT_MethodDef_Instance &inst) { NATIVE_PROFILE_CLR_CORE(); m_data.ownerType = TBL_MethodDef; - m_data.ownerIdx = inst.Method(); + m_data.ownerIndex = inst.Method(); - Initialize(inst.m_assm); + Initialize(inst.assembly); } bool CLR_RT_AttributeEnumerator::Advance() @@ -4549,10 +6386,10 @@ bool CLR_RT_AttributeEnumerator::Advance() CLR_UINT32 key = m_data.Key(); bool fRes = false; - if (ptr == NULL) + if (ptr == nullptr) { ptr = m_assm->GetAttribute(0) - 1; - num = m_assm->m_pTablesSize[TBL_Attributes]; + num = m_assm->tablesSize[TBL_Attributes]; } while (num) @@ -4560,18 +6397,21 @@ bool CLR_RT_AttributeEnumerator::Advance() ptr++; num--; - if (ptr->Key() == key) + if (ptr->Key() == key && ptr->ownerIndex == m_data.ownerIndex) { - CLR_IDX tk = ptr->constructor; - if (tk & 0x8000) - { - m_match = m_assm->m_pCrossReference_MethodRef[tk & 0x7FFF].m_target; - } - else + // get the token of the constructor (compressed format) + CLR_UINT32 token = CLR_UncompressMethodToken(ptr->constructor); + + // get the method definition, by resolving the token + CLR_RT_MethodDef_Instance method{}; + if (method.ResolveToken(token, m_assm) == false) { - m_match.Set(m_assm->m_idx, tk); + ASSERT(0); } + // get the method definition index + m_match.data = method.data; + m_blob = m_assm->GetSignature(ptr->data); fRes = true; @@ -4602,7 +6442,7 @@ bool CLR_RT_AttributeEnumerator::MatchNext( { if (instMD) { - if (m_match.m_data != instMD->m_data) + if (m_match.data != instMD->data) continue; } @@ -4614,7 +6454,7 @@ bool CLR_RT_AttributeEnumerator::MatchNext( md.InitializeFromIndex(m_match); td.InitializeFromMethod(md); - if (td.m_data != instTD->m_data) + if (td.data != instTD->data) continue; } @@ -4636,17 +6476,17 @@ HRESULT CLR_RT_AttributeParser::Initialize(const CLR_RT_AttributeEnumerator &en) NANOCLR_SET_AND_LEAVE(CLR_E_WRONG_TYPE); } - m_parser.Initialize_MethodSignature(m_md.m_assm, m_md.m_target); + m_parser.Initialize_MethodSignature(&m_md); m_parser.Advance(m_res); // Skip return value. m_assm = en.m_assm; m_blob = en.m_blob; m_currentPos = 0; - m_fixed_Count = m_md.m_target->numArgs - 1; + m_fixed_Count = m_md.target->argumentsCount - 1; m_named_Count = -1; m_constructorParsed = false; - m_mdIdx = en.m_match; + m_mdIndex = en.m_match; NANOCLR_NOCLEANUP(); } @@ -4666,7 +6506,7 @@ HRESULT CLR_RT_AttributeParser::Next(Value *&res) // Attribute class has no fields, no properties and only default constructor m_lastValue.m_mode = Value::c_DefaultConstructor; - m_lastValue.m_name = NULL; + m_lastValue.m_name = nullptr; NANOCLR_CHECK_HRESULT(g_CLR_RT_ExecutionEngine.NewObject(m_lastValue.m_value, m_td)); @@ -4681,23 +6521,23 @@ HRESULT CLR_RT_AttributeParser::Next(Value *&res) // Attribute class has a constructor with parameter(s) m_lastValue.m_mode = Value::c_ConstructorArgument; - m_lastValue.m_name = NULL; + m_lastValue.m_name = nullptr; // get type NANOCLR_CHECK_HRESULT(m_parser.Advance(m_res)); - CLR_RT_DataTypeLookup dtl = c_CLR_RT_DataTypeLookup[m_res.m_dt]; + CLR_RT_DataTypeLookup dtl = c_CLR_RT_DataTypeLookup[m_res.DataType]; //////////////////////////////////////////////// // now read the arguments from the blob - if ((m_res.m_dt == DATATYPE_OBJECT && m_res.m_levels == 1) || m_fixed_Count > 1) + if ((m_res.DataType == DATATYPE_OBJECT && m_res.Levels == 1) || m_fixed_Count > 1) { // this is either an array of objects or a constructor with multiple parameters uint8_t paramCount; - if (m_res.m_dt == DATATYPE_OBJECT && m_res.m_levels == 1) + if (m_res.DataType == DATATYPE_OBJECT && m_res.Levels == 1) { // get element count of array (from blob) NANOCLR_READ_UNALIGNED_UINT8(paramCount, m_blob); @@ -4712,11 +6552,10 @@ HRESULT CLR_RT_AttributeParser::Next(Value *&res) NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_Array::CreateInstance( m_lastValue.m_value, paramCount, - g_CLR_RT_WellKnownTypes.m_Object)); + g_CLR_RT_WellKnownTypes.Object)); // get a pointer to the first element - CLR_RT_HeapBlock *currentParam = - (CLR_RT_HeapBlock *)m_lastValue.m_value.DereferenceArray()->GetFirstElement(); + auto *currentParam = (CLR_RT_HeapBlock *)m_lastValue.m_value.DereferenceArray()->GetFirstElement(); do { @@ -4724,7 +6563,7 @@ HRESULT CLR_RT_AttributeParser::Next(Value *&res) uint8_t elementType; NANOCLR_READ_UNALIGNED_UINT8(elementType, m_blob); - CLR_DataType dt = CLR_RT_TypeSystem::MapElementTypeToDataType(elementType); + NanoCLRDataType dt = CLR_RT_TypeSystem::MapElementTypeToDataType(elementType); dtl = c_CLR_RT_DataTypeLookup[dt]; @@ -4758,9 +6597,9 @@ HRESULT CLR_RT_AttributeParser::Next(Value *&res) CLR_UINT32 size = dtl.m_sizeInBytes; CLR_RT_HeapBlock *currentParam = &m_lastValue.m_value; - NANOCLR_CHECK_HRESULT(ReadNumericValue(currentParam, m_res.m_dt, dtl.m_cls, size)); + NANOCLR_CHECK_HRESULT(ReadNumericValue(currentParam, m_res.DataType, dtl.m_cls, size)); } - else if (m_res.m_dt == DATATYPE_STRING) + else if (m_res.DataType == DATATYPE_STRING) { // single parameter of string type // OK to skip element type @@ -4801,7 +6640,7 @@ HRESULT CLR_RT_AttributeParser::Next(Value *&res) inst.InitializeFromIndex(fd); - m_parser.Initialize_FieldDef(inst.m_assm, inst.m_target); + m_parser.Initialize_FieldDef(inst.assembly, inst.target); } else { @@ -4817,7 +6656,7 @@ HRESULT CLR_RT_AttributeParser::Next(Value *&res) } else { - res = NULL; + res = nullptr; NANOCLR_SET_AND_LEAVE(S_OK); } @@ -4828,14 +6667,14 @@ HRESULT CLR_RT_AttributeParser::Next(Value *&res) // // Check for Enums. // - if (m_res.m_dt == DATATYPE_VALUETYPE) + if (m_res.DataType == DATATYPE_VALUETYPE) { CLR_RT_TypeDef_Instance td{}; - td.InitializeFromIndex(m_res.m_cls); + td.InitializeFromIndex(m_res.Class); - if ((td.m_target->flags & CLR_RECORD_TYPEDEF::TD_Semantics_Mask) == CLR_RECORD_TYPEDEF::TD_Semantics_Enum) + if ((td.target->flags & CLR_RECORD_TYPEDEF::TD_Semantics_Mask) == CLR_RECORD_TYPEDEF::TD_Semantics_Enum) { - m_res.m_dt = (CLR_DataType)td.m_target->dataType; + m_res.DataType = (NanoCLRDataType)td.target->dataType; } } @@ -4845,16 +6684,16 @@ HRESULT CLR_RT_AttributeParser::Next(Value *&res) m_blob += sizeof(CLR_UINT8); { - const CLR_RT_DataTypeLookup &dtl = c_CLR_RT_DataTypeLookup[m_res.m_dt]; + const CLR_RT_DataTypeLookup &dtl = c_CLR_RT_DataTypeLookup[m_res.DataType]; if (dtl.m_flags & CLR_RT_DataTypeLookup::c_Numeric) { CLR_UINT32 size = dtl.m_sizeInBytes; CLR_RT_HeapBlock *currentParam = &m_lastValue.m_value; - NANOCLR_CHECK_HRESULT(ReadNumericValue(currentParam, m_res.m_dt, dtl.m_cls, size)); + NANOCLR_CHECK_HRESULT(ReadNumericValue(currentParam, m_res.DataType, dtl.m_cls, size)); } - else if (m_res.m_dt == DATATYPE_STRING) + else if (m_res.DataType == DATATYPE_STRING) { CLR_RT_HeapBlock *currentParam = &m_lastValue.m_value; NANOCLR_CHECK_HRESULT(ReadString(currentParam)); @@ -4877,7 +6716,7 @@ HRESULT CLR_RT_AttributeParser::ReadString(CLR_RT_HeapBlock *&value) CLR_UINT32 tk; CLR_RT_TypeDescriptor desc{}; - NANOCLR_CHECK_HRESULT(desc.InitializeFromType(g_CLR_RT_WellKnownTypes.m_String)); + NANOCLR_CHECK_HRESULT(desc.InitializeFromType(g_CLR_RT_WellKnownTypes.String)); NANOCLR_READ_UNALIGNED_UINT16(tk, m_blob); @@ -4891,7 +6730,7 @@ HRESULT CLR_RT_AttributeParser::ReadString(CLR_RT_HeapBlock *&value) HRESULT CLR_RT_AttributeParser::ReadNumericValue( CLR_RT_HeapBlock *&value, - const CLR_DataType dt, + const NanoCLRDataType dt, const CLR_RT_TypeDef_Index *m_cls, const CLR_UINT32 size) { @@ -4900,7 +6739,7 @@ HRESULT CLR_RT_AttributeParser::ReadNumericValue( CLR_RT_TypeDescriptor desc{}; NANOCLR_CHECK_HRESULT(desc.InitializeFromType(*m_cls)); - NANOCLR_CHECK_HRESULT(g_CLR_RT_ExecutionEngine.NewObjectFromIndex(*value, g_CLR_RT_WellKnownTypes.m_TypeStatic)); + NANOCLR_CHECK_HRESULT(g_CLR_RT_ExecutionEngine.NewObjectFromIndex(*value, g_CLR_RT_WellKnownTypes.TypeStatic)); // need to setup reflection and data type Id to properly setup the object value->SetReflection(*m_cls); diff --git a/src/CLR/Core/TypeSystemLookup.cpp b/src/CLR/Core/TypeSystemLookup.cpp index cf8b6e9936..5870731314 100644 --- a/src/CLR/Core/TypeSystemLookup.cpp +++ b/src/CLR/Core/TypeSystemLookup.cpp @@ -31,10 +31,14 @@ #define DT_NUM CLR_RT_DataTypeLookup::c_Numeric #define DT_INT CLR_RT_DataTypeLookup::c_Integer #define DT_SGN CLR_RT_DataTypeLookup::c_Signed -#define DT_DIR CLR_RT_DataTypeLookup::c_Direct +#define DT_DIRCT CLR_RT_DataTypeLookup::c_Direct #define DT_OPT CLR_RT_DataTypeLookup::c_OptimizedValueType #define DT_MT CLR_RT_DataTypeLookup::c_ManagedType +#define DT_VAR CLR_RT_DataTypeLookup::c_Var +#define DT_GENER CLR_RT_DataTypeLookup::c_GenericInstance +#define DT_MVAR CLR_RT_DataTypeLookup::c_MVar + #define DT_U1 sizeof(CLR_UINT8) #define DT_I1 sizeof(CLR_INT8) #define DT_U2 sizeof(CLR_UINT16) @@ -49,7 +53,7 @@ #define DT_CNV(x) (CLR_UINT8)ELEMENT_TYPE_##x #define DT_CLS(x) &g_CLR_RT_WellKnownTypes.x -#define DT_NOREL(x) NULL +#define DT_NOREL(x) nullptr #define DT_REL(x) (CLR_RT_HeapBlockRelocate)&x #if defined(VIRTUAL_DEVICE) || defined(NANOCLR_TRACE_MEMORY_STATS) @@ -58,85 +62,85 @@ #define DT_OPT_NAME(x) #endif -#define DATATYPE_NOT_SUPPORTED { DT_NA, DT_NA, DT_NA, DT_T(FIRST_INVALID), DT_CNV(END), NULL, DT_NOREL(CLR_RT_HeapBlock) DT_OPT_NAME(NOT_SUPPORTED) }, +#define DATATYPE_NOT_SUPPORTED { DT_NA, DT_NA, DT_NA, DT_T(FIRST_INVALID), DT_CNV(END), nullptr, DT_NOREL(CLR_RT_HeapBlock) DT_OPT_NAME(NOT_SUPPORTED) }, const CLR_RT_DataTypeLookup c_CLR_RT_DataTypeLookup[] = { -//// m_flags, m_sizeInBits, m_sizeInBytes, m_promoteTo, m_convertToElementType, m_cls, m_relocate, m_name +//// flags, sizeInBits, sizeInBytes, promoteTo, convertToElementType, cls, relocate, name //// -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - { DT_NA , DT_NA, DT_NA, DT_T(VOID ), DT_CNV(VOID ), NULL , DT_NOREL(CLR_RT_HeapBlock ) DT_OPT_NAME(VOID ) }, // DATATYPE_VOID +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + { DT_NA , DT_NA, DT_NA, DT_T(VOID ), DT_CNV(VOID ), nullptr , DT_NOREL(CLR_RT_HeapBlock ) DT_OPT_NAME(VOID ) }, // DATATYPE_VOID // - { DT_NUM | DT_INT | DT_PRIM | DT_DIR | DT_OPT | DT_MT, 1, DT_U1, DT_T(I4 ), DT_CNV(BOOLEAN ), DT_CLS(m_Boolean ), DT_NOREL(CLR_RT_HeapBlock ) DT_OPT_NAME(BOOLEAN ) }, // DATATYPE_BOOLEAN - { DT_NUM | DT_INT | DT_SGN | DT_PRIM | DT_DIR | DT_OPT | DT_MT, 8, DT_I1, DT_T(I4 ), DT_CNV(I1 ), DT_CLS(m_Int8 ), DT_NOREL(CLR_RT_HeapBlock ) DT_OPT_NAME(I1 ) }, // DATATYPE_I1 - { DT_NUM | DT_INT | DT_PRIM | DT_DIR | DT_OPT | DT_MT, 8, DT_U1, DT_T(I4 ), DT_CNV(U1 ), DT_CLS(m_UInt8 ), DT_NOREL(CLR_RT_HeapBlock ) DT_OPT_NAME(U1 ) }, // DATATYPE_U1 + { DT_NUM | DT_INT | DT_PRIM | DT_DIRCT | DT_OPT | DT_MT , 1, DT_U1, DT_T(I4 ), DT_CNV(BOOLEAN ), DT_CLS(Boolean ), DT_NOREL(CLR_RT_HeapBlock ) DT_OPT_NAME(BOOLEAN ) }, // DATATYPE_BOOLEAN + { DT_NUM | DT_INT | DT_SGN | DT_PRIM | DT_DIRCT | DT_OPT | DT_MT , 8, DT_I1, DT_T(I4 ), DT_CNV(I1 ), DT_CLS(Int8 ), DT_NOREL(CLR_RT_HeapBlock ) DT_OPT_NAME(I1 ) }, // DATATYPE_I1 + { DT_NUM | DT_INT | DT_PRIM | DT_DIRCT | DT_OPT | DT_MT , 8, DT_U1, DT_T(I4 ), DT_CNV(U1 ), DT_CLS(UInt8 ), DT_NOREL(CLR_RT_HeapBlock ) DT_OPT_NAME(U1 ) }, // DATATYPE_U1 // - { DT_NUM | DT_INT | DT_PRIM | DT_DIR | DT_OPT | DT_MT, 16, DT_U2, DT_T(I4 ), DT_CNV(CHAR ), DT_CLS(m_Char ), DT_NOREL(CLR_RT_HeapBlock ) DT_OPT_NAME(char ) }, // DATATYPE_CHAR - { DT_NUM | DT_INT | DT_SGN | DT_PRIM | DT_DIR | DT_OPT | DT_MT, 16, DT_I2, DT_T(I4 ), DT_CNV(I2 ), DT_CLS(m_Int16 ), DT_NOREL(CLR_RT_HeapBlock ) DT_OPT_NAME(I2 ) }, // DATATYPE_I2 - { DT_NUM | DT_INT | DT_PRIM | DT_DIR | DT_OPT | DT_MT, 16, DT_U2, DT_T(I4 ), DT_CNV(U2 ), DT_CLS(m_UInt16 ), DT_NOREL(CLR_RT_HeapBlock ) DT_OPT_NAME(U2 ) }, // DATATYPE_U2 + { DT_NUM | DT_INT | DT_PRIM | DT_DIRCT | DT_OPT | DT_MT , 16, DT_U2, DT_T(I4 ), DT_CNV(CHAR ), DT_CLS(Char ), DT_NOREL(CLR_RT_HeapBlock ) DT_OPT_NAME(char ) }, // DATATYPE_CHAR + { DT_NUM | DT_INT | DT_SGN | DT_PRIM | DT_DIRCT | DT_OPT | DT_MT , 16, DT_I2, DT_T(I4 ), DT_CNV(I2 ), DT_CLS(Int16 ), DT_NOREL(CLR_RT_HeapBlock ) DT_OPT_NAME(I2 ) }, // DATATYPE_I2 + { DT_NUM | DT_INT | DT_PRIM | DT_DIRCT | DT_OPT | DT_MT , 16, DT_U2, DT_T(I4 ), DT_CNV(U2 ), DT_CLS(UInt16 ), DT_NOREL(CLR_RT_HeapBlock ) DT_OPT_NAME(U2 ) }, // DATATYPE_U2 // - { DT_NUM | DT_INT | DT_SGN | DT_PRIM | DT_DIR | DT_OPT | DT_MT, 32, DT_I4, DT_T(I4 ), DT_CNV(I4 ), DT_CLS(m_Int32 ), DT_NOREL(CLR_RT_HeapBlock ) DT_OPT_NAME(I4 ) }, // DATATYPE_I4 - { DT_NUM | DT_INT | DT_PRIM | DT_DIR | DT_OPT | DT_MT, 32, DT_U4, DT_T(I4 ), DT_CNV(U4 ), DT_CLS(m_UInt32 ), DT_NOREL(CLR_RT_HeapBlock ) DT_OPT_NAME(U4 ) }, // DATATYPE_U4 - { DT_NUM | DT_SGN | DT_PRIM | DT_DIR | DT_OPT | DT_MT, 32, DT_I4, DT_T(R4 ), DT_CNV(R4 ), DT_CLS(m_Single ), DT_NOREL(CLR_RT_HeapBlock ) DT_OPT_NAME(R4 ) }, // DATATYPE_R4 + { DT_NUM | DT_INT | DT_SGN | DT_PRIM | DT_DIRCT | DT_OPT | DT_MT , 32, DT_I4, DT_T(I4 ), DT_CNV(I4 ), DT_CLS(Int32 ), DT_NOREL(CLR_RT_HeapBlock ) DT_OPT_NAME(I4 ) }, // DATATYPE_I4 + { DT_NUM | DT_INT | DT_PRIM | DT_DIRCT | DT_OPT | DT_MT , 32, DT_U4, DT_T(I4 ), DT_CNV(U4 ), DT_CLS(UInt32 ), DT_NOREL(CLR_RT_HeapBlock ) DT_OPT_NAME(U4 ) }, // DATATYPE_U4 + { DT_NUM | DT_SGN | DT_PRIM | DT_DIRCT | DT_OPT | DT_MT , 32, DT_I4, DT_T(R4 ), DT_CNV(R4 ), DT_CLS(Single ), DT_NOREL(CLR_RT_HeapBlock ) DT_OPT_NAME(R4 ) }, // DATATYPE_R4 // - { DT_NUM | DT_INT | DT_SGN | DT_PRIM | DT_DIR | DT_OPT | DT_MT, 64, DT_I8, DT_T(I8 ), DT_CNV(I8 ), DT_CLS(m_Int64 ), DT_NOREL(CLR_RT_HeapBlock ) DT_OPT_NAME(I8 ) }, // DATATYPE_I8 - { DT_NUM | DT_INT | DT_PRIM | DT_DIR | DT_OPT | DT_MT, 64, DT_U8, DT_T(I8 ), DT_CNV(U8 ), DT_CLS(m_UInt64 ), DT_NOREL(CLR_RT_HeapBlock ) DT_OPT_NAME(U8 ) }, // DATATYPE_U8 - { DT_NUM | DT_SGN | DT_PRIM | DT_DIR | DT_OPT | DT_MT, 64, DT_I8, DT_T(R8 ), DT_CNV(R8 ), DT_CLS(m_Double ), DT_NOREL(CLR_RT_HeapBlock ) DT_OPT_NAME(R8 ) }, // DATATYPE_R8 - { DT_INT | DT_SGN | DT_VALUE | DT_DIR | DT_OPT | DT_MT, 64, DT_BL, DT_T(DATETIME ), DT_CNV(END ), DT_CLS(m_DateTime ), DT_NOREL(CLR_RT_HeapBlock ) DT_OPT_NAME(DATETIME ) }, // DATATYPE_DATETIME - { DT_INT | DT_SGN | DT_VALUE | DT_DIR | DT_OPT | DT_MT, 64, DT_BL, DT_T(TIMESPAN ), DT_CNV(END ), DT_CLS(m_TimeSpan ), DT_NOREL(CLR_RT_HeapBlock ) DT_OPT_NAME(TIMESPAN ) }, // DATATYPE_TIMESPAN - { DT_REF | DT_PRIM | DT_DIR | DT_MT, DT_VS, DT_BL, DT_T(STRING ), DT_CNV(STRING ), DT_CLS(m_String ), DT_REL (CLR_RT_HeapBlock ::Relocate_String ) DT_OPT_NAME(STRING ) }, // DATATYPE_STRING + { DT_NUM | DT_INT | DT_SGN | DT_PRIM | DT_DIRCT | DT_OPT | DT_MT , 64, DT_I8, DT_T(I8 ), DT_CNV(I8 ), DT_CLS(Int64 ), DT_NOREL(CLR_RT_HeapBlock ) DT_OPT_NAME(I8 ) }, // DATATYPE_I8 + { DT_NUM | DT_INT | DT_PRIM | DT_DIRCT | DT_OPT | DT_MT , 64, DT_U8, DT_T(I8 ), DT_CNV(U8 ), DT_CLS(UInt64 ), DT_NOREL(CLR_RT_HeapBlock ) DT_OPT_NAME(U8 ) }, // DATATYPE_U8 + { DT_NUM | DT_SGN | DT_PRIM | DT_DIRCT | DT_OPT | DT_MT , 64, DT_I8, DT_T(R8 ), DT_CNV(R8 ), DT_CLS(Double ), DT_NOREL(CLR_RT_HeapBlock ) DT_OPT_NAME(R8 ) }, // DATATYPE_R8 + { DT_INT | DT_SGN | DT_VALUE | DT_DIRCT | DT_OPT | DT_MT , 64, DT_BL, DT_T(DATETIME ), DT_CNV(END ), DT_CLS(DateTime ), DT_NOREL(CLR_RT_HeapBlock ) DT_OPT_NAME(DATETIME ) }, // DATATYPE_DATETIME + { DT_INT | DT_SGN | DT_VALUE | DT_DIRCT | DT_OPT | DT_MT , 64, DT_BL, DT_T(TIMESPAN ), DT_CNV(END ), DT_CLS(TimeSpan ), DT_NOREL(CLR_RT_HeapBlock ) DT_OPT_NAME(TIMESPAN ) }, // DATATYPE_TIMESPAN + { DT_REF | DT_PRIM | DT_DIRCT | DT_MT , DT_VS, DT_BL, DT_T(STRING ), DT_CNV(STRING ), DT_CLS(String ), DT_REL (CLR_RT_HeapBlock ::Relocate_String ) DT_OPT_NAME(STRING ) }, // DATATYPE_STRING // - { DT_REF | DT_DIR | DT_MT, DT_NA, DT_BL, DT_T(OBJECT ), DT_CNV(OBJECT ), DT_CLS(m_Object ), DT_REL (CLR_RT_HeapBlock ::Relocate_Obj ) DT_OPT_NAME(OBJECT ) }, // DATATYPE_OBJECT - { DT_REF | DT_CLASS | DT_MT, DT_NA, DT_BL, DT_T(CLASS ), DT_CNV(CLASS ), NULL , DT_REL (CLR_RT_HeapBlock ::Relocate_Cls ) DT_OPT_NAME(CLASS ) }, // DATATYPE_CLASS - { DT_REF | DT_VALUE | DT_MT, DT_NA, DT_BL, DT_T(VALUETYPE ), DT_CNV(VALUETYPE), NULL , DT_REL (CLR_RT_HeapBlock ::Relocate_Cls ) DT_OPT_NAME(VALUETYPE ) }, // DATATYPE_VALUETYPE - { DT_REF | DT_CLASS | DT_ARRAY | DT_MT, DT_NA, DT_BL, DT_T(SZARRAY ), DT_CNV(SZARRAY ), DT_CLS(m_Array ), DT_REL (CLR_RT_HeapBlock_Array ::Relocate ) DT_OPT_NAME(SZARRAY ) }, // DATATYPE_SZARRAY - { DT_REF | DT_MT, DT_NA, DT_NA, DT_T(BYREF ), DT_CNV(BYREF ), NULL , DT_REL (CLR_RT_HeapBlock ::Relocate_Ref ) DT_OPT_NAME(BYREF ) }, // DATATYPE_BYREF - - DATATYPE_NOT_SUPPORTED // DATATYPE_VAR - DATATYPE_NOT_SUPPORTED // DATATYPE_GENERICINST - DATATYPE_NOT_SUPPORTED // DATATYPE_MVAR - - { DT_NA , DT_NA, DT_NA, DT_T(FREEBLOCK ), DT_CNV(END ), NULL , DT_NOREL(CLR_RT_HeapBlock ) DT_OPT_NAME(FREEBLOCK ) }, // DATATYPE_FREEBLOCK - { DT_NA , DT_NA, DT_NA, DT_T(CACHEDBLOCK ), DT_CNV(END ), NULL , DT_NOREL(CLR_RT_HeapBlock_Node ) DT_OPT_NAME(CACHEDBLOCK ) }, // DATATYPE_CACHEDBLOCK - { DT_REF , DT_NA, DT_NA, DT_T(ASSEMBLY ), DT_CNV(END ), NULL , DT_REL (CLR_RT_Assembly ::Relocate ) DT_OPT_NAME(ASSEMBLY ) }, // DATATYPE_ASSEMBLY - { DT_REF | DT_MT, DT_NA, DT_BL, DT_T(WEAKCLASS ), DT_CNV(END ), DT_CLS(m_WeakReference ), DT_REL (CLR_RT_HeapBlock_WeakReference::Relocate ) DT_OPT_NAME(WEAKCLASS ) }, // DATATYPE_WEAKCLASS - { DT_MT, DT_NA, DT_NA, DT_T(REFLECTION ), DT_CNV(END ), NULL , DT_NOREL(CLR_RT_HeapBlock ) DT_OPT_NAME(REFLECTION ) }, // DATATYPE_REFLECTION - { DT_MT, DT_NA, DT_NA, DT_T(ARRAY_BYREF ), DT_CNV(END ), NULL , DT_REL (CLR_RT_HeapBlock ::Relocate_ArrayRef) DT_OPT_NAME(ARRAY_BYREF ) }, // DATATYPE_ARRAY_BYREF - { DT_REF | DT_MT, DT_NA, DT_BL, DT_T(DELEGATE_HEAD ), DT_CNV(END ), NULL , DT_REL (CLR_RT_HeapBlock_Delegate ::Relocate ) DT_OPT_NAME(DELEGATE_HEAD ) }, // DATATYPE_DELEGATE_HEAD - { DT_REF | DT_MT, DT_NA, DT_NA, DT_T(DELEGATELIST_HEAD ), DT_CNV(END ), NULL , DT_REL (CLR_RT_HeapBlock_Delegate_List::Relocate ) DT_OPT_NAME(DELEGATELIST_HEAD ) }, // DATATYPE_DELEGATELIST_HEAD - { DT_REF , DT_NA, DT_NA, DT_T(OBJECT_TO_EVENT ), DT_CNV(END ), NULL , DT_REL (CLR_RT_ObjectToEvent_Source ::Relocate ) DT_OPT_NAME(OBJECT_TO_EVENT ) }, // DATATYPE_OBJECT_TO_EVENT - { DT_REF , DT_NA, DT_NA, DT_T(BINARY_BLOB_HEAD ), DT_CNV(END ), NULL , DT_REL (CLR_RT_HeapBlock_BinaryBlob ::Relocate ) DT_OPT_NAME(BINARY_BLOB_HEAD ) }, // DATATYPE_BINARY_BLOB_HEAD + { DT_REF | DT_DIRCT | DT_MT , DT_NA, DT_BL, DT_T(OBJECT ), DT_CNV(OBJECT ), DT_CLS(Object ), DT_REL (CLR_RT_HeapBlock ::Relocate_Obj ) DT_OPT_NAME(OBJECT ) }, // DATATYPE_OBJECT + { DT_REF | DT_CLASS | DT_MT , DT_NA, DT_BL, DT_T(CLASS ), DT_CNV(CLASS ), nullptr , DT_REL (CLR_RT_HeapBlock ::Relocate_Cls ) DT_OPT_NAME(CLASS ) }, // DATATYPE_CLASS + { DT_REF | DT_VALUE | DT_MT , DT_NA, DT_BL, DT_T(VALUETYPE ), DT_CNV(VALUETYPE ), nullptr , DT_REL (CLR_RT_HeapBlock ::Relocate_Cls ) DT_OPT_NAME(VALUETYPE ) }, // DATATYPE_VALUETYPE + { DT_REF | DT_CLASS | DT_ARRAY | DT_MT , DT_NA, DT_BL, DT_T(SZARRAY ), DT_CNV(SZARRAY ), DT_CLS(Array ), DT_REL (CLR_RT_HeapBlock_Array ::Relocate ) DT_OPT_NAME(SZARRAY ) }, // DATATYPE_SZARRAY + { DT_REF | DT_MT , DT_NA, DT_NA, DT_T(BYREF ), DT_CNV(BYREF ), nullptr , DT_REL (CLR_RT_HeapBlock ::Relocate_Ref ) DT_OPT_NAME(BYREF ) }, // DATATYPE_BYREF + + { DT_MT | DT_VAR , DT_NA, DT_BL, DT_T(VAR ), DT_CNV(VAR ), nullptr , DT_NOREL(CLR_RT_HeapBlock ) DT_OPT_NAME(VAR ) }, // DATATYPE_VAR + { DT_MT | DT_GENER, DT_NA, DT_BL, DT_T(GENERICINST ), DT_CNV(GENERICINST), nullptr , DT_NOREL(CLR_RT_HeapBlock ) DT_OPT_NAME(GENERICINST ) }, // DATATYPE_GENERICINST + { DT_MT | DT_MVAR , DT_NA, DT_BL, DT_T(MVAR ), DT_CNV(MVAR ), nullptr , DT_NOREL(CLR_RT_HeapBlock ) DT_OPT_NAME(MVAR ) }, // DATATYPE_MVAR + + { DT_NA , DT_NA, DT_NA, DT_T(FREEBLOCK ), DT_CNV(END ), nullptr , DT_NOREL(CLR_RT_HeapBlock ) DT_OPT_NAME(FREEBLOCK ) }, // DATATYPE_FREEBLOCK + { DT_NA , DT_NA, DT_NA, DT_T(CACHEDBLOCK ), DT_CNV(END ), nullptr , DT_NOREL(CLR_RT_HeapBlock_Node ) DT_OPT_NAME(CACHEDBLOCK ) }, // DATATYPE_CACHEDBLOCK + { DT_REF , DT_NA, DT_NA, DT_T(ASSEMBLY ), DT_CNV(END ), nullptr , DT_REL (CLR_RT_Assembly ::Relocate ) DT_OPT_NAME(ASSEMBLY ) }, // DATATYPE_ASSEMBLY + { DT_REF | DT_MT , DT_NA, DT_BL, DT_T(WEAKCLASS ), DT_CNV(END ), DT_CLS(WeakReference ), DT_REL (CLR_RT_HeapBlock_WeakReference::Relocate ) DT_OPT_NAME(WEAKCLASS ) }, // DATATYPE_WEAKCLASS + { DT_MT , DT_NA, DT_NA, DT_T(REFLECTION ), DT_CNV(END ), nullptr , DT_NOREL(CLR_RT_HeapBlock ) DT_OPT_NAME(REFLECTION ) }, // DATATYPE_REFLECTION + { DT_MT , DT_NA, DT_NA, DT_T(ARRAY_BYREF ), DT_CNV(END ), nullptr , DT_REL (CLR_RT_HeapBlock ::Relocate_ArrayRef) DT_OPT_NAME(ARRAY_BYREF ) }, // DATATYPE_ARRAY_BYREF + { DT_REF | DT_MT , DT_NA, DT_BL, DT_T(DELEGATE_HEAD ), DT_CNV(END ), nullptr , DT_REL (CLR_RT_HeapBlock_Delegate ::Relocate ) DT_OPT_NAME(DELEGATE_HEAD ) }, // DATATYPE_DELEGATE_HEAD + { DT_REF | DT_MT , DT_NA, DT_NA, DT_T(DELEGATELIST_HEAD ), DT_CNV(END ), nullptr , DT_REL (CLR_RT_HeapBlock_Delegate_List::Relocate ) DT_OPT_NAME(DELEGATELIST_HEAD ) }, // DATATYPE_DELEGATELIST_HEAD + { DT_REF , DT_NA, DT_NA, DT_T(OBJECT_TO_EVENT ), DT_CNV(END ), nullptr , DT_REL (CLR_RT_ObjectToEvent_Source ::Relocate ) DT_OPT_NAME(OBJECT_TO_EVENT ) }, // DATATYPE_OBJECT_TO_EVENT + { DT_REF , DT_NA, DT_NA, DT_T(BINARY_BLOB_HEAD ), DT_CNV(END ), nullptr , DT_REL (CLR_RT_HeapBlock_BinaryBlob ::Relocate ) DT_OPT_NAME(BINARY_BLOB_HEAD ) }, // DATATYPE_BINARY_BLOB_HEAD // - { DT_REF , DT_NA, DT_NA, DT_T(THREAD ), DT_CNV(END ), NULL , DT_REL (CLR_RT_Thread ::Relocate ) DT_OPT_NAME(THREAD ) }, // DATATYPE_THREAD - { DT_REF , DT_NA, DT_NA, DT_T(SUBTHREAD ), DT_CNV(END ), NULL , DT_REL (CLR_RT_SubThread ::Relocate ) DT_OPT_NAME(SUBTHREAD ) }, // DATATYPE_SUBTHREAD - { DT_REF , DT_NA, DT_NA, DT_T(STACK_FRAME ), DT_CNV(END ), NULL , DT_REL (CLR_RT_StackFrame ::Relocate ) DT_OPT_NAME(STACK_FRAME ) }, // DATATYPE_STACK_FRAME - { DT_REF , DT_NA, DT_NA, DT_T(TIMER_HEAD ), DT_CNV(END ), NULL , DT_NOREL(CLR_RT_HeapBlock_Timer ) DT_OPT_NAME(TIMER_HEAD ) }, // DATATYPE_TIMER_HEAD - { DT_REF , DT_NA, DT_NA, DT_T(LOCK_HEAD ), DT_CNV(END ), NULL , DT_REL (CLR_RT_HeapBlock_Lock ::Relocate ) DT_OPT_NAME(LOCK_HEAD ) }, // DATATYPE_LOCK_HEAD - { DT_REF , DT_NA, DT_NA, DT_T(LOCK_OWNER_HEAD ), DT_CNV(END ), NULL , DT_REL (CLR_RT_HeapBlock_Lock ::Relocate_Owner ) DT_OPT_NAME(LOCK_OWNER_HEAD ) }, // DATATYPE_LOCK_OWNER_HEAD - { DT_REF , DT_NA, DT_NA, DT_T(LOCK_REQUEST_HEAD ), DT_CNV(END ), NULL , DT_REL (CLR_RT_HeapBlock_LockRequest ::Relocate ) DT_OPT_NAME(LOCK_REQUEST_HEAD ) }, // DATATYPE_LOCK_REQUEST_HEAD - { DT_REF , DT_NA, DT_NA, DT_T(WAIT_FOR_OBJECT_HEAD), DT_CNV(END ), NULL , DT_REL (CLR_RT_HeapBlock_WaitForObject::Relocate ) DT_OPT_NAME(WAIT_FOR_OBJECT_HEAD) }, // DATATYPE_WAIT_FOR_OBJECT_HEAD - { DT_REF , DT_NA, DT_NA, DT_T(FINALIZER_HEAD ), DT_CNV(END ), NULL , DT_REL (CLR_RT_HeapBlock_Finalizer ::Relocate ) DT_OPT_NAME(FINALIZER_HEAD ) }, // DATATYPE_FINALIZER_HEAD - { DT_NA , DT_NA, DT_NA, DT_T(MEMORY_STREAM_HEAD ), DT_CNV(END ), NULL , DT_NOREL(CLR_RT_HeapBlock_MemoryStream ) DT_OPT_NAME(MEMORY_STREAM_HEAD ) }, // DATATYPE_MEMORY_STREAM_HEAD - { DT_NA , DT_NA, DT_NA, DT_T(MEMORY_STREAM_DATA ), DT_CNV(END ), NULL , DT_NOREL(CLR_RT_HeapBlock_MemoryStream ) DT_OPT_NAME(MEMORY_STREAM_DATA ) }, // DATATYPE_MEMORY_STREAM_DATA + { DT_REF , DT_NA, DT_NA, DT_T(THREAD ), DT_CNV(END ), nullptr , DT_REL (CLR_RT_Thread ::Relocate ) DT_OPT_NAME(THREAD ) }, // DATATYPE_THREAD + { DT_REF , DT_NA, DT_NA, DT_T(SUBTHREAD ), DT_CNV(END ), nullptr , DT_REL (CLR_RT_SubThread ::Relocate ) DT_OPT_NAME(SUBTHREAD ) }, // DATATYPE_SUBTHREAD + { DT_REF , DT_NA, DT_NA, DT_T(STACK_FRAME ), DT_CNV(END ), nullptr , DT_REL (CLR_RT_StackFrame ::Relocate ) DT_OPT_NAME(STACK_FRAME ) }, // DATATYPE_STACK_FRAME + { DT_REF , DT_NA, DT_NA, DT_T(TIMER_HEAD ), DT_CNV(END ), nullptr , DT_NOREL(CLR_RT_HeapBlock_Timer ) DT_OPT_NAME(TIMER_HEAD ) }, // DATATYPE_TIMER_HEAD + { DT_REF , DT_NA, DT_NA, DT_T(LOCK_HEAD ), DT_CNV(END ), nullptr , DT_REL (CLR_RT_HeapBlock_Lock ::Relocate ) DT_OPT_NAME(LOCK_HEAD ) }, // DATATYPE_LOCK_HEAD + { DT_REF , DT_NA, DT_NA, DT_T(LOCK_OWNER_HEAD ), DT_CNV(END ), nullptr , DT_REL (CLR_RT_HeapBlock_Lock ::Relocate_Owner ) DT_OPT_NAME(LOCK_OWNER_HEAD ) }, // DATATYPE_LOCK_OWNER_HEAD + { DT_REF , DT_NA, DT_NA, DT_T(LOCK_REQUEST_HEAD ), DT_CNV(END ), nullptr , DT_REL (CLR_RT_HeapBlock_LockRequest ::Relocate ) DT_OPT_NAME(LOCK_REQUEST_HEAD ) }, // DATATYPE_LOCK_REQUEST_HEAD + { DT_REF , DT_NA, DT_NA, DT_T(WAIT_FOR_OBJECT_HEAD), DT_CNV(END ), nullptr , DT_REL (CLR_RT_HeapBlock_WaitForObject::Relocate ) DT_OPT_NAME(WAIT_FOR_OBJECT_HEAD) }, // DATATYPE_WAIT_FOR_OBJECT_HEAD + { DT_REF , DT_NA, DT_NA, DT_T(FINALIZER_HEAD ), DT_CNV(END ), nullptr , DT_REL (CLR_RT_HeapBlock_Finalizer ::Relocate ) DT_OPT_NAME(FINALIZER_HEAD ) }, // DATATYPE_FINALIZER_HEAD + { DT_NA , DT_NA, DT_NA, DT_T(MEMORY_STREAM_HEAD ), DT_CNV(END ), nullptr , DT_NOREL(CLR_RT_HeapBlock_MemoryStream ) DT_OPT_NAME(MEMORY_STREAM_HEAD ) }, // DATATYPE_MEMORY_STREAM_HEAD + { DT_NA , DT_NA, DT_NA, DT_T(MEMORY_STREAM_DATA ), DT_CNV(END ), nullptr , DT_NOREL(CLR_RT_HeapBlock_MemoryStream ) DT_OPT_NAME(MEMORY_STREAM_DATA ) }, // DATATYPE_MEMORY_STREAM_DATA // - { DT_NA , DT_NA, DT_NA, DT_T(SERIALIZER_HEAD ), DT_CNV(END ), NULL , DT_NOREL(CLR_RT_BinaryFormatter ) DT_OPT_NAME(SERIALIZER_HEAD ) }, // DATATYPE_SERIALIZER_HEAD - { DT_NA , DT_NA, DT_NA, DT_T(SERIALIZER_DUPLICATE), DT_CNV(END ), NULL , DT_NOREL(CLR_RT_BinaryFormatter ) DT_OPT_NAME(SERIALIZER_DUPLICATE) }, // DATATYPE_SERIALIZER_DUPLICATE - { DT_NA , DT_NA, DT_NA, DT_T(SERIALIZER_STATE ), DT_CNV(END ), NULL , DT_NOREL(CLR_RT_BinaryFormatter ) DT_OPT_NAME(SERIALIZER_STATE ) }, // DATATYPE_SERIALIZER_STATE + { DT_NA , DT_NA, DT_NA, DT_T(SERIALIZER_HEAD ), DT_CNV(END ), nullptr , DT_NOREL(CLR_RT_BinaryFormatter ) DT_OPT_NAME(SERIALIZER_HEAD ) }, // DATATYPE_SERIALIZER_HEAD + { DT_NA , DT_NA, DT_NA, DT_T(SERIALIZER_DUPLICATE), DT_CNV(END ), nullptr , DT_NOREL(CLR_RT_BinaryFormatter ) DT_OPT_NAME(SERIALIZER_DUPLICATE) }, // DATATYPE_SERIALIZER_DUPLICATE + { DT_NA , DT_NA, DT_NA, DT_T(SERIALIZER_STATE ), DT_CNV(END ), nullptr , DT_NOREL(CLR_RT_BinaryFormatter ) DT_OPT_NAME(SERIALIZER_STATE ) }, // DATATYPE_SERIALIZER_STATE // - { DT_REF , DT_NA, DT_NA, DT_T(ENDPOINT_HEAD ), DT_CNV(END ), NULL , DT_NOREL(CLR_RT_HeapBlock_EndPoint ) DT_OPT_NAME(ENDPOINT_HEAD ) }, // DATATYPE_ENDPOINT_HEAD + { DT_REF , DT_NA, DT_NA, DT_T(ENDPOINT_HEAD ), DT_CNV(END ), nullptr , DT_NOREL(CLR_RT_HeapBlock_EndPoint ) DT_OPT_NAME(ENDPOINT_HEAD ) }, // DATATYPE_ENDPOINT_HEAD // DATATYPE_NOT_SUPPORTED DATATYPE_NOT_SUPPORTED DATATYPE_NOT_SUPPORTED - { DT_REF , DT_NA, DT_NA, DT_T(IO_PORT ), DT_CNV(END ), NULL , DT_NOREL(CLR_RT_HeapBlock_NativeEventDispatcher ) DT_OPT_NAME(IO_PORT ) }, // DATATYPE_IO_PORT + { DT_REF , DT_NA, DT_NA, DT_T(IO_PORT ), DT_CNV(END ), nullptr , DT_NOREL(CLR_RT_HeapBlock_NativeEventDispatcher ) DT_OPT_NAME(IO_PORT ) }, // DATATYPE_IO_PORT DATATYPE_NOT_SUPPORTED //VTU_PORT #if defined(NANOCLR_APPDOMAINS) - { DT_REF , DT_NA, DT_NA, DT_T(APPDOMAIN_HEAD ), DT_CNV(END ), NULL , DT_REL (CLR_RT_AppDomain::Relocate ) DT_OPT_NAME(APPDOMAIN_HEAD ) }, // DATATYPE_APPDOMAIN_HEAD - { DT_REF | DT_MT, DT_NA, DT_NA, DT_T(TRANSPARENT_PROXY ), DT_CNV(END ), NULL , DT_REL (CLR_RT_HeapBlock::Relocate_TransparentProxy ) DT_OPT_NAME(TRANSPARENT_PROXY ) }, // DATATYPE_TRANSPARENT_PROXY - { DT_REF , DT_NA, DT_NA, DT_T(APPDOMAIN_ASSEMBLY ), DT_CNV(END ), NULL , DT_REL (CLR_RT_AppDomainAssembly::Relocate ) DT_OPT_NAME(APPDOMAIN_ASSEMBLY ) }, // DATATYPE_APPDOMAIN_ASSEMBLY + { DT_REF , DT_NA, DT_NA, DT_T(APPDOMAIN_HEAD ), DT_CNV(END ), nullptr , DT_REL (CLR_RT_AppDomain::Relocate ) DT_OPT_NAME(APPDOMAIN_HEAD ) }, // DATATYPE_APPDOMAIN_HEAD + { DT_REF | DT_MT , DT_NA, DT_NA, DT_T(TRANSPARENT_PROXY ), DT_CNV(END ), nullptr , DT_REL (CLR_RT_HeapBlock::Relocate_TransparentProxy ) DT_OPT_NAME(TRANSPARENT_PROXY ) }, // DATATYPE_TRANSPARENT_PROXY + { DT_REF , DT_NA, DT_NA, DT_T(APPDOMAIN_ASSEMBLY ), DT_CNV(END ), nullptr , DT_REL (CLR_RT_AppDomainAssembly::Relocate ) DT_OPT_NAME(APPDOMAIN_ASSEMBLY ) }, // DATATYPE_APPDOMAIN_ASSEMBLY #else DATATYPE_NOT_SUPPORTED DATATYPE_NOT_SUPPORTED diff --git a/src/CLR/Core/Various.cpp b/src/CLR/Core/Various.cpp index 17f9a16de6..9365a5f6b3 100644 --- a/src/CLR/Core/Various.cpp +++ b/src/CLR/Core/Various.cpp @@ -40,7 +40,7 @@ HRESULT CLR_RT_ArrayListHelper::PrepareArrayList(CLR_RT_HeapBlock &thisRef, int } NANOCLR_CHECK_HRESULT( - CLR_RT_HeapBlock_Array::CreateInstance(pThis[FIELD___items], capacity, g_CLR_RT_WellKnownTypes.m_Object)); + CLR_RT_HeapBlock_Array::CreateInstance(pThis[FIELD___items], capacity, g_CLR_RT_WellKnownTypes.Object)); pThis[FIELD___size].NumericByRef().s4 = count; @@ -89,7 +89,7 @@ HRESULT CLR_RT_ByteArrayReader::Init(const unsigned char *src, unsigned int srcS NATIVE_PROFILE_CLR_CORE(); NANOCLR_HEADER(); - if (src == NULL || srcSize == 0) + if (src == nullptr || srcSize == 0) NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER); source = src; diff --git a/src/CLR/Core/corhdr_private.h b/src/CLR/Core/corhdr_private.h index 877b70980f..acecb19544 100644 --- a/src/CLR/Core/corhdr_private.h +++ b/src/CLR/Core/corhdr_private.h @@ -37,40 +37,78 @@ typedef enum CorElementType ELEMENT_TYPE_STRING = 0xe, // every type above PTR will be simple type - ELEMENT_TYPE_PTR = 0xf, // PTR - ELEMENT_TYPE_BYREF = 0x10, // BYREF + // PTR + ELEMENT_TYPE_PTR = 0xf, + // BYREF + ELEMENT_TYPE_BYREF = 0x10, // Please use ELEMENT_TYPE_VALUETYPE. ELEMENT_TYPE_VALUECLASS is deprecated. - ELEMENT_TYPE_VALUETYPE = 0x11, // VALUETYPE - ELEMENT_TYPE_CLASS = 0x12, // CLASS - ELEMENT_TYPE_VAR = 0x13, // a class type variable VAR - ELEMENT_TYPE_ARRAY = 0x14, // MDARRAY ... ... - ELEMENT_TYPE_GENERICINST = 0x15, // instantiated type - ELEMENT_TYPE_TYPEDBYREF = 0x16, // This is a simple type. - - ELEMENT_TYPE_I = 0x18, // native integer size - ELEMENT_TYPE_U = 0x19, // native unsigned integer size - ELEMENT_TYPE_FNPTR = 0x1B, // FNPTR - ELEMENT_TYPE_OBJECT = 0x1C, // Shortcut for System.Object - ELEMENT_TYPE_SZARRAY = 0x1D, // Shortcut for single dimension zero lower bound array - // SZARRAY - ELEMENT_TYPE_MVAR = 0x1e, // a method type variable MVAR + + // VALUETYPE + ELEMENT_TYPE_VALUETYPE = 0x11, + + // CLASS + ELEMENT_TYPE_CLASS = 0x12, + + // a class type variable VAR + ELEMENT_TYPE_VAR = 0x13, + + // MDARRAY ... ... + ELEMENT_TYPE_ARRAY = 0x14, + + // instantiated type + // GENERICINST ... + ELEMENT_TYPE_GENERICINST = 0x15, + + // This is a simple type. + // TYPEDREF (it takes no args) a typed reference to some other type + ELEMENT_TYPE_TYPEDBYREF = 0x16, + + // native integer size + ELEMENT_TYPE_I = 0x18, + + // native unsigned integer size + ELEMENT_TYPE_U = 0x19, + + // FNPTR + ELEMENT_TYPE_FNPTR = 0x1B, + + // Shortcut for System.Object + ELEMENT_TYPE_OBJECT = 0x1C, + + // Shortcut for single dimension zero lower bound array + // SZARRAY + ELEMENT_TYPE_SZARRAY = 0x1D, + + + // a method type variable MVAR + ELEMENT_TYPE_MVAR = 0x1e, // This is only for binding - ELEMENT_TYPE_CMOD_REQD = 0x1F, // required C modifier : E_T_CMOD_REQD - ELEMENT_TYPE_CMOD_OPT = 0x20, // optional C modifier : E_T_CMOD_OPT + // required C modifier : E_T_CMOD_REQD + ELEMENT_TYPE_CMOD_REQD = 0x1F, + // optional C modifier : E_T_CMOD_OPT + ELEMENT_TYPE_CMOD_OPT = 0x20, // This is for signatures generated internally (which will not be persisted in any way). - ELEMENT_TYPE_INTERNAL = 0x21, // INTERNAL + // INTERNAL + ELEMENT_TYPE_INTERNAL = 0x21, // Note that this is the max of base type excluding modifiers - ELEMENT_TYPE_MAX = 0x22, // first invalid element type + // first invalid element type + ELEMENT_TYPE_MAX = 0x22, + + + ELEMENT_TYPE_MODIFIER = 0x40, + // sentinel for varargs + ELEMENT_TYPE_SENTINEL = 0x01 | ELEMENT_TYPE_MODIFIER, + ELEMENT_TYPE_PINNED = 0x05 | ELEMENT_TYPE_MODIFIER, + + // used only internally for R4 HFA types + ELEMENT_TYPE_R4_HFA = 0x06 | ELEMENT_TYPE_MODIFIER, - ELEMENT_TYPE_MODIFIER = 0x40, - ELEMENT_TYPE_SENTINEL = 0x01 | ELEMENT_TYPE_MODIFIER, // sentinel for varargs - ELEMENT_TYPE_PINNED = 0x05 | ELEMENT_TYPE_MODIFIER, - ELEMENT_TYPE_R4_HFA = 0x06 | ELEMENT_TYPE_MODIFIER, // used only internally for R4 HFA types - ELEMENT_TYPE_R8_HFA = 0x07 | ELEMENT_TYPE_MODIFIER, // used only internally for R8 HFA types + // used only internally for R8 HFA types + ELEMENT_TYPE_R8_HFA = 0x07 | ELEMENT_TYPE_MODIFIER, } CorElementType; diff --git a/src/CLR/Debugger/Debugger.cpp b/src/CLR/Debugger/Debugger.cpp index 03af70379f..d6fbc480bb 100644 --- a/src/CLR/Debugger/Debugger.cpp +++ b/src/CLR/Debugger/Debugger.cpp @@ -20,7 +20,7 @@ CLR_DBG_Debugger *g_CLR_DBG_Debugger; -BlockStorageDevice *CLR_DBG_Debugger::m_deploymentStorageDevice = NULL; +BlockStorageDevice *CLR_DBG_Debugger::m_deploymentStorageDevice = nullptr; //--// @@ -129,7 +129,7 @@ HRESULT CLR_DBG_Debugger::CreateInstance() } else { - m_deploymentStorageDevice = NULL; + m_deploymentStorageDevice = nullptr; } // UNDONE: FIXME: MFUpdate_Initialize(); @@ -168,7 +168,7 @@ HRESULT CLR_DBG_Debugger::DeleteInstance() // free debugger platform_free(g_CLR_DBG_Debugger); - g_CLR_DBG_Debugger = NULL; + g_CLR_DBG_Debugger = nullptr; NANOCLR_NOCLEANUP_NOLABEL(); } @@ -213,7 +213,7 @@ CLR_RT_AppDomain *CLR_DBG_Debugger::GetAppDomainFromID(CLR_UINT32 id) } NANOCLR_FOREACH_NODE_END(); - return NULL; + return nullptr; } #endif // NANOCLR_APPDOMAINS @@ -234,7 +234,7 @@ CLR_RT_Thread *CLR_DBG_Debugger::GetThreadFromPid(CLR_INT32 pid) } NANOCLR_FOREACH_NODE_END(); - return NULL; + return nullptr; } HRESULT CLR_DBG_Debugger::CreateListOfThreads(CLR_DBG_Commands::Debugging_Thread_List::Reply *&cmdReply, int &totLen) @@ -301,7 +301,7 @@ HRESULT CLR_DBG_Debugger::CreateListOfCalls( dst.m_IP = (CLR_UINT32)(call->m_inlineFrame->m_frame.m_IP - call->m_inlineFrame->m_frame.m_IPStart); #if defined(NANOCLR_APPDOMAINS) dst.m_appDomainID = call->m_appDomain->m_id; - dst.m_flags = call->m_flags; + dst.Flags = call->m_flags; #endif } #endif @@ -320,7 +320,7 @@ HRESULT CLR_DBG_Debugger::CreateListOfCalls( #if defined(NANOCLR_APPDOMAINS) dst.m_appDomainID = call->m_appDomain->m_id; - dst.m_flags = call->m_flags; + dst.Flags = call->m_flags; #endif } @@ -377,10 +377,10 @@ bool CLR_DBG_Debugger::Monitor_Ping(WP_Message *msg) if ((msg->m_header.m_flags & WP_Flags_c_Reply) == 0) { Monitor_Ping_Reply cmdReply; - Monitor_Ping_Command *cmd = (Monitor_Ping_Command *)msg->m_payload; + auto *cmd = (Monitor_Ping_Command *)msg->m_payload; // default is to stop the debugger (backwards compatibility) - fStopOnBoot = (cmd != NULL) && (cmd->Flags & Monitor_Ping_c_Ping_DbgFlag_Stop); + fStopOnBoot = (cmd != nullptr) && (cmd->Flags & Monitor_Ping_c_Ping_DbgFlag_Stop); cmdReply.Source = Monitor_Ping_c_Ping_Source_NanoCLR; @@ -428,13 +428,13 @@ bool CLR_DBG_Debugger::Monitor_Ping(WP_Message *msg) } else { - Monitor_Ping_Reply *pingReply = (Monitor_Ping_Reply *)msg->m_payload; + auto *pingReply = (Monitor_Ping_Reply *)msg->m_payload; // default is to stop the debugger (backwards compatibility) - fStopOnBoot = (pingReply != NULL) && (pingReply->Flags & Monitor_Ping_c_Ping_DbgFlag_Stop); + fStopOnBoot = (pingReply != nullptr) && (pingReply->Flags & Monitor_Ping_c_Ping_DbgFlag_Stop); // done, send reply - WP_ReplyToCommand(msg, true, false, NULL, 0); + WP_ReplyToCommand(msg, true, false, nullptr, 0); } if (CLR_EE_DBG_IS_MASK(StateInitialize, StateMask)) @@ -456,10 +456,10 @@ bool CLR_DBG_Debugger::Monitor_FlashSectorMap(WP_Message *msg) { NATIVE_PROFILE_CLR_DEBUGGER(); - BlockStorageDevice *storageDevices = NULL; - BlockStorageDevice *device = NULL; - DeviceBlockInfo *devicesBlockInfos = NULL; - Flash_BlockRegionInfo *pData = NULL; + BlockStorageDevice *storageDevices = nullptr; + BlockStorageDevice *device = nullptr; + DeviceBlockInfo *devicesBlockInfos = nullptr; + Flash_BlockRegionInfo *pData = nullptr; bool success = false; unsigned int rangeCount = 0; unsigned int rangeIndex = 0; @@ -472,14 +472,14 @@ bool CLR_DBG_Debugger::Monitor_FlashSectorMap(WP_Message *msg) // get an array of pointer to all the storage devices in the list and then request the device info storageDevices = (BlockStorageDevice *)platform_malloc(numDevices * sizeof(BlockStorageDevice)); - if (storageDevices == NULL) + if (storageDevices == nullptr) { // allocation failed goto cmd_executed; } devicesBlockInfos = (DeviceBlockInfo *)platform_malloc(numDevices * sizeof(DeviceBlockInfo)); - if (devicesBlockInfos == NULL) + if (devicesBlockInfos == nullptr) { // allocation failed goto cmd_executed; @@ -502,7 +502,7 @@ bool CLR_DBG_Debugger::Monitor_FlashSectorMap(WP_Message *msg) // sanity check device = &storageDevices[i]; - if (device == NULL) + if (device == nullptr) { // failed goto cmd_executed; @@ -519,7 +519,7 @@ bool CLR_DBG_Debugger::Monitor_FlashSectorMap(WP_Message *msg) pData = (Flash_BlockRegionInfo *)platform_malloc(size); - if (pData == NULL) + if (pData == nullptr) { goto cmd_executed; } @@ -886,7 +886,7 @@ void CLR_DBG_Debugger::AccessMemory( #if defined(VIRTUAL_DEVICE) - bool proceed = false; + proceed = false; void *temp; temp = (void *)sectAddr; @@ -953,7 +953,7 @@ bool CLR_DBG_Debugger::Monitor_ReadMemory(WP_Message *msg) { NATIVE_PROFILE_CLR_DEBUGGER(); - CLR_DBG_Commands_Monitor_ReadMemory *cmd = (CLR_DBG_Commands_Monitor_ReadMemory *)msg->m_payload; + auto *cmd = (CLR_DBG_Commands_Monitor_ReadMemory *)msg->m_payload; uint8_t *buffer; uint32_t errorCode; @@ -975,7 +975,7 @@ bool CLR_DBG_Debugger::Monitor_ReadMemory(WP_Message *msg) buffer = (uint8_t *)platform_malloc(allocationSize); // sanity check - if (buffer != NULL) + if (buffer != nullptr) { // clear allocated memory memset(buffer, 0, allocationSize); @@ -998,7 +998,7 @@ bool CLR_DBG_Debugger::Monitor_WriteMemory(WP_Message *msg) { NATIVE_PROFILE_CLR_DEBUGGER(); - CLR_DBG_Commands_Monitor_WriteMemory *cmd = (CLR_DBG_Commands_Monitor_WriteMemory *)msg->m_payload; + auto *cmd = (CLR_DBG_Commands_Monitor_WriteMemory *)msg->m_payload; CLR_DBG_Commands_Monitor_WriteMemory_Reply cmdReply; g_CLR_DBG_Debugger->AccessMemory(cmd->address, cmd->length, cmd->data, AccessMemory_Write, &cmdReply); @@ -1012,7 +1012,7 @@ bool CLR_DBG_Debugger::Monitor_CheckMemory(WP_Message *msg) { NATIVE_PROFILE_CLR_DEBUGGER(); - CLR_DBG_Commands_Monitor_CheckMemory *cmd = (CLR_DBG_Commands_Monitor_CheckMemory *)msg->m_payload; + auto *cmd = (CLR_DBG_Commands_Monitor_CheckMemory *)msg->m_payload; CLR_DBG_Commands_Monitor_CheckMemory_Reply cmdReply; uint32_t errorCode; @@ -1028,10 +1028,10 @@ bool CLR_DBG_Debugger::Monitor_EraseMemory(WP_Message *msg) { NATIVE_PROFILE_CLR_DEBUGGER(); - CLR_DBG_Commands_Monitor_EraseMemory *cmd = (CLR_DBG_Commands_Monitor_EraseMemory *)msg->m_payload; + auto *cmd = (CLR_DBG_Commands_Monitor_EraseMemory *)msg->m_payload; CLR_DBG_Commands_Monitor_EraseMemory_Reply cmdReply; - g_CLR_DBG_Debugger->AccessMemory(cmd->address, cmd->length, NULL, AccessMemory_Erase, &cmdReply); + g_CLR_DBG_Debugger->AccessMemory(cmd->address, cmd->length, nullptr, AccessMemory_Erase, &cmdReply); WP_ReplyToCommand(msg, true, false, &cmdReply, sizeof(cmdReply)); @@ -1042,14 +1042,14 @@ bool CLR_DBG_Debugger::Monitor_Execute(WP_Message *msg) { NATIVE_PROFILE_CLR_DEBUGGER(); - CLR_DBG_Commands::Monitor_Execute *cmd = (CLR_DBG_Commands::Monitor_Execute *)msg->m_payload; + auto *cmd = (CLR_DBG_Commands::Monitor_Execute *)msg->m_payload; #if defined(BUILD_RTM) if (!DebuggerPort_IsUsingSsl(HalSystemConfig.DebuggerPort)) return false; #endif - WP_ReplyToCommand(msg, true, false, NULL, 0); + WP_ReplyToCommand(msg, true, false, nullptr, 0); ((void (*)())(size_t)cmd->m_address)(); @@ -1062,7 +1062,7 @@ bool CLR_DBG_Debugger::Monitor_Reboot(WP_Message *msg) bool success = true; - CLR_DBG_Commands::Monitor_Reboot *cmd = (CLR_DBG_Commands::Monitor_Reboot *)msg->m_payload; + auto *cmd = (CLR_DBG_Commands::Monitor_Reboot *)msg->m_payload; if (CLR_DBG_Commands::Monitor_Reboot::c_EnterNanoBooter == (cmd->m_flags & CLR_DBG_Commands::Monitor_Reboot::c_EnterNanoBooter)) @@ -1076,7 +1076,7 @@ bool CLR_DBG_Debugger::Monitor_Reboot(WP_Message *msg) success = RequestToLaunchProprietaryBootloader(); } - WP_ReplyToCommand(msg, success, false, NULL, 0); + WP_ReplyToCommand(msg, success, false, nullptr, 0); // on success, apply reboot options and set reboot pending flag if (success) @@ -1112,7 +1112,7 @@ bool CLR_DBG_Debugger::Monitor_DeploymentMap(WP_Message *msg) { (void)msg; - WP_ReplyToCommand(msg, true, false, NULL, 0); + WP_ReplyToCommand(msg, true, false, nullptr, 0); return true; } @@ -1142,7 +1142,7 @@ bool CLR_DBG_Debugger::Monitor_QueryConfiguration(WP_Message *message) (HAL_Configuration_NetworkInterface *)platform_malloc(sizeof(HAL_Configuration_NetworkInterface)); // check allocation - if (configNetworkInterface != NULL) + if (configNetworkInterface != nullptr) { memset(configNetworkInterface, 0, sizeof(HAL_Configuration_NetworkInterface)); @@ -1170,7 +1170,7 @@ bool CLR_DBG_Debugger::Monitor_QueryConfiguration(WP_Message *message) (HAL_Configuration_Wireless80211 *)platform_malloc(sizeof(HAL_Configuration_Wireless80211)); // check allocation - if (configWireless80211NetworkInterface != NULL) + if (configWireless80211NetworkInterface != nullptr) { memset(configWireless80211NetworkInterface, 0, sizeof(HAL_Configuration_Wireless80211)); @@ -1210,7 +1210,7 @@ bool CLR_DBG_Debugger::Monitor_QueryConfiguration(WP_Message *message) x509Certificate = (HAL_Configuration_X509CaRootBundle *)platform_malloc(sizeOfBlock); // check allocation - if (x509Certificate != NULL) + if (x509Certificate != nullptr) { memset(x509Certificate, 0, sizeof(sizeOfBlock)); @@ -1276,7 +1276,7 @@ bool CLR_DBG_Debugger::Monitor_QueryConfiguration(WP_Message *message) (HAL_Configuration_WirelessAP *)platform_malloc(sizeof(HAL_Configuration_WirelessAP)); // check allocation - if (configWirelessAPNetworkInterface != NULL) + if (configWirelessAPNetworkInterface != nullptr) { memset(configWirelessAPNetworkInterface, 0, sizeof(HAL_Configuration_WirelessAP)); @@ -1402,8 +1402,7 @@ bool CLR_DBG_Debugger::Debugging_Execution_ChangeConditions(WP_Message *msg) { NATIVE_PROFILE_CLR_DEBUGGER(); - CLR_DBG_Commands::Debugging_Execution_ChangeConditions *cmd = - (CLR_DBG_Commands::Debugging_Execution_ChangeConditions *)msg->m_payload; + auto *cmd = (CLR_DBG_Commands::Debugging_Execution_ChangeConditions *)msg->m_payload; // save current value int32_t newConditions = g_CLR_RT_ExecutionEngine.m_iDebugger_Conditions; @@ -1459,15 +1458,15 @@ static void GetClrReleaseInfo(CLR_DBG_Commands::Debugging_Execution_QueryCLRCapa PLATFORMNAMESTRING, ARRAYSIZE(PLATFORMNAMESTRING)); - if (g_CLR_RT_TypeSystem.m_assemblyMscorlib && g_CLR_RT_TypeSystem.m_assemblyMscorlib->m_header) + if (g_CLR_RT_TypeSystem.m_assemblyMscorlib && g_CLR_RT_TypeSystem.m_assemblyMscorlib->header) { - const CLR_RECORD_VERSION *mscorlibVer = &(g_CLR_RT_TypeSystem.m_assemblyMscorlib->m_header->version); + const CLR_RECORD_VERSION *mscorlibVer = &(g_CLR_RT_TypeSystem.m_assemblyMscorlib->header->version); NFVersion::Init( clrInfo.m_TargetFrameworkVersion, - mscorlibVer->iMajorVersion, - mscorlibVer->iMinorVersion, - mscorlibVer->iBuildNumber, - mscorlibVer->iRevisionNumber); + mscorlibVer->majorVersion, + mscorlibVer->minorVersion, + mscorlibVer->buildNumber, + mscorlibVer->revisionNumber); } else { @@ -1503,7 +1502,7 @@ static bool GetInteropNativeAssemblies(uint8_t *&data, uint32_t *size, uint32_t data = (uint8_t *)platform_malloc(*size); // check for malloc failure - if (data == NULL) + if (data == nullptr) { return false; } @@ -1512,7 +1511,7 @@ static bool GetInteropNativeAssemblies(uint8_t *&data, uint32_t *size, uint32_t interopNativeAssemblies = (CLR_DBG_Commands::Debugging_Execution_QueryCLRCapabilities::NativeAssemblyDetails *)data; // clear buffer memory - memset(interopNativeAssemblies, 0, (uint32_t)*size); + memset(interopNativeAssemblies, 0, *size); // fill the array for (uint32_t i = 0; i < g_CLR_InteropAssembliesCount; i++) @@ -1528,10 +1527,10 @@ static bool GetInteropNativeAssemblies(uint8_t *&data, uint32_t *size, uint32_t NFVersion::Init( interopNativeAssemblies[index].Version, - g_CLR_InteropAssembliesNativeData[i]->m_Version.iMajorVersion, - g_CLR_InteropAssembliesNativeData[i]->m_Version.iMinorVersion, - g_CLR_InteropAssembliesNativeData[i]->m_Version.iBuildNumber, - g_CLR_InteropAssembliesNativeData[i]->m_Version.iRevisionNumber); + g_CLR_InteropAssembliesNativeData[i]->m_Version.majorVersion, + g_CLR_InteropAssembliesNativeData[i]->m_Version.minorVersion, + g_CLR_InteropAssembliesNativeData[i]->m_Version.buildNumber, + g_CLR_InteropAssembliesNativeData[i]->m_Version.revisionNumber); index++; } @@ -1546,13 +1545,12 @@ bool CLR_DBG_Debugger::Debugging_Execution_QueryCLRCapabilities(WP_Message *msg) { NATIVE_PROFILE_CLR_DEBUGGER(); - CLR_DBG_Commands::Debugging_Execution_QueryCLRCapabilities *cmd = - (CLR_DBG_Commands::Debugging_Execution_QueryCLRCapabilities *)msg->m_payload; + auto *cmd = (CLR_DBG_Commands::Debugging_Execution_QueryCLRCapabilities *)msg->m_payload; CLR_DBG_Commands::Debugging_Execution_QueryCLRCapabilities::ReplyUnion reply; reply.u_capsFlags = 0; - CLR_UINT8 *data = NULL; + CLR_UINT8 *data = nullptr; uint32_t size = 0; bool fSuccess = true; bool freeAllocFlag = false; @@ -1750,7 +1748,7 @@ bool CLR_DBG_Debugger::Debugging_Execution_QueryCLRCapabilities(WP_Message *msg) WP_ReplyToCommand(msg, fSuccess, false, data, size); // check if we need to free data pointer - if (freeAllocFlag && data != NULL) + if (freeAllocFlag && data != nullptr) { platform_free(data); } @@ -1781,7 +1779,7 @@ bool CLR_DBG_Debugger::Debugging_Execution_Allocate(WP_Message *msg) bool CLR_DBG_Debugger::Debugging_UpgradeToSsl(WP_Message *msg) { - CLR_DBG_Commands::Debugging_UpgradeToSsl *cmd = (CLR_DBG_Commands::Debugging_UpgradeToSsl *)msg->m_payload; + auto *cmd = (CLR_DBG_Commands::Debugging_UpgradeToSsl *)msg->m_payload; CLR_DBG_Commands::Debugging_UpgradeToSsl::Reply reply; if (!DebuggerPort_IsSslSupported(HalSystemConfig.DebuggerPort)) @@ -1809,10 +1807,14 @@ static bool FillValues( { NATIVE_PROFILE_CLR_DEBUGGER(); if (!ptr) + { return true; + } if (!array || num == 0) + { return false; + } CLR_DBG_Commands::Debugging_Value *dst = array++; num--; @@ -1820,14 +1822,14 @@ static bool FillValues( memset(dst, 0, sizeof(*dst)); - dst->m_referenceID = (CLR_UINT32)((reference != NULL) ? reference : ptr); + dst->m_referenceID = (CLR_UINT32)((reference != nullptr) ? reference : ptr); dst->m_dt = ptr->DataType(); dst->m_flags = ptr->DataFlags(); dst->m_size = ptr->DataSize(); - if (pTD != NULL) + if (pTD != nullptr) { - dst->m_td.m_data = pTD->m_data; + dst->m_td.data = pTD->data; } else if (SUCCEEDED(desc.InitializeFromObject(*ptr))) { @@ -1864,7 +1866,7 @@ static bool FillValues( { const char *text = ptr->StringText(); - if (text != NULL) + if (text != nullptr) { dst->m_charsInString = (CLR_UINT32)text; dst->m_bytesInString = (CLR_UINT32)hal_strlen_s(text); @@ -1887,20 +1889,24 @@ static bool FillValues( case DATATYPE_OBJECT: case DATATYPE_BYREF: - return FillValues(ptr->Dereference(), array, num, NULL, pTD); + return FillValues(ptr->Dereference(), array, num, nullptr, pTD); case DATATYPE_CLASS: case DATATYPE_VALUETYPE: dst->m_td = ptr->ObjectCls(); break; + case DATATYPE_GENERICINST: + dst->m_ts = ptr->ObjectGenericType(); + break; + case DATATYPE_SZARRAY: { - CLR_RT_HeapBlock_Array *ptr2 = (CLR_RT_HeapBlock_Array *)ptr; + CLR_RT_HeapBlock_Array const *ptr2 = (CLR_RT_HeapBlock_Array *)ptr; dst->m_array_numOfElements = ptr2->m_numOfElements; - dst->m_array_depth = ptr2->ReflectionDataConst().m_levels; - dst->m_array_typeIndex = ptr2->ReflectionDataConst().m_data.m_type; + dst->m_array_depth = ptr2->ReflectionDataConst().levels; + dst->m_array_typeIndex = ptr2->ReflectionDataConst().data.type; } break; @@ -1951,6 +1957,10 @@ static bool FillValues( case DATATYPE_APPDOMAIN_ASSEMBLY: #endif + break; + default: + return false; + break; } @@ -1974,7 +1984,7 @@ bool CLR_DBG_Debugger::GetValue( return true; } - WP_ReplyToCommand(msg, false, false, NULL, 0); + WP_ReplyToCommand(msg, false, false, nullptr, 0); return false; } @@ -1995,7 +2005,7 @@ bool CLR_DBG_Debugger::Debugging_Execution_SetCurrentAppDomain(WP_Message *msg) g_CLR_RT_ExecutionEngine.SetCurrentAppDomain(appDomain); } - WP_ReplyToCommand(msg, appDomain != NULL, false, NULL, 0); + WP_ReplyToCommand(msg, appDomain != nullptr, false, nullptr, 0); return true; #else @@ -2008,14 +2018,13 @@ bool CLR_DBG_Debugger::Debugging_Execution_Breakpoints(WP_Message *msg) { NATIVE_PROFILE_CLR_DEBUGGER(); - CLR_DBG_Commands::Debugging_Execution_Breakpoints *cmd = - (CLR_DBG_Commands::Debugging_Execution_Breakpoints *)msg->m_payload; + auto *cmd = (CLR_DBG_Commands::Debugging_Execution_Breakpoints *)msg->m_payload; g_CLR_RT_ExecutionEngine.InstallBreakpoints( cmd->m_data, (msg->m_header.m_size - sizeof(cmd->m_flags)) / sizeof(CLR_DBG_Commands::Debugging_Execution_BreakpointDef)); - WP_ReplyToCommand(msg, true, false, NULL, 0); + WP_ReplyToCommand(msg, true, false, nullptr, 0); return true; } @@ -2038,17 +2047,17 @@ bool CLR_DBG_Debugger::Debugging_Execution_BreakpointStatus(WP_Message *msg) //--// -CLR_RT_Assembly *CLR_DBG_Debugger::IsGoodAssembly(CLR_IDX idxAssm) +CLR_RT_Assembly *CLR_DBG_Debugger::IsGoodAssembly(CLR_INDEX indexAssm) { NATIVE_PROFILE_CLR_DEBUGGER(); NANOCLR_FOREACH_ASSEMBLY(g_CLR_RT_TypeSystem) { - if (pASSM->m_idx == idxAssm) + if (pASSM->assemblyIndex == indexAssm) return pASSM; } NANOCLR_FOREACH_ASSEMBLY_END(); - return NULL; + return nullptr; } bool CLR_DBG_Debugger::CheckTypeDef(const CLR_RT_TypeDef_Index &td, CLR_RT_TypeDef_Instance &inst) @@ -2056,7 +2065,7 @@ bool CLR_DBG_Debugger::CheckTypeDef(const CLR_RT_TypeDef_Index &td, CLR_RT_TypeD NATIVE_PROFILE_CLR_DEBUGGER(); CLR_RT_Assembly *assm = IsGoodAssembly(td.Assembly()); - if (assm && td.Type() < assm->m_pTablesSize[TBL_TypeDef]) + if (assm && td.Type() < assm->tablesSize[TBL_TypeDef]) { return inst.InitializeFromIndex(td); } @@ -2069,7 +2078,7 @@ bool CLR_DBG_Debugger::CheckFieldDef(const CLR_RT_FieldDef_Index &fd, CLR_RT_Fie NATIVE_PROFILE_CLR_DEBUGGER(); CLR_RT_Assembly *assm = IsGoodAssembly(fd.Assembly()); - if (assm && fd.Field() < assm->m_pTablesSize[TBL_FieldDef]) + if (assm && fd.Field() < assm->tablesSize[TBL_FieldDef]) { return inst.InitializeFromIndex(fd); } @@ -2082,7 +2091,7 @@ bool CLR_DBG_Debugger::CheckMethodDef(const CLR_RT_MethodDef_Index &md, CLR_RT_M NATIVE_PROFILE_CLR_DEBUGGER(); CLR_RT_Assembly *assm = IsGoodAssembly(md.Assembly()); - if (assm && md.Method() < assm->m_pTablesSize[TBL_MethodDef]) + if (assm && md.Method() < assm->tablesSize[TBL_MethodDef]) { return inst.InitializeFromIndex(md); } @@ -2118,7 +2127,7 @@ CLR_RT_StackFrame *CLR_DBG_Debugger::CheckStackFrame(CLR_INT32 pid, CLR_UINT32 d NANOCLR_FOREACH_NODE_END(); } - return NULL; + return nullptr; } //--// @@ -2129,14 +2138,13 @@ static HRESULT Debugging_Thread_Create_Helper(CLR_RT_MethodDef_Index &md, CLR_RT NANOCLR_HEADER(); CLR_RT_HeapBlock ref; - ref.SetObjectReference(NULL); + ref.SetObjectReference(nullptr); CLR_RT_ProtectFromGC gc(ref); + CLR_RT_Thread *realThread = (pid != 0) ? CLR_DBG_Debugger::GetThreadFromPid(pid) : nullptr; - CLR_RT_Thread *realThread = (pid != 0) ? CLR_DBG_Debugger::GetThreadFromPid(pid) : NULL; + th = nullptr; - th = NULL; - - NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_Delegate::CreateInstance(ref, md, NULL)); + NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_Delegate::CreateInstance(ref, md, nullptr)); NANOCLR_CHECK_HRESULT( g_CLR_RT_ExecutionEngine.NewThread(th, ref.DereferenceDelegate(), ThreadPriority::Highest, -1)); @@ -2148,19 +2156,19 @@ static HRESULT Debugging_Thread_Create_Helper(CLR_RT_MethodDef_Index &md, CLR_RT { CLR_RT_StackFrame *stack = th->CurrentFrame(); - const CLR_RECORD_METHODDEF *target = stack->m_call.m_target; - CLR_UINT8 numArgs = target->numArgs; + const CLR_RECORD_METHODDEF *target = stack->m_call.target; + CLR_UINT8 numArgs = target->argumentsCount; if (numArgs) { CLR_RT_SignatureParser parser{}; - parser.Initialize_MethodSignature(stack->m_call.m_assm, target); + parser.Initialize_MethodSignature(&stack->m_call); CLR_RT_SignatureParser::Element res; CLR_RT_HeapBlock *args = stack->m_arguments; - if (parser.m_flags & PIMAGE_CEE_CS_CALLCONV_HASTHIS) + if (parser.Flags & PIMAGE_CEE_CS_CALLCONV_HASTHIS) { - args->SetObjectReference(NULL); + args->SetObjectReference(nullptr); numArgs--; args++; @@ -2181,7 +2189,7 @@ static HRESULT Debugging_Thread_Create_Helper(CLR_RT_MethodDef_Index &md, CLR_RT { NANOCLR_CHECK_HRESULT(parser2.Advance(res)); - if (res.m_fByRef) + if (res.IsByRef) { NANOCLR_SET_AND_LEAVE(CLR_E_WRONG_TYPE); } @@ -2202,7 +2210,7 @@ static HRESULT Debugging_Thread_Create_Helper(CLR_RT_MethodDef_Index &md, CLR_RT if (th) { th->Terminate(); - th = NULL; + th = nullptr; } } @@ -2237,7 +2245,7 @@ bool CLR_DBG_Debugger::Debugging_Thread_List(WP_Message *msg) { NATIVE_PROFILE_CLR_DEBUGGER(); - CLR_DBG_Commands::Debugging_Thread_List::Reply *cmdReply = NULL; + CLR_DBG_Commands::Debugging_Thread_List::Reply *cmdReply = nullptr; int len = 0; if (FAILED(g_CLR_DBG_Debugger->CreateListOfThreads(cmdReply, len))) @@ -2258,8 +2266,8 @@ bool CLR_DBG_Debugger::Debugging_Thread_Stack(WP_Message *msg) { NATIVE_PROFILE_CLR_DEBUGGER(); - CLR_DBG_Commands::Debugging_Thread_Stack *cmd = (CLR_DBG_Commands::Debugging_Thread_Stack *)msg->m_payload; - CLR_DBG_Commands::Debugging_Thread_Stack::Reply *cmdReply = NULL; + auto *cmd = (CLR_DBG_Commands::Debugging_Thread_Stack *)msg->m_payload; + CLR_DBG_Commands::Debugging_Thread_Stack::Reply *cmdReply = nullptr; int len = 0; if (FAILED(g_CLR_DBG_Debugger->CreateListOfCalls(cmd->m_pid, cmdReply, len))) @@ -2280,7 +2288,7 @@ bool CLR_DBG_Debugger::Debugging_Thread_Kill(WP_Message *msg) { NATIVE_PROFILE_CLR_DEBUGGER(); - CLR_DBG_Commands::Debugging_Thread_Kill *cmd = (CLR_DBG_Commands::Debugging_Thread_Kill *)msg->m_payload; + auto *cmd = (CLR_DBG_Commands::Debugging_Thread_Kill *)msg->m_payload; CLR_DBG_Commands::Debugging_Thread_Kill::Reply cmdReply; CLR_RT_Thread *th = g_CLR_DBG_Debugger->GetThreadFromPid(cmd->m_pid); @@ -2304,7 +2312,7 @@ bool CLR_DBG_Debugger::Debugging_Thread_Suspend(WP_Message *msg) { NATIVE_PROFILE_CLR_DEBUGGER(); - CLR_DBG_Commands::Debugging_Thread_Suspend *cmd = (CLR_DBG_Commands::Debugging_Thread_Suspend *)msg->m_payload; + auto *cmd = (CLR_DBG_Commands::Debugging_Thread_Suspend *)msg->m_payload; CLR_RT_Thread *th = g_CLR_DBG_Debugger->GetThreadFromPid(cmd->m_pid); if (th) @@ -2312,7 +2320,7 @@ bool CLR_DBG_Debugger::Debugging_Thread_Suspend(WP_Message *msg) th->Suspend(); } - WP_ReplyToCommand(msg, th != NULL, false, NULL, 0); + WP_ReplyToCommand(msg, th != nullptr, false, nullptr, 0); return true; } @@ -2321,7 +2329,7 @@ bool CLR_DBG_Debugger::Debugging_Thread_Resume(WP_Message *msg) { NATIVE_PROFILE_CLR_DEBUGGER(); - CLR_DBG_Commands::Debugging_Thread_Resume *cmd = (CLR_DBG_Commands::Debugging_Thread_Resume *)msg->m_payload; + auto *cmd = (CLR_DBG_Commands::Debugging_Thread_Resume *)msg->m_payload; CLR_RT_Thread *th = g_CLR_DBG_Debugger->GetThreadFromPid(cmd->m_pid); if (th) @@ -2329,7 +2337,7 @@ bool CLR_DBG_Debugger::Debugging_Thread_Resume(WP_Message *msg) th->Resume(); } - WP_ReplyToCommand(msg, th != NULL, false, NULL, 0); + WP_ReplyToCommand(msg, th != nullptr, false, nullptr, 0); return true; } @@ -2338,12 +2346,12 @@ bool CLR_DBG_Debugger::Debugging_Thread_Get(WP_Message *msg) { NATIVE_PROFILE_CLR_DEBUGGER(); CLR_DBG_Debugger *dbg = g_CLR_DBG_Debugger; - CLR_DBG_Commands::Debugging_Thread_Get *cmd = (CLR_DBG_Commands::Debugging_Thread_Get *)msg->m_payload; + auto *cmd = (CLR_DBG_Commands::Debugging_Thread_Get *)msg->m_payload; CLR_RT_Thread *th = dbg->GetThreadFromPid(cmd->m_pid); CLR_RT_HeapBlock *pThread; bool fFound = false; - if (th == NULL) + if (th == nullptr) { return false; } @@ -2361,14 +2369,14 @@ bool CLR_DBG_Debugger::Debugging_Thread_Get(WP_Message *msg) NANOCLR_FOREACH_NODE(CLR_RT_ObjectToEvent_Source, src, th->m_references) { CLR_RT_HeapBlock *pManagedThread = src->m_objectPtr; - _ASSERTE(pManagedThread != NULL); + _ASSERTE(pManagedThread != nullptr); #if defined(NANOCLR_APPDOMAINS) { CLR_RT_ObjectToEvent_Source *appDomainSrc = CLR_RT_ObjectToEvent_Source::ExtractInstance( pManagedThread[Library_corlib_native_System_Threading_Thread::FIELD___appDomain]); - if (appDomainSrc == NULL) + if (appDomainSrc == nullptr) { break; } @@ -2398,7 +2406,7 @@ bool CLR_DBG_Debugger::Debugging_Thread_Get(WP_Message *msg) // placeholder for the data before the thread is started. Once the thread is started, they are copied over to // the unmanaged thread object and no longer used. The managed object is then used simply as a wrapper for the // unmanaged thread. Therefore, it is safe to simply make another managed thread here. - if (SUCCEEDED(g_CLR_RT_ExecutionEngine.NewObjectFromIndex(*pThread, g_CLR_RT_WellKnownTypes.m_Thread))) + if (SUCCEEDED(g_CLR_RT_ExecutionEngine.NewObjectFromIndex(*pThread, g_CLR_RT_WellKnownTypes.Thread))) { CLR_RT_HeapBlock *pRes = pThread->Dereference(); @@ -2428,7 +2436,8 @@ bool CLR_DBG_Debugger::Debugging_Thread_Get(WP_Message *msg) } // try to get value - WP_ReplyToCommand(msg, g_CLR_DBG_Debugger->GetValue(msg, pThread, NULL, NULL), false, NULL, 0); + // WP_ReplyToCommand(msg, g_CLR_DBG_Debugger->GetValue(msg, pThread, nullptr, nullptr), false, nullptr, 0); + return g_CLR_DBG_Debugger->GetValue(msg, pThread, nullptr, nullptr); return true; } @@ -2437,10 +2446,9 @@ bool CLR_DBG_Debugger::Debugging_Thread_GetException(WP_Message *msg) { NATIVE_PROFILE_CLR_DEBUGGER(); - CLR_DBG_Commands::Debugging_Thread_GetException *cmd = - (CLR_DBG_Commands::Debugging_Thread_GetException *)msg->m_payload; + auto *cmd = (CLR_DBG_Commands::Debugging_Thread_GetException *)msg->m_payload; CLR_RT_Thread *th = g_CLR_DBG_Debugger->GetThreadFromPid(cmd->m_pid); - CLR_RT_HeapBlock *blk = NULL; + CLR_RT_HeapBlock *blk = nullptr; if (th) { @@ -2448,7 +2456,8 @@ bool CLR_DBG_Debugger::Debugging_Thread_GetException(WP_Message *msg) } // try to get value - WP_ReplyToCommand(msg, g_CLR_DBG_Debugger->GetValue(msg, blk, NULL, NULL), false, NULL, 0); + // WP_ReplyToCommand(msg, g_CLR_DBG_Debugger->GetValue(msg, blk, nullptr, nullptr), false, nullptr, 0); + return g_CLR_DBG_Debugger->GetValue(msg, blk, nullptr, nullptr); return true; } @@ -2457,12 +2466,12 @@ bool CLR_DBG_Debugger::Debugging_Thread_Unwind(WP_Message *msg) { NATIVE_PROFILE_CLR_DEBUGGER(); - CLR_DBG_Commands::Debugging_Thread_Unwind *cmd = (CLR_DBG_Commands::Debugging_Thread_Unwind *)msg->m_payload; + auto *cmd = (CLR_DBG_Commands::Debugging_Thread_Unwind *)msg->m_payload; CLR_RT_StackFrame *call; CLR_RT_Thread *th; bool isInline = false; - if ((call = g_CLR_DBG_Debugger->CheckStackFrame(cmd->m_pid, cmd->m_depth, isInline)) != NULL) + if ((call = g_CLR_DBG_Debugger->CheckStackFrame(cmd->m_pid, cmd->m_depth, isInline)) != nullptr) { _ASSERTE((call->m_flags & CLR_RT_StackFrame::c_MethodKind_Native) == 0); @@ -2479,7 +2488,7 @@ bool CLR_DBG_Debugger::Debugging_Thread_Unwind(WP_Message *msg) us.SetPhase(CLR_RT_Thread::UnwindStack::p_2_RunningFinallys_0); } - WP_ReplyToCommand(msg, true, false, NULL, 0); + WP_ReplyToCommand(msg, true, false, nullptr, 0); return true; } @@ -2490,20 +2499,20 @@ bool CLR_DBG_Debugger::Debugging_Stack_Info(WP_Message *msg) { NATIVE_PROFILE_CLR_DEBUGGER(); - CLR_DBG_Commands::Debugging_Stack_Info *cmd = (CLR_DBG_Commands::Debugging_Stack_Info *)msg->m_payload; + auto *cmd = (CLR_DBG_Commands::Debugging_Stack_Info *)msg->m_payload; CLR_DBG_Commands::Debugging_Stack_Info::Reply cmdReply; CLR_RT_StackFrame *call; bool isInline = false; - if ((call = g_CLR_DBG_Debugger->CheckStackFrame(cmd->m_pid, cmd->m_depth, isInline)) != NULL) + if ((call = g_CLR_DBG_Debugger->CheckStackFrame(cmd->m_pid, cmd->m_depth, isInline)) != nullptr) { #ifndef NANOCLR_NO_IL_INLINE if (isInline) { cmdReply.m_md = call->m_inlineFrame->m_frame.m_call; cmdReply.m_IP = (CLR_UINT32)(call->m_inlineFrame->m_frame.m_IP - call->m_inlineFrame->m_frame.m_IPStart); - cmdReply.m_numOfArguments = call->m_inlineFrame->m_frame.m_call.m_target->numArgs; - cmdReply.m_numOfLocals = call->m_inlineFrame->m_frame.m_call.m_target->numLocals; + cmdReply.m_numOfArguments = call->m_inlineFrame->m_frame.m_call.target->argumentsCount; + cmdReply.m_numOfLocals = call->m_inlineFrame->m_frame.m_call.target->localsCount; cmdReply.m_depthOfEvalStack = (CLR_UINT32)(call->m_evalStack - call->m_inlineFrame->m_frame.m_evalStack); } else @@ -2511,8 +2520,8 @@ bool CLR_DBG_Debugger::Debugging_Stack_Info(WP_Message *msg) { cmdReply.m_md = call->m_call; cmdReply.m_IP = (CLR_UINT32)(call->m_IP - call->m_IPstart); - cmdReply.m_numOfArguments = call->m_call.m_target->numArgs; - cmdReply.m_numOfLocals = call->m_call.m_target->numLocals; + cmdReply.m_numOfArguments = call->m_call.target->argumentsCount; + cmdReply.m_numOfLocals = call->m_call.target->localsCount; cmdReply.m_depthOfEvalStack = (CLR_UINT32)call->TopValuePosition(); } @@ -2528,11 +2537,11 @@ bool CLR_DBG_Debugger::Debugging_Stack_SetIP(WP_Message *msg) { NATIVE_PROFILE_CLR_DEBUGGER(); - CLR_DBG_Commands::Debugging_Stack_SetIP *cmd = (CLR_DBG_Commands::Debugging_Stack_SetIP *)msg->m_payload; + auto *cmd = (CLR_DBG_Commands::Debugging_Stack_SetIP *)msg->m_payload; CLR_RT_StackFrame *call; bool isInline = false; - if ((call = g_CLR_DBG_Debugger->CheckStackFrame(cmd->m_pid, cmd->m_depth, isInline)) != NULL) + if ((call = g_CLR_DBG_Debugger->CheckStackFrame(cmd->m_pid, cmd->m_depth, isInline)) != nullptr) { #ifndef NANOCLR_NO_IL_INLINE if (isInline) @@ -2548,7 +2557,7 @@ bool CLR_DBG_Debugger::Debugging_Stack_SetIP(WP_Message *msg) call->m_flags &= ~CLR_RT_StackFrame::c_InvalidIP; - WP_ReplyToCommand(msg, true, false, NULL, 0); + WP_ReplyToCommand(msg, true, false, nullptr, 0); return true; } @@ -2566,21 +2575,29 @@ static bool IsBlockEnumMaybe(CLR_RT_HeapBlock *blk) CLR_RT_TypeDescriptor desc{}; if (FAILED(desc.InitializeFromObject(*blk))) + { return false; + } - const CLR_RT_DataTypeLookup &dtl = c_CLR_RT_DataTypeLookup[desc.m_handlerCls.m_target->dataType]; + // can only check for data type if the class handler is not null + if (desc.m_handlerCls.target == nullptr) + { + return false; + } + + const CLR_RT_DataTypeLookup &dtl = c_CLR_RT_DataTypeLookup[desc.m_handlerCls.target->dataType]; return (dtl.m_flags & c_MaskForPrimitive) == c_MaskForPrimitive; } -static bool SetBlockHelper(CLR_RT_HeapBlock *blk, CLR_DataType dt, CLR_UINT8 *builtinValue) +static bool SetBlockHelper(CLR_RT_HeapBlock *blk, NanoCLRDataType dt, CLR_UINT8 *builtinValue) { NATIVE_PROFILE_CLR_DEBUGGER(); bool fCanAssign = false; if (blk) { - CLR_DataType dtDst; + NanoCLRDataType dtDst; CLR_RT_HeapBlock src; dtDst = blk->DataType(); @@ -2596,11 +2613,11 @@ static bool SetBlockHelper(CLR_RT_HeapBlock *blk, CLR_DataType dt, CLR_UINT8 *bu { if (dt == DATATYPE_REFLECTION) { - fCanAssign = (dtDst == DATATYPE_OBJECT && blk->Dereference() == NULL); + fCanAssign = (dtDst == DATATYPE_OBJECT && blk->Dereference() == nullptr); } else if (dt == DATATYPE_OBJECT) { - fCanAssign = (src.Dereference() == NULL && dtDst == DATATYPE_REFLECTION); + fCanAssign = (src.Dereference() == nullptr && dtDst == DATATYPE_REFLECTION); } else { @@ -2625,7 +2642,7 @@ static bool SetBlockHelper(CLR_RT_HeapBlock *blk, CLR_DataType dt, CLR_UINT8 *bu return fCanAssign; } -static CLR_RT_HeapBlock *GetScratchPad_Helper(int idx) +static CLR_RT_HeapBlock *GetScratchPad_Helper(int index) { NATIVE_PROFILE_CLR_DEBUGGER(); CLR_RT_HeapBlock_Array *array = g_CLR_RT_ExecutionEngine.m_scratchPadArray; @@ -2634,12 +2651,12 @@ static CLR_RT_HeapBlock *GetScratchPad_Helper(int idx) tmp.SetObjectReference(array); - if (SUCCEEDED(ref.InitializeArrayReference(tmp, idx))) + if (SUCCEEDED(ref.InitializeArrayReference(tmp, index))) { - return (CLR_RT_HeapBlock *)array->GetElement(idx); + return (CLR_RT_HeapBlock *)array->GetElement(index); } - return NULL; + return nullptr; } //--// @@ -2648,18 +2665,16 @@ bool CLR_DBG_Debugger::Debugging_Value_ResizeScratchPad(WP_Message *msg) { NATIVE_PROFILE_CLR_DEBUGGER(); - CLR_DBG_Commands::Debugging_Value_ResizeScratchPad *cmd = - (CLR_DBG_Commands::Debugging_Value_ResizeScratchPad *)msg->m_payload; - + auto *cmd = (CLR_DBG_Commands::Debugging_Value_ResizeScratchPad *)msg->m_payload; CLR_RT_HeapBlock ref; if (cmd->m_size == 0) { - g_CLR_RT_ExecutionEngine.m_scratchPadArray = NULL; + g_CLR_RT_ExecutionEngine.m_scratchPadArray = nullptr; } else { - if (SUCCEEDED(CLR_RT_HeapBlock_Array::CreateInstance(ref, cmd->m_size, g_CLR_RT_WellKnownTypes.m_Object))) + if (SUCCEEDED(CLR_RT_HeapBlock_Array::CreateInstance(ref, cmd->m_size, g_CLR_RT_WellKnownTypes.Object))) { CLR_RT_HeapBlock_Array *pOld = g_CLR_RT_ExecutionEngine.m_scratchPadArray; CLR_RT_HeapBlock_Array *pNew = ref.DereferenceArray(); @@ -2675,7 +2690,7 @@ bool CLR_DBG_Debugger::Debugging_Value_ResizeScratchPad(WP_Message *msg) g_CLR_RT_ExecutionEngine.m_scratchPadArray = pNew; // done - WP_ReplyToCommand(msg, true, false, NULL, 0); + WP_ReplyToCommand(msg, true, false, nullptr, 0); } else { @@ -2690,11 +2705,11 @@ bool CLR_DBG_Debugger::Debugging_Value_GetStack(WP_Message *msg) { NATIVE_PROFILE_CLR_DEBUGGER(); - CLR_DBG_Commands::Debugging_Value_GetStack *cmd = (CLR_DBG_Commands::Debugging_Value_GetStack *)msg->m_payload; + auto *cmd = (CLR_DBG_Commands::Debugging_Value_GetStack *)msg->m_payload; CLR_RT_StackFrame *call; bool isInline = false; - if ((call = g_CLR_DBG_Debugger->CheckStackFrame(cmd->m_pid, cmd->m_depth, isInline)) != NULL) + if ((call = g_CLR_DBG_Debugger->CheckStackFrame(cmd->m_pid, cmd->m_depth, isInline)) != nullptr) { CLR_RT_HeapBlock *array; CLR_UINT32 num; @@ -2709,20 +2724,20 @@ bool CLR_DBG_Debugger::Debugging_Value_GetStack(WP_Message *msg) case CLR_DBG_Commands::Debugging_Value_GetStack::c_Argument: #ifndef NANOCLR_NO_IL_INLINE array = isInline ? call->m_inlineFrame->m_frame.m_args : call->m_arguments; - num = isInline ? md.m_target->numArgs : md.m_target->numArgs; + num = isInline ? md.target->argumentsCount : md.target->argumentsCount; #else array = call->m_arguments; - num = call->m_call.m_target->numArgs; + num = call->m_call.target->argumentsCount; #endif break; case CLR_DBG_Commands::Debugging_Value_GetStack::c_Local: #ifndef NANOCLR_NO_IL_INLINE array = isInline ? call->m_inlineFrame->m_frame.m_locals : call->m_locals; - num = isInline ? md.m_target->numLocals : md.m_target->numLocals; + num = isInline ? md.target->localsCount : md.target->localsCount; #else array = call->m_locals; - num = call->m_call.m_target->numLocals; + num = call->m_call.target->localsCount; #endif break; @@ -2747,9 +2762,9 @@ bool CLR_DBG_Debugger::Debugging_Value_GetStack(WP_Message *msg) } CLR_RT_HeapBlock *blk = &array[cmd->m_index]; - CLR_RT_HeapBlock *reference = NULL; + CLR_RT_HeapBlock *reference = nullptr; CLR_RT_HeapBlock tmp; - CLR_RT_TypeDef_Instance *pTD = NULL; + CLR_RT_TypeDef_Instance *pTD = nullptr; CLR_RT_TypeDef_Instance td; if (cmd->m_kind != CLR_DBG_Commands::Debugging_Value_GetStack::c_EvalStack && IsBlockEnumMaybe(blk)) @@ -2758,14 +2773,16 @@ bool CLR_DBG_Debugger::Debugging_Value_GetStack(WP_Message *msg) CLR_RT_SignatureParser parser{}; CLR_RT_SignatureParser::Element res; CLR_RT_TypeDescriptor desc{}; + CLR_RT_TypeDef_Index targetClass; + NanoCLRDataType targetDataType; if (cmd->m_kind == CLR_DBG_Commands::Debugging_Value_GetStack::c_Argument) { - parser.Initialize_MethodSignature(md.m_assm, md.m_target); + parser.Initialize_MethodSignature(&md); iElement++; // Skip the return value, always at the head of the signature. - if (parser.m_flags & PIMAGE_CEE_CS_CALLCONV_HASTHIS) + if (parser.Flags & PIMAGE_CEE_CS_CALLCONV_HASTHIS) { if (iElement == 0) { @@ -2778,7 +2795,7 @@ bool CLR_DBG_Debugger::Debugging_Value_GetStack(WP_Message *msg) } else { - parser.Initialize_MethodLocals(md.m_assm, md.m_target); + parser.Initialize_MethodLocals(md.assembly, md.target); } do @@ -2786,33 +2803,73 @@ bool CLR_DBG_Debugger::Debugging_Value_GetStack(WP_Message *msg) parser.Advance(res); } while (iElement--); + // handle generic parameters + if (res.DataType == DATATYPE_VAR) + { + // Generic parameter in a generic TypeDef + md.assembly->FindGenericParamAtTypeSpec(md, res.GenericParamPosition, targetClass, targetDataType); + + // isGenericInstance = true; + } + else if (res.DataType == DATATYPE_MVAR) + { + // Generic parameter in a generic method definition + CLR_RT_Assembly *assembly = md.assembly; + + CLR_RT_GenericParam_Index gpIndex; + assembly->FindGenericParamAtMethodDef(md, res.GenericParamPosition, gpIndex); + + CLR_RT_GenericParam_CrossReference gp = assembly->crossReferenceGenericParam[gpIndex.GenericParam()]; + + targetClass = gp.classTypeDef; + targetDataType = gp.dataType; + + // isGenericInstance = true; + } + else + { + // all the rest get it from parser element + targetClass = res.Class; + targetDataType = res.DataType; + } + // // Arguments to a methods come from the eval stack and we don't fix up the eval stack for each call. // So some arguments have the wrong datatype, since an eval stack push always promotes to 32 bits. // if (c_CLR_RT_DataTypeLookup[blk->DataType()].m_sizeInBytes == sizeof(CLR_INT32) && - c_CLR_RT_DataTypeLookup[res.m_dt].m_sizeInBytes < sizeof(CLR_INT32)) + c_CLR_RT_DataTypeLookup[targetDataType].m_sizeInBytes < sizeof(CLR_INT32)) { tmp.Assign(*blk); - tmp.ChangeDataType(res.m_dt); + tmp.ChangeDataType(targetDataType); reference = blk; blk = &tmp; } - // - // Check for enum. - // - desc.InitializeFromType(res.m_cls); + if (res.DataType == DATATYPE_VAR || res.DataType == DATATYPE_MVAR) + { + tmp.Assign(*blk); + tmp.ChangeDataType(targetDataType); - if (desc.m_handlerCls.m_target->IsEnum()) + reference = blk; + blk = &tmp; + } + else { - td = desc.m_handlerCls; - pTD = &td; + desc.InitializeFromType(targetClass); + + // Check for enum + if (desc.m_handlerCls.target->IsEnum()) + { + td = desc.m_handlerCls; + pTD = &td; + } } } - WP_ReplyToCommand(msg, g_CLR_DBG_Debugger->GetValue(msg, blk, reference, pTD), false, NULL, 0); + // WP_ReplyToCommand(msg, g_CLR_DBG_Debugger->GetValue(msg, blk, reference, pTD), false, nullptr, 0); + return g_CLR_DBG_Debugger->GetValue(msg, blk, reference, pTD); return true; } @@ -2824,18 +2881,17 @@ bool CLR_DBG_Debugger::Debugging_Value_GetField(WP_Message *msg) { NATIVE_PROFILE_CLR_DEBUGGER(); - CLR_UINT32 offset; - - CLR_DBG_Commands::Debugging_Value_GetField *cmd = (CLR_DBG_Commands::Debugging_Value_GetField *)msg->m_payload; + auto *cmd = (CLR_DBG_Commands::Debugging_Value_GetField *)msg->m_payload; CLR_RT_HeapBlock *blk = cmd->m_heapblock; - CLR_RT_HeapBlock *reference = NULL; - CLR_RT_TypeDef_Instance *pTD = NULL; - CLR_RT_TypeDescriptor desc{}; + CLR_RT_HeapBlock *reference = nullptr; CLR_RT_HeapBlock tmp; + CLR_RT_TypeDescriptor desc; CLR_RT_TypeDef_Instance td; + CLR_RT_TypeDef_Instance *pTD = nullptr; CLR_RT_FieldDef_Instance inst; + CLR_UINT32 offset; - if (blk != NULL && cmd->m_offset > 0) + if (blk != nullptr && cmd->m_offset > 0) { if (FAILED(desc.InitializeFromObject(*blk))) { @@ -2847,8 +2903,8 @@ bool CLR_DBG_Debugger::Debugging_Value_GetField(WP_Message *msg) while (true) { - CLR_UINT32 iFields = td.m_target->iFields_Num; - CLR_UINT32 totalFields = td.CrossReference().m_totalFields; + CLR_UINT32 iFields = td.target->instanceFieldsCount; + CLR_UINT32 totalFields = td.CrossReference().totalFields; CLR_UINT32 dFields = totalFields - iFields; if (offset >= dFields) @@ -2863,7 +2919,7 @@ bool CLR_DBG_Debugger::Debugging_Value_GetField(WP_Message *msg) } } - cmd->m_fd.Set(td.Assembly(), td.m_target->iFields_First + offset); + cmd->m_fd.Set(td.Assembly(), td.target->firstInstanceField + offset); } if (!g_CLR_DBG_Debugger->CheckFieldDef(cmd->m_fd, inst)) @@ -2871,7 +2927,7 @@ bool CLR_DBG_Debugger::Debugging_Value_GetField(WP_Message *msg) return false; } - if (blk == NULL) + if (blk == nullptr) { blk = CLR_RT_ExecutionEngine::AccessStaticField(cmd->m_fd); } @@ -2879,7 +2935,7 @@ bool CLR_DBG_Debugger::Debugging_Value_GetField(WP_Message *msg) { if (cmd->m_offset == 0) { - cmd->m_offset = inst.CrossReference().m_offset; + cmd->m_offset = inst.CrossReference().offset; } if (cmd->m_offset == 0) @@ -2918,14 +2974,15 @@ bool CLR_DBG_Debugger::Debugging_Value_GetField(WP_Message *msg) { if (SUCCEEDED(desc.InitializeFromFieldDefinition(inst))) { - if (desc.m_handlerCls.m_target->IsEnum()) + if (desc.m_handlerCls.target->IsEnum()) { pTD = &desc.m_handlerCls; } } } - WP_ReplyToCommand(msg, g_CLR_DBG_Debugger->GetValue(msg, blk, reference, pTD), false, NULL, 0); + // WP_ReplyToCommand(msg, g_CLR_DBG_Debugger->GetValue(msg, blk, reference, pTD), false, nullptr, 0); + return g_CLR_DBG_Debugger->GetValue(msg, blk, reference, pTD); return true; } @@ -2934,13 +2991,13 @@ bool CLR_DBG_Debugger::Debugging_Value_GetArray(WP_Message *msg) { NATIVE_PROFILE_CLR_DEBUGGER(); - CLR_DBG_Commands::Debugging_Value_GetArray *cmd = (CLR_DBG_Commands::Debugging_Value_GetArray *)msg->m_payload; - CLR_RT_HeapBlock *blk = NULL; - CLR_RT_HeapBlock *reference = NULL; - CLR_RT_TypeDef_Instance *pTD = NULL; + auto *cmd = (CLR_DBG_Commands::Debugging_Value_GetArray *)msg->m_payload; + CLR_RT_HeapBlock *blk = nullptr; + CLR_RT_HeapBlock *reference = nullptr; CLR_RT_HeapBlock tmp; CLR_RT_HeapBlock ref; - CLR_RT_TypeDef_Instance td{}; + CLR_RT_TypeDef_Instance *pTD = nullptr; + CLR_RT_TypeDef_Instance td; tmp.SetObjectReference(cmd->m_heapblock); @@ -2965,9 +3022,9 @@ bool CLR_DBG_Debugger::Debugging_Value_GetArray(WP_Message *msg) if (IsBlockEnumMaybe(blk)) { - if (td.InitializeFromIndex(array->ReflectionDataConst().m_data.m_type)) + if (td.InitializeFromIndex(array->ReflectionDataConst().data.type)) { - if (td.m_target->IsEnum()) + if (td.target->IsEnum()) { pTD = &td; } @@ -2975,7 +3032,8 @@ bool CLR_DBG_Debugger::Debugging_Value_GetArray(WP_Message *msg) } } - WP_ReplyToCommand(msg, g_CLR_DBG_Debugger->GetValue(msg, blk, reference, pTD), false, NULL, 0); + // WP_ReplyToCommand(msg, g_CLR_DBG_Debugger->GetValue(msg, blk, reference, pTD), false, nullptr, 0); + return g_CLR_DBG_Debugger->GetValue(msg, blk, reference, pTD); return true; } @@ -2984,10 +3042,11 @@ bool CLR_DBG_Debugger::Debugging_Value_GetBlock(WP_Message *msg) { NATIVE_PROFILE_CLR_DEBUGGER(); - CLR_DBG_Commands::Debugging_Value_GetBlock *cmd = (CLR_DBG_Commands::Debugging_Value_GetBlock *)msg->m_payload; + auto *cmd = (CLR_DBG_Commands::Debugging_Value_GetBlock *)msg->m_payload; CLR_RT_HeapBlock *blk = cmd->m_heapblock; - WP_ReplyToCommand(msg, g_CLR_DBG_Debugger->GetValue(msg, blk, NULL, NULL), false, NULL, 0); + // WP_ReplyToCommand(msg, g_CLR_DBG_Debugger->GetValue(msg, blk, nullptr, nullptr), false, nullptr, 0); + return g_CLR_DBG_Debugger->GetValue(msg, blk, nullptr, nullptr); return true; } @@ -2996,11 +3055,10 @@ bool CLR_DBG_Debugger::Debugging_Value_GetScratchPad(WP_Message *msg) { NATIVE_PROFILE_CLR_DEBUGGER(); - CLR_DBG_Commands::Debugging_Value_GetScratchPad *cmd = - (CLR_DBG_Commands::Debugging_Value_GetScratchPad *)msg->m_payload; - CLR_RT_HeapBlock *blk = GetScratchPad_Helper(cmd->m_idx); + auto *cmd = (CLR_DBG_Commands::Debugging_Value_GetScratchPad *)msg->m_payload; + CLR_RT_HeapBlock *blk = GetScratchPad_Helper(cmd->m_index); - WP_ReplyToCommand(msg, g_CLR_DBG_Debugger->GetValue(msg, blk, NULL, NULL), false, NULL, 0); + WP_ReplyToCommand(msg, g_CLR_DBG_Debugger->GetValue(msg, blk, nullptr, nullptr), false, nullptr, 0); return true; } @@ -3009,10 +3067,11 @@ bool CLR_DBG_Debugger::Debugging_Value_SetBlock(WP_Message *msg) { NATIVE_PROFILE_CLR_DEBUGGER(); - CLR_DBG_Commands::Debugging_Value_SetBlock *cmd = (CLR_DBG_Commands::Debugging_Value_SetBlock *)msg->m_payload; + auto *cmd = (CLR_DBG_Commands::Debugging_Value_SetBlock *)msg->m_payload; CLR_RT_HeapBlock *blk = cmd->m_heapblock; - WP_ReplyToCommand(msg, SetBlockHelper(blk, (CLR_DataType)cmd->m_dt, cmd->m_builtinValue), false, NULL, 0); + // WP_ReplyToCommand(msg, SetBlockHelper(blk, (NanoCLRDataType)cmd->m_dt, cmd->m_builtinValue), false, nullptr, 0); + return g_CLR_DBG_Debugger->GetValue(msg, blk, nullptr, nullptr); return true; } @@ -3021,7 +3080,7 @@ bool CLR_DBG_Debugger::Debugging_Value_SetArray(WP_Message *msg) { NATIVE_PROFILE_CLR_DEBUGGER(); - CLR_DBG_Commands::Debugging_Value_SetArray *cmd = (CLR_DBG_Commands::Debugging_Value_SetArray *)msg->m_payload; + auto *cmd = (CLR_DBG_Commands::Debugging_Value_SetArray *)msg->m_payload; CLR_RT_HeapBlock_Array *array = cmd->m_heapblock; CLR_RT_HeapBlock tmp; @@ -3030,7 +3089,7 @@ bool CLR_DBG_Debugger::Debugging_Value_SetArray(WP_Message *msg) // // We can only set values in arrays of primitive types. // - if (array != NULL && !array->m_fReference) + if (array != nullptr && !array->m_fReference) { CLR_RT_HeapBlock ref; @@ -3042,7 +3101,7 @@ bool CLR_DBG_Debugger::Debugging_Value_SetArray(WP_Message *msg) { if (SUCCEEDED(tmp.StoreToReference(ref, 0))) { - WP_ReplyToCommand(msg, true, false, NULL, 0); + WP_ReplyToCommand(msg, true, false, nullptr, 0); } } } @@ -3058,9 +3117,8 @@ bool CLR_DBG_Debugger::Debugging_Value_AllocateObject(WP_Message *msg) { NATIVE_PROFILE_CLR_DEBUGGER(); - CLR_DBG_Commands::Debugging_Value_AllocateObject *cmd = - (CLR_DBG_Commands::Debugging_Value_AllocateObject *)msg->m_payload; - CLR_RT_HeapBlock *blk = NULL; + auto *cmd = (CLR_DBG_Commands::Debugging_Value_AllocateObject *)msg->m_payload; + CLR_RT_HeapBlock *blk = nullptr; CLR_RT_HeapBlock *ptr = GetScratchPad_Helper(cmd->m_index); if (ptr) @@ -3071,7 +3129,8 @@ bool CLR_DBG_Debugger::Debugging_Value_AllocateObject(WP_Message *msg) } } - WP_ReplyToCommand(msg, g_CLR_DBG_Debugger->GetValue(msg, blk, NULL, NULL), false, NULL, 0); + // WP_ReplyToCommand(msg, g_CLR_DBG_Debugger->GetValue(msg, blk, nullptr, nullptr), false, nullptr, 0); + return g_CLR_DBG_Debugger->GetValue(msg, blk, nullptr, nullptr); return true; } @@ -3080,9 +3139,8 @@ bool CLR_DBG_Debugger::Debugging_Value_AllocateString(WP_Message *msg) { NATIVE_PROFILE_CLR_DEBUGGER(); - CLR_DBG_Commands::Debugging_Value_AllocateString *cmd = - (CLR_DBG_Commands::Debugging_Value_AllocateString *)msg->m_payload; - CLR_RT_HeapBlock *blk = NULL; + auto *cmd = (CLR_DBG_Commands::Debugging_Value_AllocateString *)msg->m_payload; + CLR_RT_HeapBlock *blk = nullptr; CLR_RT_HeapBlock *ptr = GetScratchPad_Helper(cmd->m_index); if (ptr) @@ -3091,7 +3149,7 @@ bool CLR_DBG_Debugger::Debugging_Value_AllocateString(WP_Message *msg) if (str) { - char *dst = (char *)str->StringText(); + auto *dst = (char *)str->StringText(); // // Fill the string with spaces, it will be set at a later stage. @@ -3103,7 +3161,8 @@ bool CLR_DBG_Debugger::Debugging_Value_AllocateString(WP_Message *msg) } } - WP_ReplyToCommand(msg, g_CLR_DBG_Debugger->GetValue(msg, blk, NULL, NULL), false, NULL, 0); + // WP_ReplyToCommand(msg, g_CLR_DBG_Debugger->GetValue(msg, blk, nullptr, nullptr), false, nullptr, 0); + return g_CLR_DBG_Debugger->GetValue(msg, blk, nullptr, nullptr); return true; } @@ -3112,18 +3171,17 @@ bool CLR_DBG_Debugger::Debugging_Value_AllocateArray(WP_Message *msg) { NATIVE_PROFILE_CLR_DEBUGGER(); - CLR_DBG_Commands::Debugging_Value_AllocateArray *cmd = - (CLR_DBG_Commands::Debugging_Value_AllocateArray *)msg->m_payload; - CLR_RT_HeapBlock *blk = NULL; + auto *cmd = (CLR_DBG_Commands::Debugging_Value_AllocateArray *)msg->m_payload; + CLR_RT_HeapBlock *blk = nullptr; CLR_RT_HeapBlock *ptr = GetScratchPad_Helper(cmd->m_index); if (ptr) { CLR_RT_ReflectionDef_Index reflex; - reflex.m_kind = REFLECTION_TYPE; - reflex.m_levels = cmd->m_depth; - reflex.m_data.m_type = cmd->m_td; + reflex.kind = REFLECTION_TYPE; + reflex.levels = cmd->m_depth; + reflex.data.type = cmd->m_td; if (SUCCEEDED(CLR_RT_HeapBlock_Array::CreateInstance(*ptr, cmd->m_numOfElements, reflex))) { @@ -3131,7 +3189,8 @@ bool CLR_DBG_Debugger::Debugging_Value_AllocateArray(WP_Message *msg) } } - WP_ReplyToCommand(msg, g_CLR_DBG_Debugger->GetValue(msg, blk, NULL, NULL), false, NULL, 0); + // WP_ReplyToCommand(msg, g_CLR_DBG_Debugger->GetValue(msg, blk, nullptr, nullptr), false, nullptr, 0); + return g_CLR_DBG_Debugger->GetValue(msg, blk, nullptr, nullptr); return true; } @@ -3143,17 +3202,17 @@ bool CLR_DBG_Debugger::Profiling_Command(WP_Message *msg) { NATIVE_PROFILE_CLR_DEBUGGER(); CLR_DBG_Debugger *dbg = g_CLR_DBG_Debugger; - CLR_DBG_Commands::Profiling_Command *cmd = (CLR_DBG_Commands::Profiling_Command *)msg->m_payload; + auto *cmd = (CLR_DBG_Commands::Profiling_Command *)msg->m_payload; CLR_UINT8 command = cmd->m_command; switch (command) { case CLR_DBG_Commands::Profiling_Command::c_Command_ChangeConditions: - WP_ReplyToCommand(msg, dbg->Profiling_ChangeConditions(msg), false, NULL, 0); + WP_ReplyToCommand(msg, dbg->Profiling_ChangeConditions(msg), false, nullptr, 0); break; case CLR_DBG_Commands::Profiling_Command::c_Command_FlushStream: - WP_ReplyToCommand(msg, dbg->Profiling_FlushStream(msg), false, NULL, 0); + WP_ReplyToCommand(msg, dbg->Profiling_FlushStream(msg), false, nullptr, 0); break; default: @@ -3166,8 +3225,8 @@ bool CLR_DBG_Debugger::Profiling_Command(WP_Message *msg) bool CLR_DBG_Debugger::Profiling_ChangeConditions(WP_Message *msg) { NATIVE_PROFILE_CLR_DEBUGGER(); - CLR_DBG_Commands::Profiling_Command *parent_cmd = (CLR_DBG_Commands::Profiling_Command *)msg->m_payload; - CLR_DBG_Commands::Profiling_ChangeConditions *cmd = (CLR_DBG_Commands::Profiling_ChangeConditions *)&parent_cmd[1]; + auto *parent_cmd = (CLR_DBG_Commands::Profiling_Command *)msg->m_payload; + auto *cmd = (CLR_DBG_Commands::Profiling_ChangeConditions *)&parent_cmd[1]; g_CLR_RT_ExecutionEngine.m_iProfiling_Conditions |= cmd->m_set; g_CLR_RT_ExecutionEngine.m_iProfiling_Conditions &= ~cmd->m_reset; @@ -3229,7 +3288,7 @@ static HRESULT AnalyzeObject_Helper(CLR_RT_HeapBlock *ptr, AnalyzeObject &ao) ao.m_ptr = ptr; - if (ptr == NULL || (ptr->DataType() == DATATYPE_OBJECT && ptr->Dereference() == NULL)) + if (ptr == nullptr || (ptr->DataType() == DATATYPE_OBJECT && ptr->Dereference() == nullptr)) { ao.m_fNull = true; ao.m_fBoxed = false; @@ -3256,7 +3315,7 @@ static HRESULT AnalyzeObject_Helper(CLR_RT_HeapBlock *ptr, AnalyzeObject &ao) case CLR_RT_DataTypeLookup::c_ValueType: case CLR_RT_DataTypeLookup::c_Enum: ao.m_fCanBeNull = - ao.m_fBoxed || (ao.m_desc.m_handlerCls.m_data == g_CLR_RT_WellKnownTypes.m_String.m_data); + ao.m_fBoxed || (ao.m_desc.m_handlerCls.data == g_CLR_RT_WellKnownTypes.String.data); break; default: @@ -3281,7 +3340,7 @@ static HRESULT Assign_Helper(CLR_RT_HeapBlock *blkDst, CLR_RT_HeapBlock *blkSrc) AnalyzeObject aoSrc; CLR_RT_HeapBlock srcVal; - srcVal.SetObjectReference(NULL); + srcVal.SetObjectReference(nullptr); CLR_RT_ProtectFromGC gc(srcVal); NANOCLR_CHECK_HRESULT(AnalyzeObject_Helper(blkDst, aoDst)); @@ -3337,16 +3396,17 @@ bool CLR_DBG_Debugger::Debugging_Value_Assign(WP_Message *msg) { NATIVE_PROFILE_CLR_DEBUGGER(); - CLR_DBG_Commands::Debugging_Value_Assign *cmd = (CLR_DBG_Commands::Debugging_Value_Assign *)msg->m_payload; + auto *cmd = (CLR_DBG_Commands::Debugging_Value_Assign *)msg->m_payload; CLR_RT_HeapBlock *blkDst = cmd->m_heapblockDst; CLR_RT_HeapBlock *blkSrc = cmd->m_heapblockSrc; if (blkDst && FAILED(Assign_Helper(blkDst, blkSrc))) { - blkDst = NULL; + blkDst = nullptr; } - WP_ReplyToCommand(msg, g_CLR_DBG_Debugger->GetValue(msg, blkDst, NULL, NULL), false, NULL, 0); + // WP_ReplyToCommand(msg, g_CLR_DBG_Debugger->GetValue(msg, blkDst, nullptr, nullptr), false, nullptr, 0); + return g_CLR_DBG_Debugger->GetValue(msg, blkDst, nullptr, nullptr); return true; } @@ -3364,7 +3424,7 @@ bool CLR_DBG_Debugger::Debugging_TypeSys_Assemblies(WP_Message *msg) NANOCLR_FOREACH_ASSEMBLY(g_CLR_RT_TypeSystem) { - assemblies[num++].Set(pASSM->m_idx); + assemblies[num++].Set(pASSM->assemblyIndex); } NANOCLR_FOREACH_ASSEMBLY_END(); @@ -3435,7 +3495,7 @@ bool CLR_DBG_Debugger::Debugging_Resolve_AppDomain(WP_Message *msg) NANOCLR_FOREACH_ASSEMBLY_IN_APPDOMAIN(appDomain) { - pAssemblyIndex->Set(pASSM->m_idx); + pAssemblyIndex->Set(pASSM->m_index); pAssemblyIndex++; numAssemblies++; } @@ -3467,8 +3527,8 @@ bool CLR_DBG_Debugger::Debugging_Resolve_Assembly(WP_Message *msg) CLR_DBG_Commands::Debugging_Resolve_Assembly::Reply *cmdReply; - CLR_DBG_Commands::Debugging_Resolve_Assembly *cmd = (CLR_DBG_Commands::Debugging_Resolve_Assembly *)msg->m_payload; - CLR_RT_Assembly *assm = g_CLR_DBG_Debugger->IsGoodAssembly(cmd->m_idx.Assembly()); + auto *cmd = (CLR_DBG_Commands::Debugging_Resolve_Assembly *)msg->m_payload; + CLR_RT_Assembly *assm = g_CLR_DBG_Debugger->IsGoodAssembly(cmd->m_index.Assembly()); #ifdef TARGET_RAM_CONSTRAINED // try allocating memory for reply struct @@ -3480,20 +3540,15 @@ bool CLR_DBG_Debugger::Debugging_Resolve_Assembly(WP_Message *msg) #endif // sanity check - if (cmdReply != NULL) + if (cmdReply != nullptr) { if (assm) { #if defined(VIRTUAL_DEVICE) // append path - if (assm->m_strPath != NULL) + if (assm->path != nullptr) { - sprintf_s( - cmdReply->m_szName, - ARRAYSIZE(cmdReply->m_szName), - "%s,%s", - assm->m_szName, - assm->m_strPath->c_str()); + sprintf_s(cmdReply->m_szName, ARRAYSIZE(cmdReply->m_szName), "%s,%s", assm->name, assm->path->c_str()); } else #endif @@ -3501,12 +3556,12 @@ bool CLR_DBG_Debugger::Debugging_Resolve_Assembly(WP_Message *msg) hal_strncpy_s( cmdReply->m_szName, ARRAYSIZE(cmdReply->m_szName), - assm->m_szName, + assm->name, MAXSTRLEN(cmdReply->m_szName)); } - cmdReply->m_flags = assm->m_flags; - cmdReply->m_version = assm->m_header->version; + cmdReply->m_flags = assm->flags; + cmdReply->m_version = assm->header->version; WP_ReplyToCommand(msg, true, false, cmdReply, sizeof(CLR_DBG_Commands::Debugging_Resolve_Assembly::Reply)); @@ -3529,7 +3584,7 @@ bool CLR_DBG_Debugger::Debugging_Resolve_Type(WP_Message *msg) CLR_RT_TypeDef_Instance inst; CLR_DBG_Commands::Debugging_Resolve_Type::Reply *cmdReply; - CLR_DBG_Commands::Debugging_Resolve_Type *cmd = (CLR_DBG_Commands::Debugging_Resolve_Type *)msg->m_payload; + auto *cmd = (CLR_DBG_Commands::Debugging_Resolve_Type *)msg->m_payload; #ifdef TARGET_RAM_CONSTRAINED // try allocating memory for reply struct @@ -3541,7 +3596,7 @@ bool CLR_DBG_Debugger::Debugging_Resolve_Type(WP_Message *msg) #endif // sanity check - if (cmdReply != NULL) + if (cmdReply != nullptr) { if (g_CLR_DBG_Debugger->CheckTypeDef(cmd->m_td, inst)) { @@ -3572,7 +3627,7 @@ bool CLR_DBG_Debugger::Debugging_Resolve_Field(WP_Message *msg) CLR_DBG_Commands::Debugging_Resolve_Field::Reply *cmdReply; CLR_RT_FieldDef_Instance inst; - CLR_DBG_Commands::Debugging_Resolve_Field *cmd = (CLR_DBG_Commands::Debugging_Resolve_Field *)msg->m_payload; + auto *cmd = (CLR_DBG_Commands::Debugging_Resolve_Field *)msg->m_payload; #ifdef TARGET_RAM_CONSTRAINED // try allocating memory for reply struct @@ -3584,7 +3639,7 @@ bool CLR_DBG_Debugger::Debugging_Resolve_Field(WP_Message *msg) #endif // sanity check - if (cmdReply != NULL) + if (cmdReply != nullptr) { if (g_CLR_DBG_Debugger->CheckFieldDef(cmd->m_fd, inst)) @@ -3597,8 +3652,8 @@ bool CLR_DBG_Debugger::Debugging_Resolve_Field(WP_Message *msg) CLR_RT_TypeDef_Instance instClass{}; instClass.InitializeFromField(inst); - cmdReply->m_td.m_data = instClass.m_data; - cmdReply->m_index = inst.CrossReference().m_offset; + cmdReply->m_td = instClass; + cmdReply->m_index = inst.CrossReference().offset; WP_ReplyToCommand(msg, true, false, cmdReply, sizeof(CLR_DBG_Commands::Debugging_Resolve_Field::Reply)); @@ -3623,7 +3678,7 @@ bool CLR_DBG_Debugger::Debugging_Resolve_Method(WP_Message *msg) CLR_RT_MethodDef_Instance inst; CLR_RT_TypeDef_Instance instOwner{}; - CLR_DBG_Commands::Debugging_Resolve_Method *cmd = (CLR_DBG_Commands::Debugging_Resolve_Method *)msg->m_payload; + auto *cmd = (CLR_DBG_Commands::Debugging_Resolve_Method *)msg->m_payload; #ifdef TARGET_RAM_CONSTRAINED // try allocating memory for reply struct @@ -3635,7 +3690,7 @@ bool CLR_DBG_Debugger::Debugging_Resolve_Method(WP_Message *msg) #endif // sanity check - if (cmdReply != NULL) + if (cmdReply != nullptr) { if (g_CLR_DBG_Debugger->CheckMethodDef(cmd->m_md, inst) && instOwner.InitializeFromMethod(inst)) @@ -3643,9 +3698,9 @@ bool CLR_DBG_Debugger::Debugging_Resolve_Method(WP_Message *msg) char *szBuffer = cmdReply->m_method; size_t iBuffer = MAXSTRLEN(cmdReply->m_method); - cmdReply->m_td.m_data = instOwner.m_data; + cmdReply->m_td.data = instOwner.data; - CLR_SafeSprintf(szBuffer, iBuffer, "%s", inst.m_assm->GetString(inst.m_target->name)); + CLR_SafeSprintf(szBuffer, iBuffer, "%s", inst.assembly->GetString(inst.target->name)); WP_ReplyToCommand(msg, true, false, cmdReply, sizeof(CLR_DBG_Commands::Debugging_Resolve_Method::Reply)); @@ -3664,8 +3719,7 @@ bool CLR_DBG_Debugger::Debugging_Resolve_VirtualMethod(WP_Message *msg) { NATIVE_PROFILE_CLR_DEBUGGER(); - CLR_DBG_Commands::Debugging_Resolve_VirtualMethod *cmd = - (CLR_DBG_Commands::Debugging_Resolve_VirtualMethod *)msg->m_payload; + auto *cmd = (CLR_DBG_Commands::Debugging_Resolve_VirtualMethod *)msg->m_payload; CLR_DBG_Commands::Debugging_Resolve_VirtualMethod::Reply cmdReply; CLR_RT_TypeDef_Index cls; CLR_RT_MethodDef_Index md; @@ -3700,7 +3754,7 @@ bool CLR_DBG_Debugger::Debugging_Deployment_Status(WP_Message *msg) CLR_UINT32 deployLength = 0; // find the first device in list with DEPLOYMENT blocks - if (m_deploymentStorageDevice != NULL) + if (m_deploymentStorageDevice != nullptr) { BlockStorageStream stream; @@ -3734,7 +3788,7 @@ bool CLR_DBG_Debugger::Debugging_Deployment_Status(WP_Message *msg) CLR_RT_Memory::ZeroFill(cmdReply, totLength); - cmdReply->EntryPoint = g_CLR_RT_TypeSystem.m_entryPoint.m_data; + cmdReply->EntryPoint = g_CLR_RT_TypeSystem.m_entryPoint.data; cmdReply->StorageStart = deploySectorStart; cmdReply->StorageLength = deployLength; @@ -3764,7 +3818,7 @@ bool CLR_DBG_Debugger::Debugging_Info_SetJMC_Method(const CLR_RT_MethodDef_Index return false; } - if (inst.m_target->RVA == CLR_EmptyIndex) + if (inst.target->rva == CLR_EmptyIndex) { return false; } @@ -3785,12 +3839,12 @@ bool CLR_DBG_Debugger::Debugging_Info_SetJMC_Type(const CLR_RT_TypeDef_Index &id if (!CheckTypeDef(idx, inst)) return false; - td = inst.m_target; - totMethods = td->vMethods_Num + td->iMethods_Num + td->sMethods_Num; + td = inst.target; + totMethods = td->virtualMethodCount + td->instanceMethodCount + td->staticFieldsCount; for (int i = 0; i < totMethods; i++) { - md.Set(idx.Assembly(), td->methods_First + i); + md.Set(idx.Assembly(), td->firstMethod + i); Debugging_Info_SetJMC_Method(md, fJMC); } @@ -3802,7 +3856,7 @@ bool CLR_DBG_Debugger::Debugging_Info_SetJMC(WP_Message *msg) { NATIVE_PROFILE_CLR_DEBUGGER(); - CLR_DBG_Commands::Debugging_Info_SetJMC *cmd = (CLR_DBG_Commands::Debugging_Info_SetJMC *)msg->m_payload; + auto *cmd = (CLR_DBG_Commands::Debugging_Info_SetJMC *)msg->m_payload; bool fJMC = (cmd->m_fIsJMC != 0); switch (cmd->m_kind) @@ -3816,7 +3870,7 @@ bool CLR_DBG_Debugger::Debugging_Info_SetJMC(WP_Message *msg) return false; } - for (int i = 0; i < assm->m_pTablesSize[TBL_TypeDef]; i++) + for (int i = 0; i < assm->tablesSize[TBL_TypeDef]; i++) { CLR_RT_TypeDef_Index idx; @@ -3825,7 +3879,7 @@ bool CLR_DBG_Debugger::Debugging_Info_SetJMC(WP_Message *msg) g_CLR_DBG_Debugger->Debugging_Info_SetJMC_Type(idx, fJMC); } - WP_ReplyToCommand(msg, true, false, NULL, 0); + WP_ReplyToCommand(msg, true, false, nullptr, 0); return true; } @@ -3835,7 +3889,7 @@ bool CLR_DBG_Debugger::Debugging_Info_SetJMC(WP_Message *msg) msg, g_CLR_DBG_Debugger->Debugging_Info_SetJMC_Type(cmd->m_data.m_type, fJMC), false, - NULL, + nullptr, 0); return true; @@ -3844,7 +3898,7 @@ bool CLR_DBG_Debugger::Debugging_Info_SetJMC(WP_Message *msg) msg, g_CLR_DBG_Debugger->Debugging_Info_SetJMC_Method(cmd->m_data.m_method, fJMC), false, - NULL, + nullptr, 0); return true; @@ -3853,4 +3907,4 @@ bool CLR_DBG_Debugger::Debugging_Info_SetJMC(WP_Message *msg) } } -#endif // #if defined(NANOCLR_ENABLE_SOURCELEVELDEBUGGING) +#endif // NANOCLR_ENABLE_SOURCELEVELDEBUGGING diff --git a/src/CLR/Debugger/Debugger_stub.cpp b/src/CLR/Debugger/Debugger_stub.cpp index 2690cc9592..77b8b39b53 100644 --- a/src/CLR/Debugger/Debugger_stub.cpp +++ b/src/CLR/Debugger/Debugger_stub.cpp @@ -73,21 +73,21 @@ __nfweak void NFReleaseInfo::Init( NFReleaseInfo.PlatformName[0] = 0; // fill each one, if it was provided - if (NULL != info) + if (nullptr != info) { len = MIN(infoLen, sizeof(NFReleaseInfo.InfoString) - 1); memcpy(NFReleaseInfo.InfoString, info, len); NFReleaseInfo.InfoString[len] = 0; } - if (NULL != target) + if (nullptr != target) { len = MIN(targetLen, sizeof(NFReleaseInfo.TargetName) - 1); memcpy(NFReleaseInfo.TargetName, target, len); NFReleaseInfo.TargetName[len] = 0; } - if (NULL != platform) + if (nullptr != platform) { len = MIN(platformLen, sizeof(NFReleaseInfo.PlatformName) - 1); memcpy(NFReleaseInfo.PlatformName, platform, len); diff --git a/src/CLR/Diagnostics/Diagnostics_stub.cpp b/src/CLR/Diagnostics/Diagnostics_stub.cpp index 40a2bfe6b3..45a0212725 100644 --- a/src/CLR/Diagnostics/Diagnostics_stub.cpp +++ b/src/CLR/Diagnostics/Diagnostics_stub.cpp @@ -182,9 +182,10 @@ __nfweak void CLR_RT_DUMP::TYPE(const CLR_RT_ReflectionDef_Index &reflex) NATIVE_PROFILE_CLR_DIAGNOSTICS(); } -__nfweak void CLR_RT_DUMP::METHOD(const CLR_RT_MethodDef_Index &method) +__nfweak void CLR_RT_DUMP::METHOD(const CLR_RT_MethodDef_Index &method, const CLR_RT_TypeSpec_Index *genericType) { (void)method; + (void)genericType; NATIVE_PROFILE_CLR_DIAGNOSTICS(); } @@ -234,7 +235,7 @@ __nfweak const char *CLR_RT_DUMP::GETERRORMESSAGE(HRESULT hrError) (void)hrError; NATIVE_PROFILE_CLR_DIAGNOSTICS(); - return NULL; + return nullptr; } //--// @@ -246,7 +247,7 @@ __nfweak void *CLR_PROF_CounterCallChain::Prepare(CLR_PROF_Handler *handler) (void)handler; NATIVE_PROFILE_CLR_DIAGNOSTICS(); - return NULL; + return nullptr; } __nfweak void CLR_PROF_CounterCallChain::Complete(CLR_UINT64 &t, CLR_PROF_Handler *handler) @@ -403,7 +404,7 @@ __nfweak CLR_RT_HeapBlock *CLR_PRF_Profiler::FindReferencedObject(CLR_RT_HeapBlo (void)ref; NATIVE_PROFILE_CLR_DIAGNOSTICS(); - return NULL; + return nullptr; } __nfweak void CLR_PRF_Profiler::DumpEndOfRefsList() diff --git a/src/CLR/Diagnostics/Info.cpp b/src/CLR/Diagnostics/Info.cpp index 4a196260ee..e2b5f59f3c 100644 --- a/src/CLR/Diagnostics/Info.cpp +++ b/src/CLR/Diagnostics/Info.cpp @@ -12,7 +12,7 @@ #include #include -static std::string *s_redirectedString = NULL; +static std::string *s_redirectedString = nullptr; void CLR_Debug::RedirectToString(std::string *str) { @@ -116,7 +116,7 @@ void CLR_Debug::Emit(const char *text, int len) if (s_CLR_RT_fTrace_RedirectOutput.size()) { - static HANDLE hFile = INVALID_HANDLE_VALUE; + static auto hFile = INVALID_HANDLE_VALUE; static int lines = 0; static int num = 0; @@ -143,11 +143,11 @@ void CLR_Debug::Emit(const char *text, int len) { unsigned long dwWritten; - ::WriteFile(hFile, text, (unsigned long)len, &dwWritten, NULL); + ::WriteFile(hFile, text, (unsigned long)len, &dwWritten, nullptr); if (s_CLR_RT_fTrace_RedirectLinesPerFile) { - while ((text = strchr(text, '\n')) != NULL) + while ((text = strchr(text, '\n')) != nullptr) { lines++; text++; @@ -402,27 +402,27 @@ const CLR_UINT8 *CLR_SkipBodyOfOpcodeCompressed(const CLR_UINT8 *ip, CLR_OPCODE #define LOOKUP_ELEMENT_REF(idx, tblName, tblNameUC, tblName2) \ const CLR_RECORD_##tblNameUC *p = Get##tblName(idx); \ - const CLR_RT_##tblName2##_Index *s = &m_pCrossReference_##tblName[idx].m_target; \ - if (s->m_data == 0) \ - s = NULL + const CLR_RT_##tblName2##_Index *s = &crossReference##tblName[idx].target; \ + if (s->data == 0) \ + s = nullptr #define LOOKUP_ELEMENT_IDX(idx, tblName, tblNameUC) \ const CLR_RECORD_##tblNameUC *p = Get##tblName(idx); \ CLR_RT_##tblName##_Index s; \ - s.Set(m_idx, idx) + s.Set(assemblyIndex, idx) #if defined(NANOCLR_TRACE_INSTRUCTIONS) -void CLR_RT_Assembly::DumpToken(CLR_UINT32 tk) +void CLR_RT_Assembly::DumpToken(CLR_UINT32 token) { NATIVE_PROFILE_CLR_DIAGNOSTICS(); - CLR_UINT32 idx = CLR_DataFromTk(tk); + CLR_UINT32 index = CLR_DataFromTk(token); - switch (CLR_TypeFromTk(tk)) + switch (CLR_TypeFromTk(token)) { case TBL_AssemblyRef: { - LOOKUP_ELEMENT(idx, AssemblyRef, ASSEMBLYREF); + LOOKUP_ELEMENT(index, AssemblyRef, ASSEMBLYREF); { CLR_Debug::Printf("[%s]", GetString(p->name)); } @@ -430,7 +430,7 @@ void CLR_RT_Assembly::DumpToken(CLR_UINT32 tk) } case TBL_TypeRef: { - LOOKUP_ELEMENT_REF(idx, TypeRef, TYPEREF, TypeDef); + LOOKUP_ELEMENT_REF(index, TypeRef, TYPEREF, TypeDef); if (s) { CLR_RT_DUMP::TYPE(*s); @@ -443,7 +443,7 @@ void CLR_RT_Assembly::DumpToken(CLR_UINT32 tk) } case TBL_FieldRef: { - LOOKUP_ELEMENT_REF(idx, FieldRef, FIELDREF, FieldDef); + LOOKUP_ELEMENT_REF(index, FieldRef, FIELDREF, FieldDef); if (s) { CLR_RT_DUMP::FIELD(*s); @@ -456,44 +456,43 @@ void CLR_RT_Assembly::DumpToken(CLR_UINT32 tk) } case TBL_MethodRef: { - LOOKUP_ELEMENT_REF(idx, MethodRef, METHODREF, MethodDef); - if (s) - { - CLR_RT_DUMP::METHOD(*s); - } - else - { - CLR_Debug::Printf("%s", GetString(p->name)); - } + LOOKUP_ELEMENT_IDX(index, MethodRef, METHODREF); + CLR_RT_DUMP::METHODREF(s); break; } case TBL_TypeDef: { - LOOKUP_ELEMENT_IDX(idx, TypeDef, TYPEDEF); + LOOKUP_ELEMENT_IDX(index, TypeDef, TYPEDEF); CLR_RT_DUMP::TYPE(s); break; } case TBL_FieldDef: { - LOOKUP_ELEMENT_IDX(idx, FieldDef, FIELDDEF); + LOOKUP_ELEMENT_IDX(index, FieldDef, FIELDDEF); CLR_RT_DUMP::FIELD(s); break; } case TBL_MethodDef: { - LOOKUP_ELEMENT_IDX(idx, MethodDef, METHODDEF); - CLR_RT_DUMP::METHOD(s); + LOOKUP_ELEMENT_IDX(index, MethodDef, METHODDEF); + CLR_RT_DUMP::METHOD(s, nullptr); + break; + } + case TBL_MethodSpec: + { + LOOKUP_ELEMENT_IDX(index, MethodSpec, METHODSPEC); + CLR_RT_DUMP::METHODSPEC(s); break; } case TBL_Strings: { - const char *p = GetString(idx); + const char *p = GetString(index); CLR_Debug::Printf("'%s'", p); break; } default: - CLR_Debug::Printf("[%08x]", tk); + CLR_Debug::Printf("[%08x]", token); } } @@ -539,7 +538,7 @@ void CLR_RT_Assembly::DumpSignature(CLR_SIG sig) void CLR_RT_Assembly::DumpSignature(const CLR_UINT8 *&p) { NATIVE_PROFILE_CLR_DIAGNOSTICS(); - CLR_DataType opt = CLR_UncompressElementType(p); + NanoCLRDataType opt = CLR_UncompressElementType(p); switch (opt) { @@ -614,9 +613,9 @@ void CLR_RT_Assembly::DumpSignature(const CLR_UINT8 *&p) void CLR_RT_Assembly::DumpSignatureToken(const CLR_UINT8 *&p) { NATIVE_PROFILE_CLR_DIAGNOSTICS(); - CLR_UINT32 tk = CLR_TkFromStream(p); + CLR_UINT32 token = CLR_TkFromStream(p); - CLR_Debug::Printf("[%08x]", tk); + CLR_Debug::Printf("[%08x]", token); } //--// @@ -648,12 +647,12 @@ void CLR_RT_Assembly::DumpOpcodeDirect( int pid) { NATIVE_PROFILE_CLR_DIAGNOSTICS(); - CLR_Debug::Printf(" [%04x:%04x:%08x", pid, (int)(ip - ipStart), (size_t)ip); + CLR_Debug::Printf(" [%04x:%04x", pid, (int)(ip - ipStart)); if (NANOCLR_INDEX_IS_VALID(call)) { CLR_Debug::Printf(":"); - CLR_RT_DUMP::METHOD(call); + CLR_RT_DUMP::METHOD(call, call.genericType); } CLR_OPCODE op = CLR_ReadNextOpcodeCompressed(ip); @@ -731,14 +730,14 @@ void CLR_RT_DUMP::TYPE(const CLR_RT_ReflectionDef_Index &reflex) } } -void CLR_RT_DUMP::METHOD(const CLR_RT_MethodDef_Index &method) +void CLR_RT_DUMP::METHOD(const CLR_RT_MethodDef_Index &method, const CLR_RT_TypeSpec_Index *genericType) { NATIVE_PROFILE_CLR_DIAGNOSTICS(); char rgBuffer[512]; char *szBuffer = rgBuffer; size_t iBuffer = MAXSTRLEN(rgBuffer); - g_CLR_RT_TypeSystem.BuildMethodName(method, szBuffer, iBuffer); + g_CLR_RT_TypeSystem.BuildMethodName(method, genericType, szBuffer, iBuffer); CLR_Debug::Printf("%s", rgBuffer); } @@ -791,7 +790,7 @@ void CLR_RT_DUMP::OBJECT(CLR_RT_HeapBlock *ptr, const char *text) case DATATYPE_SZARRAY: { - CLR_RT_HeapBlock_Array *array = (CLR_RT_HeapBlock_Array *)ptr; + auto *array = (CLR_RT_HeapBlock_Array *)ptr; CLR_RT_DUMP::TYPE(array->ReflectionData()); } @@ -799,9 +798,9 @@ void CLR_RT_DUMP::OBJECT(CLR_RT_HeapBlock *ptr, const char *text) case DATATYPE_DELEGATE_HEAD: { - CLR_RT_HeapBlock_Delegate *dlg = (CLR_RT_HeapBlock_Delegate *)ptr; + auto *dlg = (CLR_RT_HeapBlock_Delegate *)ptr; - CLR_RT_DUMP::METHOD(dlg->DelegateFtn()); + CLR_RT_DUMP::METHOD(dlg->DelegateFtn(), nullptr); } break; @@ -850,6 +849,32 @@ void CLR_RT_DUMP::OBJECT(CLR_RT_HeapBlock *ptr, const char *text) #undef PELEMENT_TO_STRING } +void CLR_RT_DUMP::METHODREF(const CLR_RT_MethodRef_Index &method) +{ + NATIVE_PROFILE_CLR_DIAGNOSTICS(); + + char rgBuffer[512]; + char *szBuffer = rgBuffer; + size_t iBuffer = MAXSTRLEN(rgBuffer); + + g_CLR_RT_TypeSystem.BuildMethodRefName(method, szBuffer, iBuffer); + + CLR_Debug::Printf("%s", rgBuffer); +} + +void CLR_RT_DUMP::METHODSPEC(const CLR_RT_MethodSpec_Index &method) +{ + NATIVE_PROFILE_CLR_DIAGNOSTICS(); + + char rgBuffer[512]; + char *szBuffer = rgBuffer; + size_t iBuffer = MAXSTRLEN(rgBuffer); + + g_CLR_RT_TypeSystem.BuildMethodSpecName(method, szBuffer, iBuffer); + + CLR_Debug::Printf("%s", rgBuffer); +} + #endif // defined(NANOCLR_TRACE_ERRORS) //--// @@ -876,7 +901,7 @@ void CLR_RT_DUMP::EXCEPTION(CLR_RT_StackFrame &stack, CLR_RT_HeapBlock &ref) msg = Library_corlib_native_System_Exception::GetMessage(obj); - CLR_Debug::Printf(" ++++ Message: %s\r\n", msg == NULL ? "" : msg); + CLR_Debug::Printf(" ++++ Message: %s\r\n", msg == nullptr ? "" : msg); CLR_UINT32 depth; Library_corlib_native_System_Exception::StackTrace *stackTrace = @@ -887,7 +912,7 @@ void CLR_RT_DUMP::EXCEPTION(CLR_RT_StackFrame &stack, CLR_RT_HeapBlock &ref) while (depth-- > 0) { CLR_Debug::Printf(" ++++ "); - CLR_RT_DUMP::METHOD(stackTrace->m_md); + CLR_RT_DUMP::METHOD(stackTrace->m_md, nullptr); CLR_Debug::Printf(" [IP: %04x] ++++\r\n", stackTrace->m_IP); stackTrace++; diff --git a/src/CLR/Diagnostics/Profile.cpp b/src/CLR/Diagnostics/Profile.cpp index b1e2fa4e4c..6602e6d00a 100644 --- a/src/CLR/Diagnostics/Profile.cpp +++ b/src/CLR/Diagnostics/Profile.cpp @@ -20,7 +20,7 @@ void *CLR_PROF_CounterCallChain::Prepare(CLR_PROF_Handler *handler) handler->m_target_Mode = CLR_PROF_Handler::c_Mode_Ignore; - return NULL; + return nullptr; } else { @@ -39,8 +39,8 @@ void CLR_PROF_CounterCallChain::Complete(CLR_UINT64 &t, CLR_PROF_Handler *handle { m_time_exclusive += t; - m_owningHandler->m_target = NULL; - m_owningHandler = NULL; + m_owningHandler->m_target = nullptr; + m_owningHandler = nullptr; } } @@ -111,7 +111,7 @@ void CLR_PROF_Handler::Constructor() m_target_Mode = c_Mode_Ignore; - Init(NULL); + Init(nullptr); } #if defined(NANOCLR_PROFILE_NEW_CALLS) @@ -169,13 +169,13 @@ void CLR_PROF_Handler::Init(void *target) if (m_target) { - if (m_containing && m_containing->m_target == NULL) + if (m_containing && m_containing->m_target == nullptr) { - m_target = NULL; + m_target = nullptr; } } - if (m_target == NULL) + if (m_target == nullptr) { m_target_Mode = c_Mode_Ignore; } @@ -201,7 +201,7 @@ void CLR_PROF_Handler::Calibrate() if (s_initialized) return; - s_current = NULL; + s_current = nullptr; s_time_overhead = 0; s_time_freeze = 0; s_time_adjusted = 0; diff --git a/src/CLR/Diagnostics/Profiler.cpp b/src/CLR/Diagnostics/Profiler.cpp index f9c8ff2bf1..890eb82676 100644 --- a/src/CLR/Diagnostics/Profiler.cpp +++ b/src/CLR/Diagnostics/Profiler.cpp @@ -25,16 +25,12 @@ HRESULT CLR_PRF_Profiler::CreateInstance() NANOCLR_HEADER(); g_CLR_PRF_Profiler.m_packetSeqId = 0; - g_CLR_PRF_Profiler.m_stream = NULL; + g_CLR_PRF_Profiler.m_stream = nullptr; g_CLR_PRF_Profiler.m_lastTimestamp = - (CLR_UINT32)((HAL_Time_CurrentTime() + ((1ULL << CLR_PRF_CMDS::Bits::TimestampShift) - 1)) >> - CLR_PRF_CMDS::Bits::TimestampShift); - + (CLR_UINT32)((CLR_UINT64)(HAL_Time_CurrentTime() + ((1ull << CLR_PRF_CMDS::Bits::TimestampShift) - 1)) >> CLR_PRF_CMDS::Bits::TimestampShift); g_CLR_PRF_Profiler.m_currentAssembly = 0; g_CLR_PRF_Profiler.m_currentThreadPID = 0; - NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_MemoryStream::CreateInstance(g_CLR_PRF_Profiler.m_stream, NULL, 0)); - - g_CLR_PRF_Profiler.m_initialized = true; + NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_MemoryStream::CreateInstance(g_CLR_PRF_Profiler.m_stream, nullptr, 0)); #if defined(VIRTUAL_DEVICE) // need to do the here to send the memory layout in the first packet @@ -68,22 +64,22 @@ void CLR_PRF_Profiler::SendMemoryLayout() m_stream->WriteBits(CLR_PRF_CMDS::c_Profiling_Memory_Layout, CLR_PRF_CMDS::Bits::CommandHeader); #if defined(_WIN64) - PackAndWriteBits((CLR_UINT32)((CLR_UINT64)s_CLR_RT_Heap.m_location >> 32)); + PackAndWriteBits((CLR_UINT32)((CLR_UINT64)s_CLR_RT_Heap.location >> 32)); #endif - PackAndWriteBits((CLR_UINT32)s_CLR_RT_Heap.m_location); + PackAndWriteBits((CLR_UINT32)s_CLR_RT_Heap.location); - PackAndWriteBits(s_CLR_RT_Heap.m_size); + PackAndWriteBits(s_CLR_RT_Heap.size); Stream_Send(); #if defined(VIRTUAL_DEVICE) - if (g_ProfilerMessageCallback != NULL) + if (g_ProfilerMessageCallback != nullptr) { std::string memoryLayout = std::format( "** Memory layout **\r\n start:0x{:X}\r\n end:0x{:X}\r\n size:0x{:X}\r\n", - (unsigned long long)s_CLR_RT_Heap.m_location, - (unsigned long long)s_CLR_RT_Heap.m_location + s_CLR_RT_Heap.m_size, - s_CLR_RT_Heap.m_size); + (unsigned long long)s_CLR_RT_Heap.location, + (unsigned long long)s_CLR_RT_Heap.location + s_CLR_RT_Heap.size, + s_CLR_RT_Heap.size); g_ProfilerMessageCallback(memoryLayout.c_str()); } @@ -164,7 +160,7 @@ HRESULT CLR_PRF_Profiler::DumpRoots() _ASSERTE(fin->m_object->DataType() != DATATYPE_FREEBLOCK); _ASSERTE(fin->m_object->DataType() != DATATYPE_CACHEDBLOCK); - DumpRoot(fin->m_object, CLR_PRF_CMDS::RootTypes::Root_Finalizer, 0, NULL); + DumpRoot(fin->m_object, CLR_PRF_CMDS::RootTypes::Root_Finalizer, 0, nullptr); } NANOCLR_FOREACH_NODE_END(); @@ -174,7 +170,7 @@ HRESULT CLR_PRF_Profiler::DumpRoots() _ASSERTE(fin->m_object->DataType() != DATATYPE_FREEBLOCK); _ASSERTE(fin->m_object->DataType() != DATATYPE_CACHEDBLOCK); - DumpRoot(fin->m_object, CLR_PRF_CMDS::RootTypes::Root_Finalizer, 0, NULL); + DumpRoot(fin->m_object, CLR_PRF_CMDS::RootTypes::Root_Finalizer, 0, nullptr); } NANOCLR_FOREACH_NODE_END(); @@ -182,7 +178,7 @@ HRESULT CLR_PRF_Profiler::DumpRoots() // Iterate through all the appdomains NANOCLR_FOREACH_NODE(CLR_RT_AppDomain, appDomain, g_CLR_RT_ExecutionEngine.m_appDomains) { - DumpRoot(appDomain, CLR_PRF_CMDS::RootTypes::Root_AppDomain, 0, NULL); + DumpRoot(appDomain, CLR_PRF_CMDS::RootTypes::Root_AppDomain, 0, nullptr); } NANOCLR_FOREACH_NODE_END(); #endif @@ -190,7 +186,7 @@ HRESULT CLR_PRF_Profiler::DumpRoots() // Iterate through all the assemblies. NANOCLR_FOREACH_ASSEMBLY(g_CLR_RT_TypeSystem) { - DumpRoot(pASSM, CLR_PRF_CMDS::RootTypes::Root_Assembly, 0, NULL); + DumpRoot(pASSM, CLR_PRF_CMDS::RootTypes::Root_Assembly, 0, nullptr); } NANOCLR_FOREACH_ASSEMBLY_END(); @@ -202,7 +198,7 @@ HRESULT CLR_PRF_Profiler::DumpRoots() { NANOCLR_FOREACH_NODE(CLR_RT_Thread, th, *threadLists[list]) { - DumpRoot(th, CLR_PRF_CMDS::RootTypes::Root_Thread, 0, NULL); + DumpRoot(th, CLR_PRF_CMDS::RootTypes::Root_Thread, 0, nullptr); } NANOCLR_FOREACH_NODE_END(); } @@ -239,7 +235,7 @@ void CLR_PRF_Profiler::DumpRoot( } else { - _ASSERTE(source == NULL); + _ASSERTE(source == nullptr); } } @@ -247,19 +243,19 @@ void CLR_PRF_Profiler::DumpObject(CLR_RT_HeapBlock *ptr) { NATIVE_PROFILE_CLR_DIAGNOSTICS(); // Object Proto: - // Free blocked and cached blocks are considered free memory and are not dumped. - // All other types: - // 8 bits - Profiling_HeapDump_Object - // 32 bit pointer - // 16 bit size - // 8 bit - DataType() const - // 32 bits are TypeDef info >>>> iff DataType == CLASSTYPE || DataType == VALUETYPE || DataType == SZARRAY <<<< - // 16 bits are Array Level info >>>> iff DataType == SZARRAY <<<< - // 1 bit - Reference Follows - // 0 - No more references. End of Packet - // 1 - 32-bit pointer to reference follows. Repeat. - - CLR_DataType dt = ptr->DataType(); + // Free blocked and cached blocks are considered free memory and are not dumped. + // All other types: + // 8 bits - Profiling_HeapDump_Object + // 32 bit pointer + // 16 bit size + // 8 bit - DataType() const + // 32 bits are TypeDef info >>>> iff DataType == CLASSTYPE || DataType == VALUETYPE || DataType == SZARRAY <<<< + // 16 bits are Array Level info >>>> iff DataType == SZARRAY <<<< + // 1 bit - Reference Follows + // 0 - No more references. End of Packet + // 1 - 32-bit pointer to reference follows. Repeat. + + NanoCLRDataType dt = ptr->DataType(); _ASSERTE(dt < DATATYPE_FIRST_INVALID); _ASSERTE( sizeof(struct CLR_RT_HeapBlock) == @@ -324,9 +320,9 @@ void CLR_PRF_Profiler::DumpObject(CLR_RT_HeapBlock *ptr) case DATATYPE_CLASS: case DATATYPE_VALUETYPE: { - CLR_RT_TypeDef_Index idx = ptr->ObjectCls(); - _ASSERTE(NANOCLR_INDEX_IS_VALID(idx)); - PackAndWriteBits(idx); + CLR_RT_TypeDef_Index index = ptr->ObjectCls(); + _ASSERTE(NANOCLR_INDEX_IS_VALID(index)); + PackAndWriteBits(index); DumpSingleReference(ptr->ObjectLock()); DumpListOfReferences( ptr + 1, @@ -338,10 +334,10 @@ void CLR_PRF_Profiler::DumpObject(CLR_RT_HeapBlock *ptr) case DATATYPE_SZARRAY: { // Special case needed to dump out array data type and levels. - CLR_RT_HeapBlock_Array *array = (CLR_RT_HeapBlock_Array *)ptr; + auto *array = (CLR_RT_HeapBlock_Array *)ptr; - PackAndWriteBits(array->ReflectionDataConst().m_data.m_type); - PackAndWriteBits(array->ReflectionDataConst().m_levels); + PackAndWriteBits(array->ReflectionDataConst().data.type); + PackAndWriteBits(array->ReflectionDataConst().levels); if (array->m_fReference) { @@ -352,38 +348,38 @@ void CLR_PRF_Profiler::DumpObject(CLR_RT_HeapBlock *ptr) case DATATYPE_ASSEMBLY: { - CLR_RT_Assembly *assembly = (CLR_RT_Assembly *)ptr; - DumpSingleReference(assembly->m_pFile); + auto *assembly = (CLR_RT_Assembly *)ptr; + DumpSingleReference(assembly->file); #if !defined(NANOCLR_APPDOMAINS) - DumpListOfReferences(assembly->m_pStaticFields, assembly->m_iStaticFields); + DumpListOfReferences(assembly->staticFields, assembly->staticFieldsCount); #endif break; } case DATATYPE_WEAKCLASS: { - CLR_RT_HeapBlock_WeakReference *wr = (CLR_RT_HeapBlock_WeakReference *)ptr; + auto *wr = (CLR_RT_HeapBlock_WeakReference *)ptr; DumpSingleReference(wr->m_targetDirect); break; } case DATATYPE_DELEGATE_HEAD: { - CLR_RT_HeapBlock_Delegate *dlg = (CLR_RT_HeapBlock_Delegate *)ptr; + auto *dlg = (CLR_RT_HeapBlock_Delegate *)ptr; DumpSingleReference(&dlg->m_object); break; } case DATATYPE_DELEGATELIST_HEAD: { - CLR_RT_HeapBlock_Delegate_List *dlgList = (CLR_RT_HeapBlock_Delegate_List *)ptr; + auto *dlgList = (CLR_RT_HeapBlock_Delegate_List *)ptr; DumpListOfReferences(dlgList->GetDelegates(), dlgList->m_length); break; } case DATATYPE_THREAD: { - CLR_RT_Thread *th = (CLR_RT_Thread *)ptr; + auto *th = (CLR_RT_Thread *)ptr; DumpSingleReference(th->m_dlg); DumpSingleReference(th->m_currentException.Dereference()); @@ -404,16 +400,16 @@ void CLR_PRF_Profiler::DumpObject(CLR_RT_HeapBlock *ptr) case DATATYPE_STACK_FRAME: { - CLR_RT_StackFrame *stack = (CLR_RT_StackFrame *)ptr; - DumpListOfReferences(stack->m_arguments, stack->m_call.m_target->numArgs); - DumpListOfReferences(stack->m_locals, stack->m_call.m_target->numLocals); + auto *stack = (CLR_RT_StackFrame *)ptr; + DumpListOfReferences(stack->m_arguments, stack->m_call.target->argumentsCount); + DumpListOfReferences(stack->m_locals, stack->m_call.target->localsCount); DumpListOfReferences(stack->m_evalStack, stack->TopValuePosition()); break; } case DATATYPE_OBJECT_TO_EVENT: { - CLR_RT_ObjectToEvent_Source *otes = (CLR_RT_ObjectToEvent_Source *)ptr; + auto *otes = (CLR_RT_ObjectToEvent_Source *)ptr; DumpSingleReference( otes->m_eventPtr); // The managed object should reference this obj, which references the event. break; @@ -423,7 +419,7 @@ void CLR_PRF_Profiler::DumpObject(CLR_RT_HeapBlock *ptr) { // Object points to Lock Head, Thread points to Lock Head, Lock Head points to list of lock owners and // requests - CLR_RT_HeapBlock_Lock *lock = (CLR_RT_HeapBlock_Lock *)ptr; + auto *lock = (CLR_RT_HeapBlock_Lock *)ptr; DumpListOfReferences(lock->m_owners); DumpListOfReferences(lock->m_requests); break; @@ -431,35 +427,35 @@ void CLR_PRF_Profiler::DumpObject(CLR_RT_HeapBlock *ptr) case DATATYPE_ENDPOINT_HEAD: { - CLR_RT_HeapBlock_EndPoint *ep = (CLR_RT_HeapBlock_EndPoint *)ptr; + auto *ep = (CLR_RT_HeapBlock_EndPoint *)ptr; DumpListOfReferences(ep->m_messages); break; } case DATATYPE_WAIT_FOR_OBJECT_HEAD: { - CLR_RT_HeapBlock_WaitForObject *wfo = (CLR_RT_HeapBlock_WaitForObject *)ptr; + auto *wfo = (CLR_RT_HeapBlock_WaitForObject *)ptr; DumpListOfReferences(wfo->GetWaitForObjects(), wfo->m_cObjects); break; } case DATATYPE_FINALIZER_HEAD: { - CLR_RT_HeapBlock_Finalizer *f = (CLR_RT_HeapBlock_Finalizer *)ptr; + auto *f = (CLR_RT_HeapBlock_Finalizer *)ptr; DumpSingleReference(f->m_object); break; } case DATATYPE_MEMORY_STREAM_HEAD: { - CLR_RT_HeapBlock_MemoryStream *ms = (CLR_RT_HeapBlock_MemoryStream *)ptr; + auto *ms = (CLR_RT_HeapBlock_MemoryStream *)ptr; DumpListOfReferences(ms->m_buffers); break; } case DATATYPE_SERIALIZER_HEAD: { - CLR_RT_BinaryFormatter *bf = (CLR_RT_BinaryFormatter *)ptr; + auto *bf = (CLR_RT_BinaryFormatter *)ptr; DumpSingleReference(bf->m_stream); DumpListOfReferences(bf->m_duplicates); DumpListOfReferences(bf->m_states); @@ -498,18 +494,15 @@ void CLR_PRF_Profiler::DumpObject(CLR_RT_HeapBlock *ptr) CLR_RT_HeapBlock *CLR_PRF_Profiler::FindReferencedObject(CLR_RT_HeapBlock *ref) { NATIVE_PROFILE_CLR_DIAGNOSTICS(); - while (ref) { - CLR_DataType dt = ref->DataType(); - + NanoCLRDataType dt = ref->DataType(); switch (dt) { case DATATYPE_BYREF: case DATATYPE_OBJECT: ref = ref->Dereference(); break; - #if defined(NANOCLR_APPDOMAINS) case DATATYPE_TRANSPARENT_PROXY: ref = ref->TransparentProxyDereference(); @@ -524,8 +517,7 @@ CLR_RT_HeapBlock *CLR_PRF_Profiler::FindReferencedObject(CLR_RT_HeapBlock *ref) return ref; } } - - return NULL; + return nullptr; } void CLR_PRF_Profiler::DumpEndOfRefsList() @@ -539,11 +531,11 @@ void CLR_PRF_Profiler::DumpPointer(void *ptr) NATIVE_PROFILE_CLR_DIAGNOSTICS(); #ifdef _WIN64 - CLR_UINT64 ptrVAlue = ((CLR_UINT8 *)ptr - s_CLR_RT_Heap.m_location); + CLR_UINT64 ptrVAlue = ((CLR_UINT8 *)ptr - s_CLR_RT_Heap.location); PackAndWriteBits((CLR_UINT32)(ptrVAlue >> 32)); PackAndWriteBits((CLR_UINT32)ptrVAlue); #else - PackAndWriteBits((CLR_UINT32)((CLR_UINT8 *)ptr - s_CLR_RT_Heap.m_location)); + PackAndWriteBits((CLR_UINT32)((CLR_UINT8 *)ptr - s_CLR_RT_Heap.location)); #endif } @@ -584,9 +576,8 @@ void CLR_PRF_Profiler::Timestamp() { NATIVE_PROFILE_CLR_DIAGNOSTICS(); // Send Profiling Timestamp - CLR_UINT32 time = - (CLR_UINT32)((HAL_Time_CurrentTime() + ((CLR_UINT64)((1ull << CLR_PRF_CMDS::Bits::TimestampShift) - 1))) >> - CLR_PRF_CMDS::Bits::TimestampShift); + auto time = + (CLR_UINT32)((HAL_Time_CurrentTime() + ((CLR_UINT64)((1ull << CLR_PRF_CMDS::Bits::TimestampShift) - 1))) >> CLR_PRF_CMDS::Bits::TimestampShift); if (time > m_lastTimestamp) { m_stream->WriteBits(CLR_PRF_CMDS::c_Profiling_Timestamp, CLR_PRF_CMDS::Bits::CommandHeader); @@ -740,7 +731,7 @@ void CLR_PRF_Profiler::TrackObjectCreation(CLR_RT_HeapBlock *ptr) PackAndWriteBits(idx); #if defined(VIRTUAL_DEVICE) - if (g_ProfilerMessageCallback != NULL) + if (g_ProfilerMessageCallback != nullptr) { // build type name char fullTypeName[1024] = {0}; @@ -755,7 +746,7 @@ void CLR_PRF_Profiler::TrackObjectCreation(CLR_RT_HeapBlock *ptr) c_CLR_RT_DataTypeLookup[dt].m_name, fullTypeName, (CLR_UINT64)((CLR_UINT8 *)ptr), - idx.m_data, + idx.data, (dataSize * sizeof(struct CLR_RT_HeapBlock))); g_ProfilerMessageCallback(objectCreation.c_str()); @@ -788,12 +779,12 @@ void CLR_PRF_Profiler::TrackObjectCreation(CLR_RT_HeapBlock *ptr) else if (dt == DATATYPE_SZARRAY) { CLR_RT_HeapBlock_Array *array = (CLR_RT_HeapBlock_Array *)ptr; - CLR_RT_TypeDef_Index elementIdx = array->ReflectionDataConst().m_data.m_type; - PackAndWriteBits(array->ReflectionDataConst().m_data.m_type); - PackAndWriteBits(array->ReflectionDataConst().m_levels); + CLR_RT_TypeDef_Index elementIdx = array->ReflectionDataConst().data.type; + PackAndWriteBits(array->ReflectionDataConst().data.type); + PackAndWriteBits(array->ReflectionDataConst().levels); #if defined(VIRTUAL_DEVICE) - if (g_ProfilerMessageCallback != NULL) + if (g_ProfilerMessageCallback != nullptr) { // build type name char fullTypeName[1024] = {0}; @@ -812,7 +803,7 @@ void CLR_PRF_Profiler::TrackObjectCreation(CLR_RT_HeapBlock *ptr) fullTypeName, (CLR_UINT64)((CLR_UINT8 *)ptr), (dataSize * sizeof(struct CLR_RT_HeapBlock)), - elementIdx.m_data, + elementIdx.data, array->m_numOfElements, levels); @@ -902,12 +893,12 @@ void CLR_PRF_Profiler::TrackObjectDeletion(CLR_RT_HeapBlock *ptr) Stream_Send(); #if defined(VIRTUAL_DEVICE) - if (g_ProfilerMessageCallback != NULL) + if (g_ProfilerMessageCallback != nullptr) { if (dt == DATATYPE_SZARRAY) { CLR_RT_HeapBlock_Array *array = (CLR_RT_HeapBlock_Array *)ptr; - CLR_RT_TypeDef_Index elementIdx = array->ReflectionDataConst().m_data.m_type; + CLR_RT_TypeDef_Index elementIdx = array->ReflectionDataConst().data.type; // build type name char fullTypeName[1024] = {0}; @@ -926,7 +917,7 @@ void CLR_PRF_Profiler::TrackObjectDeletion(CLR_RT_HeapBlock *ptr) fullTypeName, (CLR_UINT64)((CLR_UINT8 *)ptr), (ptr->DataSize() * sizeof(struct CLR_RT_HeapBlock)), - elementIdx.m_data, + elementIdx.data, array->m_numOfElements, levels); @@ -949,7 +940,7 @@ void CLR_PRF_Profiler::TrackObjectDeletion(CLR_RT_HeapBlock *ptr) c_CLR_RT_DataTypeLookup[dt].m_name, fullTypeName, (CLR_UINT64)((CLR_UINT8 *)ptr), - idx.m_data, + idx.data, (ptr->DataSize() * sizeof(struct CLR_RT_HeapBlock))); g_ProfilerMessageCallback(objectDeletion.c_str()); @@ -1055,7 +1046,7 @@ void CLR_PRF_Profiler::TrackObjectRelocation(void *previousAddress, void *destin { #if defined(VIRTUAL_DEVICE) - if (g_ProfilerMessageCallback != NULL) + if (g_ProfilerMessageCallback != nullptr) { CLR_RT_HeapBlock *ptr = (CLR_RT_HeapBlock *)destinationAddress; CLR_UINT8 dt = ptr->DataType(); @@ -1085,7 +1076,7 @@ void CLR_PRF_Profiler::TrackObjectRelocation(void *previousAddress, void *destin else if (dt == DATATYPE_SZARRAY) { CLR_RT_HeapBlock_Array *array = (CLR_RT_HeapBlock_Array *)ptr; - CLR_RT_TypeDef_Index elementIdx = array->ReflectionDataConst().m_data.m_type; + CLR_RT_TypeDef_Index elementIdx = array->ReflectionDataConst().data.type; // build type name char fullTypeName[1024] = {0}; @@ -1141,7 +1132,7 @@ void CLR_PRF_Profiler::RecordGarbageCollectionBegin() Stream_Send(); #if defined(VIRTUAL_DEVICE) - if (g_ProfilerMessageCallback != NULL) + if (g_ProfilerMessageCallback != nullptr) { std::string garbageCollection = std::format("GC: Starting run #{}\r\n", g_CLR_RT_GarbageCollector.m_numberOfGarbageCollections); @@ -1188,7 +1179,7 @@ void CLR_PRF_Profiler::RecordGarbageCollectionEnd() Stream_Send(); #if defined(VIRTUAL_DEVICE) - if (g_ProfilerMessageCallback != NULL) + if (g_ProfilerMessageCallback != nullptr) { std::string garbageCollection = std::format( "GC: Finished run #{} - {} bytes free\r\n", @@ -1250,7 +1241,7 @@ void CLR_PRF_Profiler::RecordHeapCompactionBegin() Stream_Send(); #if defined(VIRTUAL_DEVICE) - if (g_ProfilerMessageCallback != NULL) + if (g_ProfilerMessageCallback != nullptr) { std::string heapCompaction = std::format("Heap compaction: Starting run #{} \r\n", g_CLR_RT_GarbageCollector.m_numberOfCompactions); @@ -1298,7 +1289,7 @@ void CLR_PRF_Profiler::RecordHeapCompactionEnd() Stream_Send(); #if defined(VIRTUAL_DEVICE) - if (g_ProfilerMessageCallback != NULL) + if (g_ProfilerMessageCallback != nullptr) { std::string heapCompaction = std::format("Heap compaction: Finished run #{}\r\n", g_CLR_RT_GarbageCollector.m_numberOfCompactions); @@ -1431,7 +1422,7 @@ HRESULT CLR_PRF_Profiler::Stream_Flush() const CLR_UINT32 messageType = CLR_DBG_Commands::c_Profiling_Stream; CLR_UINT8 buffer[2 * sizeof(CLR_UINT16) + CLR_RT_HeapBlock_MemoryStream::Buffer::c_PayloadSize]; - CLR_DBG_Commands::Profiling_Stream *packet = (CLR_DBG_Commands::Profiling_Stream *)buffer; + auto *packet = (CLR_DBG_Commands::Profiling_Stream *)buffer; NANOCLR_FOREACH_NODE(CLR_RT_HeapBlock_MemoryStream::Buffer, ptr, m_stream->m_buffers) { @@ -1458,7 +1449,7 @@ HRESULT CLR_PRF_Profiler::Stream_Flush() } #if defined(VIRTUAL_DEVICE) - if (g_ProfilerDataCallback != NULL) + if (g_ProfilerDataCallback != nullptr) { g_ProfilerDataCallback(ptr->m_payload, payloadLength); } diff --git a/src/CLR/Include/nanoCLR_Checks.h b/src/CLR/Include/nanoCLR_Checks.h index 2633835bc4..f13a26126c 100644 --- a/src/CLR/Include/nanoCLR_Checks.h +++ b/src/CLR/Include/nanoCLR_Checks.h @@ -1,4 +1,4 @@ -// +// // Copyright (c) .NET Foundation and Contributors // Portions Copyright (c) Microsoft Corporation. All rights reserved. // See LICENSE file in the project root for full license information. @@ -8,6 +8,8 @@ #include +// clang-format off + #ifdef __GNUC__ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-parameter" @@ -19,16 +21,16 @@ struct CLR_RT_DUMP #if defined(NANOCLR_TRACE_ERRORS) #define DECL_POSTFIX #else -#define DECL_POSTFIX \ - { \ - } +#define DECL_POSTFIX {} #endif - static void TYPE(const CLR_RT_TypeDef_Index &cls) DECL_POSTFIX; - static void TYPE(const CLR_RT_ReflectionDef_Index &reflex) DECL_POSTFIX; - static void METHOD(const CLR_RT_MethodDef_Index &method) DECL_POSTFIX; - static void FIELD(const CLR_RT_FieldDef_Index &field) DECL_POSTFIX; - static void OBJECT(CLR_RT_HeapBlock *ptr, const char *text) DECL_POSTFIX; + static void TYPE (const CLR_RT_TypeDef_Index& cls ) DECL_POSTFIX; + static void TYPE (const CLR_RT_ReflectionDef_Index& reflex ) DECL_POSTFIX; + static void METHOD (const CLR_RT_MethodDef_Index& method, const CLR_RT_TypeSpec_Index *genericType) DECL_POSTFIX; + static void FIELD (const CLR_RT_FieldDef_Index& field ) DECL_POSTFIX; + static void OBJECT ( CLR_RT_HeapBlock* ptr , const char* text ) DECL_POSTFIX; + static void METHODREF (const CLR_RT_MethodRef_Index& method ) DECL_POSTFIX; + static void METHODSPEC(const CLR_RT_MethodSpec_Index& method ) DECL_POSTFIX; //--// @@ -36,16 +38,14 @@ struct CLR_RT_DUMP #if defined(NANOCLR_TRACE_EXCEPTIONS) #define DECL_POSTFIX #else -#define DECL_POSTFIX \ - { \ - } +#define DECL_POSTFIX {} #endif - static void EXCEPTION(CLR_RT_StackFrame &stack, CLR_RT_HeapBlock &ref) DECL_POSTFIX; - static void POST_PROCESS_EXCEPTION(CLR_RT_HeapBlock &ref) DECL_POSTFIX; + static void EXCEPTION ( CLR_RT_StackFrame& stack, CLR_RT_HeapBlock& ref ) DECL_POSTFIX; + static void POST_PROCESS_EXCEPTION( CLR_RT_HeapBlock& ref ) DECL_POSTFIX; - static const char *GETERRORMESSAGE(HRESULT hrError); + static const char* GETERRORMESSAGE( HRESULT hrError ); #if defined(VIRTUAL_DEVICE) - static const char *GETERRORDETAIL(); + static const char* GETERRORDETAIL (); #endif }; @@ -53,17 +53,14 @@ struct CLR_RT_DUMP struct CLR_Checks { - static HRESULT VerifyStackOK(CLR_RT_StackFrame &stack, CLR_RT_HeapBlock *top, int num) - { - return S_OK; - } + static HRESULT VerifyStackOK( const CLR_RT_StackFrame& stack, const CLR_RT_HeapBlock* top, const int num ); - static HRESULT VerifyObject(CLR_RT_HeapBlock &top); + static HRESULT VerifyObject ( CLR_RT_HeapBlock& top ); - static HRESULT VerifyArrayReference(CLR_RT_HeapBlock &ref); + static HRESULT VerifyArrayReference ( CLR_RT_HeapBlock& ref ); - static HRESULT VerifyUnknownInstruction(CLR_OPCODE op); - static HRESULT VerifyUnsupportedInstruction(CLR_OPCODE op); + static HRESULT VerifyUnknownInstruction ( CLR_OPCODE op ); + static HRESULT VerifyUnsupportedInstruction( CLR_OPCODE op ); }; #ifdef __GNUC__ @@ -72,4 +69,6 @@ struct CLR_Checks //////////////////////////////////////////////////////////////////////////////////////////////////// +// clang-format on + #endif // NANOCLR_CHECKS_H diff --git a/src/CLR/Include/nanoCLR_Debugging.h b/src/CLR/Include/nanoCLR_Debugging.h index e30da40970..266c57c022 100644 --- a/src/CLR/Include/nanoCLR_Debugging.h +++ b/src/CLR/Include/nanoCLR_Debugging.h @@ -550,6 +550,11 @@ struct CLR_DBG_Commands //--// + + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // !!! KEEP IN SYNC WITH nanoFramework.Tools.Debugger.WireProtocol.Commands.Debugging_Value (in managed code) !!! // + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + struct Debugging_Value { // this is a CLR_RT_HeapBlock * @@ -577,6 +582,11 @@ struct CLR_DBG_Commands // CLR_RT_TypeDef_Index m_td; + // + // For DATATYPE_GENERICINST + // + CLR_RT_TypeSpec_Index m_ts; + // // For DATATYPE_SZARRAY // @@ -651,7 +661,7 @@ struct CLR_DBG_Commands struct Debugging_Value_GetScratchPad { - CLR_UINT32 m_idx; + CLR_UINT32 m_index; // @@ -749,7 +759,7 @@ struct CLR_DBG_Commands struct Debugging_Resolve_Assembly { - CLR_RT_Assembly_Index m_idx; + CLR_RT_Assembly_Index m_index; struct Reply { @@ -904,12 +914,12 @@ struct CLR_DBG_Debugger HRESULT CreateListOfThreads( CLR_DBG_Commands::Debugging_Thread_List ::Reply*& cmdReply, int& totLen ); HRESULT CreateListOfCalls ( CLR_INT32 pid, CLR_DBG_Commands::Debugging_Thread_Stack::Reply*& cmdReply, int& totLen ); - CLR_RT_Assembly *IsGoodAssembly( CLR_IDX idxAssm ); + CLR_RT_Assembly *IsGoodAssembly( CLR_INDEX indexAssm ); bool CheckTypeDef ( const CLR_RT_TypeDef_Index& td , CLR_RT_TypeDef_Instance& inst ); bool CheckFieldDef ( const CLR_RT_FieldDef_Index& fd , CLR_RT_FieldDef_Instance& inst ); bool CheckMethodDef( const CLR_RT_MethodDef_Index& md , CLR_RT_MethodDef_Instance& inst ); - bool GetValue( WP_Message *msg, CLR_RT_HeapBlock *ptr, CLR_RT_HeapBlock *reference, CLR_RT_TypeDef_Instance *pTD ); + bool GetValue( WP_Message *msg, CLR_RT_HeapBlock *ptr, CLR_RT_HeapBlock *reference, CLR_RT_TypeDef_Instance *pTD); bool AllocateAndQueueMessage( CLR_UINT32 cmd, unsigned int length, unsigned char *data, CLR_RT_HeapBlock_EndPoint::Port port, CLR_RT_HeapBlock_EndPoint::Address addr, CLR_UINT32 found ); @@ -998,8 +1008,8 @@ struct CLR_DBG_Debugger #if defined(NANOCLR_ENABLE_SOURCELEVELDEBUGGING) static bool Debugging_Info_SetJMC ( WP_Message *msg ); - bool Debugging_Info_SetJMC_Type ( const CLR_RT_TypeDef_Index& idx, bool fJMC ); - bool Debugging_Info_SetJMC_Method ( const CLR_RT_MethodDef_Index& idx, bool fJMC ); + bool Debugging_Info_SetJMC_Type ( const CLR_RT_TypeDef_Index& index, bool fJMC ); + bool Debugging_Info_SetJMC_Method ( const CLR_RT_MethodDef_Index& index, bool fJMC ); #endif //#if defined(NANOCLR_ENABLE_SOURCELEVELDEBUGGING) static bool Profiling_Command ( WP_Message *msg ); diff --git a/src/CLR/Include/nanoCLR_Interop.h b/src/CLR/Include/nanoCLR_Interop.h index bb4f5ff4e3..fe726c98ff 100644 --- a/src/CLR/Include/nanoCLR_Interop.h +++ b/src/CLR/Include/nanoCLR_Interop.h @@ -18,7 +18,7 @@ extern HRESULT NANOCLR_DEBUG_PROCESS_EXCEPTION(HRESULT hr, const char *szFunc, c #define NANOCLR_LEAVE() \ { \ if (FAILED(hr)) \ - NANOCLR_DEBUG_PROCESS_EXCEPTION(hr, NULL, NULL, 0); \ + NANOCLR_DEBUG_PROCESS_EXCEPTION(hr, nullptr, nullptr, 0); \ goto nanoCLR_Cleanup; \ } #define NANOCLR_RETURN() return hr @@ -85,7 +85,7 @@ extern HRESULT NANOCLR_DEBUG_PROCESS_EXCEPTION(HRESULT hr, const char *szFunc, c hr = (expr); \ NANOCLR_LEAVE(); \ } -#define NANOCLR_MSG1_SET_AND_LEAVE(expr, msg, arg) \ +#define NANOCLR_MSG1_SET_AND_LEAVE(expr, msg, ...) \ { \ hr = (expr); \ NANOCLR_LEAVE(); \ @@ -204,7 +204,7 @@ HRESULT Interop_Marshal_double(const CLR_RT_StackFrame &stackFrame, unsigned int #endif HRESULT Interop_Marshal_LPCSTR(const CLR_RT_StackFrame &stackFrame, unsigned int paramIndex, const char *¶m); -// For unsupported types we set param to NULL. +// For unsupported types we set param to nullptr. HRESULT Interop_Marshal_UNSUPPORTED_TYPE( const CLR_RT_StackFrame &stackFrame, unsigned int paramIndex, @@ -298,7 +298,7 @@ template class CLR_RT_TypedArray public: CLR_RT_TypedArray() { - m_pData = NULL; + m_pData = nullptr; m_ElemCount = 0; } @@ -519,7 +519,7 @@ HRESULT Interop_Marshal_double_ByRef( #endif -// For unsuppoted types return NULL reference +// For unsuppoted types return nullptr reference HRESULT Interop_Marshal_UNSUPPORTED_TYPE_ByRef( const CLR_RT_StackFrame &stackFrame, @@ -549,7 +549,7 @@ HRESULT Interop_Marshal_StoreRef(CLR_RT_StackFrame &stackFrame, void *pVoidHeapB ** ** Arguments: [stackFrame] - Reference to the managed stack frame. ** -** Returns: Pointer to managed object or NULL in case of error. +** Returns: Pointer to managed object or nullptr in case of error. **********************************************************************/ CLR_RT_HeapBlock *Interop_Marshal_RetrieveManagedObject(CLR_RT_StackFrame &stackFrame); @@ -583,7 +583,7 @@ signed int &Interop_Marshal_GetField_float(CLR_RT_HeapBlock *pThis, unsigned int signed __int64 &Interop_Marshal_GetField_double(CLR_RT_HeapBlock *pThis, unsigned int fieldIndex); #endif -// For all other unsupported types we always return NULL reference. +// For all other unsupported types we always return nullptr reference. UNSUPPORTED_TYPE &Interop_Marshal_GetField_UNSUPPORTED_TYPE(CLR_RT_HeapBlock *pThis, unsigned int fieldIndex); /********************************************************************** @@ -668,7 +668,7 @@ void SaveNativeEventToHALQueue(CLR_RT_HeapBlock_NativeEventDispatcher *pContext, // Cleans up the data in the queue after interrupts were closed and no managed callbacks are expected. void CleanupNativeEventsFromHALQueue(CLR_RT_HeapBlock_NativeEventDispatcher *pContext); -void CLR_RetrieveCurrentMethod(unsigned int &assmIdx, unsigned int &methodIdx); +void CLR_RetrieveCurrentMethod(unsigned int &assmIndex, unsigned int &methodIndex); void CLR_SoftReboot(); diff --git a/src/CLR/Include/nanoCLR_Profiling.h b/src/CLR/Include/nanoCLR_Profiling.h index 007ba48eb9..3337ebe699 100644 --- a/src/CLR/Include/nanoCLR_Profiling.h +++ b/src/CLR/Include/nanoCLR_Profiling.h @@ -6,6 +6,8 @@ #ifndef NANOCLR_PROFILING_H #define NANOCLR_PROFILING_H +// clang-format off + #if defined(NANOCLR_PROFILE_NEW) /* @@ -19,9 +21,9 @@ int = 32BIT long = 64BIT pointer = 32BIT datatype = 8BIT -typedef-idx = 32BIT -method-idx = 32BIT - nanoCLR Method_Idx value for identifying a specific function +typedef-index = 32BIT +method-index = 32BIT + nanoCLR Method_Index value for identifying a specific function stream-packet = sequence-id length stream-payload A chunk of data sent out over the WireProtocol. @@ -65,7 +67,7 @@ heapdump-start-packet = heapdump-start-header heapdump-root-packet = heapdump-root-header ( heapdump-root-stack / heapdump-root-other ) heapdump-root-header = "00000011" -heapdump-root-stack = heapdump-root-stack-header method-idx +heapdump-root-stack = heapdump-root-stack-header method-index heapdump-root-stack-header = "101" heapdump-root-other = heapdump-root-finalizer / heapdump-root-appdomain / heapdump-root-assembly / heapdump-root-thread @@ -84,11 +86,11 @@ heapdump-object-type = heapdump-object-classvaluetype / heapdump-object-array / heapdump-object-classvaluetype = heapdump-object-classvaluetype-header heapdump-object-classvaluetype-typedef heapdump-object-classvaluetype-header = "00010001" / "00010010" -heapdump-object-classvaluetype-typedef = typedef-idx +heapdump-object-classvaluetype-typedef = typedef-index heapdump-object-array = heapdump-object-array-header heapdump-object-array-datatype heapdump-object-array-levels heapdump-object-array-header = "00010011" -heapdump-object-array-typedef = typedef-idx +heapdump-object-array-typedef = typedef-index heapdump-object-array-levels = short Rank of the array @@ -211,7 +213,7 @@ struct CLR_PRF_Profiler CLR_RT_HeapBlock_MemoryStream *m_stream; CLR_UINT16 m_packetSeqId; CLR_UINT32 m_lastTimestamp; - CLR_IDX m_currentAssembly; + CLR_INDEX m_currentAssembly; int m_currentThreadPID; bool m_initialized; }; @@ -219,4 +221,6 @@ struct CLR_PRF_Profiler extern CLR_PRF_Profiler g_CLR_PRF_Profiler; #endif // defined(NANOCLR_PROFILE_NEW) +// clang-format on + #endif // NANOCLR_PROFILING_H diff --git a/src/CLR/Include/nanoCLR_Runtime.h b/src/CLR/Include/nanoCLR_Runtime.h index 9b1a7d67de..2393b66e80 100644 --- a/src/CLR/Include/nanoCLR_Runtime.h +++ b/src/CLR/Include/nanoCLR_Runtime.h @@ -56,7 +56,7 @@ typedef CLR_RT_AddressToSymbolMap::iterator CLR_RT_AddressToSymbolMapIter; #include #endif -#endif // #if defined(_WIN32) +#endif // _WIN32 #if defined(_MSC_VER) #pragma pack(push, __NANOCLR_RUNTIME_H__, 4) @@ -90,8 +90,8 @@ class CLR_XmlUtil public: CLR_XmlUtil(/*[in]*/ const CLR_XmlUtil &xml); - CLR_XmlUtil(/*[in]*/ IXMLDOMDocument *xddDoc, /*[in]*/ const wchar_t *szRootTag = NULL); - CLR_XmlUtil(/*[in]*/ IXMLDOMNode *xdnRoot = NULL, /*[in]*/ const wchar_t *szRootTag = NULL); + CLR_XmlUtil(/*[in]*/ IXMLDOMDocument *xddDoc, /*[in]*/ const wchar_t *szRootTag = nullptr); + CLR_XmlUtil(/*[in]*/ IXMLDOMNode *xdnRoot = nullptr, /*[in]*/ const wchar_t *szRootTag = nullptr); ~CLR_XmlUtil(); @@ -106,17 +106,17 @@ class CLR_XmlUtil /*[in ]*/ const wchar_t *szFile, /*[in]*/ const wchar_t *szRootTag, /*[out]*/ bool &fLoaded, - /*[out]*/ bool *fFound = NULL); + /*[out]*/ bool *fFound = nullptr); HRESULT LoadAsStream( /*[in ]*/ IUnknown *pStream, /*[in]*/ const wchar_t *szRootTag, /*[out]*/ bool &fLoaded, - /*[out]*/ bool *fFound = NULL); + /*[out]*/ bool *fFound = nullptr); HRESULT LoadAsString( /*[in ]*/ BSTR bstrData, /*[in]*/ const wchar_t *szRootTag, /*[out]*/ bool &fLoaded, - /*[out]*/ bool *fFound = NULL); + /*[out]*/ bool *fFound = nullptr); HRESULT Save(/*[in ]*/ const wchar_t *szFile); HRESULT SaveAsStream(/*[out]*/ IUnknown **ppStream); HRESULT SaveAsString(/*[out]*/ BSTR *pbstrData); @@ -133,145 +133,145 @@ class CLR_XmlUtil HRESULT CreateNode( /*[in]*/ const wchar_t *szTag, /*[out]*/ IXMLDOMNode **pVal, - /*[in]*/ IXMLDOMNode *pxdnNode = NULL); + /*[in]*/ IXMLDOMNode *pxdnNode = nullptr); HRESULT GetAttribute( /*[in]*/ const wchar_t *szTag, /*[in]*/ const wchar_t *szAttr, /*[out]*/ IXMLDOMAttribute **pValue, /*[out]*/ bool &fFound, - /*[in]*/ IXMLDOMNode *pxdnNode = NULL); + /*[in]*/ IXMLDOMNode *pxdnNode = nullptr); HRESULT GetAttribute( /*[in]*/ const wchar_t *szTag, /*[in]*/ const wchar_t *szAttr, /*[out]*/ _bstr_t &bstrValue, /*[out]*/ bool &fFound, - /*[in]*/ IXMLDOMNode *pxdnNode = NULL); + /*[in]*/ IXMLDOMNode *pxdnNode = nullptr); HRESULT GetAttribute( /*[in]*/ const wchar_t *szTag, /*[in]*/ const wchar_t *szAttr, /*[out]*/ std::wstring &szValue, /*[out]*/ bool &fFound, - /*[in]*/ IXMLDOMNode *pxdnNode = NULL); + /*[in]*/ IXMLDOMNode *pxdnNode = nullptr); HRESULT GetAttribute( /*[in]*/ const wchar_t *szTag, /*[in]*/ const wchar_t *szAttr, /*[out]*/ signed int &lValue, /*[out]*/ bool &fFound, - /*[in]*/ IXMLDOMNode *pxdnNode = NULL); + /*[in]*/ IXMLDOMNode *pxdnNode = nullptr); HRESULT GetValue( /*[in]*/ const wchar_t *szTag, /*[out]*/ _variant_t &vValue, /*[out]*/ bool &fFound, - /*[in]*/ IXMLDOMNode *pxdnNode = NULL); + /*[in]*/ IXMLDOMNode *pxdnNode = nullptr); HRESULT GetValue( /*[in]*/ const wchar_t *szTag, /*[out]*/ _bstr_t &bstrValue, /*[out]*/ bool &fFound, - /*[in]*/ IXMLDOMNode *pxdnNode = NULL); + /*[in]*/ IXMLDOMNode *pxdnNode = nullptr); HRESULT GetValue( /*[in]*/ const wchar_t *szTag, /*[out]*/ std::wstring &szValue, /*[out]*/ bool &fFound, - /*[in]*/ IXMLDOMNode *pxdnNode = NULL); + /*[in]*/ IXMLDOMNode *pxdnNode = nullptr); HRESULT ModifyAttribute( /*[in]*/ const wchar_t *szTag, /*[in]*/ const wchar_t *szAttr, /*[in] */ const _bstr_t &bstrValue, /*[out]*/ bool &fFound, - /*[in]*/ IXMLDOMNode *pxdnNode = NULL); + /*[in]*/ IXMLDOMNode *pxdnNode = nullptr); HRESULT ModifyAttribute( /*[in]*/ const wchar_t *szTag, /*[in]*/ const wchar_t *szAttr, /*[in] */ const std::wstring &szValue, /*[out]*/ bool &fFound, - /*[in]*/ IXMLDOMNode *pxdnNode = NULL); + /*[in]*/ IXMLDOMNode *pxdnNode = nullptr); HRESULT ModifyAttribute( /*[in]*/ const wchar_t *szTag, /*[in]*/ const wchar_t *szAttr, /*[in] */ const wchar_t *szValue, /*[out]*/ bool &fFound, - /*[in]*/ IXMLDOMNode *pxdnNode = NULL); + /*[in]*/ IXMLDOMNode *pxdnNode = nullptr); HRESULT ModifyAttribute( /*[in]*/ const wchar_t *szTag, /*[in]*/ const wchar_t *szAttr, /*[in] */ signed int lValue, /*[out]*/ bool &fFound, - /*[in]*/ IXMLDOMNode *pxdnNode = NULL); + /*[in]*/ IXMLDOMNode *pxdnNode = nullptr); HRESULT ModifyValue( /*[in]*/ const wchar_t *szTag, /*[in] */ const _variant_t &vValue, /*[out]*/ bool &fFound, - /*[in]*/ IXMLDOMNode *pxdnNode = NULL); + /*[in]*/ IXMLDOMNode *pxdnNode = nullptr); HRESULT ModifyValue( /*[in]*/ const wchar_t *szTag, /*[in] */ const _bstr_t &bstrValue, /*[out]*/ bool &fFound, - /*[in]*/ IXMLDOMNode *pxdnNode = NULL); + /*[in]*/ IXMLDOMNode *pxdnNode = nullptr); HRESULT ModifyValue( /*[in]*/ const wchar_t *szTag, /*[in] */ const std::wstring &szValue, /*[out]*/ bool &fFound, - /*[in]*/ IXMLDOMNode *pxdnNode = NULL); + /*[in]*/ IXMLDOMNode *pxdnNode = nullptr); HRESULT PutAttribute( /*[in]*/ const wchar_t *szTag, /*[in]*/ const wchar_t *szAttr, /*[in] */ IXMLDOMAttribute **pValue, /*[out]*/ bool &fFound, - /*[in]*/ IXMLDOMNode *pxdnNode = NULL); + /*[in]*/ IXMLDOMNode *pxdnNode = nullptr); HRESULT PutAttribute( /*[in]*/ const wchar_t *szTag, /*[in]*/ const wchar_t *szAttr, /*[in] */ const _bstr_t &bstrValue, /*[out]*/ bool &fFound, - /*[in]*/ IXMLDOMNode *pxdnNode = NULL); + /*[in]*/ IXMLDOMNode *pxdnNode = nullptr); HRESULT PutAttribute( /*[in]*/ const wchar_t *szTag, /*[in]*/ const wchar_t *szAttr, /*[in] */ const std::wstring &szValue, /*[out]*/ bool &fFound, - /*[in]*/ IXMLDOMNode *pxdnNode = NULL); + /*[in]*/ IXMLDOMNode *pxdnNode = nullptr); HRESULT PutAttribute( /*[in]*/ const wchar_t *szTag, /*[in]*/ const wchar_t *szAttr, /*[in] */ const wchar_t *szValue, /*[out]*/ bool &fFound, - /*[in]*/ IXMLDOMNode *pxdnNode = NULL); + /*[in]*/ IXMLDOMNode *pxdnNode = nullptr); HRESULT PutAttribute( /*[in]*/ const wchar_t *szTag, /*[in]*/ const wchar_t *szAttr, /*[in] */ signed int lValue, /*[out]*/ bool &fFound, - /*[in]*/ IXMLDOMNode *pxdnNode = NULL); + /*[in]*/ IXMLDOMNode *pxdnNode = nullptr); HRESULT PutValue( /*[in]*/ const wchar_t *szTag, /*[in] */ const _variant_t &vValue, /*[out]*/ bool &fFound, - /*[in]*/ IXMLDOMNode *pxdnNode = NULL); + /*[in]*/ IXMLDOMNode *pxdnNode = nullptr); HRESULT PutValue( /*[in]*/ const wchar_t *szTag, /*[in] */ const _bstr_t &bstrValue, /*[out]*/ bool &fFound, - /*[in]*/ IXMLDOMNode *pxdnNode = NULL); + /*[in]*/ IXMLDOMNode *pxdnNode = nullptr); HRESULT PutValue( /*[in]*/ const wchar_t *szTag, /*[in] */ const std::wstring &szValue, /*[out]*/ bool &fFound, - /*[in]*/ IXMLDOMNode *pxdnNode = NULL); + /*[in]*/ IXMLDOMNode *pxdnNode = nullptr); HRESULT PutValue( /*[in]*/ const wchar_t *szTag, /*[in] */ const wchar_t *szValue, /*[out]*/ bool &fFound, - /*[in]*/ IXMLDOMNode *pxdnNode = NULL); + /*[in]*/ IXMLDOMNode *pxdnNode = nullptr); HRESULT RemoveAttribute( /*[in]*/ const wchar_t *szTag, /*[in]*/ const wchar_t *szAttr, - /*[in]*/ IXMLDOMNode *pxdnNode = NULL); - HRESULT RemoveValue(/*[in]*/ const wchar_t *szTag, /*[in]*/ IXMLDOMNode *pxdnNode = NULL); - HRESULT RemoveNode(/*[in]*/ const wchar_t *szTag, /*[in]*/ IXMLDOMNode *pxdnNode = NULL); + /*[in]*/ IXMLDOMNode *pxdnNode = nullptr); + HRESULT RemoveValue(/*[in]*/ const wchar_t *szTag, /*[in]*/ IXMLDOMNode *pxdnNode = nullptr); + HRESULT RemoveNode(/*[in]*/ const wchar_t *szTag, /*[in]*/ IXMLDOMNode *pxdnNode = nullptr); }; //--// @@ -338,6 +338,7 @@ struct CLR_RT_HeapBlock_Timer; struct CLR_RT_HeapBlock_WaitForObject; struct CLR_RT_HeapBlock_Finalizer; struct CLR_RT_HeapBlock_MemoryStream; +struct CLR_RT_HeapBlock_GenericInstance; struct CLR_RT_HeapCluster; struct CLR_RT_GarbageCollector; @@ -358,6 +359,8 @@ struct CLR_RT_TypeSpec_Instance; struct CLR_RT_TypeDef_Instance; struct CLR_RT_MethodDef_Instance; struct CLR_RT_FieldDef_Instance; +struct CLR_RT_GenericParam_Instance; +struct CLR_RT_MethodSpec_Instance; struct CLR_RT_StackFrame; struct CLR_RT_SubThread; @@ -498,8 +501,8 @@ struct CLR_PROF_Handler struct CLR_RT_MemoryRange { - unsigned char *m_location; - unsigned int m_size; + unsigned char *location; + unsigned int size; bool LimitToRange(CLR_RT_MemoryRange &filtered, unsigned char *address, unsigned int length) const; }; @@ -592,8 +595,8 @@ static const int MAXTYPENAMELEN = 256; // Including terminating null byte. Enfor //////////////////////////////////////////////////////////////////////////////////////////////////// -#define NANOCLR_INDEX_IS_VALID(idx) ((idx).m_data != 0) -#define NANOCLR_INDEX_IS_INVALID(idx) ((idx).m_data == 0) +#define NANOCLR_INDEX_IS_VALID(index) ((index).data != 0) +#define NANOCLR_INDEX_IS_INVALID(index) ((index).data == 0) // // IMPORTANT: THE ASSEMBLY IDX IN ALL THE CLR_RT_*_Index STRUCTURES SHOULD ALWAYS BE ENCODED THE SAME WAY!!! @@ -604,152 +607,245 @@ static const int MAXTYPENAMELEN = 256; // Including terminating null byte. Enfor struct CLR_RT_Assembly_Index { - CLR_UINT32 m_data; + CLR_UINT32 data; //--// void Clear() { - m_data = 0; + data = 0; } - void Set(CLR_UINT32 idxAssm) + void Set(CLR_UINT32 indexAssm) { - m_data = idxAssm << 16; + data = indexAssm << 24; } //--// - CLR_IDX Assembly() const + CLR_INDEX Assembly() const { - return (CLR_IDX)(m_data >> 16); + return (CLR_INDEX)(data >> 24); } }; struct CLR_RT_TypeSpec_Index { - CLR_UINT32 m_data; + CLR_UINT32 data; //--// void Clear() { - m_data = 0; + data = 0; } - void Set(CLR_UINT32 idxAssm, CLR_UINT32 idxType) + void Set(CLR_UINT32 indexAssm, CLR_UINT32 indexType) { - m_data = idxAssm << 16 | idxType; + data = indexAssm << 24 | indexType; } //--// - CLR_IDX Assembly() const + CLR_INDEX Assembly() const { - return (CLR_IDX)(m_data >> 16); + return (CLR_INDEX)(data >> 24); } - CLR_IDX TypeSpec() const + + CLR_INDEX TypeSpec() const { - return (CLR_IDX)(m_data); + return (CLR_INDEX)(data); } }; struct CLR_RT_TypeDef_Index { - CLR_UINT32 m_data; + CLR_UINT32 data; + + //--// + + void Clear() + { + data = 0; + } + + void Set(CLR_UINT32 indexAssm, CLR_UINT32 indexType) + { + data = indexAssm << 24 | indexType; + } + + //--// + + CLR_INDEX Assembly() const + { + return (CLR_INDEX)(data >> 24); + } + + CLR_INDEX Type() const + { + return (CLR_INDEX)(data); + } +}; + +struct CLR_RT_MethodSpec_Index +{ + CLR_UINT32 data; //--// void Clear() { - m_data = 0; + data = 0; } - void Set(CLR_UINT32 idxAssm, CLR_UINT32 idxType) + void Set(CLR_UINT32 indexAssm, CLR_UINT32 indexMethod) { - m_data = idxAssm << 16 | idxType; + data = indexAssm << 24 | indexMethod; } //--// - CLR_IDX Assembly() const + CLR_INDEX Assembly() const { - return (CLR_IDX)(m_data >> 16); + return (CLR_INDEX)(data >> 24); } - CLR_IDX Type() const + + CLR_INDEX Method() const { - return (CLR_IDX)(m_data); + return (data & 0x7FFF); } }; struct CLR_RT_FieldDef_Index { - CLR_UINT32 m_data; + CLR_UINT32 data; //--// void Clear() { - m_data = 0; + data = 0; } - void Set(CLR_UINT32 idxAssm, CLR_UINT32 idxField) + void Set(CLR_UINT32 indexAssm, CLR_UINT32 indexField) { - m_data = idxAssm << 16 | idxField; + data = indexAssm << 24 | indexField; } //--// - CLR_IDX Assembly() const + CLR_INDEX Assembly() const { - return (CLR_IDX)(m_data >> 16); + return (CLR_INDEX)(data >> 24); } - CLR_IDX Field() const + + CLR_INDEX Field() const { - return (CLR_IDX)(m_data); + return (CLR_INDEX)(data); } }; struct CLR_RT_MethodDef_Index { - CLR_UINT32 m_data; + CLR_UINT32 data; + + //--// + + void Clear() + { + data = 0; + } + + void Set(CLR_UINT32 indexAssm, CLR_UINT32 indexMethod) + { + data = indexAssm << 24 | indexMethod; + } + + //--// + + CLR_INDEX Assembly() const + { + return (CLR_INDEX)(data >> 24); + } + + CLR_INDEX Method() const + { + return (CLR_INDEX)(data); + } +}; + +struct CLR_RT_MethodRef_Index +{ + CLR_UINT32 data; //--// void Clear() { - m_data = 0; + data = 0; } - void Set(CLR_UINT32 idxAssm, CLR_UINT32 idxMethod) + void Set(CLR_UINT32 indexAssm, CLR_UINT32 indexMethod) { - m_data = idxAssm << 16 | idxMethod; + data = indexAssm << 24 | indexMethod; } //--// - CLR_IDX Assembly() const + CLR_INDEX Assembly() const { - return (CLR_IDX)(m_data >> 16); + return (CLR_INDEX)(data >> 24); } - CLR_IDX Method() const + + CLR_INDEX Method() const { - return (CLR_IDX)(m_data); + return (CLR_INDEX)(data); + } +}; + +struct CLR_RT_GenericParam_Index +{ + CLR_UINT32 data; + + //--// + + void Clear() + { + data = 0; + } + + void Set(CLR_UINT32 indexAssm, CLR_UINT32 indexGenericParam) + { + data = indexAssm << 24 | indexGenericParam; + } + + //--// + + CLR_INDEX Assembly() const + { + return (CLR_INDEX)(data >> 24); + } + + CLR_UINT8 GenericParam() const + { + return (CLR_UINT8)(data); } }; struct CLR_RT_ReflectionDef_Index { - CLR_UINT16 m_kind; // CLR_ReflectionType - CLR_UINT16 m_levels; + // CLR_ReflectionType + CLR_UINT16 kind; + CLR_UINT16 levels; union { - CLR_RT_Assembly_Index m_assm; - CLR_RT_TypeDef_Index m_type; - CLR_RT_MethodDef_Index m_method; - CLR_RT_FieldDef_Index m_field; - CLR_UINT32 m_raw; - } m_data; + CLR_RT_Assembly_Index assembly; + CLR_RT_TypeDef_Index type; + CLR_RT_MethodDef_Index method; + CLR_RT_FieldDef_Index field; + CLR_RT_TypeSpec_Index genericType; + CLR_UINT32 raw; + } data; //--// @@ -768,6 +864,7 @@ struct CLR_RT_ReflectionDef_Index static bool Convert(CLR_RT_HeapBlock &ref, CLR_RT_TypeDef_Instance &inst, CLR_UINT32 *levels); static bool Convert(CLR_RT_HeapBlock &ref, CLR_RT_MethodDef_Instance &inst); static bool Convert(CLR_RT_HeapBlock &ref, CLR_RT_FieldDef_Instance &inst); + static bool Convert(CLR_RT_HeapBlock &ref, CLR_RT_TypeSpec_Instance &inst); static bool Convert(CLR_RT_HeapBlock &ref, CLR_UINT32 &hash); }; @@ -775,27 +872,29 @@ struct CLR_RT_ReflectionDef_Index struct CLR_RT_AssemblyRef_CrossReference { - CLR_RT_Assembly *m_target; // EVENT HEAP - NO RELOCATION - + CLR_RT_Assembly *target; // EVENT HEAP - NO RELOCATION - }; struct CLR_RT_TypeRef_CrossReference { - CLR_RT_TypeDef_Index m_target; + CLR_RT_TypeDef_Index target; }; struct CLR_RT_FieldRef_CrossReference { - CLR_RT_FieldDef_Index m_target; + CLR_RT_FieldDef_Index target; + CLR_RT_TypeSpec_Index genericType; }; struct CLR_RT_MethodRef_CrossReference { - CLR_RT_MethodDef_Index m_target; + CLR_RT_MethodDef_Index target; + CLR_RT_TypeSpec_Index genericType; }; struct CLR_RT_FieldDef_CrossReference { - CLR_IDX m_offset; + CLR_INDEX offset; }; struct CLR_RT_TypeDef_CrossReference @@ -804,9 +903,9 @@ struct CLR_RT_TypeDef_CrossReference static const CLR_UINT32 TD_CR_HasFinalizer = 0x0002; static const CLR_UINT32 TD_CR_IsMarshalByRefObject = 0x0004; - CLR_UINT16 m_flags; - CLR_IDX m_totalFields; - CLR_UINT32 m_hash; + CLR_UINT16 flags; + CLR_INDEX totalFields; + CLR_UINT32 hash; }; struct CLR_RT_MethodDef_CrossReference @@ -814,18 +913,61 @@ struct CLR_RT_MethodDef_CrossReference static const CLR_UINT16 MD_CR_Patched = 0x8000; static const CLR_UINT16 MD_CR_OwnerMask = 0x7FFF; - CLR_UINT16 m_data; + CLR_UINT16 data; - CLR_IDX GetOwner() const + CLR_INDEX GetOwner() const { - return (CLR_IDX)(m_data); + return (CLR_INDEX)(data); } }; +struct CLR_RT_GenericParam_CrossReference +{ + /// @brief Generic Parameter Owner -> Index to TypeDef or MethodDef + /// + CLR_UINT16 data; + + /// @brief Tag for owner (TypeDef or MethodDef) + /// + NanoCLRTable typeOrMethodDef; + + /// @brief DataType for the generic parameter + /// + NanoCLRDataType dataType; + + /// @brief Class of the generic parameter + /// + CLR_RT_TypeDef_Index classTypeDef; + + CLR_RT_GenericParam_Index m_target; +}; + +struct CLR_RT_MethodSpec_CrossReference +{ + CLR_RT_TypeSpec_Index genericType; + + CLR_RT_MethodDef_Index methodDef; + CLR_RT_MethodRef_Index methodRef; + + CLR_INDEX signature; + + CLR_UINT16 data; + + // CLR_INDEX GetMethod() const + //{ + // return (CLR_INDEX)(m_data); + // } +}; + +struct CLR_RT_TypeSpec_CrossReference +{ + CLR_RT_TypeSpec_Index genericType; +}; + struct CLR_RT_MethodDef_Patch { - CLR_IDX m_orig; - CLR_IDX m_patched; + CLR_INDEX original; + CLR_INDEX patched; }; #if defined(NANOCLR_ENABLE_SOURCELEVELDEBUGGING) @@ -835,7 +977,7 @@ struct CLR_RT_MethodDef_DebuggingInfo static const CLR_UINT8 MD_DI_JustMyCode = 0x01; static const CLR_UINT8 MD_DI_HasBreakpoint = 0x02; - CLR_UINT8 m_flags; + CLR_UINT8 flags; bool IsJMC() const { @@ -856,24 +998,24 @@ struct CLR_RT_MethodDef_DebuggingInfo } private: - void SetFlags(CLR_UINT8 flags) + void SetFlags(CLR_UINT8 newFlags) { - m_flags |= flags; + flags |= newFlags; } - void ResetFlags(CLR_UINT8 flags) + void ResetFlags(CLR_UINT8 newFlags) { - m_flags &= ~flags; + flags &= ~newFlags; } - bool IsFlagSet(CLR_UINT8 flags) const + bool IsFlagSet(CLR_UINT8 newFlags) const { - return (m_flags & flags) != 0; + return (flags & newFlags) != 0; } - void SetResetFlags(bool b, CLR_UINT8 flags) + void SetResetFlags(bool b, CLR_UINT8 newFlags) { if (b) - SetFlags(flags); + SetFlags(newFlags); else - ResetFlags(flags); + ResetFlags(newFlags); } }; @@ -881,7 +1023,7 @@ struct CLR_RT_MethodDef_DebuggingInfo //////////////////////////////////////////////////////////////////////////////////////////////////// -#include +#include "nanoCLR_Runtime__HeapBlock.h" // TODO: Change this to an extern method that is defined in the HAL #if defined(PLATFORM_WINDOWS_EMULATOR) @@ -1019,40 +1161,67 @@ struct CLR_RT_SignatureParser static const int c_Method = 3; static const int c_Locals = 4; static const int c_Object = 5; + static const int c_GenericParamType = 6; + static const int c_MethodSpec = 7; struct Element { - bool m_fByRef; - int m_levels; - CLR_DataType m_dt; - CLR_RT_TypeDef_Index m_cls; + bool IsByRef; + int Levels; + NanoCLRDataType DataType; + CLR_RT_TypeDef_Index Class; + CLR_RT_TypeSpec_Index TypeSpec; + + /// @brief Generic Parameter position + CLR_INDEX GenericParamPosition; }; - CLR_RT_HeapBlock *m_lst; - CLR_RT_Assembly *m_assm; - CLR_PMETADATA m_sig; + CLR_RT_HeapBlock *ObjectList; + CLR_RT_Assembly *Assembly; + CLR_PMETADATA Signature; - int m_type; - CLR_UINT32 m_flags; - int m_count; + /// @brief Signature type being processed, from the constants. + int Type; + + /// @brief Flags for signature parsing. For methods this is the ECMA-335 calling convention. + CLR_UINT8 Flags; + + /// @brief Parameters count + int ParamCount; + + /// @brief Signature is from a GenericInstance + bool IsGenericInst; + + /// @brief Generic parameters count + int GenParamCount; + + /// @brief Index into MetodDef table + CLR_INDEX Method; //--// + void Initialize_TypeSpec(CLR_RT_Assembly *assm, CLR_PMETADATA ts); void Initialize_TypeSpec(CLR_RT_Assembly *assm, const CLR_RECORD_TYPESPEC *ts); + void Initialize_Interfaces(CLR_RT_Assembly *assm, const CLR_RECORD_TYPEDEF *td); - void Initialize_FieldDef(CLR_RT_Assembly *assm, const CLR_RECORD_FIELDDEF *fd); - void Initialize_MethodSignature(CLR_RT_Assembly *assm, const CLR_RECORD_METHODDEF *md); void Initialize_MethodLocals(CLR_RT_Assembly *assm, const CLR_RECORD_METHODDEF *md); + bool Initialize_GenericParamTypeSignature(CLR_RT_Assembly *assm, const CLR_RECORD_GENERICPARAM *gp); - void Initialize_TypeSpec(CLR_RT_Assembly *assm, CLR_PMETADATA ts); + void Initialize_FieldDef(CLR_RT_Assembly *assm, const CLR_RECORD_FIELDDEF *fd); void Initialize_FieldDef(CLR_RT_Assembly *assm, CLR_PMETADATA fd); + + void Initialize_FieldSignature(CLR_RT_Assembly *assm, CLR_PMETADATA md); + + void Initialize_MethodSignature(CLR_RT_Assembly *assm, const CLR_RECORD_METHODDEF *md); void Initialize_MethodSignature(CLR_RT_Assembly *assm, CLR_PMETADATA md); + void Initialize_MethodSignature(CLR_RT_MethodDef_Instance *mdInstance); + void Initialize_MethodSignature(CLR_RT_MethodSpec_Instance *msInstance); void Initialize_Objects(CLR_RT_HeapBlock *lst, int count, bool fTypes); int Available() const { - return m_count; + return ParamCount; } HRESULT Advance(Element &res); @@ -1077,10 +1246,10 @@ struct CLR_RT_SignatureParser { \ CLR_RT_Assembly **ppASSM = (ts).m_assemblies; \ size_t iASSM = ARRAYSIZE((ts).m_assemblies); \ - CLR_IDX idx = 1; \ - for (; iASSM--; ppASSM++, idx++) \ + CLR_INDEX index = 1; \ + for (; iASSM--; ppASSM++, index++) \ { \ - if (*ppASSM == NULL) + if (*ppASSM == nullptr) #define NANOCLR_FOREACH_ASSEMBLY_NULL_END() \ } \ @@ -1117,21 +1286,24 @@ struct CLR_RT_Assembly : public CLR_RT_HeapBlock_Node // EVENT HEAP - NO RELOCAT { struct Offsets { - size_t iBase; - size_t iAssemblyRef; - size_t iTypeRef; - size_t iFieldRef; - size_t iMethodRef; - size_t iTypeDef; - size_t iFieldDef; - size_t iMethodDef; + size_t base; + size_t assemblyRef; + size_t typeRef; + size_t fieldRef; + size_t methodRef; + size_t typeDef; + size_t fieldDef; + size_t methodDef; + size_t genericParam; + size_t methodSpec; + size_t typeSpec; #if !defined(NANOCLR_APPDOMAINS) - size_t iStaticFields; + size_t staticFieldsCount; #endif #if defined(NANOCLR_ENABLE_SOURCELEVELDEBUGGING) - size_t iDebuggingInfoMethods; + size_t debuggingInfoMethods; #endif // #if defined(NANOCLR_ENABLE_SOURCELEVELDEBUGGING) }; @@ -1151,51 +1323,62 @@ struct CLR_RT_Assembly : public CLR_RT_HeapBlock_Node // EVENT HEAP - NO RELOCAT // this flag should be set when the m_header was malloc'ed static const CLR_UINT32 FreeOnDestroy = 0x00000100; - CLR_UINT32 m_idx; // Relative to the type system (for static fields access). - CLR_UINT32 m_flags; + // Relative to the type system (for static fields access). + CLR_UINT32 assemblyIndex; + CLR_UINT32 flags; - const CLR_RECORD_ASSEMBLY *m_header; // ANY HEAP - DO RELOCATION - - const char *m_szName; // ANY HEAP - DO RELOCATION - + // ANY HEAP - DO RELOCATION - + const CLR_RECORD_ASSEMBLY *header; + // ANY HEAP - DO RELOCATION - + const char *name; - const CLR_RT_MethodHandler *m_nativeCode; + const CLR_RT_MethodHandler *nativeCode; - int m_pTablesSize[TBL_Max]; + int tablesSize[TBL_Max]; #if !defined(NANOCLR_APPDOMAINS) - CLR_RT_HeapBlock *m_pStaticFields; // EVENT HEAP - NO RELOCATION - (but the data they point to has to be relocated) + // EVENT HEAP - NO RELOCATION - (but the data they point to has to be relocated) + CLR_RT_HeapBlock *staticFields; #endif - int m_iStaticFields; - - CLR_RT_HeapBlock_Array *m_pFile; // ANY HEAP - DO RELOCATION - - - CLR_RT_AssemblyRef_CrossReference - *m_pCrossReference_AssemblyRef; // EVENT HEAP - NO RELOCATION - (but the data they point to has to be relocated) - CLR_RT_TypeRef_CrossReference - *m_pCrossReference_TypeRef; // EVENT HEAP - NO RELOCATION - (but the data they point to has to be relocated) - CLR_RT_FieldRef_CrossReference - *m_pCrossReference_FieldRef; // EVENT HEAP - NO RELOCATION - (but the data they point to has to be relocated) - CLR_RT_MethodRef_CrossReference - *m_pCrossReference_MethodRef; // EVENT HEAP - NO RELOCATION - (but the data they point to has to be relocated) - CLR_RT_TypeDef_CrossReference - *m_pCrossReference_TypeDef; // EVENT HEAP - NO RELOCATION - (but the data they point to has to be relocated) - CLR_RT_FieldDef_CrossReference - *m_pCrossReference_FieldDef; // EVENT HEAP - NO RELOCATION - (but the data they point to has to be relocated) - CLR_RT_MethodDef_CrossReference - *m_pCrossReference_MethodDef; // EVENT HEAP - NO RELOCATION - (but the data they point to has to be relocated) + int staticFieldsCount; + + // ANY HEAP - DO RELOCATION - + CLR_RT_HeapBlock_Array *file; + + // EVENT HEAP - NO RELOCATION - (but the data they point to has to be relocated) + CLR_RT_AssemblyRef_CrossReference *crossReferenceAssemblyRef; + // EVENT HEAP - NO RELOCATION - (but the data they point to has to be relocated) + CLR_RT_TypeRef_CrossReference *crossReferenceTypeRef; + // EVENT HEAP - NO RELOCATION - (but the data they point to has to be relocated) + CLR_RT_FieldRef_CrossReference *crossReferenceFieldRef; + // EVENT HEAP - NO RELOCATION - (but the data they point to has to be relocated) + CLR_RT_MethodRef_CrossReference *crossReferenceMethodRef; + // EVENT HEAP - NO RELOCATION - (but the data they point to has to be relocated) + CLR_RT_TypeDef_CrossReference *crossReferenceTypeDef; + // EVENT HEAP - NO RELOCATION - (but the data they point to has to be relocated) + CLR_RT_FieldDef_CrossReference *crossReferenceFieldDef; + // EVENT HEAP - NO RELOCATION - (but the data they point to has to be relocated) + CLR_RT_MethodDef_CrossReference *crossReferenceMethodDef; + // EVENT HEAP - NO RELOCATION - (but the data they point to has to be relocated) + CLR_RT_GenericParam_CrossReference *crossReferenceGenericParam; + // EVENT HEAP - NO RELOCATION - (but the data they point to has to be relocated) + CLR_RT_MethodSpec_CrossReference *crossReferenceMethodSpec; + // EVENT HEAP - NO RELOCATION - (but the data they point to has to be relocated) + CLR_RT_TypeSpec_CrossReference *crossReferenceTypeSpec; #if defined(NANOCLR_ENABLE_SOURCELEVELDEBUGGING) - CLR_RT_MethodDef_DebuggingInfo - *m_pDebuggingInfo_MethodDef; // EVENT HEAP - NO RELOCATION - (but the data they point to has to be relocated) -#endif // #if defined(NANOCLR_ENABLE_SOURCELEVELDEBUGGING) + // EVENT HEAP - NO RELOCATION - (but the data they point to has to be relocated) + CLR_RT_MethodDef_DebuggingInfo *debuggingInfoMethodDef; +#endif // NANOCLR_ENABLE_SOURCELEVELDEBUGGING #if defined(NANOCLR_TRACE_STACK_HEAVY) && defined(VIRTUAL_DEVICE) - int m_maxOpcodes; - int *m_stackDepth; + int maxOpcodes; + int *stackDepth; #endif #if defined(VIRTUAL_DEVICE) - std::string *m_strPath; + std::string *path; #endif //--// @@ -1216,43 +1399,70 @@ struct CLR_RT_Assembly : public CLR_RT_HeapBlock_Node // EVENT HEAP - NO RELOCAT static HRESULT CreateInstance(const CLR_RECORD_ASSEMBLY *data, CLR_RT_Assembly *&assm); void DestroyInstance(); - void Assembly_Initialize(CLR_RT_Assembly::Offsets &offsets); + void AssemblyInitialize(CLR_RT_Assembly::Offsets &offsets); - bool Resolve_AssemblyRef(bool fOutput); - HRESULT Resolve_TypeRef(); - HRESULT Resolve_FieldRef(); - HRESULT Resolve_MethodRef(); - void Resolve_TypeDef(); - void Resolve_MethodDef(); - void Resolve_Link(); - HRESULT Resolve_ComputeHashes(); - HRESULT Resolve_AllocateStaticFields(CLR_RT_HeapBlock *pStaticFields); + bool ResolveAssemblyRef(bool fOutput); + HRESULT ResolveTypeRef(); + HRESULT ResolveFieldRef(); + HRESULT ResolveMethodRef(); + HRESULT ResolveTypeSpec(); + void ResolveTypeDef(); + void ResolveMethodDef(); + void ResolveLink(); + HRESULT ResolveComputeHashes(); + HRESULT ResolveAllocateStaticFields(CLR_RT_HeapBlock *pStaticFields); HRESULT PrepareForExecution(); CLR_UINT32 ComputeAssemblyHash(); CLR_UINT32 ComputeAssemblyHash(const CLR_RECORD_ASSEMBLYREF *ar); - bool FindTypeDef(const char *name, const char *nameSpace, CLR_RT_TypeDef_Index &idx); - bool FindTypeDef(const char *name, CLR_IDX scope, CLR_RT_TypeDef_Index &idx); - bool FindTypeDef(CLR_UINT32 hash, CLR_RT_TypeDef_Index &idx); + bool FindTypeDef(const char *name, const char *nameSpace, CLR_RT_TypeDef_Index &index); + bool FindTypeDef(const char *name, CLR_INDEX scope, CLR_RT_TypeDef_Index &index); + bool FindTypeDef(CLR_UINT32 hash, CLR_RT_TypeDef_Index &index); + + bool FindTypeSpec(const CLR_PMETADATA sig, CLR_RT_TypeSpec_Index &index); + + bool FindGenericParamAtTypeSpec( + CLR_RT_MethodDef_Instance md, + CLR_UINT32 genericParameterPosition, + CLR_RT_TypeDef_Index &index, + NanoCLRDataType &dataType); + bool FindGenericParamAtMethodDef( + CLR_RT_MethodDef_Instance md, + CLR_UINT32 genericParameterPosition, + CLR_RT_GenericParam_Index &index); + bool FindGenericParam(CLR_INDEX typeSpecIndex, CLR_RT_GenericParam_Index &index); + bool FindMethodSpecFromTypeSpec(CLR_INDEX typeSpecIndex, CLR_RT_MethodSpec_Index &index); bool FindFieldDef( const CLR_RECORD_TYPEDEF *src, const char *name, CLR_RT_Assembly *base, CLR_SIG sig, - CLR_RT_FieldDef_Index &idx); + CLR_RT_FieldDef_Index &index); + bool FindFieldDef( + const CLR_RECORD_TYPESPEC *ts, + const char *name, + CLR_RT_Assembly *base, + CLR_SIG sig, + CLR_RT_FieldDef_Index &index); bool FindMethodDef( const CLR_RECORD_TYPEDEF *src, const char *name, CLR_RT_Assembly *base, CLR_SIG sig, - CLR_RT_MethodDef_Index &idx); + CLR_RT_MethodDef_Index &index); + bool FindMethodDef( + const CLR_RECORD_TYPESPEC *ts, + const char *name, + CLR_RT_Assembly *base, + CLR_SIG sig, + CLR_RT_MethodDef_Index &index); - bool FindNextStaticConstructor(CLR_RT_MethodDef_Index &idx); + bool FindNextStaticConstructor(CLR_RT_MethodDef_Index &index); - bool FindMethodBoundaries(CLR_IDX i, CLR_OFFSET &start, CLR_OFFSET &end); + bool FindMethodBoundaries(CLR_INDEX i, CLR_OFFSET &start, CLR_OFFSET &end); void Relocate(); @@ -1262,67 +1472,75 @@ struct CLR_RT_Assembly : public CLR_RT_HeapBlock_Node // EVENT HEAP - NO RELOCAT //--// - CLR_PMETADATA GetTable(CLR_TABLESENUM tbl) + CLR_PMETADATA GetTable(NanoCLRTable tbl) const { - return (CLR_PMETADATA)m_header + m_header->startOfTables[tbl]; + return (CLR_PMETADATA)header + header->startOfTables[tbl]; } -#define NANOCLR_ASSEMBLY_RESOLVE(cls, tbl, idx) \ - (const cls *)((CLR_UINT8 *)m_header + m_header->startOfTables[tbl] + (sizeof(cls) * idx)) - const CLR_RECORD_ASSEMBLYREF *GetAssemblyRef(CLR_IDX i) +#define NANOCLR_ASSEMBLY_RESOLVE(cls, tbl, index) \ + (const cls *)((CLR_UINT8 *)header + header->startOfTables[tbl] + (sizeof(cls) * index)) + const CLR_RECORD_ASSEMBLYREF *GetAssemblyRef(CLR_INDEX i) const { return NANOCLR_ASSEMBLY_RESOLVE(CLR_RECORD_ASSEMBLYREF, TBL_AssemblyRef, i); } - const CLR_RECORD_TYPEREF *GetTypeRef(CLR_IDX i) + const CLR_RECORD_TYPEREF *GetTypeRef(CLR_INDEX i) const { return NANOCLR_ASSEMBLY_RESOLVE(CLR_RECORD_TYPEREF, TBL_TypeRef, i); } - const CLR_RECORD_FIELDREF *GetFieldRef(CLR_IDX i) + const CLR_RECORD_FIELDREF *GetFieldRef(CLR_INDEX i) const { return NANOCLR_ASSEMBLY_RESOLVE(CLR_RECORD_FIELDREF, TBL_FieldRef, i); } - const CLR_RECORD_METHODREF *GetMethodRef(CLR_IDX i) + const CLR_RECORD_METHODREF *GetMethodRef(CLR_INDEX i) const { return NANOCLR_ASSEMBLY_RESOLVE(CLR_RECORD_METHODREF, TBL_MethodRef, i); } - const CLR_RECORD_TYPEDEF *GetTypeDef(CLR_IDX i) + const CLR_RECORD_TYPEDEF *GetTypeDef(CLR_INDEX i) const { return NANOCLR_ASSEMBLY_RESOLVE(CLR_RECORD_TYPEDEF, TBL_TypeDef, i); } - const CLR_RECORD_FIELDDEF *GetFieldDef(CLR_IDX i) + const CLR_RECORD_FIELDDEF *GetFieldDef(CLR_INDEX i) const { return NANOCLR_ASSEMBLY_RESOLVE(CLR_RECORD_FIELDDEF, TBL_FieldDef, i); } - const CLR_RECORD_METHODDEF *GetMethodDef(CLR_IDX i) + const CLR_RECORD_METHODDEF *GetMethodDef(CLR_INDEX i) const { return NANOCLR_ASSEMBLY_RESOLVE(CLR_RECORD_METHODDEF, TBL_MethodDef, i); } - const CLR_RECORD_ATTRIBUTE *GetAttribute(CLR_IDX i) + const CLR_RECORD_GENERICPARAM *GetGenericParam(CLR_INDEX i) const + { + return NANOCLR_ASSEMBLY_RESOLVE(CLR_RECORD_GENERICPARAM, TBL_GenericParam, i); + } + const CLR_RECORD_METHODSPEC *GetMethodSpec(CLR_INDEX i) const + { + return NANOCLR_ASSEMBLY_RESOLVE(CLR_RECORD_METHODSPEC, TBL_MethodSpec, i); + } + const CLR_RECORD_ATTRIBUTE *GetAttribute(CLR_INDEX i) const { return NANOCLR_ASSEMBLY_RESOLVE(CLR_RECORD_ATTRIBUTE, TBL_Attributes, i); } - const CLR_RECORD_TYPESPEC *GetTypeSpec(CLR_IDX i) + const CLR_RECORD_TYPESPEC *GetTypeSpec(CLR_INDEX i) const { return NANOCLR_ASSEMBLY_RESOLVE(CLR_RECORD_TYPESPEC, TBL_TypeSpec, i); } - const CLR_RECORD_RESOURCE_FILE *GetResourceFile(CLR_IDX i) + const CLR_RECORD_RESOURCE_FILE *GetResourceFile(CLR_INDEX i) const { return NANOCLR_ASSEMBLY_RESOLVE(CLR_RECORD_RESOURCE_FILE, TBL_ResourcesFiles, i); } - const CLR_RECORD_RESOURCE *GetResource(CLR_IDX i) + const CLR_RECORD_RESOURCE *GetResource(CLR_INDEX i) const { return NANOCLR_ASSEMBLY_RESOLVE(CLR_RECORD_RESOURCE, TBL_Resources, i); } - CLR_PMETADATA GetResourceData(CLR_UINT32 i) + CLR_PMETADATA GetResourceData(CLR_UINT32 i) const { return NANOCLR_ASSEMBLY_RESOLVE(CLR_UINT8, TBL_ResourcesData, i); } const char *GetString(CLR_STRING i); - CLR_PMETADATA GetSignature(CLR_SIG i) + CLR_PMETADATA GetSignature(CLR_SIG i) const { return NANOCLR_ASSEMBLY_RESOLVE(CLR_UINT8, TBL_Signatures, i); } - CLR_PMETADATA GetByteCode(CLR_OFFSET i) + CLR_PMETADATA GetByteCode(CLR_OFFSET i) const { return NANOCLR_ASSEMBLY_RESOLVE(CLR_UINT8, TBL_ByteCode, i); } @@ -1349,59 +1567,15 @@ struct CLR_RT_Assembly : public CLR_RT_HeapBlock_Node // EVENT HEAP - NO RELOCAT void DumpSignature(CLR_SIG sig) DECL_POSTFIX; void DumpSignature(CLR_PMETADATA &p) DECL_POSTFIX; void DumpSignatureToken(CLR_PMETADATA &p) DECL_POSTFIX; + void DumpFieldOwner(CLR_UINT32 index) DECL_POSTFIX; + void DumpMethodOwner(CLR_UINT32 index) DECL_POSTFIX; //--// #if defined(VIRTUAL_DEVICE) static FILE *s_output; static FILE *s_toclose; - - public: - static void Dump_SetDevice(FILE *&outputDeviceFile, const wchar_t *szFileName); - static void Dump_SetDevice(const wchar_t *szFileName); - - static void Dump_CloseDevice(FILE *&outputDeviceFile); - static void Dump_CloseDevice(); - - static void Dump_Printf(FILE *outputDeviceFile, const char *format, ...); - static void Dump_Printf(const char *format, ...); - - static void Dump_Indent(const CLR_RECORD_METHODDEF *md, size_t offset, size_t level); - - void Dump(bool fNoByteCode); - - unsigned int GenerateSignatureForNativeMethods(); - - bool AreInternalMethodsPresent(const CLR_RECORD_TYPEDEF *td); - void GenerateSkeleton(const wchar_t *szFileName, const wchar_t *szProjectName); - void GenerateSkeletonFromComplientNames(const wchar_t *szFileName, const wchar_t *szProjectName); - - void BuildParametersList(CLR_PMETADATA pMetaData, CLR_RT_VectorOfManagedElements &elemPtrArray); - void GenerateSkeletonStubFieldsDef( - const CLR_RECORD_TYPEDEF *pClsType, - FILE *pFileStubHead, - std::string strIndent, - std::string strMngClassName); - void GenerateSkeletonStubCode(const wchar_t *szFilePath, FILE *pFileDotNetProj); - - void BuildMethodName_NoInterop(const CLR_RECORD_METHODDEF *md, std::string &name, CLR_RT_StringMap &mapMethods); - void GenerateSkeleton_NoInterop(LPCWSTR szFileName, LPCWSTR szProjectName); - - void BuildMethodName(const CLR_RECORD_METHODDEF *md, std::string &name, CLR_RT_StringMap &mapMethods); - void BuildClassName(const CLR_RECORD_TYPEREF *tr, std::string &cls_name, bool fEscape); - void BuildClassName(const CLR_RECORD_TYPEDEF *td, std::string &cls_name, bool fEscape); - void BuildTypeName(const CLR_RECORD_TYPEDEF *td, std::string &type_name); - -#endif - private: -#if defined(VIRTUAL_DEVICE) - void Dump_Token(CLR_UINT32 tk); - void Dump_FieldOwner(CLR_UINT32 idx); - void Dump_MethodOwner(CLR_UINT32 idx); - void Dump_Signature(CLR_SIG sig); - void Dump_Signature(CLR_PMETADATA &p); - void Dump_SignatureToken(CLR_PMETADATA &p); -#endif +#endif // VIRTUAL_DEVICE //--// @@ -1411,8 +1585,7 @@ struct CLR_RT_Assembly : public CLR_RT_HeapBlock_Node // EVENT HEAP - NO RELOCAT private: CLR_UINT32 ComputeHashForName(const CLR_RT_TypeDef_Index &td, CLR_UINT32 hash); - - static CLR_UINT32 ComputeHashForType(CLR_DataType dt, CLR_UINT32 hash); + static CLR_UINT32 ComputeHashForType(NanoCLRDataType dt, CLR_UINT32 hash); }; #ifdef __GNUC__ @@ -1453,15 +1626,15 @@ struct CLR_RT_AppDomain : public CLR_RT_ObjectToEvent_Destination // EVENT HEAP CLR_RT_AppDomainAssembly *FindAppDomainAssembly(CLR_RT_Assembly *assm); - HRESULT MarshalObject(CLR_RT_HeapBlock &src, CLR_RT_HeapBlock &dst, CLR_RT_AppDomain *appDomainSrc = NULL); + HRESULT MarshalObject(CLR_RT_HeapBlock &src, CLR_RT_HeapBlock &dst, CLR_RT_AppDomain *appDomainSrc = nullptr); HRESULT MarshalParameters( CLR_RT_HeapBlock *callerArgs, CLR_RT_HeapBlock *calleeArgs, int count, bool fOnReturn, - CLR_RT_AppDomain *appDomainSrc = NULL); + CLR_RT_AppDomain *appDomainSrc = nullptr); - HRESULT VerifyTypeIsLoaded(const CLR_RT_TypeDef_Index &idx); + HRESULT VerifyTypeIsLoaded(const CLR_RT_TypeDef_Index &index); HRESULT GetAssemblies(CLR_RT_HeapBlock &ref); HRESULT LoadAssembly(CLR_RT_Assembly *assm); HRESULT GetManagedObject(CLR_RT_HeapBlock &obj); @@ -1493,94 +1666,94 @@ struct CLR_RT_AppDomainAssembly : public CLR_RT_HeapBlock_Node // EVENT HEAP - N struct CLR_RT_WellKnownTypes { - CLR_RT_TypeDef_Index m_Boolean; - CLR_RT_TypeDef_Index m_Int8; - CLR_RT_TypeDef_Index m_UInt8; - - CLR_RT_TypeDef_Index m_Char; - CLR_RT_TypeDef_Index m_Int16; - CLR_RT_TypeDef_Index m_UInt16; - - CLR_RT_TypeDef_Index m_Int32; - CLR_RT_TypeDef_Index m_UInt32; - CLR_RT_TypeDef_Index m_Single; - - CLR_RT_TypeDef_Index m_Int64; - CLR_RT_TypeDef_Index m_UInt64; - CLR_RT_TypeDef_Index m_Double; - CLR_RT_TypeDef_Index m_DateTime; - CLR_RT_TypeDef_Index m_TimeSpan; - CLR_RT_TypeDef_Index m_String; - - CLR_RT_TypeDef_Index m_Void; - CLR_RT_TypeDef_Index m_Object; - CLR_RT_TypeDef_Index m_ValueType; - CLR_RT_TypeDef_Index m_Enum; - - CLR_RT_TypeDef_Index m_AppDomainUnloadedException; - CLR_RT_TypeDef_Index m_ArgumentNullException; - CLR_RT_TypeDef_Index m_ArgumentException; - CLR_RT_TypeDef_Index m_ArgumentOutOfRangeException; - CLR_RT_TypeDef_Index m_Exception; - CLR_RT_TypeDef_Index m_IndexOutOfRangeException; - CLR_RT_TypeDef_Index m_ThreadAbortException; - CLR_RT_TypeDef_Index m_InvalidOperationException; - CLR_RT_TypeDef_Index m_InvalidCastException; - CLR_RT_TypeDef_Index m_FormatException; - CLR_RT_TypeDef_Index m_NotSupportedException; - CLR_RT_TypeDef_Index m_NotImplementedException; - CLR_RT_TypeDef_Index m_NullReferenceException; - CLR_RT_TypeDef_Index m_OutOfMemoryException; - CLR_RT_TypeDef_Index m_TimeoutException; - CLR_RT_TypeDef_Index m_ObjectDisposedException; - CLR_RT_TypeDef_Index m_ConstraintException; - CLR_RT_TypeDef_Index m_WatchdogException; - - CLR_RT_TypeDef_Index m_Delegate; - CLR_RT_TypeDef_Index m_MulticastDelegate; - - CLR_RT_TypeDef_Index m_Array; - CLR_RT_TypeDef_Index m_ArrayList; - CLR_RT_TypeDef_Index m_ICloneable; - CLR_RT_TypeDef_Index m_IList; - - CLR_RT_TypeDef_Index m_Assembly; - CLR_RT_TypeDef_Index m_TypeStatic; - CLR_RT_TypeDef_Index m_Type; - CLR_RT_TypeDef_Index m_ConstructorInfo; - CLR_RT_TypeDef_Index m_MethodInfo; - CLR_RT_TypeDef_Index m_FieldInfo; - - CLR_RT_TypeDef_Index m_WeakReference; - - CLR_RT_TypeDef_Index m_Guid; - - CLR_RT_TypeDef_Index m_SerializationHintsAttribute; - CLR_RT_TypeDef_Index m_Bitmap; - CLR_RT_TypeDef_Index m_Font; - - CLR_RT_TypeDef_Index m_TouchEvent; - CLR_RT_TypeDef_Index m_TouchInput; - - CLR_RT_TypeDef_Index m_NetworkInterface; - CLR_RT_TypeDef_Index m_Wireless80211Configuration; - CLR_RT_TypeDef_Index m_WirelessAPConfiguration; - CLR_RT_TypeDef_Index m_WirelessAPStation; + CLR_RT_TypeDef_Index Boolean; + CLR_RT_TypeDef_Index Int8; + CLR_RT_TypeDef_Index UInt8; + + CLR_RT_TypeDef_Index Char; + CLR_RT_TypeDef_Index Int16; + CLR_RT_TypeDef_Index UInt16; + + CLR_RT_TypeDef_Index Int32; + CLR_RT_TypeDef_Index UInt32; + CLR_RT_TypeDef_Index Single; + + CLR_RT_TypeDef_Index Int64; + CLR_RT_TypeDef_Index UInt64; + CLR_RT_TypeDef_Index Double; + CLR_RT_TypeDef_Index DateTime; + CLR_RT_TypeDef_Index TimeSpan; + CLR_RT_TypeDef_Index String; + + // need this prefix to disambiguate type in TI plaform + CLR_RT_TypeDef_Index n_Void; + CLR_RT_TypeDef_Index Object; + CLR_RT_TypeDef_Index ValueType; + CLR_RT_TypeDef_Index Enum; + + CLR_RT_TypeDef_Index AppDomainUnloadedException; + CLR_RT_TypeDef_Index ArgumentNullException; + CLR_RT_TypeDef_Index ArgumentException; + CLR_RT_TypeDef_Index ArgumentOutOfRangeException; + CLR_RT_TypeDef_Index Exception; + CLR_RT_TypeDef_Index IndexOutOfRangeException; + CLR_RT_TypeDef_Index ThreadAbortException; + CLR_RT_TypeDef_Index InvalidOperationException; + CLR_RT_TypeDef_Index InvalidCastException; + CLR_RT_TypeDef_Index FormatException; + CLR_RT_TypeDef_Index NotSupportedException; + CLR_RT_TypeDef_Index NotImplementedException; + CLR_RT_TypeDef_Index NullReferenceException; + CLR_RT_TypeDef_Index OutOfMemoryException; + CLR_RT_TypeDef_Index TimeoutException; + CLR_RT_TypeDef_Index ObjectDisposedException; + CLR_RT_TypeDef_Index ConstraintException; + CLR_RT_TypeDef_Index WatchdogException; + + CLR_RT_TypeDef_Index Delegate; + CLR_RT_TypeDef_Index MulticastDelegate; + + CLR_RT_TypeDef_Index Array; + CLR_RT_TypeDef_Index ArrayList; + CLR_RT_TypeDef_Index ICloneable; + CLR_RT_TypeDef_Index IList; + + CLR_RT_TypeDef_Index Assembly; + CLR_RT_TypeDef_Index TypeStatic; + CLR_RT_TypeDef_Index Type; + CLR_RT_TypeDef_Index ConstructorInfo; + CLR_RT_TypeDef_Index MethodInfo; + CLR_RT_TypeDef_Index FieldInfo; + + CLR_RT_TypeDef_Index WeakReference; + + CLR_RT_TypeDef_Index Guid; + + CLR_RT_TypeDef_Index SerializationHintsAttribute; + CLR_RT_TypeDef_Index Bitmap; + CLR_RT_TypeDef_Index Font; + + CLR_RT_TypeDef_Index TouchEvent; + CLR_RT_TypeDef_Index TouchInput; + + CLR_RT_TypeDef_Index NetworkInterface; + CLR_RT_TypeDef_Index Wireless80211Configuration; + CLR_RT_TypeDef_Index WirelessAPConfiguration; + CLR_RT_TypeDef_Index WirelessAPStation; #if defined(NANOCLR_APPDOMAINS) CLR_RT_TypeDef_Index m_AppDomain; CLR_RT_TypeDef_Index m_MarshalByRefObject; #endif - CLR_RT_TypeDef_Index m_Thread; - CLR_RT_TypeDef_Index m_ResourceManager; + CLR_RT_TypeDef_Index Thread; + CLR_RT_TypeDef_Index ResourceManager; - CLR_RT_TypeDef_Index m_SocketException; + CLR_RT_TypeDef_Index SocketException; - CLR_RT_TypeDef_Index m_I2cTransferResult; - CLR_RT_TypeDef_Index m_I2cTransferResult_old; + CLR_RT_TypeDef_Index I2cTransferResult; - CLR_RT_TypeDef_Index m_RmtCommand; + CLR_RT_TypeDef_Index RmtCommand; PROHIBIT_COPY_CONSTRUCTORS(CLR_RT_WellKnownTypes); }; @@ -1601,31 +1774,44 @@ extern CLR_RT_WellKnownMethods g_CLR_RT_WellKnownMethods; typedef void (CLR_RT_HeapBlock::*CLR_RT_HeapBlockRelocate)(); +// clang-format off + struct CLR_RT_DataTypeLookup { - static const CLR_UINT8 c_NA = 0x00; - static const CLR_UINT8 c_VariableSize = 0xFF; - - static const CLR_UINT32 c_Primitive = 0x00000001; - static const CLR_UINT32 c_Interface = 0x00000002; - static const CLR_UINT32 c_Class = 0x00000004; - static const CLR_UINT32 c_ValueType = 0x00000008; - static const CLR_UINT32 c_Enum = 0x00000010; - static const CLR_UINT32 c_SemanticMask = 0x0000001F; - - static const CLR_UINT32 c_Array = 0x00000020; - static const CLR_UINT32 c_ArrayList = 0x00000040; - static const CLR_UINT32 c_SemanticMask2 = 0x0000007F; - - static const CLR_UINT32 c_Reference = 0x00010000; - static const CLR_UINT32 c_Numeric = 0x00020000; - static const CLR_UINT32 c_Integer = 0x00040000; - static const CLR_UINT32 c_Signed = 0x00080000; - static const CLR_UINT32 c_Direct = 0x00100000; // This isn't an indirect reference. - static const CLR_UINT32 c_OptimizedValueType = 0x00200000; // A value type that is kept in a single HeapBlock. - static const CLR_UINT32 c_ManagedType = 0x00400000; // this dt represents a managed type, or a pointer to a managed - // type More specificly, TypeDescriptor::InitializeFromObject - // will succeed when starting from an object of with this dt + static const CLR_UINT8 c_NA = 0x00; + static const CLR_UINT8 c_VariableSize = 0xFF; + + static const CLR_UINT32 c_Primitive = 0x00000001; + static const CLR_UINT32 c_Interface = 0x00000002; + static const CLR_UINT32 c_Class = 0x00000004; + static const CLR_UINT32 c_ValueType = 0x00000008; + static const CLR_UINT32 c_Enum = 0x00000010; + static const CLR_UINT32 c_SemanticMask = 0x0000001F; + + static const CLR_UINT32 c_Array = 0x00000020; + static const CLR_UINT32 c_ArrayList = 0x00000040; + static const CLR_UINT32 c_SemanticMask2 = 0x0000007F; + + static const CLR_UINT32 c_Var = 0x00000100; + static const CLR_UINT32 c_GenericInstance = 0x00000200; + static const CLR_UINT32 c_MVar = 0x00000400; + + static const CLR_UINT32 c_Reference = 0x00010000; + static const CLR_UINT32 c_Numeric = 0x00020000; + static const CLR_UINT32 c_Integer = 0x00040000; + static const CLR_UINT32 c_Signed = 0x00080000; + + // This isn't an indirect reference. + static const CLR_UINT32 c_Direct = 0x00100000; + + // A value type that is kept in a single HeapBlock. + static const CLR_UINT32 c_OptimizedValueType = 0x00200000; + + + // This DataType represents a managed type, or a pointer to a managed + // type More specifically, TypeDescriptor::InitializeFromObject + // will succeed when starting from an object of with this DataType + static const CLR_UINT32 c_ManagedType = 0x00400000; CLR_UINT32 m_flags; CLR_UINT8 m_sizeInBits; @@ -1641,6 +1827,8 @@ struct CLR_RT_DataTypeLookup #endif }; +// clang-format on + extern const CLR_RT_DataTypeLookup c_CLR_RT_DataTypeLookup[]; //--// @@ -1689,7 +1877,7 @@ struct CLR_RT_OpcodeLookup #if defined(NANOCLR_OPCODE_PARSER) CLR_LOGICAL_OPCODE m_logicalOpcode; - CLR_DataType m_dt; + NanoCLRDataType m_dt; CLR_INT8 m_index; CLR_UINT16 m_flags; #endif @@ -1803,14 +1991,15 @@ struct CLR_RT_TypeSystem // EVENT HEAP - NO RELOCATION - bool FindTypeDef(const char *name, CLR_RT_TypeDef_Index &res); bool FindTypeDef(const char *name, CLR_RT_Assembly *assm, CLR_RT_ReflectionDef_Index &reflex); - HRESULT LocateResourceFile(CLR_RT_Assembly_Instance assm, const char *name, CLR_INT32 &idxResourceFile); + HRESULT LocateResourceFile(CLR_RT_Assembly_Instance assm, const char *name, CLR_INT32 &indexResourceFile); HRESULT LocateResource( CLR_RT_Assembly_Instance assm, - CLR_INT32 idxResourceFile, + CLR_INT32 indexResourceFile, CLR_INT16 id, const CLR_RECORD_RESOURCE *&res, CLR_UINT32 &size); + HRESULT BuildTypeName(const CLR_RT_TypeSpec_Index &typeIndex, char *&szBuffer, size_t &iBuffer); HRESULT BuildTypeName( const CLR_RT_TypeDef_Index &cls, char *&szBuffer, @@ -1818,19 +2007,26 @@ struct CLR_RT_TypeSystem // EVENT HEAP - NO RELOCATION - CLR_UINT32 flags, CLR_UINT32 levels); HRESULT BuildTypeName(const CLR_RT_TypeDef_Index &cls, char *&szBuffer, size_t &size); - HRESULT BuildMethodName(const CLR_RT_MethodDef_Index &md, char *&szBuffer, size_t &size); + HRESULT BuildMethodName( + const CLR_RT_MethodDef_Index &md, + const CLR_RT_TypeSpec_Index *genericType, + char *&szBuffer, + size_t &size); HRESULT BuildFieldName(const CLR_RT_FieldDef_Index &fd, char *&szBuffer, size_t &size); + HRESULT BuildMethodRefName(const CLR_RT_MethodRef_Index &method, char *&szBuffer, size_t &iBuffer); + HRESULT BuildMethodSpecName(const CLR_RT_MethodSpec_Index &ms, char *&szBuffer, size_t &iBuffer); + HRESULT QueueStringToBuffer(char *&szBuffer, size_t &size, const char *szText); bool FindVirtualMethodDef( const CLR_RT_TypeDef_Index &cls, const CLR_RT_MethodDef_Index &calleeMD, - CLR_RT_MethodDef_Index &idx); + CLR_RT_MethodDef_Index &index); bool FindVirtualMethodDef( const CLR_RT_TypeDef_Index &cls, const CLR_RT_MethodDef_Index &calleeMD, const char *calleeName, - CLR_RT_MethodDef_Index &idx); + CLR_RT_MethodDef_Index &index); static bool MatchSignature(CLR_RT_SignatureParser &parserLeft, CLR_RT_SignatureParser &parserRight); static bool MatchSignatureDirect( @@ -1840,10 +2036,12 @@ struct CLR_RT_TypeSystem // EVENT HEAP - NO RELOCATION - static bool MatchSignatureElement( CLR_RT_SignatureParser::Element &resLeft, CLR_RT_SignatureParser::Element &resRight, + CLR_RT_SignatureParser &parserLeft, + CLR_RT_SignatureParser &parserRight, bool fIsInstanceOfOK); - static CLR_DataType MapElementTypeToDataType(CLR_UINT32 et); - static CLR_UINT32 MapDataTypeToElementType(CLR_DataType dt); + static NanoCLRDataType MapElementTypeToDataType(CLR_UINT32 et); + static CLR_UINT32 MapDataTypeToElementType(NanoCLRDataType dt); #if defined(VIRTUAL_DEVICE) void Dump(const wchar_t *szFileName, bool fNoByteCode); @@ -1860,23 +2058,25 @@ extern CLR_RT_TypeSystem g_CLR_RT_TypeSystem; struct CLR_RT_Assembly_Instance : public CLR_RT_Assembly_Index { - CLR_RT_Assembly *m_assm; + CLR_RT_Assembly *assembly; //--// - bool InitializeFromIndex(const CLR_RT_Assembly_Index &idx); - void Clear(); + bool InitializeFromIndex(const CLR_RT_Assembly_Index &index); + void ClearInstance(); }; struct CLR_RT_TypeSpec_Instance : public CLR_RT_TypeSpec_Index { - CLR_RT_Assembly *m_assm; - CLR_PMETADATA m_target; + CLR_RT_Assembly *assembly; + const CLR_RECORD_TYPESPEC *target; + + CLR_INDEX typeDefIndex; //--// - bool InitializeFromIndex(const CLR_RT_TypeSpec_Index &idx); - void Clear(); + bool InitializeFromIndex(const CLR_RT_TypeSpec_Index &index); + void ClearInstance(); bool ResolveToken(CLR_UINT32 tk, CLR_RT_Assembly *assm); }; @@ -1885,25 +2085,30 @@ struct CLR_RT_TypeSpec_Instance : public CLR_RT_TypeSpec_Index struct CLR_RT_TypeDef_Instance : public CLR_RT_TypeDef_Index { - CLR_RT_Assembly *m_assm; - const CLR_RECORD_TYPEDEF *m_target; + CLR_RT_Assembly *assembly; + const CLR_RECORD_TYPEDEF *target; + +#if defined(NANOCLR_INSTANCE_NAMES) + const char *name; +#endif //--// bool InitializeFromReflection(const CLR_RT_ReflectionDef_Index &reflex, CLR_UINT32 *levels); - bool InitializeFromIndex(const CLR_RT_TypeDef_Index &idx); + bool InitializeFromIndex(const CLR_RT_TypeDef_Index &index); bool InitializeFromMethod(const CLR_RT_MethodDef_Instance &md); bool InitializeFromField(const CLR_RT_FieldDef_Instance &fd); + bool InitializeFromMethod(const CLR_RT_MethodSpec_Instance &ms); - void Clear(); + void ClearInstance(); - bool ResolveToken(CLR_UINT32 tk, CLR_RT_Assembly *assm); + bool ResolveToken(CLR_UINT32 tk, CLR_RT_Assembly *assm, const CLR_RT_MethodDef_Instance *caller = nullptr); //--// CLR_RT_TypeDef_CrossReference &CrossReference() const { - return m_assm->m_pCrossReference_TypeDef[Type()]; + return assembly->crossReferenceTypeDef[Type()]; } bool SwitchToParent(); @@ -1916,13 +2121,19 @@ struct CLR_RT_TypeDef_Instance : public CLR_RT_TypeDef_Index struct CLR_RT_FieldDef_Instance : public CLR_RT_FieldDef_Index { - CLR_RT_Assembly *m_assm; - const CLR_RECORD_FIELDDEF *m_target; + CLR_RT_Assembly *assembly; + const CLR_RECORD_FIELDDEF *target; + + const CLR_RT_TypeSpec_Index *genericType; + +#if defined(NANOCLR_INSTANCE_NAMES) + const char *name; +#endif //--// - bool InitializeFromIndex(const CLR_RT_FieldDef_Index &idx); - void Clear(); + bool InitializeFromIndex(const CLR_RT_FieldDef_Index &index); + void ClearInstance(); bool ResolveToken(CLR_UINT32 tk, CLR_RT_Assembly *assm); @@ -1930,7 +2141,7 @@ struct CLR_RT_FieldDef_Instance : public CLR_RT_FieldDef_Index CLR_RT_FieldDef_CrossReference &CrossReference() const { - return m_assm->m_pCrossReference_FieldDef[Field()]; + return assembly->crossReferenceFieldDef[Field()]; } }; @@ -1938,13 +2149,19 @@ struct CLR_RT_FieldDef_Instance : public CLR_RT_FieldDef_Index struct CLR_RT_MethodDef_Instance : public CLR_RT_MethodDef_Index { - CLR_RT_Assembly *m_assm; - const CLR_RECORD_METHODDEF *m_target; + CLR_RT_Assembly *assembly; + const CLR_RECORD_METHODDEF *target; + + const CLR_RT_TypeSpec_Index *genericType; + +#if defined(NANOCLR_INSTANCE_NAMES) + const char *name; +#endif //--// - bool InitializeFromIndex(const CLR_RT_MethodDef_Index &idx); - void Clear(); + bool InitializeFromIndex(const CLR_RT_MethodDef_Index &index); + void ClearInstance(); bool ResolveToken(CLR_UINT32 tk, CLR_RT_Assembly *assm); @@ -1952,7 +2169,7 @@ struct CLR_RT_MethodDef_Instance : public CLR_RT_MethodDef_Index CLR_RT_MethodDef_CrossReference &CrossReference() const { - return m_assm->m_pCrossReference_MethodDef[Method()]; + return assembly->crossReferenceMethodDef[Method()]; } CLR_UINT32 Hits() const { @@ -1962,11 +2179,55 @@ struct CLR_RT_MethodDef_Instance : public CLR_RT_MethodDef_Index #if defined(NANOCLR_ENABLE_SOURCELEVELDEBUGGING) CLR_RT_MethodDef_DebuggingInfo &DebuggingInfo() const { - return m_assm->m_pDebuggingInfo_MethodDef[Method()]; + return assembly->debuggingInfoMethodDef[Method()]; } #endif // #if defined(NANOCLR_ENABLE_SOURCELEVELDEBUGGING) }; +struct CLR_RT_GenericParam_Instance : public CLR_RT_GenericParam_Index +{ + CLR_RT_Assembly *assembly; + const CLR_RECORD_GENERICPARAM *target; + +#if defined(NANOCLR_INSTANCE_NAMES) + const char *name; +#endif + + //--// + + bool InitializeFromIndex(const CLR_RT_GenericParam_Index &index); + + void ClearInstance(); + + bool ResolveToken(CLR_UINT32 tk, CLR_RT_Assembly *assm); + + //--// + + CLR_RT_GenericParam_CrossReference &CrossReference() const + { + return assembly->crossReferenceGenericParam[GenericParam()]; + } +}; + +struct CLR_RT_MethodSpec_Instance : public CLR_RT_MethodSpec_Index +{ + CLR_RT_Assembly *assembly; + const CLR_RECORD_METHODSPEC *target; + + //--// + + bool InitializeFromIndex(const CLR_RT_MethodSpec_Index &index); + + void ClearInstance(); + + CLR_RT_MethodSpec_CrossReference &CrossReference() const + { + return assembly->crossReferenceMethodSpec[Method()]; + } + + CLR_EncodedMethodDefOrRef InstanceOfMethod; +}; + //////////////////////////////////////////////////////////////////////////////////////////////////// struct CLR_RT_AttributeEnumerator @@ -2015,7 +2276,7 @@ struct CLR_RT_AttributeParser CLR_PMETADATA m_blob; CLR_RT_MethodDef_Instance m_md; - CLR_RT_MethodDef_Index m_mdIdx; + CLR_RT_MethodDef_Index m_mdIndex; CLR_RT_TypeDef_Instance m_td; CLR_RT_SignatureParser m_parser; CLR_RT_SignatureParser::Element m_res; @@ -2034,7 +2295,7 @@ struct CLR_RT_AttributeParser HRESULT ReadNumericValue( CLR_RT_HeapBlock *&value, - const CLR_DataType dt, + const NanoCLRDataType dt, const CLR_RT_TypeDef_Index *m_cls, const CLR_UINT32 size); HRESULT ReadString(CLR_RT_HeapBlock *&value); @@ -2049,22 +2310,31 @@ struct CLR_RT_TypeDescriptor { CLR_UINT32 m_flags; CLR_RT_TypeDef_Instance m_handlerCls; + CLR_RT_TypeSpec_Instance m_handlerGenericType; CLR_RT_ReflectionDef_Index m_reflex; - CLR_DataType GetDataType() const + NanoCLRDataType GetDataType() const { - return (CLR_DataType)m_handlerCls.m_target->dataType; + if (m_handlerCls.data != 0) + { + return (NanoCLRDataType)m_handlerCls.target->dataType; + } + else + { + return DATATYPE_GENERICINST; + } } //--// void TypeDescriptor_Initialize(); - HRESULT InitializeFromDataType(CLR_DataType dt); + HRESULT InitializeFromDataType(NanoCLRDataType dt); HRESULT InitializeFromReflection(const CLR_RT_ReflectionDef_Index &reflex); HRESULT InitializeFromTypeSpec(const CLR_RT_TypeSpec_Index &sig); HRESULT InitializeFromType(const CLR_RT_TypeDef_Index &cls); + HRESULT InitializeFromGenericType(const CLR_RT_TypeSpec_Index &genericType); HRESULT InitializeFromFieldDefinition(const CLR_RT_FieldDef_Instance &fd); HRESULT InitializeFromSignatureParser(CLR_RT_SignatureParser &parser); HRESULT InitializeFromObject(const CLR_RT_HeapBlock &ref); @@ -2075,10 +2345,10 @@ struct CLR_RT_TypeDescriptor bool GetElementType(CLR_RT_TypeDescriptor &sub); static HRESULT ExtractTypeIndexFromObject(const CLR_RT_HeapBlock &ref, CLR_RT_TypeDef_Index &res); - static HRESULT ExtractObjectAndDataType(CLR_RT_HeapBlock *&ref, CLR_DataType &dt); + static HRESULT ExtractObjectAndDataType(CLR_RT_HeapBlock *&ref, NanoCLRDataType &dt); }; -#include +#include "nanoCLR_Runtime__Serialization.h" //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -2155,8 +2425,8 @@ struct CLR_RT_InlineBuffer struct CLR_RT_StackFrame : public CLR_RT_HeapBlock_Node // EVENT HEAP - NO RELOCATION - { - static const int c_OverheadForNewObjOrInteropMethod = - 2; // We need to have more slots in the stack to process a 'newobj' opcode. + // We need to have more slots in the stack to process a 'newobj' opcode. + static const int c_OverheadForNewObjOrInteropMethod = 2; static const int c_MinimumStack = 10; static const CLR_UINT32 c_MethodKind_Native = 0x00000000; @@ -2291,7 +2561,7 @@ struct CLR_RT_StackFrame : public CLR_RT_HeapBlock_Node // EVENT HEAP - NO RELOC HRESULT HandleSynchronized(bool fAcquire, bool fGlobal); - void SetResult(CLR_INT32 val, CLR_DataType dataType); + void SetResult(CLR_INT32 val, NanoCLRDataType dataType); void SetResult_I1(CLR_UINT8 val); void SetResult_I2(CLR_INT16 val); void SetResult_I4(CLR_INT32 val); @@ -2404,7 +2674,7 @@ struct CLR_RT_StackFrame : public CLR_RT_HeapBlock_Node // EVENT HEAP - NO RELOC { CLR_RT_HeapBlock &val = PushValue(); - val.SetObjectReference(NULL); + val.SetObjectReference(nullptr); return val; } @@ -3002,7 +3272,7 @@ struct CLR_RT_Thread : public CLR_RT_ObjectToEvent_Destination // EVENT HEAP - N //--// // - // For example, timers are implemented in terms of Threads. If not NULL, this is a worker thread for a timer. + // For example, timers are implemented in terms of Threads. If not nullptr, this is a worker thread for a timer. // ThreadTerminationCallback m_terminationCallback; void *m_terminationParameter; // EVENT HEAP - NO RELOCATION - @@ -3106,7 +3376,7 @@ struct CLR_RT_Thread : public CLR_RT_ObjectToEvent_Destination // EVENT HEAP - N CLR_RT_AppDomain *CurrentAppDomain() const { CLR_RT_StackFrame *stack = CurrentFrame(); - return stack->Prev() ? stack->m_appDomain : NULL; + return stack->Prev() ? stack->m_appDomain : nullptr; } #endif @@ -3315,7 +3585,7 @@ struct CLR_RT_EventCache return m_entriesMRU[LinkMRUArraySize() - 1].m_prev; } - static void MoveEntryToTop(Link *entries, CLR_UINT32 slot, CLR_UINT32 idx); + static void MoveEntryToTop(Link *entries, CLR_UINT32 slot, CLR_UINT32 index); }; #endif @@ -3464,8 +3734,7 @@ struct CLR_RT_ExecutionEngine static const int c_fDebugger_StateResolutionFailed = 0x00000001; static const int c_fDebugger_StateProgramRunning = 0x00000400; static const int c_fDebugger_StateProgramExited = 0x00000800; - static const int c_fDebugger_StateMask = - c_fDebugger_StateProgramRunning + c_fDebugger_StateProgramExited + c_fDebugger_StateResolutionFailed; + static const int c_fDebugger_StateMask = c_fDebugger_StateProgramRunning + c_fDebugger_StateProgramExited; // static const int c_fDebugger_BreakpointsDisabled = 0x00001000; // Do not spew debug text to the debugger @@ -3583,7 +3852,7 @@ struct CLR_RT_ExecutionEngine #define CLR_EE_REBOOT_CLR g_CLR_RT_ExecutionEngine.m_iReboot_Options = CLR_DBG_Commands::Monitor_Reboot::c_ClrOnly #define CLR_EE_DBG_EVENT_SEND(cmd, size, payload, flags) \ - ((g_CLR_DBG_Debugger->m_messaging != NULL) \ + ((g_CLR_DBG_Debugger->m_messaging != nullptr) \ ? g_CLR_DBG_Debugger->m_messaging->SendEvent(cmd, size, (unsigned char *)payload, flags) \ : false) @@ -3735,6 +4004,10 @@ struct CLR_RT_ExecutionEngine CLR_UINT32 flags, const CLR_RT_TypeDef_Index &cls, CLR_UINT32 length); + CLR_RT_HeapBlock *ExtractHeapBlocksForGenericInstance( + CLR_UINT32 flags, + const CLR_RT_TypeSpec_Index &genericType, + CLR_UINT32 length); CLR_RT_HeapBlock *ExtractHeapBytesForObjects(CLR_UINT32 dataType, CLR_UINT32 flags, CLR_UINT32 length); CLR_RT_HeapBlock *ExtractHeapBlocksForObjects(CLR_UINT32 dataType, CLR_UINT32 flags, CLR_UINT32 length); CLR_RT_HeapBlock_Node *ExtractHeapBlocksForEvents(CLR_UINT32 dataType, CLR_UINT32 flags, CLR_UINT32 length); @@ -3751,12 +4024,21 @@ struct CLR_RT_ExecutionEngine HRESULT InitializeReference(CLR_RT_HeapBlock &ref, CLR_RT_SignatureParser &parser); HRESULT InitializeReference(CLR_RT_HeapBlock &ref, const CLR_RECORD_FIELDDEF *target, CLR_RT_Assembly *assm); - HRESULT InitializeLocals(CLR_RT_HeapBlock *locals, CLR_RT_Assembly *assm, const CLR_RECORD_METHODDEF *md); + HRESULT InitializeLocals(CLR_RT_HeapBlock *locals, const CLR_RT_MethodDef_Instance &methodDefInstance); HRESULT NewObjectFromIndex(CLR_RT_HeapBlock &reference, const CLR_RT_TypeDef_Index &cls); HRESULT NewObject(CLR_RT_HeapBlock &reference, const CLR_RT_TypeDef_Instance &inst); HRESULT NewObject(CLR_RT_HeapBlock &reference, CLR_UINT32 token, CLR_RT_Assembly *assm); + HRESULT NewGenericInstanceObject( + CLR_RT_HeapBlock &reference, + const CLR_RT_TypeDef_Instance &typeDef, + const CLR_RT_TypeSpec_Index &genericType); + HRESULT NewGenericInstanceObject( + CLR_RT_HeapBlock &reference, + const CLR_RT_TypeDef_Instance &typeDef, + CLR_RT_TypeSpec_Instance &genericInstance); + HRESULT CloneObject(CLR_RT_HeapBlock &reference, const CLR_RT_HeapBlock &source); HRESULT CopyValueType(CLR_RT_HeapBlock *destination, const CLR_RT_HeapBlock *source); @@ -3836,9 +4118,9 @@ struct CLR_RT_ExecutionEngine bool SpawnStaticConstructorHelper( CLR_RT_AppDomain *appDomain, CLR_RT_AppDomainAssembly *appDomainAssembly, - const CLR_RT_MethodDef_Index &idx); + const CLR_RT_MethodDef_Index &index); #else - bool SpawnStaticConstructorHelper(CLR_RT_Assembly *assembly, const CLR_RT_MethodDef_Index &idx); + bool SpawnStaticConstructorHelper(CLR_RT_Assembly *assembly, const CLR_RT_MethodDef_Index &index); #endif static void FinalizerTerminationCallback(void *arg); static void StaticConstructorTerminationCallback(void *arg); @@ -3894,14 +4176,12 @@ struct CLR_RT_ExecutionEngine // It is used to Thread.Sleep(0) imlementation. The thread is still ready, but is last to execute. void UpdateToLowestExecutionCounter(CLR_RT_Thread *pThread) const; - void RetrieveCurrentMethod(CLR_UINT32 &assmIdx, CLR_UINT32 &methodIdx); + void RetrieveCurrentMethod(CLR_UINT32 &assmIndex, CLR_UINT32 &methodIndex); }; extern CLR_RT_ExecutionEngine g_CLR_RT_ExecutionEngine; extern CLR_UINT32 g_buildCRC; -//--// - // // CT_ASSERT macro generates a compiler error in case the size of any structure changes. // diff --git a/src/CLR/Include/nanoCLR_Runtime__HeapBlock.h b/src/CLR/Include/nanoCLR_Runtime__HeapBlock.h index 48367f9d4e..3646adb1be 100644 --- a/src/CLR/Include/nanoCLR_Runtime__HeapBlock.h +++ b/src/CLR/Include/nanoCLR_Runtime__HeapBlock.h @@ -47,7 +47,7 @@ #define CLR_RT_HEAPBLOCK_RELOCATE(ptr) \ { \ - CLR_DataType dt = ptr->DataType(); \ + NanoCLRDataType dt = ptr->DataType(); \ \ if (dt > DATATYPE_LAST_NONPOINTER && dt < DATATYPE_FIRST_INVALID) \ { \ @@ -142,7 +142,7 @@ struct CLR_RT_HeapBlock union CLR_RT_HeapBlock_Id { struct Type { - CLR_UINT8 dataType; // CLR_DataType + CLR_UINT8 dataType; // NanoCLRDataType CLR_UINT8 flags; // HB_* CLR_UINT16 size; } type; @@ -458,7 +458,7 @@ struct CLR_RT_HeapBlock R8 &operator+=(const R8 &num) { - double value = (double)*this; // uses conversion + auto value = (double)*this; // uses conversion value += (double)num; // uses conversion and then built-in type double *this = value; // uses assignment operator (operator=) return *this; @@ -466,7 +466,7 @@ struct CLR_RT_HeapBlock R8 &operator-=(const R8 &num) { - double value = (double)*this; // uses conversion + auto value = (double)*this; // uses conversion value -= (double)num; // uses conversion and then built-in type double *this = value; // uses assignment operator (operator=) return *this; @@ -474,7 +474,7 @@ struct CLR_RT_HeapBlock R8 operator*(const R8 &num) { - double value = (double)*this; // uses conversion + auto value = (double)*this; // uses conversion R8 ret_value; value *= (double)num; // uses conversion and then built-in type __int64 ret_value = value; // uses assignment operator (operator=) @@ -483,7 +483,7 @@ struct CLR_RT_HeapBlock R8 operator/(const R8 &num) { - double value = (double)*this; // uses conversion + auto value = (double)*this; // uses conversion R8 ret_value; value /= (double)num; // uses conversion and then built-in type __int64 ret_value = value; // uses assignment operator (operator=) @@ -492,25 +492,25 @@ struct CLR_RT_HeapBlock bool operator<(const R8 &num) { - double value = (double)*this; // uses conversion + auto value = (double)*this; // uses conversion return (value < (double)num); } bool operator>(const R8 &num) { - double value = (double)*this; // uses conversion + auto value = (double)*this; // uses conversion return (value > (double)num); } bool operator==(const R8 &num) { - double value = (double)*this; // uses conversion + auto value = (double)*this; // uses conversion return (value == (double)num); } bool operator==(const double num) { - double value = (double)*this; // uses conversion + auto value = (double)*this; // uses conversion return (value == num); } @@ -750,6 +750,16 @@ struct CLR_RT_HeapBlock CLR_RT_RelocationHandler m_relocate; } binaryBlob; + //--// + + struct GenericInstance + { + CLR_RT_TypeSpec_Index genericType; + CLR_RT_HeapBlock_GenericInstance *ptr; + } genericInstance; + + //--// + } m_data; public: @@ -759,10 +769,11 @@ struct CLR_RT_HeapBlock //--// - CLR_DataType DataType() const + NanoCLRDataType DataType() const { - return (CLR_DataType)m_id.type.dataType; + return (NanoCLRDataType)m_id.type.dataType; } + CLR_UINT8 DataFlags() const { return m_id.type.flags; @@ -790,8 +801,8 @@ struct CLR_RT_HeapBlock void ClearData() { - m_data.nodeLink.nextBlock = NULL; - m_data.nodeLink.prevBlock = NULL; + m_data.nodeLink.nextBlock = nullptr; + m_data.nodeLink.prevBlock = nullptr; } void SetFlags(CLR_UINT8 flags) @@ -1024,12 +1035,17 @@ struct CLR_RT_HeapBlock { CLR_RT_HeapBlock *obj; + // If already a ref type, dereference it + if (dst.DataType() == DATATYPE_BYREF) + { + obj = dst.Dereference(); + } // // ValueTypes are implemented as pointers to objects, // so getting a reference to a ValueType has to be treated like getting a reference to object, not to its // holder! // - if (dst.IsAValueType()) + else if (dst.IsAValueType()) { obj = dst.Dereference(); } @@ -1042,7 +1058,7 @@ struct CLR_RT_HeapBlock m_data.objectReference.ptr = obj; } - bool IsAReferenceOfThisType(CLR_DataType dataType) const + bool IsAReferenceOfThisType(NanoCLRDataType dataType) const { if (DataType() == DATATYPE_OBJECT) { @@ -1077,7 +1093,7 @@ struct CLR_RT_HeapBlock CLR_RT_HeapBlock_Array *RecoverArrayHeader() const { - return (DataType() == DATATYPE_ARRAY_BYREF) ? m_data.arrayReference.array : NULL; + return (DataType() == DATATYPE_ARRAY_BYREF) ? m_data.arrayReference.array : nullptr; } //--// @@ -1094,7 +1110,7 @@ struct CLR_RT_HeapBlock } } - return NULL; + return nullptr; } //--// @@ -1167,6 +1183,21 @@ struct CLR_RT_HeapBlock //--// + void SetGenericType(const CLR_RT_TypeSpec_Index &genericType) + { + m_id.raw = CLR_RT_HEAPBLOCK_RAW_ID(DATATYPE_GENERICINST, 0, 1); + m_data.genericInstance.genericType.data = genericType.data; + } + + const CLR_RT_TypeSpec_Index &ObjectGenericType() const + { + return m_data.genericInstance.genericType; + } + + HRESULT SetGenericInstanceObject(const CLR_RT_TypeSpec_Index &genericType); + + //--// + CLR_RT_HeapBlock_Array *Array() const { return m_data.arrayReference.array; @@ -1252,8 +1283,8 @@ struct CLR_RT_HeapBlock value.Debug_CheckPointer(); - CLR_RT_HeapBlock_Raw *src = (CLR_RT_HeapBlock_Raw *)this; - CLR_RT_HeapBlock_Raw *dst = (CLR_RT_HeapBlock_Raw *)&value; + auto *src = (CLR_RT_HeapBlock_Raw *)this; + auto *dst = (CLR_RT_HeapBlock_Raw *)&value; *src = *dst; } @@ -1264,8 +1295,10 @@ struct CLR_RT_HeapBlock this->m_data = value.m_data; - if (this->DataType() > DATATYPE_LAST_PRIMITIVE_TO_PRESERVE) - this->m_id = value.m_id; + if (DataType() > DATATYPE_LAST_PRIMITIVE_TO_PRESERVE) + { + this->m_id = value.m_id; // FIX: handle generic type + } } void AssignPreserveTypeCheckPinned(const CLR_RT_HeapBlock &value) @@ -1288,7 +1321,7 @@ struct CLR_RT_HeapBlock // Since it is rare case, the code is not inlined to save code size. void AssignAndPinReferencedObject(const CLR_RT_HeapBlock &value); - HRESULT Convert(CLR_DataType et, bool fOverflow, bool fUnsigned) + HRESULT Convert(NanoCLRDataType et, bool fOverflow, bool fUnsigned) { // // For V1, we don't throw on overflow. @@ -1317,6 +1350,7 @@ struct CLR_RT_HeapBlock HRESULT SetReflection(const CLR_RT_TypeDef_Index &cls); HRESULT SetReflection(const CLR_RT_FieldDef_Index &fd); HRESULT SetReflection(const CLR_RT_MethodDef_Index &md); + HRESULT SetReflection(const CLR_RT_GenericParam_Index &gp); HRESULT InitializeArrayReference(CLR_RT_HeapBlock &ref, int index); void InitializeArrayReferenceDirect(CLR_RT_HeapBlock_Array &array, int index); @@ -1341,7 +1375,7 @@ struct CLR_RT_HeapBlock static CLR_INT32 Compare_Values(const CLR_RT_HeapBlock &left, const CLR_RT_HeapBlock &right, bool fSigned); - HRESULT Convert_Internal(CLR_DataType et); + HRESULT Convert_Internal(NanoCLRDataType et); HRESULT NumericAdd(const CLR_RT_HeapBlock &right); HRESULT NumericSub(const CLR_RT_HeapBlock &right); HRESULT NumericMul(const CLR_RT_HeapBlock &right); @@ -1384,7 +1418,7 @@ struct CLR_RT_HeapBlock cls *ptr; \ cls *ptr##Next; \ \ - for (ptr = (cls *)(lst).FirstNode(); (ptr##Next = (cls *)ptr->Next()) != NULL; ptr = ptr##Next) \ + for (ptr = (cls *)(lst).FirstNode(); (ptr##Next = (cls *)ptr->Next()) != nullptr; ptr = ptr##Next) \ { \ NANOCLR_FAULT_ON_EARLY_COLLECTION(ptr##Next); @@ -1392,7 +1426,7 @@ struct CLR_RT_HeapBlock { \ cls *ptr##Next; \ \ - for (ptr = (cls *)(lst).FirstNode(); (ptr##Next = (cls *)ptr->Next()) != NULL; ptr = ptr##Next) \ + for (ptr = (cls *)(lst).FirstNode(); (ptr##Next = (cls *)ptr->Next()) != nullptr; ptr = ptr##Next) \ { \ NANOCLR_FAULT_ON_EARLY_COLLECTION(ptr##Next); @@ -1401,7 +1435,7 @@ struct CLR_RT_HeapBlock cls *ptr; \ cls *ptr##Next; \ \ - for (ptr = (cls *)(startNode); (ptr##Next = (cls *)ptr->Next()) != NULL; ptr = ptr##Next) \ + for (ptr = (cls *)(startNode); (ptr##Next = (cls *)ptr->Next()) != nullptr; ptr = ptr##Next) \ { \ NANOCLR_FAULT_ON_EARLY_COLLECTION(ptr##Next); @@ -1422,7 +1456,7 @@ struct CLR_RT_HeapBlock cls *ptr; \ cls *ptr##Prev; \ \ - for (ptr = (cls *)(lst).LastNode(); (ptr##Prev = (cls *)ptr->Prev()) != NULL; ptr = ptr##Prev) \ + for (ptr = (cls *)(lst).LastNode(); (ptr##Prev = (cls *)ptr->Prev()) != nullptr; ptr = ptr##Prev) \ { \ NANOCLR_FAULT_ON_EARLY_COLLECTION(ptr##Prev); @@ -1430,7 +1464,7 @@ struct CLR_RT_HeapBlock { \ cls *ptr##Prev; \ \ - for (ptr = (cls *)(lst).LastNode(); (ptr##Prev = (cls *)ptr->Prev()) != NULL; ptr = ptr##Prev) \ + for (ptr = (cls *)(lst).LastNode(); (ptr##Prev = (cls *)ptr->Prev()) != nullptr; ptr = ptr##Prev) \ { \ NANOCLR_FAULT_ON_EARLY_COLLECTION(ptr##Prev); @@ -1439,7 +1473,7 @@ struct CLR_RT_HeapBlock cls *ptr; \ cls *ptr##Prev; \ \ - for (ptr = (cls *)(startNode); (ptr##Prev = (cls *)ptr->Prev()) != NULL; ptr = ptr##Prev) \ + for (ptr = (cls *)(startNode); (ptr##Prev = (cls *)ptr->Prev()) != nullptr; ptr = ptr##Prev) \ { \ NANOCLR_FAULT_ON_EARLY_COLLECTION(ptr##Prev); @@ -1493,8 +1527,8 @@ struct CLR_RT_HeapBlock_Node : public CLR_RT_HeapBlock // // So we'll have to use the explicit check... // - // bool IsValidForward () const { return Next() != NULL; } - // bool IsValidBackward() const { return Prev() != NULL; } + // bool IsValidForward () const { return Next() != nullptr; } + // bool IsValidBackward() const { return Prev() != nullptr; } //--// @@ -1544,8 +1578,8 @@ struct CLR_RT_HeapBlock_Node : public CLR_RT_HeapBlock if (next) next->m_data.nodeLink.prevBlock = prev; - m_data.nodeLink.prevBlock = NULL; - m_data.nodeLink.nextBlock = NULL; + m_data.nodeLink.prevBlock = nullptr; + m_data.nodeLink.nextBlock = nullptr; } //--// @@ -1597,18 +1631,18 @@ struct CLR_RT_DblLinkedList CLR_RT_HeapBlock_Node *FirstValidNode() const { CLR_RT_HeapBlock_Node *res = m_first; - return res->Next() ? res : NULL; + return res->Next() ? res : nullptr; } CLR_RT_HeapBlock_Node *LastValidNode() const { CLR_RT_HeapBlock_Node *res = m_last; - return res->Prev() ? res : NULL; + return res->Prev() ? res : nullptr; } // Check that node pNode is not "dummy" tail or head node. static bool IsValidListNode(CLR_RT_HeapBlock_Node *pNode) { - return pNode->m_data.nodeLink.nextBlock != NULL && pNode->m_data.nodeLink.prevBlock != NULL; + return pNode->m_data.nodeLink.nextBlock != nullptr && pNode->m_data.nodeLink.prevBlock != nullptr; } CLR_RT_HeapBlock_Node *Head() const @@ -2361,6 +2395,15 @@ struct CLR_RT_HeapBlock_WeakReference : public CLR_RT_HeapBlock_Node // OBJECT H //--// +struct CLR_RT_HeapBlock_GenericInstance : public CLR_RT_HeapBlock_Node // OBJECT HEAP - DO RELOCATION - +{ + static HRESULT CreateInstance(CLR_RT_HeapBlock &reference, const CLR_RT_TypeSpec_Index &tsIndex); + + void Relocate(); +}; + +//--// + #ifdef __GNUC__ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-parameter" diff --git a/src/CLR/Include/nanoCLR_Runtime__Serialization.h b/src/CLR/Include/nanoCLR_Runtime__Serialization.h index 32446403f6..19528e2c09 100644 --- a/src/CLR/Include/nanoCLR_Runtime__Serialization.h +++ b/src/CLR/Include/nanoCLR_Runtime__Serialization.h @@ -70,7 +70,7 @@ struct CLR_RT_BinaryFormatter : public CLR_RT_HeapBlock_Node // EVENT HEAP - NO // // Type of signatures: // - // 1) NULL + // 1) nullptr // // Invalid for NeverNull // @@ -155,7 +155,7 @@ struct CLR_RT_BinaryFormatter : public CLR_RT_HeapBlock_Node // EVENT HEAP - NO bool CompareTypes( CLR_RT_TypeDescriptor* left, CLR_RT_TypeDescriptor* right ); - static CLR_DataType GetDataType ( CLR_RT_TypeDescriptor* type ); + static NanoCLRDataType GetDataType ( CLR_RT_TypeDescriptor* type ); static CLR_UINT32 GetSizeOfType( CLR_RT_TypeDescriptor* type ); static bool GetSignOfType( CLR_RT_TypeDescriptor* type ); @@ -220,13 +220,13 @@ struct CLR_RT_BinaryFormatter : public CLR_RT_HeapBlock_Node // EVENT HEAP - NO struct DuplicateTracker : public CLR_RT_HeapBlock_Node // EVENT HEAP - NO RELOCATION - { CLR_RT_HeapBlock* m_ptr; - CLR_UINT32 m_idx; + CLR_UINT32 m_index; }; //--// CLR_RT_HeapBlock_MemoryStream* m_stream; - CLR_UINT32 m_idx; + CLR_UINT32 m_index; CLR_UINT32 m_lastTypeRead; CLR_RT_DblLinkedList m_duplicates; // EVENT HEAP - NO RELOCATION - list of CLR_RT_BinaryFormatter::DuplicateTracker CLR_RT_DblLinkedList m_states; // EVENT HEAP - NO RELOCATION - list of CLR_RT_BinaryFormatter::State @@ -247,12 +247,12 @@ struct CLR_RT_BinaryFormatter : public CLR_RT_HeapBlock_Node // EVENT HEAP - NO HRESULT Advance (); static HRESULT Serialize ( CLR_RT_HeapBlock& refData, CLR_RT_HeapBlock& object ); - static HRESULT Deserialize( CLR_RT_HeapBlock& refData, CLR_RT_HeapBlock& object , CLR_UINT32* unknownType , CLR_UINT32 flags ); + static HRESULT Deserialize( CLR_RT_HeapBlock& refData, CLR_RT_HeapBlock& object , CLR_UINT32* unknownType, CLR_UINT32 flags ); static HRESULT Deserialize( CLR_RT_HeapBlock& refData, CLR_UINT8* data, CLR_UINT32 size, CLR_RT_HeapBlock* cls, CLR_UINT32* unknownType, CLR_UINT32 flags ); HRESULT TrackDuplicate ( CLR_RT_HeapBlock* object ); CLR_UINT32 SearchDuplicate( CLR_RT_HeapBlock* object ); - CLR_RT_HeapBlock* GetDuplicate ( CLR_UINT32 idx ); + CLR_RT_HeapBlock* GetDuplicate ( CLR_UINT32 index ); //--// diff --git a/src/CLR/Include/nanoCLR_Types.h b/src/CLR/Include/nanoCLR_Types.h index a2e3c859ab..a89128fcec 100644 --- a/src/CLR/Include/nanoCLR_Types.h +++ b/src/CLR/Include/nanoCLR_Types.h @@ -37,7 +37,7 @@ #define NANOCLR_PARAMCHECK_POINTER(ptr) \ { \ - if (ptr == NULL) \ + if (ptr == nullptr) \ { \ hrInner = CLR_E_NULL_REFERENCE; \ } \ @@ -45,7 +45,7 @@ #define NANOCLR_PARAMCHECK_POINTER_AND_SET(ptr, val) \ { \ - if (ptr == NULL) \ + if (ptr == nullptr) \ { \ hrInner = CLR_E_NULL_REFERENCE; \ } \ @@ -57,7 +57,7 @@ #define NANOCLR_PARAMCHECK_NOTNULL(ptr) \ { \ - if (ptr == NULL) \ + if (ptr == nullptr) \ { \ hrInner = CLR_E_INVALID_PARAMETER; \ } \ @@ -65,7 +65,7 @@ #define NANOCLR_PARAMCHECK_STRING_NOT_EMPTY(ptr) \ { \ - if (ptr == NULL || ptr[0] == 0) \ + if (ptr == nullptr || ptr[0] == 0) \ { \ hrInner = CLR_E_INVALID_PARAMETER; \ } \ @@ -106,10 +106,15 @@ typedef signed __int64 CLR_INT64; typedef CLR_UINT16 CLR_OFFSET; typedef CLR_UINT32 CLR_OFFSET_LONG; -typedef CLR_UINT16 CLR_IDX; +typedef CLR_UINT16 CLR_INDEX; typedef CLR_UINT16 CLR_STRING; typedef CLR_UINT16 CLR_SIG; typedef const CLR_UINT8 *CLR_PMETADATA; +typedef CLR_UINT16 CLR_TYPEORMETHODDEF; +typedef CLR_UINT16 CLR_ENCODEDNANOTYPE; +typedef CLR_UINT16 CLR_EncodedMethodDefOrRef; +typedef CLR_UINT16 CLR_EncodedTypeDefOrRef; +typedef CLR_UINT16 CLR_EncodedTypeRefOrSpec; //--// // may need to change later @@ -220,7 +225,7 @@ enum CLR_LOGICAL_OPCODE /////////////////////////////////////////////////////////////////////////////////////////////////// -static const CLR_IDX CLR_EmptyIndex = 0xFFFF; +static const CLR_INDEX CLR_EmptyIndex = 0xFFFF; static const CLR_UINT32 CLR_EmptyToken = 0xFFFFFFFF; static const size_t CLR_MaxStreamSize_AssemblyRef = 0x0000FFFF; static const size_t CLR_MaxStreamSize_TypeRef = 0x0000FFFF; @@ -229,6 +234,8 @@ static const size_t CLR_MaxStreamSize_MethodRef = 0x0000FFFF; static const size_t CLR_MaxStreamSize_TypeDef = 0x0000FFFF; static const size_t CLR_MaxStreamSize_FieldDef = 0x0000FFFF; static const size_t CLR_MaxStreamSize_MethodDef = 0x0000FFFF; +static const size_t CLR_MaxStreamSize_GenericParam = 0x0000FFFF; +static const size_t CLR_MaxStreamSize_MethodSpec = 0x0000FFFF; static const size_t CLR_MaxStreamSize_Attributes = 0x0000FFFF; static const size_t CLR_MaxStreamSize_TypeSpec = 0x0000FFFF; static const size_t CLR_MaxStreamSize_Resources = 0x0000FFFF; @@ -282,7 +289,11 @@ enum CLR_FlowControl /////////////////////////////////////////////////////////////////////////////////////////////////// -enum CLR_TABLESENUM +////////////////////////////////////////////////////////////////////////////////////// +// !!! KEEP IN SYNC WITH enum NanoCLRTable (in nanoCLR_TypeSystem VS extension) !!! // +// !!! KEEP IN SYNC WITH enum NanoCLRTable (in MDP) !!! // +////////////////////////////////////////////////////////////////////////////////////// +enum NanoCLRTable { TBL_AssemblyRef = 0x00000000, TBL_TypeRef = 0x00000001, @@ -291,16 +302,18 @@ enum CLR_TABLESENUM TBL_TypeDef = 0x00000004, TBL_FieldDef = 0x00000005, TBL_MethodDef = 0x00000006, - TBL_Attributes = 0x00000007, - TBL_TypeSpec = 0x00000008, - TBL_Resources = 0x00000009, - TBL_ResourcesData = 0x0000000A, - TBL_Strings = 0x0000000B, - TBL_Signatures = 0x0000000C, - TBL_ByteCode = 0x0000000D, - TBL_ResourcesFiles = 0x0000000E, - TBL_EndOfAssembly = 0x0000000F, - TBL_Max = 0x00000010, + TBL_GenericParam = 0x00000007, + TBL_MethodSpec = 0x00000008, + TBL_TypeSpec = 0x00000009, + TBL_Attributes = 0x0000000A, + TBL_Resources = 0x0000000B, + TBL_ResourcesData = 0x0000000C, + TBL_Strings = 0x0000000D, + TBL_Signatures = 0x0000000E, + TBL_ByteCode = 0x0000000F, + TBL_ResourcesFiles = 0x00000010, + TBL_EndOfAssembly = 0x000000011, + TBL_Max = 0x00000012, }; enum CLR_CorCallingConvention @@ -309,6 +322,7 @@ enum CLR_CorCallingConvention // // This is based on CorCallingConvention. // + PIMAGE_CEE_CS_CALLCONV_DEFAULT = 0x0, PIMAGE_CEE_CS_CALLCONV_VARARG = 0x5, @@ -316,66 +330,132 @@ enum CLR_CorCallingConvention PIMAGE_CEE_CS_CALLCONV_LOCAL_SIG = 0x7, PIMAGE_CEE_CS_CALLCONV_PROPERTY = 0x8, PIMAGE_CEE_CS_CALLCONV_UNMGD = 0x9, - PIMAGE_CEE_CS_CALLCONV_GENERICINST = 0xa, // generic method instantiation - PIMAGE_CEE_CS_CALLCONV_NATIVEVARARG = 0xb, // used ONLY for 64bit vararg PInvoke calls - PIMAGE_CEE_CS_CALLCONV_MAX = 0xc, // first invalid calling convention + + /// @brief generic method instantiation + /// + PIMAGE_CEE_CS_CALLCONV_GENERICINST = 0xA, + + /// @brief used ONLY for 64bit vararg PInvoke calls + /// + PIMAGE_CEE_CS_CALLCONV_NATIVEVARARG = 0xB, + + /// @brief first invalid calling convention + /// + PIMAGE_CEE_CS_CALLCONV_MAX = 0xC, // The high bits of the calling convention convey additional info - PIMAGE_CEE_CS_CALLCONV_MASK = 0x0f, // Calling convention is bottom 4 bits - PIMAGE_CEE_CS_CALLCONV_HASTHIS = 0x20, // Top bit indicates a 'this' parameter - PIMAGE_CEE_CS_CALLCONV_EXPLICITTHIS = 0x40, // This parameter is explicitly in the signature - PIMAGE_CEE_CS_CALLCONV_GENERIC = - 0x10, // Generic method sig with explicit number of type arguments (precedes ordinary parameter count) - // - // End of overlap with CorCallingConvention. - // - ///////////////////////////////////////////////////////////////////////////////////////////// + + /// @brief Calling convention is bottom 4 bits + /// + PIMAGE_CEE_CS_CALLCONV_MASK = 0x0F, + + /// @brief Top bit indicates a 'this' parameter + /// + PIMAGE_CEE_CS_CALLCONV_HASTHIS = 0x20, + + /// @brief This parameter is explicitly in the signature + /// + PIMAGE_CEE_CS_CALLCONV_EXPLICITTHIS = 0x40, + + /// @brief Generic method sig with explicit number of type arguments (precedes ordinary parameter count) + /// + PIMAGE_CEE_CS_CALLCONV_GENERIC = 0x10, + + // + // End of overlap with CorCallingConvention. + // + ///////////////////////////////////////////////////////////////////////////////////////////// }; -enum CLR_DataType // KEEP IN SYNC WITH nanoCLR_DataType enum in nanoFramework.Tools.MetadataProcessor!! +///////////////////////////////////////////////////////////////////////////////////////// +// !!! KEEP IN SYNC WITH enum NanoCLRDataType (in nanoCLR_TypeSystem VS extension) !!! // +// !!! KEEP IN SYNC WITH enum NanoCLRDataType (in nanoCLR_TypeSystem Debugger) !!! // +///////////////////////////////////////////////////////////////////////////////////////// + +enum NanoCLRDataType // KEEP IN SYNC WITH nanoCLR_DataType enum in nanoFramework.Tools.MetadataProcessor!! { - DATATYPE_VOID, // 0 bytes + /// @brief 0 bytes + DATATYPE_VOID, + + /// @brief 1 byte + DATATYPE_BOOLEAN, - DATATYPE_BOOLEAN, // 1 byte - DATATYPE_I1, // 1 byte - DATATYPE_U1, // 1 byte + /// @brief 1 byte + DATATYPE_I1, - DATATYPE_CHAR, // 2 bytes - DATATYPE_I2, // 2 bytes - DATATYPE_U2, // 2 bytes + /// @brief 1 byte + DATATYPE_U1, - DATATYPE_I4, // 4 bytes - DATATYPE_U4, // 4 bytes - DATATYPE_R4, // 4 bytes + /// @brief 2 bytes + DATATYPE_CHAR, - DATATYPE_I8, // 8 bytes - DATATYPE_U8, // 8 bytes - DATATYPE_R8, // 8 bytes - DATATYPE_DATETIME, // 8 bytes // Shortcut for System.DateTime - DATATYPE_TIMESPAN, // 8 bytes // Shortcut for System.TimeSpan + /// @brief 2 bytes + DATATYPE_I2, + + /// @brief 2 bytes + DATATYPE_U2, + + /// @brief 4 bytes + DATATYPE_I4, + + /// @brief 4 bytes + DATATYPE_U4, + + /// @brief 4 bytes + DATATYPE_R4, + + /// @brief 8 bytes + DATATYPE_I8, + + /// @brief 8 bytes + DATATYPE_U8, + + /// @brief 8 bytes + DATATYPE_R8, + + /// @brief 8 bytes (Shortcut for System.DateTime) + DATATYPE_DATETIME, + + /// @brief 8 bytes (Shortcut for System.TimeSpan) + DATATYPE_TIMESPAN, DATATYPE_STRING, - DATATYPE_LAST_NONPOINTER = DATATYPE_TIMESPAN, // This is the last type that doesn't need to be relocated. - DATATYPE_LAST_PRIMITIVE_TO_PRESERVE = DATATYPE_R8, // All the above types don't need fix-up on assignment. + /// @brief This is the last type that doesn't need to be relocated. + DATATYPE_LAST_NONPOINTER = DATATYPE_TIMESPAN, + + // All the above types don't need fix-up on assignment. + DATATYPE_LAST_PRIMITIVE_TO_PRESERVE = DATATYPE_R8, + +// All the above types can be marshaled by assignment. #if defined(NANOCLR_NO_ASSEMBLY_STRINGS) - DATATYPE_LAST_PRIMITIVE_TO_MARSHAL = DATATYPE_STRING, // All the above types can be marshaled by assignment. + DATATYPE_LAST_PRIMITIVE_TO_MARSHAL = DATATYPE_STRING, // #else - DATATYPE_LAST_PRIMITIVE_TO_MARSHAL = DATATYPE_TIMESPAN, // All the above types can be marshaled by assignment. + DATATYPE_LAST_PRIMITIVE_TO_MARSHAL = DATATYPE_TIMESPAN, #endif - DATATYPE_LAST_PRIMITIVE = DATATYPE_STRING, // All the above types don't need fix-up on assignment. - DATATYPE_OBJECT, // Shortcut for System.Object - DATATYPE_GENERIC = DATATYPE_OBJECT, // shortcut for generic type - DATATYPE_CLASS, // CLASS - DATATYPE_VALUETYPE, // VALUETYPE - DATATYPE_SZARRAY, // Shortcut for single dimension zero lower bound array SZARRAY - DATATYPE_BYREF, // BYREF + // All the above types don't need fix-up on assignment. + DATATYPE_LAST_PRIMITIVE = DATATYPE_STRING, + + /// @brief Shortcut for System.Object + DATATYPE_OBJECT, + + /// @brief CLASS + DATATYPE_CLASS, - // Generic parameter in a generic type definition, represented as number + /// @brief VALUETYPE + DATATYPE_VALUETYPE, + + /// @brief Shortcut for single dimension zero lower bound array SZARRAY + DATATYPE_SZARRAY, + + /// @brief BYREF + DATATYPE_BYREF, + + /// @brief Generic parameter in a generic type definition, represented as number DATATYPE_VAR, - // Generic type instantiation + /// @brief Generic type instantiation DATATYPE_GENERICINST, - // Generic parameter in a generic method definition, represented as number + /// @brief Generic parameter in a generic method definition, represented as number DATATYPE_MVAR, //////////////////////////////////////// @@ -449,27 +529,24 @@ enum CLR_ReflectionType REFLECTION_CONSTRUCTOR = 0x04, REFLECTION_METHOD = 0x05, REFLECTION_FIELD = 0x06, + REFLECTION_GENERICTYPE = 0x07, }; //////////////////////////////////////////////////////////////////////////////////////////////////// + inline CLR_UINT32 CLR_DataFromTk(CLR_UINT32 tk) { return tk & 0x00FFFFFF; } -inline CLR_TABLESENUM CLR_TypeFromTk(CLR_UINT32 tk) +inline NanoCLRTable CLR_TypeFromTk(CLR_UINT32 tk) { - return (CLR_TABLESENUM)(tk >> 24); + return (NanoCLRTable)(tk >> 24); } -inline CLR_UINT32 CLR_TkFromType(CLR_TABLESENUM tbl, CLR_UINT32 data) +inline CLR_UINT32 CLR_TkFromType(NanoCLRTable tbl, CLR_UINT32 data) { return ((((CLR_UINT32)tbl) << 24) & 0xFF000000) | (data & 0x00FFFFFF); } -#if 0 -// Used on LE host to target BE -inline CLR_UINT32 CLR_TkFromType( CLR_TABLESENUM tbl, CLR_UINT32 data ) { return ( ((CLR_UINT32)(tbl) & 0xFF) | (data & 0xFFFFFF00)); } -inline CLR_UINT32 CLR_DataFromTk( CLR_UINT32 tk ) { return tk & 0xFFFFFF00; } -inline CLR_TABLESENUM CLR_TypeFromTk( CLR_UINT32 tk ) { return (CLR_TABLESENUM)(tk&0xFF); } -#endif + //--// inline CLR_UINT32 CLR_UncompressStringToken(CLR_UINT32 tk) @@ -479,22 +556,21 @@ inline CLR_UINT32 CLR_UncompressStringToken(CLR_UINT32 tk) inline CLR_UINT32 CLR_UncompressTypeToken(CLR_UINT32 tk) { - // TODO: length of this table should be 4 as it is dereferenced with two bits masked from token - // The fourth value is undefined/random - static const CLR_TABLESENUM c_lookup[3] = {TBL_TypeDef, TBL_TypeRef, TBL_TypeSpec}; - return CLR_TkFromType(c_lookup[(tk >> 14) & 3], 0x3fff & tk); + static const NanoCLRTable c_lookup[] = {TBL_TypeDef, TBL_TypeRef, TBL_TypeSpec, TBL_GenericParam}; + return CLR_TkFromType(c_lookup[(tk >> 14)], 0x3fff & tk); } inline CLR_UINT32 CLR_UncompressFieldToken(CLR_UINT32 tk) { - static const CLR_TABLESENUM c_lookup[2] = {TBL_FieldDef, TBL_FieldRef}; - return CLR_TkFromType(c_lookup[(tk >> 15) & 1], 0x7fff & tk); + static const NanoCLRTable c_lookup[2] = {TBL_FieldDef, TBL_FieldRef}; + return CLR_TkFromType(c_lookup[(tk >> 15)], 0x7fff & tk); } inline CLR_UINT32 CLR_UncompressMethodToken(CLR_UINT32 tk) { - static const CLR_TABLESENUM c_lookup[2] = {TBL_MethodDef, TBL_MethodRef}; - return CLR_TkFromType(c_lookup[(tk >> 15) & 1], 0x7fff & tk); + static const NanoCLRTable c_lookup[4] = {TBL_MethodDef, TBL_MethodRef, TBL_TypeSpec, TBL_MethodSpec}; + + return CLR_TkFromType(c_lookup[(tk >> 14)], 0x3fff & tk); } #if defined(VIRTUAL_DEVICE) @@ -505,38 +581,6 @@ CLR_UINT32 CLR_ReadTokenCompressed(CLR_PMETADATA &ip, CLR_OPCODE opcode); //--// -HRESULT CLR_CompressTokenHelper(const CLR_TABLESENUM *tables, CLR_UINT16 cTables, CLR_UINT32 &tk); - -inline HRESULT CLR_CompressStringToken(CLR_UINT32 &tk) -{ - static const CLR_TABLESENUM c_lookup[1] = {TBL_Strings}; - - return CLR_CompressTokenHelper(c_lookup, ARRAYSIZE(c_lookup), tk); -} - -inline HRESULT CLR_CompressTypeToken(CLR_UINT32 &tk) -{ - static const CLR_TABLESENUM c_lookup[3] = {TBL_TypeDef, TBL_TypeRef, TBL_TypeSpec}; - - return CLR_CompressTokenHelper(c_lookup, ARRAYSIZE(c_lookup), tk); -} - -inline HRESULT CLR_CompressFieldToken(CLR_UINT32 &tk) -{ - static const CLR_TABLESENUM c_lookup[2] = {TBL_FieldDef, TBL_FieldRef}; - - return CLR_CompressTokenHelper(c_lookup, ARRAYSIZE(c_lookup), tk); -} - -inline HRESULT CLR_CompressMethodToken(CLR_UINT32 &tk) -{ - static const CLR_TABLESENUM c_lookup[2] = {TBL_MethodDef, TBL_MethodRef}; - - return CLR_CompressTokenHelper(c_lookup, ARRAYSIZE(c_lookup), tk); -} - -//--// - inline bool CLR_CompressData(CLR_UINT32 val, CLR_UINT8 *&p) { CLR_UINT8 *ptr = p; @@ -587,43 +631,24 @@ inline CLR_UINT32 CLR_UncompressData(const CLR_UINT8 *&p) val |= (CLR_UINT32)*ptr++ << 8; val |= (CLR_UINT32)*ptr++ << 0; } -#if 0 - // Handle smallest data inline. - if((val & 0x80) == 0x00) // 0??? ???? - { - } - else if((val & 0xC0) == 0x80) // 10?? ???? - { - val = (val & 0x3F); - val |= ((CLR_UINT32)*ptr++ <<8); - } - else // 110? ???? - { - val = (val & 0x1F) ; - val |= (CLR_UINT32)*ptr++ << 8; - val |= (CLR_UINT32)*ptr++ << 16; - val |= (CLR_UINT32)*ptr++ << 24; - } - -#endif p = ptr; return val; } -inline CLR_DataType CLR_UncompressElementType(const CLR_UINT8 *&p) +inline NanoCLRDataType CLR_UncompressElementType(const CLR_UINT8 *&p) { - return (CLR_DataType)*p++; + return (NanoCLRDataType)*p++; } inline CLR_UINT32 CLR_TkFromStream(const CLR_UINT8 *&p) { - static const CLR_TABLESENUM c_lookup[4] = {TBL_TypeDef, TBL_TypeRef, TBL_TypeSpec, TBL_Max}; + static const NanoCLRTable c_lookup[4] = {TBL_TypeDef, TBL_TypeRef, TBL_TypeSpec, TBL_Max}; CLR_UINT32 data = CLR_UncompressData(p); - return CLR_TkFromType(c_lookup[data & 3], data >> 2); + return CLR_TkFromType(c_lookup[data & 0x0003], data >> 2); } //--//--//--// @@ -972,16 +997,14 @@ struct CLR_Debug struct CLR_RECORD_VERSION { - CLR_UINT16 iMajorVersion; - CLR_UINT16 iMinorVersion; - CLR_UINT16 iBuildNumber; - CLR_UINT16 iRevisionNumber; + CLR_UINT16 majorVersion; + CLR_UINT16 minorVersion; + CLR_UINT16 buildNumber; + CLR_UINT16 revisionNumber; }; struct CLR_RECORD_ASSEMBLY { - static const CLR_UINT32 c_Flags_NeedReboot = 0x00000001; - CLR_UINT8 marker[8]; // CLR_UINT32 headerCRC; @@ -989,7 +1012,6 @@ struct CLR_RECORD_ASSEMBLY CLR_UINT32 flags; // CLR_UINT32 nativeMethodsChecksum; - CLR_UINT32 patchEntryOffset; // CLR_RECORD_VERSION version; // @@ -997,7 +1019,7 @@ struct CLR_RECORD_ASSEMBLY CLR_UINT16 stringTableVersion; // CLR_OFFSET_LONG startOfTables[TBL_Max]; - CLR_UINT32 numOfPatchedMethods; + // // For every table, a number of bytes that were padded to the end of the table // to align to unsigned long. Each table starts at a unsigned long boundary, and ends @@ -1017,7 +1039,7 @@ struct CLR_RECORD_ASSEMBLY void ComputeCRC(); #endif - CLR_OFFSET_LONG SizeOfTable(CLR_TABLESENUM tbl) const + CLR_OFFSET_LONG SizeOfTable(NanoCLRTable tbl) const { return startOfTables[tbl + 1] - startOfTables[tbl] - paddingOfTables[tbl]; } @@ -1032,52 +1054,157 @@ struct CLR_RECORD_ASSEMBLY static CLR_UINT32 ComputeAssemblyHash(const char *name, const CLR_RECORD_VERSION &ver); }; +///////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////// +// size of CLR_RECORDs +// these have to match the struct used in MDP +// when changing any of these structs need to update the constant in MDP +#define sizeOf_CLR_RECORD_ASSEMBLYREF 10 +#define sizeOf_CLR_RECORD_TYPEREF 6 +#define sizeOf_CLR_RECORD_FIELDREF 6 +#define sizeOf_CLR_RECORD_METHODREF 6 +#define sizeOf_CLR_RECORD_TYPEDEF 27 +#define sizeOf_CLR_RECORD_FIELDDEF 8 +#define sizeOf_CLR_RECORD_METHODDEF 19 +#define sizeOf_CLR_RECORD_TYPESPEC 2 +#define sizeOf_CLR_RECORD_GENERICPARAM 10 +#define sizeOf_CLR_RECORD_METHODSPEC 6 +///////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////// + +// record structures are aligned to 1 byte boundary to minimize PE size +#pragma pack(push, 1) + +/// @brief Assembly header struct CLR_RECORD_ASSEMBLYREF { - CLR_STRING name; // TBL_Strings - CLR_UINT16 pad; - // + /// @brief Index into TBL_Strings + CLR_STRING name; + + /// @brief Assembly version CLR_RECORD_VERSION version; }; +CT_ASSERT(sizeof(CLR_RECORD_ASSEMBLYREF) == sizeOf_CLR_RECORD_ASSEMBLYREF) + struct CLR_RECORD_TYPEREF { - CLR_STRING name; // TBL_Strings - CLR_STRING nameSpace; // TBL_Strings - // - CLR_IDX scope; // TBL_AssemblyRef | TBL_TypeRef // 0x8000 - CLR_UINT16 pad; + /// @brief Index into TBL_Strings + /// + CLR_STRING name; + + /// @brief Index into TBL_Strings + /// + CLR_STRING nameSpace; + + /// @brief TypeRefOrAssemblyRef -> Index into TBL_AssemblyRef (ORed with 0x0000) | TBL_TypeRef (ORed with 0x8000) + /// + CLR_INDEX scope; }; +CT_ASSERT(sizeof(CLR_RECORD_TYPEREF) == sizeOf_CLR_RECORD_TYPEREF) + struct CLR_RECORD_FIELDREF { - CLR_STRING name; // TBL_Strings - CLR_IDX container; // TBL_TypeRef - // - CLR_SIG sig; // TBL_Signatures - CLR_UINT16 pad; + /// @brief Index into TBL_Strings + /// + CLR_STRING name; + + /// @brief Encoded index into TBL_TypeRef or TBL_TypeSpec for the type containing this field + CLR_EncodedTypeRefOrSpec encodedOwner; + + /// @brief Index into TBL_Signatures + /// + CLR_SIG signature; + + /// @brief Index into owner table + /// + CLR_INDEX OwnerIndex() const + { + return (encodedOwner & 0x7FFF); + } + + /// @brief Index into owner table + /// + NanoCLRTable Owner() const + { + static const NanoCLRTable c_lookup[2] = {TBL_TypeRef, TBL_TypeSpec}; + + return c_lookup[(encodedOwner >> 15)]; + } }; +CT_ASSERT(sizeof(CLR_RECORD_FIELDREF) == sizeOf_CLR_RECORD_FIELDREF) + struct CLR_RECORD_METHODREF { - CLR_STRING name; // TBL_Strings - CLR_IDX container; // TBL_TypeRef - // - CLR_SIG sig; // TBL_Signatures - CLR_UINT16 pad; + /// @brief Index into TBL_Strings + /// + CLR_STRING name; + + /// @brief Encoded index into TBL_TypeRef or TBL_TypeSpec for the type containing the method + /// + CLR_EncodedTypeRefOrSpec encodedOwner; + + /// @brief Index into TBL_Signatures + /// + CLR_SIG signature; + + //--// + + /// @brief Index into owner table + /// + CLR_INDEX OwnerIndex() const + { + return (encodedOwner & 0x7FFF); + } + + /// @brief Owner table + /// + NanoCLRTable Owner() const + { + static const NanoCLRTable c_lookup[2] = {TBL_TypeRef, TBL_TypeSpec}; + + return c_lookup[(encodedOwner >> 15)]; + } + + bool HasOwnerType() const + { + return encodedOwner != CLR_EmptyIndex; + } }; +CT_ASSERT(sizeof(CLR_RECORD_METHODREF) == sizeOf_CLR_RECORD_METHODREF) + struct CLR_RECORD_TYPEDEF { static const CLR_UINT16 TD_Scope_Mask = 0x0007; - static const CLR_UINT16 TD_Scope_NotPublic = 0x0000; // Class is not public scope. - static const CLR_UINT16 TD_Scope_Public = 0x0001; // Class is public scope. - static const CLR_UINT16 TD_Scope_NestedPublic = 0x0002; // Class is nested with public visibility. - static const CLR_UINT16 TD_Scope_NestedPrivate = 0x0003; // Class is nested with private visibility. - static const CLR_UINT16 TD_Scope_NestedFamily = 0x0004; // Class is nested with family visibility. - static const CLR_UINT16 TD_Scope_NestedAssembly = 0x0005; // Class is nested with assembly visibility. - static const CLR_UINT16 TD_Scope_NestedFamANDAssem = 0x0006; // Class is nested with family and assembly visibility. - static const CLR_UINT16 TD_Scope_NestedFamORAssem = 0x0007; // Class is nested with family or assembly visibility. + /// @brief Class is not public scope. + /// + static const CLR_UINT16 TD_Scope_NotPublic = 0x0000; + /// @brief Class is public scope. + /// + static const CLR_UINT16 TD_Scope_Public = 0x0001; + /// @brief Class is nested with public visibility. + /// + static const CLR_UINT16 TD_Scope_NestedPublic = 0x0002; + /// @brief Class is nested with private visibility. + /// + static const CLR_UINT16 TD_Scope_NestedPrivate = 0x0003; + + /// @brief Class is nested with family visibility. + /// + static const CLR_UINT16 TD_Scope_NestedFamily = 0x0004; + + /// @brief Class is nested with assembly visibility. + /// + static const CLR_UINT16 TD_Scope_NestedAssembly = 0x0005; + /// @brief Class is nested with family and assembly visibility. + /// + static const CLR_UINT16 TD_Scope_NestedFamANDAssem = 0x0006; // + /// @brief Class is nested with family or assembly visibility. + /// + static const CLR_UINT16 TD_Scope_NestedFamORAssem = 0x0007; static const CLR_UINT16 TD_Serializable = 0x0008; @@ -1101,25 +1228,72 @@ struct CLR_RECORD_TYPEDEF static const CLR_UINT16 TD_HasFinalizer = 0x4000; static const CLR_UINT16 TD_HasAttributes = 0x8000; - CLR_STRING name; // TBL_Strings - CLR_STRING nameSpace; // TBL_Strings - // - CLR_IDX extends; // TBL_TypeDef | TBL_TypeRef // 0x8000 - CLR_IDX enclosingType; // TBL_TypeDef - // - CLR_SIG interfaces; // TBL_Signatures - CLR_IDX methods_First; // TBL_MethodDef - // - CLR_UINT8 vMethods_Num; - CLR_UINT8 iMethods_Num; - CLR_UINT8 sMethods_Num; + /// @brief Index into TBL_Strings with the name of the type + /// + CLR_STRING name; + + /// @brief Index into TBL_Strings with the name of the namespace containing the type + /// + CLR_STRING nameSpace; + + /// @brief Encoded index for TypeDefOrRef -> Index into TBL_TypeDef | TBL_TypeRef + /// + CLR_EncodedTypeDefOrRef encodedExtends; + + /// @brief Encoded index for TypeDefOrRef -> Index into TBL_TypeDef | TBL_TypeRef + /// + CLR_EncodedTypeDefOrRef encodedEnclosingType; + + /// @brief Index into TBL_Signatures blob table for the set of interfaces implemented by this type + /// + CLR_SIG interfaces; + + /// @brief Index into TBL_MethodDef for the first method of the type + /// + CLR_INDEX firstMethod; + + /// @brief Count of virtual methods in the type + /// + CLR_UINT8 virtualMethodCount; + + /// @brief Count of instance methods in the type + /// + CLR_UINT8 instanceMethodCount; + + /// @brief Count of static methods in the type + /// + CLR_UINT8 staticMethodCount; + + /// @brief Data type identity for the type + /// CLR_UINT8 dataType; - // - CLR_IDX sFields_First; // TBL_FieldDef - CLR_IDX iFields_First; // TBL_FieldDef - // - CLR_UINT8 sFields_Num; - CLR_UINT8 iFields_Num; + + /// @brief Index into TBL_FieldDef for the first static field of the type + /// + CLR_INDEX firstStaticField; + + /// @brief Index into TBL_FieldDef for the first instance field of the type + /// + CLR_INDEX firstInstanceField; + + /// @brief Count of static fields in the type + /// + CLR_UINT8 staticFieldsCount; + + /// @brief Count of instance fields in the type + /// + CLR_UINT8 instanceFieldsCount; + + /// @brief Index into TBL_GenericParam for the first generic parameter for the type + /// + CLR_INDEX firstGenericParam; + + /// @brief Count of generic parameters for the type + /// + CLR_UINT8 genericParamCount; + + /// @brief Flags defining intrinsic attributes and access modifiers for the type + /// CLR_UINT16 flags; //--// @@ -1128,12 +1302,57 @@ struct CLR_RECORD_TYPEDEF { return (flags & (TD_Semantics_Mask)) == TD_Semantics_Enum; } + bool IsDelegate() const { return (flags & (TD_Delegate | TD_MulticastDelegate)) != 0; } + + bool HasValidExtendsType() const + { + return encodedExtends != CLR_EmptyIndex; + } + + bool HasValidEnclosingType() const + { + return encodedEnclosingType != CLR_EmptyIndex; + } + + /// @brief Index into Extends table + /// + CLR_INDEX ExtendsIndex() const + { + return (encodedExtends & 0x7FFF); + } + + /// @brief Extends table + /// + NanoCLRTable Extends() const + { + static const NanoCLRTable c_lookup[2] = {TBL_TypeDef, TBL_TypeRef}; + + return c_lookup[(encodedExtends >> 15)]; + } + + /// @brief Index into EnclosingType table + /// + CLR_INDEX EnclosingTypeIndex() const + { + return (encodedEnclosingType & 0x7FFF); + } + + /// @brief EnclosingType table + /// + NanoCLRTable EnclosingType() const + { + static const NanoCLRTable c_lookup[2] = {TBL_TypeDef, TBL_TypeRef}; + + return c_lookup[(encodedEnclosingType >> 15)]; + } }; +CT_ASSERT(sizeof(CLR_RECORD_TYPEDEF) == sizeOf_CLR_RECORD_TYPEDEF) + struct CLR_RECORD_FIELDDEF { static const CLR_UINT16 FD_Scope_Mask = 0x0007; @@ -1159,35 +1378,89 @@ struct CLR_RECORD_FIELDDEF static const CLR_UINT16 FD_HasAttributes = 0x8000; - CLR_STRING name; // TBL_Strings - CLR_SIG sig; // TBL_Signatures - // - CLR_SIG defaultValue; // TBL_Signatures + /// @brief Index into TBL_Strings + /// + CLR_STRING name; + + /// @brief Index into TBL_Signatures + /// + CLR_SIG signature; + + /// @brief Index into TBL_Signatures + /// + CLR_SIG defaultValue; + CLR_UINT16 flags; }; +CT_ASSERT(sizeof(CLR_RECORD_FIELDDEF) == sizeOf_CLR_RECORD_FIELDDEF) + struct CLR_RECORD_METHODDEF { static const CLR_UINT32 MD_Scope_Mask = 0x00000007; - static const CLR_UINT32 MD_Scope_PrivateScope = 0x00000000; // Member not referenceable. - static const CLR_UINT32 MD_Scope_Private = 0x00000001; // Accessible only by the parent type. - static const CLR_UINT32 MD_Scope_FamANDAssem = 0x00000002; // Accessible by sub-types only in this Assembly. - static const CLR_UINT32 MD_Scope_Assem = 0x00000003; // Accessibly by anyone in the Assembly. - static const CLR_UINT32 MD_Scope_Family = 0x00000004; // Accessible only by type and sub-types. - static const CLR_UINT32 MD_Scope_FamORAssem = - 0x00000005; // Accessibly by sub-types anywhere, plus anyone in assembly. - static const CLR_UINT32 MD_Scope_Public = 0x00000006; // Accessibly by anyone who has visibility to this scope. - - static const CLR_UINT32 MD_Static = 0x00000010; // Defined on type, else per instance. - static const CLR_UINT32 MD_Final = 0x00000020; // Method may not be overridden. - static const CLR_UINT32 MD_Virtual = 0x00000040; // Method virtual. - static const CLR_UINT32 MD_HideBySig = 0x00000080; // Method hides by name+sig, else just by name. + + /// @brief ember not referenceable. + /// + static const CLR_UINT32 MD_Scope_PrivateScope = 0x00000000; + + /// @brief Accessible only by the parent type. + /// + static const CLR_UINT32 MD_Scope_Private = 0x00000001; + + /// @brief Accessible by sub-types only in this Assembly. + /// + static const CLR_UINT32 MD_Scope_FamANDAssem = 0x00000002; + + /// @brief Accessibly by anyone in the Assembly. + /// + static const CLR_UINT32 MD_Scope_Assem = 0x00000003; + + /// @brief Accessible only by type and sub-types. + /// + static const CLR_UINT32 MD_Scope_Family = 0x00000004; + + /// @brief Accessibly by sub-types anywhere, plus anyone in assembly. + /// + static const CLR_UINT32 MD_Scope_FamORAssem = 0x00000005; + + /// @brief Accessibly by anyone who has visibility to this scope. + /// + static const CLR_UINT32 MD_Scope_Public = 0x00000006; + + /// @brief Defined on type, else per instance. + /// + static const CLR_UINT32 MD_Static = 0x00000010; + + /// @brief Method may not be overridden. + /// + static const CLR_UINT32 MD_Final = 0x00000020; + + /// @brief Method virtual. + /// + static const CLR_UINT32 MD_Virtual = 0x00000040; + + /// @brief Method hides by name+sig, else just by name. + /// + static const CLR_UINT32 MD_HideBySig = 0x00000080; static const CLR_UINT32 MD_VtableLayoutMask = 0x00000100; - static const CLR_UINT32 MD_ReuseSlot = 0x00000000; // The default. - static const CLR_UINT32 MD_NewSlot = 0x00000100; // Method always gets a new slot in the vtable. - static const CLR_UINT32 MD_Abstract = 0x00000200; // Method does not provide an implementation. - static const CLR_UINT32 MD_SpecialName = 0x00000400; // Method is special. Name describes how. + + /// @brief The default. + /// + static const CLR_UINT32 MD_ReuseSlot = 0x00000000; + + /// @brief Method always gets a new slot in the vtable. + /// + static const CLR_UINT32 MD_NewSlot = 0x00000100; + + /// @brief Method does not provide an implementation. + /// + static const CLR_UINT32 MD_Abstract = 0x00000200; + + /// @brief Method is special. Name describes how. + /// + static const CLR_UINT32 MD_SpecialName = 0x00000400; + static const CLR_UINT32 MD_NativeProfiled = 0x00000800; static const CLR_UINT32 MD_Constructor = 0x00001000; @@ -1199,29 +1472,71 @@ struct CLR_RECORD_METHODDEF static const CLR_UINT32 MD_DelegateBeginInvoke = 0x00040000; static const CLR_UINT32 MD_DelegateEndInvoke = 0x00080000; + static const CLR_UINT32 MD_IsGenericInstance = 0x00100000; + static const CLR_UINT32 MD_ContainsGenericParameter = 0x00200000; + static const CLR_UINT32 MD_Synchronized = 0x01000000; static const CLR_UINT32 MD_GloballySynchronized = 0x02000000; static const CLR_UINT32 MD_Patched = 0x04000000; static const CLR_UINT32 MD_EntryPoint = 0x08000000; - static const CLR_UINT32 MD_RequireSecObject = 0x10000000; // Method calls another method containing security code. - static const CLR_UINT32 MD_HasSecurity = 0x20000000; // Method has security associate with it. + + /// @brief Method calls another method containing security code. + /// + static const CLR_UINT32 MD_RequireSecObject = 0x10000000; + + /// @brief Method has security associate with it. + /// + static const CLR_UINT32 MD_HasSecurity = 0x20000000; static const CLR_UINT32 MD_HasExceptionHandlers = 0x40000000; static const CLR_UINT32 MD_HasAttributes = 0x80000000; - CLR_STRING name; // TBL_Strings - CLR_OFFSET RVA; - // + /// @brief Index into TBL_Strings for the name of the method + /// + CLR_STRING name; + + /// @brief Offset into the IL byte code blob table for the opcodes of the method + /// + CLR_OFFSET rva; + + /// @brief Flags to indicate intrinsic attributes and semantics of the method + /// CLR_UINT32 flags; - // - CLR_UINT8 retVal; - CLR_UINT8 numArgs; - CLR_UINT8 numLocals; + + /// @brief DataType of the return value for the method + /// + CLR_UINT8 retValDataType; + + /// @brief Count of arguments to the method + /// + CLR_UINT8 argumentsCount; + + /// @brief Count of local variables for the method + /// + CLR_UINT8 localsCount; + + /// @brief Length of the evaluation stack for the method + /// CLR_UINT8 lengthEvalStack; - // - CLR_SIG locals; // TBL_Signatures - CLR_SIG sig; // TBL_Signatures + + /// @brief Index into TBL_Signatures to describe the locals for the method + /// + CLR_SIG locals; + + /// @brief Index into TBL_GenericParam for the first generic parameter for the method + /// + CLR_INDEX firstGenericParam; + + /// @brief Count of generic parameters for the method + /// + CLR_UINT8 genericParamCount; + + /// @brief Index into TBL_Signatures that describes the method itself + /// + CLR_SIG signature; }; +CT_ASSERT(sizeof(CLR_RECORD_METHODDEF) == sizeOf_CLR_RECORD_METHODDEF) + #ifdef __GNUC__ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wstrict-aliasing" @@ -1230,14 +1545,22 @@ struct CLR_RECORD_METHODDEF struct CLR_RECORD_ATTRIBUTE { - CLR_UINT16 ownerType; // one of TBL_TypeDef, TBL_MethodDef, or TBL_FieldDef. - CLR_UINT16 ownerIdx; // TBL_TypeDef | TBL_MethodDef | TBL_FielfDef + /// @brief one of TBL_TypeDef, TBL_MethodDef, or TBL_FieldDef. + /// + CLR_UINT16 ownerType; + + /// @brief TBL_TypeDef | TBL_MethodDef | TBL_FielfDef + /// + CLR_UINT16 ownerIndex; CLR_UINT16 constructor; - CLR_SIG data; // TBL_Signatures - CLR_UINT32 Key() const + /// @brief Index into TBL_Signatures + /// + CLR_SIG data; + + CLR_UINT16 Key() const { - return *(CLR_UINT32 *)&ownerType; + return *(CLR_UINT16 *)&ownerType; } }; @@ -1247,10 +1570,71 @@ struct CLR_RECORD_ATTRIBUTE struct CLR_RECORD_TYPESPEC { - CLR_SIG sig; // TBL_Signatures - CLR_UINT16 pad; + /// @brief Index into TBL_Signatures + /// + CLR_SIG signature; +}; + +CT_ASSERT(sizeof(CLR_RECORD_TYPESPEC) == sizeOf_CLR_RECORD_TYPESPEC) + +struct CLR_RECORD_GENERICPARAM +{ + /// @brief 2-byte index of the generic parameter, numbered left -to-right, from zero. + /// + CLR_UINT16 number; + + /// @brief 2-byte bitmask of type GenericParamAttributes + /// + CLR_UINT16 flags; + + /// @brief TypeOrMethodDef -> Index into TBL_TypeDef TBL_MethodDef + /// + CLR_TYPEORMETHODDEF owner; + + /// @brief Index into TBL_Signatures for parameter type signature + /// + CLR_SIG signature; + + /// @brief Index into TBL_Strings + /// + CLR_STRING name; +}; + +CT_ASSERT(sizeof(CLR_RECORD_GENERICPARAM) == sizeOf_CLR_RECORD_GENERICPARAM) + +struct CLR_RECORD_METHODSPEC +{ + /// @brief Encoded index into TBL_MethodDef | TBL_MethodRef + /// + CLR_EncodedMethodDefOrRef encodedMethod; + + /// @brief Index into TBL_Signatures holding the signature of this instantiation + /// + CLR_SIG instantiation; + + /// @brief Index into TBL_Signatures for the type specification containing the method + /// + CLR_INDEX container; + + /// @brief Index into table pointed by TBL_MethodDef | TBL_MethodRef + /// + CLR_INDEX MethodIndex() const + { + return (encodedMethod & 0x7FFF); + } + + /// @brief EnclosingType table + /// + NanoCLRTable MethodKind() const + { + static const NanoCLRTable c_lookup[2] = {TBL_MethodDef, TBL_MethodRef}; + + return c_lookup[(encodedMethod >> 15)]; + } }; +CT_ASSERT(sizeof(CLR_RECORD_METHODSPEC) == sizeOf_CLR_RECORD_METHODSPEC) + struct CLR_RECORD_EH { static const CLR_UINT16 EH_Catch = 0x0000; @@ -1262,7 +1646,7 @@ struct CLR_RECORD_EH CLR_UINT16 mode; union { - CLR_IDX classToken; // TBL_TypeDef | TBL_TypeRef + CLR_INDEX classToken; // TBL_TypeDef | TBL_TypeRef CLR_OFFSET filterStart; }; CLR_OFFSET tryStart; diff --git a/src/CLR/Messaging/Messaging.cpp b/src/CLR/Messaging/Messaging.cpp index 0a2df9cbea..cb09cb96b5 100644 --- a/src/CLR/Messaging/Messaging.cpp +++ b/src/CLR/Messaging/Messaging.cpp @@ -41,14 +41,14 @@ bool CLR_Messaging::AllocateAndQueueMessage( CLR_RT_HeapBlock_EndPoint::Message *rpc; CLR_RT_HeapBlock_EndPoint *ep; - if ((ep = CLR_RT_HeapBlock_EndPoint::FindEndPoint(port)) == NULL) + if ((ep = CLR_RT_HeapBlock_EndPoint::FindEndPoint(port)) == nullptr) return false; { CLR_RT_ProtectFromGC gc(*ep); if ((rpc = (CLR_RT_HeapBlock_EndPoint::Message *) - CLR_RT_Memory::Allocate(sizeof(*rpc) + length, CLR_RT_HeapBlock::HB_CompactOnFailure)) == NULL) + CLR_RT_Memory::Allocate(sizeof(*rpc) + length, CLR_RT_HeapBlock::HB_CompactOnFailure)) == nullptr) return false; rpc->ClearData(); @@ -73,11 +73,11 @@ bool CLR_Messaging::AllocateAndQueueMessage( bool CLR_Messaging::Messaging_Query(WP_Message *msg) { NATIVE_PROFILE_CLR_MESSAGING(); - CLR_Messaging_Commands::Messaging_Query *cmd = (CLR_Messaging_Commands::Messaging_Query *)msg->m_payload; + auto *cmd = (CLR_Messaging_Commands::Messaging_Query *)msg->m_payload; CLR_Messaging_Commands::Messaging_Query::Reply res; CLR_RT_HeapBlock_EndPoint *ep = CLR_RT_HeapBlock_EndPoint::FindEndPoint(cmd->m_addr.m_to); - res.m_found = (ep != NULL); + res.m_found = (ep != nullptr); res.m_addr = cmd->m_addr; WP_ReplyToCommand(msg, true, false, &res, sizeof(res)); @@ -89,13 +89,13 @@ bool CLR_Messaging::Messaging_Query__Reply(WP_Message *msg) { NATIVE_PROFILE_CLR_MESSAGING(); - CLR_Messaging_Commands::Messaging_Query::Reply *cmd = + auto *cmd = (CLR_Messaging_Commands::Messaging_Query::Reply *)msg->m_payload; g_CLR_Messaging->AllocateAndQueueMessage( CLR_Messaging_Commands::c_Messaging_Query, 0, - NULL, + nullptr, cmd->m_addr.m_from, cmd->m_addr, cmd->m_found); @@ -108,7 +108,7 @@ bool CLR_Messaging::Messaging_Query__Reply(WP_Message *msg) bool CLR_Messaging::Messaging_Send(WP_Message *msg) { NATIVE_PROFILE_CLR_MESSAGING(); - CLR_Messaging_Commands::Messaging_Send *cmd = (CLR_Messaging_Commands::Messaging_Send *)msg->m_payload; + auto *cmd = (CLR_Messaging_Commands::Messaging_Send *)msg->m_payload; CLR_Messaging_Commands::Messaging_Send::Reply res; CLR_UINT32 len; bool fRes; @@ -148,7 +148,7 @@ bool CLR_Messaging::Messaging_Send__Reply(WP_Message *msg) bool CLR_Messaging::Messaging_Reply(WP_Message *msg) { NATIVE_PROFILE_CLR_MESSAGING(); - CLR_Messaging_Commands::Messaging_Reply *cmd = (CLR_Messaging_Commands::Messaging_Reply *)msg->m_payload; + auto *cmd = (CLR_Messaging_Commands::Messaging_Reply *)msg->m_payload; CLR_Messaging_Commands::Messaging_Reply::Reply res; bool fRes; CLR_UINT32 len; @@ -189,7 +189,7 @@ bool CLR_Messaging::Messaging_Reply__Reply(WP_Message *msg) bool CLR_Messaging::App_ProcessHeader(void *state, WP_Message *msg) { NATIVE_PROFILE_CLR_MESSAGING(); - CLR_Messaging *pThis = (CLR_Messaging *)state; + auto *pThis = (CLR_Messaging *)state; Watchdog_Reset(); @@ -203,7 +203,7 @@ bool CLR_Messaging::App_ProcessHeader(void *state, WP_Message *msg) { void *ptr = CLR_RT_Memory::Allocate(msg->m_header.m_size, CLR_RT_HeapBlock::HB_CompactOnFailure); - if (ptr == NULL) + if (ptr == nullptr) { TRACE0(TRACE_HEADERS, "Failed to allocate 0x%08X bytes for message payload!\n"); return false; @@ -218,7 +218,7 @@ bool CLR_Messaging::App_ProcessHeader(void *state, WP_Message *msg) bool CLR_Messaging::App_ProcessPayload(void *state, WP_Message *msg) { NATIVE_PROFILE_CLR_MESSAGING(); - CLR_Messaging *pThis = (CLR_Messaging *)state; + auto *pThis = (CLR_Messaging *)state; Watchdog_Reset(); @@ -235,11 +235,11 @@ bool CLR_Messaging::App_Release(void *state, WP_Message *msg) (void)state; NATIVE_PROFILE_CLR_MESSAGING(); - if (msg->m_payload != NULL) + if (msg->m_payload != nullptr) { CLR_RT_Memory::Release(msg->m_payload); - msg->m_payload = NULL; + msg->m_payload = nullptr; } return true; @@ -263,7 +263,7 @@ HRESULT CLR_Messaging::CreateInstance() //... and clear memory memset(g_CLR_Messaging, 0, sizeof(CLR_Messaging)); - g_CLR_Messaging->Initialize(NULL, 0, NULL, 0); + g_CLR_Messaging->Initialize(nullptr, 0, nullptr, 0); NANOCLR_NOCLEANUP(); } @@ -308,7 +308,7 @@ HRESULT CLR_Messaging::DeleteInstance() // free messaging platform_free(g_CLR_Messaging); - g_CLR_Messaging = NULL; + g_CLR_Messaging = nullptr; NANOCLR_NOCLEANUP_NOLABEL(); } @@ -357,10 +357,10 @@ bool CLR_Messaging::ProcessPayload(WP_Message *msg) //--// - CLR_Messaging_CommandHandlerLookups *tables = NULL; + CLR_Messaging_CommandHandlerLookups *tables = nullptr; int tableCount = CMD_HANDLER_LOOKUP_TABLE_SIZE; size_t num; - const CLR_Messaging_CommandHandlerLookup *cmd = NULL; + const CLR_Messaging_CommandHandlerLookup *cmd = nullptr; // developer note: load lookup tables, starting with the upper one // until there is use for RPC Messaging, useful replies and request are in the second table @@ -373,7 +373,7 @@ bool CLR_Messaging::ProcessPayload(WP_Message *msg) tables = &m_Lookup_Requests[CMD_HANDLER_LOOKUP_TABLE_SIZE - 1]; } - _ASSERTE(tables != NULL); + _ASSERTE(tables != nullptr); // go over lookup tables while (tableCount-- > 0) @@ -381,7 +381,7 @@ bool CLR_Messaging::ProcessPayload(WP_Message *msg) num = tables->size; cmd = tables->table; - while (num-- > 0 && cmd != NULL) + while (num-- > 0 && cmd != nullptr) { if (cmd->cmd == msg->m_header.m_cmd) { @@ -394,7 +394,7 @@ bool CLR_Messaging::ProcessPayload(WP_Message *msg) if (!(*(cmd->hnd))(msg)) { // only need to reply if outcome is false - WP_ReplyToCommand(msg, false, false, NULL, 0); + WP_ReplyToCommand(msg, false, false, nullptr, 0); } // done here @@ -411,7 +411,7 @@ bool CLR_Messaging::ProcessPayload(WP_Message *msg) } // getting here means failure, as no command handler was found for this request - WP_ReplyToCommand(msg, false, false, NULL, 0); + WP_ReplyToCommand(msg, false, false, nullptr, 0); return true; } @@ -420,7 +420,7 @@ bool CLR_Messaging::ProcessPayload(WP_Message *msg) // has to mirror declaration of the function with the same name for platforms that implement nanoBooter extern "C" uint8_t Messaging_ProcessPayload(WP_Message *msg) { - if (g_CLR_DBG_Debugger == NULL) + if (g_CLR_DBG_Debugger == nullptr) { return false; } diff --git a/src/CLR/Startup/CLRStartup.cpp b/src/CLR/Startup/CLRStartup.cpp index 74e681d734..b69c42757f 100644 --- a/src/CLR/Startup/CLRStartup.cpp +++ b/src/CLR/Startup/CLRStartup.cpp @@ -69,14 +69,14 @@ struct Settings NANOCLR_CHECK_HRESULT(CLR_RT_Assembly::CreateInstance(header, assm)); // Get handlers for native functions in assembly - pNativeAssmData = GetAssemblyNativeData(assm->m_szName); + pNativeAssmData = GetAssemblyNativeData(assm->name); - // If pNativeAssmData not NULL- means this assembly has native calls and there is pointer to table with native + // If pNativeAssmData not nullptr - means this assembly has native calls and there is pointer to table with native // calls. - if (pNativeAssmData != NULL) + if (pNativeAssmData != nullptr) { // First verify that check sum in assembly object matches hardcoded check sum. - if (assm->m_header->nativeMethodsChecksum != pNativeAssmData->m_checkSum) + if (assm->header->nativeMethodsChecksum != pNativeAssmData->m_checkSum) { #if !defined(BUILD_RTM) CLR_Debug::Printf( @@ -87,8 +87,8 @@ struct Settings CLR_Debug::Printf("* *\r\n"); CLR_Debug::Printf( "* Invalid native checksum: %s 0x%08X!=0x%08X *\r\n", - assm->m_szName, - assm->m_header->nativeMethodsChecksum, + assm->name, + assm->header->nativeMethodsChecksum, pNativeAssmData->m_checkSum); CLR_Debug::Printf("* *\r\n"); CLR_Debug::Printf("***********************************************************************\r\n"); @@ -98,7 +98,7 @@ struct Settings } // Assembly has valid pointer to table with native methods. Save it. - assm->m_nativeCode = (const CLR_RT_MethodHandler *)pNativeAssmData->m_pNativeMethods; + assm->nativeCode = (const CLR_RT_MethodHandler *)pNativeAssmData->m_pNativeMethods; } g_CLR_RT_TypeSystem.Link(assm); NANOCLR_NOCLEANUP(); @@ -188,7 +188,7 @@ struct Settings const CLR_RECORD_ASSEMBLY *header; unsigned char *assembliesBuffer; uint32_t headerInBytes = sizeof(CLR_RECORD_ASSEMBLY); - unsigned char *headerBuffer = NULL; + unsigned char *headerBuffer = nullptr; // for the context it's being used (read the assemblies) // XIP and memory mapped block regions are equivalent so they can be ORed @@ -199,7 +199,7 @@ struct Settings { headerBuffer = (unsigned char *)platform_malloc(headerInBytes); - if (headerBuffer == NULL) + if (headerBuffer == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_OUT_OF_MEMORY); } @@ -243,7 +243,7 @@ struct Settings ///////////////////////////////////////////////////////////////////////////////////// assembliesBuffer = (unsigned char *)platform_malloc(assemblySizeInByte); - if (assembliesBuffer == NULL) + if (assembliesBuffer == nullptr) { // release the headerBuffer which has being used and leave platform_free(headerBuffer); @@ -298,12 +298,12 @@ struct Settings } // load successful, mark as deployed - assm->m_flags |= CLR_RT_Assembly::Deployed; + assm->flags |= CLR_RT_Assembly::Deployed; // if header was malloced, set the flag to request freeing it if (!isXIP) { - assm->m_flags |= CLR_RT_Assembly::FreeOnDestroy; + assm->flags |= CLR_RT_Assembly::FreeOnDestroy; } } @@ -400,7 +400,7 @@ void ClrStartup(CLR_SETTINGS params) CLR_Debug::Printf("Ready.\r\n"); #endif - hr = g_CLR_RT_ExecutionEngine.Execute(NULL, params.MaxContextSwitches); + hr = g_CLR_RT_ExecutionEngine.Execute(nullptr, params.MaxContextSwitches); #if !defined(BUILD_RTM) CLR_Debug::Printf("Done.\r\n"); @@ -419,7 +419,7 @@ void ClrStartup(CLR_SETTINGS params) { #if defined(NANOCLR_ENABLE_SOURCELEVELDEBUGGING) CLR_EE_DBG_SET_MASK(StateProgramExited, StateMask); - CLR_EE_DBG_EVENT_BROADCAST(CLR_DBG_Commands_c_Monitor_ProgramExit, 0, NULL, WP_Flags_c_NonCritical); + CLR_EE_DBG_EVENT_BROADCAST(CLR_DBG_Commands_c_Monitor_ProgramExit, 0, nullptr, WP_Flags_c_NonCritical); #endif // #if defined(NANOCLR_ENABLE_SOURCELEVELDEBUGGING) #if defined(BUILD_RTM) diff --git a/src/CLR/System.Math/nf_native_system_math.cpp b/src/CLR/System.Math/nf_native_system_math.cpp index b6c02f8f75..bd99579315 100644 --- a/src/CLR/System.Math/nf_native_system_math.cpp +++ b/src/CLR/System.Math/nf_native_system_math.cpp @@ -9,7 +9,7 @@ static const CLR_RT_MethodHandler method_lookup[] = { - NULL, + nullptr, Library_nf_native_system_math_System_Math::Abs___STATIC__R8__R8, Library_nf_native_system_math_System_Math::Abs___STATIC__R4__R4, Library_nf_native_system_math_System_Math::Acos___STATIC__R8__R8, @@ -18,10 +18,10 @@ static const CLR_RT_MethodHandler method_lookup[] = Library_nf_native_system_math_System_Math::Atan2___STATIC__R8__R8__R8, Library_nf_native_system_math_System_Math::Cbrt___STATIC__R8__R8, Library_nf_native_system_math_System_Math::Ceiling___STATIC__R8__R8, - NULL, - NULL, - NULL, - NULL, + nullptr, + nullptr, + nullptr, + nullptr, Library_nf_native_system_math_System_Math::Cos___STATIC__R8__R8, Library_nf_native_system_math_System_Math::Cosh___STATIC__R8__R8, Library_nf_native_system_math_System_Math::Exp___STATIC__R8__R8, @@ -29,16 +29,16 @@ static const CLR_RT_MethodHandler method_lookup[] = Library_nf_native_system_math_System_Math::IEEERemainder___STATIC__R8__R8__R8, Library_nf_native_system_math_System_Math::Log___STATIC__R8__R8, Library_nf_native_system_math_System_Math::Log10___STATIC__R8__R8, - NULL, + nullptr, Library_nf_native_system_math_System_Math::Max___STATIC__R8__R8__R8, Library_nf_native_system_math_System_Math::Max___STATIC__R4__R4__R4, - NULL, + nullptr, Library_nf_native_system_math_System_Math::Min___STATIC__R8__R8__R8, Library_nf_native_system_math_System_Math::Min___STATIC__R4__R4__R4, Library_nf_native_system_math_System_Math::Pow___STATIC__R8__R8__R8, Library_nf_native_system_math_System_Math::Round___STATIC__R8__R8, Library_nf_native_system_math_System_Math::Sign___STATIC__I4__R8, - NULL, + nullptr, Library_nf_native_system_math_System_Math::Sin___STATIC__R8__R8, Library_nf_native_system_math_System_Math::Sinh___STATIC__R8__R8, Library_nf_native_system_math_System_Math::Sqrt___STATIC__R8__R8, diff --git a/src/CLR/System.Math/nf_native_system_math_System_Math.cpp b/src/CLR/System.Math/nf_native_system_math_System_Math.cpp index 43d64d2ae3..b6a9ef72c7 100644 --- a/src/CLR/System.Math/nf_native_system_math_System_Math.cpp +++ b/src/CLR/System.Math/nf_native_system_math_System_Math.cpp @@ -216,7 +216,7 @@ HRESULT Library_nf_native_system_math_System_Math::Abs___STATIC__R8__R8(CLR_RT_S #else - float d = (float)stack.Arg0().NumericByRefConst().r8; + auto d = (float)stack.Arg0().NumericByRefConst().r8; float res = fabsf(d); stack.SetResult_R8(res); @@ -257,7 +257,7 @@ HRESULT Library_nf_native_system_math_System_Math::Acos___STATIC__R8__R8(CLR_RT_ #else - float d = (float)stack.Arg0().NumericByRefConst().r8; + auto d = (float)stack.Arg0().NumericByRefConst().r8; float res = acosf(d); stack.SetResult_R8(res); @@ -287,7 +287,7 @@ HRESULT Library_nf_native_system_math_System_Math::Asin___STATIC__R8__R8(CLR_RT_ #else - float d = (float)stack.Arg0().NumericByRefConst().r8; + auto d = (float)stack.Arg0().NumericByRefConst().r8; float res = asinf(d); stack.SetResult_R8(res); @@ -317,7 +317,7 @@ HRESULT Library_nf_native_system_math_System_Math::Atan___STATIC__R8__R8(CLR_RT_ #else - float d = (float)stack.Arg0().NumericByRefConst().r8; + auto d = (float)stack.Arg0().NumericByRefConst().r8; float res = atanf(d); stack.SetResult_R8(res); @@ -348,8 +348,8 @@ HRESULT Library_nf_native_system_math_System_Math::Atan2___STATIC__R8__R8__R8(CL #else - float x = (float)stack.Arg0().NumericByRefConst().r8; - float y = (float)stack.Arg1().NumericByRefConst().r8; + auto x = (float)stack.Arg0().NumericByRefConst().r8; + auto y = (float)stack.Arg1().NumericByRefConst().r8; float res = atan2f(x, y); stack.SetResult_R8(res); @@ -379,7 +379,7 @@ HRESULT Library_nf_native_system_math_System_Math::Cbrt___STATIC__R8__R8(CLR_RT_ #else - float d = (float)stack.Arg0().NumericByRefConst().r8; + auto d = (float)stack.Arg0().NumericByRefConst().r8; float res = cbrt(d); stack.SetResult_R8(res); @@ -409,7 +409,7 @@ HRESULT Library_nf_native_system_math_System_Math::Ceiling___STATIC__R8__R8(CLR_ #else - float d = (float)stack.Arg0().NumericByRefConst().r8; + auto d = (float)stack.Arg0().NumericByRefConst().r8; float res = ceilf(d); stack.SetResult_R8(res); @@ -439,7 +439,7 @@ HRESULT Library_nf_native_system_math_System_Math::Cos___STATIC__R8__R8(CLR_RT_S #else - float d = (float)stack.Arg0().NumericByRefConst().r8; + auto d = (float)stack.Arg0().NumericByRefConst().r8; float res = cosf(d); stack.SetResult_R8(res); @@ -469,7 +469,7 @@ HRESULT Library_nf_native_system_math_System_Math::Cosh___STATIC__R8__R8(CLR_RT_ #else - float d = (float)stack.Arg0().NumericByRefConst().r8; + auto d = (float)stack.Arg0().NumericByRefConst().r8; float res = coshf(d); stack.SetResult_R8(res); @@ -500,8 +500,8 @@ HRESULT Library_nf_native_system_math_System_Math::IEEERemainder___STATIC__R8__R #else - float x = (float)stack.Arg0().NumericByRefConst().r8; - float y = (float)stack.Arg1().NumericByRefConst().r8; + auto x = (float)stack.Arg0().NumericByRefConst().r8; + auto y = (float)stack.Arg1().NumericByRefConst().r8; float res = remainderf(x, y); stack.SetResult_R8(res); @@ -530,7 +530,7 @@ HRESULT Library_nf_native_system_math_System_Math::Exp___STATIC__R8__R8(CLR_RT_S #else - float d = (float)stack.Arg0().NumericByRefConst().r8; + auto d = (float)stack.Arg0().NumericByRefConst().r8; float res = expf(d); stack.SetResult_R8(res); @@ -560,7 +560,7 @@ HRESULT Library_nf_native_system_math_System_Math::Floor___STATIC__R8__R8(CLR_RT #else - float d = (float)stack.Arg0().NumericByRefConst().r8; + auto d = (float)stack.Arg0().NumericByRefConst().r8; float res = floorf(d); stack.SetResult_R8(res); @@ -590,7 +590,7 @@ HRESULT Library_nf_native_system_math_System_Math::Log___STATIC__R8__R8(CLR_RT_S #else - float d = (float)stack.Arg0().NumericByRefConst().r8; + auto d = (float)stack.Arg0().NumericByRefConst().r8; float res = logf(d); stack.SetResult_R8(res); @@ -620,7 +620,7 @@ HRESULT Library_nf_native_system_math_System_Math::Log10___STATIC__R8__R8(CLR_RT #else - float d = (float)stack.Arg0().NumericByRefConst().r8; + auto d = (float)stack.Arg0().NumericByRefConst().r8; float res = log10f(d); stack.SetResult_R8(res); @@ -648,8 +648,8 @@ HRESULT Library_nf_native_system_math_System_Math::Pow___STATIC__R8__R8__R8(CLR_ #else - float x = (float)stack.Arg0().NumericByRefConst().r8; - float y = (float)stack.Arg1().NumericByRefConst().r8; + auto x = (float)stack.Arg0().NumericByRefConst().r8; + auto y = (float)stack.Arg1().NumericByRefConst().r8; float res = powf(x, y); @@ -685,7 +685,7 @@ HRESULT Library_nf_native_system_math_System_Math::Round___STATIC__R8__R8(CLR_RT #else - float d = (float)stack.Arg0().NumericByRefConst().r8; + auto d = (float)stack.Arg0().NumericByRefConst().r8; float hi = d + 0.5; float res = floorf(hi); @@ -731,7 +731,7 @@ HRESULT Library_nf_native_system_math_System_Math::Sign___STATIC__I4__R8(CLR_RT_ #else - float d = (float)stack.Arg0().NumericByRefConst().r8; + auto d = (float)stack.Arg0().NumericByRefConst().r8; int32_t res; if (d < 0) @@ -772,7 +772,7 @@ HRESULT Library_nf_native_system_math_System_Math::Sin___STATIC__R8__R8(CLR_RT_S #else - float d = (float)stack.Arg0().NumericByRefConst().r8; + auto d = (float)stack.Arg0().NumericByRefConst().r8; float res = sinf(d); stack.SetResult_R8(res); @@ -802,7 +802,7 @@ HRESULT Library_nf_native_system_math_System_Math::Sinh___STATIC__R8__R8(CLR_RT_ #else - float d = (float)stack.Arg0().NumericByRefConst().r8; + auto d = (float)stack.Arg0().NumericByRefConst().r8; float res = sinhf(d); stack.SetResult_R8(res); @@ -832,7 +832,7 @@ HRESULT Library_nf_native_system_math_System_Math::Sqrt___STATIC__R8__R8(CLR_RT_ #else - float d = (float)stack.Arg0().NumericByRefConst().r8; + auto d = (float)stack.Arg0().NumericByRefConst().r8; float res = sqrtf(d); stack.SetResult_R8(res); @@ -862,7 +862,7 @@ HRESULT Library_nf_native_system_math_System_Math::Tan___STATIC__R8__R8(CLR_RT_S #else - float d = (float)stack.Arg0().NumericByRefConst().r8; + auto d = (float)stack.Arg0().NumericByRefConst().r8; float res = tanf(d); stack.SetResult_R8(res); @@ -892,7 +892,7 @@ HRESULT Library_nf_native_system_math_System_Math::Tanh___STATIC__R8__R8(CLR_RT_ #else - float d = (float)stack.Arg0().NumericByRefConst().r8; + auto d = (float)stack.Arg0().NumericByRefConst().r8; float res = tanhf(d); stack.SetResult_R8(res); @@ -919,7 +919,7 @@ HRESULT Library_nf_native_system_math_System_Math::Truncate___STATIC__R8__R8(CLR #else - float d = (float)stack.Arg0().NumericByRefConst().r8; + auto d = (float)stack.Arg0().NumericByRefConst().r8; float res = 0.0; modff(d, &res); diff --git a/src/DeviceInterfaces/Network/Enc28j60/enc28j60_lwip_driver.cpp b/src/DeviceInterfaces/Network/Enc28j60/enc28j60_lwip_driver.cpp index f133d400c2..2b2b3af00e 100644 --- a/src/DeviceInterfaces/Network/Enc28j60/enc28j60_lwip_driver.cpp +++ b/src/DeviceInterfaces/Network/Enc28j60/enc28j60_lwip_driver.cpp @@ -5,7 +5,7 @@ // #include -//#include "net_decl_lwip.h" +// #include "net_decl_lwip.h" #include "enc28j60_lwip.h" extern "C" @@ -221,15 +221,21 @@ int ENC28J60_LWIP_Driver::Open(ENC28J60_LWIP_DRIVER_CONFIG *config, int index) int len; HAL_Configuration_NetworkInterface *iface; - if (config == NULL) + if (config == nullptr) + { return -1; + } + iface = g_TargetConfiguration.NetworkInterfaceConfigs->Configs[index]; ; // Open SPI device HRESULT hr = nanoSPI_OpenDevice(config->SPI_Config, config->spiHandle); + if (hr < 0) + { return -1; + } if (0 == (iface->StartupAddressMode & AddressMode_DHCP)) { @@ -263,7 +269,7 @@ int ENC28J60_LWIP_Driver::Open(ENC28J60_LWIP_DRIVER_CONFIG *config, int index) (const ip4_addr_t *)&ipaddr, &netmask, &gw, - NULL, + nullptr, enc28j60_ethhw_init, ethernet_input); @@ -293,8 +299,10 @@ bool ENC28J60_LWIP_Driver::Close(ENC28J60_LWIP_DRIVER_CONFIG *config, int index) NATIVE_PROFILE_HAL_DRIVERS_ETHERNET(); - if (config == NULL) + if (config == nullptr) + { return false; + } LwipUpTimeCompletion.Abort(); @@ -306,7 +314,7 @@ bool ENC28J60_LWIP_Driver::Close(ENC28J60_LWIP_DRIVER_CONFIG *config, int index) CPU_GPIO_EnableInputPin( config->INT_Pin, 0, /* Glitch filter enable */ - NULL, /* ISR */ + nullptr, /* ISR */ 0, /* minor number */ GPIO_INT_NONE, /* Interrupt edge */ PinMode_InputPullUp); /* Resistor State / mode*/ diff --git a/src/DeviceInterfaces/Networking.Sntp/nf_networking_sntp.cpp b/src/DeviceInterfaces/Networking.Sntp/nf_networking_sntp.cpp index c10c221474..42d00ed56c 100644 --- a/src/DeviceInterfaces/Networking.Sntp/nf_networking_sntp.cpp +++ b/src/DeviceInterfaces/Networking.Sntp/nf_networking_sntp.cpp @@ -9,7 +9,7 @@ static const CLR_RT_MethodHandler method_lookup[] = { - NULL, + nullptr, Library_nf_networking_sntp_nanoFramework_Networking_Sntp::Start___STATIC__VOID, Library_nf_networking_sntp_nanoFramework_Networking_Sntp::Stop___STATIC__VOID, Library_nf_networking_sntp_nanoFramework_Networking_Sntp::UpdateNow___STATIC__VOID, diff --git a/src/DeviceInterfaces/System.Net/sys_net_native.cpp b/src/DeviceInterfaces/System.Net/sys_net_native.cpp index 1be14bfbdd..ed629b6894 100644 --- a/src/DeviceInterfaces/System.Net/sys_net_native.cpp +++ b/src/DeviceInterfaces/System.Net/sys_net_native.cpp @@ -10,190 +10,190 @@ static const CLR_RT_MethodHandler method_lookup[] = { - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, Library_sys_net_native_System_Net_NetworkInformation_NetworkInterface::InitializeNetworkInterfaceSettings___VOID, Library_sys_net_native_System_Net_NetworkInformation_NetworkInterface::UpdateConfiguration___VOID__I4, Library_sys_net_native_System_Net_NetworkInformation_NetworkInterface::GetIsNetworkAvailable___STATIC__BOOLEAN, - NULL, + nullptr, Library_sys_net_native_System_Net_NetworkInformation_NetworkInterface::GetNetworkInterfaceCount___STATIC__I4, Library_sys_net_native_System_Net_NetworkInformation_NetworkInterface::GetNetworkInterface___STATIC__SystemNetNetworkInformationNetworkInterface__U4, Library_sys_net_native_System_Net_NetworkInformation_NetworkInterface::IPV4AddressFromString___STATIC__I8__STRING, Library_sys_net_native_System_Net_NetworkInformation_NetworkInterface::IPV6AddressFromString___STATIC__SZARRAY_U2__STRING, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, Library_sys_net_native_System_Net_IPAddress::IPv4ToString___STATIC__STRING__U4, Library_sys_net_native_System_Net_IPAddress::IPv6ToString___STATIC__STRING__SZARRAY_U2, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, Library_sys_net_native_System_Net_NetworkInformation_IPGlobalProperties::GetIPAddress___STATIC__SystemNetIPAddress, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, Library_sys_net_native_System_Net_NetworkInformation_Wireless80211Configuration::GetWireless82011ConfigurationCount___STATIC__I4, Library_sys_net_native_System_Net_NetworkInformation_Wireless80211Configuration::GetWireless82011Configuration___STATIC__SystemNetNetworkInformationWireless80211Configuration__I4, Library_sys_net_native_System_Net_NetworkInformation_Wireless80211Configuration::UpdateConfiguration___STATIC__VOID, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, Library_sys_net_native_System_Net_NetworkInformation_WirelessAPConfiguration::GetWirelessAPConfigurationCount___STATIC__I4, Library_sys_net_native_System_Net_NetworkInformation_WirelessAPConfiguration::GetWirelessAPConfiguration___STATIC__SystemNetNetworkInformationWirelessAPConfiguration__I4, Library_sys_net_native_System_Net_NetworkInformation_WirelessAPConfiguration::UpdateConfiguration___STATIC__VOID, Library_sys_net_native_System_Net_NetworkInformation_WirelessAPConfiguration::NativeGetConnectedClients___STATIC__SZARRAY_SystemNetNetworkInformationWirelessAPStation__I4, Library_sys_net_native_System_Net_NetworkInformation_WirelessAPConfiguration::NativeDeauthStation___STATIC__STRING__I4, - NULL, - NULL, + nullptr, + nullptr, Library_sys_net_native_System_Net_Security_CertificateManager::AddCaCertificateBundle___STATIC__BOOLEAN__SZARRAY_U1, Library_sys_net_native_System_Net_Security_SslNative::SecureServerInit___STATIC__I4__I4__I4__SystemSecurityCryptographyX509CertificatesX509Certificate__SystemSecurityCryptographyX509CertificatesX509Certificate__BOOLEAN, Library_sys_net_native_System_Net_Security_SslNative::SecureClientInit___STATIC__I4__I4__I4__SystemSecurityCryptographyX509CertificatesX509Certificate__SystemSecurityCryptographyX509CertificatesX509Certificate__BOOLEAN, @@ -204,87 +204,87 @@ static const CLR_RT_MethodHandler method_lookup[] = Library_sys_net_native_System_Net_Security_SslNative::SecureCloseSocket___STATIC__I4__OBJECT, Library_sys_net_native_System_Net_Security_SslNative::ExitSecureContext___STATIC__I4__I4, Library_sys_net_native_System_Net_Security_SslNative::DataAvailable___STATIC__I4__OBJECT, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, Library_sys_net_native_System_Security_Cryptography_X509Certificates_X509Certificate::ParseCertificate___STATIC__VOID__SZARRAY_U1__BYREF_STRING__BYREF_STRING__BYREF_SystemDateTime__BYREF_SystemDateTime, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, Library_sys_net_native_System_Net_Sockets_NativeSocket::socket___STATIC__I4__I4__I4__I4, Library_sys_net_native_System_Net_Sockets_NativeSocket::bind___STATIC__VOID__OBJECT__SystemNetEndPoint, Library_sys_net_native_System_Net_Sockets_NativeSocket::connect___STATIC__VOID__OBJECT__SystemNetEndPoint__BOOLEAN, @@ -303,42 +303,42 @@ static const CLR_RT_MethodHandler method_lookup[] = Library_sys_net_native_System_Net_Sockets_NativeSocket::setsockopt___STATIC__VOID__OBJECT__I4__I4__SZARRAY_U1, Library_sys_net_native_System_Net_Sockets_NativeSocket::poll___STATIC__BOOLEAN__OBJECT__I4__I4, Library_sys_net_native_System_Net_Sockets_NativeSocket::ioctl___STATIC__VOID__OBJECT__U4__BYREF_U4, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, Library_sys_net_native_System_Security_Cryptography_X509Certificates_X509Certificate2::DecodePrivateKeyNative___STATIC__VOID__SZARRAY_U1__STRING, }; diff --git a/src/DeviceInterfaces/System.Net/sys_net_native_System_Net_NetworkInformation_NetworkInterface.cpp b/src/DeviceInterfaces/System.Net/sys_net_native_System_Net_NetworkInformation_NetworkInterface.cpp index 1dcfefb721..d18959d560 100644 --- a/src/DeviceInterfaces/System.Net/sys_net_native_System_Net_NetworkInformation_NetworkInterface.cpp +++ b/src/DeviceInterfaces/System.Net/sys_net_native_System_Net_NetworkInformation_NetworkInterface.cpp @@ -58,7 +58,7 @@ HRESULT Library_sys_net_native_System_Net_NetworkInformation_NetworkInterface:: NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_Array::CreateInstance( pConfig[FIELD___macAddress], NETIF_MAX_HWADDR_LEN, - g_CLR_RT_WellKnownTypes.m_UInt8)); + g_CLR_RT_WellKnownTypes.UInt8)); memcpy(pConfig[FIELD___macAddress].DereferenceArray()->GetFirstElement(), config.MacAddress, NETIF_MAX_HWADDR_LEN); NANOCLR_NOCLEANUP(); @@ -183,7 +183,7 @@ HRESULT Library_sys_net_native_System_Net_NetworkInformation_NetworkInterface::U config.SpecificConfigId = (CLR_UINT32)pConfig[FIELD___specificConfigId].NumericByRef().u4; config.StartupAddressMode = (AddressMode)pConfig[FIELD___startupAddressMode].NumericByRef().u4; - if (pMACAddress != NULL) + if (pMACAddress != nullptr) { memcpy(&config.MacAddress, pMACAddress->GetFirstElement(), NETIF_MAX_HWADDR_LEN); } @@ -271,7 +271,7 @@ HRESULT Library_sys_net_native_System_Net_NetworkInformation_NetworkInterface:: // now load adapter configuration on top of the stored config NANOCLR_CHECK_HRESULT(SOCK_CONFIGURATION_LoadConfiguration(&config, interfaceIndex)); - NANOCLR_CHECK_HRESULT(g_CLR_RT_ExecutionEngine.NewObjectFromIndex(top, g_CLR_RT_WellKnownTypes.m_NetworkInterface)); + NANOCLR_CHECK_HRESULT(g_CLR_RT_ExecutionEngine.NewObjectFromIndex(top, g_CLR_RT_WellKnownTypes.NetworkInterface)); pConfig = top.Dereference(); FAULT_ON_NULL(pConfig); @@ -298,7 +298,7 @@ HRESULT Library_sys_net_native_System_Net_NetworkInformation_NetworkInterface:: NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_Array::CreateInstance( pConfig[FIELD___macAddress], NETIF_MAX_HWADDR_LEN, - g_CLR_RT_WellKnownTypes.m_UInt8)); + g_CLR_RT_WellKnownTypes.UInt8)); memcpy(pConfig[FIELD___macAddress].DereferenceArray()->GetFirstElement(), config.MacAddress, NETIF_MAX_HWADDR_LEN); NANOCLR_NOCLEANUP(); @@ -334,7 +334,7 @@ HRESULT Library_sys_net_native_System_Net_NetworkInformation_NetworkInterface:: // Return array of uint16[8] NANOCLR_CHECK_HRESULT( - CLR_RT_HeapBlock_Array::CreateInstance(stack.PushValueAndClear(), 8, g_CLR_RT_WellKnownTypes.m_UInt16)); + CLR_RT_HeapBlock_Array::CreateInstance(stack.PushValueAndClear(), 8, g_CLR_RT_WellKnownTypes.UInt16)); { uint16_t *p = (uint16_t *)stack.TopValue().DereferenceArray()->GetFirstElement(); memcpy(p, address, sizeof(address)); diff --git a/src/DeviceInterfaces/System.Net/sys_net_native_System_Net_NetworkInformation_Wireless80211Configuration.cpp b/src/DeviceInterfaces/System.Net/sys_net_native_System_Net_NetworkInformation_Wireless80211Configuration.cpp index 3ce304bcd5..46acfc3f1b 100644 --- a/src/DeviceInterfaces/System.Net/sys_net_native_System_Net_NetworkInformation_Wireless80211Configuration.cpp +++ b/src/DeviceInterfaces/System.Net/sys_net_native_System_Net_NetworkInformation_Wireless80211Configuration.cpp @@ -43,7 +43,7 @@ HRESULT Library_sys_net_native_System_Net_NetworkInformation_Wireless80211Config // create new object for configuration NANOCLR_CHECK_HRESULT( - g_CLR_RT_ExecutionEngine.NewObjectFromIndex(top, g_CLR_RT_WellKnownTypes.m_Wireless80211Configuration)); + g_CLR_RT_ExecutionEngine.NewObjectFromIndex(top, g_CLR_RT_WellKnownTypes.Wireless80211Configuration)); // load from stack pConfig = top.Dereference(); @@ -75,12 +75,12 @@ HRESULT Library_sys_net_native_System_Net_NetworkInformation_Wireless80211Config HAL_Configuration_Wireless80211 config; CLR_RT_HeapBlock *pConfig = stack.Arg0().Dereference(); - _ASSERTE(pConfig != NULL); + _ASSERTE(pConfig != nullptr); CLR_UINT32 configurationIndex = pConfig[FIELD___configurationIndex].NumericByRefConst().u4; - CLR_RT_HeapBlock_String *hbPassword = NULL; - CLR_RT_HeapBlock_String *hbSsid = NULL; + CLR_RT_HeapBlock_String *hbPassword = nullptr; + CLR_RT_HeapBlock_String *hbSsid = nullptr; CLR_UINT32 ssidLength; CLR_UINT32 passwordLength; @@ -89,6 +89,7 @@ HRESULT Library_sys_net_native_System_Net_NetworkInformation_Wireless80211Config config.Id = (CLR_UINT32)pConfig[FIELD___id].NumericByRef().u4; config.Authentication = (AuthenticationType)pConfig[FIELD___authentication].NumericByRef().u4; config.Encryption = (EncryptionType)pConfig[FIELD___encryption].NumericByRef().u4; + config.Radio = (RadioType)pConfig[FIELD___radio].NumericByRef().u4; config.Options = (Wireless80211Configuration_ConfigurationOptions)pConfig[FIELD___options].NumericByRef().u1; @@ -96,9 +97,14 @@ HRESULT Library_sys_net_native_System_Net_NetworkInformation_Wireless80211Config // make sure the terminators are there hbPassword = pConfig[FIELD___password].DereferenceString(); FAULT_ON_NULL(hbPassword); + passwordLength = hal_strlen_s(hbPassword->StringText()); + if (passwordLength >= sizeof(config.Password)) + { NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER); + } + hal_strncpy_s( (char *)config.Password, WIRELESS82011_CONFIG_MAX_PASSWORD_LEN, @@ -107,9 +113,14 @@ HRESULT Library_sys_net_native_System_Net_NetworkInformation_Wireless80211Config hbSsid = pConfig[FIELD___ssid].DereferenceString(); FAULT_ON_NULL(hbSsid); + ssidLength = hal_strlen_s(hbSsid->StringText()); + if (ssidLength >= sizeof(config.Ssid)) + { NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER); + } + hal_strncpy_s((char *)config.Ssid, WIRELESS82011_CONFIG_MAX_SSID_LEN, hbSsid->StringText(), ssidLength); // store configuration diff --git a/src/DeviceInterfaces/System.Net/sys_net_native_System_Net_NetworkInformation_WirelessAPConfiguration.cpp b/src/DeviceInterfaces/System.Net/sys_net_native_System_Net_NetworkInformation_WirelessAPConfiguration.cpp index e7ee608a9a..19366bafb7 100644 --- a/src/DeviceInterfaces/System.Net/sys_net_native_System_Net_NetworkInformation_WirelessAPConfiguration.cpp +++ b/src/DeviceInterfaces/System.Net/sys_net_native_System_Net_NetworkInformation_WirelessAPConfiguration.cpp @@ -52,7 +52,7 @@ HRESULT Library_sys_net_native_System_Net_NetworkInformation_WirelessAPConfigura // create new object for configuration NANOCLR_CHECK_HRESULT( - g_CLR_RT_ExecutionEngine.NewObjectFromIndex(top, g_CLR_RT_WellKnownTypes.m_WirelessAPConfiguration)); + g_CLR_RT_ExecutionEngine.NewObjectFromIndex(top, g_CLR_RT_WellKnownTypes.WirelessAPConfiguration)); // load from stack pConfig = top.Dereference(); @@ -94,12 +94,12 @@ HRESULT Library_sys_net_native_System_Net_NetworkInformation_WirelessAPConfigura HAL_Configuration_WirelessAP config; CLR_RT_HeapBlock *pConfig = stack.Arg0().Dereference(); - _ASSERTE(pConfig != NULL); + _ASSERTE(pConfig != nullptr); CLR_UINT32 configurationIndex = pConfig[FIELD___apConfigurationIndex].NumericByRefConst().u4; - CLR_RT_HeapBlock_String *hbPassword = NULL; - CLR_RT_HeapBlock_String *hbSsid = NULL; + CLR_RT_HeapBlock_String *hbPassword = nullptr; + CLR_RT_HeapBlock_String *hbSsid = nullptr; CLR_UINT32 ssidLength; CLR_UINT32 passwordLength; @@ -227,7 +227,7 @@ HRESULT Library_sys_net_native_System_Net_NetworkInformation_WirelessAPConfigura NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_Array::CreateInstance( hbObj[Library_sys_net_native_System_Net_NetworkInformation_WirelessAPStation::FIELD___macAddress], 6, - g_CLR_RT_WellKnownTypes.m_UInt8)); + g_CLR_RT_WellKnownTypes.UInt8)); memcpy( hbObj[Library_sys_net_native_System_Net_NetworkInformation_WirelessAPStation::FIELD___macAddress] .DereferenceArray() diff --git a/src/DeviceInterfaces/System.Net/sys_net_native_System_Net_Security_CertificateManager.cpp b/src/DeviceInterfaces/System.Net/sys_net_native_System_Net_Security_CertificateManager.cpp index fad2c19d73..e4fa5c9031 100644 --- a/src/DeviceInterfaces/System.Net/sys_net_native_System_Net_Security_CertificateManager.cpp +++ b/src/DeviceInterfaces/System.Net/sys_net_native_System_Net_Security_CertificateManager.cpp @@ -14,7 +14,7 @@ HRESULT Library_sys_net_native_System_Net_Security_CertificateManager:: uint32_t certificateSize; uint32_t allocationSize; - HAL_Configuration_X509CaRootBundle *caBundle = NULL; + HAL_Configuration_X509CaRootBundle *caBundle = nullptr; CLR_RT_HeapBlock_Array *arrayCA = stack.Arg0().DereferenceArray(); @@ -74,7 +74,7 @@ HRESULT Library_sys_net_native_System_Net_Security_CertificateManager:: NANOCLR_CLEANUP(); - if (caBundle != NULL) + if (caBundle != nullptr) { platform_free(caBundle); } diff --git a/src/DeviceInterfaces/System.Net/sys_net_native_System_Net_Security_SslNative.cpp b/src/DeviceInterfaces/System.Net/sys_net_native_System_Net_Security_SslNative.cpp index 256177d366..8a4f4d2b8a 100644 --- a/src/DeviceInterfaces/System.Net/sys_net_native_System_Net_Security_SslNative.cpp +++ b/src/DeviceInterfaces/System.Net/sys_net_native_System_Net_Security_SslNative.cpp @@ -419,15 +419,15 @@ HRESULT Library_sys_net_native_System_Net_Security_SslNative::InitHelper(CLR_RT_ CLR_RT_HeapBlock *hbCert = stack.Arg2().Dereference(); CLR_RT_HeapBlock *caCert = stack.Arg3().Dereference(); bool useDeviceCertificate = (bool)stack.Arg4().NumericByRef().u1; - CLR_RT_HeapBlock_Array *arrCert = NULL; - CLR_RT_HeapBlock_Array *privateKey = NULL; - CLR_UINT8 *sslCert = NULL; + CLR_RT_HeapBlock_Array *arrCert = nullptr; + CLR_RT_HeapBlock_Array *privateKey = nullptr; + CLR_UINT8 *sslCert = nullptr; volatile int result; - uint8_t *pk = NULL; - const char *pkPassword = NULL; + uint8_t *pk = nullptr; + const char *pkPassword = nullptr; CLR_UINT32 pkPasswordLength = 0; - if (hbCert != NULL) + if (hbCert != nullptr) { g_CLR_RT_TypeSystem.FindTypeDef( "X509Certificate2", @@ -471,9 +471,9 @@ HRESULT Library_sys_net_native_System_Net_Security_SslNative::InitHelper(CLR_RT_ sslMode, sslVerify, (const char *)sslCert, - sslCert == NULL ? 0 : arrCert->m_numOfElements, + sslCert == nullptr ? 0 : arrCert->m_numOfElements, pk, - pk == NULL ? 0 : privateKey->m_numOfElements, + pk == nullptr ? 0 : privateKey->m_numOfElements, pkPassword, pkPasswordLength, sslContext, @@ -488,9 +488,9 @@ HRESULT Library_sys_net_native_System_Net_Security_SslNative::InitHelper(CLR_RT_ sslMode, sslVerify, (const char *)sslCert, - sslCert == NULL ? 0 : arrCert->m_numOfElements, + sslCert == nullptr ? 0 : arrCert->m_numOfElements, pk, - pk == NULL ? 0 : privateKey->m_numOfElements, + pk == nullptr ? 0 : privateKey->m_numOfElements, pkPassword, pkPasswordLength, sslContext, @@ -501,12 +501,12 @@ HRESULT Library_sys_net_native_System_Net_Security_SslNative::InitHelper(CLR_RT_ NANOCLR_CHECK_HRESULT(ThrowOnError(stack, result)); - if (caCert != NULL) + if (caCert != nullptr) { arrCert = caCert[X509Certificate::FIELD___certificate].DereferenceArray(); - // If arrCert == NULL then the certificate is an X509Certificate2 which uses a certificate handle - if (arrCert == NULL) + // If arrCert == nullptr then the certificate is an X509Certificate2 which uses a certificate handle + if (arrCert == nullptr) { arrCert = caCert[X509Certificate::FIELD___handle].DereferenceArray(); FAULT_ON_NULL(arrCert); @@ -552,7 +552,7 @@ void Library_sys_net_native_System_Net_Security_SslNative::ThrowError(CLR_RT_Sta if ((Library_corlib_native_System_Exception::CreateInstance( res, - g_CLR_RT_WellKnownTypes.m_SocketException, + g_CLR_RT_WellKnownTypes.SocketException, CLR_E_FAIL, &stack)) == S_OK) { diff --git a/src/DeviceInterfaces/System.Net/sys_net_native_System_Net_Sockets_NativeSocket.cpp b/src/DeviceInterfaces/System.Net/sys_net_native_System_Net_Sockets_NativeSocket.cpp index 751fd014f7..de037df3aa 100644 --- a/src/DeviceInterfaces/System.Net/sys_net_native_System_Net_Sockets_NativeSocket.cpp +++ b/src/DeviceInterfaces/System.Net/sys_net_native_System_Net_Sockets_NativeSocket.cpp @@ -120,7 +120,7 @@ HRESULT Library_sys_net_native_System_Net_Sockets_NativeSocket::accept___STATIC_ NANOCLR_SET_AND_LEAVE(CLR_E_PROCESS_EXCEPTION); } - ret = SOCK_accept(handle, NULL, NULL); + ret = SOCK_accept(handle, nullptr, nullptr); if (ret != SOCK_SOCKET_ERROR) { @@ -142,7 +142,7 @@ HRESULT Library_sys_net_native_System_Net_Sockets_NativeSocket:: LPCSTR szName = stack.Arg0().RecoverString(); struct SOCK_addrinfo hints; - struct SOCK_addrinfo *addr = NULL; + struct SOCK_addrinfo *addr = nullptr; struct SOCK_addrinfo *addrT; CLR_UINT32 cAddresses = 0; CLR_RT_HeapBlock *pAddress; @@ -162,7 +162,7 @@ HRESULT Library_sys_net_native_System_Net_Sockets_NativeSocket:: { memset(&hints, 0, sizeof(hints)); - ret = SOCK_getaddrinfo(szName, NULL, &hints, &addr); + ret = SOCK_getaddrinfo(szName, nullptr, &hints, &addr); if (ret == SOCK_SOCKET_ERROR) { @@ -216,17 +216,17 @@ HRESULT Library_sys_net_native_System_Net_Sockets_NativeSocket:: CLR_RT_HeapBlock hbCanonicalName; CLR_RT_HeapBlock hbAddresses; - hbCanonicalName.SetObjectReference(NULL); + hbCanonicalName.SetObjectReference(nullptr); CLR_RT_ProtectFromGC gc(hbCanonicalName); - hbAddresses.SetObjectReference(NULL); + hbAddresses.SetObjectReference(nullptr); CLR_RT_ProtectFromGC gc2(hbAddresses); for (int pass = 0; pass < 2; pass++) { cAddresses = 0; - for (addrT = addr; addrT != NULL; addrT = addrT->ai_next) + for (addrT = addr; addrT != nullptr; addrT = addrT->ai_next) { if (pass == 1) { @@ -244,7 +244,7 @@ HRESULT Library_sys_net_native_System_Net_Sockets_NativeSocket:: NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_Array::CreateInstance( *pAddress, (CLR_UINT32)addrT->ai_addrlen, - g_CLR_RT_WellKnownTypes.m_UInt8)); + g_CLR_RT_WellKnownTypes.UInt8)); // copy address. memcpy(pAddress->DereferenceArray()->GetFirstElement(), addrT->ai_addr, addrT->ai_addrlen); @@ -258,9 +258,9 @@ HRESULT Library_sys_net_native_System_Net_Sockets_NativeSocket:: // allocate array of byte arrays CLR_RT_ReflectionDef_Index idx; - idx.m_kind = REFLECTION_TYPE; - idx.m_levels = 2; - idx.m_data.m_type.m_data = g_CLR_RT_WellKnownTypes.m_UInt8.m_data; + idx.kind = REFLECTION_TYPE; + idx.levels = 2; + idx.data.type.data = g_CLR_RT_WellKnownTypes.UInt8.data; NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_Array::CreateInstance(hbAddresses, cAddresses, idx)); @@ -473,9 +473,9 @@ HRESULT Library_sys_net_native_System_Net_Sockets_NativeSocket::BindConnectHelpe CLR_INT32 Library_sys_net_native_System_Net_Sockets_NativeSocket::Helper__SelectSocket(CLR_INT32 handle, CLR_INT32 mode) { struct SOCK_timeval timeval; - SOCK_fd_set *readfds = NULL; - SOCK_fd_set *writefds = NULL; - SOCK_fd_set *exceptfds = NULL; + SOCK_fd_set *readfds = nullptr; + SOCK_fd_set *writefds = nullptr; + SOCK_fd_set *exceptfds = nullptr; SOCK_fd_set fds; SOCK_fd_set fdsExcept; CLR_INT32 res = 0; @@ -503,7 +503,7 @@ CLR_INT32 Library_sys_net_native_System_Net_Sockets_NativeSocket::Helper__Select // for a read, a write or an except. This causes a problem when there is a socket exception. The // poll will continue to block forever because the select statement wasn't looking for exceptions // Therefore, we will force the select call to look for the except case if it is not already doing it. - if (exceptfds == NULL) + if (exceptfds == nullptr) { fdsExcept.fd_count = 1; fdsExcept.fd_array[0] = handle; @@ -548,11 +548,11 @@ HRESULT Library_sys_net_native_System_Net_Sockets_NativeSocket::MarshalSockAddre CLR_RT_HeapBlock *ipEndPointHbObj; CLR_RT_HeapBlock ipAddress; - ipAddress.SetObjectReference(NULL); + ipAddress.SetObjectReference(nullptr); CLR_RT_ProtectFromGC gc1(ipAddress); CLR_RT_HeapBlock ipEndPoint; - ipEndPoint.SetObjectReference(NULL); + ipEndPoint.SetObjectReference(nullptr); CLR_RT_ProtectFromGC gc2(ipEndPoint); CLR_INT32 port; @@ -586,7 +586,7 @@ HRESULT Library_sys_net_native_System_Net_Sockets_NativeSocket::MarshalSockAddre ipAddressHbObj[Library_sys_net_native_System_Net_IPAddress::FIELD___numbers]; NANOCLR_CHECK_HRESULT( - CLR_RT_HeapBlock_Array::CreateInstance(numbersFieldRef, 8, g_CLR_RT_WellKnownTypes.m_UInt16)); + CLR_RT_HeapBlock_Array::CreateInstance(numbersFieldRef, 8, g_CLR_RT_WellKnownTypes.UInt16)); CLR_UINT16 *addrNumbers = (CLR_UINT16 *)numbersFieldRef.DereferenceArray()->GetFirstElement(); @@ -970,7 +970,7 @@ void Library_sys_net_native_System_Net_Sockets_NativeSocket::ThrowError(CLR_RT_S if ((Library_corlib_native_System_Exception::CreateInstance( res, - g_CLR_RT_WellKnownTypes.m_SocketException, + g_CLR_RT_WellKnownTypes.SocketException, CLR_E_FAIL, &stack)) == S_OK) { diff --git a/src/DeviceInterfaces/System.Net/sys_net_native_System_Security_Cryptography_X509Certificates_X509Certificate2.cpp b/src/DeviceInterfaces/System.Net/sys_net_native_System_Security_Cryptography_X509Certificates_X509Certificate2.cpp index a1022aa598..84d00bb134 100644 --- a/src/DeviceInterfaces/System.Net/sys_net_native_System_Security_Cryptography_X509Certificates_X509Certificate2.cpp +++ b/src/DeviceInterfaces/System.Net/sys_net_native_System_Security_Cryptography_X509Certificates_X509Certificate2.cpp @@ -15,7 +15,7 @@ HRESULT Library_sys_net_native_System_Security_Cryptography_X509Certificates_X50 CLR_RT_HeapBlock_Array *keyData = stack.Arg0().DereferenceArray(); CLR_UINT8 *keyBuffer; CLR_RT_HeapBlock *passwordHb = stack.Arg1().DereferenceString(); - const char *password = NULL; + const char *password = nullptr; CLR_UINT32 passwordLength = 0; // get key buffer diff --git a/src/HAL/Include/nanoHAL.h b/src/HAL/Include/nanoHAL.h index 9f778e2728..bd7272027a 100644 --- a/src/HAL/Include/nanoHAL.h +++ b/src/HAL/Include/nanoHAL.h @@ -141,8 +141,8 @@ template class HAL_DblLinkedNode public: void Initialize() { - m_nextNode = NULL; - m_prevNode = NULL; + m_nextNode = nullptr; + m_prevNode = nullptr; } T *Next() const @@ -165,7 +165,7 @@ template class HAL_DblLinkedNode bool IsLinked() const { - return m_nextNode != NULL; + return m_nextNode != nullptr; } //--// @@ -191,8 +191,8 @@ template class HAL_DblLinkedNode if (next) next->m_prevNode = prev; - m_nextNode = NULL; - m_prevNode = NULL; + m_nextNode = nullptr; + m_prevNode = nullptr; } }; @@ -222,7 +222,7 @@ template class HAL_DblLinkedList void Initialize() { m_first = Tail(); - m_null = NULL; + m_null = nullptr; m_last = Head(); } @@ -232,7 +232,7 @@ template class HAL_DblLinkedList T *ptrNext; int num = 0; - for (ptr = FirstNode(); (ptrNext = ptr->Next()) != NULL; ptr = ptrNext) + for (ptr = FirstNode(); (ptrNext = ptr->Next()) != nullptr; ptr = ptrNext) { num++; } @@ -258,12 +258,12 @@ template class HAL_DblLinkedList T *FirstValidNode() const { T *res = m_first; - return res->Next() ? res : NULL; + return res->Next() ? res : nullptr; } T *LastValidNode() const { T *res = m_last; - return res->Prev() ? res : NULL; + return res->Prev() ? res : nullptr; } T *Head() const @@ -292,7 +292,7 @@ template class HAL_DblLinkedList bool Exists(T *searchNode) { T *node = FirstValidNode(); - while (node != NULL && node != searchNode) + while (node != nullptr && node != searchNode) { if (node == node->Next()) { @@ -300,7 +300,7 @@ template class HAL_DblLinkedList } node = node->Next(); } - return (node == NULL ? false : true); + return (node == nullptr ? false : true); } #endif @@ -402,7 +402,7 @@ template class Hal_Queue_UnknownSize T *operator[](int index) { if (index < 0 || index >= NumberOfElements()) - return NULL; + return nullptr; return &m_data[(m_reader + index) % m_size]; } @@ -412,7 +412,7 @@ template class Hal_Queue_UnknownSize size_t oldWriter = m_writer; if (m_full) - return NULL; + return nullptr; m_writer++; if (m_writer == m_size) @@ -427,7 +427,7 @@ template class Hal_Queue_UnknownSize T *Peek() { if (m_writer == m_reader && !m_full) - return NULL; + return nullptr; return &m_data[m_reader]; } @@ -437,7 +437,7 @@ template class Hal_Queue_UnknownSize size_t oldReader = m_reader; if (m_reader == m_writer && !m_full) - return (T *)NULL; + return (T *)nullptr; m_reader++; if (m_reader == m_size) @@ -456,7 +456,7 @@ template class Hal_Queue_UnknownSize if (m_full || (nElements == 0)) { nElements = 0; - return NULL; + return nullptr; } if (m_writer < m_reader) @@ -482,7 +482,7 @@ template class Hal_Queue_UnknownSize size_t max = 0; if (nElements == 0) - return NULL; + return nullptr; if ((m_reader == m_writer) && !m_full) { @@ -490,7 +490,7 @@ template class Hal_Queue_UnknownSize // reset the reader/writer to maximize push potential m_reader = 0; m_writer = 0; - return NULL; + return nullptr; } if (m_writer <= m_reader) @@ -754,7 +754,7 @@ template class HAL_RingBuffer // store size of tail size_t tailSize = _write_index; - T *tempBuffer = NULL; + T *tempBuffer = nullptr; if (tailSize > 0) { diff --git a/src/HAL/Include/nanoHAL_Network.h b/src/HAL/Include/nanoHAL_Network.h index 2a965309ba..84cd437d27 100644 --- a/src/HAL/Include/nanoHAL_Network.h +++ b/src/HAL/Include/nanoHAL_Network.h @@ -202,7 +202,7 @@ typedef struct __nfpack HAL_Configuration_NetworkInterface // Specific configuration Id // Id of the configuration block specific for this interface type - // NULL otherwise + // nullptr otherwise // currently in use: // - HAL_Configuration_Wireless80211 for NetworkInterfaceType_Wireless80211 uint32_t SpecificConfigId; diff --git a/src/HAL/Include/nanoHAL_ReleaseInfo.h b/src/HAL/Include/nanoHAL_ReleaseInfo.h index f7fde4d1eb..1d79b2ea10 100644 --- a/src/HAL/Include/nanoHAL_ReleaseInfo.h +++ b/src/HAL/Include/nanoHAL_ReleaseInfo.h @@ -45,11 +45,11 @@ struct __nfpack NFReleaseInfo unsigned short minor = 0, unsigned short build = 0, unsigned short revision = 0, - const char *info = (const char *)NULL, + const char *info = (const char *)nullptr, size_t infoLen = 0, - const char *target = (const char *)NULL, + const char *target = (const char *)nullptr, size_t targetLen = 0, - const char *platform = (const char *)NULL, + const char *platform = (const char *)nullptr, size_t platformLen = 0); }; diff --git a/src/PAL/AsyncProcCall/AsyncCompletions.cpp b/src/PAL/AsyncProcCall/AsyncCompletions.cpp index 4806bcec9a..f3a42c4abf 100644 --- a/src/PAL/AsyncProcCall/AsyncCompletions.cpp +++ b/src/PAL/AsyncProcCall/AsyncCompletions.cpp @@ -200,7 +200,7 @@ void HAL_COMPLETION::WaitForInterrupts(uint64_t expireTimeInTicks, uint32_t slee int state; // Any Completion events been Queued ? - if (ptr->Next() == NULL) + if (ptr->Next() == nullptr) { // No state = setCompare | nilCompare; diff --git a/src/PAL/AsyncProcCall/AsyncContinuations.cpp b/src/PAL/AsyncProcCall/AsyncContinuations.cpp index df7fe6f1f1..599b787095 100644 --- a/src/PAL/AsyncProcCall/AsyncContinuations.cpp +++ b/src/PAL/AsyncProcCall/AsyncContinuations.cpp @@ -26,7 +26,7 @@ void HAL_CONTINUATION::InitializeList() void HAL_CONTINUATION::Enqueue() { NATIVE_PROFILE_PAL_ASYNC_PROC_CALL(); - if (this->GetEntryPoint() != NULL) + if (this->GetEntryPoint() != nullptr) { GLOBAL_LOCK(); @@ -54,12 +54,12 @@ bool HAL_CONTINUATION::Dequeue_And_Execute() // helpfull to make the call to release the global mutext happens bool result; - HAL_CONTINUATION *ptr = NULL; + HAL_CONTINUATION *ptr = nullptr; GLOBAL_LOCK(); ptr = g_HAL_Continuation_List.ExtractFirstNode(); GLOBAL_UNLOCK(); - if (ptr == NULL) + if (ptr == nullptr) { result = false; } diff --git a/src/PAL/COM/sockets/Sockets_debugger.cpp b/src/PAL/COM/sockets/Sockets_debugger.cpp index af1e9767ad..6552b5623e 100644 --- a/src/PAL/COM/sockets/Sockets_debugger.cpp +++ b/src/PAL/COM/sockets/Sockets_debugger.cpp @@ -308,7 +308,7 @@ int Sockets_LWIP_Driver::Read(int ComPortNum, char *Data, size_t size) } } - if (SOCK_SOCKET_ERROR != HAL_SOCK_select(SOCK_FD_SETSIZE, &readSet, NULL, NULL, &timeout)) + if (SOCK_SOCKET_ERROR != HAL_SOCK_select(SOCK_FD_SETSIZE, &readSet, nullptr, nullptr, &timeout)) { // we always perform an accept so that we handle pending connections // if we already are connected and the debug stream socket is still active, then we immediately close @@ -452,9 +452,9 @@ bool Sockets_LWIP_Driver::UpgradeToSsl( 0x04, (const char *)pDeviceCert, deviceCertLen, - NULL, + nullptr, 0, - NULL, + nullptr, 0, g_DebuggerPort_SslCtx_Handle, false)) @@ -503,7 +503,7 @@ bool Sockets_LWIP_Driver::InitializeMulticastDiscovery() if (g_Sockets_LWIP_Driver.s_discoveryInitialized) return TRUE; - MulticastResponseContinuation.InitializeCallback(MulticastDiscoveryRespond, NULL); + MulticastResponseContinuation.InitializeCallback(MulticastDiscoveryRespond, nullptr); // set up discovery socket to list to defined discovery port for any ip address memset(&sockAddr, 0, sizeof(sockAddr)); @@ -580,7 +580,7 @@ void Sockets_LWIP_Driver::MulticastDiscoverySchedule() privRead.fd_array[0] = g_Sockets_LWIP_Driver.m_multicastSocket; privRead.fd_count = 1; - if (1 == HAL_SOCK_select(1, &privRead, NULL, NULL, &to)) + if (1 == HAL_SOCK_select(1, &privRead, nullptr, nullptr, &to)) { if (!MulticastResponseContinuation.IsLinked()) { diff --git a/src/PAL/COM/sockets/sockets_lwip.cpp b/src/PAL/COM/sockets/sockets_lwip.cpp index 27b073aa19..a18547aa2f 100644 --- a/src/PAL/COM/sockets/sockets_lwip.cpp +++ b/src/PAL/COM/sockets/sockets_lwip.cpp @@ -260,7 +260,7 @@ void Sockets_LWIP_Driver::CloseConnections(bool fCloseDbg) { struct SocketRegisterMap &entry = g_Sockets_LWIP_Driver.m_socketHandles[i]; - if (entry.m_socket != SOCK_SOCKET_ERROR && entry.m_sslData != NULL) + if (entry.m_socket != SOCK_SOCKET_ERROR && entry.m_sslData != nullptr) { SSL_CloseSocket(entry.m_socket); } @@ -282,7 +282,7 @@ void Sockets_LWIP_Driver::CloseConnections(bool fCloseDbg) g_Sockets_LWIP_Driver.m_socketHandles[i].m_socket = SOCK_SOCKET_ERROR; g_Sockets_LWIP_Driver.m_socketHandles[i].m_flags = 0; - g_Sockets_LWIP_Driver.m_socketHandles[i].m_sslData = NULL; + g_Sockets_LWIP_Driver.m_socketHandles[i].m_sslData = nullptr; g_Sockets_LWIP_Driver.m_cntSockets--; } else if (i > 0) @@ -422,7 +422,7 @@ bool Sockets_LWIP_Driver::Initialize() { g_Sockets_LWIP_Driver.m_socketHandles[i].m_socket = SOCK_SOCKET_ERROR; g_Sockets_LWIP_Driver.m_socketHandles[i].m_flags = 0; - g_Sockets_LWIP_Driver.m_socketHandles[i].m_sslData = NULL; + g_Sockets_LWIP_Driver.m_socketHandles[i].m_sslData = nullptr; } SOCKET_CHECK_bool(HAL_SOCK_Initialize()); @@ -496,7 +496,7 @@ void Sockets_LWIP_Driver::RegisterSocket(SOCK_SOCKET sock, bool selectable, bool g_Sockets_LWIP_Driver.m_socketHandles[g_Sockets_LWIP_Driver.m_cntSockets].m_socket = sock; g_Sockets_LWIP_Driver.m_socketHandles[g_Sockets_LWIP_Driver.m_cntSockets].m_flags = 0; - g_Sockets_LWIP_Driver.m_socketHandles[g_Sockets_LWIP_Driver.m_cntSockets].m_sslData = NULL; + g_Sockets_LWIP_Driver.m_socketHandles[g_Sockets_LWIP_Driver.m_cntSockets].m_sslData = nullptr; if (fDebug) SET_SOCKET_FLAG( diff --git a/src/PAL/COM/sockets/ssl/MbedTLS/ssl_accept_internal.cpp b/src/PAL/COM/sockets/ssl/MbedTLS/ssl_accept_internal.cpp index 44d00c44e3..2b4ad85f3e 100644 --- a/src/PAL/COM/sockets/ssl/MbedTLS/ssl_accept_internal.cpp +++ b/src/PAL/COM/sockets/ssl/MbedTLS/ssl_accept_internal.cpp @@ -23,7 +23,7 @@ int ssl_accept_internal(int sd, int contextHandle) ssl = context->ssl; // sanity check - if (ssl == NULL) + if (ssl == nullptr) { return SOCK_SOCKET_ERROR; } diff --git a/src/PAL/COM/sockets/ssl/MbedTLS/ssl_add_cert_auth_internal.cpp b/src/PAL/COM/sockets/ssl/MbedTLS/ssl_add_cert_auth_internal.cpp index dc25339fc8..80b502e0e9 100644 --- a/src/PAL/COM/sockets/ssl/MbedTLS/ssl_add_cert_auth_internal.cpp +++ b/src/PAL/COM/sockets/ssl/MbedTLS/ssl_add_cert_auth_internal.cpp @@ -20,7 +20,7 @@ bool ssl_add_cert_auth_internal(int contextHandle, const char *certificate, int // sd should already have been created context = (mbedTLS_NFContext *)g_SSL_Driver.ContextArray[contextHandle].Context; - if (context != NULL) + if (context != nullptr) { ///////////////////////////////////////////////////////////////////////////////////////////////// // developer notes: // @@ -30,7 +30,7 @@ bool ssl_add_cert_auth_internal(int contextHandle, const char *certificate, int if (mbedtls_x509_crt_parse(context->ca_cert, (const unsigned char *)certificate, certLength) == 0) { // add to CA chain - mbedtls_ssl_conf_ca_chain(context->conf, context->ca_cert, NULL); + mbedtls_ssl_conf_ca_chain(context->conf, context->ca_cert, nullptr); // done return true; diff --git a/src/PAL/COM/sockets/ssl/MbedTLS/ssl_available_internal.cpp b/src/PAL/COM/sockets/ssl/MbedTLS/ssl_available_internal.cpp index 591f835949..02f37622d2 100644 --- a/src/PAL/COM/sockets/ssl/MbedTLS/ssl_available_internal.cpp +++ b/src/PAL/COM/sockets/ssl/MbedTLS/ssl_available_internal.cpp @@ -13,14 +13,14 @@ int ssl_available_internal(int sd) mbedtls_ssl_context *ssl = context->ssl; // sanity check - if (ssl == NULL) + if (ssl == nullptr) { return SOCK_SOCKET_ERROR; } // Developer note - // Ideally we should be making a call to read passing a NULL pointer and requesting 0 bytes - // Like this: mbedtls_ssl_read(ssl, NULL, 0) + // Ideally we should be making a call to read passing a nullptr pointer and requesting 0 bytes + // Like this: mbedtls_ssl_read(ssl, nullptr, 0) // It won't work because we are using blockign sockets. // Even if we unblock it temporarily, it will still won't return until there is something to be read. // That call will block the execution and the watchdog will eventually kick in. diff --git a/src/PAL/COM/sockets/ssl/MbedTLS/ssl_close_socket_internal.cpp b/src/PAL/COM/sockets/ssl/MbedTLS/ssl_close_socket_internal.cpp index e69ced804b..355b542f75 100644 --- a/src/PAL/COM/sockets/ssl/MbedTLS/ssl_close_socket_internal.cpp +++ b/src/PAL/COM/sockets/ssl/MbedTLS/ssl_close_socket_internal.cpp @@ -11,14 +11,14 @@ int ssl_close_socket_internal(int sd) mbedTLS_NFContext *context = (mbedTLS_NFContext *)SOCKET_DRIVER.GetSocketSslData(sd); // sanity check - if (context != NULL) + if (context != nullptr) { mbedtls_ssl_context *ssl = context->ssl; // be nice and notify the peer that the connection is being closed mbedtls_ssl_close_notify(ssl); - SOCKET_DRIVER.SetSocketSslData(sd, NULL); + SOCKET_DRIVER.SetSocketSslData(sd, nullptr); } SOCK_close(sd); diff --git a/src/PAL/COM/sockets/ssl/MbedTLS/ssl_connect_internal.cpp b/src/PAL/COM/sockets/ssl/MbedTLS/ssl_connect_internal.cpp index 8edb996c23..2d99ff92b5 100644 --- a/src/PAL/COM/sockets/ssl/MbedTLS/ssl_connect_internal.cpp +++ b/src/PAL/COM/sockets/ssl/MbedTLS/ssl_connect_internal.cpp @@ -25,7 +25,7 @@ int ssl_connect_internal(int sd, const char *szTargetHost, int contextHandle) // sd should already have been created // Now do the SSL negotiation context = (mbedTLS_NFContext *)g_SSL_Driver.ContextArray[contextHandle].Context; - if (context == NULL) + if (context == nullptr) { return false; } @@ -33,7 +33,7 @@ int ssl_connect_internal(int sd, const char *szTargetHost, int contextHandle) // set socket in network context context->server_fd->fd = sd; - if (szTargetHost != NULL && szTargetHost[0] != 0) + if (szTargetHost != nullptr && szTargetHost[0] != 0) { if ((ret = mbedtls_ssl_set_hostname(context->ssl, szTargetHost)) != 0) { diff --git a/src/PAL/COM/sockets/ssl/MbedTLS/ssl_decode_private_key_internal.cpp b/src/PAL/COM/sockets/ssl/MbedTLS/ssl_decode_private_key_internal.cpp index 6c53716f4b..8c374fc3cc 100644 --- a/src/PAL/COM/sockets/ssl/MbedTLS/ssl_decode_private_key_internal.cpp +++ b/src/PAL/COM/sockets/ssl/MbedTLS/ssl_decode_private_key_internal.cpp @@ -57,7 +57,7 @@ int ssl_decode_private_key_internal( #if MBEDTLS_VERSION_MAJOR < 3 retCode = mbedtls_pk_parse_key(&pkey, key, keyLength, password, passwordLength); #else - retCode = mbedtls_pk_parse_key(&pkey, key, keyLength, password, passwordLength, random, NULL); + retCode = mbedtls_pk_parse_key(&pkey, key, keyLength, password, passwordLength, random, nullptr); #endif // need to free this here diff --git a/src/PAL/COM/sockets/ssl/MbedTLS/ssl_exit_context_internal.cpp b/src/PAL/COM/sockets/ssl/MbedTLS/ssl_exit_context_internal.cpp index 93d9358d19..51569df987 100644 --- a/src/PAL/COM/sockets/ssl/MbedTLS/ssl_exit_context_internal.cpp +++ b/src/PAL/COM/sockets/ssl/MbedTLS/ssl_exit_context_internal.cpp @@ -14,13 +14,13 @@ bool ssl_exit_context_internal(int contextHandle) // Check contextHandle range if ((contextHandle >= (int)ARRAYSIZE(g_SSL_Driver.ContextArray)) || (contextHandle < 0) || - (g_SSL_Driver.ContextArray[contextHandle].Context == NULL)) + (g_SSL_Driver.ContextArray[contextHandle].Context == nullptr)) { return false; } context = (mbedTLS_NFContext *)g_SSL_Driver.ContextArray[contextHandle].Context; - if (context == NULL) + if (context == nullptr) { return false; } diff --git a/src/PAL/COM/sockets/ssl/MbedTLS/ssl_generic.cpp b/src/PAL/COM/sockets/ssl/MbedTLS/ssl_generic.cpp index f2db6f340f..c0d2c63dda 100644 --- a/src/PAL/COM/sockets/ssl/MbedTLS/ssl_generic.cpp +++ b/src/PAL/COM/sockets/ssl/MbedTLS/ssl_generic.cpp @@ -156,7 +156,7 @@ int mbedtls_net_recv_timeout(void *ctx, unsigned char *buf, size_t len, uint32_t tv.tv_sec = timeout / 1000; tv.tv_usec = (timeout % 1000) * 1000; - ret = select(fd + 1, &read_fds, NULL, NULL, timeout == 0 ? NULL : &tv); + ret = select(fd + 1, &read_fds, nullptr, nullptr, timeout == 0 ? nullptr : &tv); /* Zero fds ready means we timed out */ if (ret == 0) diff --git a/src/PAL/COM/sockets/ssl/MbedTLS/ssl_generic_init_internal.cpp b/src/PAL/COM/sockets/ssl/MbedTLS/ssl_generic_init_internal.cpp index 47d6a34ea9..5e13456c43 100644 --- a/src/PAL/COM/sockets/ssl/MbedTLS/ssl_generic_init_internal.cpp +++ b/src/PAL/COM/sockets/ssl/MbedTLS/ssl_generic_init_internal.cpp @@ -32,15 +32,15 @@ bool ssl_generic_init_internal( int endpoint = 0; int ret = 0; - HAL_Configuration_X509CaRootBundle *certStore = NULL; - HAL_Configuration_X509DeviceCertificate *deviceCert = NULL; + HAL_Configuration_X509CaRootBundle *certStore = nullptr; + HAL_Configuration_X509DeviceCertificate *deviceCert = nullptr; /////////////////////// mbedTLS_NFContext *context; for (uint32_t i = 0; i < ARRAYSIZE(g_SSL_Driver.ContextArray); i++) { - if (g_SSL_Driver.ContextArray[i].Context == NULL) + if (g_SSL_Driver.ContextArray[i].Context == nullptr) { sslContexIndex = i; break; @@ -55,7 +55,7 @@ bool ssl_generic_init_internal( // create and init MbedTLS nanoFramework context // this needs to be freed in ssl_exit_context_internal context = (mbedTLS_NFContext *)platform_malloc(sizeof(mbedTLS_NFContext)); - if (context == NULL) + if (context == nullptr) { goto error; } @@ -65,7 +65,7 @@ bool ssl_generic_init_internal( // allocate memory for net context // this needs to be freed in ssl_exit_context_internal context->server_fd = (mbedtls_net_context *)platform_malloc(sizeof(mbedtls_net_context)); - if (context->server_fd == NULL) + if (context->server_fd == nullptr) { goto error; } @@ -84,7 +84,7 @@ bool ssl_generic_init_internal( // create and init SSL context // this needs to be freed in ssl_exit_context_internal context->ssl = (mbedtls_ssl_context *)platform_malloc(sizeof(mbedtls_ssl_context)); - if (context->ssl == NULL) + if (context->ssl == nullptr) { goto error; } @@ -93,7 +93,7 @@ bool ssl_generic_init_internal( // create and init SSL configuration // this needs to be freed in ssl_exit_context_internal context->conf = (mbedtls_ssl_config *)platform_malloc(sizeof(mbedtls_ssl_config)); - if (context->conf == NULL) + if (context->conf == nullptr) { goto error; } @@ -103,7 +103,7 @@ bool ssl_generic_init_internal( // create and init CTR_DRBG // this needs to be freed in ssl_exit_context_internal context->ctr_drbg = (mbedtls_ctr_drbg_context *)platform_malloc(sizeof(mbedtls_ctr_drbg_context)); - if (context->ctr_drbg == NULL) + if (context->ctr_drbg == nullptr) { goto error; } @@ -112,7 +112,7 @@ bool ssl_generic_init_internal( // create and init entropy context // this needs to be freed in ssl_exit_context_internal context->entropy = (mbedtls_entropy_context *)platform_malloc(sizeof(mbedtls_entropy_context)); - if (context->entropy == NULL) + if (context->entropy == nullptr) { goto error; } @@ -121,7 +121,7 @@ bool ssl_generic_init_internal( // create and init private key context // this needs to be freed in ssl_exit_context_internal context->pk = (mbedtls_pk_context *)platform_malloc(sizeof(mbedtls_pk_context)); - if (context->pk == NULL) + if (context->pk == nullptr) { goto error; } @@ -131,14 +131,14 @@ bool ssl_generic_init_internal( // create and init X509 CRT // this needs to be freed in ssl_exit_context_internal context->ca_cert = (mbedtls_x509_crt *)platform_malloc(sizeof(mbedtls_x509_crt)); - if (context->ca_cert == NULL) + if (context->ca_cert == nullptr) { goto error; } mbedtls_x509_crt_init(context->ca_cert); // TODO: review if we can add some instance-unique data to the custom argument below - if (mbedtls_ctr_drbg_seed(context->ctr_drbg, mbedtls_entropy_func, context->entropy, NULL, 0) != 0) + if (mbedtls_ctr_drbg_seed(context->ctr_drbg, mbedtls_entropy_func, context->entropy, nullptr, 0) != 0) { // ctr_drbg_seed_failed goto error; @@ -212,7 +212,7 @@ bool ssl_generic_init_internal( certStore->CertificateSize); platform_free(certStore); - certStore = NULL; + certStore = nullptr; } } @@ -237,10 +237,10 @@ bool ssl_generic_init_internal( } // parse "own" certificate if passed - if (certificate != NULL && certLength > 0) + if (certificate != nullptr && certLength > 0) { // is there a private key? - if (privateKey != NULL && privateKeyLength > 0) + if (privateKey != nullptr && privateKeyLength > 0) { if (mbedtls_pk_parse_key( context->pk, @@ -263,7 +263,7 @@ bool ssl_generic_init_internal( // parse certificate // this needs to be freed in ssl_exit_context_internal context->own_cert = (mbedtls_x509_crt *)platform_malloc(sizeof(mbedtls_x509_crt)); - if (context->own_cert == NULL) + if (context->own_cert == nullptr) { goto error; } @@ -286,18 +286,18 @@ bool ssl_generic_init_internal( if (deviceCert) { platform_free(deviceCert); - deviceCert = NULL; + deviceCert = nullptr; } } else { - // no PK, need to set it to NULL + // no PK, need to set it to nullptr mbedtls_pk_free(context->pk); platform_free(context->pk); - context->pk = NULL; + context->pk = nullptr; } - mbedtls_ssl_conf_ca_chain(context->conf, context->ca_cert, NULL); + mbedtls_ssl_conf_ca_chain(context->conf, context->ca_cert, nullptr); psa_crypto_init(); diff --git a/src/PAL/COM/sockets/ssl/MbedTLS/ssl_read_internal.cpp b/src/PAL/COM/sockets/ssl/MbedTLS/ssl_read_internal.cpp index 8c62182537..1187d491ef 100644 --- a/src/PAL/COM/sockets/ssl/MbedTLS/ssl_read_internal.cpp +++ b/src/PAL/COM/sockets/ssl/MbedTLS/ssl_read_internal.cpp @@ -12,7 +12,7 @@ int ssl_read_internal(int sd, char *data, size_t size) mbedtls_ssl_context *ssl = context->ssl; // sanity check - if (ssl == NULL) + if (ssl == nullptr) { return SOCK_SOCKET_ERROR; } diff --git a/src/PAL/COM/sockets/ssl/MbedTLS/ssl_uninitialize_internal.cpp b/src/PAL/COM/sockets/ssl/MbedTLS/ssl_uninitialize_internal.cpp index e13213b5ef..0a5165a79a 100644 --- a/src/PAL/COM/sockets/ssl/MbedTLS/ssl_uninitialize_internal.cpp +++ b/src/PAL/COM/sockets/ssl/MbedTLS/ssl_uninitialize_internal.cpp @@ -16,7 +16,7 @@ bool ssl_uninitialize_internal() for (uint32_t i = 0; i < ARRAYSIZE(g_SSL_Driver.ContextArray); i++) { - if (g_SSL_Driver.ContextArray[i].Context != NULL) + if (g_SSL_Driver.ContextArray[i].Context != nullptr) { ssl_exit_context_internal(i); } diff --git a/src/PAL/COM/sockets/ssl/MbedTLS/ssl_write_internal.cpp b/src/PAL/COM/sockets/ssl/MbedTLS/ssl_write_internal.cpp index ba52a5704d..9545fdc50a 100644 --- a/src/PAL/COM/sockets/ssl/MbedTLS/ssl_write_internal.cpp +++ b/src/PAL/COM/sockets/ssl/MbedTLS/ssl_write_internal.cpp @@ -15,7 +15,7 @@ int ssl_write_internal(int sd, const char *data, size_t req_len) mbedtls_ssl_context *ssl = context->ssl; // sanity check - if (ssl == NULL) + if (ssl == nullptr) { return SOCK_SOCKET_ERROR; } diff --git a/src/PAL/COM/sockets/ssl/ssl.cpp b/src/PAL/COM/sockets/ssl/ssl.cpp index 2d418672ed..f153ef46d3 100644 --- a/src/PAL/COM/sockets/ssl/ssl.cpp +++ b/src/PAL/COM/sockets/ssl/ssl.cpp @@ -27,7 +27,7 @@ bool SSL_Uninitialize() for (uint32_t i = 0; i < ARRAYSIZE(g_SSL_Driver.ContextArray); i++) { - if (g_SSL_Driver.ContextArray[i].Context != NULL) + if (g_SSL_Driver.ContextArray[i].Context != nullptr) { ssl_exit_context_internal(i); } diff --git a/src/PAL/Events/nanoPAL_Events.cpp b/src/PAL/Events/nanoPAL_Events.cpp index 05c0a9c88a..514014d942 100644 --- a/src/PAL/Events/nanoPAL_Events.cpp +++ b/src/PAL/Events/nanoPAL_Events.cpp @@ -8,8 +8,8 @@ static uint32_t systemEvents; -set_Event_Callback g_Event_Callback = NULL; -void *g_Event_Callback_Arg = NULL; +set_Event_Callback g_Event_Callback = nullptr; +void *g_Event_Callback_Arg = nullptr; // functions below declared as weak can be replaced at target/platform level if needed @@ -36,7 +36,7 @@ __nfweak void Events_Set(uint32_t events) __atomic_fetch_or(&systemEvents, events, __ATOMIC_RELAXED); #endif - if (g_Event_Callback != NULL) + if (g_Event_Callback != nullptr) { g_Event_Callback(g_Event_Callback_Arg); } diff --git a/src/PAL/Events/nanoPAL_Events_driver.cpp b/src/PAL/Events/nanoPAL_Events_driver.cpp index 993c7ef3ab..22367bf419 100644 --- a/src/PAL/Events/nanoPAL_Events_driver.cpp +++ b/src/PAL/Events/nanoPAL_Events_driver.cpp @@ -38,7 +38,7 @@ HRESULT PalEventDriver::PostEvent(uint32_t e, uint32_t param) { PalEventListener *listener = g_palEventDriver.listenerList.FirstNode(); - while(listener->Next() != NULL) + while(listener->Next() != nullptr) { if (listener->m_eventMask & e) { diff --git a/src/PAL/FileSystem/nanoPAL_FileSystem.cpp b/src/PAL/FileSystem/nanoPAL_FileSystem.cpp index 44575c1173..1cd1baad9b 100644 --- a/src/PAL/FileSystem/nanoPAL_FileSystem.cpp +++ b/src/PAL/FileSystem/nanoPAL_FileSystem.cpp @@ -15,9 +15,9 @@ HAL_DblLinkedList FileSystemVolumeList::s_zombieVolumeList; bool FS_MountVolume(const char *rootName, uint32_t deviceFlags, const char *fileSystemDriver) { - FileSystemVolume *volume = NULL; - FILESYSTEM_DRIVER_INTERFACE *fsDriver = NULL; - STREAM_DRIVER_INTERFACE *streamDriver = NULL; + FileSystemVolume *volume = nullptr; + FILESYSTEM_DRIVER_INTERFACE *fsDriver = nullptr; + STREAM_DRIVER_INTERFACE *streamDriver = nullptr; uint32_t volumeId; if (!rootName) @@ -41,7 +41,7 @@ bool FS_MountVolume(const char *rootName, uint32_t deviceFlags, const char *file if (!(next && next->Next())) { - next = NULL; + next = nullptr; } // We'll only free the memory of this storage device @@ -151,7 +151,7 @@ bool FileSystemVolumeList::InitializeVolumes() { FileSystemVolume *volume = s_volumeList.FirstNode(); - if (volume == NULL) + if (volume == nullptr) { #if defined(PLATFORM_ARM) debug_printf("There are no file system volume to initialize"); @@ -302,7 +302,7 @@ FileSystemVolume *FileSystemVolumeList::GetNextVolume(FileSystemVolume &volume) return nextVolume; } - return NULL; + return nullptr; } uint32_t FileSystemVolumeList::GetNumVolumes() @@ -333,7 +333,7 @@ FileSystemVolume *FileSystemVolumeList::FindVolume(const char *rootName, uint32_ volume = FileSystemVolumeList::GetNextVolume(*volume); } - return NULL; + return nullptr; } FileSystemVolume *FileSystemVolumeList::FindVolume(uint32_t volumeId) @@ -350,7 +350,7 @@ FileSystemVolume *FileSystemVolumeList::FindVolume(uint32_t volumeId) volume = FileSystemVolumeList::GetNextVolume(*volume); } - return NULL; + return nullptr; } uint32_t FileSystemVolumeList::GetNextFreeVolumeId() diff --git a/src/PAL/Lwip/lwIP_Sockets.cpp b/src/PAL/Lwip/lwIP_Sockets.cpp index 1088636712..f5a84edaee 100644 --- a/src/PAL/Lwip/lwIP_Sockets.cpp +++ b/src/PAL/Lwip/lwIP_Sockets.cpp @@ -83,7 +83,7 @@ HRESULT LWIP_SOCKETS_Driver::Link_status(uint32_t interfaceIndex, bool *status) struct netif *networkInterface = netif_find_interface(g_LWIP_SOCKETS_Driver.m_interfaces[interfaceIndex].m_interfaceNumber); - if (NULL == networkInterface) + if (nullptr == networkInterface) { return CLR_E_FAIL; } @@ -295,11 +295,11 @@ bool LWIP_SOCKETS_Driver::Initialize() int interfaceNumber; #if LWIP_NETIF_STATUS_CALLBACK == 1 - PostAddressChangedContinuation.InitializeCallback(PostAddressChanged, NULL); + PostAddressChangedContinuation.InitializeCallback(PostAddressChanged, nullptr); #endif #if LWIP_NETIF_LINK_CALLBACK == 1 - PostAvailabilityOnContinuation.InitializeCallback(PostAvailabilityOn, NULL); - PostAvailabilityOffContinuation.InitializeCallback(PostAvailabilityOff, NULL); + PostAvailabilityOnContinuation.InitializeCallback(PostAvailabilityOn, nullptr); + PostAvailabilityOffContinuation.InitializeCallback(PostAvailabilityOff, nullptr); #endif // create m_interfaceNumber array @@ -573,7 +573,7 @@ SOCK_SOCKET LWIP_SOCKETS_Driver::Accept(SOCK_SOCKET socket, SOCK_sockaddr *addre Sock_SockaddrToSockaddr(address, (sockaddr *)&addr, addressLen); } - ret = lwip_accept(socket, address ? (sockaddr *)&addr : NULL, (u32_t *)addressLen); + ret = lwip_accept(socket, address ? (sockaddr *)&addr : nullptr, (u32_t *)addressLen); if (address) { @@ -598,9 +598,9 @@ SOCK_addrinfo *CreateAddressRecord( const SOCK_addrinfo *hints) { SOCK_addrinfo *ai; - SOCK_sockaddr_in *sa = NULL; + SOCK_sockaddr_in *sa = nullptr; #if LWIP_IPV6 - SOCK_sockaddr_in6 *sa6 = NULL; + SOCK_sockaddr_in6 *sa6 = nullptr; #endif int total_size = sizeof(SOCK_addrinfo); int canonNameSize; @@ -613,7 +613,7 @@ SOCK_addrinfo *CreateAddressRecord( #endif // Allow for canon name if available - if (canonname != NULL) + if (canonname != nullptr) { // Size including terminator so we allocate name after SOCK_addrinfo + SOCK_sockaddr_in canonNameSize = hal_strlen_s(canonname) + 1; @@ -621,10 +621,10 @@ SOCK_addrinfo *CreateAddressRecord( } ai = (SOCK_addrinfo *)mem_malloc(total_size); - if (ai == NULL) + if (ai == nullptr) { // Out of memory - return NULL; + return nullptr; } memset(ai, 0, total_size); @@ -667,7 +667,7 @@ SOCK_addrinfo *CreateAddressRecord( // set up addrinfo ai->ai_family = family; - if (hints != NULL) + if (hints != nullptr) { // copy socktype & protocol from hints if specified ai->ai_socktype = hints->ai_socktype; @@ -675,7 +675,7 @@ SOCK_addrinfo *CreateAddressRecord( } // Copy in canon name if available - if (canonname != NULL) + if (canonname != nullptr) { ai->ai_canonname = (char *)ai + total_size - canonNameSize; memcpy(ai->ai_canonname, canonname, canonNameSize); @@ -695,19 +695,19 @@ int LWIP_SOCKETS_Driver::GetAddrInfo( #if LWIP_DNS NATIVE_PROFILE_PAL_NETWORK(); - SOCK_addrinfo *ai = NULL; - SOCK_addrinfo *nextAi = NULL; + SOCK_addrinfo *ai = nullptr; + SOCK_addrinfo *nextAi = nullptr; struct addrinfo *lwipAddrinfo = {0}; - if (res == NULL || nodename == NULL) + if (res == nullptr || nodename == nullptr) { return SOCK_SOCKET_ERROR; } - *res = NULL; + *res = nullptr; // if the nodename == "" then return the IP addresses of this device - if (nodename[0] == 0 && servname == NULL) + if (nodename[0] == 0 && servname == nullptr) { // Work through all available Network Interfaces in reverse so link list ends up with lowest index first. for (int i = g_TargetConfiguration.NetworkInterfaceConfigs->Count - 1; i >= 0; i--) @@ -715,7 +715,7 @@ int LWIP_SOCKETS_Driver::GetAddrInfo( struct netif *networkInterface = netif_find_interface(g_LWIP_SOCKETS_Driver.m_interfaces[i].m_interfaceNumber); - if (networkInterface == NULL) + if (networkInterface == nullptr) { continue; } @@ -743,8 +743,8 @@ int LWIP_SOCKETS_Driver::GetAddrInfo( addr = networkInterface->ip6_addr[addresses - 1]; } #endif - ai = CreateAddressRecord(family, addr, 0, NULL, hints); - if (ai == NULL) + ai = CreateAddressRecord(family, addr, 0, nullptr, hints); + if (ai == nullptr) { // Out of memory ? return SOCK_SOCKET_ERROR; @@ -756,7 +756,7 @@ int LWIP_SOCKETS_Driver::GetAddrInfo( } } - if (ai == NULL) + if (ai == nullptr) { // No addresses to return return -1; @@ -789,7 +789,7 @@ int LWIP_SOCKETS_Driver::GetAddrInfo( lwipAddrinfo->ai_canonname, hints); - if (ai == NULL) + if (ai == nullptr) { // Out of memory lwip_freeaddrinfo(lwipAddrinfo); @@ -830,7 +830,7 @@ void LWIP_SOCKETS_Driver::FreeAddrInfo(SOCK_addrinfo *ai) SOCK_addrinfo *next; - while (ai != NULL) + while (ai != nullptr) { next = ai->ai_next; mem_free(ai); @@ -864,7 +864,7 @@ int LWIP_SOCKETS_Driver::GetSockLastError(SOCK_SOCKET socket) static int MARSHAL_SOCK_FDSET_TO_FDSET(SOCK_fd_set *sf, fd_set *f) { - if (f != NULL && sf != NULL) + if (f != nullptr && sf != nullptr) { FD_ZERO(f); @@ -880,7 +880,7 @@ static int MARSHAL_SOCK_FDSET_TO_FDSET(SOCK_fd_set *sf, fd_set *f) static void MARSHAL_FDSET_TO_SOCK_FDSET(SOCK_fd_set *sf, fd_set *f) { - if (sf != NULL && f != NULL) + if (sf != nullptr && f != nullptr) { int cnt = sf->fd_count; sf->fd_count = 0; @@ -911,12 +911,12 @@ int LWIP_SOCKETS_Driver::Select( fd_set write; fd_set excpt; - fd_set *pR = (readfds != NULL) ? &read : NULL; - fd_set *pW = (writefds != NULL) ? &write : NULL; - fd_set *pE = (exceptfds != NULL) ? &excpt : NULL; + fd_set *pR = (readfds != nullptr) ? &read : nullptr; + fd_set *pW = (writefds != nullptr) ? &write : nullptr; + fd_set *pE = (exceptfds != nullptr) ? &excpt : nullptr; // If network down then we should alert any pending socket actions - if (exceptfds != NULL && exceptfds->fd_count > 0) + if (exceptfds != nullptr && exceptfds->fd_count > 0) { bool networkInterfaceAvailable = false; @@ -925,7 +925,7 @@ int LWIP_SOCKETS_Driver::Select( { struct netif *networkInterface = netif_find_interface(g_LWIP_SOCKETS_Driver.m_interfaces[i].m_interfaceNumber); - if (networkInterface != NULL) + if (networkInterface != nullptr) { if (netif_is_up(networkInterface)) { @@ -937,9 +937,9 @@ int LWIP_SOCKETS_Driver::Select( if (!networkInterfaceAvailable) { - if (readfds != NULL) + if (readfds != nullptr) readfds->fd_count = 0; - if (writefds != NULL) + if (writefds != nullptr) writefds->fd_count = 0; errorCode = ENETDOWN; @@ -1299,7 +1299,7 @@ HRESULT LWIP_SOCKETS_Driver::UpdateAdapterConfiguration( struct netif *networkInterface = netif_find_interface(g_LWIP_SOCKETS_Driver.m_interfaces[interfaceIndex].m_interfaceNumber); - if (NULL == networkInterface) + if (nullptr == networkInterface) { return CLR_E_FAIL; } @@ -1746,7 +1746,7 @@ struct netif *netif_find_interface(int num) struct netif *networkInterface; - for (networkInterface = netif_list; networkInterface != NULL; networkInterface = networkInterface->next) + for (networkInterface = netif_list; networkInterface != nullptr; networkInterface = networkInterface->next) { if (num == networkInterface->num) { @@ -1755,5 +1755,5 @@ struct netif *netif_find_interface(int num) } #endif - return NULL; + return nullptr; } diff --git a/src/PAL/Lwip/lwIP_Sockets_functions.cpp b/src/PAL/Lwip/lwIP_Sockets_functions.cpp index c28f0c685f..7c740b2d45 100644 --- a/src/PAL/Lwip/lwIP_Sockets_functions.cpp +++ b/src/PAL/Lwip/lwIP_Sockets_functions.cpp @@ -197,7 +197,7 @@ void HAL_SOCK_EventsSet(uint32_t events) void *HAL_SOCK_GlobalLockContext() { NATIVE_PROFILE_PAL_NETWORK(); - return NULL; + return nullptr; } void HAL_SOCK_SetInterfaceNumber(uint32_t interfaceIndex, uint32_t interfaceNumber) diff --git a/src/System.Device.Gpio/sys_dev_gpio_native.cpp b/src/System.Device.Gpio/sys_dev_gpio_native.cpp index d97797f001..38b5122f57 100644 --- a/src/System.Device.Gpio/sys_dev_gpio_native.cpp +++ b/src/System.Device.Gpio/sys_dev_gpio_native.cpp @@ -9,41 +9,41 @@ static const CLR_RT_MethodHandler method_lookup[] = { - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, Library_sys_dev_gpio_native_System_Device_Gpio_GpioPin::Read___SystemDeviceGpioPinValue, - NULL, - NULL, - NULL, - NULL, + nullptr, + nullptr, + nullptr, + nullptr, Library_sys_dev_gpio_native_System_Device_Gpio_GpioPin::Toggle___VOID, - NULL, + nullptr, Library_sys_dev_gpio_native_System_Device_Gpio_GpioPin::DisposeNative___VOID, Library_sys_dev_gpio_native_System_Device_Gpio_GpioPin::NativeIsPinModeSupported___BOOLEAN__SystemDeviceGpioPinMode, Library_sys_dev_gpio_native_System_Device_Gpio_GpioPin::NativeSetPinMode___VOID__SystemDeviceGpioPinMode, @@ -51,53 +51,53 @@ static const CLR_RT_MethodHandler method_lookup[] = Library_sys_dev_gpio_native_System_Device_Gpio_GpioPin::NativeSetDebounceTimeout___VOID, Library_sys_dev_gpio_native_System_Device_Gpio_GpioPin::WriteNative___VOID__SystemDeviceGpioPinValue, Library_sys_dev_gpio_native_System_Device_Gpio_GpioPin::NativeSetAlternateFunction___VOID__I4, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, Library_sys_dev_gpio_native_System_Device_Gpio_GpioController::get_PinCount___I4, - NULL, - NULL, - NULL, - NULL, - NULL, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, Library_sys_dev_gpio_native_System_Device_Gpio_GpioController::DisposeNative___VOID, - NULL, + nullptr, Library_sys_dev_gpio_native_System_Device_Gpio_GpioController::IsPinModeSupported___BOOLEAN__I4__SystemDeviceGpioPinMode, Library_sys_dev_gpio_native_System_Device_Gpio_GpioController::IsPinOpen___BOOLEAN__I4, - NULL, - NULL, - NULL, + nullptr, + nullptr, + nullptr, Library_sys_dev_gpio_native_System_Device_Gpio_GpioController::SetPinMode___VOID__I4__SystemDeviceGpioPinMode, - NULL, - NULL, + nullptr, + nullptr, Library_sys_dev_gpio_native_System_Device_Gpio_GpioController::NativeRead___U1__I4, Library_sys_dev_gpio_native_System_Device_Gpio_GpioController::NativeWrite___VOID__I4__U1, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, }; const CLR_RT_NativeAssemblyData g_CLR_AssemblyNative_System_Device_Gpio = diff --git a/src/System.Device.Gpio/sys_dev_gpio_native_System_Device_Gpio_GpioController.cpp b/src/System.Device.Gpio/sys_dev_gpio_native_System_Device_Gpio_GpioController.cpp index 80f3ac2db7..a34cb5b054 100644 --- a/src/System.Device.Gpio/sys_dev_gpio_native_System_Device_Gpio_GpioController.cpp +++ b/src/System.Device.Gpio/sys_dev_gpio_native_System_Device_Gpio_GpioController.cpp @@ -66,7 +66,7 @@ HRESULT Library_sys_dev_gpio_native_System_Device_Gpio_GpioController::SetPinMod GPIO_PIN pinNumber; PinMode driveMode; - CLR_RT_HeapBlock *gpioPin = NULL; + CLR_RT_HeapBlock *gpioPin = nullptr; CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -82,7 +82,7 @@ HRESULT Library_sys_dev_gpio_native_System_Device_Gpio_GpioController::SetPinMod // try to get GpioPin object GetGpioPin(pinNumber, stack, gpioPin); - if (gpioPin == NULL) + if (gpioPin == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_OPERATION); } @@ -98,7 +98,7 @@ HRESULT Library_sys_dev_gpio_native_System_Device_Gpio_GpioController::NativeRea GPIO_PIN pinNumber; bool pinValue; - CLR_RT_HeapBlock *gpioPin = NULL; + CLR_RT_HeapBlock *gpioPin = nullptr; CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -113,7 +113,7 @@ HRESULT Library_sys_dev_gpio_native_System_Device_Gpio_GpioController::NativeRea // try to get GpioPin object GetGpioPin(pinNumber, stack, gpioPin); - if (gpioPin == NULL) + if (gpioPin == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_OPERATION); } @@ -133,7 +133,7 @@ HRESULT Library_sys_dev_gpio_native_System_Device_Gpio_GpioController::NativeWri GPIO_PIN pinNumber; GpioPinValue state; - CLR_RT_HeapBlock *gpioPin = NULL; + CLR_RT_HeapBlock *gpioPin = nullptr; CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -149,7 +149,7 @@ HRESULT Library_sys_dev_gpio_native_System_Device_Gpio_GpioController::NativeWri // try to get GpioPin object GetGpioPin(pinNumber, stack, gpioPin); - if (gpioPin == NULL) + if (gpioPin == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_OPERATION); } @@ -164,18 +164,18 @@ void Library_sys_dev_gpio_native_System_Device_Gpio_GpioController::GetGpioPin( CLR_RT_StackFrame &stack, CLR_RT_HeapBlock *&gpioPin) { - CLR_IDX assemblyIdx; + CLR_INDEX assemblyIndex; CLR_INT32 index = 0; - CLR_RT_Assembly *thisAssembly = NULL; - CLR_RT_HeapBlock *gpioPinBundle = NULL; - CLR_RT_HeapBlock_ArrayList *gpioPins = NULL; + CLR_RT_Assembly *thisAssembly = nullptr; + CLR_RT_HeapBlock *gpioPinBundle = nullptr; + CLR_RT_HeapBlock_ArrayList *gpioPins = nullptr; // get "This" because we need to access the s_GpioPins field CLR_RT_HeapBlock *pThis = stack.This(); // s_GpioPins it's a static field, need to access it through the assembly - assemblyIdx = pThis->ObjectCls().Assembly(); - thisAssembly = g_CLR_RT_TypeSystem.m_assemblies[assemblyIdx - 1]; + assemblyIndex = pThis->ObjectCls().Assembly(); + thisAssembly = g_CLR_RT_TypeSystem.m_assemblies[assemblyIndex - 1]; // finally dereference s_GpioPins (as an ArrayList) gpioPins = (CLR_RT_HeapBlock_ArrayList *)thisAssembly->GetStaticField(FIELD_STATIC__s_GpioPins)->Dereference(); @@ -186,10 +186,10 @@ void Library_sys_dev_gpio_native_System_Device_Gpio_GpioController::GetGpioPin( if (!SUCCEEDED(gpioPins->GetItem(index++, gpioPinBundle))) { // GetItem failed, clear to indicate failure. - gpioPinBundle = NULL; + gpioPinBundle = nullptr; } - if (gpioPinBundle == NULL) + if (gpioPinBundle == nullptr) { // no more items in the array break; diff --git a/src/System.Device.Gpio/sys_dev_gpio_native_System_Device_Gpio_GpioPin.cpp b/src/System.Device.Gpio/sys_dev_gpio_native_System_Device_Gpio_GpioPin.cpp index 3441d383f3..469c606266 100644 --- a/src/System.Device.Gpio/sys_dev_gpio_native_System_Device_Gpio_GpioPin.cpp +++ b/src/System.Device.Gpio/sys_dev_gpio_native_System_Device_Gpio_GpioPin.cpp @@ -78,7 +78,7 @@ HRESULT Library_sys_dev_gpio_native_System_Device_Gpio_GpioPin::Toggle___VOID(CL CPU_GPIO_TogglePinState(pinNumber); // fire event, only if there are callbacks registered - if (pThis[FIELD___callbacks].Dereference() != NULL) + if (pThis[FIELD___callbacks].Dereference() != nullptr) { PostManagedEvent(EVENT_GPIO, 0, (uint16_t)pinNumber, (uint32_t)CPU_GPIO_GetPinState(pinNumber)); } @@ -268,13 +268,13 @@ HRESULT Library_sys_dev_gpio_native_System_Device_Gpio_GpioPin::SetPinMode(CLR_R // flag to determine if there are any callbacks registered in managed code // this is use to determine if there is any need to setup and process INT handler - callbacksRegistered = (gpioPin[FIELD___callbacks].Dereference() != NULL); + callbacksRegistered = (gpioPin[FIELD___callbacks].Dereference() != nullptr); validPin = CPU_GPIO_EnableInputPin( pinNumber, (uint32_t)debounceTimeoutMilsec, - callbacksRegistered ? Gpio_Interupt_ISR : NULL, - NULL, + callbacksRegistered ? Gpio_Interupt_ISR : nullptr, + nullptr, GPIO_INT_EDGE_BOTH, pinMode); } @@ -303,7 +303,7 @@ HRESULT Library_sys_dev_gpio_native_System_Device_Gpio_GpioPin::Write(CLR_RT_Hea CPU_GPIO_SetPinState(pinNumber, pinValue); // fire event if there are callbacks registered - if (gpioPin[FIELD___callbacks].Dereference() != NULL) + if (gpioPin[FIELD___callbacks].Dereference() != nullptr) { PostManagedEvent(EVENT_GPIO, 0, (uint16_t)pinNumber, (uint32_t)pinValue); } diff --git a/src/System.Device.Spi/nanoHAL_Spi.cpp b/src/System.Device.Spi/nanoHAL_Spi.cpp index 24cb0e6733..2a5a9f6888 100644 --- a/src/System.Device.Spi/nanoHAL_Spi.cpp +++ b/src/System.Device.Spi/nanoHAL_Spi.cpp @@ -377,7 +377,7 @@ HRESULT nanoSPI_OpenDeviceEx( false, 0, spiDeviceConfig.DataIs16bits, - NULL, + nullptr, spiDeviceConfig.DeviceChipSelect, spiDeviceConfig.ChipSelectActiveState}; uint8_t buffer[2] = {0, 0}; diff --git a/src/System.Device.Spi/sys_dev_spi_native_System_Device_Spi_SpiDevice.cpp b/src/System.Device.Spi/sys_dev_spi_native_System_Device_Spi_SpiDevice.cpp index 593060ac12..c8958a14dd 100644 --- a/src/System.Device.Spi/sys_dev_spi_native_System_Device_Spi_SpiDevice.cpp +++ b/src/System.Device.Spi/sys_dev_spi_native_System_Device_Spi_SpiDevice.cpp @@ -76,10 +76,10 @@ HRESULT Library_sys_dev_spi_native_System_Device_Spi_SpiDevice::NativeTransfer( CLR_RT_HeapBlock *writeSpanByte; CLR_RT_HeapBlock *readSpanByte; - CLR_RT_HeapBlock_Array *writeBuffer = NULL; - CLR_RT_HeapBlock_Array *readBuffer = NULL; - uint8_t *writeData = NULL; - uint8_t *readData = NULL; + CLR_RT_HeapBlock_Array *writeBuffer = nullptr; + CLR_RT_HeapBlock_Array *readBuffer = nullptr; + uint8_t *writeData = nullptr; + uint8_t *readData = nullptr; int16_t writeSize = 0; int16_t readSize = 0; int16_t readOffset = 0; @@ -93,7 +93,7 @@ HRESULT Library_sys_dev_spi_native_System_Device_Spi_SpiDevice::NativeTransfer( CLR_INT64 *timeout; bool eventResult = true; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); CLR_RT_HeapBlock *connectionSettings; FAULT_ON_NULL(pThis); @@ -107,7 +107,7 @@ HRESULT Library_sys_dev_spi_native_System_Device_Spi_SpiDevice::NativeTransfer( if (data16Bits) { writeBuffer = stack.Arg1().DereferenceArray(); - if (writeBuffer != NULL) + if (writeBuffer != nullptr) { // grab the pointer to the array by getting the first element of the array writeData = (unsigned char *)writeBuffer->GetFirstElementUInt16(); @@ -120,7 +120,7 @@ HRESULT Library_sys_dev_spi_native_System_Device_Spi_SpiDevice::NativeTransfer( } readBuffer = stack.Arg2().DereferenceArray(); - if (readBuffer != NULL) + if (readBuffer != nullptr) { // grab the pointer to the array by getting the first element of the array readData = (unsigned char *)readBuffer->GetFirstElementUInt16(); @@ -136,11 +136,11 @@ HRESULT Library_sys_dev_spi_native_System_Device_Spi_SpiDevice::NativeTransfer( { // dereference the write and read SpanByte from the arguments writeSpanByte = stack.Arg1().Dereference(); - if (writeSpanByte != NULL) + if (writeSpanByte != nullptr) { // get buffer writeBuffer = writeSpanByte[SpanByte::FIELD___array].DereferenceArray(); - if (writeBuffer != NULL) + if (writeBuffer != nullptr) { // Get the write offset, only the elements defined by the span must be written, not the whole // array @@ -155,18 +155,18 @@ HRESULT Library_sys_dev_spi_native_System_Device_Spi_SpiDevice::NativeTransfer( } } - if (writeData == NULL) + if (writeData == nullptr) { // nothing to write, have to zero this writeSize = 0; } readSpanByte = stack.Arg2().Dereference(); - if (readSpanByte != NULL) + if (readSpanByte != nullptr) { // get buffer readBuffer = readSpanByte[SpanByte::FIELD___array].DereferenceArray(); - if (readBuffer != NULL) + if (readBuffer != nullptr) { // Get the read offset, only the elements defined by the span must be read, not the whole array readOffset = readSpanByte[SpanByte::FIELD___start].NumericByRef().s4; @@ -180,7 +180,7 @@ HRESULT Library_sys_dev_spi_native_System_Device_Spi_SpiDevice::NativeTransfer( } } - if (readData == NULL) + if (readData == nullptr) { // nothing to read, have to zero this readSize = 0; @@ -280,7 +280,7 @@ HRESULT Library_sys_dev_spi_native_System_Device_Spi_SpiDevice::NativeTransfer( stack.PopValue(); // null pointers and vars - pThis = NULL; + pThis = nullptr; } NANOCLR_CLEANUP(); @@ -288,12 +288,12 @@ HRESULT Library_sys_dev_spi_native_System_Device_Spi_SpiDevice::NativeTransfer( if (hr != CLR_E_THREAD_WAITING) { // unpin buffers - if (writeBuffer != NULL && writeBuffer->IsPinned()) + if (writeBuffer != nullptr && writeBuffer->IsPinned()) { writeBuffer->Unpin(); } - if (readBuffer != NULL && readBuffer->IsPinned()) + if (readBuffer != nullptr && readBuffer->IsPinned()) { readBuffer->Unpin(); } @@ -308,9 +308,9 @@ HRESULT Library_sys_dev_spi_native_System_Device_Spi_SpiDevice::NativeOpenDevice uint32_t handle = -1; SPI_DEVICE_CONFIGURATION spiConfig; - CLR_RT_HeapBlock *config = NULL; + CLR_RT_HeapBlock *config = nullptr; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -364,7 +364,7 @@ HRESULT Library_sys_dev_spi_native_System_Device_Spi_SpiDevice::DisposeNative___ { NANOCLR_HEADER(); { - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); // get device handle diff --git a/src/System.IO.FileSystem/nf_sys_io_filesystem_System_IO_Directory.cpp b/src/System.IO.FileSystem/nf_sys_io_filesystem_System_IO_Directory.cpp index e234b7a565..acfaf6fa95 100644 --- a/src/System.IO.FileSystem/nf_sys_io_filesystem_System_IO_Directory.cpp +++ b/src/System.IO.FileSystem/nf_sys_io_filesystem_System_IO_Directory.cpp @@ -1,4 +1,4 @@ -// +// // Copyright (c) .NET Foundation and Contributors // See LICENSE file in the project root for full license information. // @@ -11,7 +11,7 @@ HRESULT Library_nf_sys_io_filesystem_System_IO_Directory::NativeGetChildren___ST NATIVE_PROFILE_CLR_IO(); NANOCLR_HEADER(); - FileSystemVolume *driver = NULL; + FileSystemVolume *driver = nullptr; char *path; bool isDirectory; char rootNameBuffer[FS_NAME_MAXLENGTH + 1]; @@ -21,7 +21,7 @@ HRESULT Library_nf_sys_io_filesystem_System_IO_Directory::NativeGetChildren___ST uint32_t rootNameLength = -1; bool found = false; bool *foundP = &found; - void *findHandle = NULL; + void *findHandle = nullptr; int32_t itemsCount = 0; FS_FILEINFO fileData; @@ -75,7 +75,7 @@ HRESULT Library_nf_sys_io_filesystem_System_IO_Directory::NativeGetChildren___ST const char *fileName = (const char *)fileData.FileName; const char *extension = strrchr(fileName, '.'); - if (extension == NULL || strcmp(extension, ".sys") != 0) + if (extension == nullptr || strcmp(extension, ".sys") != 0) { // file does not have a .sys extension, maybe OK to add to list // now check other attributes @@ -92,7 +92,7 @@ HRESULT Library_nf_sys_io_filesystem_System_IO_Directory::NativeGetChildren___ST } // free memory for the file name - if (fileData.FileName != NULL) + if (fileData.FileName != nullptr) { platform_free(fileData.FileName); } @@ -104,7 +104,7 @@ HRESULT Library_nf_sys_io_filesystem_System_IO_Directory::NativeGetChildren___ST // create an array of files paths NANOCLR_CHECK_HRESULT( - CLR_RT_HeapBlock_Array::CreateInstance(top, (CLR_UINT32)itemsCount, g_CLR_RT_WellKnownTypes.m_String)); + CLR_RT_HeapBlock_Array::CreateInstance(top, (CLR_UINT32)itemsCount, g_CLR_RT_WellKnownTypes.String)); // 2nd pass to fill the array driver->FindOpen(path, findHandle); @@ -143,7 +143,7 @@ HRESULT Library_nf_sys_io_filesystem_System_IO_Directory::NativeGetChildren___ST { const char *fileName = (const char *)fileData.FileName; const char *extension = strrchr(fileName, '.'); - if (extension != NULL && strcmp(extension, ".sys") == 0) + if (extension != nullptr && strcmp(extension, ".sys") == 0) { // file has a .sys extension, skip it continue; @@ -176,7 +176,7 @@ HRESULT Library_nf_sys_io_filesystem_System_IO_Directory::NativeGetChildren___ST } // free memory for the file name - if (fileData.FileName != NULL) + if (fileData.FileName != nullptr) { platform_free(fileData.FileName); } @@ -185,14 +185,14 @@ HRESULT Library_nf_sys_io_filesystem_System_IO_Directory::NativeGetChildren___ST NANOCLR_CLEANUP(); - // close find handle (watch out for NULL handle) - if (findHandle != NULL) + // close find handle (watch out for nullptr handle) + if (findHandle != nullptr) { driver->FindClose(findHandle); } // free memory for the file name - if (fileData.FileName != NULL) + if (fileData.FileName != nullptr) { platform_free(fileData.FileName); } diff --git a/src/System.IO.FileSystem/nf_sys_io_filesystem_System_IO_DriveInfo.cpp b/src/System.IO.FileSystem/nf_sys_io_filesystem_System_IO_DriveInfo.cpp index aaed1ab7f6..69afd0cd91 100644 --- a/src/System.IO.FileSystem/nf_sys_io_filesystem_System_IO_DriveInfo.cpp +++ b/src/System.IO.FileSystem/nf_sys_io_filesystem_System_IO_DriveInfo.cpp @@ -1,4 +1,4 @@ -// +// // Copyright (c) .NET Foundation and Contributors // See LICENSE file in the project root for full license information. // @@ -47,7 +47,7 @@ HRESULT Library_nf_sys_io_filesystem_System_IO_DriveInfo::_ctor___VOID__U4(CLR_R volume = FileSystemVolumeList::FindVolume(driveIndex); - if (volume != NULL) + if (volume != nullptr) { NANOCLR_SET_AND_LEAVE(UpdateVolumeInfo(stack.This(), volume)); } @@ -67,7 +67,7 @@ HRESULT Library_nf_sys_io_filesystem_System_IO_DriveInfo::GetFileSystems___STATI CLR_RT_HeapBlock *fsNames; NANOCLR_CHECK_HRESULT( - CLR_RT_HeapBlock_Array::CreateInstance(ret, g_InstalledFSCount, g_CLR_RT_WellKnownTypes.m_String)); + CLR_RT_HeapBlock_Array::CreateInstance(ret, g_InstalledFSCount, g_CLR_RT_WellKnownTypes.String)); fsNames = (CLR_RT_HeapBlock *)ret.DereferenceArray()->GetFirstElement(); @@ -102,7 +102,7 @@ HRESULT Library_nf_sys_io_filesystem_System_IO_DriveInfo::GetDrivesNative___STAT uint32_t volumeCount = FileSystemVolumeList::GetNumVolumes(); FileSystemVolume *currentVolume; - // CLR_RT_HeapBlock *volume = NULL; + // CLR_RT_HeapBlock *volume = nullptr; CLR_RT_HeapBlock *hbVolumes; CLR_RT_HeapBlock &top = stack.PushValueAndClear(); diff --git a/src/System.IO.FileSystem/nf_sys_io_filesystem_System_IO_File.cpp b/src/System.IO.FileSystem/nf_sys_io_filesystem_System_IO_File.cpp index 863ee56762..5e3b23f592 100644 --- a/src/System.IO.FileSystem/nf_sys_io_filesystem_System_IO_File.cpp +++ b/src/System.IO.FileSystem/nf_sys_io_filesystem_System_IO_File.cpp @@ -20,7 +20,7 @@ HRESULT Library_nf_sys_io_filesystem_System_IO_File::ExistsNative___STATIC__BOOL bool exists = false; FRESULT operationResult; - char *filePath = NULL; + char *filePath = nullptr; FAULT_ON_NULL(workingPath); FAULT_ON_NULL(fileName); @@ -29,7 +29,7 @@ HRESULT Library_nf_sys_io_filesystem_System_IO_File::ExistsNative___STATIC__BOOL filePath = (char *)platform_malloc(FF_LFN_BUF + 1); // sanity check for successful malloc - if (filePath == NULL) + if (filePath == nullptr) { // failed to allocate memory NANOCLR_SET_AND_LEAVE(CLR_E_OUT_OF_MEMORY); @@ -77,7 +77,7 @@ HRESULT Library_nf_sys_io_filesystem_System_IO_File::ExistsNative___STATIC__BOOL NANOCLR_CLEANUP(); // free buffer memory, if allocated - if (filePath != NULL) + if (filePath != nullptr) { platform_free(filePath); } diff --git a/src/System.IO.FileSystem/nf_sys_io_filesystem_System_IO_NativeFileStream.cpp b/src/System.IO.FileSystem/nf_sys_io_filesystem_System_IO_NativeFileStream.cpp index 2ccf6657b8..a96cb4270c 100644 --- a/src/System.IO.FileSystem/nf_sys_io_filesystem_System_IO_NativeFileStream.cpp +++ b/src/System.IO.FileSystem/nf_sys_io_filesystem_System_IO_NativeFileStream.cpp @@ -193,7 +193,7 @@ HRESULT Library_nf_sys_io_filesystem_System_IO_NativeFileStream::Close___VOID(CL NANOCLR_CLEANUP(); - pThis[FIELD___fs].SetObjectReference(NULL); + pThis[FIELD___fs].SetObjectReference(nullptr); NANOCLR_CLEANUP_END(); } @@ -203,9 +203,9 @@ HRESULT Library_nf_sys_io_filesystem_System_IO_NativeFileStream::ReadWriteHelper NATIVE_PROFILE_CLR_IO(); NANOCLR_HEADER(); - CLR_RT_HeapBlock_Array *bufHB = NULL; + CLR_RT_HeapBlock_Array *bufHB = nullptr; CLR_RT_FileStream *fs; - CLR_RT_HeapBlock *nativeFileStreamHB = NULL; + CLR_RT_HeapBlock *nativeFileStreamHB = nullptr; uint8_t *buffer; int32_t bufferLength; @@ -284,7 +284,7 @@ HRESULT Library_nf_sys_io_filesystem_System_IO_NativeFileStream::ReadWriteHelper switch (fs->GetBufferingStrategy()) { case DIRECT_IO: - fs->AssignStorage(buffer, count, NULL, 0); + fs->AssignStorage(buffer, count, nullptr, 0); bufHB->Pin(); break; diff --git a/src/System.IO.FileSystem/nf_sys_io_filesystem_System_IO_NativeFindFile.cpp b/src/System.IO.FileSystem/nf_sys_io_filesystem_System_IO_NativeFindFile.cpp index 3ca06f9d17..af1f64199e 100644 --- a/src/System.IO.FileSystem/nf_sys_io_filesystem_System_IO_NativeFindFile.cpp +++ b/src/System.IO.FileSystem/nf_sys_io_filesystem_System_IO_NativeFindFile.cpp @@ -18,8 +18,8 @@ HRESULT Library_nf_sys_io_filesystem_System_IO_NativeFindFile::GetFileInfo___STA FS_FILEINFO fileInfo; bool found; - char *path = NULL; - FileSystemVolume *driver = NULL; + char *path = nullptr; + FileSystemVolume *driver = nullptr; CLR_RT_HeapBlock &top = stack.PushValueAndClear(); @@ -42,11 +42,11 @@ HRESULT Library_nf_sys_io_filesystem_System_IO_NativeFindFile::GetFileInfo___STA managedNativeFileInfo[NativeFileInfo::FIELD__Attributes].SetInteger((CLR_UINT32)fileInfo.Attributes); managedNativeFileInfo[NativeFileInfo::FIELD__Size].SetInteger((CLR_INT64)fileInfo.Size); - managedNativeFileInfo[NativeFileInfo::FIELD__FileName].SetObjectReference(NULL); + managedNativeFileInfo[NativeFileInfo::FIELD__FileName].SetObjectReference(nullptr); } else { - top.SetObjectReference(NULL); + top.SetObjectReference(nullptr); } NANOCLR_NOCLEANUP(); diff --git a/src/System.IO.FileSystem/nf_sys_io_filesystem_System_IO_NativeIO.cpp b/src/System.IO.FileSystem/nf_sys_io_filesystem_System_IO_NativeIO.cpp index 6caf02d21a..55058bf6ee 100644 --- a/src/System.IO.FileSystem/nf_sys_io_filesystem_System_IO_NativeIO.cpp +++ b/src/System.IO.FileSystem/nf_sys_io_filesystem_System_IO_NativeIO.cpp @@ -11,7 +11,7 @@ HRESULT Library_nf_sys_io_filesystem_System_IO_NativeIO::Delete___STATIC__VOID__ NATIVE_PROFILE_CLR_IO(); NANOCLR_HEADER(); - FileSystemVolume *driver = NULL; + FileSystemVolume *driver = nullptr; char pathBuffer[FS_MAX_PATH_LENGTH + 1]; char *path = pathBuffer; bool recursive = stack.Arg1().NumericByRef().u1 != 0; @@ -35,8 +35,8 @@ HRESULT Library_nf_sys_io_filesystem_System_IO_NativeIO::Move___STATIC__BOOLEAN_ char *path2 = path2Buffer; bool moveResult = false; - FileSystemVolume *driver1 = NULL; - FileSystemVolume *driver2 = NULL; + FileSystemVolume *driver1 = nullptr; + FileSystemVolume *driver2 = nullptr; NANOCLR_CHECK_HRESULT(FindVolume(stack.Arg0(), driver1, path1)); NANOCLR_CHECK_HRESULT(FindVolume(stack.Arg1(), driver2, path2)); @@ -132,8 +132,8 @@ HRESULT Library_nf_sys_io_filesystem_System_IO_NativeIO::Format___STATIC__VOID__ char pathBuffer[FS_MAX_PATH_LENGTH + 1]; char *path = pathBuffer; FileSystemVolume *driver; - FILESYSTEM_DRIVER_INTERFACE *originalFS = NULL; - STREAM_DRIVER_INTERFACE *originalStream = NULL; + FILESYSTEM_DRIVER_INTERFACE *originalFS = nullptr; + STREAM_DRIVER_INTERFACE *originalStream = nullptr; bool needInitialize = FALSE; NANOCLR_CHECK_HRESULT(FindVolume(stack.Arg0(), driver, path)); @@ -225,7 +225,7 @@ HRESULT Library_nf_sys_io_filesystem_System_IO_NativeIO::FindVolume( rootNameLength = hal_strlen_s(rootName); // Retrieve appropriate driver that handles this namespace - if ((volume = FileSystemVolumeList::FindVolume(rootName, rootNameLength)) == NULL) + if ((volume = FileSystemVolumeList::FindVolume(rootName, rootNameLength)) == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_VOLUME_NOT_FOUND); } @@ -257,7 +257,7 @@ HRESULT Library_nf_sys_io_filesystem_System_IO_NativeIO::FindVolume( NANOCLR_CHECK_HRESULT(CLR_RT_FileStream::SplitFilePath(fullPath, rootName, rootNameLength, relativePath)); // Retrieve appropriate driver that handles this root name - if ((volume = FileSystemVolumeList::FindVolume(rootName, rootNameLength)) == NULL) + if ((volume = FileSystemVolumeList::FindVolume(rootName, rootNameLength)) == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_DRIVER); } diff --git a/src/System.IO.Ports/sys_io_ser_native.cpp b/src/System.IO.Ports/sys_io_ser_native.cpp index e4960421a8..b75aec3e16 100644 --- a/src/System.IO.Ports/sys_io_ser_native.cpp +++ b/src/System.IO.Ports/sys_io_ser_native.cpp @@ -10,94 +10,94 @@ static const CLR_RT_MethodHandler method_lookup[] = { - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, Library_sys_io_ser_native_System_IO_Ports_SerialPort::get_BytesToRead___I4, Library_sys_io_ser_native_System_IO_Ports_SerialPort::get_InvertSignalLevels___BOOLEAN, Library_sys_io_ser_native_System_IO_Ports_SerialPort::set_InvertSignalLevels___VOID__BOOLEAN, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, Library_sys_io_ser_native_System_IO_Ports_SerialPort::Read___I4__SZARRAY_U1__I4__I4, - NULL, + nullptr, Library_sys_io_ser_native_System_IO_Ports_SerialPort::ReadExisting___STRING, Library_sys_io_ser_native_System_IO_Ports_SerialPort::ReadLine___STRING, Library_sys_io_ser_native_System_IO_Ports_SerialPort::Write___VOID__SZARRAY_U1__I4__I4, - NULL, - NULL, - NULL, - NULL, + nullptr, + nullptr, + nullptr, + nullptr, Library_sys_io_ser_native_System_IO_Ports_SerialPort::NativeDispose___VOID, Library_sys_io_ser_native_System_IO_Ports_SerialPort::NativeInit___VOID, Library_sys_io_ser_native_System_IO_Ports_SerialPort::NativeConfig___VOID, Library_sys_io_ser_native_System_IO_Ports_SerialPort::NativeSetWatchChar___VOID, Library_sys_io_ser_native_System_IO_Ports_SerialPort::NativeWriteString___VOID__STRING__BOOLEAN, Library_sys_io_ser_native_System_IO_Ports_SerialPort::NativeReceivedBytesThreshold___VOID__I4, - NULL, - NULL, + nullptr, + nullptr, Library_sys_io_ser_native_System_IO_Ports_SerialPort::GetDeviceSelector___STATIC__STRING, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, }; const CLR_RT_NativeAssemblyData g_CLR_AssemblyNative_System_IO_Ports = diff --git a/src/System.IO.Ports/sys_io_ser_native_System_IO_Ports_SerialPort__.cpp b/src/System.IO.Ports/sys_io_ser_native_System_IO_Ports_SerialPort__.cpp index 6d2c1b2da8..b460b5f090 100644 --- a/src/System.IO.Ports/sys_io_ser_native_System_IO_Ports_SerialPort__.cpp +++ b/src/System.IO.Ports/sys_io_ser_native_System_IO_Ports_SerialPort__.cpp @@ -29,8 +29,8 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::SetupWriteLine( // get pointer to string text = stack.Arg1().RecoverString(); - // check for NULL string - if (text != NULL) + // check for nullptr string + if (text != nullptr) { // get length textLength = hal_strlen_s(text); @@ -96,12 +96,12 @@ bool Library_sys_io_ser_native_System_IO_Ports_SerialPort::GetLineFromRxBuffer( uint32_t newLineIndex = 0; int32_t compareIndex = 0; uint8_t *buffer; - uint8_t *comparison = NULL; + uint8_t *comparison = nullptr; uint32_t matchCount = 0; uint32_t index = 0; // clear line - line = NULL; + line = nullptr; // check for anything in the buffer if (ringBuffer->Length() > 0) @@ -109,7 +109,7 @@ bool Library_sys_io_ser_native_System_IO_Ports_SerialPort::GetLineFromRxBuffer( // get "new line" from field newLine = serialDevice[FIELD___newLine].RecoverString(); - if (newLine != NULL) + if (newLine != nullptr) { newLineLength = hal_strlen_s(newLine); } @@ -183,7 +183,7 @@ bool Library_sys_io_ser_native_System_IO_Ports_SerialPort::GetLineFromRxBuffer( // the new line char allow enough room in the buffer for for the terminator line = (uint8_t *)platform_malloc(index); - if (line != NULL) + if (line != nullptr) { // pop string AND new line from buffer ringBuffer->Pop(line, index); diff --git a/src/System.Runtime.Serialization/nf_system_runtime_serialization.cpp b/src/System.Runtime.Serialization/nf_system_runtime_serialization.cpp index 7cdf49f660..499dd3ccbe 100644 --- a/src/System.Runtime.Serialization/nf_system_runtime_serialization.cpp +++ b/src/System.Runtime.Serialization/nf_system_runtime_serialization.cpp @@ -11,8 +11,8 @@ static const CLR_RT_MethodHandler method_lookup[] = { Library_nf_system_runtime_serialization_System_Runtime_Serialization_Formatters_Binary_BinaryFormatter::Serialize___STATIC__SZARRAY_U1__OBJECT, Library_nf_system_runtime_serialization_System_Runtime_Serialization_Formatters_Binary_BinaryFormatter::Deserialize___STATIC__OBJECT__SZARRAY_U1, - NULL, - NULL, + nullptr, + nullptr, }; const CLR_RT_NativeAssemblyData g_CLR_AssemblyNative_System_Runtime_Serialization = diff --git a/src/System.Runtime.Serialization/nf_system_runtime_serialization_System_Runtime_Serialization_Formatters_Binary_BinaryFormatter.cpp b/src/System.Runtime.Serialization/nf_system_runtime_serialization_System_Runtime_Serialization_Formatters_Binary_BinaryFormatter.cpp index 3b5c6a3ed4..3e1f3b175d 100644 --- a/src/System.Runtime.Serialization/nf_system_runtime_serialization_System_Runtime_Serialization_Formatters_Binary_BinaryFormatter.cpp +++ b/src/System.Runtime.Serialization/nf_system_runtime_serialization_System_Runtime_Serialization_Formatters_Binary_BinaryFormatter.cpp @@ -49,7 +49,7 @@ HRESULT Library_nf_system_runtime_serialization_System_Runtime_Serialization_For idx.InitializeFromHash(hash); - if (inst.InitializeFromReflection(idx, NULL)) + if (inst.InitializeFromReflection(idx, nullptr)) { res.Dereference() [Library_nf_system_runtime_serialization_System_Runtime_Serialization_SerializationException:: diff --git a/src/nanoFramework.Graphics/Graphics/Core/Graphics.cpp b/src/nanoFramework.Graphics/Graphics/Core/Graphics.cpp index 806ea87ba7..de5a7e8c0b 100644 --- a/src/nanoFramework.Graphics/Graphics/Core/Graphics.cpp +++ b/src/nanoFramework.Graphics/Graphics/Core/Graphics.cpp @@ -110,7 +110,7 @@ HRESULT CLR_GFX_Bitmap::CreateInstance( NANOCLR_HEADER(); CLR_RT_HeapBlock refUncompressed; - refUncompressed.SetObjectReference(NULL); + refUncompressed.SetObjectReference(nullptr); CLR_GFX_Bitmap *bitmap; CLR_GFX_Bitmap *bitmapNative; const CLR_GFX_BitmapDescription *bm; @@ -126,10 +126,10 @@ HRESULT CLR_GFX_Bitmap::CreateInstance( if (bm->m_type == CLR_GFX_BitmapDescription::c_TypeJpeg || bm->m_type == CLR_GFX_BitmapDescription::c_TypeGif) { - if (assm->m_pFile) + if (assm->file) { - unpinAssm = !assm->m_pFile->IsPinned(); - assm->m_pFile->Pin(); + unpinAssm = !assm->file->IsPinned(); + assm->file->Pin(); } NANOCLR_CHECK_HRESULT(CLR_GFX_Bitmap::CreateInstance(ref, data, size, bm->m_type)); @@ -192,7 +192,7 @@ HRESULT CLR_GFX_Bitmap::CreateInstance( if (unpinAssm) { // Unpin the assembly if we pinned it earlier - assm->m_pFile->Unpin(); + assm->file->Unpin(); } NANOCLR_CLEANUP_END(); @@ -236,7 +236,7 @@ HRESULT CLR_GFX_Bitmap::CreateInstanceBmp(CLR_RT_HeapBlock &ref, const CLR_UINT8 { NANOCLR_HEADER(); - CLR_GFX_Bitmap *bitmap = NULL; + CLR_GFX_Bitmap *bitmap = nullptr; CLR_GFX_BitmapDescription bm; BmpDecoder decoder; @@ -294,7 +294,7 @@ HRESULT CLR_GFX_Bitmap::DeleteInstance(CLR_RT_HeapBlock &ref) break; } - ref.SetObjectReference(NULL); + ref.SetObjectReference(nullptr); NANOCLR_NOCLEANUP(); } diff --git a/src/nanoFramework.Graphics/Graphics/Core/GraphicsDriver.cpp b/src/nanoFramework.Graphics/Graphics/Core/GraphicsDriver.cpp index 9c236c57cb..6944d542ee 100644 --- a/src/nanoFramework.Graphics/Graphics/Core/GraphicsDriver.cpp +++ b/src/nanoFramework.Graphics/Graphics/Core/GraphicsDriver.cpp @@ -254,12 +254,12 @@ void GraphicsDriver::DrawRectangleNative( int xSrc = 0, ySrc = 0; // If the outset rect is completely outside of the drawing region, we can safely return (inset rect is always inside // the outset rect) - if (ClipToVisible(bitmap, outsetX, outsetY, outsetWidth, outsetHeight, NULL, xSrc, ySrc) == false) + if (ClipToVisible(bitmap, outsetX, outsetY, outsetWidth, outsetHeight, nullptr, xSrc, ySrc) == false) return; // If the inset rectangle is completely outside of the drawing region, the insetWidth and insetHeight would be set // to 0 (We have to keep going because the outset rect is at least partly visible) - ClipToVisible(bitmap, insetX, insetY, insetWidth, insetHeight, NULL, xSrc, ySrc); + ClipToVisible(bitmap, insetX, insetY, insetWidth, insetHeight, nullptr, xSrc, ySrc); // Outline if (pen.thickness > 0) @@ -314,7 +314,7 @@ void GraphicsDriver::FillRectangleNative(const PAL_GFX_Bitmap &bitmap, GFX_Brush int height = rectangle.Height(); int xSrc = 0, ySrc = 0; - if (ClipToVisible(bitmap, x, y, width, height, NULL, xSrc, ySrc) == false) + if (ClipToVisible(bitmap, x, y, width, height, nullptr, xSrc, ySrc) == false) { return; } @@ -588,7 +588,7 @@ void GraphicsDriver::Draw4PointsRoundedRect(const PAL_GFX_Bitmap &bitmap, int of { Draw4PointsRoundedRectParams *p = (Draw4PointsRoundedRectParams *)params; - if (p->pen != NULL) + if (p->pen != nullptr) { if (p->pen->thickness < 2) { @@ -669,14 +669,14 @@ void GraphicsDriver::DrawEllipseNative( /// If Fill is expected, then do fill part first before drawing outline. if (brush.opacity != PAL_GFX_Bitmap::c_OpacityTransparent) { - params.pen = NULL; + params.pen = nullptr; params.brush = &brush; params.lastFillOffsetY = -1; EllipseAlgorithm(bitmap, radiusX, radiusY, ¶ms, &Draw4PointsEllipse); } params.pen = &pen; - params.brush = NULL; + params.brush = nullptr; EllipseAlgorithm(bitmap, radiusX, radiusY, ¶ms, &Draw4PointsEllipse); } @@ -687,7 +687,7 @@ void GraphicsDriver::Draw4PointsEllipse(const PAL_GFX_Bitmap &bitmap, int offset int centerX = p->centerX; int centerY = p->centerY; - if (p->pen != NULL) + if (p->pen != nullptr) { if (p->pen->thickness < 2) { @@ -708,7 +708,7 @@ void GraphicsDriver::Draw4PointsEllipse(const PAL_GFX_Bitmap &bitmap, int offset } } - if (p->brush != NULL) + if (p->brush != nullptr) { int opacity = p->brush->opacity; @@ -1098,7 +1098,7 @@ bool GraphicsDriver::ClipToVisible( int &xSrc, int &ySrc) { - if (pSrc != NULL) + if (pSrc != nullptr) { if (xSrc < 0 || ySrc < 0) return false; @@ -1508,7 +1508,7 @@ void GraphicsDriver::SetPixelsHelper( if (config & PAL_GFX_Bitmap::c_SetPixelsConfig_Clip) { - if (g_GraphicsDriver.ClipToVisible(bitmap, x, y, width, height, NULL, xSrc, ySrc) == FALSE) + if (g_GraphicsDriver.ClipToVisible(bitmap, x, y, width, height, nullptr, xSrc, ySrc) == FALSE) return; } diff --git a/src/nanoFramework.Graphics/Graphics/Core/Support/Fonts/Font.cpp b/src/nanoFramework.Graphics/Graphics/Core/Support/Fonts/Font.cpp index 53991dc97c..cd5462cd79 100644 --- a/src/nanoFramework.Graphics/Graphics/Core/Support/Fonts/Font.cpp +++ b/src/nanoFramework.Graphics/Graphics/Core/Support/Fonts/Font.cpp @@ -100,7 +100,7 @@ HRESULT CLR_GFX_Font::CreateInstance(CLR_RT_HeapBlock &ref, const CLR_UINT8 *dat NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_BinaryBlob::CreateInstance( ref, sizeof(CLR_GFX_Font), - NULL, + nullptr, CLR_GFX_Font::RelocationHandler, CLR_RT_HeapBlock::HB_CompactOnFailure)); @@ -300,7 +300,7 @@ void CLR_GFX_Font::DrawChar( } else { - param.antiAlias = NULL; + param.antiAlias = nullptr; config = PAL_GFX_Bitmap::c_SetPixelsConfig_Clip; } bitmap->SetPixelsHelper(rect, config, &DrawCharHelper, ¶m); @@ -317,7 +317,7 @@ void CLR_GFX_Font::CountCharactersInWidth( { CLR_RT_UnicodeHelper uh; CLR_UINT16 buf[3]; - LPCSTR breakPoint = NULL; + LPCSTR breakPoint = nullptr; CLR_UINT16 lastChar = 0; int breakWidth = 0; int breakIndex = 0; @@ -468,7 +468,7 @@ void CLR_GFX_Font::GetCharInfo(CLR_UINT16 c, CLR_GFX_FontCharacterInfo &chrEx) } else { - chrEx.antiAlias = NULL; + chrEx.antiAlias = nullptr; chrEx.iAntiAlias = 1; } } diff --git a/src/nanoFramework.Graphics/Graphics/Core/Support/Gif/Gif.cpp b/src/nanoFramework.Graphics/Graphics/Core/Support/Gif/Gif.cpp index f7834f32d5..4db81a5c47 100644 --- a/src/nanoFramework.Graphics/Graphics/Core/Support/Gif/Gif.cpp +++ b/src/nanoFramework.Graphics/Graphics/Core/Support/Gif/Gif.cpp @@ -11,7 +11,7 @@ HRESULT CLR_GFX_Bitmap::CreateInstanceGif(CLR_RT_HeapBlock &ref, const CLR_UINT8 NANOCLR_HEADER(); GifDecoder *decoder; - CLR_GFX_Bitmap *bitmap = NULL; + CLR_GFX_Bitmap *bitmap = nullptr; CLR_GFX_BitmapDescription bm; // Allocate the decoder diff --git a/src/nanoFramework.Graphics/Graphics/Core/Support/Gif/GifDecoder.cpp b/src/nanoFramework.Graphics/Graphics/Core/Support/Gif/GifDecoder.cpp index d430f1ae2c..6b5e078355 100644 --- a/src/nanoFramework.Graphics/Graphics/Core/Support/Gif/GifDecoder.cpp +++ b/src/nanoFramework.Graphics/Graphics/Core/Support/Gif/GifDecoder.cpp @@ -52,7 +52,7 @@ HRESULT GifDecoder::GifStartDecompress(CLR_GFX_Bitmap *bitmap) NANOCLR_SET_AND_LEAVE(CLR_E_FAIL); } - if (bitmap == NULL) + if (bitmap == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER); } @@ -130,7 +130,7 @@ HRESULT GifDecoder::ProcessImageChunk() { NANOCLR_HEADER(); - LZWDecompressor *lzwDec = NULL; + LZWDecompressor *lzwDec = nullptr; GifImageDescriptor currentImageDescriptor; NANOCLR_CHECK_HRESULT(source.Read(¤tImageDescriptor, sizeof(GifImageDescriptor))); diff --git a/src/nanoFramework.Graphics/Graphics/Core/Support/Jpeg/Jpeg.cpp b/src/nanoFramework.Graphics/Graphics/Core/Support/Jpeg/Jpeg.cpp index c1d6ef9a0a..fab04e2713 100644 --- a/src/nanoFramework.Graphics/Graphics/Core/Support/Jpeg/Jpeg.cpp +++ b/src/nanoFramework.Graphics/Graphics/Core/Support/Jpeg/Jpeg.cpp @@ -44,11 +44,11 @@ HRESULT CLR_GFX_Bitmap::CreateInstanceJpeg(CLR_RT_HeapBlock &ref, const CLR_UINT NANOCLR_HEADER(); jpeg_decompress_struct cinfo; - CLR_GFX_Bitmap *bitmap = NULL; + CLR_GFX_Bitmap *bitmap = nullptr; CreateInstanceJpegHelperParam param; GFX_Rect rect; - param.curBuffer = NULL; + param.curBuffer = nullptr; // Set up the error handling JPEGErrorManager errorManager; diff --git a/src/nanoFramework.Graphics/Graphics/Displays/Generic_SPI.cpp b/src/nanoFramework.Graphics/Graphics/Displays/Generic_SPI.cpp index 0e72449eb5..d0992d82b9 100644 --- a/src/nanoFramework.Graphics/Graphics/Displays/Generic_SPI.cpp +++ b/src/nanoFramework.Graphics/Graphics/Displays/Generic_SPI.cpp @@ -179,7 +179,7 @@ bool DisplayDriver::ChangeOrientation(DisplayOrientation orientation) switch (orientation) { case DisplayOrientation::DisplayOrientation_Portrait: - if (g_DisplayInterfaceConfig.GenericDriverCommands.OrientationPortrait != NULL) + if (g_DisplayInterfaceConfig.GenericDriverCommands.OrientationPortrait != nullptr) { Attributes.Height = Attributes.LongerSide; Attributes.Width = Attributes.ShorterSide; @@ -189,7 +189,7 @@ bool DisplayDriver::ChangeOrientation(DisplayOrientation orientation) break; case DisplayOrientation::DisplayOrientation_Portrait180: - if (g_DisplayInterfaceConfig.GenericDriverCommands.OrientationPortrait180 != NULL) + if (g_DisplayInterfaceConfig.GenericDriverCommands.OrientationPortrait180 != nullptr) { Attributes.Height = Attributes.LongerSide; Attributes.Width = Attributes.ShorterSide; @@ -199,7 +199,7 @@ bool DisplayDriver::ChangeOrientation(DisplayOrientation orientation) break; case DisplayOrientation::DisplayOrientation_Landscape: - if (g_DisplayInterfaceConfig.GenericDriverCommands.OrientationLandscape != NULL) + if (g_DisplayInterfaceConfig.GenericDriverCommands.OrientationLandscape != nullptr) { Attributes.Height = Attributes.ShorterSide; Attributes.Width = Attributes.LongerSide; @@ -209,7 +209,7 @@ bool DisplayDriver::ChangeOrientation(DisplayOrientation orientation) break; case DisplayOrientation::DisplayOrientation_Landscape180: - if (g_DisplayInterfaceConfig.GenericDriverCommands.OrientationLandscape180 != NULL) + if (g_DisplayInterfaceConfig.GenericDriverCommands.OrientationLandscape180 != nullptr) { Attributes.Height = Attributes.ShorterSide; Attributes.Width = Attributes.LongerSide; @@ -235,14 +235,14 @@ void DisplayDriver::PowerSave(PowerSaveState powerState) default: // Illegal fall through to Power on case PowerSaveState::NORMAL: - if (g_DisplayInterfaceConfig.GenericDriverCommands.PowerModeNormal != NULL) + if (g_DisplayInterfaceConfig.GenericDriverCommands.PowerModeNormal != nullptr) { ProcessCommand(g_DisplayInterfaceConfig.GenericDriverCommands.PowerModeNormal); } break; case PowerSaveState::SLEEP: - if (g_DisplayInterfaceConfig.GenericDriverCommands.PowerModeSleep != NULL) + if (g_DisplayInterfaceConfig.GenericDriverCommands.PowerModeSleep != nullptr) { ProcessCommand(g_DisplayInterfaceConfig.GenericDriverCommands.PowerModeSleep); } @@ -254,7 +254,7 @@ void DisplayDriver::PowerSave(PowerSaveState powerState) void DisplayDriver::Clear() { // Default behavior - if (g_DisplayInterfaceConfig.GenericDriverCommands.Clear == NULL) + if (g_DisplayInterfaceConfig.GenericDriverCommands.Clear == nullptr) { SetWindow(0, 0, Attributes.Width - 1, Attributes.Height - 1); diff --git a/src/nanoFramework.Graphics/Graphics/Displays/Spi_To_Display.cpp b/src/nanoFramework.Graphics/Graphics/Displays/Spi_To_Display.cpp index 73cb34ff6d..1a8caa9779 100644 --- a/src/nanoFramework.Graphics/Graphics/Displays/Spi_To_Display.cpp +++ b/src/nanoFramework.Graphics/Graphics/Displays/Spi_To_Display.cpp @@ -205,7 +205,7 @@ void InternalSendBytes(CLR_UINT8 *data, CLR_UINT32 length, bool sendAsync) wrc.DeviceChipSelect = spiChipSelect; wrc.ChipSelectActiveState = spiChipSelectActiveState; - nanoSPI_Write_Read(spiDeviceHandle, wrc, data, length, NULL, 0); + nanoSPI_Write_Read(spiDeviceHandle, wrc, data, length, nullptr, 0); return; } diff --git a/src/nanoFramework.Graphics/Graphics/Native/nanoFramework_Graphics_nanoFramework_UI_Bitmap.cpp b/src/nanoFramework.Graphics/Graphics/Native/nanoFramework_Graphics_nanoFramework_UI_Bitmap.cpp index d3c470b954..aad1df48bb 100644 --- a/src/nanoFramework.Graphics/Graphics/Native/nanoFramework_Graphics_nanoFramework_UI_Bitmap.cpp +++ b/src/nanoFramework.Graphics/Graphics/Native/nanoFramework_Graphics_nanoFramework_UI_Bitmap.cpp @@ -243,7 +243,7 @@ HRESULT Library_nanoFramework_Graphics_nanoFramework_UI_Bitmap:: } else { - hbText.SetObjectReference(NULL); + hbText.SetObjectReference(nullptr); } hbXRelStart.SetInteger((CLR_INT32)xRelStart); @@ -805,11 +805,11 @@ HRESULT Library_nanoFramework_Graphics_nanoFramework_UI_Bitmap::GetPixelInt___U4 HRESULT Library_nanoFramework_Graphics_nanoFramework_UI_Bitmap::GetBitmap___SZARRAY_U1(CLR_RT_StackFrame &stack) { NANOCLR_HEADER(); - CLR_RT_HeapBlock_Array *imageDataHB = NULL; - CLR_GFX_Bitmap *bitmap = NULL; - CLR_UINT32 *imageData = NULL; - CLR_UINT32 *row = NULL; - CLR_UINT32 *pixel = NULL; + CLR_RT_HeapBlock_Array *imageDataHB = nullptr; + CLR_GFX_Bitmap *bitmap = nullptr; + CLR_UINT32 *imageData = nullptr; + CLR_UINT32 *row = nullptr; + CLR_UINT32 *pixel = nullptr; int stride = 0; CLR_GFX_BitmapDescription bm; @@ -833,7 +833,7 @@ HRESULT Library_nanoFramework_Graphics_nanoFramework_UI_Bitmap::GetBitmap___SZAR } NANOCLR_CHECK_HRESULT( - CLR_RT_HeapBlock_Array::CreateInstance(array, bm.GetTotalSize(), g_CLR_RT_WellKnownTypes.m_UInt8)); + CLR_RT_HeapBlock_Array::CreateInstance(array, bm.GetTotalSize(), g_CLR_RT_WellKnownTypes.UInt8)); imageDataHB = array.DereferenceArray(); FAULT_ON_NULL(imageDataHB); @@ -1147,17 +1147,17 @@ HRESULT Library_nanoFramework_Graphics_nanoFramework_UI_Bitmap::Dispose___VOID__ CLR_RT_HeapBlock *pThis = stack.This(); - if (pThis[CLR_GFX_Bitmap::FIELD__m_bitmap].Dereference() == NULL) + if (pThis[CLR_GFX_Bitmap::FIELD__m_bitmap].Dereference() == nullptr) { NANOCLR_SET_AND_LEAVE(S_OK); } NANOCLR_CHECK_HRESULT(CLR_GFX_Bitmap::DeleteInstance(pThis[FIELD__m_bitmap])); - pThis[FIELD__m_bitmap].SetObjectReference(NULL); + pThis[FIELD__m_bitmap].SetObjectReference(nullptr); // Code from another version ? // NANOCLR_CHECK_HRESULT(CLR_GFX_Bitmap::DeleteInstance(pThis[CLR_GFX_Bitmap::FIELD__m_bitmap])); - // pThis[CLR_GFX_Bitmap::FIELD__m_bitmap].SetObjectReference(NULL); + // pThis[CLR_GFX_Bitmap::FIELD__m_bitmap].SetObjectReference(nullptr); NANOCLR_NOCLEANUP(); } diff --git a/src/nanoFramework.Graphics/Graphics/Native/nanoFramework_Graphics_nanoFramework_UI_DisplayControl.cpp b/src/nanoFramework.Graphics/Graphics/Native/nanoFramework_Graphics_nanoFramework_UI_DisplayControl.cpp index 0a13c41555..967cd4772b 100644 --- a/src/nanoFramework.Graphics/Graphics/Native/nanoFramework_Graphics_nanoFramework_UI_DisplayControl.cpp +++ b/src/nanoFramework.Graphics/Graphics/Native/nanoFramework_Graphics_nanoFramework_UI_DisplayControl.cpp @@ -138,7 +138,7 @@ HRESULT Library_nanoFramework_Graphics_nanoFramework_UI_DisplayControl:: displayConfig.Screen.height = screenconfig[ScreenConfiguration::FIELD___height].NumericByRef().u2; graphicDriver = screenconfig[ScreenConfiguration::FIELD___graphicDriver].Dereference(); - if (graphicDriver != NULL) + if (graphicDriver != nullptr) { displayConfig.GenericDriverCommands.Width = graphicDriver[GraphicDriver::FIELD___width].NumericByRef().u4; displayConfig.GenericDriverCommands.Height = graphicDriver[GraphicDriver::FIELD___height].NumericByRef().u4; diff --git a/src/nanoFramework.Graphics/Graphics/Native/nanoFramework_Graphics_nanoFramework_UI_Font.cpp b/src/nanoFramework.Graphics/Graphics/Native/nanoFramework_Graphics_nanoFramework_UI_Font.cpp index 1a4e57de72..03ea18c9ef 100644 --- a/src/nanoFramework.Graphics/Graphics/Native/nanoFramework_Graphics_nanoFramework_UI_Font.cpp +++ b/src/nanoFramework.Graphics/Graphics/Native/nanoFramework_Graphics_nanoFramework_UI_Font.cpp @@ -174,7 +174,7 @@ HRESULT Library_nanoFramework_Graphics_nanoFramework_UI_Font::ComputeExtent___VO FAULT_ON_NULL(szText); kerning = pArgs[3].NumericByRef().s4; - width = font->StringOut(szText, -1, kerning, NULL, 0, 0, 0); + width = font->StringOut(szText, -1, kerning, nullptr, 0, 0, 0); hbWidth.SetInteger((CLR_INT32)width); NANOCLR_CHECK_HRESULT(hbWidth.StoreToReference(pArgs[1], 0)); @@ -218,7 +218,7 @@ HRESULT Library_nanoFramework_Graphics_nanoFramework_UI_Font:: yRelStart, renderWidth, renderHeight, - NULL, + nullptr, 0, 0, availableWidth, diff --git a/src/nanoFramework.Graphics/Graphics/Native/nanoFramework_Graphics_nanoFramework_UI_Ink.cpp b/src/nanoFramework.Graphics/Graphics/Native/nanoFramework_Graphics_nanoFramework_UI_Ink.cpp index 9eaab4bd9e..d4775ebeff 100644 --- a/src/nanoFramework.Graphics/Graphics/Native/nanoFramework_Graphics_nanoFramework_UI_Ink.cpp +++ b/src/nanoFramework.Graphics/Graphics/Native/nanoFramework_Graphics_nanoFramework_UI_Ink.cpp @@ -12,22 +12,22 @@ extern InkDriver g_InkDriver; // Save a copy of the bimapped used by inking -static CLR_RT_HeapBlock *m_InkPinnedBitmap = NULL; +static CLR_RT_HeapBlock *m_InkPinnedBitmap = nullptr; HRESULT Library_nanoFramework_Graphics_nanoFramework_UI_Ink:: SetInkRegion___STATIC__VOID__U4__I4__I4__I4__I4__I4__I4__I4__nanoFrameworkUIBitmap(CLR_RT_StackFrame &stack) { NANOCLR_HEADER(); - CLR_GFX_Bitmap *bitmap = NULL; - PAL_GFX_Bitmap *palBmp = NULL; + CLR_GFX_Bitmap *bitmap = nullptr; + PAL_GFX_Bitmap *palBmp = nullptr; CLR_RT_HeapBlock *pArgs = &stack.Arg0(); - if (m_InkPinnedBitmap != NULL) + if (m_InkPinnedBitmap != nullptr) { m_InkPinnedBitmap->Unpin(); - m_InkPinnedBitmap = NULL; + m_InkPinnedBitmap = nullptr; } InkRegionInfo inkRegionInfo; @@ -42,7 +42,7 @@ HRESULT Library_nanoFramework_Graphics_nanoFramework_UI_Ink:: m_InkPinnedBitmap = pArgs[8].Dereference(); - if (m_InkPinnedBitmap != NULL) + if (m_InkPinnedBitmap != nullptr) { // we are drawing on the object in the PAL therefore it should not move m_InkPinnedBitmap->Pin(); @@ -65,7 +65,7 @@ HRESULT Library_nanoFramework_Graphics_nanoFramework_UI_Ink:: inkRegionInfo.Bmp = palBmp; - if (palBmp == NULL) + if (palBmp == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER); } diff --git a/src/nanoFramework.Graphics/Graphics/Native/nanoFramework_Graphics_nanoFramework_UI_TouchCollectorConfiguration.cpp b/src/nanoFramework.Graphics/Graphics/Native/nanoFramework_Graphics_nanoFramework_UI_TouchCollectorConfiguration.cpp index f11207eb0f..04922a3cc8 100644 --- a/src/nanoFramework.Graphics/Graphics/Native/nanoFramework_Graphics_nanoFramework_UI_TouchCollectorConfiguration.cpp +++ b/src/nanoFramework.Graphics/Graphics/Native/nanoFramework_Graphics_nanoFramework_UI_TouchCollectorConfiguration.cpp @@ -20,7 +20,7 @@ HRESULT Library_nanoFramework_Graphics_nanoFramework_UI_TouchCollectorConfigurat CLR_RT_HeapBlock_Array *sx; CLR_RT_HeapBlock_Array *sy; int count = 0; - CLR_RT_HeapBlock *pArgs = NULL; + CLR_RT_HeapBlock *pArgs = nullptr; CLR_RT_HeapBlock *pArgs0 = &(stack.Arg0()); NANOCLR_CHECK_HRESULT(hbCount.LoadFromReference(pArgs0[0])); count = hbCount.NumericByRef().s4; @@ -112,4 +112,4 @@ HRESULT Library_nanoFramework_Graphics_nanoFramework_UI_TouchCollectorConfigurat NANOCLR_CHECK_HRESULT(g_TouchPanelDriver.GetSetTouchInfo(flags, ¶m1, ¶m2, ¶m3)); NANOCLR_NOCLEANUP(); -} \ No newline at end of file +} diff --git a/src/nanoFramework.Graphics/Graphics/Native/nanoFramework_Graphics_nanoFramework_UI_TouchEventProcessor.cpp b/src/nanoFramework.Graphics/Graphics/Native/nanoFramework_Graphics_nanoFramework_UI_TouchEventProcessor.cpp index 342810f0be..801d5155cd 100644 --- a/src/nanoFramework.Graphics/Graphics/Native/nanoFramework_Graphics_nanoFramework_UI_TouchEventProcessor.cpp +++ b/src/nanoFramework.Graphics/Graphics/Native/nanoFramework_Graphics_nanoFramework_UI_TouchEventProcessor.cpp @@ -17,15 +17,15 @@ HRESULT Library_nanoFramework_Graphics_nanoFramework_UI_TouchEventProcessor:: CLR_UINT32 data1 = stack.Arg1().NumericByRef().u4; CLR_UINT32 numTouches = data1 >> 16; TouchPoint *touchPoint = (TouchPoint *)stack.Arg2().NumericByRef().u4; - CLR_RT_HeapBlock *touchEvent = NULL; - CLR_RT_HeapBlock_Array *touchInputArray = NULL; - CLR_RT_HeapBlock *touchInputObject = NULL; + CLR_RT_HeapBlock *touchEvent = nullptr; + CLR_RT_HeapBlock_Array *touchInputArray = nullptr; + CLR_RT_HeapBlock *touchInputObject = nullptr; // Create a nanoFramework.UI.TouchEvent object to return CLR_RT_HeapBlock &resultObject = stack.PushValue(); NANOCLR_CHECK_HRESULT( - g_CLR_RT_ExecutionEngine.NewObjectFromIndex(resultObject, g_CLR_RT_WellKnownTypes.m_TouchEvent)); + g_CLR_RT_ExecutionEngine.NewObjectFromIndex(resultObject, g_CLR_RT_WellKnownTypes.TouchEvent)); touchEvent = resultObject.Dereference(); if (!touchEvent) @@ -46,7 +46,7 @@ HRESULT Library_nanoFramework_Graphics_nanoFramework_UI_TouchEventProcessor:: NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_Array::CreateInstance( touchEvent[Library_nanoFramework_Graphics_nanoFramework_UI_TouchEvent::FIELD__Touches], numTouches, - g_CLR_RT_WellKnownTypes.m_TouchInput)); + g_CLR_RT_WellKnownTypes.TouchInput)); touchInputArray = touchEvent[Library_nanoFramework_Graphics_nanoFramework_UI_TouchEvent::FIELD__Touches].DereferenceArray(); @@ -59,7 +59,7 @@ HRESULT Library_nanoFramework_Graphics_nanoFramework_UI_TouchEventProcessor:: touchInputObject = (CLR_RT_HeapBlock *)touchInputArray->GetFirstElement(); for (; numTouches > 0; --numTouches, touchInputObject++, touchPoint++) { - g_CLR_RT_ExecutionEngine.NewObjectFromIndex(*touchInputObject, g_CLR_RT_WellKnownTypes.m_TouchInput); + g_CLR_RT_ExecutionEngine.NewObjectFromIndex(*touchInputObject, g_CLR_RT_WellKnownTypes.TouchInput); CLR_RT_HeapBlock *touchInput = touchInputObject->Dereference(); if (!touchInput) { diff --git a/src/nanoFramework.Graphics/TouchPanel/Core/Gestures.cpp b/src/nanoFramework.Graphics/TouchPanel/Core/Gestures.cpp index 0ca7c808b1..4b3e55805c 100644 --- a/src/nanoFramework.Graphics/TouchPanel/Core/Gestures.cpp +++ b/src/nanoFramework.Graphics/TouchPanel/Core/Gestures.cpp @@ -234,7 +234,7 @@ void GestureDriver::ResetRecognition() void GestureDriver::GestureContinuationRoutine(void* arg) { - if (arg == NULL) {}; // avoid unused parameter, maybe used in the future + if (arg == nullptr) {}; // avoid unused parameter, maybe used in the future HRESULT hr = S_OK; CLR_UINT32 flags = (m_index << 16) | GetTouchPointFlags_NextPoint | GetTouchPointFlags_UseTime | GetTouchPointFlags_UseSource; CLR_UINT16 source = 0; diff --git a/src/nanoFramework.Graphics/TouchPanel/Core/Ink.cpp b/src/nanoFramework.Graphics/TouchPanel/Core/Ink.cpp index c30d393a88..db6aa533f0 100644 --- a/src/nanoFramework.Graphics/TouchPanel/Core/Ink.cpp +++ b/src/nanoFramework.Graphics/TouchPanel/Core/Ink.cpp @@ -22,7 +22,7 @@ HRESULT InkDriver::Initialize() g_InkDriver.m_InkCompletion.InitializeForUserMode(InkContinuationRoutine); m_initialized = true; m_InkingActive = false; - m_InkRegionInfo.Bmp = NULL; + m_InkRegionInfo.Bmp = nullptr; m_ScreenBmp.width = g_DisplayDriver.Attributes.Width; m_ScreenBmp.height = g_DisplayDriver.Attributes.Height; // m_ScreenBmp.data = Display::GetFrameBuffer(); @@ -56,7 +56,7 @@ HRESULT InkDriver::SetRegion(InkRegionInfo *inkRegionInfo) m_ScreenBmp.clipping.top = m_InkRegionInfo.Y1 + m_InkRegionInfo.BorderWidth; m_ScreenBmp.clipping.bottom = m_InkRegionInfo.Y2 - m_InkRegionInfo.BorderWidth; - if (m_InkRegionInfo.Bmp == NULL) + if (m_InkRegionInfo.Bmp == nullptr) { m_InkRegionInfo.Bmp = &m_ScreenBmp; } @@ -97,7 +97,7 @@ HRESULT InkDriver::ResetRegion() m_InkCompletion.Abort(); m_InkingActive = false; - m_InkRegionInfo.Bmp = NULL; + m_InkRegionInfo.Bmp = nullptr; return S_OK; } @@ -109,7 +109,7 @@ void InkDriver::InkContinuationRoutine(void *arg) void InkDriver::DrawInk(void *arg) { - if (arg == NULL) + if (arg == nullptr) { }; // Avoid unused parameter, maybe we need it in the future? HRESULT hr = S_OK; @@ -132,7 +132,7 @@ void InkDriver::DrawInk(void *arg) if (m_lastx != 0xFFFF) { g_GraphicsDriver.DrawLineRaw(m_ScreenBmp, m_InkRegionInfo.Pen, m_lastx, m_lasty, x, y); - if (m_InkRegionInfo.Bmp != NULL) + if (m_InkRegionInfo.Bmp != nullptr) { g_GraphicsDriver .DrawLine(*(m_InkRegionInfo.Bmp), m_InkRegionInfo.Pen, m_lastx - dx, m_lasty - dy, x - dx, y - dy); @@ -150,4 +150,4 @@ void InkDriver::DrawInk(void *arg) if (!m_InkCompletion.IsLinked()) m_InkCompletion.EnqueueDelta(INK_COMPLETION_TIME_USEC); } -} \ No newline at end of file +} diff --git a/src/nanoFramework.Graphics/TouchPanel/Core/TouchPanel.cpp b/src/nanoFramework.Graphics/TouchPanel/Core/TouchPanel.cpp index 5009c65715..400356aa2d 100644 --- a/src/nanoFramework.Graphics/TouchPanel/Core/TouchPanel.cpp +++ b/src/nanoFramework.Graphics/TouchPanel/Core/TouchPanel.cpp @@ -73,7 +73,7 @@ HRESULT TouchPanelDriver::Initialize() g_TouchPanelDriver.m_runavgCount = 0; g_TouchPanelDriver.m_runavgIndex = 0; - g_TouchPanelDriver.m_startMovePtr = NULL; + g_TouchPanelDriver.m_startMovePtr = nullptr; g_TouchPanelDriver.m_touchMoveIndex = 0; @@ -88,7 +88,7 @@ HRESULT TouchPanelDriver::Initialize() return CLR_E_FAIL; } - g_TouchPanelDriver.m_touchCompletion.InitializeForISR(TouchPanelDriver::TouchCompletion, NULL); + g_TouchPanelDriver.m_touchCompletion.InitializeForISR(TouchPanelDriver::TouchCompletion, nullptr); /// At this point we should be ready to recieve touch inputs. return S_OK; @@ -131,7 +131,7 @@ void TouchPanelDriver::TouchPanelCalibratePoint(CLR_INT32 UncalX, CLR_INT32 Unca HRESULT TouchPanelDriver::GetDeviceCaps(unsigned int iIndex, void *lpOutput) { - if (lpOutput == NULL) + if (lpOutput == nullptr) { return FALSE; } @@ -194,7 +194,7 @@ HRESULT TouchPanelDriver::SetCalibration(int pointCount, CLR_INT16 *sx, CLR_INT1 void TouchPanelDriver::TouchCompletion(void *arg) { - if (arg == NULL) + if (arg == nullptr) { }; // Avoid the unused parameter, and maybe in future is it needed? /// Completion routine, called in every 10ms or so, when we are actively sampling stylus. @@ -225,7 +225,7 @@ void TouchPanelDriver::PollTouchPoint() /// Driver should be doing all filter/averaging of the points. TouchPanelCalibratePoint(ux, uy, &x, &y); - TouchPoint *point = NULL; + TouchPoint *point = nullptr; if ((g_TouchPanelDriver.m_InternalFlags & Contact_Down) && (!(g_TouchPanelDriver.m_InternalFlags & Contact_WasDown))) @@ -240,7 +240,7 @@ void TouchPanelDriver::PollTouchPoint() /// Stylus down. PalEventDriver::PostEvent(PAL_EVENT_TOUCH, TouchPanelStylusDown); - if (NULL != (point = AddTouchPoint(0, x, y, time, ignoreDuplicates))) + if (nullptr != (point = AddTouchPoint(0, x, y, time, ignoreDuplicates))) { PostManagedEvent(EVENT_TOUCH, TouchPanelStylusDown, 1, (CLR_UINT32)point); } @@ -260,9 +260,9 @@ void TouchPanelDriver::PollTouchPoint() (g_TouchPanelDriver.m_InternalFlags & Contact_WasDown)) { /// Stylus Move. - if (NULL != (point = AddTouchPoint(0, x, y, time, ignoreDuplicates))) + if (nullptr != (point = AddTouchPoint(0, x, y, time, ignoreDuplicates))) { - if (m_startMovePtr == NULL) + if (m_startMovePtr == nullptr) { m_startMovePtr = point; m_touchMoveIndex = 1; @@ -279,7 +279,7 @@ void TouchPanelDriver::PollTouchPoint() m_touchMoveIndex, (CLR_UINT32)m_startMovePtr); - m_startMovePtr = NULL; + m_startMovePtr = nullptr; m_touchMoveIndex = 0; } else if (m_startMovePtr != point) @@ -290,7 +290,7 @@ void TouchPanelDriver::PollTouchPoint() } // we will get here if the stylus is in a TouchDown state but hasn't moved, so if we don't have a current // move ptr, then set the start move ptr to the latest point - else if (m_startMovePtr == NULL) + else if (m_startMovePtr == nullptr) { CLR_UINT32 touchflags = GetTouchPointFlags_LatestPoint | GetTouchPointFlags_UseTime | GetTouchPointFlags_UseSource; @@ -330,21 +330,21 @@ void TouchPanelDriver::PollTouchPoint() CLR_UINT32 touchflags = GetTouchPointFlags_LatestPoint | GetTouchPointFlags_UseTime | GetTouchPointFlags_UseSource; - TouchPoint *point = NULL; + TouchPoint *point = nullptr; /// Only send a move event if we have substantial data (more than two items) otherwise, the /// TouchUp event should suffice - if (m_touchMoveIndex > 2 && m_startMovePtr != NULL) + if (m_touchMoveIndex > 2 && m_startMovePtr != nullptr) { PostManagedEvent(EVENT_TOUCH, TouchPanelStylusMove, m_touchMoveIndex, (CLR_UINT32)m_startMovePtr); } - m_startMovePtr = NULL; + m_startMovePtr = nullptr; m_touchMoveIndex = 0; if (FAILED(GetTouchPoint(&touchflags, &point))) { - point = NULL; + point = nullptr; } /// Now add special contactup delimeter. @@ -356,7 +356,7 @@ void TouchPanelDriver::PollTouchPoint() g_palEventDriver.PostEvent(PAL_EVENT_TOUCH, TouchPanelStylusUp); // Make a copy of the point for the nanoFramework.UI.Touch handler. - if (point == NULL) + if (point == nullptr) { m_tmpUpTouch.contact = 0; m_tmpUpTouch.time = time; @@ -421,7 +421,7 @@ TouchPoint *TouchPanelDriver::AddTouchPoint( /// Ignore this point if it is too far from last point. if (dist2 > g_TouchPanel_Sampling_Settings.MaxFilterDistance) - return NULL; + return nullptr; } if (g_PAL_RunningAvg_Buffer_Size > 1) @@ -461,7 +461,7 @@ TouchPoint *TouchPanelDriver::AddTouchPoint( CLR_UINT32 dy = abs(y - lastAddedY); if (dx <= 2 && dy <= 2) - return NULL; + return nullptr; } lastAddedX = x; @@ -518,13 +518,13 @@ void TouchPanelDriver::TouchIsrProc(GPIO_PIN pin, bool pinState, void *pArg) HRESULT TouchPanelDriver::GetTouchPoints(int *pointCount, CLR_INT16 *sx, CLR_INT16 *sy) { - if (pointCount == NULL) + if (pointCount == nullptr) { }; // Avoid unused parameter, maybe used in the future? - if (sx == NULL) + if (sx == nullptr) { }; // Avoid unused parameter, maybe used in the future? - if (sy == NULL) + if (sy == nullptr) { }; // Avoid unused parameter, maybe used in the future? diff --git a/src/nanoFramework.Graphics/TouchPanel/Devices/CST816S.cpp b/src/nanoFramework.Graphics/TouchPanel/Devices/CST816S.cpp index 31c12d9288..e61aba0e88 100644 --- a/src/nanoFramework.Graphics/TouchPanel/Devices/CST816S.cpp +++ b/src/nanoFramework.Graphics/TouchPanel/Devices/CST816S.cpp @@ -20,7 +20,7 @@ bool TouchDevice::Initialize() bool TouchDevice::Enable(GPIO_INTERRUPT_SERVICE_ROUTINE touchIsrProc) { - if (touchIsrProc == NULL) + if (touchIsrProc == nullptr) { }; @@ -40,4 +40,4 @@ TouchPointDevice TouchDevice::GetPoint() TouchValue.y = 0; return TouchValue; -} \ No newline at end of file +} diff --git a/src/nanoFramework.Graphics/TouchPanel/Devices/STMPE811QTR_I2C.cpp b/src/nanoFramework.Graphics/TouchPanel/Devices/STMPE811QTR_I2C.cpp index f89c1214b2..6f35df9694 100644 --- a/src/nanoFramework.Graphics/TouchPanel/Devices/STMPE811QTR_I2C.cpp +++ b/src/nanoFramework.Graphics/TouchPanel/Devices/STMPE811QTR_I2C.cpp @@ -58,7 +58,7 @@ bool TouchDevice::Enable(GPIO_INTERRUPT_SERVICE_ROUTINE touchIsrProc) GPIO_PIN STMPE811QTR_Interrupt = GPIOI_LCD_INT; PinMode driveMode = PinMode_Input; GPIO_INT_EDGE IntEdge = GPIO_INT_EDGE_HIGH; - void *ISR_Param = NULL; + void *ISR_Param = nullptr; if (CPU_GPIO_ReservePin(GPIOI_LCD_INT, true)) { if (CPU_GPIO_EnableInputPin(STMPE811QTR_Interrupt, 0, touchIsrProc, ISR_Param, IntEdge, driveMode)) diff --git a/src/nanoFramework.Graphics/TouchPanel/Devices/XPT2046.cpp b/src/nanoFramework.Graphics/TouchPanel/Devices/XPT2046.cpp index 841786392b..299ed8e529 100644 --- a/src/nanoFramework.Graphics/TouchPanel/Devices/XPT2046.cpp +++ b/src/nanoFramework.Graphics/TouchPanel/Devices/XPT2046.cpp @@ -23,7 +23,7 @@ bool TouchDevice::Initialize() bool TouchDevice::Enable(GPIO_INTERRUPT_SERVICE_ROUTINE touchIsrProc) { - if (touchIsrProc == NULL) + if (touchIsrProc == nullptr) { }; return TRUE; diff --git a/src/nanoFramework.Graphics/TouchPanel/Devices/ft6x06_I2C.cpp b/src/nanoFramework.Graphics/TouchPanel/Devices/ft6x06_I2C.cpp index 8cdc0ae929..1815289f3c 100644 --- a/src/nanoFramework.Graphics/TouchPanel/Devices/ft6x06_I2C.cpp +++ b/src/nanoFramework.Graphics/TouchPanel/Devices/ft6x06_I2C.cpp @@ -53,7 +53,7 @@ bool TouchDevice::Enable(GPIO_INTERRUPT_SERVICE_ROUTINE touchIsrProc) GPIO_PIN FT6206_Interrupt = GPIOI_LCD_INT; PinMode driveMode = PinMode_Input; GPIO_INT_EDGE IntEdge = GPIO_INT_EDGE_HIGH; - void *ISR_Param = NULL; + void *ISR_Param = nullptr; if (CPU_GPIO_ReservePin(GPIOI_LCD_INT, true)) { diff --git a/src/nanoFramework.ResourceManager/nf_system_resourcemanager.cpp b/src/nanoFramework.ResourceManager/nf_system_resourcemanager.cpp index da132248d3..7e98fdcb5e 100644 --- a/src/nanoFramework.ResourceManager/nf_system_resourcemanager.cpp +++ b/src/nanoFramework.ResourceManager/nf_system_resourcemanager.cpp @@ -11,21 +11,21 @@ static const CLR_RT_MethodHandler method_lookup[] = { Library_nf_system_resourcemanager_System_Resources_ResourceManager::GetObjectInternal___OBJECT__I2, Library_nf_system_resourcemanager_System_Resources_ResourceManager::GetObjectInternal___OBJECT__I2__I4__I4, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, Library_nf_system_resourcemanager_System_Resources_ResourceManager::FindResource___STATIC__I4__STRING__SystemReflectionAssembly, Library_nf_system_resourcemanager_System_Resources_ResourceManager::GetObject___STATIC__OBJECT__SystemResourcesResourceManager__SystemEnum, Library_nf_system_resourcemanager_nanoFramework_Runtime_Native_ResourceUtility::GetObject___STATIC__OBJECT__SystemResourcesResourceManager__SystemEnum, Library_nf_system_resourcemanager_nanoFramework_Runtime_Native_ResourceUtility::GetObject___STATIC__OBJECT__SystemResourcesResourceManager__SystemEnum__I4__I4, - NULL, - NULL, + nullptr, + nullptr, }; const CLR_RT_NativeAssemblyData g_CLR_AssemblyNative_nanoFramework_ResourceManager = diff --git a/src/nanoFramework.ResourceManager/nf_system_resourcemanager_System_Resources_ResourceManager.cpp b/src/nanoFramework.ResourceManager/nf_system_resourcemanager_System_Resources_ResourceManager.cpp index cc5acf4677..05d051e1fe 100644 --- a/src/nanoFramework.ResourceManager/nf_system_resourcemanager_System_Resources_ResourceManager.cpp +++ b/src/nanoFramework.ResourceManager/nf_system_resourcemanager_System_Resources_ResourceManager.cpp @@ -43,9 +43,9 @@ HRESULT Library_nf_system_resourcemanager_System_Resources_ResourceManager::GetO NANOCLR_CHECK_HRESULT( g_CLR_RT_TypeSystem.LocateResource(assm, resourceFileId, pArgs[0].NumericByRefConst().s2, resource, size)); - if (resource != NULL) // otherwise NULL is returned + if (resource != nullptr) // otherwise nullptr is returned { - pAssm = assm.m_assm; + pAssm = assm.assembly; buf = pAssm->GetResourceData(resource->offset); switch (resource->kind) @@ -58,8 +58,7 @@ HRESULT Library_nf_system_resourcemanager_System_Resources_ResourceManager::GetO case CLR_RECORD_RESOURCE::RESOURCE_Binary: { - NANOCLR_CHECK_HRESULT( - CLR_RT_HeapBlock_Array::CreateInstance(top, size, g_CLR_RT_WellKnownTypes.m_UInt8)); + NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_Array::CreateInstance(top, size, g_CLR_RT_WellKnownTypes.UInt8)); memcpy(top.DereferenceArray()->GetFirstElement(), buf, size); } @@ -71,8 +70,7 @@ HRESULT Library_nf_system_resourcemanager_System_Resources_ResourceManager::GetO { CLR_RT_HeapBlock *ptr; - NANOCLR_CHECK_HRESULT( - g_CLR_RT_ExecutionEngine.NewObjectFromIndex(top, g_CLR_RT_WellKnownTypes.m_Bitmap)); + NANOCLR_CHECK_HRESULT(g_CLR_RT_ExecutionEngine.NewObjectFromIndex(top, g_CLR_RT_WellKnownTypes.Bitmap)); ptr = top.Dereference(); @@ -85,7 +83,7 @@ HRESULT Library_nf_system_resourcemanager_System_Resources_ResourceManager::GetO { CLR_RT_HeapBlock *ptr; - NANOCLR_CHECK_HRESULT(g_CLR_RT_ExecutionEngine.NewObjectFromIndex(top, g_CLR_RT_WellKnownTypes.m_Font)); + NANOCLR_CHECK_HRESULT(g_CLR_RT_ExecutionEngine.NewObjectFromIndex(top, g_CLR_RT_WellKnownTypes.Font)); ptr = top.Dereference(); @@ -137,9 +135,9 @@ HRESULT Library_nf_system_resourcemanager_System_Resources_ResourceManager::GetO NANOCLR_CHECK_HRESULT( g_CLR_RT_TypeSystem.LocateResource(assm, resourceFileId, pArgs[0].NumericByRefConst().s2, resource, size)); - if (resource != NULL) // otherwise NULL is returned + if (resource != nullptr) // otherwise nullptr is returned { - pAssm = assm.m_assm; + pAssm = assm.assembly; buf = pAssm->GetResourceData(resource->offset); switch (resource->kind) @@ -171,7 +169,7 @@ HRESULT Library_nf_system_resourcemanager_System_Resources_ResourceManager::GetO } NANOCLR_CHECK_HRESULT( - CLR_RT_HeapBlock_Array::CreateInstance(top, length, g_CLR_RT_WellKnownTypes.m_UInt8)); + CLR_RT_HeapBlock_Array::CreateInstance(top, length, g_CLR_RT_WellKnownTypes.UInt8)); memcpy(top.DereferenceArray()->GetFirstElement(), buf + offset, length); } diff --git a/src/nanoFramework.Runtime.Events/nf_rt_events_native.cpp b/src/nanoFramework.Runtime.Events/nf_rt_events_native.cpp index 37bd23c4b1..00e843402d 100644 --- a/src/nanoFramework.Runtime.Events/nf_rt_events_native.cpp +++ b/src/nanoFramework.Runtime.Events/nf_rt_events_native.cpp @@ -13,56 +13,56 @@ static const CLR_RT_MethodHandler method_lookup[] = { - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, Library_nf_rt_events_native_nanoFramework_Runtime_Events_EventSink::EventConfig___VOID, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, Library_nf_rt_events_native_nanoFramework_Runtime_Events_NativeEventDispatcher::EnableInterrupt___VOID, Library_nf_rt_events_native_nanoFramework_Runtime_Events_NativeEventDispatcher::DisableInterrupt___VOID, Library_nf_rt_events_native_nanoFramework_Runtime_Events_NativeEventDispatcher::Dispose___VOID__BOOLEAN, - NULL, - NULL, + nullptr, + nullptr, Library_nf_rt_events_native_nanoFramework_Runtime_Events_NativeEventDispatcher::_ctor___VOID__STRING__U8, - NULL, - NULL, - NULL, + nullptr, + nullptr, + nullptr, Library_nf_rt_events_native_nanoFramework_Runtime_Events_WeakDelegate::Combine___STATIC__SystemDelegate__SystemDelegate__SystemDelegate, Library_nf_rt_events_native_nanoFramework_Runtime_Events_WeakDelegate::Remove___STATIC__SystemDelegate__SystemDelegate__SystemDelegate, }; diff --git a/src/nanoFramework.Runtime.Events/nf_rt_events_native_nanoFramework_Runtime_Events_EventSink.cpp b/src/nanoFramework.Runtime.Events/nf_rt_events_native_nanoFramework_Runtime_Events_EventSink.cpp index be809450e4..d9360c5101 100644 --- a/src/nanoFramework.Runtime.Events/nf_rt_events_native_nanoFramework_Runtime_Events_EventSink.cpp +++ b/src/nanoFramework.Runtime.Events/nf_rt_events_native_nanoFramework_Runtime_Events_EventSink.cpp @@ -9,11 +9,11 @@ #include "nf_rt_events_native.h" -static CLR_RT_HeapBlock_NativeEventDispatcher *g_Context = NULL; +static CLR_RT_HeapBlock_NativeEventDispatcher *g_Context = nullptr; void PostManagedEvent(uint8_t category, uint8_t subCategory, uint16_t data1, uint32_t data2) { - if(g_Context != NULL) + if(g_Context != nullptr) { uint32_t d = ((uint32_t)data1 << 16) | (category << 8) | subCategory; @@ -42,7 +42,7 @@ static HRESULT CleanupEventSink( CLR_RT_HeapBlock_NativeEventDispatcher *pContex { (void)pContext; - g_Context = NULL; + g_Context = nullptr; CleanupNativeEventsFromHALQueue( pContext ); diff --git a/src/nanoFramework.Runtime.Events/nf_rt_events_native_nanoFramework_Runtime_Events_NativeEventDispatcher.cpp b/src/nanoFramework.Runtime.Events/nf_rt_events_native_nanoFramework_Runtime_Events_NativeEventDispatcher.cpp index 5d908c37d8..b39bddabf4 100644 --- a/src/nanoFramework.Runtime.Events/nf_rt_events_native_nanoFramework_Runtime_Events_NativeEventDispatcher.cpp +++ b/src/nanoFramework.Runtime.Events/nf_rt_events_native_nanoFramework_Runtime_Events_NativeEventDispatcher.cpp @@ -9,164 +9,176 @@ #include "nf_rt_events_native.h" -HRESULT Library_nf_rt_events_native_nanoFramework_Runtime_Events_NativeEventDispatcher::EnableInterrupt___VOID( CLR_RT_StackFrame& stack ) +HRESULT Library_nf_rt_events_native_nanoFramework_Runtime_Events_NativeEventDispatcher::EnableInterrupt___VOID( + CLR_RT_StackFrame &stack) { NANOCLR_HEADER(); - CLR_RT_HeapBlock_NativeEventDispatcher *pNativeDisp = NULL; - - CLR_RT_HeapBlock* pThis = stack.This(); FAULT_ON_NULL(pThis); + CLR_RT_HeapBlock_NativeEventDispatcher *pNativeDisp = nullptr; - if(pThis[ FIELD__disposed ].NumericByRef().s1 != 0) + CLR_RT_HeapBlock *pThis = stack.This(); + FAULT_ON_NULL(pThis); + + if (pThis[FIELD__disposed].NumericByRef().s1 != 0) { NANOCLR_SET_AND_LEAVE(CLR_E_OBJECT_DISPOSED); } - NANOCLR_CHECK_HRESULT(GetEventDispatcher( stack, pNativeDisp )); + NANOCLR_CHECK_HRESULT(GetEventDispatcher(stack, pNativeDisp)); - // Calls driver to enable interrupts. Consider that there could be no driver - // associated to this object so check that the driver methods are set - if(pNativeDisp->driverMethods == NULL) + // Calls driver to enable interrupts. Consider that there could be no driver + // associated to this object so check that the driver methods are set + if (pNativeDisp->driverMethods == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_OPERATION); } - - NANOCLR_CHECK_HRESULT(pNativeDisp->driverMethods->enableProcessor( pNativeDisp, true )); - + + NANOCLR_CHECK_HRESULT(pNativeDisp->driverMethods->enableProcessor(pNativeDisp, true)); + NANOCLR_NOCLEANUP(); } -HRESULT Library_nf_rt_events_native_nanoFramework_Runtime_Events_NativeEventDispatcher::DisableInterrupt___VOID( CLR_RT_StackFrame& stack ) +HRESULT Library_nf_rt_events_native_nanoFramework_Runtime_Events_NativeEventDispatcher::DisableInterrupt___VOID( + CLR_RT_StackFrame &stack) { NANOCLR_HEADER(); - - CLR_RT_HeapBlock_NativeEventDispatcher *pNativeDisp = NULL; - - CLR_RT_HeapBlock* pThis = stack.This(); FAULT_ON_NULL(pThis); - if(pThis[ FIELD__disposed ].NumericByRef().s1 != 0) + CLR_RT_HeapBlock_NativeEventDispatcher *pNativeDisp = nullptr; + + CLR_RT_HeapBlock *pThis = stack.This(); + FAULT_ON_NULL(pThis); + + if (pThis[FIELD__disposed].NumericByRef().s1 != 0) { NANOCLR_SET_AND_LEAVE(CLR_E_OBJECT_DISPOSED); } - NANOCLR_CHECK_HRESULT(GetEventDispatcher( stack, pNativeDisp )); - - // Calls driver to enable interrupts. Consider that there could be no driver - // associated to this object so check that the driver methods are set + NANOCLR_CHECK_HRESULT(GetEventDispatcher(stack, pNativeDisp)); + + // Calls driver to enable interrupts. Consider that there could be no driver + // associated to this object so check that the driver methods are set // we will be tolerant in this case and not throw any exception - if(pNativeDisp->driverMethods != NULL) + if (pNativeDisp->driverMethods != nullptr) { - NANOCLR_CHECK_HRESULT(pNativeDisp->driverMethods->enableProcessor( pNativeDisp, false )); + NANOCLR_CHECK_HRESULT(pNativeDisp->driverMethods->enableProcessor(pNativeDisp, false)); } - + NANOCLR_NOCLEANUP(); } -HRESULT Library_nf_rt_events_native_nanoFramework_Runtime_Events_NativeEventDispatcher::Dispose___VOID__BOOLEAN( CLR_RT_StackFrame& stack ) +HRESULT Library_nf_rt_events_native_nanoFramework_Runtime_Events_NativeEventDispatcher::Dispose___VOID__BOOLEAN( + CLR_RT_StackFrame &stack) { NANOCLR_HEADER(); - - CLR_RT_HeapBlock_NativeEventDispatcher *pNativeDisp = NULL; - - CLR_RT_HeapBlock* pThis = stack.This(); FAULT_ON_NULL(pThis); - - NANOCLR_CHECK_HRESULT(GetEventDispatcher( stack, pNativeDisp )); - - // Cleanup the HAL queue from the instance of associated CLR_RT_HeapBlock_NativeEventDispatcher + + CLR_RT_HeapBlock_NativeEventDispatcher *pNativeDisp = nullptr; + + CLR_RT_HeapBlock *pThis = stack.This(); + FAULT_ON_NULL(pThis); + + NANOCLR_CHECK_HRESULT(GetEventDispatcher(stack, pNativeDisp)); + + // Cleanup the HAL queue from the instance of associated CLR_RT_HeapBlock_NativeEventDispatcher pNativeDisp->RemoveFromHALQueue(); - - // Calls driver to enable interrupts. Consider that there could be no driver - // associated to this object so check that the driver methods are set + + // Calls driver to enable interrupts. Consider that there could be no driver + // associated to this object so check that the driver methods are set // we will be tolerant in this case and not throw any exception - if(pNativeDisp->driverMethods != NULL) + if (pNativeDisp->driverMethods != nullptr) { - NANOCLR_CHECK_HRESULT(pNativeDisp->driverMethods->cleanupProcessor( pNativeDisp )); + NANOCLR_CHECK_HRESULT(pNativeDisp->driverMethods->cleanupProcessor(pNativeDisp)); } - + NANOCLR_NOCLEANUP(); } -HRESULT Library_nf_rt_events_native_nanoFramework_Runtime_Events_NativeEventDispatcher::_ctor___VOID__STRING__U8( CLR_RT_StackFrame& stack ) +HRESULT Library_nf_rt_events_native_nanoFramework_Runtime_Events_NativeEventDispatcher::_ctor___VOID__STRING__U8( + CLR_RT_StackFrame &stack) { - NANOCLR_HEADER(); - - CLR_RT_DriverInterruptMethods* pDriverMethods; - const CLR_RT_NativeAssemblyData* pNativeDriverData; - CLR_RT_HeapBlock_NativeEventDispatcher* pNativeDisp = NULL; - - const char * driverName; - uint64_t driverData; - - CLR_RT_HeapBlock* pThis = stack.This(); FAULT_ON_NULL(pThis); - - // Retrieve paramenters; - if (stack.Arg1().DataType() != DATATYPE_OBJECT) - { - NANOCLR_SET_AND_LEAVE(CLR_E_WRONG_TYPE); + NANOCLR_HEADER(); + + CLR_RT_DriverInterruptMethods *pDriverMethods; + const CLR_RT_NativeAssemblyData *pNativeDriverData; + CLR_RT_HeapBlock_NativeEventDispatcher *pNativeDisp = nullptr; + + const char *driverName; + uint64_t driverData; + + CLR_RT_HeapBlock *pThis = stack.This(); + FAULT_ON_NULL(pThis); + + // Retrieve paramenters; + if (stack.Arg1().DataType() != DATATYPE_OBJECT) + { + NANOCLR_SET_AND_LEAVE(CLR_E_WRONG_TYPE); } - driverName = stack.Arg1().RecoverString(); FAULT_ON_NULL(driverName); + driverName = stack.Arg1().RecoverString(); + FAULT_ON_NULL(driverName); driverData = stack.Arg2().NumericByRef().u8; - // Throw NULL exception if string is empty. - if(hal_strlen_s( driverName ) == 0) - { + // Throw nullptr exception if string is empty. + if (hal_strlen_s(driverName) == 0) + { NANOCLR_CHECK_HRESULT(CLR_E_ARGUMENT_NULL); } - + // Retrives pointers to driver implemented functions. - pNativeDriverData = GetAssemblyNativeData( driverName ); - + pNativeDriverData = GetAssemblyNativeData(driverName); + // Validates check sum and presence of the structure. - if(pNativeDriverData == NULL || pNativeDriverData->m_checkSum != DRIVER_INTERRUPT_METHODS_CHECKSUM) + if (pNativeDriverData == nullptr || pNativeDriverData->m_checkSum != DRIVER_INTERRUPT_METHODS_CHECKSUM) { - NANOCLR_CHECK_HRESULT(CLR_E_DRIVER_NOT_REGISTERED); + NANOCLR_CHECK_HRESULT(CLR_E_DRIVER_NOT_REGISTERED); } // Get pointer to CLR_RT_DriverInterruptMethods pDriverMethods = (CLR_RT_DriverInterruptMethods *)pNativeDriverData->m_pNativeMethods; - + // Check that all methods are present: - if( pDriverMethods->initProcessor == NULL || - pDriverMethods->enableProcessor == NULL || - pDriverMethods->cleanupProcessor == NULL) + if (pDriverMethods->initProcessor == nullptr || pDriverMethods->enableProcessor == nullptr || + pDriverMethods->cleanupProcessor == nullptr) { - NANOCLR_CHECK_HRESULT(CLR_E_DRIVER_NOT_REGISTERED); + NANOCLR_CHECK_HRESULT(CLR_E_DRIVER_NOT_REGISTERED); } // So we found driver by name and now we create instance of CLR_RT_HeapBlock_NativeEventDispatcher - NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_NativeEventDispatcher::CreateInstance( *pThis, pThis[ FIELD___NativeEventDispatcher ] )); + NANOCLR_CHECK_HRESULT( + CLR_RT_HeapBlock_NativeEventDispatcher::CreateInstance(*pThis, pThis[FIELD___NativeEventDispatcher])); - // Initialize the driver with and provide the instance of CLR_RT_HeapBlock_NativeEventDispatcher - NANOCLR_CHECK_HRESULT(GetEventDispatcher( stack, pNativeDisp )); + // Initialize the driver with and provide the instance of CLR_RT_HeapBlock_NativeEventDispatcher + NANOCLR_CHECK_HRESULT(GetEventDispatcher(stack, pNativeDisp)); // Now call the driver. First save pointer to driver data. pNativeDisp->driverMethods = pDriverMethods; - NANOCLR_CHECK_HRESULT(pDriverMethods->initProcessor( pNativeDisp, driverData )); - + NANOCLR_CHECK_HRESULT(pDriverMethods->initProcessor(pNativeDisp, driverData)); + NANOCLR_NOCLEANUP(); } //--// -CLR_RT_ObjectToEvent_Source* Library_nf_rt_events_native_nanoFramework_Runtime_Events_NativeEventDispatcher::GetEventDispReference( CLR_RT_StackFrame& stack ) +CLR_RT_ObjectToEvent_Source *Library_nf_rt_events_native_nanoFramework_Runtime_Events_NativeEventDispatcher:: + GetEventDispReference(CLR_RT_StackFrame &stack) { NATIVE_PROFILE_CLR_HARDWARE(); - CLR_RT_HeapBlock* pThis = stack.This(); + CLR_RT_HeapBlock *pThis = stack.This(); - return CLR_RT_ObjectToEvent_Source::ExtractInstance( pThis[ FIELD___NativeEventDispatcher ] ); + return CLR_RT_ObjectToEvent_Source::ExtractInstance(pThis[FIELD___NativeEventDispatcher]); } -HRESULT Library_nf_rt_events_native_nanoFramework_Runtime_Events_NativeEventDispatcher::GetEventDispatcher( CLR_RT_StackFrame& stack, CLR_RT_HeapBlock_NativeEventDispatcher*& event ) +HRESULT Library_nf_rt_events_native_nanoFramework_Runtime_Events_NativeEventDispatcher::GetEventDispatcher( + CLR_RT_StackFrame &stack, + CLR_RT_HeapBlock_NativeEventDispatcher *&event) { NATIVE_PROFILE_CLR_HARDWARE(); NANOCLR_HEADER(); - event = GetEventDispatcher( stack ); - if(event == NULL) + event = GetEventDispatcher(stack); + if (event == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_WRONG_TYPE); } @@ -174,11 +186,12 @@ HRESULT Library_nf_rt_events_native_nanoFramework_Runtime_Events_NativeEventDisp NANOCLR_NOCLEANUP(); } -CLR_RT_HeapBlock_NativeEventDispatcher* Library_nf_rt_events_native_nanoFramework_Runtime_Events_NativeEventDispatcher::GetEventDispatcher( CLR_RT_StackFrame& stack ) +CLR_RT_HeapBlock_NativeEventDispatcher *Library_nf_rt_events_native_nanoFramework_Runtime_Events_NativeEventDispatcher:: + GetEventDispatcher(CLR_RT_StackFrame &stack) { NATIVE_PROFILE_CLR_HARDWARE(); - CLR_RT_ObjectToEvent_Source* src = GetEventDispReference( stack ); + CLR_RT_ObjectToEvent_Source *src = GetEventDispReference(stack); - return (src == NULL) ? NULL : (CLR_RT_HeapBlock_NativeEventDispatcher*)src->m_eventPtr; + return (src == nullptr) ? nullptr : (CLR_RT_HeapBlock_NativeEventDispatcher *)src->m_eventPtr; } diff --git a/src/nanoFramework.Runtime.Native/Runtime.Native.vcxproj b/src/nanoFramework.Runtime.Native/Runtime.Native.vcxproj index 8fc5b88a20..b557016f7d 100644 --- a/src/nanoFramework.Runtime.Native/Runtime.Native.vcxproj +++ b/src/nanoFramework.Runtime.Native/Runtime.Native.vcxproj @@ -21,7 +21,6 @@ - diff --git a/src/nanoFramework.Runtime.Native/Runtime.Native.vcxproj.filters b/src/nanoFramework.Runtime.Native/Runtime.Native.vcxproj.filters index a995bfae7f..5712633383 100644 --- a/src/nanoFramework.Runtime.Native/Runtime.Native.vcxproj.filters +++ b/src/nanoFramework.Runtime.Native/Runtime.Native.vcxproj.filters @@ -26,9 +26,6 @@ Source Files - - Source Files - Source Files diff --git a/src/nanoFramework.Runtime.Native/nf_rt_native.cpp b/src/nanoFramework.Runtime.Native/nf_rt_native.cpp index d073919f8c..ef50406a42 100644 --- a/src/nanoFramework.Runtime.Native/nf_rt_native.cpp +++ b/src/nanoFramework.Runtime.Native/nf_rt_native.cpp @@ -10,31 +10,29 @@ static const CLR_RT_MethodHandler method_lookup[] = { - NULL, + nullptr, Library_nf_rt_native_nanoFramework_Runtime_Native_ExecutionConstraint::Install___STATIC__VOID__I4__I4, - Library_nf_rt_native_nanoFramework_Runtime_Native_GC::Run___STATIC__U4__BOOLEAN, - Library_nf_rt_native_nanoFramework_Runtime_Native_GC::EnableGCMessages___STATIC__VOID__BOOLEAN, - NULL, - NULL, - NULL, - NULL, - NULL, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, Library_nf_rt_native_nanoFramework_Runtime_Native_Power::NativeReboot___STATIC__VOID__nanoFrameworkRuntimeNativeRebootOption, - NULL, - NULL, - NULL, - NULL, - NULL, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, Library_nf_rt_native_nanoFramework_Runtime_Native_Rtc::Native_RTC_SetSystemTime___STATIC__BOOLEAN__I4__U1__U1__U1__U1__U1__U1, Library_nf_rt_native_nanoFramework_Runtime_Native_SystemInfo::GetSystemVersion___STATIC__VOID__BYREF_I4__BYREF_I4__BYREF_I4__BYREF_I4, - NULL, + nullptr, Library_nf_rt_native_nanoFramework_Runtime_Native_SystemInfo::get_OEMString___STATIC__STRING, Library_nf_rt_native_nanoFramework_Runtime_Native_SystemInfo::get_OEM___STATIC__U1, Library_nf_rt_native_nanoFramework_Runtime_Native_SystemInfo::get_Model___STATIC__U1, Library_nf_rt_native_nanoFramework_Runtime_Native_SystemInfo::get_SKU___STATIC__U2, Library_nf_rt_native_nanoFramework_Runtime_Native_SystemInfo::get_TargetName___STATIC__STRING, Library_nf_rt_native_nanoFramework_Runtime_Native_SystemInfo::get_Platform___STATIC__STRING, - NULL, + nullptr, Library_nf_rt_native_nanoFramework_Runtime_Native_SystemInfo::GetNativeFloatingPointSupport___STATIC__U1, Library_nf_rt_native_System_Environment::get_TickCount64___STATIC__I8, }; @@ -42,9 +40,9 @@ static const CLR_RT_MethodHandler method_lookup[] = const CLR_RT_NativeAssemblyData g_CLR_AssemblyNative_nanoFramework_Runtime_Native = { "nanoFramework.Runtime.Native", - 0x0EAE898B, + 0xAD1ECE38, method_lookup, - { 100, 0, 10, 0 } + { 100, 0, 11, 0 } }; // clang-format on diff --git a/src/nanoFramework.Runtime.Native/nf_rt_native.h b/src/nanoFramework.Runtime.Native/nf_rt_native.h index 5b8d9d9b32..a54efc934d 100644 --- a/src/nanoFramework.Runtime.Native/nf_rt_native.h +++ b/src/nanoFramework.Runtime.Native/nf_rt_native.h @@ -1,4 +1,4 @@ -// +// // Copyright (c) .NET Foundation and Contributors // Portions Copyright (c) Microsoft Corporation. All rights reserved. // See LICENSE file in the project root for full license information. @@ -34,14 +34,6 @@ struct Library_nf_rt_native_nanoFramework_Runtime_Native_ExecutionConstraint //--// }; -struct Library_nf_rt_native_nanoFramework_Runtime_Native_GC -{ - NANOCLR_NATIVE_DECLARE(Run___STATIC__U4__BOOLEAN); - NANOCLR_NATIVE_DECLARE(EnableGCMessages___STATIC__VOID__BOOLEAN); - - //--// -}; - struct Library_nf_rt_native_nanoFramework_Runtime_Native_Power { static const int FIELD_STATIC__OnRebootEvent = 0; diff --git a/src/nanoFramework.Runtime.Native/nf_rt_native_nanoFramework_Runtime_Native_GC.cpp b/src/nanoFramework.Runtime.Native/nf_rt_native_nanoFramework_Runtime_Native_GC.cpp deleted file mode 100644 index ece7219695..0000000000 --- a/src/nanoFramework.Runtime.Native/nf_rt_native_nanoFramework_Runtime_Native_GC.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// -// Copyright (c) .NET Foundation and Contributors -// Portions Copyright (c) Microsoft Corporation. All rights reserved. -// See LICENSE file in the project root for full license information. -// - - -#include "nf_rt_native.h" - - - -HRESULT Library_nf_rt_native_nanoFramework_Runtime_Native_GC::Run___STATIC__U4__BOOLEAN( CLR_RT_StackFrame& stack ) -{ - NATIVE_PROFILE_CLR_CORE(); - - NANOCLR_HEADER(); - -#if defined(NANOCLR_GC_VERBOSE) - if(s_CLR_RT_fTrace_GC >= c_CLR_RT_Trace_Info) - { - CLR_Debug::Printf( " Memory: Debug.GC.\r\n" ); - } -#endif - - stack.SetResult_I4( g_CLR_RT_ExecutionEngine.PerformGarbageCollection() ); - - if(stack.Arg0().NumericByRefConst().u1) - { - // - // Decrement the number of GC, otherwise the outer loop may request another compaction. - // - g_CLR_RT_GarbageCollector.m_numberOfGarbageCollections--; - - g_CLR_RT_ExecutionEngine.PerformHeapCompaction(); - } - - NANOCLR_NOCLEANUP_NOLABEL(); -} - -HRESULT Library_nf_rt_native_nanoFramework_Runtime_Native_GC::EnableGCMessages___STATIC__VOID__BOOLEAN( CLR_RT_StackFrame& stack ) -{ - NATIVE_PROFILE_CLR_CORE(); - - NANOCLR_HEADER(); - - #if defined(NANOCLR_TRACE_MEMORY_STATS) - s_CLR_RT_fTrace_MemoryStats = stack.Arg0().NumericByRefConst().u1 != 0 ? c_CLR_RT_Trace_Info : c_CLR_RT_Trace_None; - #else - (void)stack; - #endif - - NANOCLR_NOCLEANUP_NOLABEL(); -} diff --git a/src/nanoFramework.System.Collections/nf_system_collections.cpp b/src/nanoFramework.System.Collections/nf_system_collections.cpp index 2e29f564f3..bb787babcf 100644 --- a/src/nanoFramework.System.Collections/nf_system_collections.cpp +++ b/src/nanoFramework.System.Collections/nf_system_collections.cpp @@ -9,31 +9,31 @@ static const CLR_RT_MethodHandler method_lookup[] = { - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, Library_nf_system_collections_System_Collections_Hashtable::Clear___VOID, NULL, NULL, @@ -47,56 +47,56 @@ static const CLR_RT_MethodHandler method_lookup[] = Library_nf_system_collections_System_Collections_Hashtable::ContainsNative___BOOLEAN__OBJECT__I4, Library_nf_system_collections_System_Collections_Hashtable::RemoveNative___VOID__OBJECT__I4, Library_nf_system_collections_System_Collections_Hashtable::GetPrimeNative___STATIC__I4__I4, - NULL, - NULL, - NULL, - NULL, - NULL, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, Library_nf_system_collections_System_Collections_Hashtable__HashtableEnumerator::MoveNext___BOOLEAN, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, Library_nf_system_collections_System_Collections_Queue::Clear___VOID, Library_nf_system_collections_System_Collections_Queue::CopyTo___VOID__SystemArray__I4, Library_nf_system_collections_System_Collections_Queue::Enqueue___VOID__OBJECT, - NULL, + nullptr, Library_nf_system_collections_System_Collections_Queue::Dequeue___OBJECT, Library_nf_system_collections_System_Collections_Queue::Peek___OBJECT, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, Library_nf_system_collections_System_Collections_Stack::Clear___VOID, - NULL, - NULL, - NULL, - NULL, + nullptr, + nullptr, + nullptr, + nullptr, Library_nf_system_collections_System_Collections_Stack::Peek___OBJECT, Library_nf_system_collections_System_Collections_Stack::Pop___OBJECT, Library_nf_system_collections_System_Collections_Stack::Push___VOID__OBJECT, - NULL, - NULL, + nullptr, + nullptr, }; const CLR_RT_NativeAssemblyData g_CLR_AssemblyNative_nanoFramework_System_Collections = diff --git a/src/nanoFramework.System.Collections/nf_system_collections_System_Collections_Hashtable.cpp b/src/nanoFramework.System.Collections/nf_system_collections_System_Collections_Hashtable.cpp index 558b75b625..a0d6bb412d 100644 --- a/src/nanoFramework.System.Collections/nf_system_collections_System_Collections_Hashtable.cpp +++ b/src/nanoFramework.System.Collections/nf_system_collections_System_Collections_Hashtable.cpp @@ -45,11 +45,11 @@ HRESULT Library_nf_system_collections_System_Collections_Hashtable::Clear___VOID bucket = bucketElement->Dereference(); // sanity check: can only clear buckets that already have objects - if (bucket != NULL) + if (bucket != nullptr) { bucket[BucketType::FIELD___hash].NumericByRef().u4 = 0; - bucket[BucketType::FIELD___value].SetObjectReference(NULL); - bucket[BucketType::FIELD___key].SetObjectReference(NULL); + bucket[BucketType::FIELD___value].SetObjectReference(nullptr); + bucket[BucketType::FIELD___key].SetObjectReference(nullptr); } } @@ -101,7 +101,7 @@ HRESULT Library_nf_system_collections_System_Collections_Hashtable::ContainsNati bucketElement = ((CLR_RT_HeapBlock *)buckets->GetElement(bucketNumber)); bucket = bucketElement->Dereference(); - if (bucket != NULL && bucket[BucketType::FIELD___key].Dereference() != NULL && + if (bucket != nullptr && bucket[BucketType::FIELD___key].Dereference() != nullptr && (bucket[BucketType::FIELD___hash].NumericByRef().u4 == hashcode) && (CLR_RT_HeapBlock::ObjectsEqual(*bucket[BucketType::FIELD___key].Dereference(), *key, true))) { @@ -160,15 +160,15 @@ HRESULT Library_nf_system_collections_System_Collections_Hashtable::RemoveNative bucketElement = ((CLR_RT_HeapBlock *)buckets->GetElement(bucketNumber)); bucket = bucketElement->Dereference(); - if (bucket != NULL && bucket[BucketType::FIELD___key].Dereference() != NULL && + if (bucket != nullptr && bucket[BucketType::FIELD___key].Dereference() != nullptr && (bucket[BucketType::FIELD___hash].NumericByRef().u4 == hashcode) && (CLR_RT_HeapBlock::ObjectsEqual(*bucket[BucketType::FIELD___key].Dereference(), *key, true))) { // Clear hash field, then key, then value bucket[BucketType::FIELD___hash].NumericByRef().u4 = 0; - bucket[BucketType::FIELD___value].SetObjectReference(NULL); - bucket[BucketType::FIELD___key].SetObjectReference(NULL); + bucket[BucketType::FIELD___value].SetObjectReference(nullptr); + bucket[BucketType::FIELD___key].SetObjectReference(nullptr); // subtract count field pThis[FIELD___count].NumericByRef().s4--; @@ -237,7 +237,7 @@ HRESULT Library_nf_system_collections_System_Collections_Hashtable::InsertNative bucket = bucketElement->Dereference(); // Insert the key/value pair into this bucket if this bucket is empty - if (bucket == NULL || (bucket != NULL && bucket[BucketType::FIELD___key].Dereference() == NULL)) + if (bucket == nullptr || (bucket != nullptr && bucket[BucketType::FIELD___key].Dereference() == nullptr)) { // We pretty much have to insert in this order. Don't set hash // code until the value & key are set appropriately. @@ -245,7 +245,7 @@ HRESULT Library_nf_system_collections_System_Collections_Hashtable::InsertNative CLR_RT_TypeDef_Index bucketTypeDef; CLR_RT_HeapBlock newBucket; - if (bucket == NULL) + if (bucket == nullptr) { // find type, don't bother checking the result as it exists for sure g_CLR_RT_TypeSystem.FindTypeDef("Bucket", "System.Collections", bucketTypeDef); @@ -268,7 +268,7 @@ HRESULT Library_nf_system_collections_System_Collections_Hashtable::InsertNative NANOCLR_SET_AND_LEAVE(S_OK) } - if (bucket != NULL && + if (bucket != nullptr && (CLR_RT_HeapBlock::ObjectsEqual(*bucket[BucketType::FIELD___key].Dereference(), *key, true))) { if (add) @@ -334,7 +334,7 @@ HRESULT Library_nf_system_collections_System_Collections_Hashtable::GetNative___ bucketElement = ((CLR_RT_HeapBlock *)buckets->GetElement(bucketNumber)); bucket = bucketElement->Dereference(); - if (bucket != NULL && (bucket[BucketType::FIELD___hash].NumericByRef().u4 == hashcode) && + if (bucket != nullptr && (bucket[BucketType::FIELD___hash].NumericByRef().u4 == hashcode) && (CLR_RT_HeapBlock::ObjectsEqual(*bucket[BucketType::FIELD___key].Dereference(), *key, true))) { stack.SetResult_Object(bucket[BucketType::FIELD___value].Dereference()); @@ -345,7 +345,7 @@ HRESULT Library_nf_system_collections_System_Collections_Hashtable::GetNative___ } while (++entry < bucketsLength); // no key found - stack.SetResult_Object(NULL); + stack.SetResult_Object(nullptr); NANOCLR_NOCLEANUP(); } @@ -449,7 +449,7 @@ HRESULT Library_nf_system_collections_System_Collections_Hashtable::Expand(CLR_R oldBucket = oldBucketElement->Dereference(); // sanity check: can only clear buckets that already have objects - if (oldBucket != NULL && oldBucket[BucketType::FIELD___key].Dereference() != NULL) + if (oldBucket != nullptr && oldBucket[BucketType::FIELD___key].Dereference() != nullptr) { seed = oldBucket[BucketType::FIELD___hash].NumericByRef().u4; incr = 1 + ((seed * HashPrime) % ((uint32_t)newSize - 1)); @@ -461,7 +461,7 @@ HRESULT Library_nf_system_collections_System_Collections_Hashtable::Expand(CLR_R newBucketElement = ((CLR_RT_HeapBlock *)newBuckets->GetElement(newBucketNumber)); bucket = newBucketElement->Dereference(); - if (bucket == NULL || bucket[BucketType::FIELD___key].Dereference() == NULL) + if (bucket == nullptr || bucket[BucketType::FIELD___key].Dereference() == nullptr) { // create a new CLR_RT_HeapBlock newBucket; diff --git a/src/nanoFramework.System.Collections/nf_system_collections_System_Collections_Hashtable__HashtableEnumerator.cpp b/src/nanoFramework.System.Collections/nf_system_collections_System_Collections_Hashtable__HashtableEnumerator.cpp index 7c8c0b629b..afe3ea49af 100644 --- a/src/nanoFramework.System.Collections/nf_system_collections_System_Collections_Hashtable__HashtableEnumerator.cpp +++ b/src/nanoFramework.System.Collections/nf_system_collections_System_Collections_Hashtable__HashtableEnumerator.cpp @@ -43,11 +43,11 @@ HRESULT Library_nf_system_collections_System_Collections_Hashtable__HashtableEnu bucketElement = ((CLR_RT_HeapBlock *)buckets->GetElement(bucket)); currentBucket = bucketElement->Dereference(); - if (currentBucket != NULL) + if (currentBucket != nullptr) { keyv = currentBucket[BucketType::FIELD___key].Dereference(); - if (keyv != NULL) + if (keyv != nullptr) { pThis[FIELD___currentKey].SetObjectReference(keyv); pThis[FIELD___currentValue].SetObjectReference(currentBucket[BucketType::FIELD___value].Dereference()); diff --git a/src/nanoFramework.System.IO.Hashing/nf_sys_io_hashing_System_IO_Hashing_Crc32_stubs.cpp b/src/nanoFramework.System.IO.Hashing/nf_sys_io_hashing_System_IO_Hashing_Crc32_stubs.cpp index 07b0823362..645a87fae1 100644 --- a/src/nanoFramework.System.IO.Hashing/nf_sys_io_hashing_System_IO_Hashing_Crc32_stubs.cpp +++ b/src/nanoFramework.System.IO.Hashing/nf_sys_io_hashing_System_IO_Hashing_Crc32_stubs.cpp @@ -56,13 +56,13 @@ HRESULT Library_nf_sys_io_hashing_System_IO_Hashing_Crc32::ComputeHash___STATIC_ CLR_RT_HeapBlock *bufferSpanByte; CLR_RT_HeapBlock_Array *buffer; - uint8_t *bufferData = NULL; + uint8_t *bufferData = nullptr; int32_t bufferSize = 0; int32_t bufferOffset = 0; uint32_t crc32 = 0; uint32_t hash = 0; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr bufferSpanByte = stack.Arg1().Dereference(); FAULT_ON_NULL_ARG(bufferSpanByte); diff --git a/src/nanoFramework.System.Security.Cryptography/nf_sys_sec_cryptography_System_Security_Cryptography_Aes.cpp b/src/nanoFramework.System.Security.Cryptography/nf_sys_sec_cryptography_System_Security_Cryptography_Aes.cpp index 3d82aadd07..5222888e60 100644 --- a/src/nanoFramework.System.Security.Cryptography/nf_sys_sec_cryptography_System_Security_Cryptography_Aes.cpp +++ b/src/nanoFramework.System.Security.Cryptography/nf_sys_sec_cryptography_System_Security_Cryptography_Aes.cpp @@ -57,8 +57,8 @@ HRESULT Library_nf_sys_sec_cryptography_System_Security_Cryptography_Aes::Encryp size_t outputLength = 0; size_t ivLength = 0; uint16_t passCount = 0; - uint8_t *ivCopy = NULL; - uint8_t *workBuffer = NULL; + uint8_t *ivCopy = nullptr; + uint8_t *workBuffer = nullptr; CLR_RT_HeapBlock_Array *keyArray; CLR_RT_HeapBlock_Array *ivArray; @@ -69,9 +69,9 @@ HRESULT Library_nf_sys_sec_cryptography_System_Security_Cryptography_Aes::Encryp pThis = (CLR_RT_HeapBlock *)stack.This(); FAULT_ON_NULL(pThis); - // grab key and check for NULL + // grab key and check for nullptr keyArray = pThis[FIELD___key].DereferenceArray(); - if (keyArray == NULL) + if (keyArray == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_OPERATION); } @@ -80,13 +80,13 @@ HRESULT Library_nf_sys_sec_cryptography_System_Security_Cryptography_Aes::Encryp // (expecting this to be filled with the IV from managed code) ivArray = pThis[FIELD___iv].DereferenceArray(); - // need to check if IV is NULL (AES doesn't require an IV) - if (ivArray != NULL) + // need to check if IV is nullptr (AES doesn't require an IV) + if (ivArray != nullptr) { // need a copy of the IV because it will be modified by mbedtls ivCopy = (uint8_t *)platform_malloc(ivArray->m_numOfElements); - if (ivCopy == NULL) + if (ivCopy == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_OUT_OF_MEMORY); } @@ -96,7 +96,7 @@ HRESULT Library_nf_sys_sec_cryptography_System_Security_Cryptography_Aes::Encryp ivLength = ivArray->m_numOfElements; } - // grab plain text and check for NULL + // grab plain text and check for nullptr plainTextArray = stack.Arg1().DereferenceArray(); FAULT_ON_NULL_ARG(plainTextArray); @@ -112,7 +112,7 @@ HRESULT Library_nf_sys_sec_cryptography_System_Security_Cryptography_Aes::Encryp NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_Array::CreateInstance( stack.TopValue(), plainTextArray->m_numOfElements, - g_CLR_RT_WellKnownTypes.m_UInt8)); + g_CLR_RT_WellKnownTypes.UInt8)); // get a reference to the array to return cipherTextArray = stack.TopValue().DereferenceArray(); @@ -127,7 +127,7 @@ HRESULT Library_nf_sys_sec_cryptography_System_Security_Cryptography_Aes::Encryp // need a work buffer to hold the encrypted data workBuffer = (uint8_t *)platform_malloc(plainTextArray->m_numOfElements + cipherInfo->private_block_size); - if (workBuffer == NULL) + if (workBuffer == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_OUT_OF_MEMORY); } @@ -178,12 +178,12 @@ HRESULT Library_nf_sys_sec_cryptography_System_Security_Cryptography_Aes::Encryp NANOCLR_CLEANUP(); - if (ivCopy != NULL) + if (ivCopy != nullptr) { platform_free(ivCopy); } - if (workBuffer != NULL) + if (workBuffer != nullptr) { platform_free(workBuffer); } diff --git a/src/nanoFramework.System.Security.Cryptography/nf_sys_sec_cryptography_System_Security_Cryptography_HMACSHA256.cpp b/src/nanoFramework.System.Security.Cryptography/nf_sys_sec_cryptography_System_Security_Cryptography_HMACSHA256.cpp index c79729def6..5672579f42 100644 --- a/src/nanoFramework.System.Security.Cryptography/nf_sys_sec_cryptography_System_Security_Cryptography_HMACSHA256.cpp +++ b/src/nanoFramework.System.Security.Cryptography/nf_sys_sec_cryptography_System_Security_Cryptography_HMACSHA256.cpp @@ -32,7 +32,7 @@ HRESULT Library_nf_sys_sec_cryptography_System_Security_Cryptography_HMACSHA256: // create the return array (32 bytes length) stack.PushValueAndClear(); NANOCLR_CHECK_HRESULT( - CLR_RT_HeapBlock_Array::CreateInstance(stack.TopValue(), 32, g_CLR_RT_WellKnownTypes.m_UInt8)); + CLR_RT_HeapBlock_Array::CreateInstance(stack.TopValue(), 32, g_CLR_RT_WellKnownTypes.UInt8)); outputArray = stack.TopValue().DereferenceArray(); // better clear memory diff --git a/src/nanoFramework.System.Text/nf_system_text.cpp b/src/nanoFramework.System.Text/nf_system_text.cpp index c490786f3f..44a699978a 100644 --- a/src/nanoFramework.System.Text/nf_system_text.cpp +++ b/src/nanoFramework.System.Text/nf_system_text.cpp @@ -8,80 +8,80 @@ static const CLR_RT_MethodHandler method_lookup[] = { - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, Library_nf_system_text_System_Text_UTF8Decoder::Convert___VOID__SZARRAY_U1__I4__I4__SZARRAY_CHAR__I4__I4__BOOLEAN__BYREF_I4__BYREF_I4__BYREF_BOOLEAN, - NULL, + nullptr, Library_nf_system_text_System_Text_UTF8Encoding::GetBytes___SZARRAY_U1__STRING, Library_nf_system_text_System_Text_UTF8Encoding::GetBytes___I4__STRING__I4__I4__SZARRAY_U1__I4, Library_nf_system_text_System_Text_UTF8Encoding::GetChars___SZARRAY_CHAR__SZARRAY_U1, Library_nf_system_text_System_Text_UTF8Encoding::GetChars___SZARRAY_CHAR__SZARRAY_U1__I4__I4, - NULL, - NULL, + nullptr, + nullptr, }; const CLR_RT_NativeAssemblyData g_CLR_AssemblyNative_nanoFramework_System_Text = diff --git a/src/nanoFramework.System.Text/nf_system_text_System_Text_UTF8Encoding.cpp b/src/nanoFramework.System.Text/nf_system_text_System_Text_UTF8Encoding.cpp index 7e18859dd3..98d8b69343 100644 --- a/src/nanoFramework.System.Text/nf_system_text_System_Text_UTF8Encoding.cpp +++ b/src/nanoFramework.System.Text/nf_system_text_System_Text_UTF8Encoding.cpp @@ -1,4 +1,4 @@ -// +// // Copyright (c) .NET Foundation and Contributors // Portions Copyright (c) Microsoft Corporation. All rights reserved. // See LICENSE file in the project root for full license information. @@ -21,7 +21,7 @@ HRESULT Library_nf_system_text_System_Text_UTF8Encoding::GetBytes___SZARRAY_U1__ cBytes = hal_strlen_s(str); NANOCLR_CHECK_HRESULT( - CLR_RT_HeapBlock_Array::CreateInstance(ret, (CLR_UINT32)cBytes, g_CLR_RT_WellKnownTypes.m_UInt8)); + CLR_RT_HeapBlock_Array::CreateInstance(ret, (CLR_UINT32)cBytes, g_CLR_RT_WellKnownTypes.UInt8)); arr = ret.DereferenceArray(); @@ -105,13 +105,14 @@ HRESULT Library_nf_system_text_System_Text_UTF8Encoding::Helper__GetChars(CLR_RT CLR_RT_HeapBlock_Array *pArrayBytesCopy; CLR_RT_HeapBlock_Array *arrTmp; - ref.SetObjectReference(NULL); + ref.SetObjectReference(nullptr); CLR_RT_ProtectFromGC gc(ref); CLR_RT_HeapBlock_Array *pArrayBytes = stack.Arg1().DereferenceArray(); CLR_INT32 byteIdx = fIndexed ? stack.Arg2().NumericByRef().s4 : 0; CLR_INT32 byteCnt = fIndexed ? stack.Arg3().NumericByRef().s4 : pArrayBytes->m_numOfElements; + FAULT_ON_NULL(pArrayBytes); _ASSERTE(pArrayBytes->m_typeOfElement == DATATYPE_U1); @@ -122,7 +123,7 @@ HRESULT Library_nf_system_text_System_Text_UTF8Encoding::Helper__GetChars(CLR_RT cBytesCopy = byteCnt + 1; /* Copy the array to a temporary buffer to create a zero-terminated string */ - NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_Array::CreateInstance(ref, cBytesCopy, g_CLR_RT_WellKnownTypes.m_UInt8)); + NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_Array::CreateInstance(ref, cBytesCopy, g_CLR_RT_WellKnownTypes.UInt8)); pArrayBytesCopy = ref.DereferenceArray(); szText = (const char *)pArrayBytesCopy->GetFirstElement(); diff --git a/targets-community b/targets-community index 63b29dff90..45696564f0 160000 --- a/targets-community +++ b/targets-community @@ -1 +1 @@ -Subproject commit 63b29dff90ecf6b0b949ba6023de7f876cc4245c +Subproject commit 45696564f074fcf9eab982b752f7a81985203091 diff --git a/targets/AzureRTOS/ST/_common/targetHAL_ConfigurationManager.cpp b/targets/AzureRTOS/ST/_common/targetHAL_ConfigurationManager.cpp index c9f2d7d087..f3593b3507 100644 --- a/targets/AzureRTOS/ST/_common/targetHAL_ConfigurationManager.cpp +++ b/targets/AzureRTOS/ST/_common/targetHAL_ConfigurationManager.cpp @@ -198,7 +198,7 @@ __nfweak bool ConfigurationManager_GetConfigurationBlock( uint32_t configurationIndex) { int sizeOfBlock = 0; - uint8_t *blockAddress = NULL; + uint8_t *blockAddress = nullptr; // validate if the requested block exists // Count has to be non zero @@ -290,7 +290,7 @@ __nfweak bool ConfigurationManager_StoreConfigurationBlock( if (configuration == DeviceConfigurationOption_Network) { - if (g_TargetConfiguration.NetworkInterfaceConfigs == NULL || + if (g_TargetConfiguration.NetworkInterfaceConfigs == nullptr || (g_TargetConfiguration.NetworkInterfaceConfigs->Count == 0 && configurationIndex == 0)) { // there is no network config block, we are storing the default one @@ -325,7 +325,7 @@ __nfweak bool ConfigurationManager_StoreConfigurationBlock( #if (TARGET_HAS_WIFI_SUPPORT == 1) - if (g_TargetConfiguration.Wireless80211Configs == NULL || + if (g_TargetConfiguration.Wireless80211Configs == nullptr || (g_TargetConfiguration.Wireless80211Configs->Count == 0 && configurationIndex == 0)) { // there is no wireless 80211 config block, so we are storing the default one @@ -389,7 +389,7 @@ __nfweak bool ConfigurationManager_StoreConfigurationBlock( (ByteAddress)g_TargetConfiguration.CertificateStore->Certificates[configurationIndex] + offset; } - if (g_TargetConfiguration.CertificateStore == NULL || + if (g_TargetConfiguration.CertificateStore == nullptr || (g_TargetConfiguration.CertificateStore->Count == 0 || (configurationIndex + 1) > g_TargetConfiguration.CertificateStore->Count)) { @@ -402,7 +402,7 @@ __nfweak bool ConfigurationManager_StoreConfigurationBlock( } // now check if memory is erase, so the block can be stored - if (!STM32FlashDriver_IsBlockErased(NULL, storageAddress, blockSize)) + if (!STM32FlashDriver_IsBlockErased(nullptr, storageAddress, blockSize)) { // memory not erased, can't store return FALSE; @@ -439,7 +439,7 @@ __nfweak bool ConfigurationManager_StoreConfigurationBlock( (ByteAddress)g_TargetConfiguration.DeviceCertificates->Certificates[configurationIndex] + offset; } - if (g_TargetConfiguration.DeviceCertificates == NULL || + if (g_TargetConfiguration.DeviceCertificates == nullptr || (g_TargetConfiguration.DeviceCertificates->Count == 0 || (configurationIndex + 1) > g_TargetConfiguration.DeviceCertificates->Count)) { @@ -452,7 +452,7 @@ __nfweak bool ConfigurationManager_StoreConfigurationBlock( } // now check if memory is erase, so the block can be stored - if (!STM32FlashDriver_IsBlockErased(NULL, storageAddress, blockSize)) + if (!STM32FlashDriver_IsBlockErased(nullptr, storageAddress, blockSize)) { // memory not erased, can't store return FALSE; @@ -483,7 +483,7 @@ __nfweak bool ConfigurationManager_StoreConfigurationBlock( } // copy the config block content to the config block storage - success = STM32FlashDriver_Write(NULL, storageAddress, blockSize, (unsigned char *)configurationBlock, true); + success = STM32FlashDriver_Write(nullptr, storageAddress, blockSize, (unsigned char *)configurationBlock, true); // enumeration is required after we are DONE with SUCCESSFULLY storing all the config chunks requiresEnumeration = (success && done); @@ -524,7 +524,7 @@ __nfweak UpdateConfigurationResult ConfigurationManager_UpdateConfigurationBlock // allocate memory from CRT heap uint8_t *configSectorCopy = (uint8_t *)platform_malloc(sizeOfConfigSector); - if (configSectorCopy != NULL) + if (configSectorCopy != nullptr) { // copy config sector from flash to RAM memcpy(configSectorCopy, &__nanoConfig_start__, sizeOfConfigSector); @@ -662,7 +662,7 @@ __nfweak UpdateConfigurationResult ConfigurationManager_UpdateConfigurationBlock } // erase config sector - if (STM32FlashDriver_EraseBlock(NULL, (uint32_t)&__nanoConfig_start__) == TRUE) + if (STM32FlashDriver_EraseBlock(nullptr, (uint32_t)&__nanoConfig_start__) == TRUE) { // flash block is erased @@ -677,7 +677,7 @@ __nfweak UpdateConfigurationResult ConfigurationManager_UpdateConfigurationBlock // copy the config block copy back to the config block storage if (STM32FlashDriver_Write( - NULL, + nullptr, (uint32_t)&__nanoConfig_start__, sizeOfConfigSector, (unsigned char *)configSectorCopy, diff --git a/targets/AzureRTOS/ST/_nanoCLR/System.Device.I2c/sys_dev_i2c_native_System_Device_I2c_I2cDevice.cpp b/targets/AzureRTOS/ST/_nanoCLR/System.Device.I2c/sys_dev_i2c_native_System_Device_I2c_I2cDevice.cpp index 0cf7fb6ad0..ec6a5df500 100644 --- a/targets/AzureRTOS/ST/_nanoCLR/System.Device.I2c/sys_dev_i2c_native_System_Device_I2c_I2cDevice.cpp +++ b/targets/AzureRTOS/ST/_nanoCLR/System.Device.I2c/sys_dev_i2c_native_System_Device_I2c_I2cDevice.cpp @@ -127,7 +127,7 @@ static void I2CWorkingThread_entry(uint32_t arg) palI2c->Address, palI2c->WriteBuffer, palI2c->WriteSize, - NULL, + nullptr, 0, TX_TICKS_PER_MILLISEC(estimatedDurationMiliseconds)); } @@ -157,11 +157,11 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice::NativeInit___VOI { NANOCLR_HEADER(); - NF_PAL_I2C *palI2c = NULL; + NF_PAL_I2C *palI2c = nullptr; CLR_RT_HeapBlock *connectionSettings; uint8_t busIndex; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -180,7 +180,7 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice::NativeInit___VOI { #if (STM32_I2C_USE_I2C1 == TRUE) case 1: - if (I2C1_PAL.Driver == NULL) + if (I2C1_PAL.Driver == nullptr) { ConfigPins_I2C1(); @@ -194,7 +194,7 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice::NativeInit___VOI #endif #if defined(STM32_I2C_USE_I2C2) && (STM32_I2C_USE_I2C2 == TRUE) case 2: - if (I2C2_PAL.Driver == NULL) + if (I2C2_PAL.Driver == nullptr) { ConfigPins_I2C2(); @@ -208,7 +208,7 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice::NativeInit___VOI #endif #if defined(STM32_I2C_USE_I2C3) && (STM32_I2C_USE_I2C3 == TRUE) case 3: - if (I2C3_PAL.Driver == NULL) + if (I2C3_PAL.Driver == nullptr) { ConfigPins_I2C3(); @@ -222,7 +222,7 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice::NativeInit___VOI #endif #if defined(STM32_I2C_USE_I2C4) && (STM32_I2C_USE_I2C4 == TRUE) case 4: - if (I2C4_PAL.Driver == NULL) + if (I2C4_PAL.Driver == nullptr) { ConfigPins_I2C4(); @@ -258,8 +258,8 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice::NativeInit___VOI } // clear pointer to working thread - palI2c->WorkingThread = NULL; - palI2c->WorkingThreadStack = NULL; + palI2c->WorkingThread = nullptr; + palI2c->WorkingThreadStack = nullptr; NANOCLR_NOCLEANUP(); } @@ -269,11 +269,11 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice::NativeDispose___ NANOCLR_HEADER(); uint8_t busIndex; - NF_PAL_I2C *palI2c = NULL; + NF_PAL_I2C *palI2c = nullptr; CLR_RT_HeapBlock *connectionSettings; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -299,7 +299,7 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice::NativeDispose___ // deactivates the I2C peripheral i2cStop(&I2CD1); // nulls driver - I2C1_PAL.Driver = NULL; + I2C1_PAL.Driver = nullptr; } break; @@ -318,7 +318,7 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice::NativeDispose___ // deactivates the I2C peripheral i2cStop(&I2CD2); // nulls driver - I2C2_PAL.Driver = NULL; + I2C2_PAL.Driver = nullptr; } break; @@ -337,7 +337,7 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice::NativeDispose___ // deactivates the I2C peripheral i2cStop(&I2CD3); // nulls driver - I2C3_PAL.Driver = NULL; + I2C3_PAL.Driver = nullptr; } break; @@ -356,7 +356,7 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice::NativeDispose___ // deactivates the I2C peripheral i2cStop(&I2CD4); // nulls driver - I2C4_PAL.Driver = NULL; + I2C4_PAL.Driver = nullptr; } break; @@ -369,7 +369,7 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice::NativeDispose___ } // stop working thread, if it's running - if (palI2c->WorkingThread != NULL) + if (palI2c->WorkingThread != nullptr) { // delete thread tx_thread_delete(palI2c->WorkingThread); @@ -378,8 +378,8 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice::NativeDispose___ platform_free(palI2c->WorkingThreadStack); // clear pointers - palI2c->WorkingThread = NULL; - palI2c->WorkingThreadStack = NULL; + palI2c->WorkingThread = nullptr; + palI2c->WorkingThreadStack = nullptr; } NANOCLR_NOCLEANUP(); @@ -391,7 +391,7 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice:: NANOCLR_HEADER(); uint8_t busIndex; - NF_PAL_I2C *palI2c = NULL; + NF_PAL_I2C *palI2c = nullptr; bool isLongRunningOperation = false; msg_t transactionResult = MSG_OK; @@ -404,12 +404,12 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice:: CLR_RT_HeapBlock *writeSpanByte; CLR_RT_HeapBlock *readSpanByte; CLR_RT_HeapBlock *connectionSettings; - CLR_RT_HeapBlock_Array *writeBuffer = NULL; - CLR_RT_HeapBlock_Array *readBuffer = NULL; + CLR_RT_HeapBlock_Array *writeBuffer = nullptr; + CLR_RT_HeapBlock_Array *readBuffer = nullptr; int readOffset = 0; int writeOffset = 0; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -450,11 +450,11 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice:: // dereference the write and read SpanByte from the arguments writeSpanByte = stack.Arg1().Dereference(); - if (writeSpanByte != NULL) + if (writeSpanByte != nullptr) { // get buffer writeBuffer = writeSpanByte[SpanByte::FIELD___array].DereferenceArray(); - if (writeBuffer != NULL) + if (writeBuffer != nullptr) { // Get the write offset, only the elements defined by the span must be written, not the whole array writeOffset = writeSpanByte[SpanByte::FIELD___start].NumericByRef().s4; @@ -467,18 +467,18 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice:: } } - if (writeBuffer == NULL) + if (writeBuffer == nullptr) { // nothing to write, have to zero this palI2c->WriteSize = 0; } readSpanByte = stack.Arg2().Dereference(); - if (readSpanByte != NULL) + if (readSpanByte != nullptr) { // get buffer readBuffer = readSpanByte[SpanByte::FIELD___array].DereferenceArray(); - if (readBuffer != NULL) + if (readBuffer != nullptr) { // Get the read offset, only the elements defined by the span must be read, not the whole array readOffset = readSpanByte[SpanByte::FIELD___start].NumericByRef().s4; @@ -491,7 +491,7 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice:: } } - if (readBuffer == NULL) + if (readBuffer == nullptr) { // nothing to read, have to zero this palI2c->ReadSize = 0; @@ -524,7 +524,7 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice:: palI2c->Driver->addr = palI2c->Address; #endif - if (writeBuffer != NULL) + if (writeBuffer != nullptr) { // grab the pointer to the array by starting and the offset specified in the span palI2c->WriteBuffer = (uint8_t *)writeBuffer->GetElement(writeOffset); @@ -534,7 +534,7 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice:: cacheBufferFlush(palI2c->WriteBuffer, palI2c->WriteSize); } - if (readBuffer != NULL) + if (readBuffer != nullptr) { // grab the pointer to the array by starting and the offset specified in the span palI2c->ReadBuffer = (uint8_t *)readBuffer->GetElement(readOffset); @@ -556,7 +556,7 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice:: // 1. allocate memory for I2C thread palI2c->WorkingThreadStack = (uint32_t *)platform_malloc(I2C_THREAD_STACK_SIZE); - if (palI2c->WorkingThreadStack == NULL) + if (palI2c->WorkingThreadStack == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_OUT_OF_MEMORY); } @@ -567,7 +567,7 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice:: #if !defined(BUILD_RTM) (CHAR *)"I2C Thread", #else - NULL, + nullptr, #endif I2CWorkingThread_entry, (uint32_t)palI2c, @@ -618,7 +618,7 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice:: palI2c->Address, palI2c->WriteBuffer, palI2c->WriteSize, - NULL, + nullptr, 0, TX_TICKS_PER_MILLISEC(20)); } @@ -672,7 +672,7 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice:: // managed stack CLR_RT_HeapBlock &top = stack.PushValueAndClear(); NANOCLR_CHECK_HRESULT( - g_CLR_RT_ExecutionEngine.NewObjectFromIndex(top, g_CLR_RT_WellKnownTypes.m_I2cTransferResult)); + g_CLR_RT_ExecutionEngine.NewObjectFromIndex(top, g_CLR_RT_WellKnownTypes.I2cTransferResult)); result = top.Dereference(); FAULT_ON_NULL(result); @@ -688,8 +688,8 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice:: platform_free(palI2c->WorkingThreadStack); // clear pointers - palI2c->WorkingThread = NULL; - palI2c->WorkingThreadStack = NULL; + palI2c->WorkingThread = nullptr; + palI2c->WorkingThreadStack = nullptr; } // get the result from the working thread execution @@ -743,12 +743,12 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice:: if (hr != CLR_E_THREAD_WAITING) { // un-pin the buffers - if (writeBuffer != NULL && writeBuffer->IsPinned()) + if (writeBuffer != nullptr && writeBuffer->IsPinned()) { writeBuffer->Unpin(); } - if (readBuffer != NULL && readBuffer->IsPinned()) + if (readBuffer != nullptr && readBuffer->IsPinned()) { readBuffer->Unpin(); } diff --git a/targets/AzureRTOS/ST/_nanoCLR/System.Device.Spi/cpu_spi.cpp b/targets/AzureRTOS/ST/_nanoCLR/System.Device.Spi/cpu_spi.cpp index 28975d2093..d10f32b3c8 100644 --- a/targets/AzureRTOS/ST/_nanoCLR/System.Device.Spi/cpu_spi.cpp +++ b/targets/AzureRTOS/ST/_nanoCLR/System.Device.Spi/cpu_spi.cpp @@ -60,7 +60,7 @@ static void SpiCallback(SPIDriver *spip) NATIVE_INTERRUPT_START - NF_PAL_SPI *palSpi = NULL; + NF_PAL_SPI *palSpi = nullptr; // Find the NF_PAL_SPI * for driver #if STM32_SPI_USE_SPI1 @@ -255,10 +255,10 @@ uint16_t ComputeBaudRate(SPI_DEVICE_CONFIGURATION &config, int32_t &actualFreque } // Return the NF_PAL structure for busIndex -// Return NULL is invalid bus +// Return nullptr is invalid bus NF_PAL_SPI *GetNfPalfromBusIndex(uint8_t busIndex) { - NF_PAL_SPI *palSpi = NULL; + NF_PAL_SPI *palSpi = nullptr; // get the PAL struct for the SPI bus // bus index is 0 based, here it's 1 based @@ -425,12 +425,12 @@ HRESULT CPU_SPI_nWrite_nRead( // Callback sync / async palSpi->Callback = wrc.callback; - if (writeBuffer != NULL) + if (writeBuffer != nullptr) { palSpi->WriteSize = writeSize; } - if (readBuffer != NULL) + if (readBuffer != nullptr) { palSpi->ReadSize = readSize; } @@ -447,10 +447,10 @@ HRESULT CPU_SPI_nWrite_nRead( // Clear callback if sync if (sync) { - palSpi->Configuration.data_cb = NULL; + palSpi->Configuration.data_cb = nullptr; } - if (writeBuffer != NULL) + if (writeBuffer != nullptr) { // set the pointer to the write buffer as BYTE palSpi->WriteBuffer = (uint8_t *)writeBuffer; @@ -470,7 +470,7 @@ HRESULT CPU_SPI_nWrite_nRead( } } - if (readBuffer != NULL) + if (readBuffer != nullptr) { // set DMA read buffer if (palSpi->ReadSize > 0) @@ -683,7 +683,7 @@ bool CPU_SPI_Initialize(uint8_t busIndex, const SPI_DEVICE_CONFIGURATION &spiDev { #if STM32_SPI_USE_SPI1 case 1: - if (SPI1_PAL.Driver == NULL) + if (SPI1_PAL.Driver == nullptr) { ConfigPins_SPI1(spiDeviceConfig); SPI1_PAL.Driver = &SPID1; @@ -693,7 +693,7 @@ bool CPU_SPI_Initialize(uint8_t busIndex, const SPI_DEVICE_CONFIGURATION &spiDev #endif #if STM32_SPI_USE_SPI2 case 2: - if (SPI2_PAL.Driver == NULL) + if (SPI2_PAL.Driver == nullptr) { ConfigPins_SPI2(spiDeviceConfig); SPI2_PAL.Driver = &SPID2; @@ -703,7 +703,7 @@ bool CPU_SPI_Initialize(uint8_t busIndex, const SPI_DEVICE_CONFIGURATION &spiDev #endif #if STM32_SPI_USE_SPI3 case 3: - if (SPI3_PAL.Driver == NULL) + if (SPI3_PAL.Driver == nullptr) { ConfigPins_SPI3(spiDeviceConfig); SPI3_PAL.Driver = &SPID3; @@ -713,7 +713,7 @@ bool CPU_SPI_Initialize(uint8_t busIndex, const SPI_DEVICE_CONFIGURATION &spiDev #endif #if STM32_SPI_USE_SPI4 case 4: - if (SPI4_PAL.Driver == NULL) + if (SPI4_PAL.Driver == nullptr) { ConfigPins_SPI4(spiDeviceConfig); SPI4_PAL.Driver = &SPID4; @@ -723,7 +723,7 @@ bool CPU_SPI_Initialize(uint8_t busIndex, const SPI_DEVICE_CONFIGURATION &spiDev #endif #if STM32_SPI_USE_SPI5 case 5: - if (SPI5_PAL.Driver == NULL) + if (SPI5_PAL.Driver == nullptr) { ConfigPins_SPI5(spiDeviceConfig); SPI5_PAL.Driver = &SPID5; @@ -733,7 +733,7 @@ bool CPU_SPI_Initialize(uint8_t busIndex, const SPI_DEVICE_CONFIGURATION &spiDev #endif #if STM32_SPI_USE_SPI6 case 6: - if (SPI6_PAL.Driver == NULL) + if (SPI6_PAL.Driver == nullptr) { ConfigPins_SPI6(spiDeviceConfig); SPI6_PAL.Driver = &SPID6; @@ -758,7 +758,7 @@ bool CPU_SPI_Uninitialize(uint8_t busIndex) #if STM32_SPI_USE_SPI1 case 1: spiStop(&SPID1); - SPI1_PAL.Driver = NULL; + SPI1_PAL.Driver = nullptr; spiReleaseBus(&SPID1); break; #endif @@ -766,7 +766,7 @@ bool CPU_SPI_Uninitialize(uint8_t busIndex) #if STM32_SPI_USE_SPI2 case 2: spiStop(&SPID2); - SPI2_PAL.Driver = NULL; + SPI2_PAL.Driver = nullptr; spiReleaseBus(&SPID2); break; #endif @@ -774,7 +774,7 @@ bool CPU_SPI_Uninitialize(uint8_t busIndex) #if STM32_SPI_USE_SPI3 case 3: spiStop(&SPID3); - SPI3_PAL.Driver = NULL; + SPI3_PAL.Driver = nullptr; spiReleaseBus(&SPID3); break; #endif @@ -782,7 +782,7 @@ bool CPU_SPI_Uninitialize(uint8_t busIndex) #if STM32_SPI_USE_SPI4 case 4: spiStop(&SPID4); - SPI4_PAL.Driver = NULL; + SPI4_PAL.Driver = nullptr; spiReleaseBus(&SPID4); break; #endif @@ -790,7 +790,7 @@ bool CPU_SPI_Uninitialize(uint8_t busIndex) #if STM32_SPI_USE_SPI5 case 5: spiStop(&SPID5); - SPI5_PAL.Driver = NULL; + SPI5_PAL.Driver = nullptr; spiReleaseBus(&SPID5); break; #endif @@ -798,7 +798,7 @@ bool CPU_SPI_Uninitialize(uint8_t busIndex) #if STM32_SPI_USE_SPI6 case 6: spiStop(&SPID6); - SPI6_PAL.Driver = NULL; + SPI6_PAL.Driver = nullptr; spiReleaseBus(&SPID6); break; #endif diff --git a/targets/AzureRTOS/ST/_nanoCLR/System.Device.Wifi/sys_dev_wifi_native_System_Device_Wifi_WifiAdapter.cpp b/targets/AzureRTOS/ST/_nanoCLR/System.Device.Wifi/sys_dev_wifi_native_System_Device_Wifi_WifiAdapter.cpp index 770ac22532..d93ddadb02 100644 --- a/targets/AzureRTOS/ST/_nanoCLR/System.Device.Wifi/sys_dev_wifi_native_System_Device_Wifi_WifiAdapter.cpp +++ b/targets/AzureRTOS/ST/_nanoCLR/System.Device.Wifi/sys_dev_wifi_native_System_Device_Wifi_WifiAdapter.cpp @@ -273,7 +273,7 @@ HRESULT Library_sys_dev_wifi_native_System_Device_Wifi_WifiAdapter::GetNativeSca // rlen = StoreApRecordsToString(0, ap_records, number); // } - // NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_Array::CreateInstance(top, rlen, g_CLR_RT_WellKnownTypes.m_UInt8)); + // NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_Array::CreateInstance(top, rlen, g_CLR_RT_WellKnownTypes.UInt8)); // array = top.DereferenceArray(); // buf = array->GetFirstElement(); @@ -331,7 +331,7 @@ HRESULT Library_sys_dev_wifi_native_System_Device_Wifi_WifiAdapter::NativeFindWi } // build array with indexes of Wireless interfaces - NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_Array::CreateInstance(top, interfaceCount, g_CLR_RT_WellKnownTypes.m_UInt8)); + NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_Array::CreateInstance(top, interfaceCount, g_CLR_RT_WellKnownTypes.UInt8)); array = top.DereferenceArray(); arrayOfIndexes = array->GetFirstElement(); diff --git a/targets/AzureRTOS/ST/_nanoCLR/targetHAL.cpp b/targets/AzureRTOS/ST/_nanoCLR/targetHAL.cpp index f50cbf05cb..82408a405f 100644 --- a/targets/AzureRTOS/ST/_nanoCLR/targetHAL.cpp +++ b/targets/AzureRTOS/ST/_nanoCLR/targetHAL.cpp @@ -61,7 +61,7 @@ void nanoHAL_Initialize() BlockStorageList_InitializeDevices(); // clear managed heap region - unsigned char *heapStart = NULL; + unsigned char *heapStart = nullptr; unsigned int heapSize = 0; ::HeapLocation(heapStart, heapSize); @@ -168,7 +168,7 @@ void nanoHAL_Uninitialize(bool isPoweringDown) // TODO check for s_rebootHandlers // for(int i = 0; i< ARRAYSIZE(s_rebootHandlers); i++) // { - // if(s_rebootHandlers[i] != NULL) + // if(s_rebootHandlers[i] != nullptr) // { // s_rebootHandlers[i](); // } diff --git a/targets/AzureRTOS/SiliconLabs/_common/targetHAL_ConfigurationManager.cpp b/targets/AzureRTOS/SiliconLabs/_common/targetHAL_ConfigurationManager.cpp index 1d74024dd2..c67253fbef 100644 --- a/targets/AzureRTOS/SiliconLabs/_common/targetHAL_ConfigurationManager.cpp +++ b/targets/AzureRTOS/SiliconLabs/_common/targetHAL_ConfigurationManager.cpp @@ -208,7 +208,7 @@ __nfweak bool ConfigurationManager_GetConfigurationBlock( uint32_t configurationIndex) { int sizeOfBlock = 0; - uint8_t *blockAddress = NULL; + uint8_t *blockAddress = nullptr; // validate if the requested block exists // Count has to be non zero @@ -300,7 +300,7 @@ __nfweak bool ConfigurationManager_StoreConfigurationBlock( if (configuration == DeviceConfigurationOption_Network) { - if (g_TargetConfiguration.NetworkInterfaceConfigs == NULL || + if (g_TargetConfiguration.NetworkInterfaceConfigs == nullptr || (g_TargetConfiguration.NetworkInterfaceConfigs->Count == 0 && configurationIndex == 0)) { // there is no network config block, we are storing the default one @@ -335,7 +335,7 @@ __nfweak bool ConfigurationManager_StoreConfigurationBlock( // #if (TARGET_HAS_WIFI_SUPPORT == 1) - // if (g_TargetConfiguration.Wireless80211Configs == NULL || + // if (g_TargetConfiguration.Wireless80211Configs == nullptr || // (g_TargetConfiguration.Wireless80211Configs->Count == 0 && configurationIndex == 0)) // { // // there is no wireless 80211 config block, so we are storing the default one @@ -400,7 +400,7 @@ __nfweak bool ConfigurationManager_StoreConfigurationBlock( (ByteAddress)g_TargetConfiguration.CertificateStore->Certificates[configurationIndex] + offset; } - if (g_TargetConfiguration.CertificateStore == NULL || + if (g_TargetConfiguration.CertificateStore == nullptr || (g_TargetConfiguration.CertificateStore->Count == 0 || (configurationIndex + 1) > g_TargetConfiguration.CertificateStore->Count)) { @@ -413,7 +413,7 @@ __nfweak bool ConfigurationManager_StoreConfigurationBlock( } // // now check if memory is erase, so the block can be stored - // if (!STM32FlashDriver_IsBlockErased(NULL, storageAddress, blockSize)) + // if (!STM32FlashDriver_IsBlockErased(nullptr, storageAddress, blockSize)) // { // // memory not erased, can't store // return FALSE; @@ -450,7 +450,7 @@ __nfweak bool ConfigurationManager_StoreConfigurationBlock( (ByteAddress)g_TargetConfiguration.DeviceCertificates->Certificates[configurationIndex] + offset; } - if (g_TargetConfiguration.DeviceCertificates == NULL || + if (g_TargetConfiguration.DeviceCertificates == nullptr || (g_TargetConfiguration.DeviceCertificates->Count == 0 || (configurationIndex + 1) > g_TargetConfiguration.DeviceCertificates->Count)) { @@ -463,7 +463,7 @@ __nfweak bool ConfigurationManager_StoreConfigurationBlock( } // // now check if memory is erase, so the block can be stored - // if (!STM32FlashDriver_IsBlockErased(NULL, storageAddress, blockSize)) + // if (!STM32FlashDriver_IsBlockErased(nullptr, storageAddress, blockSize)) // { // // memory not erased, can't store // return FALSE; @@ -494,7 +494,7 @@ __nfweak bool ConfigurationManager_StoreConfigurationBlock( } // // copy the config block content to the config block storage - // success = STM32FlashDriver_Write(NULL, storageAddress, blockSize, (unsigned char *)configurationBlock, true); + // success = STM32FlashDriver_Write(nullptr, storageAddress, blockSize, (unsigned char *)configurationBlock, true); // enumeration is required after we are DONE with SUCCESSFULLY storing all the config chunks requiresEnumeration = (success && done); @@ -536,7 +536,7 @@ __nfweak UpdateConfigurationResult ConfigurationManager_UpdateConfigurationBlock // allocate memory from CRT heap uint8_t *configSectorCopy = (uint8_t *)platform_malloc(sizeOfConfigSector); - if (configSectorCopy != NULL) + if (configSectorCopy != nullptr) { // copy config sector from flash to RAM memcpy(configSectorCopy, &__nanoConfig_start__, sizeOfConfigSector); @@ -674,7 +674,7 @@ __nfweak UpdateConfigurationResult ConfigurationManager_UpdateConfigurationBlock } // // erase config sector - // if (STM32FlashDriver_EraseBlock(NULL, (uint32_t)&__nanoConfig_start__) == TRUE) + // if (STM32FlashDriver_EraseBlock(nullptr, (uint32_t)&__nanoConfig_start__) == TRUE) // { // // flash block is erased @@ -689,7 +689,7 @@ __nfweak UpdateConfigurationResult ConfigurationManager_UpdateConfigurationBlock // // copy the config block copy back to the config block storage // success = STM32FlashDriver_Write( - // NULL, + // nullptr, // (uint32_t)&__nanoConfig_start__, // sizeOfConfigSector, // (unsigned char *)configSectorCopy, diff --git a/targets/AzureRTOS/SiliconLabs/_nanoCLR/System.Device.Adc/sys_dev_adc_native_System_Device_Adc_AdcChannel.cpp b/targets/AzureRTOS/SiliconLabs/_nanoCLR/System.Device.Adc/sys_dev_adc_native_System_Device_Adc_AdcChannel.cpp index 803a491ac7..7a909aeb7b 100644 --- a/targets/AzureRTOS/SiliconLabs/_nanoCLR/System.Device.Adc/sys_dev_adc_native_System_Device_Adc_AdcChannel.cpp +++ b/targets/AzureRTOS/SiliconLabs/_nanoCLR/System.Device.Adc/sys_dev_adc_native_System_Device_Adc_AdcChannel.cpp @@ -17,9 +17,9 @@ HRESULT Library_sys_dev_adc_native_System_Device_Adc_AdcChannel::NativeReadValue // ADC related variables adcInitSingle = ADC_INITSINGLE_DEFAULT; uint32_t sample; - ADC_TypeDef *adcDriver = NULL; + ADC_TypeDef *adcDriver = nullptr; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); diff --git a/targets/AzureRTOS/SiliconLabs/_nanoCLR/System.Device.Adc/sys_dev_adc_native_System_Device_Adc_AdcController.cpp b/targets/AzureRTOS/SiliconLabs/_nanoCLR/System.Device.Adc/sys_dev_adc_native_System_Device_Adc_AdcController.cpp index a451e4dd8b..50efa7096b 100644 --- a/targets/AzureRTOS/SiliconLabs/_nanoCLR/System.Device.Adc/sys_dev_adc_native_System_Device_Adc_AdcController.cpp +++ b/targets/AzureRTOS/SiliconLabs/_nanoCLR/System.Device.Adc/sys_dev_adc_native_System_Device_Adc_AdcController.cpp @@ -17,11 +17,11 @@ HRESULT Library_sys_dev_adc_native_System_Device_Adc_AdcController::NativeOpenCh NF_PAL_ADC_PORT_PIN_CHANNEL adcDefinition; ADC_Init_TypeDef adcInit; CMU_Clock_TypeDef adcClock; - ADC_TypeDef *adcDriver = NULL; + ADC_TypeDef *adcDriver = nullptr; adcInit = ADC_INIT_DEFAULT; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); diff --git a/targets/AzureRTOS/SiliconLabs/_nanoCLR/System.Device.Gpio/cpu_gpio.cpp b/targets/AzureRTOS/SiliconLabs/_nanoCLR/System.Device.Gpio/cpu_gpio.cpp index 06aecd1ffc..a5007f7799 100644 --- a/targets/AzureRTOS/SiliconLabs/_nanoCLR/System.Device.Gpio/cpu_gpio.cpp +++ b/targets/AzureRTOS/SiliconLabs/_nanoCLR/System.Device.Gpio/cpu_gpio.cpp @@ -57,7 +57,7 @@ bool IsValidGpioPin(GPIO_PIN pinNumber) } // Register (or unregister) ISR for a pin -// send NULL in pinState to unregister callback +// send nullptr in pinState to unregister callback unsigned int CallbackRegisterExt(uint8_t pin, gpio_input_state *pinState) { uint16_t intNo = INTERRUPT_UNAVAILABLE; @@ -82,7 +82,7 @@ unsigned int CallbackRegisterExt(uint8_t pin, gpio_input_state *pinState) } } #else - if (gpioCallbacks[pin] == NULL) + if (gpioCallbacks[pin] == nullptr) { intNo = (unsigned int)pin; } @@ -99,12 +99,12 @@ unsigned int CallbackRegisterExt(uint8_t pin, gpio_input_state *pinState) } // Get pointer to gpio_input_state for GPIO pin -// return NULL if not found +// return nullptr if not found gpio_input_state *GetGpioWithInterrupt(uint16_t gpioPin) { gpio_input_state *ptr = gpioInputList.FirstNode(); - while (ptr->Next() != NULL) + while (ptr->Next() != nullptr) { if (GPIO_PIN(ptr->pinNumber) == gpioPin) { @@ -114,7 +114,7 @@ gpio_input_state *GetGpioWithInterrupt(uint16_t gpioPin) ptr = ptr->Next(); } - return NULL; + return nullptr; } static void DebounceTimerCallback(ULONG pinState) @@ -157,7 +157,7 @@ static void GpioEventCallback(uint32_t intFlags) pGpio = gpioCallbacks[irqIdx]; - if (pGpio != NULL) + if (pGpio != nullptr) { if (pGpio->waitingDebounce) { @@ -196,12 +196,12 @@ static void GpioEventCallback(uint32_t intFlags) } // Get pointer to gpio_input_state for GPIO pin -// return NULL if not found +// return nullptr if not found gpio_input_state *GetInputState(GPIO_PIN pinNumber) { gpio_input_state *ptr = gpioInputList.FirstNode(); - while (ptr->Next() != NULL) + while (ptr->Next() != nullptr) { if (ptr->pinNumber == pinNumber) { @@ -211,7 +211,7 @@ gpio_input_state *GetInputState(GPIO_PIN pinNumber) ptr = ptr->Next(); } - return NULL; + return nullptr; } // Allocate a new gpio_input_state and add to end of list @@ -220,12 +220,12 @@ gpio_input_state *AllocateGpioInputState(GPIO_PIN pinNumber) { gpio_input_state *ptr = GetInputState(pinNumber); - if (ptr == NULL) + if (ptr == nullptr) { ptr = (gpio_input_state *)platform_malloc(sizeof(gpio_input_state)); // sanity check - if (ptr != NULL) + if (ptr != nullptr) { memset(ptr, 0, sizeof(gpio_input_state)); ptr->pinNumber = pinNumber; @@ -256,7 +256,7 @@ void UnlinkInputState(gpio_input_state *pState) // disable the EXT interrupt channel // it's OK to do always this, no matter if it's enabled or not - CallbackRegisterExt(portPin, NULL); + CallbackRegisterExt(portPin, nullptr); pState->Unlink(); @@ -432,7 +432,7 @@ bool CPU_GPIO_EnableInputPin( // Link ISR ptr supplied and not already set up // CPU_GPIO_EnableInputPin could be called a 2nd time with changed parameters - if (pinISR != NULL && (pState->isrPtr == NULL)) + if (pinISR != nullptr && (pState->isrPtr == nullptr)) { // register nanoFramework callback and store associated interrupt ID interruptId = CallbackRegisterExt(portPin, pState); @@ -468,18 +468,18 @@ bool CPU_GPIO_EnableInputPin( break; } } - else if (pinISR == NULL && (pState->isrPtr != NULL)) + else if (pinISR == nullptr && (pState->isrPtr != nullptr)) { // there is no managed handler setup anymore // disable the EXT interrupt channel // it's OK to do always this, no matter if it's enabled or not - CallbackRegisterExt(portPin, NULL); + CallbackRegisterExt(portPin, nullptr); // clear parameters & configs - pState->isrPtr = NULL; + pState->isrPtr = nullptr; pState->mode = GPIO_INT_NONE; - pState->param = NULL; + pState->param = nullptr; pState->debounceMs = 0; } diff --git a/targets/AzureRTOS/SiliconLabs/_nanoCLR/System.Device.I2c/sys_dev_i2c_native_System_Device_I2c_I2cDevice.cpp b/targets/AzureRTOS/SiliconLabs/_nanoCLR/System.Device.I2c/sys_dev_i2c_native_System_Device_I2c_I2cDevice.cpp index b83732fc89..43547f50b9 100644 --- a/targets/AzureRTOS/SiliconLabs/_nanoCLR/System.Device.I2c/sys_dev_i2c_native_System_Device_I2c_I2cDevice.cpp +++ b/targets/AzureRTOS/SiliconLabs/_nanoCLR/System.Device.I2c/sys_dev_i2c_native_System_Device_I2c_I2cDevice.cpp @@ -130,11 +130,11 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice::NativeInit___VOI { NANOCLR_HEADER(); - NF_PAL_I2C *palI2c = NULL; + NF_PAL_I2C *palI2c = nullptr; CLR_RT_HeapBlock *connectionSettings; uint8_t busIndex; I2CSPM_Init_TypeDef i2cInit = { - NULL, + nullptr, 0, 0, 0, @@ -150,7 +150,7 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice::NativeInit___VOI i2cClockHLRStandard, }; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -174,11 +174,11 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice::NativeInit___VOI #if defined(I2C0) && (GECKO_USE_I2C0 == TRUE) case 1: - if (I2C0_PAL.Configuration == NULL) + if (I2C0_PAL.Configuration == nullptr) { I2C0_PAL.Configuration = (I2CSPM_Init_TypeDef *)platform_malloc(sizeof(I2CSPM_Init_TypeDef)); - if (I2C0_PAL.Configuration == NULL) + if (I2C0_PAL.Configuration == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_OUT_OF_MEMORY); } @@ -199,11 +199,11 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice::NativeInit___VOI #if defined(I2C1) && (GECKO_USE_I2C1 == TRUE) case 2: - if (I2C1_PAL.Configuration == NULL) + if (I2C1_PAL.Configuration == nullptr) { I2C1_PAL.Configuration = (I2CSPM_Init_TypeDef *)platform_malloc(sizeof(I2CSPM_Init_TypeDef)); - if (I2C1_PAL.Configuration == NULL) + if (I2C1_PAL.Configuration == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_OUT_OF_MEMORY); } @@ -224,11 +224,11 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice::NativeInit___VOI #if defined(I2C2) && (GECKO_USE_I2C2 == TRUE) case 3: - if (I2C2_PAL.Configuration == NULL) + if (I2C2_PAL.Configuration == nullptr) { I2C2_PAL.Configuration = (I2CSPM_Init_TypeDef *)platform_malloc(sizeof(I2CSPM_Init_TypeDef)); - if (I2C2_PAL.Configuration == NULL) + if (I2C2_PAL.Configuration == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_OUT_OF_MEMORY); } @@ -273,8 +273,8 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice::NativeInit___VOI } // clear pointer to working thread - palI2c->WorkingThread = NULL; - palI2c->WorkingThreadStack = NULL; + palI2c->WorkingThread = nullptr; + palI2c->WorkingThreadStack = nullptr; NANOCLR_NOCLEANUP(); } @@ -284,11 +284,11 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice::NativeDispose___ NANOCLR_HEADER(); uint8_t busIndex; - NF_PAL_I2C *palI2c = NULL; + NF_PAL_I2C *palI2c = nullptr; CLR_RT_HeapBlock *connectionSettings; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -321,7 +321,7 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice::NativeDispose___ platform_free(I2C0_PAL.Configuration); // clears configuration - I2C0_PAL.Configuration = NULL; + I2C0_PAL.Configuration = nullptr; } break; @@ -342,7 +342,7 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice::NativeDispose___ platform_free(I2C1_PAL.Configuration); // clears configuration - I2C1_PAL.Configuration = NULL; + I2C1_PAL.Configuration = nullptr; } break; @@ -363,7 +363,7 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice::NativeDispose___ platform_free(I2C2_PAL.Configuration); // clears configuration - I2C2_PAL.Configuration = NULL; + I2C2_PAL.Configuration = nullptr; } break; @@ -376,7 +376,7 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice::NativeDispose___ } // stop working thread, if it's running - if (palI2c->WorkingThread != NULL) + if (palI2c->WorkingThread != nullptr) { // delete thread tx_thread_delete(palI2c->WorkingThread); @@ -385,8 +385,8 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice::NativeDispose___ platform_free(palI2c->WorkingThreadStack); // clear pointers - palI2c->WorkingThread = NULL; - palI2c->WorkingThreadStack = NULL; + palI2c->WorkingThread = nullptr; + palI2c->WorkingThreadStack = nullptr; } NANOCLR_NOCLEANUP(); @@ -398,7 +398,7 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice:: NANOCLR_HEADER(); uint8_t busIndex; - NF_PAL_I2C *palI2c = NULL; + NF_PAL_I2C *palI2c = nullptr; bool isLongRunningOperation = false; CLR_RT_HeapBlock hbTimeout; @@ -410,14 +410,14 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice:: CLR_RT_HeapBlock *writeSpanByte; CLR_RT_HeapBlock *readSpanByte; CLR_RT_HeapBlock *connectionSettings; - CLR_RT_HeapBlock_Array *writeBuffer = NULL; - CLR_RT_HeapBlock_Array *readBuffer = NULL; + CLR_RT_HeapBlock_Array *writeBuffer = nullptr; + CLR_RT_HeapBlock_Array *readBuffer = nullptr; int readOffset = 0; int writeOffset = 0; I2C_TransferSeq_TypeDef i2cTransfer; I2C_TransferReturn_TypeDef transactionResult = i2cTransferInProgress; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -461,12 +461,12 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice:: // dereference the write and read SpanByte from the arguments writeSpanByte = stack.Arg1().Dereference(); - if (writeSpanByte != NULL) + if (writeSpanByte != nullptr) { // get buffer writeBuffer = writeSpanByte[SpanByte::FIELD___array].DereferenceArray(); - if (writeBuffer != NULL) + if (writeBuffer != nullptr) { // Get the write offset, only the elements defined by the span must be written, not the whole array writeOffset = writeSpanByte[SpanByte::FIELD___start].NumericByRef().s4; @@ -479,7 +479,7 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice:: } } - if (writeBuffer == NULL) + if (writeBuffer == nullptr) { // nothing to write, have to zero this palI2c->WriteSize = 0; @@ -487,12 +487,12 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice:: readSpanByte = stack.Arg2().Dereference(); - if (readSpanByte != NULL) + if (readSpanByte != nullptr) { // get buffer readBuffer = readSpanByte[SpanByte::FIELD___array].DereferenceArray(); - if (readBuffer != NULL) + if (readBuffer != nullptr) { // Get the read offset, only the elements defined by the span must be read, not the whole array readOffset = readSpanByte[SpanByte::FIELD___start].NumericByRef().s4; @@ -505,7 +505,7 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice:: } } - if (readBuffer == NULL) + if (readBuffer == nullptr) { // nothing to read, have to zero this palI2c->ReadSize = 0; @@ -535,13 +535,13 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice:: i2cTransfer.addr = (uint16_t)connectionSettings[I2cConnectionSettings::FIELD___deviceAddress].NumericByRef().s4 << 1; - if (writeBuffer != NULL) + if (writeBuffer != nullptr) { // grab the pointer to the array by starting and the offset specified in the span palI2c->WriteBuffer = (uint8_t *)writeBuffer->GetElement(writeOffset); } - if (readBuffer != NULL) + if (readBuffer != nullptr) { // grab the pointer to the array by starting and the offset specified in the span palI2c->ReadBuffer = (uint8_t *)readBuffer->GetElement(readOffset); @@ -559,7 +559,7 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice:: // 1. allocate memory for I2C thread palI2c->WorkingThreadStack = (uint32_t *)platform_malloc(I2C_THREAD_STACK_SIZE); - if (palI2c->WorkingThreadStack == NULL) + if (palI2c->WorkingThreadStack == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_OUT_OF_MEMORY); } @@ -570,7 +570,7 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice:: #if !defined(BUILD_RTM) (CHAR *)"I2C Thread", #else - NULL, + nullptr, #endif I2CWorkingThread_entry, (uint32_t)palI2c, @@ -673,7 +673,7 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice:: // managed stack CLR_RT_HeapBlock &top = stack.PushValueAndClear(); NANOCLR_CHECK_HRESULT( - g_CLR_RT_ExecutionEngine.NewObjectFromIndex(top, g_CLR_RT_WellKnownTypes.m_I2cTransferResult)); + g_CLR_RT_ExecutionEngine.NewObjectFromIndex(top, g_CLR_RT_WellKnownTypes.I2cTransferResult)); result = top.Dereference(); FAULT_ON_NULL(result); @@ -689,8 +689,8 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice:: platform_free(palI2c->WorkingThreadStack); // clear pointers - palI2c->WorkingThread = NULL; - palI2c->WorkingThreadStack = NULL; + palI2c->WorkingThread = nullptr; + palI2c->WorkingThreadStack = nullptr; } // get the result from the working thread execution @@ -737,12 +737,12 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice:: if (hr != CLR_E_THREAD_WAITING) { // un-pin the buffers - if (writeBuffer != NULL && writeBuffer->IsPinned()) + if (writeBuffer != nullptr && writeBuffer->IsPinned()) { writeBuffer->Unpin(); } - if (readBuffer != NULL && readBuffer->IsPinned()) + if (readBuffer != nullptr && readBuffer->IsPinned()) { readBuffer->Unpin(); } diff --git a/targets/AzureRTOS/SiliconLabs/_nanoCLR/System.Device.Pwm/sys_dev_pwm_native_System_Device_Pwm_PwmChannel.cpp b/targets/AzureRTOS/SiliconLabs/_nanoCLR/System.Device.Pwm/sys_dev_pwm_native_System_Device_Pwm_PwmChannel.cpp index c49e1820d4..a11e7bb182 100644 --- a/targets/AzureRTOS/SiliconLabs/_nanoCLR/System.Device.Pwm/sys_dev_pwm_native_System_Device_Pwm_PwmChannel.cpp +++ b/targets/AzureRTOS/SiliconLabs/_nanoCLR/System.Device.Pwm/sys_dev_pwm_native_System_Device_Pwm_PwmChannel.cpp @@ -85,7 +85,7 @@ TIMER_TypeDef *GetPwmTimer(int timerId) return WTIMER2; default: - return NULL; + return nullptr; } } @@ -179,7 +179,7 @@ HRESULT Library_sys_dev_pwm_native_System_Device_Pwm_PwmChannel::NativeInit___VO NANOCLR_HEADER(); - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -269,7 +269,7 @@ HRESULT Library_sys_dev_pwm_native_System_Device_Pwm_PwmChannel::NativeSetDesire NANOCLR_HEADER(); - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -303,7 +303,7 @@ HRESULT Library_sys_dev_pwm_native_System_Device_Pwm_PwmChannel::NativeSetActive NANOCLR_HEADER(); - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -343,7 +343,7 @@ HRESULT Library_sys_dev_pwm_native_System_Device_Pwm_PwmChannel::NativeStart___V NANOCLR_HEADER(); - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -368,7 +368,7 @@ HRESULT Library_sys_dev_pwm_native_System_Device_Pwm_PwmChannel::NativeStop___VO NANOCLR_HEADER(); - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -392,7 +392,7 @@ HRESULT Library_sys_dev_pwm_native_System_Device_Pwm_PwmChannel::DisposeNative__ NANOCLR_HEADER(); - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); diff --git a/targets/AzureRTOS/SiliconLabs/_nanoCLR/System.Device.Spi/cpu_spi.cpp b/targets/AzureRTOS/SiliconLabs/_nanoCLR/System.Device.Spi/cpu_spi.cpp index f3c12b9314..0c16b6f612 100644 --- a/targets/AzureRTOS/SiliconLabs/_nanoCLR/System.Device.Spi/cpu_spi.cpp +++ b/targets/AzureRTOS/SiliconLabs/_nanoCLR/System.Device.Spi/cpu_spi.cpp @@ -52,7 +52,7 @@ void SpiTransferCompleteCallback(NF_SpiDriver_Handle_t handle, Ecode_t transferS NATIVE_INTERRUPT_START - NF_PAL_SPI *palSpi = NULL; + NF_PAL_SPI *palSpi = nullptr; // Find the NF_PAL_SPI* for handle #if GECKO_USE_SPI0 == TRUE @@ -136,10 +136,10 @@ void SpiTransferCompleteCallback(NF_SpiDriver_Handle_t handle, Ecode_t transferS }; // Return the NF_PAL structure for busIndex -// Return NULL is invalid bus +// Return nullptr is invalid bus NF_PAL_SPI *GetNfPalfromBusIndex(uint8_t busIndex) { - NF_PAL_SPI *palSpi = NULL; + NF_PAL_SPI *palSpi = nullptr; // get the PAL struct for the SPI bus switch (busIndex) @@ -273,12 +273,12 @@ HRESULT CPU_SPI_nWrite_nRead( // Callback sync / async palSpi->Callback = wrc.callback; - if (writeBuffer != NULL) + if (writeBuffer != nullptr) { palSpi->WriteSize = writeSize; } - if (readBuffer != NULL) + if (readBuffer != nullptr) { palSpi->ReadSize = readSize; } @@ -292,13 +292,13 @@ HRESULT CPU_SPI_nWrite_nRead( // set bus config flag busConfigIsHalfDuplex = (palSpi->BusConfiguration == SpiBusConfiguration_HalfDuplex); - if (writeBuffer != NULL) + if (writeBuffer != nullptr) { // set the pointer to the write buffer as BYTE palSpi->WriteBuffer = (uint8_t *)writeBuffer; } - if (readBuffer != NULL) + if (readBuffer != nullptr) { // set DMA read buffer if (palSpi->ReadSize > 0) @@ -486,8 +486,8 @@ bool CPU_SPI_Initialize_Extended(uint8_t busIndex, const SPI_DEVICE_CONFIGURATIO GPIO_Port_TypeDef port; uint32_t portPin; - NF_PAL_SPI *palSpi = NULL; - void (*initSpiConfig)(NF_SpiDriver_Init_t &, bool) = NULL; + NF_PAL_SPI *palSpi = nullptr; + void (*initSpiConfig)(NF_SpiDriver_Init_t &, bool) = nullptr; // init the PAL struct for this SPI bus and assign the respective driver // all this occurs if not already done @@ -542,13 +542,13 @@ bool CPU_SPI_Initialize_Extended(uint8_t busIndex, const SPI_DEVICE_CONFIGURATIO return false; } - if (palSpi->Handle == NULL) + if (palSpi->Handle == nullptr) { // allocate memory for the USART_InitSync_TypeDef palSpi->Handle = (NF_SpiDriver_Handle_t)platform_malloc(sizeof(NF_SpiDriver_HandleData_t)); // sanity check allocation - if (palSpi->Handle == NULL) + if (palSpi->Handle == nullptr) { return false; } @@ -559,7 +559,7 @@ bool CPU_SPI_Initialize_Extended(uint8_t busIndex, const SPI_DEVICE_CONFIGURATIO palSpi->InitSpiData = (NF_SpiDriver_Init_t *)platform_malloc(sizeof(NF_SpiDriver_Init_t)); // sanity check allocation - if (palSpi->InitSpiData == NULL) + if (palSpi->InitSpiData == nullptr) { platform_free(palSpi->Handle); @@ -615,7 +615,7 @@ bool CPU_SPI_Initialize(uint8_t busIndex, const SPI_DEVICE_CONFIGURATION &busCon bool CPU_SPI_Uninitialize(uint8_t busIndex) { - NF_PAL_SPI *palSpi = NULL; + NF_PAL_SPI *palSpi = nullptr; GPIO_Port_TypeDef port; uint32_t portPin; @@ -681,7 +681,7 @@ bool CPU_SPI_Uninitialize(uint8_t busIndex) platform_free(palSpi->Handle->initData); platform_free(palSpi->Handle); - palSpi->Handle = NULL; + palSpi->Handle = nullptr; return true; } diff --git a/targets/AzureRTOS/SiliconLabs/_nanoCLR/System.Device.Spi/nf_gecko_spi_driver.cpp b/targets/AzureRTOS/SiliconLabs/_nanoCLR/System.Device.Spi/nf_gecko_spi_driver.cpp index ac2baf115e..1111f83ca4 100644 --- a/targets/AzureRTOS/SiliconLabs/_nanoCLR/System.Device.Spi/nf_gecko_spi_driver.cpp +++ b/targets/AzureRTOS/SiliconLabs/_nanoCLR/System.Device.Spi/nf_gecko_spi_driver.cpp @@ -73,7 +73,7 @@ static sl_power_manager_em_transition_event_info_t on_power_manager_event_info = }; // List of EUSART handles -sl_slist_node_t *eusart_handle_list = NULL; +sl_slist_node_t *eusart_handle_list = nullptr; #endif static bool spidrvIsInitialized = false; @@ -209,7 +209,7 @@ Ecode_t NF_SpiDriver_Init(NF_SpiDriver_Handle_t handle, NF_SpiDriver_Init_t *ini result = NF_SpiDriver_InitEusart(handle, initData); #if defined(SL_CATALOG_POWER_MANAGER_PRESENT) // Subscribe to notification to re-enable eusart after deepsleep. - if (eusart_handle_list == NULL) { + if (eusart_handle_list == nullptr) { sl_power_manager_subscribe_em_transition_event(&on_power_manager_event_handle, &on_power_manager_event_info); } sl_slist_push(&eusart_handle_list, &handle->node); @@ -250,11 +250,11 @@ static Ecode_t NF_SpiDriver_InitUsart(NF_SpiDriver_Handle_t handle, NF_SpiDriver int8_t spiPortNum = -1; #endif - if (handle == NULL) { + if (handle == nullptr) { return ECODE_EMDRV_SPIDRV_ILLEGAL_HANDLE; } - if (initData == NULL) { + if (initData == nullptr) { return ECODE_EMDRV_SPIDRV_PARAM_ERROR; } @@ -495,11 +495,11 @@ static Ecode_t NF_SpiDriver_InitUsart(NF_SpiDriver_Handle_t handle, NF_SpiDriver // Initialize DMA. DMADRV_Init(); - if (DMADRV_AllocateChannel(&handle->txDMACh, NULL) != ECODE_EMDRV_DMADRV_OK) { + if (DMADRV_AllocateChannel(&handle->txDMACh, nullptr) != ECODE_EMDRV_DMADRV_OK) { return ECODE_EMDRV_SPIDRV_DMA_ALLOC_ERROR; } - if (DMADRV_AllocateChannel(&handle->rxDMACh, NULL) != ECODE_EMDRV_DMADRV_OK) { + if (DMADRV_AllocateChannel(&handle->rxDMACh, nullptr) != ECODE_EMDRV_DMADRV_OK) { return ECODE_EMDRV_SPIDRV_DMA_ALLOC_ERROR; } @@ -532,11 +532,11 @@ static Ecode_t NF_SpiDriver_InitEusart(NF_SpiDriver_Handle_t handle, NF_SpiDrive eusartSpiInit.advancedSettings = &eusartAdvancedSpiInit; - if (handle == NULL) { + if (handle == nullptr) { return ECODE_EMDRV_SPIDRV_ILLEGAL_HANDLE; } - if (initData == NULL) { + if (initData == nullptr) { return ECODE_EMDRV_SPIDRV_PARAM_ERROR; } @@ -689,11 +689,11 @@ static Ecode_t NF_SpiDriver_InitEusart(NF_SpiDriver_Handle_t handle, NF_SpiDrive // Initialize DMA. DMADRV_Init(); - if (DMADRV_AllocateChannel(&handle->txDMACh, NULL) != ECODE_EMDRV_DMADRV_OK) { + if (DMADRV_AllocateChannel(&handle->txDMACh, nullptr) != ECODE_EMDRV_DMADRV_OK) { return ECODE_EMDRV_SPIDRV_DMA_ALLOC_ERROR; } - if (DMADRV_AllocateChannel(&handle->rxDMACh, NULL) != ECODE_EMDRV_DMADRV_OK) { + if (DMADRV_AllocateChannel(&handle->rxDMACh, nullptr) != ECODE_EMDRV_DMADRV_OK) { return ECODE_EMDRV_SPIDRV_DMA_ALLOC_ERROR; } @@ -755,7 +755,7 @@ Ecode_t NF_SpiDriver_DeInit(NF_SpiDriver_Handle_t handle) } #endif - if (handle == NULL) { + if (handle == nullptr) { return ECODE_EMDRV_SPIDRV_ILLEGAL_HANDLE; } @@ -828,7 +828,7 @@ Ecode_t NF_SpiDriver_DeInit(NF_SpiDriver_Handle_t handle) #if defined(SL_CATALOG_POWER_MANAGER_PRESENT) && defined(EUSART_PRESENT) // Unsubscribe to notification to re-enable eusart after deepsleep. sl_slist_remove(&eusart_handle_list, &handle->node); - if (eusart_handle_list == NULL) { + if (eusart_handle_list == nullptr) { sl_power_manager_unsubscribe_em_transition_event(&on_power_manager_event_handle); } #endif @@ -850,7 +850,7 @@ Ecode_t NF_SpiDriver_AbortTransfer(NF_SpiDriver_Handle_t handle) { CORE_DECLARE_IRQ_STATE; - if (handle == NULL) { + if (handle == nullptr) { return ECODE_EMDRV_SPIDRV_ILLEGAL_HANDLE; } @@ -880,7 +880,7 @@ Ecode_t NF_SpiDriver_AbortTransfer(NF_SpiDriver_Handle_t handle) em1RequestRemove(handle); - if (handle->userCallback != NULL) { + if (handle->userCallback != nullptr) { handle->userCallback(handle, ECODE_EMDRV_SPIDRV_ABORTED, handle->transferCount - handle->remaining); @@ -904,11 +904,11 @@ Ecode_t NF_SpiDriver_AbortTransfer(NF_SpiDriver_Handle_t handle) ******************************************************************************/ Ecode_t NF_SpiDriver_GetBitrate(NF_SpiDriver_Handle_t handle, uint32_t *bitRate) { - if (handle == NULL) { + if (handle == nullptr) { return ECODE_EMDRV_SPIDRV_ILLEGAL_HANDLE; } - if (bitRate == NULL) { + if (bitRate == nullptr) { return ECODE_EMDRV_SPIDRV_PARAM_ERROR; } @@ -942,11 +942,11 @@ Ecode_t NF_SpiDriver_GetBitrate(NF_SpiDriver_Handle_t handle, uint32_t *bitRate) ******************************************************************************/ Ecode_t NF_SpiDriver_GetFramelength(NF_SpiDriver_Handle_t handle, uint32_t *frameLength) { - if (handle == NULL) { + if (handle == nullptr) { return ECODE_EMDRV_SPIDRV_ILLEGAL_HANDLE; } - if (frameLength == NULL) { + if (frameLength == nullptr) { return ECODE_EMDRV_SPIDRV_PARAM_ERROR; } @@ -979,11 +979,11 @@ Ecode_t NF_SpiDriver_GetTransferStatus(NF_SpiDriver_Handle_t handle, { int remaining; - if (handle == NULL) { + if (handle == nullptr) { return ECODE_EMDRV_SPIDRV_ILLEGAL_HANDLE; } - if ((itemsTransferred == NULL) || (itemsRemaining == NULL)) { + if ((itemsTransferred == nullptr) || (itemsRemaining == nullptr)) { return ECODE_EMDRV_SPIDRV_PARAM_ERROR; } @@ -1118,7 +1118,7 @@ Ecode_t NF_SpiDriver_MTransfer(NF_SpiDriver_Handle_t handle, return retVal; } - if (rxBuffer == NULL) { + if (rxBuffer == nullptr) { return ECODE_EMDRV_SPIDRV_PARAM_ERROR; } @@ -1164,7 +1164,7 @@ Ecode_t NF_SpiDriver_MTransferB(NF_SpiDriver_Handle_t handle, return retVal; } - if (rxBuffer == NULL) { + if (rxBuffer == nullptr) { return ECODE_EMDRV_SPIDRV_PARAM_ERROR; } @@ -1202,7 +1202,7 @@ Ecode_t NF_SpiDriver_MTransferSingleItemB(NF_SpiDriver_Handle_t handle, CORE_DECLARE_IRQ_STATE; uint32_t rxBuffer; - if (handle == NULL) { + if (handle == nullptr) { return ECODE_EMDRV_SPIDRV_ILLEGAL_HANDLE; } @@ -1218,7 +1218,7 @@ Ecode_t NF_SpiDriver_MTransferSingleItemB(NF_SpiDriver_Handle_t handle, handle->state = spidrvStateTransferring; CORE_EXIT_ATOMIC(); - if ((pRx = rxValue) == NULL) { + if ((pRx = rxValue) == nullptr) { pRx = &rxBuffer; } @@ -1326,7 +1326,7 @@ Ecode_t NF_SpiDriver_SetBitrate(NF_SpiDriver_Handle_t handle, uint32_t bitRate) { CORE_DECLARE_IRQ_STATE; - if (handle == NULL) { + if (handle == nullptr) { return ECODE_EMDRV_SPIDRV_ILLEGAL_HANDLE; } @@ -1371,7 +1371,7 @@ Ecode_t NF_SpiDriver_SetFramelength(NF_SpiDriver_Handle_t handle, uint32_t frame { CORE_DECLARE_IRQ_STATE; - if (handle == NULL) { + if (handle == nullptr) { return ECODE_EMDRV_SPIDRV_ILLEGAL_HANDLE; } @@ -1579,7 +1579,7 @@ Ecode_t NF_SpiDriver_STransfer(NF_SpiDriver_Handle_t handle, return retVal; } - if (rxBuffer == NULL) { + if (rxBuffer == nullptr) { return ECODE_EMDRV_SPIDRV_PARAM_ERROR; } @@ -1639,7 +1639,7 @@ Ecode_t NF_SpiDriver_STransferB(NF_SpiDriver_Handle_t handle, return retVal; } - if (rxBuffer == NULL) { + if (rxBuffer == nullptr) { return ECODE_EMDRV_SPIDRV_PARAM_ERROR; } @@ -2085,7 +2085,7 @@ static bool RxDMAComplete(unsigned int channel, } #endif - if (handle->userCallback != NULL) { + if (handle->userCallback != nullptr) { handle->userCallback(handle, ECODE_EMDRV_SPIDRV_OK, handle->transferCount); } @@ -2126,7 +2126,7 @@ static void SlaveTimeout(sl_sleeptimer_timer_handle_t *sleepdriver_handle, void handle->transferStatus = ECODE_EMDRV_SPIDRV_TIMEOUT; handle->state = spidrvStateIdle; - if (handle->userCallback != NULL) { + if (handle->userCallback != nullptr) { handle->userCallback(handle, ECODE_EMDRV_SPIDRV_TIMEOUT, handle->transferCount - handle->remaining); @@ -2221,8 +2221,8 @@ static void StartReceiveDMA(NF_SpiDriver_Handle_t handle, false, count, size, - NULL, - NULL); + nullptr, + nullptr); } /***************************************************************************//** @@ -2298,8 +2298,8 @@ static void StartTransferDMA(NF_SpiDriver_Handle_t handle, true, count, size, - NULL, - NULL); + nullptr, + nullptr); } /***************************************************************************//** @@ -2375,8 +2375,8 @@ static void StartTransmitDMA(NF_SpiDriver_Handle_t handle, true, count, size, - NULL, - NULL); + nullptr, + nullptr); } /***************************************************************************//** @@ -2388,11 +2388,11 @@ static Ecode_t TransferApiBlockingPrologue(NF_SpiDriver_Handle_t handle, { CORE_DECLARE_IRQ_STATE; - if (handle == NULL) { + if (handle == nullptr) { return ECODE_EMDRV_SPIDRV_ILLEGAL_HANDLE; } - if ((buffer == NULL) || (count == 0) || (count > DMADRV_MAX_XFER_COUNT)) { + if ((buffer == nullptr) || (count == 0) || (count > DMADRV_MAX_XFER_COUNT)) { return ECODE_EMDRV_SPIDRV_PARAM_ERROR; } @@ -2416,11 +2416,11 @@ static Ecode_t TransferApiPrologue(NF_SpiDriver_Handle_t handle, { CORE_DECLARE_IRQ_STATE; - if (handle == NULL) { + if (handle == nullptr) { return ECODE_EMDRV_SPIDRV_ILLEGAL_HANDLE; } - if ((buffer == NULL) || (count == 0) || (count > DMADRV_MAX_XFER_COUNT)) { + if ((buffer == nullptr) || (count == 0) || (count > DMADRV_MAX_XFER_COUNT)) { return ECODE_EMDRV_SPIDRV_PARAM_ERROR; } diff --git a/targets/AzureRTOS/SiliconLabs/_nanoCLR/System.Device.UsbStream/sys_dev_usbstream_native_System_Device_Usb_UsbStream.cpp b/targets/AzureRTOS/SiliconLabs/_nanoCLR/System.Device.UsbStream/sys_dev_usbstream_native_System_Device_Usb_UsbStream.cpp index bbdd226407..47d48791c5 100644 --- a/targets/AzureRTOS/SiliconLabs/_nanoCLR/System.Device.UsbStream/sys_dev_usbstream_native_System_Device_Usb_UsbStream.cpp +++ b/targets/AzureRTOS/SiliconLabs/_nanoCLR/System.Device.UsbStream/sys_dev_usbstream_native_System_Device_Usb_UsbStream.cpp @@ -91,7 +91,7 @@ HRESULT Library_sys_dev_usbstream_native_System_Device_Usb_UsbStream::Read___I4_ uint32_t offset = 0; sl_status_t reqStatus; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -205,7 +205,7 @@ HRESULT Library_sys_dev_usbstream_native_System_Device_Usb_UsbStream::Read___I4_ if (hr != CLR_E_THREAD_WAITING) { // need to clean up the buffer, if this was not rescheduled - if (dataBuffer != NULL && dataBuffer->IsPinned()) + if (dataBuffer != nullptr && dataBuffer->IsPinned()) { dataBuffer->Unpin(); } @@ -233,7 +233,7 @@ HRESULT Library_sys_dev_usbstream_native_System_Device_Usb_UsbStream::Write___VO uint32_t xfer_len = 0; bool isLongRunning = false; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -365,7 +365,7 @@ HRESULT Library_sys_dev_usbstream_native_System_Device_Usb_UsbStream::Write___VO if (isLongRunning && hr != CLR_E_THREAD_WAITING) { // need to clean up the buffer, if this was not rescheduled - if (dataBuffer != NULL && dataBuffer->IsPinned()) + if (dataBuffer != nullptr && dataBuffer->IsPinned()) { dataBuffer->Unpin(); } @@ -412,7 +412,7 @@ HRESULT Library_sys_dev_usbstream_native_System_Device_Usb_UsbStream::NativeOpen // int32_t bufferSize; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); diff --git a/targets/AzureRTOS/SiliconLabs/_nanoCLR/System.IO.Ports/sys_io_ser_native_System_IO_Ports_SerialPort.cpp b/targets/AzureRTOS/SiliconLabs/_nanoCLR/System.IO.Ports/sys_io_ser_native_System_IO_Ports_SerialPort.cpp index 5dedf6f540..b327d20fdc 100644 --- a/targets/AzureRTOS/SiliconLabs/_nanoCLR/System.IO.Ports/sys_io_ser_native_System_IO_Ports_SerialPort.cpp +++ b/targets/AzureRTOS/SiliconLabs/_nanoCLR/System.IO.Ports/sys_io_ser_native_System_IO_Ports_SerialPort.cpp @@ -65,7 +65,7 @@ static NF_PAL_UART *GetUartPAL(uint8_t index) #endif default: - return NULL; + return nullptr; } } @@ -154,13 +154,13 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::get_BytesToRead___ NF_PAL_UART *palUart; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); // Choose the driver for this SerialDevice palUart = GetUartPAL((int)pThis[FIELD___portIndex].NumericByRef().s4); - if (palUart == NULL) + if (palUart == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER); } @@ -200,7 +200,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::Read___I4__SZARRAY CLR_RT_HeapBlock hbTimeout; CLR_RT_HeapBlock_Array *dataBuffer; - NF_PAL_UART *palUart = NULL; + NF_PAL_UART *palUart = nullptr; uint8_t *data; @@ -213,7 +213,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::Read___I4__SZARRAY int64_t *timeoutTicks; bool eventResult = true; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -256,7 +256,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::Read___I4__SZARRAY // Choose the driver for this SerialDevice palUart = GetUartPAL((int)pThis[FIELD___portIndex].NumericByRef().s4); - if (palUart == NULL) + if (palUart == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER); } @@ -338,14 +338,14 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::ReadExisting___STR { NANOCLR_HEADER(); - NF_PAL_UART *palUart = NULL; + NF_PAL_UART *palUart = nullptr; - uint8_t *buffer = NULL; + uint8_t *buffer = nullptr; uint32_t bufferLength; CLR_RT_HeapBlock &top = stack.PushValue(); - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -356,7 +356,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::ReadExisting___STR // Choose the driver for this SerialDevice palUart = GetUartPAL((int)pThis[FIELD___portIndex].NumericByRef().s4); - if (palUart == NULL) + if (palUart == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER); } @@ -370,7 +370,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::ReadExisting___STR buffer = (uint8_t *)platform_malloc(bufferLength); // sanity check - if (buffer == NULL) + if (buffer == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_OUT_OF_MEMORY); } @@ -383,12 +383,12 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::ReadExisting___STR else { // create an empty - NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_String::CreateInstance(top, (const char *)NULL)); + NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_String::CreateInstance(top, (const char *)nullptr)); } NANOCLR_CLEANUP(); - if (buffer != NULL) + if (buffer != nullptr) { platform_free(buffer); } @@ -401,17 +401,17 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::ReadLine___STRING( NANOCLR_HEADER(); CLR_RT_HeapBlock hbTimeout; - NF_PAL_UART *palUart = NULL; + NF_PAL_UART *palUart = nullptr; - uint8_t *line = NULL; - const char *newLine = NULL; + uint8_t *line = nullptr; + const char *newLine = nullptr; uint32_t newLineLength; int64_t *timeoutTicks; bool eventResult = true; bool newLineFound = false; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -426,7 +426,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::ReadLine___STRING( // Choose the driver for this SerialDevice palUart = GetUartPAL((int)pThis[FIELD___portIndex].NumericByRef().s4); - if (palUart == NULL) + if (palUart == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER); } @@ -449,8 +449,8 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::ReadLine___STRING( // get new line from field newLine = pThis[FIELD___newLine].RecoverString(); - // sanity check for NULL string - if (newLine == NULL) + // sanity check for nullptr string + if (newLine == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER); } @@ -499,7 +499,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::ReadLine___STRING( stack.SetResult_String((const char *)line); // free memory, if needed - if (line != NULL) + if (line != nullptr) { platform_free(line); } @@ -511,7 +511,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::Write___VOID__SZAR { NANOCLR_HEADER(); - NF_PAL_UART *palUart = NULL; + NF_PAL_UART *palUart = nullptr; CLR_RT_HeapBlock_Array *dataBuffer; CLR_RT_HeapBlock hbTimeout; @@ -523,7 +523,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::Write___VOID__SZAR int32_t count = 0; int32_t offset = 0; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -534,7 +534,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::Write___VOID__SZAR // Choose the driver for this SerialDevice palUart = GetUartPAL((int)pThis[FIELD___portIndex].NumericByRef().s4); - if (palUart == NULL) + if (palUart == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER); } @@ -623,7 +623,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::Write___VOID__SZAR stack.SetResult_U4(count); // null pointers and vars - pThis = NULL; + pThis = nullptr; NANOCLR_NOCLEANUP(); } @@ -632,7 +632,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::NativeDispose___VO { NANOCLR_HEADER(); - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -696,7 +696,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::NativeInit___VOID( int32_t bufferSize; uint8_t watchChar; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -749,7 +749,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::NativeInit___VOID( palUart->RxBuffer = (uint8_t *)platform_malloc(bufferSize); // sanity check - if (palUart->RxBuffer == NULL) + if (palUart->RxBuffer == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_OUT_OF_MEMORY); } @@ -776,15 +776,15 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::NativeConfig___VOI { NANOCLR_HEADER(); - NF_PAL_UART *palUart = NULL; + NF_PAL_UART *palUart = nullptr; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); // Choose the driver for this SerialDevice palUart = GetUartPAL((int)pThis[FIELD___portIndex].NumericByRef().s4); - if (palUart == NULL) + if (palUart == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER); } @@ -874,7 +874,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::NativeConfig___VOI } // null pointers and vars - pThis = NULL; + pThis = nullptr; NANOCLR_NOCLEANUP(); } @@ -885,13 +885,13 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::NativeSetWatchChar NF_PAL_UART *palUart; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); // Choose the driver for this SerialDevice palUart = GetUartPAL((int)pThis[FIELD___portIndex].NumericByRef().s4); - if (palUart == NULL) + if (palUart == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER); } @@ -907,18 +907,18 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::NativeWriteString_ { NANOCLR_HEADER(); - NF_PAL_UART *palUart = NULL; + NF_PAL_UART *palUart = nullptr; CLR_RT_HeapBlock hbTimeout; int64_t *timeoutTicks; bool eventResult = true; bool isNewAllocation = false; - char *buffer = NULL; + char *buffer = nullptr; uint32_t bufferLength = 0; int32_t length = 0; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -927,7 +927,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::NativeWriteString_ NANOCLR_SET_AND_LEAVE(CLR_E_OBJECT_DISPOSED); } - if (stack.Arg1().RecoverString() == NULL) + if (stack.Arg1().RecoverString() == nullptr) { // text string it's empty so there is noting to do here stack.SetResult_U4(0); @@ -936,7 +936,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::NativeWriteString_ // Choose the driver for this SerialDevice palUart = GetUartPAL((int)pThis[FIELD___portIndex].NumericByRef().s4); - if (palUart == NULL) + if (palUart == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER); } @@ -1020,7 +1020,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::NativeWriteString_ } // null pointers and vars - pThis = NULL; + pThis = nullptr; NANOCLR_NOCLEANUP(); } @@ -1034,7 +1034,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::NativeReceivedByte int32_t threshold; uint8_t portIndex; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -1050,7 +1050,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::NativeReceivedByte // Choose the driver for this SerialDevice palUart = GetUartPAL(portIndex); - if (palUart == NULL) + if (palUart == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER); } diff --git a/targets/AzureRTOS/SiliconLabs/_nanoCLR/System.IO.Ports/sys_io_ser_native_target.h b/targets/AzureRTOS/SiliconLabs/_nanoCLR/System.IO.Ports/sys_io_ser_native_target.h index 6168b5bc72..b4e9b3f968 100644 --- a/targets/AzureRTOS/SiliconLabs/_nanoCLR/System.IO.Ports/sys_io_ser_native_target.h +++ b/targets/AzureRTOS/SiliconLabs/_nanoCLR/System.IO.Ports/sys_io_ser_native_target.h @@ -122,9 +122,9 @@ extern NF_PAL_UART Uart5_PAL; Uart##num##_PAL.Usart = USART##num; \ USART##num->ROUTELOC0 = rx_location | tx_location; \ USART##num->ROUTEPEN |= USART_ROUTEPEN_TXPEN | USART_ROUTEPEN_RXPEN; \ - Uart##num##_PAL.TxBuffer = NULL; \ + Uart##num##_PAL.TxBuffer = nullptr; \ Uart##num##_PAL.TxOngoingCount = 0; \ - Uart##num##_PAL.RxBuffer = NULL; \ + Uart##num##_PAL.RxBuffer = nullptr; \ Uart##num##_PAL.WatchChar = 0; \ Uart##num##_PAL.NewLineChar = 0; \ Uart##num##_PAL.SignalLevelsInverted = false; \ @@ -151,9 +151,9 @@ void InitConfig_USART5(); GPIO_PinModeSet(gpio_port_tx, tx_pin, gpioModeDisabled, 0); \ CMU_ClockEnable(cmuClock_USART##num, false); \ platform_free(Uart##num##_PAL.RxBuffer); \ - Uart##num##_PAL.TxBuffer = NULL; \ - Uart##num##_PAL.RxBuffer = NULL; \ - Uart##num##_PAL.Usart = NULL; \ + Uart##num##_PAL.TxBuffer = nullptr; \ + Uart##num##_PAL.RxBuffer = nullptr; \ + Uart##num##_PAL.Usart = nullptr; \ return; \ } diff --git a/targets/AzureRTOS/SiliconLabs/_nanoCLR/nanoFramework.Device.OneWire/nf_dev_onewire_nanoFramework_Device_OneWire_OneWireHost.cpp b/targets/AzureRTOS/SiliconLabs/_nanoCLR/nanoFramework.Device.OneWire/nf_dev_onewire_nanoFramework_Device_OneWire_OneWireHost.cpp index fd79ba0737..7f74ab7ce9 100644 --- a/targets/AzureRTOS/SiliconLabs/_nanoCLR/nanoFramework.Device.OneWire/nf_dev_onewire_nanoFramework_Device_OneWire_OneWireHost.cpp +++ b/targets/AzureRTOS/SiliconLabs/_nanoCLR/nanoFramework.Device.OneWire/nf_dev_onewire_nanoFramework_Device_OneWire_OneWireHost.cpp @@ -447,7 +447,7 @@ HRESULT FindOneDevice(CLR_RT_StackFrame &stack, bool findFirst) // 1. allocate memory for thread stack workingThreadStack = (uint32_t *)platform_malloc(ONEWIRE_THREAD_STACK_SIZE); - if (workingThreadStack == NULL) + if (workingThreadStack == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_OUT_OF_MEMORY); } @@ -458,7 +458,7 @@ HRESULT FindOneDevice(CLR_RT_StackFrame &stack, bool findFirst) #if !defined(BUILD_RTM) (CHAR *)"1-Wire Thread", #else - NULL, + nullptr, #endif OneWireFindWorkingThread_entry, (uint32_t)&FindStruct, @@ -506,7 +506,7 @@ HRESULT FindOneDevice(CLR_RT_StackFrame &stack, bool findFirst) { // update serialNumber field - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); diff --git a/targets/AzureRTOS/SiliconLabs/_nanoCLR/nanoFramework.GiantGecko.Adc/nano_gg_adc_native_nanoFramework_GiantGecko_Adc_AdcChannel.cpp b/targets/AzureRTOS/SiliconLabs/_nanoCLR/nanoFramework.GiantGecko.Adc/nano_gg_adc_native_nanoFramework_GiantGecko_Adc_AdcChannel.cpp index feaf0eab9a..5448573d2d 100644 --- a/targets/AzureRTOS/SiliconLabs/_nanoCLR/nanoFramework.GiantGecko.Adc/nano_gg_adc_native_nanoFramework_GiantGecko_Adc_AdcChannel.cpp +++ b/targets/AzureRTOS/SiliconLabs/_nanoCLR/nanoFramework.GiantGecko.Adc/nano_gg_adc_native_nanoFramework_GiantGecko_Adc_AdcChannel.cpp @@ -46,13 +46,13 @@ HRESULT Library_nano_gg_adc_native_nanoFramework_GiantGecko_Adc_AdcChannel::Nati NF_PAL_ADC_PORT_PIN_CHANNEL adcDefinition; // ADC related variables - ADC_TypeDef *adcDriver = NULL; + ADC_TypeDef *adcDriver = nullptr; ADC_InitSingle_TypeDef channelInitSingle; uint64_t samplesAccumulator = 0; int32_t averageCount; int32_t samplesCount; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); diff --git a/targets/AzureRTOS/SiliconLabs/_nanoCLR/nanoFramework.GiantGecko.Adc/nano_gg_adc_native_nanoFramework_GiantGecko_Adc_AdcController.cpp b/targets/AzureRTOS/SiliconLabs/_nanoCLR/nanoFramework.GiantGecko.Adc/nano_gg_adc_native_nanoFramework_GiantGecko_Adc_AdcController.cpp index ff93141af5..958be31303 100644 --- a/targets/AzureRTOS/SiliconLabs/_nanoCLR/nanoFramework.GiantGecko.Adc/nano_gg_adc_native_nanoFramework_GiantGecko_Adc_AdcController.cpp +++ b/targets/AzureRTOS/SiliconLabs/_nanoCLR/nanoFramework.GiantGecko.Adc/nano_gg_adc_native_nanoFramework_GiantGecko_Adc_AdcController.cpp @@ -32,8 +32,8 @@ HRESULT OpenAdcChannel(int32_t channelNumber, CLR_RT_HeapBlock *adcConfiguration NF_PAL_ADC_PORT_PIN_CHANNEL adcChannelDefinition; CMU_Clock_TypeDef adcClock; - ADC_Init_TypeDef *adcInit = NULL; - bool *adcInitialized = NULL; + ADC_Init_TypeDef *adcInit = nullptr; + bool *adcInitialized = nullptr; // sanity check for existing configuration if (channelNumber >= AdcChannelCount) @@ -145,7 +145,7 @@ HRESULT Library_nano_gg_adc_native_nanoFramework_GiantGecko_Adc_AdcController::N int32_t channelNumber; ADC_TypeDef *adcDriver; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -192,7 +192,7 @@ HRESULT Library_nano_gg_adc_native_nanoFramework_GiantGecko_Adc_AdcController:: CLR_RT_TypeDef_Index adcSampleResolutionTypeDef; CLR_RT_HeapBlock_Array *supportedResolutions; - CLR_INT32 *resolution = NULL; + CLR_INT32 *resolution = nullptr; uint16_t resolutionsCount = 0; @@ -259,14 +259,14 @@ HRESULT Library_nano_gg_adc_native_nanoFramework_GiantGecko_Adc_AdcController:: uint32_t channelIndex = 0; int32_t channelNumber; ADC_InitScan_TypeDef channelInitScan = ADC_INITSCAN_DEFAULT; - ADC_TypeDef *adcDriver = NULL; + ADC_TypeDef *adcDriver = nullptr; NF_PAL_ADC_PORT_PIN_CHANNEL adcChannelDefinition; CLR_RT_HeapBlock_Array *adcChannelsToScan; CLR_RT_HeapBlock *adcConfiguration; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -301,7 +301,7 @@ HRESULT Library_nano_gg_adc_native_nanoFramework_GiantGecko_Adc_AdcController:: (NF_PAL_GECKO_ADC_CONTINUOUS_SCAN *)platform_malloc(sizeof(NF_PAL_GECKO_ADC_CONTINUOUS_SCAN)); // sanity check - if (ContinuousScanOperation == NULL) + if (ContinuousScanOperation == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_OUT_OF_MEMORY); } @@ -311,7 +311,7 @@ HRESULT Library_nano_gg_adc_native_nanoFramework_GiantGecko_Adc_AdcController:: (uint32_t *)platform_malloc(adcChannelsToScan->m_numOfElements * averageCount * sizeof(uint32_t)); // sanity check - if (ContinuousScanOperation->dataBuffer == NULL) + if (ContinuousScanOperation->dataBuffer == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_OUT_OF_MEMORY); } @@ -367,16 +367,16 @@ HRESULT Library_nano_gg_adc_native_nanoFramework_GiantGecko_Adc_AdcController:: if (FAILED(hr)) { // free memory for the scan operation - if (ContinuousScanOperation != NULL) + if (ContinuousScanOperation != nullptr) { - if (ContinuousScanOperation->dataBuffer != NULL) + if (ContinuousScanOperation->dataBuffer != nullptr) { platform_free(ContinuousScanOperation->dataBuffer); } platform_free(ContinuousScanOperation); - ContinuousScanOperation = NULL; + ContinuousScanOperation = nullptr; } } @@ -388,7 +388,7 @@ HRESULT Library_nano_gg_adc_native_nanoFramework_GiantGecko_Adc_AdcController::N { NANOCLR_HEADER(); - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -398,7 +398,7 @@ HRESULT Library_nano_gg_adc_native_nanoFramework_GiantGecko_Adc_AdcController::N // clear memory for the scan operation platform_free(ContinuousScanOperation->dataBuffer); platform_free(ContinuousScanOperation); - ContinuousScanOperation = NULL; + ContinuousScanOperation = nullptr; // all good, update flag pThis[FIELD___continuousSamplingStarted].NumericByRef().u1 = (CLR_UINT8) false; @@ -411,7 +411,7 @@ HRESULT Library_nano_gg_adc_native_nanoFramework_GiantGecko_Adc_AdcController:: { NANOCLR_HEADER(); - CLR_INT32 *sample = NULL; + CLR_INT32 *sample = nullptr; // assuming that, at 12 bits resolution, this will be enough to hold the average uint64_t samplesAccumulator = 0; @@ -421,7 +421,7 @@ HRESULT Library_nano_gg_adc_native_nanoFramework_GiantGecko_Adc_AdcController:: NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_Array::CreateInstance( stack.PushValueAndClear(), ContinuousScanOperation->channelCount, - g_CLR_RT_WellKnownTypes.m_Int32)); + g_CLR_RT_WellKnownTypes.Int32)); sampleArray = stack.TopValue().DereferenceArray(); diff --git a/targets/AzureRTOS/SiliconLabs/_nanoCLR/nanoFramework.System.IO.Hashing/nf_sys_io_hashing_System_IO_Hashing_Crc32.cpp b/targets/AzureRTOS/SiliconLabs/_nanoCLR/nanoFramework.System.IO.Hashing/nf_sys_io_hashing_System_IO_Hashing_Crc32.cpp index 90281a3017..5e63e04977 100644 --- a/targets/AzureRTOS/SiliconLabs/_nanoCLR/nanoFramework.System.IO.Hashing/nf_sys_io_hashing_System_IO_Hashing_Crc32.cpp +++ b/targets/AzureRTOS/SiliconLabs/_nanoCLR/nanoFramework.System.IO.Hashing/nf_sys_io_hashing_System_IO_Hashing_Crc32.cpp @@ -19,13 +19,13 @@ HRESULT Library_nf_sys_io_hashing_System_IO_Hashing_Crc32::ComputeHash___STATIC_ CLR_RT_HeapBlock *bufferSpanByte; CLR_RT_HeapBlock_Array *buffer; - uint8_t *bufferData = NULL; + uint8_t *bufferData = nullptr; int16_t bufferSize = 0; int16_t bufferOffset = 0; uint32_t crc32 = 0; uint32_t hash = 0; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr bufferSpanByte = stack.Arg1().Dereference(); FAULT_ON_NULL_ARG(bufferSpanByte); diff --git a/targets/AzureRTOS/SiliconLabs/_nanoCLR/targetHAL.cpp b/targets/AzureRTOS/SiliconLabs/_nanoCLR/targetHAL.cpp index d1a4aafefd..fad1b09c43 100644 --- a/targets/AzureRTOS/SiliconLabs/_nanoCLR/targetHAL.cpp +++ b/targets/AzureRTOS/SiliconLabs/_nanoCLR/targetHAL.cpp @@ -42,13 +42,13 @@ extern void DeInitPwm(); // Reboot handlers clean up on reboot // static ON_SOFT_REBOOT_HANDLER s_rebootHandlers[16] = - {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}; + {nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr}; void HAL_AddSoftRebootHandler(ON_SOFT_REBOOT_HANDLER handler) { for (size_t i = 0; i < ARRAYSIZE(s_rebootHandlers); i++) { - if (s_rebootHandlers[i] == NULL) + if (s_rebootHandlers[i] == nullptr) { s_rebootHandlers[i] = handler; return; @@ -89,7 +89,7 @@ void nanoHAL_Initialize() BlockStorageList_InitializeDevices(); // clear managed heap region - unsigned char *heapStart = NULL; + unsigned char *heapStart = nullptr; unsigned int heapSize = 0; ::HeapLocation(heapStart, heapSize); @@ -108,13 +108,13 @@ void nanoHAL_Initialize() // #if (HAL_USE_CAN == TRUE) // #if defined(STM32_CAN_USE_CAN1) && (STM32_CAN_USE_CAN1 == TRUE) - // Can1_PAL.Driver = NULL; + // Can1_PAL.Driver = nullptr; // #endif // #if (STM32_CAN_USE_CAN2) && (STM32_CAN_USE_CAN2 == TRUE) - // Can2_PAL.Driver = NULL; + // Can2_PAL.Driver = nullptr; // #endif // #if (STM32_CAN_USE_CAN3) && (STM32_CAN_USE_CAN3 == TRUE) - // Can3_PAL.Driver = NULL; + // Can3_PAL.Driver = nullptr; // #endif // #endif @@ -210,7 +210,7 @@ void nanoHAL_Uninitialize(bool isPoweringDown) // process Reboot Handlers for (size_t i = 0; i < ARRAYSIZE(s_rebootHandlers); i++) { - if (s_rebootHandlers[i] != NULL) + if (s_rebootHandlers[i] != nullptr) { s_rebootHandlers[i](); } @@ -251,26 +251,26 @@ void nanoHAL_Uninitialize(bool isPoweringDown) // #endif #if defined(I2C0) && (GECKO_USE_I2C0 == TRUE) - if (I2C0_PAL.Configuration != NULL) + if (I2C0_PAL.Configuration != nullptr) { platform_free(I2C0_PAL.Configuration); - I2C0_PAL.Configuration = NULL; + I2C0_PAL.Configuration = nullptr; } I2C_Reset(I2C0); #endif #if defined(I2C1) && (GECKO_USE_I2C1 == TRUE) - if (I2C1_PAL.Configuration != NULL) + if (I2C1_PAL.Configuration != nullptr) { platform_free(I2C1_PAL.Configuration); - I2C1_PAL.Configuration = NULL; + I2C1_PAL.Configuration = nullptr; } I2C_Reset(I2C1); #endif #if defined(I2C2) && (GECKO_USE_I2C2 == TRUE) - if (I2C2_PAL.Configuration != NULL) + if (I2C2_PAL.Configuration != nullptr) { platform_free(I2C2_PAL.Configuration); - I2C2_PAL.Configuration = NULL; + I2C2_PAL.Configuration = nullptr; } I2C_Reset(I2C2); #endif @@ -297,37 +297,37 @@ void nanoHAL_Uninitialize(bool isPoweringDown) #endif #if defined(GECKO_USE_USART0) && (GECKO_USE_USART0 == TRUE) - if (Usart0_PAL.Usart != NULL) + if (Usart0_PAL.Usart != nullptr) { UnInit_UART0(); } #endif #if defined(GECKO_USE_USART1) && (GECKO_USE_USART1 == TRUE) - if (Usart1_PAL.Usart != NULL) + if (Usart1_PAL.Usart != nullptr) { UnInit_UART1(); } #endif #if defined(GECKO_USE_USART2) && (GECKO_USE_USART2 == TRUE) - if (Usart2_PAL.Usart != NULL) + if (Usart2_PAL.Usart != nullptr) { UnInit_UART2(); } #endif #if defined(GECKO_USE_USART3) && (GECKO_USE_USART3 == TRUE) - if (Usart3_PAL.Usart != NULL) + if (Usart3_PAL.Usart != nullptr) { UnInit_UART3(); } #endif #if defined(GECKO_USE_USART_UART4) && (GECKO_USE_USART_UART4 == TRUE) - if (Usart4_PAL.Usart != NULL) + if (Usart4_PAL.Usart != nullptr) { UnInit_UART4(); } #endif #if defined(GECKO_USE_USART_UART5) && (GECKO_USE_USART_UART5 == TRUE) - if (Usart5_PAL.Usart != NULL) + if (Usart5_PAL.Usart != nullptr) { UnInit_UART5(); } diff --git a/targets/AzureRTOS/_common/nanoCLR/nanoCRT.cpp b/targets/AzureRTOS/_common/nanoCLR/nanoCRT.cpp index dad201afa3..2f9b5d3c34 100644 --- a/targets/AzureRTOS/_common/nanoCLR/nanoCRT.cpp +++ b/targets/AzureRTOS/_common/nanoCLR/nanoCRT.cpp @@ -138,7 +138,7 @@ int hal_strcpy_s(char *strDst, size_t sizeInBytes, const char *strSrc) #undef strcpy size_t len; - if (strDst == NULL || strSrc == NULL || sizeInBytes == 0) + if (strDst == nullptr || strSrc == nullptr || sizeInBytes == 0) { _ASSERTE(FALSE); return 1; @@ -161,7 +161,7 @@ int hal_strncpy_s(char *strDst, size_t sizeInBytes, const char *strSrc, size_t c { NATIVE_PROFILE_PAL_CRT(); #undef strncpy - if (strDst == NULL || strSrc == NULL || sizeInBytes == 0) + if (strDst == nullptr || strSrc == nullptr || sizeInBytes == 0) { _ASSERTE(FALSE); return 1; @@ -195,7 +195,7 @@ int hal_strncmp_s(const char *str1, const char *str2, size_t num) { NATIVE_PROFILE_PAL_CRT(); #undef strncmp - if (str1 == NULL || str2 == NULL) + if (str1 == nullptr || str2 == nullptr) { _ASSERTE(FALSE); return 1; diff --git a/targets/AzureRTOS/_common/nanoCLR/targetPAL_Events.cpp b/targets/AzureRTOS/_common/nanoCLR/targetPAL_Events.cpp index 551806fe7b..4560557f30 100644 --- a/targets/AzureRTOS/_common/nanoCLR/targetPAL_Events.cpp +++ b/targets/AzureRTOS/_common/nanoCLR/targetPAL_Events.cpp @@ -44,7 +44,7 @@ bool Events_Uninitialize_Platform() void Events_SetBoolTimer(bool *timerCompleteFlag, uint32_t millisecondsFromNow) { - if (timerCompleteFlag != NULL) + if (timerCompleteFlag != nullptr) { // As only one timer running at a time we will just save it saveTimerCompleteFlag = timerCompleteFlag; diff --git a/targets/AzureRTOS/_common/nanoCLR/targetPAL_Time.cpp b/targets/AzureRTOS/_common/nanoCLR/targetPAL_Time.cpp index 206b6630e9..fc808072d5 100644 --- a/targets/AzureRTOS/_common/nanoCLR/targetPAL_Time.cpp +++ b/targets/AzureRTOS/_common/nanoCLR/targetPAL_Time.cpp @@ -10,7 +10,7 @@ // timer for next event static TX_TIMER nextEventTimer; -void *nextEventCallbackDummyArg = NULL; +void *nextEventCallbackDummyArg = nullptr; static void NextEventTimer_Callback(uint32_t id) { diff --git a/targets/ChibiOS/ORGPAL_PALTHREE/target_system_device_adc_config.cpp b/targets/ChibiOS/ORGPAL_PALTHREE/target_system_device_adc_config.cpp index e480082ee1..98f5a1f22e 100644 --- a/targets/ChibiOS/ORGPAL_PALTHREE/target_system_device_adc_config.cpp +++ b/targets/ChibiOS/ORGPAL_PALTHREE/target_system_device_adc_config.cpp @@ -20,9 +20,9 @@ const NF_PAL_ADC_PORT_PIN_CHANNEL AdcPortPinConfig[] = { {3, GPIOF, 9, ADC_CHANNEL_IN7}, // these are the internal sources, available only at ADC1 - {1, NULL, 0, ADC_CHANNEL_SENSOR}, - {1, NULL, 0, ADC_CHANNEL_VREFINT}, - {1, NULL, 0, ADC_CHANNEL_VBAT}, + {1, nullptr, 0, ADC_CHANNEL_SENSOR}, + {1, nullptr, 0, ADC_CHANNEL_VREFINT}, + {1, nullptr, 0, ADC_CHANNEL_VBAT}, }; const int AdcChannelCount = ARRAYSIZE(AdcPortPinConfig); diff --git a/targets/ChibiOS/ORGPAL_PALX/target_system_device_adc_config.cpp b/targets/ChibiOS/ORGPAL_PALX/target_system_device_adc_config.cpp index 078392b1b7..3a67a606a2 100644 --- a/targets/ChibiOS/ORGPAL_PALX/target_system_device_adc_config.cpp +++ b/targets/ChibiOS/ORGPAL_PALX/target_system_device_adc_config.cpp @@ -14,9 +14,9 @@ const NF_PAL_ADC_PORT_PIN_CHANNEL AdcPortPinConfig[] = { {1, GPIOC, 3, ADC_CHANNEL_IN13}, // these are the internal sources, available only at ADC1 - {1, NULL, 0, ADC_CHANNEL_SENSOR}, - {1, NULL, 0, ADC_CHANNEL_VREFINT}, - {1, NULL, 0, ADC_CHANNEL_VBAT}, + {1, nullptr, 0, ADC_CHANNEL_SENSOR}, + {1, nullptr, 0, ADC_CHANNEL_VREFINT}, + {1, nullptr, 0, ADC_CHANNEL_VBAT}, }; const int AdcChannelCount = ARRAYSIZE(AdcPortPinConfig); diff --git a/targets/ChibiOS/ST_STM32F429I_DISCOVERY/nanoCLR/nanoFramework.Graphics/I2C_To_TouchPanel.cpp b/targets/ChibiOS/ST_STM32F429I_DISCOVERY/nanoCLR/nanoFramework.Graphics/I2C_To_TouchPanel.cpp index f2142e09ed..490fc5696a 100644 --- a/targets/ChibiOS/ST_STM32F429I_DISCOVERY/nanoCLR/nanoFramework.Graphics/I2C_To_TouchPanel.cpp +++ b/targets/ChibiOS/ST_STM32F429I_DISCOVERY/nanoCLR/nanoFramework.Graphics/I2C_To_TouchPanel.cpp @@ -40,7 +40,7 @@ CLR_UINT8 *TouchInterface::Write_Read( (void)numberOfValuesToSend; (void)numberValuesExpected; - // CLR_UINT8* receivedValues = NULL; + // CLR_UINT8* receivedValues = nullptr; // msg_t result = i2cMasterTransmitTimeout(&touchDriver, I2C_Address, valuesToSend, numberOfValuesToSend, // receivedValues, numberValuesExpected, TIME_MS2I(20)); return receivedValues; diff --git a/targets/ChibiOS/ST_STM32F429I_DISCOVERY/target_system_device_adc_config.cpp b/targets/ChibiOS/ST_STM32F429I_DISCOVERY/target_system_device_adc_config.cpp index 14f5b1fa4a..b7fbe5f715 100644 --- a/targets/ChibiOS/ST_STM32F429I_DISCOVERY/target_system_device_adc_config.cpp +++ b/targets/ChibiOS/ST_STM32F429I_DISCOVERY/target_system_device_adc_config.cpp @@ -17,9 +17,9 @@ const NF_PAL_ADC_PORT_PIN_CHANNEL AdcPortPinConfig[] = { {3, GPIOF, 6, ADC_CHANNEL_IN4}, // these are the internal sources, available only at ADC1 - {1, NULL, 0, ADC_CHANNEL_SENSOR}, - {1, NULL, 0, ADC_CHANNEL_VREFINT}, - {1, NULL, 0, ADC_CHANNEL_VBAT}, + {1, nullptr, 0, ADC_CHANNEL_SENSOR}, + {1, nullptr, 0, ADC_CHANNEL_VREFINT}, + {1, nullptr, 0, ADC_CHANNEL_VBAT}, }; const int AdcChannelCount = ARRAYSIZE(AdcPortPinConfig); diff --git a/targets/ChibiOS/ST_STM32F769I_DISCOVERY/nanoCLR/nanoFramework.Graphics/I2C_To_TouchPanel.cpp b/targets/ChibiOS/ST_STM32F769I_DISCOVERY/nanoCLR/nanoFramework.Graphics/I2C_To_TouchPanel.cpp index 994aa6fd5e..c3149a2700 100644 --- a/targets/ChibiOS/ST_STM32F769I_DISCOVERY/nanoCLR/nanoFramework.Graphics/I2C_To_TouchPanel.cpp +++ b/targets/ChibiOS/ST_STM32F769I_DISCOVERY/nanoCLR/nanoFramework.Graphics/I2C_To_TouchPanel.cpp @@ -47,7 +47,7 @@ CLR_UINT8 *TouchInterface::Write_Read( UNUSED(numberOfValuesToSend); UNUSED(numberValuesExpected); - // CLR_UINT8* receivedValues = NULL; + // CLR_UINT8* receivedValues = nullptr; // msg_t result = i2cMasterTransmitTimeout(&touchDriver, I2C_Address, valuesToSend, numberOfValuesToSend, // receivedValues, numberValuesExpected, TIME_MS2I(20)); return receivedValues; diff --git a/targets/ChibiOS/ST_STM32F769I_DISCOVERY/target_system_device_adc_config.cpp b/targets/ChibiOS/ST_STM32F769I_DISCOVERY/target_system_device_adc_config.cpp index c96f9c7908..027683977d 100644 --- a/targets/ChibiOS/ST_STM32F769I_DISCOVERY/target_system_device_adc_config.cpp +++ b/targets/ChibiOS/ST_STM32F769I_DISCOVERY/target_system_device_adc_config.cpp @@ -17,9 +17,9 @@ const NF_PAL_ADC_PORT_PIN_CHANNEL AdcPortPinConfig[] = { {3, GPIOF, 8, ADC_CHANNEL_IN6}, // these are the internal sources, available only at ADC1 - {1, NULL, 0, ADC_CHANNEL_SENSOR}, - {1, NULL, 0, ADC_CHANNEL_VREFINT}, - {1, NULL, 0, ADC_CHANNEL_VBAT}, + {1, nullptr, 0, ADC_CHANNEL_SENSOR}, + {1, nullptr, 0, ADC_CHANNEL_VREFINT}, + {1, nullptr, 0, ADC_CHANNEL_VBAT}, }; const int AdcChannelCount = ARRAYSIZE(AdcPortPinConfig); diff --git a/targets/ChibiOS/_FatFs/fatfs_FS_Driver.cpp b/targets/ChibiOS/_FatFs/fatfs_FS_Driver.cpp index a04406f40a..ffe63e0f37 100644 --- a/targets/ChibiOS/_FatFs/fatfs_FS_Driver.cpp +++ b/targets/ChibiOS/_FatFs/fatfs_FS_Driver.cpp @@ -76,7 +76,7 @@ void FATFS_FS_Driver::Initialize() // initialize the file handler pool #if CACHE_LINE_SIZE > 0 - chPoolObjectInit(&fileHandlerPool, sizeof(FATFS_FileHandle), NULL); + chPoolObjectInit(&fileHandlerPool, sizeof(FATFS_FileHandle), nullptr); chPoolLoadArray(&fileHandlerPool, fileHandlerPoolStorage, FILE_HANDLER_POOL_SIZE); #endif } @@ -86,7 +86,7 @@ bool FATFS_FS_Driver::InitializeVolume(const VOLUME_ID *volume, const char *path // find a free volume FATFS *fs = GetFatFsByVolumeId(volume, true); - if (fs == NULL) + if (fs == nullptr) { return FALSE; } @@ -221,11 +221,11 @@ HRESULT FATFS_FS_Driver::GetVolumeLabel(const VOLUME_ID *volume, char *volumeLab (void)volumeLabel; (void)volumeLabelLen; - // FATFS *fs = NULL; + // FATFS *fs = nullptr; // //fs = GetFileSystemForVolume(volume, true); - // if (fs == NULL) + // if (fs == nullptr) // { // return FALSE; // } @@ -257,7 +257,7 @@ HRESULT FATFS_FS_Driver::Open(const VOLUME_ID *volume, const char *path, void *& int32_t result; #endif - FATFS_FileHandle *fileHandle = NULL; + FATFS_FileHandle *fileHandle = nullptr; FILINFO info; int32_t flags; char normalizedPath[FS_MAX_DIRECTORY_LENGTH]; @@ -271,7 +271,7 @@ HRESULT FATFS_FS_Driver::Open(const VOLUME_ID *volume, const char *path, void *& fileHandle = (FATFS_FileHandle *)platform_malloc(sizeof(FATFS_FileHandle)); #endif - if (fileHandle == NULL) + if (fileHandle == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_OUT_OF_MEMORY); } @@ -333,7 +333,7 @@ HRESULT FATFS_FS_Driver::Open(const VOLUME_ID *volume, const char *path, void *& NANOCLR_CLEANUP(); - if (fileHandle != NULL) + if (fileHandle != nullptr) { platform_free(fileHandle); } @@ -579,13 +579,13 @@ HRESULT FATFS_FS_Driver::FindOpen(const VOLUME_ID *volume, const char *path, voi NANOCLR_HEADER(); char normalizedPath[FS_MAX_DIRECTORY_LENGTH]; - FATFS_FindFileHandle *findHandle = NULL; + FATFS_FindFileHandle *findHandle = nullptr; FileSystemVolume *currentVolume; // allocate file handle findHandle = (FATFS_FindFileHandle *)platform_malloc(sizeof(FATFS_FindFileHandle)); - if (findHandle == NULL) + if (findHandle == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_OUT_OF_MEMORY); } @@ -618,7 +618,7 @@ HRESULT FATFS_FS_Driver::FindOpen(const VOLUME_ID *volume, const char *path, voi NANOCLR_CLEANUP(); - if (findHandle != NULL) + if (findHandle != nullptr) { platform_free(findHandle); } @@ -673,7 +673,7 @@ HRESULT FATFS_FS_Driver::FindNext(void *handle, FS_FILEINFO *fi, bool *fileFound fi->FileName = (char *)platform_malloc(fi->FileNameSize + 1); // sanity check for successfull malloc - if (fi->FileName == NULL) + if (fi->FileName == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_OUT_OF_MEMORY); } @@ -878,7 +878,7 @@ HRESULT FATFS_FS_Driver::CreateDirectory(const VOLUME_ID *volume, const char *pa // add back the '/' separator strcat(tempPath, "/"); - segment = strtok(NULL, "/"); + segment = strtok(nullptr, "/"); } // remove trailing '/' @@ -1093,7 +1093,7 @@ static FATFS *GetFatFsByVolumeId(const VOLUME_ID *volumeId, bool assignVolume) } } - return NULL; + return nullptr; } static void FreeFatFsByVolumeId(const VOLUME_ID *volumeId) diff --git a/targets/ChibiOS/_common/targetHAL_ConfigurationManager.cpp b/targets/ChibiOS/_common/targetHAL_ConfigurationManager.cpp index 1649fdef6f..ee2567af7d 100644 --- a/targets/ChibiOS/_common/targetHAL_ConfigurationManager.cpp +++ b/targets/ChibiOS/_common/targetHAL_ConfigurationManager.cpp @@ -151,7 +151,7 @@ __nfweak bool ConfigurationManager_GetConfigurationBlock( uint32_t configurationIndex) { int sizeOfBlock = 0; - uint8_t *blockAddress = NULL; + uint8_t *blockAddress = nullptr; // validate if the requested block exists // Count has to be non zero @@ -242,7 +242,7 @@ __nfweak bool ConfigurationManager_StoreConfigurationBlock( if (configuration == DeviceConfigurationOption_Network) { - if (g_TargetConfiguration.NetworkInterfaceConfigs == NULL || + if (g_TargetConfiguration.NetworkInterfaceConfigs == nullptr || (g_TargetConfiguration.NetworkInterfaceConfigs->Count == 0 && configurationIndex == 0)) { // there is no network config block, we are storing the default one @@ -274,7 +274,7 @@ __nfweak bool ConfigurationManager_StoreConfigurationBlock( } else if (configuration == DeviceConfigurationOption_Wireless80211Network) { - if (g_TargetConfiguration.Wireless80211Configs == NULL || + if (g_TargetConfiguration.Wireless80211Configs == nullptr || (g_TargetConfiguration.Wireless80211Configs->Count == 0 || (configurationIndex + 1) > g_TargetConfiguration.Wireless80211Configs->Count)) { @@ -316,7 +316,7 @@ __nfweak bool ConfigurationManager_StoreConfigurationBlock( (ByteAddress)g_TargetConfiguration.CertificateStore->Certificates[configurationIndex] + offset; } - if (g_TargetConfiguration.CertificateStore == NULL || + if (g_TargetConfiguration.CertificateStore == nullptr || (g_TargetConfiguration.CertificateStore->Count == 0 || (configurationIndex + 1) > g_TargetConfiguration.CertificateStore->Count)) { @@ -329,7 +329,7 @@ __nfweak bool ConfigurationManager_StoreConfigurationBlock( } // now check if memory is erase, so the block can be stored - if (!STM32FlashDriver_IsBlockErased(NULL, storageAddress, blockSize)) + if (!STM32FlashDriver_IsBlockErased(nullptr, storageAddress, blockSize)) { // memory not erased, can't store return FALSE; @@ -366,7 +366,7 @@ __nfweak bool ConfigurationManager_StoreConfigurationBlock( (ByteAddress)g_TargetConfiguration.DeviceCertificates->Certificates[configurationIndex] + offset; } - if (g_TargetConfiguration.DeviceCertificates == NULL || + if (g_TargetConfiguration.DeviceCertificates == nullptr || (g_TargetConfiguration.DeviceCertificates->Count == 0 || (configurationIndex + 1) > g_TargetConfiguration.DeviceCertificates->Count)) { @@ -379,7 +379,7 @@ __nfweak bool ConfigurationManager_StoreConfigurationBlock( } // now check if memory is erase, so the block can be stored - if (!STM32FlashDriver_IsBlockErased(NULL, storageAddress, blockSize)) + if (!STM32FlashDriver_IsBlockErased(nullptr, storageAddress, blockSize)) { // memory not erased, can't store return FALSE; @@ -410,7 +410,7 @@ __nfweak bool ConfigurationManager_StoreConfigurationBlock( } // copy the config block content to the config block storage - success = STM32FlashDriver_Write(NULL, storageAddress, blockSize, (unsigned char *)configurationBlock, true); + success = STM32FlashDriver_Write(nullptr, storageAddress, blockSize, (unsigned char *)configurationBlock, true); // enumeration is required after we are DONE with SUCCESSFULLY storing all the config chunks requiresEnumeration = (success && done); @@ -451,7 +451,7 @@ __nfweak UpdateConfigurationResult ConfigurationManager_UpdateConfigurationBlock // allocate memory from CRT heap uint8_t *configSectorCopy = (uint8_t *)platform_malloc(sizeOfConfigSector); - if (configSectorCopy != NULL) + if (configSectorCopy != nullptr) { // copy config sector from flash to RAM memcpy(configSectorCopy, &__nanoConfig_start__, sizeOfConfigSector); @@ -589,7 +589,7 @@ __nfweak UpdateConfigurationResult ConfigurationManager_UpdateConfigurationBlock } // erase config sector - if (STM32FlashDriver_EraseBlock(NULL, (uint32_t)&__nanoConfig_start__) == TRUE) + if (STM32FlashDriver_EraseBlock(nullptr, (uint32_t)&__nanoConfig_start__) == TRUE) { // flash block is erased @@ -604,7 +604,7 @@ __nfweak UpdateConfigurationResult ConfigurationManager_UpdateConfigurationBlock // copy the config block copy back to the config block storage if (STM32FlashDriver_Write( - NULL, + nullptr, (uint32_t)&__nanoConfig_start__, sizeOfConfigSector, (unsigned char *)configSectorCopy, diff --git a/targets/ChibiOS/_common/targetHAL_StorageOperation.cpp b/targets/ChibiOS/_common/targetHAL_StorageOperation.cpp index 9a95e36202..0cfa6925ee 100644 --- a/targets/ChibiOS/_common/targetHAL_StorageOperation.cpp +++ b/targets/ChibiOS/_common/targetHAL_StorageOperation.cpp @@ -24,7 +24,7 @@ int create_directories(lfs_t *lfs, const char *path) { char temp[256]; - char *pos = NULL; + char *pos = nullptr; size_t len = 0; int res = 0; @@ -70,7 +70,7 @@ uint32_t HAL_StorageOperation( (void)offset; lfs_file_t lfsFile; - lfs_t *lfsDrive = NULL; + lfs_t *lfsDrive = nullptr; // default to drive 0 int32_t driveIndex = 0; @@ -86,7 +86,7 @@ uint32_t HAL_StorageOperation( char *storageName = (char *)platform_malloc(nameLength + 1); // sanity check for successfull malloc - if (storageName == NULL) + if (storageName == nullptr) { return StorageOperationErrorCode::PlatformError; } @@ -108,7 +108,7 @@ uint32_t HAL_StorageOperation( char dir_path[256]; snprintf(dir_path, sizeof(dir_path), "%s", storageName); char *last_slash = strrchr(dir_path, '/'); - if (last_slash != NULL) + if (last_slash != nullptr) { *last_slash = '\0'; } @@ -181,7 +181,7 @@ uint32_t HAL_StorageOperation( done: // free buffer memory - if (storageName != NULL) + if (storageName != nullptr) { platform_free(storageName); } diff --git a/targets/ChibiOS/_littlefs/littlefs_FS_Driver.cpp b/targets/ChibiOS/_littlefs/littlefs_FS_Driver.cpp index 0eaada5450..26071ac09b 100644 --- a/targets/ChibiOS/_littlefs/littlefs_FS_Driver.cpp +++ b/targets/ChibiOS/_littlefs/littlefs_FS_Driver.cpp @@ -76,8 +76,8 @@ HRESULT LITTLEFS_FS_Driver::Format(const VOLUME_ID *volume, const char *volumeLa (void)volumeLabel; (void)parameters; - LITTLEFS_FileHandle *fileHandle = NULL; - uint8_t *index = NULL; + LITTLEFS_FileHandle *fileHandle = nullptr; + uint8_t *index = nullptr; // get littlefs instance fileHandle->fs = hal_lfs_get_fs_from_index(volume->volumeId); @@ -100,7 +100,7 @@ HRESULT LITTLEFS_FS_Driver::GetSizeInfo(const VOLUME_ID *volume, int64_t *totalS NANOCLR_HEADER(); lfs_ssize_t allocBlocks; - LITTLEFS_FileHandle *fileHandle = NULL; + LITTLEFS_FileHandle *fileHandle = nullptr; // get littlefs instance fileHandle->fs = hal_lfs_get_fs_from_index(volume->volumeId); @@ -173,7 +173,7 @@ HRESULT LITTLEFS_FS_Driver::Open(const VOLUME_ID *volume, const char *path, void int32_t result; #endif - LITTLEFS_FileHandle *fileHandle = NULL; + LITTLEFS_FileHandle *fileHandle = nullptr; lfs_info info; int32_t flags; char normalizedPath[FS_MAX_DIRECTORY_LENGTH]; @@ -182,7 +182,7 @@ HRESULT LITTLEFS_FS_Driver::Open(const VOLUME_ID *volume, const char *path, void // allocate file handle fileHandle = (LITTLEFS_FileHandle *)platform_malloc(sizeof(LITTLEFS_FileHandle)); - if (fileHandle == NULL) + if (fileHandle == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_OUT_OF_MEMORY); } @@ -225,7 +225,7 @@ HRESULT LITTLEFS_FS_Driver::Open(const VOLUME_ID *volume, const char *path, void fileHandle->nanoAttributes = FileAttributes_Normal; fileHandle->attr = {NANO_LITTLEFS_ATTRIBUTE, &fileHandle->nanoAttributes, NANO_LITTLEFS_ATTRIBUTE_SIZE}; fileHandle->fileConfig = { - .buffer = NULL, + .buffer = nullptr, .attrs = &fileHandle->attr, .attr_count = 1, }; @@ -265,7 +265,7 @@ HRESULT LITTLEFS_FS_Driver::Open(const VOLUME_ID *volume, const char *path, void NANOCLR_CLEANUP(); - if (fileHandle != NULL) + if (fileHandle != nullptr) { platform_free(fileHandle); } @@ -541,12 +541,12 @@ HRESULT LITTLEFS_FS_Driver::FindOpen(const VOLUME_ID *volume, const char *path, NANOCLR_HEADER(); char normalizedPath[FS_MAX_DIRECTORY_LENGTH]; - LITTLEFS_FindFileHandle *findHandle = NULL; + LITTLEFS_FindFileHandle *findHandle = nullptr; // allocate file handle findHandle = (LITTLEFS_FindFileHandle *)platform_malloc(sizeof(LITTLEFS_FindFileHandle)); - if (findHandle == NULL) + if (findHandle == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_OUT_OF_MEMORY); } @@ -585,7 +585,7 @@ HRESULT LITTLEFS_FS_Driver::FindOpen(const VOLUME_ID *volume, const char *path, NANOCLR_CLEANUP(); - if (findHandle != NULL) + if (findHandle != nullptr) { platform_free(findHandle); } @@ -646,7 +646,7 @@ HRESULT LITTLEFS_FS_Driver::FindNext(void *handle, FS_FILEINFO *fi, bool *fileFo fi->FileName = (char *)platform_malloc(fi->FileNameSize + 1); // sanity check for successfull malloc - if (fi->FileName == NULL) + if (fi->FileName == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_OUT_OF_MEMORY); } @@ -677,7 +677,7 @@ HRESULT LITTLEFS_FS_Driver::FindClose(void *handle) { findHandle = (LITTLEFS_FindFileHandle *)handle; - if (findHandle->fs != NULL) + if (findHandle->fs != nullptr) { lfs_dir_close(findHandle->fs, &findHandle->dir); @@ -690,7 +690,7 @@ HRESULT LITTLEFS_FS_Driver::FindClose(void *handle) HRESULT LITTLEFS_FS_Driver::GetFileInfo(const VOLUME_ID *volume, const char *path, FS_FILEINFO *fileInfo, bool *found) { - lfs_t *fsDrive = NULL; + lfs_t *fsDrive = nullptr; lfs_info info; char normalizedPath[FS_MAX_DIRECTORY_LENGTH]; @@ -748,7 +748,7 @@ HRESULT LITTLEFS_FS_Driver::GetAttributes(const VOLUME_ID *volume, const char *p { NANOCLR_HEADER(); - lfs_t *fsDrive = NULL; + lfs_t *fsDrive = nullptr; lfs_info info; int32_t result; char normalizedPath[FS_MAX_DIRECTORY_LENGTH]; @@ -835,7 +835,7 @@ HRESULT LITTLEFS_FS_Driver::GetAttributes(const VOLUME_ID *volume, const char *p HRESULT LITTLEFS_FS_Driver::SetAttributes(const VOLUME_ID *volume, const char *path, uint32_t attributes) { - lfs_t *fsDrive = NULL; + lfs_t *fsDrive = nullptr; lfs_info info; uint32_t currentAttributes; char normalizedPath[FS_MAX_DIRECTORY_LENGTH]; @@ -892,7 +892,7 @@ HRESULT LITTLEFS_FS_Driver::SetAttributes(const VOLUME_ID *volume, const char *p HRESULT LITTLEFS_FS_Driver::CreateDirectory(const VOLUME_ID *volume, const char *path) { - lfs_t *fsDrive = NULL; + lfs_t *fsDrive = nullptr; int32_t result = LFS_ERR_OK; char normalizedPath[FS_MAX_DIRECTORY_LENGTH]; char tempPath[FS_MAX_DIRECTORY_LENGTH + 1]; @@ -932,7 +932,7 @@ HRESULT LITTLEFS_FS_Driver::CreateDirectory(const VOLUME_ID *volume, const char // add back the '/' separator strcat(tempPath, "/"); - segment = strtok(NULL, "/"); + segment = strtok(nullptr, "/"); } // remove trailing '/' @@ -978,7 +978,7 @@ HRESULT LITTLEFS_FS_Driver::CreateDirectory(const VOLUME_ID *volume, const char HRESULT LITTLEFS_FS_Driver::Move(const VOLUME_ID *volume, const char *oldPath, const char *newPath) { - lfs_t *fsDrive = NULL; + lfs_t *fsDrive = nullptr; char normalizedNewPath[FS_MAX_DIRECTORY_LENGTH]; char normalizedOldPath[FS_MAX_DIRECTORY_LENGTH]; int32_t result = LFS_ERR_OK; @@ -1022,7 +1022,7 @@ HRESULT LITTLEFS_FS_Driver::Move(const VOLUME_ID *volume, const char *oldPath, c HRESULT LITTLEFS_FS_Driver::Delete(const VOLUME_ID *volume, const char *path, bool recursive) { - lfs_t *fsDrive = NULL; + lfs_t *fsDrive = nullptr; lfs_info info; char normalizedPath[FS_MAX_DIRECTORY_LENGTH]; int32_t result; diff --git a/targets/ChibiOS/_nanoCLR/System.Device.Adc/sys_dev_adc_native_System_Device_Adc_AdcChannel.cpp b/targets/ChibiOS/_nanoCLR/System.Device.Adc/sys_dev_adc_native_System_Device_Adc_AdcChannel.cpp index dc28629d83..e18a848195 100644 --- a/targets/ChibiOS/_nanoCLR/System.Device.Adc/sys_dev_adc_native_System_Device_Adc_AdcChannel.cpp +++ b/targets/ChibiOS/_nanoCLR/System.Device.Adc/sys_dev_adc_native_System_Device_Adc_AdcChannel.cpp @@ -34,9 +34,9 @@ HRESULT Library_sys_dev_adc_native_System_Device_Adc_AdcChannel::NativeReadValue ADCConversionGroup adcgrpcfg1; bool enableVref; - ADCDriver *adcDriver = NULL; + ADCDriver *adcDriver = nullptr; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -97,8 +97,8 @@ HRESULT Library_sys_dev_adc_native_System_Device_Adc_AdcChannel::NativeReadValue adcgrpcfg1 = { FALSE, 1, - NULL, - NULL, // replace with adcerrorcallback if required for debug + nullptr, + nullptr, // replace with adcerrorcallback if required for debug 0, /* CR1 */ ADC_CR2_SWSTART, /* CR2 */ ADC_SMPR1_SMP_AN11(ADC_SAMPLE_3), /* SMPR1 */ diff --git a/targets/ChibiOS/_nanoCLR/System.Device.Adc/sys_dev_adc_native_System_Device_Adc_AdcController.cpp b/targets/ChibiOS/_nanoCLR/System.Device.Adc/sys_dev_adc_native_System_Device_Adc_AdcController.cpp index ada26de852..52397d47fd 100644 --- a/targets/ChibiOS/_nanoCLR/System.Device.Adc/sys_dev_adc_native_System_Device_Adc_AdcController.cpp +++ b/targets/ChibiOS/_nanoCLR/System.Device.Adc/sys_dev_adc_native_System_Device_Adc_AdcController.cpp @@ -14,9 +14,9 @@ HRESULT Library_sys_dev_adc_native_System_Device_Adc_AdcController::NativeOpenCh int channel; NF_PAL_ADC_PORT_PIN_CHANNEL adcDefinition; - ADCDriver *adcDriver = NULL; + ADCDriver *adcDriver = nullptr; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -62,13 +62,13 @@ HRESULT Library_sys_dev_adc_native_System_Device_Adc_AdcController::NativeOpenCh NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER); } - if (adcDefinition.portId != NULL) + if (adcDefinition.portId != nullptr) { palSetGroupMode(adcDefinition.portId, PAL_PORT_BIT(adcDefinition.pin), 0, PAL_MODE_INPUT_ANALOG); } // start ADC - adcStart(adcDriver, NULL); + adcStart(adcDriver, nullptr); NANOCLR_NOCLEANUP(); } diff --git a/targets/ChibiOS/_nanoCLR/System.Device.Dac/sys_dev_dac_native_System_Device_Dac_DacChannel.cpp b/targets/ChibiOS/_nanoCLR/System.Device.Dac/sys_dev_dac_native_System_Device_Dac_DacChannel.cpp index 566b75b5fb..756c9430c6 100644 --- a/targets/ChibiOS/_nanoCLR/System.Device.Dac/sys_dev_dac_native_System_Device_Dac_DacChannel.cpp +++ b/targets/ChibiOS/_nanoCLR/System.Device.Dac/sys_dev_dac_native_System_Device_Dac_DacChannel.cpp @@ -26,7 +26,7 @@ HRESULT Library_sys_dev_dac_native_System_Device_Dac_DacChannel::NativeWriteValu { NANOCLR_HEADER(); - CLR_RT_HeapBlock *dacController = NULL; + CLR_RT_HeapBlock *dacController = nullptr; // we are filling this below with the appropriate DAC port pin config and DAC driver NF_PAL_DAC_PORT_PIN_CHANNEL dacDefinition; @@ -39,7 +39,7 @@ HRESULT Library_sys_dev_dac_native_System_Device_Dac_DacChannel::NativeWriteValu // assign the value to the buffer sample = (dacsample_t)stack.Arg1().NumericByRef().u2; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -111,7 +111,7 @@ HRESULT Library_sys_dev_dac_native_System_Device_Dac_DacChannel::NativeDispose__ int channelNumber; bool disposeController = false; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); diff --git a/targets/ChibiOS/_nanoCLR/System.Device.Dac/sys_dev_dac_native_System_Device_Dac_DacController.cpp b/targets/ChibiOS/_nanoCLR/System.Device.Dac/sys_dev_dac_native_System_Device_Dac_DacController.cpp index 6fddb94c65..8d681a7d75 100644 --- a/targets/ChibiOS/_nanoCLR/System.Device.Dac/sys_dev_dac_native_System_Device_Dac_DacController.cpp +++ b/targets/ChibiOS/_nanoCLR/System.Device.Dac/sys_dev_dac_native_System_Device_Dac_DacController.cpp @@ -35,7 +35,7 @@ HRESULT Library_sys_dev_dac_native_System_Device_Dac_DacController::NativeOpenCh // Get channel from argument int channel = stack.Arg1().NumericByRef().s4; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -97,7 +97,7 @@ HRESULT Library_sys_dev_dac_native_System_Device_Dac_DacController::NativeOpenCh // start DAC driver if it's not already started if (palDac->Driver->state < DAC_READY) { - if (dacDefinition.portId != NULL) + if (dacDefinition.portId != nullptr) { palSetPadMode(dacDefinition.portId, dacDefinition.pin, PAL_MODE_INPUT_ANALOG); } @@ -160,7 +160,7 @@ HRESULT Library_sys_dev_dac_native_System_Device_Dac_DacController::NativeInit__ int controllerId; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); diff --git a/targets/ChibiOS/_nanoCLR/System.Device.Gpio/cpu_gpio.cpp b/targets/ChibiOS/_nanoCLR/System.Device.Gpio/cpu_gpio.cpp index 68456d251d..d886bf1a04 100644 --- a/targets/ChibiOS/_nanoCLR/System.Device.Gpio/cpu_gpio.cpp +++ b/targets/ChibiOS/_nanoCLR/System.Device.Gpio/cpu_gpio.cpp @@ -103,17 +103,17 @@ static void GpioEventCallback(void *arg) } // Get pointer to gpio_input_state for Gpio pin -// return NULL if not found +// return nullptr if not found gpio_input_state *GetInputState(GPIO_PIN pinNumber) { gpio_input_state *ptr = gpioInputList.FirstNode(); - while (ptr->Next() != NULL) + while (ptr->Next() != nullptr) { if (ptr->pinNumber == pinNumber) return ptr; ptr = ptr->Next(); } - return NULL; + return nullptr; } // Allocate a new gpio_input_state and add to end of list @@ -122,12 +122,12 @@ gpio_input_state *AllocateGpioInputState(GPIO_PIN pinNumber) { gpio_input_state *ptr = GetInputState(pinNumber); - if (ptr == NULL) + if (ptr == nullptr) { ptr = (gpio_input_state *)platform_malloc(sizeof(gpio_input_state)); // sanity check - if (ptr != NULL) + if (ptr != nullptr) { memset(ptr, 0, sizeof(gpio_input_state)); ptr->pinNumber = pinNumber; @@ -276,7 +276,7 @@ bool CPU_GPIO_EnableInputPin( // Link ISR ptr supplied and not already set up // CPU_GPIO_EnableInputPin could be called a 2nd time with changed parameters - if (pinISR != NULL && (pState->isrPtr == NULL)) + if (pinISR != nullptr && (pState->isrPtr == nullptr)) { // there are callbacks registered and... // the drive mode is input so need to setup the interrupt @@ -313,7 +313,7 @@ bool CPU_GPIO_EnableInputPin( break; } } - else if (pinISR == NULL && (pState->isrPtr != NULL)) + else if (pinISR == nullptr && (pState->isrPtr != nullptr)) { // there is no managed handler setup anymore @@ -322,9 +322,9 @@ bool CPU_GPIO_EnableInputPin( palDisableLineEvent(GetIoLine(pState->pinNumber)); // clear parameters & configs - pState->isrPtr = NULL; + pState->isrPtr = nullptr; pState->mode = GPIO_INT_NONE; - pState->param = NULL; + pState->param = nullptr; pState->debounceMs = 0; } diff --git a/targets/ChibiOS/_nanoCLR/System.Device.I2c/sys_dev_i2c_native_System_Device_I2c_I2cDevice.cpp b/targets/ChibiOS/_nanoCLR/System.Device.I2c/sys_dev_i2c_native_System_Device_I2c_I2cDevice.cpp index 573cca595c..c826100089 100644 --- a/targets/ChibiOS/_nanoCLR/System.Device.I2c/sys_dev_i2c_native_System_Device_I2c_I2cDevice.cpp +++ b/targets/ChibiOS/_nanoCLR/System.Device.I2c/sys_dev_i2c_native_System_Device_I2c_I2cDevice.cpp @@ -117,7 +117,7 @@ static THD_FUNCTION(I2CWorkingThread, arg) palI2c->Address, palI2c->WriteBuffer, palI2c->WriteSize, - NULL, + nullptr, 0, TIME_MS2I(estimatedDurationMiliseconds)); } @@ -146,11 +146,11 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice::NativeInit___VOI { NANOCLR_HEADER(); - NF_PAL_I2C *palI2c = NULL; + NF_PAL_I2C *palI2c = nullptr; CLR_RT_HeapBlock *connectionSettings; uint8_t busIndex; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -169,7 +169,7 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice::NativeInit___VOI { #if (STM32_I2C_USE_I2C1 == TRUE) case 1: - if (I2C1_PAL.Driver == NULL) + if (I2C1_PAL.Driver == nullptr) { ConfigPins_I2C1(); @@ -183,7 +183,7 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice::NativeInit___VOI #endif #if defined(STM32_I2C_USE_I2C2) && (STM32_I2C_USE_I2C2 == TRUE) case 2: - if (I2C2_PAL.Driver == NULL) + if (I2C2_PAL.Driver == nullptr) { ConfigPins_I2C2(); @@ -197,7 +197,7 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice::NativeInit___VOI #endif #if defined(STM32_I2C_USE_I2C3) && (STM32_I2C_USE_I2C3 == TRUE) case 3: - if (I2C3_PAL.Driver == NULL) + if (I2C3_PAL.Driver == nullptr) { ConfigPins_I2C3(); @@ -211,7 +211,7 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice::NativeInit___VOI #endif #if defined(STM32_I2C_USE_I2C4) && (STM32_I2C_USE_I2C4 == TRUE) case 4: - if (I2C4_PAL.Driver == NULL) + if (I2C4_PAL.Driver == nullptr) { ConfigPins_I2C4(); @@ -257,7 +257,7 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice::NativeDispose___ CLR_RT_HeapBlock *connectionSettings; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -281,7 +281,7 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice::NativeDispose___ // deactivates the I2C peripheral i2cStop(&I2CD1); // nulls driver - I2C1_PAL.Driver = NULL; + I2C1_PAL.Driver = nullptr; } break; #endif @@ -297,7 +297,7 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice::NativeDispose___ // deactivates the I2C peripheral i2cStop(&I2CD2); // nulls driver - I2C2_PAL.Driver = NULL; + I2C2_PAL.Driver = nullptr; } break; @@ -314,7 +314,7 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice::NativeDispose___ // deactivates the I2C peripheral i2cStop(&I2CD3); // nulls driver - I2C3_PAL.Driver = NULL; + I2C3_PAL.Driver = nullptr; } break; #endif @@ -330,7 +330,7 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice::NativeDispose___ // deactivates the I2C peripheral i2cStop(&I2CD4); // nulls driver - I2C4_PAL.Driver = NULL; + I2C4_PAL.Driver = nullptr; } break; #endif @@ -350,7 +350,7 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice:: NANOCLR_HEADER(); uint8_t busIndex; - NF_PAL_I2C *palI2c = NULL; + NF_PAL_I2C *palI2c = nullptr; bool isLongRunningOperation = false; msg_t transactionResult = MSG_OK; @@ -363,12 +363,12 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice:: CLR_RT_HeapBlock *writeSpanByte; CLR_RT_HeapBlock *readSpanByte; CLR_RT_HeapBlock *connectionSettings; - CLR_RT_HeapBlock_Array *writeBuffer = NULL; - CLR_RT_HeapBlock_Array *readBuffer = NULL; + CLR_RT_HeapBlock_Array *writeBuffer = nullptr; + CLR_RT_HeapBlock_Array *readBuffer = nullptr; int readOffset = 0; int writeOffset = 0; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -409,11 +409,11 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice:: // dereference the write and read SpanByte from the arguments writeSpanByte = stack.Arg1().Dereference(); - if (writeSpanByte != NULL) + if (writeSpanByte != nullptr) { // get buffer writeBuffer = writeSpanByte[SpanByte::FIELD___array].DereferenceArray(); - if (writeBuffer != NULL) + if (writeBuffer != nullptr) { // Get the write offset, only the elements defined by the span must be written, not the whole array writeOffset = writeSpanByte[SpanByte::FIELD___start].NumericByRef().s4; @@ -426,18 +426,18 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice:: } } - if (writeBuffer == NULL) + if (writeBuffer == nullptr) { // nothing to write, have to zero this palI2c->WriteSize = 0; } readSpanByte = stack.Arg2().Dereference(); - if (readSpanByte != NULL) + if (readSpanByte != nullptr) { // get buffer readBuffer = readSpanByte[SpanByte::FIELD___array].DereferenceArray(); - if (readBuffer != NULL) + if (readBuffer != nullptr) { // Get the read offset, only the elements defined by the span must be read, not the whole array readOffset = readSpanByte[SpanByte::FIELD___start].NumericByRef().s4; @@ -450,7 +450,7 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice:: } } - if (readBuffer == NULL) + if (readBuffer == nullptr) { // nothing to read, have to zero this palI2c->ReadSize = 0; @@ -483,7 +483,7 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice:: palI2c->Driver->addr = palI2c->Address; #endif - if (writeBuffer != NULL) + if (writeBuffer != nullptr) { // grab the pointer to the array by starting and the offset specified in the span palI2c->WriteBuffer = (uint8_t *)writeBuffer->GetElement(writeOffset); @@ -493,7 +493,7 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice:: cacheBufferFlush(palI2c->WriteBuffer, palI2c->WriteSize); } - if (readBuffer != NULL) + if (readBuffer != nullptr) { // grab the pointer to the array by starting and the offset specified in the span palI2c->ReadBuffer = (uint8_t *)readBuffer->GetElement(readOffset); @@ -512,9 +512,9 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice:: { // spawn working thread to perform the I2C transaction palI2c->WorkingThread = - chThdCreateFromHeap(NULL, THD_WORKING_AREA_SIZE(256), "I2CWT", NORMALPRIO, I2CWorkingThread, palI2c); + chThdCreateFromHeap(nullptr, THD_WORKING_AREA_SIZE(256), "I2CWT", NORMALPRIO, I2CWorkingThread, palI2c); - if (palI2c->WorkingThread == NULL) + if (palI2c->WorkingThread == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_PROCESS_EXCEPTION); } @@ -550,7 +550,7 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice:: palI2c->Address, palI2c->WriteBuffer, palI2c->WriteSize, - NULL, + nullptr, 0, TIME_MS2I(20)); } @@ -604,7 +604,7 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice:: // managed stack CLR_RT_HeapBlock &top = stack.PushValueAndClear(); NANOCLR_CHECK_HRESULT( - g_CLR_RT_ExecutionEngine.NewObjectFromIndex(top, g_CLR_RT_WellKnownTypes.m_I2cTransferResult)); + g_CLR_RT_ExecutionEngine.NewObjectFromIndex(top, g_CLR_RT_WellKnownTypes.I2cTransferResult)); result = top.Dereference(); FAULT_ON_NULL(result); @@ -666,12 +666,12 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice:: if (hr != CLR_E_THREAD_WAITING) { // un-pin the buffers - if (writeBuffer != NULL && writeBuffer->IsPinned()) + if (writeBuffer != nullptr && writeBuffer->IsPinned()) { writeBuffer->Unpin(); } - if (readBuffer != NULL && readBuffer->IsPinned()) + if (readBuffer != nullptr && readBuffer->IsPinned()) { readBuffer->Unpin(); } diff --git a/targets/ChibiOS/_nanoCLR/System.Device.Pwm/sys_dev_pwm_native_System_Device_Pwm_PwmChannel.cpp b/targets/ChibiOS/_nanoCLR/System.Device.Pwm/sys_dev_pwm_native_System_Device_Pwm_PwmChannel.cpp index e561d827c2..ea01364a1e 100644 --- a/targets/ChibiOS/_nanoCLR/System.Device.Pwm/sys_dev_pwm_native_System_Device_Pwm_PwmChannel.cpp +++ b/targets/ChibiOS/_nanoCLR/System.Device.Pwm/sys_dev_pwm_native_System_Device_Pwm_PwmChannel.cpp @@ -826,7 +826,7 @@ int GetAlternateFunctionPwm(int timerId) PWMDriver *GetDriverPwm(int timerId) { - PWMDriver *pwmDriver = NULL; + PWMDriver *pwmDriver = nullptr; switch (timerId) { @@ -897,7 +897,7 @@ HRESULT Library_sys_dev_pwm_native_System_Device_Pwm_PwmChannel::NativeSetDesire NANOCLR_HEADER(); - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -933,12 +933,12 @@ HRESULT Library_sys_dev_pwm_native_System_Device_Pwm_PwmChannel::NativeSetDesire // PWM period (pwmcnt_t)period, // No callback - NULL, + nullptr, // Enable all channels - {{PWM_OUTPUT_ACTIVE_HIGH, NULL}, - {PWM_OUTPUT_ACTIVE_HIGH, NULL}, - {PWM_OUTPUT_ACTIVE_HIGH, NULL}, - {PWM_OUTPUT_ACTIVE_HIGH, NULL}}, + {{PWM_OUTPUT_ACTIVE_HIGH, nullptr}, + {PWM_OUTPUT_ACTIVE_HIGH, nullptr}, + {PWM_OUTPUT_ACTIVE_HIGH, nullptr}, + {PWM_OUTPUT_ACTIVE_HIGH, nullptr}}, 0, #if STM32_PWM_USE_ADVANCED 0, @@ -970,7 +970,7 @@ HRESULT Library_sys_dev_pwm_native_System_Device_Pwm_PwmChannel::NativeSetActive NANOCLR_HEADER(); - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -1009,7 +1009,7 @@ HRESULT Library_sys_dev_pwm_native_System_Device_Pwm_PwmChannel::NativeStart___V NANOCLR_HEADER(); - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -1038,7 +1038,7 @@ HRESULT Library_sys_dev_pwm_native_System_Device_Pwm_PwmChannel::NativeStop___VO NANOCLR_HEADER(); - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); diff --git a/targets/ChibiOS/_nanoCLR/System.Device.Spi/cpu_spi.cpp b/targets/ChibiOS/_nanoCLR/System.Device.Spi/cpu_spi.cpp index 90c8fd263f..b50cc952be 100644 --- a/targets/ChibiOS/_nanoCLR/System.Device.Spi/cpu_spi.cpp +++ b/targets/ChibiOS/_nanoCLR/System.Device.Spi/cpu_spi.cpp @@ -70,7 +70,7 @@ static void SpiCallback(SPIDriver *spip) NATIVE_INTERRUPT_START - NF_PAL_SPI *palSpi = NULL; + NF_PAL_SPI *palSpi = nullptr; // Find the NF_PAL_SPI * for driver #if STM32_SPI_USE_SPI1 @@ -245,10 +245,10 @@ uint16_t ComputeBaudRate(SPI_DEVICE_CONFIGURATION &config, int32_t &actualFreque } // Return the NF_PAL structure for busIndex -// Return NULL is invalid bus +// Return nullptr is invalid bus NF_PAL_SPI *GetNfPalfromBusIndex(uint8_t busIndex) { - NF_PAL_SPI *palSpi = NULL; + NF_PAL_SPI *palSpi = nullptr; // get the PAL struct for the SPI bus // bus index is 0 based, here it's 1 based @@ -415,12 +415,12 @@ HRESULT CPU_SPI_nWrite_nRead( // Callback sync / async palSpi->Callback = wrc.callback; - if (writeBuffer != NULL) + if (writeBuffer != nullptr) { palSpi->WriteSize = writeSize; } - if (readBuffer != NULL) + if (readBuffer != nullptr) { palSpi->ReadSize = readSize; } @@ -437,10 +437,10 @@ HRESULT CPU_SPI_nWrite_nRead( // Clear callback if sync if (sync) { - palSpi->Configuration.data_cb = NULL; + palSpi->Configuration.data_cb = nullptr; } - if (writeBuffer != NULL) + if (writeBuffer != nullptr) { // set the pointer to the write buffer as BYTE palSpi->WriteBuffer = (uint8_t *)writeBuffer; @@ -460,7 +460,7 @@ HRESULT CPU_SPI_nWrite_nRead( } } - if (readBuffer != NULL) + if (readBuffer != nullptr) { // set DMA read buffer if (palSpi->ReadSize > 0) @@ -673,7 +673,7 @@ bool CPU_SPI_Initialize(uint8_t busIndex, const SPI_DEVICE_CONFIGURATION &spiDev { #if STM32_SPI_USE_SPI1 case 1: - if (SPI1_PAL.Driver == NULL) + if (SPI1_PAL.Driver == nullptr) { ConfigPins_SPI1(spiDeviceConfig); SPI1_PAL.Driver = &SPID1; @@ -683,7 +683,7 @@ bool CPU_SPI_Initialize(uint8_t busIndex, const SPI_DEVICE_CONFIGURATION &spiDev #endif #if STM32_SPI_USE_SPI2 case 2: - if (SPI2_PAL.Driver == NULL) + if (SPI2_PAL.Driver == nullptr) { ConfigPins_SPI2(spiDeviceConfig); SPI2_PAL.Driver = &SPID2; @@ -693,7 +693,7 @@ bool CPU_SPI_Initialize(uint8_t busIndex, const SPI_DEVICE_CONFIGURATION &spiDev #endif #if STM32_SPI_USE_SPI3 case 3: - if (SPI3_PAL.Driver == NULL) + if (SPI3_PAL.Driver == nullptr) { ConfigPins_SPI3(spiDeviceConfig); SPI3_PAL.Driver = &SPID3; @@ -703,7 +703,7 @@ bool CPU_SPI_Initialize(uint8_t busIndex, const SPI_DEVICE_CONFIGURATION &spiDev #endif #if STM32_SPI_USE_SPI4 case 4: - if (SPI4_PAL.Driver == NULL) + if (SPI4_PAL.Driver == nullptr) { ConfigPins_SPI4(spiDeviceConfig); SPI4_PAL.Driver = &SPID4; @@ -713,7 +713,7 @@ bool CPU_SPI_Initialize(uint8_t busIndex, const SPI_DEVICE_CONFIGURATION &spiDev #endif #if STM32_SPI_USE_SPI5 case 5: - if (SPI5_PAL.Driver == NULL) + if (SPI5_PAL.Driver == nullptr) { ConfigPins_SPI5(spiDeviceConfig); SPI5_PAL.Driver = &SPID5; @@ -723,7 +723,7 @@ bool CPU_SPI_Initialize(uint8_t busIndex, const SPI_DEVICE_CONFIGURATION &spiDev #endif #if STM32_SPI_USE_SPI6 case 6: - if (SPI6_PAL.Driver == NULL) + if (SPI6_PAL.Driver == nullptr) { ConfigPins_SPI6(spiDeviceConfig); SPI6_PAL.Driver = &SPID6; @@ -748,7 +748,7 @@ bool CPU_SPI_Uninitialize(uint8_t busIndex) #if STM32_SPI_USE_SPI1 case 1: spiStop(&SPID1); - SPI1_PAL.Driver = NULL; + SPI1_PAL.Driver = nullptr; spiReleaseBus(&SPID1); break; #endif @@ -756,7 +756,7 @@ bool CPU_SPI_Uninitialize(uint8_t busIndex) #if STM32_SPI_USE_SPI2 case 2: spiStop(&SPID2); - SPI2_PAL.Driver = NULL; + SPI2_PAL.Driver = nullptr; spiReleaseBus(&SPID2); break; #endif @@ -764,7 +764,7 @@ bool CPU_SPI_Uninitialize(uint8_t busIndex) #if STM32_SPI_USE_SPI3 case 3: spiStop(&SPID3); - SPI3_PAL.Driver = NULL; + SPI3_PAL.Driver = nullptr; spiReleaseBus(&SPID3); break; #endif @@ -772,7 +772,7 @@ bool CPU_SPI_Uninitialize(uint8_t busIndex) #if STM32_SPI_USE_SPI4 case 4: spiStop(&SPID4); - SPI4_PAL.Driver = NULL; + SPI4_PAL.Driver = nullptr; spiReleaseBus(&SPID4); break; #endif @@ -780,7 +780,7 @@ bool CPU_SPI_Uninitialize(uint8_t busIndex) #if STM32_SPI_USE_SPI5 case 5: spiStop(&SPID5); - SPI5_PAL.Driver = NULL; + SPI5_PAL.Driver = nullptr; spiReleaseBus(&SPID5); break; #endif @@ -788,7 +788,7 @@ bool CPU_SPI_Uninitialize(uint8_t busIndex) #if STM32_SPI_USE_SPI6 case 6: spiStop(&SPID6); - SPI6_PAL.Driver = NULL; + SPI6_PAL.Driver = nullptr; spiReleaseBus(&SPID6); break; #endif diff --git a/targets/ChibiOS/_nanoCLR/System.IO.Ports/sys_io_ser_native_System_IO_Ports_SerialPort.cpp b/targets/ChibiOS/_nanoCLR/System.IO.Ports/sys_io_ser_native_System_IO_Ports_SerialPort.cpp index 889a7c9a78..b7496aceef 100644 --- a/targets/ChibiOS/_nanoCLR/System.IO.Ports/sys_io_ser_native_System_IO_Ports_SerialPort.cpp +++ b/targets/ChibiOS/_nanoCLR/System.IO.Ports/sys_io_ser_native_System_IO_Ports_SerialPort.cpp @@ -78,7 +78,7 @@ static NF_PAL_UART *GetUartPAL(int index) #endif default: // this COM port is not valid; - return NULL; + return nullptr; } } @@ -268,13 +268,13 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::get_BytesToRead___ NF_PAL_UART *palUart; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); // Choose the driver for this SerialDevice palUart = GetUartPAL((int)pThis[FIELD___portIndex].NumericByRef().s4); - if (palUart == NULL) + if (palUart == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER); } @@ -291,9 +291,9 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::get_InvertSignalLe #if defined(USART_CR2_TXINV) && defined(USART_CR2_RXINV) - NF_PAL_UART *palUart = NULL; + NF_PAL_UART *palUart = nullptr; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -304,7 +304,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::get_InvertSignalLe // get the driver for this SerialDevice palUart = GetUartPAL((int)pThis[FIELD___portIndex].NumericByRef().s4); - if (palUart == NULL) + if (palUart == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER); } @@ -329,9 +329,9 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::set_InvertSignalLe #if defined(USART_CR2_TXINV) && defined(USART_CR2_RXINV) - NF_PAL_UART *palUart = NULL; + NF_PAL_UART *palUart = nullptr; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -342,7 +342,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::set_InvertSignalLe // get the driver for this SerialDevice palUart = GetUartPAL((int)pThis[FIELD___portIndex].NumericByRef().s4); - if (palUart == NULL) + if (palUart == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER); } @@ -368,7 +368,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::Read___I4__SZARRAY CLR_RT_HeapBlock hbTimeout; CLR_RT_HeapBlock_Array *dataBuffer; - NF_PAL_UART *palUart = NULL; + NF_PAL_UART *palUart = nullptr; uint8_t *data; @@ -381,7 +381,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::Read___I4__SZARRAY int64_t *timeoutTicks; bool eventResult = true; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -424,7 +424,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::Read___I4__SZARRAY // Choose the driver for this SerialDevice palUart = GetUartPAL((int)pThis[FIELD___portIndex].NumericByRef().s4); - if (palUart == NULL) + if (palUart == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER); } @@ -506,14 +506,14 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::ReadExisting___STR { NANOCLR_HEADER(); - NF_PAL_UART *palUart = NULL; + NF_PAL_UART *palUart = nullptr; - uint8_t *buffer = NULL; + uint8_t *buffer = nullptr; uint32_t bufferLength; CLR_RT_HeapBlock &top = stack.PushValue(); - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -524,7 +524,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::ReadExisting___STR // Choose the driver for this SerialDevice palUart = GetUartPAL((int)pThis[FIELD___portIndex].NumericByRef().s4); - if (palUart == NULL) + if (palUart == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER); } @@ -538,7 +538,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::ReadExisting___STR buffer = (uint8_t *)platform_malloc(bufferLength); // sanity check - if (buffer == NULL) + if (buffer == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_OUT_OF_MEMORY); } @@ -551,12 +551,12 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::ReadExisting___STR else { // create an empty - NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_String::CreateInstance(top, (const char *)NULL)); + NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_String::CreateInstance(top, (const char *)nullptr)); } NANOCLR_CLEANUP(); - if (buffer != NULL) + if (buffer != nullptr) { platform_free(buffer); } @@ -569,17 +569,17 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::ReadLine___STRING( NANOCLR_HEADER(); CLR_RT_HeapBlock hbTimeout; - NF_PAL_UART *palUart = NULL; + NF_PAL_UART *palUart = nullptr; - uint8_t *line = NULL; - const char *newLine = NULL; + uint8_t *line = nullptr; + const char *newLine = nullptr; uint32_t newLineLength; int64_t *timeoutTicks; bool eventResult = true; bool newLineFound = false; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -594,7 +594,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::ReadLine___STRING( // Choose the driver for this SerialDevice palUart = GetUartPAL((int)pThis[FIELD___portIndex].NumericByRef().s4); - if (palUart == NULL) + if (palUart == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER); } @@ -616,8 +616,8 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::ReadLine___STRING( // get new line from field newLine = pThis[FIELD___newLine].RecoverString(); - // sanity check for NULL string - if (newLine == NULL) + // sanity check for nullptr string + if (newLine == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER); } @@ -665,7 +665,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::ReadLine___STRING( stack.SetResult_String((const char *)line); // free memory, if needed - if (line != NULL) + if (line != nullptr) { platform_free(line); } @@ -677,7 +677,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::Write___VOID__SZAR { NANOCLR_HEADER(); - NF_PAL_UART *palUart = NULL; + NF_PAL_UART *palUart = nullptr; CLR_RT_HeapBlock_Array *dataBuffer; CLR_RT_HeapBlock hbTimeout; @@ -689,7 +689,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::Write___VOID__SZAR int32_t count = 0; int32_t offset = 0; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -700,7 +700,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::Write___VOID__SZAR // Choose the driver for this SerialDevice palUart = GetUartPAL((int)pThis[FIELD___portIndex].NumericByRef().s4); - if (palUart == NULL) + if (palUart == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER); } @@ -792,7 +792,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::Write___VOID__SZAR stack.SetResult_U4(count); // null pointers and vars - pThis = NULL; + pThis = nullptr; NANOCLR_NOCLEANUP(); } @@ -801,7 +801,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::NativeDispose___VO { NANOCLR_HEADER(); - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -874,7 +874,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::NativeInit___VOID( int32_t bufferSize; uint8_t watchChar; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -948,7 +948,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::NativeInit___VOID( palUart->RxBuffer = (uint8_t *)platform_malloc(bufferSize); // sanity check - if (palUart->RxBuffer == NULL) + if (palUart->RxBuffer == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_OUT_OF_MEMORY); } @@ -980,15 +980,15 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::NativeConfig___VOI { NANOCLR_HEADER(); - NF_PAL_UART *palUart = NULL; + NF_PAL_UART *palUart = nullptr; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); // Choose the driver for this SerialDevice palUart = GetUartPAL((int)pThis[FIELD___portIndex].NumericByRef().s4); - if (palUart == NULL) + if (palUart == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER); } @@ -1207,7 +1207,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::NativeConfig___VOI uartStopReceive(palUart->UartDriver); // null pointers and vars - pThis = NULL; + pThis = nullptr; NANOCLR_NOCLEANUP(); } @@ -1218,13 +1218,13 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::NativeSetWatchChar NF_PAL_UART *palUart; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); // Choose the driver for this SerialDevice palUart = GetUartPAL((int)pThis[FIELD___portIndex].NumericByRef().s4); - if (palUart == NULL) + if (palUart == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER); } @@ -1240,18 +1240,18 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::NativeWriteString_ { NANOCLR_HEADER(); - NF_PAL_UART *palUart = NULL; + NF_PAL_UART *palUart = nullptr; CLR_RT_HeapBlock hbTimeout; int64_t *timeoutTicks; bool eventResult = true; bool isNewAllocation = false; - char *buffer = NULL; + char *buffer = nullptr; uint32_t bufferLength = 0; int32_t length = 0; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -1260,7 +1260,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::NativeWriteString_ NANOCLR_SET_AND_LEAVE(CLR_E_OBJECT_DISPOSED); } - if (stack.Arg1().RecoverString() == NULL) + if (stack.Arg1().RecoverString() == nullptr) { // text string it's empty so there is noting to do here stack.SetResult_U4(0); @@ -1269,7 +1269,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::NativeWriteString_ // Choose the driver for this SerialDevice palUart = GetUartPAL((int)pThis[FIELD___portIndex].NumericByRef().s4); - if (palUart == NULL) + if (palUart == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER); } @@ -1356,7 +1356,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::NativeWriteString_ } // null pointers and vars - pThis = NULL; + pThis = nullptr; NANOCLR_NOCLEANUP(); } @@ -1370,7 +1370,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::NativeReceivedByte int32_t threshold; uint8_t portIndex; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -1386,7 +1386,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::NativeReceivedByte // Choose the driver for this SerialDevice palUart = GetUartPAL(portIndex); - if (palUart == NULL) + if (palUart == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER); } diff --git a/targets/ChibiOS/_nanoCLR/System.IO.Ports/sys_io_ser_native_target.h b/targets/ChibiOS/_nanoCLR/System.IO.Ports/sys_io_ser_native_target.h index 58690f6606..c9309ebb0c 100644 --- a/targets/ChibiOS/_nanoCLR/System.IO.Ports/sys_io_ser_native_target.h +++ b/targets/ChibiOS/_nanoCLR/System.IO.Ports/sys_io_ser_native_target.h @@ -91,18 +91,18 @@ void ConfigPins_UART8(); #define UART_INIT(num) \ void Init_UART##num() \ { \ - Uart##num##_PAL.Uart_cfg.txend2_cb = NULL; \ - Uart##num##_PAL.Uart_cfg.rxend_cb = NULL; \ - Uart##num##_PAL.Uart_cfg.rxerr_cb = NULL; \ - Uart##num##_PAL.Uart_cfg.timeout_cb = NULL; \ + Uart##num##_PAL.Uart_cfg.txend2_cb = nullptr; \ + Uart##num##_PAL.Uart_cfg.rxend_cb = nullptr; \ + Uart##num##_PAL.Uart_cfg.rxerr_cb = nullptr; \ + Uart##num##_PAL.Uart_cfg.timeout_cb = nullptr; \ Uart##num##_PAL.Uart_cfg.timeout = 0; \ Uart##num##_PAL.Uart_cfg.speed = 9600; \ Uart##num##_PAL.Uart_cfg.cr1 = 0; \ Uart##num##_PAL.Uart_cfg.cr2 = 0; \ Uart##num##_PAL.Uart_cfg.cr3 = 0; \ - Uart##num##_PAL.TxBuffer = NULL; \ + Uart##num##_PAL.TxBuffer = nullptr; \ Uart##num##_PAL.TxOngoingCount = 0; \ - Uart##num##_PAL.RxBuffer = NULL; \ + Uart##num##_PAL.RxBuffer = nullptr; \ Uart##num##_PAL.WatchChar = 0; \ Uart##num##_PAL.NewLineChar = 0; \ Uart##num##_PAL.SignalLevelsInverted = false; \ @@ -114,16 +114,16 @@ void ConfigPins_UART8(); #define UART_INIT(num) \ void Init_UART##num() \ { \ - Uart##num##_PAL.Uart_cfg.txend2_cb = NULL; \ - Uart##num##_PAL.Uart_cfg.rxend_cb = NULL; \ - Uart##num##_PAL.Uart_cfg.rxerr_cb = NULL; \ + Uart##num##_PAL.Uart_cfg.txend2_cb = nullptr; \ + Uart##num##_PAL.Uart_cfg.rxend_cb = nullptr; \ + Uart##num##_PAL.Uart_cfg.rxerr_cb = nullptr; \ Uart##num##_PAL.Uart_cfg.speed = 9600; \ Uart##num##_PAL.Uart_cfg.cr1 = 0; \ Uart##num##_PAL.Uart_cfg.cr2 = 0; \ Uart##num##_PAL.Uart_cfg.cr3 = 0; \ - Uart##num##_PAL.TxBuffer = NULL; \ + Uart##num##_PAL.TxBuffer = nullptr; \ Uart##num##_PAL.TxOngoingCount = 0; \ - Uart##num##_PAL.RxBuffer = NULL; \ + Uart##num##_PAL.RxBuffer = nullptr; \ Uart##num##_PAL.WatchChar = 0; \ Uart##num##_PAL.NewLineChar = 0; \ Uart##num##_PAL.SignalLevelsInverted = false; \ @@ -149,9 +149,9 @@ void Init_UART8(); { \ uartStop(&UARTD##num); \ platform_free(Uart##num##_PAL.RxBuffer); \ - Uart##num##_PAL.TxBuffer = NULL; \ - Uart##num##_PAL.RxBuffer = NULL; \ - Uart##num##_PAL.UartDriver = NULL; \ + Uart##num##_PAL.TxBuffer = nullptr; \ + Uart##num##_PAL.RxBuffer = nullptr; \ + Uart##num##_PAL.UartDriver = nullptr; \ return; \ } diff --git a/targets/ChibiOS/_nanoCLR/nanoCRT.cpp b/targets/ChibiOS/_nanoCLR/nanoCRT.cpp index 4297bd9a2a..02457db7ad 100644 --- a/targets/ChibiOS/_nanoCLR/nanoCRT.cpp +++ b/targets/ChibiOS/_nanoCLR/nanoCRT.cpp @@ -137,7 +137,7 @@ int hal_strcpy_s(char *strDst, size_t sizeInBytes, const char *strSrc) #undef strcpy size_t len; - if (strDst == NULL || strSrc == NULL || sizeInBytes == 0) + if (strDst == nullptr || strSrc == nullptr || sizeInBytes == 0) { _ASSERTE(FALSE); return 1; @@ -160,7 +160,7 @@ int hal_strncpy_s(char *strDst, size_t sizeInBytes, const char *strSrc, size_t c { NATIVE_PROFILE_PAL_CRT(); #undef strncpy - if (strDst == NULL || strSrc == NULL || sizeInBytes == 0) + if (strDst == nullptr || strSrc == nullptr || sizeInBytes == 0) { _ASSERTE(FALSE); return 1; @@ -194,7 +194,7 @@ int hal_strncmp_s(const char *str1, const char *str2, size_t num) { NATIVE_PROFILE_PAL_CRT(); #undef strncmp - if (str1 == NULL || str2 == NULL) + if (str1 == nullptr || str2 == nullptr) { _ASSERTE(FALSE); return 1; diff --git a/targets/ChibiOS/_nanoCLR/nanoFramework.Device.Can/nf_device_can_native_nanoFramework_Device_Can_CanController.cpp b/targets/ChibiOS/_nanoCLR/nanoFramework.Device.Can/nf_device_can_native_nanoFramework_Device_Can_CanController.cpp index 470ecaef0e..e4912e6bc8 100644 --- a/targets/ChibiOS/_nanoCLR/nanoFramework.Device.Can/nf_device_can_native_nanoFramework_Device_Can_CanController.cpp +++ b/targets/ChibiOS/_nanoCLR/nanoFramework.Device.Can/nf_device_can_native_nanoFramework_Device_Can_CanController.cpp @@ -80,7 +80,7 @@ HRESULT Library_nf_device_can_native_nanoFramework_Device_Can_CanController:: CLR_RT_HeapBlock_Array *message; CANTxFrame txmsg; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); CLR_RT_HeapBlock *pMessage = stack.Arg1().Dereference(); @@ -110,7 +110,7 @@ HRESULT Library_nf_device_can_native_nanoFramework_Device_Can_CanController:: NANOCLR_SET_AND_LEAVE(CLR_E_OUT_OF_RANGE); // compose the transmit packet to send - if (message != NULL) + if (message != nullptr) { // copy message to structure memcpy(txmsg.data8, (uint8_t *)message->GetFirstElement(), message->m_numOfElements); @@ -164,14 +164,14 @@ HRESULT Library_nf_device_can_native_nanoFramework_Device_Can_CanController:: NANOCLR_HEADER(); CLR_RT_TypeDef_Index canMessageTypeDef; - CLR_RT_HeapBlock *canMessage = NULL; + CLR_RT_HeapBlock *canMessage = nullptr; CANRxFrame canFrame; NF_PAL_CAN *palCan; uint8_t controllerIndex; size_t messageCount = 0; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -253,7 +253,7 @@ HRESULT Library_nf_device_can_native_nanoFramework_Device_Can_CanController:: CLR_RT_HeapBlock &dataArrayField = canMessage[ManagedCanMessage::FIELD___message]; // create an array of NANOCLR_CHECK_HRESULT( - CLR_RT_HeapBlock_Array::CreateInstance(dataArrayField, 8, g_CLR_RT_WellKnownTypes.m_UInt8)); + CLR_RT_HeapBlock_Array::CreateInstance(dataArrayField, 8, g_CLR_RT_WellKnownTypes.UInt8)); // get a pointer to the first object in the array CLR_UINT8 *dataBuffer = (CLR_UINT8 *)(dataArrayField.DereferenceArray()->GetFirstElement()); @@ -262,7 +262,7 @@ HRESULT Library_nf_device_can_native_nanoFramework_Device_Can_CanController:: else { // no more messages, return null - stack.SetResult_Object(NULL); + stack.SetResult_Object(nullptr); } NANOCLR_NOCLEANUP(); @@ -275,7 +275,7 @@ HRESULT Library_nf_device_can_native_nanoFramework_Device_Can_CanController::Dis uint8_t controllerIndex; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -288,7 +288,7 @@ HRESULT Library_nf_device_can_native_nanoFramework_Device_Can_CanController::Dis { #if defined(STM32_CAN_USE_CAN1) && (STM32_CAN_USE_CAN1 == TRUE) case 1: - Can1_PAL.Driver = NULL; + Can1_PAL.Driver = nullptr; // stop CAN canStop(&CAND1); break; @@ -296,7 +296,7 @@ HRESULT Library_nf_device_can_native_nanoFramework_Device_Can_CanController::Dis #if (STM32_CAN_USE_CAN2) && (STM32_CAN_USE_CAN2 == TRUE) case 2: - Can2_PAL.Driver = NULL; + Can2_PAL.Driver = nullptr; // stop CAN canStop(&CAND2); break; @@ -304,7 +304,7 @@ HRESULT Library_nf_device_can_native_nanoFramework_Device_Can_CanController::Dis #if (STM32_CAN_USE_CAN3) && (STM32_CAN_USE_CAN3 == TRUE) case 3: - Can3_PAL.Driver = NULL; + Can3_PAL.Driver = nullptr; // stop CAN canStop(&CAND3); break; @@ -323,9 +323,9 @@ HRESULT Library_nf_device_can_native_nanoFramework_Device_Can_CanController::Nat { NANOCLR_HEADER(); { - NF_PAL_CAN *palCan = NULL; + NF_PAL_CAN *palCan = nullptr; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -389,7 +389,7 @@ HRESULT Library_nf_device_can_native_nanoFramework_Device_Can_CanController::Nat { NANOCLR_HEADER(); - NF_PAL_CAN *palCan = NULL; + NF_PAL_CAN *palCan = nullptr; bool callbacksRegistered; uint8_t controllerIndex; @@ -400,7 +400,7 @@ HRESULT Library_nf_device_can_native_nanoFramework_Device_Can_CanController::Nat controllerIndex = (uint8_t)(pThis[FIELD___controllerId].NumericByRef().s4); // flag to determine if there are any callbacks registered in managed code - callbacksRegistered = (pThis[FIELD___callbacks].Dereference() != NULL); + callbacksRegistered = (pThis[FIELD___callbacks].Dereference() != nullptr); switch (controllerIndex) { @@ -437,7 +437,7 @@ HRESULT Library_nf_device_can_native_nanoFramework_Device_Can_CanController::Nat else { // no one listening, OK to remove - palCan->Driver->rxfull_cb = NULL; + palCan->Driver->rxfull_cb = nullptr; } // start CAN diff --git a/targets/ChibiOS/_nanoCLR/nanoFramework.Device.OneWire/nf_dev_onewire_nanoFramework_Device_OneWire_OneWireHost.cpp b/targets/ChibiOS/_nanoCLR/nanoFramework.Device.OneWire/nf_dev_onewire_nanoFramework_Device_OneWire_OneWireHost.cpp index 14745133ae..fb003830d4 100644 --- a/targets/ChibiOS/_nanoCLR/nanoFramework.Device.OneWire/nf_dev_onewire_nanoFramework_Device_OneWire_OneWireHost.cpp +++ b/targets/ChibiOS/_nanoCLR/nanoFramework.Device.OneWire/nf_dev_onewire_nanoFramework_Device_OneWire_OneWireHost.cpp @@ -122,7 +122,7 @@ HRESULT Library_nf_dev_onewire_nanoFramework_Device_OneWire_OneWireHost::FindFir // spawn working thread to perform the 1-Wire operations OneWireWorkingThread = chThdCreateFromHeap( - NULL, + nullptr, THD_WORKING_AREA_SIZE(256), "OWWT", NORMALPRIO, @@ -161,7 +161,7 @@ HRESULT Library_nf_dev_onewire_nanoFramework_Device_OneWire_OneWireHost::FindFir { // if a device was found update serialNumber field in managed class - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -214,7 +214,7 @@ HRESULT Library_nf_dev_onewire_nanoFramework_Device_OneWire_OneWireHost::FindNex // spawn working thread to perform the 1-Wire operations OneWireWorkingThread = chThdCreateFromHeap( - NULL, + nullptr, THD_WORKING_AREA_SIZE(256), "OWWT", NORMALPRIO, @@ -253,7 +253,7 @@ HRESULT Library_nf_dev_onewire_nanoFramework_Device_OneWire_OneWireHost::FindNex { // update serialNumber field - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); diff --git a/targets/ChibiOS/_nanoCLR/nanoFramework.Hardware.Stm32/nf_hardware_stm32_native_nanoFramework_Hardware_Stm32_BackupMemory.cpp b/targets/ChibiOS/_nanoCLR/nanoFramework.Hardware.Stm32/nf_hardware_stm32_native_nanoFramework_Hardware_Stm32_BackupMemory.cpp index 44a47e0084..fc6cea1947 100644 --- a/targets/ChibiOS/_nanoCLR/nanoFramework.Hardware.Stm32/nf_hardware_stm32_native_nanoFramework_Hardware_Stm32_BackupMemory.cpp +++ b/targets/ChibiOS/_nanoCLR/nanoFramework.Hardware.Stm32/nf_hardware_stm32_native_nanoFramework_Hardware_Stm32_BackupMemory.cpp @@ -22,7 +22,7 @@ HRESULT Library_nf_hardware_stm32_native_nanoFramework_Hardware_Stm32_BackupMemo // address of bkp register 0 __IO uint32_t *baseAddress = &(RTC->BKP0R); uint8_t *storeAddress = ((uint8_t *)baseAddress + position); - uint32_t *registerAddress = NULL; + uint32_t *registerAddress = nullptr; uint32_t tempRegisterValue; uint32_t counter = 0; uint32_t remainder; @@ -128,7 +128,7 @@ HRESULT Library_nf_hardware_stm32_native_nanoFramework_Hardware_Stm32_BackupMemo // address of bkp register 0 __IO uint32_t *baseAddress = &(RTC->BKP0R); uint8_t *storeAddress = ((uint8_t *)baseAddress + position); - uint32_t *registerAddress = NULL; + uint32_t *registerAddress = nullptr; uint32_t tempRegisterValue; uint32_t counter = 0; uint32_t remainder; diff --git a/targets/ChibiOS/_nanoCLR/nanoFramework.Hardware.Stm32/nf_hardware_stm32_native_nanoFramework_Hardware_Stm32_Configuration.cpp b/targets/ChibiOS/_nanoCLR/nanoFramework.Hardware.Stm32/nf_hardware_stm32_native_nanoFramework_Hardware_Stm32_Configuration.cpp index 2b377d076c..ade58476e2 100644 --- a/targets/ChibiOS/_nanoCLR/nanoFramework.Hardware.Stm32/nf_hardware_stm32_native_nanoFramework_Hardware_Stm32_Configuration.cpp +++ b/targets/ChibiOS/_nanoCLR/nanoFramework.Hardware.Stm32/nf_hardware_stm32_native_nanoFramework_Hardware_Stm32_Configuration.cpp @@ -9,7 +9,7 @@ #if defined(HAL_USE_ADC) && (HAL_USE_ADC == TRUE) #include -NF_PAL_ADC_PORT_PIN_CHANNEL *RuntimeAdcPortPinConfig = NULL; +NF_PAL_ADC_PORT_PIN_CHANNEL *RuntimeAdcPortPinConfig = nullptr; uint8_t RuntimeAdcChannelCount = 0; int8_t GetNextFreeAdcChannel(NF_PAL_ADC_PORT_PIN_CHANNEL *&newChannel); @@ -178,14 +178,14 @@ HRESULT Library_nf_hardware_stm32_native_nanoFramework_Hardware_Stm32_Configurat int8_t GetNextFreeAdcChannel(NF_PAL_ADC_PORT_PIN_CHANNEL *&newChannel) { int8_t channelIndex = -1; - newChannel = NULL; + newChannel = nullptr; - if (RuntimeAdcPortPinConfig == NULL) + if (RuntimeAdcPortPinConfig == nullptr) { RuntimeAdcPortPinConfig = (NF_PAL_ADC_PORT_PIN_CHANNEL *)platform_malloc(sizeof(NF_PAL_ADC_PORT_PIN_CHANNEL)); // sanity check - if (RuntimeAdcPortPinConfig != NULL) + if (RuntimeAdcPortPinConfig != nullptr) { // clear memory memset(RuntimeAdcPortPinConfig, 0, sizeof(NF_PAL_ADC_PORT_PIN_CHANNEL)); @@ -215,7 +215,7 @@ int8_t GetNextFreeAdcChannel(NF_PAL_ADC_PORT_PIN_CHANNEL *&newChannel) (RuntimeAdcChannelCount + 1) * sizeof(NF_PAL_ADC_PORT_PIN_CHANNEL)); // sanity check - if (RuntimeAdcPortPinConfig != NULL) + if (RuntimeAdcPortPinConfig != nullptr) { // update the number of channels RuntimeAdcChannelCount++; diff --git a/targets/ChibiOS/_nanoCLR/nanoFramework.Hardware.Stm32/nf_hardware_stm32_native_nanoFramework_Hardware_Stm32_Power.cpp b/targets/ChibiOS/_nanoCLR/nanoFramework.Hardware.Stm32/nf_hardware_stm32_native_nanoFramework_Hardware_Stm32_Power.cpp index fb9721049a..3a4d62ba94 100644 --- a/targets/ChibiOS/_nanoCLR/nanoFramework.Hardware.Stm32/nf_hardware_stm32_native_nanoFramework_Hardware_Stm32_Power.cpp +++ b/targets/ChibiOS/_nanoCLR/nanoFramework.Hardware.Stm32/nf_hardware_stm32_native_nanoFramework_Hardware_Stm32_Power.cpp @@ -41,7 +41,7 @@ HRESULT Library_nf_hardware_stm32_native_nanoFramework_Hardware_Stm32_Power::Dis uint32_t wakeUpPin; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock* pThis = stack.This(); FAULT_ON_NULL(pThis); switch((WakeupPin)stack.Arg0().NumericByRef().u4) @@ -110,7 +110,7 @@ HRESULT Library_nf_hardware_stm32_native_nanoFramework_Hardware_Stm32_Power::Ena uint32_t wakeUpPin; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock* pThis = stack.This(); FAULT_ON_NULL(pThis); switch((WakeupPin)stack.Arg0().NumericByRef().u4) diff --git a/targets/ChibiOS/_nanoCLR/nanoFramework.Hardware.Stm32/nf_hardware_stm32_native_nanoFramework_Hardware_Stm32_RTC.cpp b/targets/ChibiOS/_nanoCLR/nanoFramework.Hardware.Stm32/nf_hardware_stm32_native_nanoFramework_Hardware_Stm32_RTC.cpp index 3526232684..b929377089 100644 --- a/targets/ChibiOS/_nanoCLR/nanoFramework.Hardware.Stm32/nf_hardware_stm32_native_nanoFramework_Hardware_Stm32_RTC.cpp +++ b/targets/ChibiOS/_nanoCLR/nanoFramework.Hardware.Stm32/nf_hardware_stm32_native_nanoFramework_Hardware_Stm32_RTC.cpp @@ -29,7 +29,7 @@ HRESULT Library_nf_hardware_stm32_native_nanoFramework_Hardware_Stm32_RTC:: // it's only possible to set seconds, minutes, hours and date (day) // to set the alarm, it has to be stoped first (in case there is one already set) - rtcSetAlarm(&RTCD1, ALARM_ID, NULL); + rtcSetAlarm(&RTCD1, ALARM_ID, nullptr); // alarm date (day) tens and units value = stack.Arg0().NumericByRef().u1; diff --git a/targets/ChibiOS/_nanoCLR/nanoFramework.System.IO.Hashing/nf_sys_io_hashing_System_IO_Hashing_Crc32.cpp b/targets/ChibiOS/_nanoCLR/nanoFramework.System.IO.Hashing/nf_sys_io_hashing_System_IO_Hashing_Crc32.cpp index 2ce98bd318..9520fa5aa8 100644 --- a/targets/ChibiOS/_nanoCLR/nanoFramework.System.IO.Hashing/nf_sys_io_hashing_System_IO_Hashing_Crc32.cpp +++ b/targets/ChibiOS/_nanoCLR/nanoFramework.System.IO.Hashing/nf_sys_io_hashing_System_IO_Hashing_Crc32.cpp @@ -25,13 +25,13 @@ HRESULT Library_nf_sys_io_hashing_System_IO_Hashing_Crc32::ComputeHash___STATIC_ CLR_RT_HeapBlock *bufferSpanByte; CLR_RT_HeapBlock_Array *buffer; - uint8_t *bufferData = NULL; + uint8_t *bufferData = nullptr; int16_t bufferSize = 0; int16_t bufferOffset = 0; uint32_t crc32 = 0; uint32_t hash = 0; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr bufferSpanByte = stack.Arg1().Dereference(); FAULT_ON_NULL_ARG(bufferSpanByte); diff --git a/targets/ChibiOS/_nanoCLR/targetHAL.cpp b/targets/ChibiOS/_nanoCLR/targetHAL.cpp index c54146e5b8..60cea6dfba 100644 --- a/targets/ChibiOS/_nanoCLR/targetHAL.cpp +++ b/targets/ChibiOS/_nanoCLR/targetHAL.cpp @@ -68,7 +68,7 @@ void nanoHAL_Initialize() FileSystemVolumeList::InitializeVolumes(); // clear managed heap region - unsigned char *heapStart = NULL; + unsigned char *heapStart = nullptr; unsigned int heapSize = 0; ::HeapLocation(heapStart, heapSize); @@ -171,7 +171,7 @@ void nanoHAL_Uninitialize(bool isPoweringDown) // TODO check for s_rebootHandlers // for(int i = 0; i< ARRAYSIZE(s_rebootHandlers); i++) // { - // if(s_rebootHandlers[i] != NULL) + // if(s_rebootHandlers[i] != nullptr) // { // s_rebootHandlers[i](); // } diff --git a/targets/ChibiOS/_nanoCLR/targetPAL_Events.cpp b/targets/ChibiOS/_nanoCLR/targetPAL_Events.cpp index 5f5805f845..5211290127 100644 --- a/targets/ChibiOS/_nanoCLR/targetPAL_Events.cpp +++ b/targets/ChibiOS/_nanoCLR/targetPAL_Events.cpp @@ -34,7 +34,7 @@ void Events_SetBoolTimer(bool *timerCompleteFlag, uint32_t millisecondsFromNow) { NATIVE_PROFILE_PAL_EVENTS(); - if (timerCompleteFlag != NULL) + if (timerCompleteFlag != nullptr) { // no need to stop the timer even if it's running because the API does it anyway if (port_is_isr_context()) diff --git a/targets/ChibiOS/_nanoCLR/targetPAL_Time.cpp b/targets/ChibiOS/_nanoCLR/targetPAL_Time.cpp index aafa3ac1e7..8675ff98e1 100644 --- a/targets/ChibiOS/_nanoCLR/targetPAL_Time.cpp +++ b/targets/ChibiOS/_nanoCLR/targetPAL_Time.cpp @@ -11,7 +11,7 @@ // timer for next event static virtual_timer_t nextEventTimer; -void* nextEventCallbackDummyArg = NULL; +void* nextEventCallbackDummyArg = nullptr; static void NextEventTimer_Callback(virtual_timer_t *vtp, void* arg ) { diff --git a/targets/ESP32/ESP32/nanoCLR/nanoFramework.Graphics/Graphics_Memory.cpp b/targets/ESP32/ESP32/nanoCLR/nanoFramework.Graphics/Graphics_Memory.cpp index b55a150453..60baf23799 100644 --- a/targets/ESP32/ESP32/nanoCLR/nanoFramework.Graphics/Graphics_Memory.cpp +++ b/targets/ESP32/ESP32/nanoCLR/nanoFramework.Graphics/Graphics_Memory.cpp @@ -70,7 +70,7 @@ bool GraphicsMemory::GraphicsHeapLocation( graphicsStartingAddress = (CLR_UINT8 *)heap_caps_malloc(graphicsMemoryBlockSize, memoryCaps); - ASSERT(graphicsStartingAddress != NULL); + ASSERT(graphicsStartingAddress != nullptr); graphicsEndingAddress = (CLR_UINT8 *)(graphicsStartingAddress + graphicsMemoryBlockSize); // Save where we allocated it for restarts diff --git a/targets/ESP32/ESP32_C6/nanoCLR/System.Device.Pwm/sys_dev_pwm_native_System_Device_Pwm_PwmChannel.cpp b/targets/ESP32/ESP32_C6/nanoCLR/System.Device.Pwm/sys_dev_pwm_native_System_Device_Pwm_PwmChannel.cpp index 1ac27069fa..b550747868 100644 --- a/targets/ESP32/ESP32_C6/nanoCLR/System.Device.Pwm/sys_dev_pwm_native_System_Device_Pwm_PwmChannel.cpp +++ b/targets/ESP32/ESP32_C6/nanoCLR/System.Device.Pwm/sys_dev_pwm_native_System_Device_Pwm_PwmChannel.cpp @@ -166,7 +166,7 @@ HRESULT Library_sys_dev_pwm_native_System_Device_Pwm_PwmChannel::NativeInit___VO NANOCLR_HEADER(); - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -201,7 +201,7 @@ HRESULT Library_sys_dev_pwm_native_System_Device_Pwm_PwmChannel::NativeSetDesire NANOCLR_HEADER(); - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -268,7 +268,7 @@ HRESULT Library_sys_dev_pwm_native_System_Device_Pwm_PwmChannel::NativeSetActive NANOCLR_HEADER(); - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -312,7 +312,7 @@ HRESULT Library_sys_dev_pwm_native_System_Device_Pwm_PwmChannel::NativeStart___V { NANOCLR_HEADER(); - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -333,7 +333,7 @@ HRESULT Library_sys_dev_pwm_native_System_Device_Pwm_PwmChannel::NativeStop___VO NANOCLR_HEADER(); - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); diff --git a/targets/ESP32/ESP32_C6/nanoCLR/nanoFramework.Graphics/Graphics_Memory.cpp b/targets/ESP32/ESP32_C6/nanoCLR/nanoFramework.Graphics/Graphics_Memory.cpp index 06f08993c5..c302a4be65 100644 --- a/targets/ESP32/ESP32_C6/nanoCLR/nanoFramework.Graphics/Graphics_Memory.cpp +++ b/targets/ESP32/ESP32_C6/nanoCLR/nanoFramework.Graphics/Graphics_Memory.cpp @@ -68,7 +68,7 @@ bool GraphicsMemory::GraphicsHeapLocation( graphicsMemoryBlockSize = spiramMaxSize; } graphicsStartingAddress = (CLR_UINT8 *)heap_caps_malloc(graphicsMemoryBlockSize, memoryCaps); - ASSERT(graphicsStartingAddress != NULL); + ASSERT(graphicsStartingAddress != nullptr); graphicsEndingAddress = (CLR_UINT8 *)(graphicsStartingAddress + graphicsMemoryBlockSize); // Save where we allocated it for restarts diff --git a/targets/ESP32/ESP32_H2/nanoCLR/System.Device.Pwm/sys_dev_pwm_native_System_Device_Pwm_PwmChannel.cpp b/targets/ESP32/ESP32_H2/nanoCLR/System.Device.Pwm/sys_dev_pwm_native_System_Device_Pwm_PwmChannel.cpp index 1ac27069fa..b550747868 100644 --- a/targets/ESP32/ESP32_H2/nanoCLR/System.Device.Pwm/sys_dev_pwm_native_System_Device_Pwm_PwmChannel.cpp +++ b/targets/ESP32/ESP32_H2/nanoCLR/System.Device.Pwm/sys_dev_pwm_native_System_Device_Pwm_PwmChannel.cpp @@ -166,7 +166,7 @@ HRESULT Library_sys_dev_pwm_native_System_Device_Pwm_PwmChannel::NativeInit___VO NANOCLR_HEADER(); - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -201,7 +201,7 @@ HRESULT Library_sys_dev_pwm_native_System_Device_Pwm_PwmChannel::NativeSetDesire NANOCLR_HEADER(); - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -268,7 +268,7 @@ HRESULT Library_sys_dev_pwm_native_System_Device_Pwm_PwmChannel::NativeSetActive NANOCLR_HEADER(); - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -312,7 +312,7 @@ HRESULT Library_sys_dev_pwm_native_System_Device_Pwm_PwmChannel::NativeStart___V { NANOCLR_HEADER(); - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -333,7 +333,7 @@ HRESULT Library_sys_dev_pwm_native_System_Device_Pwm_PwmChannel::NativeStop___VO NANOCLR_HEADER(); - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); diff --git a/targets/ESP32/ESP32_S2/nanoCLR/nanoFramework.Graphics/Graphics_Memory.cpp b/targets/ESP32/ESP32_S2/nanoCLR/nanoFramework.Graphics/Graphics_Memory.cpp index 06f08993c5..c302a4be65 100644 --- a/targets/ESP32/ESP32_S2/nanoCLR/nanoFramework.Graphics/Graphics_Memory.cpp +++ b/targets/ESP32/ESP32_S2/nanoCLR/nanoFramework.Graphics/Graphics_Memory.cpp @@ -68,7 +68,7 @@ bool GraphicsMemory::GraphicsHeapLocation( graphicsMemoryBlockSize = spiramMaxSize; } graphicsStartingAddress = (CLR_UINT8 *)heap_caps_malloc(graphicsMemoryBlockSize, memoryCaps); - ASSERT(graphicsStartingAddress != NULL); + ASSERT(graphicsStartingAddress != nullptr); graphicsEndingAddress = (CLR_UINT8 *)(graphicsStartingAddress + graphicsMemoryBlockSize); // Save where we allocated it for restarts diff --git a/targets/ESP32/ESP32_S3/nanoCLR/nanoFramework.Graphics/Graphics_Memory.cpp b/targets/ESP32/ESP32_S3/nanoCLR/nanoFramework.Graphics/Graphics_Memory.cpp index 06f08993c5..c302a4be65 100644 --- a/targets/ESP32/ESP32_S3/nanoCLR/nanoFramework.Graphics/Graphics_Memory.cpp +++ b/targets/ESP32/ESP32_S3/nanoCLR/nanoFramework.Graphics/Graphics_Memory.cpp @@ -68,7 +68,7 @@ bool GraphicsMemory::GraphicsHeapLocation( graphicsMemoryBlockSize = spiramMaxSize; } graphicsStartingAddress = (CLR_UINT8 *)heap_caps_malloc(graphicsMemoryBlockSize, memoryCaps); - ASSERT(graphicsStartingAddress != NULL); + ASSERT(graphicsStartingAddress != nullptr); graphicsEndingAddress = (CLR_UINT8 *)(graphicsStartingAddress + graphicsMemoryBlockSize); // Save where we allocated it for restarts diff --git a/targets/ESP32/_FatFs/fatfs_FS_Driver.cpp b/targets/ESP32/_FatFs/fatfs_FS_Driver.cpp index 07b1465e77..7757124cd6 100644 --- a/targets/ESP32/_FatFs/fatfs_FS_Driver.cpp +++ b/targets/ESP32/_FatFs/fatfs_FS_Driver.cpp @@ -22,7 +22,7 @@ STREAM_DRIVER_DETAILS *FATFS_FS_Driver::DriverDetails(const VOLUME_ID *volume) { (void)volume; - static STREAM_DRIVER_DETAILS driverDetail = {DIRECT_IO, NULL, NULL, 0, 0, TRUE, TRUE, TRUE, 0, 0}; + static STREAM_DRIVER_DETAILS driverDetail = {DIRECT_IO, nullptr, nullptr, 0, 0, TRUE, TRUE, TRUE, 0, 0}; return &driverDetail; } @@ -136,11 +136,11 @@ HRESULT FATFS_FS_Driver::GetVolumeLabel(const VOLUME_ID *volume, char *volumeLab (void)volumeLabel; (void)volumeLabelLen; - // FATFS *fs = NULL; + // FATFS *fs = nullptr; // //fs = GetFileSystemForVolume(volume, true); - // if (fs == NULL) + // if (fs == nullptr) // { // return FALSE; // } @@ -172,7 +172,7 @@ HRESULT FATFS_FS_Driver::Open(const VOLUME_ID *volume, const char *path, void *& int32_t result; #endif - FATFS_FileHandle *fileHandle = NULL; + FATFS_FileHandle *fileHandle = nullptr; FILINFO info; int32_t flags; char normalizedPath[FS_MAX_DIRECTORY_LENGTH]; @@ -182,7 +182,7 @@ HRESULT FATFS_FS_Driver::Open(const VOLUME_ID *volume, const char *path, void *& // allocate file handle fileHandle = (FATFS_FileHandle *)platform_malloc(sizeof(FATFS_FileHandle)); - if (fileHandle == NULL) + if (fileHandle == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_OUT_OF_MEMORY); } @@ -242,7 +242,7 @@ HRESULT FATFS_FS_Driver::Open(const VOLUME_ID *volume, const char *path, void *& NANOCLR_CLEANUP(); - if (fileHandle != NULL) + if (fileHandle != nullptr) { platform_free(fileHandle); } @@ -484,13 +484,13 @@ HRESULT FATFS_FS_Driver::FindOpen(const VOLUME_ID *volume, const char *path, voi NANOCLR_HEADER(); char normalizedPath[FS_MAX_DIRECTORY_LENGTH]; - FATFS_FindFileHandle *findHandle = NULL; + FATFS_FindFileHandle *findHandle = nullptr; FileSystemVolume *currentVolume; // allocate file handle findHandle = (FATFS_FindFileHandle *)platform_malloc(sizeof(FATFS_FindFileHandle)); - if (findHandle == NULL) + if (findHandle == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_OUT_OF_MEMORY); } @@ -521,7 +521,7 @@ HRESULT FATFS_FS_Driver::FindOpen(const VOLUME_ID *volume, const char *path, voi NANOCLR_CLEANUP(); - if (findHandle != NULL) + if (findHandle != nullptr) { platform_free(findHandle); } @@ -576,7 +576,7 @@ HRESULT FATFS_FS_Driver::FindNext(void *handle, FS_FILEINFO *fi, bool *fileFound fi->FileName = (char *)platform_malloc(fi->FileNameSize + 1); // sanity check for successfull malloc - if (fi->FileName == NULL) + if (fi->FileName == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_OUT_OF_MEMORY); } @@ -783,7 +783,7 @@ HRESULT FATFS_FS_Driver::CreateDirectory(const VOLUME_ID *volume, const char *pa // add back the '/' separator strcat(tempPath, "/"); - segment = strtok(NULL, "/"); + segment = strtok(nullptr, "/"); } // remove trailing '/' diff --git a/targets/ESP32/_Network/NF_ESP32_Ethernet.cpp b/targets/ESP32/_Network/NF_ESP32_Ethernet.cpp index b16214fab7..3e72ba6d10 100644 --- a/targets/ESP32/_Network/NF_ESP32_Ethernet.cpp +++ b/targets/ESP32/_Network/NF_ESP32_Ethernet.cpp @@ -10,7 +10,7 @@ static const char *TAG = "ETH"; -esp_eth_handle_t eth_handle = NULL; +esp_eth_handle_t eth_handle = nullptr; // OLIMEX ESP32-EVB Rev B, OLIMEX ESP32-Gateway, Generic Lan8270 // ETH_PHY_ADDR 0 @@ -45,7 +45,7 @@ esp_err_t NF_ESP32_InitialiseEthernet(uint8_t *pMacAdr) #ifdef ESP32_ETHERNET_SUPPORT - if (eth_handle != NULL) + if (eth_handle != nullptr) { return esp_eth_start(eth_handle); } diff --git a/targets/ESP32/_Network/NF_ESP32_OpenThread.cpp b/targets/ESP32/_Network/NF_ESP32_OpenThread.cpp index 6d520a55e9..f664ffd82c 100644 --- a/targets/ESP32/_Network/NF_ESP32_OpenThread.cpp +++ b/targets/ESP32/_Network/NF_ESP32_OpenThread.cpp @@ -97,7 +97,7 @@ extern void ThreadSetInterfaceNumber(int networkInterfaceNumber); .task_queue_size = 10, \ } -static esp_netif_t *openthread_netif = NULL; +static esp_netif_t *openthread_netif = nullptr; // Maximum number of entries in cliOutputsList #define cliListMaxSize 50 @@ -118,7 +118,7 @@ static esp_netif_t *init_openthread_netif(const esp_openthread_platform_config_t { esp_netif_config_t cfg = ESP_NETIF_DEFAULT_OPENTHREAD(); esp_netif_t *netif = esp_netif_new(&cfg); - assert(netif != NULL); + assert(netif != nullptr); ESP_ERROR_CHECK(esp_netif_attach(netif, esp_openthread_netif_glue_init(config))); @@ -311,7 +311,7 @@ HRESULT OpenThreadCliOutput(CLR_RT_HeapBlock &arrayBlock) NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_Array::CreateInstance( arrayBlock, cliOutputsList.size(), - g_CLR_RT_WellKnownTypes.m_String)); + g_CLR_RT_WellKnownTypes.String)); array = arrayBlock.Array(); @@ -427,7 +427,7 @@ esp_err_t initOpenThread(ThreadDeviceType deviceType, esp_openthread_radio_mode_ // The OpenThread log level directly matches ESP log level (void)otLoggingSetLevel(CONFIG_LOG_DEFAULT_LEVEL); - otCliInit(esp_openthread_get_instance(), cliOutputCallback, NULL); + otCliInit(esp_openthread_get_instance(), cliOutputCallback, nullptr); // Clear '>' from output on init ResetLineBuffer(); @@ -457,7 +457,7 @@ static void openThreadMainTask(void *aContext) esp_openthread_netif_glue_deinit(); esp_vfs_eventfd_unregister(); - vTaskDelete(NULL); + vTaskDelete(nullptr); } bool startStopOpenThread(bool start) @@ -533,10 +533,10 @@ void JoinerStart(const char *pskc, const char *url) { otError oterr; - oterr = otJoinerStart(esp_openthread_get_instance(), pskc, url, NULL, NULL, NULL, NULL, JoinerCallback, NULL); + oterr = otJoinerStart(esp_openthread_get_instance(), pskc, url, nullptr, nullptr, nullptr, nullptr, JoinerCallback, nullptr); if (oterr != OT_ERROR_NONE) { - JoinerCallback(oterr, NULL); + JoinerCallback(oterr, nullptr); } } diff --git a/targets/ESP32/_Network/NF_ESP32_SmartConfig.cpp b/targets/ESP32/_Network/NF_ESP32_SmartConfig.cpp index 29335577b4..a790bec31b 100644 --- a/targets/ESP32/_Network/NF_ESP32_SmartConfig.cpp +++ b/targets/ESP32/_Network/NF_ESP32_SmartConfig.cpp @@ -78,7 +78,7 @@ void smartconfig_task(void *parm) ESP_ERROR_CHECK(esp_smartconfig_start(&cfg)); sc_wifi_event_group = xEventGroupCreate(); - ESP_ERROR_CHECK(esp_event_handler_register(SC_EVENT, ESP_EVENT_ANY_ID, &event_handler, NULL)); + ESP_ERROR_CHECK(esp_event_handler_register(SC_EVENT, ESP_EVENT_ANY_ID, &event_handler, nullptr)); while (1) { @@ -92,12 +92,12 @@ void smartconfig_task(void *parm) vEventGroupDelete(sc_wifi_event_group); - vTaskDelete(NULL); + vTaskDelete(nullptr); } } } void NF_ESP32_Start_wifi_smart_config(void) { - xTaskCreate(smartconfig_task, "smartconfig_task", 4096, NULL, 3, NULL); + xTaskCreate(smartconfig_task, "smartconfig_task", 4096, nullptr, 3, nullptr); } diff --git a/targets/ESP32/_Network/NF_ESP32_Wireless.cpp b/targets/ESP32/_Network/NF_ESP32_Wireless.cpp index 6954849512..38bbecb370 100644 --- a/targets/ESP32/_Network/NF_ESP32_Wireless.cpp +++ b/targets/ESP32/_Network/NF_ESP32_Wireless.cpp @@ -17,8 +17,8 @@ static wifi_mode_t wifiMode; // flag to store if Wi-Fi has been initialized static bool IsWifiInitialised = false; -static esp_netif_t *wifiStaNetif = NULL; -static esp_netif_t *wifiAPNetif = NULL; +static esp_netif_t *wifiStaNetif = nullptr; +static esp_netif_t *wifiAPNetif = nullptr; // flag to signal if connect is to happen bool NF_ESP32_IsToConnect = false; @@ -33,14 +33,14 @@ wifi_mode_t NF_ESP32_CheckExpectedWifiMode() { wifi_mode_t mode = WIFI_MODE_NULL; - HAL_Configuration_Wireless80211 *wirelessConfig = NULL; - HAL_Configuration_WirelessAP *wirelessAPConfig = NULL; + HAL_Configuration_Wireless80211 *wirelessConfig = nullptr; + HAL_Configuration_WirelessAP *wirelessAPConfig = nullptr; HAL_Configuration_NetworkInterface *networkConfig = (HAL_Configuration_NetworkInterface *)platform_malloc(sizeof(HAL_Configuration_NetworkInterface)); // check allocation - if (networkConfig == NULL) + if (networkConfig == nullptr) { return WIFI_MODE_NULL; } @@ -56,7 +56,7 @@ wifi_mode_t NF_ESP32_CheckExpectedWifiMode() { wirelessConfig = ConfigurationManager_GetWirelessConfigurationFromId(networkConfig->SpecificConfigId); - if (wirelessConfig != NULL) + if (wirelessConfig != nullptr) { if (wirelessConfig->Options & Wireless80211Configuration_ConfigurationOptions_Enable) { @@ -79,7 +79,7 @@ wifi_mode_t NF_ESP32_CheckExpectedWifiMode() wirelessAPConfig = ConfigurationManager_GetWirelessAPConfigurationFromId(networkConfig->SpecificConfigId); - if (wirelessAPConfig != NULL) + if (wirelessAPConfig != nullptr) { if (wirelessAPConfig->Options & WirelessAPConfiguration_ConfigurationOptions_Enable) { @@ -121,9 +121,9 @@ void NF_ESP32_DeinitWifi() esp_wifi_stop(); esp_netif_destroy_default_wifi(wifiStaNetif); - wifiStaNetif = NULL; + wifiStaNetif = nullptr; esp_netif_destroy_default_wifi(wifiAPNetif); - wifiAPNetif = NULL; + wifiAPNetif = nullptr; esp_wifi_deinit(); } @@ -213,7 +213,7 @@ esp_err_t NF_ESP32_InitaliseWifi() { HAL_Configuration_NetworkInterface *networkConfig = (HAL_Configuration_NetworkInterface *)platform_malloc(sizeof(HAL_Configuration_NetworkInterface)); - if (networkConfig == NULL) + if (networkConfig == nullptr) { return ESP_FAIL; } @@ -308,7 +308,7 @@ int NF_ESP32_Wireless_Open(HAL_Configuration_NetworkInterface *config) HAL_Configuration_Wireless80211 *wirelessConfig = ConfigurationManager_GetWirelessConfigurationFromId(config->SpecificConfigId); - if (wirelessConfig == NULL) + if (wirelessConfig == nullptr) { return SOCK_SOCKET_ERROR; } @@ -548,7 +548,7 @@ int NF_ESP32_Wait_NetNumber(int num) break; } - if (espNetif != NULL) + if (espNetif != nullptr) { break; } diff --git a/targets/ESP32/_common/Target_Network.cpp b/targets/ESP32/_common/Target_Network.cpp index 52a4e1e73c..05e7526c1b 100644 --- a/targets/ESP32/_common/Target_Network.cpp +++ b/targets/ESP32/_common/Target_Network.cpp @@ -189,11 +189,11 @@ bool GetWirelessConfig(int index, HAL_Configuration_Wireless80211 **wirelessConf int Network_Interface_Start_Connect(int index, const char *ssid, const char *passphase, int options) { // need to free memory, if allocated in successful GetWirelessConfig - HAL_Configuration_Wireless80211 *wirelessConfig = NULL; + HAL_Configuration_Wireless80211 *wirelessConfig = nullptr; if (GetWirelessConfig(index, &wirelessConfig) == false) { - if (wirelessConfig != NULL) + if (wirelessConfig != nullptr) { platform_free(wirelessConfig); } diff --git a/targets/ESP32/_common/targetHAL_ConfigurationManager.cpp b/targets/ESP32/_common/targetHAL_ConfigurationManager.cpp index c45c8d8c16..8344d5a93a 100644 --- a/targets/ESP32/_common/targetHAL_ConfigurationManager.cpp +++ b/targets/ESP32/_common/targetHAL_ConfigurationManager.cpp @@ -76,7 +76,7 @@ int32_t ConfigurationManager_FindConfigurationBlockSize( int32_t configSize = 0; handle = ConfigStorage_OpenFile(configuration, configurationIndex, false, false); - if (handle != NULL) + if (handle != nullptr) { configSize = ConfigStorage_FileSize(handle); #ifdef DEBUG_CONFIG @@ -98,7 +98,7 @@ bool StoreConfigBlock( FILE *fileHandle; fileHandle = ConfigStorage_OpenFile(configType, configurationIndex, true, false); - if (fileHandle != NULL) + if (fileHandle != nullptr) { result = ConfigStorage_WriteFile(fileHandle, (uint8_t *)configBlock, writeSize); #ifdef DEBUG_CONFIG @@ -126,7 +126,7 @@ bool AppendConfigBlock( fileHandle = ConfigStorage_OpenFile(configType, configurationIndex, true, true); - if (fileHandle != NULL) + if (fileHandle != nullptr) { result = ConfigStorage_AppendFile(fileHandle, (uint8_t *)configBlock, writeSize); @@ -210,7 +210,7 @@ void ConfigurationManager_EnumerateConfigurationBlocks() (HAL_CONFIGURATION_NETWORK_WIRELESS80211 *)ConfigStorage_FindNetworkWireless80211ConfigurationBlocks(); // check wireless configs count - if (networkWirelessConfigs != NULL && networkWirelessConfigs->Count == 0) + if (networkWirelessConfigs != nullptr && networkWirelessConfigs->Count == 0) { // allocate memory for ONE network configuration HAL_Configuration_Wireless80211 *wirelessConfig = @@ -235,7 +235,7 @@ void ConfigurationManager_EnumerateConfigurationBlocks() HAL_CONFIGURATION_NETWORK_WIRELESSAP *wirelessAPconfigs = ConfigStorage_FindNetworkWirelessAPConfigurationBlocks(); // check wireless AP configs count - if (wirelessAPconfigs != NULL && wirelessAPconfigs->Count == 0) + if (wirelessAPconfigs != nullptr && wirelessAPconfigs->Count == 0) { // allocate memory for ONE wireless AP configuration HAL_Configuration_WirelessAP *wirelessAPConfig = @@ -791,13 +791,13 @@ HAL_Configuration_Wireless80211 *ConfigurationManager_GetWirelessConfigurationFr } } - if (wirelessConfig != NULL) + if (wirelessConfig != nullptr) { platform_free(wirelessConfig); } // not found, or failed to allocate memory - return NULL; + return nullptr; } HAL_Configuration_WirelessAP *ConfigurationManager_GetWirelessAPConfigurationFromId(uint32_t configurationId) @@ -824,13 +824,13 @@ HAL_Configuration_WirelessAP *ConfigurationManager_GetWirelessAPConfigurationFro } } - if (wirelessAPConfig != NULL) + if (wirelessAPConfig != nullptr) { platform_free(wirelessAPConfig); } // not found, or failed to allocate memory - return NULL; + return nullptr; } HAL_Configuration_X509CaRootBundle *ConfigurationManager_GetCertificateStore() @@ -846,7 +846,7 @@ HAL_Configuration_X509CaRootBundle *ConfigurationManager_GetCertificateStore() HAL_Configuration_X509CaRootBundle *certStore = (HAL_Configuration_X509CaRootBundle *)platform_malloc(certSize); - if (certStore != NULL) + if (certStore != nullptr) { if (ConfigurationManager_GetConfigurationBlock( certStore, @@ -862,7 +862,7 @@ HAL_Configuration_X509CaRootBundle *ConfigurationManager_GetCertificateStore() } // not found, or failed to allocate memory - return NULL; + return nullptr; } HAL_Configuration_X509DeviceCertificate *ConfigurationManager_GetDeviceCertificate() @@ -878,7 +878,7 @@ HAL_Configuration_X509DeviceCertificate *ConfigurationManager_GetDeviceCertifica HAL_Configuration_X509DeviceCertificate *deviceCert = (HAL_Configuration_X509DeviceCertificate *)platform_malloc(certSize); - if (deviceCert != NULL) + if (deviceCert != nullptr) { if (ConfigurationManager_GetConfigurationBlock( deviceCert, @@ -894,7 +894,7 @@ HAL_Configuration_X509DeviceCertificate *ConfigurationManager_GetDeviceCertifica } // not found, or failed to allocate memory - return NULL; + return nullptr; } // default implementation diff --git a/targets/ESP32/_common/targetHAL_FileOperation.cpp b/targets/ESP32/_common/targetHAL_FileOperation.cpp index 9cfb3bddad..b3b4e79aae 100644 --- a/targets/ESP32/_common/targetHAL_FileOperation.cpp +++ b/targets/ESP32/_common/targetHAL_FileOperation.cpp @@ -30,8 +30,8 @@ void CombinePathAndName(char *outpath, const char *path1, const char *path2) // char *ConvertToVfsPath(const char *filepath) { - char *startPath = NULL; - char *path = NULL; + char *startPath = nullptr; + char *path = nullptr; int pathlen = hal_strlen_s(filepath); @@ -40,10 +40,10 @@ char *ConvertToVfsPath(const char *filepath) startPath = (char *)platform_malloc(pathlen + 1); // sanity check for successfull malloc - if (startPath == NULL) + if (startPath == nullptr) { // failed to allocate memory - return NULL; + return nullptr; } path = startPath; @@ -67,4 +67,4 @@ char *ConvertToVfsPath(const char *filepath) } return startPath; -} \ No newline at end of file +} diff --git a/targets/ESP32/_common/targetHAL_Network.cpp b/targets/ESP32/_common/targetHAL_Network.cpp index cb49b025d7..1afe918386 100644 --- a/targets/ESP32/_common/targetHAL_Network.cpp +++ b/targets/ESP32/_common/targetHAL_Network.cpp @@ -103,7 +103,7 @@ static void initialize_sntp() .server_from_dhcp = false, .wait_for_sync = true, .start = true, - .sync_cb = NULL, + .sync_cb = nullptr, .renew_servers_after_new_IP = false, .ip_event_to_renew = (ip_event_t)0, .index_of_first_server = 0, @@ -516,21 +516,21 @@ void nanoHAL_Network_Initialize() #if defined(CONFIG_SOC_WIFI_SUPPORTED) // register the handler for WIFI events - ESP_ERROR_CHECK(esp_event_handler_instance_register(WIFI_EVENT, ESP_EVENT_ANY_ID, &event_handler, NULL, NULL)); + ESP_ERROR_CHECK(esp_event_handler_instance_register(WIFI_EVENT, ESP_EVENT_ANY_ID, &event_handler, nullptr, nullptr)); #endif // register the event handler for IP events - ESP_ERROR_CHECK(esp_event_handler_instance_register(IP_EVENT, ESP_EVENT_ANY_ID, &event_handler, NULL, NULL)); + ESP_ERROR_CHECK(esp_event_handler_instance_register(IP_EVENT, ESP_EVENT_ANY_ID, &event_handler, nullptr, nullptr)); #ifdef ESP32_ETHERNET_SUPPORT // register the event handler for Ethernet events - ESP_ERROR_CHECK(esp_event_handler_instance_register(ETH_EVENT, ESP_EVENT_ANY_ID, &event_handler, NULL, NULL)); + ESP_ERROR_CHECK(esp_event_handler_instance_register(ETH_EVENT, ESP_EVENT_ANY_ID, &event_handler, nullptr, nullptr)); #endif #if HAL_USE_THREAD == TRUE // register the event handler for OpenThread events ESP_ERROR_CHECK( - esp_event_handler_instance_register(OPENTHREAD_EVENT, ESP_EVENT_ANY_ID, &thread_event_handler, NULL, NULL)); + esp_event_handler_instance_register(OPENTHREAD_EVENT, ESP_EVENT_ANY_ID, &thread_event_handler, nullptr, nullptr)); #endif } } diff --git a/targets/ESP32/_common/targetHAL_StorageOperation.cpp b/targets/ESP32/_common/targetHAL_StorageOperation.cpp index 09fe347c56..2edcee7623 100644 --- a/targets/ESP32/_common/targetHAL_StorageOperation.cpp +++ b/targets/ESP32/_common/targetHAL_StorageOperation.cpp @@ -26,7 +26,7 @@ void EnsureStorageInitialized() int create_directories(const char *path) { char temp[256]; - char *pos = NULL; + char *pos = nullptr; size_t len = 0; len = hal_strlen_s(path); @@ -82,7 +82,7 @@ uint32_t HAL_StorageOperation( char *strName = (char *)platform_malloc(nameLength + 1); // sanity check for successfull malloc - if (strName == NULL) + if (strName == nullptr) { return StorageOperationErrorCode::PlatformError; } @@ -108,7 +108,7 @@ uint32_t HAL_StorageOperation( char dir_path[256]; snprintf(dir_path, sizeof(dir_path), "%s", storageNameChar); char *last_slash = strrchr(dir_path, '/'); - if (last_slash != NULL) + if (last_slash != nullptr) { *last_slash = '\0'; } @@ -175,7 +175,7 @@ uint32_t HAL_StorageOperation( } // free buffer memory - if (storageNameChar != NULL) + if (storageNameChar != nullptr) { platform_free(storageNameChar); } diff --git a/targets/ESP32/_littlefs/littlefs_FS_Driver.cpp b/targets/ESP32/_littlefs/littlefs_FS_Driver.cpp index 7ce53c1432..242ea26ff5 100644 --- a/targets/ESP32/_littlefs/littlefs_FS_Driver.cpp +++ b/targets/ESP32/_littlefs/littlefs_FS_Driver.cpp @@ -22,7 +22,7 @@ STREAM_DRIVER_DETAILS *LITTLEFS_FS_Driver::DriverDetails(const VOLUME_ID *volume { (void)volume; - static STREAM_DRIVER_DETAILS driverDetail = {DIRECT_IO, NULL, NULL, 0, 0, TRUE, TRUE, TRUE, 0, 0}; + static STREAM_DRIVER_DETAILS driverDetail = {DIRECT_IO, nullptr, nullptr, 0, 0, TRUE, TRUE, TRUE, 0, 0}; return &driverDetail; } @@ -136,11 +136,11 @@ HRESULT LITTLEFS_FS_Driver::GetVolumeLabel(const VOLUME_ID *volume, char *volume (void)volumeLabel; (void)volumeLabelLen; - // FATFS *fs = NULL; + // FATFS *fs = nullptr; // //fs = GetFileSystemForVolume(volume, true); - // if (fs == NULL) + // if (fs == nullptr) // { // return FALSE; // } @@ -172,7 +172,7 @@ HRESULT LITTLEFS_FS_Driver::Open(const VOLUME_ID *volume, const char *path, void int32_t result; #endif - LITTLEFS_FileHandle *fileHandle = NULL; + LITTLEFS_FileHandle *fileHandle = nullptr; struct stat info; const char *flags; char normalizedPath[FS_MAX_DIRECTORY_LENGTH]; @@ -182,7 +182,7 @@ HRESULT LITTLEFS_FS_Driver::Open(const VOLUME_ID *volume, const char *path, void // allocate file handle fileHandle = (LITTLEFS_FileHandle *)platform_malloc(sizeof(LITTLEFS_FileHandle)); - if (fileHandle == NULL) + if (fileHandle == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_OUT_OF_MEMORY); } @@ -217,7 +217,7 @@ HRESULT LITTLEFS_FS_Driver::Open(const VOLUME_ID *volume, const char *path, void flags = "w+"; } fileHandle->file = fopen(normalizedPath, flags); - if (fileHandle->file != NULL) + if (fileHandle->file != nullptr) { // store the handle handle = fileHandle; @@ -233,7 +233,7 @@ HRESULT LITTLEFS_FS_Driver::Open(const VOLUME_ID *volume, const char *path, void NANOCLR_CLEANUP(); - if (fileHandle != NULL) + if (fileHandle != nullptr) { platform_free(fileHandle); } @@ -502,13 +502,13 @@ HRESULT LITTLEFS_FS_Driver::FindOpen(const VOLUME_ID *volume, const char *path, NANOCLR_HEADER(); char normalizedPath[FS_MAX_DIRECTORY_LENGTH]; - LITTLEFS_FindFileHandle *findHandle = NULL; + LITTLEFS_FindFileHandle *findHandle = nullptr; FileSystemVolume *currentVolume; // allocate file handle findHandle = (LITTLEFS_FindFileHandle *)platform_malloc(sizeof(LITTLEFS_FindFileHandle)); - if (findHandle == NULL) + if (findHandle == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_OUT_OF_MEMORY); } @@ -528,7 +528,7 @@ HRESULT LITTLEFS_FS_Driver::FindOpen(const VOLUME_ID *volume, const char *path, // open directory for seek findHandle->dir = opendir(normalizedPath); - if (findHandle->dir != NULL) + if (findHandle->dir != nullptr) { // store the handle handle = findHandle; @@ -543,7 +543,7 @@ HRESULT LITTLEFS_FS_Driver::FindOpen(const VOLUME_ID *volume, const char *path, NANOCLR_CLEANUP(); - if (findHandle != NULL) + if (findHandle != nullptr) { platform_free(findHandle); } @@ -577,9 +577,9 @@ HRESULT LITTLEFS_FS_Driver::FindNext(void *handle, FS_FILEINFO *fi, bool *fileFo // read the next entry entry = readdir(findHandle->dir); - if (entry == NULL) + if (entry == nullptr) { - // readdir() returns NULL on error or if end of directory is reached + // readdir() returns nullptr on error or if end of directory is reached // End of directory *fileFound = false; @@ -615,7 +615,7 @@ HRESULT LITTLEFS_FS_Driver::FindNext(void *handle, FS_FILEINFO *fi, bool *fileFo fi->FileName = (char *)platform_malloc(fi->FileNameSize + 1); // Sanity check for successful malloc - if (fi->FileName == NULL) + if (fi->FileName == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_OUT_OF_MEMORY); } @@ -840,7 +840,7 @@ HRESULT LITTLEFS_FS_Driver::CreateDirectory(const VOLUME_ID *volume, const char segment = strtok(normalizedPath, "/"); strcat(tempPath, segment); strcat(tempPath, "/"); - segment = strtok(NULL, "/"); + segment = strtok(nullptr, "/"); while (segment) { @@ -856,7 +856,7 @@ HRESULT LITTLEFS_FS_Driver::CreateDirectory(const VOLUME_ID *volume, const char // add back the '/' separator strcat(tempPath, "/"); - segment = strtok(NULL, "/"); + segment = strtok(nullptr, "/"); } // remove trailing '/' diff --git a/targets/ESP32/_nanoCLR/Memory.cpp b/targets/ESP32/_nanoCLR/Memory.cpp index 1248293e44..76996abf2b 100644 --- a/targets/ESP32/_nanoCLR/Memory.cpp +++ b/targets/ESP32/_nanoCLR/Memory.cpp @@ -45,7 +45,7 @@ static const char *TAG = "Memory"; // #define PRINT_HEAP_INFO 1 // Saved memory allocation for when heap is reset so we can return same value. -unsigned char *managedHeap = NULL; +unsigned char *managedHeap = nullptr; size_t managedHeapSize = 0; #ifdef PRINT_HEAP_INFO @@ -108,7 +108,7 @@ void HeapLocation(unsigned char *&baseAddress, unsigned int &sizeInBytes) NATIVE_PROFILE_PAL_HEAP(); // Memory allocated yet ? - if (managedHeap == NULL) + if (managedHeap == nullptr) { #ifdef PRINT_HEAP_INFO print_heap_info(MALLOC_CAP_8BIT | MALLOC_CAP_32BIT | MALLOC_CAP_SPIRAM); diff --git a/targets/ESP32/_nanoCLR/System.Device.Adc/sys_dev_adc_native_System_Device_Adc_AdcChannel.cpp b/targets/ESP32/_nanoCLR/System.Device.Adc/sys_dev_adc_native_System_Device_Adc_AdcChannel.cpp index 8c0a7542e2..0bf45a4ed7 100644 --- a/targets/ESP32/_nanoCLR/System.Device.Adc/sys_dev_adc_native_System_Device_Adc_AdcChannel.cpp +++ b/targets/ESP32/_nanoCLR/System.Device.Adc/sys_dev_adc_native_System_Device_Adc_AdcChannel.cpp @@ -18,7 +18,7 @@ HRESULT Library_sys_dev_adc_native_System_Device_Adc_AdcChannel::NativeReadValue int adcNumber; int reading = 0; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); diff --git a/targets/ESP32/_nanoCLR/System.Device.Adc/sys_dev_adc_native_System_Device_Adc_AdcController.cpp b/targets/ESP32/_nanoCLR/System.Device.Adc/sys_dev_adc_native_System_Device_Adc_AdcController.cpp index 5b6c800b58..4fd3a2de2a 100644 --- a/targets/ESP32/_nanoCLR/System.Device.Adc/sys_dev_adc_native_System_Device_Adc_AdcController.cpp +++ b/targets/ESP32/_nanoCLR/System.Device.Adc/sys_dev_adc_native_System_Device_Adc_AdcController.cpp @@ -44,7 +44,7 @@ HRESULT Library_sys_dev_adc_native_System_Device_Adc_AdcController::NativeOpenCh adc_bits_width_t width_bit = (adc_bits_width_t)SOC_ADC_RTC_MAX_BITWIDTH; adc_atten_t atten = ADC_ATTEN_DB_12; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); diff --git a/targets/ESP32/_nanoCLR/System.Device.Dac/sys_dev_dac_native_System_Device_Dac_DacChannel.cpp b/targets/ESP32/_nanoCLR/System.Device.Dac/sys_dev_dac_native_System_Device_Dac_DacChannel.cpp index 8c09785b43..cc3dc859ae 100644 --- a/targets/ESP32/_nanoCLR/System.Device.Dac/sys_dev_dac_native_System_Device_Dac_DacChannel.cpp +++ b/targets/ESP32/_nanoCLR/System.Device.Dac/sys_dev_dac_native_System_Device_Dac_DacChannel.cpp @@ -12,7 +12,7 @@ HRESULT Library_sys_dev_dac_native_System_Device_Dac_DacChannel::NativeWriteValu { NANOCLR_HEADER(); { - CLR_RT_HeapBlock *dacController = NULL; + CLR_RT_HeapBlock *dacController = nullptr; int channelNumber; int controllerId; dac_channel_t dacChannel = DAC_CHAN_0; @@ -20,7 +20,7 @@ HRESULT Library_sys_dev_dac_native_System_Device_Dac_DacChannel::NativeWriteValu // Get value argumant and mask to 0 - 255 range uint16_t value = (stack.Arg1().NumericByRefConst().u2 & 0xff); - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -69,7 +69,7 @@ HRESULT Library_sys_dev_dac_native_System_Device_Dac_DacChannel::NativeDispose__ int dacChannel; bool disposeController = false; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); diff --git a/targets/ESP32/_nanoCLR/System.Device.Dac/sys_dev_dac_native_System_Device_Dac_DacController.cpp b/targets/ESP32/_nanoCLR/System.Device.Dac/sys_dev_dac_native_System_Device_Dac_DacController.cpp index 3cf099fa23..aa8d3022f4 100644 --- a/targets/ESP32/_nanoCLR/System.Device.Dac/sys_dev_dac_native_System_Device_Dac_DacController.cpp +++ b/targets/ESP32/_nanoCLR/System.Device.Dac/sys_dev_dac_native_System_Device_Dac_DacController.cpp @@ -17,7 +17,7 @@ HRESULT Library_sys_dev_dac_native_System_Device_Dac_DacController::NativeOpenCh int channelNumber; dac_channel_t dacChannel = DAC_CHAN_0; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -105,7 +105,7 @@ HRESULT Library_sys_dev_dac_native_System_Device_Dac_DacController::NativeInit__ int controllerId; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); diff --git a/targets/ESP32/_nanoCLR/System.Device.Gpio/cpu_gpio.cpp b/targets/ESP32/_nanoCLR/System.Device.Gpio/cpu_gpio.cpp index 4dd38a241e..fecb1b14d2 100644 --- a/targets/ESP32/_nanoCLR/System.Device.Gpio/cpu_gpio.cpp +++ b/targets/ESP32/_nanoCLR/System.Device.Gpio/cpu_gpio.cpp @@ -70,12 +70,12 @@ static uint16_t pinReserved[TOTAL_GPIO_PORTS]; // reserved - 1 bit p static uint16_t pinStateStore[TOTAL_GPIO_PORTS]; // Get pointer to gpio_input_state for Gpio pin -// return NULL if not found +// return nullptr if not found gpio_input_state *GetInputState(GPIO_PIN pinNumber) { gpio_input_state *ptr = gpioInputList.FirstNode(); - while (ptr->Next() != NULL) + while (ptr->Next() != nullptr) { if (ptr->pinNumber == pinNumber) { @@ -85,7 +85,7 @@ gpio_input_state *GetInputState(GPIO_PIN pinNumber) ptr = ptr->Next(); } - return NULL; + return nullptr; } // Allocate a new gpio_input_state and add to end of list @@ -94,7 +94,7 @@ gpio_input_state *AllocateGpioInputState(GPIO_PIN pinNumber) { gpio_input_state *ptr = GetInputState(pinNumber); - if (ptr == NULL) + if (ptr == nullptr) { ptr = (gpio_input_state *)platform_malloc(sizeof(gpio_input_state)); memset(ptr, 0, sizeof(gpio_input_state)); @@ -107,7 +107,7 @@ gpio_input_state *AllocateGpioInputState(GPIO_PIN pinNumber) void UnlinkInputState(gpio_input_state *state) { - if (state->debounceTimer != NULL) + if (state->debounceTimer != nullptr) { xTimerDelete(state->debounceTimer, 100); } @@ -138,7 +138,7 @@ static void Esp_Gpio_DebounceHandler(TimerHandle_t timer) gpio_input_state *state = (gpio_input_state *)pvTimerGetTimerID(timer); // sanity check - if (state != NULL) + if (state != nullptr) { // get current pin state bool actual = CPU_GPIO_GetPinState(state->pinNumber); @@ -371,7 +371,7 @@ bool CPU_GPIO_EnableInputPin( // Link ISR ptr supplied and not already set up // CPU_GPIO_EnableInputPin could be called a 2nd time with changed parameters - if (pinISR != NULL && (state->isrPtr == NULL)) + if (pinISR != nullptr && (state->isrPtr == nullptr)) { ret = gpio_isr_handler_add((gpio_num_t)pinNumber, gpio_isr, (void *)state); if (ret != ESP_OK) @@ -422,7 +422,7 @@ bool CPU_GPIO_EnableInputPin( break; } } - else if (pinISR == NULL && (state->isrPtr != NULL)) + else if (pinISR == nullptr && (state->isrPtr != nullptr)) { // there is no managed handler setup anymore // remove INT handler @@ -431,9 +431,9 @@ bool CPU_GPIO_EnableInputPin( gpio_isr_handler_remove((gpio_num_t)state->pinNumber); // clear parameters & configs - state->isrPtr = NULL; + state->isrPtr = nullptr; state->mode = GPIO_INT_NONE; - state->param = NULL; + state->param = nullptr; state->debounceMs = 0; } @@ -609,7 +609,7 @@ bool CPU_GPIO_SetPinDebounce(GPIO_PIN pinNumber, uint32_t debounceTimeMillisecon } // check if there was a timer already setup - if (state->debounceTimer == NULL) + if (state->debounceTimer == nullptr) { // Create timer because it doesn't exist for this pin state->debounceTimer = diff --git a/targets/ESP32/_nanoCLR/System.Device.I2c.Slave/sys_dev_i2c_slave_native_System_Device_I2c_I2cSlaveDevice.cpp b/targets/ESP32/_nanoCLR/System.Device.I2c.Slave/sys_dev_i2c_slave_native_System_Device_I2c_I2cSlaveDevice.cpp index 66fcb9c749..a25e4da369 100644 --- a/targets/ESP32/_nanoCLR/System.Device.I2c.Slave/sys_dev_i2c_slave_native_System_Device_I2c_I2cSlaveDevice.cpp +++ b/targets/ESP32/_nanoCLR/System.Device.I2c.Slave/sys_dev_i2c_slave_native_System_Device_I2c_I2cSlaveDevice.cpp @@ -38,7 +38,7 @@ NF_PAL_I2CSLAVE *GetPalI2cSlaveFromBusIndex(int busIndex) #endif default: - return NULL; + return nullptr; } } @@ -82,7 +82,7 @@ void I2cSlaveRxWorkerTask(void *pvParameters) Events_Set(SYSTEM_EVENT_FLAG_I2C_SLAVE); // delete task - vTaskDelete(NULL); + vTaskDelete(nullptr); } void I2cSlaveTxWorkerTask(void *pvParameters) @@ -101,7 +101,7 @@ void I2cSlaveTxWorkerTask(void *pvParameters) Events_Set(SYSTEM_EVENT_FLAG_I2C_SLAVE); // delete task - vTaskDelete(NULL); + vTaskDelete(nullptr); } HRESULT Library_sys_dev_i2c_slave_native_System_Device_I2c_I2cSlaveDevice::NativeInit___VOID(CLR_RT_StackFrame &stack) @@ -124,7 +124,7 @@ HRESULT Library_sys_dev_i2c_slave_native_System_Device_I2c_I2cSlaveDevice::Nativ .slave = {.addr_10bit_en = 0, .slave_addr = 0, .maximum_speed = 0}, .clk_flags = 0}; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -175,13 +175,13 @@ HRESULT Library_sys_dev_i2c_slave_native_System_Device_I2c_I2cSlaveDevice::Nativ Esp_I2C_Initialised_Flag[bus]++; palI2c = GetPalI2cSlaveFromBusIndex(bus); - if (palI2c == NULL) + if (palI2c == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER); } palI2c->BusNum = bus; - palI2c->Buffer = NULL; + palI2c->Buffer = nullptr; palI2c->RequestedBytes = 0; palI2c->BytesTransferred = 0; palI2c->TimeoutTicks = 0; @@ -201,7 +201,7 @@ HRESULT Library_sys_dev_i2c_slave_native_System_Device_I2c_I2cSlaveDevice::Nativ i2c_port_t bus; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -219,7 +219,7 @@ HRESULT Library_sys_dev_i2c_slave_native_System_Device_I2c_I2cSlaveDevice:: { NANOCLR_HEADER(); - NF_PAL_I2CSLAVE *palI2c = NULL; + NF_PAL_I2CSLAVE *palI2c = nullptr; int32_t bufferOffset = 0; int32_t requestedCount = 0; @@ -234,10 +234,10 @@ HRESULT Library_sys_dev_i2c_slave_native_System_Device_I2c_I2cSlaveDevice:: CLR_RT_HeapBlock hbTimeout; CLR_RT_HeapBlock *readSpanByte; CLR_RT_HeapBlock *writeSpanByte; - CLR_RT_HeapBlock_Array *readBuffer = NULL; - CLR_RT_HeapBlock_Array *writeBuffer = NULL; + CLR_RT_HeapBlock_Array *readBuffer = nullptr; + CLR_RT_HeapBlock_Array *writeBuffer = nullptr; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -247,7 +247,7 @@ HRESULT Library_sys_dev_i2c_slave_native_System_Device_I2c_I2cSlaveDevice:: // get pointer to PAL UART palI2c = GetPalI2cSlaveFromBusIndex(bus); - if (palI2c == NULL) + if (palI2c == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER); } @@ -266,7 +266,7 @@ HRESULT Library_sys_dev_i2c_slave_native_System_Device_I2c_I2cSlaveDevice:: readBuffer = readSpanByte[SpanByte::FIELD___array].DereferenceArray(); - if (readBuffer != NULL) + if (readBuffer != nullptr) { // set flag to read operation isRead = true; @@ -282,7 +282,7 @@ HRESULT Library_sys_dev_i2c_slave_native_System_Device_I2c_I2cSlaveDevice:: { writeBuffer = writeSpanByte[SpanByte::FIELD___array].DereferenceArray(); - if (writeBuffer != NULL) + if (writeBuffer != nullptr) { // Get the write offset, only the elements defined by the span must be written, not the whole array bufferOffset = writeSpanByte[SpanByte::FIELD___start].NumericByRef().s4; @@ -292,7 +292,7 @@ HRESULT Library_sys_dev_i2c_slave_native_System_Device_I2c_I2cSlaveDevice:: } } - if (requestedCount == 0 || (writeBuffer == NULL && readBuffer == NULL)) + if (requestedCount == 0 || (writeBuffer == nullptr && readBuffer == nullptr)) { // nothing to do here NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER); @@ -320,7 +320,7 @@ HRESULT Library_sys_dev_i2c_slave_native_System_Device_I2c_I2cSlaveDevice:: // need to allocate buffer from internal memory palI2c->Buffer = (uint8_t *)heap_caps_malloc(requestedCount, MALLOC_CAP_8BIT | MALLOC_CAP_INTERNAL); - if (palI2c->Buffer == NULL) + if (palI2c->Buffer == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_OUT_OF_MEMORY); } @@ -494,15 +494,15 @@ HRESULT Library_sys_dev_i2c_slave_native_System_Device_I2c_I2cSlaveDevice:: if (hr != CLR_E_THREAD_WAITING) { - if (palI2c != NULL && palI2c->Buffer != NULL) + if (palI2c != nullptr && palI2c->Buffer != nullptr) { heap_caps_free(palI2c->Buffer); - palI2c->Buffer = NULL; + palI2c->Buffer = nullptr; } - if (palI2c != NULL && palI2c->I2cSlaveWorkerTaskStack != NULL) + if (palI2c != nullptr && palI2c->I2cSlaveWorkerTaskStack != nullptr) { heap_caps_free(palI2c->I2cSlaveWorkerTaskStack); - palI2c->I2cSlaveWorkerTaskStack = NULL; + palI2c->I2cSlaveWorkerTaskStack = nullptr; } } diff --git a/targets/ESP32/_nanoCLR/System.Device.I2c/sys_dev_i2c_native_System_Device_I2c_I2cDevice.cpp b/targets/ESP32/_nanoCLR/System.Device.I2c/sys_dev_i2c_native_System_Device_I2c_I2cDevice.cpp index 4968ed8d7f..76b962abc1 100644 --- a/targets/ESP32/_nanoCLR/System.Device.I2c/sys_dev_i2c_native_System_Device_I2c_I2cDevice.cpp +++ b/targets/ESP32/_nanoCLR/System.Device.I2c/sys_dev_i2c_native_System_Device_I2c_I2cDevice.cpp @@ -57,7 +57,7 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice::NativeInit___VOI { CLR_RT_HeapBlock *pConfig; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -106,7 +106,7 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice::NativeDispose___ CLR_RT_HeapBlock *pConfig; i2c_port_t bus; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -134,8 +134,8 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice:: { NANOCLR_HEADER(); - uint8_t *writeBuffer = NULL; - uint8_t *readBuffer = NULL; + uint8_t *writeBuffer = nullptr; + uint8_t *readBuffer = nullptr; int writeOffset = 0; int writeSize = 0; int readOffset = 0; @@ -149,14 +149,14 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice:: CLR_RT_HeapBlock *result; CLR_RT_HeapBlock *writeSpanByte; CLR_RT_HeapBlock *readSpanByte; - CLR_RT_HeapBlock_Array *writeData = NULL; - CLR_RT_HeapBlock_Array *readData = NULL; - CLR_RT_HeapBlock *pConfig = NULL; + CLR_RT_HeapBlock_Array *writeData = nullptr; + CLR_RT_HeapBlock_Array *readData = nullptr; + CLR_RT_HeapBlock *pConfig = nullptr; // create the return object (I2cTransferResult) CLR_RT_HeapBlock &top = stack.PushValueAndClear(); - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -173,11 +173,11 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice:: // dereference the write and read SpanByte from the arguments writeSpanByte = stack.Arg1().Dereference(); - if (writeSpanByte != NULL) + if (writeSpanByte != nullptr) { writeData = writeSpanByte[SpanByte::FIELD___array].DereferenceArray(); - if (writeData != NULL) + if (writeData != nullptr) { // Get the write offset, only the elements defined by the span must be written, not the whole array writeOffset = writeSpanByte[SpanByte::FIELD___start].NumericByRef().s4; @@ -190,7 +190,7 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice:: // need to allocate buffer from internal memory writeBuffer = (uint8_t *)heap_caps_malloc(writeSize, MALLOC_CAP_8BIT | MALLOC_CAP_INTERNAL); - if (writeBuffer == NULL) + if (writeBuffer == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_OUT_OF_MEMORY); } @@ -216,7 +216,7 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice:: { readData = readSpanByte[SpanByte::FIELD___array].DereferenceArray(); - if (readData != NULL) + if (readData != nullptr) { // Get the read offset, only the elements defined by the span must be read, not the whole array readOffset = readSpanByte[SpanByte::FIELD___start].NumericByRef().s4; @@ -229,7 +229,7 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice:: // need to allocate buffer from internal memory readBuffer = (uint8_t *)heap_caps_malloc(readSize, MALLOC_CAP_8BIT | MALLOC_CAP_INTERNAL); - if (readBuffer == NULL) + if (readBuffer == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_OUT_OF_MEMORY); } @@ -263,8 +263,7 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice:: i2c_cmd_link_delete(cmd); // create return object - NANOCLR_CHECK_HRESULT( - g_CLR_RT_ExecutionEngine.NewObjectFromIndex(top, g_CLR_RT_WellKnownTypes.m_I2cTransferResult)); + NANOCLR_CHECK_HRESULT(g_CLR_RT_ExecutionEngine.NewObjectFromIndex(top, g_CLR_RT_WellKnownTypes.I2cTransferResult)); result = top.Dereference(); FAULT_ON_NULL(result); diff --git a/targets/ESP32/_nanoCLR/System.Device.I2s/sys_dev_i2s_native_System_Device_I2s_I2sDevice.cpp b/targets/ESP32/_nanoCLR/System.Device.I2s/sys_dev_i2s_native_System_Device_I2s_I2sDevice.cpp index 6d7a39af43..6ae31b52f8 100644 --- a/targets/ESP32/_nanoCLR/System.Device.I2s/sys_dev_i2s_native_System_Device_I2s_I2sDevice.cpp +++ b/targets/ESP32/_nanoCLR/System.Device.I2s/sys_dev_i2s_native_System_Device_I2s_I2sDevice.cpp @@ -227,7 +227,7 @@ HRESULT SetI2sConfig(i2s_port_t bus, CLR_RT_HeapBlock *config) if (Esp_I2S_Initialised_Flag[bus] == 0) { // Install driver without events - esp_err_t res = i2s_driver_install(bus, &conf, 0, NULL); + esp_err_t res = i2s_driver_install(bus, &conf, 0, nullptr); if (res != ESP_OK) { NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER); @@ -356,13 +356,13 @@ HRESULT Library_sys_dev_i2s_native_System_Device_I2s_I2sDevice::Read___VOID__Sys { CLR_RT_HeapBlock *pConfig; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); - CLR_RT_HeapBlock *readSpanByte = NULL; - CLR_RT_HeapBlock_Array *readBuffer = NULL; - uint8_t *readData = NULL; + CLR_RT_HeapBlock *readSpanByte = nullptr; + CLR_RT_HeapBlock_Array *readBuffer = nullptr; + uint8_t *readData = nullptr; int readSize = 0; int readOffset = 0; uint8_t transform_buffer[SIZEOF_TRANSFORM_BUFFER_IN_BYTES]; @@ -394,11 +394,11 @@ HRESULT Library_sys_dev_i2s_native_System_Device_I2s_I2sDevice::Read___VOID__Sys // dereference the SpanByte from the arguments readSpanByte = stack.Arg1().Dereference(); - if (readSpanByte != NULL) + if (readSpanByte != nullptr) { readBuffer = readSpanByte[SpanByte::FIELD___array].DereferenceArray(); - if (readBuffer != NULL) + if (readBuffer != nullptr) { // Get the read offset, only the elements defined by the span must be read, not the whole array readOffset = readSpanByte[SpanByte::FIELD___start].NumericByRef().s4; @@ -477,13 +477,13 @@ HRESULT Library_sys_dev_i2s_native_System_Device_I2s_I2sDevice::Write___VOID__Sy { CLR_RT_HeapBlock *pConfig; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); - CLR_RT_HeapBlock *writeSpanByte = NULL; - CLR_RT_HeapBlock_Array *writeBuffer = NULL; - uint8_t *writeData = NULL; + CLR_RT_HeapBlock *writeSpanByte = nullptr; + CLR_RT_HeapBlock_Array *writeBuffer = nullptr; + uint8_t *writeData = nullptr; int writeSize = 0; int writeOffset = 0; size_t bytesWritten; @@ -510,11 +510,11 @@ HRESULT Library_sys_dev_i2s_native_System_Device_I2s_I2sDevice::Write___VOID__Sy // dereference the write and read SpanByte from the arguments writeSpanByte = stack.Arg1().Dereference(); - if (writeSpanByte != NULL) + if (writeSpanByte != nullptr) { writeBuffer = writeSpanByte[SpanByte::FIELD___array].DereferenceArray(); - if (writeBuffer != NULL) + if (writeBuffer != nullptr) { // Get the write offset, only the elements defined by the span must be written, not the whole array writeOffset = writeSpanByte[SpanByte::FIELD___start].NumericByRef().s4; @@ -553,7 +553,7 @@ HRESULT Library_sys_dev_i2s_native_System_Device_I2s_I2sDevice::NativeInit___VOI { CLR_RT_HeapBlock *pConfig; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -594,7 +594,7 @@ HRESULT Library_sys_dev_i2s_native_System_Device_I2s_I2sDevice::NativeDispose___ { CLR_RT_HeapBlock *pConfig; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); diff --git a/targets/ESP32/_nanoCLR/System.Device.Pwm/sys_dev_pwm_native_System_Device_Pwm_PwmChannel.cpp b/targets/ESP32/_nanoCLR/System.Device.Pwm/sys_dev_pwm_native_System_Device_Pwm_PwmChannel.cpp index c70b3d338e..9fdbc13c6a 100644 --- a/targets/ESP32/_nanoCLR/System.Device.Pwm/sys_dev_pwm_native_System_Device_Pwm_PwmChannel.cpp +++ b/targets/ESP32/_nanoCLR/System.Device.Pwm/sys_dev_pwm_native_System_Device_Pwm_PwmChannel.cpp @@ -238,7 +238,7 @@ HRESULT Library_sys_dev_pwm_native_System_Device_Pwm_PwmChannel::NativeInit___VO NANOCLR_HEADER(); - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -278,7 +278,7 @@ HRESULT Library_sys_dev_pwm_native_System_Device_Pwm_PwmChannel::NativeSetDesire NANOCLR_HEADER(); - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -359,7 +359,7 @@ HRESULT Library_sys_dev_pwm_native_System_Device_Pwm_PwmChannel::NativeSetActive NANOCLR_HEADER(); - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -429,7 +429,7 @@ HRESULT Library_sys_dev_pwm_native_System_Device_Pwm_PwmChannel::NativeStop___VO NANOCLR_HEADER(); - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); diff --git a/targets/ESP32/_nanoCLR/System.Device.Spi/cpu_spi.cpp b/targets/ESP32/_nanoCLR/System.Device.Spi/cpu_spi.cpp index 7f1213960b..45db74d5c0 100644 --- a/targets/ESP32/_nanoCLR/System.Device.Spi/cpu_spi.cpp +++ b/targets/ESP32/_nanoCLR/System.Device.Spi/cpu_spi.cpp @@ -433,8 +433,8 @@ HRESULT CPU_SPI_nWrite_nRead( { NANOCLR_HEADER(); { - uint8_t *writeDataBuffer = NULL; - uint8_t *readDataBuffer = NULL; + uint8_t *writeDataBuffer = nullptr; + uint8_t *readDataBuffer = nullptr; bool async = (wrc.callback != 0); esp_err_t ret; diff --git a/targets/ESP32/_nanoCLR/System.Device.Wifi/sys_dev_wifi_native_System_Device_Wifi_WifiAdapter.cpp b/targets/ESP32/_nanoCLR/System.Device.Wifi/sys_dev_wifi_native_System_Device_Wifi_WifiAdapter.cpp index 382be93810..1e0251432a 100644 --- a/targets/ESP32/_nanoCLR/System.Device.Wifi/sys_dev_wifi_native_System_Device_Wifi_WifiAdapter.cpp +++ b/targets/ESP32/_nanoCLR/System.Device.Wifi/sys_dev_wifi_native_System_Device_Wifi_WifiAdapter.cpp @@ -295,7 +295,7 @@ HRESULT Library_sys_dev_wifi_native_System_Device_Wifi_WifiAdapter::GetNativeSca rlen = StoreApRecordsToString(0, ap_records, number); } - NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_Array::CreateInstance(top, rlen, g_CLR_RT_WellKnownTypes.m_UInt8)); + NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_Array::CreateInstance(top, rlen, g_CLR_RT_WellKnownTypes.UInt8)); array = top.DereferenceArray(); buf = array->GetFirstElement(); @@ -330,7 +330,7 @@ HRESULT Library_sys_dev_wifi_native_System_Device_Wifi_WifiAdapter::NativeFindWi (HAL_Configuration_NetworkInterface *)platform_malloc(sizeof(HAL_Configuration_NetworkInterface)); // check allocation - if (netInterfaceConfig == NULL) + if (netInterfaceConfig == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_OUT_OF_MEMORY); } @@ -351,7 +351,7 @@ HRESULT Library_sys_dev_wifi_native_System_Device_Wifi_WifiAdapter::NativeFindWi } // build array with indexes of Wireless interfaces - NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_Array::CreateInstance(top, interfaceCount, g_CLR_RT_WellKnownTypes.m_UInt8)); + NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_Array::CreateInstance(top, interfaceCount, g_CLR_RT_WellKnownTypes.UInt8)); array = top.DereferenceArray(); arrayOfIndexes = array->GetFirstElement(); diff --git a/targets/ESP32/_nanoCLR/System.IO.FileSystem/nf_sys_io_filesystem_nanoFramework_System_IO_FileSystem_SDCard.cpp b/targets/ESP32/_nanoCLR/System.IO.FileSystem/nf_sys_io_filesystem_nanoFramework_System_IO_FileSystem_SDCard.cpp index e0d3f61602..8aa6722475 100644 --- a/targets/ESP32/_nanoCLR/System.IO.FileSystem/nf_sys_io_filesystem_nanoFramework_System_IO_FileSystem_SDCard.cpp +++ b/targets/ESP32/_nanoCLR/System.IO.FileSystem/nf_sys_io_filesystem_nanoFramework_System_IO_FileSystem_SDCard.cpp @@ -75,7 +75,7 @@ HRESULT Library_nf_sys_io_filesystem_nanoFramework_System_IO_FileSystem_SDCard:: int cardDetectPin; bool cdPinState; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -164,7 +164,7 @@ HRESULT Library_nf_sys_io_filesystem_nanoFramework_System_IO_FileSystem_SDCard:: int slotIndex; #endif - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -219,7 +219,7 @@ HRESULT Library_nf_sys_io_filesystem_nanoFramework_System_IO_FileSystem_SDCard:: int slotIndex; char mountPoint[] = INDEX0_DRIVE_LETTER; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -322,7 +322,7 @@ HRESULT Library_nf_sys_io_filesystem_nanoFramework_System_IO_FileSystem_SDCard:: SDCard_SDInterfaceType cardType; int slotIndex; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); diff --git a/targets/ESP32/_nanoCLR/System.IO.Ports/sys_io_ser_native_System_IO_Ports_SerialPort.cpp b/targets/ESP32/_nanoCLR/System.IO.Ports/sys_io_ser_native_System_IO_Ports_SerialPort.cpp index 0b91b4181e..b0095ddeeb 100644 --- a/targets/ESP32/_nanoCLR/System.IO.Ports/sys_io_ser_native_System_IO_Ports_SerialPort.cpp +++ b/targets/ESP32/_nanoCLR/System.IO.Ports/sys_io_ser_native_System_IO_Ports_SerialPort.cpp @@ -55,7 +55,7 @@ NF_PAL_UART *GetPalUartFromUartNum_sys(int uart_num) break; } - return NULL; + return nullptr; } void UninitializePalUart_sys(NF_PAL_UART *palUart) @@ -66,14 +66,14 @@ void UninitializePalUart_sys(NF_PAL_UART *palUart) uart_event_t event; event.type = UART_EVENT_MAX; xQueueSend(palUart->UartEventQueue, &event, 0); - palUart->UartEventTask = NULL; + palUart->UartEventTask = nullptr; // free buffer memory platform_free(palUart->RxBuffer); // null all pointers - palUart->RxBuffer = NULL; - palUart->TxBuffer = NULL; + palUart->RxBuffer = nullptr; + palUart->TxBuffer = nullptr; // delete driver uart_driver_delete((uart_port_t)palUart->UartNum); @@ -224,7 +224,7 @@ void uart_event_task_sys(void *pvParameters) } } - vTaskDelete(NULL); + vTaskDelete(nullptr); } void UartTxWorkerTask_sys(void *pvParameters) @@ -240,17 +240,17 @@ void UartTxWorkerTask_sys(void *pvParameters) Events_Set(SYSTEM_EVENT_FLAG_COM_OUT); // delete task - vTaskDelete(NULL); + vTaskDelete(nullptr); } HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::get_BytesToRead___I4(CLR_RT_StackFrame &stack) { NANOCLR_HEADER(); - NF_PAL_UART *palUart = NULL; + NF_PAL_UART *palUart = nullptr; uart_port_t uart_num; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -264,7 +264,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::get_BytesToRead___ // get pointer to PAL UART palUart = GetPalUartFromUartNum_sys(uart_num); - if (palUart == NULL) + if (palUart == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER); } @@ -279,10 +279,10 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::get_InvertSignalLe { NANOCLR_HEADER(); - NF_PAL_UART *palUart = NULL; + NF_PAL_UART *palUart = nullptr; uart_port_t uart_num; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -296,7 +296,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::get_InvertSignalLe // get pointer to PAL UART palUart = GetPalUartFromUartNum_sys(uart_num); - if (palUart == NULL) + if (palUart == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER); } @@ -311,10 +311,10 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::set_InvertSignalLe { NANOCLR_HEADER(); - NF_PAL_UART *palUart = NULL; + NF_PAL_UART *palUart = nullptr; uart_port_t uart_num; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -328,7 +328,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::set_InvertSignalLe // get pointer to PAL UART palUart = GetPalUartFromUartNum_sys(uart_num); - if (palUart == NULL) + if (palUart == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER); } @@ -351,7 +351,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::Read___I4__SZARRAY CLR_RT_HeapBlock hbTimeout; CLR_RT_HeapBlock_Array *dataBuffer; - NF_PAL_UART *palUart = NULL; + NF_PAL_UART *palUart = nullptr; uint8_t *data; @@ -365,7 +365,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::Read___I4__SZARRAY int64_t *timeoutTicks; bool eventResult = true; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -411,7 +411,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::Read___I4__SZARRAY // get pointer to PAL UART palUart = GetPalUartFromUartNum_sys(uart_num); - if (palUart == NULL) + if (palUart == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER); } @@ -493,15 +493,15 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::ReadExisting___STR { NANOCLR_HEADER(); - NF_PAL_UART *palUart = NULL; + NF_PAL_UART *palUart = nullptr; uart_port_t uart_num; - uint8_t *buffer = NULL; + uint8_t *buffer = nullptr; uint32_t bufferLength; CLR_RT_HeapBlock &top = stack.PushValue(); - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -515,7 +515,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::ReadExisting___STR // get pointer to PAL UART palUart = GetPalUartFromUartNum_sys(uart_num); - if (palUart == NULL) + if (palUart == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER); } @@ -529,7 +529,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::ReadExisting___STR buffer = (uint8_t *)platform_malloc(bufferLength); // sanity check - if (buffer == NULL) + if (buffer == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_OUT_OF_MEMORY); } @@ -542,12 +542,12 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::ReadExisting___STR else { // create an empty - NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_String::CreateInstance(top, (const char *)NULL)); + NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_String::CreateInstance(top, (const char *)nullptr)); } NANOCLR_CLEANUP(); - if (buffer != NULL) + if (buffer != nullptr) { platform_free(buffer); } @@ -560,18 +560,18 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::ReadLine___STRING( NANOCLR_HEADER(); CLR_RT_HeapBlock hbTimeout; - NF_PAL_UART *palUart = NULL; + NF_PAL_UART *palUart = nullptr; uart_port_t uart_num; - uint8_t *line = NULL; - const char *newLine = NULL; + uint8_t *line = nullptr; + const char *newLine = nullptr; uint32_t newLineLength; int64_t *timeoutTicks; bool eventResult = true; bool newLineFound = false; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -589,7 +589,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::ReadLine___STRING( // get pointer to PAL UART palUart = GetPalUartFromUartNum_sys(uart_num); - if (palUart == NULL) + if (palUart == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER); } @@ -611,8 +611,8 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::ReadLine___STRING( // get new line from field newLine = pThis[FIELD___newLine].RecoverString(); - // sanity check for NULL string - if (newLine == NULL) + // sanity check for nullptr string + if (newLine == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER); } @@ -660,7 +660,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::ReadLine___STRING( stack.SetResult_String((const char *)line); // free memory, if needed - if (line != NULL) + if (line != nullptr) { platform_free(line); } @@ -672,7 +672,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::Write___VOID__SZAR { NANOCLR_HEADER(); - NF_PAL_UART *palUart = NULL; + NF_PAL_UART *palUart = nullptr; CLR_RT_HeapBlock_Array *dataBuffer; CLR_RT_HeapBlock hbTimeout; @@ -687,7 +687,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::Write___VOID__SZAR int64_t *timeoutTicks; bool eventResult = true; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -701,7 +701,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::Write___VOID__SZAR // get pointer to PAL UART palUart = GetPalUartFromUartNum_sys(uart_num); - if (palUart == NULL) + if (palUart == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER); } @@ -770,7 +770,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::Write___VOID__SZAR char task_name[16]; snprintf(task_name, ARRAYSIZE(task_name), "uart%d_tx", uart_num); - if (xTaskCreate(UartTxWorkerTask_sys, task_name, 2048, palUart, 12, NULL) != pdPASS) + if (xTaskCreate(UartTxWorkerTask_sys, task_name, 2048, palUart, 12, nullptr) != pdPASS) { ESP_LOGE(TAG, "Failed to start UART TX task"); NANOCLR_SET_AND_LEAVE(CLR_E_FAIL); @@ -824,7 +824,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::Write___VOID__SZAR stack.SetResult_U4(length); // null pointers and vars - pThis = NULL; + pThis = nullptr; NANOCLR_NOCLEANUP(); } @@ -835,7 +835,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::NativeDispose___VO uart_port_t uart_num; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -859,7 +859,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::NativeInit___VOID( NF_PAL_UART *palUart; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -879,7 +879,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::NativeInit___VOID( #endif palUart = GetPalUartFromUartNum_sys(uart_num); - if (palUart == NULL) + if (palUart == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER); } @@ -899,7 +899,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::NativeInit___VOID( palUart->RxBuffer = (uint8_t *)platform_malloc(bufferSize); // sanity check - if (palUart->RxBuffer == NULL) + if (palUart->RxBuffer == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_OUT_OF_MEMORY); } @@ -964,7 +964,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::NativeConfig___VOI { uart_config_t uart_config = {}; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -1114,7 +1114,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::NativeConfig___VOI // get pointer to PAL UART NF_PAL_UART *palUart = GetPalUartFromUartNum_sys(uart_num); - if (palUart == NULL) + if (palUart == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER); } @@ -1171,7 +1171,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::NativeConfig___VOI } // null pointers and vars - pThis = NULL; + pThis = nullptr; } NANOCLR_NOCLEANUP(); } @@ -1183,7 +1183,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::NativeSetWatchChar uart_port_t uart_num; uint8_t watchChar; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -1211,7 +1211,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::NativeWriteString_ { NANOCLR_HEADER(); - NF_PAL_UART *palUart = NULL; + NF_PAL_UART *palUart = nullptr; uart_port_t uart_num; CLR_RT_HeapBlock hbTimeout; @@ -1219,12 +1219,12 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::NativeWriteString_ bool eventResult = true; bool isNewAllocation = false; - char *buffer = NULL; - const char *bufferPointer = NULL; + char *buffer = nullptr; + const char *bufferPointer = nullptr; uint32_t bufferLength; int32_t length = 0; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -1238,12 +1238,12 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::NativeWriteString_ // get pointer to PAL UART palUart = GetPalUartFromUartNum_sys(uart_num); - if (palUart == NULL) + if (palUart == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER); } - if (stack.Arg1().RecoverString() == NULL) + if (stack.Arg1().RecoverString() == nullptr) { // text string it's empty so there is noting to do here stack.SetResult_U4(0); @@ -1303,7 +1303,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::NativeWriteString_ char task_name[16]; snprintf(task_name, ARRAYSIZE(task_name), "uart%d_tx", uart_num); - if (xTaskCreate(UartTxWorkerTask_sys, task_name, 2048, palUart, 12, NULL) != pdPASS) + if (xTaskCreate(UartTxWorkerTask_sys, task_name, 2048, palUart, 12, nullptr) != pdPASS) { ESP_LOGE(TAG, "Failed to start UART TX task"); NANOCLR_SET_AND_LEAVE(CLR_E_FAIL); @@ -1369,13 +1369,13 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::NativeWriteString_ stack.SetResult_U4(length); // free memory, if it was allocated - if (isNewAllocation && buffer != NULL) + if (isNewAllocation && buffer != nullptr) { platform_free(buffer); } // null pointers and vars - pThis = NULL; + pThis = nullptr; NANOCLR_NOCLEANUP(); } @@ -1389,7 +1389,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::NativeReceivedByte int32_t threshold; uart_port_t uart_num; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -1406,7 +1406,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::NativeReceivedByte // get pointer to PAL UART palUart = GetPalUartFromUartNum_sys(uart_num); - if (palUart == NULL) + if (palUart == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER); } diff --git a/targets/ESP32/_nanoCLR/nanoCRT.cpp b/targets/ESP32/_nanoCLR/nanoCRT.cpp index 0968b35c6c..76a3990807 100644 --- a/targets/ESP32/_nanoCLR/nanoCRT.cpp +++ b/targets/ESP32/_nanoCLR/nanoCRT.cpp @@ -138,7 +138,7 @@ int hal_strcpy_s(char *strDst, size_t sizeInBytes, const char *strSrc) #undef strcpy size_t len; - if (strDst == NULL || strSrc == NULL || sizeInBytes == 0) + if (strDst == nullptr || strSrc == nullptr || sizeInBytes == 0) { _ASSERTE(FALSE); return 1; @@ -161,7 +161,7 @@ int hal_strncpy_s(char *strDst, size_t sizeInBytes, const char *strSrc, size_t c { NATIVE_PROFILE_PAL_CRT(); #undef strncpy - if (strDst == NULL || strSrc == NULL || sizeInBytes == 0) + if (strDst == nullptr || strSrc == nullptr || sizeInBytes == 0) { _ASSERTE(FALSE); return 1; @@ -195,7 +195,7 @@ int hal_strncmp_s(const char *str1, const char *str2, size_t num) { NATIVE_PROFILE_PAL_CRT(); #undef strncmp - if (str1 == NULL || str2 == NULL) + if (str1 == nullptr || str2 == nullptr) { _ASSERTE(FALSE); return 1; diff --git a/targets/ESP32/_nanoCLR/nanoFramework.Device.Bluetooth/esp32_nimble.cpp b/targets/ESP32/_nanoCLR/nanoFramework.Device.Bluetooth/esp32_nimble.cpp index 67d0b6658c..04475ea5d5 100644 --- a/targets/ESP32/_nanoCLR/nanoFramework.Device.Bluetooth/esp32_nimble.cpp +++ b/targets/ESP32/_nanoCLR/nanoFramework.Device.Bluetooth/esp32_nimble.cpp @@ -444,7 +444,7 @@ bool Esp32BleStartAdvertise(bleServicesContext *context) adv_params.conn_mode = bleContext.isConnectable ? BLE_GAP_CONN_MODE_UND : BLE_GAP_CONN_MODE_NON; adv_params.disc_mode = bleContext.isDiscoverable ? BLE_GAP_DISC_MODE_GEN : BLE_GAP_DISC_MODE_NON; - rc = ble_gap_adv_start(BLE_OWN_ADDR_PUBLIC, NULL, BLE_HS_FOREVER, &adv_params, Esp32GapEvent, (void *)&bleContext); + rc = ble_gap_adv_start(BLE_OWN_ADDR_PUBLIC, nullptr, BLE_HS_FOREVER, &adv_params, Esp32GapEvent, (void *)&bleContext); if (rc != 0) { BLE_DEBUG_PRINTF("error enabling advertisement; rc=%d\n", rc); @@ -468,7 +468,7 @@ static void Esp32BleOnSync(void) } uint8_t addr_val[6] = {0}; - rc = ble_hs_id_copy_addr(esp32_addr_type, addr_val, NULL); + rc = ble_hs_id_copy_addr(esp32_addr_type, addr_val, nullptr); if (rc != 0) { ESP_LOGI(tag, "error ble_hs_id_copy_addr; rc=%d\n", rc); @@ -549,8 +549,8 @@ void Device_ble_dispose() vSemaphoreDelete(ble_event_data.mutex); } - ble_event_waitgroup = NULL; - ble_event_data.mutex = NULL; + ble_event_waitgroup = nullptr; + ble_event_data.mutex = nullptr; ble_initialized = false; diff --git a/targets/ESP32/_nanoCLR/nanoFramework.Device.Bluetooth/nimble_utils.cpp b/targets/ESP32/_nanoCLR/nanoFramework.Device.Bluetooth/nimble_utils.cpp index a56c398bab..377c45ad81 100644 --- a/targets/ESP32/_nanoCLR/nanoFramework.Device.Bluetooth/nimble_utils.cpp +++ b/targets/ESP32/_nanoCLR/nanoFramework.Device.Bluetooth/nimble_utils.cpp @@ -185,7 +185,7 @@ HRESULT OmBufferToStack(CLR_RT_StackFrame &stack, os_mbuf *om) // Create managed byte array of correct size as per OM buffer NANOCLR_CHECK_HRESULT( - CLR_RT_HeapBlock_Array::CreateInstance(stack.PushValueAndClear(), om_len, g_CLR_RT_WellKnownTypes.m_UInt8)); + CLR_RT_HeapBlock_Array::CreateInstance(stack.PushValueAndClear(), om_len, g_CLR_RT_WellKnownTypes.UInt8)); // get a pointer to the first object in the array pReturnBuffer = stack.TopValue().DereferenceArray()->GetFirstElement(); @@ -202,14 +202,14 @@ HRESULT PushEmptyBufferToStack(CLR_RT_StackFrame &stack) { // Error return empty array, event not found ? NANOCLR_CHECK_HRESULT( - CLR_RT_HeapBlock_Array::CreateInstance(stack.PushValueAndClear(), 0, g_CLR_RT_WellKnownTypes.m_UInt8)); + CLR_RT_HeapBlock_Array::CreateInstance(stack.PushValueAndClear(), 0, g_CLR_RT_WellKnownTypes.UInt8)); } NANOCLR_NOCLEANUP(); } bool LockEventMutex() { - if (ble_event_data.mutex == NULL) + if (ble_event_data.mutex == nullptr) { return false; } @@ -219,7 +219,7 @@ bool LockEventMutex() void ReleaseEventMutex() { - if (ble_event_data.mutex == NULL) + if (ble_event_data.mutex == nullptr) { return; } diff --git a/targets/ESP32/_nanoCLR/nanoFramework.Device.Bluetooth/sys_dev_ble_native_nanoFramework_Device_Bluetooth_BluetoothLEAdvertisementWatcher.cpp b/targets/ESP32/_nanoCLR/nanoFramework.Device.Bluetooth/sys_dev_ble_native_nanoFramework_Device_Bluetooth_BluetoothLEAdvertisementWatcher.cpp index 81b1357ee3..098efa3dcf 100644 --- a/targets/ESP32/_nanoCLR/nanoFramework.Device.Bluetooth/sys_dev_ble_native_nanoFramework_Device_Bluetooth_BluetoothLEAdvertisementWatcher.cpp +++ b/targets/ESP32/_nanoCLR/nanoFramework.Device.Bluetooth/sys_dev_ble_native_nanoFramework_Device_Bluetooth_BluetoothLEAdvertisementWatcher.cpp @@ -42,7 +42,7 @@ void BleCentralStartScan() disc_params.filter_policy = BLE_HCI_SCAN_FILT_NO_WL; disc_params.limited = 0; - rc = ble_gap_disc(own_addr_type, BLE_HS_FOREVER, &disc_params, Esp32GapEvent, NULL); + rc = ble_gap_disc(own_addr_type, BLE_HS_FOREVER, &disc_params, Esp32GapEvent, nullptr); BLE_DEBUG_PRINTF("ble_gap_disc; reason=%d active %d\n", rc, ble_gap_disc_active()); if (rc != 0) { @@ -135,7 +135,7 @@ Library_sys_dev_ble_native_nanoFramework_Device_Bluetooth_Advertisement_Bluetoot NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_Array::CreateInstance( pThis[FIELD___rawAdvertData], gEvent->disc.length_data, - g_CLR_RT_WellKnownTypes.m_UInt8)); + g_CLR_RT_WellKnownTypes.UInt8)); buffer = pThis[FIELD___rawAdvertData].DereferenceArray()->GetFirstElement(); memcpy(buffer, gEvent->disc.data, gEvent->disc.length_data); @@ -151,4 +151,4 @@ Library_sys_dev_ble_native_nanoFramework_Device_Bluetooth_Advertisement_Bluetoot stack.SetResult_Boolean(result); } NANOCLR_NOCLEANUP(); -} \ No newline at end of file +} diff --git a/targets/ESP32/_nanoCLR/nanoFramework.Device.Bluetooth/sys_dev_ble_native_nanoFramework_Device_Bluetooth_BluetoothLEDevice.cpp b/targets/ESP32/_nanoCLR/nanoFramework.Device.Bluetooth/sys_dev_ble_native_nanoFramework_Device_Bluetooth_BluetoothLEDevice.cpp index 8c970bfda6..ee7c1be996 100644 --- a/targets/ESP32/_nanoCLR/nanoFramework.Device.Bluetooth/sys_dev_ble_native_nanoFramework_Device_Bluetooth_BluetoothLEDevice.cpp +++ b/targets/ESP32/_nanoCLR/nanoFramework.Device.Bluetooth/sys_dev_ble_native_nanoFramework_Device_Bluetooth_BluetoothLEDevice.cpp @@ -48,7 +48,7 @@ central_context *GetContext(ushort connection) { central_context *ptr = ConnectionList.FirstNode(); - while (ptr->Next() != NULL) + while (ptr->Next() != nullptr) { if (ptr->connectionHandle == connection) { @@ -58,7 +58,7 @@ central_context *GetContext(ushort connection) ptr = ptr->Next(); } - return NULL; + return nullptr; } void InitConnectionList() @@ -388,7 +388,7 @@ HRESULT Library_sys_dev_ble_native_nanoFramework_Device_Bluetooth_BluetoothLEDev // Fill in details for Gap event to use. con->connectionHandle = eventRouting; - rc = ble_gap_connect(own_addr_type, &peerAddr, connectTimeout, NULL, CentralGapEvent, con); + rc = ble_gap_connect(own_addr_type, &peerAddr, connectTimeout, nullptr, CentralGapEvent, con); BLE_DEBUG_PRINTF("ble_gap_connect exit %X\n", rc); if (rc == BLE_HS_EDONE) @@ -533,7 +533,7 @@ HRESULT Library_sys_dev_ble_native_nanoFramework_Device_Bluetooth_BluetoothLEDev central_context *con; BLE_DEBUG_PRINTF("NativeUpdateService\n"); - // get a pointer to the managed object instance of BlueToothLEDevcie and check that it's not NULL + // get a pointer to the managed object instance of BlueToothLEDevcie and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -671,7 +671,7 @@ HRESULT Library_sys_dev_ble_native_nanoFramework_Device_Bluetooth_GenericAttribu { NANOCLR_HEADER(); { - // get a pointer to the managed object instance of GattDeviceService and check that it's not NULL + // get a pointer to the managed object instance of GattDeviceService and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -790,7 +790,7 @@ HRESULT Library_sys_dev_ble_native_nanoFramework_Device_Bluetooth_BluetoothLEDev uint16_t val_handle = stack.Arg2().NumericByRef().u2; central_context *con = GetContext(conn_handle); - if (con == NULL) + if (con == nullptr) { rc = BLE_HS_ENOTCONN; } @@ -893,7 +893,7 @@ HRESULT Library_sys_dev_ble_native_nanoFramework_Device_Bluetooth_BluetoothLEDev bufferPtr = heapBuffer->GetFirstElement(); central_context *con = GetContext(conn_handle); - if (con == NULL) + if (con == nullptr) { rc = BLE_HS_ENOTCONN; } @@ -1056,4 +1056,4 @@ HRESULT Library_sys_dev_ble_native_nanoFramework_Device_Bluetooth_GenericAttribu xEventGroupSetBits(ble_event_waitgroup, N_BLE_EVENT_HANDLED); } NANOCLR_NOCLEANUP(); -} \ No newline at end of file +} diff --git a/targets/ESP32/_nanoCLR/nanoFramework.Device.Bluetooth/sys_dev_ble_native_nanoFramework_Device_Bluetooth_BluetoothNanoDevice.cpp b/targets/ESP32/_nanoCLR/nanoFramework.Device.Bluetooth/sys_dev_ble_native_nanoFramework_Device_Bluetooth_BluetoothNanoDevice.cpp index 753ff7055e..0acf573e14 100644 --- a/targets/ESP32/_nanoCLR/nanoFramework.Device.Bluetooth/sys_dev_ble_native_nanoFramework_Device_Bluetooth_BluetoothNanoDevice.cpp +++ b/targets/ESP32/_nanoCLR/nanoFramework.Device.Bluetooth/sys_dev_ble_native_nanoFramework_Device_Bluetooth_BluetoothNanoDevice.cpp @@ -7,7 +7,7 @@ BluetoothNanoDevice_Mode ble_operatingMode = BluetoothNanoDevice_Mode_NotRunning; -char *bleDeviceName = NULL; +char *bleDeviceName = nullptr; void UpdateNameInContext() { @@ -28,7 +28,7 @@ void SetDeviceName(const char *deviceName) if (bleDeviceName) { platform_free(bleDeviceName); - bleDeviceName = NULL; + bleDeviceName = nullptr; } size_t nlen = hal_strlen_s(deviceName); @@ -104,4 +104,4 @@ HRESULT Library_sys_dev_ble_native_nanoFramework_Device_Bluetooth_BluetoothNanoD } } NANOCLR_NOCLEANUP(); -} \ No newline at end of file +} diff --git a/targets/ESP32/_nanoCLR/nanoFramework.Device.Bluetooth/sys_dev_ble_native_nanoFramework_Device_Bluetooth_GenericAttributeProfile_GattServiceProvider.cpp b/targets/ESP32/_nanoCLR/nanoFramework.Device.Bluetooth/sys_dev_ble_native_nanoFramework_Device_Bluetooth_GenericAttributeProfile_GattServiceProvider.cpp index fb23ac49d4..9928ed7100 100644 --- a/targets/ESP32/_nanoCLR/nanoFramework.Device.Bluetooth/sys_dev_ble_native_nanoFramework_Device_Bluetooth_GenericAttributeProfile_GattServiceProvider.cpp +++ b/targets/ESP32/_nanoCLR/nanoFramework.Device.Bluetooth/sys_dev_ble_native_nanoFramework_Device_Bluetooth_GenericAttributeProfile_GattServiceProvider.cpp @@ -46,25 +46,25 @@ static void FreeContext(bleServicesContext &srvContext) if (srvContext.advertData) { platform_free((void *)srvContext.advertData); - srvContext.advertData = NULL; + srvContext.advertData = nullptr; } if (srvContext.scanResponse) { platform_free((void *)srvContext.scanResponse); - srvContext.scanResponse = NULL; + srvContext.scanResponse = nullptr; } if (srvContext.pDeviceName) { platform_free((void *)srvContext.pDeviceName); - srvContext.pDeviceName = NULL; + srvContext.pDeviceName = nullptr; } if (srvContext.gatt_service_def) { platform_free((void *)srvContext.gatt_service_def); - srvContext.gatt_service_def = NULL; + srvContext.gatt_service_def = nullptr; } // For each Service free up memory @@ -74,37 +74,37 @@ static void FreeContext(bleServicesContext &srvContext) if (context->serviceUuid) { platform_free(context->serviceUuid); - context->serviceUuid = NULL; + context->serviceUuid = nullptr; } if (context->characteristicsDefs) { platform_free(context->characteristicsDefs); - context->characteristicsDefs = NULL; + context->characteristicsDefs = nullptr; } if (context->characteristicsUuids) { platform_free(context->characteristicsUuids); - context->characteristicsUuids = NULL; + context->characteristicsUuids = nullptr; } if (context->attrHandles) { platform_free(context->attrHandles); - context->attrHandles = NULL; + context->attrHandles = nullptr; } if (context->descriptorDefs) { platform_free(context->descriptorDefs); - context->descriptorDefs = NULL; + context->descriptorDefs = nullptr; } if (context->descriptorUuids) { platform_free(context->descriptorUuids); - context->descriptorUuids = NULL; + context->descriptorUuids = nullptr; } } @@ -113,7 +113,7 @@ static void FreeContext(bleServicesContext &srvContext) if (srvContext.bleSrvContexts) { platform_free((void *)srvContext.bleSrvContexts); - srvContext.bleSrvContexts = NULL; + srvContext.bleSrvContexts = nullptr; } } @@ -173,7 +173,7 @@ bool BuildGattServices(bleServicesContext &context) // Define all services and null service(end) int svcDefSize = sizeof(ble_gatt_svc_def) * (srvCount + 1); ble_gatt_svc_def *svcDef = (ble_gatt_svc_def *)platform_malloc(svcDefSize); - if (svcDef == NULL) + if (svcDef == nullptr) { return false; } @@ -213,7 +213,7 @@ void AssignDescriptor(ble_gatt_dsc_def *pDsc, CLR_RT_HeapBlock *pPfItem, ble_uui pDsc->att_flags = BLE_ATT_F_READ; - if (pPfItem[GattLocalDescriptor::FIELD__WriteRequested].Dereference() != NULL) + if (pPfItem[GattLocalDescriptor::FIELD__WriteRequested].Dereference() != nullptr) { pDsc->att_flags |= BLE_ATT_F_WRITE; @@ -332,7 +332,7 @@ bool ParseAndBuildNimbleDefinition(ble_context &context, CLR_RT_HeapBlock *pGatt context.characteristicsCount = CharacteristicsCount; context.characteristicsDefs = (ble_gatt_chr_def *)platform_malloc(sizeof(ble_gatt_chr_def) * context.characteristicsCount); - if (context.characteristicsDefs == NULL) + if (context.characteristicsDefs == nullptr) { // Out of memory return false; @@ -348,7 +348,7 @@ bool ParseAndBuildNimbleDefinition(ble_context &context, CLR_RT_HeapBlock *pGatt { CLR_RT_HeapBlock *pUserDescriptionDescriptors = (CLR_RT_HeapBlock *)pItem[GattLocalCharacteristic::FIELD___userDescriptionDescriptor].Dereference(); - if (pUserDescriptionDescriptors != NULL) + if (pUserDescriptionDescriptors != nullptr) { descriptorCount++; } @@ -375,7 +375,7 @@ bool ParseAndBuildNimbleDefinition(ble_context &context, CLR_RT_HeapBlock *pGatt // Allocate attribute handles for characteristics context.attrHandles = (uint16_t *)platform_malloc(sizeof(uint16_t) * context.characteristicsCount); - if (context.attrHandles == NULL) + if (context.attrHandles == nullptr) { // Out of memory return false; @@ -384,7 +384,7 @@ bool ParseAndBuildNimbleDefinition(ble_context &context, CLR_RT_HeapBlock *pGatt // Allocate UUID table context.characteristicsUuids = (ble_uuid_any_t *)platform_malloc(sizeof(ble_uuid_any_t) * context.characteristicsCount); - if (context.characteristicsUuids == NULL) + if (context.characteristicsUuids == nullptr) { // Out of memory return false; @@ -392,13 +392,13 @@ bool ParseAndBuildNimbleDefinition(ble_context &context, CLR_RT_HeapBlock *pGatt // Allocate tables context.descriptorDefs = (ble_gatt_dsc_def *)platform_malloc(sizeof(ble_gatt_dsc_def) * descriptorCount); - if (context.descriptorDefs == NULL && descriptorCount != 0) + if (context.descriptorDefs == nullptr && descriptorCount != 0) { // Out of memory return false; } context.descriptorUuids = (ble_uuid_any_t *)platform_malloc(sizeof(ble_uuid_any_t) * descriptorCount); - if (context.descriptorUuids == NULL && descriptorCount != 0) + if (context.descriptorUuids == nullptr && descriptorCount != 0) { // Out of memory return false; @@ -535,7 +535,7 @@ bool ParseAndBuildNimbleDefinition(ble_context &context, CLR_RT_HeapBlock *pGatt // Set up User description descriptor if any CLR_RT_HeapBlock *pUserDescriptionDescriptors = (CLR_RT_HeapBlock *)pItem[GattLocalCharacteristic::FIELD___userDescriptionDescriptor].Dereference(); - if (pUserDescriptionDescriptors != NULL) + if (pUserDescriptionDescriptors != nullptr) { // Allocate descriptor for each User Description ble_gatt_dsc_def *pDsc = &context.descriptorDefs[descIndex]; @@ -582,7 +582,7 @@ bool ParseAndBuildNimbleDefinition(ble_context &context, CLR_RT_HeapBlock *pGatt } // Terminate characteristics - context.characteristicsDefs[CharacteristicsCount - 1].uuid = NULL; + context.characteristicsDefs[CharacteristicsCount - 1].uuid = nullptr; BLE_DEBUG_PRINTF( "characteristics start %X last def %X \n ", @@ -600,7 +600,7 @@ void PrintChars(const ble_gatt_chr_def *pchars) BLE_DEBUG_PRINTF("==Characteristics definitions==\n"); - while (pchar->uuid != NULL) + while (pchar->uuid != nullptr) { BLE_DEBUG_PRINTF("==characteristic==\n"); PrintUuid(pchar->uuid); @@ -657,7 +657,7 @@ HRESULT Library_sys_dev_ble_native_nanoFramework_Device_Bluetooth_GenericAttribu // Allocate contexts for all service definitions size_t bleContextSize = sizeof(ble_context) * bleContext.serviceCount; bleContext.bleSrvContexts = (ble_context *)platform_malloc(bleContextSize); - if (bleContext.bleSrvContexts == NULL) + if (bleContext.bleSrvContexts == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_OUT_OF_MEMORY); } @@ -843,4 +843,4 @@ HRESULT Library_sys_dev_ble_native_nanoFramework_Device_Bluetooth_Advertisement_ stack.SetResult_Boolean(result); } NANOCLR_NOCLEANUP_NOLABEL(); -} \ No newline at end of file +} diff --git a/targets/ESP32/_nanoCLR/nanoFramework.Device.Bluetooth/sys_dev_ble_native_nanoFramework_Device_Bluetooth_GenericAttributeProfile_GattWriteRequest.cpp b/targets/ESP32/_nanoCLR/nanoFramework.Device.Bluetooth/sys_dev_ble_native_nanoFramework_Device_Bluetooth_GenericAttributeProfile_GattWriteRequest.cpp index c1251e40c5..b2a00e019e 100644 --- a/targets/ESP32/_nanoCLR/nanoFramework.Device.Bluetooth/sys_dev_ble_native_nanoFramework_Device_Bluetooth_GenericAttributeProfile_GattWriteRequest.cpp +++ b/targets/ESP32/_nanoCLR/nanoFramework.Device.Bluetooth/sys_dev_ble_native_nanoFramework_Device_Bluetooth_GenericAttributeProfile_GattWriteRequest.cpp @@ -35,7 +35,7 @@ HRESULT Library_sys_dev_ble_native_nanoFramework_Device_Bluetooth_GenericAttribu NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_Array::CreateInstance( stack.PushValueAndClear(), om_len, - g_CLR_RT_WellKnownTypes.m_UInt8)); + g_CLR_RT_WellKnownTypes.UInt8)); // get a pointer to the first object in the array pReturnBuffer = stack.TopValue().DereferenceArray()->GetFirstElement(); @@ -53,7 +53,7 @@ HRESULT Library_sys_dev_ble_native_nanoFramework_Device_Bluetooth_GenericAttribu { // Error return empty array, event not found ? NANOCLR_CHECK_HRESULT( - CLR_RT_HeapBlock_Array::CreateInstance(stack.PushValueAndClear(), 0, g_CLR_RT_WellKnownTypes.m_UInt8)); + CLR_RT_HeapBlock_Array::CreateInstance(stack.PushValueAndClear(), 0, g_CLR_RT_WellKnownTypes.UInt8)); } } NANOCLR_NOCLEANUP(); @@ -105,4 +105,4 @@ HRESULT Library_sys_dev_ble_native_nanoFramework_Device_Bluetooth_GenericAttribu } } NANOCLR_NOCLEANUP_NOLABEL(); -} \ No newline at end of file +} diff --git a/targets/ESP32/_nanoCLR/nanoFramework.Device.OneWire/nf_dev_onewire_nanoFramework_Device_OneWire_OneWireHost.cpp b/targets/ESP32/_nanoCLR/nanoFramework.Device.OneWire/nf_dev_onewire_nanoFramework_Device_OneWire_OneWireHost.cpp index 5e21b0f248..20b712bf94 100644 --- a/targets/ESP32/_nanoCLR/nanoFramework.Device.OneWire/nf_dev_onewire_nanoFramework_Device_OneWire_OneWireHost.cpp +++ b/targets/ESP32/_nanoCLR/nanoFramework.Device.OneWire/nf_dev_onewire_nanoFramework_Device_OneWire_OneWireHost.cpp @@ -68,7 +68,7 @@ HRESULT oneWireInit() return CLR_E_INVALID_OPERATION; } - if (uart_driver_install(NF_ONEWIRE_ESP32_UART_NUM, 256, 256, 0, NULL, ESP_INTR_FLAG_IRAM) != ESP_OK) + if (uart_driver_install(NF_ONEWIRE_ESP32_UART_NUM, 256, 256, 0, nullptr, ESP_INTR_FLAG_IRAM) != ESP_OK) { return CLR_E_INVALID_OPERATION; } @@ -439,7 +439,7 @@ static void OneWireFindWorkingThread(void *pvParameters) // fire event for 1-Wire operation completed xTaskNotifyGive(WaitingTask); - vTaskDelete(NULL); + vTaskDelete(nullptr); } HRESULT FindOneDevice(CLR_RT_StackFrame &stack, bool findFirst) @@ -488,9 +488,9 @@ HRESULT FindOneDevice(CLR_RT_StackFrame &stack, bool findFirst) { // update serialNumber field - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); - if (pThis == NULL) + if (pThis == nullptr) { return CLR_E_NULL_REFERENCE; } diff --git a/targets/ESP32/_nanoCLR/nanoFramework.Hardware.ESP32/nanoFramework_hardware_esp32_native_System_Device_Gpio_GpioPulseCounter.cpp b/targets/ESP32/_nanoCLR/nanoFramework.Hardware.ESP32/nanoFramework_hardware_esp32_native_System_Device_Gpio_GpioPulseCounter.cpp index 6382c2f961..413cd198f2 100644 --- a/targets/ESP32/_nanoCLR/nanoFramework.Hardware.ESP32/nanoFramework_hardware_esp32_native_System_Device_Gpio_GpioPulseCounter.cpp +++ b/targets/ESP32/_nanoCLR/nanoFramework.Hardware.ESP32/nanoFramework_hardware_esp32_native_System_Device_Gpio_GpioPulseCounter.cpp @@ -25,7 +25,7 @@ typedef Library_corlib_native_System_TimeSpan TimeSpan; // Maximum count value from driver #define MAX_COUNTER_VALUE 0x7fff -// Pulse counter information entry held in "counterEntries" array when active, inactive entries will be NULL. +// Pulse counter information entry held in "counterEntries" array when active, inactive entries will be nullptr. struct PulseCounterEntry { int8_t gpioPinA; @@ -46,7 +46,7 @@ static IRAM_ATTR bool pcnt_callback_handler( void *user_ctx) { PulseCounterEntry *entry = counterEntries[(int)user_ctx]; - if (entry != NULL) + if (entry != nullptr) { if (edata->watch_point_value == MAX_COUNTER_VALUE) { @@ -69,7 +69,7 @@ static int FindFreeCounter(int gpioPinA, int gpioPinB) for (counterIndex = 0; counterIndex < PCNT_NUM_UNIT; counterIndex++) { - if (counterEntries[counterIndex] == NULL) + if (counterEntries[counterIndex] == nullptr) { PulseCounterEntry *counter = new PulseCounterEntry(); counterEntries[counterIndex] = counter; @@ -92,7 +92,7 @@ static int FindCounterForGpio(int gpioPin) for (counterIndex = 0; counterIndex < PCNT_NUM_UNIT; counterIndex++) { - if (counterEntries[counterIndex] != NULL && counterEntries[counterIndex]->gpioPinA == gpioPin) + if (counterEntries[counterIndex] != nullptr && counterEntries[counterIndex]->gpioPinA == gpioPin) { return counterIndex; } @@ -110,7 +110,7 @@ static pcnt_unit_handle_t InitialiseCounter(int counterIndex) if (counterIndex >= SOC_PCNT_UNITS_PER_GROUP) { - return NULL; + return nullptr; } PulseCounterEntry *counter = counterEntries[counterIndex]; @@ -121,19 +121,19 @@ static pcnt_unit_handle_t InitialiseCounter(int counterIndex) unit_config.low_limit = -MAX_COUNTER_VALUE; unit_config.high_limit = MAX_COUNTER_VALUE; - counter->unitHandle = NULL; + counter->unitHandle = nullptr; ec = pcnt_new_unit(&unit_config, &counter->unitHandle); if (ec != ESP_OK) { - return NULL; + return nullptr; } pcnt_chan_config_t chan_config_a = {}; chan_config_a.edge_gpio_num = counter->gpioPinA; chan_config_a.level_gpio_num = counter->gpioPinB; - counter->chanHandleA = NULL; - counter->chanHandleB = NULL; + counter->chanHandleA = nullptr; + counter->chanHandleB = nullptr; ec |= pcnt_new_channel(counter->unitHandle, &chan_config_a, &counter->chanHandleA); @@ -156,7 +156,7 @@ static pcnt_unit_handle_t InitialiseCounter(int counterIndex) cbs.on_reach = pcnt_callback_handler; pcnt_unit_register_event_callbacks(counter->unitHandle, &cbs, (void *)counterIndex); - return (ec == ESP_OK) ? counter->unitHandle : NULL; + return (ec == ESP_OK) ? counter->unitHandle : nullptr; } static pcnt_unit_handle_t InitialiseEdgeAndActions(int counterIndex, GpioPulsePolarity polarity) @@ -211,13 +211,13 @@ static pcnt_unit_handle_t InitialiseEdgeAndActions(int counterIndex, GpioPulsePo PCNT_CHANNEL_LEVEL_ACTION_INVERSE); } - return (ec == ESP_OK) ? counter->unitHandle : NULL; + return (ec == ESP_OK) ? counter->unitHandle : nullptr; } static void DisposeCounter(int counterIndex) { PulseCounterEntry *counter = counterEntries[counterIndex]; - if (counter != NULL) + if (counter != nullptr) { pcnt_unit_disable(counter->unitHandle); @@ -227,18 +227,18 @@ static void DisposeCounter(int counterIndex) pcnt_del_unit(counter->unitHandle); // delete channel A ? - if (counter->chanHandleA != NULL) + if (counter->chanHandleA != nullptr) { pcnt_del_channel(counter->chanHandleA); } // delete channel B ? - if (counter->chanHandleB != NULL) + if (counter->chanHandleB != nullptr) { pcnt_del_channel(counter->chanHandleB); } - counterEntries[counterIndex] = NULL; + counterEntries[counterIndex] = nullptr; delete counter; } } @@ -247,7 +247,7 @@ void PulseCountUninitialize() { for (int counterIndex = 0; counterIndex < PCNT_NUM_UNIT; counterIndex++) { - if (counterEntries[counterIndex] != NULL) + if (counterEntries[counterIndex] != nullptr) { DisposeCounter(counterIndex); } @@ -276,7 +276,7 @@ HRESULT Library_nanoFramework_hardware_esp32_native_System_Device_Gpio_GpioPulse // We need to initialize the array if it's the first one for (int i = 0; i < PCNT_NUM_UNIT; i++) { - counterEntries[i] = NULL; + counterEntries[i] = nullptr; } } @@ -294,7 +294,7 @@ HRESULT Library_nanoFramework_hardware_esp32_native_System_Device_Gpio_GpioPulse NANOCLR_SET_AND_LEAVE(CLR_E_NOT_SUPPORTED); } - if (InitialiseCounter(counterIndex) == NULL) + if (InitialiseCounter(counterIndex) == nullptr) { DisposeCounter(counterIndex); NANOCLR_SET_AND_LEAVE(CLR_E_NOT_SUPPORTED); diff --git a/targets/ESP32/_nanoCLR/nanoFramework.Hardware.ESP32/nanoFramework_hardware_esp32_native_nanoFramework_Hardware_Esp32_Touch_TouchPad.cpp b/targets/ESP32/_nanoCLR/nanoFramework.Hardware.ESP32/nanoFramework_hardware_esp32_native_nanoFramework_Hardware_Esp32_Touch_TouchPad.cpp index 558594ec6e..c1138115ee 100644 --- a/targets/ESP32/_nanoCLR/nanoFramework.Hardware.ESP32/nanoFramework_hardware_esp32_native_nanoFramework_Hardware_Esp32_Touch_TouchPad.cpp +++ b/targets/ESP32/_nanoCLR/nanoFramework.Hardware.ESP32/nanoFramework_hardware_esp32_native_nanoFramework_Hardware_Esp32_Touch_TouchPad.cpp @@ -14,7 +14,7 @@ static int numberInitialzed = 0; static bool isTouchInitialized = false; static bool isTouchPadUsed[TOUCH_PAD_MAX]; static bool isFilterOn = false; -static TaskHandle_t handleReadTask = NULL; +static TaskHandle_t handleReadTask = nullptr; static bool isTouched[TOUCH_PAD_MAX]; static uint32_t thresholds[TOUCH_PAD_MAX]; static bool isTimeModeOn = false; @@ -60,12 +60,12 @@ Resources need to be cleaned and the driver uninstalled in case of a soft reboot static void TouchPad_Uninitialize() { // stop the task - if (handleReadTask != NULL) + if (handleReadTask != nullptr) { vTaskDelete(handleReadTask); } - handleReadTask = NULL; + handleReadTask = nullptr; isTimeModeOn = false; // Clean the isr registration @@ -75,7 +75,7 @@ static void TouchPad_Uninitialize() touch_pad_intr_disable((touch_pad_intr_mask_t)(TOUCH_PAD_INTR_MASK_ACTIVE | TOUCH_PAD_INTR_MASK_INACTIVE | TOUCH_PAD_INTR_MASK_TIMEOUT)); #endif - touch_pad_isr_deregister(IsrCallBack, NULL); + touch_pad_isr_deregister(IsrCallBack, nullptr); // Clean filter and uninstall the driver #if defined(CONFIG_IDF_TARGET_ESP32) touch_pad_filter_stop(); @@ -126,10 +126,10 @@ static void MakeSureTouchIsInitialized() #if defined(CONFIG_IDF_TARGET_ESP32) // and features will be added in the future. // touch_pad_intr_enable(); - // touch_pad_isr_register(IsrCallBack, NULL); + // touch_pad_isr_register(IsrCallBack, nullptr); #else // touch_pad_intr_enable(TOUCH_PAD_INTR_MASK_ACTIVE | TOUCH_PAD_INTR_MASK_INACTIVE | - // TOUCH_PAD_INTR_MASK_TIMEOUT); touch_pad_isr_register(IsrCallBack, NULL, TOUCH_PAD_INTR_MASK_ALL); + // TOUCH_PAD_INTR_MASK_TIMEOUT); touch_pad_isr_register(IsrCallBack, nullptr, TOUCH_PAD_INTR_MASK_ALL); #endif } } @@ -793,14 +793,14 @@ HRESULT Library_nanoFramework_hardware_esp32_native_nanoFramework_Hardware_Esp32 isTimeModeOn = false; // If we just switch mode, we have to wait for the task to exit // So killing it - if (handleReadTask != NULL) + if (handleReadTask != nullptr) { vTaskDelete(handleReadTask); } // Waiting a bit to make sure the task is properly deleted vTaskDelay(20 / portTICK_PERIOD_MS); - handleReadTask = NULL; + handleReadTask = nullptr; } // We are starting a task when on timer mode. @@ -810,7 +810,7 @@ HRESULT Library_nanoFramework_hardware_esp32_native_nanoFramework_Hardware_Esp32 { isTimeModeOn = true; // Start a task to show what pads have been touched - xTaskCreate(&ReadTask, "ReadTask", 4096, NULL, 5, &handleReadTask); + xTaskCreate(&ReadTask, "ReadTask", 4096, nullptr, 5, &handleReadTask); } } diff --git a/targets/ESP32/_nanoCLR/nanoFramework.Hardware.Esp32.Rmt/nanoFramework_hardware_esp32_rmt_native_nanoFramework_Hardware_Esp32_Rmt_ReceiverChannel.cpp b/targets/ESP32/_nanoCLR/nanoFramework.Hardware.Esp32.Rmt/nanoFramework_hardware_esp32_rmt_native_nanoFramework_Hardware_Esp32_Rmt_ReceiverChannel.cpp index b4ebef726c..14c83d8628 100644 --- a/targets/ESP32/_nanoCLR/nanoFramework.Hardware.Esp32.Rmt/nanoFramework_hardware_esp32_rmt_native_nanoFramework_Hardware_Esp32_Rmt_ReceiverChannel.cpp +++ b/targets/ESP32/_nanoCLR/nanoFramework.Hardware.Esp32.Rmt/nanoFramework_hardware_esp32_rmt_native_nanoFramework_Hardware_Esp32_Rmt_ReceiverChannel.cpp @@ -27,7 +27,7 @@ HRESULT Library_nanoFramework_hardware_esp32_rmt_native_nanoFramework_Hardware_E CLR_RT_HeapBlock *receiver_channel_settings; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -105,7 +105,7 @@ HRESULT Library_nanoFramework_hardware_esp32_rmt_native_nanoFramework_Hardware_E { NANOCLR_HEADER(); - CLR_RT_HeapBlock *receiver_channel_settings = NULL; + CLR_RT_HeapBlock *receiver_channel_settings = nullptr; CLR_INT32 channel; bool clearBuffer; esp_err_t err; @@ -134,7 +134,7 @@ HRESULT Library_nanoFramework_hardware_esp32_rmt_native_nanoFramework_Hardware_E size_t length = 0; rmt_item32_t *rmtItems; - while ((rmtItems = (rmt_item32_t *)xRingbufferReceive(ringbufHandle, &length, 0)) != NULL) + while ((rmtItems = (rmt_item32_t *)xRingbufferReceive(ringbufHandle, &length, 0)) != nullptr) { // Release items back to Ringbuffer vRingbufferReturnItem(ringbufHandle, (void *)rmtItems); @@ -155,7 +155,7 @@ HRESULT Library_nanoFramework_hardware_esp32_rmt_native_nanoFramework_Hardware_E { NANOCLR_HEADER(); - CLR_RT_HeapBlock *receiver_channel_settings = NULL; + CLR_RT_HeapBlock *receiver_channel_settings = nullptr; CLR_INT32 channel; esp_err_t err; @@ -185,7 +185,7 @@ HRESULT Library_nanoFramework_hardware_esp32_rmt_native_nanoFramework_Hardware_E RingbufHandle_t ringbufHandle; UBaseType_t uxItemsWaiting; - CLR_RT_HeapBlock *receiver_channel_settings = NULL; + CLR_RT_HeapBlock *receiver_channel_settings = nullptr; CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -200,7 +200,7 @@ HRESULT Library_nanoFramework_hardware_esp32_rmt_native_nanoFramework_Hardware_E NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER); } - vRingbufferGetInfo(ringbufHandle, NULL, NULL, NULL, NULL, &uxItemsWaiting); + vRingbufferGetInfo(ringbufHandle, nullptr, nullptr, nullptr, nullptr, &uxItemsWaiting); stack.SetResult_I4(uxItemsWaiting); @@ -280,9 +280,9 @@ HRESULT Library_nanoFramework_hardware_esp32_rmt_native_nanoFramework_Hardware_E CLR_INT32 waitMs; CLR_INT64 *timespan; size_t length = 0; - rmt_item32_t *rmtItems = NULL; + rmt_item32_t *rmtItems = nullptr; - CLR_RT_HeapBlock *receiver_channel_settings = NULL; + CLR_RT_HeapBlock *receiver_channel_settings = nullptr; CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -336,7 +336,7 @@ HRESULT Library_nanoFramework_hardware_esp32_rmt_native_nanoFramework_Hardware_E if (length == 0) { - stack.SetResult_Object(NULL); + stack.SetResult_Object(nullptr); } NANOCLR_NOCLEANUP(); @@ -352,7 +352,7 @@ HRESULT Library_nanoFramework_hardware_esp32_rmt_native_nanoFramework_Hardware_E uint8_t threshold; esp_err_t err; - CLR_RT_HeapBlock *receiver_channel_settings = NULL; + CLR_RT_HeapBlock *receiver_channel_settings = nullptr; CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -382,7 +382,7 @@ HRESULT Library_nanoFramework_hardware_esp32_rmt_native_nanoFramework_Hardware_E CLR_INT32 channel; esp_err_t err; - CLR_RT_HeapBlock *receiver_channel_settings = NULL; + CLR_RT_HeapBlock *receiver_channel_settings = nullptr; CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -409,7 +409,7 @@ HRESULT Library_nanoFramework_hardware_esp32_rmt_native_nanoFramework_Hardware_E CLR_INT32 channel; - CLR_RT_HeapBlock *receiver_channel_settings = NULL; + CLR_RT_HeapBlock *receiver_channel_settings = nullptr; CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); diff --git a/targets/ESP32/_nanoCLR/nanoFramework.Hardware.Esp32.Rmt/nanoFramework_hardware_esp32_rmt_native_nanoFramework_Hardware_Esp32_Rmt_RmtChannel.cpp b/targets/ESP32/_nanoCLR/nanoFramework.Hardware.Esp32.Rmt/nanoFramework_hardware_esp32_rmt_native_nanoFramework_Hardware_Esp32_Rmt_RmtChannel.cpp index ecb3a44b2a..af212c82c9 100644 --- a/targets/ESP32/_nanoCLR/nanoFramework.Hardware.Esp32.Rmt/nanoFramework_hardware_esp32_rmt_native_nanoFramework_Hardware_Esp32_Rmt_RmtChannel.cpp +++ b/targets/ESP32/_nanoCLR/nanoFramework.Hardware.Esp32.Rmt/nanoFramework_hardware_esp32_rmt_native_nanoFramework_Hardware_Esp32_Rmt_RmtChannel.cpp @@ -45,7 +45,7 @@ HRESULT Library_nanoFramework_hardware_esp32_rmt_native_nanoFramework_Hardware_E { NANOCLR_HEADER(); - CLR_RT_HeapBlock *channel_settings = NULL; + CLR_RT_HeapBlock *channel_settings = nullptr; int32_t channel; uint8_t clockdiv = (uint8_t)stack.Arg1().NumericByRef().u1; @@ -71,7 +71,7 @@ HRESULT Library_nanoFramework_hardware_esp32_rmt_native_nanoFramework_Hardware_E { NANOCLR_HEADER(); { - CLR_RT_HeapBlock *channel_settings = NULL; + CLR_RT_HeapBlock *channel_settings = nullptr; int32_t channel; uint8_t rmt_mem_num; diff --git a/targets/ESP32/_nanoCLR/nanoFramework.Hardware.Esp32.Rmt/nanoFramework_hardware_esp32_rmt_native_nanoFramework_Hardware_Esp32_Rmt_TransmitterChannel.cpp b/targets/ESP32/_nanoCLR/nanoFramework.Hardware.Esp32.Rmt/nanoFramework_hardware_esp32_rmt_native_nanoFramework_Hardware_Esp32_Rmt_TransmitterChannel.cpp index 6d0883522d..613b76d828 100644 --- a/targets/ESP32/_nanoCLR/nanoFramework.Hardware.Esp32.Rmt/nanoFramework_hardware_esp32_rmt_native_nanoFramework_Hardware_Esp32_Rmt_TransmitterChannel.cpp +++ b/targets/ESP32/_nanoCLR/nanoFramework.Hardware.Esp32.Rmt/nanoFramework_hardware_esp32_rmt_native_nanoFramework_Hardware_Esp32_Rmt_TransmitterChannel.cpp @@ -17,7 +17,7 @@ HRESULT Library_nanoFramework_hardware_esp32_rmt_native_nanoFramework_Hardware_E { NANOCLR_HEADER(); { - CLR_RT_HeapBlock *transmitter_channel_settings = NULL; + CLR_RT_HeapBlock *transmitter_channel_settings = nullptr; int32_t channel; int32_t pin_number; @@ -110,7 +110,7 @@ HRESULT Library_nanoFramework_hardware_esp32_rmt_native_nanoFramework_Hardware_E { NANOCLR_HEADER(); - CLR_RT_HeapBlock *transmitter_channel_settings = NULL; + CLR_RT_HeapBlock *transmitter_channel_settings = nullptr; int32_t channel; bool retVal = 0; rmt_idle_level_t level; @@ -139,7 +139,7 @@ HRESULT Library_nanoFramework_hardware_esp32_rmt_native_nanoFramework_Hardware_E { NANOCLR_HEADER(); - CLR_RT_HeapBlock *transmitter_channel_settings = NULL; + CLR_RT_HeapBlock *transmitter_channel_settings = nullptr; int32_t channel; bool enabled; esp_err_t err; @@ -173,7 +173,7 @@ HRESULT Library_nanoFramework_hardware_esp32_rmt_native_nanoFramework_Hardware_E #if SOC_RMT_SUPPORT_TX_LOOP_COUNT - CLR_RT_HeapBlock *transmitter_channel_settings = NULL; + CLR_RT_HeapBlock *transmitter_channel_settings = nullptr; int32_t channel; uint32_t count; esp_err_t err; @@ -218,7 +218,7 @@ HRESULT Library_nanoFramework_hardware_esp32_rmt_native_nanoFramework_Hardware_E bool carrier_level; esp_err_t err; - CLR_RT_HeapBlock *transmitter_channel_settings = NULL; + CLR_RT_HeapBlock *transmitter_channel_settings = nullptr; CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -270,7 +270,7 @@ HRESULT Library_nanoFramework_hardware_esp32_rmt_native_nanoFramework_Hardware_E bool idle_level; esp_err_t err; - CLR_RT_HeapBlock *transmitter_channel_settings = NULL; + CLR_RT_HeapBlock *transmitter_channel_settings = nullptr; CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -301,7 +301,7 @@ HRESULT Library_nanoFramework_hardware_esp32_rmt_native_nanoFramework_Hardware_E { NANOCLR_HEADER(); - CLR_RT_HeapBlock *transmitter_channel_settings = NULL; + CLR_RT_HeapBlock *transmitter_channel_settings = nullptr; CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -344,7 +344,7 @@ HRESULT Library_nanoFramework_hardware_esp32_rmt_native_nanoFramework_Hardware_E { NANOCLR_HEADER(); - CLR_RT_HeapBlock *transmitter_channel_settings = NULL; + CLR_RT_HeapBlock *transmitter_channel_settings = nullptr; int32_t channel; CLR_RT_HeapBlock *pThis = stack.This(); @@ -396,4 +396,4 @@ rmt_config_t Library_nanoFramework_hardware_esp32_rmt_native_nanoFramework_Hardw config.tx_config.idle_output_en = true; return config; -} \ No newline at end of file +} diff --git a/targets/ESP32/_nanoCLR/nanoFramework.Networking.Thread/net_thread_native_nanoFramework_Networking_Thread_OpenThread.cpp b/targets/ESP32/_nanoCLR/nanoFramework.Networking.Thread/net_thread_native_nanoFramework_Networking_Thread_OpenThread.cpp index d27741d4e8..106470b33c 100644 --- a/targets/ESP32/_nanoCLR/nanoFramework.Networking.Thread/net_thread_native_nanoFramework_Networking_Thread_OpenThread.cpp +++ b/targets/ESP32/_nanoCLR/nanoFramework.Networking.Thread/net_thread_native_nanoFramework_Networking_Thread_OpenThread.cpp @@ -108,7 +108,7 @@ HRESULT StoreDataset(CLR_RT_StackFrame &stack, otOperationalDataset &dataset, CL NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_Array::CreateInstance( datasetObject[OpenThreadDataSet::FIELD___networkName], len, - g_CLR_RT_WellKnownTypes.m_UInt8)); + g_CLR_RT_WellKnownTypes.UInt8)); memcpy( datasetObject[OpenThreadDataSet::FIELD___networkName].DereferenceArray()->GetElement(0), dataset.mNetworkName.m8, @@ -123,7 +123,7 @@ HRESULT StoreDataset(CLR_RT_StackFrame &stack, otOperationalDataset &dataset, CL NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_Array::CreateInstance( datasetObject[OpenThreadDataSet::FIELD___extendedPanId], OT_EXT_PAN_ID_SIZE, - g_CLR_RT_WellKnownTypes.m_UInt8)); + g_CLR_RT_WellKnownTypes.UInt8)); memcpy( datasetObject[OpenThreadDataSet::FIELD___extendedPanId].DereferenceArray()->GetElement(0), dataset.mExtendedPanId.m8, @@ -138,7 +138,7 @@ HRESULT StoreDataset(CLR_RT_StackFrame &stack, otOperationalDataset &dataset, CL NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_Array::CreateInstance( datasetObject[OpenThreadDataSet::FIELD___networkKey], OT_NETWORK_KEY_SIZE, - g_CLR_RT_WellKnownTypes.m_UInt8)); + g_CLR_RT_WellKnownTypes.UInt8)); memcpy( datasetObject[OpenThreadDataSet::FIELD___networkKey].DereferenceArray()->GetElement(0), dataset.mNetworkKey.m8, @@ -226,7 +226,7 @@ HRESULT Library_net_thread_native_nanoFramework_Networking_Thread_OpenThread::Na // Fill in active dataset from managed object CLR_RT_HeapBlock *datasetRef = pThis[Networking_Thread_OpenThread::FIELD___dataset].Dereference(); - if (datasetRef != NULL) + if (datasetRef != nullptr) { LoadDataset(dataset, datasetRef); @@ -260,7 +260,7 @@ HRESULT Library_net_thread_native_nanoFramework_Networking_Thread_OpenThread::Na // Save active dataset to managed object CLR_RT_HeapBlock *datasetRef = pThis[Networking_Thread_OpenThread::FIELD___dataset].Dereference(); - if (datasetRef != NULL) + if (datasetRef != nullptr) { // Save active dataset to managed object oterr = otDatasetGetActive(instance, &dataset); @@ -280,7 +280,7 @@ HRESULT Library_net_thread_native_nanoFramework_Networking_Thread_OpenThread::Na NANOCLR_HEADER(); { const char *pskc = stack.Arg1().DereferenceString()->StringText(); - JoinerStart(pskc, NULL); + JoinerStart(pskc, nullptr); } NANOCLR_NOCLEANUP_NOLABEL(); } @@ -326,7 +326,7 @@ HRESULT Library_net_thread_native_nanoFramework_Networking_Thread_OpenThread:: { NANOCLR_HEADER(); { - const char *commandLine = NULL; + const char *commandLine = nullptr; bool waitResponse = false; commandLine = stack.Arg1().DereferenceString()->StringText(); @@ -360,7 +360,7 @@ HRESULT Library_net_thread_native_nanoFramework_Networking_Thread_OpenThread::Na stack.PushValueAndClear(); NANOCLR_CHECK_HRESULT( - CLR_RT_HeapBlock_Array::CreateInstance(stack.TopValue(), 16, g_CLR_RT_WellKnownTypes.m_UInt8)); + CLR_RT_HeapBlock_Array::CreateInstance(stack.TopValue(), 16, g_CLR_RT_WellKnownTypes.UInt8)); // Get address of frist element iparray = stack.TopValue().DereferenceArray()->GetFirstElement(); diff --git a/targets/ESP32/_nanoCLR/nanoFramework.Runtime.Native/nf_rt_native_nanoFramework_Runtime_Native_Rtc.cpp b/targets/ESP32/_nanoCLR/nanoFramework.Runtime.Native/nf_rt_native_nanoFramework_Runtime_Native_Rtc.cpp index 0d388206d6..28dbddc559 100644 --- a/targets/ESP32/_nanoCLR/nanoFramework.Runtime.Native/nf_rt_native_nanoFramework_Runtime_Native_Rtc.cpp +++ b/targets/ESP32/_nanoCLR/nanoFramework.Runtime.Native/nf_rt_native_nanoFramework_Runtime_Native_Rtc.cpp @@ -29,7 +29,7 @@ HRESULT Library_nf_rt_native_nanoFramework_Runtime_Native_Rtc::Native_RTC_SetSys time_t t = mktime(&newTime); struct timeval now = { .tv_sec = t, .tv_usec = 0 }; - settimeofday(&now, NULL); + settimeofday(&now, nullptr); // Return value to the managed application stack.SetResult_Boolean(true); diff --git a/targets/ESP32/_nanoCLR/nanoFramework.System.IO.Hashing/nf_sys_io_hashing_System_IO_Hashing_Crc32.cpp b/targets/ESP32/_nanoCLR/nanoFramework.System.IO.Hashing/nf_sys_io_hashing_System_IO_Hashing_Crc32.cpp index b15b6c977d..3dd2b12652 100644 --- a/targets/ESP32/_nanoCLR/nanoFramework.System.IO.Hashing/nf_sys_io_hashing_System_IO_Hashing_Crc32.cpp +++ b/targets/ESP32/_nanoCLR/nanoFramework.System.IO.Hashing/nf_sys_io_hashing_System_IO_Hashing_Crc32.cpp @@ -15,13 +15,13 @@ HRESULT Library_nf_sys_io_hashing_System_IO_Hashing_Crc32::ComputeHash___STATIC_ CLR_RT_HeapBlock *bufferSpanByte; CLR_RT_HeapBlock_Array *buffer; - uint8_t *bufferData = NULL; + uint8_t *bufferData = nullptr; int16_t bufferSize = 0; int16_t bufferOffset = 0; uint32_t crc32 = 0; uint32_t hash = 0; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr bufferSpanByte = stack.Arg1().Dereference(); FAULT_ON_NULL_ARG(bufferSpanByte); diff --git a/targets/ESP32/_nanoCLR/targetHAL.cpp b/targets/ESP32/_nanoCLR/targetHAL.cpp index 0bc0da8629..348a15af44 100644 --- a/targets/ESP32/_nanoCLR/targetHAL.cpp +++ b/targets/ESP32/_nanoCLR/targetHAL.cpp @@ -30,13 +30,13 @@ extern void ibeacon_start(); // Reboot handlers clean up on reboot // static ON_SOFT_REBOOT_HANDLER s_rebootHandlers[16] = - {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}; + {nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr}; void HAL_AddSoftRebootHandler(ON_SOFT_REBOOT_HANDLER handler) { for (unsigned int i = 0; i < ARRAYSIZE(s_rebootHandlers); i++) { - if (s_rebootHandlers[i] == NULL) + if (s_rebootHandlers[i] == nullptr) { s_rebootHandlers[i] = handler; return; @@ -87,7 +87,7 @@ void nanoHAL_Initialize() FileSystemVolumeList::InitializeVolumes(); // allocate & clear managed heap region - unsigned char *heapStart = NULL; + unsigned char *heapStart = nullptr; unsigned int heapSize = 0; ::HeapLocation(heapStart, heapSize); @@ -138,7 +138,7 @@ void nanoHAL_Uninitialize(bool isPoweringDown) // check for s_rebootHandlers for (unsigned int i = 0; i < ARRAYSIZE(s_rebootHandlers); i++) { - if (s_rebootHandlers[i] != NULL) + if (s_rebootHandlers[i] != nullptr) { s_rebootHandlers[i](); } diff --git a/targets/ESP32/_nanoCLR/targetHAL_Time.cpp b/targets/ESP32/_nanoCLR/targetHAL_Time.cpp index d4f1e97a10..b5608ecdb2 100644 --- a/targets/ESP32/_nanoCLR/targetHAL_Time.cpp +++ b/targets/ESP32/_nanoCLR/targetHAL_Time.cpp @@ -19,7 +19,7 @@ uint64_t HAL_Time_CurrentDateTime(bool datePartOnly) struct timeval tv; - gettimeofday(&tv, NULL); + gettimeofday(&tv, nullptr); // Convert from Unix time(year since 1900) to SYSTEMTIME(Years since 1601) int64_t time = ((int64_t)tv.tv_sec * (int64_t)TIME_CONVERSION__TO_SECONDS) + ((int64_t)tv.tv_usec * (int64_t)TIME_CONVERSION__TO_USECS) + TIME_UNIX_EPOCH_AS_TICKS; @@ -58,7 +58,7 @@ void HAL_Time_SetUtcTime(uint64_t utcTime) time_t t = mktime(&newTime); struct timeval now = { .tv_sec = t, .tv_usec = 0 }; - settimeofday(&now, NULL); + settimeofday(&now, nullptr); } bool HAL_Time_TimeSpanToStringEx( const int64_t& ticks, char*& buf, size_t& len ) diff --git a/targets/ESP32/_nanoCLR/targetPAL_Events.cpp b/targets/ESP32/_nanoCLR/targetPAL_Events.cpp index 18eae3f1c8..a49efbaee1 100644 --- a/targets/ESP32/_nanoCLR/targetPAL_Events.cpp +++ b/targets/ESP32/_nanoCLR/targetPAL_Events.cpp @@ -45,7 +45,7 @@ void Events_SetBoolTimer(bool *timerCompleteFlag, uint32_t millisecondsFromNow) // we assume only 1 can be active, abort previous just in case xTimerStop(boolEventsTimer, 0); - if (timerCompleteFlag != NULL) + if (timerCompleteFlag != nullptr) { vTimerSetTimerID(boolEventsTimer, (void *)timerCompleteFlag); xTimerChangePeriod(boolEventsTimer, millisecondsFromNow / portTICK_PERIOD_MS, 0); diff --git a/targets/FreeRTOS/NXP/_common/targetHAL_ConfigurationManager.cpp b/targets/FreeRTOS/NXP/_common/targetHAL_ConfigurationManager.cpp index 5e13cd372b..16d12b6c84 100644 --- a/targets/FreeRTOS/NXP/_common/targetHAL_ConfigurationManager.cpp +++ b/targets/FreeRTOS/NXP/_common/targetHAL_ConfigurationManager.cpp @@ -103,7 +103,7 @@ bool ConfigurationManager_GetConfigurationBlock( uint32_t configurationIndex) { int sizeOfBlock = 0; - uint8_t *blockAddress = NULL; + uint8_t *blockAddress = nullptr; // validate if the requested block exists // Count has to be non zero @@ -113,7 +113,7 @@ bool ConfigurationManager_GetConfigurationBlock( if (g_TargetConfiguration.NetworkInterfaceConfigs->Count == 0) { // there is no network config block, init one with default settings - if (!InitialiseNetworkDefaultConfig(NULL, 0)) + if (!InitialiseNetworkDefaultConfig(nullptr, 0)) { return FALSE; } @@ -270,7 +270,7 @@ bool ConfigurationManager_StoreConfigurationBlock( } // copy the config block content to the config block storage - success = iMXRTFlexSPIDriver_Write(NULL, storageAddress, blockSize, (unsigned char *)configurationBlock, false); + success = iMXRTFlexSPIDriver_Write(nullptr, storageAddress, blockSize, (unsigned char *)configurationBlock, false); // enumeration is required after we are DONE with SUCCESSFULLY storing all the config chunks requiresEnumeration = (success && done); @@ -308,7 +308,7 @@ UpdateConfigurationResult ConfigurationManager_UpdateConfigurationBlock( // allocate memory from CRT heap uint8_t *configSectorCopy = (uint8_t *)platform_malloc(sizeOfConfigSector); - if (configSectorCopy != NULL) + if (configSectorCopy != nullptr) { // copy config sector from flash to RAM memcpy(configSectorCopy, &__nanoConfig_start__, sizeOfConfigSector); @@ -370,7 +370,7 @@ UpdateConfigurationResult ConfigurationManager_UpdateConfigurationBlock( } // erase config sector - if (iMXRTFlexSPIDriver_EraseBlock(NULL, (uint32_t)&__nanoConfig_start__) == TRUE) + if (iMXRTFlexSPIDriver_EraseBlock(nullptr, (uint32_t)&__nanoConfig_start__) == TRUE) { // flash block is erased @@ -385,7 +385,7 @@ UpdateConfigurationResult ConfigurationManager_UpdateConfigurationBlock( // copy the config block copy back to the config block storage if (iMXRTFlexSPIDriver_Write( - NULL, + nullptr, (uint32_t)&__nanoConfig_start__, sizeOfConfigSector, (unsigned char *)configSectorCopy, diff --git a/targets/FreeRTOS/NXP/_nanoCLR/System.Device.Gpio/cpu_gpio.cpp b/targets/FreeRTOS/NXP/_nanoCLR/System.Device.Gpio/cpu_gpio.cpp index e06f47d595..1455a10374 100644 --- a/targets/FreeRTOS/NXP/_nanoCLR/System.Device.Gpio/cpu_gpio.cpp +++ b/targets/FreeRTOS/NXP/_nanoCLR/System.Device.Gpio/cpu_gpio.cpp @@ -200,14 +200,14 @@ extern "C" } // Get pointer to gpio_input_state for Gpio pin -// return NULL if not found +// return nullptr if not found gpio_input_state *GetInputState(GPIO_PIN pinNumber) { int port = GetIoPort(pinNumber); int bit = GetIoBit(pinNumber); - if (port_array[port] == NULL) - return NULL; + if (port_array[port] == nullptr) + return nullptr; statePortArray *inputStates = port_array[port]; return *inputStates[bit]; @@ -220,11 +220,11 @@ gpio_input_state *AllocateGpioInputState(GPIO_PIN pinNumber) int port = GetIoPort(pinNumber); int bit = GetIoBit(pinNumber); - if (port_array[port] == NULL) + if (port_array[port] == nullptr) { port_array[port] = (statePortArray *)platform_malloc(sizeof(statePortArray)); - if (port_array[port] == NULL) - return NULL; + if (port_array[port] == nullptr) + return nullptr; memset(port_array[port], 0, sizeof(statePortArray)); } @@ -232,7 +232,7 @@ gpio_input_state *AllocateGpioInputState(GPIO_PIN pinNumber) statePortArray *inputStates = port_array[port]; gpio_input_state *pState = (*inputStates)[bit]; - if (pState == NULL) + if (pState == nullptr) { pState = (gpio_input_state *)platform_malloc(sizeof(gpio_input_state)); memset(pState, 0, sizeof(gpio_input_state)); @@ -249,7 +249,7 @@ void DeleteInputState(GPIO_PIN pinNumber) int bit = GetIoBit(pinNumber); statePortArray *inputStates = port_array[port]; - if (inputStates == NULL) + if (inputStates == nullptr) return; gpio_input_state *pState = (*inputStates)[bit]; @@ -265,7 +265,7 @@ void DeleteInputState(GPIO_PIN pinNumber) GPIO_PinInit(GPIO_BASE(pinNumber), GPIO_PIN(pinNumber), &config); platform_free(pState); - (*inputStates)[bit] = NULL; + (*inputStates)[bit] = nullptr; } } @@ -292,10 +292,10 @@ bool CPU_GPIO_Uninitialize() for (int port = 0; port < TOTAL_GPIO_PORTS; port++) { statePortArray *inputStates = port_array[port]; - if (inputStates != NULL) + if (inputStates != nullptr) { platform_free(port_array[port]); // free up inputStates array - port_array[port] = NULL; + port_array[port] = nullptr; } } @@ -395,7 +395,7 @@ bool CPU_GPIO_EnableInputPin( pState = AllocateGpioInputState(pinNumber); - if (pinISR != NULL && (pState->isrPtr == NULL)) + if (pinISR != nullptr && (pState->isrPtr == nullptr)) { // enable interupt mode with correct edge gpio_pin_config_t config = {kGPIO_DigitalInput, 0, kGPIO_IntRisingOrFallingEdge}; @@ -441,7 +441,7 @@ bool CPU_GPIO_EnableInputPin( } } } - else if (pinISR == NULL && (pState->isrPtr != NULL)) + else if (pinISR == nullptr && (pState->isrPtr != nullptr)) { // there is no managed handler setup anymore // remove INT handler @@ -450,9 +450,9 @@ bool CPU_GPIO_EnableInputPin( GPIO_PortDisableInterrupts(GPIO_BASE(pinNumber), 1U << GetIoBit(pinNumber)); // clear parameters & configs - pState->isrPtr = NULL; + pState->isrPtr = nullptr; pState->mode = GPIO_INT_NONE; - pState->param = NULL; + pState->param = nullptr; pState->debounceMs = 0; } diff --git a/targets/FreeRTOS/NXP/_nanoCLR/System.Device.I2c/sys_dev_i2c_native_System_Device_I2c_I2cDevice.cpp b/targets/FreeRTOS/NXP/_nanoCLR/System.Device.I2c/sys_dev_i2c_native_System_Device_I2c_I2cDevice.cpp index efaa6cb8be..8d2bf36618 100644 --- a/targets/FreeRTOS/NXP/_nanoCLR/System.Device.I2c/sys_dev_i2c_native_System_Device_I2c_I2cDevice.cpp +++ b/targets/FreeRTOS/NXP/_nanoCLR/System.Device.I2c/sys_dev_i2c_native_System_Device_I2c_I2cDevice.cpp @@ -50,7 +50,7 @@ i2c_structure_t *I2C_ChoosePeripheralStructure(uint8_t busIndex) } else { - return NULL; + return nullptr; } } @@ -171,7 +171,7 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice::NativeInit___VOI i2c_structure_t *pI2Cx; uint8_t busIndex; - // Get a pointer to the managed object instance and check that it's not NULL + // Get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -220,7 +220,7 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice::NativeDispose___ CLR_RT_HeapBlock *pConfig; - // Get a pointer to the managed object instance and check that it's not NULL + // Get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -289,12 +289,12 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice:: CLR_RT_HeapBlock *writeSpanByte; CLR_RT_HeapBlock *readSpanByte; - CLR_RT_HeapBlock_Array *writeBuffer = NULL; - CLR_RT_HeapBlock_Array *readBuffer = NULL; + CLR_RT_HeapBlock_Array *writeBuffer = nullptr; + CLR_RT_HeapBlock_Array *readBuffer = nullptr; CLR_RT_HeapBlock *result; CLR_RT_HeapBlock *pConfig; - // Get a pointer to the managed object instance and check that it's not NULL + // Get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); CLR_RT_HeapBlock &top = stack.PushValueAndClear(); @@ -311,38 +311,38 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice:: // dereference the write and read SpanByte from the arguments writeSpanByte = stack.Arg1().Dereference(); - if (writeSpanByte != NULL) + if (writeSpanByte != nullptr) { // get buffer writeBuffer = writeSpanByte[SpanByte::FIELD___array].DereferenceArray(); - if (writeBuffer != NULL) + if (writeBuffer != nullptr) { pI2Cx->txBuffer = writeBuffer->GetFirstElement(); pI2Cx->txSize = writeBuffer->m_numOfElements; } } - if (writeBuffer == NULL) + if (writeBuffer == nullptr) { - pI2Cx->txBuffer = NULL; + pI2Cx->txBuffer = nullptr; pI2Cx->txSize = 0; } readSpanByte = stack.Arg2().Dereference(); - if (readSpanByte != NULL) + if (readSpanByte != nullptr) { // get buffer readBuffer = readSpanByte[SpanByte::FIELD___array].DereferenceArray(); - if (readBuffer != NULL) + if (readBuffer != nullptr) { pI2Cx->rxBuffer = readBuffer->GetFirstElement(); pI2Cx->rxSize = readBuffer->m_numOfElements; } } - if (readBuffer == NULL) + if (readBuffer == nullptr) { - pI2Cx->rxBuffer = NULL; + pI2Cx->rxBuffer = nullptr; pI2Cx->rxSize = 0; } @@ -366,7 +366,7 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice:: // Create return object NANOCLR_CHECK_HRESULT( - g_CLR_RT_ExecutionEngine.NewObjectFromIndex(top, g_CLR_RT_WellKnownTypes.m_I2cTransferResult)); + g_CLR_RT_ExecutionEngine.NewObjectFromIndex(top, g_CLR_RT_WellKnownTypes.I2cTransferResult)); result = top.Dereference(); FAULT_ON_NULL(result); diff --git a/targets/FreeRTOS/NXP/_nanoCLR/System.IO.Ports/sys_io_ser_native_System_IO_Ports_SerialPort.cpp b/targets/FreeRTOS/NXP/_nanoCLR/System.IO.Ports/sys_io_ser_native_System_IO_Ports_SerialPort.cpp index a20029a2e0..18283bfb4f 100644 --- a/targets/FreeRTOS/NXP/_nanoCLR/System.IO.Ports/sys_io_ser_native_System_IO_Ports_SerialPort.cpp +++ b/targets/FreeRTOS/NXP/_nanoCLR/System.IO.Ports/sys_io_ser_native_System_IO_Ports_SerialPort.cpp @@ -16,7 +16,7 @@ static NF_PAL_UART Uart_PAL1, Uart_PAL2, Uart_PAL3, Uart_PAL4, Uart_PAL5, Uart_P // Array of pointers to above config UART structs. NF_PAL_UART *const - Uart_PAL[]{NULL, &Uart_PAL1, &Uart_PAL2, &Uart_PAL3, &Uart_PAL4, &Uart_PAL5, &Uart_PAL6, &Uart_PAL7, &Uart_PAL8}; + Uart_PAL[]{nullptr, &Uart_PAL1, &Uart_PAL2, &Uart_PAL3, &Uart_PAL4, &Uart_PAL5, &Uart_PAL6, &Uart_PAL7, &Uart_PAL8}; // Task firing up event after receiving wanted amount of bytes static void vREvent(void *pvParameters) @@ -210,10 +210,10 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::Read___I4__SZARRAY NANOCLR_HEADER(); CLR_RT_HeapBlock hbTimeout; - CLR_RT_HeapBlock_Array *dataBuffer = NULL; - NF_PAL_UART *palUart = NULL; + CLR_RT_HeapBlock_Array *dataBuffer = nullptr; + NF_PAL_UART *palUart = nullptr; - uint8_t *data = NULL; + uint8_t *data = nullptr; uint8_t uartNum = 0; size_t bytesRead = 0; @@ -351,14 +351,14 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::ReadExisting___STR { NANOCLR_HEADER(); - NF_PAL_UART *palUart = NULL; + NF_PAL_UART *palUart = nullptr; uint8_t uartNum = 0; - uint8_t *buffer = NULL; + uint8_t *buffer = nullptr; uint32_t bufferLength; CLR_RT_HeapBlock &top = stack.PushValue(); - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -387,7 +387,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::ReadExisting___STR buffer = (uint8_t *)platform_malloc(bufferLength); // sanity check - if (buffer == NULL) + if (buffer == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_OUT_OF_MEMORY); } @@ -400,12 +400,12 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::ReadExisting___STR else { // create an empty - NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_String::CreateInstance(top, (const char *)NULL)); + NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_String::CreateInstance(top, (const char *)nullptr)); } NANOCLR_CLEANUP(); - if (buffer != NULL) + if (buffer != nullptr) { platform_free(buffer); } @@ -418,18 +418,18 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::ReadLine___STRING( NANOCLR_HEADER(); CLR_RT_HeapBlock hbTimeout; - NF_PAL_UART *palUart = NULL; + NF_PAL_UART *palUart = nullptr; uint8_t uartNum = 0; - uint8_t *line = NULL; - const char *newLine = NULL; + uint8_t *line = nullptr; + const char *newLine = nullptr; uint32_t newLineLength; int64_t *timeoutTicks; bool eventResult = true; bool newLineFound = false; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -471,8 +471,8 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::ReadLine___STRING( // get new line from field newLine = pThis[FIELD___newLine].RecoverString(); - // sanity check for NULL string - if (newLine == NULL) + // sanity check for nullptr string + if (newLine == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER); } @@ -520,7 +520,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::ReadLine___STRING( stack.SetResult_String((const char *)line); // free memory, if needed - if (line != NULL) + if (line != nullptr) { platform_free(line); } @@ -532,7 +532,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::Write___VOID__SZAR { NANOCLR_HEADER(); - NF_PAL_UART *palUart = NULL; + NF_PAL_UART *palUart = nullptr; size_t length = 0; @@ -541,12 +541,12 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::Write___VOID__SZAR int64_t *timeoutTicks; bool eventResult = true; - uint8_t *data = NULL; + uint8_t *data = nullptr; uint8_t uartNum = 0; size_t count = 0; size_t offset = 0; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -650,7 +650,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::Write___VOID__SZAR stack.SetResult_U4(count); // null pointers and vars - pThis = NULL; + pThis = nullptr; NANOCLR_NOCLEANUP(); } @@ -662,7 +662,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::NativeDispose___VO NF_PAL_UART *palUart; uint8_t uartNum = 0; - LPUART_Type *base = NULL; + LPUART_Type *base = nullptr; CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -671,7 +671,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::NativeDispose___VO base = lpuart_bases[uartNum]; // Quit if parameters or device is invalid or out of range - if (uartNum >= (sizeof(Uart_PAL) / sizeof(Uart_PAL[0])) || base == NULL) + if (uartNum >= (sizeof(Uart_PAL) / sizeof(Uart_PAL[0])) || base == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER); } @@ -682,8 +682,8 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::NativeDispose___VO platform_free(palUart->RxBuffer); // null all pointers - palUart->RxBuffer = NULL; - palUart->TxBuffer = NULL; + palUart->RxBuffer = nullptr; + palUart->TxBuffer = nullptr; // Deinitialize device and delete FreeRTOS idle tasks LPUART_Deinit(base); @@ -699,9 +699,9 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::NativeInit___VOID( status_t status = 0; uint8_t uartNum = 0; - lpuart_config_t *config = NULL; - LPUART_Type *base = NULL; - NF_PAL_UART *palUart = NULL; + lpuart_config_t *config = nullptr; + LPUART_Type *base = nullptr; + NF_PAL_UART *palUart = nullptr; BaseType_t xReturned; int32_t bufferSize; uint8_t watchChar; @@ -714,7 +714,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::NativeInit___VOID( base = lpuart_bases[uartNum]; // Quit if parameters or device is invalid or out of range - if (uartNum >= (sizeof(Uart_PAL) / sizeof(Uart_PAL[0])) || config == NULL || base == NULL) + if (uartNum >= (sizeof(Uart_PAL) / sizeof(Uart_PAL[0])) || config == nullptr || base == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER); } @@ -726,7 +726,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::NativeInit___VOID( palUart->RxBuffer = (uint8_t *)platform_malloc(bufferSize * sizeof(uint8_t)); - if (palUart->RxBuffer == NULL) + if (palUart->RxBuffer == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_OUT_OF_MEMORY); } @@ -803,8 +803,8 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::NativeConfig___VOI status_t status = 0; uint8_t uartNum = 0; - lpuart_config_t *config = NULL; - LPUART_Type *base = NULL; + lpuart_config_t *config = nullptr; + LPUART_Type *base = nullptr; CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -813,7 +813,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::NativeConfig___VOI config = &Uart_PAL[uartNum]->uartCfg; base = lpuart_bases[uartNum]; - if (uartNum >= (sizeof(Uart_PAL) / sizeof(Uart_PAL[0])) || config == NULL || base == NULL) + if (uartNum >= (sizeof(Uart_PAL) / sizeof(Uart_PAL[0])) || config == nullptr || base == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_IO); } @@ -897,7 +897,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::NativeSetWatchChar NF_PAL_UART *palUart; uint8_t uartNum; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -931,11 +931,11 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::NativeWriteString_ bool eventResult = true; bool isNewAllocation = false; - char *buffer = NULL; + char *buffer = nullptr; uint32_t bufferLength; int32_t length = 0; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -955,7 +955,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::NativeWriteString_ palUart = Uart_PAL[uartNum]; - if (stack.Arg1().RecoverString() == NULL) + if (stack.Arg1().RecoverString() == nullptr) { // text string it's empty so there is noting to do here stack.SetResult_U4(0); @@ -1043,7 +1043,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::NativeWriteString_ } // null pointers and vars - pThis = NULL; + pThis = nullptr; NANOCLR_NOCLEANUP(); } @@ -1057,7 +1057,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::NativeReceivedByte int32_t threshold; uint8_t uartNum; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -1099,7 +1099,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::GetDeviceSelector_ int len = 0; for (uint8_t i = 1; i < (sizeof(Uart_PAL) / sizeof(Uart_PAL[0])); i++) { - if (Uart_PAL[i] != NULL) + if (Uart_PAL[i] != nullptr) { char com[6] = "COM1,"; com[3] = i + '0'; diff --git a/targets/FreeRTOS/NXP/_nanoCLR/targetHAL.cpp b/targets/FreeRTOS/NXP/_nanoCLR/targetHAL.cpp index 02d9ca47b5..ea256bc26e 100644 --- a/targets/FreeRTOS/NXP/_nanoCLR/targetHAL.cpp +++ b/targets/FreeRTOS/NXP/_nanoCLR/targetHAL.cpp @@ -15,13 +15,13 @@ // Reboot handlers clean up on reboot // static ON_SOFT_REBOOT_HANDLER s_rebootHandlers[16] = - {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}; + {nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr}; void HAL_AddSoftRebootHandler(ON_SOFT_REBOOT_HANDLER handler) { for (unsigned int i = 0; i < ARRAYSIZE(s_rebootHandlers); i++) { - if (s_rebootHandlers[i] == NULL) + if (s_rebootHandlers[i] == nullptr) { s_rebootHandlers[i] = handler; return; @@ -62,7 +62,7 @@ void nanoHAL_Initialize() BlockStorageList_InitializeDevices(); // clear managed heap region - unsigned char *heapStart = NULL; + unsigned char *heapStart = nullptr; unsigned int heapSize = 0; ::HeapLocation(heapStart, heapSize); @@ -91,7 +91,7 @@ void nanoHAL_Uninitialize(bool isPoweringDown) // check for s_rebootHandlers for (unsigned int i = 0; i < ARRAYSIZE(s_rebootHandlers); i++) { - if (s_rebootHandlers[i] != NULL) + if (s_rebootHandlers[i] != nullptr) { s_rebootHandlers[i](); } diff --git a/targets/FreeRTOS/_common/nanoCLR/nanoCRT.cpp b/targets/FreeRTOS/_common/nanoCLR/nanoCRT.cpp index 4297bd9a2a..02457db7ad 100644 --- a/targets/FreeRTOS/_common/nanoCLR/nanoCRT.cpp +++ b/targets/FreeRTOS/_common/nanoCLR/nanoCRT.cpp @@ -137,7 +137,7 @@ int hal_strcpy_s(char *strDst, size_t sizeInBytes, const char *strSrc) #undef strcpy size_t len; - if (strDst == NULL || strSrc == NULL || sizeInBytes == 0) + if (strDst == nullptr || strSrc == nullptr || sizeInBytes == 0) { _ASSERTE(FALSE); return 1; @@ -160,7 +160,7 @@ int hal_strncpy_s(char *strDst, size_t sizeInBytes, const char *strSrc, size_t c { NATIVE_PROFILE_PAL_CRT(); #undef strncpy - if (strDst == NULL || strSrc == NULL || sizeInBytes == 0) + if (strDst == nullptr || strSrc == nullptr || sizeInBytes == 0) { _ASSERTE(FALSE); return 1; @@ -194,7 +194,7 @@ int hal_strncmp_s(const char *str1, const char *str2, size_t num) { NATIVE_PROFILE_PAL_CRT(); #undef strncmp - if (str1 == NULL || str2 == NULL) + if (str1 == nullptr || str2 == nullptr) { _ASSERTE(FALSE); return 1; diff --git a/targets/FreeRTOS/_common/nanoCLR/targetPAL_Events.cpp b/targets/FreeRTOS/_common/nanoCLR/targetPAL_Events.cpp index 876ffc5417..13a056bb30 100644 --- a/targets/FreeRTOS/_common/nanoCLR/targetPAL_Events.cpp +++ b/targets/FreeRTOS/_common/nanoCLR/targetPAL_Events.cpp @@ -45,7 +45,7 @@ void Events_SetBoolTimer(bool *timerCompleteFlag, uint32_t millisecondsFromNow) // we assume only 1 can be active, abort previous just in case xTimerStop(boolEventsTimer, 0); - if (timerCompleteFlag != NULL) + if (timerCompleteFlag != nullptr) { vTimerSetTimerID(boolEventsTimer, (void *)timerCompleteFlag); xTimerChangePeriod(boolEventsTimer, millisecondsFromNow / portTICK_PERIOD_MS, 0); diff --git a/targets/TI_SimpleLink/TI_CC1352R1_LAUNCHXL/common/Device_BlockStorage.c b/targets/TI_SimpleLink/TI_CC1352R1_LAUNCHXL/common/Device_BlockStorage.c index a5970491c9..81655f6435 100644 --- a/targets/TI_SimpleLink/TI_CC1352R1_LAUNCHXL/common/Device_BlockStorage.c +++ b/targets/TI_SimpleLink/TI_CC1352R1_LAUNCHXL/common/Device_BlockStorage.c @@ -10,8 +10,8 @@ const BlockRange BlockRange1[] = { // the last block is reserved for Customer Configuration Area and Bootloader Backdoor configuration // so we don't take it into account for the map - {BlockRange_BLOCKTYPE_CODE, 0, 22}, // 0x00000000 nanoCLR - {BlockRange_BLOCKTYPE_DEPLOYMENT, 23, 42}, // 0x0002E000 deployment + {BlockRange_BLOCKTYPE_CODE, 0, 25}, // 0x00000000 nanoCLR + {BlockRange_BLOCKTYPE_DEPLOYMENT, 26, 42}, // 0x00034000 deployment }; const BlockRegionInfo BlockRegions[] = {{ diff --git a/targets/TI_SimpleLink/TI_CC1352R1_LAUNCHXL/nanoCLR/CC13x2_26x2_CLR.ld b/targets/TI_SimpleLink/TI_CC1352R1_LAUNCHXL/nanoCLR/CC13x2_26x2_CLR.ld index 200dc6725e..db6c8d1a3c 100644 --- a/targets/TI_SimpleLink/TI_CC1352R1_LAUNCHXL/nanoCLR/CC13x2_26x2_CLR.ld +++ b/targets/TI_SimpleLink/TI_CC1352R1_LAUNCHXL/nanoCLR/CC13x2_26x2_CLR.ld @@ -40,7 +40,7 @@ HEAPSIZE = 0x2500; /* Size of heap buffer used by HeapMem */ MEMORY { /* original flash LENGTH was 0x00057fa8 */ - FLASH (RX) : ORIGIN = 0x00000000, LENGTH = 0x0002E000 + FLASH (RX) : ORIGIN = 0x00000000, LENGTH = 0x00034000 /* * Customer Configuration Area and Bootloader Backdoor configuration in * flash, 40 bytes diff --git a/targets/TI_SimpleLink/TI_CC1352R1_LAUNCHXL/nanoCLR/main.c b/targets/TI_SimpleLink/TI_CC1352R1_LAUNCHXL/nanoCLR/main.c index 055bcfdf86..bc397f9645 100644 --- a/targets/TI_SimpleLink/TI_CC1352R1_LAUNCHXL/nanoCLR/main.c +++ b/targets/TI_SimpleLink/TI_CC1352R1_LAUNCHXL/nanoCLR/main.c @@ -108,3 +108,14 @@ int main(void) return (0); } + +/////////////////////////////////////////////////////////////////////// +// need this dummy implementation here (started with SDK 4.20.01.04) // +/////////////////////////////////////////////////////////////////////// +void __attribute__((naked)) _exit(int code) +{ + (void)code; + + for (;;) + ; +} diff --git a/targets/TI_SimpleLink/_common/simplelink_sockets.cpp b/targets/TI_SimpleLink/_common/simplelink_sockets.cpp index f098d8b2e2..6bc6a62d32 100644 --- a/targets/TI_SimpleLink/_common/simplelink_sockets.cpp +++ b/targets/TI_SimpleLink/_common/simplelink_sockets.cpp @@ -116,9 +116,9 @@ bool SimpleLink_SOCKETS_Initialize() { NATIVE_PROFILE_PAL_NETWORK(); - PostAddressChangedContinuation.InitializeCallback(PostAddressChanged, NULL); - PostAvailabilityOnContinuation.InitializeCallback(PostAvailabilityOn, NULL); - PostAvailabilityOffContinuation.InitializeCallback(PostAvailabilityOff, NULL); + PostAddressChangedContinuation.InitializeCallback(PostAddressChanged, nullptr); + PostAvailabilityOnContinuation.InitializeCallback(PostAvailabilityOn, nullptr); + PostAvailabilityOffContinuation.InitializeCallback(PostAvailabilityOff, nullptr); return true; } diff --git a/targets/TI_SimpleLink/_common/simplelink_sockets_functions.cpp b/targets/TI_SimpleLink/_common/simplelink_sockets_functions.cpp index ba9c6cb4c2..40510bd32a 100644 --- a/targets/TI_SimpleLink/_common/simplelink_sockets_functions.cpp +++ b/targets/TI_SimpleLink/_common/simplelink_sockets_functions.cpp @@ -172,7 +172,7 @@ HRESULT HAL_SOCK_CONFIGURATION_UpdateAdapterConfiguration( // all changes require SL reinit sl_Stop(0); - sl_Start(NULL, NULL, NULL); + sl_Start(nullptr, nullptr, nullptr); return S_OK; } @@ -212,5 +212,5 @@ void HAL_SOCK_EventsSet(uint32_t events) void *HAL_SOCK_GlobalLockContext() { NATIVE_PROFILE_PAL_NETWORK(); - return NULL; + return nullptr; } diff --git a/targets/TI_SimpleLink/_common/sockets_simplelink.cpp b/targets/TI_SimpleLink/_common/sockets_simplelink.cpp index 77c3f1dddc..f134fc60df 100644 --- a/targets/TI_SimpleLink/_common/sockets_simplelink.cpp +++ b/targets/TI_SimpleLink/_common/sockets_simplelink.cpp @@ -18,7 +18,7 @@ int socketErrorCode; static int MARSHAL_SOCK_FDSET_TO_SL_SDSET(SOCK_fd_set *sf, SlNetSock_SdSet_t *f) { - if (f != NULL && sf != NULL) + if (f != nullptr && sf != nullptr) { SlNetSock_sdsClrAll(f); @@ -35,7 +35,7 @@ static int MARSHAL_SOCK_FDSET_TO_SL_SDSET(SOCK_fd_set *sf, SlNetSock_SdSet_t *f) static void MARSHAL_SL_SDSET_TO_SOCK_FDSET(SOCK_fd_set *sf, SlNetSock_SdSet_t *f) { - if (sf != NULL && f != NULL) + if (sf != nullptr && f != nullptr) { int cnt = sf->fd_count; sf->fd_count = 0; @@ -321,17 +321,17 @@ int SOCK_getaddrinfo( NATIVE_PROFILE_PAL_COM(); SOCK_addrinfo *ai; - SOCK_sockaddr_in *sa = NULL; + SOCK_sockaddr_in *sa = nullptr; int total_size = sizeof(SOCK_addrinfo) + sizeof(SOCK_sockaddr_in); - struct SlNetUtil_addrInfo_t *addrInfo = NULL; + struct SlNetUtil_addrInfo_t *addrInfo = nullptr; - if (res == NULL) + if (res == nullptr) return SOCK_SOCKET_ERROR; - *res = NULL; + *res = nullptr; // if the nodename == "" then return the IP address of this device - if (nodename[0] == 0 && servname == NULL) + if (nodename[0] == 0 && servname == nullptr) { uint16_t configOptions; uint16_t ipLen = sizeof(SlNetCfgIpV4Args_t); @@ -341,7 +341,7 @@ int SOCK_getaddrinfo( { ai = (SOCK_addrinfo *)platform_malloc(total_size); - if (ai != NULL) + if (ai != nullptr) { memset(ai, 0, total_size); sa = (SOCK_sockaddr_in *)((uint8_t *)ai + sizeof(SOCK_addrinfo)); @@ -359,7 +359,7 @@ int SOCK_getaddrinfo( // set up addrinfo ai->ai_family = SL_AF_INET; - if (hints != NULL) + if (hints != nullptr) { // copy socktype & protocol from hints if specified ai->ai_socktype = hints->ai_socktype; @@ -388,7 +388,7 @@ int SOCK_getaddrinfo( SlNetSock_AddrIn_t *sockaddr_in; ai = (SOCK_addrinfo *)platform_malloc(total_size); - if (ai == NULL) + if (ai == nullptr) { SlNetUtil_freeAddrInfo(addrInfo); } @@ -406,7 +406,7 @@ int SOCK_getaddrinfo( /* set up addrinfo */ ai->ai_family = addrInfo->ai_family; - if (hints != NULL) + if (hints != nullptr) { /* copy socktype & protocol from hints if specified */ ai->ai_socktype = hints->ai_socktype; @@ -655,7 +655,7 @@ int SOCK_select( uint32_t networkInterfaceID; // If the network goes down then we should alert any pending socket actions - if (exceptfds != NULL && exceptfds->fd_count > 0) + if (exceptfds != nullptr && exceptfds->fd_count > 0) { // find the network interface for this socket // the socket handle is "burried" inside the exceptfds struct (see the caller code in Helper__SelectSocket) @@ -669,11 +669,11 @@ int SOCK_select( if (SlNetIf_getConnectionStatus(networkInterfaceID) == SLNETIF_STATUS_DISCONNECTED) { - if (readfds != NULL) + if (readfds != nullptr) { readfds->fd_count = 0; } - if (writefds != NULL) + if (writefds != nullptr) { writefds->fd_count = 0; } @@ -686,7 +686,7 @@ int SOCK_select( // developer note: // The original code, being lwIP based, uses the convention that 0 is infinite timeout - // Because SimpleLink infinite timeout is negative or NULL we need to translate it. + // Because SimpleLink infinite timeout is negative or nullptr we need to translate it. SlNetSock_Timeval_t timeoutCopy; bool isInfiniteTimeout = false; @@ -705,7 +705,7 @@ int SOCK_select( (SlNetSock_SdSet_t *)readfds, (SlNetSock_SdSet_t *)writefds, (SlNetSock_SdSet_t *)exceptfds, - isInfiniteTimeout ? NULL : &timeoutCopy); + isInfiniteTimeout ? nullptr : &timeoutCopy); socketErrorCode = ret; diff --git a/targets/TI_SimpleLink/_common/ssl_simplelink.cpp b/targets/TI_SimpleLink/_common/ssl_simplelink.cpp index 9b4a200d6b..54ed6edb93 100644 --- a/targets/TI_SimpleLink/_common/ssl_simplelink.cpp +++ b/targets/TI_SimpleLink/_common/ssl_simplelink.cpp @@ -102,7 +102,7 @@ bool ssl_generic_init_internal( /////////////////////// for (uint32_t i = 0; i < ARRAYSIZE(g_SSL_Driver.ContextArray); i++) { - if (g_SSL_Driver.ContextArray[i].Context == NULL) + if (g_SSL_Driver.ContextArray[i].Context == nullptr) { sslContexIndex = i; break; @@ -115,7 +115,7 @@ bool ssl_generic_init_internal( // create and init nanoFramework Simple Link context // this needs to be freed in ssl_exit_context_internal context = (SlSSL_Context *)platform_malloc(sizeof(SlSSL_Context)); - if (context == NULL) + if (context == nullptr) { goto error; } @@ -124,7 +124,7 @@ bool ssl_generic_init_internal( // this is the equivalent of SSL context in MbedTLS // it needs to be freed in ssl_exit_context_internal context->SecurityAttributes = SlNetSock_secAttribCreate(); - if (context->SecurityAttributes == NULL) + if (context->SecurityAttributes == nullptr) { goto error; } @@ -166,7 +166,7 @@ bool ssl_generic_init_internal( // CA root certs are taken from Simple Link trusted root-certificate catalog, so nothing to do here // // parse "own" certificate if passed - // if(certificate != NULL && certLength > 0) + // if(certificate != nullptr && certLength > 0) // { // // TODO // // this isn't required for client authentication @@ -185,7 +185,7 @@ bool ssl_generic_init_internal( // // } // // if( mbedtls_pk_parse_key( &pkey, (const unsigned char *) mbedtls_test_cli_key, mbedtls_test_cli_key_len, - // NULL, 0 ) != 0) + // nullptr, 0 ) != 0) // // { // // // failed parsing the // // } @@ -225,12 +225,12 @@ bool ssl_generic_init_internal( error: // check for any memory allocation that needs to be freed before exiting - if (context != NULL) + if (context != nullptr) { platform_free(context); } - if (context->SecurityAttributes != NULL) + if (context->SecurityAttributes != nullptr) { SlNetSock_secAttribDelete(context->SecurityAttributes); } @@ -240,17 +240,17 @@ bool ssl_generic_init_internal( bool ssl_exit_context_internal(int contextHandle) { - SlSSL_Context *context = NULL; + SlSSL_Context *context = nullptr; // Check contextHandle range if ((contextHandle >= (int)ARRAYSIZE(g_SSL_Driver.ContextArray)) || (contextHandle < 0) || - (g_SSL_Driver.ContextArray[contextHandle].Context == NULL)) + (g_SSL_Driver.ContextArray[contextHandle].Context == nullptr)) { return false; } context = (SlSSL_Context *)g_SSL_Driver.ContextArray[contextHandle].Context; - if (context == NULL) + if (context == nullptr) { return false; } @@ -283,7 +283,7 @@ int ssl_connect_internal(int sd, const char *szTargetHost, int contextHandle) // sd should already have been created // Now do the SSL negotiation context = (SlSSL_Context *)g_SSL_Driver.ContextArray[contextHandle].Context; - if (context == NULL) + if (context == nullptr) { return SOCK_SOCKET_ERROR; } @@ -291,7 +291,7 @@ int ssl_connect_internal(int sd, const char *szTargetHost, int contextHandle) // set socket in network context context->SocketFd = sd; - if (szTargetHost != NULL && szTargetHost[0] != 0) + if (szTargetHost != nullptr && szTargetHost[0] != 0) { status = SlNetSock_secAttribSet( context->SecurityAttributes, diff --git a/targets/TI_SimpleLink/_common/targetHAL_ConfigurationManager_CC13xx_26xx.cpp b/targets/TI_SimpleLink/_common/targetHAL_ConfigurationManager_CC13xx_26xx.cpp index 4261ae5257..53eee12381 100644 --- a/targets/TI_SimpleLink/_common/targetHAL_ConfigurationManager_CC13xx_26xx.cpp +++ b/targets/TI_SimpleLink/_common/targetHAL_ConfigurationManager_CC13xx_26xx.cpp @@ -35,9 +35,9 @@ void *ConfigurationManagerCC13xx_26xx_FindNetworkConfigurationBlocks() fileList = (slGetfileList_t *)platform_malloc(sizeof(slGetfileList_t) * NETWORK_CONFIG_MAX_COUNT); // check successful malloc - if (fileList == NULL) + if (fileList == nullptr) { - return NULL; + return nullptr; } // clear memory @@ -249,7 +249,7 @@ bool ConfigurationManager_GetConfigurationBlock( DeviceConfigurationOption configuration, uint32_t configurationIndex) { - unsigned char *fileName = NULL; + unsigned char *fileName = nullptr; int32_t fileHandle; uint32_t token = 0; @@ -259,7 +259,7 @@ bool ConfigurationManager_GetConfigurationBlock( uint8_t dummyMAC[SL_MAC_ADDR_LEN]; uint32_t dummyPriority; - HAL_Configuration_Wireless80211 *wirelessConfigBlock = NULL; + HAL_Configuration_Wireless80211 *wirelessConfigBlock = nullptr; // validate if the requested block exists // Count has to be non zero @@ -333,7 +333,7 @@ bool ConfigurationManager_GetConfigurationBlock( } } - if (fileName != NULL) + if (fileName != nullptr) { platform_free(fileName); } @@ -358,7 +358,7 @@ bool ConfigurationManager_GetConfigurationBlock( &dummyNameLen, &dummyMAC[0], &secParams, - NULL, + nullptr, &dummyPriority); if (retVal == SL_ERROR_WLAN_GET_PROFILE_INVALID_INDEX) { @@ -370,7 +370,7 @@ bool ConfigurationManager_GetConfigurationBlock( wirelessConfigBlock->Authentication = GetAuthentication(secParams); wirelessConfigBlock->Encryption = GetEncryption(secParams); - // password is hidden, NULL the string + // password is hidden, nullptr the string memset(wirelessConfigBlock->Password, 0, sizeof(wirelessConfigBlock->Password)); // wirelessConfigBlock->Radio @@ -418,7 +418,7 @@ bool ConfigurationManager_StoreConfigurationBlock( bool requiresEnumeration = false; bool success = false; - unsigned char *fileName = NULL; + unsigned char *fileName = nullptr; int32_t fileHandle; uint32_t token = 0; @@ -473,7 +473,7 @@ bool ConfigurationManager_StoreConfigurationBlock( } } - if (fileName != NULL) + if (fileName != nullptr) { platform_free(fileName); } @@ -491,9 +491,9 @@ bool ConfigurationManager_StoreConfigurationBlock( retVal = sl_WlanProfileAdd( (const signed char *)wirelessConfigBlock->Ssid, hal_strlen_s((const char *)(wirelessConfigBlock->Ssid)), - NULL, + nullptr, &secParams, - NULL, + nullptr, 0, 0); if (retVal < 0) diff --git a/targets/TI_SimpleLink/_common/targetHAL_ConfigurationManager_CC32xx.cpp b/targets/TI_SimpleLink/_common/targetHAL_ConfigurationManager_CC32xx.cpp index f4ad372220..ab33021c54 100644 --- a/targets/TI_SimpleLink/_common/targetHAL_ConfigurationManager_CC32xx.cpp +++ b/targets/TI_SimpleLink/_common/targetHAL_ConfigurationManager_CC32xx.cpp @@ -35,9 +35,9 @@ void *ConfigurationManagerCC32xx_FindNetworkConfigurationBlocks() fileList = (slGetfileList_t *)platform_malloc(sizeof(slGetfileList_t) * NETWORK_CONFIG_MAX_COUNT); // check successful malloc - if (fileList == NULL) + if (fileList == nullptr) { - return NULL; + return nullptr; } // clear memory @@ -248,7 +248,7 @@ bool ConfigurationManager_GetConfigurationBlock( DeviceConfigurationOption configuration, uint32_t configurationIndex) { - unsigned char *fileName = NULL; + unsigned char *fileName = nullptr; int32_t fileHandle; uint32_t token = 0; @@ -258,7 +258,7 @@ bool ConfigurationManager_GetConfigurationBlock( uint8_t dummyMAC[SL_MAC_ADDR_LEN]; uint32_t dummyPriority; - HAL_Configuration_Wireless80211 *wirelessConfigBlock = NULL; + HAL_Configuration_Wireless80211 *wirelessConfigBlock = nullptr; // validate if the requested block exists // Count has to be non zero @@ -332,7 +332,7 @@ bool ConfigurationManager_GetConfigurationBlock( } } - if (fileName != NULL) + if (fileName != nullptr) { platform_free(fileName); } @@ -357,7 +357,7 @@ bool ConfigurationManager_GetConfigurationBlock( &dummyNameLen, &dummyMAC[0], &secParams, - NULL, + nullptr, &dummyPriority); if (retVal == SL_ERROR_WLAN_GET_PROFILE_INVALID_INDEX) { @@ -369,7 +369,7 @@ bool ConfigurationManager_GetConfigurationBlock( wirelessConfigBlock->Authentication = GetAuthentication(secParams); wirelessConfigBlock->Encryption = GetEncryption(secParams); - // password is hidden, NULL the string + // password is hidden, nullptr the string memset(wirelessConfigBlock->Password, 0, sizeof(wirelessConfigBlock->Password)); // wirelessConfigBlock->Radio @@ -417,7 +417,7 @@ bool ConfigurationManager_StoreConfigurationBlock( bool requiresEnumeration = false; bool success = false; - unsigned char *fileName = NULL; + unsigned char *fileName = nullptr; int32_t fileHandle; uint32_t token = 0; @@ -472,7 +472,7 @@ bool ConfigurationManager_StoreConfigurationBlock( } } - if (fileName != NULL) + if (fileName != nullptr) { platform_free(fileName); } @@ -490,9 +490,9 @@ bool ConfigurationManager_StoreConfigurationBlock( retVal = sl_WlanProfileAdd( (const signed char *)wirelessConfigBlock->Ssid, hal_strlen_s((const char *)(wirelessConfigBlock->Ssid)), - NULL, + nullptr, &secParams, - NULL, + nullptr, 0, 0); if (retVal < 0) diff --git a/targets/TI_SimpleLink/_nanoCLR/System.Device.Adc/sys_dev_adc_native_System_Device_Adc_AdcChannel.cpp b/targets/TI_SimpleLink/_nanoCLR/System.Device.Adc/sys_dev_adc_native_System_Device_Adc_AdcChannel.cpp index f670441602..9666aeb45c 100644 --- a/targets/TI_SimpleLink/_nanoCLR/System.Device.Adc/sys_dev_adc_native_System_Device_Adc_AdcChannel.cpp +++ b/targets/TI_SimpleLink/_nanoCLR/System.Device.Adc/sys_dev_adc_native_System_Device_Adc_AdcChannel.cpp @@ -35,7 +35,7 @@ HRESULT Library_sys_dev_adc_native_System_Device_Adc_AdcChannel::NativeReadValue double rawValue; ADC_Handle adcHandler; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -49,7 +49,7 @@ HRESULT Library_sys_dev_adc_native_System_Device_Adc_AdcChannel::NativeReadValue FAULT_ON_NULL(adcHandler); // sanity check - if (adcHandler == NULL) + if (adcHandler == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_FAIL); } diff --git a/targets/TI_SimpleLink/_nanoCLR/System.Device.Adc/sys_dev_adc_native_System_Device_Adc_AdcController.cpp b/targets/TI_SimpleLink/_nanoCLR/System.Device.Adc/sys_dev_adc_native_System_Device_Adc_AdcController.cpp index bfc0a33be1..047a32f8ef 100644 --- a/targets/TI_SimpleLink/_nanoCLR/System.Device.Adc/sys_dev_adc_native_System_Device_Adc_AdcController.cpp +++ b/targets/TI_SimpleLink/_nanoCLR/System.Device.Adc/sys_dev_adc_native_System_Device_Adc_AdcController.cpp @@ -77,7 +77,7 @@ HRESULT Library_sys_dev_adc_native_System_Device_Adc_AdcController::NativeInit__ { NANOCLR_HEADER(); - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); diff --git a/targets/TI_SimpleLink/_nanoCLR/System.Device.Gpio/cpu_gpio.cpp b/targets/TI_SimpleLink/_nanoCLR/System.Device.Gpio/cpu_gpio.cpp index b82d86609e..e66fa3da5e 100644 --- a/targets/TI_SimpleLink/_nanoCLR/System.Device.Gpio/cpu_gpio.cpp +++ b/targets/TI_SimpleLink/_nanoCLR/System.Device.Gpio/cpu_gpio.cpp @@ -61,12 +61,12 @@ static HAL_DblLinkedList gpioInputList; // static uint8_t pinReserved[TOTAL_GPIO_PORTS]; // Get pointer to gpio_input_state for GPIO pin -// return NULL if not found +// return nullptr if not found gpio_input_state *GetInputState(GPIO_PIN pinNumber) { gpio_input_state *pState = gpioInputList.FirstNode(); - while (pState->Next() != NULL) + while (pState->Next() != nullptr) { if (pState->pinNumber == pinNumber) { @@ -76,16 +76,16 @@ gpio_input_state *GetInputState(GPIO_PIN pinNumber) pState = pState->Next(); } - return NULL; + return nullptr; } // Get pointer to gpio_input_state for GPIO pin -// return NULL if not found +// return nullptr if not found gpio_input_state *GetInputStateByConfigIndex(uint8_t pinConfigIndex) { gpio_input_state *pState = gpioInputList.FirstNode(); - while (pState->Next() != NULL) + while (pState->Next() != nullptr) { if (pState->pinConfigIndex == pinConfigIndex) { @@ -95,7 +95,7 @@ gpio_input_state *GetInputStateByConfigIndex(uint8_t pinConfigIndex) pState = pState->Next(); } - return NULL; + return nullptr; } // Allocate a new gpio_input_state and add to end of list @@ -104,13 +104,13 @@ gpio_input_state *AllocateGpioInputState(GPIO_PIN pinNumber) { gpio_input_state *pState = GetInputState(pinNumber); - if (pState == NULL) + if (pState == nullptr) { // found a free slot! pState = (gpio_input_state *)platform_malloc(sizeof(gpio_input_state)); // sanity check - if (pState != NULL) + if (pState != nullptr) { memset(pState, 0, sizeof(gpio_input_state)); @@ -190,7 +190,7 @@ static void GpioEventCallback(uint_least8_t index) gpio_input_state *pState = GetInputStateByConfigIndex(index); // Any pin set up here ? - if (pState != NULL) + if (pState != nullptr) { // Ignore any pin changes during debounce timeout if (!pState->waitingDebounce) @@ -355,7 +355,7 @@ bool CPU_GPIO_EnableInputPin( // Link ISR ptr supplied and not already set up // CPU_GPIO_EnableInputPin could be called a 2nd time with changed parameters - if (pinISR != NULL && (pState->isrPtr == NULL)) + if (pinISR != nullptr && (pState->isrPtr == nullptr)) { // set callback GPIO_setCallback(pState->pinConfigIndex, GpioEventCallback); @@ -370,7 +370,7 @@ bool CPU_GPIO_EnableInputPin( pState->debounceMs = debounceTimeMilliseconds; // create timer if not there yet - if (pState->debounceMs > 0 && pState->debounceTimer == NULL) + if (pState->debounceMs > 0 && pState->debounceTimer == nullptr) { // setup timer Clock_Params params; @@ -411,7 +411,7 @@ bool CPU_GPIO_EnableInputPin( break; } } - else if (pinISR == NULL && (pState->isrPtr != NULL)) + else if (pinISR == nullptr && (pState->isrPtr != nullptr)) { // there is no managed handler setup anymore // remove INT handler @@ -419,12 +419,12 @@ bool CPU_GPIO_EnableInputPin( // disable interrupt GPIO_disableInt(pState->pinConfigIndex); // remove callback - GPIO_setCallback(pState->pinConfigIndex, NULL); + GPIO_setCallback(pState->pinConfigIndex, nullptr); // clear parameters & configs - pState->isrPtr = NULL; + pState->isrPtr = nullptr; pState->mode = GPIO_INT_NONE; - pState->param = NULL; + pState->param = nullptr; pState->debounceMs = 0; } @@ -556,7 +556,7 @@ uint32_t CPU_GPIO_GetPinDebounce(GPIO_PIN pinNumber) { gpio_input_state *pState = GetInputState(pinNumber); - _ASSERTE(pState == NULL); + _ASSERTE(pState == nullptr); return pState->debounceMs; } @@ -567,7 +567,7 @@ bool CPU_GPIO_SetPinDebounce(GPIO_PIN pinNumber, uint32_t debounceTimeMillisecon // can only change the debounce in pin state if the pin has already been configured as input // if not, doesn't matter, because the new debounce will be used next time it's required - if (pState != NULL) + if (pState != nullptr) { pState->debounceMs = debounceTimeMilliseconds; } diff --git a/targets/TI_SimpleLink/_nanoCLR/System.Device.I2c/sys_dev_i2c_native_System_Device_I2c_I2cDevice.cpp b/targets/TI_SimpleLink/_nanoCLR/System.Device.I2c/sys_dev_i2c_native_System_Device_I2c_I2cDevice.cpp index be08282165..f86afb251e 100644 --- a/targets/TI_SimpleLink/_nanoCLR/System.Device.I2c/sys_dev_i2c_native_System_Device_I2c_I2cDevice.cpp +++ b/targets/TI_SimpleLink/_nanoCLR/System.Device.I2c/sys_dev_i2c_native_System_Device_I2c_I2cDevice.cpp @@ -30,10 +30,10 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice::NativeInit___VOI { NANOCLR_HEADER(); { - NF_PAL_I2C *palI2c = NULL; + NF_PAL_I2C *palI2c = nullptr; I2cBusSpeed busSpeed; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -51,7 +51,7 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice::NativeInit___VOI switch (busIndex) { case 1: - if (I2C1_PAL.i2c == NULL) + if (I2C1_PAL.i2c == nullptr) { palI2c = &I2C1_PAL; } @@ -102,7 +102,7 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice::NativeDispose___ uint8_t busIndex; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -121,7 +121,7 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice::NativeDispose___ // no more devices on the bus // deactivates the I2C peripheral I2C_close(I2C1_PAL.i2c); - I2C1_PAL.i2c == NULL; + I2C1_PAL.i2c == nullptr; } break; @@ -141,7 +141,7 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice:: NANOCLR_HEADER(); uint8_t busIndex; - NF_PAL_I2C *palI2c = NULL; + NF_PAL_I2C *palI2c = nullptr; CLR_RT_HeapBlock hbTimeout; CLR_INT64 *timeout; @@ -152,10 +152,10 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice:: CLR_RT_HeapBlock *writeSpanByte; CLR_RT_HeapBlock *readSpanByte; CLR_RT_HeapBlock *connectionSettings; - CLR_RT_HeapBlock_Array *writeBuffer = NULL; - CLR_RT_HeapBlock_Array *readBuffer = NULL; + CLR_RT_HeapBlock_Array *writeBuffer = nullptr; + CLR_RT_HeapBlock_Array *readBuffer = nullptr; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -180,36 +180,36 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice:: // dereference the write and read SpanByte from the arguments writeSpanByte = stack.Arg1().Dereference(); - if (writeSpanByte != NULL) + if (writeSpanByte != nullptr) { // get buffer writeBuffer = writeSpanByte[SpanByte::FIELD___array].DereferenceArray(); - if (writeBuffer != NULL) + if (writeBuffer != nullptr) { // get the size of the buffer by reading the number of elements in the CLR_RT_HeapBlock_Array palI2c->i2cTransaction.writeCount = writeBuffer->m_numOfElements; } } - if (writeBuffer == NULL) + if (writeBuffer == nullptr) { // nothing to write, have to zero this palI2c->i2cTransaction.writeCount = 0; } readSpanByte = stack.Arg2().Dereference(); - if (readSpanByte != NULL) + if (readSpanByte != nullptr) { // get buffer readBuffer = readSpanByte[SpanByte::FIELD___array].DereferenceArray(); - if (readBuffer != NULL) + if (readBuffer != nullptr) { // get the size of the buffer by reading the number of elements in the CLR_RT_HeapBlock_Array palI2c->i2cTransaction.readCount = readBuffer->m_numOfElements; } } - if (readBuffer == NULL) + if (readBuffer == nullptr) { // nothing to read, have to zero this palI2c->i2cTransaction.readCount = 0; @@ -223,13 +223,13 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice:: NANOCLR_CHECK_HRESULT(stack.SetupTimeoutFromTicks(hbTimeout, timeout)); // pin the buffers so DMA can find them where they are supposed to be - if (writeBuffer != NULL) + if (writeBuffer != nullptr) { writeBuffer->Pin(); palI2c->i2cTransaction.writeBuf = (uint8_t *)writeBuffer->GetFirstElement(); } - if (readBuffer != NULL) + if (readBuffer != nullptr) { readBuffer->Pin(); palI2c->i2cTransaction.readBuf = (uint8_t *)readBuffer->GetFirstElement(); @@ -259,7 +259,7 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice:: // managed stack CLR_RT_HeapBlock &top = stack.PushValueAndClear(); NANOCLR_CHECK_HRESULT( - g_CLR_RT_ExecutionEngine.NewObjectFromIndex(top, g_CLR_RT_WellKnownTypes.m_I2cTransferResult)); + g_CLR_RT_ExecutionEngine.NewObjectFromIndex(top, g_CLR_RT_WellKnownTypes.I2cTransferResult)); result = top.Dereference(); FAULT_ON_NULL(result); @@ -289,12 +289,12 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice:: if (hr != CLR_E_THREAD_WAITING) { // un-pin the buffers - if (writeBuffer != NULL && writeBuffer->IsPinned()) + if (writeBuffer != nullptr && writeBuffer->IsPinned()) { writeBuffer->Unpin(); } - if (readBuffer != NULL && readBuffer->IsPinned()) + if (readBuffer != nullptr && readBuffer->IsPinned()) { readBuffer->Unpin(); } diff --git a/targets/TI_SimpleLink/_nanoCLR/System.Device.Pwm/sys_dev_pwm_native_System_Device_Pwm_PwmChannel.cpp b/targets/TI_SimpleLink/_nanoCLR/System.Device.Pwm/sys_dev_pwm_native_System_Device_Pwm_PwmChannel.cpp index d27db271d0..fa665360f3 100644 --- a/targets/TI_SimpleLink/_nanoCLR/System.Device.Pwm/sys_dev_pwm_native_System_Device_Pwm_PwmChannel.cpp +++ b/targets/TI_SimpleLink/_nanoCLR/System.Device.Pwm/sys_dev_pwm_native_System_Device_Pwm_PwmChannel.cpp @@ -23,7 +23,7 @@ HRESULT Library_sys_dev_pwm_native_System_Device_Pwm_PwmChannel::NativeSetDesire { NANOCLR_HEADER(); { - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -41,7 +41,7 @@ HRESULT Library_sys_dev_pwm_native_System_Device_Pwm_PwmChannel::NativeSetActive { NANOCLR_HEADER(); { - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -61,7 +61,7 @@ HRESULT Library_sys_dev_pwm_native_System_Device_Pwm_PwmChannel::NativeStart___V { NANOCLR_HEADER(); { - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -83,7 +83,7 @@ HRESULT Library_sys_dev_pwm_native_System_Device_Pwm_PwmChannel::NativeStart___V params.periodUnits = PWM_PERIOD_HZ; params.periodValue = frequency; PwmPins[pinNumber] = PWM_open(pinNumber, ¶ms); - if (PwmPins[pinNumber] == NULL) + if (PwmPins[pinNumber] == nullptr) { // Board_PWM did not open NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER); @@ -98,7 +98,7 @@ HRESULT Library_sys_dev_pwm_native_System_Device_Pwm_PwmChannel::NativeStop___VO { NANOCLR_HEADER(); { - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -116,7 +116,7 @@ HRESULT Library_sys_dev_pwm_native_System_Device_Pwm_PwmChannel::DisposeNative__ { NANOCLR_HEADER(); { - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); diff --git a/targets/TI_SimpleLink/_nanoCLR/System.Device.Spi/cpu_spi.cpp b/targets/TI_SimpleLink/_nanoCLR/System.Device.Spi/cpu_spi.cpp index 310f1e0487..41cf41de9b 100644 --- a/targets/TI_SimpleLink/_nanoCLR/System.Device.Spi/cpu_spi.cpp +++ b/targets/TI_SimpleLink/_nanoCLR/System.Device.Spi/cpu_spi.cpp @@ -11,7 +11,6 @@ #include #include -#include #include #include @@ -132,7 +131,7 @@ HRESULT CPU_SPI_nWrite_nRead( NANOCLR_HEADER(); { - unsigned char *readDataBuffer = NULL; + unsigned char *readDataBuffer = nullptr; GetSPIConfig(sdev, wrc); @@ -150,7 +149,7 @@ HRESULT CPU_SPI_nWrite_nRead( } // check allocation - if (SPI1_PAL.transactions == NULL) + if (SPI1_PAL.transactions == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_OUT_OF_MEMORY); } diff --git a/targets/TI_SimpleLink/_nanoCLR/System.IO.Ports/sys_io_ser_native_System_IO_Ports_SerialPort.cpp b/targets/TI_SimpleLink/_nanoCLR/System.IO.Ports/sys_io_ser_native_System_IO_Ports_SerialPort.cpp index 5b8761e5e6..8440beae44 100644 --- a/targets/TI_SimpleLink/_nanoCLR/System.IO.Ports/sys_io_ser_native_System_IO_Ports_SerialPort.cpp +++ b/targets/TI_SimpleLink/_nanoCLR/System.IO.Ports/sys_io_ser_native_System_IO_Ports_SerialPort.cpp @@ -32,7 +32,7 @@ Task_Struct SerialRxTaskStruct; NF_PAL_UART *GetPalUartFromUartNum(int uart_num) { - NF_PAL_UART *palUart = NULL; + NF_PAL_UART *palUart = nullptr; switch (uart_num) { @@ -55,7 +55,7 @@ void UnitializePalUart(NF_PAL_UART *palUart) if (palUart && palUart->UartDriver) { // destroy task UART task - if (palUart->WorkingTask != NULL) + if (palUart->WorkingTask != nullptr) { Task_destruct(&SerialRxTaskStruct); } @@ -66,10 +66,10 @@ void UnitializePalUart(NF_PAL_UART *palUart) platform_free(palUart->RxBuffer); // null all pointers - palUart->TxBuffer = NULL; - palUart->RxBuffer = NULL; - palUart->UartDriver = NULL; - palUart->WorkingTask = NULL; + palUart->TxBuffer = nullptr; + palUart->RxBuffer = nullptr; + palUart->UartDriver = nullptr; + palUart->WorkingTask = nullptr; palUart->WatchChar = 0; } } @@ -191,7 +191,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::get_BytesToRead___ NF_PAL_UART *palUart; uint8_t uartNum; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -199,7 +199,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::get_BytesToRead___ // Choose the driver for this SerialDevice palUart = GetPalUartFromUartNum(uartNum); - if (palUart == NULL) + if (palUart == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER); } @@ -239,7 +239,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::Read___I4__SZARRAY CLR_RT_HeapBlock hbTimeout; CLR_RT_HeapBlock_Array *dataBuffer; - NF_PAL_UART *palUart = NULL; + NF_PAL_UART *palUart = nullptr; uint8_t uartNum; uint8_t *data; @@ -253,7 +253,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::Read___I4__SZARRAY int64_t *timeoutTicks; bool eventResult = true; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -300,7 +300,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::Read___I4__SZARRAY // Choose the driver for this SerialDevice palUart = GetPalUartFromUartNum(uartNum); - if (palUart == NULL) + if (palUart == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER); } @@ -382,7 +382,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::ReadExisting___STR { NANOCLR_HEADER(); - NF_PAL_UART *palUart = NULL; + NF_PAL_UART *palUart = nullptr; uint8_t uartNum; uint8_t *buffer; @@ -390,7 +390,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::ReadExisting___STR CLR_RT_HeapBlock &top = stack.PushValue(); - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -403,7 +403,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::ReadExisting___STR // Choose the driver for this SerialDevice palUart = GetPalUartFromUartNum(uartNum); - if (palUart == NULL) + if (palUart == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER); } @@ -417,7 +417,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::ReadExisting___STR buffer = (uint8_t *)platform_malloc(bufferLength); // sanity check - if (buffer == NULL) + if (buffer == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_OUT_OF_MEMORY); } @@ -430,12 +430,12 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::ReadExisting___STR else { // create an empty - NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_String::CreateInstance(top, (const char *)NULL)); + NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_String::CreateInstance(top, (const char *)nullptr)); } NANOCLR_CLEANUP(); - if (buffer != NULL) + if (buffer != nullptr) { platform_free(buffer); } @@ -448,18 +448,18 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::ReadLine___STRING( NANOCLR_HEADER(); CLR_RT_HeapBlock hbTimeout; - NF_PAL_UART *palUart = NULL; + NF_PAL_UART *palUart = nullptr; uint8_t uartNum; - uint8_t *line = NULL; - const char *newLine = NULL; + uint8_t *line = nullptr; + const char *newLine = nullptr; uint32_t newLineLength; int64_t *timeoutTicks; bool eventResult = true; bool newLineFound = false; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -476,7 +476,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::ReadLine___STRING( // Choose the driver for this SerialDevice palUart = GetPalUartFromUartNum(uartNum); - if (palUart == NULL) + if (palUart == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER); } @@ -498,8 +498,8 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::ReadLine___STRING( // get new line from field newLine = pThis[FIELD___newLine].RecoverString(); - // sanity check for NULL string - if (newLine == NULL) + // sanity check for nullptr string + if (newLine == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER); } @@ -547,7 +547,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::ReadLine___STRING( stack.SetResult_String((const char *)line); // free memory, if needed - if (line != NULL) + if (line != nullptr) { platform_free(line); } @@ -559,7 +559,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::Write___VOID__SZAR { NANOCLR_HEADER(); - NF_PAL_UART *palUart = NULL; + NF_PAL_UART *palUart = nullptr; uint8_t uartNum; CLR_RT_HeapBlock_Array *dataBuffer; @@ -575,7 +575,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::Write___VOID__SZAR int32_t count = 0; int32_t offset = 0; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -588,7 +588,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::Write___VOID__SZAR // Choose the driver for this SerialDevice palUart = GetPalUartFromUartNum(uartNum); - if (palUart == NULL) + if (palUart == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER); } @@ -645,7 +645,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::Write___VOID__SZAR // Write data to start sending // by design: don't bother checking the return value - UART2_write(palUart->UartDriver, (const void *)data, count, NULL); + UART2_write(palUart->UartDriver, (const void *)data, count, nullptr); // bump custom state so the read value above is pushed only once stack.m_customState = 2; @@ -658,7 +658,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::Write___VOID__SZAR // Write data to ring buffer to start sending // by design: don't bother checking the return value - UART2_write(palUart->UartDriver, (const void *)data, count, NULL); + UART2_write(palUart->UartDriver, (const void *)data, count, nullptr); } } @@ -712,7 +712,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::NativeDispose___VO uint8_t uartNum; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -733,7 +733,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::NativeInit___VOID( int32_t bufferSize; uint8_t watchChar; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -749,7 +749,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::NativeInit___VOID( // Choose the driver for this SerialDevice palUart = GetPalUartFromUartNum(uartNum); - if (palUart == NULL) + if (palUart == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER); } @@ -757,7 +757,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::NativeInit___VOID( #if defined(NF_SERIAL_COMM_TI_USE_UART1) && (NF_SERIAL_COMM_TI_USE_UART1 == TRUE) // assign buffers, if not already done - if (palUart->RxBuffer == NULL) + if (palUart->RxBuffer == nullptr) { // alloc buffer memory bufferSize = pThis[FIELD___bufferSize].NumericByRef().s4; @@ -765,7 +765,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::NativeInit___VOID( palUart->RxBuffer = (uint8_t *)platform_malloc(bufferSize); // check allocation - if (palUart->RxBuffer == NULL) + if (palUart->RxBuffer == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_OUT_OF_MEMORY); } @@ -797,10 +797,10 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::NativeConfig___VOI { NANOCLR_HEADER(); - NF_PAL_UART *palUart = NULL; + NF_PAL_UART *palUart = nullptr; uint8_t uartNum; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -808,7 +808,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::NativeConfig___VOI // Choose the driver for this SerialDevice palUart = GetPalUartFromUartNum(uartNum); - if (palUart == NULL) + if (palUart == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER); } @@ -866,25 +866,25 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::NativeConfig___VOI UART2_readCancel(palUart->UartDriver); UART2_writeCancel(palUart->UartDriver); - if (palUart->UartDriver != NULL) + if (palUart->UartDriver != nullptr) { // stop UART before changing configuration, just in case UART2_close(palUart->UartDriver); // destroy task UART task, if it's running - if (palUart->WorkingTask != NULL) + if (palUart->WorkingTask != nullptr) { Task_destruct(&SerialRxTaskStruct); // null pointer - palUart->WorkingTask = NULL; + palUart->WorkingTask = nullptr; } } palUart->UartDriver = UART2_open(uartNum, &palUart->UartParams); // check if UART was opened - if (palUart->UartDriver == NULL) + if (palUart->UartDriver == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_OPERATION); } @@ -902,7 +902,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::NativeConfig___VOI taskParams.arg0 = (UArg)palUart->UartNum; // construct task - Task_construct(&SerialRxTaskStruct, (Task_FuncPtr)SerialRxTask, &taskParams, NULL); + Task_construct(&SerialRxTaskStruct, (Task_FuncPtr)SerialRxTask, &taskParams, nullptr); // store pointer to task palUart->WorkingTask = Task_handle(&SerialRxTaskStruct); @@ -917,14 +917,14 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::NativeSetWatchChar NF_PAL_UART *palUart; uint8_t uartNum; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); uartNum = PORT_INDEX_TO_UART_NUM(pThis[FIELD___portIndex].NumericByRef().s4); palUart = GetPalUartFromUartNum(uartNum); - if (palUart == NULL) + if (palUart == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER); } @@ -948,11 +948,11 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::NativeWriteString_ bool eventResult = true; bool isNewAllocation = false; - char *buffer = NULL; + char *buffer = nullptr; uint32_t bufferLength; int32_t length = 0; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -961,7 +961,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::NativeWriteString_ NANOCLR_SET_AND_LEAVE(CLR_E_OBJECT_DISPOSED); } - if (stack.Arg1().RecoverString() == NULL) + if (stack.Arg1().RecoverString() == nullptr) { // text string it's empty so there is noting to do here stack.SetResult_U4(0); @@ -971,7 +971,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::NativeWriteString_ uartNum = PORT_INDEX_TO_UART_NUM(pThis[FIELD___portIndex].NumericByRef().s4); palUart = GetPalUartFromUartNum(uartNum); - if (palUart == NULL) + if (palUart == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER); } @@ -998,7 +998,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::NativeWriteString_ // set TX ongoing count palUart->TxOngoingCount = bufferLength; - UART2_write(palUart->UartDriver, (const void *)buffer, bufferLength, NULL); + UART2_write(palUart->UartDriver, (const void *)buffer, bufferLength, nullptr); // bump custom state stack.m_customState = 2; @@ -1049,7 +1049,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::NativeWriteString_ } // null pointers and vars - pThis = NULL; + pThis = nullptr; NANOCLR_NOCLEANUP(); } @@ -1063,7 +1063,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::NativeReceivedByte int32_t threshold; uint8_t portIndex; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -1079,7 +1079,7 @@ HRESULT Library_sys_io_ser_native_System_IO_Ports_SerialPort::NativeReceivedByte // Choose the driver for this SerialDevice palUart = GetPalUartFromUartNum(portIndex); - if (palUart == NULL) + if (palUart == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER); } diff --git a/targets/TI_SimpleLink/_nanoCLR/nanoCRT.cpp b/targets/TI_SimpleLink/_nanoCLR/nanoCRT.cpp index 4297bd9a2a..02457db7ad 100644 --- a/targets/TI_SimpleLink/_nanoCLR/nanoCRT.cpp +++ b/targets/TI_SimpleLink/_nanoCLR/nanoCRT.cpp @@ -137,7 +137,7 @@ int hal_strcpy_s(char *strDst, size_t sizeInBytes, const char *strSrc) #undef strcpy size_t len; - if (strDst == NULL || strSrc == NULL || sizeInBytes == 0) + if (strDst == nullptr || strSrc == nullptr || sizeInBytes == 0) { _ASSERTE(FALSE); return 1; @@ -160,7 +160,7 @@ int hal_strncpy_s(char *strDst, size_t sizeInBytes, const char *strSrc, size_t c { NATIVE_PROFILE_PAL_CRT(); #undef strncpy - if (strDst == NULL || strSrc == NULL || sizeInBytes == 0) + if (strDst == nullptr || strSrc == nullptr || sizeInBytes == 0) { _ASSERTE(FALSE); return 1; @@ -194,7 +194,7 @@ int hal_strncmp_s(const char *str1, const char *str2, size_t num) { NATIVE_PROFILE_PAL_CRT(); #undef strncmp - if (str1 == NULL || str2 == NULL) + if (str1 == nullptr || str2 == nullptr) { _ASSERTE(FALSE); return 1; diff --git a/targets/TI_SimpleLink/_nanoCLR/nanoFramework.Hardware.TI/nf_hardware_ti_native.h b/targets/TI_SimpleLink/_nanoCLR/nanoFramework.Hardware.TI/nf_hardware_ti_native.h index 43913f88cd..19017fcc09 100644 --- a/targets/TI_SimpleLink/_nanoCLR/nanoFramework.Hardware.TI/nf_hardware_ti_native.h +++ b/targets/TI_SimpleLink/_nanoCLR/nanoFramework.Hardware.TI/nf_hardware_ti_native.h @@ -7,7 +7,6 @@ #define NF_HARDWARE_TI_NATIVE_H #include -#include #include #include diff --git a/targets/TI_SimpleLink/_nanoCLR/nanoFramework.Hardware.TI/nf_hardware_ti_native_nanoFramework_Hardware_TI_Power.cpp b/targets/TI_SimpleLink/_nanoCLR/nanoFramework.Hardware.TI/nf_hardware_ti_native_nanoFramework_Hardware_TI_Power.cpp index 6e2a765df8..99f441268b 100644 --- a/targets/TI_SimpleLink/_nanoCLR/nanoFramework.Hardware.TI/nf_hardware_ti_native_nanoFramework_Hardware_TI_Power.cpp +++ b/targets/TI_SimpleLink/_nanoCLR/nanoFramework.Hardware.TI/nf_hardware_ti_native_nanoFramework_Hardware_TI_Power.cpp @@ -39,8 +39,8 @@ HRESULT Library_nf_hardware_ti_native_nanoFramework_Hardware_TI_Power:: int32_t configCount; int32_t index = 0; - PIN_Config *wakeupConfigurations = NULL; - CLR_RT_HeapBlock *pinWakeupConfig = NULL; + PIN_Config *wakeupConfigurations = nullptr; + CLR_RT_HeapBlock *pinWakeupConfig = nullptr; CLR_RT_HeapBlock_Array *configArray = stack.Arg0().DereferenceArray(); FAULT_ON_NULL(configArray); @@ -55,7 +55,7 @@ HRESULT Library_nf_hardware_ti_native_nanoFramework_Hardware_TI_Power:: wakeupConfigurations = (PIN_Config *)platform_malloc((configCount + 1) * sizeof(PIN_Config)); // check allocation - if (wakeupConfigurations != NULL) + if (wakeupConfigurations != nullptr) { // clear memory memset(wakeupConfigurations, 0, configCount * sizeof(PIN_Config)); diff --git a/targets/TI_SimpleLink/_nanoCLR/nanoFramework.Hardware.TI/nf_hardware_ti_native_nanoFramework_Hardware_TI_Utilities.cpp b/targets/TI_SimpleLink/_nanoCLR/nanoFramework.Hardware.TI/nf_hardware_ti_native_nanoFramework_Hardware_TI_Utilities.cpp index a280c829ee..10f0c6a43a 100644 --- a/targets/TI_SimpleLink/_nanoCLR/nanoFramework.Hardware.TI/nf_hardware_ti_native_nanoFramework_Hardware_TI_Utilities.cpp +++ b/targets/TI_SimpleLink/_nanoCLR/nanoFramework.Hardware.TI/nf_hardware_ti_native_nanoFramework_Hardware_TI_Utilities.cpp @@ -16,7 +16,7 @@ HRESULT Library_nf_hardware_ti_native_nanoFramework_Hardware_TI_Utilities::Nativ CLR_RT_HeapBlock &top = stack.PushValueAndClear(); // dereference the byte array from the static field - NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_Array::CreateInstance(top, 8, g_CLR_RT_WellKnownTypes.m_UInt8)); + NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_Array::CreateInstance(top, 8, g_CLR_RT_WellKnownTypes.UInt8)); ieeeAddress = top.DereferenceArray()->GetFirstElement(); FAULT_ON_NULL(ieeeAddress); diff --git a/targets/TI_SimpleLink/_nanoCLR/nanoFramework.TI.EasyLink/nf_ti_easylink.h b/targets/TI_SimpleLink/_nanoCLR/nanoFramework.TI.EasyLink/nf_ti_easylink.h index d68ab64d2d..77c52cf33f 100644 --- a/targets/TI_SimpleLink/_nanoCLR/nanoFramework.TI.EasyLink/nf_ti_easylink.h +++ b/targets/TI_SimpleLink/_nanoCLR/nanoFramework.TI.EasyLink/nf_ti_easylink.h @@ -7,7 +7,6 @@ #define NF_TI_EASYLINK_H #include -#include #include #include #include diff --git a/targets/TI_SimpleLink/_nanoCLR/nanoFramework.TI.EasyLink/nf_ti_easylink_nanoFramework_TI_EasyLink_EasyLinkController.cpp b/targets/TI_SimpleLink/_nanoCLR/nanoFramework.TI.EasyLink/nf_ti_easylink_nanoFramework_TI_EasyLink_EasyLinkController.cpp index dc1898449b..2abc14d87b 100644 --- a/targets/TI_SimpleLink/_nanoCLR/nanoFramework.TI.EasyLink/nf_ti_easylink_nanoFramework_TI_EasyLink_EasyLinkController.cpp +++ b/targets/TI_SimpleLink/_nanoCLR/nanoFramework.TI.EasyLink/nf_ti_easylink_nanoFramework_TI_EasyLink_EasyLinkController.cpp @@ -347,7 +347,7 @@ HRESULT Library_nf_ti_easylink_nanoFramework_TI_EasyLink_EasyLinkController::Ini taskParams.priority = 4; // create task - Task_construct(&easyLinkTask, EasyLinkTask, &taskParams, NULL); + Task_construct(&easyLinkTask, EasyLinkTask, &taskParams, nullptr); // bump custom state stack.m_customState = 2; @@ -403,7 +403,7 @@ HRESULT Library_nf_ti_easylink_nanoFramework_TI_EasyLink_EasyLinkController:: CLR_INT64 *timeoutTicks; bool eventResult = true; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -459,8 +459,8 @@ HRESULT Library_nf_ti_easylink_nanoFramework_TI_EasyLink_EasyLinkController:: NANOCLR_CHECK_HRESULT( g_CLR_RT_ExecutionEngine.WaitEvents(stack.m_owningThread, *timeoutTicks, Event_Radio, eventResult)); - // set to NULL and protect from GC - hbObj.SetObjectReference(NULL); + // set to nullptr and protect from GC + hbObj.SetObjectReference(nullptr); CLR_RT_ProtectFromGC gc1(hbObj); if (eventResult) @@ -498,7 +498,7 @@ HRESULT Library_nf_ti_easylink_nanoFramework_TI_EasyLink_EasyLinkController:: NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_Array::CreateInstance( packet[ReceivedPacket::FIELD___address], (CLR_UINT32)ARRAYSIZE(latestRxPacket.dstAddr), - g_CLR_RT_WellKnownTypes.m_UInt8)); + g_CLR_RT_WellKnownTypes.UInt8)); buffer = packet[ReceivedPacket::FIELD___address].DereferenceArray(); // copy address memcpy(buffer->GetFirstElement(), latestRxPacket.dstAddr, ARRAYSIZE(latestRxPacket.dstAddr)); @@ -507,7 +507,7 @@ HRESULT Library_nf_ti_easylink_nanoFramework_TI_EasyLink_EasyLinkController:: NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_Array::CreateInstance( packet[ReceivedPacket::FIELD___payload], (CLR_UINT32)ARRAYSIZE(latestRxPacket.payload), - g_CLR_RT_WellKnownTypes.m_UInt8)); + g_CLR_RT_WellKnownTypes.UInt8)); buffer = packet[ReceivedPacket::FIELD___payload].DereferenceArray(); // copy payload content memcpy(buffer->GetFirstElement(), latestRxPacket.payload, ARRAYSIZE(latestRxPacket.payload)); @@ -533,7 +533,7 @@ HRESULT Library_nf_ti_easylink_nanoFramework_TI_EasyLink_EasyLinkController:: // packet it's passed as "out" meaning BYREF // need to store the ReceivedPacket object in its reference - // hbObj it's either NULL or it's a properly formated ReceivedPacket object + // hbObj it's either nullptr or it's a properly formated ReceivedPacket object NANOCLR_CHECK_HRESULT(hbObj.StoreToReference(stack.Arg1(), 0)); } @@ -623,7 +623,7 @@ HRESULT Library_nf_ti_easylink_nanoFramework_TI_EasyLink_EasyLinkController:: uint32_t absTime; bool eventResult = true; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -758,17 +758,17 @@ HRESULT Library_nf_ti_easylink_nanoFramework_TI_EasyLink_EasyLinkController::Upd { NANOCLR_HEADER(); - uint8_t *addressTable = NULL; - uint8_t *addressTableCursor = NULL; + uint8_t *addressTable = nullptr; + uint8_t *addressTableCursor = nullptr; uint8_t addressSize; // need to initialize these because they are passed by ref int addressCount = 0, capacity = 0; - CLR_RT_HeapBlock_Array *addressList = NULL; + CLR_RT_HeapBlock_Array *addressList = nullptr; CLR_RT_HeapBlock_Array *address; CLR_RT_HeapBlock *addressField; - // get a pointer to the managed object instance and check that it's not NULL + // get a pointer to the managed object instance and check that it's not nullptr CLR_RT_HeapBlock *pThis = stack.This(); FAULT_ON_NULL(pThis); @@ -788,7 +788,7 @@ HRESULT Library_nf_ti_easylink_nanoFramework_TI_EasyLink_EasyLinkController::Upd addressTable = (uint8_t *)platform_malloc(addressCount * addressSize); // sanity check - if (addressTable == NULL) + if (addressTable == nullptr) { // mem allocation failed NANOCLR_SET_AND_LEAVE(CLR_E_OUT_OF_MEMORY); @@ -802,7 +802,7 @@ HRESULT Library_nf_ti_easylink_nanoFramework_TI_EasyLink_EasyLinkController::Upd for (int i = 0; i < addressCount; i++) { address = ((CLR_RT_HeapBlock_Array *)addressList->GetElement(i))->DereferenceArray(); - if (address != NULL) + if (address != nullptr) { memcpy(addressTableCursor, address->GetFirstElement(), addressSize); @@ -814,7 +814,7 @@ HRESULT Library_nf_ti_easylink_nanoFramework_TI_EasyLink_EasyLinkController::Upd EasyLink_enableRxAddrFilter(addressTable, addressCount, addressSize); } - if (addressTable != NULL) + if (addressTable != nullptr) { platform_free(addressTable); } diff --git a/targets/TI_SimpleLink/_nanoCLR/targetHAL.cpp b/targets/TI_SimpleLink/_nanoCLR/targetHAL.cpp index 1e93be609a..4466df793e 100644 --- a/targets/TI_SimpleLink/_nanoCLR/targetHAL.cpp +++ b/targets/TI_SimpleLink/_nanoCLR/targetHAL.cpp @@ -30,13 +30,13 @@ // Reboot handlers clean up on reboot // static ON_SOFT_REBOOT_HANDLER s_rebootHandlers[16] = - {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}; + {nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr}; void HAL_AddSoftRebootHandler(ON_SOFT_REBOOT_HANDLER handler) { for (unsigned int i = 0; i < ARRAYSIZE(s_rebootHandlers); i++) { - if (s_rebootHandlers[i] == NULL) + if (s_rebootHandlers[i] == nullptr) { s_rebootHandlers[i] = handler; return; @@ -77,7 +77,7 @@ void nanoHAL_Initialize() BlockStorageList_InitializeDevices(); // clear managed heap region - unsigned char *heapStart = NULL; + unsigned char *heapStart = nullptr; unsigned int heapSize = 0; ::HeapLocation(heapStart, heapSize); @@ -118,7 +118,7 @@ void nanoHAL_Uninitialize(bool isPoweringDown) // check for s_rebootHandlers for (unsigned int i = 0; i < ARRAYSIZE(s_rebootHandlers); i++) { - if (s_rebootHandlers[i] != NULL) + if (s_rebootHandlers[i] != nullptr) { s_rebootHandlers[i](); } diff --git a/targets/netcore/littlefs/littlefs_FS_Driver.cpp b/targets/netcore/littlefs/littlefs_FS_Driver.cpp index 768f18f7b5..af90ddb47c 100644 --- a/targets/netcore/littlefs/littlefs_FS_Driver.cpp +++ b/targets/netcore/littlefs/littlefs_FS_Driver.cpp @@ -21,7 +21,7 @@ STREAM_DRIVER_DETAILS *LITTLEFS_FS_Driver::DriverDetails(const VOLUME_ID *volume { (void)volume; - static STREAM_DRIVER_DETAILS driverDetail = {SYSTEM_BUFFERED_IO, NULL, NULL, 0, 0, TRUE, TRUE, TRUE, 0, 0}; + static STREAM_DRIVER_DETAILS driverDetail = {SYSTEM_BUFFERED_IO, nullptr, nullptr, 0, 0, TRUE, TRUE, TRUE, 0, 0}; return &driverDetail; } @@ -58,8 +58,8 @@ HRESULT LITTLEFS_FS_Driver::Format(const VOLUME_ID *volume, const char *volumeLa (void)volumeLabel; (void)parameters; - lfs_t *fsDrive = NULL; - uint8_t *index = NULL; + lfs_t *fsDrive = nullptr; + uint8_t *index = nullptr; // get littlefs instance fsDrive = hal_lfs_get_fs_from_index(volume->volumeId); @@ -142,7 +142,7 @@ HRESULT LITTLEFS_FS_Driver::Open(const VOLUME_ID *volume, const char *path, void int32_t result; #endif - LITTLEFS_FileHandle *fileHandle = NULL; + LITTLEFS_FileHandle *fileHandle = nullptr; lfs_info info; int32_t flags; char normalizedPath[FS_MAX_DIRECTORY_LENGTH]; @@ -151,7 +151,7 @@ HRESULT LITTLEFS_FS_Driver::Open(const VOLUME_ID *volume, const char *path, void // allocate file handle fileHandle = (LITTLEFS_FileHandle *)platform_malloc(sizeof(LITTLEFS_FileHandle)); - if (fileHandle == NULL) + if (fileHandle == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_OUT_OF_MEMORY); } @@ -193,7 +193,7 @@ HRESULT LITTLEFS_FS_Driver::Open(const VOLUME_ID *volume, const char *path, void fileHandle->nanoAttributes = FileAttributes_Normal; fileHandle->attr = {NANO_LITTLEFS_ATTRIBUTE, &fileHandle->nanoAttributes, NANO_LITTLEFS_ATTRIBUTE_SIZE}; fileHandle->fileConfig = { - .buffer = NULL, + .buffer = nullptr, .attrs = &fileHandle->attr, .attr_count = 1, }; @@ -233,7 +233,7 @@ HRESULT LITTLEFS_FS_Driver::Open(const VOLUME_ID *volume, const char *path, void NANOCLR_CLEANUP(); - if (fileHandle != NULL) + if (fileHandle != nullptr) { platform_free(fileHandle); } @@ -508,12 +508,12 @@ HRESULT LITTLEFS_FS_Driver::FindOpen(const VOLUME_ID *volume, const char *path, NANOCLR_HEADER(); char normalizedPath[FS_MAX_DIRECTORY_LENGTH]; - LITTLEFS_FindFileHandle *findHandle = NULL; + LITTLEFS_FindFileHandle *findHandle = nullptr; // allocate file handle findHandle = (LITTLEFS_FindFileHandle *)platform_malloc(sizeof(LITTLEFS_FindFileHandle)); - if (findHandle == NULL) + if (findHandle == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_OUT_OF_MEMORY); } @@ -552,7 +552,7 @@ HRESULT LITTLEFS_FS_Driver::FindOpen(const VOLUME_ID *volume, const char *path, NANOCLR_CLEANUP(); - if (findHandle != NULL) + if (findHandle != nullptr) { platform_free(findHandle); } @@ -613,7 +613,7 @@ HRESULT LITTLEFS_FS_Driver::FindNext(void *handle, FS_FILEINFO *fi, bool *fileFo fi->FileName = (char *)platform_malloc(fi->FileNameSize + 1); // sanity check for successfull malloc - if (fi->FileName == NULL) + if (fi->FileName == nullptr) { NANOCLR_SET_AND_LEAVE(CLR_E_OUT_OF_MEMORY); } @@ -644,7 +644,7 @@ HRESULT LITTLEFS_FS_Driver::FindClose(void *handle) { findHandle = (LITTLEFS_FindFileHandle *)handle; - if (findHandle->fs != NULL) + if (findHandle->fs != nullptr) { lfs_dir_close(findHandle->fs, &findHandle->dir); @@ -657,7 +657,7 @@ HRESULT LITTLEFS_FS_Driver::FindClose(void *handle) HRESULT LITTLEFS_FS_Driver::GetFileInfo(const VOLUME_ID *volume, const char *path, FS_FILEINFO *fileInfo, bool *found) { - lfs_t *fsDrive = NULL; + lfs_t *fsDrive = nullptr; lfs_info info; char normalizedPath[FS_MAX_DIRECTORY_LENGTH]; @@ -715,7 +715,7 @@ HRESULT LITTLEFS_FS_Driver::GetAttributes(const VOLUME_ID *volume, const char *p { NANOCLR_HEADER(); - lfs_t *fsDrive = NULL; + lfs_t *fsDrive = nullptr; lfs_info info; int32_t result; char normalizedPath[FS_MAX_DIRECTORY_LENGTH]; @@ -804,7 +804,7 @@ HRESULT LITTLEFS_FS_Driver::GetAttributes(const VOLUME_ID *volume, const char *p HRESULT LITTLEFS_FS_Driver::SetAttributes(const VOLUME_ID *volume, const char *path, uint32_t attributes) { - lfs_t *fsDrive = NULL; + lfs_t *fsDrive = nullptr; lfs_info info; uint32_t currentAttributes; char normalizedPath[FS_MAX_DIRECTORY_LENGTH]; @@ -861,7 +861,7 @@ HRESULT LITTLEFS_FS_Driver::SetAttributes(const VOLUME_ID *volume, const char *p HRESULT LITTLEFS_FS_Driver::CreateDirectory(const VOLUME_ID *volume, const char *path) { - lfs_t *fsDrive = NULL; + lfs_t *fsDrive = nullptr; int32_t result = LFS_ERR_OK; char normalizedPath[FS_MAX_DIRECTORY_LENGTH]; char tempPath[FS_MAX_DIRECTORY_LENGTH + 1]; @@ -900,7 +900,7 @@ HRESULT LITTLEFS_FS_Driver::CreateDirectory(const VOLUME_ID *volume, const char // add back the '/' separator strcat(tempPath, "/"); - segment = strtok(NULL, "/"); + segment = strtok(nullptr, "/"); } // remove trailing '/' @@ -945,7 +945,7 @@ HRESULT LITTLEFS_FS_Driver::CreateDirectory(const VOLUME_ID *volume, const char HRESULT LITTLEFS_FS_Driver::Move(const VOLUME_ID *volume, const char *oldPath, const char *newPath) { - lfs_t *fsDrive = NULL; + lfs_t *fsDrive = nullptr; char normalizedNewPath[FS_MAX_DIRECTORY_LENGTH]; char normalizedOldPath[FS_MAX_DIRECTORY_LENGTH]; int32_t result = LFS_ERR_OK; @@ -989,7 +989,7 @@ HRESULT LITTLEFS_FS_Driver::Move(const VOLUME_ID *volume, const char *oldPath, c HRESULT LITTLEFS_FS_Driver::Delete(const VOLUME_ID *volume, const char *path, bool recursive) { - lfs_t *fsDrive = NULL; + lfs_t *fsDrive = nullptr; lfs_info info; char normalizedPath[FS_MAX_DIRECTORY_LENGTH]; int32_t result; diff --git a/targets/netcore/nanoCLR.sln b/targets/netcore/nanoCLR.sln index b428924285..146dcbf244 100644 --- a/targets/netcore/nanoCLR.sln +++ b/targets/netcore/nanoCLR.sln @@ -84,6 +84,11 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "littlefs", "littlefs\little EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FileStream", "..\..\src\CLR\Core\FileStream\FileStream.vcxproj", "{ABFE159E-84D5-489E-BFE6-8A7F4B597A44}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{65520520-70C9-4D4A-89AD-74A13DE78A31}" + ProjectSection(SolutionItems) = preProject + ..\..\nf.props = ..\..\nf.props + EndProjectSection +EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "System.Device.I2c", "..\..\src\System.Device.I2c\System.Device.I2c.vcxproj", "{E9AE1AF4-6B6A-4E10-B136-7A8AFFC5B910}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "System.Device.Spi", "..\..\src\System.Device.Spi\System.Device.Spi.vcxproj", "{197C5BB5-72D2-4634-A5F8-8443DBF39985}" diff --git a/targets/netcore/nanoFramework.nanoCLR/CLRStartup.cpp b/targets/netcore/nanoFramework.nanoCLR/CLRStartup.cpp index 55fb51a808..fda4d3dd9e 100644 --- a/targets/netcore/nanoFramework.nanoCLR/CLRStartup.cpp +++ b/targets/netcore/nanoFramework.nanoCLR/CLRStartup.cpp @@ -59,14 +59,14 @@ struct Settings NANOCLR_CHECK_HRESULT(CLR_RT_Assembly::CreateInstance(header, assm)); // Get handlers for native functions in assembly - pNativeAssmData = GetAssemblyNativeData(assm->m_szName); + pNativeAssmData = GetAssemblyNativeData(assm->name); - // If pNativeAssmData not NULL- means this assembly has native calls and there is pointer to table with native - // calls. - if (pNativeAssmData != NULL) + // If pNativeAssmData not nullptr- means this assembly has native calls and there is pointer to table with + // native calls. + if (pNativeAssmData != nullptr) { // First verify that check sum in assembly object matches hardcoded check sum. - if (assm->m_header->nativeMethodsChecksum != pNativeAssmData->m_checkSum) + if (assm->header->nativeMethodsChecksum != pNativeAssmData->m_checkSum) { CLR_Debug::Printf( "\r\n\r\n***********************************************************************\r\n"); @@ -76,8 +76,8 @@ struct Settings CLR_Debug::Printf("* *\r\n"); CLR_Debug::Printf( "* Invalid native checksum: %s 0x%08X!=0x%08X *\r\n", - assm->m_szName, - assm->m_header->nativeMethodsChecksum, + assm->name, + assm->header->nativeMethodsChecksum, pNativeAssmData->m_checkSum); CLR_Debug::Printf("* *\r\n"); CLR_Debug::Printf("***********************************************************************\r\n"); @@ -86,7 +86,7 @@ struct Settings } // Assembly has valid pointer to table with native methods. Save it. - assm->m_nativeCode = (const CLR_RT_MethodHandler *)pNativeAssmData->m_pNativeMethods; + assm->nativeCode = (const CLR_RT_MethodHandler *)pNativeAssmData->m_pNativeMethods; } g_CLR_RT_TypeSystem.Link(assm); NANOCLR_NOCLEANUP(); @@ -114,7 +114,7 @@ struct Settings for (CLR_RT_ParseOptions::BufferMapIter it = m_assemblies.begin(); it != m_assemblies.end(); it++) { CLR_RT_Assembly *assm; - const CLR_RT_Buffer *buffer = (const CLR_RT_Buffer *)it->second; + auto *buffer = (const CLR_RT_Buffer *)it->second; const CLR_RECORD_ASSEMBLY *header = (CLR_RECORD_ASSEMBLY *)&(*buffer)[0]; // Creates instance of assembly, sets pointer to native functions, links to g_CLR_RT_TypeSystem @@ -169,13 +169,13 @@ struct Settings unsigned int datSize = ROUNDTOMULTIPLE((unsigned int)(*end) - (unsigned int)(*start), CLR_UINT32); if (BlockStorageList_FindDeviceForPhysicalAddress(&device, (unsigned int)(*start), &datByteAddress) && - device != NULL) + device != nullptr) { const DeviceBlockInfo *deviceInfo = BlockStorageDevice_GetDeviceInfo(device); if (deviceInfo->Attribute & MediaAttribute_SupportsXIP) { - unsigned char *datAssembliesBuffer = + auto *datAssembliesBuffer = (unsigned char *)CLR_RT_Memory::Allocate_And_Erase(datSize, CLR_RT_HeapBlock ::HB_Unmovable); CHECK_ALLOCATION(datAssembliesBuffer); @@ -199,7 +199,7 @@ struct Settings const CLR_RECORD_ASSEMBLY *header; unsigned char *assembliesBuffer; signed int headerInBytes = sizeof(CLR_RECORD_ASSEMBLY); - unsigned char *headerBuffer = NULL; + unsigned char *headerBuffer = nullptr; if (!isXIP) { @@ -270,7 +270,7 @@ struct Settings break; } - assm->m_flags |= CLR_RT_Assembly::Deployed; + assm->flags |= CLR_RT_Assembly::Deployed; } if (!isXIP) CLR_RT_Memory::Release(headerBuffer); @@ -324,7 +324,7 @@ struct Settings { m_fInitialized = false; #if defined(VIRTUAL_DEVICE) - m_configureRuntimeCallback = NULL; + m_configureRuntimeCallback = nullptr; m_configured = false; #endif } @@ -346,11 +346,14 @@ struct Settings if (header->GoodAssembly() == false) { - wprintf(L"Invalid assembly format for '%s': ", src); - for (int i = 0; i < sizeof(header->marker); i++) + wprintf(L"Invalid assembly format for assembly '%s'\n", src); + + wprintf(L"Header is: "); + for (size_t i = 0; i < sizeof(header->marker); i++) { - wprintf(L"%02x", header->marker[i]); + wprintf(L"%c", header->marker[i]); } + wprintf(L"\n"); NANOCLR_SET_AND_LEAVE(CLR_E_FAIL); @@ -363,7 +366,7 @@ struct Settings { NANOCLR_HEADER(); - CLR_RT_Buffer *buffer = new CLR_RT_Buffer(data, data + size); + auto *buffer = new CLR_RT_Buffer(data, data + size); CLR_RECORD_ASSEMBLY *header; header = (CLR_RECORD_ASSEMBLY *)&(*buffer)[0]; @@ -401,7 +404,7 @@ struct Settings while (header + 1 <= headerEnd && header->GoodAssembly()) { - CLR_RT_Buffer *bufferSub = new CLR_RT_Buffer(); + auto *bufferSub = new CLR_RT_Buffer(); CLR_RECORD_ASSEMBLY *headerSub; CLR_RT_Assembly *assm; @@ -426,7 +429,7 @@ struct Settings break; } - CLR_RT_UnicodeHelper::ConvertFromUTF8(assm->m_szName, strName); + CLR_RT_UnicodeHelper::ConvertFromUTF8(assm->name, strName); m_assemblies[strName] = bufferSub; assm->DestroyInstance(); @@ -453,20 +456,20 @@ struct Settings NANOCLR_FOREACH_ASSEMBLY(g_CLR_RT_TypeSystem) { - const CLR_RECORD_ASSEMBLYREF *src = (const CLR_RECORD_ASSEMBLYREF *)pASSM->GetTable(TBL_AssemblyRef); - for (int i = 0; i < pASSM->m_pTablesSize[TBL_AssemblyRef]; i++, src++) + auto *src = (const CLR_RECORD_ASSEMBLYREF *)pASSM->GetTable(TBL_AssemblyRef); + for (int i = 0; i < pASSM->tablesSize[TBL_AssemblyRef]; i++, src++) { const char *szName = pASSM->GetString(src->name); - if (g_CLR_RT_TypeSystem.FindAssembly(szName, &src->version, true) == NULL) + if (g_CLR_RT_TypeSystem.FindAssembly(szName, &src->version, true) == nullptr) { printf( "Missing assembly: %s (%d.%d.%d.%d)\n", szName, - src->version.iMajorVersion, - src->version.iMinorVersion, - src->version.iBuildNumber, - src->version.iRevisionNumber); + src->version.majorVersion, + src->version.minorVersion, + src->version.buildNumber, + src->version.revisionNumber); fError = true; } @@ -540,7 +543,7 @@ void ClrStartup(CLR_SETTINGS params) CLR_Debug::Printf("Ready.\r\n"); #endif - (void)g_CLR_RT_ExecutionEngine.Execute(NULL, params.MaxContextSwitches); + (void)g_CLR_RT_ExecutionEngine.Execute(nullptr, params.MaxContextSwitches); #if !defined(BUILD_RTM) CLR_Debug::Printf("Done.\r\n"); @@ -559,7 +562,7 @@ void ClrStartup(CLR_SETTINGS params) { #if defined(NANOCLR_ENABLE_SOURCELEVELDEBUGGING) CLR_EE_DBG_SET_MASK(StateProgramExited, StateMask); - CLR_EE_DBG_EVENT_BROADCAST(CLR_DBG_Commands::c_Monitor_ProgramExit, 0, NULL, WP_Flags_c_NonCritical); + CLR_EE_DBG_EVENT_BROADCAST(CLR_DBG_Commands::c_Monitor_ProgramExit, 0, nullptr, WP_Flags_c_NonCritical); #endif // #if defined(NANOCLR_ENABLE_SOURCELEVELDEBUGGING) if (params.EnterDebuggerLoopAfterExit) diff --git a/targets/netcore/nanoFramework.nanoCLR/Target_BlockStorage.cpp b/targets/netcore/nanoFramework.nanoCLR/Target_BlockStorage.cpp index c9a7cd1b62..d9790b2ddf 100644 --- a/targets/netcore/nanoFramework.nanoCLR/Target_BlockStorage.cpp +++ b/targets/netcore/nanoFramework.nanoCLR/Target_BlockStorage.cpp @@ -146,7 +146,7 @@ bool BlockStorageStream_SetReadModifyWrite(BlockStorageStream *stream) bool BlockStorageStream_Initialize(BlockStorageStream *stream, unsigned int blockUsage) { - return BlockStorageStream_InitializeWithBlockStorageDevice(stream, blockUsage, NULL); + return BlockStorageStream_InitializeWithBlockStorageDevice(stream, blockUsage, nullptr); } bool BlockStorageStream_InitializeWithBlockStorageDevice( @@ -154,14 +154,14 @@ bool BlockStorageStream_InitializeWithBlockStorageDevice( unsigned int blockUsage, BlockStorageDevice *pDevice) { - DeviceBlockInfo *deviceInfo = NULL; + DeviceBlockInfo *deviceInfo = nullptr; BlockStorageStream backupStream; - BlockStorageDevice *device = NULL; + BlockStorageDevice *device = nullptr; // backup original stream, in case this gets messed up memcpy(&backupStream, stream, sizeof(BlockStorageStream)); - if (pDevice != NULL) + if (pDevice != nullptr) { device = pDevice; @@ -188,13 +188,13 @@ bool BlockStorageStream_InitializeWithBlockStorageDevice( else { // couldn't find a block matching the request usage - // need to NULL the device info that's going to be used to fill in the stream details - deviceInfo = NULL; + // need to nullptr the device info that's going to be used to fill in the stream details + deviceInfo = nullptr; } } } - if (deviceInfo != NULL) + if (deviceInfo != nullptr) { BlockRegionInfo *pRegion = &deviceInfo->Regions[stream->RegionIndex]; @@ -241,7 +241,7 @@ bool BlockStorageStream_InitializeWithBlockStorageDevice( bool BlockStorageStream_NextStream(BlockStorageStream *stream) { - if (stream->Device == NULL || BlockStorageDevice_Prev(stream->Device) == NULL) + if (stream->Device == nullptr || BlockStorageDevice_Prev(stream->Device) == nullptr) return false; const BlockRegionInfo *pRegion; @@ -261,7 +261,7 @@ bool BlockStorageStream_NextStream(BlockStorageStream *stream) { stream->Device = BlockStorageDevice_Prev(stream->Device); - if (stream->Device == NULL || BlockStorageDevice_Prev(stream->Device) == NULL) + if (stream->Device == nullptr || BlockStorageDevice_Prev(stream->Device) == nullptr) { memcpy(stream, &orig, sizeof(orig)); return false; @@ -311,7 +311,7 @@ bool BlockStorageStream_NextStream(BlockStorageStream *stream) bool BlockStorageStream_PrevStream(BlockStorageStream *stream) { - if (stream->Device == NULL || BlockStorageDevice_Prev(stream->Device) == NULL) + if (stream->Device == nullptr || BlockStorageDevice_Prev(stream->Device) == nullptr) return false; const BlockRegionInfo *pRegion; @@ -331,7 +331,7 @@ bool BlockStorageStream_PrevStream(BlockStorageStream *stream) { stream->Device = BlockStorageDevice_Prev(stream->Device); - if (stream->Device == NULL || BlockStorageDevice_Prev(stream->Device) == NULL) + if (stream->Device == nullptr || BlockStorageDevice_Prev(stream->Device) == nullptr) { memcpy(stream, &orig, sizeof(orig)); return false; @@ -449,7 +449,7 @@ bool BlockStorageStream_ReadIntoBuffer(BlockStorageStream *stream, unsigned char bool BlockStorageStream_Read(BlockStorageStream *stream, unsigned char **buffer, unsigned int length) { - if (stream == NULL || stream->Device == NULL || buffer == 0) + if (stream == nullptr || stream->Device == nullptr || buffer == 0) { return false; } @@ -532,14 +532,14 @@ BlockStorageDevice *BlockStorageDevice_Next(BlockStorageDevice *device) { (void)device; - return NULL; + return nullptr; } BlockStorageDevice *BlockStorageDevice_Prev(BlockStorageDevice *device) { (void)device; - return NULL; + return nullptr; } ///////////////////////////////////////////////////////// @@ -555,8 +555,8 @@ BlockStorageDevice *BlockStorageDevice_Prev(BlockStorageDevice *device) // bool BlockStorageDevice_InitializeDevice(BlockStorageDevice *device) { - ASSERT(device != NULL); - ASSERT(device->m_context != NULL); + ASSERT(device != nullptr); + ASSERT(device->m_context != nullptr); return device->m_BSD->InitializeDevice(device->m_context); } @@ -573,8 +573,8 @@ bool BlockStorageDevice_InitializeDevice(BlockStorageDevice *device) // bool BlockStorageDevice_UninitializeDevice(BlockStorageDevice *device) { - ASSERT(device != NULL); - ASSERT(device->m_context != NULL); + ASSERT(device != nullptr); + ASSERT(device->m_context != nullptr); return device->m_BSD->UninitializeDevice(device->m_context); } @@ -585,8 +585,8 @@ bool BlockStorageDevice_UninitializeDevice(BlockStorageDevice *device) // DeviceBlockInfo *BlockStorageDevice_GetDeviceInfo(BlockStorageDevice *device) { - ASSERT(device != NULL); - ASSERT(device->m_context != NULL); + ASSERT(device != nullptr); + ASSERT(device->m_context != nullptr); return device->m_BSD->GetDeviceInfo(device->m_context); } @@ -611,13 +611,13 @@ DeviceBlockInfo *BlockStorageDevice_GetDeviceInfo(BlockStorageDevice *device) // Remarks: // This function reads the number of sectors specified from the device. // -// pSectorBuff may be NULL. This is to allow for reading just the metadata. +// pSectorBuff may be nullptr. This is to allow for reading just the metadata. // -// pSectorMetadata can be set to NULL if the caller does not need the extra +// pSectorMetadata can be set to nullptr if the caller does not need the extra // data. // // If the device does not support sector Metadata it should fail if the -// pSectorMetadata parameter is not NULL. +// pSectorMetadata parameter is not nullptr. // bool BlockStorageDevice_Read( BlockStorageDevice *device, @@ -625,8 +625,8 @@ bool BlockStorageDevice_Read( unsigned int numBytes, unsigned char *buffer) { - ASSERT(device != NULL); - ASSERT(device->m_context != NULL); + ASSERT(device != nullptr); + ASSERT(device->m_context != nullptr); return device->m_BSD->Read(device->m_context, startAddress, numBytes, buffer); } @@ -657,10 +657,10 @@ bool BlockStorageDevice_Read( // on a sector. // // If the device does not support sector Metadata it should fail if the -// pSectorMetadata parameter is not NULL. +// pSectorMetadata parameter is not nullptr. // -// pSectorMetadata can be set to NULL if the caller does not need the extra -// data. Implementations must not attempt to write data through a NULL pointer! +// pSectorMetadata can be set to nullptr if the caller does not need the extra +// data. Implementations must not attempt to write data through a nullptr pointer! // bool BlockStorageDevice_Write( BlockStorageDevice *device, @@ -669,8 +669,8 @@ bool BlockStorageDevice_Write( unsigned char *buffer, bool readModifyWrite) { - ASSERT(device != NULL); - ASSERT(device->m_context != NULL); + ASSERT(device != nullptr); + ASSERT(device->m_context != nullptr); return device->m_BSD->Write(device->m_context, startAddress, numBytes, buffer, readModifyWrite); } @@ -681,8 +681,8 @@ bool BlockStorageDevice_Memset( unsigned char buffer, unsigned int numBytes) { - ASSERT(device != NULL); - ASSERT(device->m_context != NULL); + ASSERT(device != nullptr); + ASSERT(device->m_context != nullptr); return device->m_BSD->Memset(device->m_context, startAddress, buffer, numBytes); } @@ -706,8 +706,8 @@ bool BlockStorageDevice_Memset( // bool BlockStorageDevice_IsBlockErased(BlockStorageDevice *device, unsigned int blockStartAddress, unsigned int length) { - ASSERT(device != NULL); - ASSERT(device->m_context != NULL); + ASSERT(device != nullptr); + ASSERT(device->m_context != nullptr); return device->m_BSD->IsBlockErased(device->m_context, blockStartAddress, length); } @@ -727,8 +727,8 @@ bool BlockStorageDevice_IsBlockErased(BlockStorageDevice *device, unsigned int b // bool BlockStorageDevice_EraseBlock(BlockStorageDevice *device, unsigned int address) { - ASSERT(device != NULL); - ASSERT(device->m_context != NULL); + ASSERT(device != nullptr); + ASSERT(device->m_context != nullptr); return device->m_BSD->EraseBlock(device->m_context, address); } @@ -747,8 +747,8 @@ bool BlockStorageDevice_EraseBlock(BlockStorageDevice *device, unsigned int addr // void BlockStorageDevice_SetPowerState(BlockStorageDevice *device, unsigned int state) { - ASSERT(device != NULL); - ASSERT(device->m_context != NULL); + ASSERT(device != nullptr); + ASSERT(device->m_context != nullptr); device->m_BSD->SetPowerState(device->m_context, state); } @@ -759,7 +759,7 @@ bool BlockStorageDevice_FindRegionFromAddress( unsigned int *blockRegionIndex, unsigned int *blockRangeIndex) { - ASSERT(device != NULL); + ASSERT(device != nullptr); DeviceBlockInfo *deviceInfo = BlockStorageDevice_GetDeviceInfo(device); @@ -773,7 +773,7 @@ bool BlockStorageDevice_FindForBlockUsage( unsigned int *blockRegionIndex, unsigned int *blockRangeIndex) { - ASSERT(device != NULL); + ASSERT(device != nullptr); DeviceBlockInfo *deviceInfo = BlockStorageDevice_GetDeviceInfo(device); @@ -787,7 +787,7 @@ bool BlockStorageDevice_FindNextUsageBlock( unsigned int *blockRegionIndex, unsigned int *blockRangeIndex) { - ASSERT(device != NULL); + ASSERT(device != nullptr); DeviceBlockInfo *deviceInfo = BlockStorageDevice_GetDeviceInfo(device); @@ -800,8 +800,8 @@ bool BlockStorageDevice_GetMemoryMappedAddress( unsigned int blockRangeIndex, unsigned int *address) { - ASSERT(device != NULL); - ASSERT(device->m_context != NULL); + ASSERT(device != nullptr); + ASSERT(device->m_context != nullptr); return device->m_BSD->GetMemoryMappedAddress(device->m_context, blockRegionIndex, blockRangeIndex, address); } @@ -814,7 +814,7 @@ void BlockStorageList_Initialize() { for (int i = 0; i < TARGET_BLOCKSTORAGE_COUNT; i++) { - g_BlockStorage.DeviceList[i] = NULL; + g_BlockStorage.DeviceList[i] = nullptr; } g_BlockStorage.DeviceCount = 0; @@ -841,7 +841,7 @@ bool BlockStorageList_AddDevice(BlockStorageDevice *pBSD, IBlockStorageDevice *v // find next empty device slot for (int i = 0; i < TARGET_BLOCKSTORAGE_COUNT; i++) { - if (g_BlockStorage.DeviceList[i] == NULL) + if (g_BlockStorage.DeviceList[i] == nullptr) { // found an empty slot @@ -888,7 +888,7 @@ bool BlockStorageList_RemoveDevice(BlockStorageDevice *pBSD, bool unInit) } // remove device - g_BlockStorage.DeviceList[i] = NULL; + g_BlockStorage.DeviceList[i] = nullptr; // done here return true; @@ -903,7 +903,7 @@ bool BlockStorageList_FindDeviceForPhysicalAddress( unsigned int physicalAddress, ByteAddress *blockAddress) { - *pBSD = NULL; + *pBSD = nullptr; BlockStorageDevice *block = BlockStorageList_GetFirstDevice(); @@ -938,13 +938,13 @@ BlockStorageDevice *BlockStorageList_GetFirstDevice() { for (int i = 0; i < TARGET_BLOCKSTORAGE_COUNT; i++) { - if (g_BlockStorage.DeviceList[i] != NULL) + if (g_BlockStorage.DeviceList[i] != nullptr) { return g_BlockStorage.DeviceList[i]; } } - return NULL; + return nullptr; } // returns the next device in BlockStorageList @@ -960,7 +960,7 @@ BlockStorageDevice *BlockStorageList_GetNextDevice(BlockStorageDevice *device) } } } - return NULL; + return nullptr; } // // returns number of devices has been declared in the system diff --git a/targets/netcore/nanoFramework.nanoCLR/Target_BlockStorage_TransientFlashDriver.cpp b/targets/netcore/nanoFramework.nanoCLR/Target_BlockStorage_TransientFlashDriver.cpp index 1a83b45e91..58491c3629 100644 --- a/targets/netcore/nanoFramework.nanoCLR/Target_BlockStorage_TransientFlashDriver.cpp +++ b/targets/netcore/nanoFramework.nanoCLR/Target_BlockStorage_TransientFlashDriver.cpp @@ -7,7 +7,7 @@ #include -CLR_RT_Buffer *storage = NULL; +CLR_RT_Buffer *storage = nullptr; bool TransientFlashDriver_InitializeDevice(void *context) { @@ -52,9 +52,9 @@ bool TransientFlashDriver_Write( auto *config = (MEMORY_MAPPED_NOR_BLOCK_CONFIG *)context; auto offset = startAddress - config->Memory.BaseAddress; - + std::memcpy(&(*storage)[offset], buffer, numBytes); - + return true; } diff --git a/targets/netcore/nanoFramework.nanoCLR/nanoCLR_native.cpp b/targets/netcore/nanoFramework.nanoCLR/nanoCLR_native.cpp index f9327bcc6e..2f9e9001d9 100644 --- a/targets/netcore/nanoFramework.nanoCLR/nanoCLR_native.cpp +++ b/targets/netcore/nanoFramework.nanoCLR/nanoCLR_native.cpp @@ -44,15 +44,15 @@ #endif -DebugPrintCallback gDebugPrintCallback = NULL; +DebugPrintCallback gDebugPrintCallback = nullptr; #if defined(VIRTUAL_DEVICE) -ProfilerMessageCallback g_ProfilerMessageCallback = NULL; -ProfilerDataCallback g_ProfilerDataCallback = NULL; +ProfilerMessageCallback g_ProfilerMessageCallback = nullptr; +ProfilerDataCallback g_ProfilerDataCallback = nullptr; #endif -WireTransmitCallback WireProtocolTransmitCallback = NULL; -WireReceiveCallback WireProtocolReceiveCallback = NULL; +WireTransmitCallback WireProtocolTransmitCallback = nullptr; +WireReceiveCallback WireProtocolReceiveCallback = nullptr; // flag requesting stopping of WP processing bool _wireProtocolStopProcess; @@ -216,16 +216,16 @@ bool nanoCLR_GetNativeAssemblyInformation(const CLR_UINT8 *data, size_t size) memcpy((void *)data, &g_CLR_InteropAssembliesNativeData[i]->m_checkSum, sizeof(CLR_UINT32)); data += sizeof(CLR_UINT32); - memcpy((void *)data, &g_CLR_InteropAssembliesNativeData[i]->m_Version.iMajorVersion, sizeof(CLR_UINT16)); + memcpy((void *)data, &g_CLR_InteropAssembliesNativeData[i]->m_Version.majorVersion, sizeof(CLR_UINT16)); data += sizeof(CLR_UINT16); - memcpy((void *)data, &g_CLR_InteropAssembliesNativeData[i]->m_Version.iMinorVersion, sizeof(CLR_UINT16)); + memcpy((void *)data, &g_CLR_InteropAssembliesNativeData[i]->m_Version.minorVersion, sizeof(CLR_UINT16)); data += sizeof(CLR_UINT16); - memcpy((void *)data, &g_CLR_InteropAssembliesNativeData[i]->m_Version.iBuildNumber, sizeof(CLR_UINT16)); + memcpy((void *)data, &g_CLR_InteropAssembliesNativeData[i]->m_Version.buildNumber, sizeof(CLR_UINT16)); data += sizeof(CLR_UINT16); - memcpy((void *)data, &g_CLR_InteropAssembliesNativeData[i]->m_Version.iRevisionNumber, sizeof(CLR_UINT16)); + memcpy((void *)data, &g_CLR_InteropAssembliesNativeData[i]->m_Version.revisionNumber, sizeof(CLR_UINT16)); data += sizeof(CLR_UINT16); hal_strcpy_s((char *)data, 128, g_CLR_InteropAssembliesNativeData[i]->m_szAssemblyName); diff --git a/targets/netcore/nanoFramework.nanoCLR/platform_BlockStorage.cpp b/targets/netcore/nanoFramework.nanoCLR/platform_BlockStorage.cpp index c6061a4e91..3e01866461 100644 --- a/targets/netcore/nanoFramework.nanoCLR/platform_BlockStorage.cpp +++ b/targets/netcore/nanoFramework.nanoCLR/platform_BlockStorage.cpp @@ -16,8 +16,8 @@ IBlockStorageDevice TransientFlash_BlockStorageInterface = { &TransientFlashDriver_GetDeviceInfo, &TransientFlashDriver_Read, &TransientFlashDriver_Write, - NULL, + nullptr, &TransientFlashDriver_IsBlockErased, &TransientFlashDriver_EraseBlock, - NULL, - NULL}; + nullptr, + nullptr}; diff --git a/targets/netcore/nanoFramework.nanoCLR/target_littlefs.cpp b/targets/netcore/nanoFramework.nanoCLR/target_littlefs.cpp index 009b6ff4c8..68a4925afd 100644 --- a/targets/netcore/nanoFramework.nanoCLR/target_littlefs.cpp +++ b/targets/netcore/nanoFramework.nanoCLR/target_littlefs.cpp @@ -7,7 +7,7 @@ #include #include -CLR_RT_Buffer *storageLfs0 = NULL; +CLR_RT_Buffer *storageLfs0 = nullptr; // target specific implementation of hal_lfs_erase int32_t hal_lfs_erase_0(const struct lfs_config *c, lfs_block_t block) diff --git a/targets/win32/nanoCLR.sln b/targets/win32/nanoCLR.sln index 40686a949e..56eef710d0 100644 --- a/targets/win32/nanoCLR.sln +++ b/targets/win32/nanoCLR.sln @@ -74,6 +74,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "System.Device.Gpio", "..\.. EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "System.Runtime.Serialization", "..\..\src\System.Runtime.Serialization\System.Runtime.Serialization.vcxproj", "{C9264D0A-AC25-46B0-BD08-4A3252427F19}" EndProject +Project("{11A8DD76-328B-46DF-9F39-F559912D0360}") = "nanoFramework.System.Threading", "..\..\..\..\nanoframework\lib-nanoFramework.System.Threading\nanoFramework.System.Threading\nanoFramework.System.Threading.nfproj", "{A8146E83-014A-4570-A2F9-8B8BE68CFD7B}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "System.Device.I2c", "..\..\src\System.Device.I2c\System.Device.I2c.vcxproj", "{E9AE1AF4-6B6A-4E10-B136-7A8AFFC5B910}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "System.Device.Spi", "..\..\src\System.Device.Spi\System.Device.Spi.vcxproj", "{197C5BB5-72D2-4634-A5F8-8443DBF39985}" diff --git a/targets/win32/nanoCLR/CLRStartup.cpp b/targets/win32/nanoCLR/CLRStartup.cpp index e18910303b..da91f585f1 100644 --- a/targets/win32/nanoCLR/CLRStartup.cpp +++ b/targets/win32/nanoCLR/CLRStartup.cpp @@ -1,4 +1,4 @@ -// +// // Copyright (c) .NET Foundation and Contributors // Portions Copyright (c) Microsoft Corporation. All rights reserved. // See LICENSE file in the project root for full license information. @@ -79,14 +79,14 @@ struct Settings : CLR_RT_ParseOptions NANOCLR_CHECK_HRESULT(CLR_RT_Assembly::CreateInstance(header, assm)); // Get handlers for native functions in assembly - pNativeAssmData = GetAssemblyNativeData(assm->m_szName); + pNativeAssmData = GetAssemblyNativeData(assm->name); // If pNativeAssmData not NULL- means this assembly has native calls and there is pointer to table with native // calls. if (pNativeAssmData != NULL) { // First verify that check sum in assembly object matches hardcoded check sum. - if (assm->m_header->nativeMethodsChecksum != pNativeAssmData->m_checkSum) + if (assm->header->nativeMethodsChecksum != pNativeAssmData->m_checkSum) { CLR_Debug::Printf( "\r\n\r\n***********************************************************************\r\n"); @@ -96,8 +96,8 @@ struct Settings : CLR_RT_ParseOptions CLR_Debug::Printf("* *\r\n"); CLR_Debug::Printf( "* Invalid native checksum: %s 0x%08X!=0x%08X *\r\n", - assm->m_szName, - assm->m_header->nativeMethodsChecksum, + assm->name, + assm->header->nativeMethodsChecksum, pNativeAssmData->m_checkSum); CLR_Debug::Printf("* *\r\n"); CLR_Debug::Printf("***********************************************************************\r\n"); @@ -106,7 +106,7 @@ struct Settings : CLR_RT_ParseOptions } // Assembly has valid pointer to table with native methods. Save it. - assm->m_nativeCode = (const CLR_RT_MethodHandler *)pNativeAssmData->m_pNativeMethods; + assm->nativeCode = (const CLR_RT_MethodHandler *)pNativeAssmData->m_pNativeMethods; } g_CLR_RT_TypeSystem.Link(assm); NANOCLR_NOCLEANUP(); @@ -305,7 +305,7 @@ struct Settings : CLR_RT_ParseOptions CLR_RT_Memory::Release(assembliesBuffer); break; } - assm->m_flags |= CLR_RT_Assembly::Deployed; + assm->flags |= CLR_RT_Assembly::Deployed; } if (!isXIP) CLR_RT_Memory::Release(headerBuffer); @@ -505,7 +505,7 @@ struct Settings : CLR_RT_ParseOptions break; } - CLR_RT_UnicodeHelper::ConvertFromUTF8(assm->m_szName, strName); + CLR_RT_UnicodeHelper::ConvertFromUTF8(assm->name, strName); m_assemblies[strName] = bufferSub; assm->DestroyInstance(); @@ -533,7 +533,7 @@ struct Settings : CLR_RT_ParseOptions NANOCLR_FOREACH_ASSEMBLY(g_CLR_RT_TypeSystem) { const CLR_RECORD_ASSEMBLYREF *src = (const CLR_RECORD_ASSEMBLYREF *)pASSM->GetTable(TBL_AssemblyRef); - for (int i = 0; i < pASSM->m_pTablesSize[TBL_AssemblyRef]; i++, src++) + for (int i = 0; i < pASSM->tablesSize[TBL_AssemblyRef]; i++, src++) { const char *szName = pASSM->GetString(src->name); @@ -542,10 +542,10 @@ struct Settings : CLR_RT_ParseOptions printf( "Missing assembly: %s (%d.%d.%d.%d)\n", szName, - src->version.iMajorVersion, - src->version.iMinorVersion, - src->version.iBuildNumber, - src->version.iRevisionNumber); + src->version.majorVersion, + src->version.minorVersion, + src->version.buildNumber, + src->version.revisionNumber); fError = true; } diff --git a/targets/win32/nanoCLR/FileStore_Win32.cpp b/targets/win32/nanoCLR/FileStore_Win32.cpp index 5c3736ed91..c1464478ec 100644 --- a/targets/win32/nanoCLR/FileStore_Win32.cpp +++ b/targets/win32/nanoCLR/FileStore_Win32.cpp @@ -45,7 +45,7 @@ HRESULT CLR_RT_FileStore::SaveFile(const wchar_t *szFile, const CLR_RT_Buffer &v { NANOCLR_HEADER(); - const CLR_UINT8 *buf = NULL; + const CLR_UINT8 *buf = nullptr; size_t size = vec.size(); if (size > 0) @@ -69,7 +69,7 @@ HRESULT CLR_RT_FileStore::SaveFile(const wchar_t *szFile, const CLR_UINT8 *buf, NANOCLR_SET_AND_LEAVE(CLR_E_FAIL); } - if (buf != NULL && size != 0) + if (buf != nullptr && size != 0) { if (fwrite(buf, size, 1, stream) != 1) { @@ -113,8 +113,8 @@ void CLR_RT_FileStore::ExtractTokens( bool fNoComments) { std::wstring tmp; - char *szBufA = NULL; - wchar_t *szBufW = NULL; + char *szBufA = nullptr; + wchar_t *szBufW = nullptr; const wchar_t *src; size_t len; diff --git a/targets/win32/nanoCLR/Memory.cpp b/targets/win32/nanoCLR/Memory.cpp index a0b8f9faa1..c718ec21f1 100644 --- a/targets/win32/nanoCLR/Memory.cpp +++ b/targets/win32/nanoCLR/Memory.cpp @@ -8,7 +8,7 @@ // using namespace Microsoft::SPOT::Emulator; // From minheap.cpp -static unsigned char *s_Memory_Start = NULL; +static unsigned char *s_Memory_Start = nullptr; static unsigned int s_Memory_Length = 1024 * 1024 * 10; void HeapLocation(unsigned char *&BaseAddress, unsigned int &SizeInBytes) @@ -16,7 +16,7 @@ void HeapLocation(unsigned char *&BaseAddress, unsigned int &SizeInBytes) if (!s_Memory_Start) { s_Memory_Start = - (unsigned char *)::VirtualAlloc(NULL, s_Memory_Length, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE); + (unsigned char *)::VirtualAlloc(nullptr, s_Memory_Length, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE); if (s_Memory_Start) { @@ -31,14 +31,14 @@ void HeapLocation(unsigned char *&BaseAddress, unsigned int &SizeInBytes) SizeInBytes = s_Memory_Length; } -static unsigned char *s_CustomHeap_Start = NULL; +static unsigned char *s_CustomHeap_Start = nullptr; void CustomHeapLocation(unsigned char *&BaseAddress, unsigned int &SizeInBytes) { if (!s_CustomHeap_Start) { s_CustomHeap_Start = - (unsigned char *)::VirtualAlloc(NULL, s_Memory_Length, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE); + (unsigned char *)::VirtualAlloc(nullptr, s_Memory_Length, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE); if (s_CustomHeap_Start) { diff --git a/targets/win32/nanoCLR/PAL/ConfigHelper_stubs.cpp b/targets/win32/nanoCLR/PAL/ConfigHelper_stubs.cpp index 55c74a90d5..c9b6a77fd4 100644 --- a/targets/win32/nanoCLR/PAL/ConfigHelper_stubs.cpp +++ b/targets/win32/nanoCLR/PAL/ConfigHelper_stubs.cpp @@ -24,12 +24,12 @@ // // const HAL_CONFIG_BLOCK* HAL_CONFIG_BLOCK::Next() const //{ -// return NULL; +// return nullptr; //} // // const void* HAL_CONFIG_BLOCK::Data() const //{ -// return NULL; +// return nullptr; //} // ////--// @@ -43,7 +43,7 @@ // // const HAL_CONFIG_BLOCK* HAL_CONFIG_BLOCK::Find( const char* Name, bool fSkipCurrent, bool fAppend ) const //{ -// return NULL; +// return nullptr; //} // ////--// diff --git a/targets/win32/nanoCLR/PAL/blockstorageList_stubs.cpp b/targets/win32/nanoCLR/PAL/blockstorageList_stubs.cpp index c3d38cbbde..30d56fa278 100644 --- a/targets/win32/nanoCLR/PAL/blockstorageList_stubs.cpp +++ b/targets/win32/nanoCLR/PAL/blockstorageList_stubs.cpp @@ -9,7 +9,7 @@ // HAL_DblLinkedList BlockStorageList::s_deviceList; // BlockStorageDevice* BlockStorageList::s_primaryDevice = NULL; -static BlockStorageDevice *s_primaryDevice = NULL; +static BlockStorageDevice *s_primaryDevice = nullptr; //--// @@ -71,7 +71,7 @@ unsigned int BlockStorageList_GetNumDevices() // bool BlockStorageList::FindDeviceForPhysicalAddress( BlockStorageDevice** pBSD, unsigned int PhysicalAddress, // ByteAddress &SectAddress) //{ -// *pBSD = NULL; +// *pBSD = nullptr; // return FALSE; //} bool BlockStorageList_FindDeviceForPhysicalAddress( diff --git a/targets/win32/nanoCLR/Various.cpp b/targets/win32/nanoCLR/Various.cpp index d44b86c635..b7bdba8618 100644 --- a/targets/win32/nanoCLR/Various.cpp +++ b/targets/win32/nanoCLR/Various.cpp @@ -102,21 +102,21 @@ void NFReleaseInfo::Init( NFReleaseInfo.PlatformName[0] = 0; // fill each one, if it was provided - if (NULL != info) + if (nullptr != info) { len = MIN(infoLen, sizeof(NFReleaseInfo.InfoString) - 1); memcpy(NFReleaseInfo.InfoString, info, len); NFReleaseInfo.InfoString[len] = 0; } - if (NULL != target) + if (nullptr != target) { len = MIN(targetLen, sizeof(NFReleaseInfo.TargetName) - 1); memcpy(NFReleaseInfo.TargetName, target, len); NFReleaseInfo.TargetName[len] = 0; } - if (NULL != platform) + if (nullptr != platform) { len = MIN(platformLen, sizeof(NFReleaseInfo.PlatformName) - 1); memcpy(NFReleaseInfo.PlatformName, platform, len); @@ -126,13 +126,13 @@ void NFReleaseInfo::Init( //////////////////////////////////////////////////////////////////////////////////////////////////// -static ON_SOFT_REBOOT_HANDLER s_rebootHandlers[5] = {NULL, NULL, NULL, NULL, NULL}; +static ON_SOFT_REBOOT_HANDLER s_rebootHandlers[5] = {nullptr, nullptr, nullptr, nullptr, nullptr}; void __cdecl HAL_AddSoftRebootHandler(ON_SOFT_REBOOT_HANDLER handler) { for (int i = 0; i < ARRAYSIZE(s_rebootHandlers); i++) { - if (s_rebootHandlers[i] == NULL) + if (s_rebootHandlers[i] == nullptr) { s_rebootHandlers[i] = handler; return; @@ -169,7 +169,7 @@ void nanoHAL_Uninitialize(bool isPoweringDown) for (int i = 0; i < ARRAYSIZE(s_rebootHandlers); i++) { - if (s_rebootHandlers[i] != NULL) + if (s_rebootHandlers[i] != nullptr) { s_rebootHandlers[i](); return; diff --git a/targets/win32/nanoCLR/base64.cpp b/targets/win32/nanoCLR/base64.cpp index 1ee81ede97..25a656edea 100644 --- a/targets/win32/nanoCLR/base64.cpp +++ b/targets/win32/nanoCLR/base64.cpp @@ -163,7 +163,7 @@ __nfweak int mbedtls_base64_encode(unsigned char *dst, size_t dlen, size_t *olen n *= 4; - if ((dlen < n + 1) || (NULL == dst)) + if ((dlen < n + 1) || (nullptr == dst)) { *olen = n + 1; return MBEDTLS_ERR_BASE64_BUFFER_TOO_SMALL; @@ -291,7 +291,7 @@ __nfweak int mbedtls_base64_decode(unsigned char *dst, size_t dlen, size_t *olen n = (6 * (n >> 3)) + ((6 * (n & 0x7) + 7) >> 3); n -= equals; - if (dst == NULL || dlen < n) + if (dst == nullptr || dlen < n) { *olen = n; return MBEDTLS_ERR_BASE64_BUFFER_TOO_SMALL; diff --git a/version.json b/version.json index 3bafd3fbcd..de2a67f529 100644 --- a/version.json +++ b/version.json @@ -1,28 +1,28 @@ -{ - "$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json", - "version": "1.12.4", - "assemblyVersion": { - "precision": "revision" - }, - "semVer1NumericIdentifierPadding": 3, - "nuGetPackageVersion": { - "semVer": 2.0 - }, - "publicReleaseRefSpec": [ - "refs/head/*" - ], - "cloudBuild": { - "setAllVariables": true, - "buildNumber": { - "enabled": false, - "includeCommitId": { - "when": "always" - } - } - }, - "release": { - "branchName": "release-v{version}", - "versionIncrement": "build", - "firstUnstableTag": "preview" - } -} +{ + "$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json", + "version": "2.0.0", + "assemblyVersion": { + "precision": "revision" + }, + "semVer1NumericIdentifierPadding": 3, + "nuGetPackageVersion": { + "semVer": 2.0 + }, + "publicReleaseRefSpec": [ + "refs/head/*" + ], + "cloudBuild": { + "setAllVariables": true, + "buildNumber": { + "enabled": false, + "includeCommitId": { + "when": "always" + } + } + }, + "release": { + "branchName": "release-v{version}", + "versionIncrement": "build", + "firstUnstableTag": "preview" + } +}