#include "StdAfx.h" #using <mscorlib.dll> #include "clientapi_m.h" using namespace System::Runtime::InteropServices; p4dn::ClientApi::ClientApi() { _clientApi = new ::ClientApi(); _keepAliveDelegate = NULL; } p4dn::ClientApi::~ClientApi() { delete _clientApi; delete _keepAliveDelegate; } void p4dn::ClientApi::SetTrans( int output, int content, int fnames, int dialog ) { _clientApi->SetTrans( output, content, fnames, dialog ); } void p4dn::ClientApi::SetProtocol( String *p, String *v ) { char* str_p = (char *)(void *) Marshal::StringToHGlobalAnsi( p ); char* str_v = (char *)(void *) Marshal::StringToHGlobalAnsi( v ); _clientApi->SetProtocol( str_p, str_v ); Marshal::FreeHGlobal( str_p ); Marshal::FreeHGlobal( str_v ); } void p4dn::ClientApi::SetArgv( String* args[] ) { char** argsArray = new char* [ args->Length ]; for (int i = 0; i < args->Length; ++i) { argsArray[i] = (char *)(void *) Marshal::StringToHGlobalAnsi( args[i] ); } _clientApi->SetArgv( args->Length, argsArray ); for (int i = 0; i < args->Length; ++i) { Marshal::FreeHGlobal( argsArray[i] ); } } void p4dn::ClientApi::SetProtocolV( String* p ) { char* str_p = (char *)(void *) Marshal::StringToHGlobalAnsi( p ); _clientApi->SetProtocolV( str_p ); Marshal::FreeHGlobal( str_p ); } String* p4dn::ClientApi::GetProtocol( String *v ) { char* str_p = (char *)(void *) Marshal::StringToHGlobalAnsi( v ); StrPtr* ptr = _clientApi->GetProtocol( str_p ); String* s = ptr->Text(); delete ptr; Marshal::FreeHGlobal( str_p ); return s; } void p4dn::ClientApi::Init( p4dn::Error* e ) { _clientApi->Init( e->get_InternalError() ); } void p4dn::ClientApi::Run( String* func, p4dn::ClientUser *ui ) { // System::Console::WriteLine( "Running command {0}", func ); char* f = (char *)(void *) Marshal::StringToHGlobalAnsi( func ); _clientApi->Run( f, ui->_clientUserDelegate ); Marshal::FreeHGlobal( f ); } int p4dn::ClientApi::Final( p4dn::Error *e ) { return _clientApi->Final( e->get_InternalError() ); } int p4dn::ClientApi::Dropped() { return _clientApi->Dropped(); } void p4dn::ClientApi::RunTag( String* func, p4dn::ClientUser *ui ) { char* f = (char *)(void *) Marshal::StringToHGlobalAnsi( func ); _clientApi->RunTag( f, ui->_clientUserDelegate ); Marshal::FreeHGlobal( f ); } void p4dn::ClientApi::WaitTag( p4dn::ClientUser *ui ) { _clientApi->WaitTag( ui->_clientUserDelegate ); } void p4dn::ClientApi::SetCharset( String* c ) { char* f = (char *)(void *) Marshal::StringToHGlobalAnsi( c ); _clientApi->SetCharset( f ); Marshal::FreeHGlobal( f ); } void p4dn::ClientApi::SetClient( String* c ) { char* f = (char *)(void *) Marshal::StringToHGlobalAnsi( c ); _clientApi->SetClient( f ); Marshal::FreeHGlobal( f ); } void p4dn::ClientApi::SetCwd( String* c ) { char* f = (char *)(void *) Marshal::StringToHGlobalAnsi( c ); _clientApi->SetCwd( f ); Marshal::FreeHGlobal( f ); } void p4dn::ClientApi::SetHost( String* c ) { char* f = (char *)(void *) Marshal::StringToHGlobalAnsi( c ); _clientApi->SetHost( f ); Marshal::FreeHGlobal( f ); } void p4dn::ClientApi::SetLanguage( String* c ) { char* f = (char *)(void *) Marshal::StringToHGlobalAnsi( c ); _clientApi->SetLanguage( f ); Marshal::FreeHGlobal( f ); } void p4dn::ClientApi::SetPassword( String* c ) { char* f = (char *)(void *) Marshal::StringToHGlobalAnsi( c ); _clientApi->SetPassword( f ); Marshal::FreeHGlobal( f ); } void p4dn::ClientApi::SetPort( String* c ) { char* f = (char *)(void *) Marshal::StringToHGlobalAnsi( c ); _clientApi->SetPort( f ); Marshal::FreeHGlobal( f ); } void p4dn::ClientApi::SetUser( String* c ) { char* f = (char *)(void *) Marshal::StringToHGlobalAnsi( c ); _clientApi->SetUser( f ); Marshal::FreeHGlobal( f ); } void p4dn::ClientApi::SetBreak( p4dn::KeepAlive *keepAlive ) { if (_keepAliveDelegate != NULL) { return; } // get pinned handle and stach it away. GCHandle h =GCHandle::Alloc( keepAlive ); IntPtr ptr = GCHandle::op_Explicit( h ); int handle = ptr.ToInt32(); _keepAliveDelegate = new KeepAliveDelegate( handle ); } void p4dn::ClientApi::DefineCharset( String* c, p4dn::Error* e ) { char* f = (char *)(void *) Marshal::StringToHGlobalAnsi( c ); _clientApi->DefineCharset( f, e->get_InternalError() ); Marshal::FreeHGlobal( f ); } void p4dn::ClientApi::DefineClient( String* c, p4dn::Error* e ) { char* f = (char *)(void *) Marshal::StringToHGlobalAnsi( c ); _clientApi->DefineClient( f, e->get_InternalError() ); Marshal::FreeHGlobal( f ); } void p4dn::ClientApi::DefineHost( String* c, p4dn::Error* e ) { char* f = (char *)(void *) Marshal::StringToHGlobalAnsi( c ); _clientApi->DefineHost( f, e->get_InternalError() ); Marshal::FreeHGlobal( f ); } void p4dn::ClientApi::DefineLanguage( String* c, p4dn::Error* e ) { char* f = (char *)(void *) Marshal::StringToHGlobalAnsi( c ); _clientApi->DefineLanguage( f, e->get_InternalError() ); Marshal::FreeHGlobal( f ); } void p4dn::ClientApi::DefinePassword( String* c, p4dn::Error* e ) { char* f = (char *)(void *) Marshal::StringToHGlobalAnsi( c ); _clientApi->DefinePassword( f, e->get_InternalError() ); Marshal::FreeHGlobal( f ); } void p4dn::ClientApi::DefinePort( String* c, p4dn::Error* e ) { char* f = (char *)(void *) Marshal::StringToHGlobalAnsi( c ); _clientApi->DefinePort( f, e->get_InternalError() ); Marshal::FreeHGlobal( f ); } void p4dn::ClientApi::DefineUser( String* c, p4dn::Error* e ) { char* f = (char *)(void *) Marshal::StringToHGlobalAnsi( c ); _clientApi->DefineUser( f, e->get_InternalError() ); Marshal::FreeHGlobal( f ); }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#5 | 5826 | Shawn Hladky | PerforceDotNet is now obsolete | ||
#4 | 5064 | Shawn Hladky |
WIP -- Added ability to parse forms. Added new tester application. ** not ready for human consumption, needs more review and testing. |
||
#3 | 4643 | Shawn Hladky | Clean-up some more memory issues | ||
#2 | 4545 | Shawn Hladky |
Several Fixes: Updated solution to Visual Studio 2003 Implemented InputData Implemented OutPutBinary Changed ClientAPI and Error objects to implement the IDisposable interface to improve Garbage Collection Changed header files so you don't need to add #pragma once to the p4 api headers. Refactored the ClientUserDelagate class Fixed a few minor memory leaks |
||
#1 | 4328 | Shawn Hladky | Branching from //guest/jacob_gladish/PerforceDotNet/... | ||
//guest/jacob_gladish/PerforceDotNet/p4dn/ClientApi_m.cpp | |||||
#1 | 3787 | Jacob Gladish | initial code submission |