diff options
| author | Po Lu | 2022-05-20 01:49:43 +0000 |
|---|---|---|
| committer | Po Lu | 2022-05-20 01:50:25 +0000 |
| commit | d2865bfa2ca933b712b34507fe294dbcc047cdf0 (patch) | |
| tree | 3e63cd3f6794f4da309dc2c311b644b7cba50c24 | |
| parent | de9dfb1939caba80fd4acc42789794f5c9273df8 (diff) | |
| download | emacs-d2865bfa2ca933b712b34507fe294dbcc047cdf0.tar.gz emacs-d2865bfa2ca933b712b34507fe294dbcc047cdf0.zip | |
Implement more data type conversions for Haiku selections
* src/haikuselect.c (haiku_message_to_lisp):
(lisp_to_type_code):
(haiku_lisp_to_message):
(Fhaiku_drag_message): Recognize `double' and `float' types.
(syms_of_haikuselect): New defsyms.
| -rw-r--r-- | src/haikuselect.c | 53 |
1 files changed, 52 insertions, 1 deletions
diff --git a/src/haikuselect.c b/src/haikuselect.c index 313b26f6ba9..6d03d6eb681 100644 --- a/src/haikuselect.c +++ b/src/haikuselect.c | |||
| @@ -295,6 +295,14 @@ haiku_message_to_lisp (void *message) | |||
| 295 | t1 = make_int ((intmax_t) *(ssize_t *) buf); | 295 | t1 = make_int ((intmax_t) *(ssize_t *) buf); |
| 296 | break; | 296 | break; |
| 297 | 297 | ||
| 298 | case 'DBLE': | ||
| 299 | t1 = make_float (*(double *) buf); | ||
| 300 | break; | ||
| 301 | |||
| 302 | case 'FLOT': | ||
| 303 | t1 = make_float (*(float *) buf); | ||
| 304 | break; | ||
| 305 | |||
| 298 | default: | 306 | default: |
| 299 | t1 = make_uninit_string (buf_size); | 307 | t1 = make_uninit_string (buf_size); |
| 300 | memcpy (SDATA (t1), buf, buf_size); | 308 | memcpy (SDATA (t1), buf, buf_size); |
| @@ -353,6 +361,14 @@ haiku_message_to_lisp (void *message) | |||
| 353 | t2 = Qpoint; | 361 | t2 = Qpoint; |
| 354 | break; | 362 | break; |
| 355 | 363 | ||
| 364 | case 'DBLE': | ||
| 365 | t2 = Qdouble; | ||
| 366 | break; | ||
| 367 | |||
| 368 | case 'FLOT': | ||
| 369 | t2 = Qfloat; | ||
| 370 | break; | ||
| 371 | |||
| 356 | default: | 372 | default: |
| 357 | t2 = make_int (type_code); | 373 | t2 = make_int (type_code); |
| 358 | } | 374 | } |
| @@ -398,6 +414,10 @@ lisp_to_type_code (Lisp_Object obj) | |||
| 398 | return 'SSZT'; | 414 | return 'SSZT'; |
| 399 | else if (EQ (obj, Qpoint)) | 415 | else if (EQ (obj, Qpoint)) |
| 400 | return 'BPNT'; | 416 | return 'BPNT'; |
| 417 | else if (EQ (obj, Qfloat)) | ||
| 418 | return 'FLOT'; | ||
| 419 | else if (EQ (obj, Qdouble)) | ||
| 420 | return 'DBLE'; | ||
| 401 | else | 421 | else |
| 402 | return -1; | 422 | return -1; |
| 403 | } | 423 | } |
| @@ -416,7 +436,8 @@ haiku_lisp_to_message (Lisp_Object obj, void *message) | |||
| 416 | ssize_t ssizet_data; | 436 | ssize_t ssizet_data; |
| 417 | intmax_t t4; | 437 | intmax_t t4; |
| 418 | uintmax_t t5; | 438 | uintmax_t t5; |
| 419 | float t6, t7; | 439 | float t6, t7, float_data; |
| 440 | double double_data; | ||
| 420 | int rc; | 441 | int rc; |
| 421 | specpdl_ref ref; | 442 | specpdl_ref ref; |
| 422 | 443 | ||
| @@ -520,6 +541,30 @@ haiku_lisp_to_message (Lisp_Object obj, void *message) | |||
| 520 | signal_error ("Invalid point", data); | 541 | signal_error ("Invalid point", data); |
| 521 | break; | 542 | break; |
| 522 | 543 | ||
| 544 | case 'FLOT': | ||
| 545 | CHECK_NUMBER (data); | ||
| 546 | float_data = XFLOATINT (data); | ||
| 547 | |||
| 548 | rc = be_add_message_data (message, SSDATA (name), | ||
| 549 | type_code, &float_data, | ||
| 550 | sizeof float_data); | ||
| 551 | |||
| 552 | if (rc) | ||
| 553 | signal_error ("Failed to add float", data); | ||
| 554 | break; | ||
| 555 | |||
| 556 | case 'DBLE': | ||
| 557 | CHECK_NUMBER (data); | ||
| 558 | double_data = XFLOATINT (data); | ||
| 559 | |||
| 560 | rc = be_add_message_data (message, SSDATA (name), | ||
| 561 | type_code, &double_data, | ||
| 562 | sizeof double_data); | ||
| 563 | |||
| 564 | if (rc) | ||
| 565 | signal_error ("Failed to add double", data); | ||
| 566 | break; | ||
| 567 | |||
| 523 | case 'SHRT': | 568 | case 'SHRT': |
| 524 | if (!TYPE_RANGED_FIXNUMP (int16, data)) | 569 | if (!TYPE_RANGED_FIXNUMP (int16, data)) |
| 525 | signal_error ("Invalid value", data); | 570 | signal_error ("Invalid value", data); |
| @@ -734,6 +779,10 @@ system. If TYPE is `ssize_t', then DATA is an integer that can hold | |||
| 734 | values from -1 to the maximum value of the C data type `ssize_t' on | 779 | values from -1 to the maximum value of the C data type `ssize_t' on |
| 735 | the current system. If TYPE is `point', then DATA is a cons of float | 780 | the current system. If TYPE is `point', then DATA is a cons of float |
| 736 | values describing the X and Y coordinates of an on-screen location. | 781 | values describing the X and Y coordinates of an on-screen location. |
| 782 | If TYPE is `float', then DATA is a low-precision floating point | ||
| 783 | number, whose exact precision is not guaranteed. If TYPE is `double', | ||
| 784 | then DATA is a floating point number that can represent any value a | ||
| 785 | Lisp float can represent. | ||
| 737 | 786 | ||
| 738 | If the field name is not a string but the symbol `type', then it | 787 | If the field name is not a string but the symbol `type', then it |
| 739 | associates to a 32-bit unsigned integer describing the type of the | 788 | associates to a 32-bit unsigned integer describing the type of the |
| @@ -928,6 +977,8 @@ used to retrieve the current position of the mouse. */); | |||
| 928 | DEFSYM (Qsize_t, "size_t"); | 977 | DEFSYM (Qsize_t, "size_t"); |
| 929 | DEFSYM (Qssize_t, "ssize_t"); | 978 | DEFSYM (Qssize_t, "ssize_t"); |
| 930 | DEFSYM (Qpoint, "point"); | 979 | DEFSYM (Qpoint, "point"); |
| 980 | DEFSYM (Qfloat, "float"); | ||
| 981 | DEFSYM (Qdouble, "double"); | ||
| 931 | DEFSYM (Qalready_running, "already-running"); | 982 | DEFSYM (Qalready_running, "already-running"); |
| 932 | 983 | ||
| 933 | defsubr (&Shaiku_selection_data); | 984 | defsubr (&Shaiku_selection_data); |