Exemplo n.º 1
0
/*
 * NAME:	kfun->compile_object()
 * DESCRIPTION:	compile an object
 */
int kf_compile_object(frame *f, int nargs)
{
    char file[STRINGSZ];
    value *v;
    object *obj;
    string **strs;
    int i;

    v = &f->sp[nargs - 1];
    if (path_string(file, v->u.string->text, v->u.string->len) == (char *) NULL)
    {
	return 1;
    }
    obj = o_find(file, OACC_MODIFY);
    if (obj != (object *) NULL) {
	if (!(obj->flags & O_MASTER)) {
	    error("Cannot recompile cloned object");
	}
	if (O_UPGRADING(obj)) {
	    error("Object is already being upgraded");
	}
	if (O_INHERITED(obj)) {
	    error("Cannot recompile inherited object");
	}
    }
    if (--nargs != 0) {
	strs = ALLOCA(string*, nargs);
	for (i = nargs, v = f->sp; i > 0; --i) {
	    *strs++ = (v++)->u.string;
	}
	if (ec_push((ec_ftn) NULL)) {
	    AFREE(strs - nargs);
	    error((char *) NULL);
	}
    } else {
Exemplo n.º 2
0
/*
 * NAME:	kfun->old_compile_object()
 * DESCRIPTION:	compile an object
 */
int kf_old_compile_object(frame *f)
{
    char file[STRINGSZ];
    object *obj;

    if (path_string(file, f->sp->u.string->text,
		    f->sp->u.string->len) == (char *) NULL) {
	return 1;
    }
    obj = o_find(file, OACC_MODIFY);
    if (obj != (object *) NULL) {
	if (!(obj->flags & O_MASTER)) {
	    error("Cannot recompile cloned object");
	}
	if (O_UPGRADING(obj)) {
	    error("Object is already being upgraded");
	}
	if (O_INHERITED(obj)) {
	    error("Cannot recompile inherited object");
	}
    }
    obj = c_compile(f, file, obj, (string **) NULL, 0,
		    (OBJR(f->oindex)->flags & O_DRIVER) &&
		    strcmp(d_get_strconst(f->p_ctrl, f->func->inherit,
					  f->func->index)->text,
			   "inherit_program") == 0);
    str_del(f->sp->u.string);
    PUT_OBJVAL(f->sp, obj);

    return 0;
}
Exemplo n.º 3
0
Arquivo: std.cpp Projeto: RetroMud/dgd
/*
 * NAME:	kfun->compile_object()
 * DESCRIPTION:	compile an object
 */
int kf_compile_object(Frame *f, int nargs, kfunc *kf)
{
    char file[STRINGSZ];
    Value *v;
    Object *obj;
    String **strs;
    int i;
    bool iflag;

    UNREFERENCED_PARAMETER(kf);

    v = &f->sp[nargs - 1];
    if (path_string(file, v->u.string->text, v->u.string->len) == (char *) NULL)
    {
	return 1;
    }
    obj = o_find(file, OACC_MODIFY);
    if (obj != (Object *) NULL) {
	if (!(obj->flags & O_MASTER)) {
	    error("Cannot recompile cloned object");
	}
	if (O_UPGRADING(obj)) {
	    error("Object is already being upgraded");
	}
	if (O_INHERITED(obj)) {
	    error("Cannot recompile inherited object");
	}
    }
    if (--nargs != 0) {
	strs = ALLOCA(String*, nargs);
	for (i = nargs, v = f->sp; i > 0; --i) {
	    *strs++ = (v++)->u.string;
	}
    } else {
Exemplo n.º 4
0
		/*!
		 * \brief
		 * Appends a path or resource to the URL's path section.
		 * 
		 * \param path
		 * Pointer to the path string to append.
		 * 
		 * \param unescape
		 * Sets whether to unescape the directory/resource name(s).
		 * 
		 * Appends a path or resource to the URL's path section.
		 */
		void c_url_interface::AppendPath(const char* path, bool unescape)
		{
			// /directory/directory/directory/resource

			std::string path_string(path);

			if(!path_string.length())
				return;

			std::string::size_type offset;

			// remove trailing and leading slashes
			offset = 0;
			if((std::string::npos != (offset = path_string.find("/"))) && (offset == 0))
				path_string.replace(0, 1, "");

			offset = 0;
			if((std::string::npos != (offset = path_string.rfind("/"))) && (offset == path_string.length() - 1))
				path_string.replace(path_string.length() - 1, 1, "");

			// replace directory traversal dots with empty strings
			offset = 0;
			while(std::string::npos != (offset = path_string.find("..")))
				path_string.replace(offset, 2, "");

			// replace double slashes with single slashes
			offset = 0;
			while(std::string::npos != (offset = path_string.find("//")))
				path_string.replace(offset, 2, "/");

			do
			{
				std::string directory;

				SplitString(path_string, directory, "/", true);

				if((directory.length() == 0) && path_string.length())
				{
					directory = path_string;
					path_string.clear();
				}

				if(directory.length())
				{
					if(unescape)
						Unescape(directory);
					m_path.push_back(directory);
				}
			}while(path_string.length());
		}
Exemplo n.º 5
0
//******************************************************************
// Get depth image out of the disparity image
//******************************************************************
Matrix<double>  AncillaryMethods::GetDepthLibelas(int frame_nr, const Camera& camera, double baseline)
{


    //================================================
    // Read in the disparity image
    //================================================
    char dispImagePath[128];

    sprintf(dispImagePath, Globals::tempDepthL.c_str(), frame_nr);

    string path_string(dispImagePath);
    Matrix<float> image(Globals::dImWidth, Globals::dImHeight, 0.0);

    if(path_string.find(".txt") != string::npos)
    {
        image.ReadFromTXT(dispImagePath);
    }
    else
    {
        image.ReadFromBinaryFile(dispImagePath);
    }

    //================================================
    // Compute the depth map
    //================================================
    Matrix<double> depthMap(Globals::dImWidth, Globals::dImHeight, 0.0);

    Matrix<double> intrinsics = camera.get_K();

    double focalLength = intrinsics(0,0);

    double par = (baseline*focalLength);

    for(int i = 0; i < Globals::dImWidth; i++)
    {
        for(int j = 0; j < Globals::dImHeight; j++)
        {
            depthMap(i,j) = max(0.0, min(30.0,(par/(image(i,j)))/1000.0));
        }
    }

    return depthMap;
}
Exemplo n.º 6
0
void PredicateChecker::handle_boolean(const std::string &key, const bool value)
{
    push_path(key);

    Document view(m_document, path_string(m_path), false);

    if(view.empty() || (view.get_type() != ObjectType::True && view.get_type() != ObjectType::False))
    {
        m_matched = false;
    }
    else
    {
        bool other = view.as_boolean();
        if(other != value)
        {
            m_matched = false;
        }
    }

    pop_path();
}
Exemplo n.º 7
0
void PredicateChecker::handle_float(const std::string &key, const json::float_t value)
{
    push_path(key);

    if(mode() == predicate_mode::NORMAL)
    {
        Document view(m_document, path_string(m_path), false);

        if(view.empty() || view.get_type() != ObjectType::Float)
        {
            m_matched = false;
        }
        else
        {
            json::float_t other = view.as_float();
            if(other != value)
            {
                m_matched = false;
            }
        }
    }
    else if(mode() == predicate_mode::IN)
    {
        for(auto &val: m_pred_values)
        {
            if(val.type == ObjectType::Float && val.floating == value)
            {
                m_pred_matches = true;
            }
            else if(val.type == ObjectType::Integer && val.integer == value)
            {
                m_pred_matches = true;
            }
        }
    }
    else if(mode() == predicate_mode::LESS_THAN)
    {
        for(auto &val: m_pred_values)
        {
            if(val.type == ObjectType::Float && val.floating < value)
            {
                m_pred_matches = true;
            }
            else if(val.type == ObjectType::Integer && val.integer < value)
            {
                m_pred_matches = true;
            }
        }
    }
    else if(mode() == predicate_mode::LESS_THAN_EQUAL)
    {
        for(auto &val: m_pred_values)
        {
            if(val.type == ObjectType::Float && val.floating <= value)
            {
                m_pred_matches = true;
            }
            else if(val.type == ObjectType::Integer && val.integer <= value)
            {
                m_pred_matches = true;
            }
        }
    }
    else if(mode() == predicate_mode::GREATER_THAN)
    {
        for(auto &val: m_pred_values)
        {
            if(val.type == ObjectType::Float && val.floating > value)
            {
                m_pred_matches = true;
            }
            else if(val.type == ObjectType::Integer && val.integer > value)
            {
                m_pred_matches = true;
            }
        }
    }
    else if(mode() == predicate_mode::GREATER_THAN_EQUAL)
    {
        for(auto &val: m_pred_values)
        {
            if(val.type == ObjectType::Float && val.floating >= value)
            {
                m_pred_matches = true;
            }
            else if(val.type == ObjectType::Integer && val.integer >= value)
            {
                m_pred_matches = true;
            }
        }
    }
    else if(mode() == predicate_mode::EQUAL)
    {
        for(auto &val: m_pred_values)
        {
            if(val.type == ObjectType::Float && val.floating == value)
            {
                m_pred_matches = true;
            }
            else if(val.type == ObjectType::Integer && val.integer == value)
            {
                m_pred_matches = true;
            }
        }
    }
    else if(mode() == predicate_mode::NOT_EQUAL)
    {
        for(auto &val: m_pred_values)
        {
            if(val.type == ObjectType::Float && val.floating != value)
            {
                m_pred_matches = true;
            }
            else if(val.type == ObjectType::Integer && val.integer != value)
            {
                m_pred_matches = true;
            }
        }
    }

    pop_path();
}
Exemplo n.º 8
0
		BC_COREPLATFORMIMP_DLL
		bc_platform_path<g_api_win32>::bc_platform_path(const bcECHAR* p_path)
			: m_pack(path_string(p_path))
		{
		}