1 #include "libs/Kernel.h"
2 #include "PublicData.h"
3 #include "PublicDataRequest.h"
5 bool PublicData::get_value(uint16_t csa
, uint16_t csb
, uint16_t csc
, void *data
) {
6 PublicDataRequest
pdr(csa
, csb
, csc
);
7 // the caller may have created the storage for the returned data so we clear the flag,
8 // if it gets set by the callee setting the data ptr that means the data is a pointer to a pointer and is set to a pointer to the returned data
9 pdr
.set_data_ptr(data
, false);
10 THEKERNEL
->call_event(ON_GET_PUBLIC_DATA
, &pdr
);
11 if(pdr
.is_taken() && pdr
.has_returned_data()) {
12 // the callee set the returned data pointer
13 *(void**)data
= pdr
.get_data_ptr();
15 return pdr
.is_taken();
18 bool PublicData::set_value(uint16_t csa
, uint16_t csb
, uint16_t csc
, void *data
) {
19 PublicDataRequest
pdr(csa
, csb
, csc
);
20 pdr
.set_data_ptr(data
);
21 THEKERNEL
->call_event(ON_SET_PUBLIC_DATA
, &pdr
);
22 return pdr
.is_taken();