[quickjs-devel] Some suggestions on better support of native windows and none-c99 build

  • From: Xingyi HU <huxingyi@xxxxxxx>
  • To: "quickjs-devel@xxxxxxxxxxxxx" <quickjs-devel@xxxxxxxxxxxxx>
  • Date: Thu, 25 Jul 2019 11:14:45 +0000

Hi,

Thanks for making such a state of the art work, I am using it in my 3D modeling 
software to provide procedural nodes generation api.
May I suggest some of the code changes to better support visual studio please?
Before I list my suggestions, I have to say that QuickJS is very easy to embed 
into C++ codebase. However I have to do many dirty works before it compiles on 
visual studio, I see there is a new release, I guess I have to do it again if I 
want update QuickJS to the latest version.

Here are some suggestions:

    - Change the triple dots inside switch-case to normal cases
    - Remove the zero length array at the beginning of JSShape structure

        struct JSShape {
            #if !defined(_MSC_VER)
                uint32_t prop_hash_end[0]; /* hash table of size hash_mask + 1
                                              before the start of the 
structure. */
            #endif
            ... ...
        }
        #if defined(_MSC_VER)
        #define prop_hash_end_field_of_shape(shape) ((uint32_t *)(shape))
        #else
        #define prop_hash_end_field_of_shape(shape) (shape)->prop_hash_end
        #endif

        Replace all `sh->prop_hash_end` with `prop_hash_end_field_of_shape(sh)`

    - Other c99 features, such as

        Replace
            #define JS_MKVAL(tag, val) (JSValue){ .u.int32 = val, tag }
        With
            static inline JSValue JS_MKVAL(uint64_t tag, int32_t val)
            {
                JSValue value = {};
                value.u.int32 = val;
                value.tag = tag;
                return value;
            }

Some informations maybe useful for testing on Windows:

    - Here is the 90 days free windows for virtual machines provided by 
Microsoft
        https://developer.microsoft.com/en-us/microsoft-edge/tools/vms/

    - My modified quickjs-2019-07-09:
        
https://github.com/huxingyi/dust3d/tree/master/thirdparty/quickjs/quickjs-2019-07-09-dust3d
        I made it runs on linux and native windows with many dirty fixes.

Best regards,
Jeremy.

Other related posts:

  • » [quickjs-devel] Some suggestions on better support of native windows and none-c99 build - Xingyi HU