Skip to content

Commit d75ff5d

Browse files
DOGE the operators
1 parent 27872bd commit d75ff5d

File tree

1 file changed

+0
-94
lines changed

1 file changed

+0
-94
lines changed

code/logic/fossil/pizza/common.h

Lines changed: 0 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -105,20 +105,6 @@ extern "C" {
105105
*/
106106
#define notnull(ptr) ((ptr) != null)
107107

108-
/**
109-
* @brief Option-like behavior to return a pointer or a default value.
110-
*
111-
* Mimics Rust's `Option::unwrap_or()` safely.
112-
*/
113-
#define unwrap_or(ptr, default_val) ((ptr) ? (ptr) : (default_val))
114-
115-
/**
116-
* @brief Unwraps a pointer safely or terminates if it's null.
117-
*
118-
* Mimics Rust's `Option::unwrap()`.
119-
*/
120-
#define unwrap(ptr) ((notnull(ptr)) ? (ptr) : (fprintf(stderr, "Fatal error: called unwrap() on a null pointer at %s:%d\n", __FILE__, __LINE__), exit(EXIT_FAILURE), null))
121-
122108
/**
123109
* @brief Safely casts one pointer type to another with null-checking.
124110
*
@@ -192,86 +178,6 @@ extern "C" {
192178
*/
193179
#define cempty ""
194180

195-
/**
196-
* @brief Ensure safe cleanup by nullifying pointers after use.
197-
*
198-
* Mimics Rust's memory safety using explicit pointer management.
199-
*/
200-
#define pizza_drop(ptr) do { nullify(ptr); } while (0)
201-
202-
/**
203-
* @brief Panic behavior for immediate program termination with error message.
204-
*
205-
* This macro causes the program to immediately terminate with an error message,
206-
* similar to Rust's `pizza_panic!()` functionality.
207-
*
208-
* @param msg The message to display when pizza_panicking.
209-
*/
210-
#define pizza_panic(msg) (pizza_io_fprintf(PIZZA_STDERR, "Panic: %s\n", msg), exit(EXIT_FAILURE))
211-
212-
/**
213-
* @brief Mimics Rust's Option type.
214-
*
215-
* The `pizza_optional` macro represents a nullable pointer that can be either `null` or a valid pointer.
216-
* It can be used to model optional values that may or may not be present.
217-
*/
218-
#define pizza_optional(ptr) ((ptr) ? (ptr) : null)
219-
220-
/**
221-
* @brief `Option` structure to mimic Rust's `Option<T>`.
222-
*
223-
* This structure allows representation of an optional value where it can either contain a value
224-
* (`Some`) or be `None` (`null`).
225-
*/
226-
typedef struct {
227-
void* value; // The value held by the Option (could be a pointer to any type)
228-
int is_some; // Flag indicating whether the Option is `Some` (1) or `None` (0)
229-
} Option;
230-
231-
/**
232-
* @brief Creates an `Option` with a value (Some).
233-
*
234-
* @param val The value to wrap in the Option.
235-
* @return The created `Option` containing the value.
236-
*/
237-
#ifdef __cplusplus
238-
#define pizza_some(val) (Option{val, 1})
239-
#else
240-
#define pizza_some(val) ((Option){(void*)(val), 1})
241-
#endif
242-
243-
/**
244-
* @brief Creates an empty `Option` (None).
245-
*
246-
* @return An `Option` representing `None`.
247-
*/
248-
#ifdef __cplusplus
249-
#define pizza_none() (Option{null, 0})
250-
#else
251-
#define pizza_none() ((Option){null, 0})
252-
#endif
253-
254-
/**
255-
* @brief Unwraps the `Option`. If it's `Some`, return the value; if it's `None`, pizza_panic.
256-
*
257-
* Mimics Rust's `Option::unwrap()`.
258-
*
259-
* @param opt The `Option` to unwrap.
260-
* @return The value inside the `Option`.
261-
*/
262-
#define unwrap_option(opt) ((opt).is_some ? (opt).value : (fprintf(stderr, "Panic: Unwrapped a None value at %s:%d\n", __FILE__, __LINE__), exit(EXIT_FAILURE), null))
263-
264-
/**
265-
* @brief Returns the value inside the `Option` or a default value if it's `None`.
266-
*
267-
* Mimics Rust's `Option::unwrap_or()`.
268-
*
269-
* @param opt The `Option` to unwrap.
270-
* @param default_val The default value to return if the `Option` is `None`.
271-
* @return The value inside the `Option`, or the default value if `None`.
272-
*/
273-
#define unwrap_or_option(opt, default_val) ((opt).is_some ? (opt).value : (default_val))
274-
275181
// *****************************************************************************
276182
// Command Pallet
277183
// *****************************************************************************

0 commit comments

Comments
 (0)