Skip to content

Commit 5e64006

Browse files
committed
fix: support latest version of mojo
1 parent 92d0748 commit 5e64006

File tree

5 files changed

+19
-22
lines changed

5 files changed

+19
-22
lines changed

external/libc.mojo

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ alias char_pointer = AnyPointer[c_char]
3737
# fn to_string(self, size: Int) -> String:
3838
# var result: String = ""
3939
# for i in range(size):
40-
# result += chr(self.vector[i].to_int())
40+
# result += chr(int(self.vector[i]))
4141
# return result
4242

4343
# fn __enter__(owned self: Self) -> Self:
@@ -751,7 +751,7 @@ fn inet_pton(address_family: Int, address: String) -> Int:
751751
var conv_status = inet_pton(
752752
rebind[c_int](address_family), to_char_ptr(address), ip_buf
753753
)
754-
return ip_buf.bitcast[c_uint]().load().to_int()
754+
return int(ip_buf.bitcast[c_uint]().load())
755755

756756

757757
# --- ( File Related Syscalls & Structs )---------------------------------------

external/morrow.mojo

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ struct TimeZone:
5151
@staticmethod
5252
fn local() -> TimeZone:
5353
var local_t = c_localtime(0)
54-
return TimeZone(local_t.tm_gmtoff.to_int(), "local")
54+
return TimeZone(int(local_t.tm_gmtoff), "local")
5555

5656
@staticmethod
5757
fn from_utc(utc_str: String) raises -> TimeZone:
@@ -247,15 +247,15 @@ struct Morrow:
247247
tz = TimeZone(0, "UTC")
248248
else:
249249
tm = c_localtime(t.tv_sec)
250-
tz = TimeZone(tm.tm_gmtoff.to_int(), "local")
250+
tz = TimeZone(int(tm.tm_gmtoff), "local")
251251

252252
var result = Self(
253-
tm.tm_year.to_int() + 1900,
254-
tm.tm_mon.to_int() + 1,
255-
tm.tm_mday.to_int(),
256-
tm.tm_hour.to_int(),
257-
tm.tm_min.to_int(),
258-
tm.tm_sec.to_int(),
253+
int(tm.tm_year) + 1900,
254+
int(tm.tm_mon) + 1,
255+
int(tm.tm_mday),
256+
int(tm.tm_hour),
257+
int(tm.tm_min),
258+
int(tm.tm_sec),
259259
t.tv_usec,
260260
tz,
261261
)
@@ -264,13 +264,13 @@ struct Morrow:
264264
@staticmethod
265265
fn fromtimestamp(timestamp: Float64) raises -> Self:
266266
var timestamp_ = normalize_timestamp(timestamp)
267-
var t = CTimeval(timestamp_.to_int())
267+
var t = CTimeval(int(timestamp_))
268268
return Self._fromtimestamp(t, False)
269269

270270
@staticmethod
271271
fn utcfromtimestamp(timestamp: Float64) raises -> Self:
272272
var timestamp_ = normalize_timestamp(timestamp)
273-
var t = CTimeval(timestamp_.to_int())
273+
var t = CTimeval(int(timestamp_))
274274
return Self._fromtimestamp(t, True)
275275

276276

lightbug_http/__init__.mojo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ from lightbug_http.sys.server import SysServer
44

55

66
trait DefaultConstructible:
7-
fn __init__(inout self):
7+
fn __init__(inout self) raises:
88
...

lightbug_http/net.mojo

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ alias default_tcp_keep_alive = Duration(15 * 1000 * 1000 * 1000) # 15 seconds
1919

2020

2121
trait Net(DefaultConstructible):
22-
fn __init__(inout self):
22+
fn __init__(inout self) raises:
2323
...
2424

2525
fn __init__(inout self, keep_alive: Duration) raises:
@@ -284,4 +284,4 @@ fn get_peer_name(fd: Int32) raises -> HostPort:
284284
return HostPort(
285285
host=convert_binary_ip_to_string(addr_in.sin_addr.s_addr, AF_INET, 16),
286286
port=convert_binary_port_to_int(addr_in.sin_port),
287-
)
287+
)

lightbug_http/sys/net.mojo

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,10 @@ struct SysListenConfig(ListenConfig):
128128
var __keep_alive: Duration
129129

130130
fn __init__(inout self) raises:
131-
self.__keep_alive = Duration(default_tcp_keep_alive)
131+
self.__keep_alive = default_tcp_keep_alive
132132

133133
fn __init__(inout self, keep_alive: Duration) raises:
134-
self.__keep_alive = Duration(keep_alive)
134+
self.__keep_alive = keep_alive
135135

136136
fn listen(inout self, network: String, address: String) raises -> SysListener:
137137
var addr = resolve_internet_addr(network, address)
@@ -235,11 +235,8 @@ struct SysConnection(Connection):
235235
struct SysNet(Net):
236236
var __lc: SysListenConfig
237237

238-
fn __init__(inout self):
239-
try:
240-
self.__lc = SysListenConfig(default_tcp_keep_alive)
241-
except e:
242-
print("Could not initialize SysListenConfig: " + e.__str__())
238+
fn __init__(inout self) raises:
239+
self.__lc = SysListenConfig(default_tcp_keep_alive)
243240

244241
fn __init__(inout self, keep_alive: Duration) raises:
245242
self.__lc = SysListenConfig(keep_alive)

0 commit comments

Comments
 (0)