Пример #1
0
/*{{{  display*/
void display(int x, int y, int my_width, int my_height, int image_width, int image_height)
{
  int image_x=0,image_y=0;

  m_func(BIT_CLR);
  m_bitwrite(0,0,my_width,my_height);
  m_func(BIT_SRC);
  if (x<0) { image_width+=x; image_x-=x; x=0; }
  if (y<0) { image_height+=y; image_y-=y; y=0; }
  m_bitcopyto(x,y,image_width,image_height,image_x,image_y,WINDOW_BITMAP,IMAGE_BITMAP);
}
Пример #2
0
void Task::run(bool async)
{
    if (async) {
        m_mutex.lock();
        launch([this]() {
            m_func();
            m_mutex.unlock();
        });
    }
    else {
        m_func();
    }
}
Пример #3
0
void zDBFunctionWrapper::Invoke(sqlite3_context* context, int argc, sqlite3_value** argv)
{
	zDBArgumentCollection^		args;		// Function argument collection
	zDBResult^					result;		// Function result object

	if(m_func == nullptr) return;			// No delegate, nothing to do

	zDBConnection^ conn = zDBConnection::FindConnection(m_hDatabase);

	// Both the arguments as well as the result need to be disposed of
	// as soon as we are finished with them, so use an ugly little nested
	// try/finally setup in here

	args = gcnew zDBArgumentCollection(argc, argv);
	try { 

		result = gcnew zDBResult(conn, context);

		try { m_func(conn, args, result); }		// Invoke the delegate
		finally { delete result; }				// Dispose of result
	}
	
	finally { delete args; }					// Dispose of arguments

	GC::KeepAlive(conn);						// Keep the connection alive
}	
Пример #4
0
void
CFunctionJob::run()
{
    if (m_func != NULL) {
        m_func(m_arg);
    }
}
Пример #5
0
main()
   {

	int clean();

	/* setup MGR */

	m_setup(M_DEBUG);
   m_push(P_FLAGS|P_FONT);
   signal(SIGTERM,clean);
   signal(SIGINT,clean);
   m_setmode(M_OVERSTRIKE);
	m_func(14);
   /* m_font(4); */
	m_clear();

	/* display output */

   conv(stdin);

	/* wait for ack. */

	getpass("\007");
   clean(0);
   }
Пример #6
0
void AsyncFuncImpl::threadFuncImpl() {
  if (s_initFunc && !m_noInit) {
    s_initFunc(s_initFuncArg);
  }
  try {
    m_func(m_obj);
  } catch (Exception &e) {
    m_exceptioned = true;
    m_exception = e;
  } catch (std::exception &e) {
    m_exceptioned = true;
    m_exception.setMessage(e.what());
  } catch (...) {
    m_exceptioned = true;
    m_exception.setMessage("(unknown exception)");
  }
  {
    Lock lock(m_stopMonitor.getMutex());
    m_stopped = true;
    m_stopMonitor.notify();
  }
  if (s_finiFunc) {
    s_finiFunc(s_finiFuncArg);
  }
}
Пример #7
0
void
FunctionEventJob::run(const Event& event)
{
	if (m_func != NULL) {
		m_func(event, m_arg);
	}
}
Пример #8
0
/*{{{  redraw*/
void redraw(int my_width, int my_height)
{
  m_clear();
  m_func(BIT_SRC);
  m_bitcopyto(0,0,my_width/2,my_height,0,0,0,EYE_BITMAP);
  m_bitcopyto(my_width/2,0,my_width/2,my_height,0,0,0,EYE_BITMAP);
}
Пример #9
0
void DepthConvert2::process(void *, const ZimgImageBufferConst &src, const ZimgImageBuffer &dst, void *tmp, unsigned i, unsigned left, unsigned right) const
{
    LineBuffer<const void> src_buf{ src };
    LineBuffer<void> dst_buf{ dst };

    const void *src_p = reinterpret_cast<const char *>(src_buf[i]) + left * pixel_size(m_pixel_in);
    void *dst_p = reinterpret_cast<char *>(dst_buf[i]) + left * pixel_size(m_pixel_out);

    if (!m_func && !m_f16c) {
        if (src_p != dst_p)
            std::copy_n(reinterpret_cast<const char *>(src_p), (right - left) * pixel_size(m_pixel_out), reinterpret_cast<char *>(dst_p));
    } else {
        if (m_func) {
            if (m_f16c)
                dst_p = tmp;

            m_func(src_p, dst_p, m_scale, m_offset, right - left);

            src_p = dst_p;
            dst_p = reinterpret_cast<char *>(dst_buf[i]) + left * pixel_size(m_pixel_out);
        }

        if (m_f16c)
            m_f16c(src_p, dst_p, right - left);
    }
}
Пример #10
0
void RenderingDebugOutput::addToQueue(
	GLenum source,
	GLenum type,
	GLuint id,
	GLenum severity,
	GLsizei length,
	const GLchar* message)
{
	if (severity < m_minimumSeverityLevel)
		return;

	std::stringstream errorString;

	errorString << "Debug Message:" <<
		"\n\t Source: " << sourceToString(source) <<
		"\n\t Type: " << typeToString(type) <<
		"\n\t Severity: " << severityToString(severity) <<
		"\n\t ID: " << id <<
		"\n\t Message: " << message << "\n";

	if (m_multithreaded)
	{
		std::lock_guard<std::mutex> lock(m_mutex);
		m_log.push_back(std::move(errorString.str()));
	}
	else
	{
		m_func(errorString.str());
	}
}
Пример #11
0
	bool Condition::validateCondition(State& state) const {
		aiVariant v1, v2;
		v1 = state[m_arg1];
		v2 = state[m_arg2];
		bool result;
        m_func(v1,v2, result);
		return result;
	}
Пример #12
0
 bool Condition::validateCondition(BlackBoard* bb) const {
     aiVariant v1, v2;
     v1 = bb->getStateVariant(m_arg1);
     v2 = bb->getStateVariant(m_arg2);
     bool result;
     m_func(v1,v2, result);
     return result;
 }
Пример #13
0
 void operator()(unsigned char ch)
 {
     if (m_func == nullptr)
     {
         return;
     }
     m_func(ch);
 }
Пример #14
0
/*{{{  mkeye*/
void mkeye(int width, int height, int *puiple)
{
  m_bitcreate(EYE_BITMAP,width,height);
  m_func(BIT_CLR);
  m_bitwriteto(0,0,width,height,EYE_BITMAP);
  m_func(BIT_SET);
  m_fcircleto(EYE_BITMAP,width/2,height/2,(10*width)/22,(10*height)/22);
  m_func(BIT_CLR);
  m_fcircleto(EYE_BITMAP,width/2,height/2,(10*width)/26,(10*height)/26);

  *puiple=(10*(width>height ? height : width))/90;
  m_bitcreate(PUIPLE_BITMAP,2**puiple,2**puiple);
  m_func(BIT_CLR);
  m_bitwriteto(0,0,2**puiple,2**puiple,PUIPLE_BITMAP);
  m_func(BIT_SET);
  m_fcircleto(PUIPLE_BITMAP,*puiple,*puiple,*puiple,*puiple);
}
Пример #15
0
 void call(_Args&&... args)
 {
     if (!m_called)
     {
         m_called = true;
         m_func(std::forward<_Args>(args)...);
     }
 }
Пример #16
0
    T& Value()
    {
        if (!m_value.IsInit())
        {
            m_value = m_func();
        }

        return *m_value;
    }
Пример #17
0
void
StateDescriptor::BndryFunc::operator () (Real* data,const int* lo,const int* hi,
                                         const int* dom_lo, const int* dom_hi,
                                         const Real* dx, const Real* grd_lo,
                                         const Real* time, const int* bc) const
{
    BL_ASSERT(m_func != 0);

    bool thread_safe = bf_thread_safety(lo, hi, dom_lo, dom_hi, bc, 1);
    if (thread_safe) {
	m_func(data,ARLIM(lo),ARLIM(hi),dom_lo,dom_hi,dx,grd_lo,time,bc);
    } else {
#ifdef _OPENMP
#pragma omp critical (bndryfunc)
#endif
	m_func(data,ARLIM(lo),ARLIM(hi),dom_lo,dom_hi,dx,grd_lo,time,bc);
    }
}
Пример #18
0
 result_type call(Args&&... args)
 {
     if (!m_called)
     {
         m_called = true;
         m_result = m_func(std::forward<Args>(args)...);
     }
     return m_result;
 }
Пример #19
0
void RenderingDebugOutput::dumpOutput()
{
	std::lock_guard<std::mutex> lock(m_mutex);

	for (int i = 0; i < m_log.size(); ++i)
	{
		m_func(m_log[i]);
	}

	std::vector<std::string>().swap(m_log);
}
Пример #20
0
Time AngleChange::step(Time t)
{
    m_cur += t;
    float part = m_period == 0 ? 1.f : clamp(static_cast<float>(m_cur) / m_period, 0.0f, 1.0f);
    part = m_func(part);

    float angle = m_curStartAngle + lerp(0.f, m_curDeltaAngle, part);
    m_obj->setAngle(angle);

    return m_cur >= m_period ? m_cur - m_period : 0;
}
Пример #21
0
Time ColorComponentChange::step(Time t)
{
    m_cur += t;
    float part = m_period == 0 ? 1.f : clamp(static_cast<float>(m_cur) / m_period, 0.0f, 1.0f);
    part = m_func(part);

    float colorComponent = m_curStartColorComponent + lerp(0.f, m_curDeltaColorComponent, part);
    m_property->set(colorComponent);

    return m_cur >= m_period ? m_cur - m_period : 0;
}
Пример #22
0
void CallbackTimeCounter::update(float dt)
{
	if (m_isCounting == false){
		return;
	}
	m_Time += dt;

	if (m_Time > m_CBTime){
		m_func();
		m_isCounting = false;
	}
}
Пример #23
0
bool LineEdit::onKeyPressed(const sf::Event::KeyEvent &evt)
{
	Widget::onKeyPressed(evt);
	if(m_inputison)
	{
		switch(evt.code)
		{
			case sf::Keyboard::Return:
				if(m_func)
					m_func(getString());
				m_inputison = false;
				break;

			case sf::Keyboard::Left:
				if(m_positioncursor > 0)
					m_positioncursor--;
				break;

			case sf::Keyboard::Right:
				if(m_positioncursor < m_text.getString().getSize())
					m_positioncursor++;
				break;

			case sf::Keyboard::BackSpace:
				//erase character
				if(m_positioncursor > 0)
				{
					sf::String temp(m_text.getString());
					temp.erase(m_positioncursor - 1, 1);
					m_text.setString(temp);
					m_positioncursor--;
				}
				break;

			case sf::Keyboard::Delete:
				//erase character
				if(m_positioncursor < m_text.getString().getSize())
				{
					sf::String temp(m_text.getString());
					temp.erase(m_positioncursor, 1);
					m_text.setString(temp);
				}
				break;

			default:
				break;
		}

		updateCursor();
		return true;
	}
	return false;
}
Пример #24
0
			constexpr auto& Else(FalseFunctor falseFunctor) const
			{
				if( m_func != nullptr )
				{
					m_func( Ident{} );
				}
				else
				{
					falseFunctor( Ident{} );
				}

				return *this;
			}
Пример #25
0
void WorkerThread::MainLoop()
{
	while (m_isAlive)
	{	
		std::unique_lock<std::mutex> locker(m_waitVarMutex);
		m_var.wait(locker, [&](){ return (m_needCheck || !m_isAlive); });
		
		if (m_needCheck)
		{
			m_needCheck = false;
			m_func();
			m_pool->Completed(m_index);
		}
	}
}
Пример #26
0
void
ErrorRec::ErrorFunc2::operator () (int* tag, D_DECL(const int&tlo0,const int&tlo1,const int&tlo2), 
                                   D_DECL(const int&thi0,const int&thi1,const int&thi2), 
                                   const int* tagval, const int* clearval,
                                   Real* data, D_DECL(const int&dlo0,const int&dlo1,const int&dlo2), 
                                   D_DECL(const int&dhi0,const int&dhi1,const int&dhi2), 
                                   const int* lo, const int * hi, const int* nvar,
                                   const int* domain_lo, const int* domain_hi,
                                   const Real* dx, const int* level, const Real* avg) const
{
    BL_ASSERT(m_func != 0);

    m_func(tag,D_DECL(tlo0,tlo1,tlo2),D_DECL(thi0,thi1,thi2),
           tagval,clearval,data,D_DECL(dlo0,dlo1,dlo2),D_DECL(dhi0,dhi1,dhi2),lo,hi,nvar,
           domain_lo,domain_hi,dx,level,avg);
}
Пример #27
0
bool SevenZipLibrary::CreateObject( const GUID& clsID, const GUID& interfaceID, void** outObject ) const
{
	if ( m_func == NULL )
	{
		return false;
		//throw SevenZipException( _T( "Library is not loaded" ) );
	}

	HRESULT hr = m_func( &clsID, &interfaceID, outObject );
	if ( FAILED( hr ) )
	{
		return false;
		//throw SevenZipException( GetCOMErrMsg( _T( "CreateObject" ), hr ) );
	}
	return true;
}
Пример #28
0
Time ScaleChange::step(Time t)
{
    m_cur += t;
    float part = m_period == 0 ? 1.f : clamp(static_cast<float>(m_cur) / m_period, 0.0f, 1.0f);
    part = m_func(part);

    auto scaleX = m_obj->scaleX();
    auto scaleY = m_obj->scaleY();
    if (m_scalingType == X || m_scalingType == Both)
        scaleX = m_curStartScaleX + lerp(0.f, m_curDeltaScaleX, part);
    if (m_scalingType == Y || m_scalingType == Both)
        scaleY = m_curStartScaleY + lerp(0.f, m_curDeltaScaleY, part);
    m_obj->setScale(scaleX, scaleY);

    return m_cur >= m_period ? m_cur - m_period : 0;
}
Пример #29
0
 bool visit_ext(const char* v, uint32_t size) {
     if (size > m_limit.ext()) throw msgpack::ext_size_overflow("ext size overflow");
     msgpack::object* obj = m_stack.back();
     obj->type = msgpack::type::EXT;
     if (m_func && m_func(obj->type, size, m_user_data)) {
         obj->via.ext.ptr = v;
         set_referenced(true);
     }
     else {
         char* tmp = static_cast<char*>(zone().allocate_align(size, MSGPACK_ZONE_ALIGNOF(char)));
         std::memcpy(tmp, v, size);
         obj->via.ext.ptr = tmp;
     }
     obj->via.ext.size = static_cast<uint32_t>(size - 1);
     return true;
 }
Пример #30
0
Time AdvancedMove::step(Time t)
{
    m_cur += t;
    float part = m_period == 0 ? 1.f : clamp(static_cast<float>(m_cur) / m_period, 0.0f, 1.0f);
    part = m_func(part);
    float newCoord = m_curStartValue;
    newCoord += lerp(0.f, m_curDeltaValue, part);

    auto pos = m_obj->getOffset();
    if (m_coordType == Coord::X)
        pos.x = newCoord;
    else
        pos.y = newCoord;
    m_obj->setOffset(pos);

    return m_cur >= m_period ? m_cur - m_period : 0;
}