Skip to content

Commit acd5d4b

Browse files
committed
Remove result types from style getters
1 parent 00d11f2 commit acd5d4b

File tree

4 files changed

+218
-142
lines changed

4 files changed

+218
-142
lines changed

ctaffy/include/taffy.h

Lines changed: 44 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -283,11 +283,6 @@ typedef struct TaffyStyle TaffyStyle;
283283

284284
typedef struct TaffyTree TaffyTree;
285285

286-
typedef struct TaffyIntResult {
287-
enum TaffyReturnCode return_code;
288-
int32_t value;
289-
} TaffyIntResult;
290-
291286
typedef const struct TaffyStyle *TaffyStyleConstRef;
292287

293288
typedef struct TaffyStyle *TaffyStyleMutRef;
@@ -298,28 +293,13 @@ typedef struct TaffyDimension {
298293
enum TaffyUnit unit;
299294
} TaffyDimension;
300295

301-
typedef struct TaffyDimensionResult {
302-
enum TaffyReturnCode return_code;
303-
struct TaffyDimension value;
304-
} TaffyDimensionResult;
305-
306-
typedef struct TaffyFloatResult {
307-
enum TaffyReturnCode return_code;
308-
float value;
309-
} TaffyFloatResult;
310-
311296
// For all fields, zero represents not set
312297
typedef struct TaffyGridPlacement {
313298
int16_t start;
314299
int16_t end;
315300
uint16_t span;
316301
} TaffyGridPlacement;
317302

318-
typedef struct TaffyGridPlacementResult {
319-
enum TaffyReturnCode return_code;
320-
struct TaffyGridPlacement value;
321-
} TaffyGridPlacementResult;
322-
323303
typedef struct TaffyTree *TaffyTreeOwnedRef;
324304

325305
typedef struct TaffyTree *TaffyTreeMutRef;
@@ -363,33 +343,33 @@ typedef const struct TaffyTree *TaffyTreeConstRef;
363343
extern "C" {
364344
#endif // __cplusplus
365345

366-
struct TaffyIntResult TaffyStyle_GetDisplay(TaffyStyleConstRef raw_style);
346+
enum TaffyDisplay TaffyStyle_GetDisplay(TaffyStyleConstRef raw_style);
367347

368348
enum TaffyReturnCode TaffyStyle_SetDisplay(TaffyStyleMutRef raw_style, enum TaffyDisplay value);
369349

370-
struct TaffyIntResult TaffyStyle_GetPosition(TaffyStyleConstRef raw_style);
350+
enum TaffyPosition TaffyStyle_GetPosition(TaffyStyleConstRef raw_style);
371351

372352
enum TaffyReturnCode TaffyStyle_SetPosition(TaffyStyleMutRef raw_style, enum TaffyPosition value);
373353

374-
struct TaffyIntResult TaffyStyle_GetOverflowX(TaffyStyleConstRef raw_style);
354+
enum TaffyOverflow TaffyStyle_GetOverflowX(TaffyStyleConstRef raw_style);
375355

376356
enum TaffyReturnCode TaffyStyle_SetOverflowX(TaffyStyleMutRef raw_style, enum TaffyOverflow value);
377357

378-
struct TaffyIntResult TaffyStyle_GetOverflowY(TaffyStyleConstRef raw_style);
358+
enum TaffyOverflow TaffyStyle_GetOverflowY(TaffyStyleConstRef raw_style);
379359

380360
enum TaffyReturnCode TaffyStyle_SetOverflowY(TaffyStyleMutRef raw_style, enum TaffyOverflow value);
381361

382-
struct TaffyIntResult TaffyStyle_GetAlignContent(TaffyStyleConstRef raw_style);
362+
int32_t TaffyStyle_GetAlignContent(TaffyStyleConstRef raw_style);
383363

384-
struct TaffyIntResult TaffyStyle_GetAlignItems(TaffyStyleConstRef raw_style);
364+
int32_t TaffyStyle_GetAlignItems(TaffyStyleConstRef raw_style);
385365

386-
struct TaffyIntResult TaffyStyle_GetAlignSelf(TaffyStyleConstRef raw_style);
366+
int32_t TaffyStyle_GetAlignSelf(TaffyStyleConstRef raw_style);
387367

388-
struct TaffyIntResult TaffyStyle_GetJustifyContent(TaffyStyleConstRef raw_style);
368+
int32_t TaffyStyle_GetJustifyContent(TaffyStyleConstRef raw_style);
389369

390-
struct TaffyIntResult TaffyStyle_GetJustifyItems(TaffyStyleConstRef raw_style);
370+
int32_t TaffyStyle_GetJustifyItems(TaffyStyleConstRef raw_style);
391371

392-
struct TaffyIntResult TaffyStyle_GetJustifySelf(TaffyStyleConstRef raw_style);
372+
int32_t TaffyStyle_GetJustifySelf(TaffyStyleConstRef raw_style);
393373

394374
enum TaffyReturnCode TaffyStyle_SetAlignContent(TaffyStyleMutRef raw_style, enum TaffyAlignContent value);
395375

@@ -403,145 +383,145 @@ enum TaffyReturnCode TaffyStyle_SetJustifyItems(TaffyStyleMutRef raw_style, enum
403383

404384
enum TaffyReturnCode TaffyStyle_SetJustifySelf(TaffyStyleMutRef raw_style, enum TaffyAlignItems value);
405385

406-
struct TaffyIntResult TaffyStyle_GetFlexDirection(TaffyStyleConstRef raw_style);
386+
enum TaffyFlexDirection TaffyStyle_GetFlexDirection(TaffyStyleConstRef raw_style);
407387

408388
enum TaffyReturnCode TaffyStyle_SetFlexDirection(TaffyStyleMutRef raw_style, enum TaffyFlexDirection value);
409389

410-
struct TaffyIntResult TaffyStyle_GetFlexWrap(TaffyStyleConstRef raw_style);
390+
enum TaffyFlexWrap TaffyStyle_GetFlexWrap(TaffyStyleConstRef raw_style);
411391

412392
enum TaffyReturnCode TaffyStyle_SetFlexWrap(TaffyStyleMutRef raw_style, enum TaffyFlexWrap value);
413393

414-
struct TaffyIntResult TaffyStyle_GetGridAutoFlow(TaffyStyleConstRef raw_style);
394+
enum TaffyGridAutoFlow TaffyStyle_GetGridAutoFlow(TaffyStyleConstRef raw_style);
415395

416396
enum TaffyReturnCode TaffyStyle_SetGridAutoFlow(TaffyStyleMutRef raw_style, enum TaffyGridAutoFlow value);
417397

418-
struct TaffyDimensionResult TaffyStyle_GetWidth(TaffyStyleConstRef raw_style);
398+
struct TaffyDimension TaffyStyle_GetWidth(TaffyStyleConstRef raw_style);
419399

420400
enum TaffyReturnCode TaffyStyle_SetWidth(TaffyStyleMutRef raw_style, float value, enum TaffyUnit unit);
421401

422-
struct TaffyDimensionResult TaffyStyle_GetHeight(TaffyStyleConstRef raw_style);
402+
struct TaffyDimension TaffyStyle_GetHeight(TaffyStyleConstRef raw_style);
423403

424404
enum TaffyReturnCode TaffyStyle_SetHeight(TaffyStyleMutRef raw_style, float value, enum TaffyUnit unit);
425405

426-
struct TaffyDimensionResult TaffyStyle_GetMinWidth(TaffyStyleConstRef raw_style);
406+
struct TaffyDimension TaffyStyle_GetMinWidth(TaffyStyleConstRef raw_style);
427407

428408
enum TaffyReturnCode TaffyStyle_SetMinWidth(TaffyStyleMutRef raw_style, float value, enum TaffyUnit unit);
429409

430-
struct TaffyDimensionResult TaffyStyle_GetMinHeight(TaffyStyleConstRef raw_style);
410+
struct TaffyDimension TaffyStyle_GetMinHeight(TaffyStyleConstRef raw_style);
431411

432412
enum TaffyReturnCode TaffyStyle_SetMinHeight(TaffyStyleMutRef raw_style, float value, enum TaffyUnit unit);
433413

434-
struct TaffyDimensionResult TaffyStyle_GetMaxWidth(TaffyStyleConstRef raw_style);
414+
struct TaffyDimension TaffyStyle_GetMaxWidth(TaffyStyleConstRef raw_style);
435415

436416
enum TaffyReturnCode TaffyStyle_SetMaxWidth(TaffyStyleMutRef raw_style, float value, enum TaffyUnit unit);
437417

438-
struct TaffyDimensionResult TaffyStyle_GetMaxHeight(TaffyStyleConstRef raw_style);
418+
struct TaffyDimension TaffyStyle_GetMaxHeight(TaffyStyleConstRef raw_style);
439419

440420
enum TaffyReturnCode TaffyStyle_SetMaxHeight(TaffyStyleMutRef raw_style, float value, enum TaffyUnit unit);
441421

442-
struct TaffyDimensionResult TaffyStyle_GetInsetTop(TaffyStyleConstRef raw_style);
422+
struct TaffyDimension TaffyStyle_GetInsetTop(TaffyStyleConstRef raw_style);
443423

444424
enum TaffyReturnCode TaffyStyle_SetInsetTop(TaffyStyleMutRef raw_style, float value, enum TaffyUnit unit);
445425

446-
struct TaffyDimensionResult TaffyStyle_GetInsetBottom(TaffyStyleConstRef raw_style);
426+
struct TaffyDimension TaffyStyle_GetInsetBottom(TaffyStyleConstRef raw_style);
447427

448428
enum TaffyReturnCode TaffyStyle_SetInsetBottom(TaffyStyleMutRef raw_style, float value, enum TaffyUnit unit);
449429

450-
struct TaffyDimensionResult TaffyStyle_GetInsetLeft(TaffyStyleConstRef raw_style);
430+
struct TaffyDimension TaffyStyle_GetInsetLeft(TaffyStyleConstRef raw_style);
451431

452-
struct TaffyDimensionResult TaffyStyle_GetInsetRight(TaffyStyleConstRef raw_style);
432+
struct TaffyDimension TaffyStyle_GetInsetRight(TaffyStyleConstRef raw_style);
453433

454434
enum TaffyReturnCode TaffyStyle_SetInsetLeft(TaffyStyleMutRef raw_style, float value, enum TaffyUnit unit);
455435

456436
enum TaffyReturnCode TaffyStyle_SetInsetRight(TaffyStyleMutRef raw_style, float value, enum TaffyUnit unit);
457437

458-
struct TaffyDimensionResult TaffyStyle_GetMarginTop(TaffyStyleConstRef raw_style);
438+
struct TaffyDimension TaffyStyle_GetMarginTop(TaffyStyleConstRef raw_style);
459439

460440
enum TaffyReturnCode TaffyStyle_SetMarginTop(TaffyStyleMutRef raw_style, float value, enum TaffyUnit unit);
461441

462-
struct TaffyDimensionResult TaffyStyle_GetMarginBottom(TaffyStyleConstRef raw_style);
442+
struct TaffyDimension TaffyStyle_GetMarginBottom(TaffyStyleConstRef raw_style);
463443

464444
enum TaffyReturnCode TaffyStyle_SetMarginBottom(TaffyStyleMutRef raw_style, float value, enum TaffyUnit unit);
465445

466-
struct TaffyDimensionResult TaffyStyle_GetMarginLeft(TaffyStyleConstRef raw_style);
446+
struct TaffyDimension TaffyStyle_GetMarginLeft(TaffyStyleConstRef raw_style);
467447

468-
struct TaffyDimensionResult TaffyStyle_GetMarginRight(TaffyStyleConstRef raw_style);
448+
struct TaffyDimension TaffyStyle_GetMarginRight(TaffyStyleConstRef raw_style);
469449

470450
enum TaffyReturnCode TaffyStyle_SetMarginLeft(TaffyStyleMutRef raw_style, float value, enum TaffyUnit unit);
471451

472452
enum TaffyReturnCode TaffyStyle_SetMarginRight(TaffyStyleMutRef raw_style, float value, enum TaffyUnit unit);
473453

474-
struct TaffyDimensionResult TaffyStyle_GetPaddingTop(TaffyStyleConstRef raw_style);
454+
struct TaffyDimension TaffyStyle_GetPaddingTop(TaffyStyleConstRef raw_style);
475455

476456
enum TaffyReturnCode TaffyStyle_SetPaddingTop(TaffyStyleMutRef raw_style, float value, enum TaffyUnit unit);
477457

478-
struct TaffyDimensionResult TaffyStyle_GetPaddingBottom(TaffyStyleConstRef raw_style);
458+
struct TaffyDimension TaffyStyle_GetPaddingBottom(TaffyStyleConstRef raw_style);
479459

480460
enum TaffyReturnCode TaffyStyle_SetPaddingBottom(TaffyStyleMutRef raw_style, float value, enum TaffyUnit unit);
481461

482-
struct TaffyDimensionResult TaffyStyle_GetPaddingLeft(TaffyStyleConstRef raw_style);
462+
struct TaffyDimension TaffyStyle_GetPaddingLeft(TaffyStyleConstRef raw_style);
483463

484-
struct TaffyDimensionResult TaffyStyle_GetPaddingRight(TaffyStyleConstRef raw_style);
464+
struct TaffyDimension TaffyStyle_GetPaddingRight(TaffyStyleConstRef raw_style);
485465

486466
enum TaffyReturnCode TaffyStyle_SetPaddingLeft(TaffyStyleMutRef raw_style, float value, enum TaffyUnit unit);
487467

488468
enum TaffyReturnCode TaffyStyle_SetPaddingRight(TaffyStyleMutRef raw_style, float value, enum TaffyUnit unit);
489469

490-
struct TaffyDimensionResult TaffyStyle_GetBorderTop(TaffyStyleConstRef raw_style);
470+
struct TaffyDimension TaffyStyle_GetBorderTop(TaffyStyleConstRef raw_style);
491471

492472
enum TaffyReturnCode TaffyStyle_SetBorderTop(TaffyStyleMutRef raw_style, float value, enum TaffyUnit unit);
493473

494-
struct TaffyDimensionResult TaffyStyle_GetBorderBottom(TaffyStyleConstRef raw_style);
474+
struct TaffyDimension TaffyStyle_GetBorderBottom(TaffyStyleConstRef raw_style);
495475

496476
enum TaffyReturnCode TaffyStyle_SetBorderBottom(TaffyStyleMutRef raw_style, float value, enum TaffyUnit unit);
497477

498-
struct TaffyDimensionResult TaffyStyle_GetBorderLeft(TaffyStyleConstRef raw_style);
478+
struct TaffyDimension TaffyStyle_GetBorderLeft(TaffyStyleConstRef raw_style);
499479

500-
struct TaffyDimensionResult TaffyStyle_GetBorderRight(TaffyStyleConstRef raw_style);
480+
struct TaffyDimension TaffyStyle_GetBorderRight(TaffyStyleConstRef raw_style);
501481

502482
enum TaffyReturnCode TaffyStyle_SetBorderLeft(TaffyStyleMutRef raw_style, float value, enum TaffyUnit unit);
503483

504484
enum TaffyReturnCode TaffyStyle_SetBorderRight(TaffyStyleMutRef raw_style, float value, enum TaffyUnit unit);
505485

506-
struct TaffyDimensionResult TaffyStyle_GetColumnGap(TaffyStyleConstRef raw_style);
486+
struct TaffyDimension TaffyStyle_GetColumnGap(TaffyStyleConstRef raw_style);
507487

508488
enum TaffyReturnCode TaffyStyle_SetColumnGap(TaffyStyleMutRef raw_style, float value, enum TaffyUnit unit);
509489

510-
struct TaffyDimensionResult TaffyStyle_GetRowGap(TaffyStyleConstRef raw_style);
490+
struct TaffyDimension TaffyStyle_GetRowGap(TaffyStyleConstRef raw_style);
511491

512492
enum TaffyReturnCode TaffyStyle_SetRowGap(TaffyStyleMutRef raw_style, float value, enum TaffyUnit unit);
513493

514-
struct TaffyFloatResult TaffyStyle_GetAspectRatio(TaffyStyleConstRef raw_style);
494+
float TaffyStyle_GetAspectRatio(TaffyStyleConstRef raw_style);
515495

516496
enum TaffyReturnCode TaffyStyle_SetAspectRatio(TaffyStyleMutRef raw_style, float value);
517497

518-
struct TaffyFloatResult TaffyStyle_GetScrollbarWidth(TaffyStyleConstRef raw_style);
498+
float TaffyStyle_GetScrollbarWidth(TaffyStyleConstRef raw_style);
519499

520500
enum TaffyReturnCode TaffyStyle_SetScrollbarWidth(TaffyStyleMutRef raw_style, float value);
521501

522-
struct TaffyDimensionResult TaffyStyle_GetFlexBasis(TaffyStyleConstRef raw_style);
502+
struct TaffyDimension TaffyStyle_GetFlexBasis(TaffyStyleConstRef raw_style);
523503

524504
enum TaffyReturnCode TaffyStyle_SetFlexBasis(TaffyStyleMutRef raw_style, float value, enum TaffyUnit unit);
525505

526-
struct TaffyFloatResult TaffyStyle_GetFlexGrow(TaffyStyleConstRef raw_style);
506+
float TaffyStyle_GetFlexGrow(TaffyStyleConstRef raw_style);
527507

528508
enum TaffyReturnCode TaffyStyle_SetFlexGrow(TaffyStyleMutRef raw_style, float value);
529509

530-
struct TaffyFloatResult TaffyStyle_GetFlexShrink(TaffyStyleConstRef raw_style);
510+
float TaffyStyle_GetFlexShrink(TaffyStyleConstRef raw_style);
531511

532512
enum TaffyReturnCode TaffyStyle_SetFlexShrink(TaffyStyleMutRef raw_style, float value);
533513

534514
// Function to set all the value of margin
535515
enum TaffyReturnCode TaffyStyle_SetMargin(TaffyStyleMutRef raw_style, enum TaffyEdge edge, struct TaffyDimension value);
536516

537517
// Get grid item's column placement
538-
struct TaffyGridPlacementResult TaffyStyle_GetGridColumn(TaffyStyleMutRef raw_style);
518+
struct TaffyGridPlacement TaffyStyle_GetGridColumn(TaffyStyleMutRef raw_style);
539519

540520
// Set grid item's column placement
541521
enum TaffyReturnCode TaffyStyle_SetGridColumn(TaffyStyleMutRef raw_style, struct TaffyGridPlacement placement);
542522

543523
// Get grid item's row placement
544-
struct TaffyGridPlacementResult TaffyStyle_GetGridRow(TaffyStyleMutRef raw_style);
524+
struct TaffyGridPlacement TaffyStyle_GetGridRow(TaffyStyleMutRef raw_style);
545525

546526
// Set grid item's row placement
547527
enum TaffyReturnCode TaffyStyle_SetGridRow(TaffyStyleMutRef raw_style, struct TaffyGridPlacement placement);

ctaffy/src/error.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,17 @@ macro_rules! bail_if_null {
2323
};
2424
}
2525

26+
#[macro_export]
27+
macro_rules! debug_assert_non_null {
28+
($raw_ptr:expr) => {
29+
#[cfg(debug)]
30+
if $raw_ptr.is_null() {
31+
eprintln!("Supplied pointer was null");
32+
::std::process::exit(1);
33+
}
34+
};
35+
}
36+
2637
#[macro_export]
2738
macro_rules! try_or {
2839
($error_code:ident, $block:expr) => {

0 commit comments

Comments
 (0)