-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathconstants.cpp
More file actions
86 lines (77 loc) · 3.67 KB
/
Copy pathconstants.cpp
File metadata and controls
86 lines (77 loc) · 3.67 KB
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
//
// Semigroups.jl
// Copyright (C) 2026, James W. Swent
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
#include "libsemigroups_julia.hpp"
namespace libsemigroups_julia {
void define_constants(jl::Module& m) {
// POSITIVE_INFINITY values for different integer types
// POSITIVE_INFINITY represents max-1 value of the type
m.method("POSITIVE_INFINITY_UInt8",
[]() -> uint8_t { return libsemigroups::POSITIVE_INFINITY; });
m.method("POSITIVE_INFINITY_UInt16",
[]() -> uint16_t { return libsemigroups::POSITIVE_INFINITY; });
m.method("POSITIVE_INFINITY_UInt32",
[]() -> uint32_t { return libsemigroups::POSITIVE_INFINITY; });
m.method("POSITIVE_INFINITY_UInt64",
[]() -> uint64_t { return libsemigroups::POSITIVE_INFINITY; });
m.method("POSITIVE_INFINITY_Int64",
[]() -> int64_t { return libsemigroups::POSITIVE_INFINITY; });
// LIMIT_MAX values for different integer types
// LIMIT_MAX represents max-2 value of the type
m.method("LIMIT_MAX_UInt8",
[]() -> uint8_t { return libsemigroups::LIMIT_MAX; });
m.method("LIMIT_MAX_UInt16",
[]() -> uint16_t { return libsemigroups::LIMIT_MAX; });
m.method("LIMIT_MAX_UInt32",
[]() -> uint32_t { return libsemigroups::LIMIT_MAX; });
m.method("LIMIT_MAX_UInt64",
[]() -> uint64_t { return libsemigroups::LIMIT_MAX; });
m.method("LIMIT_MAX_Int64",
[]() -> int64_t { return libsemigroups::LIMIT_MAX; });
// NEGATIVE_INFINITY for signed types
m.method("NEGATIVE_INFINITY_Int8",
[]() -> int8_t { return libsemigroups::NEGATIVE_INFINITY; });
m.method("NEGATIVE_INFINITY_Int16",
[]() -> int16_t { return libsemigroups::NEGATIVE_INFINITY; });
m.method("NEGATIVE_INFINITY_Int32",
[]() -> int32_t { return libsemigroups::NEGATIVE_INFINITY; });
m.method("NEGATIVE_INFINITY_Int64",
[]() -> int64_t { return libsemigroups::NEGATIVE_INFINITY; });
// congruence_kind enum for sided-ness of a congruence
m.add_bits<libsemigroups::congruence_kind>("congruence_kind",
jl::julia_type("CppEnum"));
m.set_const("congruence_kind_onesided",
libsemigroups::congruence_kind::onesided);
m.set_const("congruence_kind_twosided",
libsemigroups::congruence_kind::twosided);
// tril enum for three-valued logic (true, false, unknown)
m.add_bits<libsemigroups::tril>("tril", jl::julia_type("CppEnum"));
m.set_const("tril_FALSE", libsemigroups::tril::FALSE);
m.set_const("tril_TRUE", libsemigroups::tril::TRUE);
m.set_const("tril_unknown", libsemigroups::tril::unknown);
// Helper to convert tril to Julia Bool or nothing
m.method("tril_to_bool", [](libsemigroups::tril t) -> jl_value_t* {
if (t == libsemigroups::tril::TRUE) {
return jl_box_bool(true);
} else if (t == libsemigroups::tril::FALSE) {
return jl_box_bool(false);
} else {
return jl_nothing;
}
});
}
} // namespace libsemigroups_julia