cshape 0.2.1__tar.gz → 0.2.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {cshape-0.2.1 → cshape-0.2.2}/PKG-INFO +10 -1
- {cshape-0.2.1 → cshape-0.2.2}/README.md +9 -0
- {cshape-0.2.1 → cshape-0.2.2}/cshape.egg-info/PKG-INFO +10 -1
- {cshape-0.2.1 → cshape-0.2.2}/cshape.py +37 -64
- {cshape-0.2.1 → cshape-0.2.2}/pyproject.toml +1 -1
- {cshape-0.2.1 → cshape-0.2.2}/tests/test_smoke.py +18 -2
- {cshape-0.2.1 → cshape-0.2.2}/LICENSE +0 -0
- {cshape-0.2.1 → cshape-0.2.2}/cshape.egg-info/SOURCES.txt +0 -0
- {cshape-0.2.1 → cshape-0.2.2}/cshape.egg-info/dependency_links.txt +0 -0
- {cshape-0.2.1 → cshape-0.2.2}/cshape.egg-info/top_level.txt +0 -0
- {cshape-0.2.1 → cshape-0.2.2}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: cshape
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.2
|
|
4
4
|
Summary: A dependency-free C AST + printer: build a tree in Python, get C11 source back
|
|
5
5
|
Author-email: Alex Balan <outsiders.b@gmail.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -62,6 +62,12 @@ int add(int a, int b) {
|
|
|
62
62
|
starts with a blank line by default, so `.strip()` if you're printing a
|
|
63
63
|
single node standalone rather than concatenating several.)
|
|
64
64
|
|
|
65
|
+
## Documentation
|
|
66
|
+
|
|
67
|
+
- [docs/api.md](docs/api.md) - documentation index
|
|
68
|
+
- [docs/quickstart.md](docs/quickstart.md) - getting started and first example
|
|
69
|
+
- [docs/reference.md](docs/reference.md) - current API reference
|
|
70
|
+
|
|
65
71
|
## What it covers
|
|
66
72
|
|
|
67
73
|
- Types: named types, pointers, arrays, function types, structs/unions, enums
|
|
@@ -77,6 +83,9 @@ single node standalone rather than concatenating several.)
|
|
|
77
83
|
- A `.mark` field on every node: set it to any string and it shows up as a
|
|
78
84
|
`/*mark*/` comment right before that node in the output — useful for
|
|
79
85
|
tracing which part of your own compiler/generator produced which bit of C
|
|
86
|
+
- A `.note` field on every value, printed as a `/* note */` comment *after*
|
|
87
|
+
the value — for saying where a value came from once it no longer shows:
|
|
88
|
+
`3.125 /* totalVolume / elementVolume */`
|
|
80
89
|
|
|
81
90
|
## What it doesn't do
|
|
82
91
|
|
|
@@ -44,6 +44,12 @@ int add(int a, int b) {
|
|
|
44
44
|
starts with a blank line by default, so `.strip()` if you're printing a
|
|
45
45
|
single node standalone rather than concatenating several.)
|
|
46
46
|
|
|
47
|
+
## Documentation
|
|
48
|
+
|
|
49
|
+
- [docs/api.md](docs/api.md) - documentation index
|
|
50
|
+
- [docs/quickstart.md](docs/quickstart.md) - getting started and first example
|
|
51
|
+
- [docs/reference.md](docs/reference.md) - current API reference
|
|
52
|
+
|
|
47
53
|
## What it covers
|
|
48
54
|
|
|
49
55
|
- Types: named types, pointers, arrays, function types, structs/unions, enums
|
|
@@ -59,6 +65,9 @@ single node standalone rather than concatenating several.)
|
|
|
59
65
|
- A `.mark` field on every node: set it to any string and it shows up as a
|
|
60
66
|
`/*mark*/` comment right before that node in the output — useful for
|
|
61
67
|
tracing which part of your own compiler/generator produced which bit of C
|
|
68
|
+
- A `.note` field on every value, printed as a `/* note */` comment *after*
|
|
69
|
+
the value — for saying where a value came from once it no longer shows:
|
|
70
|
+
`3.125 /* totalVolume / elementVolume */`
|
|
62
71
|
|
|
63
72
|
## What it doesn't do
|
|
64
73
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: cshape
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.2
|
|
4
4
|
Summary: A dependency-free C AST + printer: build a tree in Python, get C11 source back
|
|
5
5
|
Author-email: Alex Balan <outsiders.b@gmail.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -62,6 +62,12 @@ int add(int a, int b) {
|
|
|
62
62
|
starts with a blank line by default, so `.strip()` if you're printing a
|
|
63
63
|
single node standalone rather than concatenating several.)
|
|
64
64
|
|
|
65
|
+
## Documentation
|
|
66
|
+
|
|
67
|
+
- [docs/api.md](docs/api.md) - documentation index
|
|
68
|
+
- [docs/quickstart.md](docs/quickstart.md) - getting started and first example
|
|
69
|
+
- [docs/reference.md](docs/reference.md) - current API reference
|
|
70
|
+
|
|
65
71
|
## What it covers
|
|
66
72
|
|
|
67
73
|
- Types: named types, pointers, arrays, function types, structs/unions, enums
|
|
@@ -77,6 +83,9 @@ single node standalone rather than concatenating several.)
|
|
|
77
83
|
- A `.mark` field on every node: set it to any string and it shows up as a
|
|
78
84
|
`/*mark*/` comment right before that node in the output — useful for
|
|
79
85
|
tracing which part of your own compiler/generator produced which bit of C
|
|
86
|
+
- A `.note` field on every value, printed as a `/* note */` comment *after*
|
|
87
|
+
the value — for saying where a value came from once it no longer shows:
|
|
88
|
+
`3.125 /* totalVolume / elementVolume */`
|
|
80
89
|
|
|
81
90
|
## What it doesn't do
|
|
82
91
|
|
|
@@ -55,13 +55,12 @@ def str_nl_indent(nl=1):
|
|
|
55
55
|
return s
|
|
56
56
|
|
|
57
57
|
|
|
58
|
-
def render(node, style='legacy', indent='\t'
|
|
58
|
+
def render(node, style='legacy', indent='\t'):
|
|
59
59
|
global indent_level, styleguide, nl_symbol, indent_symbol
|
|
60
60
|
|
|
61
61
|
saved = (indent_level, styleguide, nl_symbol, indent_symbol)
|
|
62
62
|
indent_level = 0
|
|
63
63
|
styleguide = styles[style]
|
|
64
|
-
nl_symbol = newline
|
|
65
64
|
indent_symbol = indent
|
|
66
65
|
|
|
67
66
|
try:
|
|
@@ -141,11 +140,6 @@ def str_gcc_attributes(attributes):
|
|
|
141
140
|
|
|
142
141
|
|
|
143
142
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
143
|
class CField():
|
|
150
144
|
def __init__(self, id, type, specifiers=None, nl=0):
|
|
151
145
|
#assert(isinstance(type, CType))
|
|
@@ -395,13 +389,14 @@ class KV():
|
|
|
395
389
|
|
|
396
390
|
|
|
397
391
|
class CValue():
|
|
398
|
-
def __init__(self):
|
|
392
|
+
def __init__(self, nl=0):
|
|
399
393
|
self.mark = None
|
|
394
|
+
self.nl = nl
|
|
400
395
|
|
|
401
396
|
|
|
402
397
|
class CValueIdentifier(CValue):
|
|
403
|
-
def __init__(self, id):
|
|
404
|
-
super().__init__()
|
|
398
|
+
def __init__(self, id, nl=0):
|
|
399
|
+
super().__init__(nl=nl)
|
|
405
400
|
self.id = id
|
|
406
401
|
self.precedence = 15
|
|
407
402
|
|
|
@@ -412,8 +407,8 @@ class CValueIdentifier(CValue):
|
|
|
412
407
|
|
|
413
408
|
|
|
414
409
|
class CValueInteger(CValue):
|
|
415
|
-
def __init__(self, number, as_hex=False, nsigns=0, suffix=''):
|
|
416
|
-
super().__init__()
|
|
410
|
+
def __init__(self, number, as_hex=False, nsigns=0, suffix='', nl=0):
|
|
411
|
+
super().__init__(nl=nl)
|
|
417
412
|
assert(isinstance(number, int))
|
|
418
413
|
assert(isinstance(as_hex, bool))
|
|
419
414
|
self.precedence = 15
|
|
@@ -441,9 +436,9 @@ def string_literal_prefix(width):
|
|
|
441
436
|
|
|
442
437
|
|
|
443
438
|
class CValueString(CValue):
|
|
444
|
-
def __init__(self, string, width):
|
|
439
|
+
def __init__(self, string, width, nl=0):
|
|
445
440
|
assert(isinstance(string, str))
|
|
446
|
-
super().__init__()
|
|
441
|
+
super().__init__(nl=nl)
|
|
447
442
|
self.string = string
|
|
448
443
|
self.width = width
|
|
449
444
|
self.precedence = 15
|
|
@@ -475,9 +470,9 @@ def code_to_char(cc):
|
|
|
475
470
|
|
|
476
471
|
|
|
477
472
|
class CValueChar(CValue):
|
|
478
|
-
def __init__(self, cc, width=8):
|
|
473
|
+
def __init__(self, cc, width=8, nl=0):
|
|
479
474
|
assert(isinstance(cc, int))
|
|
480
|
-
super().__init__()
|
|
475
|
+
super().__init__(nl=nl)
|
|
481
476
|
self.char_code = cc
|
|
482
477
|
self.width = width
|
|
483
478
|
self.precedence = 15
|
|
@@ -488,8 +483,8 @@ class CValueChar(CValue):
|
|
|
488
483
|
|
|
489
484
|
|
|
490
485
|
class CValueArray(CValue):
|
|
491
|
-
def __init__(self, items):
|
|
492
|
-
super().__init__()
|
|
486
|
+
def __init__(self, items, nl=0):
|
|
487
|
+
super().__init__(nl=nl)
|
|
493
488
|
self.items = items
|
|
494
489
|
self.precedence = 15
|
|
495
490
|
|
|
@@ -520,8 +515,8 @@ class CValueArray(CValue):
|
|
|
520
515
|
|
|
521
516
|
|
|
522
517
|
class CValueStruct(CValue):
|
|
523
|
-
def __init__(self, items):
|
|
524
|
-
super().__init__()
|
|
518
|
+
def __init__(self, items, nl=0):
|
|
519
|
+
super().__init__(nl=nl)
|
|
525
520
|
self.items = items
|
|
526
521
|
self.precedence = 15
|
|
527
522
|
|
|
@@ -561,14 +556,14 @@ class CValueStruct(CValue):
|
|
|
561
556
|
|
|
562
557
|
|
|
563
558
|
class CValueParen(CValue):
|
|
564
|
-
def __init__(self, value):
|
|
559
|
+
def __init__(self, value, nl=0):
|
|
565
560
|
assert(isinstance(value, CValue))
|
|
566
|
-
super().__init__()
|
|
561
|
+
super().__init__(nl=nl)
|
|
567
562
|
self.value = value
|
|
568
563
|
self.precedence = 15
|
|
569
564
|
|
|
570
565
|
def __str__(self):
|
|
571
|
-
return
|
|
566
|
+
return str_cvalue(self.value, ext_precedence=valuePrecedenceMax)
|
|
572
567
|
|
|
573
568
|
|
|
574
569
|
|
|
@@ -661,28 +656,6 @@ class CValueDereference(CValue):
|
|
|
661
656
|
return '*%s' % str_cvalue(self.value, ext_precedence=self.precedence)
|
|
662
657
|
|
|
663
658
|
|
|
664
|
-
class CValueIncrement(CValue):
|
|
665
|
-
def __init__(self, value):
|
|
666
|
-
assert(isinstance(value, CValue))
|
|
667
|
-
super().__init__()
|
|
668
|
-
self.value = value
|
|
669
|
-
self.precedence = 13
|
|
670
|
-
|
|
671
|
-
def __str__(self):
|
|
672
|
-
return '++%s' % (str_cvalue(self.value, ext_precedence=self.precedence))
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
class CValueDecrement(CValue):
|
|
676
|
-
def __init__(self, value):
|
|
677
|
-
assert(isinstance(value, CValue))
|
|
678
|
-
super().__init__()
|
|
679
|
-
self.value = value
|
|
680
|
-
self.precedence = 13
|
|
681
|
-
|
|
682
|
-
def __str__(self):
|
|
683
|
-
return '--%s' % str_cvalue(self.value, ext_precedence=self.precedence)
|
|
684
|
-
|
|
685
|
-
|
|
686
659
|
class CValueUnaryPlus(CValue):
|
|
687
660
|
def __init__(self, value):
|
|
688
661
|
assert(isinstance(value, CValue))
|
|
@@ -760,7 +733,7 @@ class CValueMul(CValue):
|
|
|
760
733
|
|
|
761
734
|
def __str__(self):
|
|
762
735
|
lx = str_cvalue(self.left, ext_precedence=self.precedence)
|
|
763
|
-
rx = str_cvalue(self.right, ext_precedence=self.precedence)
|
|
736
|
+
rx = str_cvalue(self.right, ext_precedence=self.precedence + 1)
|
|
764
737
|
return '%s * %s' % (lx, rx)
|
|
765
738
|
|
|
766
739
|
|
|
@@ -775,7 +748,7 @@ class CValueDiv(CValue):
|
|
|
775
748
|
|
|
776
749
|
def __str__(self):
|
|
777
750
|
lx = str_cvalue(self.left, ext_precedence=self.precedence)
|
|
778
|
-
rx = str_cvalue(self.right, ext_precedence=self.precedence)
|
|
751
|
+
rx = str_cvalue(self.right, ext_precedence=self.precedence + 1)
|
|
779
752
|
return '%s / %s' % (lx, rx)
|
|
780
753
|
|
|
781
754
|
|
|
@@ -790,7 +763,7 @@ class CValueMod(CValue):
|
|
|
790
763
|
|
|
791
764
|
def __str__(self):
|
|
792
765
|
lx = str_cvalue(self.left, ext_precedence=self.precedence)
|
|
793
|
-
rx = str_cvalue(self.right, ext_precedence=self.precedence)
|
|
766
|
+
rx = str_cvalue(self.right, ext_precedence=self.precedence + 1)
|
|
794
767
|
return '%s %% %s' % (lx, rx)
|
|
795
768
|
|
|
796
769
|
|
|
@@ -805,7 +778,7 @@ class CValueAdd(CValue):
|
|
|
805
778
|
|
|
806
779
|
def __str__(self):
|
|
807
780
|
lx = str_cvalue(self.left, ext_precedence=self.precedence)
|
|
808
|
-
rx = str_cvalue(self.right, ext_precedence=self.precedence)
|
|
781
|
+
rx = str_cvalue(self.right, ext_precedence=self.precedence + 1)
|
|
809
782
|
return '%s + %s' % (lx, rx)
|
|
810
783
|
|
|
811
784
|
|
|
@@ -820,7 +793,7 @@ class CValueSub(CValue):
|
|
|
820
793
|
|
|
821
794
|
def __str__(self):
|
|
822
795
|
lx = str_cvalue(self.left, ext_precedence=self.precedence)
|
|
823
|
-
rx = str_cvalue(self.right, ext_precedence=self.precedence)
|
|
796
|
+
rx = str_cvalue(self.right, ext_precedence=self.precedence + 1)
|
|
824
797
|
return '%s - %s' % (lx, rx)
|
|
825
798
|
|
|
826
799
|
|
|
@@ -839,7 +812,7 @@ class CValueShiftLeft(CValue):
|
|
|
839
812
|
lprec = self.precedence
|
|
840
813
|
if self.left.precedence == self.precedence + 1:
|
|
841
814
|
lprec = valuePrecedenceMax
|
|
842
|
-
rprec = self.precedence
|
|
815
|
+
rprec = self.precedence + 1
|
|
843
816
|
if self.right.precedence == self.precedence + 1:
|
|
844
817
|
rprec = valuePrecedenceMax
|
|
845
818
|
|
|
@@ -863,7 +836,7 @@ class CValueShiftRight(CValue):
|
|
|
863
836
|
lprec = self.precedence
|
|
864
837
|
if self.left.precedence == self.precedence + 1:
|
|
865
838
|
lprec = valuePrecedenceMax
|
|
866
|
-
rprec = self.precedence
|
|
839
|
+
rprec = self.precedence + 1
|
|
867
840
|
if self.right.precedence == self.precedence + 1:
|
|
868
841
|
rprec = valuePrecedenceMax
|
|
869
842
|
|
|
@@ -883,7 +856,7 @@ class CValueLt(CValue):
|
|
|
883
856
|
|
|
884
857
|
def __str__(self):
|
|
885
858
|
lx = str_cvalue(self.left, ext_precedence=self.precedence)
|
|
886
|
-
rx = str_cvalue(self.right, ext_precedence=self.precedence)
|
|
859
|
+
rx = str_cvalue(self.right, ext_precedence=self.precedence + 1)
|
|
887
860
|
return '%s < %s' % (lx, rx)
|
|
888
861
|
|
|
889
862
|
|
|
@@ -898,7 +871,7 @@ class CValueGt(CValue):
|
|
|
898
871
|
|
|
899
872
|
def __str__(self):
|
|
900
873
|
lx = str_cvalue(self.left, ext_precedence=self.precedence)
|
|
901
|
-
rx = str_cvalue(self.right, ext_precedence=self.precedence)
|
|
874
|
+
rx = str_cvalue(self.right, ext_precedence=self.precedence + 1)
|
|
902
875
|
return '%s > %s' % (lx, rx)
|
|
903
876
|
|
|
904
877
|
|
|
@@ -913,7 +886,7 @@ class CValueLE(CValue):
|
|
|
913
886
|
|
|
914
887
|
def __str__(self):
|
|
915
888
|
lx = str_cvalue(self.left, ext_precedence=self.precedence)
|
|
916
|
-
rx = str_cvalue(self.right, ext_precedence=self.precedence)
|
|
889
|
+
rx = str_cvalue(self.right, ext_precedence=self.precedence + 1)
|
|
917
890
|
return '%s <= %s' % (lx, rx)
|
|
918
891
|
|
|
919
892
|
|
|
@@ -928,7 +901,7 @@ class CValueGE(CValue):
|
|
|
928
901
|
|
|
929
902
|
def __str__(self):
|
|
930
903
|
lx = str_cvalue(self.left, ext_precedence=self.precedence)
|
|
931
|
-
rx = str_cvalue(self.right, ext_precedence=self.precedence)
|
|
904
|
+
rx = str_cvalue(self.right, ext_precedence=self.precedence + 1)
|
|
932
905
|
return '%s >= %s' % (lx, rx)
|
|
933
906
|
|
|
934
907
|
|
|
@@ -943,7 +916,7 @@ class CValueEq(CValue):
|
|
|
943
916
|
|
|
944
917
|
def __str__(self):
|
|
945
918
|
lx = str_cvalue(self.left, ext_precedence=self.precedence)
|
|
946
|
-
rx = str_cvalue(self.right, ext_precedence=self.precedence)
|
|
919
|
+
rx = str_cvalue(self.right, ext_precedence=self.precedence + 1)
|
|
947
920
|
return '%s == %s' % (lx, rx)
|
|
948
921
|
|
|
949
922
|
|
|
@@ -958,7 +931,7 @@ class CValueNe(CValue):
|
|
|
958
931
|
|
|
959
932
|
def __str__(self):
|
|
960
933
|
lx = str_cvalue(self.left, ext_precedence=self.precedence)
|
|
961
|
-
rx = str_cvalue(self.right, ext_precedence=self.precedence)
|
|
934
|
+
rx = str_cvalue(self.right, ext_precedence=self.precedence + 1)
|
|
962
935
|
return '%s != %s' % (lx, rx)
|
|
963
936
|
|
|
964
937
|
|
|
@@ -982,7 +955,7 @@ class CValueBitwiseAnd(CValue):
|
|
|
982
955
|
|
|
983
956
|
def __str__(self):
|
|
984
957
|
lx = str_cvalue(self.left, ext_precedence=self.precedence)
|
|
985
|
-
rx = str_cvalue(self.right, ext_precedence=self.precedence)
|
|
958
|
+
rx = str_cvalue(self.right, ext_precedence=self.precedence + 1)
|
|
986
959
|
return '%s & %s' % (lx, rx)
|
|
987
960
|
|
|
988
961
|
|
|
@@ -997,7 +970,7 @@ class CValueBitwiseXor(CValue):
|
|
|
997
970
|
|
|
998
971
|
def __str__(self):
|
|
999
972
|
lx = str_cvalue(self.left, ext_precedence=select_prio_plus(self.precedence, self.left.precedence, n=1))
|
|
1000
|
-
rx = str_cvalue(self.right, ext_precedence=select_prio_plus(self.precedence, self.right.precedence, n=1))
|
|
973
|
+
rx = str_cvalue(self.right, ext_precedence=max(self.precedence + 1, select_prio_plus(self.precedence, self.right.precedence, n=1)))
|
|
1001
974
|
return '%s ^ %s' % (lx, rx)
|
|
1002
975
|
|
|
1003
976
|
|
|
@@ -1012,7 +985,7 @@ class CValueBitwiseOr(CValue):
|
|
|
1012
985
|
|
|
1013
986
|
def __str__(self):
|
|
1014
987
|
lx = str_cvalue(self.left, ext_precedence=select_prio_plus(self.precedence, self.left.precedence, n=2))
|
|
1015
|
-
rx = str_cvalue(self.right, ext_precedence=select_prio_plus(self.precedence, self.right.precedence, n=2))
|
|
988
|
+
rx = str_cvalue(self.right, ext_precedence=max(self.precedence + 1, select_prio_plus(self.precedence, self.right.precedence, n=2)))
|
|
1016
989
|
return '%s | %s' % (lx, rx)
|
|
1017
990
|
|
|
1018
991
|
|
|
@@ -1027,7 +1000,7 @@ class CValueLogicalAnd(CValue):
|
|
|
1027
1000
|
|
|
1028
1001
|
def __str__(self):
|
|
1029
1002
|
lx = str_cvalue(self.left, ext_precedence=self.precedence)
|
|
1030
|
-
rx = str_cvalue(self.right, ext_precedence=self.precedence)
|
|
1003
|
+
rx = str_cvalue(self.right, ext_precedence=self.precedence + 1)
|
|
1031
1004
|
return '%s && %s' % (lx, rx)
|
|
1032
1005
|
|
|
1033
1006
|
|
|
@@ -1042,7 +1015,7 @@ class CValueLogicalOr(CValue):
|
|
|
1042
1015
|
|
|
1043
1016
|
def __str__(self):
|
|
1044
1017
|
lx = str_cvalue(self.left, ext_precedence=select_prio_plus(self.precedence, self.left.precedence, n=1))
|
|
1045
|
-
rx = str_cvalue(self.right, ext_precedence=select_prio_plus(self.precedence, self.right.precedence, n=1))
|
|
1018
|
+
rx = str_cvalue(self.right, ext_precedence=max(self.precedence + 1, select_prio_plus(self.precedence, self.right.precedence, n=1)))
|
|
1046
1019
|
return '%s || %s' % (lx, rx)
|
|
1047
1020
|
|
|
1048
1021
|
|
|
@@ -1109,7 +1082,7 @@ class CValueStringConcat(CValue):
|
|
|
1109
1082
|
|
|
1110
1083
|
def __str__(self):
|
|
1111
1084
|
lx = str_cvalue(self.left, ext_precedence=self.precedence)
|
|
1112
|
-
rx = str_cvalue(self.right, ext_precedence=self.precedence)
|
|
1085
|
+
rx = str_cvalue(self.right, ext_precedence=self.precedence + 1)
|
|
1113
1086
|
return lx + ' ' + rx
|
|
1114
1087
|
|
|
1115
1088
|
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import unittest
|
|
2
2
|
|
|
3
3
|
from cshape import (
|
|
4
|
-
CField, CStmtBlock, CStmtDefFunc,
|
|
5
|
-
CValueAdd,
|
|
4
|
+
CField, CStmtBlock, CStmtDefFunc, CStmtDefVar, CStmtReturn, CTypeArray,
|
|
5
|
+
CTypeFunction, CTypeIdentifier, CValueAdd, CValueArray, CValueIdentifier,
|
|
6
|
+
CValueInteger, render,
|
|
6
7
|
)
|
|
7
8
|
|
|
8
9
|
|
|
@@ -36,6 +37,21 @@ class SmokeTest(unittest.TestCase):
|
|
|
36
37
|
v.mark = 'debug-note'
|
|
37
38
|
self.assertIn('/*debug-note*/', render(v))
|
|
38
39
|
|
|
40
|
+
def test_value_constructor_accepts_nl_for_array_layout(self):
|
|
41
|
+
array_def = CStmtDefVar(
|
|
42
|
+
id='numbers',
|
|
43
|
+
type=CTypeArray(CTypeIdentifier('int')),
|
|
44
|
+
initializer=CValueArray([
|
|
45
|
+
CValueInteger(1, nl=1),
|
|
46
|
+
CValueInteger(2),
|
|
47
|
+
]),
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
self.assertEqual(
|
|
51
|
+
render(array_def).strip(),
|
|
52
|
+
'int numbers[] = {\n\t1, 2\n};',
|
|
53
|
+
)
|
|
54
|
+
|
|
39
55
|
|
|
40
56
|
if __name__ == '__main__':
|
|
41
57
|
unittest.main()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|