forked from oscar-system/GAP.jl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.jl
96 lines (68 loc) · 1.85 KB
/
types.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
"""
FFE
Wrap a pointer to a GAP FFE ("finite field element") immediate object.
This type is defined in the JuliaInterface C code.
# Examples
```jldoctest
julia> x = GAP.evalstr( "Z(3)" )
GAP: Z(3)
julia> typeof( x )
FFE
```
"""
primitive type FFE 64 end
"""
GapObj
This is the Julia type of all those GAP objects that are not
"immediate" (booleans, small integers, FFEs).
# Examples
```jldoctest
julia> isa( GAP.evalstr( "[ 1, 2 ]" ), GapObj ) # a GAP list
true
julia> isa( GAP.evalstr( "rec()" ), GapObj ) # a GAP record
true
julia> isa( GAP.evalstr( "(1,2,3)" ), GapObj ) # a GAP permutation
true
julia> isa( GAP.evalstr( "2^64" ), GapObj ) # a large GAP integer
true
julia> typeof( GAP.evalstr( "2^59" ) ) # a small GAP integer
Int64
julia> typeof( GAP.evalstr( "Z(2)" ) ) # a GAP FFE
FFE
julia> typeof( GAP.evalstr( "true" ) ) # a boolean
Bool
```
Note that this is Julia's viewpoint on GAP objects.
From the viewpoint of GAP, also the pointers to Julia objects are
implemented as "non-immediate GAP objects",
but they appear as Julia objects to Julia, not "doubly wrapped".
# Examples
```jldoctest
julia> GAP.evalstr( "Julia.Base" )
Base
julia> typeof( GAP.evalstr( "Julia.Base" ) ) # native Julia object
Module
```
One can use `GapObj` as a constructor,
in order to convert Julia objects to GAP objects.
Such calls are delegated to [`julia_to_gap`](@ref).
# Examples
```jldoctest
julia> GapObj(1//3)
GAP: 1/3
julia> GapObj([1 2; 3 4])
GAP: [ [ 1, 2 ], [ 3, 4 ] ]
```
For technical reasons, `GapObj` is created inside the Julia module `GAP_jll`,
before the module `GAP` gets loaded.
Thus Julia prints it as `GAP_jll.MPtr`.
# Examples
```jldoctest
julia> GapObj
GAP_jll.MPtr
```
"""
const GapObj = GAP_jll.MPtr
# TODO: should we document Obj?
const Obj = Union{GapObj,FFE,Int64,Bool,Nothing}
export FFE, GapObj