Example #1
0
static void PrintObject(JSObject* obj, int depth, ObjectPile* pile)
{
    PrintObjectBasics(obj);

    switch(pile->Visit(obj))
    {
    case ObjectPile::primary:
        puts("");
        break;
    case ObjectPile::seen:
        puts(" (SEE ABOVE)");
        return;
    case ObjectPile::overflow:
        puts(" (TOO MANY OBJECTS)");
        return;
    }

    if(!OBJ_IS_NATIVE(obj))
        return;

    JSObject* parent = (JSObject*)(obj->slots[JSSLOT_PARENT]);
    JSObject* proto  = (JSObject*)(obj->slots[JSSLOT_PROTO]);

    printf("%*sparent: ", INDENT(depth+1));
    if(parent)
        PrintObject(parent, depth+1, pile);
    else
        puts("null");
    printf("%*sproto: ", INDENT(depth+1));
    if(proto)
        PrintObject(proto, depth+1, pile);
    else
        puts("null");
}
void CBaseObject::ValidateIndex(void)
{
	CChars			sz;

	if (IsEmbedded())
	{
		if (moi != INVALID_O_INDEX)
		{
			sz.Init();
			PrintObject(&sz, IsEmbedded());
			gcLogger.Error2(__METHOD__, " Object {", sz.Text(), "} should have an Index [", IndexToString(moi), "] of INVALID_O_INDEX [", IndexToString(INVALID_O_INDEX),"].", NULL);
			sz.Kill();
		}
	}
	else
	{
		if (moi == INVALID_O_INDEX)
		{
			sz.Init();
			PrintObject(&sz, IsEmbedded());
			gcLogger.Error2(__METHOD__, " Object {", sz.Text(), "} should not have an Index of INVALID_O_INDEX [", IndexToString(INVALID_O_INDEX),"].", NULL);
			sz.Kill();
		}
	}
}
Example #3
0
static void PrintObject(JSObject* obj, int depth, ObjectPile* pile)
{
    PrintObjectBasics(obj);

    switch(pile->Visit(obj))
    {
    case ObjectPile::primary:
        puts("");
        break;
    case ObjectPile::seen:
        puts(" (SEE ABOVE)");
        return;
    case ObjectPile::overflow:
        puts(" (TOO MANY OBJECTS)");
        return;
    }

    if(!JS_IsNative(obj))
        return;

    JSObject* parent = js::GetObjectParent(obj);
    JSObject* proto  = js::GetObjectProto(obj);

    printf("%*sparent: ", INDENT(depth+1));
    if(parent)
        PrintObject(parent, depth+1, pile);
    else
        puts("null");
    printf("%*sproto: ", INDENT(depth+1));
    if(proto)
        PrintObject(proto, depth+1, pile);
    else
        puts("null");
}
void CBaseObject::ValidateObjectsThisIn(void)
{
	CChars			sz;

	if (IsEmbedded())
	{
		if (mpcObjectsThisIn != NULL)
		{
			sz.Init();
			PrintObject(&sz, IsEmbedded());
			gcLogger.Error2(__METHOD__, " Object {", sz.Text(), "} should not have ObjectsThisIn [", PointerToString(mpcObjectsThisIn), "] set.", NULL);
			sz.Kill();
		}
	}
	else
	{
		if (mpcObjectsThisIn == NULL)
		{
			sz.Init();
			PrintObject(&sz, IsEmbedded());
			gcLogger.Error2(__METHOD__, " Object {", sz.Text(), "} should have ObjectsThisIn [NULL] set.", NULL);
			sz.Kill();
		}
	}
}
void CEmbeddedObject::ValidateFrom(CBaseObject* pcBaseObject)
{
	CChars	szObject;
	CChars	szFromObject;
	int		iThisDistToRoot;
	int		iOtherDistToRoot;
	BOOL	bFromPointsTo;

	iThisDistToRoot = GetDistToRoot();
	iOtherDistToRoot = pcBaseObject->GetDistToRoot();
	if ((iThisDistToRoot >= ROOT_DIST_TO_ROOT && iOtherDistToRoot >= ROOT_DIST_TO_ROOT) && (iOtherDistToRoot < iThisDistToRoot - 1))
	{
		szObject.Init();
		PrintObject(&szObject, IsEmbedded());
		szFromObject.Init();
		pcBaseObject->PrintObject(&szFromObject, pcBaseObject->IsEmbedded());
		gcLogger.Error2(__METHOD__, " Object {", szObject.Text(), "} pointed to from object {", szFromObject.Text(), "} cannot have a DistToRoot that is different by more than 1.", NULL);
		szFromObject.Kill();
		szObject.Kill();
	}

	bFromPointsTo = pcBaseObject->ContainsPointerTo(this);
	if (!bFromPointsTo)
	{
		szObject.Init();
		PrintObject(&szObject, IsEmbedded());
		szFromObject.Init();
		pcBaseObject->PrintObject(&szFromObject, pcBaseObject->IsEmbedded());
		gcLogger.Error2(__METHOD__, " Object {", szObject.Text(), "} pointed to from object {", szFromObject.Text(), "} does not have a from pointing to.", NULL);
		szFromObject.Kill();
		szObject.Kill();
	}
}
void CBaseObject::ValidateDistToRoot(void)
{
	CChars			sz;
	CBaseObject*	pcContainer;

	if (!((miDistToRoot >= ROOT_DIST_TO_ROOT) || (miDistToRoot == UNATTACHED_DIST_TO_ROOT)))
	{
		sz.Init();
		PrintObject(&sz, IsEmbedded());
		gcLogger.Error2(__METHOD__, " Object {", sz.Text(), "} should not have a dist to root of [", IntToString(miDistToRoot), "].", NULL);
		sz.Kill();
	}

	if (IsEmbedded())
	{
		pcContainer = GetEmbeddingContainer();
		if (pcContainer->GetDistToRoot() != GetDistToRoot())
		{
			sz.Init();
			PrintObject(&sz, IsEmbedded());
			gcLogger.Error2(__METHOD__, " Object {", sz.Text(), "} should have a dist to root [", IntToString(miDistToRoot), "] the same as it's embedding object [", IntToString(pcContainer->GetDistToRoot()),"].", NULL);
			sz.Kill();
		}
	}
}
void CBaseObject::ValidateCanFindRoot(void)
{
	ValidateNotEmbedded(__METHOD__);

	CChars			sz;
	BOOL			bCanFindRoot;

	if (miDistToRoot > ROOT_DIST_TO_ROOT)
	{
		bCanFindRoot = CanFindRoot();

		if (!bCanFindRoot)
		{
			sz.Init();
			PrintObject(&sz, IsEmbedded());
			gcLogger.Error2(__METHOD__, " Object {", sz.Text(), "} has a positive dist to root and should be able to find the Root object.", NULL);
			sz.Kill();
		}
	}
	else if (miDistToRoot == ROOT_DIST_TO_ROOT)
	{
		if (!IsRoot())
		{
			sz.Init();
			PrintObject(&sz, IsEmbedded());
			gcLogger.Error2(__METHOD__, " Object {", sz.Text(), "} has a dist to root [0] but is not the Root object.", NULL);
			sz.Kill();
		}
	}
	else if (miDistToRoot == UNATTACHED_DIST_TO_ROOT)
	{
		bCanFindRoot = CanFindRoot();

		if (bCanFindRoot)
		{
			sz.Init();
			PrintObject(&sz, IsEmbedded());
			gcLogger.Error2(__METHOD__, " Object {", sz.Text(), "} has an [UNATTACHED_DIST_TO_ROOT] dist to root should not be able to find the Root object.", NULL);
			sz.Kill();
		}
	}
	else if (miDistToRoot == CLEARED_DIST_TO_ROOT)
	{
		sz.Init();
		PrintObject(&sz, IsEmbedded());
		gcLogger.Error2(__METHOD__, " Object {", sz.Text(), "} should not have dist to root [CLEARED_DIST_TO_ROOT].", NULL);
		sz.Kill();
	}
	else
	{
		sz.Init();
		PrintObject(&sz, IsEmbedded());
		gcLogger.Error2(__METHOD__, " Object {", sz.Text(), "} should not have dist to root [", IntToString(miDistToRoot), "].", NULL);
		sz.Kill();
	}
}
Example #8
0
/* printing functions */
void PrintValue(VALUE value)
{
    switch (value.type)
    {
        case VAL_PRIMITIVE: 
//#ifdef WIN32
//            printf("%l64i", value.data.primitive); 
//#else
            printf("%lli", value.data.primitive); 
//#endif
            break;
        case VAL_FLOATING_POINT: 
            if (_SUPPORTS_80BIT_FLOATING_POINT)
            {
                printf("%.18Lg", value.data.floatp);
                break;
            } else {
                printf("%.16Lg", value.data.floatp); 
                break;
            }
        case VAL_STRING: printf("%s", value.data.string); break;
        case VAL_REFERENCE: PrintObject(value.data.reference); break;
        case VAL_FUNCTION: PrintFunction(value.data.function); break;
        case VAL_DICTIONARY: PrintDictionary(value.data.dictionary); break;
    default:
        case VAL_NIL: printf("[NIL]"); break;
    }
}
Example #9
0
void QUserPanel::DropItem(const char* itemname, TClass* cl, int kind)
{
   switch (TabWidget->currentIndex()) {
      case 0:
         DragLbl->setText("User dropped item");
         DragItemLbl->setText(itemname);
         DragClassLbl->setText(cl==0 ? "No class specified" : cl->GetName());
         DragKindLbl->setText(kindString(kind));
         break;
      case 1:
         if (cl==0) {
            PrintLbl->setText("Can not drop item of uncknown class");
         } else {
            PrintLbl->setText(QString("Print item: ") + itemname);
            RemoveLink("PrintItem");
            AddLink(itemname, "PrintItem");
            PrintObject(GetLinked("PrintItem", 2));
         }

         break;
      case 2:
        DrawObjectOnCanvas(itemname);
        break;
   }
}
Example #10
0
File: objects.c Project: IAPark/vlc
static int VarsCommand (vlc_object_t *obj, char const *cmd,
                        vlc_value_t oldval, vlc_value_t newval, void *data)
{
    void *p;

    (void) cmd; (void) oldval; (void) data;

    if (sscanf (newval.psz_string, "%p", &p) == 1)
    {
        p = ObjectExists (obj, p);
        if (p == NULL)
        {
            msg_Err (obj, "no such object: %s", newval.psz_string);
            return VLC_ENOOBJ;
        }
        obj = p;
    }
    else
        vlc_object_hold (obj);

    PrintObject (obj, "");
    DumpVariables (obj);
    vlc_object_release (obj);

    return VLC_SUCCESS;
}
void CBaseObject::DumpFroms(void)
{
	CChars				sz;
	int					i;
	int					iNumEmbedded;
	CEmbeddedObject*	pcEmbedded;
	int					j;
	int					iNumHeapFroms;
	CBaseObject*		pcFromObject;
	int					iLength;
	CChars				szLine;

	sz.Init();

	sz.Append("-- ");
	PrintObject(&sz);
	sz.Append(" --\n");
	iLength = sz.Length()-1;

	szLine.Init('-', iLength);
	szLine.AppendNewLine();

	sz.Insert(0, &szLine);
	sz.Append("Total Heap Froms [");
	sz.Append(NumHeapFroms());
	sz.Append("], ");

	sz.Append("Stack Froms [");
	sz.Append(NumStackFroms());
	sz.Append("]\n");

	iNumEmbedded = GetNumEmbedded();
	for (i = 0; i < iNumEmbedded; i++)
	{
		pcEmbedded = GetEmbeddedObject(i);
		iNumHeapFroms = pcEmbedded->CEmbeddedObject::NumHeapFroms();
		sz.Append("Embedded ");
		sz.Append(i);
		sz.Append(" Heap Froms [");
		sz.Append(iNumHeapFroms);
		sz.Append("], ");
		sz.Append("Stack Froms [");
		sz.Append(pcEmbedded->CEmbeddedObject::NumStackFroms());
		sz.Append("]\n");

		for (j = 0; j < iNumHeapFroms; j++)
		{
			pcFromObject = pcEmbedded->GetHeapFrom(j);
			sz.Append(" ");
			pcFromObject->PrintObject(&sz);
			sz.AppendNewLine();
		}
	}

	sz.Append(&szLine);
	szLine.Kill();

	sz.Dump();
	sz.Kill();
}
Example #12
0
/**
 * @brief Returns the Json representation of a Json Object.
 */
std::string JsonProcessor::PrintObject (const JsonValueObject* value, const int indent_level)
{
    int il = indent_level + 1;
    std::string in (il * indent, ' ');
    std::stringstream ss;
    ss << "{";

    bool first = true;
    for (JsonValueObject::const_iterator it = value->cbegin(); it != value->cend(); ++it) {
        JsonValueObject::ObjectPair v = *it;
        if (!first) {
            ss << ",";
        }
        ss << "\n" << in << "\"" << v.first << "\": ";
        if (v.second->IsArray()) {
            ss << PrintArray(JsonValueToArray(v.second), il);
        } else if (v.second->IsObject()) {
            ss << PrintObject(JsonValueToObject(v.second), il);
        } else {
            ss << PrintValue(v.second);
        }
        first = false;
    }

    ss << "\n" << std::string(indent_level * indent, ' ') << "}";
    return ss.str();
}
Example #13
0
File: objects.c Project: paa/vlc
static void DumpStructure (vlc_object_internals_t *priv, unsigned i_level,
                           char *psz_foo)
{
    char i_back = psz_foo[i_level];
    psz_foo[i_level] = '\0';

    PrintObject (priv, psz_foo);

    psz_foo[i_level] = i_back;

    if( i_level / 2 >= MAX_DUMPSTRUCTURE_DEPTH )
    {
        msg_Warn( vlc_externals(priv), "structure tree is too deep" );
        return;
    }

    for (priv = priv->first; priv != NULL; priv = priv->next)
    {
        if( i_level )
        {
            psz_foo[i_level-1] = ' ';

            if( psz_foo[i_level-2] == '`' )
            {
                psz_foo[i_level-2] = ' ';
            }
        }

        psz_foo[i_level] = priv->next ? '|' : '`';
        psz_foo[i_level+1] = '-';
        psz_foo[i_level+2] = '\0';

        DumpStructure (priv, i_level + 2, psz_foo);
    }
}
void CBaseObject::ValidateContainerFlag(void)
{
	CChars	sz;
	int		iEmbeddedFlags;
	int		iThisFlags;
	int		iIgnoredFlags;
	char*	szEmbeddedFlags;
	char*	szFlags;
	char*	szIgnoredFlags;

	if (IsEmbedded())
	{
		iIgnoredFlags = OBJECT_FLAGS_CALLED_CLASS;
		iEmbeddedFlags = mpcEmbedded->miFlags & ~iIgnoredFlags;
		iThisFlags = miFlags & ~iIgnoredFlags;
		if ((iEmbeddedFlags) != (iThisFlags))
		{
			sz.Init();
			PrintObject(&sz, IsEmbedded());
			szFlags = ShortToFlags(miFlags);
			szEmbeddedFlags = ShortToFlags(mpcEmbedded->miFlags);
			szIgnoredFlags = ShortToFlags(iIgnoredFlags);
			ReplaceOneWithX(szFlags, szIgnoredFlags);
			ReplaceOneWithX(szEmbeddedFlags, szIgnoredFlags);

			gcLogger.Error2(__METHOD__, " Object {", sz.Text(), "} should have the same flags [", szFlags ,"] as it's embedding container's flags [", szEmbeddedFlags, "].", NULL);
			sz.Kill();
		}
	}
}
void CBaseObject::ValidateInitCalled(void)
{
	CChars	szObject;

	if (miPreInits != miPostInits)
	{
		szObject.Init();
		PrintObject(&szObject, IsEmbedded());
		gcLogger.Error2(__METHOD__, " Object {", szObject.Text(), "} has pre-inits [", IntToString(miPreInits), "] not equal to post inits [", IntToString(miPostInits), "].", NULL);
		szObject.Kill();
	}
	else if (miPreInits == 0)
	{
		szObject.Init();
		PrintObject(&szObject, IsEmbedded());
		gcLogger.Error2(__METHOD__, " Object {", szObject.Text(), "} has a pre-init of zero.", NULL);
		szObject.Kill();
	}
}
//-----------------------------------------------------------------------------
// Function:    DisplayObjectChanged
// Purpose:     Called to display a PPEER_EVENT_OBJECT_CHANGED_DATA structure
// Parameters:  
//   pObjectChangedData    [in] : pointer to a PPEER_EVENT_OBJECT_CHANGED_DATA structure
//
void DisplayObjectChanged(const PEER_EVENT_OBJECT_CHANGED_DATA *pObjectChangedData)
{
    if (pObjectChangedData)
    { 
        PrintContact(pObjectChangedData->pContact);
        PrintEndpoint(pObjectChangedData->pEndpoint);
        wprintf(L"\tChange Type: %s\n", ChangeType(pObjectChangedData->changeType));
        PrintObject(pObjectChangedData->pObject);
    }
}
//-----------------------------------------------------------------------------
// Function:    DisplayEndpointObjects
// Purpose:     Retrieves and displays object information from an endpoint. 
//              Should call PeerCollabRefreshEndpointData before using this function.
// Parameters:  
//   PCPEER_ENDPOINT : [in] endpoint about which information is displayed
//
HRESULT DisplayEndpointObjects(__in PCPEER_ENDPOINT pcEndpoint)
{
    HPEERENUM           hObjectEnum = NULL;
    ULONG               cObjects = 0;
    ULONG               i = 0;
    PPEER_OBJECT*       ppObjects = NULL;
    HRESULT             hr = S_OK;

    // Get a list of objects published by this endpoint - The NULL parameter
    // indicates that we wish to retrieve all objects
    hr = PeerCollabEnumObjects(pcEndpoint, NULL, &hObjectEnum);
    
    if (FAILED(hr))
    {
        wprintf(L"Error retrieving objects. HRESULT=0x%x\n", hr);
        PrintError(hr);
        goto exit;
    }

    hr = PeerGetItemCount(hObjectEnum, &cObjects);

    if (FAILED(hr))
    {
        wprintf(L"Error retrieving item count. HRESULT=0x%x\n", hr);
        PrintError(hr);
        goto exit;
    }

    if (cObjects == 0)
    {
        wprintf(L"No objects found for this endpoint\n");
        hr = E_FAIL;
        goto exit;
    }

    hr = PeerGetNextItem(hObjectEnum, &cObjects, (PVOID **) &ppObjects);

    if (FAILED(hr))
    {
        wprintf(L"PeerGetNextItem failed. HRESULT=0x%x\n", hr);
        goto exit;
    }

    for (i = 0; i < cObjects; i++)
    {
        PrintObject(ppObjects[i]);
    }


exit:
    SAFE_PEER_FREE_DATA(ppObjects);
    SAFE_PEER_END_ENUMERATION(hObjectEnum);

    return hr;
}
Example #18
0
void QUserPanel::linkedObjectRemoved(const char* linkname)
{
    if (strcmp(linkname, "PrintItem")==0)
      PrintObject(0);
    else
    if (strcmp(linkname, "DrawItem")==0) {
      RemoveLink("DrawItem");
      fxDrawCanvas->getCanvas()->Clear();
      fxDrawCanvas->getCanvas()->Update();
    }
}
void CBaseObject::ValidateFlagSet(int iFlag, char* szFlag)
{
	CChars	sz;

	if (!(miFlags & iFlag))
	{
		sz.Init();
		PrintObject(&sz, IsEmbedded());
		gcLogger.Error2(__METHOD__, " Object {", sz.Text(), "} should have flag [", szFlag,"] set.", NULL);
		sz.Kill();
	}
}
Example #20
0
void QUserPanel::linkedObjectUpdated(const char* linkname, TObject* obj)
{
    if (strcmp(linkname, "PrintItem")==0)
      PrintObject(obj);
    else
    if (strcmp(linkname, "DrawItem")==0) {
       fxDrawCanvas->getCanvas()->Clear();
       fxDrawCanvas->getCanvas()->cd();
       obj->Draw("");
       fxDrawCanvas->getCanvas()->Update();
    }
}
void CBaseObject::ValidateHasClass(void)
{
	CChars sz;

	if (!HasClass())
	{
		sz.Init();
		PrintObject(&sz, IsEmbedded());

		gcLogger.Error2(__METHOD__, " Object {", sz.Text(), "} does not have Class initialised.", NULL);

		sz.Kill();
	}
}
Example #22
0
File: objects.c Project: paa/vlc
/*****************************************************************************
 * DumpCommand: print the current vlc structure
 *****************************************************************************
 * This function prints either an ASCII tree showing the connections between
 * vlc objects, and additional information such as their refcount, thread ID,
 * etc. (command "tree"), or the same data as a simple list (command "list").
 *****************************************************************************/
static int DumpCommand( vlc_object_t *p_this, char const *psz_cmd,
                        vlc_value_t oldval, vlc_value_t newval, void *p_data )
{
    (void)oldval; (void)p_data;
    vlc_object_t *p_object = NULL;

    if( *newval.psz_string )
    {
        /* try using the object's name to find it */
        p_object = vlc_object_find_name( p_this, newval.psz_string,
                                         FIND_ANYWHERE );
        if( !p_object )
        {
            return VLC_ENOOBJ;
        }
    }

    libvlc_lock (p_this->p_libvlc);
    if( *psz_cmd == 't' )
    {
        char psz_foo[2 * MAX_DUMPSTRUCTURE_DEPTH + 1];

        if( !p_object )
            p_object = VLC_OBJECT(p_this->p_libvlc);

        psz_foo[0] = '|';
        DumpStructure( vlc_internals(p_object), 0, psz_foo );
    }
    else if( *psz_cmd == 'v' )
    {
        if( !p_object )
            p_object = p_this->p_libvlc ? VLC_OBJECT(p_this->p_libvlc) : p_this;

        PrintObject( vlc_internals(p_object), "" );
        vlc_mutex_lock( &vlc_internals( p_object )->var_lock );
        if( vlc_internals( p_object )->var_root == NULL )
            puts( " `-o No variables" );
        else
            twalk( vlc_internals( p_object )->var_root, DumpVariable );
        vlc_mutex_unlock( &vlc_internals( p_object )->var_lock );
    }
    libvlc_unlock (p_this->p_libvlc);

    if( *newval.psz_string )
    {
        vlc_object_release( p_object );
    }
    return VLC_SUCCESS;
}
Example #23
0
int runABETest(Charm_t *pGroup)
{
	Charm_t *pClass = NULL;

    pClass = InitScheme("abenc_bsw07", "CPabe_BSW07", pGroup);
    if(pClass == NULL) return -1;

    Charm_t *pKeys = CallMethod(pClass, "setup", "");
    debug("setup ok.\n");

	Charm_t *pkDict = GetIndex(pKeys, 0);
	Charm_t *mskDict = GetIndex(pKeys, 1);

	Charm_t *pValue = GetDict(pkDict, "g");
	Charm_t *pValue1 = GetDict(mskDict, "beta");

	char *attrList = "[ONE, TWO]";

	debug("calling keygen...\n");
	char *policy = "((THREE or ONE) and (THREE or TWO))";
	printf("attribute: '%s'\n", attrList);
	printf("enc policy: '%s'\n", policy);
	Charm_t *skDict = CallMethod(pClass, "keygen", "%O%O%A", pkDict, mskDict, attrList);

	Charm_t *pValue2 = GetDict(skDict, "D");

	Charm_t *msg = CallMethod(pGroup, "random", "%I", GT);
	Charm_t *ctDict = CallMethod(pClass, "encrypt", "%O%O%s", pkDict, msg, policy);
	Charm_t *pValue3 = GetDict(ctDict, "C_tilde");

	Charm_t *pValue4 = CallMethod(pClass, "decrypt", "%O%O%O", pkDict, skDict, ctDict);

	PrintObject(pValue);
	PrintObject(pValue1);
	PrintObject(pValue2);
	printf("ct :=> \n");
	PrintObject(pValue3);
	printf("msg :=> \n");
	PrintObject(msg);
	printf("rec msg :=> \n");
	PrintObject(pValue4);

	Free(pValue);
	Free(pValue1);
	Free(pValue2);
	Free(pValue3);
	Free(pValue4);
	Free(skDict);
	Free(pkDict);
	Free(mskDict);
	Free(pKeys);
	Free(pClass);
    return 0;
}
Example #24
0
JSBool
xpc_DumpJSObject(JSObject* obj)
{
    ObjectPile pile;

    puts("Debugging reminders...");
    puts("  class:  (JSClass*)(obj->fslots[2]-1)");
    puts("  parent: (JSObject*)(obj->fslots[1])");
    puts("  proto:  (JSObject*)(obj->fslots[0])");
    puts("");

    if(obj)
        PrintObject(obj, 0, &pile);
    else
        puts("xpc_DumpJSObject passed null!");

    return JS_TRUE;
}
void CEmbeddedObject::ValidatePointerTo(CEmbeddedObject* pcPointedTo)
{
	CChars	szObject;
	CChars	szToObject;
	BOOL	bToPointsToFrom;

	bToPointsToFrom = pcPointedTo->ContainsFrom(this);
	if (!bToPointsToFrom)
	{
		szObject.Init();
		PrintObject(&szObject, IsEmbedded());
		szToObject.Init();
		pcPointedTo->PrintObject(&szToObject, pcPointedTo->IsEmbedded());
		gcLogger.Error2(__METHOD__, " Object {", szObject.Text(), "} pointing to object {", szToObject.Text(), "} does not have a from pointing to.", NULL);
		szToObject.Kill();
		szObject.Kill();
	}
}
Example #26
0
JSBool
xpc_DumpJSObject(JSObject* obj)
{
    ObjectPile pile;

    DebugDump("%s", "Debugging reminders...\n");
    DebugDump("%s", "  class:  (JSClass*)(obj->fslots[2]-1)\n");
    DebugDump("%s", "  parent: (JSObject*)(obj->fslots[1])\n");
    DebugDump("%s", "  proto:  (JSObject*)(obj->fslots[0])\n");
    DebugDump("%s", "\n");

    if (obj)
        PrintObject(obj, 0, &pile);
    else
        DebugDump("%s", "xpc_DumpJSObject passed null!\n");

    return true;
}
Example #27
0
/* duck.print(arg1), duck.println(arg1) */
int DuckPrint(int argument_count)
{
    int error = 0;
    VALUE argument = GetRecord("output", gCurrentContext);
    
    if (argument.type == VAL_PRIMITIVE)
    {
        printf("%i", argument.primitive);
    }
    else if (argument.type == VAL_FLOATING_POINT)
    {
        printf("%g", argument.floatp);
    }
    else if (argument.type == VAL_STRING)
    {
        printf("%s", argument.string);
    }
    else if (argument.type == VAL_REFERENCE)
    {
        PrintObject(argument.reference);
    }
    else if (argument.type == VAL_FUNCTION)
    {
        printf("f(");
        PAIR* list = argument.function->parameters;
        while (list)
        {
            printf("%s", list->identifier);
            if (list->next)
                printf(", ");
            list = list->next;
        }
        printf(")");
    }
    else
    {
        printf("[NIL]");
    }
    
    gLastExpression.type = VAL_NIL;
    printf("\n");

    return error;
}
Example #28
0
static void DumpStructure( vlc_object_t *p_this, int i_level, char *psz_foo )
{
    int i;
    char i_back = psz_foo[i_level];
    psz_foo[i_level] = '\0';

    PrintObject( p_this, psz_foo );

    psz_foo[i_level] = i_back;

    if( i_level / 2 >= MAX_DUMPSTRUCTURE_DEPTH )
    {
        msg_Warn( p_this, "structure tree is too deep" );
        return;
    }

    for( i = 0 ; i < p_this->i_children ; i++ )
    {
        if( i_level )
        {
            psz_foo[i_level-1] = ' ';

            if( psz_foo[i_level-2] == '`' )
            {
                psz_foo[i_level-2] = ' ';
            }
        }

        if( i == p_this->i_children - 1 )
        {
            psz_foo[i_level] = '`';
        }
        else
        {
            psz_foo[i_level] = '|';
        }

        psz_foo[i_level+1] = '-';
        psz_foo[i_level+2] = '\0';

        DumpStructure( p_this->pp_children[i], i_level + 2, psz_foo );
    }
}
Example #29
0
/**
 * @brief Returns the Json representation of a Json Array.
 */
std::string JsonProcessor::PrintArray (const JsonValueArray* value, const int indent_level)
{
    int il = indent_level + 1;
    std::string in (il * indent, ' ');
    std::ostringstream ss;

    // check if array contains non-simple values. if so, we use better bracket
    // placement to make document look nicer
    bool has_large = false;
    for (JsonValueArray::const_iterator it = value->cbegin(); it != value->cend(); ++it) {
        JsonValue* v = *it;
        has_large |= (v->IsArray() || v->IsObject());
    }

    ss << "[ ";
    bool first = true;
    for (JsonValueArray::const_iterator it = value->cbegin(); it != value->cend(); ++it) {
        JsonValue* v = *it;
        if (!first) {
            ss << ", ";
        }
        if (has_large) {
            ss << "\n" << in;
        }
        if (v->IsArray()) {
            ss << PrintArray(JsonValueToArray(v), il);
        } else if (v->IsObject()) {
            ss << PrintObject(JsonValueToObject(v), il);
        } else {
            ss << PrintValue(v);
        }
        first = false;
    }

    if (has_large) {
        ss << "\n" << std::string(indent_level * indent, ' ');
    } else {
        ss << " ";
    }
    ss << "]";
    return ss.str();
}
//-----------------------------------------------------------------------------
// Render a value to text. 
char* JSON::PrintValue(int depth, bool fmt)
{
	char *out=0;

    switch (Type)
	{
        case JSON_Null:	    out = JSON_strdup("null");	break;
        case JSON_Bool:
            if ((int)dValue == 0)
                out = JSON_strdup("false");
            else
                out = JSON_strdup("true");
            break;
        case JSON_Number:	out = PrintNumber(dValue); break;
        case JSON_String:	out = PrintString(Value); break;
        case JSON_Array:	out = PrintArray(depth, fmt); break;
        case JSON_Object:	out = PrintObject(depth, fmt); break;
        case JSON_None: OVR_ASSERT_LOG(false, ("Bad JSON type.")); break;
	}
	return out;
}