diff --git a/Package.swift b/Package.swift index 2aac1ac..19b152f 100644 --- a/Package.swift +++ b/Package.swift @@ -17,15 +17,30 @@ let package = Package( name: "PMCalc", dependencies: [ .product(name: "Adwaita", package: "adwaita-swift"), - .product(name: "Localized", package: "localized") + .product(name: "Localized", package: "localized"), + "CMath" ], - path: "Sources", + path: "Sources/PMCalc", resources: [ .process("Localized.yml") ], + cSettings: [ + .headerSearchPath("Sources/CMath/include") + ], + linkerSettings: [ + .unsafeFlags([ + "-L./Sources/CMath/lib/", + "-lcmath" + ]) + ], plugins: [ .plugin(name: "GenerateLocalized", package: "localized") ] + ), + .systemLibrary( + name: "CMath", + path: "Sources/CMath", + providers: [] ) ], swiftLanguageModes: [.v5] diff --git a/Sources/CMath/include/add_nums.h b/Sources/CMath/include/add_nums.h new file mode 100644 index 0000000..6c98505 --- /dev/null +++ b/Sources/CMath/include/add_nums.h @@ -0,0 +1,13 @@ +// +// add_nums.h +// CMath +// +// Created by TheAlgorithm476 on 28/03/2025. +// + +#ifndef __ADD_NUMS_H +#define __ADD_NUMS_H + +double add_nums(double a, double b); + +#endif // __ADD_NUMS_H diff --git a/Sources/CMath/include/div_nums.h b/Sources/CMath/include/div_nums.h new file mode 100644 index 0000000..f9167c5 --- /dev/null +++ b/Sources/CMath/include/div_nums.h @@ -0,0 +1,13 @@ +// +// div_nums.h +// CMath +// +// Created by TheAlgorithm476 on 28/03/2025. +// + +#ifndef __DIV_NUMS_H +#define __DIV_NUMS_H + +double div_nums(double a, double b); + +#endif // __DIV_NUMS_H diff --git a/Sources/CMath/include/mul_nums.h b/Sources/CMath/include/mul_nums.h new file mode 100644 index 0000000..ccbc5a9 --- /dev/null +++ b/Sources/CMath/include/mul_nums.h @@ -0,0 +1,13 @@ +// +// mul_nums.h +// CMath +// +// Created by TheAlgorithm476 on 28/03/2025. +// + +#ifndef __MUL_NUMS_H +#define __MUL_NUMS_H + +double mul_nums(double a, double b); + +#endif // __MUL_NUMS_H diff --git a/Sources/CMath/include/spc_nums.h b/Sources/CMath/include/spc_nums.h new file mode 100644 index 0000000..8e456bc --- /dev/null +++ b/Sources/CMath/include/spc_nums.h @@ -0,0 +1,17 @@ +// +// spc_nums.h +// CMath +// +// Created by TheAlgorithm476 on 28/03/2025. +// + +#ifndef __SPC_NUMS_H +#define __SPC_NUMS_H + +#define POOR_MANS_POW_GUESSES 12 +#define NEWTONIAN_DIV_GUESSES 12 + +double pow(double x, double exp); +double sqrt(double x); + +#endif // __SPC_NUMS_H diff --git a/Sources/CMath/include/sub_nums.h b/Sources/CMath/include/sub_nums.h new file mode 100644 index 0000000..00439e9 --- /dev/null +++ b/Sources/CMath/include/sub_nums.h @@ -0,0 +1,13 @@ +// +// sub_nums.h +// CMath +// +// Created by TheAlgorithm476 on 28/03/2025. +// + +#ifndef __SUB_NUMS_H +#define __SUB_NUMS_H + +double sub_nums(double a, double b); + +#endif // __SUB_NUMS_H diff --git a/Sources/CMath/lib/libcmath.so b/Sources/CMath/lib/libcmath.so new file mode 100755 index 0000000..ff37e52 Binary files /dev/null and b/Sources/CMath/lib/libcmath.so differ diff --git a/Sources/CMath/module.modulemap b/Sources/CMath/module.modulemap new file mode 100644 index 0000000..16d4599 --- /dev/null +++ b/Sources/CMath/module.modulemap @@ -0,0 +1,9 @@ +module CMath { + header "include/add_nums.h" + header "include/sub_nums.h" + header "include/mul_nums.h" + header "include/div_nums.h" + header "include/spc_nums.h" + export * + link "cmath" +} diff --git a/Sources/Localized.yml b/Sources/PMCalc/Localized.yml similarity index 100% rename from Sources/Localized.yml rename to Sources/PMCalc/Localized.yml diff --git a/Sources/PMCalc.swift b/Sources/PMCalc/PMCalc.swift similarity index 99% rename from Sources/PMCalc.swift rename to Sources/PMCalc/PMCalc.swift index f607410..ca0afc8 100644 --- a/Sources/PMCalc.swift +++ b/Sources/PMCalc/PMCalc.swift @@ -2,6 +2,7 @@ // https://docs.swift.org/swift-book import Adwaita +import CMath @main struct PMCalc: App { diff --git a/Sources/ToolbarView.swift b/Sources/PMCalc/ToolbarView.swift similarity index 100% rename from Sources/ToolbarView.swift rename to Sources/PMCalc/ToolbarView.swift diff --git a/me.thealgorithm476.PMCalc.PMCalc.json b/me.thealgorithm476.PMCalc.PMCalc.json index 9ce7bc5..d8aa641 100644 --- a/me.thealgorithm476.PMCalc.PMCalc.json +++ b/me.thealgorithm476.PMCalc.PMCalc.json @@ -46,7 +46,8 @@ "install -Dm644 data/me.thealgorithm476.PMCalc.PMCalc.metainfo.xml $DESTDIR/app/share/metainfo/me.thealgorithm476.PMCalc.PMCalc.metainfo.xml", "install -Dm644 data/me.thealgorithm476.PMCalc.PMCalc.desktop $DESTDIR/app/share/applications/me.thealgorithm476.PMCalc.PMCalc.desktop", "install -Dm644 data/icons/me.thealgorithm476.PMCalc.PMCalc.svg $DESTDIR/app/share/icons/hicolor/scalable/apps/me.thealgorithm476.PMCalc.PMCalc.svg", - "install -Dm644 data/icons/me.thealgorithm476.PMCalc.PMCalc-symbolic.svg $DESTDIR/app/share/icons/hicolor/symbolic/apps/me.thealgorithm476.PMCalc.PMCalc-symbolic.svg" + "install -Dm644 data/icons/me.thealgorithm476.PMCalc.PMCalc-symbolic.svg $DESTDIR/app/share/icons/hicolor/symbolic/apps/me.thealgorithm476.PMCalc.PMCalc-symbolic.svg", + "install -Dm644 Sources/CMath/lib/libcmath.so /app/lib/libcmath.so" ] } ]