C API Discussion - abroekhuis/NativeOSGi GitHub Wiki

This page details the progress of porting the OSGi Java API to C. The listing follows chapter 6 in OSGi Service Platform Core Specification Version 4.2. (Note: what version(s) do we want to support? What are the API differences?).

Mapping

Simply mapping a Java API to C is not possible. This is related to the lack of namespaces in C. The following scheme shows how the C API is mapped to Java:

/**
 * int: return type for the status code, as a replacement for exceptions.
 * 
 * typeName: name of the object/type this function is part of.
 * functionName: the name of the function.
 * 
 * typeName_t: The actual instance to "invoke" this function on, 
 *   by conventions types end with _t. This must be compared to 
 *   the actual instance in Java.
 * parameters: default function parameters
 * output parameters: the output which the caller can use to 
 *   get the output. This must be compared to the return type/value 
 *   in the Java API.
 */
celix_status_t typeName_functionName([typeName_t instance, ][parameters, ]
     [output parameters]);

Framework API Progress:

  • AdminPermission
  • AllServiceListener
  • Bundle -> Complete
  • BundleActivator -> Complete
  • BundleContext -> Complete
  • BundleEvent -> Complete
  • BundleException -> Complete (as listing in nosgi_errno.h)
  • BundleListener -> Complete
  • BundlePermission
  • BundleReference
  • Configurable
  • Constants -> Partial
  • Filter -> Complete
  • FrameworkEvent -> Complete
  • FrameworkListener -> Complete
  • FrameworkUtil
  • InvalidSyntaxException -> Complete (in nosgi_errno.h)
  • PackagePermission
  • ServiceEvent -> Complete
  • ServiceException -> Complete (in nosgi_errno.h)
  • ServiceFactory -> Complete
  • ServiceListener -> Complete
  • ServicePermission
  • ServiceReference -> Complete
  • ServiceRegistration -> Complete (Note: In Celix I had to change the behaviour. SR has a list of references, instead of only one. This is needed to be able to delete "unget"ted services.)
  • SynchronousBundleListener
  • Version -> Completed the header, need to copy the implementation from Celix.