Пример #1
1
void wxsGridBagSizer::OnBuildSizerCreatingCode()
{
	switch ( GetLanguage() )
	{
		case wxsCPP:
		{
			AddHeader(_T("<wx/gbsizer.h>"),GetInfo().ClassName,hfInPCH);
			Codef(_T("%C(%s, %s);\n"),
				#if wxCHECK_VERSION(3, 0, 0)
				VGap.GetPixelsCode(GetCoderContext()).wx_str(),
				HGap.GetPixelsCode(GetCoderContext()).wx_str());
				#else
				VGap.GetPixelsCode(GetCoderContext()).c_str(),
				HGap.GetPixelsCode(GetCoderContext()).c_str());
				#endif

			wxArrayInt Cols = GetArray(GrowableCols);
			for ( size_t i=0; i<Cols.Count(); i++ )
			{
				Codef(_T("%AAddGrowableCol(%d);\n"),Cols[i]);
			}

			wxArrayInt Rows = GetArray(GrowableRows);
			for ( size_t i=0; i<Rows.Count(); i++ )
			{
				Codef(_T("%AAddGrowableRow(%d);\n"),Rows[i]);
			}

			return;
		}

		case wxsUnknownLanguage: // fall-through
		default:
		{
			wxsCodeMarks::Unknown(_T("wxsGridBagSizer::OnBuildSizerCreatingCode"),GetLanguage());
		}
	}
}
Пример #2
0
void getDevices(v8::FunctionArgs args)
{
    cl_device_type deviceType = GetNumber(args[1]);
    cl_uint deviceArraySize = GetNumber(args[2]);
    cl_uint totalDevices = 0;

    const auto deviceList = GetArray(args[3]);
    const auto deviceDetails = GetArray(args[4]);

    auto deviceArray = std::unique_ptr<cl_device_id[]>(new cl_device_id[deviceArraySize]);
    auto platformID = static_cast<cl_platform_id>(UnwrapPointer(args[0]));
    auto devicesOut = deviceList->IsNull() ? nullptr : deviceArray.get();
    auto totalOut = deviceDetails->IsNull() ? nullptr : &totalDevices;
    auto error = clGetDeviceIDs(platformID, deviceType, deviceArraySize, devicesOut, totalOut);

    if (!deviceList->IsNull())
    {
        for (auto i = 0; i < deviceArraySize; ++i)
        {
            deviceList->Set(i, v8::WrapPointer(deviceArray[i]));
        }
    }

    if (!deviceDetails->IsNull())
    {
        deviceDetails->Set(v8::NewString("length"), v8::NewNumber(totalDevices));
    }
    
    Return(args, error);
}
Пример #3
0
void cStringList::Resize( int NewSize ) {
	if(NewSize==0) { 
		if(Array!=NULL) { delete [] Array; Array=NULL; }
		used=0; allocated=0; 
		return;
	}

	if(NewSize==allocated) return;

	if(Array==NULL) {
		allocated=NewSize;
		used=0;
		GetArray();
		return;
	}
	else if(allocated==0) {
		cerr<<"WARNING: Array is not null and allocated is 0, this is bad"<<endl;
		cerr<<"ERR requested size was "<<NewSize<<endl;
		exit(1);
	}
	
	cString * OldArray;
	OldArray = Array;                    // Save array
	Array=NULL;				// Nullify old array pointer
	allocated = NewSize;
	GetArray( );
	for( int i = 0; i < used; i++ )
	        Array[ i ] = OldArray[ i ];
	delete [ ] OldArray;
	
}
Пример #4
0
    Var ES5ArrayEnumerator::GetCurrentAndMoveNext(PropertyId& propertyId, PropertyAttributes* attributes)
    {
        propertyId = Constants::NoProperty;

        if (!doneArray)
        {
            while (true)
            {
                if (index == dataIndex)
                {
                    dataIndex = arrayObject->GetNextIndex(dataIndex);
                }
                if (index == descriptorIndex || !GetArray()->IsValidDescriptorToken(descriptorValidationToken))
                {
                    descriptorIndex = GetArray()->GetNextDescriptor(index, &descriptor, &descriptorValidationToken);
                }

                index = min(dataIndex, descriptorIndex);
                if (index >= initialLength) // End of array
                {
                    doneArray = true;
                    break;
                }

                if (enumNonEnumerable
                    || index < descriptorIndex
                    || (descriptor->Attributes & PropertyEnumerable))
                {
                    if (attributes != nullptr)
                    {
                        if (index < descriptorIndex)
                        {
                            *attributes = PropertyEnumerable;
                        }
                        else
                        {
                            *attributes = descriptor->Attributes;
                        }
                    }

                    return arrayObject->GetScriptContext()->GetIntegerString(index);
                }
            }
        }
        if (!doneObject)
        {
            Var currentIndex = objectEnumerator->GetCurrentAndMoveNext(propertyId, attributes);
            if (currentIndex)
            {
                return currentIndex;
            }
            doneObject = true;
        }
        return NULL;
    }
Пример #5
0
void CIni::GetArray(LPCTSTR lpSection, LPCTSTR lpKey, CStringArray *pArray, LPCTSTR lpDelimiter, BOOL bTrimString) const
{
	if (pArray != NULL)
		pArray->RemoveAll();

	const DWORD LEN = GetArray(lpSection, lpKey, NULL, 0, lpDelimiter);
	if (LEN == 0)
		return;

	LPTSTR psz = new TCHAR[LEN + 3];
	GetArray(lpSection, lpKey, psz, LEN + 2, lpDelimiter);
	ParseDNTString(psz, __SubStrAdd, (LPVOID)pArray);
	delete [] psz;
}
Пример #6
0
	void cVertexBufferVBO::Transform(const cMatrixf &a_mtxTransform)
	{
		float *pPosArray = GetArray(eVertexFlag_Position);
		float *pNormalArray = GetArray(eVertexFlag_Normal);
		float *pTangentArray = NULL;
		if(mbTangents)pTangentArray = GetArray(eVertexFlag_Texture1);

		int lVtxNum = GetVertexNum();

		cMatrixf mtxRot = a_mtxTransform.GetRotation();

		int lVtxStride = kvVertexElements[cMath::Log2ToInt(eVertexFlag_Position)];

		int lOffset = GetVertexNum()*4;

		for(int i=0; i<lVtxNum; i++)
		{
			float* pPos = &pPosArray[i*lVtxStride];
			float* pNorm = &pNormalArray[i*3];
			float* pTan = NULL;
			if(mbTangents)pTan = &pTangentArray[i*4];

			cVector3f vPos = cMath::MatrixMul(a_mtxTransform, cVector3f(pPos[0],pPos[1],pPos[2]));
			pPos[0] = vPos.x; pPos[1] = vPos.y; pPos[2] = vPos.z;

			if(mbHasShadowDouble){
				float* pExtraPos = &pPosArray[i*lVtxStride + lOffset];
				pExtraPos[0] = vPos.x; pExtraPos[1] = vPos.y; pExtraPos[2] = vPos.z;
			}

			cVector3f vNorm = cMath::MatrixMul(mtxRot, cVector3f(pNorm[0],pNorm[1],pNorm[2]));
			vNorm.Normalise();
			pNorm[0] = vNorm.x; pNorm[1] = vNorm.y; pNorm[2] = vNorm.z;

			if(mbTangents){
				cVector3f vTan = cMath::MatrixMul(mtxRot, cVector3f(pTan[0],pTan[1],pTan[2]));
				vTan.Normalise();
				pTan[0] = vTan.x; pTan[1] = vTan.y; pTan[2] = vTan.z;
			}
		}

		if(mbCompiled)
		{
			if(mbTangents)
				UpdateData(eVertexFlag_Position | eVertexFlag_Normal | eVertexFlag_Texture1,false);
			else
				UpdateData(eVertexFlag_Position | eVertexFlag_Normal,false);
		}
	}
Пример #7
0
CFX_Matrix CPDF_Dictionary::GetMatrix(const CFX_ByteStringC& key) const {
  CFX_Matrix matrix;
  CPDF_Array* pArray = GetArray(key);
  if (pArray)
    matrix = pArray->GetMatrix();
  return matrix;
}
HRESULT CLR_RT_HeapBlock_Queue::Clear()
{
    NATIVE_PROFILE_CLR_CORE();
    TINYCLR_HEADER();

    CLR_RT_HeapBlock_Array* array = GetArray();
    CLR_INT32               size  = GetSize();
    CLR_INT32               head  =    Head();
    CLR_INT32               tail  = GetTail();

    if(size > 0)
    {
        if(head < tail)
        {
            TINYCLR_CHECK_HRESULT(array->ClearElements( head, size ));
        }
        else
        {
            TINYCLR_CHECK_HRESULT(array->ClearElements( head, array->m_numOfElements - head ));
            TINYCLR_CHECK_HRESULT(array->ClearElements( 0   , tail                          ));
        }
        
        SetSize( 0 );
    }

    SetHead( 0 );
    SetTail( 0 );

    TINYCLR_NOCLEANUP();
}
HRESULT CLR_RT_HeapBlock_Queue::CopyTo( CLR_RT_HeapBlock_Array* toArray, CLR_INT32 index )
{
    NATIVE_PROFILE_CLR_CORE();
    TINYCLR_HEADER();
    
    CLR_RT_HeapBlock_Array* array = GetArray();
    CLR_INT32               size  = GetSize();
    CLR_INT32               head  =    Head();
    CLR_INT32               tail  = GetTail();

    // if the target array is of type Object, we don't need to call the complex Array::Copy() since there will be no casting involved
    HRESULT (*arrayCopy)( CLR_RT_HeapBlock_Array*, int, CLR_RT_HeapBlock_Array*, int, int ) = 
        (toArray->m_typeOfElement == DATATYPE_OBJECT) ? ObjArrayMemcpy : CLR_RT_HeapBlock_Array::Copy;
    
    if(((CLR_INT32)toArray->m_numOfElements) - index < size) TINYCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER);

    if(size > 0)
    {
        if(head < tail)
        {
            TINYCLR_SET_AND_LEAVE(arrayCopy( array, head, toArray, index, size ));
        }
        else
        {
            CLR_INT32 firstPart = array->m_numOfElements - head;

            TINYCLR_CHECK_HRESULT(arrayCopy( array, head, toArray, index            , firstPart ));
            TINYCLR_SET_AND_LEAVE(arrayCopy( array, 0   , toArray, index + firstPart, tail      ));
        }
    }

    TINYCLR_NOCLEANUP();
}
Пример #10
0
unsigned int ConfigNode::GetArray(const char * i_variable_name, const char * o_values[]) const
{
    if(!m_dictionary)
    {
        std::printf("Error: Config Node has no dictionary to look up the array of strings: %s",i_variable_name);
        return 0;
    }

    cocos2d::CCArray * array = GetArray(i_variable_name);

    if(!array)
    {
        std::printf("Error: Could not find array %s",i_variable_name);
        return 0;
    }

    unsigned int count = array->count();

    const char ** out_iter = o_values;
    for(unsigned int i=0; i!=count; ++i,++out_iter)
    {
        *out_iter = dynamic_cast<cocos2d::CCString*>(array->objectAtIndex(i))->getCString();
    }

    return count;
}
Пример #11
0
 template<typename VALUE_T>uint32_t
 Document_t<VALUE_T>::Locate(uint32_t pos, const char *path) const
 {
     char *cur, *next, *_path = strdup(path);
     for (cur = _path; cur != NULL; cur = next) {
         if ((next = strchr(cur, '.')) != NULL) *next++ = 0;
         if (strlen(cur) == strspn(cur, "0123456789")) {
             if (!IsArray(pos)) {
                 pos = UINT32_MAX; goto quit0;
             }
             uint32_t idx = atol(cur);
             if (idx >= GetArraySpace(pos)) {
                 pos = UINT32_MAX; goto quit0;
             }
             pos = GetArray(pos, idx);
         } else {
             if (!IsObject(pos)) {
                 pos = UINT32_MAX; goto quit0;
             }
             if ((pos = ObjectSearch(pos, cur)) == UINT32_MAX) {
                 pos = UINT32_MAX; goto quit0;
             }
         }
     }
 quit0:
     free(_path);
     return pos;
 }
Пример #12
0
CFX_FloatRect CPDF_Dictionary::GetRect(const CFX_ByteStringC& key) const {
  CFX_FloatRect rect;
  CPDF_Array* pArray = GetArray(key);
  if (pArray)
    rect = pArray->GetRect();
  return rect;
}
Пример #13
0
wxGridBagSizer* wxsGridBagSizer::OnBuildSizerPreview(wxWindow* Parent)
{
	wxGridBagSizer* Sizer = new wxGridBagSizer(VGap.GetPixels(Parent),HGap.GetPixels(Parent));

	wxArrayInt Cols = GetArray(GrowableCols);
	for ( size_t i=0; i<Cols.Count(); i++ )
	{
		Sizer->AddGrowableCol(Cols[i]);
	}

	wxArrayInt Rows = GetArray(GrowableRows);
	for ( size_t i=0; i<Rows.Count(); i++ )
	{
		Sizer->AddGrowableRow(Rows[i]);
	}
	return Sizer;
}
Пример #14
0
cStringList::cStringList( int Size ) {
	skipblanks=true;
	Array=NULL;
	allocated = Size;
	used=0;
	GetArray();
	if(Array!=NULL && allocated==0) { exit(1);}
}
    Var ES5ArrayIndexEnumerator::MoveAndGetNext(PropertyId& propertyId, PropertyAttributes* attributes)
    {
        propertyId = Constants::NoProperty;

        if (!doneArray)
        {
            while (true)
            {
                if (index == dataIndex)
                {
                    dataIndex = arrayObject->GetNextIndex(dataIndex);
                }
                if (index == descriptorIndex || !GetArray()->IsValidDescriptorToken(descriptorValidationToken))
                {
                    descriptorIndex = GetArray()->GetNextDescriptor(index, &descriptor, &descriptorValidationToken);
                }

                index = min(dataIndex, descriptorIndex);
                if (index >= initialLength) // End of array
                {
                    doneArray = true;
                    break;
                }

                if (!!(flags & EnumeratorFlags::EnumNonEnumerable)
                    || index < descriptorIndex
                    || (descriptor->Attributes & PropertyEnumerable))
                {
                    if (attributes != nullptr)
                    {
                        if (index < descriptorIndex)
                        {
                            *attributes = PropertyEnumerable;
                        }
                        else
                        {
                            *attributes = descriptor->Attributes;
                        }
                    }

                    return this->GetScriptContext()->GetIntegerString(index);
                }
            }
        }
        return nullptr;
    }
Пример #16
0
 template<typename VALUE_T>uint32_t
 Document_t<VALUE_T>::GetArraySize(uint32_t pos) const
 {
     uint32_t size = 0;
     for (uint32_t idx = 0; idx < GetArraySpace(pos); ++idx)
         if (!IsRemoved(GetArray(pos, idx))) ++size;
     return size;
 }
Пример #17
0
CFX_AffineMatrix CPDF_Dictionary::GetMatrix(FX_BSTR key) const
{
    CFX_AffineMatrix matrix;
    CPDF_Array* pArray = GetArray(key);
    if (pArray) {
        matrix = pArray->GetMatrix();
    }
    return matrix;
}
Пример #18
0
CFX_FloatRect CPDF_Dictionary::GetRect(FX_BSTR key) const
{
    CFX_FloatRect rect;
    CPDF_Array* pArray = GetArray(key);
    if (pArray) {
        rect = pArray->GetRect();
    }
    return rect;
}
Пример #19
0
bool CWizXmlRpcStructValue::GetStringArray(const QString& strName, CWizStdStringArray& arrayData) const
{
    CWizXmlRpcArrayValue* pArray = GetArray(strName);
    if (!pArray) {
        TOLOG("Failed to get array data in struct");
        return false;
	}

	return pArray->ToStringArray(arrayData);
}
HRESULT CLR_RT_HeapBlock_Queue::Peek( CLR_RT_HeapBlock*& value )
{
    NATIVE_PROFILE_CLR_CORE();
    TINYCLR_HEADER();

    if(GetSize() == 0) TINYCLR_SET_AND_LEAVE(CLR_E_INVALID_OPERATION);

    value = ((CLR_RT_HeapBlock*)GetArray()->GetElement( Head() ))->Dereference();

    TINYCLR_NOCLEANUP();
}
Пример #21
0
void
FileManagerInfo::AddFileManager(FileManager* aFileManager)
{
  AssertIsOnIOThread();

  nsTArray<RefPtr<FileManager> >& managers = GetArray(aFileManager->Type());

  NS_ASSERTION(!managers.Contains(aFileManager), "Adding more than once?!");

  managers.AppendElement(aFileManager);
}
Пример #22
0
	template<typename V> V GetVec(const std::string& key, int len) const {
		const std::map<std::string, LuaTable*>::const_iterator it = StrTblPairs.find(key);

		V v;

		if (it != StrTblPairs.end()) {
			GetArray(it->second, &v.x, len);
		}

		return v;
	}
Пример #23
0
BOOL CWizXmlRpcStructValue::GetStringArray(const CString& strName, CWizStdStringArray& arrayData) const
{
    CWizXmlRpcArrayValue* pArray = GetArray(strName);
	if (!pArray)
	{
		TOLOG(_T("Failed to get array data in struct"));
		return FALSE;
	}
	//
	return pArray->ToStringArray(arrayData);
}
Пример #24
0
ScriptToken* ScriptToken::ToBasicToken() const
{
	if (CanConvertTo(kTokenType_String))
		return Create(GetString());
	else if (CanConvertTo(kTokenType_Array))
		return CreateArray(GetArray());
	else if (CanConvertTo(kTokenType_Form))
		return CreateForm(GetFormID());
	else if (CanConvertTo(kTokenType_Number))
		return Create(GetNumber());
	else
		return NULL;
}
Пример #25
0
void
FileManagerInfo::InvalidateAndRemoveFileManagers(
                                               PersistenceType aPersistenceType)
{
  AssertIsOnIOThread();

  nsTArray<RefPtr<FileManager > >& managers = GetArray(aPersistenceType);

  for (uint32_t i = 0; i < managers.Length(); i++) {
    managers[i]->Invalidate();
  }

  managers.Clear();
}
Пример #26
0
void createContextFromType(v8::FunctionArgs args)
{
    if (args.Length() == 5)
    {
        auto array = GetArray(args[0]);
        auto flags = GetNumber(args[1]);
   
        const auto platformID = cl_context_properties(UnwrapPointer(array->Get(1)));
        const auto platformType = array->Get(0)->NumberValue();
        const auto platformIndex = array->Get(2)->NumberValue();

        cl_context_properties properties[] = { (cl_prop)platformType, (cl_prop)platformID, (cl_prop)platformIndex };
        cl_context context = clCreateContextFromType(properties, flags, nullptr, nullptr, nullptr);
        
        Return(args, v8::WrapPointer(context));
    }
}
Пример #27
0
bool FileReader::OpenMemoryArray(std::function<bool(TArray<uint8_t>&)> getter)
{
	auto reader = new MemoryArrayReader(nullptr, 0);
	if (getter(reader->GetArray()))
	{
		Close();
		reader->UpdateBuffer();
		mReader = reader;
		return true;
	}
	else
	{
		// This will keep the old buffer, if one existed
		delete reader;
		return false;
	}
}
Пример #28
0
void
FileManagerInfo::InvalidateAndRemoveFileManager(
                                               PersistenceType aPersistenceType,
                                               const nsAString& aName)
{
  AssertIsOnIOThread();

  nsTArray<RefPtr<FileManager > >& managers = GetArray(aPersistenceType);

  for (uint32_t i = 0; i < managers.Length(); i++) {
    RefPtr<FileManager>& fileManager = managers[i];
    if (fileManager->DatabaseName() == aName) {
      fileManager->Invalidate();
      managers.RemoveElementAt(i);
      return;
    }
  }
}
Пример #29
0
void JSONValue::ToBinary(Stream& dest) const
{
    dest.Write((unsigned char)type);

    switch (type)
    {
    case JSON_BOOL:
        dest.Write(data.boolValue);
        break;

    case JSON_NUMBER:
        dest.Write(data.numberValue);
        break;

    case JSON_STRING:
        dest.Write(GetString());
        break;

    case JSON_ARRAY:
        {
            const JSONArray& array = GetArray();
            dest.WriteVLE(array.Size());
            for (auto it = array.Begin(); it != array.End(); ++it)
                it->ToBinary(dest);
        }
        break;

    case JSON_OBJECT:
        {
            const JSONObject& object = GetObject();
            dest.WriteVLE(object.Size());
            for (auto it = object.Begin(); it != object.End(); ++it)
            {
                dest.Write(it->first);
                it->second.ToBinary(dest);
            }
        }
        break;

    default:
        break;
    }
}
Пример #30
0
// Note that prefix needs to be atomized (with nametable) prior to calling LookupNamespace()
CLR_RT_HeapBlock_String* CLR_RT_HeapBlock_XmlNamespaceStack::LookupNamespace( CLR_RT_HeapBlock_String* prefix )
{
    CLR_RT_HeapBlock_Array* array    = GetArray();
    CLR_INT32               size     = GetSize();
    CLR_INT32               capacity = array->m_numOfElements;

    for(int i = capacity - size; i < capacity; i++)
    {
        CLR_RT_HeapBlock_XmlNamespaceEntry* entry = (CLR_RT_HeapBlock_XmlNamespaceEntry*)((CLR_RT_HeapBlock*)array->GetElement( i ))->Dereference();

        // since prefix is atomized, we only need to compare its reference.
        if(entry->GetPrefix() == prefix)
        {
            return entry->GetNamespaceURI();
        }
    }

    return NULL;
}