qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kp...@apache.org
Subject svn commit: r470447 - in /incubator/qpid/trunk/qpid/gentools: org/apache/qpid/gentools/ templ.cpp/
Date Thu, 02 Nov 2006 17:46:46 GMT
Author: kpvdr
Date: Thu Nov  2 09:46:45 2006
New Revision: 470447

URL: http://svn.apache.org/viewvc?view=rev&rev=470447
Log:
Gentools C++ generator generation for AMQP_ClientOperations.h and AMQP_ServerOperations.h
now complete, but untested.

Modified:
    incubator/qpid/trunk/qpid/gentools/org/apache/qpid/gentools/AmqpDomain.java
    incubator/qpid/trunk/qpid/gentools/org/apache/qpid/gentools/AmqpDomainMap.java
    incubator/qpid/trunk/qpid/gentools/org/apache/qpid/gentools/AmqpField.java
    incubator/qpid/trunk/qpid/gentools/org/apache/qpid/gentools/AmqpFieldMap.java
    incubator/qpid/trunk/qpid/gentools/org/apache/qpid/gentools/AmqpMethod.java
    incubator/qpid/trunk/qpid/gentools/org/apache/qpid/gentools/AmqpOrdinalFieldMap.java
    incubator/qpid/trunk/qpid/gentools/org/apache/qpid/gentools/CppGenerator.java
    incubator/qpid/trunk/qpid/gentools/templ.cpp/AMQP_ClientOperations.h.tmpl
    incubator/qpid/trunk/qpid/gentools/templ.cpp/AMQP_ServerOperations.h.tmpl

Modified: incubator/qpid/trunk/qpid/gentools/org/apache/qpid/gentools/AmqpDomain.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/gentools/org/apache/qpid/gentools/AmqpDomain.java?view=diff&rev=470447&r1=470446&r2=470447
==============================================================================
--- incubator/qpid/trunk/qpid/gentools/org/apache/qpid/gentools/AmqpDomain.java (original)
+++ incubator/qpid/trunk/qpid/gentools/org/apache/qpid/gentools/AmqpDomain.java Thu Nov  2
09:46:45 2006
@@ -42,17 +42,17 @@
 		versionSet.add(version);
 	}
 
-	public String getDomainType(AmqpVersion v)
+	public String getDomainType(AmqpVersion version)
 	    throws AmqpTypeMappingException
 	{
 		Iterator<String> i = keySet().iterator();
 		while (i.hasNext())
 		{
 			String type = i.next();
-			AmqpVersionSet vs = get(type);
-			if (vs.contains(v))
+			AmqpVersionSet versionSet = get(type);
+			if (versionSet.contains(version))
 				return type;
-		} throw new AmqpTypeMappingException("Unable to find version " + v + ".");
+		} throw new AmqpTypeMappingException("Unable to find version " + version + ".");
 	}
 	
 	public boolean hasVersion(String type, AmqpVersion v)

Modified: incubator/qpid/trunk/qpid/gentools/org/apache/qpid/gentools/AmqpDomainMap.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/gentools/org/apache/qpid/gentools/AmqpDomainMap.java?view=diff&rev=470447&r1=470446&r2=470447
==============================================================================
--- incubator/qpid/trunk/qpid/gentools/org/apache/qpid/gentools/AmqpDomainMap.java (original)
+++ incubator/qpid/trunk/qpid/gentools/org/apache/qpid/gentools/AmqpDomainMap.java Thu Nov
 2 09:46:45 2006
@@ -82,22 +82,26 @@
 		}	
 	}
 
-	public String getDomainType(String domainName, AmqpVersion v)
+	public String getDomainType(String domainName, AmqpVersion version)
 	    throws AmqpTypeMappingException
 	{
-		AmqpDomain domain = get(domainName);
+		AmqpDomain domainType = get(domainName);
 		// For AMQP 8.0, primitive types were not described as domains, so
 		// return itself as the type.
-		if (domain == null)
-			return converter.getDomainType(domainName, v);
+		if (domainType == null)
+		{
+//			return converter.getDomainType(domainName, version);
+System.out.println("@DEBUG Unable to find domain " + domainName);
+			return domainName;
+		}
 		try
 		{
-			return domain.getDomainType(v);
+			return domainType.getDomainType(version);
 		}
 		catch (AmqpTypeMappingException e)
 		{
 			throw new AmqpTypeMappingException("Unable to find domain type for domain \"" + domainName
+
-				"\" version " + v + ".");
+				"\" version " + version + ".");
 		}
 	}
 	

Modified: incubator/qpid/trunk/qpid/gentools/org/apache/qpid/gentools/AmqpField.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/gentools/org/apache/qpid/gentools/AmqpField.java?view=diff&rev=470447&r1=470446&r2=470447
==============================================================================
--- incubator/qpid/trunk/qpid/gentools/org/apache/qpid/gentools/AmqpField.java (original)
+++ incubator/qpid/trunk/qpid/gentools/org/apache/qpid/gentools/AmqpField.java Thu Nov  2
09:46:45 2006
@@ -70,7 +70,7 @@
 		thisVersionList.add(version);
 	}
 	
-	public boolean isCodeTypeConsistent(Generator generator)
+	public boolean isCodeTypeConsistent(LanguageConverter converter)
 	    throws AmqpTypeMappingException
 	{
 		if (domainMap.size() == 1)
@@ -81,7 +81,7 @@
 		{
 			String domainName = itr.next();
 			AmqpVersionSet versionSet = domainMap.get(domainName);
-			String codeType = generator.getGeneratedType(domainName, versionSet.first());
+			String codeType = converter.getGeneratedType(domainName, versionSet.first());
 			if (!codeTypeList.contains(codeType))
 				codeTypeList.add(codeType);
 		}

Modified: incubator/qpid/trunk/qpid/gentools/org/apache/qpid/gentools/AmqpFieldMap.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/gentools/org/apache/qpid/gentools/AmqpFieldMap.java?view=diff&rev=470447&r1=470446&r2=470447
==============================================================================
--- incubator/qpid/trunk/qpid/gentools/org/apache/qpid/gentools/AmqpFieldMap.java (original)
+++ incubator/qpid/trunk/qpid/gentools/org/apache/qpid/gentools/AmqpFieldMap.java Thu Nov
 2 09:46:45 2006
@@ -41,7 +41,9 @@
 		return newMap;
 	}
 	
-	public AmqpOrdinalFieldMap getMapForVersion(AmqpVersion version)
+	public AmqpOrdinalFieldMap getMapForVersion(AmqpVersion version, boolean codeTypeFlag,
+		LanguageConverter converter)
+		throws AmqpTypeMappingException
 	{
 		AmqpOrdinalFieldMap ordinalFieldMap = new AmqpOrdinalFieldMap();
 		Iterator<String> fItr = keySet().iterator();
@@ -58,7 +60,11 @@
 					domain = dItr.next();
 					AmqpVersionSet versionSet = field.domainMap.get(domain);
 					if (version == null || versionSet.contains(version))
+					{
+						if (codeTypeFlag)
+							domain = converter.getGeneratedType(domain, version);
 						dFound = true;
+					}
 				}
 				
 				int ordinal = -1;
@@ -81,7 +87,7 @@
 		}
 		return ordinalFieldMap;
 	}
-	
+		
 	public boolean isDomainConsistent(Generator generator, AmqpVersionSet versionSet)
         throws AmqpTypeMappingException
 	{
@@ -104,7 +110,7 @@
 	}
 	
 	public String parseFieldMap(Method commonGenerateMethod, Method mangledGenerateMethod,
-		int indentSize, int tabSize, Generator codeGenerator)
+		int indentSize, int tabSize, LanguageConverter converter)
         throws AmqpTypeMappingException, IllegalAccessException, InvocationTargetException
 	{
 		String indent = Utils.createSpaces(indentSize);
@@ -126,19 +132,19 @@
 		{
 			String fieldName = itr.next();
 			AmqpField field = get(fieldName);
-			if (field.isCodeTypeConsistent(codeGenerator))
+			if (field.isCodeTypeConsistent(converter))
 			{
 				// All versions identical - Common declaration
 				String domainName = field.domainMap.firstKey();
 				AmqpVersionSet versionSet = field.domainMap.get(domainName);
-				String codeType = codeGenerator.getGeneratedType(domainName, versionSet.first());
+				String codeType = converter.getGeneratedType(domainName, versionSet.first());
 				if (commonGenerateMethod != null)
-					sb.append(commonGenerateMethod.invoke(codeGenerator, codeType, field, versionSet,
+					sb.append(commonGenerateMethod.invoke(converter, codeType, field, versionSet,
 					    indentSize, tabSize, itr.hasNext()));
 			}
 			else if (mangledGenerateMethod != null) // Version-mangled
 			{
-				sb.append(mangledGenerateMethod.invoke(codeGenerator, field, indentSize, tabSize,
+				sb.append(mangledGenerateMethod.invoke(converter, field, indentSize, tabSize,
 					itr.hasNext()));
 			}
 		}

Modified: incubator/qpid/trunk/qpid/gentools/org/apache/qpid/gentools/AmqpMethod.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/gentools/org/apache/qpid/gentools/AmqpMethod.java?view=diff&rev=470447&r1=470446&r2=470447
==============================================================================
--- incubator/qpid/trunk/qpid/gentools/org/apache/qpid/gentools/AmqpMethod.java (original)
+++ incubator/qpid/trunk/qpid/gentools/org/apache/qpid/gentools/AmqpMethod.java Thu Nov  2
09:46:45 2006
@@ -135,32 +135,31 @@
 		}		
 	}
 	
-	public AmqpOverloadedParameterMap getOverloadedParameterLists(AmqpVersionSet globalVersionSet)
+	public AmqpOverloadedParameterMap getOverloadedParameterLists(AmqpVersionSet globalVersionSet,
+		Generator generator)
+		throws AmqpTypeMappingException
 	{
 		AmqpOverloadedParameterMap parameterVersionMap = new AmqpOverloadedParameterMap();
 		Iterator<AmqpVersion> vItr = globalVersionSet.iterator();
 		while (vItr.hasNext())
 		{
 			AmqpVersion version = vItr.next();
-			AmqpOrdinalFieldMap ordinalFieldMap = fieldMap.getMapForVersion(version);
-			if (ordinalFieldMap.size() > 0)
+			AmqpOrdinalFieldMap ordinalFieldMap = fieldMap.getMapForVersion(version, true, generator);
+			AmqpVersionSet methodVersionSet = parameterVersionMap.get(ordinalFieldMap);
+			if (methodVersionSet == null)
 			{
-				AmqpVersionSet methodVersionSet = parameterVersionMap.get(ordinalFieldMap);
-				if (methodVersionSet == null)
-				{
-					methodVersionSet = new AmqpVersionSet();
-					methodVersionSet.add(version);
-					parameterVersionMap.put(ordinalFieldMap, methodVersionSet);
-				}
-				else
-				{
-					methodVersionSet.add(version);
-				}
+				methodVersionSet = new AmqpVersionSet();
+				methodVersionSet.add(version);
+				parameterVersionMap.put(ordinalFieldMap, methodVersionSet);
+			}
+			else
+			{
+				methodVersionSet.add(version);
 			}
 		}
 		return parameterVersionMap;
 	}
-	
+		
 	public boolean isVersionConsistent(AmqpVersionSet globalVersionSet)
 	{
 		if (!versionSet.equals(globalVersionSet))

Modified: incubator/qpid/trunk/qpid/gentools/org/apache/qpid/gentools/AmqpOrdinalFieldMap.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/gentools/org/apache/qpid/gentools/AmqpOrdinalFieldMap.java?view=diff&rev=470447&r1=470446&r2=470447
==============================================================================
--- incubator/qpid/trunk/qpid/gentools/org/apache/qpid/gentools/AmqpOrdinalFieldMap.java (original)
+++ incubator/qpid/trunk/qpid/gentools/org/apache/qpid/gentools/AmqpOrdinalFieldMap.java Thu
Nov  2 09:46:45 2006
@@ -7,6 +7,9 @@
 @SuppressWarnings("serial")
 public class AmqpOrdinalFieldMap extends TreeMap<Integer, String[]> implements Comparable
 {
+	protected static final int FIELD_DOMAIN = 1;
+	protected boolean codeTypeFlag = false;
+	
 	public int compareTo(Object obj)
 	{
 		AmqpOrdinalFieldMap o = (AmqpOrdinalFieldMap)obj;
@@ -51,5 +54,18 @@
 			}
 		}
 		return 0;
+	}
+	
+	public String toString()
+	{
+		StringBuffer sb = new StringBuffer();
+		Iterator<Integer> itr = keySet().iterator();
+		while (itr.hasNext())
+		{
+			int ordinal = itr.next();
+			String[] pair = get(ordinal);
+			sb.append("[" + ordinal + "] " + pair[0] + " : " + pair[1] + Utils.lineSeparator);
+		}
+		return sb.toString();
 	}
 }

Modified: incubator/qpid/trunk/qpid/gentools/org/apache/qpid/gentools/CppGenerator.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/gentools/org/apache/qpid/gentools/CppGenerator.java?view=diff&rev=470447&r1=470446&r2=470447
==============================================================================
--- incubator/qpid/trunk/qpid/gentools/org/apache/qpid/gentools/CppGenerator.java (original)
+++ incubator/qpid/trunk/qpid/gentools/org/apache/qpid/gentools/CppGenerator.java Thu Nov
 2 09:46:45 2006
@@ -139,6 +139,8 @@
 	public String getGeneratedType(String domainName, AmqpVersion version)
 		throws AmqpTypeMappingException
 	{
+		if (version == null)
+			version = globalVersionSet.first();
 		String domainType = globalDomainMap.getDomainType(domainName, version);
 		if (domainType == null)
 			throw new AmqpTypeMappingException("Domain type \"" + domainName +
@@ -312,13 +314,24 @@
 		String token = tline.substring(tokxStart).trim();
 		sb.delete(listMarkerStartIndex, lend);
 		
-		if (token.compareTo("${co_method_handler_get_method}") == 0)
+		// ClientOperations.h
+		if (token.compareTo("${coh_method_handler_get_method}") == 0)
 		{
-			codeSnippet = generateMethodHandlerGetMethods(model, 8);
+			codeSnippet = generateMethodHandlerGetMethods(model, false, 4);
 		}
-		else if (token.compareTo("${co_server_method_inner_class}") == 0)
+		else if (token.compareTo("${coh_inner_class}") == 0)
 		{
-			codeSnippet = generateInnerClasses(model, 8, 4);
+			codeSnippet = generateInnerClasses(model, false, 4, 4);
+		}
+		
+		// ServerOperations.h
+		else if (token.compareTo("${soh_method_handler_get_method}") == 0)
+		{
+			codeSnippet = generateMethodHandlerGetMethods(model, true, 4);
+		}
+		else if (token.compareTo("${soh_inner_class}") == 0)
+		{
+			codeSnippet = generateInnerClasses(model, true, 4, 4);
 		}
 		
 		else // Oops!
@@ -397,7 +410,7 @@
 	
 	// Methods used for generation of code snippets for ServerOperations class generation
 	
-	protected String generateMethodHandlerGetMethods(AmqpModel model, int indentSize)
+	protected String generateMethodHandlerGetMethods(AmqpModel model, boolean serverFlag, int
indentSize)
 	{
 		String indent = Utils.createSpaces(indentSize);
 		StringBuffer sb = new StringBuffer();
@@ -405,13 +418,26 @@
 		while (cItr.hasNext())
 		{
 			AmqpClass thisClass = model.classMap.get(cItr.next());
-			sb.append(indent + "virtual AMQP_ServerOperations::" +
-				thisClass.name + "Handler* get" + thisClass.name + "Handler() = 0;" + cr);
+			// Only generate for this class if there is at least one method of the
+			// required chassis (server/client flag).
+			boolean chassisFoundFlag = false;
+			Iterator<String> mItr = thisClass.methodMap.keySet().iterator();
+			while (mItr.hasNext() && !chassisFoundFlag)
+			{
+				AmqpMethod method = thisClass.methodMap.get(mItr.next());
+				boolean clientChassisFlag = method.clientMethodFlagMap.isSet();
+				boolean serverChassisFlag = method.serverMethodFlagMap.isSet();
+				if ((serverFlag && serverChassisFlag) || (!serverFlag && clientChassisFlag))
+					chassisFoundFlag = true;
+			}
+			if (chassisFoundFlag)
+				sb.append(indent + "virtual AMQP_ServerOperations::" +
+				    thisClass.name + "Handler* get" + thisClass.name + "Handler() = 0;" + cr);
 		}
 		return sb.toString();
 	}
 	
-	protected String generateInnerClasses(AmqpModel model, int indentSize, int tabSize)
+	protected String generateInnerClasses(AmqpModel model, boolean serverFlag, int indentSize,
int tabSize)
 		throws AmqpTypeMappingException
 	{
 		String indent = Utils.createSpaces(indentSize);
@@ -425,6 +451,8 @@
 			String className = thisClass.name + "Handler";
 			if (!first)
 				sb.append(cr);
+			sb.append(indent + "// ==================== class " + className +
+				" ====================" + cr);
 			sb.append(indent + "class " + className);
 			if (thisClass.versionSet.size() != globalVersionSet.size())
 				sb.append(" // AMQP Version(s) " + thisClass.versionSet + cr);
@@ -444,14 +472,14 @@
 			sb.append(cr);
 			sb.append(indent + tab + "// Protocol methods" + cr);
 			sb.append(cr);
-			sb.append(generateInnerClassMethods(thisClass, indentSize + tabSize, tabSize));
+			sb.append(generateInnerClassMethods(thisClass, serverFlag, indentSize + tabSize, tabSize));
 			sb.append(indent + "}; // class " + className + cr);
 			first = false;
 		}
 		return sb.toString();		
 	}
 	
-	protected String generateInnerClassMethods(AmqpClass thisClass, int indentSize, int tabSize)
+	protected String generateInnerClassMethods(AmqpClass thisClass, boolean serverFlag, int
indentSize, int tabSize)
 		throws AmqpTypeMappingException
 	{
 		String indent = Utils.createSpaces(indentSize);
@@ -461,22 +489,28 @@
 		while (mItr.hasNext())
 		{
 			AmqpMethod method = thisClass.methodMap.get(mItr.next());
-			AmqpOverloadedParameterMap overloadededParameterMap = method.getOverloadedParameterLists(globalVersionSet);
-			Iterator<AmqpOrdinalFieldMap> ofmItr = overloadededParameterMap.keySet().iterator();
-			String methodName = parseForReservedWords(method.name, thisClass.name);
-			while (ofmItr.hasNext())
-			{
-				AmqpOrdinalFieldMap fieldMap = ofmItr.next();
-				AmqpVersionSet versionSet = overloadededParameterMap.get(fieldMap);
-				if (!first)
-					sb.append(cr);
-				sb.append(indent + "virtual void " + methodName + "(");
-				sb.append(generateMethodParameterList(fieldMap, indentSize + (5*tabSize)));
-				if (versionSet.size() != globalVersionSet.size())
-					sb.append(") = 0; // AMQP Version(s) " + versionSet + cr);
-				else
-					sb.append(") = 0;" + cr);
-				first = false;
+			boolean clientChassisFlag = method.clientMethodFlagMap.isSet();
+			boolean serverChassisFlag = method.serverMethodFlagMap.isSet();
+			if ((serverFlag && serverChassisFlag) || (!serverFlag && clientChassisFlag))
+			{
+				String methodName = parseForReservedWords(method.name, thisClass.name);				
+				AmqpOverloadedParameterMap overloadededParameterMap =
+					method.getOverloadedParameterLists(thisClass.versionSet, this);
+				Iterator<AmqpOrdinalFieldMap> ofmItr = overloadededParameterMap.keySet().iterator();
+				while (ofmItr.hasNext())
+				{
+					AmqpOrdinalFieldMap fieldMap = ofmItr.next();
+					AmqpVersionSet versionSet = overloadededParameterMap.get(fieldMap);
+					if (!first)
+						sb.append(cr);
+					sb.append(indent + "virtual void " + methodName + "( u_int16_t channel");
+					sb.append(generateMethodParameterList(fieldMap, indentSize + (5*tabSize)));
+					if (versionSet.size() != globalVersionSet.size())
+						sb.append(" ) = 0; // AMQP Version(s) " + versionSet + cr);
+					else
+						sb.append(" ) = 0;" + cr);
+					first = false;
+				}
 			}
 		}
 		return sb.toString();		
@@ -492,10 +526,10 @@
 		while(pItr.hasNext())
 		{
 			String[] field = fieldMap.get(pItr.next());
-			String codeType = getGeneratedType(field[FIELD_DOMAIN], globalVersionSet.first());
-			if (!first)
-				sb.append(indent);
-			sb.append(setRef(codeType) + " " + field[FIELD_NAME] + (pItr.hasNext() ? "," + cr : ""));
+			if (first)
+				sb.append("," + cr);
+			sb.append(indent + setRef(field[FIELD_DOMAIN]) + " " + field[FIELD_NAME] +
+				(pItr.hasNext() ? "," + cr : ""));
 			first = false;
 		}
 		return sb.toString();		
@@ -616,7 +650,7 @@
 		String indent = Utils.createSpaces(indentSize);
 		StringBuffer sb = new StringBuffer();
 		ArrayList<String> bitFieldList = new ArrayList<String>();
-		AmqpOrdinalFieldMap ordinalFieldMap = fieldMap.getMapForVersion(version);
+		AmqpOrdinalFieldMap ordinalFieldMap = fieldMap.getMapForVersion(version, false, this);
 		Iterator<Integer> oItr = ordinalFieldMap.keySet().iterator();
 		int ordinal = 0;
 		while (oItr.hasNext())
@@ -626,9 +660,9 @@
 			AmqpVersion thisVersion = version == null ? globalVersionSet.first() : version;
 			String domainType = getDomainType(fieldDomainPair[FIELD_DOMAIN], thisVersion);
 			
-			// Defer bit types by adding them to an array. When the first non-bit type is
-			// encountered, then handle the bits. This allows consecutive bits to be placed
-			// into the same byte(s) - 8 bits to the byte.
+			// Defer bit types by adding them to an array. When the first subsequent non-bit
+			// type is encountered, then handle the bits. This allows consecutive bits to be
+			// placed into the same byte(s) - 8 bits to the byte.
 			if (domainType.compareTo("bit") == 0)
 			{
 				bitFieldList.add(fieldDomainPair[FIELD_NAME]);
@@ -675,7 +709,7 @@
 		String indent = Utils.createSpaces(indentSize);
 		StringBuffer sb = new StringBuffer();
 		ArrayList<String> bitFieldList = new ArrayList<String>();
-		AmqpOrdinalFieldMap ordinalFieldMap = fieldMap.getMapForVersion(version);
+		AmqpOrdinalFieldMap ordinalFieldMap = fieldMap.getMapForVersion(version, false, this);
 		Iterator<Integer> oItr = ordinalFieldMap.keySet().iterator();
 		int ordinal = 0;
 		while (oItr.hasNext())
@@ -685,9 +719,9 @@
 			AmqpVersion thisVersion = version == null ? globalVersionSet.first() : version;
 			String domainType = getDomainType(fieldDomainPair[FIELD_DOMAIN], thisVersion);
 			
-			// Defer bit types by adding them to an array. When the first non-bit type is
-			// encountered, then handle the bits. This allows consecutive bits to be placed
-			// into the same byte(s) - 8 bits to the byte.
+			// Defer bit types by adding them to an array. When the first subsequent non-bit
+			// type is encountered, then handle the bits. This allows consecutive bits to be
+			// placed into the same byte(s) - 8 bits to the byte.
 			if (domainType.compareTo("bit") == 0)
 			{
 				bitFieldList.add(fieldDomainPair[FIELD_NAME]);
@@ -743,7 +777,7 @@
 		String indent = Utils.createSpaces(indentSize);
 		StringBuffer sb = new StringBuffer();
 		ArrayList<String> bitFieldList = new ArrayList<String>();
-		AmqpOrdinalFieldMap ordinalFieldMap = fieldMap.getMapForVersion(version);
+		AmqpOrdinalFieldMap ordinalFieldMap = fieldMap.getMapForVersion(version, false, this);
 		Iterator<Integer> oItr = ordinalFieldMap.keySet().iterator();
 		int ordinal = 0;
 		while (oItr.hasNext())
@@ -753,9 +787,9 @@
 			AmqpVersion thisVersion = version == null ? globalVersionSet.first() : version;
 			String domainType = getDomainType(fieldDomainPair[FIELD_DOMAIN], thisVersion);
 			
-			// Defer bit types by adding them to an array. When the first non-bit type is
-			// encountered, then handle the bits. This allows consecutive bits to be placed
-			// into the same byte(s) - 8 bits to the byte.
+			// Defer bit types by adding them to an array. When the first subsequent non-bit
+			// type is encountered, then handle the bits. This allows consecutive bits to be
+			// placed into the same byte(s) - 8 bits to the byte.
 			if (domainType.compareTo("bit") == 0)
 			{
 				bitFieldList.add(fieldDomainPair[FIELD_NAME]);
@@ -809,95 +843,26 @@
 	{
 		String indent = Utils.createSpaces(indentSize);
 		StringBuffer sb = new StringBuffer();
-		AmqpOrdinalFieldMap ordinalFieldMap = fieldMap.getMapForVersion(version);
+		AmqpOrdinalFieldMap ordinalFieldMap = fieldMap.getMapForVersion(version, true, this);
 		Iterator<Integer> oItr = ordinalFieldMap.keySet().iterator();
 		int ordinal = 0;
 		while (oItr.hasNext())
 		{
 			ordinal = oItr.next();
 			String[] fieldDomainPair = ordinalFieldMap.get(ordinal);
-			AmqpVersion thisVersion = version == null ? globalVersionSet.first() : version;
-			String codeType = getGeneratedType(fieldDomainPair[FIELD_DOMAIN], thisVersion);
-			sb.append(indent + (defineFlag ? codeType + " " : "") +
+			sb.append(indent + (defineFlag ? fieldDomainPair[FIELD_DOMAIN] + " " : "") +
 				fieldDomainPair[FIELD_NAME] + (initializerFlag ? "(" + fieldDomainPair[FIELD_NAME] +
")" : "") +
 				(oItr.hasNext() ? "," : "") + cr);
 		}
 		return sb.toString();				
 	}
-//	protected String generateMbParamList(String codeType, AmqpField field,
-//		AmqpVersionSet versionSet, int indentSize, int tabSize, boolean nextFlag)
-//	{
-//		return mbParamList(codeType, field, versionSet, indentSize, nextFlag, false, false);
-//	}
-//	
-//	protected String generateMbMangledParamList(AmqpField field, int indentSize,
-//		int tabSize, boolean nextFlag)
-//		throws AmqpTypeMappingException
-//	{
-//		return mbMangledParamList(field, indentSize, nextFlag, false, false);
-//	}
-//	
-//	protected String generateMbParamDeclareList(String codeType, AmqpField field,
-//		AmqpVersionSet versionSet, int indentSize, int tabSize, boolean nextFlag)
-//	{
-//		return mbParamList(codeType, field, versionSet, indentSize, nextFlag, true, false);
-//	}
-//	
-//	protected String generateMbMangledParamDeclareList(AmqpField field, int indentSize,
-//		int tabSize, boolean nextFlag)
-//		throws AmqpTypeMappingException
-//	{
-//		return mbMangledParamList(field, indentSize, nextFlag, true, false);
-//	}
-//	
-//	protected String generateMbParamInitList(String codeType, AmqpField field,
-//		AmqpVersionSet versionSet, int indentSize, int tabSize, boolean nextFlag)
-//	{
-//		return mbParamList(codeType, field, versionSet, indentSize, nextFlag, false, true);
-//	}
-//	
-//	protected String generateMbMangledParamInitList(AmqpField field, int indentSize,
-//		int tabSize, boolean nextFlag)
-//		throws AmqpTypeMappingException
-//	{
-//		return mbMangledParamList(field, indentSize, nextFlag, false, true);
-//	}
-//	
-//	protected String mbParamList(String codeType, AmqpField field, AmqpVersionSet versionSet,
-//		int indentSize, boolean nextFlag, boolean defineFlag, boolean initializerFlag)
-//		{
-//			return Utils.createSpaces(indentSize) + (defineFlag ? codeType + " " : "") +
-//				field.name + (initializerFlag ? "(" + field.name + ")" : "") +
-//				(nextFlag ? "," : "") + " /* AMQP version(s): " + versionSet + " */" + cr;
-//		}
-//	
-//	protected String mbMangledParamList(AmqpField field, int indentSize,
-//		boolean nextFlag, boolean defineFlag, boolean initializerFlag)
-//		throws AmqpTypeMappingException
-//	{
-//		StringBuffer sb = new StringBuffer();
-//		Iterator<String> dItr = field.domainMap.keySet().iterator();
-//		int domainCntr = 0;
-//		while (dItr.hasNext())
-//		{
-//			String domainName = dItr.next();
-//			AmqpVersionSet versionSet = field.domainMap.get(domainName);
-//			String codeType = getGeneratedType(domainName, versionSet.first());
-//			sb.append(Utils.createSpaces(indentSize) + (defineFlag ? codeType + " " : "") +
-//				field.name + "_" + domainCntr +
-//				(initializerFlag ? "(" + field.name + "_" + domainCntr + ")" : "") +
-//				(nextFlag ? "," : "") + " /* AMQP version(s): " + versionSet + " */" + cr);
-//			domainCntr++;
-//		}
-//		return sb.toString();		
-//	}
 	
 	private String parseForReservedWords(String methodName, String className)
 	{
 		for (int i=0; i<cppReservedWords.length; i++)
 			if (methodName.compareTo(cppReservedWords[i]) == 0)
 			{
-				System.err.println("WARNING: Found method \"" + methodName +
+				System.out.println("WARNING: Found method \"" + methodName +
 					"\" in class \"" + className +
 					"\", which is a C/C++ reserved word. " +
 					"Changing generated method name to \"" + methodName + "_\".");

Modified: incubator/qpid/trunk/qpid/gentools/templ.cpp/AMQP_ClientOperations.h.tmpl
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/gentools/templ.cpp/AMQP_ClientOperations.h.tmpl?view=diff&rev=470447&r1=470446&r2=470447
==============================================================================
--- incubator/qpid/trunk/qpid/gentools/templ.cpp/AMQP_ClientOperations.h.tmpl (original)
+++ incubator/qpid/trunk/qpid/gentools/templ.cpp/AMQP_ClientOperations.h.tmpl Thu Nov  2 09:46:45
2006
@@ -34,16 +34,28 @@
 
 class AMQP_ClientOperations
 {
-    public:
-        AMQP_ClientOperations() {}
-        virtual ~AMQP_ClientOperations() {}
-{so_get_amqp_major}
-{so_get_amqp_minor}
+private:
+    u_int8_t major;
+    u_int8_t minor;
 
-	// Method handler get methods
-{CLIST} {co_method_handler_get_method}
+public:
+    AMQP_ClientOperations(u_int8_t major, u_int8_t minor) : major(major), minor(minor) {}
+    virtual ~AMQP_ClientOperations() {}
 
-{CLIST} {co_cleint method_inner_class}
+    inline u_int8_t getMajor() { return major; }
+    inline u_int8_t getMinor() { return minor; }
+    inline isVersion(u_int8_t _major, u_int8_t _minor)
+    {
+        return major == _major && minor == _minor;
+    }
+
+    // Method handler get methods
+
+%{CLIST} ${coh_method_handler_get_method}
+
+    // Inner classes
+
+%{CLIST} ${coh_inner_class}
 
 }; /* class AMQP_ClientOperations */
 

Modified: incubator/qpid/trunk/qpid/gentools/templ.cpp/AMQP_ServerOperations.h.tmpl
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/gentools/templ.cpp/AMQP_ServerOperations.h.tmpl?view=diff&rev=470447&r1=470446&r2=470447
==============================================================================
--- incubator/qpid/trunk/qpid/gentools/templ.cpp/AMQP_ServerOperations.h.tmpl (original)
+++ incubator/qpid/trunk/qpid/gentools/templ.cpp/AMQP_ServerOperations.h.tmpl Thu Nov  2 09:46:45
2006
@@ -34,27 +34,28 @@
 
 class AMQP_ServerOperations
 {
-	private:
-		u_int8_t major;
-		u_int8_t minor;
-    public:
-        AMQP_ServerOperations(u_int8_t major, u_int8_t minor) : major(major), minor(minor)
{}
-        virtual ~AMQP_ServerOperations() {}
-        
-        inline u_int8_t getMajor() { return major; }
-        inline u_int8_t getMinor() { return minor; }
-        inline isVersion(u_int8_t _major, u_int8_t _minor)
-        {
-        	return major == _major && minor == _minor;
-        }
-
-		// Method handler get methods
-	
-%{CLIST} ${co_method_handler_get_method}
+private:
+    u_int8_t major;
+    u_int8_t minor;
 
-		// Inner classes
+public:
+    AMQP_ServerOperations(u_int8_t major, u_int8_t minor) : major(major), minor(minor) {}
+    virtual ~AMQP_ServerOperations() {}
 
-%{CLIST} ${co_server_method_inner_class}
+    inline u_int8_t getMajor() { return major; }
+    inline u_int8_t getMinor() { return minor; }
+    inline isVersion(u_int8_t _major, u_int8_t _minor)
+    {
+        return major == _major && minor == _minor;
+    }
+
+    // Method handler get methods
+
+%{CLIST} ${soh_method_handler_get_method}
+
+    // Inner classes
+
+%{CLIST} ${soh_inner_class}
 
 }; /* class AMQP_ServerOperations */
 



Mime
View raw message