Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - RIL

Pages: [1] 2 3 ... 11
1
IIRC there is indeed a way to call an add-in function.
I found this snippet somewhere on this forum. I never used it myself though.

$opCode = %EXEC_ADD_IN("CS_Addin", "GetSignals", classGUID, classStereotype, ...)%

Geert

Thanks of that hint, I will definitely look into that!

//Rolf

2
No idea since I do not touch that awkward stuff...
q.

I begin to understand what you mean. :)

//Rolf

3
Think about scripting the whole thing yourself.
q.

I definitely have thought of it, but at this time I'm only testing out some little idea I have and so I won't have the time to start from scratch. I had hoped EA would have supported at least the most basic of tings.

Q: Anyway, can the code templates call external scripts (so I could at least do some point fixes here and there?)

//Rolf

4
Hm. After I restarted the EA Model (after importing the code into a new model) the link-problems are back again.

Had this been a problem with Rhino3d and me posting about it on their Forum, then one of the developers would have asked for a stripped down test project in order to hunt down the problem.

Anyway, something seems to get messed up in the database. Code example again below; A List Property insists on being reintroduced as a Link attribute, disregarding the fact that the Property with the same name already exist.

//Rolf

Quote
   private CoObject _CoClassMemberInfo;
   public CoClassMemberInfo CoClassMemberInfo; // <-- This sneaks in again and again...
   public CoClassMemberInfo CoClassMemberInfo
   {
      get
      {
         if (_CoClassMemberInfo == null)
            _CoClassMemberInfo = new CoClassMemberInfo();
         return (CoClassMemberInfo)_CoClassMemberInfo;
      }
      set
      {
         Debug.Assert(false, "The CoClassMemberInfo property is read only");
      }
   }

5
What does your model look like?

Very simple. A few more lines than I already posted (it's just a small test case for some ideas I'm testing).

What changes have you made to the code templates?

None. Just to make sure nothing spooky were lurking in the code templates, I created a new EA model (100% guaranteed untouched code template) and imported and generated, and the same happened again.

But, I noticed something strange with the newly imported model - it had two copies of the class which had the problematic links. That explains it. So I deleted the dupe and generated code, and the sun is shining again.

And no, I had NOT copied that class, at least not consciously. That copy was not visible in the Project Browser on the original model. Only now, when I imported the model into a new EA project, then EA put both copies on a auto-diagram and also showing the two classes in the Project Browser.

Basically, the Code Templates that you can change are in balance with the grammars defined for the importer, which you can't change. If you change the code templates to generate something that doesn't match what the importer sees you will get this behavior.

I honestly don't think so. As long as I have valid C# code (compiling in VS) I have so far not had any problem with EA importing it. Which means that EA knows the grammar, and no matter what kind of code I would generate with a modified template (which compiles in VS), EA seems to pick it up. No connection there.

Or if I put it another way; I do not make templates which produces invalid C# code which neither VS nor EA can  handle.

The only ways to prevent it are either to not make those changes or not reverse engineer the model from the code after it's generated.

Hm, that doesn't seem to be irrelevant. What's relevant is that the C# code is valid. Well, so far EA 16.1 has handled import without any problem.

What I have noticed though is that sometimes EA doesn't show what it has in the database.  For example the Delphi project I posted about which had some 16.300 .pas files. I had to close EA and start it again before any of the ~20.000 classes would show in the Project Browser. Reminds about this problem where the Project Browser didn't bother show me I had a copy of a class (must have pressed CTRL-C, CTRL-V when not having focus in the right place... or something).

The developers would have reasons to  investigate why the UI doesn't always reflect the data...

//Rolf

6
For some reason some (several) list attributes which I turned into Properties, keeps being regenerated as List attribute again, causing conflict (due to duplicate identifiers).

Illustrated below the Property "CoElements" is re-generated as a list attribute even if I delete it in the code and synchronize the code back up to EA. But when generating code the next time, that evil attribute is back in the code again. I have several of these cases, which requires manual clean up.

Q: Is there any way I can prevent EA from regenerating such extra attribute copies of what should only be a property? (plus its inner member).

Quote
public List<Co_Element> CoElements;     // Attribute keeps being regenerated - Irritating

private List<Co_Element> _CoElements; // "Inner member" as intended - OK

public List<Co_Element> CoElements;    // Property as intended - OK
{
    get
    {
        if (_CoElements == null)
            _CoElements = new List<Co_Element>();
        return _CoElements;
    }
}

//Rolf

7
Just a guess (not done Delphi for a long time) - is that because you have a semicolon between your definitions of Originator and OriginalEvent on Line 150, so EA treats that as a newline (hence the 'of' which you have on numerical Line 151 could 'technically' be treated by EA as Line 152 by EA)?

In this particular case I have in an earlier step tried to comment away the failing code altogether (see the "//" in the left margin). But that only proved to me that EA doesn't even respect the comment symbols, it still tries to parse the commented code as some code it needs to pick up...

That's when I really started doubting that Delphi code language has been supported for a long long time... :-(

Now, at this time I don't really need Delphi code that compiles, I just need to import a bunch of classes to study the structure. There are more than 16.000 files in the project (yes sixteen thousand+), which is the reason I want to examine the code also with the help of UML. But when it became obvious that EA doesn't even respect (or skip parsing) the commented code, it felt rather cheap. I had to use regex to pick up the "of" keywords and split it into "o/f" so EA wouldn't nose-dive into it.

The Delphi language in EA hasn't received much love in recent decades, I can tell.  :)

Although I program mostly in C# these days, the listed support for the Delphi language was one of the reasons I bought EA, because I have plenty of legacy Delphi code I could make use of if having the right tools for it.

//Rolf

8
Interestingly enough, EA doesn't even skip commented lines, it still complains about an "of" on line 152 even if it's been commented out and the former row isn't even on the same line anymore.

Quote
148 //  RIL Disabled:
149 //  TEventHandler = procedure (
150 //    Originator: TObject; OriginalEvent: TEvent;
151 //    RequestedEvent: TRequestedEvent) of object;
152     TEventHandler = T_procedure_RILFakeEvent; // Gotta let EA create something...

I realize that Delphi code isn't really supported by EA.

//Rolf

9
Quote
From memory (and it's been a few years) EA handles partial classes by modeling them as separate entities, because even though they are conceptually part of the same thing, the language authors appeared to want to separate/hide portions of the code for a class. That means you have two filename fields to work with and you can do what you're after.

The problem with that is that when moving the project or copying the project, there would be need to recreated the file names, and then the two classes (with the same name) would.... have the same name and thus overwrite each other.

But as I write this I wonder if I could use a %path_name%\ClassName.co.cs to preserve the originally defined classname? I will try that.

//Rolf

10
I wasn't ignoring you because you changed topic within a thread. I was at home relaxing because I don't actually work 24 hours a day.

Why would you assume that I felt ignored but not assuming that I suddenly realized that it is (generally speaking) better to start new threads for new topics?

As I'm writing this I'm finding that the question wasn't answered neither here or in the new thread. What should I assume is the reason for that? Would it be more decent of me to not assume anything at all and just wait for an answer, or try to come up with some less than amicable reason? What do you think?

//Rolf

11
General Board / Delphi code import doesn't recognize "set of" and "of"
« on: February 20, 2024, 09:05:38 am »
Trying to import some legacy Delphi code the code importer failed the import with with unrecognized keywords  "set of" and "of".

Example of code that fails to import:

Quote
TSmallEventSet = set of TSmallEvent;

TExtendedEventHandler = procedure (
    Originator: TObject; OriginalEvent: TEvent;
    RequestedEvent: TRequestedEvent; const Args: array of const) of object;

These keywords are from around 2000 (Delphi 6 or 7) but seems to still be valid syntax as of at least Delphi 10.4.
https://docwiki.embarcadero.com/RADStudio/Sydney/en/Structured_Types_(Delphi)

Perhaps there's an alternate syntax I could transform into before importing?

//Rolf


These

12
Q: What would be the easiest way to manipulate the Code Generation to suggest a different file name than only the plain Class name?

I had an idea that I could either Tag a copy of the class, or make a different Code Template for the (other) partial class (and run the code generation twice by swapping the code language at the package level), but it seems that the Code Templates are not involved in constructing the class file name (?)

Since I use partial classes to shovel some framework code aside, I need to generate code in two different ways from the same class and thus I need to create two different files from the same class as well.
Example: Say I want the default name for one partial class file (MyClass.cs) and the other partial class filename (MyClass.co.cs)


13
OK. I'll ask the last question again in a different thread.

//Rolf

14
Quote
I suspect that the way to do what you want is to apply a transformation to the imported code

Well, EA should support such a simple trick to solve an immensely powerful concept.

Q: Anyway, is the a way to manipulate the Code Template to suggest a different file name than only the plain Class name? It doesn't seem like the Code Template is involved in constructing the file name (for a class), but I might be wrong.

I need to put different partial classes into different files, but as long as the file name is the (plain) class name by default, there's the risk that the filename name gets reverted to default name, and so there's the risk for overwriting the wrong partial class code.

//Rolf

15
QUESTION:
Would it be possible to somehow use one language template for Code Generation (like my customized language version(s)), but for synchronize/import of source code, use the original EA C# language template? That would be gold.

But As I understand it, the language gets sticky in the properties of classes after first code generation, and it'd be very time consuming to switch the language between code generation and synchronization.

BUT WHY...?
I find that I more often than not want to modify the Code Template (for C# in this case) but since I also don't want to "destroy" the original template, I want to make a copy and modify the copy. This is sometimes due to very "heavy modifications".

Well, I tried this the other day. And my new fancy language version worked fine for Code Generation but... when I want to Synchronize, then EA complains that it cannot import source code with a customized template. I get that, and so that's why the question.

To use the original C# language for import won't be a problem since my own version is still generating only valid C# code (of course).

Any ideas for how to manage this? (I suppose that EA doesn't want to provide anytime soon an extra property ("Language_gen") which if assigned a language name, EA would use that language for code generation instead of the standard language.)

//Rolf

Pages: [1] 2 3 ... 11