msvc.patch 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. From 5382b796b5b92901d492ec3f63c3447fe3beb1ad Mon Sep 17 00:00:00 2001
  2. From: SpringFestival <[email protected]>
  3. Date: Sat, 23 Mar 2024 16:28:15 +0800
  4. Subject: [PATCH] fix header to fit msvc
  5. ---
  6. quickjs.h | 13 +++++++++++--
  7. 1 file changed, 11 insertions(+), 2 deletions(-)
  8. diff --git a/quickjs.h b/quickjs.h
  9. index 7199936..1da1999 100644
  10. --- a/quickjs.h
  11. +++ b/quickjs.h
  12. @@ -215,9 +215,18 @@ typedef struct JSValue {
  13. #define JS_VALUE_GET_FLOAT64(v) ((v).u.float64)
  14. #define JS_VALUE_GET_PTR(v) ((v).u.ptr)
  15. +#ifndef __MINGW__COMPILE__
  16. +
  17. +#define JS_MKVAL(tag, val) (JSValue){ (JSValueUnion){ val }, tag }
  18. +#define JS_MKPTR(tag, p) (JSValue){ (JSValueUnion){ p }, tag }
  19. +
  20. +#else
  21. +
  22. #define JS_MKVAL(tag, val) (JSValue){ (JSValueUnion){ .int32 = val }, tag }
  23. #define JS_MKPTR(tag, p) (JSValue){ (JSValueUnion){ .ptr = p }, tag }
  24. +#endif
  25. +
  26. #define JS_TAG_IS_FLOAT64(tag) ((unsigned)(tag) == JS_TAG_FLOAT64)
  27. #define JS_NAN (JSValue){ .u.float64 = JS_FLOAT64_NAN, JS_TAG_FLOAT64 }
  28. @@ -670,7 +679,7 @@ static inline JSValue JS_DupValue(JSContext *ctx, JSValueConst v)
  29. JSRefCountHeader *p = (JSRefCountHeader *)JS_VALUE_GET_PTR(v);
  30. p->ref_count++;
  31. }
  32. - return (JSValue)v;
  33. + return v;
  34. }
  35. static inline JSValue JS_DupValueRT(JSRuntime *rt, JSValueConst v)
  36. @@ -679,7 +688,7 @@ static inline JSValue JS_DupValueRT(JSRuntime *rt, JSValueConst v)
  37. JSRefCountHeader *p = (JSRefCountHeader *)JS_VALUE_GET_PTR(v);
  38. p->ref_count++;
  39. }
  40. - return (JSValue)v;
  41. + return v;
  42. }
  43. int JS_ToBool(JSContext *ctx, JSValueConst val); /* return -1 for JS_EXCEPTION */
  44. --
  45. 2.40.0.windows.1