You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@etch.apache.org by sc...@apache.org on 2009/01/26 18:55:13 UTC
svn commit: r737767 - in /incubator/etch/trunk:
binding-csharp/compiler/src/main/java/etch/bindings/csharp/compiler/
binding-java/compiler/src/main/java/etch/bindings/java/compiler/
binding-xml/compiler/src/main/java/etch/bindings/xml/compiler/ compile...
Author: sccomer
Date: Mon Jan 26 17:55:12 2009
New Revision: 737767
URL: http://svn.apache.org/viewvc?rev=737767&view=rev
Log:
fix for ETCH-27: mixins cause trouble when two or more mixed in files define a type with the same name.
Modified:
incubator/etch/trunk/binding-csharp/compiler/src/main/java/etch/bindings/csharp/compiler/Compiler.java
incubator/etch/trunk/binding-java/compiler/src/main/java/etch/bindings/java/compiler/Compiler.java
incubator/etch/trunk/binding-xml/compiler/src/main/java/etch/bindings/xml/compiler/Compiler.java
incubator/etch/trunk/compiler/src/main/java/etch/compiler/ast/Service.java
incubator/etch/trunk/compiler/src/main/java/etch/compiler/ast/TypeRef.java
incubator/etch/trunk/compiler/src/main/javacc/EtchGrammar.jj
Modified: incubator/etch/trunk/binding-csharp/compiler/src/main/java/etch/bindings/csharp/compiler/Compiler.java
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-csharp/compiler/src/main/java/etch/bindings/csharp/compiler/Compiler.java?rev=737767&r1=737766&r2=737767&view=diff
==============================================================================
--- incubator/etch/trunk/binding-csharp/compiler/src/main/java/etch/bindings/csharp/compiler/Compiler.java (original)
+++ incubator/etch/trunk/binding-csharp/compiler/src/main/java/etch/bindings/csharp/compiler/Compiler.java Mon Jan 26 17:55:12 2009
@@ -269,24 +269,10 @@
for (Service intf : module)
{
- // TODO flush gIntf
- gIntf = intf;
- try
- {
- generate( intf, what, dir, templateDir );
- }
- finally
- {
- // TODO flush gIntf
- gIntf = null;
- }
+ generate( intf, what, dir, templateDir );
}
}
- // TODO flush gIntf
- @Deprecated
- private Service gIntf;
-
private void generate( final Service intf, Set<String> what, Output dir,
Output templateDir ) throws Exception
{
@@ -856,7 +842,11 @@
{
// we have to use a fully qualified name here.
// find the actual type...
- Named<?> n = gIntf.get( t.image );
+ Named<?> n = type.intf().get( t.image );
+ if (n == null)
+ throw new IllegalArgumentException( String.format(
+ "undefined or ambiguous name at line %d: %s",
+ t.beginLine, t.image ) );
return n.efqname( this );
}
}
@@ -896,7 +886,11 @@
{
// we have to use a fully qualified name here.
// find the actual type...
- Named<?> n = gIntf.get( t.image );
+ Named<?> n = type.intf().get( t.image );
+ if (n == null)
+ throw new IllegalArgumentException( String.format(
+ "undefined or ambiguous name at line %d: %s",
+ t.beginLine, t.image ) );
if (n.isEnumx())
return (n.efqname( this ) + "?");
return n.efqname( this );
@@ -1074,7 +1068,7 @@
return "Validator_" + type.type() + ".Get( " + type.dim()
+ " )";
- Named<?> n = type.getNamed( gIntf );
+ Named<?> n = type.getNamed( type.intf() );
if (n.isBuiltin())
{
Modified: incubator/etch/trunk/binding-java/compiler/src/main/java/etch/bindings/java/compiler/Compiler.java
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-java/compiler/src/main/java/etch/bindings/java/compiler/Compiler.java?rev=737767&r1=737766&r2=737767&view=diff
==============================================================================
--- incubator/etch/trunk/binding-java/compiler/src/main/java/etch/bindings/java/compiler/Compiler.java (original)
+++ incubator/etch/trunk/binding-java/compiler/src/main/java/etch/bindings/java/compiler/Compiler.java Mon Jan 26 17:55:12 2009
@@ -273,24 +273,10 @@
for (Service intf : module)
{
- // TODO flush gIntf
- gIntf = intf;
- try
- {
- generate( intf, what, dir, templateDir );
- }
- finally
- {
- // TODO flush gIntf
- gIntf = null;
- }
+ generate( intf, what, dir, templateDir );
}
}
- // TODO flush gIntf
- @Deprecated
- private Service gIntf;
-
private void generate( final Service intf, Set<String> what, Output dir,
Output templateDir ) throws Exception
{
@@ -860,7 +846,11 @@
{
// we have to use a fully qualified name here.
// find the actual type...
- Named<?> n = gIntf.get( t.image );
+ Named<?> n = type.intf().get( t.image );
+ if (n == null)
+ throw new IllegalArgumentException( String.format(
+ "undefined or ambiguous name at line %d: %s",
+ t.beginLine, t.image ) );
return n.efqname( this );
}
}
@@ -900,7 +890,11 @@
{
// we have to use a fully qualified name here.
// find the actual type...
- Named<?> n = gIntf.get( t.image );
+ Named<?> n = type.intf().get( t.image );
+ if (n == null)
+ throw new IllegalArgumentException( String.format(
+ "undefined or ambiguous name at line %d: %s",
+ t.beginLine, t.image ) );
return n.efqname( this );
}
}
@@ -1054,7 +1048,7 @@
return String.format( "Validator_%s.get( %d )",
type.type(), type.dim() );
- Named<?> n = type.getNamed( gIntf );
+ Named<?> n = type.getNamed( type.intf() );
if (n.isBuiltin())
{
Modified: incubator/etch/trunk/binding-xml/compiler/src/main/java/etch/bindings/xml/compiler/Compiler.java
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-xml/compiler/src/main/java/etch/bindings/xml/compiler/Compiler.java?rev=737767&r1=737766&r2=737767&view=diff
==============================================================================
--- incubator/etch/trunk/binding-xml/compiler/src/main/java/etch/bindings/xml/compiler/Compiler.java (original)
+++ incubator/etch/trunk/binding-xml/compiler/src/main/java/etch/bindings/xml/compiler/Compiler.java Mon Jan 26 17:55:12 2009
@@ -210,24 +210,10 @@
for (Service intf : module)
{
- // TODO flush gIntf
- gIntf = intf;
- try
- {
- generate( intf, dir );
- }
- finally
- {
- // TODO flush gIntf
- gIntf = null;
- }
+ generate( intf, dir );
}
}
- // TODO flush gIntf
- @Deprecated
- private Service gIntf;
-
private void generate( final Service intf, Output dir )
throws Exception
{
@@ -337,7 +323,11 @@
{
// we have to use a fully qualified name here.
// find the actual type...
- Named<?> n = gIntf.get( t.image );
+ Named<?> n = type.intf().get( t.image );
+ if (n == null)
+ throw new IllegalArgumentException( String.format(
+ "undefined or ambiguous name at line %d: %s",
+ t.beginLine, t.image ) );
String s = n.efqname( this );
if ( ( s == null ) && ( n instanceof Extern ) )
@@ -382,7 +372,7 @@
// patch here. more generic approach needed.
// currently, only taking care of Map, Set, List & Datetime
- case 34:
+ case EtchGrammarConstants.ID:
if ( t.toString().equals("Map") || t.toString().equals("List") ||
t.toString().equals("Set") || t.toString().equals("Datetime") )
return true;
@@ -414,7 +404,11 @@
{
// we have to use a fully qualified name here.
// find the actual type...
- Named<?> n = gIntf.get( t.image );
+ Named<?> n = type.intf().get( t.image );
+ if (n == null)
+ throw new IllegalArgumentException( String.format(
+ "undefined or ambiguous name at line %d: %s",
+ t.beginLine, t.image ) );
if ( n.isExtern() )
@@ -552,7 +546,7 @@
if (type.isBuiltin())
return "Validator_"+type.type()+".get( "+type.dim()+" )";
- return "Validator_custom.getCustom( "+type.getNamed( gIntf ).efqname( this )+".class, "+type.dim()+" )";
+ return "Validator_custom.getCustom( "+type.getNamed( type.intf() ).efqname( this )+".class, "+type.dim()+" )";
}
if (named instanceof Thrown)
Modified: incubator/etch/trunk/compiler/src/main/java/etch/compiler/ast/Service.java
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/compiler/src/main/java/etch/compiler/ast/Service.java?rev=737767&r1=737766&r2=737767&view=diff
==============================================================================
--- incubator/etch/trunk/compiler/src/main/java/etch/compiler/ast/Service.java (original)
+++ incubator/etch/trunk/compiler/src/main/java/etch/compiler/ast/Service.java Mon Jan 26 17:55:12 2009
@@ -250,7 +250,7 @@
Token rmType = new Token();
rmType.kind = EtchGrammarConstants.VOID;
rmType.image = "void";
- TypeRef rmTypeRef = new TypeRef( rmType );
+ TypeRef rmTypeRef = new TypeRef( this, rmType );
nameList.check( rmName );
Message rm = new Message( this, rmName, new HashMap<String, Opt>(),
Modified: incubator/etch/trunk/compiler/src/main/java/etch/compiler/ast/TypeRef.java
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/compiler/src/main/java/etch/compiler/ast/TypeRef.java?rev=737767&r1=737766&r2=737767&view=diff
==============================================================================
--- incubator/etch/trunk/compiler/src/main/java/etch/compiler/ast/TypeRef.java (original)
+++ incubator/etch/trunk/compiler/src/main/java/etch/compiler/ast/TypeRef.java Mon Jan 26 17:55:12 2009
@@ -28,17 +28,29 @@
{
/**
* Constructs the TypeRef.
+ * @param intf
*
* @param type
*/
- public TypeRef( Token type )
+ public TypeRef( Service intf, Token type )
{
+ this.intf = intf;
this.type = type;
}
+ private final Service intf;
+
private final Token type;
/**
+ * @return the parent object of this reference.
+ */
+ public Service intf()
+ {
+ return intf;
+ }
+
+ /**
* @return the token of the type.
*/
public Token type()
Modified: incubator/etch/trunk/compiler/src/main/javacc/EtchGrammar.jj
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/compiler/src/main/javacc/EtchGrammar.jj?rev=737767&r1=737766&r2=737767&view=diff
==============================================================================
--- incubator/etch/trunk/compiler/src/main/javacc/EtchGrammar.jj (original)
+++ incubator/etch/trunk/compiler/src/main/javacc/EtchGrammar.jj Mon Jan 26 17:55:12 2009
@@ -47,6 +47,8 @@
}
private Backend binding;
+
+ private Service gintf;
}
PARSER_END(EtchGrammar)
@@ -156,9 +158,12 @@
i = m.addService( n, opts );
serviceComment( i, getComment() );
binding.addDefaults( i );
+ Service ointf = gintf;
+ gintf = i;
}
<LBRACE> stmts( i ) <RBRACE>
{
+ gintf = ointf;
doEndService( i );
}
}
@@ -406,7 +411,7 @@
| t = <DOUBLE>
| t = <STRING>
)
- { return new TypeRef( t ); }
+ { return new TypeRef( gintf, t ); }
}
TypeRef ptype() :
@@ -414,8 +419,8 @@
{
(
tr = ctype()
- | t = <OBJECT> { tr = new TypeRef( t ); }
- | t = ref() { tr = new TypeRef( t ); }
+ | t = <OBJECT> { tr = new TypeRef( gintf, t ); }
+ | t = ref() { tr = new TypeRef( gintf, t ); }
)
{ return tr; }
}
@@ -425,7 +430,7 @@
{
(
( tr = ptype() d = dim() { tr.setDim( d ); } )
- | t = <VOID> { tr = new TypeRef( t ); }
+ | t = <VOID> { tr = new TypeRef( gintf, t ); }
)
{ return tr; }
}