Recent Changes - Search:

edit SideBar

ChangesToCCodeGeneratorJavaFileMadeForMbed

Back to Mbed

The purpose of this file is to log the changes made in CCodeGenerator.java, and hopefully help anyone else that needs to edit this file for compatibility issues.

  • variable "emptyToken" in file _ptTypes.h is declared in the header file. This should be extern and declared in the c source file so that a C++ compiler will work.
    • Fixed, edited CCodeGenerator.java where this was put, used codeC.append() to add the code to c file, and edited file that was added to the .h file on a condition.

Before:

    // Token declareBlock.
        if (typeMembers.length() != 0) {
            sharedStream.clear();
            args.add(typeMembers.toString());
            sharedStream.appendCodeBlock("tokenDeclareBlock", args);

            if (defineEmptyToken) {
                sharedStream.append("Token emptyToken; "
                        + comment("Used by *_delete() and others.") + _eol);
            }
            codeH.append(sharedStream.toString());
        }

After:

    // Token declareBlock.
        if (typeMembers.length() != 0) {
            sharedStream.clear();
            args.add(typeMembers.toString());
            sharedStream.appendCodeBlock("tokenDeclareBlock", args);

            if (defineEmptyToken) {
                sharedStream.append("extern Token emptyToken; "
                        + comment("Used by *_delete() and others.") + _eol);
                codeC.append("Token emptyToken;" 
                        + comment("Used by *_delete() and others.") + _eol); 
            }
            codeH.append(sharedStream.toString());
        }
  • The other change to be made for the same issue. Note, I also fixed the CompositeActor declaration since it has the same issue.
    • Variables "struct AtomicActor* Display_Sequence3" and "struct AtomicActor* Display_Display" in Display.h

Before:

    for (Object containedActorO : container.deepEntityList()) {
            NamedObj containedActor = (NamedObj) containedActorO;
            if (CodeGeneratorAdapter.generateName(containedActor).contains(
                    "Controller")) {
                continue;
            }
            if (containedActor instanceof AtomicActor
                    || containedActor instanceof FSMActor) {
                HCode.append("struct AtomicActor* "
                        + CodeGeneratorAdapter.generateName(containedActor)
                        + ";" + _eol);
            } else if (containedActor instanceof CompositeActor) {
                HCode.append("struct CompositeActor* "
                        + CodeGeneratorAdapter.generateName(containedActor)
                        + ";" + _eol);
            }
        }

After:

    for (Object containedActorO : container.deepEntityList()) {
            NamedObj containedActor = (NamedObj) containedActorO;
            if (CodeGeneratorAdapter.generateName(containedActor).contains(
                    "Controller")) {
                continue;
            }
            if (containedActor instanceof AtomicActor
                    || containedActor instanceof FSMActor) {
                CCode.append("struct AtomicActor* "
                        + CodeGeneratorAdapter.generateName(containedActor)
                        + ";" + _eol);
                HCode.append("extern struct AtomicActor* "
                        + CodeGeneratorAdapter.generateName(containedActor)
                        + ";" + _eol);
            } else if (containedActor instanceof CompositeActor) {
                CCode.append("struct CompositeActor* "
                        + CodeGeneratorAdapter.generateName(containedActor)
                        + ";" + _eol);
                HCode.append("extern struct CompositeActor* "
                        + CodeGeneratorAdapter.generateName(containedActor)
                        + ";" + _eol);
            }
        }

In order to fix #include issues that embedded platforms do not have, certain files that are included in the generated code have to be changed. An example of a change made"

  • #include <sys/dir.h> in pbl.h mbed does not have this. Location of the file:
    • pbl.h is created from $PTII/ptolemy/cg/kernel/generic/program/procedural/c/structures/pbl.h

In order to fix this. The include is wrapped in:

    #if !defined(__MBED___)
        #include <sys/dir.h> 
    #endif
Edit - History - Print - Recent Changes - Search
Page last modified on March 03, 2015, at 11:11 pm