Exemplo n.º 1
0
void writestart(struct config *cfg)
{
    FILE *out;
    char line[256], *banner;
    struct classinfo *cl;
    
    snprintf(line, 255, "%s/%s_start.c", cfg->gendir, cfg->modulename);
    out = fopen(line, "w");

    if (out == NULL)
    {
        perror(line);
        exit(20);
    }

    banner = getBanner(cfg);
    fprintf(out, banner);
    freeBanner(banner);

    writedecl(out, cfg);
    if (!(cfg->options & OPTION_NORESIDENT))
    {
	writeresident(out, cfg);
	writedeclsets(out, cfg);
	writeinitlib(out, cfg);
	if (cfg->modtype != RESOURCE)
	{
	    writeopenlib(out, cfg);
	    writecloselib(out, cfg);
	    writeexpungelib(out, cfg);
	    writeextfunclib(out, cfg);
	    if (cfg->modtype == MCC || cfg->modtype == MUI || cfg->modtype == MCP)
	        writemccquery(out, cfg);
	    else if (cfg->modtype == DATATYPE)
	        writeobtainengine(out, cfg);
	}
	writesets(out, cfg);
    }
    writefunctable(out, cfg);

    for (cl = cfg->classlist; cl != NULL; cl = cl->next)
    {
	switch (cl->classtype)
	{
	case MCC:
	case MUI:
	case MCP:
	    /* Second argument to next call: the class is not the main class if it is not
	     * the first class or the modtype is not a MUI class
	     */
	    writemccinit(out, cl != cfg->classlist || cfg->modtype != cl->classtype, cl);
	    break;
	case GADGET:
	case DATATYPE:
	case CLASS:
	case IMAGE:
	    writeclassinit(out, cl);
	    break;
	case HIDD:
	    writeoopinit(out, cl);
	    break;
	default:
	    fprintf(stdout, "Internal error: unsupported classtype in writestart\n");
	    exit(20);
	}
    }
    
    fclose(out);
}
Exemplo n.º 2
0
void writeincdefines(struct config *cfg)
{
    FILE *out;
    char line[256], *banner;
    struct functionhead *funclistit;

    snprintf(line, 255, "%s/defines/%s.h", cfg->gendir, cfg->modulename);
    out = fopen(line, "w");

    if (out == NULL)
    {
        perror(line);
        exit(20);
    }

    banner = getBanner(cfg);
    fprintf(out,
	    "#ifndef DEFINES_%s_H\n"
	    "#define DEFINES_%s_H\n"
	    "\n"
        "%s"
	    "\n"
        "/*\n"
	    "    Desc: Defines for %s\n"
	    "*/\n"
	    "\n"
	    "#include <aros/libcall.h>\n"
	    "#include <exec/types.h>\n"
	    "#include <aros/preprocessor/variadic/cast2iptr.hpp>\n"
	    "\n",
	    cfg->modulenameupper, cfg->modulenameupper, banner, cfg->modulename
    );
    freeBanner(banner);

    if (cfg->command!=DUMMY)
    {
	for (funclistit = cfg->funclist; funclistit!=NULL; funclistit = funclistit->next)
	{
	    if (!funclistit->priv && (funclistit->lvo >= cfg->firstlvo))
	    {
		if (funclistit->libcall != STACK)
		{
		    writedefineregister(out, funclistit, cfg);
		    if (!funclistit->novararg)
			writedefinevararg(out, funclistit, cfg);
		}
		else /* libcall == STACK */
		{
		    writedefinestack(out, funclistit, cfg);
		}
		
		writealiases(out, funclistit, cfg);
	    }
	}
    }
    fprintf(out,
	    "\n"
	    "#endif /* DEFINES_%s_H*/\n",
	    cfg->modulenameupper
    );
    fclose(out);
}