text: // vi: nu:noai:ts=4:sw=4
  
  //	Class Object Metods and Tables for 'Value'
  //	Generated 12/31/2019 15:27:11
  
  
  /*
   This is free and unencumbered software released into the public domain.
   
   Anyone is free to copy, modify, publish, use, compile, sell, or
   distribute this software, either in source code form or as a compiled
   binary, for any purpose, commercial or non-commercial, and by any
   means.
   
   In jurisdictions that recognize copyright laws, the author or authors
   of this software dedicate any and all copyright interest in the
   software to the public domain. We make this dedication for the benefit
   of the public at large and to the detriment of our heirs and
   successors. We intend this dedication to be an overt act of
   relinquishment in perpetuity of all present and future rights to this
   software under copyright law.
   
   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
   IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
   OTHER DEALINGS IN THE SOFTWARE.
   
   For more information, please refer to <http://unlicense.org/>
   */
  
  
  
  
  #define			VALUE_OBJECT_C	    1
  #include        <Value_internal.h>
  #ifdef  VALUE_SINGLETON
  #include        <psxLock.h>
  #endif
  
  
  
  //===========================================================
  //                  Class Object Definition
  //===========================================================
  
  struct Value_class_data_s	{
      // Warning - OBJ_DATA must be first in this object!
      OBJ_DATA        super;
      
      // Common Data
  #ifdef  VALUE_SINGLETON
      volatile
      VALUE_DATA       *pSingleton;
  #endif
      //uint32_t        misc;
      //OBJ_ID          pObjCatalog;
  };
  
  
  
  
  //-----------------------------------------------------------
  //                  Class Methods
  //-----------------------------------------------------------
  
  
  
  static
  void *          ValueClass_QueryInfo (
      OBJ_ID          objId,
      uint32_t        type,
      void            *pData
  );
  
  
  static
  const
  OBJ_INFO        Value_Info;            // Forward Reference
  
  
  
  
  static
  bool            ValueClass_IsKindOf (
      uint16_t		classID
  )
  {
      OBJ_DATA        *pObj;
      
      if (OBJ_IDENT_VALUE_CLASS == classID) {
         return true;
      }
      if (OBJ_IDENT_OBJ_CLASS == classID) {
         return true;
      }
      
      pObj = obj_getInfo(Value_Class())->pClassSuperObject;
      if (pObj == obj_BaseClass())
          ;
      else {
          return obj_getVtbl(pObj)->pIsKindOf(classID);
      }
      
      return false;
  }
  
  
  static
  uint16_t		ValueClass_WhoAmI (
      void
  )
  {
      return OBJ_IDENT_VALUE_CLASS;
  }
  
  
  
  
  //===========================================================
  //                 Class Object Vtbl Definition
  //===========================================================
  
  static
  const
  VALUE_CLASS_VTBL    class_Vtbl = {
      {
          &Value_Info,
          ValueClass_IsKindOf,
          obj_RetainNull,
          obj_ReleaseNull,
          NULL,
          Value_Class,
          ValueClass_WhoAmI,
          (P_OBJ_QUERYINFO)ValueClass_QueryInfo,
          NULL                        // ValueClass_ToDebugString
      },
  };
  
  
  
  //-----------------------------------------------------------
  //						Class Object
  //-----------------------------------------------------------
  
  VALUE_CLASS_DATA  Value_ClassObj = {
      {
          (const OBJ_IUNKNOWN *)&class_Vtbl,      // pVtbl
          sizeof(VALUE_CLASS_DATA),                  // cbSize
          0,                                      // cbFlags
          1,                                      // cbRetainCount
          {0}                                     // cbMisc
      },
  	//0
  };
  
  
  
  //---------------------------------------------------------------
  //          S i n g l e t o n  M e t h o d s
  //---------------------------------------------------------------
  
  #ifdef  VALUE_SINGLETON
  VALUE_DATA *     Value_getSingleton (
      void
  )
  {
      return (OBJ_ID)(Value_ClassObj.pSingleton);
  }
  
  
  bool            Value_setSingleton (
      VALUE_DATA       *pValue
  )
  {
      PSXLOCK_DATA    *pLock = OBJ_NIL;
      bool            fRc;
      
      pLock = psxLock_New( );
      if (OBJ_NIL == pLock) {
          DEBUG_BREAK();
          return false;
      }
      fRc = psxLock_Lock(pLock);
      if (!fRc) {
          DEBUG_BREAK();
          obj_Release(pLock);
          pLock = OBJ_NIL;
          return false;
      }
      
      obj_Retain(pValue);
      if (Value_ClassObj.pSingleton) {
          obj_Release((OBJ_ID)(Value_ClassObj.pSingleton));
      }
      Value_ClassObj.pSingleton = pValue;
      
      fRc = psxLock_Unlock(pLock);
      obj_Release(pLock);
      pLock = OBJ_NIL;
      return true;
  }
  
  
  
  VALUE_DATA *     Value_Shared (
      void
  )
  {
      VALUE_DATA       *this = (OBJ_ID)(Value_ClassObj.pSingleton);
      
      if (NULL == this) {
          this = Value_New( );
          Value_setSingleton(this);
          obj_Release(this);          // Shared controls object retention now.
          // Value_ClassObj.pSingleton = OBJ_NIL;
      }
      
      return this;
  }
  
  
  
  void            Value_SharedReset (
      void
  )
  {
      VALUE_DATA       *this = (OBJ_ID)(Value_ClassObj.pSingleton);
      
      if (this) {
          obj_Release(this);
          Value_ClassObj.pSingleton = OBJ_NIL;
      }
      
  }
  
  
  
  #endif
  
  
  
  //---------------------------------------------------------------
  //                     Q u e r y  I n f o
  //---------------------------------------------------------------
  
  static
  void *          ValueClass_QueryInfo (
      OBJ_ID          objId,
      uint32_t        type,
      void            *pData
  )
  {
      VALUE_CLASS_DATA *this = objId;
      const
      char            *pStr = pData;
      
      if (OBJ_NIL == this) {
          return NULL;
      }
      
      switch (type) {
        
          case OBJ_QUERYINFO_TYPE_OBJECT_SIZE:
              return (void *)sizeof(VALUE_DATA);
              break;
              
          case OBJ_QUERYINFO_TYPE_CLASS_OBJECT:
              return this;
              break;
              
          // Query for an address to specific data within the object.  
          // This should be used very sparingly since it breaks the 
          // object's encapsulation.                 
          case OBJ_QUERYINFO_TYPE_DATA_PTR:
              switch (*pStr) {
   
                  case 'C':
                      if (str_Compare("ClassInfo", (char *)pStr) == 0) {
                          return (void *)&Value_Info;
                      }
                      break;
                      
                  case 'S':
                      if (str_Compare("SuperClass", (char *)pStr) == 0) {
                          return (void *)&Value_Info.pClassSuperObject;
                      }
                  default:
                      break;
              }
              break;
              
          case OBJ_QUERYINFO_TYPE_INFO:
              return (void *)obj_getInfo(this);
              break;
              
          case OBJ_QUERYINFO_TYPE_METHOD:
              switch (*pStr) {
                      
                  case 'N':
                      if (str_Compare("New", (char *)pStr) == 0) {
                          return Value_New;
                      }
                      break;
                      
                  case 'P':
  #ifdef  W32STRC_JSON_SUPPORT
  					if (str_Compare("ParseJsonFields", (char *)pStr) == 0) {
  						return Value_ParseJsonFields;
  					}
  					if (str_Compare("ParseJsonObject", (char *)pStr) == 0) {
  						return Value_ParseJsonObject;
  					}
  #endif
                      break;
   
                  case 'T':
  #ifdef  W32STRC_JSON_SUPPORT
  					if (str_Compare("ToJsonFields", (char *)pStr) == 0) {
  						return Value_ToJsonFields;
  					}
  					if (str_Compare("ToJson", (char *)pStr) == 0) {
  						return Value_ToJson;
  					}
  #endif
                      break;
  
                   case 'W':
                      if (str_Compare("WhoAmI", (char *)pStr) == 0) {
                          return ValueClass_WhoAmI;
                      }
                      break;
                      
                  default:
                      break;
              }
              break;
              
          default:
              break;
      }
      
      return NULL;
  }
  
  
  
  
  static
  bool            Value_IsKindOf (
      uint16_t		classID
  )
  {
      OBJ_DATA        *pObj;
      const
      OBJ_INFO        *pInfo;
  
      if (OBJ_IDENT_VALUE == classID) {
         return true;
      }
      if (OBJ_IDENT_OBJ == classID) {
         return true;
      }
  
      pObj = obj_getInfo(Value_Class())->pClassSuperObject;
      if (pObj == obj_BaseClass())
          ;
      else {
          pInfo = obj_getInfo(pObj);
          return pInfo->pDefaultVtbls->pIsKindOf(classID);
      }
      
      return false;
  }
  
  
  // Dealloc() should be put into the Internal Header as well
  // for classes that get inherited from.
  void            Value_Dealloc (
      OBJ_ID          objId
  );
  
  
  OBJ_ID          Value_Class (
      void
  )
  {
      return (OBJ_ID)&Value_ClassObj;
  }
  
  
  static
  uint16_t		Value_WhoAmI (
      void
  )
  {
      return OBJ_IDENT_VALUE;
  }
  
  
  
  
  
  //===========================================================
  //                  Object Vtbl Definition
  //===========================================================
  
  const
  VALUE_VTBL     Value_Vtbl = {
      {
          &Value_Info,
          Value_IsKindOf,
  #ifdef  VALUE_IS_SINGLETON
          obj_RetainNull,
          obj_ReleaseNull,
  #else
          obj_RetainStandard,
          obj_ReleaseStandard,
  #endif
          Value_Dealloc,
          Value_Class,
          Value_WhoAmI,
          (P_OBJ_QUERYINFO)Value_QueryInfo,
          (P_OBJ_TOSTRING)Value_ToDebugString,
          NULL,			// Value_Enable,
          NULL,			// Value_Disable,
          (P_OBJ_ASSIGN)Value_Assign,
          (P_OBJ_COMPARE)Value_Compare,
          (P_OBJ_PTR)Value_Copy,
          NULL, 			// (P_OBJ_PTR)Value_DeepCopy,
          NULL 			// (P_OBJ_HASH)Value_Hash,
      },
      // Put other object method names below this.
      // Properties:
      // Methods:
      //Value_IsEnabled,
   
  };
  
  
  
  static
  const
  OBJ_INFO        Value_Info = {
      "Value",
      "Primitive Value",
      (OBJ_DATA *)&Value_ClassObj,
      (OBJ_DATA *)&obj_ClassObj,
      (OBJ_IUNKNOWN *)&Value_Vtbl,
      sizeof(VALUE_DATA)
  };
  
  
  
  
  
  