Exemplo n.º 1
0
int buffer_to_output(char *pBuffer, FILE *pOutput)
{
    int iRetval = 0;
    macro_list *pMacros = NULL;

    /*  Tokenize the macros and their corresponding values.
     */
    pMacros = extract_macros(pBuffer);
    if(pMacros != NULL) {
	/*  Perform forward to backslash conversion on those macros known to be
	 *      path information only.
	 */
	slash_convert(pMacros, "JBOOTDIRS");
	slash_convert(pMacros, "JDIRS");
	slash_convert(pMacros, "DEPTH");
	slash_convert(pMacros, "NS_DEPTH");
	slash_convert(pMacros, "PACKAGE");
	slash_convert(pMacros, "JMC_GEN_DIR");
	slash_convert(pMacros, "DIST_PUBLIC");

	/*  Process some of the macros, and convert them
	 *      into different macros with different data.
	 */
	morph_macro(&pMacros, "JMC_GEN", "JMC_HEADERS", "$(JMC_GEN_DIR)\\%s.h");
	morph_macro(&pMacros, "JMC_GEN", "JMC_STUBS", "$(JMC_GEN_DIR)\\%s.c");
	morph_macro(&pMacros, "JMC_GEN", "JMC_OBJS", ".\\$(OBJDIR)\\%s.obj");
	morph_macro(&pMacros, "CSRCS", "C_OBJS", ".\\$(OBJDIR)\\%s.obj");
	morph_macro(&pMacros, "CPPSRCS", "CPP_OBJS", ".\\$(OBJDIR)\\%s.obj");
	morph_macro(&pMacros, "REQUIRES", "LINCS", "-I$(XPDIST)\\public\\%s");

	create_classroot( &pMacros );

	/*  Output the Macros and the corresponding values.
	 */
	iRetval = write_macros(pMacros, pOutput);

	/*  Output rule file inclusion
	 */
	if(iRetval == 0)    {
	    iRetval = output_rules(pOutput);
	}

	/*  Output explicit build rules/dependencies for JMC_GEN.
	 */
	if(iRetval == 0)    {
	    iRetval = explicit_rules(pMacros, "JMC_GEN", pOutput);
	}

	if(iRetval == 0)    {
	    iRetval = output_end(pOutput);
	}
	/*  Free off the macro list.
	 */
	free_macro_list(pMacros);
	pMacros = NULL;
    }

    return(iRetval);
}
Exemplo n.º 2
0
void constructor_header(std::string & save_directory,int paramCount)
{
	std::string fileName("cpp_constructor.h");
	std::string file = save_directory + fileName;
	std::ofstream f( file.c_str() );
	include_guard_top(f,"OOLUA_CPP_CONSTRUCTOR_H_");
	add_file_header(f,fileName);
	
	include_header(f,"lua_includes.h");
	include_header(f,"oolua_storage.h");
	include_header(f,"param_traits.h");
	include_header(f,"oolua_userdata.h");
	include_header(f,"member_func_helper.h");
	include_header(f,"oolua_parameter_helper.h");
	include_header(f,"oolua_converters.h");
	
	f<<"namespace OOLUA\n{\nnamespace INTERNAL\n{\n";
	
    f<<"template<typename ObjType>\n"
	<<"void add_and_set_gc(lua_State* l,ObjType obj)\n"
	<<"{\n"
	<<tab<<"Lua_ud* ud = add_ptr(l,obj,false);\n"
	<<tab<<"userdata_gc_value(ud,true);\n"
	<<"}\n\n";
    
	write_default_constructor(f);
	
	for(int i = 1;i <= paramCount; ++i)
		write_constructor_with_parameters(f,i);
	
	f<<"\n}\n}\n";//end namespace
	
	write_macros(f,paramCount);
	
	include_guard_bottom(f);
}