Changeset - 6a998310e0e8
[Not reviewed]
0 1 0
HanzZ - 13 years ago 2012-04-11 22:15:50
hanzz.k@gmail.com
Find serv_
1 file changed with 6 insertions and 2 deletions:
0 comments (0 inline, 0 general)
backends/libpurple/gen_dynamic_purple.py
Show inline comments
 
@@ -16,29 +16,29 @@ def handle_file(cpp):
 
	sys.stdout.write("getting used methods in " + cpp + ": ")
 
	sys.stdout.flush()
 

	
 
	counter = 0
 

	
 
	new_file = ""
 
	f = open(cpp, "r")
 
	for line in f.readlines():
 
		new_line = ""
 
		index = 0
 
		while index < len(line):
 
			new_line += line[index]
 
			if line[index:].startswith("purple_") or line[index:].startswith("wpurple_"):
 
			if line[index:].startswith("purple_") or line[index:].startswith("wpurple_") or line[index:].startswith("serv_"):
 
				if line[index:].find("=") != -1 and line[index:].find("=") < line[index:].find("("):
 
					index += 1
 
					continue
 
				if line[index-1] == "_" or line[index:].find("(") == -1 or line[index:].startswith("purple_commands_init"):
 
				if line[index-1] == "_" or line[index:].find("(") == -1 or line[index:].startswith("purple_commands_init") or line[index:].startswith("serv_addr"):
 
					index += 1
 
					continue
 
				m = line[index:line[index:].find("(")+index]
 
				new_line += m[1:] + "_wrapped("
 
				index += len(m)
 
				if not m + "(" in methods and len(m) != 0:
 
					methods += [m + "("]
 
					counter += 1
 
			index += 1
 
		new_file += new_line
 
	f.close()
 

	
 
@@ -97,29 +97,33 @@ def get_args(d):
 
	for arg in x:
 
		y = arg.split(" ")
 
		if len(y) == 1:
 
			continue
 
		args += [y[-1].replace("*", "")]
 

	
 
	return args
 

	
 
def get_name(d):
 
	x = d[:d.find("(")+1].lstrip()
 
	if x.find("wpurple_") != -1:
 
		return x[x.find("wpurple_"):]
 
	if x.find("serv_") != -1:
 
		return x[x.find("serv_"):]
 
	return x[x.find("purple_"):]
 

	
 
def get_rtype(d):
 
	if d.find("wpurple_") != -1:
 
		return d[:d.find("wpurple_")].lstrip()
 
	if d.find("serv_") != -1:
 
		return d[:d.find("serv_")].lstrip()
 
	return d[:d.find("purple_")].lstrip()
 

	
 
def output():
 
	global definitions
 

	
 
	header = open("purple_defs.h", "w")
 
	print >> header, "#pragma once"
 
	print >> header, "#ifdef WIN32"
 

	
 
	for d in definitions:
 
		#typedef void (WINAPI * purple_util_set_user_wrapped_func)(const char *dir);
 
		print >> header, "typedef", get_rtype(d), "(WINAPI *", get_name(d)[:-1] + "_wrapped_fnc)(" + get_raw_args(d) + ");"
0 comments (0 inline, 0 general)