Beispiel #1
0
Cell lookup(Cell var, Cell env) {
    while (!is_null(env)) {
        Cell frame = car(env);
        Cell vars = car(frame);
        Cell vals = cdr(frame);
        while (!is_null(vars)) {
            if (is_eq(car(vars), var)) {
                return car(vals);
            }
            vars = cdr(vars);
            vals = cdr(vals);
        }
        env = cdr(env);
    }
    return atom("#<unbound>");
}
Beispiel #2
0
void Parser::pattern_pkg() {
    if (tokens[look].type == OPENPAREN) {
        pattern_group();
    } else {
        atom();
        if (tokens[look].type == OPENBRACE) {
            match(OPENBRACE);
            atoms[atoms.size()-1].interval_from = Number(tokens[look].value);
            match(NUM);
            match(COMMA);
            atoms[atoms.size()-1].interval_to = Number(tokens[look].value);
            match(NUM);
            match(CLOSEBRACE);
        }
    }
}
Beispiel #3
0
void XfitMan::setIconGeometry(Window _wid, QRect* rect) const
{
    Atom net_wm_icon_geometry = atom("_NET_WM_ICON_GEOMETRY");
    if(!rect)
        XDeleteProperty(QX11Info::display(), _wid, net_wm_icon_geometry);
    else
    {
        long data[4];
        data[0] = rect->x();
        data[1] = rect->y();
        data[2] = rect->width();
        data[3] = rect->height();
        XChangeProperty(QX11Info::display(), _wid, net_wm_icon_geometry,
                        XA_CARDINAL, 32, PropModeReplace, (unsigned char*)data, 4);
    }
}
Beispiel #4
0
void testLiteral()
{
	tryLiteralOk("true ", [](const JSONAtom &atom) { assertTrue(atom.asBool()); });
	tryLiteralOk("false ", [](const JSONAtom &atom) { assertFalse(atom.asBool()); });
	tryLiteralOk("null ", [](const JSONAtom &atom) { assertNull(atom.asNull()); });

	const char *const json = "invalid ";
	memoryStream_t stream(const_cast<char *const>(json), length(json));
	JSONParser parser(stream);
	try
	{
		std::unique_ptr<JSONAtom> atom(literal(parser));
		fail("The parser failed to throw an exception on invalid literal");
	}
	catch (const JSONParserError &err) { }
}
Beispiel #5
0
/**
 * @brief returns the window that currently has inputfocus
 */
Window XfitMan::getActiveWindow() const
{
    unsigned long len;
    unsigned long *data;
    if (!getWindowProperty(root, atom("_NET_ACTIVE_WINDOW"), XA_WINDOW,
                          &len, (unsigned char**) &data)
       )
        return 0;

    Window result = 0;
    if (len)
        result = data[0];

    XFree(data);
    return result;
}
Beispiel #6
0
PDBChain DNAMutator::mutate(const std::string& seq, const PDBChain& chain) const
{
    if(seq.size() != chain.size())
        throw std::invalid_argument("sequence and chain have different size");

    std::size_t index = 0;
    PDBChain mutated;

    for(auto residue = chain.cbegin(); residue != chain.cend(); ++residue)
    {
        std::shared_ptr<PDBResidue> res(new PDBResidue);
        for(auto iter = (*residue)->cbegin();
                iter != (*residue)->cend(); ++iter)
        {
            // deep copy
            std::shared_ptr<PDBAtom> atom(new PDBAtom(**iter));
            res->push_back(atom);
        }

        ax::Vector3d B(0e0);
        ax::Vector3d S(0e0);

        for(auto atom = res->cbegin(); atom != res->cend(); ++atom)
        {
            if((*atom)->atom() == "DB  ")
                B = (*atom)->pos();
            else if((*atom)->atom() == "DS  ")
                S = (*atom)->pos();
        }

        const ax::Vector3d direction = (B - S) / length(B - S);
        const ax::Vector3d B_newpos = S + 
            direction * this->SBlength.at(seq.at(index));

        for(auto atom = res->cbegin(); atom != res->cend(); ++atom)
        {
            (*atom)->residue() = std::string("D") + seq.at(index) + std::string(" ");
                 if((*atom)->atom() == "DB  ") (*atom)->pos() = B_newpos;
            else if((*atom)->atom() == "DS  ") S = (*atom)->pos();
        }

        mutated.push_back(res);
        index++;
    }

    return mutated;
}
Beispiel #7
0
double atom()
{
	double res = NAN;
	
	if(isdigit(top())) {
		res = literal();
	} else if(top() == '(') {
		next();
		res = addexpr();
		next();
	} else if(top() == '-') {
		next();
		res = -atom();
	}
	
	return res;
}
Beispiel #8
0
/// ( )
void eval_expr5(parser &p, float &value)
{
    MSG("EVAL5\n");
    if(p.tokens[p.index].type == PARENTHESIS_LEFT) {
        p.index++;

        eval_expr(p, value);

        if(p.tokens[p.index].type != PARENTHESIS_RIGHT) {
            MSG("expected )\n");
            return;
        }
        p.index++;
    } else {
        atom(p, value);
    }
}
Beispiel #9
0
 void delayed_reply(const actor_ptr& to,
                    const Duration& rel_time,
                    message_id_t id,
                    any_tuple data           ) {
     CPPA_REQUIRE(!id.valid() || id.is_response());
     if (id.valid()) {
         auto tup = make_any_tuple(atom("REPLY"),
                                   util::duration{rel_time},
                                   to,
                                   id,
                                   std::move(data));
         delayed_send_helper()->enqueue(self, std::move(tup));
     }
     else {
         this->delayed_send(to, rel_time, std::move(data));
     }
 }
Beispiel #10
0
Cell set(Cell var, Cell val, Cell env) {
    while (!is_null(env)) {
        Cell frame = car(env);
        Cell vars = car(frame);
        Cell vals = cdr(frame);
        while (!is_null(vars)) {
            if (is_eq(car(vars), var)) {
                set_car(vals, val);
                return atom("#<void>");
            }
            vars = cdr(vars);
            vals = cdr(vals);
        }
        env = cdr(env);
    }
    fprintf(stderr, "unbound variable\n");
}
Beispiel #11
0
void tryNumberOk(const char *const json, void tests(const JSONAtom &))
{
	try
	{
		memoryStream_t stream(const_cast<char *const>(json), length(json));
		JSONParser parser(stream);
		std::unique_ptr<JSONAtom> atom(number(parser));
		assertNotNull(atom.get());
		tests(*atom);
	}
	catch (const JSONParserError &err)
		{ fail(err.error()); }
	catch (const JSONTypeError &err)
		{ fail(err.error()); }
	catch (const std::bad_alloc &err)
		{ fail(err.what()); }
}
Beispiel #12
0
/*
 * ISO 9660 file names must be uppercase, digits, or underscore.
 * We use lowercase, digits, and underscore, translating lower to upper
 * in mkisostring, and upper to lower in isostring.
 * Files with uppercase letters in their names are thus nonconforming.
 * Conforming files also must have a basename
 * at most 8 letters and at most one suffix of at most 3 letters.
 */
char*
isostring(uchar *buf, int len)
{
	char *p, *q;

	p = emalloc(len+1);
	memmove(p, buf, len);
	p[len] = '\0';
	while(len > 0 && p[len-1] == ' ')
		p[--len] = '\0';
	for(q=p; *q; q++)
		*q = tolower(*q);

	q = atom(p);
	free(p);
	return q;
}
Beispiel #13
0
Expression read_from_tokens(InputIterator& first, InputIterator& last) {
    if (first == last) {
        throw std::runtime_error("Syntax error: unexpected EOF while reading");
    }

    if ("(" == *first) {
        List out;
        while ( *(++first) != ")" ) {
            out.push_back(read_from_tokens(first,last));
        }
        return out;
    } else if (")" == *first) {
        throw std::runtime_error("Syntax error: unexpected ')'");
    }
    else {
        return atom(*first);
    }
}
void
FilterTotalFormalCharge::Calculate(OpenBabel::OBMol* mol)
{
   _result = 0;
   for(OpenBabel::OBMolAtomIter atom(mol); atom; ++atom)
   {
      _result += atom->GetFormalCharge();
   }
   
   if ((_minLimit && (_result < _min)) || (_maxLimit && (_result > _max)))
   {
      _passed = false;
   }
   else
   {
      _passed = true;
   }
}
Beispiel #15
0
void
FilterCarbons::Calculate(OpenBabel::OBMol* mol)
{
   _result = 0;
   for(OpenBabel::OBMolAtomIter atom(mol); atom; ++atom)
   {
      if (atom->IsCarbon()) ++_result;
   }
   
   if ((_minLimit && (_result < _min)) || (_maxLimit && (_result > _max)))
   {
      _passed = false;
   }
   else
   {
      _passed = true;
   }
}
void default_actor_addressing::put(const process_information& node,
                                   actor_id aid,
                                   const actor_proxy_ptr& proxy) {
    auto& submap = m_proxies[node];
    auto i = submap.find(aid);
    if (i == submap.end()) {
        submap.insert(make_pair(aid, proxy));
        m_parent->enqueue(node,
        {nullptr, nullptr},
        make_any_tuple(atom("MONITOR"),
                       process_information::get(),
                       aid));
    }
    else {
        CPPA_LOGMF(CPPA_ERROR, self, "proxy for " << aid << ":"
                   << to_string(node) << " already exists");
    }
}
Beispiel #17
0
DEM redu (DEM x)
{
int forme_Sfg;
DEM rf, ra, f1, a1, x1, r1, r2, t1, t2, t3, t4, t5, t6, r, rr1;
	trace_dem ("redu", x);
	if (atom(x))
        {
                trace_dem ("atom: return", x);
		return x;
        }
        trace_dem ("not atom", x);
        rf = redu (fnc(x)); trace_dem ("", rf);
        ra = redu (arg(x)); trace_dem ("", ra);
	f1 = right (rf); trace_dem ("", f1);
	a1 = right (ra); trace_dem ("", a1);
        trace_dem ("", x);
        if (fnc(x)==f1 && arg(x)==a1)
	{
		r1 = redu1 (x); trace_dem ("", r1);
                rr1 = right(r1); trace_dem ("", rr1);
		if (rr1 == x)
                {
                        trace_dem ("return", r1);
			return r1;
                }
                trace_dem ("", rr1);
		r2 = redu (rr1); trace_dem ("", r2);
		if (left(r2) == right(r2))
			return r1;
		if (left(r1) == right(r1))
			return r2;
		r = trans (r1, r2); trace_dem ("", r);
		return r;
	}
	x1 = ap (f1, a1); trace_dem ("", x1);
	r1 = redu1 (x1); trace_dem ("", r1);
	if (right(r1) == x)
		r2 = r1;
	r2 = redu (right(r1)); trace_dem ("", r2);
	t3 = ap (rf, ra); trace_dem ("", t3);
	t4 = trans (t3, r1); trace_dem ("", t4);
	t5 = trans (t4, r2); trace_dem ("", t5);
	return t5;
}
Beispiel #18
0
int	script_parse(const char *script, const char *_arg) {
	char	*arg = NULL;
	int	a, b;

	if (script == NULL)
		return(0);

	if (_arg != NULL)
		_arg = arg = strdup(_arg);
	for (a = 0; (a < 50) && (arg != NULL); a++) {
		char	buf[1024], *tmp;

		tmp = atom(arg);
		snprintf(buf, sizeof(buf), "args%i*", a+1);
		secs_setvar(buf, tmp);
		arg = firstwhite(arg);
		snprintf(buf, sizeof(buf), "arg%i", a+1);
		secs_setvar(buf, tmp);
        }
	for (b = a; b < 50; b++) {
		char	buf[1024];

		snprintf(buf, sizeof(buf), "args%i*", b+1);
		secs_setvar(buf, "");
		snprintf(buf, sizeof(buf), "arg%i", b+1);
		secs_setvar(buf, "");
	}

	secs_script_parse(script);

	while (a > 0) {
		char	buf[1024];

		snprintf(buf, sizeof(buf), "arg%i", a);
		secs_setvar(buf, "");
		snprintf(buf, sizeof(buf), "args%i*", a);
		secs_setvar(buf, "");
		a--;
	}

	if (_arg != NULL)
		free((void *)_arg);
	return(1);
}
Beispiel #19
0
bool actor::establish_backlink(const actor_ptr& other) {
    std::uint32_t reason = exit_reason::not_exited;
    if (other && other != this) {
        guard_type guard{m_mtx};
        reason = m_exit_reason;
        if (reason == exit_reason::not_exited) {
            auto i = std::find(m_links.begin(), m_links.end(), other);
            if (i == m_links.end()) {
                m_links.push_back(other);
                return true;
            }
        }
    }
    // send exit message without lock
    if (reason != exit_reason::not_exited) {
        send_as(this, other, make_any_tuple(atom("EXIT"), reason));
    }
    return false;
}
Beispiel #20
0
bool parser::parse_atom(utf8str::iterator& it, utf8str::iterator& it_end, shared_ptr<expr>& result)
{
	if (it != it_end)
	{
		uint32_t ch = utf8::peek_next(it, it_end);		
		if (is_atom_char(ch))
		{
			utf8::unchecked::next(it);
			shared_ptr<utf8str> atom(new utf8str());
			atom->append(ch);
			while (it != it_end)
			{
				ch = utf8::peek_next(it, it_end);
				if (is_atom_char(ch))
				{
					utf8::unchecked::next(it);
					atom->append(ch);
				}
				else
				{					
					break;
				}
			}
			try
			{
				cout << "Trying to coerce value to integer" << std::endl;
				int intValue = boost::lexical_cast<int>(atom->get_string());
				result = shared_ptr<expr>(new expr(intValue));				
			}
			catch(boost::bad_lexical_cast& e)
			{
				cout << "Not an integer, than symbol" << std::endl;
				result = shared_ptr<expr>(new expr(atom));				
			}
			return true;
		}
		else
		{			
			return false;
		}
	}
	return false;
}
Beispiel #21
0
List Factory::convert(Data::Geometry& geometry)
{
   List list;
   Atoms* atoms(new Atoms());
   Bonds* bonds(new Bonds());
   list.append(atoms);
   list.append(bonds);

   unsigned nAtoms(geometry.nAtoms());
   OpenBabel::OBMol obMol;
   obMol.BeginModify();
   AtomMap atomMap;
   
   for (unsigned i = 0; i < nAtoms; ++i) {
       unsigned Z(geometry.atomicNumber(i));
       qglviewer::Vec position(geometry.position(i));

       Atom* atom(new Atom(geometry.atomicNumber(i)));
       atom->setPosition(geometry.position(i));
       atoms->appendLayer(atom);

       OpenBabel::OBAtom* obAtom(obMol.NewAtom());
       obAtom->SetAtomicNum(Z);
       obAtom->SetVector(position.x, position.y, position.z);
       atomMap.insert(obAtom, atom);
   }

   obMol.SetTotalCharge(geometry.charge());
   obMol.SetTotalSpinMultiplicity(geometry.multiplicity());
   obMol.EndModify();
   obMol.ConnectTheDots();
   obMol.PerceiveBondOrders();

   for (OpenBabel::OBMolBondIter obBond(&obMol); obBond; ++obBond) {
       Atom* begin(atomMap.value(obBond->GetBeginAtom()));
       Atom* end(atomMap.value(obBond->GetEndAtom()));
       Bond* bond(new Bond(begin, end));
       bond->setOrder(obBond->GetBondOrder());
       bonds->appendLayer(bond);
   }

   return list;
}
Beispiel #22
0
char*
jolietstring(uchar *buf, int len)
{
	char *p, *q;
	int i;
	Rune *rp;

	rp = emalloc(sizeof(Rune)*(len/2+1));
	p = emalloc(UTFmax*(len/2+1));

	for(i=0; i<len/2; i++)
		rp[i] = (buf[2*i]<<8) | buf[2*i+1];
	rp[i] = (Rune)'\0';

	snprint(p, UTFmax*(len/2+1), "%S", rp);
	q = atom(p);
	free(p);
	return q;
}
Beispiel #23
0
namespace riac {

/// Used to query all known nodes from nexus
using list_nodes = atom_constant<atom("listNodes")>;

/// Used to query meta information about a particular node.
using get_node = atom_constant<atom("getNode")>;

/// Used to query all peers of a particular node.
using list_peers = atom_constant<atom("listPeers")>;

/// Used to query system load information on a particular node.
using get_sys_load = atom_constant<atom("getSysLoad")>;

/// Used to query RAM usage on a particular node.
using get_ram_usage = atom_constant<atom("getRam")>;

/// Used to query all known actors on a particular node.
using list_actors = atom_constant<atom("listActors")>;

/// Used to query a single actor on a particular node.
using get_actor = atom_constant<atom("getActor")>;

struct nexus_proxy_state {
  riac::probe_data_map data;
  std::list<node_id> visited_nodes;
};

using nexus_proxy_type =
  nexus_type::extend<
    reacts_to<probe_data_map>,
    replies_to<list_nodes>::with<std::vector<node_id>>,
    replies_to<list_nodes, std::string>::with<std::vector<node_id>>,
    replies_to<get_node, node_id>::with<node_info>,
    replies_to<list_peers, node_id>::with<std::vector<node_id>>,
    replies_to<get_sys_load, node_id>::with<work_load>,
    replies_to<get_ram_usage, node_id>::with<ram_usage>,
    replies_to<list_actors, node_id>::with<std::vector<strong_actor_ptr>>,
    replies_to<get_actor, node_id, actor_id>::with<strong_actor_ptr>
  >;

nexus_proxy_type::behavior_type
nexus_proxy(nexus_proxy_type::stateful_pointer<nexus_proxy_state> self);

} // namespace riac
Beispiel #24
0
/**
 * @brief gets a client list
 */
WindowList XfitMan::getClientList() const
{
    //initialize the parameters for the XGetWindowProperty call
    unsigned long length, *data;
    length=0;

    /**
     * @todo maybe support multiple desktops here!
     */
    QList<Window> output;

    if (getRootWindowProperty(atom("_NET_CLIENT_LIST"), (Atom)AnyPropertyType, &length,  (unsigned char**) &data))
    {
        for (unsigned int i = 0; i < length; i ++)
            output.append(data[i]);
        XFree(data);
    }

    return output;
}
Beispiel #25
0
object *eval (object *o)
{
  /* printf("%s: Trying to eval object type: %d\n", __func__, o->type); */

if (is_truthy (atom (o))) {
  if (symbol_p (o)) {
    /* printf("%s: Looking for symbol\n", __func__); */
    return env_find_symbol_value (current_env, o);
  } else {
    /* printf("%s: Not eval-ing\n", __func__); */
    return o;
  }
 } else {
  /* printf("%s: Function call\n", __func__); */
    object *symbol = car (o);
    object *arguments = cdr (o);

    return call_function (symbol, arguments);
  }
}
Beispiel #26
0
void Parser::parseAtoms() {
    int id;
    char buff[1024];
    
    while(true) {
        in >> id;
        switch(id) {
        case 0:
            return;
            
        default:
            assert(id > 0);
            in.getline(buff, 1024);
            Atom atom(program, id);
            assert(buff[0] = ' ');
            atom.setName(string(buff+1));
            break;
        }
    }
}
Beispiel #27
0
  static void test_common()
  {
    try
    {
      std::size_t actor_num = 10;
      context ctx;
      threaded_actor base = spawn(ctx);

      for (std::size_t a=0; a<5; ++a)
      {
        for (std::size_t i=0; i<actor_num; ++i)
        {
          aid_t aid = spawn(
            base,
            boost::bind(&coro_ut::my_actor, _arg1, base.get_aid()),
            monitored
            );
        }

        std::size_t i=0;
        while (i < actor_num)
        {
          message msg;
          aid_t sender = base.recv(msg);
          match_t type = msg.get_type();
          if (type == atom("echo"))
          {
            base.send(sender, msg);
          }
          else
          {
            ++i;
          }
        }
      }
    }
    catch (std::exception& ex)
    {
      std::cerr << ex.what() << std::endl;
    }
  }
Beispiel #28
0
void cESBTL::pdbTranslate(const std::string& fileIn, const std::string& fileOut, const cVector3<double>& offset)
{
    checkExtension(fileIn);
    checkExtension(fileOut);

    // input
    ESBTL::PDB_line_selector                                pdbSelector;
    std::vector<ESBTL::Default_system>                      pdbSystems;
    ESBTL::All_atom_system_builder<ESBTL::Default_system>   pdbBuilder(pdbSystems, pdbSelector.max_nb_systems());

    require(ESBTL::read_a_pdb_file(fileIn, pdbSelector, pdbBuilder, Occupancy_policy_all()), "cannot read PDB file");
    require(!pdbSystems.empty(),     "No PDB system");
    require( pdbSystems.size() == 1, "More than one PDB system: pdbSystems.size() = " + num2str(pdbSystems.size()));
    require(!pdbSystems[0].has_no_model(),          "No model in 1st PDB system");
    require( pdbSystems[0].number_of_models() == 1, "More than one model in 1st PDB system: pdbSystems[0].number_of_models() = "
                                                 + num2str(pdbSystems[0].number_of_models()));

    // output
    std::ofstream               output(fileOut.c_str());
    assure(output);

    // translate
    for (ESBTL::Default_system::Models_iterator iterModel  = pdbSystems[0].models_begin();
                                                iterModel != pdbSystems[0].models_end();
                                                iterModel++) {

        const ESBTL::Default_system::Model&     model = *iterModel;

        for (ESBTL::Default_system::Model::Atoms_const_iterator iterAtom  = model.atoms_begin();
                                                                iterAtom != model.atoms_end();
                                                                iterAtom++) {
            ESBTL::Default_system::Atom     atom(*iterAtom);

            atom.x() += offset[0];
            atom.y() += offset[1];
            atom.z() += offset[2];

            output << ESBTL::PDB::get_atom_pdb_format(atom) << "\n";
        }
    }
}
void
FilterLipinskiDonors::Calculate(OpenBabel::OBMol* mol)
{
   _result = 0;
   for(OpenBabel::OBMolAtomIter atom(mol); atom; ++atom)
   {
      if (atom->IsOxygen() || atom->IsNitrogen())
      {
         _result += atom->GetImplicitValence() - atom->GetHvyValence();
      }
   }
   
   if ((_minLimit && (_result < _min)) || (_maxLimit && (_result > _max)))
   {
      _passed = false;
   }
   else
   {
      _passed = true;
   }
}
Beispiel #30
0
/**
 * @brief rejects a window from beeing listed
 */
bool XfitMan::acceptWindow(Window window) const
{
    {
        AtomList types = getWindowType(window);
        AtomList ignoreList;
        ignoreList  << atom("_NET_WM_WINDOW_TYPE_DESKTOP")
                    << atom("_NET_WM_WINDOW_TYPE_DOCK")
                    << atom("_NET_WM_WINDOW_TYPE_SPLASH")
                    << atom("_NET_WM_WINDOW_TYPE_TOOLBAR")
                    << atom("_NET_WM_WINDOW_TYPE_MENU")
                    // for qlipper - using qpopup as a main window
                    << atom("_NET_WM_WINDOW_TYPE_POPUP_MENU");
        // issue #284: qmmp its not registered in window list panel
        // qmmp has _KDE_NET_WM_WINDOW_TYPE_OVERRIDE in its
        // _NET_WM_WINDOW_TYPE(ATOM) = _KDE_NET_WM_WINDOW_TYPE_OVERRIDE, _NET_WM_WINDOW_TYPE_NORMAL
        // Let's expect that _KDE_NET_WM_WINDOW_TYPE_OVERRIDE can be set for
        // regular windows too. If it should be hidden we should expect
        // one of atoms listed above.
//                    << atom("_KDE_NET_WM_WINDOW_TYPE_OVERRIDE");

        foreach (Atom i, ignoreList)
        {
            if (types.contains(i))
                return false;
        }

        WindowState state = getWindowState(window);
        if (state.SkipTaskBar)  return false;
    }

    Window transFor = None;
    // WM_TRANSIENT_FOR hint not set - normal window
    if (!XGetTransientForHint(QX11Info::display(), window, &transFor))
        return true;

    if (transFor == 0)      return true;
    if (transFor == window) return true;
    if (transFor == root)   return true;

     AtomList transForTypes = getWindowType(transFor);
     return !transForTypes.contains(atom("_NET_WM_WINDOW_TYPE_NORMAL"));
}