You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by wh...@apache.org on 2005/01/06 17:21:28 UTC
cvs commit: ws-axis/c/tools/org/apache/axis/tools/common FilePart.java Headers.java InputCppSourceCode.java MethodPart.java Parameter.java PrototypePart.java Signature.java
whitlock 2005/01/06 08:21:28
Modified: c/tools/org/apache/axis/tools/cbindings
CBindingGenerator.java cbindinggenerator.conf
c/tools/org/apache/axis/tools/common FilePart.java
Headers.java InputCppSourceCode.java
MethodPart.java Parameter.java PrototypePart.java
Signature.java
Log:
Enhanced version of the C binding generator
Revision Changes Path
1.2 +285 -39 ws-axis/c/tools/org/apache/axis/tools/cbindings/CBindingGenerator.java
Index: CBindingGenerator.java
===================================================================
RCS file: /home/cvs/ws-axis/c/tools/org/apache/axis/tools/cbindings/CBindingGenerator.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- CBindingGenerator.java 17 Dec 2004 11:49:47 -0000 1.1
+++ CBindingGenerator.java 6 Jan 2005 16:21:28 -0000 1.2
@@ -22,6 +22,8 @@
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.List;
+import java.util.StringTokenizer;
import org.apache.axis.tools.common.CParsingTool;
import org.apache.axis.tools.common.Configuration;
@@ -29,6 +31,7 @@
import org.apache.axis.tools.common.FileActor;
import org.apache.axis.tools.common.FilePart;
import org.apache.axis.tools.common.InputCppSourceCode;
+import org.apache.axis.tools.common.MethodPart;
import org.apache.axis.tools.common.Parameter;
import org.apache.axis.tools.common.ParsingException;
import org.apache.axis.tools.common.PrototypePart;
@@ -90,79 +93,322 @@
BufferedWriter outputFile)
throws Exception {
+ boolean foundCopyright = false;
+ String define = inputFile.getName();
+ define = define.toUpperCase();
+ define = define.substring(0, define.indexOf("."));
+ define += "_INCLUDED";
+
+ int prevPart = FilePart.COMMENT; // Suppresse newline before copyright
String text;
Iterator it = inputFile.getPartIterator();
while (it.hasNext()) {
FilePart fp = (FilePart) (it.next());
+ if (!foundCopyright
+ && (FilePart.DIRECTIVE == fp.getType()
+ || FilePart.ENUM == fp.getType()
+ || FilePart.PROTOTYPE == fp.getType())) {
+ outputFile.write("#ifndef " + define);
+ outputFile.newLine();
+ outputFile.write("#define " + define);
+ outputFile.newLine();
+ foundCopyright = true;
+ }
+
switch (fp.getType()) {
case FilePart.COMMENT :
- outputFile.write(fp.toString().trim());
- break;
-
- case FilePart.DIRECTIVE :
- //TODO: replace axis with axisc, etc
+ if (FilePart.COMMENT != prevPart)
+ outputFile.newLine();
+ prevPart = fp.getType();
text = fp.toString().trim();
- if (-1 != text.indexOf("include")) {
- StringBuffer sb = new StringBuffer(text);
- int ext = sb.indexOf(".hpp");
- if (-1 != ext) {
- sb.delete(ext + 2, ext + 4);
- text = sb.toString();
+ StringTokenizer tkzr = new StringTokenizer(text, "\n\r");
+ while (tkzr.hasMoreTokens()) {
+ String line = tkzr.nextToken();
+ if (-1 == line.indexOf("@author")) {
+ outputFile.write(line);
+ outputFile.newLine();
}
}
+ break;
- outputFile.write(fp.toString().trim());
+ case FilePart.DIRECTIVE :
+ if (FilePart.DIRECTIVE != prevPart)
+ outputFile.newLine();
+ prevPart = fp.getType();
+ generateDirective(fp, outputFile, inputFile.getName());
break;
- case FilePart.ENUM :
- //TODO: replace axis with axisc, etc
- outputFile.write(fp.toString().trim());
+ case FilePart.TYPEDEF :
+ prevPart = fp.getType();
+ // TODO: make sure all typedefs are prefixed with AXISC_
+ outputFile.write(changeAxisToAxisc(fp.toString().trim()));
+ outputFile.newLine();
break;
+ case FilePart.METHOD :
case FilePart.PROTOTYPE :
- text = generateFunctionPrototype((PrototypePart) fp);
- outputFile.write(text);
+ if (FilePart.COMMENT != prevPart
+ && FilePart.METHOD != prevPart
+ && FilePart.PROTOTYPE != prevPart)
+ outputFile.newLine();
+ prevPart = fp.getType();
+ generateFunctionPrototype(fp, outputFile);
+ break;
+
+ case FilePart.ENUM :
+ Utils.rude(
+ "Enums should be wrappered with a typedef so "
+ + "they appear the same in C and C++",
+ inputFile.getName(),
+ 0,
+ fp.toString());
break;
// do nothing for other file parts
}
+ }
+
+ outputFile.newLine();
+ outputFile.write("#endif // " + define);
+ outputFile.newLine();
+ }
+
+ private boolean keepIfdef = false;
+ private void generateDirective(
+ FilePart fp,
+ BufferedWriter outputFile,
+ String filename)
+ throws Exception {
+
+ //TODO: replace axis with axisc, etc
+ String text = fp.toString().trim();
+ if (-1 != text.indexOf("include")) {
+ StringBuffer sb = new StringBuffer(text);
+ int ext = sb.indexOf(".hpp");
+ int dot = sb.indexOf(".");
+ if (-1 != ext) {
+ // change .hpp ext to .h
+ sb.delete(ext + 2, ext + 4);
+ text = sb.toString();
+ } else if (-1 == dot) {
+ // remove C++ includes with no ext
+ text = new String();
+ }
+ outputFile.write(text);
+ outputFile.newLine();
+ } else if (
+ // In AxisUserAPI.h we must keep a #ifdef WIN32/#else/#endif
+ keepIfdef
+ || ("AxisUserAPI.hpp".equals(filename)
+ && -1 != text.indexOf("WIN32"))) {
+ outputFile.write(text);
outputFile.newLine();
+ if (!keepIfdef)
+ keepIfdef = true;
+ else if (-1 != text.indexOf("endif"))
+ keepIfdef = false;
}
}
- private String generateFunctionPrototype(PrototypePart pp)
+ private void generateFunctionPrototype(
+ FilePart fp,
+ BufferedWriter outputFile)
throws Exception {
- Signature sign = pp.getSignature();
- String text = sign.getReturnType().toString() + " ";
- text += "axisc";
+ Signature sign = null;
+ if (FilePart.PROTOTYPE == fp.getType()) {
+ PrototypePart pp = (PrototypePart) fp;
+ sign = pp.getSignature();
+ } else {
+ MethodPart mp = (MethodPart) fp;
+ sign = mp.getSignature();
+ }
+
+ // Ignore private and protected methods.
+ if (!sign.getScope().equals("public"))
+ return;
+
+ String classname = sign.getClassName();
+ if (null != classname && classname.endsWith("::"))
+ classname = classname.substring(0, classname.length() - 2);
String method = sign.getMethodName();
- text += Character.toUpperCase(method.charAt(0));
- text += method.substring(1);
- text += "(";
-
+ if (Configuration.methodExcluded(classname, method))
+ return;
+
Parameter[] parms = sign.getParameters();
- String classname = sign.getClassName();
- if (null != classname
- && -1 != sign.getAttributes().indexOf("static")) {
- text += "AXISCHANDLE ";
- text += Character.toLowerCase(classname.charAt(0));
- text += classname.substring(1);
+ String text = new String();
+
+ // Look to see if this method is overloaded by another method
+ // in the same class or a different class. If methods in two
+ // different classes happen to have the same name, then change
+ // their names. If methods are overloaded in the same class then
+ // convert the longest method prototype to C. We should really
+ // superset the parameters in the two prototypes instead of
+ // picking the longest one.
+ List overloads = headers.getMethods(method);
+ boolean sameClass = true;
+ if (overloads.size() > 1) {
+ Iterator it = overloads.iterator();
+ while (it.hasNext()) {
+ Signature s = (Signature) it.next();
+ if (!s.getTrimClassName().equals(classname))
+ sameClass = false;
+ else {
+ int n1 = 0;
+ int n2 = 0;
+ if (null != s.getParameters())
+ n1 = s.getParameters().length;
+ if (null != sign.getParameters())
+ n2 = sign.getParameters().length;
+ if (n1 > n2)
+ return;
+ }
+ }
+ }
+
+ if (sign.isConstructor()) {
+ text += "AXISCHANDLE axiscCreate" + classname + "(";
+ } else if (sign.isDestructor()) {
+ text += "void axiscDestroy" + classname + "(AXISCHANDLE ";
+ String prettyClass = classNamePretty(classname);
+ text += Character.toLowerCase(prettyClass.charAt(0));
+ text += prettyClass.substring(1);
if (null != parms)
- text += ",";
+ text += ", ";
+ } else {
+ String retType = toCType(sign.getReturnType());
+ text += retType + " ";
+ text += "axisc";
+ text += Character.toUpperCase(method.charAt(0));
+ text += method.substring(1);
+ String retClass = getClassFromRetType(sign);
+ if ("AXISCHANDLE".equals(retType)
+ && -1 == method.indexOf(retClass))
+ text += retClass;
+ if (!sameClass)
+ text += classname;
+ text += "(";
+
+ if (null != classname
+ && -1 == sign.getAttributes().indexOf("static")) {
+ text += "AXISCHANDLE ";
+ String prettyClass = classNamePretty(classname);
+ text += Character.toLowerCase(prettyClass.charAt(0));
+ text += prettyClass.substring(1);
+ if (null != parms)
+ text += ", ";
+ }
}
- if (parms != null)
+ if (parms != null) {
for (int i = 0; i < parms.length; i++) {
- if (0 != i)
- text += ",";
- String type = parms[i].getType();
- if (null != type)
- text += type + " ";
+ if (0 != i) {
+ text += ", ";
+ if (text.length() > 50) { // wrap long lines at 50 chars
+ outputFile.write(text);
+ outputFile.newLine();
+ text = "\t";
+ }
+ }
+ text += toCType(parms[i]) + " ";
String name = parms[i].getName();
- if (null != name)
+ if (null != name) // "..." has no parm name
text += name;
}
+ }
text += ");";
+ outputFile.write(text);
+ outputFile.newLine();
+ }
+
+ private static String classNamePretty(String className) {
+ if (className == null)
+ return null;
+ if (className.startsWith("I"))
+ return className.substring(1);
+ return className;
+ }
+
+ /**
+ * Converts a C++ datatype to a C-style datatype.
+ * References are converted to pointers.
+ * STL strings are converted to char* C-style strings
+ * String& is converted to char* (not char**)
+ * AXIS, Axis and axis are converted to AXISC, Axisc and axisc
+ */
+ private String toCType(Parameter p) throws Exception {
+ if (p.isVoid())
+ return "void";
+
+ String type = new String();
+ Iterator it = p.iterator();
+ String prev = new String();
+ while (it.hasNext()) {
+ String tok = (String) it.next();
+ if ("&".equals(tok)) {
+ if (!"string".equals(prev))
+ type += "*";
+ } else if ("string".equals(tok)) {
+ type += "char*";
+ prev = tok;
+ } else if (headers.isClassName(tok)) {
+ return "AXISCHANDLE";
+ } else if ("AnyType".equals(tok)) {
+ type += "AxiscAnyType";
+ } else {
+ type += changeAxisToAxisc(tok);
+ }
+ if (it.hasNext())
+ type += " ";
+ }
+ return type;
+ }
+
+ private String getClassFromRetType(Signature sign) {
+ Parameter p = sign.getReturnType();
+ if (p.isVoid())
+ return null;
+
+ Iterator it = p.iterator();
+ while (it.hasNext()) {
+ String tok = (String) it.next();
+ if (headers.isClassName(tok))
+ return classNamePretty(tok);
+ }
+ return null;
+ }
+
+ /**
+ * Converts AXIS, axis and Axis to AXISC, axisc and Axisc.
+ * Does not convert Axisc, axisc or AXISC_
+ */
+ private static String changeAxisToAxisc(String text) throws Exception {
+ String[] from = { "axis", "Axis", "AXIS" };
+ String[] to = { "axisc", "Axisc", "AXISC_" };
+ String[] postfix = { "c", "c", "C" };
+
+ int idx = 0;
+ while (idx < text.length()
+ && -1 != text.toLowerCase().indexOf("axis", idx)) {
+ int newidx = text.length();
+ String c = "c";
+ for (int arridx = 0; arridx < from.length; arridx++) {
+ int axis = text.indexOf(from[arridx], idx);
+ if (-1 != axis && axis < newidx) {
+ newidx = axis;
+ if (text.indexOf(to[arridx], idx) == axis)
+ c = "";
+ else
+ c = postfix[arridx];
+ }
+ }
+
+ if (text.length() != newidx && c.length() > 0)
+ text =
+ text.substring(0, newidx + 4)
+ + c
+ + text.substring(newidx + 4);
+ idx = newidx + 4 + c.length();
+ }
return text;
}
1.2 +10 -0 ws-axis/c/tools/org/apache/axis/tools/cbindings/cbindinggenerator.conf
Index: cbindinggenerator.conf
===================================================================
RCS file: /home/cvs/ws-axis/c/tools/org/apache/axis/tools/cbindings/cbindinggenerator.conf,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- cbindinggenerator.conf 17 Dec 2004 11:49:47 -0000 1.1
+++ cbindinggenerator.conf 6 Jan 2005 16:21:28 -0000 1.2
@@ -24,3 +24,13 @@
#
attribute=AXISCALL
attribute=STORAGE_CLASS_INFO
+#
+excludefile=GDefine.hpp
+excludefile=AxisUserAPI.hpp
+excludefile=Handler.hpp
+#
+excludemethod=BasicNode::serialize
+excludemethod=Call::getTransport
+excludemethod=Call::getSOAPSerializer
+
+
1.2 +1 -0 ws-axis/c/tools/org/apache/axis/tools/common/FilePart.java
Index: FilePart.java
===================================================================
RCS file: /home/cvs/ws-axis/c/tools/org/apache/axis/tools/common/FilePart.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- FilePart.java 17 Dec 2004 11:49:48 -0000 1.1
+++ FilePart.java 6 Jan 2005 16:21:28 -0000 1.2
@@ -32,6 +32,7 @@
public final static int CLASSATTRIBUTE = 9;
public final static int ENUM = 10;
public final static int PROTOTYPE = 11;
+ public final static int TYPEDEF = 12;
protected String cppsource;
protected int type;
1.2 +30 -2 ws-axis/c/tools/org/apache/axis/tools/common/Headers.java
Index: Headers.java
===================================================================
RCS file: /home/cvs/ws-axis/c/tools/org/apache/axis/tools/common/Headers.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Headers.java 17 Dec 2004 11:49:48 -0000 1.1
+++ Headers.java 6 Jan 2005 16:21:28 -0000 1.2
@@ -20,12 +20,13 @@
import java.io.FileReader;
import java.util.ArrayList;
import java.util.Iterator;
-
-import org.apache.axis.tools.trace.TraceInstrumentor;
+import java.util.List;
public class Headers implements FileActor {
private ArrayList instanceMethods = new ArrayList();
private ArrayList staticMethods = new ArrayList();
+ private ArrayList allMethods = new ArrayList();
+ private ArrayList classNames = new ArrayList();
private boolean failed = false;
public void actOnFile(File header, File ignored, int depth)
@@ -51,6 +52,13 @@
String className = pp.className();
if (null==className)
continue;
+ String trimClassName = className;
+ if (className.endsWith("::"))
+ trimClassName =
+ className.substring(0, className.length() - 2);
+ if (!classNames.contains(trimClassName))
+ classNames.add(trimClassName);
+
Signature sign = new Signature(fp.toString());
sign.setClassName(className);
@@ -67,6 +75,8 @@
}
inputFile.close();
+ allMethods.addAll(staticMethods);
+ allMethods.addAll(instanceMethods);
}
public boolean failed() {
@@ -91,5 +101,23 @@
return true;
}
return false;
+ }
+
+ public List getMethods(String method) {
+ ArrayList list = new ArrayList();
+ if (null == method)
+ return list;
+
+ Iterator it = allMethods.iterator();
+ while (it.hasNext()) {
+ Signature s = (Signature) it.next();
+ if (method.equals(s.getMethodName()))
+ list.add(s);
+ }
+ return list;
+ }
+
+ public boolean isClassName(String text) {
+ return classNames.contains(text);
}
}
1.2 +28 -9 ws-axis/c/tools/org/apache/axis/tools/common/InputCppSourceCode.java
Index: InputCppSourceCode.java
===================================================================
RCS file: /home/cvs/ws-axis/c/tools/org/apache/axis/tools/common/InputCppSourceCode.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- InputCppSourceCode.java 17 Dec 2004 11:49:48 -0000 1.1
+++ InputCppSourceCode.java 6 Jan 2005 16:21:28 -0000 1.2
@@ -56,6 +56,7 @@
String rest, text = "";
int scopedepth = 0;
+ String scope = "public";
String currentClass = null;
for (int idx = 0; idx < str.length(); /* No idx++ */
) {
@@ -108,6 +109,7 @@
// TODO: better checking that this brace really ends the class
if (0 == scopedepth)
currentClass = null;
+ scope = "public";
parts.add(new FilePart("}", FilePart.ENDSCOPE));
idx++;
@@ -172,6 +174,7 @@
name,
lineNo(str, idx),
rest.substring(0, rest.indexOf("\n")));
+ scope = str.substring(idx, idx + colon);
text = str.substring(idx, idx + colon + 1);
FilePart fp = new FilePart(text, FilePart.CLASSATTRIBUTE);
parts.add(fp);
@@ -190,7 +193,7 @@
if (-1 == brace || semicolon < brace) {
// Simple typedef
- text = str.substring(idx, idx + semicolon);
+ text = str.substring(idx, idx + semicolon + 1);
} else {
// Typedef of a struct, etc
int endbrace = Utils.findMatching(rest, '{', '}');
@@ -198,7 +201,7 @@
semicolon = Utils.indexOf(rest2, ';');
text = str.substring(idx, idx + endbrace + semicolon + 1);
}
- FilePart fp = new FilePart(text, FilePart.FIELD);
+ FilePart fp = new FilePart(text, FilePart.TYPEDEF);
parts.add(fp);
idx += text.length();
@@ -214,6 +217,10 @@
name,
lineNo(str, idx),
signature.getOriginal());
+ if (null != currentClass
+ && null == signature.getClassName())
+ signature.setClassName(currentClass);
+ signature.setScope(scope);
String body = rest.substring(brace);
int endBrace = Utils.findMatching(body, '{', '}');
@@ -222,7 +229,7 @@
idx + signature.originalLength() + body.length();
text = str.substring(idx, endIdx);
MethodPart mp =
- new MethodPart(text, FilePart.METHOD, signature, body);
+ new MethodPart(text, signature, body);
parts.add(mp);
idx += text.length();
@@ -236,8 +243,9 @@
} else if (isPrototype(rest)) {
int semicolon = Utils.indexOf(rest, ';');
text = str.substring(idx, idx + semicolon + 1);
- FilePart fp = new PrototypePart(text, currentClass);
- parts.add(fp);
+ PrototypePart pp = new PrototypePart(text, currentClass);
+ pp.setScope(scope);
+ parts.add(pp);
idx += text.length();
} else {
@@ -276,12 +284,19 @@
if (isMethod(s))
return false;
- if (Utils.startsWith(s, "class"))
- return true;
+ int brace = Utils.indexOf(s, '{');
+ int semicolon = Utils.indexOf(s, ';');
+
+ // Return false for class prototypes, but true for class definitions.
+ if (Utils.startsWith(s, "class")) {
+ if (-1 == brace)
+ return false;
+ if (-1 == semicolon)
+ return true;
+ return brace < semicolon;
+ }
if (Utils.startsWith(s, "struct")) {
- int brace = Utils.indexOf(s, '{');
- int semicolon = Utils.indexOf(s, ';');
if (-1 == brace || -1 == semicolon)
return false;
return brace < semicolon;
@@ -374,6 +389,10 @@
private static boolean isField(String s) throws ParsingException {
int semicolon = Utils.indexOf(s, ';');
return !isMethod(s) && !isPrototype(s) && -1 != semicolon;
+ }
+
+ public String getName() {
+ return name;
}
public String toString() {
1.2 +2 -2 ws-axis/c/tools/org/apache/axis/tools/common/MethodPart.java
Index: MethodPart.java
===================================================================
RCS file: /home/cvs/ws-axis/c/tools/org/apache/axis/tools/common/MethodPart.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- MethodPart.java 17 Dec 2004 11:49:48 -0000 1.1
+++ MethodPart.java 6 Jan 2005 16:21:28 -0000 1.2
@@ -24,8 +24,8 @@
private Signature signature;
private String body;
- MethodPart(String s, int type, Signature signature, String body) {
- super(s, type);
+ MethodPart(String s, Signature signature, String body) {
+ super(s, METHOD);
this.signature = signature;
this.body = body;
}
1.2 +6 -0 ws-axis/c/tools/org/apache/axis/tools/common/Parameter.java
Index: Parameter.java
===================================================================
RCS file: /home/cvs/ws-axis/c/tools/org/apache/axis/tools/common/Parameter.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Parameter.java 17 Dec 2004 11:49:48 -0000 1.1
+++ Parameter.java 6 Jan 2005 16:21:28 -0000 1.2
@@ -166,4 +166,10 @@
return getType();
return getType() + " " + name;
}
+
+ public Iterator iterator() {
+ if (null == type)
+ return null;
+ return type.iterator();
+ }
}
1.2 +7 -2 ws-axis/c/tools/org/apache/axis/tools/common/PrototypePart.java
Index: PrototypePart.java
===================================================================
RCS file: /home/cvs/ws-axis/c/tools/org/apache/axis/tools/common/PrototypePart.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- PrototypePart.java 17 Dec 2004 11:49:48 -0000 1.1
+++ PrototypePart.java 6 Jan 2005 16:21:28 -0000 1.2
@@ -22,9 +22,10 @@
private Signature signature;
public PrototypePart(String s, String className) {
- super(s, FilePart.PROTOTYPE);
+ super(s, PROTOTYPE);
signature = new Signature(s);
- signature.setClassName(className);
+ if (null != className)
+ signature.setClassName(className);
}
String className() {
@@ -33,5 +34,9 @@
public Signature getSignature() {
return signature;
+ }
+
+ public void setScope(String scope) {
+ signature.setScope(scope);
}
}
1.2 +43 -1 ws-axis/c/tools/org/apache/axis/tools/common/Signature.java
Index: Signature.java
===================================================================
RCS file: /home/cvs/ws-axis/c/tools/org/apache/axis/tools/common/Signature.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Signature.java 17 Dec 2004 11:49:48 -0000 1.1
+++ Signature.java 6 Jan 2005 16:21:28 -0000 1.2
@@ -36,6 +36,7 @@
private Parameter returnType = null;
private Parameter[] params = null;
private String trailingAttributes;
+ private String scope = "public";
private boolean failed = false;
private boolean traceable = true;
@@ -231,7 +232,12 @@
while (it.hasNext()) {
if (attributes.length() > 0)
attributes += " ";
- attributes += (String) it.next();
+ String next = (String) it.next();
+ if ("public".equals(next)
+ || "protected".equals(next)
+ || "private".equals(next))
+ scope = next;
+ attributes += next;
}
}
@@ -358,6 +364,10 @@
return className;
}
+ public String getTrimClassName() {
+ return trimClassName(className);
+ }
+
public String getMethodName() {
return methodName;
}
@@ -369,6 +379,25 @@
public Parameter[] getParameters() {
return params;
}
+
+ public boolean isConstructor() {
+ return className != null
+ && methodName != null
+ && trimClassName(className).equals(methodName);
+ }
+
+ public boolean isDestructor() {
+ return className != null
+ && methodName != null
+ && methodName.startsWith("~")
+ && methodName.endsWith(trimClassName(className));
+ }
+
+ private static String trimClassName(String name) {
+ if (name.endsWith("::"))
+ return name.substring(0, name.length() - 2);
+ return name;
+ }
void setClassName(String className) {
if (null == className)
@@ -376,6 +405,19 @@
if (!className.endsWith("::"))
className += "::";
this.className = className;
+ }
+
+ public String getScope() {
+ return scope;
+ }
+
+ /**
+ * Sets the scope, but only if the scope is not set by an explicit
+ * attribute in the signature.
+ */
+ public void setScope(String scope) {
+ if (-1 == attributes.indexOf(this.scope))
+ this.scope = scope;
}
/**