Exemple #1
0
static void uncrustify_start(const char *data, int data_len)
{
   /**
    * Parse the text into chunks
    */
   tokenize(data, data_len, NULL);

   /* Add the file header */
   if (cpd.file_hdr.data != NULL)
   {
      add_file_header();
   }

   /* Add the file footer */
   if (cpd.file_ftr.data != NULL)
   {
      add_file_footer();
   }

   /**
    * Change certain token types based on simple sequence.
    * Example: change '[' + ']' to '[]'
    * Note that level info is not yet available, so it is OK to do all
    * processing that doesn't need to know level info. (that's very little!)
    */
   tokenize_cleanup();

   /**
    * Detect the brace and paren levels and insert virtual braces.
    * This handles all that nasty preprocessor stuff
    */
   brace_cleanup();

   /**
    * At this point, the level information is available and accurate.
    */

   if ((cpd.lang_flags & LANG_PAWN) != 0)
   {
      pawn_prescan();
   }

   /**
    * Re-type chunks, combine chunks
    */
   fix_symbols();

   mark_comments();

   /**
    * Look at all colons ':' and mark labels, :? sequences, etc.
    */
   combine_labels();
}
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);
}