示例#1
0
static void recreate_from_state(struct SoundPlugin *plugin, hash_t *state){
#if JUCE_LINUX
  const MessageManagerLock mmLock;
#endif
  
  Data *data = (Data*)plugin->data;
  
  AudioPluginInstance *audio_instance = data->audio_instance;

  if (HASH_has_key(state, "audio_instance_state")) {
    const char *stateAsString = HASH_get_chars(state, "audio_instance_state");
    MemoryBlock sourceData;
    sourceData.fromBase64Encoding(stateAsString);
    audio_instance->setStateInformation(sourceData.getData(), sourceData.getSize());
  }

  
  if (HASH_has_key(state, "audio_instance_current_program")) {
    int current_program = HASH_get_int(state, "audio_instance_current_program");
    audio_instance->setCurrentProgram(current_program);
  }

  if (HASH_has_key(state, "audio_instance_program_state")){
    const char *programStateAsString = HASH_get_chars(state, "audio_instance_program_state");
    MemoryBlock sourceData;
    sourceData.fromBase64Encoding(programStateAsString);
    
    audio_instance->setCurrentProgramStateInformation(sourceData.getData(), sourceData.getSize());
  }
  
  if (HASH_has_key(state, "x_pos"))
    data->x = HASH_get_int(state, "x_pos");
  
  if (HASH_has_key(state, "y_pos"))
    data->y = HASH_get_int(state, "y_pos");
}
	void fileClicked(const File & newFile, const MouseEvent &) override
	{
		MemoryBlock mb;
		bool success = newFile.loadFileAsData(mb);

		if (!success)
			return;

		if (!(newFile.hasFileExtension("ttf") || newFile.hasFileExtension("otf")))
			return;

		newTypeface = Typeface::createSystemTypefaceFor(mb.getData(), mb.getSize());

		updateFont(newTypeface);
	}
示例#3
0
bool CtrlrMIDITransaction::compareMemoryWithWildcard(const MidiMessage &midi, const MemoryBlock &memory)
{
	const uint8 *responsePtr = midi.getRawData();

	for (size_t i=0; i<memory.getSize(); i++)
	{
		if (memory[i] == 0xff)
			continue;

		if (*(responsePtr+i) != memory[i])
			return (false);
	}

	return (true);
}
示例#4
0
static void create_state(struct SoundPlugin *plugin, hash_t *state){
#if JUCE_LINUX
  const MessageManagerLock mmLock;
#endif
  
  Data *data = (Data*)plugin->data;
  
  AudioPluginInstance *audio_instance = data->audio_instance;

  // save state
  {
    MemoryBlock destData;
    audio_instance->getStateInformation(destData);

    if (destData.getSize() > 0){
      String stateAsString = destData.toBase64Encoding();    
      HASH_put_chars(state, "audio_instance_state", stateAsString.toRawUTF8());
    }
  }

  // save program state
  {
    MemoryBlock destData;
    audio_instance->getCurrentProgramStateInformation(destData);

    if (destData.getSize() > 0){
      String stateAsString = destData.toBase64Encoding();    
      HASH_put_chars(state, "audio_instance_program_state", stateAsString.toRawUTF8());
    }
  }

  HASH_put_int(state, "audio_instance_current_program", audio_instance->getCurrentProgram());

  HASH_put_int(state, "x_pos", data->x);
  HASH_put_int(state, "y_pos", data->y);
}
void HostFilterComponent::menuItemSelected (int menuItemID,
                                            int topLevelMenuIndex)
{
    Config* config = Config::getInstance();
    GraphComponent* graph = main->getGraph ();

    switch (topLevelMenuIndex)
    {
    case 0: // CommandCategories::file
        {
            // handle recent plugins selection
            int fileID = menuItemID - CommandIDs::recentPlugins;
            if (fileID >= 0 && fileID < config->recentPlugins.getNumFiles())
            {
                File fileToLoad = config->recentPlugins.getFile (fileID);

                if (graph)
                    graph->loadAndAppendPlugin (config->recentPlugins.getFile (fileID), 100, 100);

                break;
            }

            // handle recent session selection
            fileID = menuItemID - CommandIDs::recentSessions;
            if (fileID >= 0 && fileID < config->recentSessions.getNumFiles())
            {
                MemoryBlock fileData;
                File fileToLoad = config->recentSessions.getFile (fileID);

                if (fileToLoad.existsAsFile()
                    && fileToLoad.loadFileAsData (fileData))
                {
                    getFilter ()->setStateInformation (fileData.getData (), fileData.getSize());

                    Config::getInstance()->addRecentSession (fileToLoad);
                    Config::getInstance()->lastSessionFile = fileToLoad;
                }
            }
            break;
        }
    }

    toFront (true);
}
void GraphComponent::itemDropped (const String& sourceDescription,
                                  Component* sourceComponent,
                                  int x, int y)
{
    if (sourceDescription.startsWith (T("Plugins: ")))
    {
        StringArray array;
        //array.addTokens (sourceDescription.replace (T("Plugins: "), T("")), false);
		array.add(sourceDescription.replace (T("Plugins: "), T("")));

        if (array.size () > 0)
        {
            for (int i = 0; i < array.size (); i++)
            {
                File file (array [i]);
                if (file.existsAsFile ())
                    dropPluginOnTrack (file, x + i * 5, y + i * 5);
            }
        }
    }
    else if (sourceDescription.startsWith (T("Sessions: ")))
    {
        StringArray array;
        array.addTokens (sourceDescription.replace (T("Sessions: "), T("")), false);

        if (array.size () > 0)
        {
            File file (array [array.size () - 1]);
            
            MemoryBlock data;
            if (file.existsAsFile()
                && file.loadFileAsData (data))
            {
                Config::getInstance()->addRecentSession (file);
                owner->getFilter ()->setStateInformation (data.getData (), data.getSize());

                return;
            }
        }
    }

    somethingIsBeingDraggedOver = false;
    repaint();
}
const String CtrlrMidiInputComparatorSingle::dumpTableContents()
{
	String ret;

	for (int i=0; i<kMidiMessageType; i++)
	{
		CtrlrMidiMap &map = getMap((const CtrlrMidiMessageType)i);

		if (&map != &mapNull)
		{
			ret << "\n*****************************************************************************\n";
			ret << "\t\tMAP type: " << midiMessageTypeToString((const CtrlrMidiMessageType)i) << ", size=" << STR((uint32)map.size());
			ret << "\n*****************************************************************************\n";

			for(CtrlrMidiMapIterator itr = map.begin(); itr != map.end(); ++itr)
			{
				ret << "\n\tindex=" << String(itr->first) << " targets=" << String(itr->second.targets.size());
				for (int j=0; j<itr->second.targets.size(); j++)
				{
					ret << "\n\t\ttarget=" << itr->second.targets[j]->getName();
				}
			}
			ret << "\n*****************************************************************************\n\n";
		}
	}

	ret << "\n*****************************************************************************\n";
	ret << "\t\tMAP SysEx " << "size=" << STR((uint32)mapSysEx.size());
	ret << "\n*****************************************************************************\n";
	for(CtrlrMultiMidiMapIterator itr = mapSysEx.begin(); itr != mapSysEx.end(); ++itr)
	{
		MemoryBlock bl = itr->first.toMemoryBlock();
		ret << "\n\tindex=" << String::toHexString (bl.getData(), (int)bl.getSize(), 1) << " targets=" << String(itr->second.targets.size());
		for (int j=0; j<itr->second.targets.size(); j++)
		{
			ret << "\n\t\ttarget=" << itr->second.targets[j]->getName();
		}
	}
	ret << "\n*****************************************************************************\n\n";
	return (ret);
}
示例#8
0
String asHex(MemoryBlock const& msg, bool newline)
{
	size_t const msgSize = msg.getSize();

	MemoryBlock result(msgSize * 10, true);
	int offset = 0;
	for (size_t i = 0; i < msgSize; ++i)
	{	
		if (newline && ((i % 16) == 0))
		{
			result.copyFrom("\n", offset, 1);
			++offset;
		}
		char dest[100];
		sprintf(dest, "%02X ", (unsigned char)(msg[i]));
		result.copyFrom(dest, offset, strlen(dest));
		offset += strlen(dest);
	
	}	
	return result.toString();
}
//==============================================================================
void StandaloneFilterWindow::saveState()
{
    PropertySet* const globalSettings = getGlobalSettings();

    FileChooser fc (TRANS("Save current state"),
                    globalSettings != 0 ? File (globalSettings->getValue (T("lastStateFile")))
                                        : File::nonexistent);

    if (fc.browseForFileToSave (true))
    {
        MemoryBlock data;
        filter->getStateInformation (data);

        if (! fc.getResult().replaceWithData (data.getData(), data.getSize()))
        {
            AlertWindow::showMessageBox (AlertWindow::WarningIcon,
                                         TRANS("Error whilst saving"),
                                         TRANS("Couldn't write to the specified file!"));
        }
    }
}
示例#10
0
    WebInputStream (const String& address, bool isPost, const MemoryBlock& postData,
                    URL::OpenStreamProgressCallback* progressCallback, void* progressCallbackContext,
                    const String& headers, int timeOutMs, StringPairArray* responseHeaders,
                    const int maxRedirects)
        : multi (nullptr), curl (nullptr), headerList (nullptr), lastError (CURLE_OK),
          contentLength (-1), streamPos (0),
          finished (false), skipBytes (0),
          postBuffer (nullptr), postPosition (0)
    {
        statusCode = -1;

        if (init() && setOptions (address, timeOutMs, (responseHeaders != nullptr),
                                  maxRedirects, headers, isPost, postData.getSize()))
        {
            connect (responseHeaders, isPost, postData, progressCallback, progressCallbackContext);
        }
        else
        {
            cleanup();
        }
    }
String EncryptedString::encrypt (const String& stringToEncrypt, const String& publicKey, bool resultAsHex)
{
    RSAKey rsaKey (publicKey);
    
    CharPointer_UTF8 stringPointer (stringToEncrypt.toUTF8());
    MemoryBlock stringMemoryBlock (stringPointer.getAddress(), stringPointer.sizeInBytes());

    BigInteger stringAsData;
    stringAsData.loadFromMemoryBlock (stringMemoryBlock);

    rsaKey.applyToValue (stringAsData);
    
    if (resultAsHex)
    {
        MemoryBlock encryptedMemoryBlock (stringAsData.toMemoryBlock());
        return String::toHexString ((char*) encryptedMemoryBlock.getData(), (int) encryptedMemoryBlock.getSize(), 0);
    }
    else
    {
        return stringAsData.toMemoryBlock().toBase64Encoding();
    }
}
示例#12
0
文件: Jobs.cpp 项目: kushview/ksp1
            void work (const URIs& uris, const lvtk::Atom& atom) override
            {
                const File file (String::fromUTF8 (path.c_str()));
                if (ScopedXml xml = XmlDocument::parse (file))
                {
                    if (ScopedPointer<SamplerSynth> ss = SamplerSynth::create ())
                    {
                        if (ss->loadValueTreeXml (*xml))
                        {
#define compressd_json 1
#if compressd_json

                            var json;
                            const bool haveJson = ss->getNestedVariant (json);
#endif
                            uint8_t buf [2048];
                            getForge()->set_buffer (buf, 2048);
                            ObjectRef synth (*getForge(), uris.ksp1_SamplerSynth, ss.release());
                            respond (synth);

                            if (haveJson)
                            {
                                MemoryBlock block (0, false);
                                MemoryOutputStream stream (block, false);
                                GZIPCompressorOutputStream compressed (&stream, 9);
                                JSON::writeToStream (compressed, json, true);
                                compressed.flush();

                                if (block.getSize() > 0)
                                {
                                    Forge& f = *getForge();
                                    int bufSize = nextPowerOfTwo ((int) block.getSize());
                                    bufSize = nextPowerOfTwo (bufSize);
                                    MemoryBlock buffer ((size_t) bufSize, false);
                                    f.set_buffer ((uint8*) buffer.getData(), buffer.getSize());
                                    lvtk::Atom gzipped (f.write_atom (block.getSize(), 100100));
                                    f.write_raw (block.getData(), block.getSize());
                                    DBG ("SIZE: " << (int)block.getSize());
                                    respond (gzipped);
                                }
                            }
                        }
                    }
                }
            }
void StandaloneFilterWindow::loadState()
{
    PropertySet* const globalSettings = getGlobalSettings();

    FileChooser fc (TRANS("Load a saved state"),
                    globalSettings != 0 ? File (globalSettings->getValue (T("lastStateFile")))
                                        : File::nonexistent);

    if (fc.browseForFileToOpen())
    {
        MemoryBlock data;

        if (fc.getResult().loadFileAsData (data))
        {
            filter->setStateInformation (data.getData(), data.getSize());
        }
        else
        {
            AlertWindow::showMessageBox (AlertWindow::WarningIcon,
                                         TRANS("Error whilst loading"),
                                         TRANS("Couldn't read from the specified file!"));
        }
    }
}
//==============================================================================
bool InterprocessConnection::sendMessage (const MemoryBlock& message)
{
    uint32 messageHeader[2];
    messageHeader [0] = ByteOrder::swapIfBigEndian (magicMessageHeader);
    messageHeader [1] = ByteOrder::swapIfBigEndian ((uint32) message.getSize());

    MemoryBlock messageData (sizeof (messageHeader) + message.getSize());
    messageData.copyFrom (messageHeader, 0, sizeof (messageHeader));
    messageData.copyFrom (message.getData(), sizeof (messageHeader), message.getSize());

    int bytesWritten = 0;

    const ScopedLock sl (pipeAndSocketLock);

    if (socket != nullptr)
        bytesWritten = socket->write (messageData.getData(), (int) messageData.getSize());
    else if (pipe != nullptr)
        bytesWritten = pipe->write (messageData.getData(), (int) messageData.getSize(), pipeReceiveMessageTimeout);

    return bytesWritten == (int) messageData.getSize();
}
示例#15
0
    static MemoryBlock createRequestHeader (const String& hostName, const int hostPort,
                                            const String& proxyName, const int proxyPort,
                                            const String& hostPath, const String& originalURL,
                                            const String& userHeaders, const MemoryBlock& postData,
                                            const bool isPost)
    {
        MemoryOutputStream header;

        if (proxyName.isEmpty())
            writeHost (header, isPost, hostPath, hostName, hostPort);
        else
            writeHost (header, isPost, originalURL, proxyName, proxyPort);

        writeValueIfNotPresent (header, userHeaders, "User-Agent:", "JUCE/" JUCE_STRINGIFY(JUCE_MAJOR_VERSION)
                                                                        "." JUCE_STRINGIFY(JUCE_MINOR_VERSION)
                                                                        "." JUCE_STRINGIFY(JUCE_BUILDNUMBER));
        writeValueIfNotPresent (header, userHeaders, "Connection:", "Close");
        writeValueIfNotPresent (header, userHeaders, "Content-Length:", String ((int) postData.getSize()));

        header << "\r\n" << userHeaders
               << "\r\n" << postData;

        return header.getMemoryBlock();
    }
示例#16
0
OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, const MemoryBlock& data)
{
    stream.write (data.getData(), (int) data.getSize());
    return stream;
}
bool WindowsRegistry::setValue (const String& regValuePath, const MemoryBlock& value)
{
    return RegistryKeyWrapper::setValue (regValuePath, REG_BINARY, value.getData(), value.getSize());
}
 void messageReceived (const MemoryBlock& message) override
 {
     jassert (dll.isLoaded());
     dll.projucer_sendMessage (liveCodeBuilder, message.getData(), message.getSize());
 }
示例#19
0
//==============================================================================
MD5::MD5 (const MemoryBlock& data)
{
    ProcessContext context;
    context.processBlock (data.getData(), data.getSize());
    context.finish (result);
}
    WebInputStream (String address, bool isPost, const MemoryBlock& postData,
                    URL::OpenStreamProgressCallback* progressCallback, void* progressCallbackContext,
                    const String& headers, int timeOutMs, StringPairArray* responseHeaders)
        : statusCode (0)
    {
        if (! address.contains ("://"))
            address = "http://" + address;

        JNIEnv* env = getEnv();

        jbyteArray postDataArray = 0;

        if (postData.getSize() > 0)
        {
            postDataArray = env->NewByteArray (postData.getSize());
            env->SetByteArrayRegion (postDataArray, 0, postData.getSize(), (const jbyte*) postData.getData());
        }

        LocalRef<jobject> responseHeaderBuffer (env->NewObject (StringBuffer, StringBuffer.constructor));

        // Annoyingly, the android HTTP functions will choke on this call if you try to do it on the message
        // thread. You'll need to move your networking code to a background thread to keep it happy..
        jassert (Thread::getCurrentThread() != nullptr);

        jintArray statusCodeArray = env->NewIntArray (1);
        jassert (statusCodeArray != 0);

        stream = GlobalRef (env->CallStaticObjectMethod (JuceAppActivity,
                                                         JuceAppActivity.createHTTPStream,
                                                         javaString (address).get(),
                                                         (jboolean) isPost,
                                                         postDataArray,
                                                         javaString (headers).get(),
                                                         (jint) timeOutMs,
                                                         statusCodeArray,
                                                         responseHeaderBuffer.get()));

        jint* const statusCodeElements = env->GetIntArrayElements (statusCodeArray, 0);
        statusCode = statusCodeElements[0];
        env->ReleaseIntArrayElements (statusCodeArray, statusCodeElements, 0);
        env->DeleteLocalRef (statusCodeArray);

        if (postDataArray != 0)
            env->DeleteLocalRef (postDataArray);

        if (stream != 0)
        {
            StringArray headerLines;

            {
                LocalRef<jstring> headersString ((jstring) env->CallObjectMethod (responseHeaderBuffer.get(),
                                                                                  StringBuffer.toString));
                headerLines.addLines (juceString (env, headersString));
            }

            if (responseHeaders != 0)
            {
                for (int i = 0; i < headerLines.size(); ++i)
                {
                    const String& header = headerLines[i];
                    const String key (header.upToFirstOccurrenceOf (": ", false, false));
                    const String value (header.fromFirstOccurrenceOf (": ", false, false));
                    const String previousValue ((*responseHeaders) [key]);

                    responseHeaders->set (key, previousValue.isEmpty() ? value : (previousValue + "," + value));
                }
            }
        }
    }
示例#21
0
void PMixDocument::createNodeFromXml (XmlElement& xml, const String& newSourceCode)
{
  PluginDescription pd;
  
  forEachXmlChildElement (xml, e)
  {
    if (pd.loadFromXml (*e))
      break;
  }
  
  String errorMessage;
  
  AudioPluginInstance* instance = audioEngine.createPluginInstance(pd, errorMessage);
  
  jassert(instance != nullptr);
  
  if (pd.pluginFormatName == "FAUST")
  {
    FaustAudioPluginInstance* faustProc = dynamic_cast<FaustAudioPluginInstance*>(instance);
    faustProc->initialize(getLibraryPath(), drawPath);
    
    if (newSourceCode.length())
      faustProc->setSourceCode(newSourceCode, true);
    
    // TODO: this is a bit wrong!
    faustProc->prepareToPlay(44100., 8192);
    
//    xml.setAttribute("numInputs", faustProc->getNumInputChannels());
//    xml.setAttribute("numOutputs", faustProc->getNumOutputChannels()); ???
  }
  
  AudioProcessorGraph::Node::Ptr node (audioEngine.getGraph().addNode (instance, xml.getIntAttribute ("uid")));
  
  if (!newSourceCode.length())
  {
    if (const XmlElement* const state = xml.getChildByName ("STATE"))
    {
      MemoryBlock m;
      m.fromBase64Encoding (state->getAllSubText());
      
      node->getProcessor()->setStateInformation (m.getData(), (int) m.getSize());
    }
  }
  
  node->properties.set ("x", xml.getDoubleAttribute ("x"));
  node->properties.set ("y", xml.getDoubleAttribute ("y"));
  node->properties.set ("uiLastX", xml.getIntAttribute ("uiLastX"));
  node->properties.set ("uiLastY", xml.getIntAttribute ("uiLastY"));
  node->properties.set ("uiStatus", xml.getIntAttribute ("uiStatus"));

  // presets etc for faust & plugin nodes
  if(!InternalPluginFormat::isInternalFormat(pd.name))
  {
    node->properties.set ("colour", xml.getStringAttribute ("colour"));
    node->properties.set ("iposx", xml.getDoubleAttribute ("iposx"));
    node->properties.set ("iposy", xml.getDoubleAttribute ("iposy"));
    if (const XmlElement* const params = xml.getChildByName ("PARAMS"))
    {
      var vparams = JSON::parse(params->getAllSubText());
      node->properties.set ("params", vparams);
    }
    
    Array<var> presetsArr;
    
    forEachXmlChildElement (xml, e)
    {
      if (e->hasTagName ("PRESET"))
      {
        DynamicObject* obj = new DynamicObject();
        obj->setProperty("name", e->getStringAttribute("name"));
        obj->setProperty("x", e->getDoubleAttribute("x"));
        obj->setProperty("y", e->getDoubleAttribute("y"));
        obj->setProperty("radius", e->getDoubleAttribute("radius"));
        obj->setProperty("hidden", e->getBoolAttribute("hidden"));
        //  obj->setProperty("distance", e->getDoubleAttribute("distance"));
        obj->setProperty("coeff", e->getDoubleAttribute("coeff"));
        
        var vparams = JSON::parse(e->getAllSubText());
        obj->setProperty("state", vparams);
        obj->setProperty("uid", e->getIntAttribute("uid"));
        
        var preset = var(obj);
        presetsArr.add(preset);
      }
    }
    
    node->properties.set("presets", presetsArr);
  }
示例#22
0
    void writeDataAsCppLiteral (const MemoryBlock& mb, OutputStream& out,
                                bool breakAtNewLines, bool allowStringBreaks)
    {
        const int maxCharsOnLine = 250;

        const unsigned char* data = (const unsigned char*) mb.getData();
        int charsOnLine = 0;

        bool canUseStringLiteral = mb.getSize() < 32768; // MS compilers can't handle big string literals..

        if (canUseStringLiteral)
        {
            unsigned int numEscaped = 0;

            for (size_t i = 0; i < mb.getSize(); ++i)
            {
                const unsigned int num = (unsigned int) data[i];
                if (! ((num >= 32 && num < 127) || num == '\t' || num == '\r' || num == '\n'))
                {
                    if (++numEscaped > mb.getSize() / 4)
                    {
                        canUseStringLiteral = false;
                        break;
                    }
                }
            }
        }

        if (! canUseStringLiteral)
        {
            out << "{ ";

            for (size_t i = 0; i < mb.getSize(); ++i)
            {
                const int num = (int) (unsigned int) data[i];
                out << num << ',';

                charsOnLine += 2;

                if (num >= 10)
                {
                    ++charsOnLine;

                    if (num >= 100)
                        ++charsOnLine;
                }

                if (charsOnLine >= maxCharsOnLine)
                {
                    charsOnLine = 0;
                    out << newLine;
                }
            }

            out << "0,0 };";
        }
        else
        {
            out << "\"";
            CppTokeniserFunctions::writeEscapeChars (out, (const char*) data, (int) mb.getSize(),
                                                     maxCharsOnLine, breakAtNewLines, false, allowStringBreaks);
            out << "\";";
        }
    }
示例#23
0
文件: gc.cpp 项目: abhijangda/Leopard
void GarbageCollector::collectPartition (int partitionNum)
{
    int i;
    HeapAllocator* heapAllocator;
    vector<AllocatedObject*>* reachableObjects;
    
    /* Get all reachable objects of partition*/
    heapAllocator = ptrVM->getHeapAllocator ();
    reachableObjects = heapAllocator->reachableObjectsForPartition (partitionNum);
    
    /* Insert them one by one in the partition */
    for (i = 0; i < reachableObjects->size (); i++)
    {
        MemoryBlock *memBlock;
        int size;
        AllocatedObject* allocObj;

        size = reachableObjects->at (i)->getClassInfo ()->getSize ();
        memBlock = heapAllocator->allocateInPartition (partitionNum+1, size);

        if (memBlock)
        {
            MemoryBlock *prevMemBlock;
            byte* prevMem;
            byte *mem;
            int j = 0;
            
            allocObj = reachableObjects->at(i);
            prevMemBlock = allocObj->getMemBlock ();
            prevMem = prevMemBlock->getMemory ();
            mem = memBlock->getMemory ();
            ptrVM->updateAddressForAllocatedObject (prevMemBlock->getStartPos (),
                                                    memBlock->getStartPos (),
                                                    allocObj);
            memBlock->setAllocatedVariable (allocObj);
            allocObj->setMemBlock (memBlock);

            /* Copy data from previous block to the new block*/
            for (j = 0; j < memBlock->getSize (); j++)
            {
                mem[j] = prevMem[j];
            }

            heapAllocator->freeAddress (prevMemBlock->getStartPos ());

            /* Update the value of pointer in the reachable objects */
            j = allocObj->totalAddresses () - 1;

            while (j >= 0)
            {
                *allocObj->popAddress () = memBlock->getStartPos ();
                j--;
            }
        }
        else
        {
            break;
        }
    }

    if (i < reachableObjects->size ())
    {
        /* Not all objects have been allocated
         * collect this partition also */
        collectPartition (partitionNum + 1);
        
        /* Insert remaining reachable objects in this partition */
        for (; i < reachableObjects->size (); i++)
        {
            MemoryBlock *memBlock;
            int size;
            AllocatedObject* allocObj;
    
            size = reachableObjects->at (i)->getClassInfo ()->getSize ();
            memBlock = heapAllocator->allocateInPartition (partitionNum+1, size);
    
            if (memBlock)
            {
                MemoryBlock *prevMemBlock;
                int j = 0;
    
                allocObj = reachableObjects->at(i);
                prevMemBlock = allocObj->getMemBlock ();
                ptrVM->updateAddressForAllocatedObject (prevMemBlock->getStartPos (),
                                                        memBlock->getStartPos (),
                                                        allocObj);
                memBlock->setAllocatedVariable (reachableObjects->at (i));
                allocObj->setMemBlock (memBlock);
                
                /* Copy data from previous block to the new block*/
                for (j = 0; j < memBlock->getSize (); j++)
                {
                    memBlock->getMemory ()[i] = prevMemBlock->getMemory ()[i];
                }

                heapAllocator->freeAddress (prevMemBlock->getStartPos ());
    
                /* Update the value of pointer in the reachable objects */
                j = allocObj->totalAddresses () - 1;
                while (j >= 0)
                {
                    *allocObj->popAddress () = memBlock->getStartPos ();
                    j--;
                }
            }
            else
            {
                break;
            }
        }
    }

    delete reachableObjects;
}
示例#24
0
void LMemoryBlock::append (MemoryBlock &dataToAppend)
{
	MemoryBlock::append (dataToAppend.getData(), dataToAppend.getSize());
}
示例#25
0
void LMemoryBlock::insert (MemoryBlock &dataToInsert, int insertPosition)
{
	MemoryBlock::insert (dataToInsert.getData(), dataToInsert.getSize(), insertPosition);
}
示例#26
0
void LMemoryBlock::replaceWith(MemoryBlock &dataToReplace)
{
	MemoryBlock::replaceWith (dataToReplace.getData(), dataToReplace.getSize());
}
示例#27
0
bool JUCE_CALLTYPE WindowsRegistry::setValue (const String& regValuePath, const MemoryBlock& value, WoW64Mode mode)
{
    return RegistryKeyWrapper::setValue (regValuePath, REG_BINARY, value.getData(), value.getSize(), (DWORD) mode);
}
示例#28
0
size_t CtrlrMIDITransaction::getDataLengthFromFormula(const String &formula)
{
	MemoryBlock bl;
	bl.loadFromHexString (formula);
	return (bl.getSize());
}
示例#29
0
    //==============================================================================
    static XmlElement decryptXML (String hexData, RSAKey rsaPublicKey)
    {
        BigInteger val;
        val.parseString (hexData, 16);

        RSAKey key (rsaPublicKey);
        jassert (key.isValid());

        ScopedPointer<XmlElement> xml;

        if (! val.isZero())
        {
            key.applyToValue (val);

            const MemoryBlock mb (val.toMemoryBlock());

            if (CharPointer_UTF8::isValidString (static_cast<const char*> (mb.getData()), (int) mb.getSize()))
                xml = XmlDocument::parse (mb.toString());
        }

        return xml != nullptr ? *xml : XmlElement("key");
    }
示例#30
0
// A few quick utility functions to convert between raw data and ValueTrees
static ValueTree memoryBlockToValueTree (const MemoryBlock& mb)
{
    return ValueTree::readFromData (mb.getData(), mb.getSize());
}