void Value_Raw::put_Data( vuint8* inDataBuffer, vuint32 inBufferSize ) { vuint8* pBegin = inDataBuffer; vuint8* pEnd = inDataBuffer + inBufferSize; if( pBegin == nullptr || inBufferSize == 0 ) { put_IsNull( true ); } else { put_IsNull( false ); vuint32 OldLen = get_Length(); vuint32 Available = get_Allocated(); vuint32 Assigned = vuint32(pEnd - pBegin); Assigned = Assigned > Available ? Available : Assigned; if( Assigned > 0) { memcpy( m_pStart, pBegin, Assigned ); m_pEnd = m_pStart + Assigned; } if( gEraseInformation ) { // Fill the peace of space that has been freed after old value with 0. vuint32 NewLen = get_Length(); vint32 Diff = static_cast<vint32>(OldLen - NewLen); if( Diff > 0 ) { memset(m_pEnd, 0, static_cast<vuint32>(Diff)); } } } }
STDMETHODIMP CGaugeOverlay::HitTest(/*[in]*/ short X, /*[in]*/ short Y, /*[out, retval]*/ VARIANT_BOOL *retVal) { if (retVal == NULL) return E_POINTER; *retVal = false; long val = 0; IMeter *iMeter; get_meter(&iMeter); if (iMeter && SUCCEEDED(iMeter->GetAsLong(selector, &val))) { PointF points[1] = { PointF(X, Y) }; long max, min, length, thickness; get_Max(&max); get_Min(&min); get_Length(&length); get_Thickness(&thickness); long size = max - min; long offset = val - min; REAL el[6]; CumulativeTransform(size, offset, el); Matrix transform(el[0], el[1], el[2], el[3], el[4], el[5]); transform.Invert(); transform.TransformPoints(points, 1); RectF bounds(0.0, 0.0, (float)length, (float)thickness); *retVal = bounds.Contains(points[0]); } return S_OK; }
int main(int argc, char* argv[]) { fs::path game_dir("C:\\my\\unity\\proj1\\proj1\\build\\1_Data"); fs::path managed_dir = game_dir / "Managed"; fs::path mono_dir = game_dir / "Mono"; fs::path dll_path = mono_dir / "_mono.dll"; HMODULE dll = LoadLibraryA(dll_path.string().c_str()); auto f = make_shared<mono_wrapper::functions_t>(mono_wrapper::load_mono_functions_from_dll(dll)); f->mono_set_dirs(managed_dir.string().c_str(), (game_dir / "Mono/etc").string().c_str()); { std::stringstream ss; ss << managed_dir.string() << ";" << mono_dir.string(); f->mono_set_assemblies_path(ss.str().c_str()); } MonoDomain* domain = f->mono_jit_init("My domain"); auto s = new_String(f, "Hello!"); auto s1 = s->ToUpper(); string s1_content = s1->to_utf8(); int32_t len = s->get_Length(); return 0; }
vuint32 Value_Raw::TruncateTo( vuint32 inNewSize ) { // For speed consideration this method does not perform any checking. vuint32 OldLen = get_Length(); vuint32 NewLen = OldLen > inNewSize ? inNewSize : OldLen; char* NewBuf = nullptr; if( inNewSize ) { NewBuf = new char[inNewSize]; if( !NewBuf ) { return OldLen; } // Copy and free old content memcpy(NewBuf, m_pStart, NewLen ); } delete [] m_pStart; // Set pointers m_pStart = NewBuf; m_pBufferEnd = m_pStart + inNewSize; m_pEnd = m_pStart + NewLen; return NewLen; }
void Value_Raw::Increment( void ) { if( m_pStart ) { char c = *m_pStart < 'z' ? ++(*m_pStart) : 'a'; memset( m_pStart, c, get_Length() ); } }
String Value_Raw::get_String( tslen inLimit ) const { // There is no sense to work with Binary data as with zero terminated and probably // multi byte string. // tslen Limit = inLimit; if( Limit == -1 ) { Limit = static_cast<tslen>(get_Length()); } return String(m_pStart, Limit); }
char* Value_Raw::get_String( char* outString, tslen inBufferChars ) const { // The size of input buffer (inBufferChars) cannot be -1 ! // Because this is unsafe then to write to the memory // location pointed by outString - because we don't know the size ! if( outString == nullptr || inBufferChars <= 0 ) return nullptr; tslen length = (tslen) get_Length(); if( length < inBufferChars ) inBufferChars = length; memcpy( outString, m_pStart, (vuint32) inBufferChars ); return outString + inBufferChars; }
STDMETHODIMP CGaugeOverlay::Render(LONG hdc) { long val = 0; IMeter *iMeter; get_meter(&iMeter); if (iMeter && SUCCEEDED(iMeter->GetAsLong(selector, &val))) { GraphicsPath path(FillModeAlternate); long max, min, length, thickness; get_Max(&max); get_Min(&min); get_Length(&length); get_Thickness(&thickness); long size = max - min; long offset = val - min; path.AddRectangle(RectF(0.0, 0.0, (float)length, (float)thickness)); REAL el[6]; CumulativeTransform(size, offset, el); Matrix matrix(el[0], el[1], el[2], el[3], el[4], el[5]); path.Transform(&matrix); Graphics graphics((HDC)hdc); graphics.SetInterpolationMode(InterpolationModeHighQuality); graphics.SetSmoothingMode(SmoothingModeAntiAlias); graphics.SetPixelOffsetMode(PixelOffsetModeHalf); long rgb; BYTE alpha; get_Color(&rgb); get_Alpha(&alpha); Color color; color.SetFromCOLORREF(rgb); rgb = color.GetValue() & 0x00FFFFFF; color.SetValue(rgb | ((long)alpha << 24)); SolidBrush fg(color); graphics.FillPath(&fg, &path); } return S_OK; }
vuint32 Value_Raw::get_Data( vuint8* outDataBuffer, vuint32 inBufferSize ) const { FBL_CHECK(outDataBuffer); if( !outDataBuffer || inBufferSize == 0 ) { return 0; } vuint32 MyLen = get_Length(); if( MyLen == 0 ) { return 0; } vuint32 ToCopy = inBufferSize > MyLen ? MyLen : inBufferSize; memcpy(outDataBuffer, m_pStart, ToCopy); // Return the count of copied bytes. return ToCopy; }
vuint32 FileWin::DoRead( char* inBuffer, flength inFrom, vuint32 inHowMuch ) { FBL_CHECK(inBuffer); /* pre: read existing information */ FBL_CHECK( inFrom + inHowMuch <= get_Length() ); /* Set file marker to right position */ Seek(inFrom, begin); DWORD Read; if (!::ReadFile(mHandle, inBuffer, inHowMuch, &Read, NULL)) { ERROR_TYPE err = (ERROR_TYPE) ::GetLastError(); throw xOSFileError( err ); } return Read; }
vuint32 Value_Raw::GrowBy( vuint32 inBySize ) { // For speed consideration this method does not perform // any checking of input parameters. vuint32 OldLen = get_Length(); vuint32 NewSize = get_Allocated() + inBySize; char* NewBuf = new char[NewSize]; if( !NewBuf ) { // Return the old size. return NewSize - inBySize; } // Copy and free old content memcpy(NewBuf, m_pStart, OldLen); delete []m_pStart; // Set pointers m_pStart = NewBuf; m_pBufferEnd = m_pStart + NewSize; m_pEnd = m_pStart + OldLen; if( gEraseInformation ) { // Fill additional memory with 0. vuint32 Rest = vuint32(m_pBufferEnd - m_pEnd); if( Rest ) { memset(m_pEnd, 0, Rest); } } return NewSize; }
uint32_t __array<T>::__get_size() { return sizeof(__array<T>) + get_Length() * __array_element_size(); }
int32_t __array<T>::System_Collections_ICollection_get_Count() { return get_Length(); }