CPD Results
The following document contains the results of PMD's CPD 4.1.
Duplications
| File | Line |
|---|---|
| org/objectweb/fractal/cecilia/adl/idl/util/CUtil.java | 253 |
| org/objectweb/fractal/cecilia/adl/idl/util/CUtil.java | 308 |
public static String buildUnionField(final Field field, final String name) {
final StringBuilder result = new StringBuilder();
Type type = getContainedType(field);
boolean alreadyWrittenConst = false;
/* if the field is of a Cecilia IDL primitive type */
if (Util.isPrimitiveType(type)) {
if (isIDLPrimitiveTypeAlsoCPrimitiveType((PrimitiveType) type)) {
/* and if the field has the 'const' qualifier */
if (Util.isConstField(field)) {
result.append("const ");
alreadyWrittenConst = true;
}
}
}
String arraySpec = "";
int nbPointer = 0;
while (type instanceof ArrayOf) {
final String size = ((ArrayOf) type).getSize();
if (size != null) {
arraySpec = "[" + size + "]" + arraySpec;
} else {
arraySpec = "[]" + arraySpec;
}
type = getContainedType((ArrayOf) type);
}
while (type instanceof PointerOf) {
nbPointer++;
type = getContainedType((PointerOf) type);
}
result.append(buildComplexOrPrimitiveType(type));
for (int i = 0; i < nbPointer; i++)
result.append('*');
result.append(' ');
if (Util.isConstField(field) && !alreadyWrittenConst) {
result.append("const ");
}
result.append(name).append(arraySpec);
return result.toString();
}
/**
* @param type the signature of the type to be included.
* @return the include definition in C for the given type.
*/
public static String buildInclude(final String type) {
| |
| File | Line |
|---|---|
| org/objectweb/fractal/cecilia/adl/controllers/ControllerImplementationVisitor.java | 252 |
| org/objectweb/fractal/cecilia/primitive/thinkMC/source/CompilationVisitor.java | 295 |
}
}
// ---------------------------------------------------------------------------
// Implementation of the BindingController interface
// ---------------------------------------------------------------------------
@Override
public String[] listFc() {
final String[] superItfs = super.listFc();
final String[] itfs = new String[superItfs.length + 1];
System.arraycopy(superItfs, 0, itfs, 0, superItfs.length);
itfs[superItfs.length] = COMPILATION_TASK_FACTORY_ITF_NAME;
return itfs;
}
@Override
public void bindFc(final String clientItfName, final Object serverItf)
throws NoSuchInterfaceException, IllegalBindingException,
IllegalLifeCycleException {
if (clientItfName == null) {
throw new IllegalArgumentException("Interface name can't be null");
}
if (clientItfName.equals(COMPILATION_TASK_FACTORY_ITF_NAME))
compilationTaskFactoryItf = (CompilationTaskFactory) serverItf;
else
super.bindFc(clientItfName, serverItf);
}
@Override
public Object lookupFc(final String clientItfName)
throws NoSuchInterfaceException {
if (clientItfName == null) {
throw new IllegalArgumentException("Interface name can't be null");
}
if (clientItfName.equals(COMPILATION_TASK_FACTORY_ITF_NAME))
return compilationTaskFactoryItf;
else
return super.lookupFc(clientItfName);
}
@Override
public void unbindFc(final String clientItfName)
throws NoSuchInterfaceException, IllegalBindingException,
IllegalLifeCycleException {
if (clientItfName == null) {
throw new IllegalArgumentException("Interface name can't be null");
}
if (clientItfName.equals(COMPILATION_TASK_FACTORY_ITF_NAME))
compilationTaskFactoryItf = null;
else
super.unbindFc(clientItfName);
}
}
| |
| File | Line |
|---|---|
| org/objectweb/fractal/cecilia/adl/components/InstanceVisitor.java | 53 |
| org/objectweb/fractal/cecilia/adl/types/TypeVisitor.java | 52 |
getAbsoluteName(path, node)), node);
}
// ---------------------------------------------------------------------------
// Utility methods
// ---------------------------------------------------------------------------
protected String getAbsoluteName(final List<Node> path,
final ComponentContainer container) {
String realname = getComponentName(container);
for (int i = path.size() - 1; i >= 0; i--)
realname = getComponentName(path.get(i)) + "/" + realname;
return realname;
}
protected String getComponentName(final Node container) {
if (container instanceof Definition)
return ((Definition) container).getName();
else if (container instanceof org.objectweb.fractal.adl.components.Component)
return ((org.objectweb.fractal.adl.components.Component) container)
.getName();
else
throw new IllegalArgumentException(
"The given node is neither a Definition nor a Component");
}
// ---------------------------------------------------------------------------
// Task classes
// ---------------------------------------------------------------------------
/**
* Provides the name of the type of the given component.
*/
@TaskParameters("componentNode")
@ServerInterfaces(@ServerInterface(name = "type-name-provider", signature = TypeNameProvider.class, record = "role:typeNameProvider, id:%", parameters = "componentNode"))
| |
| File | Line |
|---|---|
| org/objectweb/fractal/cecilia/adl/implementations/GlobalInitVisitor.java | 200 |
| org/objectweb/fractal/cecilia/primitive/thinkMC/source/SourceFileVisitor.java | 212 |
public void execute() throws Exception {
final String fileName = getFileName();
final File outputFile = new File(adlBuildDirectory, fileName);
final CodeWriter cw = new CodeWriter();
cw.appendln("// THIS FILE HAS BEEN GENERATED BY THE CECILIA ADL "
+ "COMPILER.");
cw.appendln("// DO NOT EDIT").endl();
prepareSourceCode(cw);
try {
SourceFileWriter.writeToFile(outputFile, cw.toString());
} catch (final IOException e) {
throw new ADLException(GenericErrors.INTERNAL_ERROR, e,
"An error occurs while writing to file '"
+ outputFile.getAbsolutePath() + "'");
}
sourceFile = new SourceFile(getSignature(), outputFile);
}
// -------------------------------------------------------------------------
// Implementation of the SourceFileProvider interface
// -------------------------------------------------------------------------
public SourceFile getSourceFile() {
return sourceFile;
}
}
/**
* Builds the ".adl.c" source file that contains the definition of the
* component structure, the inclusion of the implementation file and the
* instantiation/initialization of the static instances.
*/
@TaskParameters("componentNode")
| |
| File | Line |
|---|---|
| org/objectweb/fractal/cecilia/composite/c/components/CloneableInstantiationVisitor.java | 119 |
| org/objectweb/fractal/cecilia/composite/c/components/ComponentInstantiationVisitor.java | 138 |
cw.append("&").append(instanceName).append("}, // cc").endl();
cw.appendln("// private data");
cw.append("sizeof(").append(instanceName).append(
"_subComponents) / sizeof(").append(instanceName).append(
"_subComponents[0]), // nbSubComponents").endl();
cw.append("sizeof(").append(instanceName).append("_bindings) / sizeof(")
.append(instanceName).append("_bindings[0]), // nbBindings").endl();
cw.append("0, // started").endl();
cw.append(instanceName).append("_subComponents,").endl();
cw.append(instanceName).append("_bindings,").endl();
cw.appendln("};");
| |
| File | Line |
|---|---|
| org/objectweb/fractal/cecilia/composite/c/components/ComponentDefinitionVisitor.java | 49 |
| org/objectweb/fractal/cecilia/primitive/thinkMC/components/ComponentDefinitionVisitor.java | 52 |
public class ComponentDefinitionVisitor extends AbstractTaskFactoryUser
implements
ComponentVisitor {
// ---------------------------------------------------------------------------
// Implementation of the ComponentVisitor interface
// ---------------------------------------------------------------------------
/**
* Visits {@link ComponentContainer} nodes and creates a task that writes the
* source code containing the definition of the component data structure.
*/
public Component visit(final List<Node> path,
final ComponentContainer container, final Map<Object, Object> context)
throws ADLException, TaskException {
return taskFactoryItf.newPrimitiveTask(new ComponentDefinitionTask(),
container);
}
// ---------------------------------------------------------------------------
// Task classes
// ---------------------------------------------------------------------------
/**
* Builds source code for the definition of the component data structure for
* the given component node. This task provides the produced source code. It
* uses the source code provided for client/server interfaces, controllers,
* and the attributes of the component.
*/
@TaskParameters("componentNode")
@ServerInterfaces(@ServerInterface(name = "component-definition-provider", signature = SourceCodeProvider.class, record = "role:componentDefinition, id:%", parameters = "componentNode"))
public static class ComponentDefinitionTask extends AbstractDefinitionTask {
// -------------------------------------------------------------------------
// Task client interfaces
// -------------------------------------------------------------------------
/** Source code to be included for interface definitions (optional). */
@ClientInterface(name = "interface-definition-provider", contingency = OPTIONAL, record = "role:interfaceDefinition, id:%", parameters = "componentNode")
public SourceCodeProvider interfaceDefinitionsProviderItf;
/** Source code to be included for attribute definitions (optional). */
@ClientInterface(name = "attribute-definition-provider", contingency = OPTIONAL, record = "role:attributeDefinition, id:%", parameters = "componentNode")
| |
| File | Line |
|---|---|
| org/objectweb/fractal/cecilia/adl/idl/CEnumFileVisitor.java | 145 |
| org/objectweb/fractal/cecilia/adl/idl/CUnionFileVisitor.java | 145 |
headerFileName = unionDefinition.getName().replace('.',
File.separatorChar)
+ ".idl.h";
prepareSourceCode();
prepareSourceFile();
}
}
// -------------------------------------------------------------------------
// Implementation of the SourceCodeProvider interface
// -------------------------------------------------------------------------
public String getSourceCode() {
return sourceCode;
}
// -------------------------------------------------------------------------
// Implementation of the SourceFileProvider interface
// -------------------------------------------------------------------------
public SourceFile getSourceFile() {
return sourceFile;
}
// -------------------------------------------------------------------------
// Utility methods
// -------------------------------------------------------------------------
protected void prepareSourceCode() {
final CodeWriter cw = new CodeWriter();
cw.append("#include \"").append(headerFileName).append("\"").endl();
sourceCode = cw.toString();
}
protected void prepareSourceFile() throws Exception {
final File file = new File(idlBuildDirectory, headerFileName);
sourceFile = new SourceFile(unionDefinition.getName(), file);
| |