Exemple #1
0
static PyObject *PyView_find(PyView *o, PyObject *_args, PyObject* _kwargs) {
  PWONumber start(0);
  PWOMapping crit;
  try {
    PWOSequence args(_args);
    if (_kwargs) {
      PWOMapping kwargs(_kwargs);
      if (kwargs.hasKey("start")) {
        start = kwargs["start"];
        kwargs.delItem("start");
      }
      crit = kwargs;
    }
    int numargs = args.len();
    for (int i=0; i<numargs; ++i) {
      if (PyNumber_Check((PyObject*)args[i]))
        start = args[i];
      else
        crit = args[i];
    }
    c4_Row temp;
    o->makeRow(temp, crit, false);
    return PWONumber(o->Find(temp, start)).disOwn();
  }
  catch (...) { return 0; }
}
Exemple #2
0
/*!
 * Load a JSON object with an args array and kwargs object parsed from the args string
 */
static void loadArgs(
    const CodeLine &codeLine, Poco::JSON::Object &obj, const std::string &argsStr,
    const std::string &argsKey = "args", const std::string &kwargsKey = "kwargs")
{
    Poco::JSON::Array::Ptr args(new Poco::JSON::Array());
    Poco::JSON::Object::Ptr kwargs(new Poco::JSON::Object());
    try {extractArgs(argsStr, args, kwargs);}
    catch (const Pothos::Exception &ex)
    {
        throw Pothos::SyntaxException(codeLine.toString(), ex);
    }

    if (args->size() > 0) obj.set(argsKey, args);
    if (kwargs->size() > 0) obj.set(kwargsKey, kwargs);
}