Skip to content

Commit

Permalink
genimport: annotate code with propid_t/proptag_t types
Browse files Browse the repository at this point in the history
  • Loading branch information
jengelh committed Oct 24, 2024
1 parent 5cb1b50 commit fd4adec
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
10 changes: 7 additions & 3 deletions doc/mtformat.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,13 @@ All integers are to be in little-endian form.
Number of entries in the NP map
* Repeat *np_entries* times:
* ``uint32_t proptag;``
The named property's assigned proptag for the MT stream.
The high 16 bits convey the propid, the low 16 bits can be
ignored.
The named property's assigned proptag for the MT stream. The
high 16 bits convey the propid, the low 16 bits the proptype.
An MT writer may emit PT_UNSPECIFIED for the proptype to
signal that an MT reader shall mask/disregard proptypes
during propid-to-propid remapping. If an MT writer emits any
other proptype, the MT reader should only do propid-to-propid
translations if the proptype matches.
* PROPERTY_NAME serialized struct

The remainder of the stream is a set of "instructions" (so to speak) to mt2exm
Expand Down
4 changes: 2 additions & 2 deletions tools/genimport.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ struct gi_delete : public gromox::stdlib_delete {
inline void operator()(TARRAY_SET *x) const { tarray_set_free(x); }
};

using gi_name_map = std::unordered_map<uint32_t, PROPERTY_XNAME>;
using gi_name_map = std::unordered_map<gromox::proptag_t, PROPERTY_XNAME>;
struct namedprop_bimap;

struct parent_desc {
Expand Down Expand Up @@ -98,7 +98,7 @@ extern void gi_folder_map_read(const void *, size_t, gi_folder_map_t &);
extern void gi_folder_map_write(const gi_folder_map_t &);
extern void gi_name_map_read(const void *, size_t, gi_name_map &);
extern void gi_name_map_write(const gi_name_map &);
extern uint16_t gi_resolve_namedprop(const PROPERTY_XNAME &);
extern gromox::propid_t gi_resolve_namedprop(const PROPERTY_XNAME &);
extern int exm_set_change_keys(TPROPVAL_ARRAY *props, eid_t cn);
extern int exm_create_folder(uint64_t parent_fld, TPROPVAL_ARRAY *props, bool o_excl, uint64_t *new_fld_id);
extern int exm_permissions(eid_t, const std::vector<PERMISSION_DATA> &);
Expand Down
17 changes: 9 additions & 8 deletions tools/staticnpmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,17 @@

struct namedprop_bimap {
public:
uint16_t emplace(uint16_t, PROPERTY_XNAME &&);
gromox::propid_t emplace(gromox::propid_t, PROPERTY_XNAME &&);

gi_name_map fwd; /* note this is uint32_t -> */
std::unordered_map<std::string, uint16_t> rev;
uint16_t nextid = 0x8000;
gi_name_map fwd;
std::unordered_map<std::string, gromox::propid_t> rev;
gromox::propid_t nextid = 0x8000;
};

static struct namedprop_bimap static_namedprop_map;

uint16_t namedprop_bimap::emplace(uint16_t desired_propid, PROPERTY_XNAME &&name)
gromox::propid_t namedprop_bimap::emplace(gromox::propid_t desired_propid,
PROPERTY_XNAME &&name)
{
if (desired_propid == 0)
desired_propid = nextid;
Expand All @@ -39,7 +40,7 @@ uint16_t namedprop_bimap::emplace(uint16_t desired_propid, PROPERTY_XNAME &&name
if (!newly_added)
return iter->second;
fwd.emplace(PROP_TAG(PT_UNSPECIFIED, desired_propid), std::move(name));
nextid = std::max(nextid, static_cast<uint16_t>(desired_propid + 1));
nextid = std::max(nextid, static_cast<gromox::propid_t>(desired_propid + 1));
return desired_propid;
}

Expand All @@ -55,8 +56,8 @@ static BOOL ee_get_propids(const PROPNAME_ARRAY *names, PROPID_ARRAY *ids) try
return false;
}

static const PROPERTY_XNAME *ee_get_propname(uint16_t) __attribute__((unused));
static const PROPERTY_XNAME *ee_get_propname(uint16_t propid)
static const PROPERTY_XNAME *ee_get_propname(gromox::propid_t) __attribute__((unused));
static const PROPERTY_XNAME *ee_get_propname(gromox::propid_t propid)
{
auto i = static_namedprop_map.fwd.find(propid);
return i != static_namedprop_map.fwd.end() ? &i->second : nullptr;
Expand Down

0 comments on commit fd4adec

Please sign in to comment.