/** * Same as {@link #createBytes(IntSupplier)}, and additionally creates a symbol with the * provided name for the allocated bytes. */ public static <T extends PointerBase> CGlobalData<T> createBytes(IntSupplier sizeSupplier, String symbolName) { return new CGlobalDataImpl<>(symbolName, sizeSupplier); }
/** * Create a reference to the symbol with the specified name. Calling {@link CGlobalData#get()} * on the returned object at runtime returns the referenced symbol's address. */ public static <T extends PointerBase> CGlobalData<T> forSymbol(String symbolName) { return new CGlobalDataImpl<>(symbolName); }
/** * Same as {@link #createBytes(Supplier)}, and additionally creates a symbol with the provided * name for the allocated bytes. */ public static <T extends PointerBase> CGlobalData<T> createBytes(Supplier<byte[]> contentSupplier, String symbolName) { return new CGlobalDataImpl<>(symbolName, contentSupplier); }
/** * Same as {@link #createWord()}, and additionally creates a symbol with the provided name for * the allocated word. */ public static <T extends PointerBase> CGlobalData<T> createWord(String symbolName) { return new CGlobalDataImpl<>(symbolName, () -> ConfigurationValues.getTarget().wordSize); }
/** * Same as {@link #createCString(String)}, and additionally creates a symbol with the provided * name for the allocated string. */ public static <T extends PointerBase> CGlobalData<T> createCString(String content, String symbolName) { return new CGlobalDataImpl<>(symbolName, () -> Utf8.stringToUtf8(content, true)); }
/** * Same as {@link #createWord(WordBase)}, and additionally creates a symbol with the provided * name for the allocated word. */ public static <T extends PointerBase> CGlobalData<T> createWord(WordBase initialValue, String symbolName) { Supplier<byte[]> supplier = () -> { assert ConfigurationValues.getTarget().wordSize == Long.BYTES; return ByteBuffer.allocate(Long.BYTES).order(ByteOrder.nativeOrder()).putLong(initialValue.rawValue()).array(); }; return new CGlobalDataImpl<>(symbolName, supplier); }