-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Lots of refs, cesium-nebula, seperation of concerns, condensation of …
…related items
- Loading branch information
Showing
49 changed files
with
493 additions
and
687 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
54 changes: 27 additions & 27 deletions
54
contracts/nomisma-c/contract.c → contracts/example-c/contract.c
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 |
---|---|---|
@@ -1,27 +1,27 @@ | ||
#include <stdio.h> | ||
#include <stdint.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
#include "convert.h" | ||
|
||
__attribute__((import_module("env"), import_name("h_gen_id"))) | ||
extern int64_t h_gen_id(); | ||
|
||
int32_t initialize() { | ||
return 0; | ||
} | ||
|
||
int32_t create() { | ||
int64_t big_ptr = h_gen_id(); | ||
|
||
// Get the pointer and length from the combined value | ||
const uint8_t *ptr; | ||
size_t length; | ||
|
||
unfold_ptr(big_ptr, &ptr, &length); | ||
|
||
// Get the char* from the pointer | ||
const char *str = (const char *)ptr; | ||
|
||
return 0; | ||
} | ||
#include <stdio.h> | ||
#include <stdint.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
#include "convert.h" | ||
|
||
__attribute__((import_module("env"), import_name("h_gen_id"))) | ||
extern int64_t h_gen_id(); | ||
|
||
int32_t initialize() { | ||
return 0; | ||
} | ||
|
||
int32_t create() { | ||
int64_t big_ptr = h_gen_id(); | ||
|
||
// Get the pointer and length from the combined value | ||
const uint8_t *ptr; | ||
size_t length; | ||
|
||
unfold_ptr(big_ptr, &ptr, &length); | ||
|
||
// Get the char* from the pointer | ||
const char *str = (const char *)ptr; | ||
|
||
return 0; | ||
} |
26 changes: 13 additions & 13 deletions
26
contracts/nomisma-c/convert.c → contracts/example-c/convert.c
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 |
---|---|---|
@@ -1,13 +1,13 @@ | ||
#include "convert.h" | ||
|
||
void unfold_ptr(int64_t combined, const uint8_t **ptr, size_t *length) { | ||
*length = (size_t)(combined >> 32); // Extract length from the upper 32 bits | ||
*ptr = (const uint8_t *)(uintptr_t)(combined & 0xFFFFFFFF); // Extract pointer from the lower 32 bits | ||
} | ||
|
||
void unfold_ptrs(__int128 encoded, UnfoldedPtrs *result) { | ||
result->ptr1 = (uint32_t)(encoded & 0xFFFFFFFF); // Extract ptr1 | ||
result->len1 = (uint32_t)((encoded >> 32) & 0xFFFFFFFF); // Extract len1 | ||
result->ptr2 = (uint32_t)((encoded >> 64) & 0xFFFFFFFF); // Extract ptr2 | ||
result->len2 = (uint32_t)((encoded >> 96) & 0xFFFFFFFF); // Extract len2 | ||
} | ||
#include "convert.h" | ||
|
||
void unfold_ptr(int64_t combined, const uint8_t **ptr, size_t *length) { | ||
*length = (size_t)(combined >> 32); // Extract length from the upper 32 bits | ||
*ptr = (const uint8_t *)(uintptr_t)(combined & 0xFFFFFFFF); // Extract pointer from the lower 32 bits | ||
} | ||
|
||
void unfold_ptrs(__int128 encoded, UnfoldedPtrs *result) { | ||
result->ptr1 = (uint32_t)(encoded & 0xFFFFFFFF); // Extract ptr1 | ||
result->len1 = (uint32_t)((encoded >> 32) & 0xFFFFFFFF); // Extract len1 | ||
result->ptr2 = (uint32_t)((encoded >> 64) & 0xFFFFFFFF); // Extract ptr2 | ||
result->len2 = (uint32_t)((encoded >> 96) & 0xFFFFFFFF); // Extract len2 | ||
} |
44 changes: 22 additions & 22 deletions
44
contracts/nomisma-c/convert.h → contracts/example-c/convert.h
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 |
---|---|---|
@@ -1,22 +1,22 @@ | ||
// convert.h | ||
#ifndef CONVERT_H | ||
#define CONVERT_H | ||
|
||
#include <stdint.h> | ||
#include <stddef.h> | ||
|
||
// Struct to hold the unpacked values for `unfold_ptrs` | ||
typedef struct { | ||
uint32_t ptr1; | ||
uint32_t len1; | ||
uint32_t ptr2; | ||
uint32_t len2; | ||
} UnfoldedPtrs; | ||
|
||
// Function to unpack a 64-bit integer into a pointer and length | ||
void unfold_ptr(int64_t combined, const uint8_t **ptr, size_t *length); | ||
|
||
// Function to unpack a 128-bit integer into four 32-bit values | ||
void unfold_ptrs(__int128 encoded, UnfoldedPtrs *result); | ||
|
||
#endif // CONVERT_H | ||
// convert.h | ||
#ifndef CONVERT_H | ||
#define CONVERT_H | ||
|
||
#include <stdint.h> | ||
#include <stddef.h> | ||
|
||
// Struct to hold the unpacked values for `unfold_ptrs` | ||
typedef struct { | ||
uint32_t ptr1; | ||
uint32_t len1; | ||
uint32_t ptr2; | ||
uint32_t len2; | ||
} UnfoldedPtrs; | ||
|
||
// Function to unpack a 64-bit integer into a pointer and length | ||
void unfold_ptr(int64_t combined, const uint8_t **ptr, size_t *length); | ||
|
||
// Function to unpack a 128-bit integer into four 32-bit values | ||
void unfold_ptrs(__int128 encoded, UnfoldedPtrs *result); | ||
|
||
#endif // CONVERT_H |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.