Some fiddling to keep the CPP bits in sync as well.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@6397 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -10,11 +10,6 @@ import com.threerings.presents.tools.InvocationTask.ServiceMethod;
|
|||||||
|
|
||||||
public class CPPArgBuilder
|
public class CPPArgBuilder
|
||||||
{
|
{
|
||||||
public CPPArgBuilder(boolean ignoreFirst)
|
|
||||||
{
|
|
||||||
_ignoreFirst = ignoreFirst;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getArguments (ServiceMethod meth)
|
public String getArguments (ServiceMethod meth)
|
||||||
{
|
{
|
||||||
return getArguments(meth, "");
|
return getArguments(meth, "");
|
||||||
@@ -24,11 +19,11 @@ public class CPPArgBuilder
|
|||||||
{
|
{
|
||||||
StringBuilder buf = new StringBuilder(prefix);
|
StringBuilder buf = new StringBuilder(prefix);
|
||||||
Type[] ptypes = meth.method.getGenericParameterTypes();
|
Type[] ptypes = meth.method.getGenericParameterTypes();
|
||||||
for (int ii = _ignoreFirst ? 1 : 0; ii < ptypes.length; ii++) {
|
for (int ii = 0; ii < ptypes.length; ii++) {
|
||||||
if (buf.length() > 0) {
|
if (buf.length() > 0) {
|
||||||
buf.append(", ");
|
buf.append(", ");
|
||||||
}
|
}
|
||||||
buf.append(CPPUtil.getCPPType(ptypes[ii])).append(" arg").append(ii);
|
buf.append(CPPUtil.getCPPType(ptypes[ii])).append(" arg").append(ii+1);
|
||||||
}
|
}
|
||||||
return buf.toString();
|
return buf.toString();
|
||||||
}
|
}
|
||||||
@@ -36,9 +31,9 @@ public class CPPArgBuilder
|
|||||||
public List<String> getArgumentNames (ServiceMethod meth)
|
public List<String> getArgumentNames (ServiceMethod meth)
|
||||||
{
|
{
|
||||||
Type[] ptypes = meth.method.getGenericParameterTypes();
|
Type[] ptypes = meth.method.getGenericParameterTypes();
|
||||||
List<String> args = Lists.newArrayListWithCapacity(ptypes.length - 1);
|
List<String> args = Lists.newArrayListWithCapacity(ptypes.length);
|
||||||
for (int ii = 1; ii < ptypes.length; ii++) {
|
for (int ii = 0; ii < ptypes.length; ii++) {
|
||||||
args.add("arg" + ii);
|
args.add("arg" + (ii+1));
|
||||||
}
|
}
|
||||||
return args;
|
return args;
|
||||||
}
|
}
|
||||||
@@ -47,7 +42,7 @@ public class CPPArgBuilder
|
|||||||
{
|
{
|
||||||
StringBuilder buf = new StringBuilder();
|
StringBuilder buf = new StringBuilder();
|
||||||
Type[] ptypes = meth.method.getGenericParameterTypes();
|
Type[] ptypes = meth.method.getGenericParameterTypes();
|
||||||
for (int ii = _ignoreFirst ? 1 : 0; ii < ptypes.length; ii++) {
|
for (int ii = 0; ii < ptypes.length; ii++) {
|
||||||
if (buf.length() > 0) {
|
if (buf.length() > 0) {
|
||||||
buf.append(", ");
|
buf.append(", ");
|
||||||
}
|
}
|
||||||
@@ -61,11 +56,9 @@ public class CPPArgBuilder
|
|||||||
{
|
{
|
||||||
Type[] ptypes = meth.method.getGenericParameterTypes();
|
Type[] ptypes = meth.method.getGenericParameterTypes();
|
||||||
List<String> args = Lists.newArrayListWithCapacity(ptypes.length);
|
List<String> args = Lists.newArrayListWithCapacity(ptypes.length);
|
||||||
for (int ii = _ignoreFirst ? 1 : 0; ii < ptypes.length; ii++) {
|
for (int ii = 0; ii < ptypes.length; ii++) {
|
||||||
args.add(new CPPType(ptypes[ii]).getAsStreamable("arg" + ii));
|
args.add(new CPPType(ptypes[ii]).getAsStreamable("arg" + (ii+1)));
|
||||||
}
|
}
|
||||||
return args;
|
return args;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final boolean _ignoreFirst;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ public class GenCPPServiceTask extends GenServiceTask
|
|||||||
ctx.put("namespace", Joiner.on("::").join(namespaces));
|
ctx.put("namespace", Joiner.on("::").join(namespaces));
|
||||||
ctx.put("methods", MethodDescriptor.from(sdesc.methods));
|
ctx.put("methods", MethodDescriptor.from(sdesc.methods));
|
||||||
ctx.put("listeners", sdesc.listeners);
|
ctx.put("listeners", sdesc.listeners);
|
||||||
ctx.put("argbuilder", new CPPArgBuilder(true));
|
ctx.put("argbuilder", new CPPArgBuilder());
|
||||||
|
|
||||||
Set<String> includes = Sets.newTreeSet();
|
Set<String> includes = Sets.newTreeSet();
|
||||||
Set<String> implIncludes = Sets.newTreeSet();
|
Set<String> implIncludes = Sets.newTreeSet();
|
||||||
|
|||||||
@@ -24,9 +24,10 @@ public class MethodDescriptor
|
|||||||
|
|
||||||
public MethodDescriptor(ServiceMethod methodSource) {
|
public MethodDescriptor(ServiceMethod methodSource) {
|
||||||
methodName = methodSource.method.getName();
|
methodName = methodSource.method.getName();
|
||||||
vectorArguments = new CPPArgBuilder(false).getArgumentsFromVector(methodSource);
|
vectorArguments = new CPPArgBuilder().getArgumentsFromVector(methodSource);
|
||||||
arguments = new CPPArgBuilder(false).getArguments(methodSource);
|
arguments = new CPPArgBuilder().getArguments(methodSource);
|
||||||
clientArguments = new CPPArgBuilder(true).getArguments(methodSource, "Shared<presents::PresentsClient> client");
|
clientArguments = new CPPArgBuilder().getArguments(
|
||||||
serviceArguments = new CPPArgBuilder(true).getServiceArguments(methodSource);
|
methodSource, "Shared<presents::PresentsClient> client");
|
||||||
|
serviceArguments = new CPPArgBuilder().getServiceArguments(methodSource);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user