コード例 #1
0
ファイル: export.c プロジェクト: tulip5/tulip
/*
 * Generate the XML for an overload.
 */
static void xmlOverload(sipSpec *pt, moduleDef *mod, classDef *scope,
        memberDef *md, overDef *od, classDef *xtnds, int stat, int indent,
        FILE *fp)
{
    const char *name, *cppname = od->cppname;
    int a, no_res;

    xmlIndent(indent++, fp);
    fprintf(fp, "<Function name=\"");

    if (isReflected(od))
    {
        if ((name = reflectedSlot(md->slot)) != NULL)
            cppname = name;
        else
            name = md->pyname->text;
    }
    else
    {
        name = md->pyname->text;
    }

    prScopedPythonName(fp, scope, name);

    fprintf(fp, "\"");

    xmlRealScopedName(scope, cppname, fp);

    if (hasCppSignature(od->cppsig))
    {
        fprintf(fp, " cppsig=\"");
        xmlCppSignature(fp, od->cppsig, isConst(od));
        fprintf(fp, "\"");
    }

    if (isAbstract(od))
        fprintf(fp, " abstract=\"1\"");

    if (stat)
        fprintf(fp, " static=\"1\"");

    if (isSlot(od))
        fprintf(fp, " slot=\"1\"");

    if (isVirtual(od))
    {
        fprintf(fp, " virtual=\"1\"");
    }

    if (xtnds != NULL)
    {
        fprintf(fp, " extends=\"");
        prScopedPythonName(fp, xtnds->ecd, xtnds->pyname->text);
        fprintf(fp, "\"");
    }

    /* An empty type hint specifies a void return. */
    if (od->pysig.result.typehint_out != NULL && od->pysig.result.typehint_out->raw_hint[0] == '\0')
        no_res = TRUE;
    else
        no_res = (od->pysig.result.atype == void_type && od->pysig.result.nrderefs == 0);

    /* Handle the trivial case. */
    if (no_res && od->pysig.nrArgs == 0)
    {
        fprintf(fp, "/>\n");
        return;
    }

    fprintf(fp, ">\n");

    if (!no_res)
        xmlArgument(pt, mod, &od->pysig.result, TRUE, NoKwArgs,
                isResultTransferredBack(od), indent, fp);

    for (a = 0; a < od->pysig.nrArgs; ++a)
    {
        argDef *ad = &od->pysig.args[a];

        /*
         * Ignore the first argument of non-reflected number slots and the
         * second argument of reflected number slots.
         */
        if (isNumberSlot(md) && od->pysig.nrArgs == 2)
            if ((a == 0 && !isReflected(od)) || (a == 1 && isReflected(od)))
                continue;

        if (isInArg(ad))
            xmlArgument(pt, mod, ad, FALSE, od->kwargs, FALSE, indent, fp);

        if (isOutArg(ad))
            xmlArgument(pt, mod, ad, TRUE, od->kwargs, FALSE, indent, fp);
    }

    xmlIndent(--indent, fp);
    fprintf(fp, "</Function>\n");
}
コード例 #2
0
ファイル: RayTracer.cpp プロジェクト: jefchavesfer/H3DGE
//Tree for the secondary rays
node* treeGenerator( node** freeRayNodes, int hmax,
                     node *currNode, scene *myScene ) {
	node * result;
	int type1 = REFRACTED_RAY;
	int state1 = INSIDE;
	coord param_t = 0;
	triangle* current_fig = NULL;

	if ( currNode->level < hmax )
	{
		//printf("is reflect verification\n");
		if ( isReflected( currNode, myScene, &current_fig, &param_t ) == 1
		     && ( currNode->state == OUTSIDE || currNode->state == ROOT_RAY ) )
			// On est reste ici
		{
			result = requestNode( freeRayNodes );
			if( result == NULL )
			{
				return result;
			}
			// void initNode( node* curNode, node* parent, kdTreeNode* packet,
			//                ray r, triangle* trigIntersected, int h,
			//                int type, int state)
			initNode( result,
			          currNode,
			          currNode->currentPacket,
			          createReflected( currNode->v,
			                           myScene,
			                           current_fig,
			                           param_t ),
			          currNode->lastIntercepted,
			          currNode->level + 1,
			          REFLECTED_RAY ,
			          OUTSIDE );
			currNode->left = result;
			return result;
		}
		//printf("is refracted verification\n");
		if ( isRefracted( currNode, myScene, &current_fig, &param_t ) == 1 )
		{
			result = requestNode( freeRayNodes );
			if( result == NULL )
			{
				return result;
			}
			ray r_rf = createRefracted( currNode->v,
			                            myScene,
			                            currNode->state,
			                            &type1,
			                            &state1,
			                            current_fig,
			                            param_t );
			initNode( result,
			          currNode,
			          currNode->currentPacket,
			          r_rf,
			          currNode->lastIntercepted,
			          currNode->level + 1,
			          type1,
			          state1 );
			currNode->right = result;
			return result;
		}
	}

	node * current = currNode->parent;

	while ( current != 0 )
	{
		//printf("is refracted verification - returning\n");
		if( isRefracted( currNode, myScene, &current_fig, &param_t ) == 1 )
			break;
		current = current->parent;
	}

	if ( current == 0 ) {
		return 0;
	}

	result = requestNode( freeRayNodes );
	if ( result != NULL )
	{
		ray r_rf = createRefracted( current->v,
		                            myScene,
		                            current->state,
		                            &type1,
		                            &state1,
		                            current_fig,
		                            param_t );
		initNode( result,
		          current,
		          current->currentPacket,
		          r_rf,
		          current->lastIntercepted,
		          current->level + 1,
		          type1,
		          state1 );
		current->right = result;
	}
	else
	{
		printf(" no node available\n");
	}
	return result;
}