PluginUtilsIOS.h 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /****************************************************************************
  2. Copyright (c) 2012+2013 cocos2d+x.org
  3. http://www.cocos2d+x.org
  4. Permission is hereby granted, free of charge, to any person obtaining a copy
  5. of this software and associated documentation files (the "Software"), to deal
  6. in the Software without restriction, including without limitation the rights
  7. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. copies of the Software, and to permit persons to whom the Software is
  9. furnished to do so, subject to the following conditions:
  10. The above copyright notice and this permission notice shall be included in
  11. all copies or substantial portions of the Software.
  12. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  13. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  14. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  15. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  16. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  17. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  18. THE SOFTWARE.
  19. ****************************************************************************/
  20. #ifndef __PLUGIN_UTILS_IOS_H__
  21. #define __PLUGIN_UTILS_IOS_H__
  22. #include "PluginProtocol.h"
  23. #include <string>
  24. #include <map>
  25. #include "PluginParam.h"
  26. namespace cocos2d { namespace plugin {
  27. typedef struct _PluginOCData
  28. {
  29. id obj;
  30. std::string className;
  31. } PluginOCData;
  32. class PluginUtilsIOS
  33. {
  34. public:
  35. static void initOCPlugin(PluginProtocol* pPlugin, id ocObj, const char* className);
  36. static PluginOCData* getPluginOCData(PluginProtocol* pKeyObj);
  37. static void setPluginOCData(PluginProtocol* pKeyObj, PluginOCData* pData);
  38. static void erasePluginOCData(PluginProtocol* pKeyObj);
  39. static PluginProtocol* getPluginPtr(id obj);
  40. static id getOCObjFromParam(PluginParam* param);
  41. static NSMutableDictionary* createDictFromMap(std::map<std::string, std::string>* paramMap);
  42. /**
  43. @brief method don't have return value
  44. */
  45. static void callOCFunctionWithName_oneParam(PluginProtocol* pPlugin, const char* funcName, id param);
  46. static void callOCFunctionWithName(PluginProtocol* pPlugin, const char* funcName);
  47. /**
  48. @brief method return int value
  49. */
  50. static int callOCIntFunctionWithName_oneParam(PluginProtocol* pPlugin, const char* funcName, id param);
  51. static int callOCIntFunctionWithName(PluginProtocol* pPlugin, const char* funcName);
  52. /**
  53. @brief method return float value
  54. */
  55. static float callOCFloatFunctionWithName_oneParam(PluginProtocol* pPlugin, const char* funcName, id param);
  56. static float callOCFloatFunctionWithName(PluginProtocol* pPlugin, const char* funcName);
  57. /**
  58. @brief method return bool value
  59. */
  60. static bool callOCBoolFunctionWithName_oneParam(PluginProtocol* pPlugin, const char* funcName, id param);
  61. static bool callOCBoolFunctionWithName(PluginProtocol* pPlugin, const char* funcName);
  62. /**
  63. @brief method return string value
  64. */
  65. static std::string callOCStringFunctionWithName_oneParam(PluginProtocol* pPlugin, const char* funcName, id param);
  66. static std::string callOCStringFunctionWithName(PluginProtocol* pPlugin, const char* funcName);
  67. static void outputLog(const char* pFormat, ...);
  68. private:
  69. static id callRetFunctionWithParam(PluginProtocol* pPlugin, const char* funcName, id param);
  70. static id callRetFunction(PluginProtocol* pPlugin, const char* funcName);
  71. };
  72. }} // namespace cocos2d { namespace plugin {
  73. #endif //__PLUGIN_UTILS_IOS_H__