コード例 #1
0
pointer us_bundle_stop(scheme* sc, pointer args)
{
  if(args == sc->NIL)
  {
    std::cerr << "Empty argument list" << std::endl;
    return sc->F;
  }

  if (sc->vptr->list_length(sc, args) != 1)
  {
    return sc->F;
  }

  pointer arg = pair_car(args);

  Bundle bundle;
  if (is_string(arg))
  {
    std::string name = sc->vptr->string_value(arg);
    bundle = get_bundle(name);
  }
  else if (is_integer(arg))
  {
    bundle = GetBundleContext().GetBundle(ivalue(arg));
  }

  if (bundle)
  {
    try
    {
      bundle.Stop();
      return sc->T;
    }
    catch (const std::exception& e)
    {
      std::cerr << e.what();
    }
  }

  return sc->F;
}