[openrtm-commit:00903] r364 - in trunk/rtmtools/jp.go.aist.rtm.rtcbuilder: src/jp/go/aist/rtm/rtcbuilder/generator test/jp/go/aist/rtm/rtcbuilder/_test/com

openrtm @ openrtm.org openrtm @ openrtm.org
2012年 11月 5日 (月) 12:39:09 JST


Author: 
Date: 2012-11-05 12:39:08 +0900 (Mon, 05 Nov 2012)
New Revision: 364

Modified:
   trunk/rtmtools/jp.go.aist.rtm.rtcbuilder/src/jp/go/aist/rtm/rtcbuilder/generator/IDLParamConverter.java
   trunk/rtmtools/jp.go.aist.rtm.rtcbuilder/test/jp/go/aist/rtm/rtcbuilder/_test/com/CORBAParseTypeTest.java
Log:
Modified for nested IDL module

Modified: trunk/rtmtools/jp.go.aist.rtm.rtcbuilder/src/jp/go/aist/rtm/rtcbuilder/generator/IDLParamConverter.java
===================================================================
--- trunk/rtmtools/jp.go.aist.rtm.rtcbuilder/src/jp/go/aist/rtm/rtcbuilder/generator/IDLParamConverter.java	2012-11-04 16:22:03 UTC (rev 363)
+++ trunk/rtmtools/jp.go.aist.rtm.rtcbuilder/src/jp/go/aist/rtm/rtcbuilder/generator/IDLParamConverter.java	2012-11-05 03:39:08 UTC (rev 364)
@@ -11,6 +11,7 @@
 import jp.go.aist.rtm.rtcbuilder.corba.idl.parser.syntaxtree.NodeToken;
 import jp.go.aist.rtm.rtcbuilder.corba.idl.parser.syntaxtree.array_declarator;
 import jp.go.aist.rtm.rtcbuilder.corba.idl.parser.syntaxtree.base_type_spec;
+import jp.go.aist.rtm.rtcbuilder.corba.idl.parser.syntaxtree.definition;
 import jp.go.aist.rtm.rtcbuilder.corba.idl.parser.syntaxtree.enum_type;
 import jp.go.aist.rtm.rtcbuilder.corba.idl.parser.syntaxtree.fixed_array_size;
 import jp.go.aist.rtm.rtcbuilder.corba.idl.parser.syntaxtree.identifier;
@@ -345,29 +346,50 @@
 			@SuppressWarnings("unchecked")
 			@Override
 			public void visit(module n, String argu) {
-				final String moduleName = node2String(n.identifier);
-				n.accept(new GJVoidDepthFirst() {
-					@Override
-					public void visit(struct_type n, Object argu) {
-						String typeName = node2String(n.identifier);
-						if( moduleName!=null && moduleName.length()>0 ) {
-							typeName = moduleName + "::" + typeName;
-						}
-						results.add(typeName);
-					}
-					
-				},null);
+				moduleName = new ArrayList<String>();
+				final String moduleNames = node2String(n.identifier);
+				System.out.println("Mt:" + moduleNames);
+				moduleName.add(moduleNames);
+				n.accept(new ExtractModule(results),null);
 			}
 			//
 			@Override
 			public void visit(struct_type n, String argu) {
 				String typeName = node2String(n.identifier);
 				results.add(typeName);
+				System.out.println("Tt:" + typeName);
 			}
 		}, null);
 
 		return results;
 	}
+	private static final class ExtractModule extends GJVoidDepthFirst {
+		private List<String> results;
+		
+		public ExtractModule(List<String> results) {
+			this.results = results;
+		}
+		
+		@Override
+		public void visit(definition n, Object argu) {
+			n.accept(new GJVoidDepthFirst() {
+				@Override
+				public void visit(struct_type n, Object argu) {
+					String typeName = node2String(n.identifier);
+					System.out.println("Ti:" + typeName);
+					results.add(getModuleNames() + "::" + typeName);
+				}
+				@Override
+				public void visit(module n, Object argu) {
+					String typeName = node2String(n.identifier);
+					System.out.println("Mi:" + typeName);
+					moduleName.add(typeName);
+					n.accept(new ExtractModule(results),null);
+				}
+			},null);
+		}
+	}
+
 	/**
 	 * インタフェースのモジュール名を取得する
 	 * 

Modified: trunk/rtmtools/jp.go.aist.rtm.rtcbuilder/test/jp/go/aist/rtm/rtcbuilder/_test/com/CORBAParseTypeTest.java
===================================================================
--- trunk/rtmtools/jp.go.aist.rtm.rtcbuilder/test/jp/go/aist/rtm/rtcbuilder/_test/com/CORBAParseTypeTest.java	2012-11-04 16:22:03 UTC (rev 363)
+++ trunk/rtmtools/jp.go.aist.rtm.rtcbuilder/test/jp/go/aist/rtm/rtcbuilder/_test/com/CORBAParseTypeTest.java	2012-11-05 03:39:08 UTC (rev 364)
@@ -10,6 +10,21 @@
 
 public class CORBAParseTypeTest extends TestBase {
 
+	public void testModules() throws Exception{
+		List<DataTypeParam> sourceContents = new ArrayList<DataTypeParam>();
+		List<String> results = new ArrayList<String>();
+		sourceContents.add(new DataTypeParam(rootPath + "\\resource\\IDL\\Modules.idl"));
+		
+		for(int intidx=0;intidx<sourceContents.size();intidx++) {
+			String idlContent = FileUtil.readFile(sourceContents.get(intidx).getFullPath());
+			sourceContents.get(intidx).setContent(idlContent);
+		}
+		IDLParamConverter.extractTypeDef(sourceContents, results);
+
+		assertEquals(1, results.size());
+		assertTrue(results.contains("AAA::BBB::CCC::TimeBBB"));
+	}
+	
 	public void testException() throws Exception{
 		List<DataTypeParam> sourceContents = new ArrayList<DataTypeParam>();
 		List<String> results = new ArrayList<String>();



More information about the openrtm-commit mailing list