Skip to content

Commit

Permalink
arm mac book
Browse files Browse the repository at this point in the history
  • Loading branch information
qimiko committed Jun 1, 2024
1 parent 0183881 commit b55b7f3
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 11 deletions.
11 changes: 8 additions & 3 deletions include/ast.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,19 @@ namespace broma {
Windows = 2,
Android = 4,
iOS = 8,
Android32 = 20, // includes Android
Android64 = 36, // includes Android
Android32 = 16 | 4, // includes Android
Android64 = 32 | 4, // includes Android
MacIntel = 64 | 1,
MacArm = 128 | 1,
};

inline Platform str_to_platform(std::string const& str) {
if (str == "mac") return Platform::Mac;
if (str == "win") return Platform::Windows;
if (str == "android") return Platform::Android;
if (str == "ios") return Platform::iOS;
if (str == "imac") return Platform::MacIntel;
if (str == "m1") return Platform::MacArm;
if (str == "android32") return Platform::Android32;
if (str == "android64") return Platform::Android64;
return Platform::None;
Expand All @@ -49,7 +53,8 @@ namespace broma {

/// @brief Binding offsets for each platform.
struct PlatformNumber {
ptrdiff_t mac = -1;
ptrdiff_t imac = -1;
ptrdiff_t m1 = -1;
ptrdiff_t ios = -1;
ptrdiff_t win = -1;
ptrdiff_t android32 = -1;
Expand Down
4 changes: 3 additions & 1 deletion src/basic_components.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ namespace broma {
keyword(android);
keyword(android32);
keyword(android64);
keyword(m1);
keyword(imac);
keyword(PAD);

#undef keyword
Expand All @@ -103,5 +105,5 @@ namespace broma {

/// @brief A platform identifier (mac, win, ios, android).
template <typename T>
struct tagged_platform : tagged_for_each<T, sor<keyword_mac, keyword_win, keyword_ios, keyword_android, keyword_android32, keyword_android64>> {};
struct tagged_platform : tagged_for_each<T, sor<keyword_mac, keyword_win, keyword_ios, keyword_android, keyword_android32, keyword_android64, keyword_imac, keyword_m1>> {};
} // namespace broma
7 changes: 5 additions & 2 deletions src/bind.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,11 @@ namespace broma {
size_t out = std::stoul(input.string(), nullptr, 16);

switch (scratch->wip_bind_platform) {
case Platform::Mac:
scratch->wip_bind.mac = out;
case Platform::MacIntel:
scratch->wip_bind.imac = out;
break;
case Platform::MacArm:
scratch->wip_bind.m1 = out;
break;
case Platform::iOS:
scratch->wip_bind.ios = out;
Expand Down
9 changes: 6 additions & 3 deletions src/member.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,10 @@ namespace broma {
scratch->wip_bind = p;

if (auto platform = scratch->wip_platform_block) {
if ((platform.value() & Platform::Mac) != Platform::None)
scratch->wip_bind.mac = 0;
if ((platform.value() & Platform::MacIntel) != Platform::None)
scratch->wip_bind.imac = 0;
if ((platform.value() & Platform::MacArm) != Platform::None)
scratch->wip_bind.m1 = 0;
if ((platform.value() & Platform::iOS) != Platform::None)
scratch->wip_bind.ios = 0;
if ((platform.value() & Platform::Windows) != Platform::None)
Expand All @@ -111,7 +113,8 @@ namespace broma {

auto platform = scratch->wip_platform_block.value();

scratch->wip_bind.mac = (platform & Platform::Mac) != Platform::None ? out : 0;
scratch->wip_bind.imac = (platform & Platform::MacIntel) != Platform::None ? out : 0;
scratch->wip_bind.m1 = (platform & Platform::MacArm) != Platform::None ? out : 0;
scratch->wip_bind.ios = (platform & Platform::iOS) != Platform::None ? out : 0;
scratch->wip_bind.win = (platform & Platform::Windows) != Platform::None ? out : 0;
scratch->wip_bind.android32 = (platform & Platform::Android32) != Platform::None ? out : 0;
Expand Down
2 changes: 1 addition & 1 deletion test/free.bro
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
void say_hello(int a, int b, int c) = win 0x0, mac 0x24, ios 0x343;
void say_hello(int a, int b, int c) = win 0x0, imac 0x24, m1 0x554, ios 0x343;
void i_hate_mat(std::string a, std::vector<int> b, std::vector<cocos2d::CCPoint>& points) = mac 0x33;


Expand Down
3 changes: 2 additions & 1 deletion test/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ void print_func(broma::FunctionProto& func, broma::PlatformNumber& addrs) {
}
std::cout << ") = " << std::hex;
std::cout << "win 0x" << addrs.win << ", ";
std::cout << "mac 0x" << addrs.mac << ", ";
std::cout << "imac 0x" << addrs.imac << ", ";
std::cout << "m1 0x" << addrs.m1 << ", ";
std::cout << "ios 0x" << addrs.ios << ";\n";
std::cout << std::dec;
}
Expand Down

0 comments on commit b55b7f3

Please sign in to comment.