Skip to content

Commit c0e94f5

Browse files
committed
Rename @cppty_str to @cpp_str
1 parent b5eb29c commit c0e94f5

File tree

6 files changed

+88
-82
lines changed

6 files changed

+88
-82
lines changed

examples/overloading.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ using CppCall
44

55
declare"""#include "overloading.h" """
66

7-
x = @cppinit cppty"int"
7+
x = @cppinit cpp"int"
88

99
@time @fcall increment(x)
1010

1111
@time @fcall increment(x)
1212

13-
y = @cppinit cppty"double"
13+
y = @cppinit cpp"double"
1414

1515
@time @fcall increment(y)
1616

src/CppCall.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ include("convert.jl")
4444

4545
include("macros.jl")
4646
export @declare_str, @include
47-
export @cppty_str, @qualty_str
47+
export @cpp_str, @qualty
4848
export @cppinit, @cppnew
4949
export @ptr, @cptr, @vptr, @cvptr, @ref
5050

src/macros.jl

+7-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,13 @@ macro cppnew(cppty, args...)
114114
end)
115115
end
116116

117-
macro cppty_str(name::AbstractString, flags...)
117+
118+
"""
119+
@cpp_str -> CppType
120+
121+
Construct a `CppType` with optional qualifiers marked by the flags `c`, `v`, `cv`.
122+
"""
123+
macro cpp_str(name::AbstractString, flags...)
118124
qualifier = :(CppCall.U)
119125
if !isempty(flags)
120126
flag = first(flags)

test/call.jl

+18-18
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ using Test
1212
@fcall pbv(x)
1313
@test x[] == 0
1414
# const T& -> T
15-
x = @cppinit cppty"int"c
15+
x = @cppinit cpp"int"c
1616
xref = @ref x
1717
@fcall pbv(xref)
1818

@@ -21,21 +21,21 @@ using Test
2121
px = @ptr x
2222
GC.@preserve x @fcall pbp(px)
2323
@test x[] == 1
24-
x = @cppinit cppty"int"
24+
x = @cppinit cpp"int"
2525
x[] = 1
2626
px = @ptr x
2727
GC.@preserve x @fcall pbp(px)
2828
@test x[] == 2
29-
x = @cppinit cppty"int"c
29+
x = @cppinit cpp"int"c
3030
px = @ptr x
3131
@test_throws ArgumentError GC.@preserve x @fcall pbp(px) # FIXME: should be ambiguous call
3232

3333
@info "invoke `void pbp2c(const int* ptr)`: "
34-
x = @cppinit cppty"int"c
34+
x = @cppinit cpp"int"c
3535
px = @ptr x
3636
GC.@preserve x @fcall pbp2c(px)
3737
@test x[] == 0
38-
x = @cppinit cppty"int"
38+
x = @cppinit cpp"int"
3939
px = @ptr x
4040
GC.@preserve x @fcall pbp2c(px) # this is ok
4141
@test x[] == 0
@@ -48,21 +48,21 @@ using Test
4848
cpx = @cptr x
4949
GC.@preserve x @fcall pbcp(cpx)
5050
@test x[] == 2
51-
x = @cppinit cppty"int"c
51+
x = @cppinit cpp"int"c
5252
px = @ptr x
5353
@test_throws ArgumentError GC.@preserve x @fcall pbcp(px) # no permissive
54-
x = @cppinit cppty"int"
54+
x = @cppinit cpp"int"
5555
x[] = 2
5656
px = @ptr x
5757
GC.@preserve x @fcall pbcp(px)
5858
@test x[] == 3
5959

6060
@info "invoke `void pbcp2c(const int* const ptr)`: "
61-
x = @cppinit cppty"int"c
61+
x = @cppinit cpp"int"c
6262
px = @ptr x
6363
GC.@preserve x @fcall pbcp2c(px)
6464
@test x[] == 0
65-
x = @cppinit cppty"int"
65+
x = @cppinit cpp"int"
6666
px = @ptr x
6767
GC.@preserve x @fcall pbcp2c(px)
6868
@test x[] == 0
@@ -78,21 +78,21 @@ using Test
7878
xref = @ref x
7979
@fcall pblvr(xref)
8080
@test x[] == 2
81-
x = @cppinit cppty"int"c
81+
x = @cppinit cpp"int"c
8282
@test_throws ArgumentError @fcall pblvr(x) # should not discard const-qualifier
8383
xref = @ref x
8484
@test_throws ArgumentError @fcall pblvr(xref) # should not discard const-qualifier
8585

8686
@info "invoke `void pbclvr(const int& ref)`: "
87-
x = @cppinit cppty"int"c
87+
x = @cppinit cpp"int"c
8888
x[] = 1 # FIXME: this should not be allowed
8989
@fcall pbclvr(x)
9090
@test x[] == 1
9191
xref = @ref x
9292
xref[] = 2 # FIXME: this should not be allowed
9393
@fcall pbclvr(xref)
9494
@test x[] == 2
95-
x = @cppinit cppty"int"
95+
x = @cppinit cpp"int"
9696
x[] = 1
9797
@fcall pbclvr(x)
9898
@test x[] == 1
@@ -132,29 +132,29 @@ end
132132
@test_logs min_level=Logging.Error declare"""#include "overloading.h" """
133133

134134
@info "`void increment(const int& value)` vs `void increment(int value)`:"
135-
x = @cppinit cppty"int"c
135+
x = @cppinit cpp"int"c
136136
@fcall increment(x::Cint) # calls `void increment(int value)`
137137
@test x[] == 0
138-
@fcall increment(x::CppRef{cppty"int"c}) # calls `void increment(const int& value)`
138+
@fcall increment(x::CppRef{cpp"int"c}) # calls `void increment(const int& value)`
139139
@test x[] == 0
140140
@test_throws ArgumentError @fcall increment(x) # ambiguous call
141141

142142
xref = @ref x
143-
@fcall increment(xref::CppRef{cppty"int"c}) # calls `void increment(const int& value)`
143+
@fcall increment(xref::CppRef{cpp"int"c}) # calls `void increment(const int& value)`
144144
@test x[] == 0
145145
@fcall increment(xref::Cint) # calls `void increment(int value)`
146146
@test x[] == 0
147147
@test_throws ArgumentError @fcall increment(xref) # ambiguous call
148148

149-
x = @cppinit cppty"int"
150-
@fcall increment(x::CppRef{cppty"int"c}) # calls `void increment(const int& value)`
149+
x = @cppinit cpp"int"
150+
@fcall increment(x::CppRef{cpp"int"c}) # calls `void increment(const int& value)`
151151
@test x[] == 0
152152
@fcall increment(x::Cint) # calls `void increment(int value)`
153153
@test x[] == 0
154154
@test_throws ArgumentError @fcall increment(x) # ambiguous call
155155

156156
xref = @ref x
157-
@fcall increment(xref::CppRef{cppty"int"c}) # calls `void increment(const int& value)`
157+
@fcall increment(xref::CppRef{cpp"int"c}) # calls `void increment(const int& value)`
158158
@test x[] == 0
159159
@fcall increment(xref::Cint) # calls `void increment(int value)`
160160
@test x[] == 0

0 commit comments

Comments
 (0)