diff --git a/src/python/pants/engine/native.py b/src/python/pants/engine/native.py index de32a5ab155..960e397621a 100644 --- a/src/python/pants/engine/native.py +++ b/src/python/pants/engine/native.py @@ -376,6 +376,12 @@ def extern_store_i64(self, context_handle, i64): c = self._ffi.from_handle(context_handle) return c.to_value(i64) + @_extern_decl('Handle', ['ExternContext*', 'double']) + def extern_store_f64(self, context_handle, f64): + """Given a context and double, return a new Handle to represent the double.""" + c = self._ffi.from_handle(context_handle) + return c.to_value(f64) + @_extern_decl('Handle', ['ExternContext*', '_Bool']) def extern_store_bool(self, context_handle, b): """Given a context and _Bool, return a new Handle to represent the _Bool.""" @@ -634,6 +640,7 @@ def init_externs(): self.ffi_lib.extern_store_bytes, self.ffi_lib.extern_store_utf8, self.ffi_lib.extern_store_i64, + self.ffi_lib.extern_store_f64, self.ffi_lib.extern_store_bool, self.ffi_lib.extern_project_ignoring_type, self.ffi_lib.extern_project_multi, diff --git a/src/rust/engine/src/externs.rs b/src/rust/engine/src/externs.rs index 83f210e459e..c81bee215e1 100644 --- a/src/rust/engine/src/externs.rs +++ b/src/rust/engine/src/externs.rs @@ -120,6 +120,11 @@ pub fn store_i64(val: i64) -> Value { with_externs(|e| (e.store_i64)(e.context, val).into()) } +#[allow(dead_code)] +pub fn store_f64(val: f64) -> Value { + with_externs(|e| (e.store_f64)(e.context, val).into()) +} + #[allow(dead_code)] pub fn store_bool(val: bool) -> Value { with_externs(|e| (e.store_bool)(e.context, val).into()) @@ -343,6 +348,7 @@ pub struct Externs { pub store_bytes: StoreBytesExtern, pub store_utf8: StoreUtf8Extern, pub store_i64: StoreI64Extern, + pub store_f64: StoreF64Extern, pub store_bool: StoreBoolExtern, pub project_ignoring_type: ProjectIgnoringTypeExtern, pub project_multi: ProjectMultiExtern, @@ -382,6 +388,8 @@ pub type StoreUtf8Extern = extern "C" fn(*const ExternContext, *const u8, u64) - pub type StoreI64Extern = extern "C" fn(*const ExternContext, i64) -> Handle; +pub type StoreF64Extern = extern "C" fn(*const ExternContext, f64) -> Handle; + pub type StoreBoolExtern = extern "C" fn(*const ExternContext, bool) -> Handle; /// diff --git a/src/rust/engine/src/lib.rs b/src/rust/engine/src/lib.rs index b354eb3356c..cc5d3d5ee98 100644 --- a/src/rust/engine/src/lib.rs +++ b/src/rust/engine/src/lib.rs @@ -62,8 +62,8 @@ use crate::externs::{ Buffer, BufferBuffer, CallExtern, CloneValExtern, CreateExceptionExtern, DropHandlesExtern, EqualsExtern, EvalExtern, ExternContext, Externs, GeneratorSendExtern, HandleBuffer, IdentifyExtern, LogExtern, ProjectIgnoringTypeExtern, ProjectMultiExtern, PyResult, - SatisfiedByExtern, SatisfiedByTypeExtern, StoreBoolExtern, StoreBytesExtern, StoreI64Extern, - StoreTupleExtern, StoreUtf8Extern, TypeIdBuffer, TypeToStrExtern, ValToStrExtern, + SatisfiedByExtern, SatisfiedByTypeExtern, StoreBoolExtern, StoreBytesExtern, StoreF64Extern, + StoreI64Extern, StoreTupleExtern, StoreUtf8Extern, TypeIdBuffer, TypeToStrExtern, ValToStrExtern, }; use crate::handles::Handle; use crate::rule_graph::{GraphMaker, RuleGraph}; @@ -119,6 +119,7 @@ pub extern "C" fn externs_set( store_bytes: StoreBytesExtern, store_utf8: StoreUtf8Extern, store_i64: StoreI64Extern, + store_f64: StoreF64Extern, store_bool: StoreBoolExtern, project_ignoring_type: ProjectIgnoringTypeExtern, project_multi: ProjectMultiExtern, @@ -146,6 +147,7 @@ pub extern "C" fn externs_set( store_bytes, store_utf8, store_i64, + store_f64, store_bool, project_ignoring_type, project_multi,