foreach $i (@g_EnumFunc)
{
	$i =~ s/\s//g;
	$XXX{$i} = "1";
}

$dd_fin = "../DynamicDraw/${g_FileName}.cpp";
$dd_fout = "${g_FileName}.cpp";

$l_DefMode = "0";
$l_DefFunc = "";
$l_DefFuncX = "";
$l_IsPrintMode = "0";
$l_bIsRawMode = "0";

open(DD_FIN, "${dd_fin}") || die "Cannot open ${dd_fin}\n";
open(DD_FOUT, ">${dd_fout}") || die "Cannot open ${dd_fout}\n";

print DD_FOUT "#include \"StdAfx.h\"\n";
foreach $i (@g_IncludeCpp)
{
	print DD_FOUT "#include $i\n";
}
print DD_FOUT "#include \"${g_FileName}.h\"\n";

WID:while (<DD_FIN>)
{
	if (/<EXPORT TO SERVER>/)
	#----- _xZkqqHx_jAiCiCoKjHkMiClFiDiCiBfLiDgIiKeKiOgO_xHqqkZx_ <EXPORT TO SDK>_xZkqqHx_iCmMiPoKiNiH_xHqqkZx_ -----
	{
		$l_bIsRawMode = "1";
		next WID;
	}
	elsif (/<\/EXPORT TO SERVER>/)
	#----- _xZkqqHx_jAiCiCoKjHkMiClFiDiCiBfLiDgIiPeJjHlJ_xHqqkZx_ <\/EXPORT TO SDK>_xZkqqHx_iCmMiPoKiNiH_xHqqkZx_ -----
	{
		$l_bIsRawMode = "0";
		next WID;
	}
	elsif ($l_bIsRawMode eq "1")
	#----- _xZkqqHx_jAiCiCoKjHkMiClFiDiCiBfLiDgI_xHqqkZx_ <EXPORT TO SDK>_xZkqqHx_jCiGiCmMiPoKiNiH_xHqqkZx_ -----
	{
		print DD_FOUT;
		next WID;
	}

	if ($l_DefMode eq "0")
	{
		if (/^\w/)
		{
			if (!/;/ and !/\\/)
			{
				$l_DefMode = "1";
			}
		}
	} elsif ($l_DefMode eq "1")
	{
		if (/^{/)
		{
			$l_DefMode = "2";
		}
	}

	if ($l_DefMode eq "1")
	{
		$l_DefFunc .= $_;
		$l_ = $_;
		$l_ =~ s/\/\/.*$//;
		$l_DefFuncX .= $l_;
	} elsif ($l_DefMode eq "2")
	{
		$l_DefFuncX =~ s/\s+/ /g;
		$l_DefFuncX =~ s/^[^\(]+\s+([^\s]+\s*\(.*\))[^\)]*$/$1/;
		$l_DefFuncX =~ s/\s//g;

		if ($XXX{$l_DefFuncX} eq "1")
		{
			$l_IsPrintMode = "1";
			print DD_FOUT "\n";
			print DD_FOUT $l_DefFunc;
		}
		$l_DefFuncX = "";
		$l_DefFunc = "";
	}

	if ($l_IsPrintMode eq "1")
	{
		print DD_FOUT;
	}

	if ($l_DefMode eq "2")
	{
		$l_DefMode = "3";
	} elsif ($l_DefMode eq "3")
	{
		if (/^}/)
		{
			$l_DefMode = "0";
			$l_IsPrintMode = "0";
		}
	}
}

close DD_FIN;
close DD_FOUT;

print "OK\n";

