BEGIN {
		print "// Automatically-generated SDPGTK wrappers for Gtk+ events"
		print "//"
		print "// This file was generated with 'awk -f sdpgtkevents.cpp.awk sdpgtkevents.data > source/sdpgtkevents.cpp'"
		print "// Do not edit this file by hand!  Alter sdpgtkevents.cpp.awk or sdpgtkevents.data!"
		print ""
		print ""

		print "#include \"sdpgtkevents.h\""
		print ""

		FS = " "
}




# Create class ...

{
	class = $1
	signal = $2
	result = $3
	firstarg = 4

	print "///////////////////////////////////////////////////////////////////////////////"
	print "// " class " ('" signal "')"
	print ""

# Class constructor ...

	print class "::" class "(SDPCSTRING EventSignal, SDPCSTRING EventName, bool After, sdpGtkObjectContainer* EventContainer, GtkObject* EventObject) : sdpGtkObjectEvent(EventSignal, EventName, After, EventContainer, EventObject) {}"

# Connect() pure-virtual override ...

	print "void " class "::Connect() { m_EventHandler = m_After ? gtk_signal_connect_after(m_EventObject, m_EventSignal, GtkSignalFunc(RawEvent), gpointer(this)) : gtk_signal_connect(m_EventObject, m_EventSignal, GtkSignalFunc(RawEvent), gpointer(this)); }"

# Event arguments ...

	fullargs = ""
	setargs = ""
	args = ""

	for(i = firstarg; i < NF; i+=2)
		{
			if(i > firstarg)
				{
					fullargs = fullargs ", "
					args = args ", "
				}

			fullargs = fullargs $i " " $(i+1)
			setargs = setargs "m_" $(i+1) " = " $(i+1) "; "
			args = args $(i+1)
		}

# Event and raw-event handlers ...

	if(result == "void")
		{
			print "void " class "::Event(" fullargs ") { " setargs "m_EventContainer->OnEvent(this); }"
			print "void " class "::RawEvent(" fullargs ", gpointer EventData) { ((" class "*)EventData)->Event(" args "); }"
		}
	else
		{
			print result " "class "::Event(" fullargs ") { " setargs "m_EventContainer->OnEvent(this); return m_Result; }"
			print result " "class "::RawEvent(" fullargs ", gpointer EventData) { return ((" class "*)EventData)->Event(" args "); }"
		}
		
	print ""
}

