Skip to content

Commit

Permalink
refactor: naming constants
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohammad.Sh committed Oct 1, 2024
1 parent 20e7214 commit 1b77d37
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion ctowasm/src/modules/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ export const voidDataType: VoidDataType = {
export const FOREIGN_OBJ_IDENTIFIER= 0xF0BA;

// Key to store the address of foreign objects in the object itself
export const SOURCE_C_IDENTIFIER = "_sourceCIdentifier";
export const SOURCE_C_IDENTIFIER_KEY = "_sourceCIdentifier";

export const NULL_PTR_ADR = 0;
6 changes: 3 additions & 3 deletions ctowasm/src/modules/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import BigNumber from "bignumber.js";
import { calculateNumberOfPagesNeededForBytes } from "~src/common/utils";
import { ModulesGlobalConfig, SharedWasmGlobalVariables } from "~src/modules";
import {mallocFunction} from "~src/modules/source_stdlib/memory";
import {FOREIGN_OBJ_IDENTIFIER, NULL_PTR_ADR, SOURCE_C_IDENTIFIER} from "~src/modules/constants";
import {FOREIGN_OBJ_IDENTIFIER, NULL_PTR_ADR, SOURCE_C_IDENTIFIER_KEY} from "~src/modules/constants";

// export function extractImportedFunctionCDetails(
// wasmModuleImports: Record<string, ImportedFunction>
Expand Down Expand Up @@ -137,14 +137,14 @@ export function storeObjectInMemoryAndRegistry(
objArr[i] = objIdentifier[i];
}

(obj as any)[SOURCE_C_IDENTIFIER] = address;
(obj as any)[SOURCE_C_IDENTIFIER_KEY] = address;
objectReferenceRegistry.set(address, obj);

return address;
}

export function getAddressOfRegisteredObj(obj: Object) {
return (obj as any)[SOURCE_C_IDENTIFIER];
return (obj as any)[SOURCE_C_IDENTIFIER_KEY];
}

/**
Expand Down

0 comments on commit 1b77d37

Please sign in to comment.