Esempio n. 1
0
/* Parse a macro */
VyObject ParseMacro(VyParseTree* code){
	/* Parse the function arguments */
	VyParseTree* args = GetListData(code, 1);
	int numArguments = 0;
	char* error = NULL;
	Argument** arguments = ParseFunctionArguments(args, &numArguments, &error);
	if(error != NULL){
		return ToObject(CreateError(error, code));	
	}

	/* Take the rest of the expressions in the lambda as code */
	VyParseTree* exprList = MakeListTree();
	int i;
	for(i = 2; i < ListTreeSize(code); i++){
		AddToList(exprList, GetListData(code, i));  
	}

	/* Take variables from the current function scope and the local scope */
	Scope* funcScope = GetCurrentFunctionScope();
	Scope* localScope = GetLocalScope();

	/* Make sure the local scope isn't the global scope */
	if(localScope == GetGlobalScope()) {
		localScope = NULL; 
	}

	/* Merge the two scopes to get the current function scope */
	Scope* closureScope = MergeScopes(funcScope, localScope);

	/* Create the function from the data gathered */
	VyMacro** mac = CreateMacro(arguments, numArguments, exprList, closureScope);
	return ToObject(mac);	
}
Esempio n. 2
0
void ggTool::s_Save()
{

	int pointNum = (int)m_points.size();
	std::string output = "3d_points.csv";
	std::string output_bu = "3d_points_backup.csv1";

	//	バックアップを保存する
	std::ofstream ofs(output_bu, std::ios::out);
	for (int i = 0; i < pointNum; i++)
	{
		cv::Point3f p = m_points[i].first;
		std::string str = m_points[i].second;
		ofs << p.x << "," << p.y << "," << p.z << "," << str << std::endl;
	}
	ofs.close();

	//	更新版を保存する
	std::vector<PointWithComment> pts = GetListData();

	ofs.open(output, std::ios::out);
	for (int i = 0; i < pointNum; i++)
	{
		cv::Point3f p = pts[i].first;
		std::string str = pts[i].second;
		ofs << p.x << "," << p.y << "," << p.z << "," << str << std::endl;
	}

	//	確認ボックス
	QMessageBox box;
	box.setText(QString::fromStdString("Saved following file.\n" + output));
	box.exec();
}
Esempio n. 3
0
void CMainWnd::GetBuffDataWorker()
{
	if (IsEmpty())
		return;
	KillTimer(this->GetHWnd(), GETDATATIMER);
	PCHAR data = GetListData();
	if (data != NULL)
	{
		UINT bufSiz = strlen(data) * 2;
		PCHAR pBuff = (PCHAR)calloc(bufSiz, 1);
		UINT len = 0;
		while(data)
		{
			UINT datalen = lstrlen(data);
			if(bufSiz <= datalen + len)
			{
				UINT tmplen = bufSiz + (datalen * 2);
				PCHAR tmp = (PCHAR)realloc(pBuff, tmplen);
				if (tmp) 
				{
					pBuff = tmp;
					bufSiz = tmplen;
				}
				else
				{
					break;
				}
			}
			strcpy(&pBuff[len], data);
			len += datalen;
			free(data);
			data = GetListData();
		}
		
		this->addtoEdit(pBuff);
		free(pBuff);
		if (data) {
			OutputDebugString("<=================== data is Not Null!!! ====================>\n");
			this->addtoEdit(data);
			free(data);
		}
	}
	SetTimer(this->GetHWnd(), GETDATATIMER, TIMERINTERVAL, NULL);
}
Esempio n. 4
0
/* Check and print errors  */
int CheckAndPrintErrors(VyParseTree* tree){
	int treeType = tree->type;
	int error = 0;

	if(treeType == TREE_LIST){
		/* Check each element recursively */
		int i;
		for(i = 0; i < ListTreeSize(tree); i++){	
			VyParseTree* next = GetListData(tree,i);

			/* Check the sub nodes for errors */
			int listError = CheckAndPrintErrors(next);
			if(listError) error = 1;
		}
	}

	/* Check each piece of the ref */
	else if(treeType == TREE_REF){

		int objError = CheckAndPrintErrors(GetObj(tree));
		int refError = CheckAndPrintErrors(GetRef(tree));
		if(objError || refError) error = 1;
	}

	/* If it is an error, print the error */
	else if(treeType == TREE_ERROR){
		printf("\n\n");
		printf("------- Parsing Error -------\n");
		printf("Position: ");
		PrintPosition(tree->pos);
		printf("\n");
		printf(tree->data->error.message);
		printf("\n-----------------------------");
		error = 1;
	}

	return error; 


}
Esempio n. 5
0
File: WinBase.c Progetto: RFBGH/ugui
PWindow LocatWinByXY(PPoint pPoint)
{
    PWindow pWinCurr = NULL;
    PWindow pWinParent = NULL;
    CList   list;
    int     iStackTop;

    InitList(&list);
    pWinCurr = pWinRoot;
    while(TRUE)
    {
        if(pWinCurr)
        {

            PushList(&list, pWinCurr);
            pWinCurr = pWinCurr->m_pLastSon;          
        }
        else{
            iStackTop = list.m_iListSize;
            if(iStackTop == -1)
            {
                break;
            }
            
            pWinCurr = GetListData(&list, iStackTop-1);
            RemoveListByData(&list, pWinCurr);

            if(PointInRect(pPoint, &pWinCurr->m_showRect))
            {
                break;
            }
            pWinCurr = pWinCurr->m_pLast;
        }
    }

    DeletList(&list);
    return pWinCurr;
}
Esempio n. 6
0
void PrintListGeneric(VyParseTree* tree, char oDelim, char cDelim){
	printf("%c", oDelim);

	/* Print each element recursively */
	int i;
	for(i = 0; i < ListTreeSize(tree); i++){	
		VyParseTree* next = GetListData(tree,i);
		if(IsQuote(next)){
			printf("'");
			PrintParseTree(GetListData(next, 1));
		}
		else if(IsSubstitution(next)){
			if(IsSplicingSubstitution(next)){
				printf("$@");		
			}else{
				printf("$");	
			}

			PrintParseTree(GetListData(next, 1));
		}
		else if(next->type == TREE_LIST){
			VyParseTree* first = GetListData(next, 0);
			if(first->type == TREE_IDENT && StrEquals(GetStrData(first), "infix")){
				PrintListGeneric(GetListData(next, 1), '{','}');
			}
			else if(first->type == TREE_IDENT && StrEquals(GetStrData(first), "quote-substitutions")){
				PrintListGeneric(GetListData(next, 1), '[',']');
			}else{
				PrintParseTree(next);	
			}
		}
		else{
			PrintParseTree(next);
		}
	}

	/* If it wasn't an empty list, remove the extra space generated by the item inside */
	if(ListTreeSize(tree) > 0){
		printf("\b");
	}

	printf("%c ", cDelim);  
}