Skip site navigation (1)Skip section navigation (2)
Date:      12 Apr 2002 04:02:09 -0700
From:      Max Okumoto <okumoto@ucsd.edu>
To:        freebsd-libh@FreeBSD.ORG
Subject:   cleanup of HSystem (stage 2)
Message-ID:  <hfads96uz2.fsf@multivac.sdsc.edu>

next in thread | raw e-mail | index | archive | help

* (tcl_interface_gen.cc) Used new types defined in HSystem.h
	ClassDesc, MethodDesc, CallBackDesc


--- lib/tcl/tcl_interface_gen.cc.stage1	Fri Apr 12 03:00:27 2002
+++ lib/tcl/tcl_interface_gen.cc	Fri Apr 12 03:38:06 2002
@@ -118,11 +118,11 @@
 } /* HSystem::gen_header */
 
 void
-HSystem::gen_class_header(ostream& out, const LanguageInterface::Object::ClassDescription* aClassDescription)
+HSystem::gen_class_header(ostream& out, const ClassDesc* aClassDescription)
 {
 	out << "class " << replace_chars( aClassDescription->name, ':', '_' ) << "Access : ";
 	if ( aClassDescription->parents[0] ) {
-		for ( const LanguageInterface::Object::ClassDescription* const* pd = aClassDescription->parents; *pd; ++pd ) {
+		for ( const ClassDesc* const* pd = aClassDescription->parents; *pd; ++pd ) {
 			if ( pd != aClassDescription->parents )
 				out << ", ";
 			out << "public " << replace_chars( (*pd)->name, ':', '_' ) << "Access";
@@ -138,14 +138,14 @@
 } /* HSystem::gen_class_header */
 
 void
-HSystem::gen_callback_interfaces(ostream& out, const LanguageInterface::Object::ClassDescription* aClassDescription)
+HSystem::gen_callback_interfaces(ostream& out, const ClassDesc* aClassDescription)
 {
 	if ( aClassDescription->has_callbacks() ) {
 		out << "	virtual void activate_callback( Tcl_Interp* interp, Tcl_Obj* aCommand, Tcl_Obj* aUserData, Tcl_Obj* aArg, LanguageInterface::SpecificCallbackData& aSpecificCallbackData )\n"
 		<< "		{\n"
 		<< "			/* cerr << \"" << aClassDescription->name << " activate_callback\" << endl; */\n"
 		<< "			";
-		for ( const LanguageInterface::Object::CallbackDescription* cd = aClassDescription->callbacks; cd->type; ++cd ) {
+		for ( const CallBackDesc* cd = aClassDescription->callbacks; cd->type; ++cd ) {
 			out << "if ( dynamic_cast<" << cd->type << "*>( &aSpecificCallbackData ) != 0 ) {\n"
 			<< "				" << cd->type << "& scd = dynamic_cast<" << cd->type << "&>( aSpecificCallbackData );\n"
 			<< "				Tcl_Obj* toEval = Tcl_NewObj();\n"
@@ -180,7 +180,7 @@
 } /* HSystem::gen_callback_interfaces */
 
 void
-HSystem::gen_dynamic_methods_interfaces(ostream& out, const LanguageInterface::Object::ClassDescription* aClassDescription)
+HSystem::gen_dynamic_methods_interfaces(ostream& out, const ClassDesc* aClassDescription)
 {
 	out << "	static int methodCommand( ClientData obj, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[] )\n"
 	<< "		{\n"
@@ -209,7 +209,7 @@
 	<< "			}\n"
 	<< "			else ";
 
-	for ( const LanguageInterface::Object::MethodDescription* method = aClassDescription->methods; method->name; ++method ) {
+	for ( const MethodDesc* method = aClassDescription->methods; method->name; ++method ) {
 		if ( method->dynamic() ) {
 			cout << '\t' << method->name << endl;
 			out << "if ( !strcmp( method, \"" << method->name << "\" ) ) {\n";
@@ -226,14 +226,14 @@
 			for ( int argno = 0; argno < max_args; ++argno ) {
 				if ( !method->getOrSet() || argno != max_args - 1 ) {
 					out << prefix << LanguageInterface::method_argument_type( method->args[argno], false ) << " a" << to_string( argno );
-					if ( method->args[argno] == LanguageInterface::Object::MethodDescription::vtList || method->args[argno] == LanguageInterface::Object::MethodDescription::vtListRef || method->args[argno] == LanguageInterface::Object::MethodDescription::vtListPtr )
+					if ( method->args[argno] == MethodDesc::vtList || method->args[argno] == MethodDesc::vtListRef || method->args[argno] == MethodDesc::vtListPtr )
 						out << ";\n" << prefix << gen_method_argument( method->args[argno], argno + 3, argno + 1, false ) << ";\n";
 					else
 						out << " = " << gen_method_argument( method->args[argno], argno + 3, argno + 1, false ) << ";\n";
 				}
 			}
 
-			const bool result_present = method->result != LanguageInterface::Object::MethodDescription::vtVoid;
+			const bool result_present = method->result != MethodDesc::vtVoid;
 			if ( method->getOrSet() ) {
 				if ( method->setReturnsOld() ) {
 					out << prefix << "const " << LanguageInterface::method_result_type( method->result, false ) << " result_object = object_t->" << method->name_to_call << "( ";
@@ -246,7 +246,7 @@
 
 					out << prefix << "if ( objc - 3 == " << max_args << " ) { /* set requested */\n";
 					out << prefix << "	" << LanguageInterface::method_argument_type( method->args[max_args - 1], false ) << " a" << to_string( max_args - 1 );
-					if ( method->args[max_args - 1] == LanguageInterface::Object::MethodDescription::vtList || method->args[max_args - 1] == LanguageInterface::Object::MethodDescription::vtListRef || method->args[max_args - 1] == LanguageInterface::Object::MethodDescription::vtListPtr )
+					if ( method->args[max_args - 1] == MethodDesc::vtList || method->args[max_args - 1] == MethodDesc::vtListRef || method->args[max_args - 1] == MethodDesc::vtListPtr )
 						out << ";\n" << prefix << "	" << gen_method_argument( method->args[max_args - 1], max_args + 2, max_args, true ) << ";\n";
 					else
 						out << " = " << gen_method_argument( method->args[max_args - 1], max_args + 2, max_args, true ) << ";\n";
@@ -262,7 +262,7 @@
 				else if ( method->setReturnsNew() ) {
 					out << prefix << "if ( objc - 3 == " << max_args << " ) { /* set requested */\n";
 					out << prefix << "	" << LanguageInterface::method_argument_type( method->args[max_args - 1], false ) << " a" << to_string( max_args - 1 );
-					if ( method->args[max_args - 1] == LanguageInterface::Object::MethodDescription::vtList || method->args[max_args - 1] == LanguageInterface::Object::MethodDescription::vtListRef || method->args[max_args - 1] == LanguageInterface::Object::MethodDescription::vtListPtr )
+					if ( method->args[max_args - 1] == MethodDesc::vtList || method->args[max_args - 1] == MethodDesc::vtListRef || method->args[max_args - 1] == MethodDesc::vtListPtr )
 						out << ";\n" << prefix << "	" << gen_method_argument( method->args[max_args - 1], max_args + 2, max_args, true ) << ";\n";
 					else
 						out << " = " << gen_method_argument( method->args[max_args - 1], max_args + 2, max_args, true ) << ";\n";
@@ -285,7 +285,7 @@
 				else {
 					out << prefix << "if ( objc - 3 == " << max_args << " ) { /* set requested */\n";
 					out << prefix << "	" << LanguageInterface::method_argument_type( method->args[max_args - 1], false ) << " a" << to_string( max_args - 1 );
-					if ( method->args[max_args - 1] == LanguageInterface::Object::MethodDescription::vtList || method->args[max_args - 1] == LanguageInterface::Object::MethodDescription::vtListRef || method->args[max_args - 1] == LanguageInterface::Object::MethodDescription::vtListPtr )
+					if ( method->args[max_args - 1] == MethodDesc::vtList || method->args[max_args - 1] == MethodDesc::vtListRef || method->args[max_args - 1] == MethodDesc::vtListPtr )
 						out << ";\n" << prefix << "	" << gen_method_argument( method->args[max_args - 1], max_args + 2, max_args, true ) << ";\n";
 					else
 						out << " = " << gen_method_argument( method->args[max_args - 1], max_args + 2, max_args, true ) << ";\n";
@@ -337,7 +337,7 @@
 
 	if ( aClassDescription->parents[0] ) {
 		out << "if ( ";
-		for ( const LanguageInterface::Object::ClassDescription* const* pd = aClassDescription->parents; *pd; ++pd ) {
+		for ( const ClassDesc* const* pd = aClassDescription->parents; *pd; ++pd ) {
 			if ( pd != aClassDescription->parents )
 				out << " && ";
 			out << replace_chars( (*pd)->name, ':', '_' ) << "Access::methodCommand_object( object, method, master_interpreter, interp, objc, objv ) == TCL_ERROR";
@@ -358,11 +358,11 @@
 } /* HSystem::gen_dynamic_methods_interfaces */
 
 void
-HSystem::gen_static_method_interfaces( ostream& out, const LanguageInterface::Object::ClassDescription* aClassDescription)
+HSystem::gen_static_method_interfaces( ostream& out, const ClassDesc* aClassDescription)
 {
 	if ( aClassDescription->staticMethods() > 0 ) {
 		out << "  public:\n";
-		for ( const LanguageInterface::Object::MethodDescription* method = aClassDescription->methods; method->name; ++method ) {
+		for ( const MethodDesc* method = aClassDescription->methods; method->name; ++method ) {
 			if ( !method->dynamic() ) {
 				cout << '\t' << method->name << endl;
 
@@ -380,20 +380,20 @@
 
 				int min_args, max_args;
 				method->numberOfArgs( min_args, max_args );
-				const int max_args_in_call = method->args[max_args-1] == LanguageInterface::Object::MethodDescription::vtLanguageInterface ? max_args - 1 : max_args;
+				const int max_args_in_call = method->args[max_args-1] == MethodDesc::vtLanguageInterface ? max_args - 1 : max_args;
 				out << "				if ( objc - 2 < " << min_args << " || objc - 2 > " << max_args_in_call << " ) \n"
 				<< "					return error( interp, \"Wrong number of arguments: \", \"" << aClassDescription->name << "::" << method->name << "\", \" (was \", to_string( objc - 2 ).c_str(), \", expected " << ( min_args < max_args_in_call ? to_string( min_args ) + " to " + to_string( max_args_in_call ) : to_string( max_args_in_call ) ) << ")\", 0 );\n";
 				out << "				const char* method = \"" << method->name << "\";\n";
 				string prefix = "				";
 				for ( int argno = 0; argno < max_args; ++argno ) {
 					out << prefix << LanguageInterface::method_argument_type( method->args[argno], false ) << " a" << to_string( argno );
-					if ( method->args[argno] == LanguageInterface::Object::MethodDescription::vtList || method->args[argno] == LanguageInterface::Object::MethodDescription::vtListRef || method->args[argno] == LanguageInterface::Object::MethodDescription::vtListPtr )
+					if ( method->args[argno] == MethodDesc::vtList || method->args[argno] == MethodDesc::vtListRef || method->args[argno] == MethodDesc::vtListPtr )
 						out << ";\n" << prefix << gen_method_argument( method->args[argno], argno + 2, argno + 1, false ) << ";\n";
 					else
 						out << " = " << gen_method_argument( method->args[argno], argno + 2, argno + 1, false ) << ";\n";
 				}
 				out << prefix;
-				if ( method->result != LanguageInterface::Object::MethodDescription::vtVoid )
+				if ( method->result != MethodDesc::vtVoid )
 					out << LanguageInterface::method_result_type( method->result, false ) << " result_object = ";
 				out << aClassDescription->cxx_name << "::" << method->name_to_call << "( ";
 				for ( int argno = 0; argno < max_args; ++argno ) {
@@ -402,7 +402,7 @@
 						out << ", ";
 				}
 				out << " );\n";
-				if ( method->result != LanguageInterface::Object::MethodDescription::vtVoid ) {
+				if ( method->result != MethodDesc::vtVoid ) {
 					out << "				Tcl_SetObjResult( interp, " << gen_result_to_obj( method->result ) << " );\n";
 				}
 				else {
@@ -477,35 +477,35 @@
 
 
 string
-HSystem::gen_result_to_obj(LanguageInterface::Object::MethodDescription::Value t)
+HSystem::gen_result_to_obj(MethodDesc::Value t)
 {
-	switch ( (LanguageInterface::Object::MethodDescription::ValueType)t ) {
-	case LanguageInterface::Object::MethodDescription::vtVoid:
+	switch ( (MethodDesc::ValueType)t ) {
+	case MethodDesc::vtVoid:
 		return("Tcl_NewObj()");
-	case LanguageInterface::Object::MethodDescription::vtChar:
-	case LanguageInterface::Object::MethodDescription::vtUChar:
-	case LanguageInterface::Object::MethodDescription::vtShort:
-	case LanguageInterface::Object::MethodDescription::vtUShort:
-	case LanguageInterface::Object::MethodDescription::vtInt:
-	case LanguageInterface::Object::MethodDescription::vtUInt:
-	case LanguageInterface::Object::MethodDescription::vtLong:
-	case LanguageInterface::Object::MethodDescription::vtULong:
-	case LanguageInterface::Object::MethodDescription::vtLongLong:
-	case LanguageInterface::Object::MethodDescription::vtULongLong:
-	case LanguageInterface::Object::MethodDescription::vtBool:
-	case LanguageInterface::Object::MethodDescription::vtFloat:
-	case LanguageInterface::Object::MethodDescription::vtDouble:
-	case LanguageInterface::Object::MethodDescription::vtLongDouble:
-	case LanguageInterface::Object::MethodDescription::vtString:
-	case LanguageInterface::Object::MethodDescription::vtObject:
+	case MethodDesc::vtChar:
+	case MethodDesc::vtUChar:
+	case MethodDesc::vtShort:
+	case MethodDesc::vtUShort:
+	case MethodDesc::vtInt:
+	case MethodDesc::vtUInt:
+	case MethodDesc::vtLong:
+	case MethodDesc::vtULong:
+	case MethodDesc::vtLongLong:
+	case MethodDesc::vtULongLong:
+	case MethodDesc::vtBool:
+	case MethodDesc::vtFloat:
+	case MethodDesc::vtDouble:
+	case MethodDesc::vtLongDouble:
+	case MethodDesc::vtString:
+	case MethodDesc::vtObject:
 		return("tclLanguageInterface->cxx2tcl( result_object )");
-	case LanguageInterface::Object::MethodDescription::vtList:
-	case LanguageInterface::Object::MethodDescription::vtListRef:
-	case LanguageInterface::Object::MethodDescription::vtListPtr:
+	case MethodDesc::vtList:
+	case MethodDesc::vtListRef:
+	case MethodDesc::vtListPtr:
 		return("tclLanguageInterface->list2tcl( interp, result_object )");
-	case LanguageInterface::Object::MethodDescription::vtLanguageInterface:
+	case MethodDesc::vtLanguageInterface:
 		throw LanguageInterface::Error( string( "vtLanguageInterface cannot be used as method return type for method " ) + (const char*)t );
-	case LanguageInterface::Object::MethodDescription::vtCallbackData:
+	case MethodDesc::vtCallbackData:
 		return("tclLanguageInterface->callbackData2tcl( interp, result_object )");
 	}
 
@@ -515,56 +515,56 @@
 
 
 string
-HSystem::gen_method_argument(LanguageInterface::Object::MethodDescription::Value t, int argno, int method_argno, bool last_arg_in_set_method)
+HSystem::gen_method_argument(MethodDesc::Value t, int argno, int method_argno, bool last_arg_in_set_method)
 {
 	string result;
-	if ( t.optional() && t != LanguageInterface::Object::MethodDescription::vtList && t != LanguageInterface::Object::MethodDescription::vtListRef && t != LanguageInterface::Object::MethodDescription::vtListPtr && !last_arg_in_set_method ) {
+	if ( t.optional() && t != MethodDesc::vtList && t != MethodDesc::vtListRef && t != MethodDesc::vtListPtr && !last_arg_in_set_method ) {
 		result += string( "( objc - 1 < " ) + to_string( argno ) + " ) ? " + t.defaultValue() + " : ";
 	}
 
-	switch ( (LanguageInterface::Object::MethodDescription::ValueType)t ) {
-	case LanguageInterface::Object::MethodDescription::vtVoid:
+	switch ( (MethodDesc::ValueType)t ) {
+	case MethodDesc::vtVoid:
 		return("void");
-	case LanguageInterface::Object::MethodDescription::vtChar:
-	case LanguageInterface::Object::MethodDescription::vtUChar:
+	case MethodDesc::vtChar:
+	case MethodDesc::vtUChar:
 		result += string( "*Tcl_GetStringFromObj( objv[" ) + to_string( argno ) + "], 0 )";
 		break;
-	case LanguageInterface::Object::MethodDescription::vtShort:
-	case LanguageInterface::Object::MethodDescription::vtUShort:
-	case LanguageInterface::Object::MethodDescription::vtInt:
-	case LanguageInterface::Object::MethodDescription::vtUInt:
+	case MethodDesc::vtShort:
+	case MethodDesc::vtUShort:
+	case MethodDesc::vtInt:
+	case MethodDesc::vtUInt:
 		result += string( "TclLanguageInterface::tcl_obj2int( interp, objv[" ) + to_string( argno ) + "], method, " + to_string( method_argno ) + " )";
 		break;
-	case LanguageInterface::Object::MethodDescription::vtLong:
-	case LanguageInterface::Object::MethodDescription::vtULong:
-	case LanguageInterface::Object::MethodDescription::vtLongLong:
-	case LanguageInterface::Object::MethodDescription::vtULongLong:
+	case MethodDesc::vtLong:
+	case MethodDesc::vtULong:
+	case MethodDesc::vtLongLong:
+	case MethodDesc::vtULongLong:
 		result += string( "TclLanguageInterface::tcl_obj2long( interp, objv[" ) + to_string( argno ) + "], method, " + to_string( method_argno ) + " )";
 		break;
-	case LanguageInterface::Object::MethodDescription::vtBool:
+	case MethodDesc::vtBool:
 		result += string( "TclLanguageInterface::tcl_obj2bool( interp, objv[" ) + to_string( argno ) + "], method, " + to_string( method_argno ) + " )";
 		break;
-	case LanguageInterface::Object::MethodDescription::vtFloat:
-	case LanguageInterface::Object::MethodDescription::vtDouble:
-	case LanguageInterface::Object::MethodDescription::vtLongDouble:
+	case MethodDesc::vtFloat:
+	case MethodDesc::vtDouble:
+	case MethodDesc::vtLongDouble:
 		result += string( "TclLanguageInterface::tcl_obj2double( interp, objv[" ) + to_string( argno ) + "], method, " + to_string( method_argno ) + " )";
 		break;
-	case LanguageInterface::Object::MethodDescription::vtString:
+	case MethodDesc::vtString:
 		result += string( "TclLanguageInterface::to_string( objv[" ) + to_string( argno ) + "] )";
 		break;
-	case LanguageInterface::Object::MethodDescription::vtObject:
+	case MethodDesc::vtObject:
 		result += string( "tclLanguageInterface->tcl2object( objv[" ) + to_string( argno ) + "], (" + (const char*)t + "*)0, method, " + to_string( method_argno ) + " )";
 		break;
-	case LanguageInterface::Object::MethodDescription::vtList:
-	case LanguageInterface::Object::MethodDescription::vtListRef:
-	case LanguageInterface::Object::MethodDescription::vtListPtr:
+	case MethodDesc::vtList:
+	case MethodDesc::vtListRef:
+	case MethodDesc::vtListPtr:
 		if ( t.optional() && !last_arg_in_set_method )
 			result += string( "( objc - 1 < " ) + to_string( argno ) + " ) ? ( a" + to_string( method_argno - 1 ) + " = " + t.defaultValue() + " ) : ";
 		result += string( "tclLanguageInterface->tcl2list( a" ) + to_string( method_argno - 1 ) + ", interp, objv[" + to_string( argno ) + "], method, " + to_string( method_argno ) + " )";
 		break;
-	case LanguageInterface::Object::MethodDescription::vtLanguageInterface:
+	case MethodDesc::vtLanguageInterface:
 		return("tclLanguageInterface");
-	case LanguageInterface::Object::MethodDescription::vtCallbackData:
+	case MethodDesc::vtCallbackData:
 		result += string( "tclLanguageInterface->tcl2callbackData( interp, objv[" ) + to_string( argno ) + "] )";
 		break;
 	default:

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-libh" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?hfads96uz2.fsf>