Fix code generation to work with jmustache 1.4
In addition to the streamable generation, there were also issues with the receiver stuff, mostly to do with import
ordering. Modernizing that code to use ImportSet and {importGroups} seems to have fixed it.
NOTE: This is also broken in narya 1.9, but it not really worth the effort to fix that. It's easier just to move all
the projects that need it back to trunk. Hurray bleeding edge!
Testing done: gencode in orth and who, checked no diffs were generated.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@6727 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -21,11 +21,12 @@
|
|||||||
|
|
||||||
package com.threerings.bureau.server;
|
package com.threerings.bureau.server;
|
||||||
|
|
||||||
import com.threerings.bureau.client.BureauDecoder;
|
|
||||||
import com.threerings.bureau.client.BureauReceiver;
|
|
||||||
import com.threerings.presents.data.ClientObject;
|
import com.threerings.presents.data.ClientObject;
|
||||||
import com.threerings.presents.server.InvocationSender;
|
import com.threerings.presents.server.InvocationSender;
|
||||||
|
|
||||||
|
import com.threerings.bureau.client.BureauDecoder;
|
||||||
|
import com.threerings.bureau.client.BureauReceiver;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to issue notifications to a {@link BureauReceiver} instance on a
|
* Used to issue notifications to a {@link BureauReceiver} instance on a
|
||||||
* client.
|
* client.
|
||||||
|
|||||||
@@ -21,11 +21,12 @@
|
|||||||
|
|
||||||
package com.threerings.crowd.server;
|
package com.threerings.crowd.server;
|
||||||
|
|
||||||
import com.threerings.crowd.client.LocationDecoder;
|
|
||||||
import com.threerings.crowd.client.LocationReceiver;
|
|
||||||
import com.threerings.presents.data.ClientObject;
|
import com.threerings.presents.data.ClientObject;
|
||||||
import com.threerings.presents.server.InvocationSender;
|
import com.threerings.presents.server.InvocationSender;
|
||||||
|
|
||||||
|
import com.threerings.crowd.client.LocationDecoder;
|
||||||
|
import com.threerings.crowd.client.LocationReceiver;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to issue notifications to a {@link LocationReceiver} instance on a
|
* Used to issue notifications to a {@link LocationReceiver} instance on a
|
||||||
* client.
|
* client.
|
||||||
|
|||||||
@@ -24,13 +24,11 @@ package com.threerings.presents.tools;
|
|||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.lang.reflect.Modifier;
|
import java.lang.reflect.Modifier;
|
||||||
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
import com.google.common.collect.Iterators;
|
|
||||||
|
|
||||||
import com.samskivert.util.ComparableArrayList;
|
import com.samskivert.util.ComparableArrayList;
|
||||||
import com.samskivert.util.StringUtil;
|
import com.samskivert.util.StringUtil;
|
||||||
@@ -95,27 +93,26 @@ public class GenReceiverTask extends InvocationTask
|
|||||||
// get rid of primitives and java.lang types
|
// get rid of primitives and java.lang types
|
||||||
imports.removeGlobals();
|
imports.removeGlobals();
|
||||||
|
|
||||||
generateSender(source, rname, rpackage, methods, imports.toList().iterator());
|
generateSender(source, rname, rpackage, methods, imports);
|
||||||
generateDecoder(receiver, source, rname, rpackage, methods, imports.toList().iterator(),
|
generateDecoder(receiver, source, rname, rpackage, methods, imports,
|
||||||
StringUtil.md5hex(rpackage + "." + rname));
|
StringUtil.md5hex(rpackage + "." + rname));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void generateSender (File source, String rname, String rpackage,
|
protected void generateSender (File source, String rname, String rpackage,
|
||||||
List<?> methods, Iterator<String> imports)
|
List<?> methods, ImportSet imports)
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
String name = rname.replace("Receiver", "");
|
String name = rname.replace("Receiver", "");
|
||||||
String spackage = rpackage.replace(".client", ".server");
|
String spackage = rpackage.replace(".client", ".server");
|
||||||
|
|
||||||
// construct our imports list
|
// construct our imports list
|
||||||
ComparableArrayList<String> implist = new ComparableArrayList<String>();
|
ImportSet impset = new ImportSet();
|
||||||
Iterators.addAll(implist, imports);
|
impset.addAll(imports);
|
||||||
checkedAdd(implist, ClientObject.class.getName());
|
impset.add(ClientObject.class);
|
||||||
checkedAdd(implist, InvocationSender.class.getName());
|
impset.add(InvocationSender.class);
|
||||||
String dname = rname.replace("Receiver", "Decoder");
|
String dname = rname.replace("Receiver", "Decoder");
|
||||||
checkedAdd(implist, rpackage + "." + dname);
|
impset.add(rpackage + "." + dname);
|
||||||
checkedAdd(implist, rpackage + "." + rname);
|
impset.add(rpackage + "." + rname);
|
||||||
implist.sort();
|
|
||||||
|
|
||||||
// determine the path to our sender file
|
// determine the path to our sender file
|
||||||
String mpath = source.getPath();
|
String mpath = source.getPath();
|
||||||
@@ -125,20 +122,19 @@ public class GenReceiverTask extends InvocationTask
|
|||||||
"name", name,
|
"name", name,
|
||||||
"package", spackage,
|
"package", spackage,
|
||||||
"methods", methods,
|
"methods", methods,
|
||||||
"imports", implist);
|
"importGroups", impset.toGroups());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void generateDecoder (Class<?> receiver, File source, String rname, String rpackage,
|
protected void generateDecoder (Class<?> receiver, File source, String rname, String rpackage,
|
||||||
List<ServiceMethod> methods, Iterator<String> imports,
|
List<ServiceMethod> methods, ImportSet imports,
|
||||||
String rcode) throws Exception
|
String rcode) throws Exception
|
||||||
{
|
{
|
||||||
String name = rname.replace("Receiver", "");
|
String name = rname.replace("Receiver", "");
|
||||||
|
|
||||||
// construct our imports list
|
// construct our imports list
|
||||||
ComparableArrayList<String> implist = new ComparableArrayList<String>();
|
ImportSet impset = new ImportSet();
|
||||||
Iterators.addAll(implist, imports);
|
impset.addAll(imports);
|
||||||
checkedAdd(implist, InvocationDecoder.class.getName());
|
impset.add(InvocationDecoder.class);
|
||||||
implist.sort();
|
|
||||||
|
|
||||||
// determine the path to our sender file
|
// determine the path to our sender file
|
||||||
String mpath = source.getPath();
|
String mpath = source.getPath();
|
||||||
@@ -148,7 +144,7 @@ public class GenReceiverTask extends InvocationTask
|
|||||||
"receiver_code", rcode,
|
"receiver_code", rcode,
|
||||||
"package", rpackage,
|
"package", rpackage,
|
||||||
"methods", methods,
|
"methods", methods,
|
||||||
"imports", implist);
|
"importGroups", impset.toGroups());
|
||||||
if (_asroot == null) {
|
if (_asroot == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -160,17 +156,17 @@ public class GenReceiverTask extends InvocationTask
|
|||||||
"receiver_code", rcode,
|
"receiver_code", rcode,
|
||||||
"package", rpackage,
|
"package", rpackage,
|
||||||
"methods", methods,
|
"methods", methods,
|
||||||
"imports", implist);
|
"importGroups", impset.toGroups());
|
||||||
|
|
||||||
// ... and an ActionScript receiver
|
// ... and an ActionScript receiver
|
||||||
aspath = _asroot + File.separator + sppath + File.separator + rname + ".as";
|
aspath = _asroot + File.separator + sppath + File.separator + rname + ".as";
|
||||||
implist.remove(InvocationDecoder.class.getName());
|
impset.remove(InvocationDecoder.class);
|
||||||
checkedAdd(implist, InvocationReceiver.class.getName());
|
impset.add(InvocationReceiver.class);
|
||||||
writeTemplate(AS_RECEIVER_TMPL, aspath,
|
writeTemplate(AS_RECEIVER_TMPL, aspath,
|
||||||
"name", name,
|
"name", name,
|
||||||
"package", rpackage,
|
"package", rpackage,
|
||||||
"methods", methods,
|
"methods", methods,
|
||||||
"imports", implist);
|
"importGroups", impset.toGroups());
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The path to our ActionScript source files. */
|
/** The path to our ActionScript source files. */
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ import static com.threerings.presents.tools.cpp.CPPUtil.makePath;
|
|||||||
|
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -36,6 +35,7 @@ import com.google.common.collect.Maps;
|
|||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
|
|
||||||
import com.threerings.presents.tools.GenReceiverTask;
|
import com.threerings.presents.tools.GenReceiverTask;
|
||||||
|
import com.threerings.presents.tools.ImportSet;
|
||||||
|
|
||||||
public class GenCPPReceiverTask extends GenReceiverTask
|
public class GenCPPReceiverTask extends GenReceiverTask
|
||||||
{
|
{
|
||||||
@@ -46,7 +46,7 @@ public class GenCPPReceiverTask extends GenReceiverTask
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void generateDecoder (Class<?> receiver, File source, String rname, String rpackage,
|
protected void generateDecoder (Class<?> receiver, File source, String rname, String rpackage,
|
||||||
List<ServiceMethod> methods, Iterator<String> imports, String rcode)
|
List<ServiceMethod> methods, ImportSet imports, String rcode)
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
String dname = rname.replace("Receiver", "Decoder");
|
String dname = rname.replace("Receiver", "Decoder");
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
package {{package}};
|
package {{package}};
|
||||||
|
|
||||||
{{#imports}}
|
{{#importGroups}}
|
||||||
|
{{#this}}
|
||||||
import {{this}};
|
import {{this}};
|
||||||
{{/imports}}
|
{{/this}}
|
||||||
|
|
||||||
|
{{/importGroups}}
|
||||||
/**
|
/**
|
||||||
* Dispatches calls to a {@link {{name}}Receiver} instance.
|
* Dispatches calls to a {@link {{name}}Receiver} instance.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
package {{package}} {
|
package {{package}} {
|
||||||
|
|
||||||
{{#imports}}
|
{{#importGroups}}
|
||||||
|
{{#this}}
|
||||||
import {{this}};
|
import {{this}};
|
||||||
{{/imports}}
|
{{/this}}
|
||||||
|
|
||||||
|
{{/importGroups}}
|
||||||
/**
|
/**
|
||||||
* Dispatches calls to a {@link {{name}}Receiver} instance.
|
* Dispatches calls to a {@link {{name}}Receiver} instance.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
package {{package}} {
|
package {{package}} {
|
||||||
|
|
||||||
{{#imports}}
|
{{#importGroups}}
|
||||||
|
{{#this}}
|
||||||
import {{this}};
|
import {{this}};
|
||||||
{{/imports}}
|
{{/this}}
|
||||||
|
|
||||||
|
{{/importGroups}}
|
||||||
public interface {{name}}Receiver extends InvocationReceiver
|
public interface {{name}}Receiver extends InvocationReceiver
|
||||||
{
|
{
|
||||||
{{#methods}}
|
{{#methods}}
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
package {{package}};
|
package {{package}};
|
||||||
|
|
||||||
{{#imports}}
|
{{#importGroups}}
|
||||||
|
{{#this}}
|
||||||
import {{this}};
|
import {{this}};
|
||||||
{{/imports}}
|
{{/this}}
|
||||||
|
|
||||||
|
{{/importGroups}}
|
||||||
/**
|
/**
|
||||||
* Used to issue notifications to a {@link {{name}}Receiver} instance on a
|
* Used to issue notifications to a {@link {{name}}Receiver} instance on a
|
||||||
* client.
|
* client.
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ public class {{classname}} {{^extends.isEmpty}}extends {{extends}}
|
|||||||
{{#pubFields}}
|
{{#pubFields}}
|
||||||
public var {{name}} :{{simpleType}};{{#hasTypeParameters}} /* of */ {{parameterTypes}};{{/hasTypeParameters}}
|
public var {{name}} :{{simpleType}};{{#hasTypeParameters}} /* of */ {{parameterTypes}};{{/hasTypeParameters}}
|
||||||
|
|
||||||
|
|
||||||
{{/pubFields}}
|
{{/pubFields}}
|
||||||
{{#dobject}}
|
{{#dobject}}
|
||||||
{{#pubFields}}
|
{{#pubFields}}
|
||||||
@@ -139,11 +138,13 @@ class Signaller
|
|||||||
{
|
{
|
||||||
var signal :Signal;
|
var signal :Signal;
|
||||||
switch (event.getName()) {
|
switch (event.getName()) {
|
||||||
{{#pubFields}}{{#dset}}
|
{{#pubFields}}
|
||||||
|
{{#dset}}
|
||||||
case "{{name}}":
|
case "{{name}}":
|
||||||
signal = _obj.{{name}}EntryAdded;
|
signal = _obj.{{name}}EntryAdded;
|
||||||
break;
|
break;
|
||||||
{{/dset}}{{/pubFields}}
|
{{/dset}}
|
||||||
|
{{/pubFields}}
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -154,11 +155,13 @@ class Signaller
|
|||||||
{
|
{
|
||||||
var signal :Signal;
|
var signal :Signal;
|
||||||
switch (event.getName()) {
|
switch (event.getName()) {
|
||||||
{{#pubFields}}{{#dset}}
|
{{#pubFields}}
|
||||||
|
{{#dset}}
|
||||||
case "{{name}}":
|
case "{{name}}":
|
||||||
signal = _obj.{{name}}EntryRemoved;
|
signal = _obj.{{name}}EntryRemoved;
|
||||||
break;
|
break;
|
||||||
{{/dset}}{{/pubFields}}
|
{{/dset}}
|
||||||
|
{{/pubFields}}
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -169,11 +172,13 @@ class Signaller
|
|||||||
{
|
{
|
||||||
var signal :Signal;
|
var signal :Signal;
|
||||||
switch (event.getName()) {
|
switch (event.getName()) {
|
||||||
{{#pubFields}}{{#dset}}
|
{{#pubFields}}
|
||||||
|
{{#dset}}
|
||||||
case "{{name}}":
|
case "{{name}}":
|
||||||
signal = _obj.{{name}}EntryUpdated;
|
signal = _obj.{{name}}EntryUpdated;
|
||||||
break;
|
break;
|
||||||
{{/dset}}{{/pubFields}}
|
{{/dset}}
|
||||||
|
{{/pubFields}}
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -184,11 +189,13 @@ class Signaller
|
|||||||
{
|
{
|
||||||
var signal :Signal;
|
var signal :Signal;
|
||||||
switch (event.getName()) {
|
switch (event.getName()) {
|
||||||
{{#pubFields}}{{#array}}
|
{{#pubFields}}
|
||||||
|
{{#array}}
|
||||||
case "{{name}}":
|
case "{{name}}":
|
||||||
signal = _obj.{{name}}ElementUpdated;
|
signal = _obj.{{name}}ElementUpdated;
|
||||||
break;
|
break;
|
||||||
{{/array}}{{/pubFields}}
|
{{/array}}
|
||||||
|
{{/pubFields}}
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -199,11 +206,13 @@ class Signaller
|
|||||||
{
|
{
|
||||||
var signal :Signal;
|
var signal :Signal;
|
||||||
switch (event.getName()) {
|
switch (event.getName()) {
|
||||||
{{#pubFields}}{{#oidList}}
|
{{#pubFields}}
|
||||||
|
{{#oidList}}
|
||||||
case "{{name}}":
|
case "{{name}}":
|
||||||
signal = _obj.{{name}}ObjectAdded;
|
signal = _obj.{{name}}ObjectAdded;
|
||||||
break;
|
break;
|
||||||
{{/oidList}}{{/pubFields}}
|
{{/oidList}}
|
||||||
|
{{/pubFields}}
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -214,11 +223,13 @@ class Signaller
|
|||||||
{
|
{
|
||||||
var signal :Signal;
|
var signal :Signal;
|
||||||
switch (event.getName()) {
|
switch (event.getName()) {
|
||||||
{{#pubFields}}{{#oidList}}
|
{{#pubFields}}
|
||||||
|
{{#oidList}}
|
||||||
case "{{name}}":
|
case "{{name}}":
|
||||||
signal = _obj.{{name}}ObjectRemoved;
|
signal = _obj.{{name}}ObjectRemoved;
|
||||||
break;
|
break;
|
||||||
{{/oidList}}{{/pubFields}}
|
{{/oidList}}
|
||||||
|
{{/pubFields}}
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user