Skip to content

Commit

Permalink
Update for Gleam v0.30.0
Browse files Browse the repository at this point in the history
  • Loading branch information
lpil committed Jul 27, 2023
1 parent c696a5e commit 77b98fe
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 33 deletions.
8 changes: 4 additions & 4 deletions src/gleam/otp/actor.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,8 @@ fn selecting_system_messages(
)
}

external fn convert_system_message(Dynamic, Dynamic) -> Message(msg) =
"gleam_otp_external" "convert_system_message"
@external(erlang, "gleam_otp_external", "convert_system_message")
fn convert_system_message(a: Dynamic, b: Dynamic) -> Message(msg)

fn process_status_info(self: Self(state, msg)) -> StatusInfo {
StatusInfo(
Expand Down Expand Up @@ -301,8 +301,8 @@ fn loop(self: Self(state, msg)) -> ExitReason {
}

// TODO: replace this when we have Gleam bindings to the logger
external fn log_warning(Charlist, List(Charlist)) -> Nil =
"logger" "warning"
@external(erlang, "logger", "warning")
fn log_warning(a: Charlist, b: List(Charlist)) -> Nil

fn initialise_actor(
spec: Spec(state, msg),
Expand Down
4 changes: 2 additions & 2 deletions src/gleam/otp/intensity_tracker.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ pub fn new(limit limit: Int, period period: Int) -> IntensityTracker {
IntensityTracker(limit: limit, period: period, events: [])
}

external fn monotonic_time(Int) -> Int =
"erlang" "monotonic_time"
@external(erlang, "erlang", "monotonic_time")
fn monotonic_time(a: Int) -> Int

fn now_seconds() -> Int {
monotonic_time(1)
Expand Down
2 changes: 1 addition & 1 deletion src/gleam/otp/node.gleam
Original file line number Diff line number Diff line change
@@ -1 +1 @@
pub external type Node
pub type Node
2 changes: 1 addition & 1 deletion src/gleam/otp/port.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
///
/// [1]: https://erlang.org/doc/reference_manual/ports.html
///
pub external type Port
pub type Port
6 changes: 3 additions & 3 deletions src/gleam/otp/supervisor.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -380,10 +380,10 @@ pub type ApplicationStartMode {
Failover(Node)
}

pub external type ApplicationStop
pub type ApplicationStop

pub external fn application_stopped() -> ApplicationStop =
"gleam_otp_external" "application_stopped"
@external(erlang, "gleam_otp_external", "application_stopped")
pub fn application_stopped() -> ApplicationStop

/// The result of starting a Gleam actor.
///
Expand Down
20 changes: 10 additions & 10 deletions src/gleam/otp/system.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ pub type DebugOption {
NoDebug
}

pub external type DebugState
pub type DebugState

pub external fn debug_state(List(DebugOption)) -> DebugState =
"sys" "debug_options"
@external(erlang, "sys", "debug_options")
pub fn debug_state(a: List(DebugOption)) -> DebugState

pub type StatusInfo {
StatusInfo(
Expand Down Expand Up @@ -46,7 +46,7 @@ pub type SystemMessage {
GetStatus(fn(StatusInfo) -> Nil)
}

external type DoNotLeak
type DoNotLeak

/// Get the state of a given OTP compatible process. This function is only
/// intended for debugging.
Expand All @@ -55,11 +55,11 @@ external type DoNotLeak
///
/// [1]: https://erlang.org/doc/man/sys.html#get_state-1
///
pub external fn get_state(from: Pid) -> Dynamic =
"sys" "get_state"
@external(erlang, "sys", "get_state")
pub fn get_state(from from: Pid) -> Dynamic

external fn erl_suspend(Pid) -> DoNotLeak =
"sys" "suspend"
@external(erlang, "sys", "suspend")
fn erl_suspend(a: Pid) -> DoNotLeak

/// Request an OTP compatible process to suspend, causing it to only handle
/// system messages.
Expand All @@ -73,8 +73,8 @@ pub fn suspend(pid: Pid) -> Nil {
Nil
}

external fn erl_resume(from: Pid) -> DoNotLeak =
"sys" "resume"
@external(erlang, "sys", "resume")
fn erl_resume(from from: Pid) -> DoNotLeak

/// Request a suspended OTP compatible process to result, causing it to handle
/// all messages rather than only system messages.
Expand Down
12 changes: 6 additions & 6 deletions test/gleam/otp/actor_test.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ pub fn get_state_test() {
|> should.equal(dynamic.from("Test state"))
}

external fn get_status(Pid) -> Dynamic =
"sys" "get_status"
@external(erlang, "sys", "get_status")
fn get_status(a: Pid) -> Dynamic

pub fn get_status_test() {
let assert Ok(subject) = actor.start(Nil, fn(_msg, state) { Continue(state) })
Expand Down Expand Up @@ -134,8 +134,8 @@ pub fn unexpected_message_handled_test() {
|> should.equal(dynamic.from("Unexpected message 1"))
}

external fn raw_send(Pid, anything) -> anything =
"erlang" "send"
@external(erlang, "erlang", "send")
fn raw_send(a: Pid, b: anything) -> anything

external fn logger_set_primary_config(Atom, Atom) -> Nil =
"logger" "set_primary_config"
@external(erlang, "logger", "set_primary_config")
fn logger_set_primary_config(a: Atom, b: Atom) -> Nil
12 changes: 6 additions & 6 deletions test/gleam/otp/task_test.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import gleeunit/should
import gleam/otp/task.{Timeout}
import gleam/erlang/process.{Pid}

external fn flush() -> Nil =
"gleam_otp_test_external" "flush"
@external(erlang, "gleam_otp_test_external", "flush")
fn flush() -> Nil

external fn get_message_queue_length(pid: Pid) -> Int =
"gleam_otp_test_external" "get_message_queue_length"
@external(erlang, "gleam_otp_test_external", "get_message_queue_length")
fn get_message_queue_length(pid pid: Pid) -> Int

external fn sleep(Int) -> Nil =
"timer" "sleep"
@external(erlang, "timer", "sleep")
fn sleep(a: Int) -> Nil

fn work(x) {
fn() {
Expand Down

0 comments on commit 77b98fe

Please sign in to comment.