From: Soemin Tjong Date: Fri, 3 Mar 2017 08:13:17 +0000 (-0800) Subject: Define OC_CALL (call convention for public APIs). X-Git-Tag: 1.3.0~80 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f300165df9bc54d547ad6aae2472bbb68c20c45e;p=platform%2Fupstream%2Fiotivity.git Define OC_CALL (call convention for public APIs). Set to __stdcall for WIN32. Add to IPCA public APIs. Other public APIs will be updated in separate commit. Change-Id: I3201b7088eeb2227d2681847d20172825fbf4cae Signed-off-by: Soemin Tjong Reviewed-on: https://gerrit.iotivity.org/gerrit/18169 Tested-by: jenkins-iotivity Reviewed-by: Dan Mihai Reviewed-by: Way Vadhanasin Reviewed-by: Mike Fenelon Reviewed-by: Dave Thaler Reviewed-on: https://gerrit.iotivity.org/gerrit/18847 --- diff --git a/resource/IPCA/inc/ipca.h b/resource/IPCA/inc/ipca.h index 98f479d3b..a4169c691 100644 --- a/resource/IPCA/inc/ipca.h +++ b/resource/IPCA/inc/ipca.h @@ -98,6 +98,19 @@ extern "C" { * + Property ("x.oem.DisplayBackground", type: string, access: read-write) */ +#ifdef OC_CALL +# define IPCA_CALL OC_CALL +#else +# ifdef _WIN32 + /* + * Set to __stdcall for Windows, consistent with WIN32 APIs. + */ +# define IPCA_CALL __stdcall +# else +# define IPCA_CALL +# endif +#endif + /** * Handle types returned by IPCA. */ @@ -112,13 +125,6 @@ struct IPCAUuid uint8_t uuid[16]; }; -// @todo: determine if this needs to map to __stdcall. -// On x86 this causes the following run time failure. -// "Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call. -// This is usually a result of calling a function declared with one calling convention with a -// function pointer declared with a different calling convention." -#define IPCA_CALL - /** * Some information about the device from device discovery. * Use IPCAGetDeviceInfo() for detailed device information. @@ -302,9 +308,10 @@ typedef enum * Use IPCAPropertyBag APIs to retrieve the values indexed by keys. * propertyBagHandle is only valid during this callback. */ -typedef void (IPCA_CALL *IPCAResourceChangeCallback)(IPCAStatus result, - void* context, - IPCAPropertyBagHandle propertyBagHandle); +typedef void (IPCA_CALL *IPCAResourceChangeCallback)( + IPCAStatus result, + void* context, + IPCAPropertyBagHandle propertyBagHandle); /** * Callback from IPCA to application when device responds to IPCAGetProperties(). @@ -315,9 +322,10 @@ typedef void (IPCA_CALL *IPCAResourceChangeCallback)(IPCAStatus result, * Use IPCAPropertyBag APIs to retrieve the values indexed by keys. * propertyBagHandle is only valid during this callback. */ -typedef void (IPCA_CALL *IPCAGetPropertiesComplete)(IPCAStatus result, - void* context, - IPCAPropertyBagHandle propertyBagHandle); +typedef void (IPCA_CALL *IPCAGetPropertiesComplete)( + IPCAStatus result, + void* context, + IPCAPropertyBagHandle propertyBagHandle); /** * Callback from IPCA to application when device responds to IPCASetProperties(). * @@ -327,9 +335,10 @@ typedef void (IPCA_CALL *IPCAGetPropertiesComplete)(IPCAStatus result, * Use IPCAPropertyBag APIs to retrieve the values indexed by keys. * propertyBagHandle is only valid during this callback. */ -typedef void (IPCA_CALL *IPCASetPropertiesComplete)(IPCAStatus result, - void* context, - IPCAPropertyBagHandle propertyBagHandle); +typedef void (IPCA_CALL *IPCASetPropertiesComplete)( + IPCAStatus result, + void* context, + IPCAPropertyBagHandle propertyBagHandle); /** * Callback from IPCA to application when device responds to IPCACreateResource(). @@ -342,10 +351,11 @@ typedef void (IPCA_CALL *IPCASetPropertiesComplete)(IPCAStatus result, * propertyBagHandle is only valid during this callback. * */ -typedef void (IPCA_CALL *IPCACreateResourceComplete)(IPCAStatus result, - void* context, - const char* newResourcePath, - IPCAPropertyBagHandle propertyBagHandle); +typedef void (IPCA_CALL *IPCACreateResourceComplete)( + IPCAStatus result, + void* context, + const char* newResourcePath, + IPCAPropertyBagHandle propertyBagHandle); /** * Callback from IPCA to application when device responds to IPCADeleteResource(). @@ -386,9 +396,9 @@ typedef enum */ typedef void (IPCA_CALL *IPCADiscoverDeviceCallback)( - void* context, - IPCADeviceStatus deviceStatus, - const IPCADiscoveredDeviceInfo* discoveredDeviceInfo); + void* context, + IPCADeviceStatus deviceStatus, + const IPCADiscoveredDeviceInfo* discoveredDeviceInfo); /** * An application calls this method one time to register with IPCA. @@ -399,9 +409,10 @@ typedef void (IPCA_CALL *IPCADiscoverDeviceCallback)( * * @return IPCA_OK if successful. */ -IPCAStatus IPCA_CALL IPCAOpen(const IPCAAppInfo* ipcaAppInfo, - IPCAVersion ipcaVersion, - IPCAAppHandle* ipcaAppHandle); +IPCAStatus IPCA_CALL IPCAOpen( + const IPCAAppInfo* ipcaAppInfo, + IPCAVersion ipcaVersion, + IPCAAppHandle* ipcaAppHandle); /** * Close the handle returned in IPCAOpen(). @@ -432,12 +443,13 @@ void IPCA_CALL IPCAClose(IPCAAppHandle ipcaAppHandle); * * @return IPCA_OK if successful. */ -IPCAStatus IPCA_CALL IPCADiscoverDevices(IPCAAppHandle ipcaAppHandle, - IPCADiscoverDeviceCallback discoverDeviceCallback, - void* context, - const char* const* resourceTypeList, - int resourceTypeCount, - IPCAHandle* handle); +IPCAStatus IPCA_CALL IPCADiscoverDevices( + IPCAAppHandle ipcaAppHandle, + IPCADiscoverDeviceCallback discoverDeviceCallback, + void* context, + const char* const* resourceTypeList, + int resourceTypeCount, + IPCAHandle* handle); /** * Application indicates to IPCA the intention to start working with a device whose ID matches @@ -450,9 +462,10 @@ IPCAStatus IPCA_CALL IPCADiscoverDevices(IPCAAppHandle ipcaAppHandle, * @return IPCA_OK if successful. IPCA_DEVICE_NOT_DISCOVERED if device is not yet discovered, call * IPCADiscoverDevices(). */ -IPCAStatus IPCA_CALL IPCAOpenDevice(IPCAAppHandle ipcaAppHandle, - const char* deviceId, - IPCADeviceHandle* deviceHandle); +IPCAStatus IPCA_CALL IPCAOpenDevice( + IPCAAppHandle ipcaAppHandle, + const char* deviceId, + IPCADeviceHandle* deviceHandle); /** * Closes device handle. The application will stop receiving notifications and callbacks from the @@ -474,14 +487,14 @@ void IPCA_CALL IPCACloseDevice(IPCADeviceHandle deviceHandle); * IPCA_INFORMATION_NOT_AVAILABLE if server has not returned the device info query. * IPCA_INFO_VERSION_NOT_SUPPORTED when requested info version is not supported. */ -IPCAStatus IPCAGetDeviceInfo(IPCADeviceHandle deviceHandle, IPCADeviceInfo** deviceInfo); +IPCAStatus IPCA_CALL IPCAGetDeviceInfo(IPCADeviceHandle deviceHandle, IPCADeviceInfo** deviceInfo); /** * Free the memory allocated in IPCAGetDeviceInfo(). * * @param[in] deviceInfo a Pointer to IPCADeviceInfo structure returned in IPCAGetDeviceInfo(). */ -void IPCAFreeDeviceInfo(IPCADeviceInfo* deviceInfo); +void IPCA_CALL IPCAFreeDeviceInfo(IPCADeviceInfo* deviceInfo); /** * This method returns a pointer to IPCAPlatformInfo structure. @@ -495,7 +508,9 @@ void IPCAFreeDeviceInfo(IPCADeviceInfo* deviceInfo); * IPCA_INFORMATION_NOT_AVAILABLE if server has not returned the platform info query. * IPCA_INFO_VERSION_NOT_SUPPORTED when requested info version is not supported. */ -IPCAStatus IPCAGetPlatformInfo(IPCADeviceHandle deviceHandle, IPCAPlatformInfo** platformInfo); +IPCAStatus IPCA_CALL IPCAGetPlatformInfo( + IPCADeviceHandle deviceHandle, + IPCAPlatformInfo** platformInfo); /** * Free the memory allocated in IPCAGetPlatformInfo(). @@ -503,7 +518,7 @@ IPCAStatus IPCAGetPlatformInfo(IPCADeviceHandle deviceHandle, IPCAPlatformInfo** * @param[in] platformInfo A pointer to IPCAPlatformInfo structure returned * in IPCAGetPlatformInfo(). */ -void IPCAFreePlatformInfo(IPCAPlatformInfo* platformInfo); +void IPCA_CALL IPCAFreePlatformInfo(IPCAPlatformInfo* platformInfo); /** * Get the resources that implement resource types in IPCADiscoverDevices(). @@ -520,11 +535,12 @@ void IPCAFreePlatformInfo(IPCAPlatformInfo* platformInfo); * * @return IPCA_OK if successful. */ -IPCAStatus IPCA_CALL IPCAGetResources(IPCADeviceHandle deviceHandle, - const char* resourceInterface, - const char* resourceType, - char*** resourcePathList, - size_t* resourcePathCount); +IPCAStatus IPCA_CALL IPCAGetResources( + IPCADeviceHandle deviceHandle, + const char* resourceInterface, + const char* resourceType, + char*** resourcePathList, + size_t* resourcePathCount); /** * Get the list of resource types implemented by a resource. @@ -539,10 +555,11 @@ IPCAStatus IPCA_CALL IPCAGetResources(IPCADeviceHandle deviceHandle, * * @return IPCA_OK if successful. */ -IPCAStatus IPCA_CALL IPCAGetResourceTypes(IPCADeviceHandle deviceHandle, - const char* resourcePath, - char*** resourceTypeList, - size_t* resourceTypeCount); +IPCAStatus IPCA_CALL IPCAGetResourceTypes( + IPCADeviceHandle deviceHandle, + const char* resourcePath, + char*** resourceTypeList, + size_t* resourceTypeCount); /** * Get the list of resource interfaces implemented by a resource. @@ -558,10 +575,11 @@ IPCAStatus IPCA_CALL IPCAGetResourceTypes(IPCADeviceHandle deviceHandle, * * @return IPCA_OK if successful. */ -IPCAStatus IPCA_CALL IPCAGetResourceInterfaces(IPCADeviceHandle deviceHandle, - const char* resourcePath, - char*** resourceInterfaceList, - size_t* resourceInterfaceCount); +IPCAStatus IPCA_CALL IPCAGetResourceInterfaces( + IPCADeviceHandle deviceHandle, + const char* resourcePath, + char*** resourceInterfaceList, + size_t* resourceInterfaceCount); /** * Free string array returned in IPCAGetResources(), IPCAGetResourceTypes(), @@ -594,13 +612,14 @@ void IPCA_CALL IPCAFreeStringArray(char** stringArray, size_t stringCount); * * @return IPCA_OK if successful. IPCA calls getPropertiesComplete() when device responds. */ -IPCAStatus IPCA_CALL IPCAGetProperties(IPCADeviceHandle deviceHandle, - IPCAGetPropertiesComplete getPropertiesComplete, - void* context, - const char* resourcePath, - const char* resourceInterface, - const char* resourceType, - IPCAHandle* handle); +IPCAStatus IPCA_CALL IPCAGetProperties( + IPCADeviceHandle deviceHandle, + IPCAGetPropertiesComplete getPropertiesComplete, + void* context, + const char* resourcePath, + const char* resourceInterface, + const char* resourceType, + IPCAHandle* handle); /** * Set property values of a resource. @@ -625,14 +644,15 @@ IPCAStatus IPCA_CALL IPCAGetProperties(IPCADeviceHandle deviceHandle, * * @return IPCA_OK if successful. IPCA calls setPropertiesComplete() when device reponds. */ -IPCAStatus IPCA_CALL IPCASetProperties(IPCADeviceHandle deviceHandle, - IPCASetPropertiesComplete setPropertiesComplete, - void* context, - const char* resourcePath, - const char* resourceInterface, - const char* resourceType, - IPCAPropertyBagHandle propertyBagHandle, - IPCAHandle* handle); +IPCAStatus IPCA_CALL IPCASetProperties( + IPCADeviceHandle deviceHandle, + IPCASetPropertiesComplete setPropertiesComplete, + void* context, + const char* resourcePath, + const char* resourceInterface, + const char* resourceType, + IPCAPropertyBagHandle propertyBagHandle, + IPCAHandle* handle); /** * Request device to create a new resource. @@ -656,14 +676,15 @@ IPCAStatus IPCA_CALL IPCASetProperties(IPCADeviceHandle deviceHandle, * * @return IPCA_OK if successful. IPCA calls createResourceComplete() when device reponds. */ -IPCAStatus IPCA_CALL IPCACreateResource(IPCADeviceHandle deviceHandle, - IPCACreateResourceComplete createResourceComplete, - void* context, - const char* resourceCollectionPath, - const char* resourceInterface, - const char* resourceType, - IPCAPropertyBagHandle propertyBagHandle, - IPCAHandle* handle); +IPCAStatus IPCA_CALL IPCACreateResource( + IPCADeviceHandle deviceHandle, + IPCACreateResourceComplete createResourceComplete, + void* context, + const char* resourceCollectionPath, + const char* resourceInterface, + const char* resourceType, + IPCAPropertyBagHandle propertyBagHandle, + IPCAHandle* handle); /** * Request device to delete a resource. @@ -684,11 +705,12 @@ IPCAStatus IPCA_CALL IPCACreateResource(IPCADeviceHandle deviceHandle, * @return IPCA_OK if successful. IPCA calls deleteResourceComplete() when device reponds. */ -IPCAStatus IPCA_CALL IPCADeleteResource(IPCADeviceHandle deviceHandle, - IPCADeleteResourceComplete deleteResourceComplete, - void* context, - const char* resourcePath, - IPCAHandle* handle); +IPCAStatus IPCA_CALL IPCADeleteResource( + IPCADeviceHandle deviceHandle, + IPCADeleteResourceComplete deleteResourceComplete, + void* context, + const char* resourcePath, + IPCAHandle* handle); /** * Function returns whether a resource is observable. @@ -699,9 +721,10 @@ IPCAStatus IPCA_CALL IPCADeleteResource(IPCADeviceHandle deviceHandle, * * @return IPCA_OK if successful. */ -void IPCA_CALL IPCAIsResourceObservable(IPCADeviceHandle deviceHandle, - const char* resourcePath, - bool* isObservable); +void IPCA_CALL IPCAIsResourceObservable( + IPCADeviceHandle deviceHandle, + const char* resourcePath, + bool* isObservable); /** * Function to start observing a resource. Use IPCACloseHandle() to stop receiving resource change @@ -722,12 +745,13 @@ void IPCA_CALL IPCAIsResourceObservable(IPCADeviceHandle deviceHandle, * @return IPCA_OK if successful. IPCA calls resourceChangeCallback() when device sends * notifications. */ -IPCAStatus IPCA_CALL IPCAObserveResource(IPCADeviceHandle deviceHandle, - IPCAResourceChangeCallback resourceChangeCallback, - void* context, - const char* resourcePath, - const char* resourceType, - IPCAHandle* handle); +IPCAStatus IPCA_CALL IPCAObserveResource( + IPCADeviceHandle deviceHandle, + IPCAResourceChangeCallback resourceChangeCallback, + void* context, + const char* resourcePath, + const char* resourceType, + IPCAHandle* handle); /** * Stop receiving callbacks for the handle. @@ -778,7 +802,7 @@ IPCAStatus IPCA_CALL IPCAReboot(IPCADeviceHandle deviceHandle); * * @return IPCA_OK if successful. */ -IPCAStatus IPCAPropertyBagCreate(IPCAPropertyBagHandle* propertyBagHandle); +IPCAStatus IPCA_CALL IPCAPropertyBagCreate(IPCAPropertyBagHandle* propertyBagHandle); /** * Delete an IPCPropertyBag object. @@ -786,7 +810,7 @@ IPCAStatus IPCAPropertyBagCreate(IPCAPropertyBagHandle* propertyBagHandle); * @param[in] propertyBagHandle Handle returned in IPCAPropertyBagCreate(). */ -void IPCAPropertyBagDestroy(IPCAPropertyBagHandle propertyBagHandle); +void IPCA_CALL IPCAPropertyBagDestroy(IPCAPropertyBagHandle propertyBagHandle); /** * Get the resource path of the property bag. @@ -798,8 +822,9 @@ void IPCAPropertyBagDestroy(IPCAPropertyBagHandle propertyBagHandle); * * @return IPCA_OK if successful. */ -IPCAStatus IPCAPropertyBagGetResourcePath(IPCAPropertyBagHandle propertyBagHandle, - char** resourcePath); +IPCAStatus IPCA_CALL IPCAPropertyBagGetResourcePath( + IPCAPropertyBagHandle propertyBagHandle, + char** resourcePath); /** * Value type of a property in a property bag. @@ -832,10 +857,11 @@ typedef enum * * @return IPCA_OK if successful. */ -IPCAStatus IPCAPropertyBagGetAllKeyValuePairs(IPCAPropertyBagHandle propertyBagHandle, - char*** keys, - IPCAValueType** valueTypes, - size_t* count); +IPCAStatus IPCA_CALL IPCAPropertyBagGetAllKeyValuePairs( + IPCAPropertyBagHandle propertyBagHandle, + char*** keys, + IPCAValueType** valueTypes, + size_t* count); /** * Free memory allocated for IPCAValueType in IPCAPropertyBagGetAllKeyValuePairs(). @@ -843,7 +869,7 @@ IPCAStatus IPCAPropertyBagGetAllKeyValuePairs(IPCAPropertyBagHandle propertyBagH * @param[in] valueArray Array of IPCAValueType values returned in * IPCAPropertyBagGetAllKeyValuePairs(). */ -void IPCAPropertyBagFreeIPCAValueTypeArray(IPCAValueType* valueArray); +void IPCA_CALL IPCAPropertyBagFreeIPCAValueTypeArray(IPCAValueType* valueArray); /** * Set property value. @@ -855,26 +881,31 @@ void IPCAPropertyBagFreeIPCAValueTypeArray(IPCAValueType* valueArray); * * @return IPCA_OK if successful. */ -IPCAStatus IPCAPropertyBagSetValueInt(IPCAPropertyBagHandle propertyBagHandle, - const char* key, - int value); - -IPCAStatus IPCAPropertyBagSetValueDouble(IPCAPropertyBagHandle propertyBagHandle, - const char* key, - double value); - -IPCAStatus IPCAPropertyBagSetValueBool(IPCAPropertyBagHandle - propertyBagHandle, - const char* key, - bool value); - -IPCAStatus IPCAPropertyBagSetValueString(IPCAPropertyBagHandle propertyBagHandle, - const char* key, - const char* value); - -IPCAStatus IPCAPropertyBagSetValuePropertyBag(IPCAPropertyBagHandle propertyBagHandle, - const char* key, - const IPCAPropertyBagHandle value); +IPCAStatus IPCA_CALL IPCAPropertyBagSetValueInt( + IPCAPropertyBagHandle propertyBagHandle, + const char* key, + int value); + +IPCAStatus IPCA_CALL IPCAPropertyBagSetValueDouble( + IPCAPropertyBagHandle propertyBagHandle, + const char* key, + double value); + +IPCAStatus IPCA_CALL IPCAPropertyBagSetValueBool( + IPCAPropertyBagHandle + propertyBagHandle, + const char* key, + bool value); + +IPCAStatus IPCA_CALL IPCAPropertyBagSetValueString( + IPCAPropertyBagHandle propertyBagHandle, + const char* key, + const char* value); + +IPCAStatus IPCA_CALL IPCAPropertyBagSetValuePropertyBag( + IPCAPropertyBagHandle propertyBagHandle, + const char* key, + const IPCAPropertyBagHandle value); /** * Set array value. @@ -888,30 +919,35 @@ IPCAStatus IPCAPropertyBagSetValuePropertyBag(IPCAPropertyBagHandle propertyBagH * * @return IPCA_OK if successful. */ -IPCAStatus IPCAPropertyBagSetValueIntArray(IPCAPropertyBagHandle propertyBagHandle, - const char* key, - const int* valueArray, - size_t valueCount); - -IPCAStatus IPCAPropertyBagSetValueDoubleArray(IPCAPropertyBagHandle propertyBagHandle, - const char* key, - const double* valueArray, - size_t valueCount); - -IPCAStatus IPCAPropertyBagSetValueBoolArray(IPCAPropertyBagHandle propertyBagHandle, - const char* key, - const bool* valueArray, - size_t valueCount); - -IPCAStatus IPCAPropertyBagSetValueStringArray(IPCAPropertyBagHandle propertyBagHandle, - const char* key, - const char** valueArray, - size_t valueCount); - -IPCAStatus IPCAPropertyBagSetValuePropertyBagArray(IPCAPropertyBagHandle propertyBagHandle, - const char* key, - const IPCAPropertyBagHandle* valueArray, - size_t valueCount); +IPCAStatus IPCA_CALL IPCAPropertyBagSetValueIntArray( + IPCAPropertyBagHandle propertyBagHandle, + const char* key, + const int* valueArray, + size_t valueCount); + +IPCAStatus IPCA_CALL IPCAPropertyBagSetValueDoubleArray( + IPCAPropertyBagHandle propertyBagHandle, + const char* key, + const double* valueArray, + size_t valueCount); + +IPCAStatus IPCA_CALL IPCAPropertyBagSetValueBoolArray( + IPCAPropertyBagHandle propertyBagHandle, + const char* key, + const bool* valueArray, + size_t valueCount); + +IPCAStatus IPCA_CALL IPCAPropertyBagSetValueStringArray( + IPCAPropertyBagHandle propertyBagHandle, + const char* key, + const char** valueArray, + size_t valueCount); + +IPCAStatus IPCA_CALL IPCAPropertyBagSetValuePropertyBagArray( + IPCAPropertyBagHandle propertyBagHandle, + const char* key, + const IPCAPropertyBagHandle* valueArray, + size_t valueCount); /** * Get property value. @@ -931,25 +967,30 @@ IPCAStatus IPCAPropertyBagSetValuePropertyBagArray(IPCAPropertyBagHandle propert * * @return IPCA_OK if successful. */ -IPCAStatus IPCAPropertyBagGetValueInt(IPCAPropertyBagHandle propertyBagHandle, - const char* key, - int* value); - -IPCAStatus IPCAPropertyBagGetValueDouble(IPCAPropertyBagHandle propertyBagHandle, - const char* key, - double* value); - -IPCAStatus IPCAPropertyBagGetValueBool(IPCAPropertyBagHandle propertyBagHandle, - const char* key, - bool* value); - -IPCAStatus IPCAPropertyBagGetValueString(IPCAPropertyBagHandle propertyBagHandle, - const char* key, - char** value); - -IPCAStatus IPCAPropertyBagGetValuePropertyBag(IPCAPropertyBagHandle propertyBagHandle, - const char* key, - IPCAPropertyBagHandle* value); +IPCAStatus IPCA_CALL IPCAPropertyBagGetValueInt( + IPCAPropertyBagHandle propertyBagHandle, + const char* key, + int* value); + +IPCAStatus IPCA_CALL IPCAPropertyBagGetValueDouble( + IPCAPropertyBagHandle propertyBagHandle, + const char* key, + double* value); + +IPCAStatus IPCA_CALL IPCAPropertyBagGetValueBool( + IPCAPropertyBagHandle propertyBagHandle, + const char* key, + bool* value); + +IPCAStatus IPCA_CALL IPCAPropertyBagGetValueString( + IPCAPropertyBagHandle propertyBagHandle, + const char* key, + char** value); + +IPCAStatus IPCA_CALL IPCAPropertyBagGetValuePropertyBag( + IPCAPropertyBagHandle propertyBagHandle, + const char* key, + IPCAPropertyBagHandle* value); /** * Get array value. @@ -968,46 +1009,53 @@ IPCAStatus IPCAPropertyBagGetValuePropertyBag(IPCAPropertyBagHandle propertyBagH * * @return IPCA_OK if successful. */ -IPCAStatus IPCAPropertyBagGetValueIntArray(IPCAPropertyBagHandle propertyBagHandle, - const char* key, - int** value, - size_t* valueCount); - -IPCAStatus IPCAPropertyBagGetValueDoubleArray(IPCAPropertyBagHandle propertyBagHandle, - const char* key, - double** value, - size_t* valueCount); - -IPCAStatus IPCAPropertyBagGetValueBoolArray(IPCAPropertyBagHandle propertyBagHandle, - const char* key, - bool** value, - size_t* valueCount); - -IPCAStatus IPCAPropertyBagGetValueStringArray(IPCAPropertyBagHandle propertyBagHandle, - const char* key, - char*** value, - size_t* valueCount); - -IPCAStatus IPCAPropertyBagGetValuePropertyBagArray(IPCAPropertyBagHandle propertyBagHandle, - const char* key, - IPCAPropertyBagHandle** value, - size_t* valueCount); +IPCAStatus IPCA_CALL IPCAPropertyBagGetValueIntArray( + IPCAPropertyBagHandle propertyBagHandle, + const char* key, + int** value, + size_t* valueCount); + +IPCAStatus IPCA_CALL IPCAPropertyBagGetValueDoubleArray( + IPCAPropertyBagHandle propertyBagHandle, + const char* key, + double** value, + size_t* valueCount); + +IPCAStatus IPCA_CALL IPCAPropertyBagGetValueBoolArray( + IPCAPropertyBagHandle propertyBagHandle, + const char* key, + bool** value, + size_t* valueCount); + +IPCAStatus IPCA_CALL IPCAPropertyBagGetValueStringArray( + IPCAPropertyBagHandle propertyBagHandle, + const char* key, + char*** value, + size_t* valueCount); + +IPCAStatus IPCA_CALL IPCAPropertyBagGetValuePropertyBagArray( + IPCAPropertyBagHandle propertyBagHandle, + const char* key, + IPCAPropertyBagHandle** value, + size_t* valueCount); /** * Free array types. */ -void IPCAPropertyBagFreeIntArray(int* valueArray); -void IPCAPropertyBagFreeDoubleArray(double* valueArray); -void IPCAPropertyBagFreeBoolArray(bool* valueArray); -void IPCAPropertyBagFreeStringArray(char** valueArray, size_t valueCount); -void IPCAPropertyBagFreePropertyBagArray(IPCAPropertyBagHandle* valueArray, size_t valueCount); +void IPCA_CALL IPCAPropertyBagFreeIntArray(int* valueArray); +void IPCA_CALL IPCAPropertyBagFreeDoubleArray(double* valueArray); +void IPCA_CALL IPCAPropertyBagFreeBoolArray(bool* valueArray); +void IPCA_CALL IPCAPropertyBagFreeStringArray(char** valueArray, size_t valueCount); +void IPCA_CALL IPCAPropertyBagFreePropertyBagArray( + IPCAPropertyBagHandle* valueArray, + size_t valueCount); /** * Free stringBuffer allocated in IPCAPropertyBagGetValueString(). * * @param[in] stringBuffer String buffer returned in IPCAPropertyBagGetValueString(). */ -void IPCAPropertyBagFreeString(char* stringBuffer); +void IPCA_CALL IPCAPropertyBagFreeString(char* stringBuffer); /** * Security authentication type used during Ownership Transfer communication. @@ -1119,10 +1167,11 @@ typedef IPCAStatus (IPCA_CALL *IPCADisplayPasswordCallback)( * argument in the password callbacks. * */ -IPCAStatus IPCA_CALL IPCASetPasswordCallbacks(IPCAAppHandle ipcaAppHandle, - IPCAProvidePasswordCallback providePasswordCallback, - IPCADisplayPasswordCallback displayPasswordCallback, - void* context); +IPCAStatus IPCA_CALL IPCASetPasswordCallbacks( + IPCAAppHandle ipcaAppHandle, + IPCAProvidePasswordCallback providePasswordCallback, + IPCADisplayPasswordCallback displayPasswordCallback, + void* context); /** * Callback from IPCA when a request initiated by the application using IPCARequestAccess has been @@ -1134,8 +1183,9 @@ IPCAStatus IPCA_CALL IPCASetPasswordCallbacks(IPCAAppHandle ipcaAppHandle, * IPCA_SECURITY_UPDATE_REQUEST_FAILED. * @param[in] context Applications's context set in IPCARequestAccess(). */ -typedef void (IPCA_CALL *IPCARequestAccessCompletionCallback)(IPCAStatus completionStatus, - void* context); +typedef void (IPCA_CALL *IPCARequestAccessCompletionCallback)( + IPCAStatus completionStatus, + void* context); /** * Initiate a request to access a device. Called by the application after IPCAGetProperties or @@ -1157,11 +1207,12 @@ typedef void (IPCA_CALL *IPCARequestAccessCompletionCallback)(IPCAStatus complet * @return * IPCA_OK if the request has been successfully initiated. */ -IPCAStatus IPCA_CALL IPCARequestAccess(IPCADeviceHandle deviceHandle, - const char* resourcePath, - IPCARequestAccessCompletionCallback completionCallback, - void* context, - IPCAHandle* handle); +IPCAStatus IPCA_CALL IPCARequestAccess( + IPCADeviceHandle deviceHandle, + const char* resourcePath, + IPCARequestAccessCompletionCallback completionCallback, + void* context, + IPCAHandle* handle); #ifdef __cplusplus } /* extern "C" */ #endif diff --git a/resource/IPCA/samples/ElevatorClient/ElevatorClient.cpp b/resource/IPCA/samples/ElevatorClient/ElevatorClient.cpp index a8d0ee6e3..e25ca3a20 100644 --- a/resource/IPCA/samples/ElevatorClient/ElevatorClient.cpp +++ b/resource/IPCA/samples/ElevatorClient/ElevatorClient.cpp @@ -37,8 +37,10 @@ // Forward decls. extern bool RediscoverElevator(); -extern void ResourceChangeNotificationCallback(IPCAStatus result, void* context, - IPCAPropertyBagHandle propertyBagHandle); +extern void IPCA_CALL ResourceChangeNotificationCallback( + IPCAStatus result, + void* context, + IPCAPropertyBagHandle propertyBagHandle); // Key is device id. Value is pointer to OCFDevice. std::map g_OCFDeviceList; @@ -84,8 +86,10 @@ IPCAStatus RequestObserve() } // Callback from IPCAObserveResource(). -void ResourceChangeNotificationCallback(IPCAStatus result, void* context, - IPCAPropertyBagHandle propertyBagHandle) +void IPCA_CALL ResourceChangeNotificationCallback( + IPCAStatus result, + void* context, + IPCAPropertyBagHandle propertyBagHandle) { UNUSED_PARAMETER(context); @@ -137,9 +141,10 @@ void ResourceChangeNotificationCallback(IPCAStatus result, void* context, std::mutex g_getPropertiesCbMutex; std::condition_variable g_getPropertiesCompleteCV; -void GetPropertiesCallback(IPCAStatus result, - void* context, - IPCAPropertyBagHandle propertyBagHandle) +void IPCA_CALL GetPropertiesCallback( + IPCAStatus result, + void* context, + IPCAPropertyBagHandle propertyBagHandle) { UNUSED_PARAMETER(context); @@ -188,9 +193,10 @@ void GetPropertiesCallback(IPCAStatus result, // IPCASetProperties() completion callback. std::mutex g_setPropertiesCbMutex; std::condition_variable g_setPropertiesCompleteCV; -void SetPropertiesCallback(IPCAStatus result, - void* context, - IPCAPropertyBagHandle propertyBagHandle) +void IPCA_CALL SetPropertiesCallback( + IPCAStatus result, + void* context, + IPCAPropertyBagHandle propertyBagHandle) { UNUSED_PARAMETER(context); UNUSED_PARAMETER(propertyBagHandle); @@ -211,9 +217,10 @@ void SetPropertiesCallback(IPCAStatus result, // Callback when device is discovered. std::mutex g_deviceDiscoveredCbMutex; std::condition_variable g_deviceDiscoveredCV; -void DiscoverDevicesCallback(void* context, - IPCADeviceStatus deviceStatus, - const IPCADiscoveredDeviceInfo* deviceInfo) +void IPCA_CALL DiscoverDevicesCallback( + void* context, + IPCADeviceStatus deviceStatus, + const IPCADiscoveredDeviceInfo* deviceInfo) { UNUSED_PARAMETER(context); @@ -555,13 +562,13 @@ bool RediscoverElevator() return true; } -IPCAStatus PwdInputCallback( - void* context, - const IPCADeviceInfo* deviceInformation, - const IPCAPlatformInfo* platformInformation, - IPCAOwnershipTransferType type, - char* passwordBuffer, - size_t passwordBufferSize) +IPCAStatus IPCA_CALL PwdInputCallback( + void* context, + const IPCADeviceInfo* deviceInformation, + const IPCAPlatformInfo* platformInformation, + IPCAOwnershipTransferType type, + char* passwordBuffer, + size_t passwordBufferSize) { UNUSED_PARAMETER(passwordBufferSize); UNUSED_PARAMETER(type); @@ -585,12 +592,12 @@ IPCAStatus PwdInputCallback( return IPCA_OK; } -IPCAStatus PwdDisplayCallback( - void* context, - const IPCADeviceInfo* deviceInformation, - const IPCAPlatformInfo* platformInformation, - IPCAOwnershipTransferType type, - const char* password) +IPCAStatus IPCA_CALL PwdDisplayCallback( + void* context, + const IPCADeviceInfo* deviceInformation, + const IPCAPlatformInfo* platformInformation, + IPCAOwnershipTransferType type, + const char* password) { UNUSED_PARAMETER(context); UNUSED_PARAMETER(deviceInformation); @@ -607,7 +614,7 @@ IPCAStatus PwdDisplayCallback( return IPCA_OK; } -void AuthCompletionCallback(IPCAStatus completionStatus, void* context) +void IPCA_CALL AuthCompletionCallback(IPCAStatus completionStatus, void* context) { UNUSED_PARAMETER(context); std::cout << "AuthCompletionCallback(). Completion status is: " << completionStatus; diff --git a/resource/IPCA/samples/ipcaapp/ipcaapp.cpp b/resource/IPCA/samples/ipcaapp/ipcaapp.cpp index f462574c9..8cd90c9f5 100644 --- a/resource/IPCA/samples/ipcaapp/ipcaapp.cpp +++ b/resource/IPCA/samples/ipcaapp/ipcaapp.cpp @@ -134,9 +134,10 @@ IPCAPlatformInfo* OCFDevice::GetPlatformInfo() return m_platformInfo; } -void C_GetPropertiesCallback(IPCAStatus result, - void* context, - IPCAPropertyBagHandle propertyBagHandle) +void IPCA_CALL C_GetPropertiesCallback( + IPCAStatus result, + void* context, + IPCAPropertyBagHandle propertyBagHandle) { std::lock_guard lock(g_globalMutex); @@ -508,9 +509,10 @@ void OCFDevice::GetDeviceDetails(std::string deviceName, const char** deviceUris std::map g_OCFDeviceList; // Callback when device is discovered. -void DiscoverDevicesCallback(void* context, - IPCADeviceStatus deviceStatus, - const IPCADiscoveredDeviceInfo* deviceInfo) +void IPCA_CALL DiscoverDevicesCallback( + void* context, + IPCADeviceStatus deviceStatus, + const IPCADiscoveredDeviceInfo* deviceInfo) { UNUSED_PARAMETER(context); @@ -556,12 +558,13 @@ void DiscoverDevicesCallback(void* context, ocfDevice->DisplayDevice(); } -IPCAStatus IPCA_CALL PasswordInputCallback(void* context, - const IPCADeviceInfo* deviceInformation, - const IPCAPlatformInfo* platformInformation, - IPCAOwnershipTransferType type, - char* passwordBuffer, - size_t passwordBufferSize) +IPCAStatus IPCA_CALL PasswordInputCallback( + void* context, + const IPCADeviceInfo* deviceInformation, + const IPCAPlatformInfo* platformInformation, + IPCAOwnershipTransferType type, + char* passwordBuffer, + size_t passwordBufferSize) { UNUSED_PARAMETER(context); UNUSED_PARAMETER(deviceInformation); @@ -576,11 +579,12 @@ IPCAStatus IPCA_CALL PasswordInputCallback(void* context, return IPCA_FAIL; } -IPCAStatus IPCA_CALL PasswordDisplayCallback(void* context, - const IPCADeviceInfo* deviceInformation, - const IPCAPlatformInfo* platformInformation, - IPCAOwnershipTransferType type, - const char* password) +IPCAStatus IPCA_CALL PasswordDisplayCallback( + void* context, + const IPCADeviceInfo* deviceInformation, + const IPCAPlatformInfo* platformInformation, + IPCAOwnershipTransferType type, + const char* password) { UNUSED_PARAMETER(context); UNUSED_PARAMETER(deviceInformation); diff --git a/resource/IPCA/src/inc/callback.h b/resource/IPCA/src/inc/callback.h index d8ec2b6da..dcc8c644e 100644 --- a/resource/IPCA/src/inc/callback.h +++ b/resource/IPCA/src/inc/callback.h @@ -90,9 +90,10 @@ struct CallbackInfo }; // Represent IPCAResourceChangeCallback, IPCAGetPropertiesComplete, IPCASetPropertiesComplete. -typedef void (IPCA_CALL *GenericAppCallback)(IPCAStatus result, - void* context, - IPCAPropertyBagHandle propertyBagHandle); +typedef void (IPCA_CALL *GenericAppCallback)( + IPCAStatus result, + void* context, + IPCAPropertyBagHandle propertyBagHandle); // One Callback object per App. One app per IPCAOpen(). class Callback diff --git a/resource/IPCA/src/ipca.cpp b/resource/IPCA/src/ipca.cpp index 53baf9903..28d3d0c77 100644 --- a/resource/IPCA/src/ipca.cpp +++ b/resource/IPCA/src/ipca.cpp @@ -32,7 +32,8 @@ std::mutex g_ipcaAppMutex; bool g_unitTestMode = false; -IPCAStatus IPCA_CALL IPCAOpen(const IPCAAppInfo* ipcaAppInfo, +IPCAStatus IPCA_CALL IPCAOpen( + const IPCAAppInfo* ipcaAppInfo, IPCAVersion ipcaVersion, IPCAAppHandle* ipcaAppHandle) { @@ -89,20 +90,22 @@ void IPCA_CALL IPCAClose(IPCAAppHandle ipcaAppHandle) g_app = nullptr; } -IPCAStatus IPCA_CALL IPCADiscoverDevices(IPCAAppHandle ipcaAppHandle, - IPCADiscoverDeviceCallback callback, - void* context, - const char* const* resourceTypeList, - int resourceTypeCount, - IPCAHandle* handle) +IPCAStatus IPCA_CALL IPCADiscoverDevices( + IPCAAppHandle ipcaAppHandle, + IPCADiscoverDeviceCallback callback, + void* context, + const char* const* resourceTypeList, + int resourceTypeCount, + IPCAHandle* handle) { App* app = reinterpret_cast(ipcaAppHandle); return app->DiscoverDevices(callback, context, resourceTypeList, resourceTypeCount, handle); } -IPCAStatus IPCA_CALL IPCAOpenDevice(IPCAAppHandle ipcaAppHandle, - const char* deviceId, - IPCADeviceHandle* deviceHandle) +IPCAStatus IPCA_CALL IPCAOpenDevice( + IPCAAppHandle ipcaAppHandle, + const char* deviceId, + IPCADeviceHandle* deviceHandle) { App* app = reinterpret_cast(ipcaAppHandle); return app->OpenDevice(deviceId, deviceHandle); @@ -115,29 +118,31 @@ void IPCA_CALL IPCACloseDevice(IPCADeviceHandle deviceHandle) app->CloseDevice(deviceHandle); } -IPCAStatus IPCAGetDeviceInfo(IPCADeviceHandle deviceHandle, IPCADeviceInfo** deviceInfo) +IPCAStatus IPCA_CALL IPCAGetDeviceInfo(IPCADeviceHandle deviceHandle, IPCADeviceInfo** deviceInfo) { DeviceWrapper* deviceWrapper = reinterpret_cast(deviceHandle); return deviceWrapper->device->GetDeviceInfo(deviceInfo); } -void IPCAFreeDeviceInfo(IPCADeviceInfo* deviceInfo) +void IPCA_CALL IPCAFreeDeviceInfo(IPCADeviceInfo* deviceInfo) { OCFFramework::FreeDeviceInfo(deviceInfo); } -IPCAStatus IPCAGetPlatformInfo(IPCADeviceHandle deviceHandle, IPCAPlatformInfo** platformInfo) +IPCAStatus IPCA_CALL IPCAGetPlatformInfo(IPCADeviceHandle deviceHandle, + IPCAPlatformInfo** platformInfo) { DeviceWrapper* deviceWrapper = reinterpret_cast(deviceHandle); return deviceWrapper->device->GetPlatformInfo(platformInfo); } -void IPCAFreePlatformInfo(IPCAPlatformInfo* platformInfo) +void IPCA_CALL IPCAFreePlatformInfo(IPCAPlatformInfo* platformInfo) { OCFFramework::FreePlatformInfo(platformInfo); } -IPCAStatus IPCA_CALL IPCAGetResources(IPCADeviceHandle deviceHandle, +IPCAStatus IPCA_CALL IPCAGetResources( + IPCADeviceHandle deviceHandle, const char* resourceInterface, const char* resourceType, char*** resourcePathList, @@ -247,14 +252,15 @@ IPCAStatus IPCA_CALL IPCAObserveResource(IPCADeviceHandle deviceHandle, handle); } -IPCAStatus IPCA_CALL IPCACreateResource(IPCADeviceHandle deviceHandle, - IPCACreateResourceComplete createResourceCb, - void* context, - const char* resourcePath, - const char* resourceInterface, - const char* resourceType, - IPCAPropertyBagHandle propertyBagHandle, - IPCAHandle* handle) +IPCAStatus IPCA_CALL IPCACreateResource( + IPCADeviceHandle deviceHandle, + IPCACreateResourceComplete createResourceCb, + void* context, + const char* resourcePath, + const char* resourceInterface, + const char* resourceType, + IPCAPropertyBagHandle propertyBagHandle, + IPCAHandle* handle) { DeviceWrapper* deviceWrapper = reinterpret_cast(deviceHandle); return deviceWrapper->app->CreateResource( @@ -268,11 +274,12 @@ IPCAStatus IPCA_CALL IPCACreateResource(IPCADeviceHandle deviceHandle, handle); } -IPCAStatus IPCA_CALL IPCADeleteResource(IPCADeviceHandle deviceHandle, - IPCADeleteResourceComplete deleteResourceCb, - void* context, - const char* resourcePath, - IPCAHandle* handle) +IPCAStatus IPCA_CALL IPCADeleteResource( + IPCADeviceHandle deviceHandle, + IPCADeleteResourceComplete deleteResourceCb, + void* context, + const char* resourcePath, + IPCAHandle* handle) { DeviceWrapper* deviceWrapper = reinterpret_cast(deviceHandle); return deviceWrapper->app->DeleteResource( @@ -303,7 +310,10 @@ typedef struct IPCAStatus result; } AsyncContext; -void AsyncCallback(IPCAStatus result, void* context, IPCAPropertyBagHandle propertyBagHandle) +void IPCA_CALL AsyncCallback( + IPCAStatus result, + void* context, + IPCAPropertyBagHandle propertyBagHandle) { OC_UNUSED(propertyBagHandle); @@ -398,20 +408,22 @@ IPCAStatus IPCA_CALL IPCAReboot(IPCADeviceHandle deviceHandle) return status; } -IPCAStatus IPCA_CALL IPCASetPasswordCallbacks(IPCAAppHandle ipcaAppHandle, - IPCAProvidePasswordCallback inputCallback, - IPCADisplayPasswordCallback displayCallback, - void* context) +IPCAStatus IPCA_CALL IPCASetPasswordCallbacks( + IPCAAppHandle ipcaAppHandle, + IPCAProvidePasswordCallback inputCallback, + IPCADisplayPasswordCallback displayCallback, + void* context) { App* app = reinterpret_cast(ipcaAppHandle); return app->SetPasswordCallbacks(inputCallback, displayCallback, context); } -IPCAStatus IPCA_CALL IPCARequestAccess(IPCADeviceHandle deviceHandle, - const char* resourcePath, - IPCARequestAccessCompletionCallback completionCallback, - void* context, - IPCAHandle* handle) +IPCAStatus IPCA_CALL IPCARequestAccess( + IPCADeviceHandle deviceHandle, + const char* resourcePath, + IPCARequestAccessCompletionCallback completionCallback, + void* context, + IPCAHandle* handle) { DeviceWrapper* deviceWrapper = reinterpret_cast(deviceHandle); return deviceWrapper->app->RequestAccess( diff --git a/resource/IPCA/src/ipcavariant.cpp b/resource/IPCA/src/ipcavariant.cpp index 8540277d7..7d462e815 100644 --- a/resource/IPCA/src/ipcavariant.cpp +++ b/resource/IPCA/src/ipcavariant.cpp @@ -25,7 +25,7 @@ #define TAG "IPCA_Variant" -IPCAStatus IPCAPropertyBagCreate(IPCAPropertyBagHandle* propertyBagHandle) +IPCAStatus IPCA_CALL IPCAPropertyBagCreate(IPCAPropertyBagHandle* propertyBagHandle) { OC::OCRepresentation* rep = new OC::OCRepresentation(); @@ -38,13 +38,16 @@ IPCAStatus IPCAPropertyBagCreate(IPCAPropertyBagHandle* propertyBagHandle) return IPCA_OK; } -void IPCAPropertyBagDestroy(IPCAPropertyBagHandle propertyBagHandle) +void IPCA_CALL IPCAPropertyBagDestroy(IPCAPropertyBagHandle propertyBagHandle) { delete(reinterpret_cast(propertyBagHandle)); } template -IPCAStatus IPCAPropertySetValue(IPCAPropertyBagHandle propertyBagHandle, const char* key, _T value) +IPCAStatus IPCA_CALL IPCAPropertySetValue( + IPCAPropertyBagHandle propertyBagHandle, + const char* key, + _T value) { if (propertyBagHandle == nullptr) { @@ -64,38 +67,43 @@ IPCAStatus IPCAPropertySetValue(IPCAPropertyBagHandle propertyBagHandle, const c } } -IPCAStatus IPCAPropertyBagSetValueInt(IPCAPropertyBagHandle propertyBagHandle, - const char* key, - int value) +IPCAStatus IPCA_CALL IPCAPropertyBagSetValueInt( + IPCAPropertyBagHandle propertyBagHandle, + const char* key, + int value) { return IPCAPropertySetValue(propertyBagHandle, key, value); } -IPCAStatus IPCAPropertyBagSetValueDouble(IPCAPropertyBagHandle propertyBagHandle, - const char* key, - double value) +IPCAStatus IPCA_CALL IPCAPropertyBagSetValueDouble( + IPCAPropertyBagHandle propertyBagHandle, + const char* key, + double value) { return IPCAPropertySetValue(propertyBagHandle, key, value); } -IPCAStatus IPCAPropertyBagSetValueBool(IPCAPropertyBagHandle propertyBagHandle, - const char* key, - bool value) +IPCAStatus IPCA_CALL IPCAPropertyBagSetValueBool( + IPCAPropertyBagHandle propertyBagHandle, + const char* key, + bool value) { return IPCAPropertySetValue(propertyBagHandle, key, value); } -IPCAStatus IPCAPropertyBagSetValueString(IPCAPropertyBagHandle propertyBagHandle, - const char* key, - const char* value) +IPCAStatus IPCA_CALL IPCAPropertyBagSetValueString( + IPCAPropertyBagHandle propertyBagHandle, + const char* key, + const char* value) { std::string valueString = value; return IPCAPropertySetValue(propertyBagHandle, key, valueString); } -IPCAStatus IPCAPropertyBagSetValuePropertyBag(IPCAPropertyBagHandle propertyBagHandle, - const char* key, - const IPCAPropertyBagHandle value) +IPCAStatus IPCA_CALL IPCAPropertyBagSetValuePropertyBag( + IPCAPropertyBagHandle propertyBagHandle, + const char* key, + const IPCAPropertyBagHandle value) { if (propertyBagHandle == nullptr) { @@ -118,10 +126,11 @@ IPCAStatus IPCAPropertyBagSetValuePropertyBag(IPCAPropertyBagHandle propertyBagH } template -IPCAStatus IPCAPropertyBagSetValueArray(IPCAPropertyBagHandle propertyBagHandle, - const char* key, - const _T* valueArray, - size_t arrayCount) +IPCAStatus IPCA_CALL IPCAPropertyBagSetValueArray( + IPCAPropertyBagHandle propertyBagHandle, + const char* key, + const _T* valueArray, + size_t arrayCount) { if (propertyBagHandle == nullptr) { @@ -149,35 +158,39 @@ IPCAStatus IPCAPropertyBagSetValueArray(IPCAPropertyBagHandle propertyBagHandle, } } -IPCAStatus IPCAPropertyBagSetValueIntArray(IPCAPropertyBagHandle propertyBagHandle, - const char* key, - const int* valueArray, - size_t arrayCount) +IPCAStatus IPCA_CALL IPCAPropertyBagSetValueIntArray( + IPCAPropertyBagHandle propertyBagHandle, + const char* key, + const int* valueArray, + size_t arrayCount) { return IPCAPropertyBagSetValueArray(propertyBagHandle, key, valueArray, arrayCount); } -IPCAStatus IPCAPropertyBagSetValueDoubleArray(IPCAPropertyBagHandle propertyBagHandle, - const char* key, - const double* valueArray, - size_t arrayCount) +IPCAStatus IPCA_CALL IPCAPropertyBagSetValueDoubleArray( + IPCAPropertyBagHandle propertyBagHandle, + const char* key, + const double* valueArray, + size_t arrayCount) { return IPCAPropertyBagSetValueArray(propertyBagHandle, key, valueArray, arrayCount); } -IPCAStatus IPCAPropertyBagSetValueBoolArray(IPCAPropertyBagHandle propertyBagHandle, - const char* key, - const bool* valueArray, - size_t arrayCount) +IPCAStatus IPCA_CALL IPCAPropertyBagSetValueBoolArray( + IPCAPropertyBagHandle propertyBagHandle, + const char* key, + const bool* valueArray, + size_t arrayCount) { return IPCAPropertyBagSetValueArray(propertyBagHandle, key, valueArray, arrayCount); } -IPCAStatus IPCAPropertyBagSetValueStringArray(IPCAPropertyBagHandle propertyBagHandle, - const char* key, - const char** valueArray, - size_t arrayCount) +IPCAStatus IPCA_CALL IPCAPropertyBagSetValueStringArray( + IPCAPropertyBagHandle propertyBagHandle, + const char* key, + const char** valueArray, + size_t arrayCount) { if (propertyBagHandle == nullptr) { @@ -205,10 +218,11 @@ IPCAStatus IPCAPropertyBagSetValueStringArray(IPCAPropertyBagHandle propertyBagH } } -IPCAStatus IPCAPropertyBagSetValuePropertyBagArray(IPCAPropertyBagHandle propertyBagHandle, - const char* key, - const IPCAPropertyBagHandle* valueArray, - size_t valueCount) +IPCAStatus IPCA_CALL IPCAPropertyBagSetValuePropertyBagArray( + IPCAPropertyBagHandle propertyBagHandle, + const char* key, + const IPCAPropertyBagHandle* valueArray, + size_t valueCount) { if (propertyBagHandle == nullptr) { @@ -238,7 +252,10 @@ IPCAStatus IPCAPropertyBagSetValuePropertyBagArray(IPCAPropertyBagHandle propert } template -IPCAStatus AllocateAndCopyTypeVectorToArrayOfType(std::vector<_T> array, _T** dest, size_t* count) +IPCAStatus IPCA_CALL AllocateAndCopyTypeVectorToArrayOfType( + std::vector<_T> array, + _T** dest, + size_t* count) { _T* buffer; size_t arraySize = array.size(); @@ -262,9 +279,10 @@ IPCAStatus AllocateAndCopyTypeVectorToArrayOfType(std::vector<_T> array, _T** de } template -IPCAStatus IPCAPropertyBagGetValueArray(IPCAPropertyBagHandle propertyBagHandle, - const char* key, _T** value, - size_t* valueCount) +IPCAStatus IPCA_CALL IPCAPropertyBagGetValueArray( + IPCAPropertyBagHandle propertyBagHandle, + const char* key, _T** value, + size_t* valueCount) { if (propertyBagHandle == nullptr) { @@ -281,49 +299,53 @@ IPCAStatus IPCAPropertyBagGetValueArray(IPCAPropertyBagHandle propertyBagHandle, return AllocateAndCopyTypeVectorToArrayOfType(array, value, valueCount); } -IPCAStatus IPCAPropertyBagGetValueIntArray(IPCAPropertyBagHandle propertyBagHandle, - const char* key, - int** value, - size_t* valueCount) +IPCAStatus IPCA_CALL IPCAPropertyBagGetValueIntArray( + IPCAPropertyBagHandle propertyBagHandle, + const char* key, + int** value, + size_t* valueCount) { return IPCAPropertyBagGetValueArray(propertyBagHandle, key, value, valueCount); } -void IPCAPropertyBagFreeIntArray(int* valueArray) +void IPCA_CALL IPCAPropertyBagFreeIntArray(int* valueArray) { OICFree((void*)valueArray); } -IPCAStatus IPCAPropertyBagGetValueDoubleArray(IPCAPropertyBagHandle propertyBagHandle, - const char* key, - double** value, - size_t* valueCount) +IPCAStatus IPCA_CALL IPCAPropertyBagGetValueDoubleArray( + IPCAPropertyBagHandle propertyBagHandle, + const char* key, + double** value, + size_t* valueCount) { return IPCAPropertyBagGetValueArray(propertyBagHandle, key, value, valueCount); } -void IPCAPropertyBagFreeDoubleArray(double* valueArray) +void IPCA_CALL IPCAPropertyBagFreeDoubleArray(double* valueArray) { OICFree((void*)valueArray); } -IPCAStatus IPCAPropertyBagGetValueBoolArray(IPCAPropertyBagHandle propertyBagHandle, - const char* key, - bool** value, - size_t* valueCount) +IPCAStatus IPCA_CALL IPCAPropertyBagGetValueBoolArray( + IPCAPropertyBagHandle propertyBagHandle, + const char* key, + bool** value, + size_t* valueCount) { return IPCAPropertyBagGetValueArray(propertyBagHandle, key, value, valueCount); } -void IPCAPropertyBagFreeBoolArray(bool* valueArray) +void IPCA_CALL IPCAPropertyBagFreeBoolArray(bool* valueArray) { OICFree((void*)valueArray); } -IPCAStatus IPCAPropertyBagGetValueStringArray(IPCAPropertyBagHandle propertyBagHandle, - const char* key, - char*** value, - size_t* valueCount) +IPCAStatus IPCA_CALL IPCAPropertyBagGetValueStringArray( + IPCAPropertyBagHandle propertyBagHandle, + const char* key, + char*** value, + size_t* valueCount) { if (propertyBagHandle == nullptr) { @@ -341,15 +363,16 @@ IPCAStatus IPCAPropertyBagGetValueStringArray(IPCAPropertyBagHandle propertyBagH return AllocateAndCopyStringVectorToArrayOfCharPointers(array, value, valueCount); } -void IPCAPropertyBagFreeStringArray(char** valueArray, size_t valueCount) +void IPCA_CALL IPCAPropertyBagFreeStringArray(char** valueArray, size_t valueCount) { FreeArrayOfCharPointers(valueArray, valueCount); } -IPCAStatus IPCAPropertyBagGetValuePropertyBagArray(IPCAPropertyBagHandle propertyBagHandle, - const char* key, - IPCAPropertyBagHandle** value, - size_t* count) +IPCAStatus IPCA_CALL IPCAPropertyBagGetValuePropertyBagArray( + IPCAPropertyBagHandle propertyBagHandle, + const char* key, + IPCAPropertyBagHandle** value, + size_t* count) { if (propertyBagHandle == nullptr) { @@ -419,7 +442,9 @@ IPCAStatus IPCAPropertyBagGetValuePropertyBagArray(IPCAPropertyBagHandle propert return IPCA_OK; } -void IPCAPropertyBagFreePropertyBagArray(IPCAPropertyBagHandle* valueArray, size_t valueCount) +void IPCA_CALL IPCAPropertyBagFreePropertyBagArray( + IPCAPropertyBagHandle* valueArray, + size_t valueCount) { for (size_t i = 0; i < valueCount; i++) { @@ -429,9 +454,10 @@ void IPCAPropertyBagFreePropertyBagArray(IPCAPropertyBagHandle* valueArray, size OICFree(valueArray); } -IPCAStatus IPCAPropertyBagGetValueInt(IPCAPropertyBagHandle propertyBagHandle, - const char* key, - int* value) +IPCAStatus IPCA_CALL IPCAPropertyBagGetValueInt( + IPCAPropertyBagHandle propertyBagHandle, + const char* key, + int* value) { if (propertyBagHandle == nullptr) { @@ -447,9 +473,10 @@ IPCAStatus IPCAPropertyBagGetValueInt(IPCAPropertyBagHandle propertyBagHandle, return IPCA_OK; } -IPCAStatus IPCAPropertyBagGetValueDouble(IPCAPropertyBagHandle propertyBagHandle, - const char* key, - double* value) +IPCAStatus IPCA_CALL IPCAPropertyBagGetValueDouble( + IPCAPropertyBagHandle propertyBagHandle, + const char* key, + double* value) { if (propertyBagHandle == nullptr) { @@ -465,9 +492,10 @@ IPCAStatus IPCAPropertyBagGetValueDouble(IPCAPropertyBagHandle propertyBagHandle return IPCA_OK; } -IPCAStatus IPCAPropertyBagGetValueBool(IPCAPropertyBagHandle propertyBagHandle, - const char* key, - bool* value) +IPCAStatus IPCA_CALL IPCAPropertyBagGetValueBool( + IPCAPropertyBagHandle propertyBagHandle, + const char* key, + bool* value) { if (propertyBagHandle == nullptr) { @@ -483,9 +511,10 @@ IPCAStatus IPCAPropertyBagGetValueBool(IPCAPropertyBagHandle propertyBagHandle, return IPCA_OK; } -IPCAStatus IPCAPropertyBagGetValueString(IPCAPropertyBagHandle propertyBagHandle, - const char* key, - char** buffer) +IPCAStatus IPCA_CALL IPCAPropertyBagGetValueString( + IPCAPropertyBagHandle propertyBagHandle, + const char* key, + char** buffer) { if (propertyBagHandle == nullptr) { @@ -502,14 +531,15 @@ IPCAStatus IPCAPropertyBagGetValueString(IPCAPropertyBagHandle propertyBagHandle return AllocateAndCopyStringToFlatBuffer(stringValue, buffer); } -void IPCAPropertyBagFreeString(char* buffer) +void IPCA_CALL IPCAPropertyBagFreeString(char* buffer) { OICFree(static_cast(buffer)); } -IPCAStatus IPCAPropertyBagGetValuePropertyBag(IPCAPropertyBagHandle propertyBagHandle, - const char* key, - IPCAPropertyBagHandle* value) +IPCAStatus IPCA_CALL IPCAPropertyBagGetValuePropertyBag( + IPCAPropertyBagHandle propertyBagHandle, + const char* key, + IPCAPropertyBagHandle* value) { if (propertyBagHandle == nullptr) { @@ -533,8 +563,9 @@ IPCAStatus IPCAPropertyBagGetValuePropertyBag(IPCAPropertyBagHandle propertyBagH return IPCA_OK; } -IPCAStatus IPCAPropertyBagGetResourcePath(IPCAPropertyBagHandle propertyBagHandle, - char** resourcePath) +IPCAStatus IPCA_CALL IPCAPropertyBagGetResourcePath( + IPCAPropertyBagHandle propertyBagHandle, + char** resourcePath) { if (propertyBagHandle == nullptr) { @@ -546,7 +577,7 @@ IPCAStatus IPCAPropertyBagGetResourcePath(IPCAPropertyBagHandle propertyBagHandl resourcePath); } -IPCAValueType AttributeTypeToIPCAValueType(AttributeType type) +IPCAValueType IPCA_CALL AttributeTypeToIPCAValueType(AttributeType type) { IPCAValueType ipcaValueType; @@ -592,7 +623,8 @@ IPCAValueType AttributeTypeToIPCAValueType(AttributeType type) return ipcaValueType; } -IPCAStatus IPCAPropertyBagGetAllKeyValuePairs(IPCAPropertyBagHandle propertyBagHandle, +IPCAStatus IPCA_CALL IPCAPropertyBagGetAllKeyValuePairs( + IPCAPropertyBagHandle propertyBagHandle, char*** keys, IPCAValueType** valueTypes, size_t* count) @@ -637,12 +669,12 @@ IPCAStatus IPCAPropertyBagGetAllKeyValuePairs(IPCAPropertyBagHandle propertyBagH return status; } -void IPCAPropertyBagFreeIPCAValueTypeArray(IPCAValueType* valueArray) +void IPCA_CALL IPCAPropertyBagFreeIPCAValueTypeArray(IPCAValueType* valueArray) { OICFree((void*)valueArray); } -void IPCAPropertyBagDebugDump(IPCAPropertyBagHandle propertyBagHandle) +void IPCA_CALL IPCAPropertyBagDebugDump(IPCAPropertyBagHandle propertyBagHandle) { OC::OCRepresentation* rep = (reinterpret_cast(propertyBagHandle)); PrintOCRep(*rep); diff --git a/resource/IPCA/unittests/IPCAElevatorClient.cpp b/resource/IPCA/unittests/IPCAElevatorClient.cpp index 681daa82e..a7db6693b 100644 --- a/resource/IPCA/unittests/IPCAElevatorClient.cpp +++ b/resource/IPCA/unittests/IPCAElevatorClient.cpp @@ -64,7 +64,10 @@ IPCAStatus IPCAElevatorClient::RebootElevator() return status; } -void C_GetPropertiesCb(IPCAStatus result, void* context, IPCAPropertyBagHandle propertyBagHandle) +void IPCA_CALL C_GetPropertiesCb( + IPCAStatus result, + void* context, + IPCAPropertyBagHandle propertyBagHandle) { IPCAElevatorClient* ipcaElevatorClient = (IPCAElevatorClient*)context; ipcaElevatorClient->GetPropertiesCallback(result, context, propertyBagHandle); @@ -94,7 +97,10 @@ bool IPCAElevatorClient::GetElevatorProperties() return m_getPropertiesCallbackCalled; } -void C_SetPropertiesCb(IPCAStatus result, void* context, IPCAPropertyBagHandle propertyBagHandle) +void IPCA_CALL C_SetPropertiesCb( + IPCAStatus result, + void* context, + IPCAPropertyBagHandle propertyBagHandle) { IPCAElevatorClient* ipcaTest = (IPCAElevatorClient*)context; ipcaTest->SetPropertiesCallback(result, context, propertyBagHandle); @@ -126,7 +132,8 @@ bool IPCAElevatorClient::SetElevatorProperties(IPCAPropertyBagHandle propertyBag return m_setPropertiesCallbackCalled; } -void C_CreateResourceCb(IPCAStatus result, +void IPCA_CALL C_CreateResourceCb( + IPCAStatus result, void* context, const char* newResourcePath, IPCAPropertyBagHandle propertyBagHandle) @@ -135,8 +142,9 @@ void C_CreateResourceCb(IPCAStatus result, ipcaTest->CreateResourceCallback(result, newResourcePath, propertyBagHandle); } -bool IPCAElevatorClient::CreateElevatorResource(std::string resourcePath, - IPCAPropertyBagHandle propertyBagHandle) +bool IPCAElevatorClient::CreateElevatorResource( + std::string resourcePath, + IPCAPropertyBagHandle propertyBagHandle) { m_createResourceCallbackCalled = false; @@ -162,7 +170,7 @@ bool IPCAElevatorClient::CreateElevatorResource(std::string resourcePath, return m_createResourceCallbackCalled; } -void C_DeleteResourceCb(IPCAStatus result, void* context) +void IPCA_CALL C_DeleteResourceCb(IPCAStatus result, void* context) { IPCAElevatorClient* ipcaTest = (IPCAElevatorClient*)context; ipcaTest->DeleteResourceCallback(result); @@ -243,7 +251,8 @@ void IPCAElevatorClient::CreateResouceExplicitPath() { } -void C_ResourceChangeNotificationCb(IPCAStatus result, +void IPCA_CALL C_ResourceChangeNotificationCb( + IPCAStatus result, void* context, IPCAPropertyBagHandle propertyBagHandle) { @@ -594,9 +603,10 @@ void IPCAElevatorClient::DiscoverElevator1Callback( } } -void C_DiscoverElevator1Cb(void* context, - IPCADeviceStatus deviceStatus, - const IPCADiscoveredDeviceInfo* discoveredDeviceInfo) +void IPCA_CALL C_DiscoverElevator1Cb( + void* context, + IPCADeviceStatus deviceStatus, + const IPCADiscoveredDeviceInfo* discoveredDeviceInfo) { IPCAElevatorClient* ipcaTest = (IPCAElevatorClient*)context; ipcaTest->DiscoverElevator1Callback(context, deviceStatus, discoveredDeviceInfo); @@ -695,8 +705,9 @@ void IPCAElevatorClient::DeleteResourceCallback(IPCAStatus result) m_deleteResourceCompleteCV.notify_all(); } -void IPCAElevatorClient::ResourceChangeNotificationCallback(IPCAStatus result, - IPCAPropertyBagHandle propertyBagHandle) +void IPCAElevatorClient::ResourceChangeNotificationCallback( + IPCAStatus result, + IPCAPropertyBagHandle propertyBagHandle) { EXPECT_EQ(IPCA_OK, result); diff --git a/resource/IPCA/unittests/ipcaunittests.cpp b/resource/IPCA/unittests/ipcaunittests.cpp index 7c0ad0fab..38bc5380a 100644 --- a/resource/IPCA/unittests/ipcaunittests.cpp +++ b/resource/IPCA/unittests/ipcaunittests.cpp @@ -36,7 +36,7 @@ using namespace std; using namespace std::placeholders; // Implemented in ipca.dll. -void IPCASetUnitTestMode(); +void IPCA_CALL IPCASetUnitTestMode(); // IPCA test app info. IPCAUuid IPCATestAppUuid = { diff --git a/resource/c_common/platform_features.h b/resource/c_common/platform_features.h index a4a7f1365..3e6f0b018 100644 --- a/resource/c_common/platform_features.h +++ b/resource/c_common/platform_features.h @@ -119,6 +119,18 @@ /** * Mark a parameter as unused. Used to prevent unused variable compiler warnings. */ -#define OC_UNUSED(x) (void)(x) +# define OC_UNUSED(x) (void)(x) + +/** + * Calling convention. + */ +#ifdef _WIN32 +/* + * Set to __stdcall for Windows, consistent with WIN32 APIs. + */ +# define OC_CALL __stdcall +#else +# define OC_CALL +#endif #endif