当前位置: 首页>>代码示例>>C++>>正文


C++ NS_PTR_TO_INT32函数代码示例

本文整理汇总了C++中NS_PTR_TO_INT32函数的典型用法代码示例。如果您正苦于以下问题:C++ NS_PTR_TO_INT32函数的具体用法?C++ NS_PTR_TO_INT32怎么用?C++ NS_PTR_TO_INT32使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了NS_PTR_TO_INT32函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: GetCOMPtrCount

static int32_t* GetCOMPtrCount(void* aPtr)
{
  PLHashEntry** hep = PL_HashTableRawLookup(gSerialNumbers, PLHashNumber(NS_PTR_TO_INT32(aPtr)), aPtr);
  if (hep && *hep) {
    return &((reinterpret_cast<serialNumberRecord*>((*hep)->value))->COMPtrCount);
  } else {
    return nullptr;
  }
}
开发者ID:lail3344,项目名称:mozilla-central,代码行数:9,代码来源:nsTraceRefcntImpl.cpp

示例2: GetSerialNumber

static intptr_t GetSerialNumber(void* aPtr, bool aCreate)
{
  PLHashEntry** hep = PL_HashTableRawLookup(gSerialNumbers, PLHashNumber(NS_PTR_TO_INT32(aPtr)), aPtr);
  if (hep && *hep) {
    return reinterpret_cast<serialNumberRecord*>((*hep)->value)->serialNumber;
  }
  else if (aCreate) {
    serialNumberRecord *record = PR_NEW(serialNumberRecord);
    record->serialNumber = ++gNextSerialNumber;
    record->refCount = 0;
    record->COMPtrCount = 0;
    PL_HashTableRawAdd(gSerialNumbers, hep, PLHashNumber(NS_PTR_TO_INT32(aPtr)), aPtr, reinterpret_cast<void*>(record));
    return gNextSerialNumber;
  }
  else {
    return 0;
  }
}
开发者ID:lail3344,项目名称:mozilla-central,代码行数:18,代码来源:nsTraceRefcntImpl.cpp

示例3: NS_ASSERTION

// static
nsHTMLTag
nsHTMLTags::CaseSensitiveLookupTag(const PRUnichar* aTagName)
{
  NS_ASSERTION(gTagTable, "no lookup table, needs addref");
  NS_ASSERTION(aTagName, "null tagname!");

  PRUint32 tag = NS_PTR_TO_INT32(PL_HashTableLookupConst(gTagTable, aTagName));

  return tag == eHTMLTag_unknown ? eHTMLTag_userdefined : (nsHTMLTag)tag;
}
开发者ID:BigManager,项目名称:platform,代码行数:11,代码来源:nsHTMLTags.cpp

示例4:

PRBool
tmQueue::IsAttached(PRUint32 aClientID) {
  // XXX could be an issue if the aClientID is 0 and there
  // is a "hole" in the mListeners vector. - may NEED to store PRUint32*s
  PRUint32 size = mListeners.Size();
  for (PRUint32 index = 0; index < size; index++) {
    if (aClientID == (PRUint32)NS_PTR_TO_INT32(mListeners[index]))
      return PR_TRUE;
  }
  return PR_FALSE;
}
开发者ID:EdgarChen,项目名称:mozilla-cvs-history,代码行数:11,代码来源:tmQueue.cpp

示例5: NS_ASSERTION

PLHashNumber
nsNodeInfoManager::GetNodeInfoInnerHashValue(const void *key)
{
  NS_ASSERTION(key, "Null key passed to nsNodeInfo::GetHashValue!");

  const nsINodeInfo::nsNodeInfoInner *node =
    reinterpret_cast<const nsINodeInfo::nsNodeInfoInner *>(key);

  // Is this an acceptable hash value?
  return (PLHashNumber(NS_PTR_TO_INT32(node->mName)) & 0xffff) >> 8;
}
开发者ID:EdgarChen,项目名称:mozilla-cvs-history,代码行数:11,代码来源:nsNodeInfoManager.cpp

示例6: AssertActivityIsLegal

static void
AssertActivityIsLegal()
{
  if (gActivityTLS == BAD_TLS_INDEX ||
      NS_PTR_TO_INT32(PR_GetThreadPrivate(gActivityTLS)) != 0) {
    if (PR_GetEnv("MOZ_FATAL_STATIC_XPCOM_CTORS_DTORS")) {
      NS_RUNTIMEABORT(kStaticCtorDtorWarning);
    } else {
      NS_WARNING(kStaticCtorDtorWarning);
    }
  }
}
开发者ID:Tripleman,项目名称:mozilla-central,代码行数:12,代码来源:nsTraceRefcntImpl.cpp

示例7: NS_ASSERTION

nsresult
txMozillaXMLOutput::endHTMLElement(nsIContent* aElement)
{
    nsIAtom *atom = aElement->Tag();

    if (mTableState == ADDED_TBODY) {
        NS_ASSERTION(atom == txHTMLAtoms::tbody,
                     "Element flagged as added tbody isn't a tbody");
        PRUint32 last = mCurrentNodeStack.Count() - 1;
        NS_ASSERTION(last != (PRUint32)-1, "empty stack");

        mCurrentNode = mCurrentNodeStack.SafeObjectAt(last);
        mCurrentNodeStack.RemoveObjectAt(last);
        mTableState = static_cast<TableState>
                                 (NS_PTR_TO_INT32(mTableStateStack.pop()));

        return NS_OK;
    }
    else if (mCreatingNewDocument && atom == txHTMLAtoms::base &&
             !mHaveBaseElement) {
        // The first base wins
        mHaveBaseElement = PR_TRUE;

        nsAutoString value;
        aElement->GetAttr(kNameSpaceID_None, txHTMLAtoms::target, value);
        mDocument->SetBaseTarget(value);

        aElement->GetAttr(kNameSpaceID_None, txHTMLAtoms::href, value);
        nsCOMPtr<nsIURI> baseURI;
        NS_NewURI(getter_AddRefs(baseURI), value, nsnull);

        if (baseURI) {
            mDocument->SetBaseURI(baseURI); // The document checks if it is legal to set this base
        }
    }
    else if (mCreatingNewDocument && atom == txHTMLAtoms::meta) {
        // handle HTTP-EQUIV data
        nsAutoString httpEquiv;
        aElement->GetAttr(kNameSpaceID_None, txHTMLAtoms::httpEquiv, httpEquiv);
        if (!httpEquiv.IsEmpty()) {
            nsAutoString value;
            aElement->GetAttr(kNameSpaceID_None, txHTMLAtoms::content, value);
            if (!value.IsEmpty()) {
                ToLowerCase(httpEquiv);
                nsCOMPtr<nsIAtom> header = do_GetAtom(httpEquiv);
                processHTTPEquiv(header, value);
            }
        }
    }
    
    return NS_OK;
}
开发者ID:amyvmiwei,项目名称:firefox,代码行数:52,代码来源:txMozillaXMLOutput.cpp

示例8: NS_LogCOMPtrRelease

NS_LogCOMPtrRelease(void* aCOMPtr, nsISupports* aObject)
{
#if defined(NS_IMPL_REFCNT_LOGGING) && defined(HAVE_CPP_DYNAMIC_CAST_TO_VOID_PTR)
  // Get the most-derived object.
  void *object = dynamic_cast<void *>(aObject);

  // This is a very indirect way of finding out what the class is
  // of the object being logged.  If we're logging a specific type,
  // then
  if (!gTypesToLog || !gSerialNumbers) {
    return;
  }
  intptr_t serialno = GetSerialNumber(object, false);
  if (serialno == 0) {
    return;
  }

  if (!gInitialized)
    InitTraceLog();
  if (gLogging) {
    LOCK_TRACELOG();

    int32_t* count = GetCOMPtrCount(object);
    if(count)
      (*count)--;

    bool loggingThisObject = (!gObjectsToLog || LogThisObj(serialno));

    if (gCOMPtrLog && loggingThisObject) {
      fprintf(gCOMPtrLog, "\n<?> 0x%08X %ld nsCOMPtrRelease %d 0x%08X\n",
              NS_PTR_TO_INT32(object), serialno, count?(*count):-1, NS_PTR_TO_INT32(aCOMPtr));
      nsTraceRefcntImpl::WalkTheStack(gCOMPtrLog);
    }

    UNLOCK_TRACELOG();
  }
#endif
}
开发者ID:Tripleman,项目名称:mozilla-central,代码行数:38,代码来源:nsTraceRefcntImpl.cpp

示例9: uint32_t

void
LossyConvertEncoding16to8::write_sse2(const char16_t* aSource,
                                      uint32_t aSourceLength)
{
  char* dest = mDestination;

  // Align source to a 16-byte boundary.
  uint32_t i = 0;
  uint32_t alignLen =
    XPCOM_MIN<uint32_t>(aSourceLength, uint32_t(-NS_PTR_TO_INT32(aSource) & 0xf) / sizeof(char16_t));
  for (; i < alignLen; ++i) {
    dest[i] = static_cast<unsigned char>(aSource[i]);
  }

  // Walk 64 bytes (four XMM registers) at a time.
  __m128i vectmask = _mm_set1_epi16(0x00ff);
  for (; aSourceLength - i > 31; i += 32) {
    __m128i source1 = _mm_load_si128(reinterpret_cast<const __m128i*>(aSource + i));
    source1 = _mm_and_si128(source1, vectmask);

    __m128i source2 = _mm_load_si128(reinterpret_cast<const __m128i*>(aSource + i + 8));
    source2 = _mm_and_si128(source2, vectmask);

    __m128i source3 = _mm_load_si128(reinterpret_cast<const __m128i*>(aSource + i + 16));
    source3 = _mm_and_si128(source3, vectmask);

    __m128i source4 = _mm_load_si128(reinterpret_cast<const __m128i*>(aSource + i + 24));
    source4 = _mm_and_si128(source4, vectmask);


    // Pack the source data.  SSE2 views this as a saturating uint16_t to
    // uint8_t conversion, but since we masked off the high-order byte of every
    // uint16_t, we're really just grabbing the low-order bytes of source1 and
    // source2.
    __m128i packed1 = _mm_packus_epi16(source1, source2);
    __m128i packed2 = _mm_packus_epi16(source3, source4);

    // This store needs to be unaligned since there's no guarantee that the
    // alignment we did above for the source will align the destination.
    _mm_storeu_si128(reinterpret_cast<__m128i*>(dest + i),      packed1);
    _mm_storeu_si128(reinterpret_cast<__m128i*>(dest + i + 16), packed2);
  }

  // Finish up the rest.
  for (; i < aSourceLength; ++i) {
    dest[i] = static_cast<unsigned char>(aSource[i]);
  }

  mDestination += i;
}
开发者ID:afabbro,项目名称:gecko-dev,代码行数:50,代码来源:nsUTF8UtilsSSE2.cpp

示例10: TestCase_NestedLoop

void TestCase_NestedLoop(nsIThread *thread, PRInt32 index)
{
    nsCOMPtr<nsIProxyObjectManager> manager =
            do_GetService(NS_XPCOMPROXY_CONTRACTID);

    LOG(("TEST: ProxyObjectManager: %p\n", (void *) manager.get()));
    
    PR_ASSERT(manager);

    nsITestProxy         *proxyObject;
    nsTestXPCFoo2*        foo   = new nsTestXPCFoo2();
    
    PR_ASSERT(foo);
    
    
    manager->GetProxyForObject(thread, NS_GET_IID(nsITestProxy), foo, NS_PROXY_SYNC, (void**)&proxyObject);
    
    if (proxyObject)
    {
        // release ownership of the real object. 
        
        nsresult rv;
        
        LOG(("TEST: Deleting real Object (%d)\n", index));
        NS_RELEASE(foo);
   
        PRInt32 retval;
        
        LOG(("TEST: Getting EventThread...\n"));

        //nsCOMPtr<nsIThread> curThread = do_GetCurrentThread();
        PRThread *curThread = PR_GetCurrentThread();
        if (curThread)
        {
            LOG(("TEST: Thread (%d) Prior to calling proxyObject->Test.\n", index));
            rv = proxyObject->Test(NS_PTR_TO_INT32((void*)curThread), 0, &retval);   // XXX broken on 64-bit arch
            LOG(("TEST: Thread (%d) proxyObject error: %x.\n", index, rv));

            LOG(("TEST: Deleting Proxy Object (%d)\n", index));
            NS_RELEASE(proxyObject);
        }    

        PR_Sleep( PR_MillisecondsToInterval(1000) );  // If your thread goes away, your stack goes away.  Only use ASYNC on calls that do not have out parameters
    }
}
开发者ID:Akin-Net,项目名称:mozilla-central,代码行数:45,代码来源:proxytests.cpp

示例11: NS_ASSERTION

bool
nsSmallVoidArray::InsertElementAt(void* aElement, int32_t aIndex)
{
  NS_ASSERTION(!(NS_PTR_TO_INT32(aElement) & 0x1),
               "Attempt to add element with 0x1 bit set to nsSmallVoidArray");

  if (aIndex == 0 && IsEmpty()) {
    SetSingle(aElement);

    return true;
  }

  if (!EnsureArray()) {
    return false;
  }

  return AsArray()->InsertElementAt(aElement, aIndex);
}
开发者ID:hibrium,项目名称:Pale-Moon,代码行数:18,代码来源:nsVoidArray.cpp

示例12: NS_ASSERTION

PRBool
nsSmallVoidArray::AppendElement(void* aElement)
{
  NS_ASSERTION(!(NS_PTR_TO_INT32(aElement) & 0x1),
               "Attempt to add element with 0x1 bit set to nsSmallVoidArray");

  if (IsEmpty()) {
    SetSingle(aElement);
    
    return PR_TRUE;
  }

  if (!EnsureArray()) {
    return PR_FALSE;
  }

  return AsArray()->AppendElement(aElement);
}
开发者ID:LittleForker,项目名称:mozilla-central,代码行数:18,代码来源:nsVoidArray.cpp

示例13: FirstNon8BitUnvectorized

static inline PRInt32
FirstNon8BitUnvectorized(const PRUnichar *str, const PRUnichar *end)
{
#if PR_BYTES_PER_WORD == 4
    const size_t mask = 0xff00ff00;
    const PRUint32 alignMask = 0x3;
    const PRUint32 numUnicharsPerWord = 2;
#elif PR_BYTES_PER_WORD == 8
    const size_t mask = 0xff00ff00ff00ff00;
    const PRUint32 alignMask = 0x7;
    const PRUint32 numUnicharsPerWord = 4;
#else
#error Unknown platform!
#endif

    const PRInt32 len = end - str;
    PRInt32 i = 0;

    // Align ourselves to a word boundary.
    PRInt32 alignLen =
        NS_MIN(len, PRInt32(((-NS_PTR_TO_INT32(str)) & alignMask) / sizeof(PRUnichar)));
    for (; i < alignLen; i++) {
        if (str[i] > 255)
            return i;
    }

    // Check one word at a time.
    const PRInt32 wordWalkEnd = ((len - i) / numUnicharsPerWord) * numUnicharsPerWord;
    for (; i < wordWalkEnd; i += numUnicharsPerWord) {
        const size_t word = *reinterpret_cast<const size_t*>(str + i);
        if (word & mask)
            return i;
    }

    // Take care of the remainder one character at a time.
    for (; i < len; i++) {
        if (str[i] > 255)
            return i;
    }

    return -1;
}
开发者ID:harthur,项目名称:mozilla-central,代码行数:42,代码来源:nsTextFragment.cpp

示例14: XPCOM_MIN

void
LossyConvertEncoding8to16::write_sse2(const char* aSource,
                                      uint32_t aSourceLength)
{
  char16_t* dest = mDestination;

  // Align source to a 16-byte boundary.  We choose to align source rather than
  // dest because we'd rather have our loads than our stores be fast. You have
  // to wait for a load to complete, but you can keep on moving after issuing a
  // store.
  uint32_t i = 0;
  uint32_t alignLen = XPCOM_MIN(aSourceLength, uint32_t(-NS_PTR_TO_INT32(aSource) & 0xf));
  for (; i < alignLen; ++i) {
    dest[i] = static_cast<unsigned char>(aSource[i]);
  }

  // Walk 32 bytes (two XMM registers) at a time.
  for (; aSourceLength - i > 31; i += 32) {
    __m128i source1 = _mm_load_si128(reinterpret_cast<const __m128i*>(aSource + i));
    __m128i source2 = _mm_load_si128(reinterpret_cast<const __m128i*>(aSource + i + 16));

    // Interleave 0s in with the bytes of source to create lo and hi.
    __m128i lo1 = _mm_unpacklo_epi8(source1, _mm_setzero_si128());
    __m128i hi1 = _mm_unpackhi_epi8(source1, _mm_setzero_si128());
    __m128i lo2 = _mm_unpacklo_epi8(source2, _mm_setzero_si128());
    __m128i hi2 = _mm_unpackhi_epi8(source2, _mm_setzero_si128());

    // store lo and hi into dest.
    _mm_storeu_si128(reinterpret_cast<__m128i*>(dest + i),      lo1);
    _mm_storeu_si128(reinterpret_cast<__m128i*>(dest + i + 8),  hi1);
    _mm_storeu_si128(reinterpret_cast<__m128i*>(dest + i + 16), lo2);
    _mm_storeu_si128(reinterpret_cast<__m128i*>(dest + i + 24), hi2);
  }

  // Finish up whatever's left.
  for (; i < aSourceLength; ++i) {
    dest[i] = static_cast<unsigned char>(aSource[i]);
  }

  mDestination += i;
}
开发者ID:afabbro,项目名称:gecko-dev,代码行数:41,代码来源:nsUTF8UtilsSSE2.cpp

示例15: NS_LogDtor

NS_LogDtor(void* aPtr, const char* aType, uint32_t aInstanceSize)
{
#ifdef NS_IMPL_REFCNT_LOGGING
  ASSERT_ACTIVITY_IS_LEGAL;
  if (!gInitialized)
    InitTraceLog();

  if (gLogging) {
    LOCK_TRACELOG();

    if (gBloatLog) {
      BloatEntry* entry = GetBloatEntry(aType, aInstanceSize);
      if (entry) {
        entry->Dtor();
      }
    }

    bool loggingThisType = (!gTypesToLog || LogThisType(aType));
    intptr_t serialno = 0;
    if (gSerialNumbers && loggingThisType) {
      serialno = GetSerialNumber(aPtr, false);
      RecycleSerialNumberPtr(aPtr);
    }

    bool loggingThisObject = (!gObjectsToLog || LogThisObj(serialno));

    // (If we're on a losing architecture, don't do this because we'll be
    // using LogDeleteXPCOM instead to get file and line numbers.)
    if (gAllocLog && loggingThisType && loggingThisObject) {
      fprintf(gAllocLog, "\n<%s> 0x%08X %ld Dtor (%d)\n",
             aType, NS_PTR_TO_INT32(aPtr), serialno, aInstanceSize);
      nsTraceRefcntImpl::WalkTheStack(gAllocLog);
    }

    UNLOCK_TRACELOG();
  }
#endif
}
开发者ID:Tripleman,项目名称:mozilla-central,代码行数:38,代码来源:nsTraceRefcntImpl.cpp


注:本文中的NS_PTR_TO_INT32函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。