Skip to content

Commit

Permalink
Merge pull request #6 from Decompollaborate/develop
Browse files Browse the repository at this point in the history
1.1.1
  • Loading branch information
AngheloAlf committed Dec 23, 2023
2 parents 59e69bb + 8a26456 commit 057e0fb
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/maturin_upload_pypi.yml
Expand Up @@ -123,7 +123,7 @@ jobs:
path: dist

check_clippy_python_bindings:
name: Check clippy for C bindings
name: Check clippy for Python bindings
runs-on: ubuntu-latest

steps:
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Expand Up @@ -7,6 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [1.1.1] - 2023-12-23

### Fixed

- Python bindings:
- Fix `detectCIC` and `detect_cic_raw` functions not accepting `bytearray`
objects.
- Fix some typos

## [1.1.0] - 2023-12-22

### Added
Expand Down Expand Up @@ -53,6 +62,7 @@ version of the library.
- Initial relase

[unreleased]: https://github.com/Decompollaborate/ipl3checksum/compare/main...develop
[1.1.1]: https://github.com/Decompollaborate/ipl3checksum/compare/1.1.0...1.1.1
[1.1.0]: https://github.com/Decompollaborate/ipl3checksum/compare/1.0.1...1.1.0
[1.0.1]: https://github.com/Decompollaborate/ipl3checksum/compare/1.0.0...1.0.1
[1.0.0]: https://github.com/Decompollaborate/ipl3checksum/releases/tag/1.0.0
10 changes: 5 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Expand Up @@ -4,7 +4,7 @@
[package]
name = "ipl3checksum"
# Version should be synced with src/ipl3checksum/__init__.py, pyproject.toml and src/rs/version.rs
version = "1.1.0"
version = "1.1.1"
edition = "2021"
description = "Library to calculate the IPL3 checksum for N64 ROMs"
repository = "https://github.com/decompollaborate/ipl3checksum"
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Expand Up @@ -4,7 +4,7 @@
[project]
name = "ipl3checksum"
# Version should be synced with src/ipl3checksum/__init__.py, Cargo.toml and src/rs/version.rs
version = "1.1.0"
version = "1.1.1"
description = "Library to calculate the IPL3 checksum for N64 ROMs"
readme = "README.md"
requires-python = ">=3.7"
Expand Down
2 changes: 1 addition & 1 deletion src/ipl3checksum/__init__.py
Expand Up @@ -6,7 +6,7 @@
from __future__ import annotations

# Version should be synced with pyproject.toml, Cargo.toml and src/rs/version.rs
__version_info__: tuple[int, int, int] = (1, 1, 0)
__version_info__: tuple[int, int, int] = (1, 1, 1)
__version__ = ".".join(map(str, __version_info__))
__author__ = "Decompollaborate"

Expand Down
16 changes: 12 additions & 4 deletions src/rs/detect.rs
Expand Up @@ -47,12 +47,20 @@ pub fn detect_cic(rom_bytes: &[u8]) -> Result<CICKind, Ipl3ChecksumError> {
#[allow(non_snake_case)]
pub(crate) mod python_bindings {
use pyo3::prelude::*;
use std::borrow::Cow;

/**
* We use a `Cow` instead of a plain &[u8] the latter only allows Python's
* `bytes` objects, while Cow allows for both `bytes` and `bytearray`.
* This is important because an argument typed as `bytes` allows to pass a
* `bytearray` object too.
*/

#[pyfunction]
pub(crate) fn detectCICRaw(
raw_bytes: &[u8],
raw_bytes: Cow<[u8]>,
) -> Result<Option<super::CICKind>, super::Ipl3ChecksumError> {
match super::detect_cic_raw(raw_bytes) {
match super::detect_cic_raw(&raw_bytes) {
Ok(cic) => Ok(Some(cic)),
Err(e) => match e {
super::Ipl3ChecksumError::BufferSizeIsWrong {
Expand All @@ -67,9 +75,9 @@ pub(crate) mod python_bindings {

#[pyfunction]
pub(crate) fn detectCIC(
rom_bytes: &[u8],
rom_bytes: Cow<[u8]>,
) -> Result<Option<super::CICKind>, super::Ipl3ChecksumError> {
match super::detect_cic(rom_bytes) {
match super::detect_cic(&rom_bytes) {
Ok(cic) => Ok(Some(cic)),
Err(e) => match e {
super::Ipl3ChecksumError::BufferSizeIsWrong {
Expand Down
6 changes: 3 additions & 3 deletions src/rs/version.rs
Expand Up @@ -4,12 +4,12 @@
// Version should be synced with pyproject.toml, Cargo.toml and src/ipl3checksum/__init__.py
pub static VERSION_MAJOR: i32 = 1;
pub static VERSION_MINOR: i32 = 1;
pub static VERSION_PATCH: i32 = 0;
pub static VERSION_PATCH: i32 = 1;

pub static VERSION_INFO: (i32, i32, i32) = (VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH);

// TODO: figure out a way to construct this string by using VERSION_MAJOR, VERSION_MINOR and VERSION_PATCH (concat! and stringify! didn't work)
pub static VERSION_STR: &str = "1.1.0";
pub static VERSION_STR: &str = "1.1.1";

pub static AUTHOR: &str = "Decompollaborate";

Expand All @@ -24,7 +24,7 @@ mod c_bindings {

// TODO: construct this from super::VERSION_STR
#[no_mangle]
static ipl3checksum_version_str: &[u8] = b"1.1.0\0";
static ipl3checksum_version_str: &[u8] = b"1.1.1\0";

// TODO: construct this from super::AUTHOR
#[no_mangle]
Expand Down

0 comments on commit 057e0fb

Please sign in to comment.