Advertisement
expired6978

ScaleformCallbacks.cpp

Apr 12th, 2014
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.66 KB | None | 0 0
  1. #include "ScaleformCallbacks.h"
  2. #include <typeinfo>
  3.  
  4. GFxValue::~GFxValue()
  5. {
  6.     CleanManaged();
  7. }
  8.  
  9. void GFxValue::AddManaged(void)
  10. {
  11.     if(IsManaged())
  12.         CALL_MEMBER_FN(objectInterface, AddManaged_Internal)(this, data.obj);
  13. }
  14.  
  15. void GFxValue::CleanManaged(void)
  16. {
  17.     if(IsManaged())
  18.     {
  19.         CALL_MEMBER_FN(objectInterface, ReleaseManaged_Internal)(this, data.obj);
  20.  
  21.         objectInterface = NULL;
  22.         type = kType_Undefined;
  23.     }
  24. }
  25.  
  26. void GFxValue::SetUndefined(void)
  27. {
  28.     CleanManaged();
  29.  
  30.     type = kType_Undefined;
  31. }
  32.  
  33. void GFxValue::SetNull(void)
  34. {
  35.     CleanManaged();
  36.  
  37.     type = kType_Null;
  38. }
  39.  
  40. void GFxValue::SetBool(bool value)
  41. {
  42.     CleanManaged();
  43.  
  44.     type = kType_Bool;
  45.     data.boolean = value;
  46. }
  47.  
  48. void GFxValue::SetNumber(double value)
  49. {
  50.     CleanManaged();
  51.  
  52.     type = kType_Number;
  53.     data.number = value;
  54. }
  55.  
  56. void GFxValue::SetString(const char * value)
  57. {
  58.     CleanManaged();
  59.  
  60.     type = kType_String;
  61.     data.string = value;
  62. }
  63.  
  64. void GFxValue::SetWideString(const wchar_t * value)
  65. {
  66.     CleanManaged();
  67.  
  68.     type = kType_WideString;
  69.     data.wideString = value;
  70. }
  71.  
  72. bool GFxValue::GetBool(void)
  73. {
  74.     switch(GetType())
  75.     {
  76.         case kType_Bool: return data.boolean;
  77.         case kType_Number: return data.number != 0;
  78.         default: HALT("GFxValue::GetBool: bad type"); return false;
  79.     }
  80. }
  81.  
  82. const char * GFxValue::GetString(void)
  83. {
  84.     if(GetType() != kType_String)
  85.         return NULL;
  86.  
  87.     if(IsManaged())
  88.         return *data.managedString;
  89.     else
  90.         return data.string;
  91. }
  92.  
  93. const wchar_t * GFxValue::GetWideString(void)
  94. {
  95.     if(GetType() != kType_WideString)
  96.         return NULL;
  97.  
  98.     if(IsManaged())
  99.         return *data.managedWideString;
  100.     else
  101.         return data.wideString;
  102. }
  103.  
  104. double GFxValue::GetNumber(void)
  105. {
  106.     switch(GetType())
  107.     {
  108.         case kType_Number:  return data.number;
  109.         case kType_Bool:    return data.boolean ? 1 : 0;
  110.         default:            HALT("GFxValue::GetNumber: bad type"); return 0;
  111.     }
  112. }
  113.  
  114. bool GFxValue::HasMember(const char * name)
  115. {
  116.     return CALL_MEMBER_FN(objectInterface, HasMember)(data.obj, name, IsDisplayObject());
  117. }
  118.  
  119. bool GFxValue::SetMember(const char * name, GFxValue * value)
  120. {
  121.     return CALL_MEMBER_FN(objectInterface, SetMember)(data.obj, name, value, IsDisplayObject());
  122. }
  123.  
  124. bool GFxValue::GetMember(const char * name, GFxValue * value)
  125. {
  126.     return CALL_MEMBER_FN(objectInterface, GetMember)(data.obj, name, value, IsDisplayObject());
  127. }
  128.  
  129. bool GFxValue::DeleteMember(const char * name)
  130. {
  131.     return CALL_MEMBER_FN(objectInterface, DeleteMember)(data.obj, name, IsDisplayObject());
  132. }
  133.  
  134. bool GFxValue::Invoke(const char * name, GFxValue * result, GFxValue * args, UInt32 numArgs)
  135. {
  136.     return CALL_MEMBER_FN(objectInterface, Invoke)(data.obj, result, name, args, numArgs, IsDisplayObject());
  137. }
  138.  
  139. bool GFxValue::PushBack(GFxValue * value)
  140. {
  141.     return CALL_MEMBER_FN(objectInterface, PushBack)(data.obj, value);
  142. }
  143.  
  144. UInt32 GFxValue::GetArraySize()
  145. {
  146.     return CALL_MEMBER_FN(objectInterface, GetArraySize)(data.obj);
  147. }
  148.  
  149. bool GFxValue::GetElement(UInt32 index, GFxValue * value)
  150. {
  151.     return CALL_MEMBER_FN(objectInterface, GetElement)(data.obj, index, value);
  152. }
  153.  
  154. bool GFxValue::GetDisplayInfo(DisplayInfo * displayInfo)
  155. {
  156.     return CALL_MEMBER_FN(objectInterface, GetDisplayInfo)(data.obj, displayInfo);
  157. }
  158.  
  159. bool GFxValue::SetDisplayInfo(DisplayInfo * displayInfo)
  160. {
  161.     return CALL_MEMBER_FN(objectInterface, SetDisplayInfo)(data.obj, displayInfo);
  162. }
  163.  
  164.  
  165. UInt32 g_GFxFunctionHandler_count = 0;
  166.  
  167. GFxFunctionHandler::GFxFunctionHandler()
  168. {
  169.     g_GFxFunctionHandler_count++;
  170. }
  171.  
  172. GFxFunctionHandler::~GFxFunctionHandler()
  173. {
  174.     g_GFxFunctionHandler_count--;
  175. }
  176.  
  177. FunctionHandlerCache g_functionHandlerCache;
  178.  
  179. const FxDelegateHandler::Callback PlaySoundCallback = (FxDelegateHandler::Callback)0x00899940;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement