Skip to content

Commit 65bd4bc

Browse files
Indentation consistency (#58)
1 parent c9bfc77 commit 65bd4bc

File tree

7 files changed

+507
-507
lines changed

7 files changed

+507
-507
lines changed

README.md

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ it is possible to access these directly using `@objc`, ObjectiveC.jl provides a
6868
automatically generate the appropriate `getproperty`, `setproperty!` and `propertynames`
6969
definitions:
7070

71-
```julia
71+
```julia-repl
7272
julia> @objcproperties NSValue begin
73-
@autoproperty pointerValue::Ptr{Cvoid}
73+
@autoproperty pointerValue::Ptr{Cvoid}
7474
end
7575
7676
julia> obj.pointerValue
@@ -82,30 +82,30 @@ property macros:
8282

8383
```julia
8484
@objcproperties SomeObject begin
85-
# simplest definition: just generate a getter,
86-
# and convert the property value to `DstTyp`
87-
@autoproperty someProperty::DstTyp
88-
89-
# also generate a setter
90-
@autoproperty someProperty::DstTyp setter=setSomeProperty
91-
92-
# if the property is an ObjC object, use an object pointer type.
93-
# this will make sure to do a nil check and return nothing,
94-
# or convert the pointer to an instance of the specified type
95-
@autoproperty someProperty::id{DstTyp}
96-
97-
# sometimes you may want to convert to a different type
98-
@autoproperty someStringProperty::id{NSString} type=String
99-
100-
# and finally, if more control is needed, just do it yourselv:
101-
@getproperty someComplexProperty function(obj)
102-
# do something with obj
103-
# return a value
104-
end
105-
@setproperty! someComplexProperty function(obj, val)
106-
# do something with obj and val
107-
# return nothing
108-
end
85+
# simplest definition: just generate a getter,
86+
# and convert the property value to `DstTyp`
87+
@autoproperty someProperty::DstTyp
88+
89+
# also generate a setter
90+
@autoproperty someProperty::DstTyp setter=setSomeProperty
91+
92+
# if the property is an ObjC object, use an object pointer type.
93+
# this will make sure to do a nil check and return nothing,
94+
# or convert the pointer to an instance of the specified type
95+
@autoproperty someProperty::id{DstTyp}
96+
97+
# sometimes you may want to convert to a different type
98+
@autoproperty someStringProperty::id{NSString} type=String
99+
100+
# and finally, if more control is needed, just do it yourself:
101+
@getproperty someComplexProperty function(obj)
102+
# do something with obj
103+
# return a value
104+
end
105+
@setproperty! someComplexProperty function(obj, val)
106+
# do something with obj and val
107+
# return nothing
108+
end
109109
end
110110
```
111111

@@ -114,10 +114,10 @@ end
114114

115115
Julia callables can be converted to Objective-C blocks using the `@objcblock` macro:
116116

117-
```julia
117+
```julia-repl
118118
julia> function hello(x)
119-
println("Hello, $x!")
120-
x+1
119+
println("Hello, $x!")
120+
x+1
121121
end
122122
julia> block = @objcblock(hello, Cint, (Cint,))
123123
```
@@ -134,11 +134,11 @@ may decide to coalesce multiple conditions into a single execution, so it is pre
134134
use `@objcblock` whenever possible. It is also not possible to pass any arguments to the
135135
condition, but you can use a closure to capture any state you need:
136136

137-
```julia
137+
```julia-repl
138138
julia> counter = 0
139139
julia> cond = Base.AsyncCondition() do async_cond
140-
counter += 1
141-
end
140+
counter += 1
141+
end
142142
julia> block = @objcasyncblock(cond)
143143
```
144144

@@ -147,7 +147,7 @@ julia> block = @objcasyncblock(cond)
147147

148148
ObjectiveC.jl also provides ready-made wrappers for essential frameworks like Foundation:
149149

150-
```julia
150+
```julia-repl
151151
julia> using .Foundation
152152
153153
@@ -156,9 +156,9 @@ NSString("test")
156156
157157
158158
julia> NSArray([str, str])
159-
(
160-
test,
161-
test
159+
<__NSArrayI 0x12e69b9b0>(
160+
test,
161+
test
162162
)
163163
164164
@@ -181,7 +181,7 @@ Dict{NSString, NSString} with 1 entry:
181181
To see what ObjectiveC.jl is doing under the hood, you can toggle the `tracing` preference,
182182
which will make the package print out the Objective-C calls it makes:
183183

184-
```julia
184+
```julia-repl
185185
julia> using ObjectiveC
186186
julia> ObjectiveC.enable_tracing(true)
187187
[ Info: ObjectiveC.jl tracing setting changed; restart your Julia session for this change to take effect!

src/blocks.jl

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -32,22 +32,22 @@ end
3232
# NSBlocks are untracked by the Julia GC, so we need to manually root the Julia objects
3333
const julia_block_roots = Dict{NSBlock,JuliaBlock}()
3434
function julia_block_copy(_dst, _src)
35-
dst_nsblock = NSBlock(reinterpret(id{NSBlock}, _dst))
36-
src_nsblock = NSBlock(reinterpret(id{NSBlock}, _src))
35+
dst_nsblock = NSBlock(reinterpret(id{NSBlock}, _dst))
36+
src_nsblock = NSBlock(reinterpret(id{NSBlock}, _src))
3737

38-
@assert haskey(julia_block_roots, src_nsblock)
39-
julia_block_roots[dst_nsblock] = julia_block_roots[src_nsblock]
38+
@assert haskey(julia_block_roots, src_nsblock)
39+
julia_block_roots[dst_nsblock] = julia_block_roots[src_nsblock]
4040

41-
return
41+
return
4242
end
4343
function julia_block_dispose(_block)
44-
block = unsafe_load(_block)
45-
nsblock = NSBlock(reinterpret(id{NSBlock}, _block))
44+
block = unsafe_load(_block)
45+
nsblock = NSBlock(reinterpret(id{NSBlock}, _block))
4646

47-
@assert haskey(julia_block_roots, nsblock)
48-
delete!(julia_block_roots, nsblock)
47+
@assert haskey(julia_block_roots, nsblock)
48+
delete!(julia_block_roots, nsblock)
4949

50-
return
50+
return
5151
end
5252

5353
# JuliaBlock is the concrete version of NSBlock, so make it possible to derive a regular
@@ -78,13 +78,13 @@ const julia_block_descriptor_initialized = Ref{Bool}(false)
7878
function JuliaBlock(trampoline, callable)
7979
# lazily create a descriptor (these sometimes don't precompile properly)
8080
if !julia_block_descriptor_initialized[]
81-
# simple cfunctions, so don't need to be rooted
82-
copy_cb = @cfunction(julia_block_copy, Nothing, (Ptr{JuliaBlock}, Ptr{JuliaBlock}))
83-
dispose_cb = @cfunction(julia_block_dispose, Nothing, (Ptr{JuliaBlock},))
81+
# simple cfunctions, so don't need to be rooted
82+
copy_cb = @cfunction(julia_block_copy, Nothing, (Ptr{JuliaBlock}, Ptr{JuliaBlock}))
83+
dispose_cb = @cfunction(julia_block_dispose, Nothing, (Ptr{JuliaBlock},))
8484

85-
julia_block_descriptor[] = JuliaBlockDescriptor(0, sizeof(JuliaBlock),
86-
copy_cb, dispose_cb)
87-
julia_block_descriptor_initialized[] = true
85+
julia_block_descriptor[] = JuliaBlockDescriptor(0, sizeof(JuliaBlock),
86+
copy_cb, dispose_cb)
87+
julia_block_descriptor_initialized[] = true
8888
end
8989

9090
# set-up the block data structures
@@ -183,10 +183,10 @@ const julia_async_block_descriptor_initialized = Ref{Bool}(false)
183183
function JuliaAsyncBlock(cond)
184184
# lazily create a descriptor (these sometimes don't precompile properly)
185185
if !julia_async_block_descriptor_initialized[]
186-
# simple cfunctions, so don't need to be rooted
187-
julia_async_block_descriptor[] = JuliaAsyncBlockDescriptor(0, sizeof(JuliaAsyncBlock),
188-
C_NULL, C_NULL)
189-
julia_async_block_descriptor_initialized[] = true
186+
# simple cfunctions, so don't need to be rooted
187+
julia_async_block_descriptor[] = JuliaAsyncBlockDescriptor(0, sizeof(JuliaAsyncBlock),
188+
C_NULL, C_NULL)
189+
julia_async_block_descriptor_initialized[] = true
190190
end
191191

192192
# create a trampoline to wake libuv with the user-provided condition

src/classes.jl

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,39 +2,39 @@
22
# resurrecting it, please look at the repository at commit 22118319da.
33

44
function allocclass(name, super)
5-
ptr = ccall(:objc_allocateClassPair, Ptr{Cvoid}, (Ptr{Cvoid}, Ptr{Cchar}, Csize_t),
6-
super, name, 0)
7-
ptr == C_NULL && error("Couldn't allocate class $name")
8-
return Class(ptr)
5+
ptr = ccall(:objc_allocateClassPair, Ptr{Cvoid}, (Ptr{Cvoid}, Ptr{Cchar}, Csize_t),
6+
super, name, 0)
7+
ptr == C_NULL && error("Couldn't allocate class $name")
8+
return Class(ptr)
99
end
1010

1111
function register(class::Class)
12-
ccall(:objc_registerClassPair, Cvoid, (Ptr{Cvoid},),
13-
class)
14-
return class
12+
ccall(:objc_registerClassPair, Cvoid, (Ptr{Cvoid},),
13+
class)
14+
return class
1515
end
1616

1717
createclass(name, super) = allocclass(name, super) |> register
1818

1919
getmethod(class::Class, sel::Selector) =
20-
ccall(:class_getInstanceMethod, Ptr{Cvoid}, (Ptr{Cvoid}, Ptr{Cvoid}),
21-
class, sel)
20+
ccall(:class_getInstanceMethod, Ptr{Cvoid}, (Ptr{Cvoid}, Ptr{Cvoid}),
21+
class, sel)
2222

2323
methodtypeenc(method::Ptr) =
24-
ccall(:method_getTypeEncoding, Ptr{Cchar}, (Ptr{Cvoid},),
25-
method) |> unsafe_string
24+
ccall(:method_getTypeEncoding, Ptr{Cchar}, (Ptr{Cvoid},),
25+
method) |> unsafe_string
2626

2727
methodtypeenc(class::Class, sel::Selector) = methodtypeenc(getmethod(class, sel))
2828

2929
methodtype(args...) = methodtypeenc(args...) |> parseencoding
3030

3131
replacemethod(class::Class, sel::Selector, imp::Ptr{Cvoid}, types::String) =
32-
ccall(:class_replaceMethod, Bool, (Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cchar}),
33-
class, sel, imp, types)
32+
ccall(:class_replaceMethod, Bool, (Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cchar}),
33+
class, sel, imp, types)
3434

3535
function setmethod(class::Class, sel::Selector, imp::Ptr{Cvoid}, types::String)
36-
meth = getmethod(class, sel)
37-
meth C_NULL && methodtype(meth) != parseencoding(types) &&
38-
error("New method $(name(sel)) of $class must match $(methodtype(meth))")
39-
replacemethod(class, sel, imp, types)
36+
meth = getmethod(class, sel)
37+
meth C_NULL && methodtype(meth) != parseencoding(types) &&
38+
error("New method $(name(sel)) of $class must match $(methodtype(meth))")
39+
replacemethod(class, sel, imp, types)
4040
end

0 commit comments

Comments
 (0)