Skip to content

Commit

Permalink
TodoReturn is now an enum and add option to not use custom GNU STL fo…
Browse files Browse the repository at this point in the history
…r android
  • Loading branch information
SpaghettDev committed Jul 27, 2024
1 parent 573666b commit 9770261
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 14 deletions.
2 changes: 1 addition & 1 deletion BromaIDA.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION = "5.4.0"
VERSION = "5.5.0"
__AUTHOR__ = "SpaghettDev"

PLUGIN_NAME = "BromaIDA"
Expand Down
10 changes: 9 additions & 1 deletion broma_ida/broma/codegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class BromaCodegen:
#include <array>
#define BROMAIDA_PLATFORM_MACRO_NAME
#define BROMAIDA_USE_CUSTOM_GNUSTL_MACRO
#define STR_CONCAT_WRAPPER(a, b) a ## b
#define STR_CONCAT(a, b) STR_CONCAT_WRAPPER(a, b)
Expand All @@ -20,18 +21,21 @@ class BromaCodegen:
_classes: dict[str, Class]
_path: Path
_target_platform: BROMA_PLATFORMS
_use_custom_gnustl: bool = True
_broma_path: Path

_added_classes: set[str] = set()

def __init__(
self,
platform: BROMA_PLATFORMS,
use_custom_gnustl: bool,
broma_classes: dict[str, Class],
path: Path,
broma_path: Path
):
self._target_platform = platform
self._use_custom_gnustl = use_custom_gnustl
self._classes = broma_classes
self._path = path
self._broma_path = broma_path
Expand All @@ -54,6 +58,10 @@ def write(self):
self.FILE_HEADER.replace(
"BROMAIDA_PLATFORM_MACRO_NAME",
self._get_bromaida_platform_macro()
).replace(
"BROMAIDA_USE_CUSTOM_GNUSTL_MACRO",
"BROMAIDA_USE_CUSTOM_GNUSTL" if self._use_custom_gnustl \
else "BROMAIDA_DONT_USE_CUSTOM_GNUSTL"
)
)

Expand Down Expand Up @@ -102,7 +110,7 @@ def write(self):
f.write("// Broma\n\n")

f.write("// typdefs\n")
f.write("using TodoReturn = void; // :troll:\n")
f.write("enum class TodoReturn {}; // :troll:\n")
f.write("\n")

f.flush()
Expand Down
12 changes: 11 additions & 1 deletion broma_ida/broma/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
FUNC_LIB
)
from ida_funcs import get_func, add_func
from ida_kernwin import ASKBTN_BTN1, ASKBTN_CANCEL
from ida_kernwin import ASKBTN_BTN1, ASKBTN_BTN2, ASKBTN_CANCEL
from ida_typeinf import (
get_idati, get_ordinal_qty,
func_type_data_t as ida_func_type_data_t,
Expand Down Expand Up @@ -426,8 +426,18 @@ def _codegen_classes(self, classes: dict[str, Class]) -> bool:
)
return False

use_custom_gnustl = True
if self._target_platform.startswith("android"):
if popup(
"Yes", "No", None,
"Use custom GNU STL? "
"(Recommended if you're not using genuine android GCC headers)"
) == ASKBTN_BTN2:
use_custom_gnustl = False

BromaCodegen(
self._target_platform,
use_custom_gnustl,
classes,
plugin_path / "broma_ida" / "types",
Path("/".join(Path(self._file_path).parts[:-1]))
Expand Down
10 changes: 5 additions & 5 deletions broma_ida/types/cocos2d.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@
#include <climits>
#include <cctype>

#if !defined(BROMAIDA_PLATFORM_ANDROID32) && !defined(BROMAIDA_PLATFORM_ANDROID64)
#if !defined(BROMAIDA_DONT_USE_CUSTOM_GNUSTL) && (defined(BROMAIDA_PLATFORM_ANDROID32) || defined(BROMAIDA_PLATFORM_ANDROID64))

#include <string>
#include <vector>
#include <set>
#include "gnustl.hpp"

#else

#include "gnustl.hpp"
#include <string>
#include <vector>
#include <set>

#endif

Expand Down
2 changes: 1 addition & 1 deletion broma_ida/types/gnustl.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// taken from: https://github.com/geode-sdk/geode/blob/main/loader/include/Geode/c++stl/string.hpp

#if defined(BROMAIDA_PLATFORM_ANDROID32) || defined(BROMAIDA_PLATFORM_ANDROID64)
#if !defined(BROMAIDA_DONT_USE_CUSTOM_GNUSTL) && (defined(BROMAIDA_PLATFORM_ANDROID32) || defined(BROMAIDA_PLATFORM_ANDROID64))

#include <cstdint>
#include <cstddef>
Expand Down
10 changes: 5 additions & 5 deletions broma_ida/types/stl_types.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#include <utility>

#if !defined(BROMAIDA_PLATFORM_ANDROID32) && !defined(BROMAIDA_PLATFORM_ANDROID64)
#if !defined(BROMAIDA_DONT_USE_CUSTOM_GNUSTL) && (defined(BROMAIDA_PLATFORM_ANDROID32) || defined(BROMAIDA_PLATFORM_ANDROID64))

#include "gnustl.hpp"

#else

#include <string>
#include <vector>
Expand All @@ -9,10 +13,6 @@
#include <set>
#include <unordered_set>

#else

#include "gnustl.hpp"

#endif

#include "enums.hpp"
Expand Down

0 comments on commit 9770261

Please sign in to comment.