From 017349bdbe171c66974a5835f2f74f76138386ea Mon Sep 17 00:00:00 2001 From: Mason Reed <35282038+emesare@users.noreply.github.com> Date: Sun, 22 Feb 2026 20:40:28 -0800 Subject: [WARP] Allow containers to be constructed programmatically (#7952) --- plugins/warp/api/python/warp.py | 7 +++++++ plugins/warp/api/warp.cpp | 8 ++++++++ plugins/warp/api/warp.h | 3 +++ plugins/warp/api/warpcore.h | 1 + 4 files changed, 19 insertions(+) (limited to 'plugins/warp/api') diff --git a/plugins/warp/api/python/warp.py b/plugins/warp/api/python/warp.py index fc487a4d..a699ebbc 100644 --- a/plugins/warp/api/python/warp.py +++ b/plugins/warp/api/python/warp.py @@ -350,6 +350,13 @@ class WarpContainer(metaclass=_WarpContainerMetaclass): warpcore.BNWARPFreeContainerList(containers, count.value) return result + @staticmethod + def add(name: str) -> 'WarpContainer': + container = warpcore.BNWARPAddContainer(name) + if container is None: + raise ValueError(f"Failed to add container: {name}") + return WarpContainer(container) + @staticmethod def by_name(name: str) -> Optional['WarpContainer']: for container in WarpContainer: diff --git a/plugins/warp/api/warp.cpp b/plugins/warp/api/warp.cpp index f6106605..c051e3c7 100644 --- a/plugins/warp/api/warp.cpp +++ b/plugins/warp/api/warp.cpp @@ -246,6 +246,14 @@ std::vector > Container::All() return result; } +Ref Container::Add(const std::string &name) +{ + BNWARPContainer *result = BNWARPAddContainer(name.c_str()); + if (!result) + return nullptr; + return new Container(result); +} + std::string Container::GetName() const { char *rawName = BNWARPContainerGetName(m_object); diff --git a/plugins/warp/api/warp.h b/plugins/warp/api/warp.h index 14be9a0d..01f4aaee 100644 --- a/plugins/warp/api/warp.h +++ b/plugins/warp/api/warp.h @@ -381,6 +381,9 @@ namespace Warp { /// Retrieve all available containers. static std::vector > All(); + /// Add a new container with the given name. + static Ref Add(const std::string &name); + std::string GetName() const; std::vector GetSources() const; diff --git a/plugins/warp/api/warpcore.h b/plugins/warp/api/warpcore.h index 633ffcbf..c52485aa 100644 --- a/plugins/warp/api/warpcore.h +++ b/plugins/warp/api/warpcore.h @@ -111,6 +111,7 @@ extern "C" WARP_FFI_API BNWARPFunction* BNWARPGetFunction(BNFunction* analysisFunction); WARP_FFI_API BNWARPFunction* BNWARPGetMatchedFunction(BNFunction* analysisFunction); WARP_FFI_API BNWARPContainer** BNWARPGetContainers(size_t* count); + WARP_FFI_API BNWARPContainer* BNWARPAddContainer(const char* name); WARP_FFI_API char* BNWARPContainerGetName(BNWARPContainer* container); -- cgit v1.3.1