larsiusprime / polymod

Atomic modding framework for Haxe
MIT License
159 stars 60 forks source link

[BUG] Syntax error 'constant' in PolymodErrorType.h #152

Closed gamerbross closed 1 year ago

gamerbross commented 1 year ago

I get an error in the code compiled to C++ and I did not modify any Polymod file.

Error: InitialState.cpp
PolymodErrorType.h(26): error C2059: syntax error: 'constant'
PolymodErrorType.h(26): error C2238: unexpected token(s) preceding ';'

image

Full Header File ```cpp #ifndef INCLUDED_polymod_PolymodErrorType #define INCLUDED_polymod_PolymodErrorType #ifndef HXCPP_H #include #endif HX_DECLARE_CLASS1(polymod,PolymodErrorType) namespace polymod{ class PolymodErrorType_obj : public ::hx::EnumBase_obj { typedef ::hx::EnumBase_obj super; typedef PolymodErrorType_obj OBJ_; public: PolymodErrorType_obj() {}; HX_DO_ENUM_RTTI; static void __boot(); static void __register(); static bool __GetStatic(const ::String &inName, Dynamic &outValue, ::hx::PropertyAccess inCallProp); ::String GetEnumName( ) const { return HX_("polymod.PolymodErrorType",64,c3,9f,be); } ::String __ToString() const { return HX_("PolymodErrorType.",c2,82,7f,3a) + _hx_tag; } static ::polymod::PolymodErrorType ERROR; static inline ::polymod::PolymodErrorType ERROR_dyn() { return ERROR; } static ::polymod::PolymodErrorType NOTICE; static inline ::polymod::PolymodErrorType NOTICE_dyn() { return NOTICE; } static ::polymod::PolymodErrorType WARNING; static inline ::polymod::PolymodErrorType WARNING_dyn() { return WARNING; } }; } // end namespace polymod #endif /* INCLUDED_polymod_PolymodErrorType */ ```

The initial state file only contains this code mentioning polymod

Polymod.init({
    modRoot: "mods",
    dirs: [
        for (folder in FileSystem.readDirectory("mods"))
            if (FileSystem.isDirectory('mods/$folder')) folder
    ],
    ignoredFiles: Polymod.getDefaultIgnoreList(),
    framework: FLIXEL,
    apiVersionRule: "0.0.1",
    errorCallback: function(error)
    {
        trace('[${error.severity}] (${Std.string(error.code).toUpperCase()}): ${error.message}');
    }
});
trace("MOD METADATA: " + Polymod.loadMod("test"));

I don't have any idea of what is causing this :(

EliteMasterEric commented 1 year ago

Never seen this before, I test all my builds with HXCPP.

What version of Haxe are you using?

What operating system are you on?

Have you been able to reproduce this in any of the sample projects?

gamerbross commented 1 year ago

Never seen this before, I test all my builds with HXCPP.

What version of Haxe are you using?

What operating system are you on?

Have you been able to reproduce this in any of the sample projects?

I already managed to fix it, I just moved the errorCallback function to a new variable and changed the error parameter to dynamic (I don't know if it's necessary).

image image

EliteMasterEric commented 1 year ago

My guess is it might be a bug with Haxe's type interpretation.

Also, for reference, the error argument is of the type polymod.Polymod.PolymodError, which has several useful attributes (like severity and code, the latter of which is an enum you can use to handle specific errors).