Добавлены CElemnet::GetPosition и CVehicle::Create, в качестве примеров работы с Lua userdata и создание объектов в Mono (на примере Vector3)

This commit is contained in:
Dmitry Korolev 2014-10-12 12:22:41 +04:00
parent 4123ce833b
commit f12d496246
24 changed files with 4251 additions and 50 deletions

View File

@ -1,4 +1,5 @@
using System; using System;
using System.Collections.Generic;
using MultiTheftAuto; using MultiTheftAuto;
using MultiTheftAuto.Native; using MultiTheftAuto.Native;
@ -8,11 +9,26 @@ namespace Test
{ {
public Resource() public Resource()
{ {
Debug.Error( "{0}", new Color( 255, 128, 0 ).ToARGB().ToString( "X" ) ); var vehicles = new List<UInt32>( 10 );
Vehicle vehicle = Vehicle.Create( 562, new Vector3( 192.0f, 168.0f, 0.0f ), new Vector3( 0.0f, 0.0f, 0.0f ) ); for( int i = 0; i < vehicles.Capacity; i++ )
{
UInt32 vehicle = Vehicle.Create( 562, new Vector3( 192.0f, 168.0f, 10.0f ) * i, new Vector3( 0.0f, 0.0f, 0.0f ) );
//Debug.Log( "{0}", Element.GetPosition( vehicle ) ); if( vehicle != 0 )
{
vehicles.Add( vehicle );
}
else
{
Debug.Error( "Failed to create vehicle" );
}
}
foreach( UInt32 vehicle in vehicles )
{
Debug.Log( "{0} {1}", vehicle, Element.GetPosition( vehicle ) );
}
} }
} }
} }

View File

@ -32,6 +32,7 @@
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit> <Prefer32Bit>false</Prefer32Bit>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />

View File

@ -5,6 +5,9 @@ MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Dependencies", "Dependencies", "{AC4FC54A-60A7-4EB0-A40D-14768DD633F1}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Dependencies", "Dependencies", "{AC4FC54A-60A7-4EB0-A40D-14768DD633F1}"
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mta-mono", "mta-mono\mta-mono.vcxproj", "{5E5C7A85-A869-4D86-88FF-05DCEFC07AC3}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mta-mono", "mta-mono\mta-mono.vcxproj", "{5E5C7A85-A869-4D86-88FF-05DCEFC07AC3}"
ProjectSection(ProjectDependencies) = postProject
{E2629417-52DF-854E-B510-C15A87AB4BE3} = {E2629417-52DF-854E-B510-C15A87AB4BE3}
EndProjectSection
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lua51", "mta-mono\vendor\lua51\lua51.vcxproj", "{E2629417-52DF-854E-B510-C15A87AB4BE3}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lua51", "mta-mono\vendor\lua51\lua51.vcxproj", "{E2629417-52DF-854E-B510-C15A87AB4BE3}"
EndProject EndProject
@ -63,6 +66,7 @@ Global
{2E5D4B1E-405E-453F-BEED-25735E25ACD8}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {2E5D4B1E-405E-453F-BEED-25735E25ACD8}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{2E5D4B1E-405E-453F-BEED-25735E25ACD8}.Release|Mixed Platforms.Build.0 = Release|Any CPU {2E5D4B1E-405E-453F-BEED-25735E25ACD8}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{2E5D4B1E-405E-453F-BEED-25735E25ACD8}.Release|Win32.ActiveCfg = Release|Any CPU {2E5D4B1E-405E-453F-BEED-25735E25ACD8}.Release|Win32.ActiveCfg = Release|Any CPU
{2E5D4B1E-405E-453F-BEED-25735E25ACD8}.Release|Win32.Build.0 = Release|Any CPU
{2E5D4B1E-405E-453F-BEED-25735E25ACD8}.Release|x64.ActiveCfg = Release|Any CPU {2E5D4B1E-405E-453F-BEED-25735E25ACD8}.Release|x64.ActiveCfg = Release|Any CPU
{CBD7F8D5-39F2-4AA5-9FFF-2D3185533DDD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {CBD7F8D5-39F2-4AA5-9FFF-2D3185533DDD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CBD7F8D5-39F2-4AA5-9FFF-2D3185533DDD}.Debug|Any CPU.Build.0 = Debug|Any CPU {CBD7F8D5-39F2-4AA5-9FFF-2D3185533DDD}.Debug|Any CPU.Build.0 = Debug|Any CPU
@ -75,6 +79,7 @@ Global
{CBD7F8D5-39F2-4AA5-9FFF-2D3185533DDD}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {CBD7F8D5-39F2-4AA5-9FFF-2D3185533DDD}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{CBD7F8D5-39F2-4AA5-9FFF-2D3185533DDD}.Release|Mixed Platforms.Build.0 = Release|Any CPU {CBD7F8D5-39F2-4AA5-9FFF-2D3185533DDD}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{CBD7F8D5-39F2-4AA5-9FFF-2D3185533DDD}.Release|Win32.ActiveCfg = Release|Any CPU {CBD7F8D5-39F2-4AA5-9FFF-2D3185533DDD}.Release|Win32.ActiveCfg = Release|Any CPU
{CBD7F8D5-39F2-4AA5-9FFF-2D3185533DDD}.Release|Win32.Build.0 = Release|Any CPU
{CBD7F8D5-39F2-4AA5-9FFF-2D3185533DDD}.Release|x64.ActiveCfg = Release|Any CPU {CBD7F8D5-39F2-4AA5-9FFF-2D3185533DDD}.Release|x64.ActiveCfg = Release|Any CPU
{63CBE79D-C717-4797-860B-174FABF780A0}.Debug|Any CPU.ActiveCfg = Debug|Win32 {63CBE79D-C717-4797-860B-174FABF780A0}.Debug|Any CPU.ActiveCfg = Debug|Win32
{63CBE79D-C717-4797-860B-174FABF780A0}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 {63CBE79D-C717-4797-860B-174FABF780A0}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
@ -99,6 +104,7 @@ Global
{DC461F17-D2EC-4B7C-8CDB-AE81BEDEBD0F}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {DC461F17-D2EC-4B7C-8CDB-AE81BEDEBD0F}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{DC461F17-D2EC-4B7C-8CDB-AE81BEDEBD0F}.Release|Mixed Platforms.Build.0 = Release|Any CPU {DC461F17-D2EC-4B7C-8CDB-AE81BEDEBD0F}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{DC461F17-D2EC-4B7C-8CDB-AE81BEDEBD0F}.Release|Win32.ActiveCfg = Release|Any CPU {DC461F17-D2EC-4B7C-8CDB-AE81BEDEBD0F}.Release|Win32.ActiveCfg = Release|Any CPU
{DC461F17-D2EC-4B7C-8CDB-AE81BEDEBD0F}.Release|Win32.Build.0 = Release|Any CPU
{DC461F17-D2EC-4B7C-8CDB-AE81BEDEBD0F}.Release|x64.ActiveCfg = Release|Any CPU {DC461F17-D2EC-4B7C-8CDB-AE81BEDEBD0F}.Release|x64.ActiveCfg = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
@ -108,9 +114,9 @@ Global
{E2629417-52DF-854E-B510-C15A87AB4BE3} = {AC4FC54A-60A7-4EB0-A40D-14768DD633F1} {E2629417-52DF-854E-B510-C15A87AB4BE3} = {AC4FC54A-60A7-4EB0-A40D-14768DD633F1}
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution GlobalSection(ExtensibilityGlobals) = postSolution
AMDCaProjectFile = C:\Users\Owner\Development\monogit\mono\msvc\CodeAnalyst\mono.caw
AMDCaPersistentStartup = mono
AMDCaPersistentConfig = Debug|Win32 AMDCaPersistentConfig = Debug|Win32
AMDCaPersistentStartup = mono
AMDCaProjectFile = C:\Users\Owner\Development\monogit\mono\msvc\CodeAnalyst\mono.caw
EndGlobalSection EndGlobalSection
GlobalSection(DPCodeReviewSolutionGUID) = preSolution GlobalSection(DPCodeReviewSolutionGUID) = preSolution
DPCodeReviewSolutionGUID = {00000000-0000-0000-0000-000000000000} DPCodeReviewSolutionGUID = {00000000-0000-0000-0000-000000000000}

BIN
mta-mono/lib/eglib.lib Normal file

Binary file not shown.

View File

@ -11,6 +11,7 @@
</ProjectConfiguration> </ProjectConfiguration>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="src\CMonoClass.cpp" />
<ClCompile Include="src\CMonoFunctions.cpp" /> <ClCompile Include="src\CMonoFunctions.cpp" />
<ClCompile Include="src\CMonoObject.cpp" /> <ClCompile Include="src\CMonoObject.cpp" />
<ClCompile Include="src\CResource.cpp" /> <ClCompile Include="src\CResource.cpp" />
@ -23,6 +24,7 @@
<ClCompile Include="src\lua\CLuaFunctionDefinitions.cpp" /> <ClCompile Include="src\lua\CLuaFunctionDefinitions.cpp" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="src\CMonoClass.h" />
<ClInclude Include="src\CMonoFunctions.h" /> <ClInclude Include="src\CMonoFunctions.h" />
<ClInclude Include="src\CMonoObject.h" /> <ClInclude Include="src\CMonoObject.h" />
<ClInclude Include="src\CResource.h" /> <ClInclude Include="src\CResource.h" />
@ -38,6 +40,7 @@
<ClInclude Include="src\lua\CLuaFunctionDefinitions.h" /> <ClInclude Include="src\lua\CLuaFunctionDefinitions.h" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Library Include="lib\eglib.lib" />
<Library Include="lib\lua51.lib" /> <Library Include="lib\lua51.lib" />
<Library Include="lib\mono-2.0.lib" /> <Library Include="lib\mono-2.0.lib" />
</ItemGroup> </ItemGroup>
@ -92,7 +95,7 @@
</Midl> </Midl>
<ClCompile> <ClCompile>
<Optimization>Disabled</Optimization> <Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>.\src\include;.\vendor;.\vendor\lua51\src;.\vendor\mono;.\vendor\mysql</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>.\src\include;.\vendor;.\vendor\lua51\src;.\vendor\mono;.\vendor\mysql;.\vendor\eglib</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;_USRDLL;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;_USRDLL;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild> <MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
@ -109,7 +112,7 @@
<AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile> </ResourceCompile>
<Link> <Link>
<AdditionalDependencies>lib/lua51.lib;lib/mono.lib;%(AdditionalDependencies)</AdditionalDependencies> <AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile> <OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
<IgnoreSpecificDefaultLibraries>MSVCRT;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries> <IgnoreSpecificDefaultLibraries>MSVCRT;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
<ModuleDefinitionFile /> <ModuleDefinitionFile />
@ -129,7 +132,7 @@
<MkTypLibCompatible>false</MkTypLibCompatible> <MkTypLibCompatible>false</MkTypLibCompatible>
</Midl> </Midl>
<ClCompile> <ClCompile>
<AdditionalIncludeDirectories>.\src\include;.\vendor;.\vendor\lua51\src;.\vendor\mono;.\vendor\mysql</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>.\src\include;.\vendor;.\vendor\lua51\src;.\vendor\mono;.\vendor\mysql;.\vendor\eglib</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;_USRDLL;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;_USRDLL;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType> <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>

View File

@ -0,0 +1,83 @@
#include "CMonoClass.h"
CMonoClass::CMonoClass( MonoClass* pMonoClass )
{
this->m_pMonoClass = pMonoClass;
}
CMonoClass::~CMonoClass()
{
}
CMonoObject* CMonoClass::New( MonoDomain* pMonoDomain )
{
MonoObject* pObject = mono_object_new( pMonoDomain, this->m_pMonoClass );
if( !pObject )
{
g_pModuleManager->ErrorPrintf( "%s:%d: Failed to create mono object for %s::%s\n", this->GetNameSpace(), this->GetName(), __FILE__, __LINE__ );
return NULL;
}
mono_runtime_object_init( pObject );
return new CMonoObject( pObject );
}
CMonoObject* CMonoClass::New( MonoDomain* pMonoDomain, void** args, int argc )
{
MonoObject* pObject = mono_object_new( pMonoDomain, this->m_pMonoClass );
if( !pObject )
{
g_pModuleManager->ErrorPrintf( "%s:%d: Failed to create mono object for %s::%s\n", this->GetNameSpace(), this->GetName(), __FILE__, __LINE__ );
return NULL;
}
MonoMethod* pMonoMethod = mono_class_get_method_from_name( this->m_pMonoClass, ".ctor", argc );
if( !pMonoMethod )
{
g_pModuleManager->ErrorPrintf( "%s:%d: Could not lookup constructor for class %s::%s\n", this->GetNameSpace(), this->GetName(), __FILE__, __LINE__ );
return NULL;
}
mono_runtime_invoke( pMonoMethod, pObject, args, NULL );
return new CMonoObject( pObject );
}
const char* CMonoClass::GetName()
{
return mono_class_get_name( this->m_pMonoClass );
}
const char* CMonoClass::GetNameSpace()
{
return mono_class_get_namespace( this->m_pMonoClass );
}
MonoMethod* CMonoClass::GetMethod( const char* szMethodName, int iParamCount )
{
return mono_class_get_method_from_name( this->m_pMonoClass, szMethodName, iParamCount );
}
MonoMethod* CMonoClass::GetMethod( const char* szMethodName )
{
MonoMethodDesc* pMonoMethodDesc = mono_method_desc_new( szMethodName, false );
if( pMonoMethodDesc )
{
MonoMethod* pMethod = mono_method_desc_search_in_class( pMonoMethodDesc, this->m_pMonoClass );
mono_method_desc_free( pMonoMethodDesc );
return pMethod;
}
return NULL;
}

37
mta-mono/src/CMonoClass.h Normal file
View File

@ -0,0 +1,37 @@
class CMonoClass;
#ifndef _C_MONO_CLASS
#define _C_MONO_CLASS
#include "Common.h"
#include "CMonoObject.h"
extern ILuaModuleManager10 *g_pModuleManager;
class CMonoClass
{
private:
MonoClass* m_pMonoClass;
public:
CMonoClass( MonoClass* pMonoClass );
~CMonoClass();
CMonoObject* New( MonoDomain* pMonoDomain );
CMonoObject* New( MonoDomain* pMonoDomain, void** args, int argc );
const char* GetName();
const char* GetNameSpace();
MonoMethod* GetMethod( const char* szMethodName, int iParamCount );
MonoMethod* GetMethod( const char* szMethodName );
MonoClass* GetMonoClass() { return this->m_pMonoClass; };
MonoClass* GetClass()
{
return this->m_pMonoClass;
}
};
#endif

View File

@ -28,6 +28,7 @@ void CMonoFunctions::AddInternals( void )
mono_add_internal_call( "MultiTheftAuto.Debug::Error", CMonoFunctions::Debug::Error ); mono_add_internal_call( "MultiTheftAuto.Debug::Error", CMonoFunctions::Debug::Error );
mono_add_internal_call( "MultiTheftAuto.Native.Config::Get", CMonoFunctions::Config::Get ); mono_add_internal_call( "MultiTheftAuto.Native.Config::Get", CMonoFunctions::Config::Get );
mono_add_internal_call( "MultiTheftAuto.Native.Config::Set", CMonoFunctions::Config::Set ); mono_add_internal_call( "MultiTheftAuto.Native.Config::Set", CMonoFunctions::Config::Set );
mono_add_internal_call( "MultiTheftAuto.Native.Element::GetPosition", CMonoFunctions::Element::GetPosition );
mono_add_internal_call( "MultiTheftAuto.Native.Vehicle::Create", CMonoFunctions::Vehicle::Create ); mono_add_internal_call( "MultiTheftAuto.Native.Vehicle::Create", CMonoFunctions::Vehicle::Create );
} }
@ -83,7 +84,45 @@ bool CMonoFunctions::Config::Set( MonoString *msKey, MonoString *msValue )
return false; return false;
} }
MonoObject* CMonoFunctions::Vehicle::Create( int model, MonoObject* position, MonoObject* rotation, string &numberplate, bool direction, int variant1, int variant2 ) MonoObject* CMonoFunctions::Element::GetPosition( unsigned int element )
{
if( RESOURCE )
{
float
fX = 0.0f,
fY = 0.0f,
fZ = 0.0f;
if( CLuaFunctionDefinitions::GetPosition( RESOURCE->GetLua(), (void*)element, fX, fY, fZ ) )
{
CMonoClass* pClass = RESOURCE->GetClassFromName( "MultiTheftAuto", "Vector3" );
if( pClass )
{
void *args[] = { &fX, &fY, &fZ };
CMonoObject* pObject = pClass->New( mono_domain_get(), args, 3 );
if( pObject )
{
return pObject->GetObject();
}
else
{
g_pModuleManager->ErrorPrintf( "%s:%d: failed to create instance of 'MultiTheftAuto::Vector3'\n", __FILE__, __LINE__ );
}
}
else
{
g_pModuleManager->ErrorPrintf( "%s:%d: class 'MultiTheftAuto::Vector3' not found\n", __FILE__, __LINE__ );
}
}
}
return NULL;
}
unsigned int CMonoFunctions::Vehicle::Create( int model, MonoObject* position, MonoObject* rotation, MonoString* numberplate, bool direction, int variant1, int variant2 )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
@ -99,11 +138,19 @@ MonoObject* CMonoFunctions::Vehicle::Create( int model, MonoObject* position, Mo
float fRY = pRotation.GetPropertyValue<float>( "Y" ); float fRY = pRotation.GetPropertyValue<float>( "Y" );
float fRZ = pRotation.GetPropertyValue<float>( "Z" ); float fRZ = pRotation.GetPropertyValue<float>( "Z" );
void* pVehicle = CLuaFunctionDefinitions::CreateVehicle( RESOURCE->GetLua(), model, fX, fY, fZ, fRX, fRY, fRZ, numberplate, direction, variant1, variant2 ); string sNumberplate = "";
if( numberplate && mono_string_length( numberplate ) > 0 )
{
sNumberplate = mono_string_to_utf8( numberplate );
}
void* pVehicle = CLuaFunctionDefinitions::CreateVehicle( RESOURCE->GetLua(), model, fX, fY, fZ, fRX, fRY, fRZ, sNumberplate, direction, variant1, variant2 );
if( pVehicle ) if( pVehicle )
{ {
return (unsigned int)pVehicle;
//return 0x1337;
} }
} }

View File

@ -38,10 +38,16 @@ public:
static bool Set ( MonoString *msKey, MonoString *msValue ); static bool Set ( MonoString *msKey, MonoString *msValue );
}; };
class Element
{
public:
static MonoObject* GetPosition ( unsigned int element );
};
class Vehicle class Vehicle
{ {
public: public:
static MonoObject* Create ( int model, MonoObject* position, MonoObject* rotation, string &numberplate, bool direction = false, int variant1 = 255, int variant2 = 255 ); static unsigned int Create ( int model, MonoObject* position, MonoObject* rotation, MonoString* numberplate, bool direction = false, int variant1 = 255, int variant2 = 255 );
}; };
}; };

View File

@ -1,6 +1,5 @@
#include "CMonoObject.h" #include "CMonoObject.h"
CMonoObject::CMonoObject( MonoObject* pMonoObject ) CMonoObject::CMonoObject( MonoObject* pMonoObject )
{ {
this->m_pMonoObject = pMonoObject; this->m_pMonoObject = pMonoObject;
@ -11,9 +10,16 @@ CMonoObject::~CMonoObject()
{ {
} }
MonoClass* CMonoObject::GetClass() CMonoClass* CMonoObject::GetClass()
{ {
return mono_object_get_class( this->m_pMonoObject ); MonoClass* pMonoClass = mono_object_get_class( this->m_pMonoObject );
if( pMonoClass )
{
return new CMonoClass( pMonoClass );
}
return NULL;
} }
MonoObject* CMonoObject::GetPropertyValue( const char* szPropertyName ) MonoObject* CMonoObject::GetPropertyValue( const char* szPropertyName )
@ -29,3 +35,36 @@ MonoObject* CMonoObject::GetPropertyValue( const char* szPropertyName )
return mono_property_get_value( pMonoProperty, this->m_pMonoObject, NULL, NULL ); return mono_property_get_value( pMonoProperty, this->m_pMonoObject, NULL, NULL );
} }
bool CMonoObject::SetPropertyValue( const char* szPropertyName, int iValue )
{
return this->SetPropertyValue( szPropertyName, (void*)&iValue );
}
bool CMonoObject::SetPropertyValue( const char* szPropertyName, float fValue )
{
return this->SetPropertyValue( szPropertyName, (void*)&fValue );
}
bool CMonoObject::SetPropertyValue( const char* szPropertyName, char* szValue )
{
return this->SetPropertyValue( szPropertyName, mono_string_new( mono_domain_get(), szValue ) );
}
bool CMonoObject::SetPropertyValue( const char* szPropertyName, gpointer gValue )
{
MonoClass* pMonoClass = mono_object_get_class( this->m_pMonoObject );
MonoProperty* pMonoProperty = mono_class_get_property_from_name( pMonoClass, szPropertyName );
if( !pMonoProperty )
{
return false;
}
gpointer args[ 1 ] = { gValue };
mono_property_set_value( pMonoProperty, this->m_pMonoObject, args, NULL );
return true;
}

View File

@ -4,6 +4,7 @@ class CMonoObject;
#define _C_MONO_OBJECT #define _C_MONO_OBJECT
#include "Common.h" #include "Common.h"
#include "CMonoClass.h"
class CMonoObject class CMonoObject
{ {
@ -14,7 +15,12 @@ public:
CMonoObject( MonoObject* pMonoObject ); CMonoObject( MonoObject* pMonoObject );
~CMonoObject(); ~CMonoObject();
MonoClass* GetClass(); CMonoClass* GetClass();
bool SetPropertyValue( const char* szPropertyName, int iValue );
bool SetPropertyValue( const char* szPropertyName, float fValue );
bool SetPropertyValue( const char* szPropertyName, char* szValue );
bool SetPropertyValue( const char* szPropertyName, gpointer gValue );
MonoObject* GetPropertyValue( const char* szPropertyName ); MonoObject* GetPropertyValue( const char* szPropertyName );
@ -22,6 +28,21 @@ public:
{ {
return *( reinterpret_cast<T*>( mono_object_unbox( this->GetPropertyValue( szPropertyName ) ) ) ); return *( reinterpret_cast<T*>( mono_object_unbox( this->GetPropertyValue( szPropertyName ) ) ) );
} }
void* GetValue()
{
return mono_object_unbox( this->m_pMonoObject );
}
template <class T> T GetValue()
{
return *( reinterpret_cast<T*>( mono_object_unbox( this->m_pMonoObject ) ) );
}
MonoObject *GetObject()
{
return this->m_pMonoObject;
}
}; };
#endif #endif

View File

@ -24,9 +24,11 @@ CResource::CResource( lua_State *pLuaVM, string sName )
this->m_sName = sName; this->m_sName = sName;
this->m_pMonoAssembly = NULL; this->m_pMonoAssembly = NULL;
this->m_pMonoAssemblyLib = NULL;
this->m_pMonoGCHandle = NULL; this->m_pMonoGCHandle = NULL;
this->m_pMonoDomain = NULL; this->m_pMonoDomain = NULL;
this->m_pMonoImage = NULL; this->m_pMonoImage = NULL;
this->m_pMonoImageLib = NULL;
this->m_pMonoClass = NULL; this->m_pMonoClass = NULL;
} }
@ -49,7 +51,8 @@ bool CResource::Init( void )
{ {
if( this->m_pLuaVM ) if( this->m_pLuaVM )
{ {
string sPath ( "mods/deathmatch/mono/resources/" + this->m_sName + ".dll" ); string sDirectory ( "mods/deathmatch/mono/resources/" );
string sPath ( sDirectory + this->m_sName + ".dll" );
string sNamespace ( this->m_sName ); string sNamespace ( this->m_sName );
string sClass ( "Resource" ); string sClass ( "Resource" );
@ -64,6 +67,13 @@ bool CResource::Init( void )
mono_domain_set( this->m_pMonoDomain, false ); mono_domain_set( this->m_pMonoDomain, false );
this->m_pMonoAssemblyLib = mono_domain_assembly_open( this->m_pMonoDomain, ( sDirectory + "MultiTheftAuto.dll" ).c_str() );
if( this->m_pMonoAssemblyLib )
{
this->m_pMonoImageLib = mono_assembly_get_image( this->m_pMonoAssemblyLib );
}
this->m_pMonoAssembly = mono_domain_assembly_open( this->m_pMonoDomain, sPath.c_str() ); this->m_pMonoAssembly = mono_domain_assembly_open( this->m_pMonoDomain, sPath.c_str() );
if( !this->m_pMonoAssembly ) if( !this->m_pMonoAssembly )
@ -88,16 +98,6 @@ bool CResource::Init( void )
return false; return false;
} }
string CResource::GetName( void )
{
return this->m_sName;
}
lua_State *CResource::GetLua( void )
{
return this->m_pLuaVM;
}
void CResource::OnStopping( void ) void CResource::OnStopping( void )
{ {
} }
@ -117,3 +117,20 @@ bool CResource::RegisterFunction( const char *szFunctionName, lua_CFunction Func
return true; return true;
} }
CMonoClass* CResource::GetClassFromName( const char* szNamespace, const char* szName )
{
MonoClass* pMonoClass = mono_class_from_name( this->m_pMonoImage, szNamespace, szName );
if( !pMonoClass )
{
pMonoClass = mono_class_from_name( this->m_pMonoImageLib, szNamespace, szName );
}
if( pMonoClass )
{
return new CMonoClass( pMonoClass );
}
return NULL;
}

View File

@ -16,6 +16,7 @@ class CResource;
#define __CRESOURCE_H #define __CRESOURCE_H
#include "Common.h" #include "Common.h"
#include "CMonoClass.h"
class CResource class CResource
{ {
@ -23,7 +24,9 @@ private:
string m_sName; string m_sName;
MonoAssembly *m_pMonoAssembly; MonoAssembly *m_pMonoAssembly;
MonoAssembly *m_pMonoAssemblyLib;
MonoImage *m_pMonoImage; MonoImage *m_pMonoImage;
MonoImage *m_pMonoImageLib;
MonoClass *m_pMonoClass; MonoClass *m_pMonoClass;
uint32_t m_pMonoGCHandle; uint32_t m_pMonoGCHandle;
@ -39,10 +42,10 @@ public:
void DoPulse ( void ); void DoPulse ( void );
bool RegisterFunction ( const char *szFunctionName, lua_CFunction Func ); bool RegisterFunction ( const char *szFunctionName, lua_CFunction Func );
string GetName ( void ); CMonoClass* GetClassFromName( const char* szNamespace, const char* szName );
lua_State *GetLua ( void );
const void Test( void ); string GetName ( void ) { return this->m_sName; }
lua_State *GetLua ( void ) { return this->m_pLuaVM; }
}; };
#endif #endif

View File

@ -35,6 +35,8 @@ extern "C"
#include <sys/stat.h> #include <sys/stat.h>
#include <assert.h> #include <assert.h>
#include <glib.h>
#include <mono/jit/jit.h> #include <mono/jit/jit.h>
#include <mono/metadata/assembly.h> #include <mono/metadata/assembly.h>
#include <mono/metadata/mono-debug.h> #include <mono/metadata/mono-debug.h>

View File

@ -162,7 +162,25 @@ bool CLuaFunctionDefinitions::SetRuleValue( lua_State *pLuaVM, const string &sKe
return false; return false;
} }
void* CLuaFunctionDefinitions::CreateVehicle( lua_State* pLuaVM, int model, float fX, float fY, float fZ, float fRX, float fRY, float fRZ, string &numberplate, bool direction, int variant1, int variant2 ) bool CLuaFunctionDefinitions::GetPosition( lua_State* pLuaVM, void* pUserData, float &fX, float &fY, float &fZ )
{
CLuaArguments pLuaArguments;
pLuaArguments.PushUserData( pUserData );
if( pLuaArguments.Call( pLuaVM, "getElementPosition", 3 ) )
{
fX = static_cast< float >( ( new CLuaArgument( pLuaVM, -3 ) )->GetNumber() );
fY = static_cast< float >( ( new CLuaArgument( pLuaVM, -2 ) )->GetNumber() );
fZ = static_cast< float >( ( new CLuaArgument( pLuaVM, -1 ) )->GetNumber() );
return true;
}
return false;
}
void* CLuaFunctionDefinitions::CreateVehicle( lua_State* pLuaVM, int model, float fX, float fY, float fZ, float fRX, float fRY, float fRZ, string numberplate, bool direction, int variant1, int variant2 )
{ {
CLuaArguments pLuaArguments; CLuaArguments pLuaArguments;
@ -173,10 +191,14 @@ void* CLuaFunctionDefinitions::CreateVehicle( lua_State* pLuaVM, int model, floa
pLuaArguments.PushNumber( fRX ); pLuaArguments.PushNumber( fRX );
pLuaArguments.PushNumber( fRY ); pLuaArguments.PushNumber( fRY );
pLuaArguments.PushNumber( fRZ ); pLuaArguments.PushNumber( fRZ );
if( numberplate.length() > 0 )
{
pLuaArguments.PushString( numberplate.c_str() ); pLuaArguments.PushString( numberplate.c_str() );
pLuaArguments.PushBoolean( direction ); pLuaArguments.PushBoolean( direction );
pLuaArguments.PushNumber( variant1 ); pLuaArguments.PushNumber( variant1 );
pLuaArguments.PushNumber( variant2 ); pLuaArguments.PushNumber( variant2 );
}
if( pLuaArguments.Call( pLuaVM, "createVehicle", 1 ) ) if( pLuaArguments.Call( pLuaVM, "createVehicle", 1 ) )
{ {

View File

@ -31,7 +31,9 @@ public:
static bool SetMapName ( lua_State* pLuaVM, const string &sName ); static bool SetMapName ( lua_State* pLuaVM, const string &sName );
static bool SetRuleValue ( lua_State* pLuaVM, const string &sKey, const string &sValue ); static bool SetRuleValue ( lua_State* pLuaVM, const string &sKey, const string &sValue );
static void* CreateVehicle ( lua_State* luaVM, int model, float fX, float fY, float fZ, float fRX, float fRY, float fRZ, string &numberplate, bool direction = false, int variant1 = 255, int variant2 = 255 ); static bool GetPosition ( lua_State* pLuaVM, void* pUserData, float &fX, float &fY, float &fZ );
static void* CreateVehicle ( lua_State* luaVM, int model, float fX, float fY, float fZ, float fRX, float fRY, float fRZ, string numberplate, bool direction = false, int variant1 = 255, int variant2 = 255 );
/* /*
static int CallRemote ( lua_State* luaVM ); static int CallRemote ( lua_State* luaVM );
static int FetchRemote ( lua_State* luaVM ); static int FetchRemote ( lua_State* luaVM );

46
mta-mono/vendor/eglib/eglib-config.h.in vendored Normal file
View File

@ -0,0 +1,46 @@
#ifndef __EGLIB_CONFIG_H
#define __EGLIB_CONFIG_H
/*
* System-dependent settings
*/
#define G_GNUC_PRETTY_FUNCTION @GNUC_PRETTY@
#define G_GNUC_UNUSED @GNUC_UNUSED@
#define G_BYTE_ORDER @ORDER@
#define G_GNUC_NORETURN @GNUC_NORETURN@
#define G_SEARCHPATH_SEPARATOR_S "@SEARCHSEP@"
#define G_SEARCHPATH_SEPARATOR '@SEARCHSEP@'
#define G_DIR_SEPARATOR '@PATHSEP@'
#define G_DIR_SEPARATOR_S "@PATHSEP@"
#define G_BREAKPOINT() @BREAKPOINT@
#define G_OS_@OS@
#define GPOINTER_TO_INT(ptr) @GPOINTER_TO_INT@
#define GPOINTER_TO_UINT(ptr) @GPOINTER_TO_UINT@
#define GINT_TO_POINTER(v) @GINT_TO_POINTER@
#define GUINT_TO_POINTER(v) @GUINT_TO_POINTER@
#if @HAVE_ALLOCA_H@ == 1
#define G_HAVE_ALLOCA_H
#endif
typedef unsigned @GSIZE@ gsize;
typedef signed @GSIZE@ gssize;
#define G_GSIZE_FORMAT @GSIZE_FORMAT@
#define G_GUINT64_FORMAT @G_GUINT64_FORMAT@
#define G_GINT64_FORMAT @G_GINT64_FORMAT@
#define G_GUINT32_FORMAT @G_GUINT32_FORMAT@
#define G_GINT32_FORMAT @G_GINT32_FORMAT@
#if @G_HAVE_ISO_VARARGS@ == 1
#define G_HAVE_ISO_VARARGS
#endif
#if defined (__native_client__)
#undef G_BREAKPOINT
#define G_BREAKPOINT()
#endif
typedef @PIDTYPE@ GPid;
#endif

76
mta-mono/vendor/eglib/eglib-config.hw vendored Normal file
View File

@ -0,0 +1,76 @@
#ifndef __EGLIB_CONFIG_H
#define __EGLIB_CONFIG_H
/*
* System-dependent settings
*/
#define G_OS_WIN32 1
#ifdef _MSC_VER
#include <io.h>
#define G_GNUC_PRETTY_FUNCTION __FUNCTION__
#define G_GNUC_UNUSED
#define G_BYTE_ORDER 1234
#define G_GNUC_NORETURN
#define G_BREAKPOINT() __debugbreak()
#define MAXPATHLEN 242
typedef uintptr_t gsize;
typedef intptr_t gssize;
typedef int pid_t;
#define G_DIR_SEPARATOR '\\'
#define G_DIR_SEPARATOR_S "\\"
#define G_SEARCHPATH_SEPARATOR_S ";"
#define G_SEARCHPATH_SEPARATOR ';'
#define G_GSIZE_FORMAT "d"
#define G_GUINT64_FORMAT "d"
#define G_GINT64_FORMAT "d"
#define GPOINTER_TO_INT(ptr) ((gint)(intptr_t) (ptr))
#define GPOINTER_TO_UINT(ptr) ((guint)(intptr_t) (ptr))
#define GINT_TO_POINTER(v) ((gpointer)(intptr_t) (v))
#define GUINT_TO_POINTER(v) ((gpointer)(intptr_t) (v))
/* VS 2010 and later have stdint.h */
#if defined(_MSC_VER) && _MSC_VER < 1600
#define INT32_MAX 2147483647
#define INT32_MIN (~ INT32_MAX)
#define INT64_MAX 9223372036854775807i64
#define INT64_MIN (~INT64_MAX)
#define UINT32_MAX 0xffffffffU
#define UINT64_MAX 0xffffffffffffffffULL
#endif
#define STDOUT_FILENO (int)(intptr_t)stdout
#define STDERR_FILENO (int)(intptr_t)stderr
/* FIXME: what should this be ?*/
#define X_OK 4 /* This is really read */
#define WNOHANG 1
#define F_SETFD 1
#define FD_CLOEXEC 1
#undef inline
#define inline __inline
#define strtok_r strtok_s
#undef G_HAVE_UNISTD_H
#undef G_HAVE_SYS_TIME_H
#undef G_HAVE_SYS_WAIT_H
#undef G_HAVE_PWD_H
#undef G_HAVE_STRNDUP
#define G_HAVE_GETOPT_H 1
/* disable the following warnings
* C4100: The formal parameter is not referenced in the body of the function. The unreferenced parameter is ignored.
* C4127: conditional expression is constant
*/
#pragma warning(disable:4100 4127)
#endif
typedef void * GPid;
#endif

281
mta-mono/vendor/eglib/eglib-remap.h vendored Normal file
View File

@ -0,0 +1,281 @@
#define g_array_append monoeg_g_array_append
#define g_array_append_vals monoeg_g_array_append_vals
#define g_array_free monoeg_g_array_free
#define g_array_insert_vals monoeg_g_array_insert_vals
#define g_array_new monoeg_g_array_new
#define g_array_remove_index monoeg_g_array_remove_index
#define g_array_remove_index_fast monoeg_g_array_remove_index_fast
#define g_array_set_size monoeg_g_array_set_size
#define g_array_sized_new monoeg_g_array_sized_new
#define g_ascii_strdown monoeg_g_ascii_strdown
#define g_ascii_strncasecmp monoeg_g_ascii_strncasecmp
#define g_ascii_tolower monoeg_g_ascii_tolower
#define g_ascii_xdigit_value monoeg_g_ascii_xdigit_value
#define g_build_path monoeg_g_build_path
#define g_byte_array_append monoeg_g_byte_array_append
#define g_byte_array_free monoeg_g_byte_array_free
#define g_byte_array_new monoeg_g_byte_array_new
#define g_clear_error monoeg_g_clear_error
#define g_convert monoeg_g_convert
#define g_convert_error_quark monoeg_g_convert_error_quark
#define g_dir_close monoeg_g_dir_close
#define g_dir_open monoeg_g_dir_open
#define g_dir_read_name monoeg_g_dir_read_name
#define g_dir_rewind monoeg_g_dir_rewind
#define g_mkdir_with_parents monoeg_g_mkdir_with_parents
#define g_direct_equal monoeg_g_direct_equal
#define g_direct_hash monoeg_g_direct_hash
#define g_error_free monoeg_g_error_free
#define g_error_new monoeg_g_error_new
#define g_error_vnew monoeg_g_error_vnew
#define g_file_error_quark monoeg_g_file_error_quark
#define g_file_error_from_errno monoeg_g_file_error_from_errno
#define g_file_get_contents monoeg_g_file_get_contents
#define g_file_set_contents monoeg_g_file_set_contents
#define g_file_open_tmp monoeg_g_file_open_tmp
#define g_file_test monoeg_g_file_test
#define g_filename_from_uri monoeg_g_filename_from_uri
#define g_filename_from_utf8 monoeg_g_filename_from_utf8
#define g_filename_to_uri monoeg_g_filename_to_uri
#define g_find_program_in_path monoeg_g_find_program_in_path
#define g_fprintf monoeg_g_fprintf
#define g_free monoeg_g_free
#define g_get_charset monoeg_g_get_charset
#define g_get_current_dir monoeg_g_get_current_dir
#define g_get_current_time monoeg_g_get_current_time
#define g_get_home_dir monoeg_g_get_home_dir
#define g_get_prgname monoeg_g_get_prgname
#define g_get_tmp_dir monoeg_g_get_tmp_dir
#define g_get_user_name monoeg_g_get_user_name
#define g_getenv monoeg_g_getenv
#define g_hash_table_destroy monoeg_g_hash_table_destroy
#define g_hash_table_find monoeg_g_hash_table_find
#define g_hash_table_foreach monoeg_g_hash_table_foreach
#define g_hash_table_foreach_remove monoeg_g_hash_table_foreach_remove
#define g_hash_table_foreach_steal monoeg_g_hash_table_foreach_steal
#define g_hash_table_get_keys monoeg_g_hash_table_get_keys
#define g_hash_table_get_values monoeg_g_hash_table_get_values
#define g_hash_table_insert_replace monoeg_g_hash_table_insert_replace
#define g_hash_table_lookup monoeg_g_hash_table_lookup
#define g_hash_table_lookup_extended monoeg_g_hash_table_lookup_extended
#define g_hash_table_new monoeg_g_hash_table_new
#define g_hash_table_new_full monoeg_g_hash_table_new_full
#define g_hash_table_remove monoeg_g_hash_table_remove
#define g_hash_table_steal monoeg_g_hash_table_steal
#define g_hash_table_size monoeg_g_hash_table_size
#define g_hash_table_print_stats monoeg_g_hash_table_print_stats
#define g_hash_table_remove_all monoeg_g_hash_table_remove_all
#define g_hash_table_iter_init monoeg_g_hash_table_iter_init
#define g_hash_table_iter_next monoeg_g_hash_table_iter_next
#define g_iconv monoeg_g_iconv
#define g_iconv_close monoeg_g_iconv_close
#define g_iconv_open monoeg_g_iconv_open
#define g_int_equal monoeg_g_int_equal
#define g_int_hash monoeg_g_int_hash
#define g_list_alloc monoeg_g_list_alloc
#define g_list_append monoeg_g_list_append
#define g_list_concat monoeg_g_list_concat
#define g_list_copy monoeg_g_list_copy
#define g_list_delete_link monoeg_g_list_delete_link
#define g_list_find monoeg_g_list_find
#define g_list_find_custom monoeg_g_list_find_custom
#define g_list_first monoeg_g_list_first
#define g_list_foreach monoeg_g_list_foreach
#define g_list_free monoeg_g_list_free
#define g_list_free_1 monoeg_g_list_free_1
#define g_list_index monoeg_g_list_index
#define g_list_insert_before monoeg_g_list_insert_before
#define g_list_insert_sorted monoeg_g_list_insert_sorted
#define g_list_last monoeg_g_list_last
#define g_list_length monoeg_g_list_length
#define g_list_nth monoeg_g_list_nth
#define g_list_nth_data monoeg_g_list_nth_data
#define g_list_prepend monoeg_g_list_prepend
#define g_list_remove monoeg_g_list_remove
#define g_list_remove_all monoeg_g_list_remove_all
#define g_list_remove_link monoeg_g_list_remove_link
#define g_list_reverse monoeg_g_list_reverse
#define g_list_sort monoeg_g_list_sort
#define g_locale_from_utf8 monoeg_g_locale_from_utf8
#define g_locale_to_utf8 monoeg_g_locale_to_utf8
#define g_log monoeg_g_log
#define g_log_set_always_fatal monoeg_g_log_set_always_fatal
#define g_log_set_fatal_mask monoeg_g_log_set_fatal_mask
#define g_logv monoeg_g_logv
#define g_markup_parse_context_end_parse monoeg_g_markup_parse_context_end_parse
#define g_markup_parse_context_free monoeg_g_markup_parse_context_free
#define g_markup_parse_context_new monoeg_g_markup_parse_context_new
#define g_markup_parse_context_parse monoeg_g_markup_parse_context_parse
#define g_memdup monoeg_g_memdup
#define g_module_build_path monoeg_g_module_build_path
#define g_module_close monoeg_g_module_close
#define g_module_error monoeg_g_module_error
#define g_module_open monoeg_g_module_open
#define g_module_symbol monoeg_g_module_symbol
#define g_path_get_basename monoeg_g_path_get_basename
#define g_path_get_dirname monoeg_g_path_get_dirname
#define g_path_is_absolute monoeg_g_path_is_absolute
#define g_pattern_match_string monoeg_g_pattern_match_string
#define g_pattern_spec_free monoeg_g_pattern_spec_free
#define g_pattern_spec_new monoeg_g_pattern_spec_new
#define g_print monoeg_g_print
#define g_printf monoeg_g_printf
#define g_printerr monoeg_g_printerr
#define g_propagate_error monoeg_g_propagate_error
#define g_ptr_array_add monoeg_g_ptr_array_add
#define g_ptr_array_foreach monoeg_g_ptr_array_foreach
#define g_ptr_array_free monoeg_g_ptr_array_free
#define g_ptr_array_new monoeg_g_ptr_array_new
#define g_ptr_array_remove monoeg_g_ptr_array_remove
#define g_ptr_array_remove_fast monoeg_g_ptr_array_remove_fast
#define g_ptr_array_remove_index monoeg_g_ptr_array_remove_index
#define g_ptr_array_remove_index_fast monoeg_g_ptr_array_remove_index_fast
#define g_ptr_array_set_size monoeg_g_ptr_array_set_size
#define g_ptr_array_sized_new monoeg_g_ptr_array_sized_new
#define g_ptr_array_sort monoeg_g_ptr_array_sort
#define g_ptr_array_sort_with_data monoeg_g_ptr_array_sort_with_data
#define g_qsort_with_data monoeg_g_qsort_with_data
#define g_queue_free monoeg_g_queue_free
#define g_queue_is_empty monoeg_g_queue_is_empty
#define g_queue_foreach monoeg_g_queue_foreach
#define g_queue_new monoeg_g_queue_new
#define g_queue_pop_head monoeg_g_queue_pop_head
#define g_queue_push_head monoeg_g_queue_push_head
#define g_queue_push_tail monoeg_g_queue_push_tail
#define g_set_error monoeg_g_set_error
#define g_set_prgname monoeg_g_set_prgname
#define g_setenv monoeg_g_setenv
#define g_shell_parse_argv monoeg_g_shell_parse_argv
#define g_shell_quote monoeg_g_shell_quote
#define g_shell_unquote monoeg_g_shell_unquote
#define g_slist_alloc monoeg_g_slist_alloc
#define g_slist_append monoeg_g_slist_append
#define g_slist_concat monoeg_g_slist_concat
#define g_slist_copy monoeg_g_slist_copy
#define g_slist_delete_link monoeg_g_slist_delete_link
#define g_slist_find monoeg_g_slist_find
#define g_slist_find_custom monoeg_g_slist_find_custom
#define g_slist_foreach monoeg_g_slist_foreach
#define g_slist_free monoeg_g_slist_free
#define g_slist_free_1 monoeg_g_slist_free_1
#define g_slist_index monoeg_g_slist_index
#define g_slist_insert_before monoeg_g_slist_insert_before
#define g_slist_insert_sorted monoeg_g_slist_insert_sorted
#define g_slist_last monoeg_g_slist_last
#define g_slist_length monoeg_g_slist_length
#define g_slist_nth monoeg_g_slist_nth
#define g_slist_nth_data monoeg_g_slist_nth_data
#define g_slist_prepend monoeg_g_slist_prepend
#define g_slist_remove monoeg_g_slist_remove
#define g_slist_remove_all monoeg_g_slist_remove_all
#define g_slist_remove_link monoeg_g_slist_remove_link
#define g_slist_reverse monoeg_g_slist_reverse
#define g_slist_sort monoeg_g_slist_sort
#define g_snprintf monoeg_g_snprintf
#define g_spaced_primes_closest monoeg_g_spaced_primes_closest
#define g_spawn_async_with_pipes monoeg_g_spawn_async_with_pipes
#define g_spawn_command_line_sync monoeg_g_spawn_command_line_sync
#define g_sprintf monoeg_g_sprintf
#define g_stpcpy monoeg_g_stpcpy
#define g_str_equal monoeg_g_str_equal
#define g_str_has_prefix monoeg_g_str_has_prefix
#define g_str_has_suffix monoeg_g_str_has_suffix
#define g_str_hash monoeg_g_str_hash
#define g_strchomp monoeg_g_strchomp
#define g_strchug monoeg_g_strchug
#define g_strconcat monoeg_g_strconcat
#define g_strdelimit monoeg_g_strdelimit
#define g_strdown monoeg_g_strdown
#define g_strdup_printf monoeg_g_strdup_printf
#define g_strdup_vprintf monoeg_g_strdup_vprintf
#define g_strerror monoeg_g_strerror
#define g_strescape monoeg_g_strescape
#define g_strfreev monoeg_g_strfreev
#define g_strdupv monoeg_g_strdupv
#define g_string_append monoeg_g_string_append
#define g_string_append_c monoeg_g_string_append_c
#define g_string_append_len monoeg_g_string_append_len
#define g_string_append_unichar monoeg_g_string_append_unichar
#define g_string_append_printf monoeg_g_string_append_printf
#define g_string_append_vprintf monoeg_g_string_append_vprintf
#define g_string_erase monoeg_g_string_erase
#define g_string_free monoeg_g_string_free
#define g_string_insert monoeg_g_string_insert
#define g_string_new monoeg_g_string_new
#define g_string_new_len monoeg_g_string_new_len
#define g_string_prepend monoeg_g_string_prepend
#define g_string_printf monoeg_g_string_printf
#define g_string_set_size monoeg_g_string_set_size
#define g_string_sized_new monoeg_g_string_sized_new
#define g_string_truncate monoeg_g_string_truncate
#define g_strjoin monoeg_g_strjoin
#define g_strjoinv monoeg_g_strjoinv
#define g_strlcpy monoeg_g_strlcpy
#define g_strndup monoeg_g_strndup
#define g_strnfill monoeg_g_strnfill
#define g_strreverse monoeg_g_strreverse
#define g_strsplit monoeg_g_strsplit
#define g_strsplit_set monoeg_g_strsplit_set
#define g_strv_length monoeg_g_strv_length
#define g_timer_destroy monoeg_g_timer_destroy
#define g_timer_elapsed monoeg_g_timer_elapsed
#define g_timer_new monoeg_g_timer_new
#define g_timer_start monoeg_g_timer_start
#define g_timer_stop monoeg_g_timer_stop
#define g_trailingBytesForUTF8 monoeg_g_trailingBytesForUTF8
#define g_ucs4_to_utf8 monoeg_g_ucs4_to_utf8
#define g_ucs4_to_utf16 monoeg_g_ucs4_to_utf16
#define g_unichar_case monoeg_g_unichar_case
#define g_unichar_isxdigit monoeg_g_unichar_isxdigit
#define g_unichar_tolower monoeg_g_unichar_tolower
#define g_unichar_totitle monoeg_g_unichar_totitle
#define g_unichar_toupper monoeg_g_unichar_toupper
#define g_unichar_type monoeg_g_unichar_type
#define g_unichar_xdigit_value monoeg_g_unichar_xdigit_value
#define g_unsetenv monoeg_g_unsetenv
#define g_usleep monoeg_g_usleep
#define g_utf16_to_ucs4 monoeg_g_utf16_to_ucs4
#define g_utf16_to_utf8 monoeg_g_utf16_to_utf8
#define g_utf8_get_char monoeg_g_utf8_get_char
#define g_utf8_offset_to_pointer monoeg_g_utf8_offset_to_pointer
#define g_utf8_pointer_to_offset monoeg_g_utf8_pointer_to_offset
#define g_utf8_strdown monoeg_g_utf8_strdown
#define g_utf8_strlen monoeg_g_utf8_strlen
#define g_utf8_strup monoeg_g_utf8_strup
#define g_utf8_to_ucs4_fast monoeg_g_utf8_to_ucs4_fast
#define g_utf8_to_utf16 monoeg_g_utf8_to_utf16
#define g_utf8_validate monoeg_g_utf8_validate
#define g_unichar_to_utf8 monoeg_g_unichar_to_utf8
#define g_unichar_is_space monoeg_g_unichar_is_space
#define g_unicode_break_type monoeg_g_unicode_break_type
#define g_utf8_offset_to_pointer monoeg_g_utf8_offset_to_pointer
#define g_utf8_pointer_to_offset monoeg_g_utf8_pointer_to_offset
#define g_utf8_to_ucs4_fast monoeg_g_utf8_to_ucs4_fast
#define g_win32_getlocale monoeg_g_win32_getlocale
#define g_assertion_message monoeg_assertion_message
#define g_malloc monoeg_malloc
#define g_malloc0 monoeg_malloc0
#define g_ptr_array_grow monoeg_ptr_array_grow
#define g_realloc monoeg_realloc
#define g_try_malloc monoeg_try_malloc
#define g_try_realloc monoeg_try_realloc
#define g_strdup monoeg_strdup
#define g_ucs4_to_utf16_len monoeg_ucs4_to_utf16_len
#define g_utf16_to_ucs4_len monoeg_utf16_to_ucs4_len
#define g_ascii_strcasecmp monoeg_ascii_strcasecmp
#define g_ascii_strup monoeg_ascii_strup
#define g_ascii_toupper monoeg_ascii_toupper
#define g_unichar_break_type monoeg_unichar_break_type
#define g_unichar_isspace monoeg_unichar_isspace
#define g_unichar_to_utf16 monoeg_unichar_to_utf16
#define g_utf8_find_prev_char monoeg_utf8_find_prev_char
#define g_utf8_get_char_validated monoeg_utf8_get_char_validated
#define g_utf8_prev_char monoeg_utf8_prev_char
#define g_utf8_to_ucs4 monoeg_utf8_to_ucs4
#define g_log_default_handler monoeg_log_default_handler
#define g_log_set_default_handler monoeg_log_set_default_handler
#define g_set_print_handler monoeg_set_print_handler
#define g_set_printerr_handler monoeg_set_printerr_handler

1085
mta-mono/vendor/eglib/glib.h vendored Normal file

File diff suppressed because it is too large Load Diff

37
mta-mono/vendor/eglib/gmodule.h vendored Normal file
View File

@ -0,0 +1,37 @@
#ifndef __GLIB_GMODULE_H
#define __GLIB_GMODULE_H
#include <glib.h>
#define G_MODULE_IMPORT extern
#ifdef G_OS_WIN32
#define G_MODULE_EXPORT __declspec(dllexport)
#else
#define G_MODULE_EXPORT
#endif
G_BEGIN_DECLS
/*
* Modules
*/
typedef enum {
G_MODULE_BIND_LAZY = 0x01,
G_MODULE_BIND_LOCAL = 0x02,
G_MODULE_BIND_MASK = 0x03
} GModuleFlags;
typedef struct _GModule GModule;
GModule *g_module_open (const gchar *file, GModuleFlags flags);
gboolean g_module_symbol (GModule *module, const gchar *symbol_name,
gpointer *symbol);
const gchar *g_module_error (void);
gboolean g_module_close (GModule *module);
gchar * g_module_build_path (const gchar *directory, const gchar *module_name);
extern char *gmodule_libprefix;
extern char *gmodule_libsuffix;
G_END_DECLS
#endif

208
mta-mono/vendor/eglib/sort.frag.h vendored Normal file
View File

@ -0,0 +1,208 @@
/*
* sort.frag.h: Common implementation of linked-list sorting
*
* Author:
* Raja R Harinath (rharinath@novell.com)
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* (C) 2006 Novell, Inc.
*/
/*
* This code requires a typedef named 'list_node' for the list node. It
* is assumed that the list type is the type of a pointer to a list
* node, and that the node has a field named 'next' that implements to
* the linked list. No additional invariant is maintained (e.g. the
* 'prev' pointer of a doubly-linked list node is _not_ updated). Any
* invariant would require a post-processing pass to fix matters if
* necessary.
*/
typedef list_node *digit;
/*
* The maximum possible depth of the merge tree
* = ceiling (log2 (maximum number of list nodes))
* = ceiling (log2 (maximum possible memory size/size of each list node))
* = number of bits in 'size_t' - floor (log2 (sizeof digit))
* Also, each list in sort_info is at least 2 nodes long: we can reduce the depth by 1
*/
#define FLOOR_LOG2(x) (((x)>=2) + ((x)>=4) + ((x)>=8) + ((x)>=16) + ((x)>=32) + ((x)>=64) + ((x)>=128))
#define MAX_RANKS ((sizeof (size_t) * 8) - FLOOR_LOG2(sizeof (list_node)) - 1)
struct sort_info
{
int min_rank, n_ranks;
GCompareFunc func;
/* Invariant: ranks[i] == NULL || length(ranks[i]) >= 2**(i+1) */
list_node *ranks [MAX_RANKS]; /* ~ 128 bytes on 32bit, ~ 512 bytes on 64bit */
};
static inline void
init_sort_info (struct sort_info *si, GCompareFunc func)
{
si->min_rank = si->n_ranks = 0;
si->func = func;
/* we don't need to initialize si->ranks, since we never lookup past si->n_ranks. */
}
static inline list_node *
merge_lists (list_node *first, list_node *second, GCompareFunc func)
{
/* merge the two lists */
list_node *list = NULL;
list_node **pos = &list;
while (first && second) {
if (func (first->data, second->data) > 0) {
*pos = second;
second = second->next;
} else {
*pos = first;
first = first->next;
}
pos = &((*pos)->next);
}
*pos = first ? first : second;
return list;
}
/* Pre-condition: upto <= si->n_ranks, list == NULL || length(list) == 1 */
static inline list_node *
sweep_up (struct sort_info *si, list_node *list, int upto)
{
#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 406)
/*
* GCC incorrectly thinks we're writing below si->ranks array bounds.
*/
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warray-bounds"
#endif
int i;
for (i = si->min_rank; i < upto; ++i) {
list = merge_lists (si->ranks [i], list, si->func);
si->ranks [i] = NULL;
}
return list;
#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 406)
#pragma GCC diagnostic pop
#endif
}
/*
* The 'ranks' array essentially captures the recursion stack of a mergesort.
* The merge tree is built in a bottom-up manner. The control loop for
* updating the 'ranks' array is analogous to incrementing a binary integer,
* and the O(n) time for counting upto n translates to O(n) merges when
* inserting rank-0 lists. When we plug in the sizes of the lists involved in
* those merges, we get the O(n log n) time for the sort.
*
* Inserting higher-ranked lists reduce the height of the merge tree, and also
* eliminate a lot of redundant comparisons when merging two lists that would've
* been part of the same run. Adding a rank-i list is analogous to incrementing
* a binary integer by 2**i in one operation, thus sharing a similar speedup.
*
* When inserting higher-ranked lists, we choose to clear out the lower ranks
* in the interests of keeping the sort stable, but this makes analysis harder.
* Note that clearing the lower-ranked lists is O(length(list))-- thus it
* shouldn't affect the O(n log n) behaviour. IOW, inserting one rank-i list
* is equivalent to inserting 2**i rank-0 lists, thus even if we do i additional
* merges in the clearing-out (taking at most 2**i time) we are still fine.
*/
#define stringify2(x) #x
#define stringify(x) stringify2(x)
/* Pre-condition: 2**(rank+1) <= length(list) < 2**(rank+2) (therefore: length(list) >= 2) */
static inline void
insert_list (struct sort_info *si, list_node* list, int rank)
{
#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 406)
/*
* GCC incorrectly thinks we're writing below si->ranks array bounds.
*/
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warray-bounds"
#endif
int i;
if (rank > si->n_ranks) {
if (rank > MAX_RANKS) {
g_warning ("Rank '%d' should not exceed " stringify (MAX_RANKS), rank);
rank = MAX_RANKS;
}
list = merge_lists (sweep_up (si, NULL, si->n_ranks), list, si->func);
for (i = si->n_ranks; i < rank; ++i)
si->ranks [i] = NULL;
} else {
if (rank)
list = merge_lists (sweep_up (si, NULL, rank), list, si->func);
for (i = rank; i < si->n_ranks && si->ranks [i]; ++i) {
list = merge_lists (si->ranks [i], list, si->func);
si->ranks [i] = NULL;
}
}
if (i == MAX_RANKS) /* Will _never_ happen: so we can just devolve into quadratic ;-) */
--i;
if (i >= si->n_ranks)
si->n_ranks = i + 1;
si->min_rank = i;
si->ranks [i] = list;
#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 406)
#pragma GCC diagnostic pop
#endif
}
#undef stringify2
#undef stringify
#undef MAX_RANKS
#undef FLOOR_LOG2
/* A non-recursive mergesort */
static inline digit
do_sort (list_node* list, GCompareFunc func)
{
struct sort_info si;
init_sort_info (&si, func);
while (list && list->next) {
list_node* next = list->next;
list_node* tail = next->next;
if (func (list->data, next->data) > 0) {
next->next = list;
next = list;
list = list->next;
}
next->next = NULL;
insert_list (&si, list, 0);
list = tail;
}
return sweep_up (&si, list, si.n_ranks);
}

2152
mta-mono/vendor/eglib/unicode-data.h vendored Normal file

File diff suppressed because it is too large Load Diff

11
mta-mono/vendor/eglib/vasprintf.h vendored Normal file
View File

@ -0,0 +1,11 @@
#ifndef __VASPRINTF_H
#define __VASPRINTF_H
#include <stdarg.h>
#include <config.h>
#ifndef HAVE_VASPRINTF
int vasprintf(char **ret, const char *fmt, va_list ap);
#endif
#endif /* __VASPRINTF_H */