void StructEncoder::EncodeStructFieldToBuf(const Field& field,
	const LuaRef& luaTable, uint8_t* pBuf)
{
	assert(pBuf);
	const char* pFieldName = field.name()->c_str();
	const LuaRef luaValue = luaTable.get(pFieldName);
	if (!luaValue)
		ERR_RET("missing struct field " + PopFullName());

	const reflection::Type& type = *field.type();
	uint16_t offset = field.offset();
	uint8_t* pDest = pBuf + offset;
	if (IsEnumType(type))
		return EncodeEnumToBuf(type, luaValue, pDest);

	reflection::BaseType eBaseType = type.base_type();
	if (eBaseType <= reflection::Double)
	{
		EncodeScalarToBuf(eBaseType, luaValue, pDest);
		return;
	}

	assert(eBaseType == reflection::Obj);
	const Object* pFieldObj = Objects()[type.index()];
	assert(pFieldObj);
	assert(pFieldObj->is_struct());
	EncodeStructToBuf(*pFieldObj, luaValue, pDest);
}  // EncodeStructFieldToBuf()