Example #1
0
static bool HHVM_FUNCTION(clock_settime,
                          int64_t clk_id, int64_t sec, int64_t nsec) {
#if defined(__APPLE__)
  throw NotSupportedException(__func__, "feature not supported on OSX");
#else
  struct timespec ts;
  ts.tv_sec = sec;
  ts.tv_nsec = nsec;
  int ret = clock_settime(clk_id, &ts);
  return ret == 0;
#endif
}
Example #2
0
static bool HHVM_FUNCTION(clock_getres,
                          int64_t clk_id, VRefParam sec, VRefParam nsec) {
#if defined(__APPLE__)
  throw NotSupportedException(__func__, "feature not supported on OSX");
#else
  struct timespec ts;
  int ret = clock_getres(clk_id, &ts);
  sec = (int64_t)ts.tv_sec;
  nsec = (int64_t)ts.tv_nsec;
  return ret == 0;
#endif
}
Example #3
0
Variant f_forward_static_call(int _argc, CVarRef function, CArrRef _argv /* = null_array */) {
#ifdef ENABLE_LATE_STATIC_BINDING
  CStrRef cls = FrameInjection::GetClassName();
  if (cls.empty()) {
    raise_error("Cannot call forward_static_call() "
                "when no class scope is active");
    return null;
  }
  FrameInjection::StaticClassNameHelper h(ThreadInfo::s_threadInfo.get(), cls);
  return f_call_user_func_array(function, _argv, true);
#else
  throw NotSupportedException(__func__, "ENABLE_LATE_STATIC_BINDING is off");
#endif
}
Example #4
0
Variant f_sncompress(CStrRef data) {
#ifndef HAVE_SNAPPY
  throw NotSupportedException(__func__, "Snappy library cannot be found");
#else
  size_t size;
  char *compressed =
    (char *)malloc(snappy::MaxCompressedLength(data.size()) + 1);

  snappy::RawCompress(data.data(), data.size(), compressed, &size);
  compressed = (char *)realloc(compressed, size + 1);
  compressed[size] = '\0';
  return String(compressed, size, AttachString);
#endif
}
    void MemoryStream::WriteByte(byte value)
      {
      CheckIfClosedThrowDisposed();
      if(!_canWrite)
        throw NotSupportedException(L"Cannot write to this stream.");

      if(_position >= _length)
        {
        Expand(_position + 1);
        _length = _position + 1;
        }

      (*_internalBuffer)[_position++] = value;
      }
Example #6
0
void FileStream::Write(const u8 *buffer, u64 count)
{
	if (!(access & std::ios::out))
		throw NotSupportedException();

	if (!stream.is_open())
		throw IOException();

	if (stream.fail())
		throw IOException();

	stream.write((const char *) buffer, count);
	if (stream.fail())
		throw IOException();
}
void GraphController::Load(const std::string& desc, const std::vector<IEditorGraph*>& editors) {
	// Try to load the file with one of the editor interfaces.
	bool loaded = false;
	for (auto& graphEditor : editors) {
		try {
			graphEditor->LoadJSON(desc);
			m_model = graphEditor;
			loaded = true;
			break;
		}
		catch (NotSupportedException&) {
			// Graph editor does not support specified type.
		}
	}
	if (!loaded) {
		throw NotSupportedException("Graph type is not supported.");
	}

	m_nodes.clear();

	// Set node list.
	std::vector<std::u32string> nameList;
	for (const auto& name : m_model->GetNodeList()) {
		nameList.push_back(EncodeString<char32_t>(name));
	}
	m_selectPanel->SetChoices(nameList);

	// Create nodes.
	std::map<IGraphEditorNode*, NodeControl*> inversionMap;

	auto graphNodes = m_model->GetNodes();
	for (auto realNode : graphNodes) {
		auto viewNode = CreateViewNode(realNode);
		Vec2 position = realNode->GetMetaData().placement;
		m_view->AddNode(viewNode, position);
		inversionMap[realNode] = viewNode.get();
		m_nodes.insert({viewNode, realNode});
	}

	auto graphLinks = m_model->GetLinks();
	for (auto realLink : graphLinks) {
		NodeControl* src = inversionMap[realLink.sourceNode];
		NodeControl* tar = inversionMap[realLink.targetNode];

		m_view->AddLink(src, realLink.sourcePort, tar, realLink.targetPort);
	}
}
    void MemoryStream::Capacity(int32 value)
      { 
      CheckIfClosedThrowDisposed();

      if(!_expandable)
        throw NotSupportedException(L"Cannot expand this MemoryStream");

      if(value < 0 || value < _length)
        throw ArgumentOutOfRangeException(L"value", L"New capacity cannot be negative or less than the current capacity" /*+ value + " " + capacity*/);

      if(!_internalBuffer->IsNull() && value == (int32)_internalBuffer->Length())
        return;

      _internalBuffer->Length(value);
      _dirty_bytes = 0;
      _capacity = value;
      }
Example #9
0
Variant f_snuncompress(CStrRef data) {
#ifndef HAVE_SNAPPY
  throw NotSupportedException(__func__, "Snappy library cannot be found");
#else
  char *uncompressed;
  size_t dsize;

  snappy::GetUncompressedLength(data.data(), data.size(), &dsize);
  uncompressed = (char *)malloc(dsize + 1);

  if (!snappy::RawUncompress(data.data(), data.size(), uncompressed)) {
    free(uncompressed);
    return false;
  }
  uncompressed[dsize] = '\0';
  return String(uncompressed, dsize, AttachString);
#endif
}
Example #10
0
void FileStream::Open(std::string path, FileMode mode, FileAccess access)
{
	this->mode = mode;
	this->access = access;

	if (mode == FileMode::Append || mode == FileMode::Open || mode == FileMode::Truncate)
	{
		if (!FileExists(path.c_str()))
			throw FileNotFoundException();
	}

	if (mode == FileMode::CreateNew)
	{
		if (FileExists(path.c_str()))
			throw IOException();
	}

	if ((mode == FileMode::Append || mode == FileMode::Truncate) && access == FileAccess::Read)
	{
		throw NotSupportedException();
	}

	/* Create the file if it doesn't exist */
	if (mode == FileMode::CreateNew || mode == FileMode::Create || mode == FileMode::OpenOrCreate)
	{
		if (!FileExists(path.c_str()))
		{
			std::fstream tmp(path, std::ios::out);
			/* Let's do a dummy write */
			tmp.write(path.c_str(), 0);
			tmp.close();
		}
	}

	int openFlags = (int) access | std::ios::binary;
	if (mode == FileMode::Append)
		openFlags |= std::ios::ate;
	else if (mode == FileMode::Truncate)
		openFlags |= std::ios::trunc;

	stream.open(path, openFlags);
	if (!stream.is_open() || !stream.good())
		throw IOException();
}
Example #11
0
static Variant HHVM_FUNCTION(assert, const Variant& assertion) {
  if (!s_option_data->assertActive) return true;

  JIT::CallerFrame cf;
  Offset callerOffset;
  auto const fp = cf(&callerOffset);

  auto const passed = [&]() -> bool {
    if (assertion.isString()) {
      if (RuntimeOption::EvalAuthoritativeMode) {
        // We could support this with compile-time string literals,
        // but it's not yet implemented.
        throw NotSupportedException(__func__,
          "assert with strings argument in RepoAuthoritative mode");
      }
      return eval_for_assert(fp, assertion.toString()).toBoolean();
    }
    return assertion.toBoolean();
  }();
  if (passed) return true;

  if (!s_option_data->assertCallback.isNull()) {
    auto const unit = fp->m_func->unit();

    PackedArrayInit ai(3);
    ai.append(String(const_cast<StringData*>(unit->filepath())));
    ai.append(Variant(unit->getLineNumber(callerOffset)));
    ai.append(assertion.isString() ? assertion.toString()
                                   : static_cast<String>(empty_string));
    f_call_user_func(1, s_option_data->assertCallback, ai.toArray());
  }

  if (s_option_data->assertWarning) {
    auto const str = !assertion.isString()
      ? String("Assertion failed")
      : concat3("Assertion \"", assertion.toString(), "\" failed");
    raise_warning("%s", str.data());
  }
  if (s_option_data->assertBail) {
    throw Assertion();
  }

  return uninit_null();
}
Example #12
0
Variant f_assert(CVarRef assertion) {
  if (!s_option_data->assertActive) return true;

  Transl::CallerFrame cf;
  Offset callerOffset;
  auto const fp = cf(&callerOffset);

  auto const passed = [&]() -> bool {
    if (assertion.isString()) {
      if (RuntimeOption::RepoAuthoritative) {
        // We could support this with compile-time string literals,
        // but it's not yet implemented.
        throw NotSupportedException(__func__,
          "assert with strings argument in RepoAuthoritative mode");
      }
      return eval_for_assert(fp, assertion.toString()).toBoolean();
    }
    return assertion.toBoolean();
  }();
  if (passed) return true;

  if (!s_option_data->assertCallback.isNull()) {
    auto const unit = fp->m_func->unit();

    ArrayInit ai(3, ArrayInit::vectorInit);
    ai.set(String(unit->filepath()));
    ai.set(Variant(unit->getLineNumber(callerOffset)));
    ai.set(assertion.isString() ? assertion.toString() : String(""));
    f_call_user_func(1, s_option_data->assertCallback, ai.toArray());
  }

  if (s_option_data->assertWarning) {
    auto const str = !assertion.isString()
      ? String("Assertion failed")
      : concat3("Assertion \"", assertion.toString(), "\" failed");
    raise_warning("%s", str.data());
  }
  if (s_option_data->assertBail) {
    throw Assertion();
  }

  return uninit_null();
}
Example #13
0
Variant f_qlzcompress(CStrRef data, int level /* = 1 */) {
#ifndef HAVE_QUICKLZ
  throw NotSupportedException(__func__, "QuickLZ library cannot be found");
#else
  if (level < 1 || level > 3) {
    throw_invalid_argument("level: %d", level);
    return false;
  }

  char *compressed = (char*)malloc(data.size() + 401);
  size_t size;

  switch (level) {
    case 1: {
      QuickLZ1::qlz_state_compress state;
      memset(&state, 0, sizeof(state));
      size = QuickLZ1::qlz_compress(data.data(), compressed, data.size(),
                                    &state);
      break;
    }
    case 2: {
      QuickLZ2::qlz_state_compress state;
      memset(&state, 0, sizeof(state));
      size = QuickLZ2::qlz_compress(data.data(), compressed, data.size(),
                                    &state);
      break;
    }
    case 3:
      QuickLZ3::qlz_state_compress *state = new QuickLZ3::qlz_state_compress();
      memset(state, 0, sizeof(*state));
      size = QuickLZ3::qlz_compress(data.data(), compressed, data.size(),
                                    state);
      delete state;
      break;
  }

  ASSERT(size < (size_t)data.size() + 401);
  compressed = (char *)realloc(compressed, size + 1);
  compressed[size] = '\0';
  return String(compressed, size, AttachString);
#endif
}
Example #14
0
u64 FileStream::Read(u8 *buffer, u64 count)
{
	if (!(access & std::ios::in))
		throw NotSupportedException();

	if (!stream.is_open())
		throw IOException();

	if (stream.fail())
		throw IOException();

	if (stream.eof())
		return 0;

	stream.read((char *) buffer, count);
	if (stream.fail())
		throw IOException();

	return stream.gcount();
}
Example #15
0
void wpi_selfTrace()
{
	throw NotSupportedException();
}
Example #16
0
/**
 * Toggle the state of the FPGA status LED on the cRIO.
 * @return The new state of the FPGA LED.
 */
INT32 ToggleRIO_FPGA_LED()
{
	throw NotSupportedException();
}
Example #17
0
static INT32 wpiStackTask(INT32 taskId)
{
	throw NotSupportedException();
}
Example #18
0
/**
 * Set the state of the FPGA status LED on the cRIO.
 */
void SetRIO_FPGA_LED(UINT32 state)
{
	throw NotSupportedException();
}
Example #19
0
/**
 * Get the current state of the FPGA status LED on the cRIO.
 * @return The curent state of the FPGA LED.
 */
INT32 GetRIO_FPGA_LED()
{
	throw NotSupportedException();
}
Example #20
0
/**
 * Toggle the state of the USER1 status LED on the cRIO.
 * @return The new state of the USER1 LED.
 */
INT32 ToggleRIOUserLED()
{
	throw NotSupportedException();
}
Example #21
0
/**
 * Get the current state of the USER1 status LED on the cRIO.
 * @return The curent state of the USER1 LED.
 */
INT32 GetRIOUserLED()
{
	throw NotSupportedException();
}
Example #22
0
/**
 * Set the state of the USER1 status LED on the cRIO.
 */
void SetRIOUserLED(UINT32 state)
{
	throw NotSupportedException();
}
Example #23
0
/**
 * Enable Stack trace after asserts.
 */
void wpi_stackTraceOnAssertEnable(bool enabled)
{
	throw NotSupportedException();
}
Example #24
0
bool f_output_add_rewrite_var(const String& name, const String& value) {
  throw NotSupportedException(__func__, "bad coding style");
}
Example #25
0
static void wpi_handleTracing()
{
	throw NotSupportedException();
}
Example #26
0
/**
 * Return the FPGA Revision number.
 * The format of the revision is 3 numbers.
 * The 12 most significant bits are the Major Revision.
 * the next 8 bits are the Minor Revision.
 * The 12 least significant bits are the Build Number.
 * @return FPGA Revision number.
 */
UINT32 GetFPGARevision()
{
	throw NotSupportedException();
}
Example #27
0
static bool HHVM_FUNCTION(set_magic_quotes_runtime, bool new_setting) {
  if (new_setting) {
    throw NotSupportedException(__func__, "not using magic quotes");
  }
  return true;
}
Example #28
0
/**
 * Read the microsecond-resolution timer on the FPGA.
 * 
 * @return The current time in microseconds according to the FPGA (since FPGA reset).
 */
UINT32 GetFPGATime()
{
	throw NotSupportedException();
}
Example #29
0
bool f_output_reset_rewrite_vars() {
  throw NotSupportedException(__func__, "bad coding style");
}
Example #30
0
/**
 * Read the value of the USER1 DIP switch on the cRIO.
 */
INT32 GetRIOUserSwitch()
{
	throw NotSupportedException();
}