Skip to content

Commit 0ed274c

Browse files
committed
Uglify
Signed-off-by: Bob Weinand <[email protected]>
1 parent 70a78e2 commit 0ed274c

File tree

18 files changed

+1218
-392
lines changed

18 files changed

+1218
-392
lines changed

ddcommon-ffi/src/option.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ impl<T> Option<T> {
1212
pub fn to_std(self) -> std::option::Option<T> {
1313
self.into()
1414
}
15-
15+
1616
pub fn to_std_ref(&self) -> std::option::Option<&T> {
1717
match self {
1818
Option::Some(ref s) => Some(s),

live-debugger-ffi/src/data.rs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
2-
// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2021-Present Datadog, Inc.
1+
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache
2+
// License Version 2.0. This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2021-Present Datadog, Inc.
33

4+
use datadog_live_debugger::debugger_defs::{ProbeMetadata, ProbeMetadataLocation};
45
use datadog_live_debugger::{
56
Capture, DslString, EvaluateAt, InBodyLocation, MetricKind, ProbeCondition, ProbeValue,
67
SpanProbeTarget,
78
};
8-
use datadog_live_debugger::debugger_defs::{ProbeMetadata, ProbeMetadataLocation};
9-
use ddcommon_ffi::{CharSlice, Option};
109
use ddcommon_ffi::slice::AsBytes;
10+
use ddcommon_ffi::{CharSlice, Option};
1111

1212
#[repr(C)]
1313
pub struct CharSliceVec<'a> {
@@ -222,8 +222,16 @@ impl<'a> From<&Probe<'a>> for ProbeMetadata<'a> {
222222
ProbeMetadata {
223223
id: unsafe { val.id.assume_utf8() }.into(),
224224
location: ProbeMetadataLocation {
225-
method: val.target.method_name.to_std_ref().map(|s| unsafe { s.assume_utf8() }.into()),
226-
r#type: val.target.type_name.to_std_ref().map(|s| unsafe { s.assume_utf8() }.into()),
225+
method: val
226+
.target
227+
.method_name
228+
.to_std_ref()
229+
.map(|s| unsafe { s.assume_utf8() }.into()),
230+
r#type: val
231+
.target
232+
.type_name
233+
.to_std_ref()
234+
.map(|s| unsafe { s.assume_utf8() }.into()),
227235
},
228236
}
229237
}

live-debugger-ffi/src/evaluator.rs

Lines changed: 52 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
2-
// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2021-Present Datadog, Inc.
1+
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache
2+
// License Version 2.0. This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2021-Present Datadog, Inc.
33

4-
use std::borrow::Cow;
4+
use datadog_live_debugger::debugger_defs::SnapshotEvaluationError;
55
use datadog_live_debugger::{DslString, ProbeCondition};
6+
use ddcommon_ffi::slice::AsBytes;
67
use ddcommon_ffi::CharSlice;
8+
use std::borrow::Cow;
79
use std::ffi::c_void;
8-
use ddcommon_ffi::slice::AsBytes;
9-
use datadog_live_debugger::debugger_defs::SnapshotEvaluationError;
1010

1111
#[repr(C)]
1212
pub enum IntermediateValue<'a> {
@@ -50,7 +50,7 @@ pub struct Evaluator {
5050
pub greater_or_equals:
5151
for<'a> extern "C" fn(&'a mut c_void, IntermediateValue<'a>, IntermediateValue<'a>) -> bool,
5252
pub fetch_identifier:
53-
for<'a, 'b> extern "C" fn(&'a mut c_void, &CharSlice<'b>) -> Option<&'static c_void>, // special values: @duration, @return, @exception
53+
for<'a, 'b> extern "C" fn(&'a mut c_void, &CharSlice<'b>) -> Option<&'static c_void>, /* special values: @duration, @return, @exception */
5454
pub fetch_index: for<'a, 'b> extern "C" fn(
5555
&'a mut c_void,
5656
&'a c_void,
@@ -65,7 +65,7 @@ pub struct Evaluator {
6565
pub try_enumerate: for<'a> extern "C" fn(&'a mut c_void, &'a c_void) -> VoidCollection,
6666
pub stringify: for<'a> extern "C" fn(&'a mut c_void, &'a c_void) -> CharSlice<'static>,
6767
pub get_string: for<'a> extern "C" fn(&'a mut c_void, &'a c_void) -> CharSlice<'static>,
68-
pub convert_index: for<'a> extern "C" fn(&'a mut c_void, &'a c_void) -> isize, // return < 0 on error
68+
pub convert_index: for<'a> extern "C" fn(&'a mut c_void, &'a c_void) -> isize, /* return < 0 on error */
6969
pub instanceof: for<'a> extern "C" fn(&'a mut c_void, &'a c_void, &CharSlice<'a>) -> bool,
7070
}
7171

@@ -80,33 +80,53 @@ impl<'e> EvalCtx<'e> {
8080
fn new(context: &'e mut c_void) -> Self {
8181
EvalCtx {
8282
context,
83-
eval: unsafe { FFI_EVALUATOR.as_ref().unwrap() }
83+
eval: unsafe { FFI_EVALUATOR.as_ref().unwrap() },
8484
}
8585
}
8686
}
8787

8888
impl<'e> datadog_live_debugger::Evaluator<'e, c_void> for EvalCtx<'e> {
89-
fn equals(&mut self, a: datadog_live_debugger::IntermediateValue<'e, c_void>, b: datadog_live_debugger::IntermediateValue<'e, c_void>) -> bool {
89+
fn equals(
90+
&mut self,
91+
a: datadog_live_debugger::IntermediateValue<'e, c_void>,
92+
b: datadog_live_debugger::IntermediateValue<'e, c_void>,
93+
) -> bool {
9094
(self.eval.equals)(self.context, (&a).into(), (&b).into())
9195
}
9296

93-
fn greater_than(&mut self, a: datadog_live_debugger::IntermediateValue<'e, c_void>, b: datadog_live_debugger::IntermediateValue<'e, c_void>) -> bool {
97+
fn greater_than(
98+
&mut self,
99+
a: datadog_live_debugger::IntermediateValue<'e, c_void>,
100+
b: datadog_live_debugger::IntermediateValue<'e, c_void>,
101+
) -> bool {
94102
(self.eval.greater_than)(self.context, (&a).into(), (&b).into())
95103
}
96104

97-
fn greater_or_equals(&mut self, a: datadog_live_debugger::IntermediateValue<'e, c_void>, b: datadog_live_debugger::IntermediateValue<'e, c_void>) -> bool {
105+
fn greater_or_equals(
106+
&mut self,
107+
a: datadog_live_debugger::IntermediateValue<'e, c_void>,
108+
b: datadog_live_debugger::IntermediateValue<'e, c_void>,
109+
) -> bool {
98110
(self.eval.greater_or_equals)(self.context, (&a).into(), (&b).into())
99111
}
100112

101113
fn fetch_identifier(&mut self, identifier: &str) -> Option<&'e c_void> {
102114
(self.eval.fetch_identifier)(self.context, &CharSlice::from(identifier))
103115
}
104116

105-
fn fetch_index(&mut self, value: &'e c_void, index: datadog_live_debugger::IntermediateValue<'e, c_void>) -> Option<&'e c_void> {
117+
fn fetch_index(
118+
&mut self,
119+
value: &'e c_void,
120+
index: datadog_live_debugger::IntermediateValue<'e, c_void>,
121+
) -> Option<&'e c_void> {
106122
(self.eval.fetch_index)(self.context, value, (&index).into())
107123
}
108124

109-
fn fetch_nested(&mut self, value: &'e c_void, member: datadog_live_debugger::IntermediateValue<'e, c_void>) -> Option<&'e c_void> {
125+
fn fetch_nested(
126+
&mut self,
127+
value: &'e c_void,
128+
member: datadog_live_debugger::IntermediateValue<'e, c_void>,
129+
) -> Option<&'e c_void> {
110130
(self.eval.fetch_nested)(self.context, value, (&member).into())
111131
}
112132

@@ -119,12 +139,15 @@ impl<'e> datadog_live_debugger::Evaluator<'e, c_void> for EvalCtx<'e> {
119139
if collection.count < 0 {
120140
None
121141
} else {
122-
// We need to copy, Vec::from_raw_parts with only free in the allocator would be unstable...
142+
// We need to copy, Vec::from_raw_parts with only free in the allocator would be
143+
// unstable...
123144
let mut vec = Vec::with_capacity(collection.count as usize);
124-
unsafe { vec.extend_from_slice(std::slice::from_raw_parts(
125-
collection.elements as *const &c_void,
126-
collection.count as usize,
127-
)) };
145+
unsafe {
146+
vec.extend_from_slice(std::slice::from_raw_parts(
147+
collection.elements as *const &c_void,
148+
collection.count as usize,
149+
))
150+
};
128151
(collection.free)(collection);
129152
Some(vec)
130153
}
@@ -162,20 +185,27 @@ pub unsafe extern "C" fn ddog_register_expr_evaluator(eval: &Evaluator) {
162185
pub enum ConditionEvaluationResult {
163186
Success,
164187
Failure,
165-
Error(Box<Vec<SnapshotEvaluationError>>)
188+
Error(Box<Vec<SnapshotEvaluationError>>),
166189
}
167190

168191
#[no_mangle]
169-
pub extern "C" fn ddog_evaluate_condition(condition: &ProbeCondition, context: &mut c_void) -> ConditionEvaluationResult {
192+
pub extern "C" fn ddog_evaluate_condition(
193+
condition: &ProbeCondition,
194+
context: &mut c_void,
195+
) -> ConditionEvaluationResult {
170196
let mut ctx = EvalCtx::new(context);
171197
match datadog_live_debugger::eval_condition(&mut ctx, condition) {
172198
Ok(true) => ConditionEvaluationResult::Success,
173199
Ok(false) => ConditionEvaluationResult::Failure,
174-
Err(error) => ConditionEvaluationResult::Error(Box::new(vec![error]))
200+
Err(error) => ConditionEvaluationResult::Error(Box::new(vec![error])),
175201
}
176202
}
177203

178-
pub fn ddog_evaluate_string<'a>(condition: &'a DslString, context: &'a mut c_void, errors: &mut Option<Box<Vec<SnapshotEvaluationError>>>) -> Cow<'a, str> {
204+
pub fn ddog_evaluate_string<'a>(
205+
condition: &'a DslString,
206+
context: &'a mut c_void,
207+
errors: &mut Option<Box<Vec<SnapshotEvaluationError>>>,
208+
) -> Cow<'a, str> {
179209
let mut ctx = EvalCtx::new(context);
180210
let (result, new_errors) = datadog_live_debugger::eval_string(&mut ctx, condition);
181211
if !new_errors.is_empty() {

live-debugger-ffi/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
2-
// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2021-Present Datadog, Inc.
1+
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache
2+
// License Version 2.0. This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2021-Present Datadog, Inc.
33

44
pub mod data;
55
pub mod evaluator;

live-debugger-ffi/src/parse.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Copyright 2021-Present Datadog, Inc. https://www.datadoghq.com/
2+
// SPDX-License-Identifier: Apache-2.0
3+
14
use crate::data::LiveDebuggingData;
25
use ddcommon_ffi::slice::AsBytes;
36
use ddcommon_ffi::CharSlice;
@@ -15,7 +18,8 @@ pub extern "C" fn ddog_parse_live_debugger_json(json: CharSlice) -> LiveDebuggin
1518
{
1619
let parsed = Box::new(parsed);
1720
LiveDebuggingParseResult {
18-
// we have the box. Rust doesn't allow us to specify a self-referential struct, so pretend it's 'static
21+
// we have the box. Rust doesn't allow us to specify a self-referential struct, so
22+
// pretend it's 'static
1923
data: unsafe {
2024
std::mem::transmute::<&_, &'static datadog_live_debugger::LiveDebuggingData>(
2125
&*parsed,

0 commit comments

Comments
 (0)