cogu / cfile Goto Github PK
View Code? Open in Web Editor NEWA python C code generator
License: MIT License
A python C code generator
License: MIT License
Thanks for the work, probably the only one which would work for the my needs!
Is there a way to generate either of the following lines:
typedef struct mystruct {
int field_1;
int field_2;
} my_struct_t ;
my_struct_t instance = {
.field_1= 0,
.field_2= 1
};
or
typedef struct mystruct {
int field_1;
int field_2;
} my_struct_t ;
my_struct_t instance = { 0, 1 };
Thanks in advance
Hi,
Cool project by the way.
I was messing around with my fork of your project (not many changes mostly just running black and a couple of tweaks), and the I ran mypy:
mypy src
and I got the following (I fixed a couple, so this list should be a little longer on your version). I definitely recommend checking this out since you need to have rigor in your type system and vs code doesn't pick up on these.
src/cfile/core.py:469: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs [annotation-unchecked]
src/cfile/core.py:477: error: Item "Comment" of "Comment | Statement | Sequence" has no attribute "append" [union-attr]
src/cfile/core.py:477: error: Item "Statement" of "Comment | Statement | Sequence" has no attribute "append" [union-attr]
src/cfile/core.py:484: error: Item "Comment" of "Comment | Statement | Sequence" has no attribute "extend" [union-attr]
src/cfile/core.py:484: error: Item "Statement" of "Comment | Statement | Sequence" has no attribute "extend" [union-attr]
src/cfile/writer.py:34: error: Incompatible types in assignment (expression has type "None", variable has type "str") [assignment]
src/cfile/writer.py:35: error: Incompatible types in assignment (expression has type "None", variable has type "TextIO") [assignment]
src/cfile/writer.py:141: error: "TextIO" has no attribute "getvalue" [attr-defined]
src/cfile/writer.py:148: error: "TextIO" has no attribute "getvalue" [attr-defined]
src/cfile/writer.py:155: error: Cannot call function of unknown type [operator]
src/cfile/writer.py:162: error: Item "Comment" of "Comment | Statement | Sequence" has no attribute "__iter__" (not iterable) [union-attr]
src/cfile/writer.py:162: error: Item "Statement" of "Comment | Statement | Sequence" has no attribute "__iter__" (not iterable) [union-attr]
src/cfile/writer.py:162: error: Item "Sequence" of "Comment | Statement | Sequence" has no attribute "__iter__" (not iterable) [union-attr]
src/cfile/writer.py:189: error: Cannot call function of unknown type [operator]
src/cfile/writer.py:212: error: Cannot call function of unknown type [operator]
src/cfile/writer.py:317: error: Argument 1 to "_write_type" of "Writer" has incompatible type "Type | Struct"; expected "Type | StructRef" [arg-type]
src/cfile/writer.py:341: error: Item "Struct" of "Type | Struct" has no attribute "pointer" [union-attr]
src/cfile/writer.py:351: error: Item "Struct" of "Type | Struct" has no attribute "pointer" [union-attr]
src/cfile/writer.py:437: error: Argument 1 to "len" has incompatible type "Comment | Statement | Sequence"; expected "Sized" [arg-type]
src/cfile/factory.py:34: error: Incompatible return value type (got "Line", expected "Blank") [return-value]
src/cfile/factory.py:99: error: Invalid type comment or annotation [valid-type]
src/cfile/factory.py:99: note: Suggestion: use core.Block[...] instead of core.Block(...)
src/cfile/factory.py:114: error: Argument 2 to "Function" has incompatible type "str | Type | Struct | None"; expected "str | Type | None" [arg-type]
src/cfile/factory.py:126: error: Argument 1 to "Type" has incompatible type "str | Type | Struct"; expected "str | Type" [arg-type]
Found 22 errors in 3 files (checked 5 source files)
In several places I have found highly redundant boolean opertions. For example:
Line 25 in 21bc32b
self.sys=sys
, or self.sys=bool(sys)
if you're paranoid about imprecise types. Also, in general, x == True
is eqivalent to x
, and x == False
- to not x
. I think refactoring this would make your code a lot clearerA declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.