示例#1
0
/*
================
idThread::Event_GetTraceJoint
================
*/
void idThread::Event_GetTraceJoint( void ) {
	if ( trace.fraction < 1.0f && trace.c.id < 0 ) {
		idAFEntity_Base *af = static_cast<idAFEntity_Base *>( gameLocal.entities[ trace.c.entityNum ] );
		if ( af && af->IsType( idAFEntity_Base::Type ) && af->IsActiveAF() ) {
			ReturnString( af->GetAnimator()->GetJointName( CLIPMODEL_ID_TO_JOINT_HANDLE( trace.c.id ) ) );
			return;
		}
	}
	ReturnString( "" );
}
示例#2
0
/*
================
idThread::Event_GetTraceBody
================
*/
void idThread::Event_GetTraceBody( void ) {
	if ( trace.fraction < 1.0f && trace.c.id < 0 ) {
		idAFEntity_Base *af = static_cast<idAFEntity_Base *>( gameLocal.entities[ trace.c.entityNum ] );
		if ( af && af->IsType( idAFEntity_Base::Type ) && af->IsActiveAF() ) {
			int bodyId = af->BodyForClipModelId( trace.c.id );
			idAFBody *body = af->GetAFPhysics()->GetBody( bodyId );
			if ( body ) {
				ReturnString( body->GetName() );
				return;
			}
		}
	}
	ReturnString( "" );
}
/*
================
idThread::Event_GetPersistantString
================
*/
void idThread::Event_GetPersistantString( const char *key )
{
    const char *result;

    gameLocal.persistentLevelInfo.GetString( key, "", &result );
    ReturnString( result );
}
/*
================
idThread::Event_SpawnString
================
*/
void idThread::Event_SpawnString( const char *key, const char *defaultvalue )
{
    const char *result;

    spawnArgs.GetString( key, defaultvalue, &result );
    ReturnString( result );
}
示例#5
0
extern "C" DLL_EXPORT LPSTR MarshalPointer_InOut(/*[in,out]*/LPSTR *s)
{
    //Check the Input
    size_t len = strlen(*s);

    if((len != lenstrManaged)||(memcmp(*s,strManaged,len)!=0))
    {
        printf("Error in Function MarshalPointer_InOut\n");
        
        for(size_t i = 0; i< lenstrManaged;++i)
            putchar(*(((char *)strManaged)+i));
                
        for( size_t j = 0; j < len; ++j)
            putchar(*(((char *)*s) + j));
        
        return ReturnErrorString();
    }

    //Allocate New
    CoTaskMemFree(*s);
    *s = (LPSTR)CoTaskMemAlloc(sizeof(char)*(lenstrNative+1));
    memset(*s,0,lenstrNative+1);
    strncpy_s(*s,len + 1,strNative,lenstrNative);

    //Return
    return ReturnString();
}
示例#6
0
extern "C" DLL_EXPORT LPSTR MarshalPointer_Out(/*[out]*/ LPSTR *s)
{
    *s = (LPSTR)CoTaskMemAlloc(sizeof(char)*(lenstrNative+1));
    memset(*s,0,lenstrNative+1);
    strncpy_s(*s,lenstrNative+1,strNative,lenstrNative);

    return ReturnString();
}
示例#7
0
BOOL GetLangSaveFolderName( char *fileWithPath, char *filename )
{
    char szPath[256];
	char *szFilter;

    szFilter = "Language Files (*.lang)\0*.lang\0\0";
	PathFromFullPath( fileWithPath, szPath );
 	return GetSaveDialog( fileWithPath, filename, szPath, szFilter, ReturnString(IDS_LANG_SAVEAS), "lang", 1);
}
示例#8
0
extern "C" DLL_EXPORT LPWSTR MarshalPointer_Out(/*[out]*/ LPWSTR *s)
{
	size_t length = lenstrNative+1;
    *s = (LPWSTR)CoTaskMemAlloc(sizeof(WCHAR)*length);
	memset(*s, '\0', length  * sizeof(WCHAR));
    wcsncpy_s(*s,length,strNative,lenstrNative);

    return ReturnString();
}
示例#9
0
extern "C" DLL_EXPORT LPWSTR Marshal_Out(/*[Out]*/LPWSTR s)
{
    s = (LPWSTR)CoTaskMemAlloc(sizeof(WCHAR)*(lenstrNative+1));;
    memset(s,0, sizeof(WCHAR)*(lenstrNative + 1));

    //In-Place Change
    wcsncpy_s(s,lenstrNative+1,strNative,lenstrNative);

    //Return
    return ReturnString();
}
示例#10
0
extern "C" DLL_EXPORT LPSTR Marshal_Out(/*[Out]*/LPSTR s)
{
    s = (LPSTR)(CoTaskMemAlloc(sizeof(char)*(lenstrNative+1)));

    memset(s,0,lenstrNative+1);
    //In-Place Change
    strncpy_s(s,lenstrNative+1,strNative,lenstrNative);

    //Return
    return ReturnString();
}
示例#11
0
	inline long ReturnCustom(VRuntime* pRuntime, const ExpStore& r)
	{
		if (r.Type() == EXPTYPE_STRING)
			ReturnString(pRuntime, (const char*)*(r.eData.str));
		else {
			// Bitwise copy
			eType = r.Type();
			eData.iVal = r.eData.iVal;
		}

		return 0;
	}
示例#12
0
void InitLangList()
{
	char colTitles[LANG_LINE_SIZE];
	char *catStr;
	char lineStr[LANG_LINE_SIZE];
	short i;
	short category = -1;
	changedSomeStrings = 0;
	alreadySaving = 0;

	// If we have already displayed (created) the list,
	// then week need to delete the column headings... this seems to do it...
	if ( hWndLangBuilderListView )
	{
		ListView_DeleteColumn( hWndLangBuilderListView, EDIT_LANGUAGE_LISTVIEW_POS );
		ListView_DeleteColumn( hWndLangBuilderListView, DEFAULT_ENGLISH_LISTVIEW_POS );
		ListView_DeleteColumn( hWndLangBuilderListView, CATEGORY_NAME_LISTVIEW_POS );
	}
	
	// Initialise the Language list, means creating the column titles and adding them,
	// then making sure there is no data in the list
	mystrncpyNull( colTitles, ReturnString( IDS_LANGBUILDER_LISTTITLES ), LANG_LINE_SIZE );
	mystrncatNull( colTitles, MyPrefStruct.language, LANG_LINE_SIZE );
	hWndLangBuilderListView = InitGenericListView( hDlg, IDC_LANGTOKEN_LIST, 0, 0, colTitles );
	ListView_DeleteAllItems( hWndLangBuilderListView );		

	ListView_SetColumnWidth( hWndLangBuilderListView, CATEGORY_NAME_LISTVIEW_POS, 100 );
	ListView_SetColumnWidth( hWndLangBuilderListView, DEFAULT_ENGLISH_LISTVIEW_POS, 200 );
	ListView_SetColumnWidth( hWndLangBuilderListView, EDIT_LANGUAGE_LISTVIEW_POS, 200 );

	// Add the Language strings to the list
	for ( i = SUMM_BEGIN; i < END_OF_STRINGS; i++ )
	{
		catStr = GetLangSectionName(i);
		if ( !catStr )
			continue;
		mystrncpyNull( lineStr, catStr, LANG_LINE_SIZE ); 
		mystrncatNull( lineStr, LANG_LIST_SEP, LANG_LINE_SIZE ); 
		mystrncatNull( lineStr, DefaultEnglishStr(i), LANG_LINE_SIZE ); 
		mystrncatNull( lineStr, LANG_LIST_SEP, LANG_LINE_SIZE ); 
		mystrncatNull( lineStr, TranslateID(i), LANG_LINE_SIZE ); 
		AddItemToListView( hWndLangBuilderListView, ListView_GetItemCount(hWndLangBuilderListView), 3, lineStr, LANG_LIST_SEP );
	}
	ListView_GetItemText( hWndLangBuilderListView, 0, EDIT_LANGUAGE_LISTVIEW_POS, lineStr, LANG_LINE_SIZE );
	SetWindowText( GetDlgItem( hDlg, IDC_LANGTOKEN_TEXT), lineStr );
	SetFocus( GetDlgItem( hDlg, IDC_LANGTOKEN_LIST ) );
	int state = LVIS_SELECTED|LVIS_FOCUSED;
	if ( hWndLangBuilderListView )
		ListView_SetItemState( hWndLangBuilderListView, 0, state, state );
}
示例#13
0
void ErrorOpeningFile( const char *filename )
{
	char errtxt[256];
	char msg[511];

#ifdef DEF_WINDOWS
	GetLastErrorTxt( errtxt );
#else
	mystrcpy( errtxt, strerror(errno) );
#endif

	sprintf( msg, ReturnString( IDS_ERR_CANTOPENLOG ), filename );
	strcat( msg, "\n" );
	strcat( msg, errtxt );
	ErrorMsg( msg );
}
示例#14
0
//Test Method2
extern "C" DLL_EXPORT LPWSTR Marshal_InOut(/*[In,Out]*/LPWSTR s)
{

    //Check the Input
	size_t len = wcslen(s);

    if((len != lenstrManaged)||(wmemcmp(s,(WCHAR*)strManaged,len)!=0))
    {
        printf("Error in Function Marshal_InOut(Native Client)\n");
        return ReturnErrString();
    }

    //In-Place Change
    wcsncpy_s(s,len+1,strNative,lenstrNative);

    //Return
    return ReturnString();
}
示例#15
0
extern "C" DLL_EXPORT LPWSTR MarshalPointer_InOut(/*[in,out]*/LPWSTR *s)
{
    //Check the Input
	size_t len = wcslen(*s);
    if((len != lenstrManaged)||(wmemcmp(*s,(WCHAR*)strManaged,len)!=0))
    {
        printf("Error in Function MarshalPointer_InOut\n");     
        return ReturnErrString();
    }

    //Allocate New
    CoTaskMemFree(*s);

    //Alloc New
	size_t length = lenstrNative + 1;
    *s = (LPWSTR)CoTaskMemAlloc(length * sizeof(WCHAR));
    memset(*s,'\0',length  * sizeof(WCHAR));
    wcsncpy_s(*s,length,strNative,lenstrNative);

    //Return
    return ReturnString();
}
示例#16
0
//Test Method2
extern "C" DLL_EXPORT LPSTR Marshal_InOut(/*[In,Out]*/LPSTR s)
{
    //Check the Input
    size_t len = strlen(s);

    if((len != lenstrManaged)||(memcmp(s,strManaged,len)!=0))
    {
        printf("Error in Function Marshal_InOut(Native Client)\n");        
        
        for(size_t i = 0; i< lenstrManaged;++i)
            putchar(*(((char *)strManaged)+i));               
        
        for(size_t j = 0; j < len; ++j )
            putchar(*(((char *)s) + j));
        return ReturnErrorString();
    }

    //In-Place Change
    strncpy_s(s,len + 1,strNative,lenstrNative);

    //Return
    return ReturnString();
}
int main(int argc, char* argv[]) {

	clock_t start, end;
	start = clock();

	// pattern part
	char *patternFilename = new char[100];
	strcpy(patternFilename, "../datafolder/onlydata.txt");
	int totalCheckNumberLine = CountLines(patternFilename);
	int patternLength;


	// text part
	char *textFilename = new char[100];
	strcpy(textFilename, "../datafolder/longest.txt");
	string Text = ReturnString(patternFilename,0);

	// alphabet part
	string alphabet = "GTAC ";
	int alphabetSize = alphabet.length();

	//alphabet matrix S
	Matrix S;
	std::map<char,Vector> sMap;

	//result Matrix
	std::vector<Matrix> SinglePatternResult;

    for (int j = 0; j <= totalCheckNumberLine ;j++)
    {
    	if(j == 57054) continue;

		string Pattern = ReturnString(patternFilename,j).substr(0,32);
		patternLength = Pattern.length();

		S.setsize(patternLength, alphabetSize);
		S.set(initWithSpecificChar(0.0, patternLength*alphabetSize));
		initWithInputString(Pattern,alphabet,S);
		S=S.transpose();

		sMap.clear();
		sMap = sMapInit(S,alphabet);

		SinglePatternResult.clear();
		SinglePatternResult.push_back(getExactMatchMatrix(Pattern,Text,sMap));

		for (int i = 0;i < errorLimit ;i ++)
		{
			SinglePatternResult.push_back(getNextMatrix(Pattern,Text,sMap,SinglePatternResult[i],i));
		}

	  	Vector outputResult(SinglePatternResult[errorLimit][Pattern.length()-1]);
	  	int posnum = 0;
	  	int *pos = new int[Text.length()];

		for (int i = 0;i < outputResult.getn() ;i ++)
		{
			if (outputResult[i] == 1)
			{
				cout<<"find it @ position " <<' '<< i+1 << " in "<<j<<" sequence!!!"<<endl;
				pos[posnum] = i;
				++ posnum;
			}
		}
		if(posnum == 0 )
			cout<<j<<" sequence!!!"<<endl;
		delete []pos;
	}
  	delete []textFilename;
  	delete []patternFilename;
  	
  	end = clock();

  	// show the clock elipse time
 	std::cout<<"Run time: "<<(double)(end - start) / CLOCKS_PER_SEC<<" s"<<std::endl;
	return 0;
}
示例#18
0
//FlashCS5extension.StartMakeObjectFile(생성할 오브젝트 파일패스, UV 파일패스들)
JSBool StartMakeObjectFile(JSContext *cx, JSObject *obj, unsigned int argc, jsval *argv, jsval *rval) {
    
    clearlog();
    
    *rval = JS_BooleanToValue(JS_FALSE);
    
    if(argc != 3)
        return ReturnString(cx, "error: argument count", rval);
	
	unsigned int filePathLen;
	unsigned short* filePath = JS_ValueToString(cx, argv[0], &filePathLen);
	
	if(filePath == NULL)
        return ReturnString(cx, "error: obj file path", rval);
	
	JSObject* uvObj;
	if(JS_ValueToObject(cx, argv[1], &uvObj) == JS_FALSE)
        return ReturnString(cx, "error: uv file array", rval);
	
	long uvLen = JS_GetArrayLength(cx, uvObj);
	if(uvLen == -1)
        return ReturnString(cx, "error: image file array length", rval);
    
    JSObject* slicePathObj;
    if(JS_ValueToObject(cx, argv[2], &slicePathObj) == JS_FALSE)
        return ReturnString(cx, "error: slicePaht file array", rval);
	
	unsigned int uvPathLen[uvLen];
	unsigned short* uvPath[uvLen];
    
    char* slicePath = GetString(cx, slicePathObj, 0);
	
	int i;
	for(i = 0; i < uvLen; i++) {
		jsval posUV;
		if(JS_GetElement(cx, uvObj, i, &posUV) == JS_FALSE)
			return ReturnString(cx, "error: uv file array element", rval);
		
		uvPath[i] = JS_ValueToString(cx, posUV, &uvPathLen[i]);
		if(uvPath[i] == NULL)
			return ReturnString(cx, "error: uv file array element file path string", rval);
		
		FILE* uvDataFile = OpenFileString(uvPath[i], uvPathLen[i], "r");
        fread(&root_w, sizeof(long), 1, uvDataFile);
        fread(&root_h, sizeof(long), 1, uvDataFile);
		if(uvDataFile) {
			fseek(uvDataFile, 0, SEEK_END);
			long uvDataSize = ftell(uvDataFile);
			fseek(uvDataFile, sizeof(long) + sizeof(long), SEEK_SET);
			int result = sizeof(long) + sizeof(long);
			while(result < uvDataSize)
				result += ReadUVdata(uvDataFile, slicePath);
			fclose(uvDataFile);
		} else {
			return ReturnString(cx, "error: uv data fopen", rval);
		}
	}
    
    free(slicePath);
	
#define BreakStartMakeObjectFile(errorstr) \
fclose(pObjectFile); \
pObjectFile = NULL; \
return ReturnString(cx, errorstr, rval)
    
    if(pObjectFile) {
        fclose(pObjectFile);
        pObjectFile = NULL;
    }
	
	if(pObjectFile == NULL) {
		char* path = StringToAscii(filePath, filePathLen);
		pObjectFile = fopen(path, "w+");
		free(path);
		if(pObjectFile) {
			//fwrite(&imgLen, sizeof(long), 1, pObjectFile);FlashCS5extension.bundle
			for(i = 0; i < uvLen; i++) {
//				FILE* imgFile;
//				path = StringToAscii(imgPath[i], imgPathLen[i]);
//				if(path == NULL) {
//					BreakStartMakeObjectFile("error: image file path");
//				}
//				imgFile = fopen(path, "r");
//				free(path);
//				if(imgFile) {
//					WriteFileToFile(pObjectFile, imgFile);
//                    writelog("success write image");
//					fclose(imgFile);
//				} else {
//					BreakStartMakeObjectFile("error: image file fopen");
//				}
				
				int i;
				fwrite(&uv_data_len, sizeof(unsigned int), 1, pObjectFile);
                writelog("uv data length = %d", uv_data_len);
				for(i = 0; i < uv_data_len; i++) {
					fwrite(&uv_data[i].libID, sizeof(unsigned int), 1, pObjectFile);
                    writelog("libid = %d", uv_data[i].libID);
                    fwrite(&uv_data[i].pathCount, sizeof(int), 1, pObjectFile);
                    writelog("path count = %d", uv_data[i].pathCount);
                    for(int j = 0; j < uv_data[i].pathCount; ++j) {
                        float uv_x = (float)uv_data[i].x[j];
                        float uv_y = (float)uv_data[i].y[j];
                        fwrite(&uv_x, sizeof(float), 1, pObjectFile);
                        fwrite(&uv_y, sizeof(float), 1, pObjectFile);
                        writelog("x = %.3f, y = %.3f", uv_data[i].x[j], uv_data[i].y[j]);
                    }
				}
			}
		} else {
			//return JS_FALSE;
            return ReturnString(cx, "error : fail to make obj file", rval);
		}
	} else {
		//return JS_FALSE;
        return ReturnString(cx, "error : pObjectFile in use", rval);
	}
	
#undef BreakStartMakeObjectFile
	
	*rval = JS_BooleanToValue(JS_TRUE);
	for(int i = 0; i < root_library_name_id_len; i++) {
		writelog("??????????????????????????libname info length = %i data = %s??????????????????????????", strlen(root_library_name_id[i].name), root_library_name_id[i].name);
	}
	
	return JS_TRUE;
}
示例#19
0
//FlashCS5extension.EndMakeObjectFile()
JSBool EndMakeObjectFile(JSContext *cx, JSObject *obj, unsigned int argc, jsval *argv, jsval *rval) {
	for(int i = 0; i < root_library_name_id_len; i++) {
		writelog("??????????????????????????libname info length = %i data = %s??????????????????????????", strlen(root_library_name_id[i].name), root_library_name_id[i].name);
	}
    if(argc != 2)
        return JS_FALSE;
	
	if(pObjectFile) {
		fseek(pObjectFile, 0, SEEK_END);
		long size = ftell(pObjectFile);
		fseek(pObjectFile, 0, SEEK_SET);
		void* allMem = malloc(size);
		fread(allMem, 1, size, pObjectFile);
		
		fseek(pObjectFile, 0, SEEK_SET);
        
		int i;
        //비트맵 이름을 업데이트 한다.
        JSObject* bitmapNameObj;
        if(JS_ValueToObject(cx, argv[0], &bitmapNameObj) == JS_FALSE)
            return ReturnString(cx, "fail to load bitmapNameArray", rval);
        
        int bitmapCount = JS_GetArrayLength(cx, bitmapNameObj);
        if(bitmapCount == -1)
            return ReturnString(cx, "fail to get bitmap Count", rval);
        
        for(i = 0; i < bitmapCount; ++i) {
            JSObject* bitmapObj;
            if(GetObject(cx, bitmapNameObj, i, &bitmapObj) == JS_FALSE)
                return ReturnString(cx, "fail to get bitmap obj", rval);
            
            char* bitmapName = GetString(cx, bitmapObj, 0);
            char* bitmapPath = GetString(cx, bitmapObj, 1);
			writelog("@@@@@@@@@@ %s %s @@@@@@@@@", bitmapPath, bitmapName);
            ChangeLibraryName(bitmapPath, bitmapName);
        }
        
        
        
        double frameRate;
        float frameRatef;
        
        if(JS_ValueToDouble(cx, argv[1], &frameRate) == JS_FALSE)
            return ReturnString(cx, "fail to load bitmapNameArray", rval);
        
        fwrite(&root_w, sizeof(long), 1, pObjectFile);
        fwrite(&root_h, sizeof(long), 1, pObjectFile);
        writelog("uv size = %f, %f", root_w, root_h);
        fwrite(&root_flash_w, sizeof(long), 1, pObjectFile);
        fwrite(&root_flash_h, sizeof(long), 1, pObjectFile);
        writelog("flash size = %f, %f", root_flash_w, root_flash_h);
        
        frameRatef = (float)frameRate;
        fwrite(&frameRatef, sizeof(float), 1, pObjectFile);
        writelog("frameRate = %f", frameRatef);
        
        writelog("=========== lib name layer ============");
        
		unsigned int name_len;
		fwrite(&root_library_name_id_len, sizeof(unsigned int), 1, pObjectFile);
		for(i = 0; i < root_library_name_id_len; i++) {
			name_len = strlen(root_library_name_id[i].name);
			writelog("libname info length = %i data = %s", name_len, root_library_name_id[i].name);
			fwrite(&name_len, sizeof(unsigned int), 1, pObjectFile);
			fwrite(root_library_name_id[i].name, sizeof(char), name_len, pObjectFile);
			fwrite(&root_library_name_id[i].id, sizeof(unsigned int), 1, pObjectFile);
            
            writelog("libname = %s, libid = %d", root_library_name_id[i].name, root_library_name_id[i].id);
		}
		fwrite(allMem, 1, size, pObjectFile);
		free(allMem);
		fclose(pObjectFile);
		pObjectFile = NULL;
		
		FreeLibraryName();
		FreeUVdata();
		
		*rval = JS_BooleanToValue(JS_TRUE);
		
		return JS_TRUE; 
	} else {
		
		FreeLibraryName();
	 	FreeUVdata();
		
		return JS_FALSE; 
	}
}
示例#20
0
/*
================
idThread::Event_GetCvar
================
*/
void idThread::Event_GetCvar( const char *name ) const {
	ReturnString( cvarSystem->GetCVarString( name ) );
}
示例#21
0
//FlashCS5extension.WriteDynamic(라이브러리 다이나믹들)
JSBool WriteDynamic(JSContext *cx, JSObject *obj, unsigned int argc, jsval *argv, jsval *rval) {
    
    writelog("begin");
    
    if(argc != 1)
        return JS_FALSE;
    
    writelog("check arg count");
	
	if(pObjectFile) {
		JSObject* dynamicObjs;
		if(JS_ValueToObject(cx, argv[0], &dynamicObjs) == JS_FALSE)
			return ReturnString(cx, "q _ 1", rval);
        
        writelog("get dynamic objects from argv[0]");
		
		unsigned int dynamicLen = (unsigned int)JS_GetArrayLength(cx, dynamicObjs);
		if(dynamicLen == -1)
			return ReturnString(cx, "q _ 2", rval);
        
        writelog("get dynamic length = %u", dynamicLen);
		
		fwrite(&dynamicLen, sizeof(unsigned int), 1, pObjectFile);
		
		for(int i = 0; i < dynamicLen; i++) {
			jsval posDynamic;
			if(JS_GetElement(cx, dynamicObjs, i, &posDynamic) == JS_FALSE)
				return ReturnString(cx, "q _ 3", rval);
            
            writelog("==================================");
            writelog("get dynamic element %d", i);
			
			JSObject* dynamicObj;
			if(JS_ValueToObject(cx, posDynamic, &dynamicObj) == JS_FALSE)
				return ReturnString(cx, "q _ 4", rval);
            
            writelog("get dynamic object %d", i);
			
			//라이브러리 네임
            char *libName = GetString(cx, dynamicObj, 0);
            if(libName == 0)
                return ReturnString(cx, "q _ 5", rval);
            
            //library ID
			unsigned int libID = PushLibraryName(libName);
			fwrite(&libID, sizeof(unsigned int), 1, pObjectFile);
            writelog("libName = %s, libID = %u", libName, libID);
			free(libName);
            
            //library Type
            long libType;
            if(GetInteger(cx, dynamicObj, 4, &libType) == JS_FALSE)
                return ReturnString(cx, "q _ 51", rval);
            
            writelog("lib type = %d", libType);
            fwrite(&libType, sizeof(long), 1, pObjectFile);
            
            //frame Length
            long frameLength;
            if(GetInteger(cx, dynamicObj, 5, &frameLength) == JS_FALSE)
                return ReturnString(cx, "q _ 51", rval);
            
            writelog("frame length = %d", frameLength);
            fwrite(&frameLength, sizeof(long), 1, pObjectFile);
            
//            //인스턴스 
//            {
//                JSObject* instanceObj;
//                if(GetObject(cx, dynamicObj, 3, &instanceObj) == JS_FALSE)
//                    return ReturnString(cx, "instance  _ 1", rval);
//                
//                //인스턴스 개수
//                int insLen = (int)JS_GetArrayLength(cx, instanceObj);
//                if(insLen == -1)
//                    return ReturnString(cx, "instance  _ 2", rval);
//                
//                fwrite(&insLen, sizeof(int), 1, pObjectFile);
//                
//                writelog("instance length = %d", insLen);
//                
//                for(int m = 0; m < insLen; m++) {
//                    //instance obj
//                    JSObject* insObj;
//                    if(GetObject(cx, instanceObj, m, &insObj) == JS_FALSE)
//                        return ReturnString(cx, "instance  _ 3", rval);
//                    
//                    //instance id
//                    long insid;
//                    if(GetInteger(cx, insObj, 1, &insid) == JS_FALSE)
//                        return ReturnString(cx, "instance  _ 4", rval);
//                    
//                    //instance name
//                    char* insName = GetString(cx, insObj, 0);
//                    //instnace name length
//                    int insNameLen = strlen(insName);
//                    
//                    fwrite(&insNameLen, sizeof(int), 1, pObjectFile);
//                    
//                    writelog("instance name length = %d", insNameLen);
//                    
//                    fwrite(insName, sizeof(char), insNameLen, pObjectFile);
//                    
//                    writelog("instance name = %s", insName);
//                    
//                    fwrite(&insid, sizeof(int), 1, pObjectFile);
//                    
//                    writelog("instance id = %d", insid);
//                    
//                    free(insName);
//                }
//            }
            
            //레퍼런스
            {
                JSObject* referenceObj;
                if(GetObject(cx, dynamicObj, 1, &referenceObj) == JS_FALSE)
                    return ReturnString(cx, "q _ 6", rval);
                
                writelog("--------------------------------");
                writelog("get reference obj");
                
                
                
                //reference count
                int refLen = (int)JS_GetArrayLength(cx, referenceObj);
                if(refLen == -1)
                    return ReturnString(cx, "q _ 7", rval);
                
                writelog("reference length = %ld", refLen);
                
                fwrite(&refLen, sizeof(int), 1, pObjectFile);
                
                for(int j = 0; j < refLen; ++j) {
                    writelog("--------------------------------");
                    
                    //ref info obj
                    JSObject* refObj;
                    if(GetObject(cx, referenceObj, j, &refObj) == JS_FALSE)
                        return ReturnString(cx, "q _ 71", rval);
                    
                    int refMemberIndex = 0;
                    
                    int refinfoLen = (int)JS_GetArrayLength(cx, refObj);
                    if(refinfoLen == -1)
                        return ReturnString(cx, "q _ 72", rval);
                    
                    //reference ID
                    long refid;
                    if(GetInteger(cx, refObj, refMemberIndex++, &refid) == JS_FALSE)
                        return ReturnString(cx, "q _ 8", rval);
                    
                    //type
                    long type;
                    if(GetInteger(cx, refObj, refMemberIndex++, &type) == JS_FALSE)
                        return ReturnString(cx, "q _ 11", rval);
                    
                    writelog("type = %d", type);
                    
                    fwrite(&type, sizeof(long), 1, pObjectFile);
                    
                    //lib ID
                    char* libName = GetString(cx, refObj, refMemberIndex++);

                    //read Depth
                    
                    //read StartFrame
                    long startFrame;
                    if(GetInteger(cx, refObj, refMemberIndex++, &startFrame) == JS_FALSE)
                        return ReturnString(cx, "q _ 11", rval);
                    
                    //read End Frame
                    long endFrame;
                    if(GetInteger(cx, refObj, refMemberIndex++, &endFrame) == JS_FALSE)
                        return ReturnString(cx, "q _ 42", rval);
                    
                    //read next reference ID
                    long nextrefid;
                    if(GetInteger(cx, refObj, refMemberIndex++, &nextrefid) == JS_FALSE)
                        return ReturnString(cx, "q _ 8", rval);
                    
                    //read depth
                    long depth;
                    if(GetInteger(cx, refObj, refMemberIndex++, &depth) == JS_FALSE)
                        return ReturnString(cx, "q _ 8", rval);
                    
                                        
                    if(type == _TYPE_BITMAP_) {
                        //lib Path                    
                        char* libPath = GetString(cx, refObj, refMemberIndex++);
                        unsigned int libID = PushLibraryName(libPath);
                        fwrite(&libID, sizeof(unsigned int), 1, pObjectFile);
                        writelog("lib path = %s, lib = %u", libPath, libID);
                        free(libPath);
                    } else if(type == _TYPE_GRAPHIC_) {
                        //get lib name
                        unsigned int libID = PushLibraryName(libName);
                        fwrite(&libID, sizeof(unsigned int), 1, pObjectFile);
                        writelog("lib name = %s, lib = %u", libName, libID);
                        free(libName); 
                    } else {
                        //get lib name
                        unsigned int libID = PushLibraryName(libName);
                        fwrite(&libID, sizeof(unsigned int), 1, pObjectFile);
                        writelog("lib name = %s, lib = %u", libName, libID);
                        free(libName);    
                        
                        //instance ID
                        long insLen;
                        char* insName = GetString(cx, refObj, refMemberIndex++);
                        insLen = strlen(insName);
                        fwrite(&insLen, sizeof(long), 1, pObjectFile);
                        fwrite(insName, insLen, 1, pObjectFile);
                        writelog("instnace name = %s", insName);
                    }
                    
                    //write depth
                    writelog("depth = %d", depth);
                    fwrite(&depth, sizeof(long), 1, pObjectFile);
                    
                    //write Start Frame
                    writelog("startFrame = %d", startFrame);
                    
                    fwrite(&startFrame, sizeof(long), 1, pObjectFile);
                    
                    //write End Frame
                    writelog("end frame = %d", endFrame);
                    
                    fwrite(&endFrame, sizeof(long), 1, pObjectFile);

                    if(type == _TYPE_BITMAP_ || type == _TYPE_GRAPHIC_ || type == _TYPE_MOVIECLIP_) {
                        
                        
                        writelog("ref id = %d", refid);
                        
                        fwrite(&refid, sizeof(long), 1, pObjectFile);
                        
                        //write next reference ID
                        writelog("next ref id = %d", nextrefid);
                        
                        fwrite(&nextrefid, sizeof(long), 1, pObjectFile);
                        
                        //Start Position
                        double startX;
                        double startY;
                        if(GetDouble(cx, refObj, refMemberIndex++, &startX) == JS_FALSE)
                            return ReturnString(cx, "q _ 12", rval);
                        
                        if(GetDouble(cx, refObj, refMemberIndex++, &startY) == JS_FALSE)
                            return ReturnString(cx, "q _ 13", rval);
                        
                        float startXf, startYf;
                        startXf = (float)startX;
                        startYf = (float)startY;
                        fwrite(&startXf, sizeof(float), 1, pObjectFile);
                        fwrite(&startYf, sizeof(float), 1, pObjectFile);
                        
                        writelog("startX = %f, startY = %f", startX, startY);
                        
                        //Anchor
                        double anchorX;
                        double anchorY;
                        if(GetDouble(cx, refObj, refMemberIndex++, &anchorX) == JS_FALSE)
                            return ReturnString(cx, "q _ 14", rval);
                        
                        if(GetDouble(cx, refObj, refMemberIndex++, &anchorY) == JS_FALSE)
                            return ReturnString(cx, "q _ 15", rval);
                        
                        float anchorXf, anchorYf;
                        anchorXf = (float)anchorX;
                        anchorYf = (float)anchorY;
                        fwrite(&anchorXf, sizeof(float), 1, pObjectFile);
                        fwrite(&anchorYf, sizeof(float), 1, pObjectFile);
                        
                        writelog("anchorX = %f, anchorY = %f", anchorX, anchorY);
                        
                        //Start Rotation
                        double startRotation;
                        if(GetDouble(cx, refObj, refMemberIndex++, &startRotation) == JS_FALSE)
                            return ReturnString(cx, "q _ 16", rval);
                        
                        float rotf = (float)startRotation;
                        fwrite(&rotf, sizeof(float), 1, pObjectFile);
                        
                        writelog("rotation = %f", startRotation);
                        
                        //Start Scale
                        double scaleX;
                        double scaleY;
                        if(GetDouble(cx, refObj, refMemberIndex++, &scaleX) == JS_FALSE)
                            return ReturnString(cx, "q _ 17", rval);
                        if(GetDouble(cx, refObj, refMemberIndex++, &scaleY) == JS_FALSE)
                            return ReturnString(cx, "q _ 18", rval);
                        
                        float scaleXf, scaleYf;
                        scaleXf = (float)scaleX;
                        scaleYf = (float)scaleY;
                        fwrite(&scaleXf, sizeof(float), 1, pObjectFile);
                        fwrite(&scaleYf, sizeof(float), 1, pObjectFile);
                        
                        writelog("scale x = %f, y = %f", scaleX, scaleY);
                        
                        //Start Skew
                        double startSkewX;
                        double startSkewY;
                        if(GetDouble(cx, refObj, refMemberIndex++, &startSkewX) == JS_FALSE)
                            return ReturnString(cx, "q _ 19", rval);
                        if(GetDouble(cx, refObj, refMemberIndex++, &startSkewY) == JS_FALSE)
                            return ReturnString(cx, "q _ 20", rval);
                        
                        float skewXf, skewYf;
                        skewXf = (float)startSkewX;
                        skewYf = (float)startSkewY;
                        fwrite(&skewXf, sizeof(float), 1, pObjectFile);
                        fwrite(&skewYf, sizeof(float), 1, pObjectFile);
                        
                        writelog("skew x = %f, y = %f", startSkewX, startSkewY);
                        
                        if(type == _TYPE_GRAPHIC_ || type == _TYPE_MOVIECLIP_) {
                            //Start Color Style
                            long startColorAlphaPercent;
                            long startColorRedPercent;
                            long startColorGreenPercent;
                            long startColorBluePercent;
                            long startColorAlphaAmount;
                            long startColorRedAmount;
                            long startColorGreenAmount;
                            long startColorBlueAmount;
                            
                            if(GetInteger(cx, refObj, refMemberIndex++, &startColorAlphaPercent) == JS_FALSE)
                                return ReturnString(cx, "q _ 22", rval);
                            if(GetInteger(cx, refObj, refMemberIndex++, &startColorRedPercent) == JS_FALSE)
                                return ReturnString(cx, "q _ 23", rval);
                            if(GetInteger(cx, refObj, refMemberIndex++, &startColorGreenPercent) == JS_FALSE)
                                return ReturnString(cx, "q _ 24", rval);
                            if(GetInteger(cx, refObj, refMemberIndex++, &startColorBluePercent) == JS_FALSE)
                                return ReturnString(cx, "q _ 25", rval);
                            if(GetInteger(cx, refObj, refMemberIndex++, &startColorAlphaAmount) == JS_FALSE)
                                return ReturnString(cx, "q _ 26", rval);
                            if(GetInteger(cx, refObj, refMemberIndex++, &startColorRedAmount) == JS_FALSE)
                                return ReturnString(cx, "q _ 27", rval);
                            if(GetInteger(cx, refObj, refMemberIndex++, &startColorGreenAmount) == JS_FALSE)
                                return ReturnString(cx, "q _ 28", rval);
                            if(GetInteger(cx, refObj, refMemberIndex++, &startColorBlueAmount) == JS_FALSE)
                                return ReturnString(cx, "q _ 29", rval);
                            
                            char alphaPercent = (char)startColorAlphaPercent;
                            char redPercent = (char)startColorRedPercent;
                            char greenPercent = (char)startColorGreenPercent;
                            char bluePercent = (char)startColorBluePercent;
                            short alphaAmount = (short)startColorAlphaAmount;
                            short redAmount = (short)startColorRedAmount;
                            short greenAmount = (short)startColorGreenAmount;
                            short blueAmount = (short)startColorBlueAmount;                            
                            fwrite(&redPercent, sizeof(char), 1, pObjectFile);
                            fwrite(&greenPercent, sizeof(char), 1, pObjectFile);
                            fwrite(&bluePercent, sizeof(char), 1, pObjectFile);
                            fwrite(&alphaPercent, sizeof(char), 1, pObjectFile);                            
                            fwrite(&redAmount, sizeof(short), 1, pObjectFile);
                            fwrite(&greenAmount, sizeof(short), 1, pObjectFile);
                            fwrite(&blueAmount, sizeof(short), 1, pObjectFile);
                            fwrite(&alphaAmount, sizeof(short), 1, pObjectFile);
                            
                            writelog("alpha percent = %d", startColorAlphaPercent);
                            writelog("red percent = %d", startColorRedPercent);
                            writelog("green percent = %d", startColorGreenPercent);
                            writelog("blue percent = %d", startColorBluePercent);
                            writelog("alpha amount = %d", startColorAlphaAmount);
                            writelog("red amount = %d", startColorRedAmount);
                            writelog("green amount = %d", startColorGreenAmount);
                            writelog("blue amount = %d", startColorBlueAmount);
                        }
                        
                        if(type == _TYPE_GRAPHIC_ || type == _TYPE_MOVIECLIP_)  {
                            long startColorBlendMode;
                            if(GetInteger(cx, refObj, refMemberIndex++, &startColorBlendMode) == JS_FALSE)
                                return ReturnString(cx, "q _ 30", rval);
                            
                            unsigned char blendMode = (unsigned char)startColorBlendMode;
                            fwrite(&blendMode, sizeof(blendMode), 1, pObjectFile);
                            writelog("blend mode = %d", startColorBlendMode);
                            
                            //Ease
                            long easeType;
                            if(GetInteger(cx, refObj, refMemberIndex++, &easeType) == JS_FALSE)
                                return ReturnString(cx, "q _ 31", rval);
                            
                            writelog("ease type = %d", easeType);
                            
                            unsigned char easeTypeuc = (unsigned char)easeType;
                            fwrite(&easeTypeuc, sizeof(easeTypeuc), 1, pObjectFile);
                            
                            if(easeType == 2) {  //멀티 타입일 경우(Position, Rotation, Scale, Color, Filters)
                                for(int l = 0; l < 4; ++l)
                                {
                                    JSObject* easeObj;
                                    if(GetObject(cx, refObj, refMemberIndex++, &easeObj) == JS_FALSE)
                                        return ReturnString(cx, "q _ 32", rval);
                                    
                                    writelog("get multi ease obj");
                                    
                                    int easeCount = JS_GetArrayLength(cx, easeObj);
                                    if(easeCount == -1)
                                        return ReturnString(cx, "q _ 33", rval);
                                    
                                    writelog("get ease length = %d", easeCount);
                                    
                                    fwrite(&easeCount, sizeof(int), 1, pObjectFile);
                                    
                                    for(int k = 0; k < easeCount; ++k) {
                                        JSObject* posObj;
                                        if(GetObject(cx, easeObj, k, &posObj) == JS_FALSE)
                                            return ReturnString(cx, "q _ 34", rval);
                                        
                                        writelog("get pos obj");
                                        
                                        double x, y;
                                        if(GetDouble(cx, posObj, 0, &x) == JS_FALSE)
                                            return ReturnString(cx, "q _ 35", rval);
                                        if(GetDouble(cx, posObj, 1, &y) == JS_FALSE)
                                            return ReturnString(cx, "q _ 36", rval);
                                        
                                        float fx, fy;
                                        fx = (float)x;
                                        fy = (float)y;
                                        fwrite(&fx, sizeof(float), 1, pObjectFile);
                                        fwrite(&fy, sizeof(float), 1, pObjectFile);
                                        
                                        writelog("x = %f, y = %f", x, y);
                                    }
                                }
                            } else if(easeType == 1) {        //싱글이나 심플일 경우
                                JSObject* easeObj;
                                if(GetObject(cx, refObj, refMemberIndex++, &easeObj) == JS_FALSE)
                                    return ReturnString(cx, "q _ 37", rval);
                                
                                writelog("get ease obj");
                                
                                int easeCount = JS_GetArrayLength(cx, easeObj);
                                if(easeCount == -1)
                                    return ReturnString(cx, "q _ 38", rval);
                                
                                writelog("get ease length = %d", easeCount);
                                
                                fwrite(&easeCount, sizeof(int), 1, pObjectFile);
                                
                                for(int k = 0; k < easeCount; ++k) {
                                    JSObject* posObj;
                                    if(GetObject(cx, easeObj, k, &posObj) == JS_FALSE)
                                        return ReturnString(cx, "q _ 39", rval);
                                    
                                    writelog("get pos obj");
                                    
                                    double x, y;
                                    if(GetDouble(cx, posObj, 0, &x) == JS_FALSE)
                                        return ReturnString(cx, "q _ 40", rval);
                                    if(GetDouble(cx, posObj, 1, &y) == JS_FALSE)
                                        return ReturnString(cx, "q _ 41", rval);
                                    
                                    float fx, fy;
                                    fx = (float)x;
                                    fy = (float)y;
                                    fwrite(&fx, sizeof(float), 1, pObjectFile);
                                    fwrite(&fy, sizeof(float), 1, pObjectFile);
                                    
                                    writelog("x = %f, y = %f", x, y);
                                }
                            }
                        }    
                    }
                }                
            }
            
//			//프레임
//            {
//                JSObject* frameObj;
//                if(GetObject(cx, dynamicObj, 2, &frameObj) == JS_FALSE)
//                    return ReturnString(cx, "q _ 60", rval);
//                
//                writelog("get frame obj");
//                
//                //프레임 개수
//                int frameCount;
//                frameCount = JS_GetArrayLength(cx, frameObj);
//                if(frameCount == -1)
//                    return ReturnString(cx, "q _ 61", rval);
//                
//                writelog("get frame count = %d", frameCount);
//                
//                fwrite(&frameCount, sizeof(int), 1, pObjectFile);
//                
//                for(int j = 0; j < frameCount; ++j) {
//                    //레퍼런스 아이디 배열
//                    JSObject* refObj;
//                    if(GetObject(cx, frameObj, j, &refObj) == JS_FALSE)
//                        return ReturnString(cx, "q _ 62", rval);
//                    
//                    fwrite(&j, sizeof(int), 1, pObjectFile);
//                    
//                    writelog("frame = %d", j);
//                    
//                    //레퍼런스 개수
//                    int refCount = JS_GetArrayLength(cx, refObj);
//                    if(refCount == -1)
//                        return ReturnString(cx, "q _ 63", rval);
//                    
//                    fwrite(&refCount, sizeof(int), 1, pObjectFile);
//                    
//                    writelog("ref count = %d", refCount);
//                    
//                    for(int k = 0; k < refCount; ++k) {
//                        //레퍼런스 번호
//                        long refid;
//                        if(GetInteger(cx, refObj, k, &refid) == JS_FALSE)
//                            return ReturnString(cx, "q _ 64", rval);
//                        
//                        fwrite(&refid, sizeof(long), 1, pObjectFile);
//                        
//                        writelog("ref id = %d", refid);
//                    }
//                }
//            }
		}
        
		*rval = JS_BooleanToValue(JS_TRUE);
		
		return JS_TRUE; 
	} else {
		return ReturnString(cx, "a _ 17", rval);
	}
}