-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
49 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ target_sources( | |
|
||
PRIVATE | ||
bytes.hpp | ||
capi.cpp | ||
constexpr_vector.hpp | ||
exceptions.cpp | ||
exceptions.hpp | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Fizzy: A fast WebAssembly interpreter | ||
// Copyright 2020 The Fizzy Authors. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#include "parser.hpp" | ||
#include <fizzy/fizzy.h> | ||
|
||
extern "C" { | ||
bool fizzy_validate(const uint8_t* wasm_binary, size_t wasm_binary_size) | ||
{ | ||
try | ||
{ | ||
fizzy::parse({wasm_binary, wasm_binary_size}); | ||
return true; | ||
} | ||
catch (...) | ||
{ | ||
return false; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,9 @@ | |
|
||
#include <fizzy/fizzy.h> | ||
|
||
void dummy() {} | ||
bool dummy(void); | ||
|
||
bool dummy() | ||
{ | ||
return fizzy_validate(NULL, 0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Fizzy: A fast WebAssembly interpreter | ||
// Copyright 2020 The Fizzy Authors. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#include <fizzy/fizzy.h> | ||
#include <gtest/gtest.h> | ||
|
||
TEST(capi, fizzy_validate) | ||
{ | ||
uint8_t wasm_prefix[]{0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00}; | ||
EXPECT_TRUE(fizzy_validate(wasm_prefix, sizeof(wasm_prefix))); | ||
wasm_prefix[7] = 1; | ||
EXPECT_FALSE(fizzy_validate(wasm_prefix, sizeof(wasm_prefix))); | ||
} |