+++ /dev/null
-/*\r
-* Copyright (c) 2007-2010 SlimDX Group\r
-* \r
-* Permission is hereby granted, free of charge, to any person obtaining a copy\r
-* of this software and associated documentation files (the "Software"), to deal\r
-* in the Software without restriction, including without limitation the rights\r
-* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r
-* copies of the Software, and to permit persons to whom the Software is\r
-* furnished to do so, subject to the following conditions:\r
-* \r
-* The above copyright notice and this permission notice shall be included in\r
-* all copies or substantial portions of the Software.\r
-* \r
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
-* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
-* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
-* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r
-* THE SOFTWARE.\r
-*/\r
-#include "stdafx.h"\r
-\r
-#include "ShaderMacroDC.h"\r
-\r
-using namespace System;\r
-using namespace System::Runtime::InteropServices;\r
-\r
-namespace SlimDX\r
-{\r
-namespace D3DCompiler\r
-{\r
- stack_array<D3D10_SHADER_MACRO> ShaderMacro::Marshal( array<ShaderMacro>^ macros, [Out] array<GCHandle>^% handles )\r
- {\r
- if( macros == nullptr )\r
- {\r
- handles = nullptr;\r
- return stack_array<D3D10_SHADER_MACRO>();\r
- }\r
-\r
- // this array is null terminated, so we need to patch in an extra value\r
- stack_array<D3D10_SHADER_MACRO> result( macros->Length + 1 );\r
- handles = gcnew array<GCHandle>( macros->Length * 2 );\r
-\r
- for( int i = 0; i < macros->Length; ++i )\r
- {\r
- array<Byte>^ nameBytes = System::Text::ASCIIEncoding::ASCII->GetBytes( macros[i].Name );\r
- array<Byte>^ defBytes = System::Text::ASCIIEncoding::ASCII->GetBytes( macros[i].Value );\r
-\r
- handles[2 * i] = GCHandle::Alloc( nameBytes, GCHandleType::Pinned );\r
- handles[2 * i + 1] = GCHandle::Alloc( defBytes, GCHandleType::Pinned );\r
-\r
- result[i].Name = reinterpret_cast<LPCSTR>( handles[2 * i].AddrOfPinnedObject().ToPointer() );\r
- result[i].Definition = reinterpret_cast<LPCSTR>( handles[2 * i + 1].AddrOfPinnedObject().ToPointer() );\r
- }\r
-\r
- result[macros->Length].Name = NULL;\r
- result[macros->Length].Definition = NULL;\r
-\r
- return result;\r
- }\r
-\r
- void ShaderMacro::Unmarshal( array<GCHandle>^ handles )\r
- {\r
- if( handles != nullptr )\r
- {\r
- for( int i = 0; i < handles->Length; ++i )\r
- handles[i].Free();\r
- }\r
- }\r
-\r
- ShaderMacro::ShaderMacro( String^ name )\r
- {\r
- Name = name;\r
- Value = "";\r
- }\r
-\r
- ShaderMacro::ShaderMacro( String^ name, String^ value )\r
- {\r
- Name = name;\r
- Value = value;\r
- }\r
-\r
- bool ShaderMacro::operator == ( ShaderMacro left, ShaderMacro right )\r
- {\r
- return ShaderMacro::Equals( left, right );\r
- }\r
-\r
- bool ShaderMacro::operator != ( ShaderMacro left, ShaderMacro right )\r
- {\r
- return !ShaderMacro::Equals( left, right );\r
- }\r
-\r
- int ShaderMacro::GetHashCode()\r
- {\r
- return Name->GetHashCode() + Value->GetHashCode();\r
- }\r
-\r
- bool ShaderMacro::Equals( Object^ value )\r
- {\r
- if( value == nullptr )\r
- return false;\r
-\r
- if( value->GetType() != GetType() )\r
- return false;\r
-\r
- return Equals( safe_cast<ShaderMacro>( value ) );\r
- }\r
-\r
- bool ShaderMacro::Equals( ShaderMacro value )\r
- {\r
- return ( Name == value.Name && Value == value.Value );\r
- }\r
-\r
- bool ShaderMacro::Equals( ShaderMacro% value1, ShaderMacro% value2 )\r
- {\r
- return ( value1.Name == value2.Name && value1.Value == value2.Value );\r
- }\r
-}\r
-}\r