void MainWindow::OpenImage(const QString &fileName)
{
	QScrollArea* area = new QScrollArea();
	ImageWidget* img = new ImageWidget();

	// Nur les- und schreibbare Bildformate werden unterstützt
	if (img->OpenImage(fileName)) {
		QString shortFileName = ParseFileName(fileName);
		shortFileName = shortFileName.mid(0, shortFileName.lastIndexOf('.'));

		// Bild in die ScrollArea laden
		area->setWidget(img);
		area->setStyleSheet("background: qlineargradient(x1: 0, y0: 1, x2:1, y2: 0, stop: 0.96 #383838, stop: 0.99 #2e2e2e);");

		// neuen Tab hinzufügen
		int index = ui->imagetab->addTab(area, shortFileName);
		ui->imagetab->setTabToolTip(index, shortFileName);
		ui->imagetab->setCurrentIndex(index);

		// schließlich Signalhandler setzen
		connect(this, SIGNAL(Arguments(QHash<QString,QString>)), img, SLOT(Arguments(QHash<QString,QString>)));
		connect(this, SIGNAL(Operation(IOperation*,QHash<QString,QString>)), img, SLOT(Operation(IOperation*,QHash<QString,QString>)));
		connect(this, SIGNAL(Operation(IOperation*,QHash<QString,QString>,OperationType)), img, SLOT(Operation(IOperation*,QHash<QString,QString>,OperationType)));
		emit Operation(mOperation, GetArgs());
	}
Exemplo n.º 2
0
                bool
        Query (
                const char		*name)
        {
                if (!Arguments() . test ())
                        return false;

                if (!Arguments() . Set (0, name))
                        return false;

                if (!CLxCommandQuery::Query (1))
                        return false;

                return (Count () > 0);
        }
Exemplo n.º 3
0
    FunctionCallNode::FunctionCallNode(QString * name, ListNode<ASTNode> * expressionList)
            :  _name(name),
             _expressionList(expressionList)
    {
        auto function = SymbolTable::Instance().Function(name);
        auto expectedArguments = function->Arguments();

        _type = function->Type();

        if (expectedArguments->size() != expressionList->size())
        {
            std::cerr << WRONG_NUMBER_OF_ARGUMENTS << "(" << name->toStdString() << ")\n";
            exit(EXIT_FAILURE);
        }

        for (size_t i=0; i<expectedArguments->size(); i++)
        {
            int typeExpected = expectedArguments->at(i)->Type();
            int typeActual = expressionList->at(i)->Type();
            if (typeExpected != typeActual)
            {
                std::cerr << TYPE_CONFLICT << SymbolTable::Instance().TypeName(typeActual).toStdString() << " to " << SymbolTable::Instance().TypeName(typeExpected).toStdString() << std::endl;
                std::cerr << "in function: " << name->toStdString() << std::endl;
                std::cerr << "argument: " << i << std::endl;
                exit(EXIT_FAILURE);
            }
        }


    }
Exemplo n.º 4
0
/**
 * This function is reimplemented from the ClientProtocolIODevice class, and is called between connection and service selecting. It tells the server if it wants to enable SSL or not.
 */
void ClientProtocolTcp::connected()
{
	qxt_d().lastPing = QDateTime::currentDateTime();
	if (url().scheme() == "tcp")
	{
		callProtocolFunction(Signature("setSsl(bool)"), Arguments() << false);
	}
	else if (url().scheme() == "tcps")
	{
		callProtocolFunction(Signature("setSsl(bool)"), Arguments() << true);
// 		qxt_d().socket.startClientEncryption();
// 		qxt_d().socket.waitForEncrypted();
	}
	else
	{
		qCritical(qPrintable(QString("Error: Tcp does not support protocol: %1").arg(url().scheme())));
		emit returnReceived(Message(connectId(), ReturnValue(1, QString("Error: Tcp does not support protocol: %1").arg(url().scheme()))));
	}
}
Exemplo n.º 5
0
/**
 * This function is used internally to handle pinging the server and detecting timeouts. Timeouts are enabled and disabled server side.
 */
void ClientProtocolTcpPrivate::ping()
{
	if (lastPing.secsTo(QDateTime::currentDateTime()) > timeout)
	{
		qCritical() << "Remove host has timed out.";
		qxt_p().protocolDisconnect();
		return;
	}
	qxt_p().callProtocolFunction(Signature("ping()"), Arguments());
}
QImage Erosion::Draw(const QImage &image, const QHash<QString, QString>& args)
{
	int shape = cv::MORPH_ELLIPSE;
	int ksize = 2;

	Arguments(args, shape, ksize);

	cv::Mat mat = QImageToMat(image);
	cv::Mat kernel = cv::getStructuringElement(shape, cv::Size(ksize, ksize));
	cv::erode(mat, mat, kernel);
	return MatToQImage(mat);
}
Exemplo n.º 7
0
    static Arguments Main()
    {
        int ac;
        LPWSTR *w_av = CommandLineToArgvW(GetCommandLineW(), &ac);
        std::vector<std::wstring> av1(ac);
        std::vector<wchar_t const *> av2(ac);
        for (int i = 0; i < ac; i++) {
			av1[i]=w_av[i];
            av2[i] = av1[i].c_str();
        }
        LocalFree(w_av);
        return Arguments(ac,&av2[0]);
    }
Exemplo n.º 8
0
int main()
{
    ReferenceCounting();
    AttachToMemory();
    StandardSharedPtrCreation();
    AccesingRawPointer();
    Arguments();

    boost::shared_ptr<X> x(new X(true));
    STLContainer(x);

    AssignToSmartPtr();
    EarlyExits();
    CustomDelete();

    return 0;
}
QImage Sobel::Draw(const QImage &image, const QHash<QString, QString>& args)
{
	int ksize = 3;

	cv::Mat src, grad, result;
	cv::Mat gradX, gradY;
	cv::Mat absGradX, absGradY;

	Arguments(args, ksize);

	src = QImageToMat(image);
	cv::cvtColor(src, src, CV_BGR2GRAY);
	cv::Sobel(src, gradX, -1, 1, 0, ksize);
	cv::convertScaleAbs(gradX, absGradX);
	cv::Sobel(src, gradY, -1, 0, 1, ksize);
	cv::convertScaleAbs(gradY, absGradY);
	cv::addWeighted(absGradX, 0.5, absGradY, 0.5, 0, grad);
	grad.convertTo(result, CV_8U);
	return MatToQImage(result);
}
Exemplo n.º 10
0
Cursor::Arguments Cursor::get_arguments() const
{
	auto generator = [this](unsigned int index) {
		CXCursor cx_cursor(clang_Cursor_getArgument(this->m_cx_cursor, index));
		if ( is_null(cx_cursor) ) {
			CLANGXX_THROW_LogicError("Error retrieving the argument cursor of a function or method.");
		}

		return Cursor(std::move(cx_cursor), this->m_translation_unit);
	};

	int num_args{clang_Cursor_getNumArguments(m_cx_cursor)};
	if ( num_args < 0 ) {
		if ( is_null(m_cx_cursor) ) {
			CLANGXX_THROW_LogicError("Error retrieving the number of non-variadic arguments associated with this cursor.");
		}
		num_args = 0;
	}

	return Arguments(generator, num_args);
}
Exemplo n.º 11
0
void Send::start(QStringList &arguments) {
	SEStringList list;
	QStringList Arguments(arguments);
	QString blob, message;
	MyConversation::Refs inbox;
	MyConversation::Ref sconv;
	
	if (Arguments.size() != 2) {
		emit finished(new Response(false,"invalid arguments"));
		return;
	}

	blob    = Arguments[0];
	message = Arguments[1];

	//std::cout << "  room: " << (const char *)blob.toLocal8Bit()  << std::endl << "  message: " << (const char *)message.toLocal8Bit() << std::endl;

	skype->GetConversationList(inbox, Conversation::INBOX_CONVERSATIONS);
	fetch(inbox);

	for (int i = 0; i < inbox.size();i++) {
		SEString displayName;

		sconv = inbox[i];
		sconv->GetPropDisplayname(displayName);		
		
		if (strcmp((const char *)displayName,(const char *)blob.toLocal8Bit()) == 0) {
			//std::cout << (const char *)displayName << std::endl;

			Message::Ref rep;
			sconv->PostText((const char *)message.toLocal8Bit(), rep, false);
			
			emit finished(new Response(true,"ok"));
			return;
		}
	}
	
	emit finished(new Response(false,"not found"));
}
Exemplo n.º 12
0
///////////////////////////////////////////////////////////////////////////////
//
// Command
//
///////////////////////////////////////////////////////////////////////////////
void Command::deserialize()
{
   //find dot delimiter
   string ids;
   size_t pos = command_.find('.');
   if (pos == string::npos)
      ids = command_;
   else
   {
      ids = command_.substr(0, pos);
      args_ = move(Arguments(command_.substr(pos + 1)));
   }

   //tokensize by &
   vector<size_t> posv;
   pos = 0;
   while ((pos = ids.find('&', pos)) != string::npos)
   {
      posv.push_back(pos);
      pos++;
   }

   if (posv.size() == 0)
      throw runtime_error("no IDs found in command string");

   posv.push_back(ids.size());

   for (int i = 0; i < posv.size() - 1; i++)
   {
      ssize_t len = posv[i + 1] - posv[i] - 1;
      if (len < 0)
         throw range_error("invalid id len");
      ids_.push_back(ids.substr(posv[i] + 1, len));
   }

   method_ = ids_.back();
   ids_.pop_back();
}
Exemplo n.º 13
0
size_t BlockChain::getBlockUnclesCount(const char *hash)
{
    Json::Value result = _provider.request("eth_getUncleCountByBlockHash", Arguments(hash));
    return unhex<size_t>(result.asCString());
}
Exemplo n.º 14
0
    Var BoundFunction::NewInstance(RecyclableObject* function, CallInfo callInfo, ...)
    {
        RUNTIME_ARGUMENTS(args, callInfo);
        ScriptContext* scriptContext = function->GetScriptContext();

        if (args.Info.Count == 0)
        {
            JavascriptError::ThrowTypeError(scriptContext, JSERR_NeedFunction /* TODO-ERROR: get arg name - args[0] */);
        }

        BoundFunction *boundFunction = (BoundFunction *) function;
        Var targetFunction = boundFunction->targetFunction;

        //
        // var o = new boundFunction()
        // a new object should be created using the actual function object
        //
        Var newVarInstance = nullptr;
        if (callInfo.Flags & CallFlags_New)
        {
          if (JavascriptProxy::Is(targetFunction))
          {
            JavascriptProxy* proxy = JavascriptProxy::FromVar(targetFunction);
            Arguments proxyArgs(CallInfo(CallFlags_New, 1), &targetFunction);
            args.Values[0] = newVarInstance = proxy->ConstructorTrap(proxyArgs, scriptContext, 0);
          }
          else
          {
            args.Values[0] = newVarInstance = JavascriptOperators::NewScObjectNoCtor(targetFunction, scriptContext);
          }
        }

        Js::Arguments actualArgs = args;

        if (boundFunction->count > 0)
        {
            BOOL isCrossSiteObject = boundFunction->IsCrossSiteObject();
            // OACR thinks that this can change between here and the check in the for loop below
            const unsigned int argCount = args.Info.Count;

            if ((boundFunction->count + argCount) > CallInfo::kMaxCountArgs)
            {
                JavascriptError::ThrowRangeError(scriptContext, JSERR_ArgListTooLarge);
            }

            Var *newValues = RecyclerNewArray(scriptContext->GetRecycler(), Var, boundFunction->count + argCount);

            uint index = 0;

            //
            // For [[Construct]] use the newly created var instance
            // For [[Call]] use the "this" to which bind bound it.
            //
            if (callInfo.Flags & CallFlags_New)
            {
                newValues[index++] = args[0];
            }
            else
            {
                newValues[index++] = boundFunction->boundThis;
            }

            // Copy the bound args
            if (!isCrossSiteObject)
            {
                for (uint i = 0; i < boundFunction->count; i++)
                {
                    newValues[index++] = boundFunction->boundArgs[i];
                }
            }
            else
            {
                // it is possible that the bound arguments are not marshalled yet.
                for (uint i = 0; i < boundFunction->count; i++)
                {
                    newValues[index++] = CrossSite::MarshalVar(scriptContext, boundFunction->boundArgs[i]);
                }
            }

            // Copy the extra args
            for (uint i=1; i<argCount; i++)
            {
                newValues[index++] = args[i];
            }

            actualArgs = Arguments(args.Info, newValues);
            actualArgs.Info.Count = boundFunction->count + argCount;
        }
        else
        {
            if (!(callInfo.Flags & CallFlags_New))
            {
                actualArgs.Values[0] = boundFunction->boundThis;
            }
        }

        RecyclableObject* actualFunction = RecyclableObject::FromVar(targetFunction);
        Var aReturnValue = JavascriptFunction::CallFunction<true>(actualFunction, actualFunction->GetEntryPoint(), actualArgs);

        //
        // [[Construct]] and call returned a non-object
        // return the newly created var instance
        //
        if ((callInfo.Flags & CallFlags_New) && !JavascriptOperators::IsObject(aReturnValue))
        {
            aReturnValue = newVarInstance;
        }

        return aReturnValue;
    }
Exemplo n.º 15
0
Block BlockChain::getBlock(int number)
{
    return Block(_provider.request("eth_getBlockByNumber", Arguments(hex(number), _fetchBlockDetails)));
}
Exemplo n.º 16
0
int			Tdi0Decompile_R(
struct descriptor_r	*pin,
int			prec,
struct descriptor_d	*pout)
{
struct descriptor_r	*r_ptr;
char		 	*ptext;
struct TdiFunctionStruct *fun_ptr;
int			narg = pin->ndesc;
int			m, lorr, newone, status = 1;
struct op_rec		*pop;
unsigned int		dtype;
enum OpcOpcodes        opcode;

	switch (pin->dtype) {
	default :
		status = Append("%Unknown%", pout);
		break;

	case DTYPE_PARAM :
	case DTYPE_SIGNAL :
	case DTYPE_DIMENSION :
	case DTYPE_WINDOW :
	case DTYPE_SLOPE :
	case DTYPE_CONGLOM :
	case DTYPE_ACTION :
	case DTYPE_DISPATCH :
	case DTYPE_PROGRAM :
	case DTYPE_ROUTINE :
	case DTYPE_PROCEDURE :
	case DTYPE_METHOD :
	case DTYPE_DEPENDENCY :
	case DTYPE_CONDITION :
	case DTYPE_WITH_UNITS :
	case DTYPE_WITH_ERROR :
        case DTYPE_OPAQUE :
build:		status = Append("Build_", pout);
		if (status&1)	status = Append(bname[pin->dtype - DTYPE_PARAM], pout);
		if (status&1)	status = Append("(", pout);
		if (pin->length) {
			if (pin->length == 1) opcode = (enum OpcOpcodes)(*(unsigned char *)pin->pointer);
			else if (pin->length == 2) opcode = (enum OpcOpcodes)(*(unsigned short *)pin->pointer);
			else if (pin->length == 4) opcode = (enum OpcOpcodes)(*(unsigned int *)pin->pointer);
			else opcode = (enum OpcOpcodes)-1;
			if (status&1)	status = TdiSingle(opcode, pout);
			if (status&1)	status = Append(", ", pout);
		}
		if (status&1)	status = Arguments(0, 0, ")", pin, pout);
		break;

	case DTYPE_RANGE :
		opcode = OpcDtypeRange;
		goto range;

	case DTYPE_FUNCTION :
		opcode = (enum OpcOpcodes)(*(unsigned short *)pin->pointer);
		if ((int)opcode >= TdiFUNCTION_MAX) return (int)(opcode = (enum OpcOpcodes)0);

range:		fun_ptr = (struct TdiFunctionStruct *)&TdiRefFunction[opcode];
		if (narg < fun_ptr->m1 || narg > fun_ptr->m2) goto cannot;
		else if (fun_ptr->token == LEX_CONST) status = Append(fun_ptr->name, pout);

		/*****************************************
		Functions, subscripts, and constructors.
		*****************************************/
		else switch (opcode) {
		default :		/*intrinsic(arg, ...)*/
cannot:			status = Append(fun_ptr->name, pout);
			if (status&1)	status = Arguments(0, "(", ")", pin, pout);
			break;
		case OpcFun :	/*fun ident(arg, ...) stmt*/
			if (prec < P_STMT) status = Append("(", pout);
			if (status&1)	status = Append("Fun ", pout);
			if (!(status&1)) break;
			r_ptr = (struct descriptor_r *)pin->dscptrs[0];
			if (r_ptr->dtype == DTYPE_T) status = StrAppend(pout, r_ptr);
			else status = Tdi0Decompile(r_ptr, P_SUBS, pout);
			if (status&1)	status = Arguments(2, " (", ") ", pin, pout);
			if (status&1)	status = CompoundStatement(1, (struct descriptor_r **)&pin->dscptrs[1], pout);
			if (status&1 && prec < P_STMT)	status = Append(")", pout);
			break;
		case OpcIn :		/*input argument*/
		case OpcInOut :	/*input and output argument*/
		case OpcOptional :	/*optional argument*/
		case OpcOut :	/*output argument*/
		case OpcPrivate :	/*private ident*/
		case OpcPublic :	/*public ident*/
			status = Append(fun_ptr->name, pout);
			if (status & 1) status = Append(" ", pout);
			r_ptr = (struct descriptor_r *)pin->dscptrs[0];
			if (status & 1)
			if (r_ptr->dtype == DTYPE_T) status = StrAppend(pout, r_ptr);
			else	status = Tdi0Decompile(r_ptr, P_SUBS, pout);
			break;
		case OpcExtFunction : /*_label(arg, ...)*/
			if (pin->dscptrs[0] != 0
			|| pin->dscptrs[1] == 0
			|| pin->dscptrs[1]->dtype != DTYPE_T) goto cannot;
			status = StrAppend(pout, pin->dscptrs[1]);
			if (status&1)	status = Arguments(2, "(", ")", pin, pout);
			break;
		case OpcSubscript :	/*postfix[subscript, ...]*/
					status = Tdi0Decompile(pin->dscptrs[0], P_SUBS, pout);
			if (status&1)	status = Arguments(1, "[", "]", pin, pout);
			break;
		case OpcVector :	/*[elem, ...]*/
			status = Arguments(0, "[", "]", pin, pout);
			break;
		/****************
		Unary operations.
		****************/
		case OpcInot :	case OpcNot :
		case OpcPreDec :	case OpcPreInc :
		case OpcUnaryMinus :case OpcUnaryPlus :
		case OpcPostDec :	case OpcPostInc :
			for (pop = unary; pop->opcode; pop++) if ((enum OpcOpcodes)pop->opcode == opcode) break;
			newone = pop->prec;
			lorr = pop->lorr;
			if (		lorr > 0)	status = Append(pop->symbol, pout);
			if (status&1 && prec <= newone)	status = Append("(", pout);
			if (status&1)			status = Tdi0Decompile(pin->dscptrs[0], newone + lorr, pout);
			if (status&1 && prec <= newone)	status = Append(")", pout);
			if (status&1 && lorr < 0)	status = Append(pop->symbol, pout);
			break;

		/***********************
		Binary/n-ary operations.
		***********************/
		case OpcEqualsFirst :
			r_ptr = (struct descriptor_r *)pin->dscptrs[0];
			newone = *(unsigned short *)r_ptr->pointer;
			narg = r_ptr->ndesc;
			goto first;
		case OpcPower :
		case OpcDivide :	case OpcMultiply :
		case OpcAdd :	case OpcSubtract :
		case OpcShiftLeft :	case OpcShiftRight :
		case OpcConcat :
		case OpcIsIn :
		case OpcGe :		case OpcGt :		case OpcLe :		case OpcLt :
		case OpcEq :		case OpcNe :
		case OpcAnd :	case OpcNand :
		case OpcOr :		case OpcNor :
		case OpcEqv :	case OpcNeqv :
		case OpcPromote :
		case OpcEquals :
		case OpcDtypeRange :
		case OpcComma :
		case OpcConditional :
			r_ptr = (struct descriptor_r *)pin;
			newone = (int)opcode;
first:			for (pop = binary; pop->opcode; pop++) if (pop->opcode == newone) break;
			newone = pop->prec;
			lorr = pop->lorr;
			if (opcode == OpcEqualsFirst) {
				newone = binary[2].prec;
				lorr = binary[2].lorr;
			}
			if (prec <= newone) status = Append("(", pout);
			if (opcode == OpcConditional) {
				if (status&1)	status = Tdi0Decompile(r_ptr->dscptrs[2], newone - lorr, pout);
				if (status&1)	status = Append(pop->symbol, pout);
				if (status&1)	status = Tdi0Decompile(r_ptr->dscptrs[0], newone, pout);
				if (status&1)	status = Append(" : ", pout);
				if (status&1)	status = Tdi0Decompile(r_ptr->dscptrs[1], newone + lorr, pout);
			}
			else {
				if (status&1)	status = Tdi0Decompile(r_ptr->dscptrs[0], newone - lorr, pout);
				for (m = 1; m < narg; m++) {
					if (status&1)	status = Append(pop->symbol, pout);
					if (status&1 && pin != r_ptr) status = Append("= ", pout);
					if (status&1)	status = Tdi0Decompile(r_ptr->dscptrs[m], newone + lorr, pout);
				}
			}
			if (status&1 && prec <= newone) status = Append(")", pout);
			break;

		/*****************************************
		C-language constructs followed by newline.
		Plus WHERE.
		*****************************************/
		case OpcBreak :	/*break;*/
		case OpcContinue :	/*continue;*/
			if (prec < P_STMT) status = Append("(", pout);
			if (status&1)	status = Append(fun_ptr->name, pout);
			if (status&1)	status = OneStatement(0, pout);
			if (prec < P_STMT && status&1) status = Append(")", pout);
			break;
		case OpcCase :	/*case (xxx) stmt ...*/
			if (prec < P_STMT) status = Append("(", pout);
			if (status&1)	status = Append("Case (", pout);
			if (status&1)	status = Tdi0Decompile(pin->dscptrs[0], P_STMT, pout);
			if (status&1)	status = Append(") ", pout);
			if (status&1)	status = MultiStatement(narg-1, (struct descriptor_r **)&pin->dscptrs[1], pout);
			if (prec < P_STMT && status&1) status = Append(")", pout);
			break;
		case OpcDefault :	/*case default stmt ...*/
			if (prec < P_STMT) status = Append("(", pout);
			if (status&1)	status = Append("Case Default ", pout);
			if (status&1)	status = MultiStatement(narg, (struct descriptor_r **)&pin->dscptrs[0], pout);
			if (prec < P_STMT && status&1) status = Append(")", pout);
			break;
		case OpcDo :		/*do {stmt} while (exp); Note argument order is (exp,stmt,...)*/
			if (prec < P_STMT) status = Append("(", pout);
			if (status&1)	status = Append("DO {", pout);
			if (status&1)	status = MultiStatement(narg-1, (struct descriptor_r **)&pin->dscptrs[1], pout);
			if (status&1)	status = Append("} While ", pout);
			if (status&1)	status = Tdi0Decompile(pin->dscptrs[0], P_STMT, pout);
			if (status&1)	status = MultiStatement(0, (struct descriptor_r **)0, pout);
			if (prec < P_STMT && status&1) status = Append(")", pout);
			break;
		case OpcFor :	/*for (init;test;step) stmt*/
			if (prec < P_STMT) status = Append("(", pout);
			if (status&1)	status = Append("For (", pout);
			if (status&1)	status = Tdi0Decompile(pin->dscptrs[0], P_STMT, pout);
			if (status&1)	status = Append("; ", pout);
			if (status&1)	status = Tdi0Decompile(pin->dscptrs[1], P_STMT, pout);
			if (status&1)	status = Append("; ", pout);
			if (status&1)	status = Tdi0Decompile(pin->dscptrs[2], P_STMT, pout);
			if (status&1)	status = Append(") ", pout);
			if (status&1)	
                           status = CompoundStatement(narg-3, (struct descriptor_r **)&pin->dscptrs[3], pout);
			if (prec < P_STMT && status&1) status = Append(")", pout);
			break;
		case OpcGoto :	/*goto xxx;*/
			if (prec < P_STMT) status = Append("(", pout);
			if (status&1)	status = Append("GoTo ", pout);
			if (status&1)	status = StrAppend(pout, pin->dscptrs[0]);
			if (status&1)	status = OneStatement(0, pout);
			if (prec < P_STMT && status&1) status = Append(")", pout);
			break;
		case OpcIf :		/*if (exp) stmt else stmt*/
		case OpcWhere :	/*where (exp) stmt elsewhere stmt*/
			if (prec < P_STMT) status = Append("(", pout);
			if (status&1)	status = Append((opcode == OpcIf) ? "If (" : "Where (", pout);
			if (status&1)	status = Tdi0Decompile(pin->dscptrs[0], P_STMT, pout);
			if (status&1)	status = Append(") ", pout);
			if (status&1)	status = CompoundStatement(1, (struct descriptor_r **)&pin->dscptrs[1], pout);
			if (status&1 && narg >= 3) {
						status = Append((opcode == OpcIf) ? " Else " : " ElseWhere ", pout);
				if (status&1)	
                                   status = CompoundStatement(1, (struct descriptor_r **)&pin->dscptrs[2], pout);
			}
			if (prec < P_STMT && status&1) status = Append(")", pout);
			break;
		case OpcLabel :	/*xxx : stmt ...*/
			if (prec < P_STMT) status = Append("(", pout);
			if (status&1)	status = Append("Label ", pout);
			if (status&1)	status = StrAppend(pout, pin->dscptrs[0]);
			if (status&1)	status = Append(" : ", pout);
			if (status&1)	status = MultiStatement(narg-1, (struct descriptor_r **)&pin->dscptrs[1], pout);
			if (prec < P_STMT && status&1) status = Append(")", pout);
			break;
		case OpcReturn :	/*return (optional-exp);*/
			if (prec < P_STMT) status = Append("(", pout);
			if (status&1)	status = Append("Return (", pout);
			if (status&1)	status = Tdi0Decompile(pin->ndesc ? pin->dscptrs[0] : 0, P_STMT, pout);
			if (status&1)	status = Append(")", pout);
			if (status&1)	status = OneStatement(0, pout);
			if (prec < P_STMT && status&1) status = Append(")", pout);
			break;
		case OpcStatement :	/*{stmt ...}*/
			if (prec < P_STMT) status = Append("(", pout);
			if (status&1)	status = MultiStatement(narg, (struct descriptor_r **)&pin->dscptrs[0], pout);
			if (prec < P_STMT && status&1) status = Append(")", pout);
			break;
		case OpcSwitch :	/*switch (exp) stmt*/
		case OpcWhile :	/*while (exp) stmt*/
			if (prec < P_STMT) status = Append("(", pout);
			if (status&1)	status = Append((opcode == OpcSwitch) ? "Switch (" : "While (", pout);
			if (status&1)	status = Tdi0Decompile(pin->dscptrs[0], P_STMT, pout);
			if (status&1)	status = Append(") ", pout);
			if (status&1)	
                           status = CompoundStatement(narg-1, (struct descriptor_r **)&pin->dscptrs[1], pout);
			if (prec < P_STMT && status&1) status = Append(")", pout);
			break;
		}
		/********************
		End of opcode switch.
		********************/
		break;
	case DTYPE_CALL : /*label->label(arg, ...) or label->label:type(arg, ...)*/
		if (pin->dscptrs[0] == 0 || pin->dscptrs[0]->dtype != DTYPE_T) goto build;
		if (pin->dscptrs[1] == 0 || pin->dscptrs[1]->dtype != DTYPE_T) goto build;
		status = StrConcat((struct descriptor *)pout, (struct descriptor *)pout, pin->dscptrs[0], &ARROW, pin->dscptrs[1] MDS_END_ARG);
		if (status&1 && pin->length && pin->pointer) {
			dtype = *(char *)pin->pointer;
			if (dtype < TdiCAT_MAX)  ptext = TdiREF_CAT[dtype].name;
			else if (dtype == DTYPE_NID) ptext = "Nid";
			else if (dtype == DTYPE_PATH) ptext = "Path";
			else ptext = "%Unknown%";
					status = Append(":", pout);
			if (status&1)	status = Append(ptext , pout);
		}
		if (status&1)	status = Arguments(2, "(", ")", pin, pout);
		break;
	}
	/*******************
	End of dtype switch.
	*******************/
	return status;
}
Exemplo n.º 17
0
Block BlockChain::getBlock(const char *hash)
{
    return Block(_provider.request("eth_getBlockByHash", Arguments(hash, _fetchBlockDetails)));
}
Exemplo n.º 18
0
	AnyObjectPtr create_object(ClassPtr cls, size_t num_constructor_args, const Value* args) {
		return create_object_with_arguments(cls, Arguments(args, num_constructor_args));
	}
Exemplo n.º 19
0
Block BlockChain::getUncle(const char *blockHash, int index)
{
    return Block(_provider.request("eth_getUncleByBlockHashAndIndex", Arguments(blockHash, hex(index))));
}
Exemplo n.º 20
0
Block BlockChain::getUncle(int blockNumber, int index)
{
    return Block(_provider.request("eth_getUncleByBlockNumberAndIndex", Arguments(hex(blockNumber), hex(index))));
}
Exemplo n.º 21
0
Transaction BlockChain::getTransaction(const char *hash)
{
    return Transaction(_provider.request("eth_getTransactionByHash", Arguments(hash)));
}
Exemplo n.º 22
0
size_t BlockChain::getBlockUnclesCount(size_t blockNumber)
{
    Json::Value result = _provider.request("eth_getUncleCountByBlockNumber", Arguments(hex(blockNumber)));
    return unhex<size_t>(result.asCString());
}
Exemplo n.º 23
0
Transaction BlockChain::getBlockTransaction(size_t blockNumber, size_t index)
{
    return Transaction(_provider.request("eth_getTransactionByBlockNumberAndIndex", Arguments(hex(blockNumber), hex(index))));
}
Exemplo n.º 24
0
Transaction BlockChain::getBlockTransaction(const char *blockHash, size_t index)
{
    return Transaction(_provider.request("eth_getTransactionByBlockHashAndIndex", Arguments(blockHash, hex(index))));
}
Exemplo n.º 25
0
main(int argc, char *argv[])
{
	openlog("tpserver", LOG_PID|LOG_PERROR, LOG_DAEMON);
	Arguments(argc, argv);

	SWITCHBOARD = strdup(SWITCHBOARD);	/* I want to be able to modify it */
	char *p = strrchr(SWITCHBOARD, ':');
	if (!p)
	{	/* AF_UNIX address */
		master = socket(PF_UNIX, SOCK_STREAM, 0);
		if (master == -1)
			fatal("socket: %m");

		struct sockaddr_un my_addr = { AF_UNIX };
		strncat(my_addr.sun_path, SWITCHBOARD, sizeof(my_addr.sun_path));
		unlink(SWITCHBOARD);
		if (bind(master, (struct sockaddr *)&my_addr, sizeof my_addr) == -1)
			fatal("bind to %s: %m", my_addr.sun_path);
	}
	else
	{	/* AF_INET address */
		*p++ = 0;
		struct servent *service = getservbyname(p, "tcp");
		struct sockaddr_in my_addr;
		bzero(&my_addr, sizeof(my_addr));

		struct hostent *host = gethostbyname(SWITCHBOARD);
		if (!host)
			fatal("%s: %s", SWITCHBOARD, hstrerror(h_errno));
		bcopy(host->h_addr, &my_addr.sin_addr, host->h_length);
		my_addr.sin_family = host->h_addrtype;
		endhostent();

		my_addr.sin_port = service? service->s_port: htons(atoi(p));
		if (!ntohs(my_addr.sin_port))
			fatal("%s: No such service", p);
		endservent();

		master = socket(AF_INET, SOCK_STREAM, 0);
		if (master == -1)
			fatal("socket: %m");

		if (bind(master, (struct sockaddr *)&my_addr, sizeof my_addr) == -1)
		{
			p[-1] = ':';
			fatal("bind to %s: %m", SWITCHBOARD);
		}
	}

	if (listen(master, 5) == -1)
		fatal("listen to %s: %m", SWITCHBOARD);

	if (!DEBUG)
		switch (fork())
		{
		case -1:
			error("fork");
			exit(2);
		case 0:
			close(0);
			close(1);
			close(2);
			setsid();
			break;
		default:
			exit(0);
		}
	trap_signals();
	for (;;)
	{
		Iowait();
		debug(1, "------------------------------------------");
	}
	debug(1, "tpserver exit.  why?");
	return 15;
}
Exemplo n.º 26
0
size_t BlockChain::getTransactionsCount(const char *address)
{
    Json::Value result = _provider.request("eth_getTransactionCount", Arguments(address));
    return unhex<size_t>(result.asCString());
}