| 54 | } |
| 55 | |
| 56 | void PatchLuaBytecode(dmLuaDDF::LuaSource *source) |
| 57 | { |
| 58 | // the application can have bytecode bundled in three different ways: |
| 59 | // |
| 60 | // OPTION 1 |
| 61 | // if the application was bundled for use on both 32 and 64 bit hardware |
| 62 | // using the 'use-lua-bytecode-delta' option it will contain both the |
| 63 | // 64-bit bytecode and a 32-bit delta |
| 64 | |
| 65 | // OPTION 2 |
| 66 | // if the application was bundled for use on both 32 and 64 bit hardware |
| 67 | // without the 'use-lua-bytecode-delta' option it will contain both the |
| 68 | // 32-bit bytecode and the 64-bit bytecode |
| 69 | |
| 70 | // OPTION 3 |
| 71 | // if the application was bundled for only 32 or 64 bit hardware it will |
| 72 | // only contain bytecode for the appropriate CPU architecture |
| 73 | |
| 74 | // OPTION 1 - patch bytecode if running on 32 bit |
| 75 | if (source->m_Delta.m_Count > 0) |
| 76 | { |
| 77 | #if defined(DM_PLATFORM_32BIT) |
| 78 | // get the 32-bit bytecode delta generated by bob |
| 79 | uint8_t* delta = source->m_Delta.m_Data; |
| 80 | uint32_t delta_size = source->m_Delta.m_Count; |
| 81 | |
| 82 | // get the 64-bit bytecode |
| 83 | uint8_t* bc = source->m_Bytecode.m_Data; |
| 84 | uint32_t bc_size = source->m_Bytecode.m_Count; |
| 85 | |
| 86 | // apply the delta to the 64-bit bytecode |
| 87 | PatchBytes(bc, bc_size, delta, delta_size); |
| 88 | #endif |
| 89 | } |
| 90 | // OPTION 2 - use 32 or 64 bit bytecode |
| 91 | else if (source->m_Bytecode.m_Count == 0) |
| 92 | { |
| 93 | #if defined(DM_PLATFORM_32BIT) |
| 94 | source->m_Bytecode.m_Data = source->m_Bytecode32.m_Data; |
| 95 | source->m_Bytecode.m_Count = source->m_Bytecode32.m_Count; |
| 96 | #else |
| 97 | source->m_Bytecode.m_Data = source->m_Bytecode64.m_Data; |
| 98 | source->m_Bytecode.m_Count = source->m_Bytecode64.m_Count; |
| 99 | #endif |
| 100 | } |
| 101 | // OPTION 3 - use bytecode as-is |
| 102 | else |
| 103 | { |
| 104 | // no-op |
| 105 | } |
| 106 | } |
| 107 | |
| 108 | dmResource::Result LoadLuaModule(dmResource::HFactory factory, const char* path, dmLuaDDF::LuaModule** module) |
| 109 | { |
no test coverage detected