Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Insoft-UK committed Sep 27, 2024
1 parent e1a6d0f commit 8d4e53d
Show file tree
Hide file tree
Showing 32 changed files with 322 additions and 155 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ xcuserdata/
*.sh
*.psd
bin/*
.www
www
examples/Kelvin.*
examples/Celsius.*
*.zip
87 changes: 0 additions & 87 deletions build

This file was deleted.

6 changes: 3 additions & 3 deletions compress
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
!/bin/bash
#!/bin/bash
DIR=$(dirname "$0")
printf '\e[1;40;92m'
clear
Expand All @@ -21,10 +21,10 @@ echo "Archiving File... Please Wait!"

zip_file="$xcodeproj_name.zip"

echo "Archiving for $platform"
echo "Archiving..."
rm $zip_file

zip $zip_file bin/* -r -x "*/.DS_Store"
zip $zip_file bin/macos/* -r -x "*/.DS_Store"
zip $zip_file pplib/* -x "*/.DS_Store"
zip $zip_file hpprgm/* -x "*/.DS_Store"

Expand Down
60 changes: 60 additions & 0 deletions linux
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/bin/bash
DIR=$(dirname "$0")

clear
ANSI_ART=$(cat <<EOF
\e[0;m \e[48;5;214m \e[0;m \e[0;m
\e[48;5;214m \e[0;m \e[48;5;214m \e[0;m \e[48;5;214m \e[0;m
\e[48;5;214m \e[0;m \e[48;5;214m \e[0;m \e[48;5;214m \e[0;m
\e[48;5;214m \e[0;m \e[48;5;214m \e[0;m \e[48;5;214m \e[0;m
\e[48;5;214m \e[0;m \e[48;5;214m \e[0;m \e[48;5;214m \e[0;m
\e[48;5;214m \e[0;m \e[48;5;214m \e[0;m \e[48;5;214m \e[0;m
\e[48;5;214m \e[0;m \e[48;5;214m \e[0;m \e[48;5;214m \e[0;m
\e[48;5;214m \e[0;m \e[48;5;214m \e[0;m \e[48;5;214m \e[0;m
\e[48;5;214m \e[0;m \e[48;5;214m \e[0;m \e[48;5;214m \e[0;m
\e[48;5;214m \e[0;m \e[48;5;214m \e[0;m \e[48;5;214m \e[0;m
\e[48;5;214m \e[0;m \e[48;5;214m \e[0;m \e[48;5;214m \e[0;m
\e[0;m \e[48;5;214m \e[0;m \e[0;m
EOF
)
printf "$ANSI_ART\n"

cd $DIR

# Use find to locate the .xcodeproj file
xcodeproj_file=$(find . -name "*.xcodeproj" -print -quit)

# Check if a .xcodeproj file was found
if [ -n "$xcodeproj_file" ]; then
xcodeproj_name=$(basename "$xcodeproj_file" .xcodeproj)
else
echo "No .xcodeproj file found."
read
# Close the Terminal window
osascript -e 'tell application "Terminal" to close window 1' & exit
fi

# Ask the user a question
CPU=$(osascript -e 'display dialog "CPU?" buttons {"x86_64", "i386", "aarch64"} default button "x86_64"')
CPU=$xcodeproj_name_${CPU#button returned:}

# Process the results
TARGET=$CPU-linux-gnu

# Compiling Code...
if [ ! -d "bin" ]; then
mkdir bin
fi
if [ ! -d "bin/linux" ]; then
mkdir bin/linux
fi
if [ ! -d "bin/linux/$CPU" ]; then
mkdir bin/linux/$CPU
fi

echo "Compiling Code..."
zig c++ -target $TARGET -std=c++20 -o bin/linux/$CPU/$xcodeproj_name src/*.cpp -s


# Close the Terminal window
osascript -e 'tell application "Terminal" to close window 1' & exit
66 changes: 66 additions & 0 deletions macos
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#!/bin/bash
DIR=$(dirname "$0")
clear
ANSI_ART=$(cat <<EOF
\e[0;m \e[48;5;34m \e[0;m \e[0;m
\e[0;m \e[48;5;34m \e[0;m \e[0;m
\e[0;m \e[48;5;34m \e[0;m \e[0;m
\e[0;m \e[0;m
\e[0;m \e[48;5;34m \e[0;m \e[48;5;34m \e[0;m
\e[0;m \e[48;5;220m \e[0;m
\e[48;5;220m \e[0;m \e[0;m
\e[48;5;208m \e[0;m \e[0;m
\e[48;5;208m \e[0;m \e[0;m
\e[48;5;160m \e[0;m \e[0;m
\e[48;5;160m \e[0;m
\e[0;m \e[48;5;125m \e[0;m
\e[0;m \e[48;5;125m \e[0;m \e[0;m
\e[0;m \e[48;5;38m \e[0;m \e[48;5;38m \e[0;m \e[0;m
EOF
)

printf "$ANSI_ART\n"

cd $DIR

# Use find to locate the .xcodeproj file
xcodeproj_file=$(find . -name "*.xcodeproj" -print -quit)

# Check if a .xcodeproj file was found
if [ -n "$xcodeproj_file" ]; then
xcodeproj_name=$(basename "$xcodeproj_file" .xcodeproj)
else
echo "No .xcodeproj file found."
# Close the Terminal window
osascript -e 'tell application "Terminal" to close window 1' & exit
fi

# Compiling Code...

if [ ! -d "bin" ]; then
mkdir bin
fi
if [ ! -d "bin/macos" ]; then
mkdir bin/macos
fi

echo "Compiling Code..."
echo "macOS Universal Binary"
g++ -arch x86_64 -arch arm64 -std=c++20 src/*.cpp -o bin/macos/$xcodeproj_name -Os -fno-ident -fno-asynchronous-unwind-tables
strip bin/macos/$xcodeproj_name
lipo -info bin/macos/$xcodeproj_name

# Ask the user a question
result=$(osascript -e 'display dialog "Do you want to sign this code?" buttons {"Yes", "No"} default button "Yes"')

# Process the result
if [[ "$result" == *"Yes"* ]]; then
# Code Signing...
echo "Code Signing... Please wait!"

IDENTITY=$(security find-identity -v -p codesigning | grep "Developer ID Application" | awk '{print $2}')
codesign -s "$IDENTITY" ./bin/macos/$xcodeproj_name
fi

# Close the Terminal window
osascript -e 'tell application "Terminal" to close window 1' & exit
2 changes: 2 additions & 0 deletions p+.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
137FB2942A046E8E00AEFDF2 /* p+.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "p+.entitlements"; sourceTree = "<group>"; };
1384DE7B2B6D70DE0090E24D /* switch.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = switch.cpp; sourceTree = "<group>"; };
1384DE7C2B6D70DE0090E24D /* switch.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = switch.hpp; sourceTree = "<group>"; };
1389CFEA2CA73BA6008FDBEB /* timer.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = timer.hpp; sourceTree = "<group>"; };
138F54D22C976F10009357F9 /* LICENCE.txt */ = {isa = PBXFileReference; lastKnownFileType = text; path = LICENCE.txt; sourceTree = "<group>"; };
138F54DC2C9E12EF009357F9 /* for_next.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = for_next.cpp; sourceTree = "<group>"; };
138F54DD2C9E12EF009357F9 /* for_next.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = for_next.hpp; sourceTree = "<group>"; };
Expand Down Expand Up @@ -130,6 +131,7 @@
13C21F9B2A783D8D0067CE22 /* common.cpp */,
1308E8F52AC48F20001EEC82 /* singleton.hpp */,
1308E8F42AC48F20001EEC82 /* singleton.cpp */,
1389CFEA2CA73BA6008FDBEB /* timer.hpp */,
);
path = src;
sourceTree = "<group>";
Expand Down
12 changes: 6 additions & 6 deletions src/alias.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ using namespace pp;

static Singleton *singleton = Singleton::shared();

static void parseAlias(const std::string &str, Aliases::TIdentity &identity) {
static void parseAlias(const std::string& str, Aliases::TIdentity& identity) {
/*
eg. name:alias
Group 0 name:alias
Expand All @@ -51,36 +51,36 @@ static void parseAlias(const std::string &str, Aliases::TIdentity &identity) {
}
}

static void parseAliases(const std::string &str, Aliases::TIdentity &identity) {
static void parseAliases(const std::string& str, Aliases::TIdentity& identity) {
std::regex r(R"((?:[^\x00-\x7F]|\w)+\w*:[a-zA-Z][\w.]*((?:::)?[a-zA-Z][\w.]*)*)");

for(std::sregex_iterator it = std::sregex_iterator(str.begin(), str.end(), r); it != std::sregex_iterator(); ++it) {
parseAlias(it->str(), identity);
}
}

static void parseFunctionName(const std::string &str) {
static void parseFunctionName(const std::string& str) {
Aliases::TIdentity identity;
identity.scope = Aliases::Scope::Global;
identity.type = Aliases::Type::Function;
parseAlias(str, identity);
}

static void parseParameters(const std::string &str) {
static void parseParameters(const std::string& str) {
Aliases::TIdentity identity;
identity.scope = Aliases::Scope::Local;
identity.type = Aliases::Type::Unknown;
parseAliases(str, identity);
}

static void parseVariables(const std::string &str) {
static void parseVariables(const std::string& str) {
Aliases::TIdentity identity;
identity.scope = Aliases::Scope::Auto;
identity.type = Aliases::Type::Variable;
parseAliases(str, identity);
}

bool Alias::parse(std::string &str) {
bool Alias::parse(std::string& str) {
std::string s;
std::regex r;
std::smatch m;
Expand Down
2 changes: 1 addition & 1 deletion src/alias.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
namespace pp {
class Alias {
public:
static bool parse(std::string &str);
static bool parse(std::string& str);
};
}

Expand Down
12 changes: 6 additions & 6 deletions src/aliases.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@ namespace pp {

bool verbose = false;

bool append(const TIdentity &identity);
bool append(const TIdentity& identity);
void removeAllLocalAliases();
void removeAllAliasesOfType(const Type type);
std::string resolveAliasesInText(const std::string &str);
void remove(const std::string &identifier);
bool exists(const TIdentity &identity);
bool identifierExists(const std::string &identifier);
bool realExists(const std::string &real);
std::string resolveAliasesInText(const std::string& str);
void remove(const std::string& identifier);
bool exists(const TIdentity& identity);
bool identifierExists(const std::string& identifier);
bool realExists(const std::string& real);
void dumpIdentities();

private:
Expand Down
9 changes: 5 additions & 4 deletions src/auto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ static std::string base10ToBase32(unsigned int num) {
}

// This function will examine any variable name thats not a valid PPL variable name and asign an auto: prefix to it.
static void inferredAutoForVariableName(std::string &ln) {
static void inferredAutoForVariableName(std::string& ln) {
std::regex r;

r = std::regex(R"(\b((?:var|local|const) +)(.*)(?=;))", std::regex_constants::icase);
Expand All @@ -69,7 +69,8 @@ static void inferredAutoForVariableName(std::string &ln) {
std::string s = trim_copy(it->str());
if (regex_search(s, std::regex(R"(^[A-Za-z]\w*:[a-zA-Z])"))) {
code.append(s);
} else {
}
else {
if (regex_search(s, std::regex(R"(^[A-Za-z]\w*(?:(::)|\.))"))) {
s.insert(0, "auto:");
}
Expand All @@ -83,7 +84,7 @@ static void inferredAutoForVariableName(std::string &ln) {
}
}

static void inferredAutoForShortNameOnly(std::string &str) {
static void inferredAutoForShortNameOnly(std::string& str) {
std::regex r;
std::smatch m;

Expand All @@ -95,7 +96,7 @@ static void inferredAutoForShortNameOnly(std::string &str) {
}
}

bool Auto::parse(std::string &str) {
bool Auto::parse(std::string& str) {
std::smatch m;
std::regex r;
size_t pos;
Expand Down
2 changes: 1 addition & 1 deletion src/auto.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace pp {

class Auto {
public:
bool parse(std::string &str);
bool parse(std::string& str);

private:
unsigned _fnCount = 0, _varCount = 0, _paramCount = 0, _globalCount = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/bitwise.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
namespace pp {
class Bitwise {
public:
static bool parse(std::string &str);
static bool parse(std::string& str);
};
}

Expand Down
Loading

0 comments on commit 8d4e53d

Please sign in to comment.