Beispiel #1
0
void C4TargetRect::CompileFunc(StdCompiler *pComp) {
  C4Rect::CompileFunc(pComp);
  pComp->Seperator();
  pComp->Value(mkDefaultAdapt(tx, 0));
  pComp->Seperator();
  pComp->Value(mkDefaultAdapt(ty, 0));
}
Beispiel #2
0
void C4Rect::CompileFunc(StdCompiler *pComp) {
  pComp->Value(mkDefaultAdapt(x, 0));
  pComp->Seperator();
  pComp->Value(mkDefaultAdapt(y, 0));
  pComp->Seperator();
  pComp->Value(mkDefaultAdapt(Wdt, 0));
  pComp->Seperator();
  pComp->Value(mkDefaultAdapt(Hgt, 0));
}
Beispiel #3
0
void C4SVal::CompileFunc(StdCompiler *pComp) {
  pComp->Value(mkDefaultAdapt(Std, 0));
  if (!pComp->Seperator()) return;
  pComp->Value(mkDefaultAdapt(Rnd, 0));
  if (!pComp->Seperator()) return;
  pComp->Value(mkDefaultAdapt(Min, 0));
  if (!pComp->Seperator()) return;
  pComp->Value(mkDefaultAdapt(Max, 100));
}
void C4GraphicsOverlay::CompileFunc(StdCompiler *pComp)
{
	// read ID
	pComp->Value(iID); pComp->Separator();
	// read def-graphics
	pComp->Value(mkDefaultAdapt(C4DefGraphicsAdapt(pSourceGfx), (C4DefGraphics *)NULL));
	pComp->Separator();
	// read mode
	pComp->Value(mkIntAdapt(eMode)); pComp->Separator();
	// read action (identifier)
	pComp->Value(mkStringAdaptMIE(Action)); pComp->Separator();
	// read blit mode
	pComp->Value(dwBlitMode); pComp->Separator();
	// read phase
	pComp->Value(iPhase); pComp->Separator();
	// read transform
	pComp->Separator(StdCompiler::SEP_START);
	pComp->Value(Transform);
	pComp->Separator(StdCompiler::SEP_END);
	// read color-modulation
	if (pComp->Separator())
		pComp->Value(mkIntAdapt(dwClrModulation));
	else
		// default
		if (pComp->isCompiler()) dwClrModulation = 0xffffff;
	// read overlay target object
	if (pComp->Separator())
		pComp->Value(OverlayObj);
	else
		// default
		if (pComp->isCompiler()) OverlayObj = NULL;
	// update used facet according to read data
	if (pComp->isCompiler()) UpdateFacet();
}
Beispiel #5
0
void C4Network2Address::CompileFunc(StdCompiler *pComp)
{
	// Clear
	if (pComp->isCompiler())
	{
		ZeroMem(&addr, sizeof(addr));
		addr.sin_family = AF_INET;
	}

	// Write protocol
	StdEnumEntry<C4Network2IOProtocol> Protocols[] =
	{
		{ "UDP", P_UDP },
		{ "TCP", P_TCP },

		{ NULL,  P_NONE },
	};
	pComp->Value(mkEnumAdaptT<uint8_t>(eProtocol, Protocols));
	pComp->Separator(StdCompiler::SEP_PART2); // ':'

	// Write IP (no IP = 0.0.0.0)
	in_addr zero; zero.s_addr = INADDR_ANY;
	pComp->Value(mkDefaultAdapt(addr.sin_addr, zero));
	pComp->Separator(StdCompiler::SEP_PART2); // ':'

	// Write port
	uint16_t iPort = htons(addr.sin_port);
	pComp->Value(iPort);
	addr.sin_port = htons(iPort);
}
Beispiel #6
0
void C4ValueMapData::CompileFunc(StdCompiler *pComp, C4ValueNumbers * numbers)
{
	bool deserializing = pComp->isDeserializer();
	C4ValueMapNames *pOldNames = pNames;
	if (deserializing) Reset();
	// Compile item count
	int32_t iValueCnt;
	if (!deserializing) iValueCnt = pNames ? pNames->iSize : 0;
	pComp->Value(mkDefaultAdapt(iValueCnt, 0));
	// nuthing 2do for no items
	if (!iValueCnt) return;
	// Separator (';')
	pComp->Separator(StdCompiler::SEP_SEP2);
	// Data
	char **ppNames = !deserializing ? pNames->pNames : new char * [iValueCnt];
	if (deserializing) for (int32_t i = 0; i < iValueCnt; i++) ppNames[i] = nullptr;
	C4Value *pValues = !deserializing ? pData : new C4Value [iValueCnt];
	// Compile
	try
	{
		for (int32_t i = 0; i < iValueCnt; i++)
		{
			// Separate
			if (i) pComp->Separator();
			// Name
			StdStrBuf Name;
			if (!deserializing) Name.Ref(ppNames[i]);
			pComp->Value(mkParAdapt(Name, StdCompiler::RCT_Idtf));
			if (deserializing) ppNames[i] = Name.GrabPointer();
			// Separator ('=')
			pComp->Separator(StdCompiler::SEP_SET);
			// Value
			pComp->Value(mkParAdapt(pValues[i], numbers));
		}
	}
	catch (...)
	{
		// make sure no mem is leaked on compiler error in name list
		if (deserializing)
		{
			for (int32_t i = 0; i < iValueCnt; i++) if (ppNames[i]) free(ppNames[i]);
			delete [] ppNames;
			delete [] pValues;
		}
		throw;
	}
	// Set
	if (deserializing)
	{
		// Set
		CreateTempNameList();
		pNames->SetNameArray(const_cast<const char **>(ppNames), iValueCnt);
		for (int32_t i = 0; i < iValueCnt; i++) free(ppNames[i]);
		delete [] ppNames; delete [] pData;
		pData = pValues;
		// Assign old name list
		if (pOldNames) SetNameList(pOldNames);
	}
}
void C4NameList::CompileFunc(StdCompiler *pComp, bool fValues)
{
	bool fCompiler = pComp->isCompiler();
	for (int32_t cnt=0; cnt<C4MaxNameList; cnt++)
		if (fCompiler || Name[cnt][0])
		{
			if (cnt) pComp->Separator(StdCompiler::SEP_SEP2);
			// Name
			pComp->Value(mkDefaultAdapt(mkStringAdapt(Name[cnt], C4MaxName, StdCompiler::RCT_Idtf), ""));
			// Value
			if (fValues)
			{
				pComp->Separator(StdCompiler::SEP_SET);
				pComp->Value(mkDefaultAdapt(Count[cnt], 0));
			}
		}
}
void C4DefGraphicsAdapt::CompileFunc(StdCompiler *pComp)
{
	bool fCompiler = pComp->isCompiler();
	// nothing?
	if (!fCompiler && !pDefGraphics) return;
	// definition
	C4ID id; if (!fCompiler) id = pDefGraphics->pDef->id;
	pComp->Value(id);
	// go over two separators ("::"). Expect them if an id was found.
	if (!pComp->Separator(StdCompiler::SEP_PART2) || !pComp->Separator(StdCompiler::SEP_PART2))
		pComp->excCorrupt("DefGraphics: expected \"::\"");
	// compile name
	StdStrBuf Name; if (!fCompiler) Name = pDefGraphics->GetName();
	pComp->Value(mkDefaultAdapt(mkParAdapt(Name, StdCompiler::RCT_Idtf), ""));
	// reading: search def-graphics
	if (fCompiler)
	{
		// search definition, throw expection if not found
		C4Def *pDef = ::Definitions.ID2Def(id);
		// search def-graphics
		if (!pDef || !( pDefGraphics = pDef->Graphics.Get(Name.getData()) ))
			pComp->excCorrupt("DefGraphics: could not find graphics \"%s\" in %s(%s)!", Name.getData(), id.ToString(), pDef ? pDef->GetName() : "def not found");
	}
}
Beispiel #9
0
void C4IDList::CompileFunc(StdCompiler *pComp, bool fValues)
{
	// Get compiler characteristics
	bool deserializing = pComp->isDeserializer();
	bool fNaming = pComp->hasNaming();
	// Compiling: Clear existing data first
	if (deserializing) Clear();
	// Start
	C4IDListChunk *pChunk = this;
	size_t iNr = 0, iCNr = 0;
	// Without naming: Compile Count
	int32_t iCount = Count;
	if (!fNaming) pComp->Value(iCount);
	Count = iCount;
	// Read
	for (;;)
	{
		// Prepare compiling of single mapping
		if (!deserializing)
		{
			// End of list?
			if (iNr >= Count) break;
			// End of chunk?
			if (iCNr >= C4IDListChunkSize)
			{
				pChunk = pChunk->pNext;
				iCNr = 0;
			}
		}
		else
		{
			// End of list?
			if (!fNaming) if (iNr >= Count) break;
			// End of chunk?
			if (iCNr >= C4IDListChunkSize)
			{
				pChunk = pChunk->pNext = new C4IDListChunk();
				iCNr = 0;
			}
		}
		// Separator (';')
		if (iNr > 0) if (!pComp->Separator(StdCompiler::SEP_SEP2)) break;
		// ID
		pComp->Value(mkDefaultAdapt(pChunk->id[iCNr], C4ID::None));
		// ID not valid? Note that C4ID::None is invalid.
		if (pChunk->id[iCNr] == C4ID::None) break;
		// Value: Skip this part if requested
		if (fValues)
		{
			// Separator ('=')
			if (pComp->Separator(StdCompiler::SEP_SET))
				// Count
				pComp->Value(mkDefaultAdapt(pChunk->Count[iCNr], 0));
		}
		else if (deserializing)
			pChunk->Count[iCNr] = 0;
		// Goto next entry
		iNr++; iCNr++;
		// Save back count
		if (deserializing && fNaming) Count = iNr;
	}
}