I'm trying to generate a class diagram, using reverse engineering, but the following is happening:
There was an error parsing C:\Documents and Settings\Meus documentos\EA_Documentos\Modelos\Environment\class\Factory.h on line 11. Unexpected symbol: ISIMFactory
You may need to define a language macro.
There was an error parsing C:\Documents and Settings\Meus documentos\EA_Documentos\Modelos\Environment\class\Model.h on line 99. Unexpected symbol: ISIMModel
You may need to define a language macro.
There are many more of these.
This is the corresponding code in CSIMEnvironmentModel.h
class SIMMDLENVv01_EXPORT CSIMEnvironmentModel // line 99
: public ISIMModel
, public ISIMEventSource
, public ISIMScheduledModel
, public ISIMExecut
, public ISIMPublisher
{
public:
CSIMEnvironmentModel(const std::string &a_modelType);
virtual ~CSIMEnvironmentModel(void);
and CSIMEnvFactory.h
class SIMMDLENVv01_EXPORT CSIMEnvFactory // line 11
: public ISIMFactory
{
public:
CSIMEnvFactory();
virtual ~CSIMEnvFactory(void);
std::vector<ISIMModel*> InstanceModel(const std::string &a_modelType, const std::string &a_conf);
};
What's the reason for this error message?
Your code contains usage of a macro definition (SIMMDLENVv01_EXPORT) that isn't part of EA's standard macro definitions (there's whole a lot of them covering ATL and MFC mostly).
You'll need to add additional ones under 'Settings->Language Macros' (as the hint in the error message suggests).
NOTE
Use the syntax MACRO() when declaring macros that were #defined to receive any number of arguments.
If you're trying to reverse engineer framework libraries like Qt or alike, you'll need to set many of these that you're able to reverse engineer the code without getting errors.
May be you should think of a different strategy to reference these types and classes in your model then.
Another workaround might be to solely preprocess all the code you want to import first, and import from the preprocessed results.
Related
I'm using Calcite for parsing and executing queries, and can't figure out how to implement functions like Postgres' current_schema(). For functions with non-reserved keywords, ex: VERSION(), the implementation is fairly straightforward:
private void addRootOperators() {
SchemaPlus plus = this.rootSchema.plus();
// VersionFunction is a custom class with a run() method
plus.add("VERSION", ScalarFunctionImpl.create(VersionFunction.class, "run"));
}
Unfortunately this approach doesn't work when I try to implement CURRENT_SCHEMA(), though it will if I give it a non-reserved name.
When I run the query SELECT current_schema() with the function defined like VERSION above, I get the error:
Encountered "(" at line 1, column 22
I believe this is because the default implementation of CURRENT_SCHEMA is as a SqlStringContextVariable (hence why the parentheses are causing a parsing error), but I don't know how to support the version of the function with the parentheses in light of this.
Full disclosure, I asked this same question on the PyTorch forums about a few days ago and got no reply, so this is technically a repost, but I believe it's still a good question, because I've been unable to find an answer anywhere online. Here goes:
Can you show an example of using register_module with a custom module?
The only examples I’ve found online are registering linear layers or convolutional layers as the submodules.
I tried to write my own module and register it with another module and I couldn’t get it to work.
My IDE is telling me no instance of overloaded function "MyModel::register_module" matches the argument list -- argument types are: (const char [14], TreeEmbedding)
(TreeEmbedding is the name of another struct I made which extends torch::nn::Module.)
Am I missing something? An example of this would be very helpful.
Edit: Additional context follows below.
I have a header file "model.h" which contains the following:
struct TreeEmbedding : torch::nn::Module {
TreeEmbedding();
torch::Tensor forward(Graph tree);
};
struct MyModel : torch::nn::Module{
size_t embeddingSize;
TreeEmbedding treeEmbedding;
MyModel(size_t embeddingSize=10);
torch::Tensor forward(std::vector<Graph> clauses, std::vector<Graph> contexts);
};
I also have a cpp file "model.cpp" which contains the following:
MyModel::MyModel(size_t embeddingSize) :
embeddingSize(embeddingSize)
{
treeEmbedding = register_module("treeEmbedding", TreeEmbedding{});
}
This setup still has the same error as above. The code in the documentation does work (using built-in components like linear layers), but using a custom module does not. After tracking down torch::nn::Linear, it looks as though that is a ModuleHolder (Whatever that is...)
Thanks,
Jack
I will accept a better answer if anyone can provide more details, but just in case anyone's wondering, I thought I would put up the little information I was able to find:
register_module takes in a string as its first argument and its second argument can either be a ModuleHolder (I don't know what this is...) or alternatively it can be a shared_ptr to your module. So here's my example:
treeEmbedding = register_module<TreeEmbedding>("treeEmbedding", make_shared<TreeEmbedding>());
This seemed to work for me so far.
I'm working on a relatively large SML codebase. It was originally written to compile with MLton, but I'm now working with it under SML/NJ. I need to use RedBlackMapFn, which is defined in smlnj-lib.cm. However, I get an error:
elaborate/elaborate-bomenv.fun:9.20-9.27 Error: unbound signature: ORD_KEY
elaborate/elaborate-bomenv.fun:14.21-14.40 Error: unbound functor: RedBlackMapFn
elaborate/elaborate-bomenv.fun:32.20-32.27 Error: unbound signature: ORD_KEY
elaborate/elaborate-bomenv.fun:37.21-37.40 Error: unbound functor: RedBlackMapFn
So I assume that smlnj-lib.cm is not being pulled by CM. In an effort to fix this, I added $/smlnj-lib.cm to the sources.cm file in the directory that I'm working in. This causes a separate issue:
elaborate/sources.cm:25.1-25.18 Error: structure Random imported from $SMLNJ-LIB/Util/smlnj-lib.cm#243997(random.sml) and also from ./(sources.cm):lib/(sources.cm):basic/(sources.cm):random.sml
elaborate/sources.cm:25.1-25.18 Error: structure Queue imported from $SMLNJ-LIB/Util/smlnj-lib.cm#436143(queue.sml) and also from ./(sources.cm):lib/(sources.cm):basic/(sources.cm):two-list-queue.sml
No dice. I tried removing the Random structure that's coming from ./(sources.cm):lib/(sources.cm):basic/(sources.cm):random.sml, but it appears that it isn't equivalent to the one defined in the standard library, so I can't just substitute one for the other.
I'd like to use something like Python's import ... from ... as ...
mechanism to give a new name to the Random that's coming from the standard library, but CM's documentation doesn't offer any hints as to how I'd go about that.
How can I resolve a module naming conflict across multiple SML files?
I ended up splitting off the problematic file in to a separate .cm. The problem file here is elaborate-bomenv.{sig, fun}. The .cm file for this directory is sources.cm, which caused errors when it looked like:
Group
...
is
$/basis.cm
...
elaborate-bomenv.fun
elaborate-bomenv.sig
...
So instead, I made an elaborate-bomenv-sources.cm that looks like:
Group
signature ELABORATE_BOMENV
functor BOMEnv
is
$/smlnj-lib.cm
...
elaborate-bomenv.sig
elaborate-bomenv.fun
and changed the original sources.cm to read:
Group
...
is
$/basis.cm
...
./elaborate-bomenv-sources.cm
...
Which is ugly, but it works.
I am trying to create a very simple MFC application when suddenly Visual Studio decides it no longer recognizes what a BOOL is.
I cannot figure out why this is happening. Does anyone know why this is going on and how to fix it?
It looks like you're missing a closing semi-colon at the end of your class.
class CApp : public CWinApp {
...
}; <---
This is the proper class syntax. I'm sure you know that and just happened to delete it and missed the simple error. I would say when you look at the error report it's best to solve the topmost one first. Doing so can eliminate other errors in the list especially in the case of a ;. Your image reflects that on the first line where it tells you about a missing ;.
I try to make a class diagram from existing C++ code using Enterprise Architect 9.3.935. I do Code Engineering / Import Source Directory and then select my directory.
However, I get tons of error of type:
"There was an error parsing C:\xxxxx # on line xxxx. Unexpected symbol: XXXXX.
You may need to define a language macro."
In the code, I have a macro for exporting DLL and most of my class look like :
class MACRO_FOR_DLL_EXPORT CMyClassName
{
...
}
or
class MACRO_FOR_DLL_EXPORT CMyClassName : public CHerMother
{
...
}
The unexpected symbol is usually "{" in the first case and "CHerMother" in the second.
How to fix this issue, is it related with the macro ?
You can declare several Language specific macros in your EA project, to ignore these when reverse engineering (parsing) code. There's a number of standard C/C++ framework macros predefined natively by EA.