Skip to content

Commit 4a49ba5

Browse files
committed
[WARP] Add network container
This is going to be disabled by default on this upcoming stable, however users may enable it once we deploy the public server. The data from the server is done through `Container::fetch_functions` independent of the nonblocking function lookup functions. The sidebar has been updated to drive fetching so that when users navigate to a new function the fetcher will kick off. This fetcher operates on a separate thread, in the event of a user navigating to many functions before the current fetch has completed they all will be batched together in a single fetch. Networked container currently is limited to just function prototypes, other type information separate from the function object will be omitted.
1 parent 9c80b72 commit 4a49ba5

File tree

17 files changed

+1777
-55
lines changed

17 files changed

+1777
-55
lines changed

Cargo.lock

Lines changed: 963 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plugins/warp/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ thiserror = "2.0"
2424
ar = { git = "https://github.com/mdsteele/rust-ar" }
2525
tempdir = "0.3.7"
2626
regex = "1.11"
27+
reqwest = { version = "0.12", features = ["blocking", "json", "multipart"] }
2728

2829
# For reports
2930
minijinja = "2.10.2"

plugins/warp/api/python/_warpcore.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,29 @@ def BNWARPContainerCommitSource(
204204
return _BNWARPContainerCommitSource(container, source)
205205

206206

207+
# -------------------------------------------------------
208+
# _BNWARPContainerFetchFunctions
209+
210+
_BNWARPContainerFetchFunctions = core.BNWARPContainerFetchFunctions
211+
_BNWARPContainerFetchFunctions.restype = None
212+
_BNWARPContainerFetchFunctions.argtypes = [
213+
ctypes.POINTER(BNWARPContainer),
214+
ctypes.POINTER(BNWARPTarget),
215+
ctypes.POINTER(BNWARPTypeGUID),
216+
ctypes.c_ulonglong,
217+
]
218+
219+
220+
# noinspection PyPep8Naming
221+
def BNWARPContainerFetchFunctions(
222+
container: ctypes.POINTER(BNWARPContainer),
223+
target: ctypes.POINTER(BNWARPTarget),
224+
guids: ctypes.POINTER(BNWARPTypeGUID),
225+
count: int
226+
) -> None:
227+
return _BNWARPContainerFetchFunctions(container, target, guids, count)
228+
229+
207230
# -------------------------------------------------------
208231
# _BNWARPContainerGetFunctionsWithGUID
209232

plugins/warp/api/python/warp.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,13 @@ def remove_types(self, source: Source, guids: List[TypeGUID]) -> bool:
305305
core_guids[i] = guids[i].uuid
306306
return warpcore.BNWARPContainerRemoveTypes(self.handle, source.uuid, core_guids, count)
307307

308+
def fetch_functions(self, target: WarpTarget, guids: List[FunctionGUID]):
309+
count = len(guids)
310+
core_guids = (warpcore.BNWARPFunctionGUID * count)()
311+
for i in range(count):
312+
core_guids[i] = guids[i].uuid
313+
warpcore.BNWARPContainerFetchFunctions(self.handle, target.handle, core_guids, count)
314+
308315
def get_sources_with_function_guid(self, target: WarpTarget, guid: FunctionGUID) -> List[Source]:
309316
count = ctypes.c_size_t()
310317
sources = warpcore.BNWARPContainerGetSourcesWithFunctionGUID(self.handle, target.handle, guid.uuid, count)

plugins/warp/api/warp.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,16 @@ bool Container::RemoveTypes(const Source &source, const std::vector<TypeGUID> &g
249249
return result;
250250
}
251251

252+
void Container::FetchFunctions(const Target &target, const std::vector<FunctionGUID> &guids) const
253+
{
254+
size_t count = guids.size();
255+
BNWARPFunctionGUID *apiGuids = new BNWARPFunctionGUID[count];
256+
for (size_t i = 0; i < count; i++)
257+
apiGuids[i] = *guids[i].Raw();
258+
BNWARPContainerFetchFunctions(m_object, target.m_object, apiGuids, count);
259+
delete[] apiGuids;
260+
}
261+
252262
std::vector<Source> Container::GetSourcesWithFunctionGUID(const Target& target, const FunctionGUID &guid) const
253263
{
254264
size_t count;

plugins/warp/api/warp.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,8 @@ namespace Warp {
354354

355355
bool RemoveTypes(const Source &source, const std::vector<TypeGUID> &guids) const;
356356

357+
void FetchFunctions(const Target& target, const std::vector<FunctionGUID> &guids) const;
358+
357359
std::vector<Source> GetSourcesWithFunctionGUID(const Target& target, const FunctionGUID &guid) const;
358360

359361
std::vector<Source> GetSourcesWithTypeGUID(const TypeGUID &guid) const;

plugins/warp/api/warpcore.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ extern "C"
108108
WARP_FFI_API bool BNWARPContainerRemoveFunctions(BNWARPContainer* container, const BNWARPTarget* target, const BNWARPSource* source, BNWARPFunction** functions, size_t count);
109109
WARP_FFI_API bool BNWARPContainerRemoveTypes(BNWARPContainer* container, const BNWARPSource* source, BNWARPTypeGUID* types, size_t count);
110110

111+
WARP_FFI_API void BNWARPContainerFetchFunctions(BNWARPContainer* container, BNWARPTarget* target, const BNWARPTypeGUID* guids, size_t count);
112+
111113
WARP_FFI_API BNWARPSource* BNWARPContainerGetSourcesWithFunctionGUID(BNWARPContainer* container, const BNWARPTarget* target, const BNWARPFunctionGUID* guid, size_t* count);
112114
WARP_FFI_API BNWARPSource* BNWARPContainerGetSourcesWithTypeGUID(BNWARPContainer* container, const BNWARPTypeGUID* guid, size_t* count);
113115
WARP_FFI_API BNWARPFunction** BNWARPContainerGetFunctionsWithGUID(BNWARPContainer* container, const BNWARPTarget* target, const BNWARPSource* source, const BNWARPFunctionGUID* guid, size_t* count);

plugins/warp/src/container.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,19 @@ pub trait Container: Send + Sync + Display + Debug {
208208
functions: &[Function],
209209
) -> ContainerResult<()>;
210210

211+
/// Fetches WARP information for the associated functions.
212+
///
213+
/// Typically, a container that resides only in memory has nothing to fetch, so the default implementation
214+
/// will do nothing. This function is blocking, so assume it will take a few seconds for a container
215+
/// that intends to fetch over the network.
216+
fn fetch_functions(
217+
&mut self,
218+
_target: &Target,
219+
_functions: &[FunctionGUID],
220+
) -> ContainerResult<()> {
221+
Ok(())
222+
}
223+
211224
/// Get the sources that contain a type with the given [`TypeGUID`].
212225
fn sources_with_type_guid(&self, guid: &TypeGUID) -> ContainerResult<Vec<SourceId>>;
213226

0 commit comments

Comments
 (0)