Exemple #1
0
SINT    ConvertBinaryData2Ascii(MEMPTR lpMem, SINT DataSize, SINT BufSize)
{
    MEMPTR      intrbuf, Temp;
    HANDLE      intrhandle;
    SINT        AsciiDataSize = 0;

    if (BufSize >= (SINT)(DataSize/4*5 + sizeof(ASCII85DecodeBegine)+sizeof(ASCII85DecodeEnd) + 2048))
    {
        if ((intrhandle = GlobalAlloc(GHND, BufSize)) != NULL)
        {
            if ((intrbuf = (MEMPTR) GlobalLock(intrhandle)) != NULL)
            {
                Temp = intrbuf;
                Temp += WriteObject(Temp,  NewLine);
                Temp += WriteObject(Temp,  ASCII85DecodeBegine);
                Temp += WriteObject(Temp,  NewLine);
                Temp += WriteASCII85Cont(Temp, BufSize, lpMem, DataSize);
                Temp += WriteObject(Temp,  ASCII85DecodeEnd);
                AsciiDataSize = (SINT)(Temp - intrbuf);
                lstrcpyn(lpMem, intrbuf, (WORD)AsciiDataSize); 
                GlobalUnlock(intrhandle);
            }
        }
        GlobalFree(intrhandle);
   }
   return (AsciiDataSize);
}
Exemple #2
0
    void DiMotionSerializerImpl::WriteBones( const DiSkeleton* pSkeleton )
    {
        WriteChunkHeader(DI_BONES,CalcBonesSize(pSkeleton));

        uint16 numBones = (uint16)pSkeleton->GetNumBones();
        WriteShorts(&numBones,1);

        for (size_t i = 0; i < numBones; ++i)
        {
            const DiBone* pBone = pSkeleton->GetBone(i);

            // name
            WriteString(pBone->GetName());

            // handle
            uint16 handle = (uint16)pBone->GetHandle();
            WriteShorts(&handle,1);

            // position
            WriteObject(pBone->GetPosition());

            // orientation
            WriteObject(pBone->GetOrientation());

            // �Ƿ���scale
            bool hasscale = pBone->GetScale() != DiVec3::UNIT_SCALE;
            WriteBools(&hasscale,1);

            if (hasscale)
            {
                // scale
                WriteObject(pBone->GetScale());
            }
        }
    }
Exemple #3
0
void	PingReply(Host Session_SN, ushort Reply2ID)
{
    uchar		Request[0xFF];
    ushort		TransID;
    uchar		*PRequest, *Mark;
    uint		Size, SizeSz;
    ObjectDesc	ObjNbr;

    PRequest = Request;

    ZeroMemory(Request, 0xFF);
    TransID = BytesRandomWord();
    if (0xFFFF - TransID < 0x1000)
        TransID -= 0x1000;

    *(unsigned short *)PRequest = htons(TransID);
    PRequest += 2;

    Mark = PRequest;
    WriteValue(&PRequest, 0x0A);
    WriteValue(&PRequest, 0x293);
    *(unsigned short *)PRequest = htons(Reply2ID);
    PRequest += 2;

    *PRequest++ = RAW_PARAMS;
    WriteValue(&PRequest, 0x02);

    ObjNbr.Family = OBJ_FAMILY_NBR;
    ObjNbr.Id = 0x01;
    ObjNbr.Value.Nbr = 0x02;
    WriteObject(&PRequest, ObjNbr);

    ObjNbr.Family = OBJ_FAMILY_NBR;
    ObjNbr.Id = 0x08;
    ObjNbr.Value.Nbr = 0x0A;
    WriteObject(&PRequest, ObjNbr);

    Size = (uint)(PRequest - Request);
    SizeSz = GetWrittenSz(Size << 1);

    PRequest = Request;
    memmove_s(Request + SizeSz, 0xFF, Request, 0xFF - SizeSz);
    WriteValue(&PRequest , Size << 1);

    Size += SizeSz;

    CipherTCP(&(Keys.SendStream), Request, 3);
    CipherTCP(&(Keys.SendStream), Request + 3, Size - 3);

    printf("Sending Ping Response..\n");

    NoWait = 1;
    SendPacketTCP(Session_SN.socket, Session_SN, Request, Size, HTTPS_PORT, &(Session_SN.Connected));
}
Exemple #4
0
void CObjectOStream::WriteSeparateObject(const CConstObjectInfo& object)
{
    if ( m_Objects ) {
        size_t firstObject = m_Objects->GetObjectCount();
        WriteObject(object);
        size_t lastObject = m_Objects->GetObjectCount();
        m_Objects->ForgetObjects(firstObject, lastObject);
    }
    else {
        WriteObject(object);
    }
}
Exemple #5
0
void AnnotWriter::UpdateBePDFAcroForm() {
	if (mWrittenFonts.empty()) return;

	Object acroForm;
	Object oldDR;

	acroForm.initDict(mXRef);
	oldDR.initNull();

	if (is_empty_ref(mBePDFAcroForm->GetRef())) {
		Ref fieldsRef = mXRefTable.GetNewRef(xrefEntryUncompressed);
		// create empty array for fields
		Object fields;
		fields.initArray(mXRef);
		WriteObject(fieldsRef, &fields);
		fields.free();

		// create new BePDFAcroForm
		mBePDFAcroFormRef = mXRefTable.GetNewRef(xrefEntryUncompressed);
		AddName(&acroForm, "Type", "BePDFAcroForm");
		AddRef(&acroForm, "Fields", fieldsRef);
	} else {
		// copy existing BePDFAcroForm except DR
		mBePDFAcroFormRef = mBePDFAcroForm->GetRef();
		Object ref;
		Object oldForm;
		ref.initRef(mBePDFAcroFormRef.num, mBePDFAcroFormRef.gen);
		ref.fetch(mXRef, &oldForm);
		CopyDict(&oldForm, &acroForm, acroFormExcludeKeys);
		oldForm.dictLookup("DR", &oldDR);
		oldForm.free();
		ref.free();
	}
	// Add DR to BePDFAcroForm
	Object dr;
	dr.initDict(mXRef);
	if (oldDR.isDict()) {
		CopyDict(&oldDR, &dr, drExcludeKeys);
		oldDR.free();
	}
	// Add font dict
	Object font;
	font.initDict(mXRef);
	// add old fonts
	AddFonts(&font, mBePDFAcroForm->GetFonts());
	// add new fonts
	AddFonts(&font, &mWrittenFonts);
	AddDict(&dr, "Font", &font);
	AddDict(&acroForm, "DR", &dr);
	WriteObject(mBePDFAcroFormRef, &acroForm);
	acroForm.free();
}
Exemple #6
0
void WriteObject(VM* vm, Object* top)
{
	if(top->type == OBJ_NUMBER)
		printf("%g", top->number);
	else if(top->type == OBJ_STRING)
		printf("%s", top->string);
	else if(top->type == OBJ_NATIVE)
		printf("native pointer");
	else if(top->type == OBJ_FUNC)
	{
		if(top->func.isExtern)
			printf("extern %s", vm->externNames[top->func.index]);
		else
			printf("func %s", vm->functionNames[top->func.index]);
	}
	else if(top->type == OBJ_ARRAY)
	{
		printf("[");
		for(int i = 0; i < top->array.length; ++i)
		{	
			WriteObject(vm, top->array.members[i]);
			if(i + 1 < top->array.length)
				printf(",");
		}
		printf("]");
	}
	else if(top->type == OBJ_DICT)
	{
		printf("{ ");
		for(int i = 0; i < top->dict.active.length; ++i)
		{
			DictNode* node = top->dict.buckets[top->dict.active.data[i]];
			
			while(node)
			{
				printf("%s = ", node->key);
				WriteObject(vm, node->value);
				
				if(node->next || (i + 1 < top->dict.active.length))
					printf(", ");
				node = node->next;
			}
		}
		printf(" }");
	}
	else if(top->type == OBJ_NULL)
		printf("null");
}
// ****************************************************************************
// Method: ColorTableManager::WriteConfigFile
//
// Purpose: 
//   Writes a the color table to a file.
//
// Arguments:
//   filename : The name of the file to write.
//
// Programmer: Brad Whitlock
// Creation:   Thu Jul 3 18:27:28 PST 2003
//
// Modifications:
//   Brad Whitlock, Thu Nov 13 11:55:17 PDT 2003
//   I made it throw a VisItException if the file can't be opened.
//
//   Brad Whitlock, Thu Dec 18 11:18:06 PDT 2003
//   I made it call CreateNode with the new completeSave flag set to false.
//
//   Brad Whitlock, Thu Feb 17 15:55:29 PST 2005
//   I removed the exception and made the function return a bool.
//
//   Kathleen Biagas, Fri Aug 8 08:34:29 PDT 2014
//   Set default category name to 'UserDefined'.
//
// ****************************************************************************
bool
ColorTableManager::WriteConfigFile(std::ostream& out)
{
    DataNode topLevel("topLevel");
    // Create the color table node.
    DataNode *ctNode = new DataNode("ColorTable");
    topLevel.AddNode(ctNode);
    ctNode->AddNode(new DataNode("Version", std::string(VISIT_VERSION)));

    // Let the color table create and add its information to the node.
    ccpl.CreateNode(ctNode, false, true);
    // This is an export, set the categoryName to UserDefined, adding the node
    // if necessary.
    if (ctNode->GetNode("ColorControlPointList")->GetNode("category"))
    {
        // if the category is Standard 
        std::string category = 
            ctNode->GetNode("ColorControlPointList")->GetNode("category")->AsString();
        if (category == std::string("Standard"))
        {
            ctNode->GetNode("ColorControlPointList")->GetNode("category")->SetString("UserDefined");
        }
    }
    else
    {
        ctNode->GetNode("ColorControlPointList")->AddNode(new DataNode("category",std::string("UserDefined")));
    }

    // Write the output file.
    out << "<?xml version=\"1.0\"?>\n";
    WriteObject(out, ctNode);

    return true;
}
Exemple #8
0
/**
	Save the complete script state.
**/
void Script::SaveText(const char* filename)
{
	// Open the text file to write the script state to.
	FILE* file = fopen(filename, "wt");

	// For safety, just in case we leave something behind on the script stack.
	AutoBlock block(*this);

	// Run through all the globals.
	int i;
	Object table = GetGlobals();
	PushNil();
	while ((i = Next(table.GetStackIndex())) != 0)
	{
		// Retrieve the global's key and value.
		Object key = GetObject(GetTop() - 1);
		Object value = GetObject(GetTop());

		// Save the global to the text file.
		if (strcmp(key.GetString(), "_VERSION") != 0)
		{
			WriteObject(*this, file, key.GetString(), value, 0);
		}

		// Go to the next global.
		Pop();
	}

	// Close the text file.
	fclose(file);
}
bool
VLIFileManager::WriteConfigFile(const char *filename)
{
    DataNode topLevel("topLevel");

    // Create the color table node.
    DataNode *ctNode = new DataNode("VLIFile");
    topLevel.AddNode(ctNode);
    ctNode->AddNode(new DataNode("Version", std::string(VISIT_VERSION)));

    // Let the vli file manager create and add its information to the node.
    ctNode->AddNode(Export());

    // Try to open the output file.
    if((fp = fopen(filename, "wb")) == 0)
    {
        return false;
    }

    // Write the output file.
    fprintf(fp, "<?xml version=\"1.0\"?>\n");
    WriteObject(ctNode);

    // Close the file
    fclose(fp);
    fp = 0;

    return true;
}
bool
SingleAttributeConfigManager::WriteConfigFile(const char *filename)
{
    // We need to start with a top-level container data node, but that's
    // not what we wind up saving; get the actual one from inside it.
    DataNode topLevel("topLevel");
    attribute->CreateNode(&topLevel, completeSave, true);
    DataNode *actualNode = topLevel.GetNode(attribute->TypeName());
    if (!actualNode)
        return false;

    // Try to open the output file.
    if((fp = fopen(filename, "wb")) == 0)
    {
        return false;
    }

    // Write the output file.
    fprintf(fp, "<?xml version=\"1.0\"?>\n");
    WriteObject(actualNode);

    // Close the file
    fclose(fp);
    fp = 0;

    return true;
}
static ZS_status_t
io()
{
	ZS_status_t ret;

	uint32_t wr_flags = 0;
	uint32_t i = 0;

	char key[256] = {'\0'};
	char value[256] = {'\0'};

	char *data = NULL;
	uint64_t len = 0;

	fprintf(fp,"****** io started ******\n");

	fprintf(fp,"****** Writing objects *******\n");
	for (i = 0; i < MAX_ITERATION; i++) {
		snprintf(key, 255, "%s_%d", "key", i);
		snprintf(value, 255, "%s_%d", "value", i);
		if(ZS_SUCCESS == (ret = WriteObject(cguid, key, value, wr_flags)))
		{
			fprintf(fp,"write sucessful: key%s\n", key);
		} else {
			fprintf(fp,"write failed: key=%s error=%s\n", key, ZSStrError(ret));
			goto exit_io;
		}

		/*
		 * Flush few object
		 */
		if (0 == (i % 2)) {
			if(ZS_SUCCESS == (ret = FlushObject(cguid, key)))
			{
				fprintf(fp,"flush sucessful: key%s\n", key);
			} else {
				fprintf(fp,"flush failed: key=%s error=%s\n", key, ZSStrError(ret));
				goto exit_io;
			}
		}
	}

	/*
	 * Issue read
	 */
	fprintf(fp,"****** Reading objects *******\n");

	for (i = 0; i < MAX_ITERATION; i++) {
		snprintf(key, 255, "%s_%d", "key", i);
		if(ZS_SUCCESS == (ret = ReadObject(cguid, key, &data, &len)))
		{
			fprintf(fp,"read successful: key=%s data=%s\n", key, data);
		} else {
			fprintf(fp,"read failed: read key= %s error=%s\n", key, ZSStrError(ret));
			goto exit_io;
		}
	}
exit_io:
	return ret;
}
Exemple #12
0
void CObjectOStream::WriteContainer(const CContainerTypeInfo* cType,
                                    TConstObjectPtr containerPtr)
{
    BEGIN_OBJECT_FRAME2(eFrameArray, cType);
    BeginContainer(cType);
        
    CContainerTypeInfo::CConstIterator i;
    if ( cType->InitIterator(i, containerPtr) ) {
        TTypeInfo elementType = cType->GetElementType();
        BEGIN_OBJECT_FRAME2(eFrameArrayElement, elementType);

        do {
            BeginContainerElement(elementType);
            
            WriteObject(cType->GetElementPtr(i), elementType);
            
            EndContainerElement();
        } while ( cType->NextElement(i) );

        END_OBJECT_FRAME();
    }

    EndContainer();
    END_OBJECT_FRAME();
}
void cTWUtil::WriteConfigText(const TCHAR*                 filename,
                              const TSTRING                configText,
                              bool                         bEncrypt,
                              const cElGamalSigPrivateKey* pPrivateKey)
{
    cSerializableNString nstring;

    nstring.mString = CONFIG_FILE_MAGIC_8BYTE;

    std::string ns;
    cStringUtil::Convert(ns, configText);
    nstring.mString += ns;

    cFileHeader fileHeader;
    fileHeader.SetID(cConfigFile::GetFileHeaderID());

    fileHeader.SetVersion(CURRENT_FIXED_VERSION);

    if (bEncrypt)
    {
        ASSERT(pPrivateKey != 0);
        cElGamalSigPublicKey publicKey(*pPrivateKey);
        fileHeader.GetBaggage().MapArchive(0, publicKey.GetWriteLen());
        publicKey.Write(fileHeader.GetBaggage().GetMap());
    }

    WriteObject(filename, NULL, nstring, fileHeader, bEncrypt, pPrivateKey);

    iUserNotify::GetInstance()->Notify(iUserNotify::V_NORMAL,
                                       _T("%s%s\n"),
                                       TSS_GetString(cTW, tw::STR_WRITE_CONFIG_FILE).c_str(),
                                       cDisplayEncoder::EncodeInline(filename).c_str());
}
///////////////////////////////////////////////////////////////////////////////
// WriteDatabase
///////////////////////////////////////////////////////////////////////////////
void cTWUtil::WriteDatabase(const TCHAR*                 filename,
                            cFCODatabaseFile&            db,
                            bool                         bEncrypt,
                            const cElGamalSigPrivateKey* pPrivateKey)
{
    cFileHeader fileHeader;
    fileHeader.SetID(db.GetFileHeaderID());

    // I am almost positive that this does nothing, WriteObject() sets the version in the cFileHeader - Jun 8, 1999 - dmb
    //fileHeader.SetVersion(1);

#ifdef TW_PROFILE
    cTaskTimer timer(_T("Write Database"));
    timer.Start();
#endif

    WriteObject(filename, 0, db, fileHeader, bEncrypt, pPrivateKey);

#ifdef TW_PROFILE
    timer.Stop();
#endif

    iUserNotify::GetInstance()->Notify(iUserNotify::V_NORMAL,
                                       _T("%s%s\n"),
                                       TSS_GetString(cTW, tw::STR_WRITE_DB_FILE).c_str(),
                                       cDisplayEncoder::EncodeInline(filename).c_str());
}
Exemple #15
0
	void SerializeImpl(T&& t, const char* key)
	{
		m_jsutil.StartObject();
		m_jsutil.WriteValue(key);
		WriteObject(std::forward<T>(t));
		m_jsutil.EndObject();
	}
Exemple #16
0
void CObjectOStream::WriteOther(TConstObjectPtr object,
                                TTypeInfo typeInfo)
{
    WriteOtherBegin(typeInfo);
    WriteObject(object, typeInfo);
    WriteOtherEnd(typeInfo);
}
Exemple #17
0
void EditorConfig::SetInteger(const wxString& name, long value)
{
    SimpleLongValue data;
    data.SetValue(value);
    WriteObject(name, &data);
    m_cacheLongValues[name] = value;
}
Exemple #18
0
void EditorConfig::SetString(const wxString& key, const wxString& value)
{
    SimpleStringValue data;
    data.SetValue(value);
    WriteObject(key, &data);
    // update the cache
    m_cacheStringValues[key] = value;
}
Exemple #19
0
void CObjectOStream::WriteContainerElement(const CConstObjectInfo& element)
{
    BeginContainerElement(element.GetTypeInfo());

    WriteObject(element);

    EndContainerElement();
}
Exemple #20
0
void CObjectOStream::WriteExternalObject(TConstObjectPtr objectPtr,
                                         TTypeInfo typeInfo)
{
    _TRACE("CObjectOStream::WriteExternalObject(" <<
           NStr::PtrToString(objectPtr) << ", "
           << typeInfo->GetName() << ')');
    RegisterObject(objectPtr, typeInfo);
    WriteObject(objectPtr, typeInfo);
}
Exemple #21
0
void AnnotWriter::WriteModDate(Ref ref) {
	GString* date = new GString();
	AnnotUtils::CurrentDate(date);

	Object obj;
	obj.initString(date);
	WriteObject(ref, &obj);
	obj.free(); // frees date
}
// ****************************************************************************
// Method: AccessViewerSession::WriteConfigFile
//
// Purpose: 
//   Writes the modified data tree to a session file.
//
// Arguments:
//   filename : The name of the file to write.
//
// Programmer: Brad Whitlock
// Creation:   Mon Nov 13 15:45:25 PST 2006
//
// Modifications:
//   
// ****************************************************************************
bool
AccessViewerSession::WriteConfigFile(std::ostream& out)
{
    // Write the output file to stdout for now.
    out << "<?xml version=\"1.0\"?>\n";
    WriteObject(out, GetRootNode());

    return true;
}
void
ConfigManager::WriteObject(std::ostream& out, DataNode *node, int indentLevel)
{
    // Write the beginning tag.
    WriteIndent(out, indentLevel);
    if(node->GetNodeType() == INTERNAL_NODE)
        out << "<Object name=\"" << node->GetKey().c_str() << "\">\n";
    else
    {
        // Write out the field tag based on the node type.
        switch(node->GetNodeType())
        {
        case CHAR_ARRAY_NODE:
        case UNSIGNED_CHAR_ARRAY_NODE:
        case INT_ARRAY_NODE:
        case LONG_ARRAY_NODE:
        case FLOAT_ARRAY_NODE:
        case DOUBLE_ARRAY_NODE:
        case STRING_ARRAY_NODE:
        case BOOL_ARRAY_NODE:
            out << "<Field name=\"" << node->GetKey().c_str()
                                   << "\" type=\"" << NodeTypeName(node->GetNodeType())
                                   << "\" length=\"" << node->GetLength() << "\">";
            break;
        default:
            out << "<Field name=\""<< node->GetKey().c_str()
                << "\" type=\"" << NodeTypeName(node->GetNodeType()) << "\">";
        }
    }

    // Write the children of the node if there are any.
    if(node->GetNodeType() == INTERNAL_NODE)
    {
        if(node->GetNumChildren() > 0)
        {
            DataNode **children = node->GetChildren();
            for(int i = 0; i < node->GetNumChildren(); ++i)
                WriteObject(out, children[i], indentLevel + 1);
        }
    }
    else
    {
        // We have to write actual values.
        WriteData(out, node);
    }

    // Write the ending tag.
    if(node->GetNodeType() == INTERNAL_NODE)
    {
        WriteIndent(out, indentLevel);
        out << "</Object>\n";
    }
    else
    {
        out << "</Field>\n";
    }
}
Exemple #24
0
	inline void WriteArray(Array& v)
	{
		m_jsutil.StartArray();
		for (auto i : v)
		{
			WriteObject(i);
		}
		m_jsutil.EndArray();
	}
Exemple #25
0
int  CXMLObject::WriteObject ( cpstr FName, int pos, int indent )  {
CFile f;
  f.assign ( FName,True );
  if (f.rewrite())  {
    WriteObject ( f,pos,indent );
    f.shut();
    return 0;
  }
  return 1;
}
int test_basic_check_1(uint32_t aw)
{
    ZS_status_t ret;
    int tag = 0;
    testname[3] = "#test3:basic check for flush object.";
    fprintf(fp,"****** async write = %d ******\n",aw);
    fprintf(fp,"%s\n",testname[3]);

    for(int i = 0; i < 3; i++)
    {
        ret = OpenContainer("test3", 1, aw, i);
        if(ZS_SUCCESS == ret)
        {
            if(ZS_SUCCESS == WriteObject(cguid, "xxx", 4, "sadf", 5, 1))
            {
                ret = FlushObject(cguid, "xxx", 4);
                if(ZS_SUCCESS == ret)
                {
                    result[aw][3][i] += 1;
                }
                if(ZS_SUCCESS == WriteObject(cguid, "xxx", 4, "yyy", 4, 2))
                {
                    ret = FlushObject(cguid, "xxx", 4);
                    if(ZS_SUCCESS == ret)
                    {
                        result[aw][3][i] += 1;
                    }
                }
                (void)DeleteObject(cguid, "xxx", 4);
            }
            (void)CloseContainer(cguid);
            (void)DeleteContainer(cguid);
        }
        if(2 == result[aw][3][i])
        {
            result[aw][3][i] = 1;
            tag += 1;
        } else {
            result[aw][3][i] = 0;
        }
    }
    return (3 == tag);
}
Exemple #27
0
void AnnotWriter::WriteObject(Ref ref, Object* obj, GString* stream) {
	mXRefTable.SetOffset(ref, Tell());
	Write(ref); Write(" obj"); WriteCr();
	WriteObject(obj); WriteCr();
	if (stream != NULL) {
		Write("stream"); WriteCr();
		Write(stream);
		Write("endstream"); WriteCr();
	}
	Write("endobj"); WriteCr();
}
void
ConfigManager::WriteBack(DataNode *root)
{
    std::ofstream outf;
    outf.open("WRITEBACK", ios::out | ios::trunc); //"wt"
    // Write the output file to stdout for now.
    outf << "<?xml version=\"1.0\"?>\n";
    WriteObject(outf, root);

    outf.close();
}
Exemple #29
0
void CObjectOStream::WriteClassMember(const CMemberId& memberId,
                                      TTypeInfo memberType,
                                      TConstObjectPtr memberPtr)
{
    BEGIN_OBJECT_FRAME2(eFrameClassMember, memberId);
    BeginClassMember(memberId);

    WriteObject(memberPtr, memberType);

    EndClassMember();
    END_OBJECT_FRAME();
}
Exemple #30
0
bool SQFunctionProto::Save(SQVM *v,SQUserPointer up,SQWRITEFUNC write)
{
	SQInteger i,nsize=_literals.size();
	_CHECK_IO(WriteTag(v,write,up,SQ_CLOSURESTREAM_PART));
	_CHECK_IO(WriteObject(v,up,write,_sourcename));
	_CHECK_IO(WriteObject(v,up,write,_name));
	_CHECK_IO(WriteTag(v,write,up,SQ_CLOSURESTREAM_PART));
	_CHECK_IO(SafeWrite(v,write,up,&nsize,sizeof(nsize)));
	for(i=0;i<nsize;i++){
		_CHECK_IO(WriteObject(v,up,write,_literals[i]));
	}
	_CHECK_IO(WriteTag(v,write,up,SQ_CLOSURESTREAM_PART));
	nsize=_parameters.size();
	_CHECK_IO(SafeWrite(v,write,up,&nsize,sizeof(nsize)));
	for(i=0;i<nsize;i++){
		_CHECK_IO(WriteObject(v,up,write,_parameters[i]));
	}
	_CHECK_IO(WriteTag(v,write,up,SQ_CLOSURESTREAM_PART));
	nsize=_outervalues.size();
	_CHECK_IO(SafeWrite(v,write,up,&nsize,sizeof(nsize)));
	for(i=0;i<nsize;i++){
		_CHECK_IO(SafeWrite(v,write,up,&_outervalues[i]._type,sizeof(SQUnsignedInteger)));
		_CHECK_IO(WriteObject(v,up,write,_outervalues[i]._src));
		_CHECK_IO(WriteObject(v,up,write,_outervalues[i]._name));
	}
	_CHECK_IO(WriteTag(v,write,up,SQ_CLOSURESTREAM_PART));
	nsize=_localvarinfos.size();
	_CHECK_IO(SafeWrite(v,write,up,&nsize,sizeof(nsize)));
	for(i=0;i<nsize;i++){
		SQLocalVarInfo &lvi=_localvarinfos[i];
		_CHECK_IO(WriteObject(v,up,write,lvi._name));
		_CHECK_IO(SafeWrite(v,write,up,&lvi._pos,sizeof(SQUnsignedInteger)));
		_CHECK_IO(SafeWrite(v,write,up,&lvi._start_op,sizeof(SQUnsignedInteger)));
		_CHECK_IO(SafeWrite(v,write,up,&lvi._end_op,sizeof(SQUnsignedInteger)));
	}
	_CHECK_IO(WriteTag(v,write,up,SQ_CLOSURESTREAM_PART));
	nsize=_lineinfos.size();
	_CHECK_IO(SafeWrite(v,write,up,&nsize,sizeof(nsize)));
	_CHECK_IO(SafeWrite(v,write,up,&_lineinfos[0],sizeof(SQLineInfo)*nsize));
	_CHECK_IO(WriteTag(v,write,up,SQ_CLOSURESTREAM_PART));
	nsize=_instructions.size();
	_CHECK_IO(SafeWrite(v,write,up,&nsize,sizeof(nsize)));
	_CHECK_IO(SafeWrite(v,write,up,&_instructions[0],sizeof(SQInstruction)*nsize));
	_CHECK_IO(WriteTag(v,write,up,SQ_CLOSURESTREAM_PART));
	nsize=_functions.size();
	_CHECK_IO(SafeWrite(v,write,up,&nsize,sizeof(nsize)));
	for(i=0;i<nsize;i++){
		_CHECK_IO(_funcproto(_functions[i])->Save(v,up,write));
	}
	_CHECK_IO(SafeWrite(v,write,up,&_stacksize,sizeof(_stacksize)));
	_CHECK_IO(SafeWrite(v,write,up,&_bgenerator,sizeof(_bgenerator)));
	_CHECK_IO(SafeWrite(v,write,up,&_varparams,sizeof(_varparams)));
	return true;
}