Skip to content

Modules with static variables to resolve readable names to plaftorm specific symbols #5

Open
@notnotmelon

Description

@notnotmelon

Currently you have to put the raw mangled name into the detour macro.
This is ugly and only works on windows.

We need a giant enum of nice function names into mangled names for both platforms.
We also need automated scripts to update the enum when factorio's version increases.

Here is a mockup:

#[cfg(target_os = "linux")]
mod linux {
    pub mod LuaSurface {
        pub const valid: &str = "_ZNK10LuaSurface5validEv";
    }

    pub mod LuaEntity {
        pub const valid: &str = "_ZNK9LuaEntity5validEv";

        #[deprecated(note = "LuaEntity::luaDamage is unknown on linux")]
        pub const luaDamage: () = ();
    }

    pub mod LuaPlayer {
        pub const valid: &str = "_ZNK9LuaPlayer5validEv";
    }

    pub mod LuaRCON {
        pub const getObjectName: &str = "_ZNK7LuaRCON13getObjectNameEv";
        pub const luaIndex: &str = "_ZN7LuaRCON8luaIndexEP9lua_State";
        pub const luaPrint: &str = "_ZN7LuaRCON8luaPrintEP9lua_State";
        pub const deconstructor: &str = "_ZN7LuaRCOND0Ev";
    }
}

#[cfg(target_os = "windows")]
mod windows {
    pub mod LuaSurface {
        pub const valid: () = ();
    }

    pub mod LuaEntity {
        pub const valid: () = ();
    }

    pub mod LuaPlayer {
        pub const valid: () = ();
    }

    pub mod LuaRCON {
        pub const getObjectName: () = ();
        pub const luaIndex: () = ();
        pub const luaPrint: () = ();
        pub const deconstructor: () = ();
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions