[SAMBA4] ldb_map changes required to support "foreign" languages

Martin Kühl mkhl at samba.org
Thu Aug 10 21:29:25 GMT 2006

One of my plans with the ldb_map module is to support defining
mappings in "foreign" (i.e. not C) languages; I'm assuming JavaScript
as the target language in this mail.  A problem with this is that the
ldb_map api requires C functions to perform conversion of values and
elements, and I haven't found a way to auto-generate a C function from
a JavaScript function object.

The solution I came up with is to define a single C function that
dispatches to the correct JavaScript function.  However, this function
needs additional info to determine _which_ mapping to dispatch to --
this information is implicit when there's exactly one conversion
function per mapping.

Possible ways to dispatch to the correct mapping are:

1) The caller module (i.e. the module that sets up mappings and calls
   `ldb_map_init' for initialization) holds two structures to map from
   local and remote name (respectively) to objects in the target
   language that contain the conversion logic.
   The conversion dispatcher function would require the local/remote
   name of the mapping to be passed in.

2) The mapping (i.e. the `ldb_map_attribute' structure) is augmented
   to hold a pointer to private data; the caller module takes care of
   pointing it to an object in the target languages that contains the
   conversion logic.
   The conversion dispatcher function would require the private data
   pointer of the mapping to be passed in.

The dispatcher function could also be passed a pointer to the mapping
structure, leaving it up to the caller module to decide on a method of
dispatch; this would still require private data stored in each
mapping, however, to support dispatch on anything but the name.

The attached patch demonstrates an implementation of approach 1) in my
version of the ldb_map module and in the calling samba3sam module.
The increased flexibility lets me lean towards approach 2) now though.

Comments on this are very welcome.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: ldb_map-pass_attribute_names.patch
Type: text/x-patch
Size: 7425 bytes
Desc: not available
Url : http://lists.samba.org/archive/samba-technical/attachments/20060810/0318576a/ldb_map-pass_attribute_names.bin

More information about the samba-technical mailing list