Skip to content

Commit

Permalink
Updated ffi interface to use ParseModes
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminwinger committed Apr 29, 2020
1 parent 52fbba2 commit 14de592
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions ffi/src/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::{f32, mem, panic, ptr};
use libc::{c_char, c_float, size_t};

use constants::*;
use esplugin::Plugin;
use esplugin::{ParseMode, Plugin};
use helpers::*;

#[no_mangle]
Expand Down Expand Up @@ -45,8 +45,13 @@ pub unsafe extern "C" fn esp_plugin_parse(plugin_ptr: *mut Plugin, load_header_o
if plugin_ptr.is_null() {
ESP_ERROR_NULL_POINTER
} else {
let mode = if load_header_only {
ParseMode::HeaderOnly
} else {
ParseMode::RecordIds
};
let plugin = &mut *plugin_ptr;
match plugin.parse_file(load_header_only) {
match plugin.parse_file(mode) {
Ok(_) => ESP_OK,
Err(_) => ESP_ERROR_PARSE_ERROR,
}
Expand Down Expand Up @@ -168,7 +173,12 @@ pub unsafe extern "C" fn esp_plugin_is_valid(
Err(x) => return x,
};

*is_valid = Plugin::is_valid(mapped_game_id, rust_path, load_header_only);
let mode = if load_header_only {
ParseMode::HeaderOnly
} else {
ParseMode::RecordIds
};
*is_valid = Plugin::is_valid(mapped_game_id, rust_path, mode);

ESP_OK
}
Expand Down

0 comments on commit 14de592

Please sign in to comment.