text:
#include "defs.h"
#include "charset.h"
#include "value.h"
#include "language.h"
#include "target-float.h"
#include "valprint.h"
#include "infcall.h"
#include "expression.h"
#include "cp-abi.h"
#include "python.h"

#include "python-internal.h"

/* Even though Python scalar types directly map to host types, we use
   target types here to remain consistent with the values system in
   GDB (which uses target arithmetic).  */

/* Python's integer type corresponds to C's long type.  */
#define builtin_type_pyint builtin_type (python_gdbarch)->builtin_long

/* Python's float type corresponds to C's double type.  */
#define builtin_type_pyfloat builtin_type (python_gdbarch)->builtin_double

/* Python's long type corresponds to C's long long type.  */
#define builtin_type_pylong builtin_type (python_gdbarch)->builtin_long_long

/* Python's long type corresponds to C's long long type.  Unsigned version.  */
#define builtin_type_upylong builtin_type \
  (python_gdbarch)->builtin_unsigned_long_long

#define builtin_type_pybool \
  language_bool_type (python_language, python_gdbarch)

#define builtin_type_pychar \
  language_string_char_type (python_language, python_gdbarch)

typedef struct value_object {
  PyObject_HEAD
  struct value_object *next;
  struct value_object *prev;
  struct value *value;
  PyObject *address;
  PyObject *type;
  PyObject *dynamic_type;
} value_object;

/* List of all values which are currently exposed to Python. It is
   maintained so that when an objfile is discarded, preserve_values
   can copy the values' types if needed.  */
/* This variable is unnecessarily initialized to NULL in order to
   work around a linker bug on MacOS.  */
static value_object *values_in_python = NULL;

/* Called by the Python interpreter when deallocating a value object.  */
static void
valpy_dealloc (PyObject *obj)
{
  value_object *self = (value_object *) obj;

  /* Remove SELF from the global list.  */
  if (self->prev)
    self->prev->next = self->next;
  else
    {
      gdb_assert (values_in_python == self);
      values_in_python = self->next;
    }
  if (self->next)
    self->next->prev = self->prev;

  value_decref (self->value);

  Py_XDECREF (self->address);
  Py_XDECREF (self->type);
  Py_XDECREF (self->dynamic_type);

  Py_TYPE (self)->tp_free (self);
}

/* Helper to push a Value object on the global list.  */
static void
note_value (value_object *value_obj)
{
  value_obj->next = values_in_python;
  if (value_obj->next)
    value_obj->next->prev = value_obj;
  value_obj->prev = NULL;
  values_in_python = value_obj;
}

/* Convert a python object OBJ with type TYPE to a gdb value.  The
   python object in question must conform to the python buffer
   protocol.  On success, return the converted value, otherwise
   nullptr.  */

static struct value *
convert_buffer_and_type_to_value (PyObject *obj, struct type *type)
{
  Py_buffer_up buffer_up;
  Py_buffer py_buf;

  if (PyObject_CheckBuffer (obj)
      && PyObject_GetBuffer (obj, &py_buf, PyBUF_SIMPLE) == 0)
    {
      /* Got a buffer, py_buf, out of obj.  Cause it to be released
         when it goes out of scope.  */
      buffer_up.reset (&py_buf);
    }
  else
    {
      PyErr_SetString (PyExc_TypeError,
		       _("Object must support the python buffer protocol."));
      return nullptr;
    }

  if (TYPE_LENGTH (type) > py_buf.len)
    {
      PyErr_SetString (PyExc_ValueError,
		       _("Size of type is larger than that of buffer object."));
      return nullptr;
    }

  return value_from_contents (type, (const gdb_byte *) py_buf.buf);
}

/* Called when a new gdb.Value object needs to be allocated.  Returns NULL on
   error, with a python exception set.  */
static PyObject *
valpy_new (PyTypeObject *subtype, PyObject *args, PyObject *kwargs)
{
  static const char *keywords[] = { "val", "type", NULL };
  PyObject *val_obj = nullptr;
  PyObject *type_obj = nullptr;

  if (!gdb_PyArg_ParseTupleAndKeywords (args, kwargs, "O|O", keywords,
					&val_obj, &type_obj))
    return nullptr;

  struct type *type = nullptr;

  if (type_obj != nullptr)
    {
      type = type_object_to_type (type_obj);
      if (type == nullptr)
        {
	  PyErr_SetString (PyExc_TypeError,
			   _("type argument must be a gdb.Type."));
	  return nullptr;
	}
    }

  value_object *value_obj = (value_object *) subtype->tp_alloc (subtype, 1);
  if (value_obj == NULL)
    {
      PyErr_SetString (PyExc_MemoryError, _("Could not allocate memory to "
					    "create Value object."));
      return NULL;
    }

  struct value *value;

  if (type == nullptr)
    value = convert_value_from_python (val_obj);
  else
    value = convert_buffer_and_type_to_value (val_obj, type);

  if (value == nullptr)
    {
      subtype->tp_free (value_obj);
      return NULL;
    }

  value_obj->value = release_value (value).release ();
  value_obj->address = NULL;
  value_obj->type = NULL;
  value_obj->dynamic_type = NULL;
  note_value (value_obj);

  return (PyObject *) value_obj;
}

/* Iterate over all the Value objects, calling preserve_one_value on
   each.  */
void
gdbpy_preserve_values (const struct extension_language_defn *extlang,
		       struct objfile *objfile, htab_t copied_types)
{
  value_object *iter;

  for (iter = values_in_python; iter; iter = iter->next)
    preserve_one_value (iter->value, objfile, copied_types);
}

/* Given a value of a pointer type, apply the C unary * operator to it.  */
static PyObject *
valpy_dereference (PyObject *self, PyObject *args)
{
  PyObject *result = NULL;

  TRY
    {
      struct value *res_val;
      scoped_value_mark free_values;

      res_val = value_ind (((value_object *) self)->value);
      result = value_to_value_object (res_val);
    }
  CATCH (except, RETURN_MASK_ALL)
    {
      GDB_PY_HANDLE_EXCEPTION (except);
    }
  END_CATCH

  return result;
}

/* Given a value of a pointer type or a reference type, return the value
   referenced. The difference between this function and valpy_dereference is
   that the latter applies * unary operator to a value, which need not always
   result in the value referenced. For example, for a value which is a reference
   to an 'int' pointer ('int *'), valpy_dereference will result in a value of
   type 'int' while valpy_referenced_value will result in a value of type
   'int *'.  */

static PyObject *
valpy_referenced_value (PyObject *self, PyObject *args)
{
  PyObject *result = NULL;

  TRY
    {
      struct value *self_val, *res_val;
      scoped_value_mark free_values;

      self_val = ((value_object *) self)->value;
      switch (TYPE_CODE (check_typedef (value_type (self_val))))
        {
        case TYPE_CODE_PTR:
          res_val = value_ind (self_val);
          break;
        case TYPE_CODE_REF:
        case TYPE_CODE_RVALUE_REF:
          res_val = coerce_ref (self_val);
          break;
        default:
          error(_("Trying to get the referenced value from a value which is "
                  "neither a pointer nor a reference."));
        }

      result = value_to_value_object (res_val);
    }
  CATCH (except, RETURN_MASK_ALL)
    {
      GDB_PY_HANDLE_EXCEPTION (except);
    }
  END_CATCH

  return result;
}

/* Return a value which is a reference to the value.  */

static PyObject *
valpy_reference_value (PyObject *self, PyObject *args, enum type_code refcode)
{
  PyObject *result = NULL;

  TRY
    {
      struct value *self_val;
      scoped_value_mark free_values;

      self_val = ((value_object *) self)->value;
      result = value_to_value_object (value_ref (self_val, refcode));
    }
  CATCH (except, RETURN_MASK_ALL)
    {
      GDB_PY_HANDLE_EXCEPTION (except);
    }
  END_CATCH

  return result;
}

static PyObject *
valpy_lvalue_reference_value (PyObject *self, PyObject *args)
{
  return valpy_reference_value (self, args, TYPE_CODE_REF);
}

static PyObject *
valpy_rvalue_reference_value (PyObject *self, PyObject *args)
{
  return valpy_reference_value (self, args, TYPE_CODE_RVALUE_REF);
}

/* Return a "const" qualified version of the value.  */

static PyObject *
valpy_const_value (PyObject *self, PyObject *args)
{
  PyObject *result = NULL;

  TRY
    {
      struct value *self_val, *res_val;
      scoped_value_mark free_values;

      self_val = ((value_object *) self)->value;
      res_val = make_cv_value (1, 0, self_val);
      result = value_to_value_object (res_val);
    }
  CATCH (except, RETURN_MASK_ALL)
    {
      GDB_PY_HANDLE_EXCEPTION (except);
    }
  END_CATCH

  return result;
}

/* Return "&value".  */
static PyObject *
valpy_get_address (PyObject *self, void *closure)
{
  value_object *val_obj = (value_object *) self;

  if (!val_obj->address)
    {
      TRY
	{
	  struct value *res_val;
	  scoped_value_mark free_values;

	  res_val = value_addr (val_obj->value);
	  val_obj->address = value_to_value_object (res_val);
	}
      CATCH (except, RETURN_MASK_ALL)
	{
	  val_obj->address = Py_None;
	  Py_INCREF (Py_None);
	}
      END_CATCH
    }

  Py_XINCREF (val_obj->address);

  return val_obj->address;
}

/* Return type of the value.  */
static PyObject *
valpy_get_type (PyObject *self, void *closure)
{
  value_object *obj = (value_object *) self;

  if (!obj->type)
    {
      obj->type = type_to_type_object (value_type (obj->value));
      if (!obj->type)
	return NULL;
    }
  Py_INCREF (obj->type);
  return obj->type;
}

/* Return dynamic type of the value.  */

static PyObject *
valpy_get_dynamic_type (PyObject *self, void *closure)
{
  value_object *obj = (value_object *) self;
  struct type *type = NULL;

  if (obj->dynamic_type != NULL)
    {
      Py_INCREF (obj->dynamic_type);
      return obj->dynamic_type;
    }

  TRY
    {
      struct value *val = obj->value;
      scoped_value_mark free_values;

      type = value_type (val);
      type = check_typedef (type);

      if (((TYPE_CODE (type) == TYPE_CODE_PTR) || TYPE_IS_REFERENCE (type))
	  && (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_STRUCT))
	{
	  struct value *target;
	  int was_pointer = TYPE_CODE (type) == TYPE_CODE_PTR;

	  if (was_pointer)
	    target = value_ind (val);
	  else
	    target = coerce_ref (val);
	  type = value_rtti_type (target, NULL, NULL, NULL);

	  if (type)
	    {
	      if (was_pointer)
		type = lookup_pointer_type (type);
	      else
		type = lookup_lvalue_reference_type (type);
	    }
	}
      else if (TYPE_CODE (type) == TYPE_CODE_STRUCT)
	type = value_rtti_type (val, NULL, NULL, NULL);
      else
	{
	  /* Re-use object's static type.  */
	  type = NULL;
	}
    }
  CATCH (except, RETURN_MASK_ALL)
    {
      GDB_PY_HANDLE_EXCEPTION (except);
    }
  END_CATCH

  if (type == NULL)
    obj->dynamic_type = valpy_get_type (self, NULL);
  else
    obj->dynamic_type = type_to_type_object (type);

  Py_XINCREF (obj->dynamic_type);
  return obj->dynamic_type;
}

/* Implementation of gdb.Value.lazy_string ([encoding] [, length]) ->
   string.  Return a PyObject representing a lazy_string_object type.
   A lazy string is a pointer to a string with an optional encoding and
   length.  If ENCODING is not given, encoding is set to None.  If an
   ENCODING is provided the encoding parameter is set to ENCODING, but
   the string is not encoded.
   If LENGTH is provided then the length parameter is set to LENGTH.
   Otherwise if the value is an array of known length then the array's length
   is used.  Otherwise the length will be set to -1 (meaning first null of
   appropriate with).

   Note: In order to not break any existing uses this allows creating
   lazy strings from anything.  PR 20769.  E.g.,
   gdb.parse_and_eval("my_int_variable").lazy_string().
   "It's easier to relax restrictions than it is to impose them after the
   fact."  So we should be flagging any unintended uses as errors, but it's
   perhaps too late for that.  */

static PyObject *
valpy_lazy_string (PyObject *self, PyObject *args, PyObject *kw)
{
  gdb_py_longest length = -1;
  struct value *value = ((value_object *) self)->value;
  const char *user_encoding = NULL;
  static const char *keywords[] = { "encoding", "length", NULL };
  PyObject *str_obj = NULL;

  if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "|s" GDB_PY_LL_ARG,
					keywords, &user_encoding, &length))
    return NULL;

  if (length < -1)
    {
      PyErr_SetString (PyExc_ValueError, _("Invalid length."));
      return NULL;
    }

  TRY
    {
      scoped_value_mark free_values;
      struct type *type, *realtype;
      CORE_ADDR addr;

      type = value_type (value);
      realtype = check_typedef (type);

      switch (TYPE_CODE (realtype))
	{
	case TYPE_CODE_ARRAY:
	  {
	    LONGEST array_length = -1;
	    LONGEST low_bound, high_bound;

	    /* PR 20786: There's no way to specify an array of length zero.
	       Record a length of [0,-1] which is how Ada does it.  Anything
	       we do is broken, but this one possible solution.  */
	    if (get_array_bounds (realtype, &low_bound, &high_bound))
	      array_length = high_bound - low_bound + 1;
	    if (length == -1)
	      length = array_length;
	    else if (array_length == -1)
	      {
		type = lookup_array_range_type (TYPE_TARGET_TYPE (realtype),
						0, length - 1);
	      }
	    else if (length != array_length)
	      {
		/* We need to create a new array type with the
		   specified length.  */
		if (length > array_length)
		  error (_("Length is larger than array size."));
		type = lookup_array_range_type (TYPE_TARGET_TYPE (realtype),
						low_bound,
						low_bound + length - 1);
	      }
	    addr = value_address (value);
	    break;
	  }
	case TYPE_CODE_PTR:
	  /* If a length is specified we defer creating an array of the
	     specified width until we need to.  */
	  addr = value_as_address (value);
	  break;
	default:
	  /* Should flag an error here.  PR 20769.  */
	  addr = value_address (value);
	  break;
	}

      str_obj = gdbpy_create_lazy_string_object (addr, length, user_encoding,
						 type);
    }
  CATCH (except, RETURN_MASK_ALL)
    {
      GDB_PY_HANDLE_EXCEPTION (except);
    }
  END_CATCH

  return str_obj;
}

/* Implementation of gdb.Value.string ([encoding] [, errors]
   [, length]) -> string.  Return Unicode string with value contents.
   If ENCODING is not given, the string is assumed to be encoded in
   the target's charset.  If LENGTH is provided, only fetch string to
   the length provided.  */

static PyObject *
valpy_string (PyObject *self, PyObject *args, PyObject *kw)
{
  int length = -1;
  gdb::unique_xmalloc_ptr<gdb_byte> buffer;
  struct value *value = ((value_object *) self)->value;
  const char *encoding = NULL;
  const char *errors = NULL;
  const char *user_encoding = NULL;
  const char *la_encoding = NULL;
  struct type *char_type;
  static const char *keywords[] = { "encoding", "errors", "length", NULL };

  if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "|ssi", keywords,
					&user_encoding, &errors, &length))
    return NULL;

  TRY
    {
      LA_GET_STRING (value, &buffer, &length, &char_type, &la_encoding);
    }
  CATCH (except, RETURN_MASK_ALL)
    {
      GDB_PY_HANDLE_EXCEPTION (except);
    }
  END_CATCH

  encoding = (user_encoding && *user_encoding) ? user_encoding : la_encoding;
  return PyUnicode_Decode ((const char *) buffer.get (),
			   length * TYPE_LENGTH (char_type),
			   encoding, errors);
}

/* A helper function that implements the various cast operators.  */

static PyObject *
valpy_do_cast (PyObject *self, PyObject *args, enum exp_opcode op)
{
  PyObject *type_obj, *result = NULL;
  struct type *type;

  if (! PyArg_ParseTuple (args, "O", &type_obj))
    return NULL;

  type = type_object_to_type (type_obj);
  if (! type)
    {
      PyErr_SetString (PyExc_RuntimeError,
		       _("Argument must be a type."));
      return NULL;
    }

  TRY
    {
      struct value *val = ((value_object *) self)->value;
      struct value *res_val;
      scoped_value_mark free_values;

      if (op == UNOP_DYNAMIC_CAST)
	res_val = value_dynamic_cast (type, val);
      else if (op == UNOP_REINTERPRET_CAST)
	res_val = value_reinterpret_cast (type, val);
      else
	{
	  gdb_assert (op == UNOP_CAST);
	  res_val = value_cast (type, val);
	}

      result = value_to_value_object (res_val);
    }
  CATCH (except, RETURN_MASK_ALL)
    {
      GDB_PY_HANDLE_EXCEPTION (except);
    }
  END_CATCH

  return result;
}

/* Implementation of the "cast" method.  */

static PyObject *
valpy_cast (PyObject *self, PyObject *args)
{
  return valpy_do_cast (self, args, UNOP_CAST);
}

/* Implementation of the "dynamic_cast" method.  */

static PyObject *
valpy_dynamic_cast (PyObject *self, PyObject *args)
{
  return valpy_do_cast (self, args, UNOP_DYNAMIC_CAST);
}

/* Implementation of the "reinterpret_cast" method.  */

static PyObject *
valpy_reinterpret_cast (PyObject *self, PyObject *args)
{
  return valpy_do_cast (self, args, UNOP_REINTERPRET_CAST);
}

static Py_ssize_t
valpy_length (PyObject *self)
{
  /* We don't support getting the number of elements in a struct / class.  */
  PyErr_SetString (PyExc_NotImplementedError,
		   _("Invalid operation on gdb.Value."));
  return -1;
}

/* Return 1 if the gdb.Field object FIELD is present in the value V.
   Returns 0 otherwise.  If any Python error occurs, -1 is returned.  */

static int
value_has_field (struct value *v, PyObject *field)
{
  struct type *parent_type, *val_type;
  enum type_code type_code;
  gdbpy_ref<> type_object (PyObject_GetAttrString (field, "parent_type"));
  int has_field = 0;

  if (type_object == NULL)
    return -1;

  parent_type = type_object_to_type (type_object.get ());
  if (parent_type == NULL)
    {
      PyErr_SetString (PyExc_TypeError,
		       _("'parent_type' attribute of gdb.Field object is not a"
			 "gdb.Type object."));
      return -1;
    }

  TRY
    {
      val_type = value_type (v);
      val_type = check_typedef (val_type);
      if (TYPE_IS_REFERENCE (val_type) || TYPE_CODE (val_type) == TYPE_CODE_PTR)
      val_type = check_typedef (TYPE_TARGET_TYPE (val_type));

      type_code = TYPE_CODE (val_type);
      if ((type_code == TYPE_CODE_STRUCT || type_code == TYPE_CODE_UNION)
	  && types_equal (val_type, parent_type))
	has_field = 1;
      else
	has_field = 0;
    }
  CATCH (except, RETURN_MASK_ALL)
    {
      GDB_PY_SET_HANDLE_EXCEPTION (except);
    }
  END_CATCH

  return has_field;
}

/* Return the value of a flag FLAG_NAME in a gdb.Field object FIELD.
   Returns 1 if the flag value is true, 0 if it is false, and -1 if
   a Python error occurs.  */

static int
get_field_flag (PyObject *field, const char *flag_name)
{
  gdbpy_ref<> flag_object (PyObject_GetAttrString (field, flag_name));

  if (flag_object == NULL)
    return -1;

  return PyObject_IsTrue (flag_object.get ());
}

/* Return the "type" attribute of a gdb.Field object.
   Returns NULL on error, with a Python exception set.  */

static struct type *
get_field_type (PyObject *field)
{
  gdbpy_ref<> ftype_obj (PyObject_GetAttrString (field, "type"));
  struct type *ftype;

  if (ftype_obj == NULL)
    return NULL;
  ftype = type_object_to_type (ftype_obj.get ());
  if (ftype == NULL)
    PyErr_SetString (PyExc_TypeError,
		     _("'type' attribute of gdb.Field object is not a "
		       "gdb.Type object."));

  return ftype;
}

/* Given string name or a gdb.Field object corresponding to an element inside
   a structure, return its value object.  Returns NULL on error, with a python
   exception set.  */

static PyObject *
valpy_getitem (PyObject *self, PyObject *key)
{
  struct gdb_exception except = exception_none;
  value_object *self_value = (value_object *) self;
  gdb::unique_xmalloc_ptr<char> field;
  struct type *base_class_type = NULL, *field_type = NULL;
  long bitpos = -1;
  PyObject *result = NULL;

  if (gdbpy_is_string (key))
    {
      field = python_string_to_host_string (key);
      if (field == NULL)
	return NULL;
    }
  else if (gdbpy_is_field (key))
    {
      int is_base_class, valid_field;

      valid_field = value_has_field (self_value->value, key);
      if (valid_field < 0)
	return NULL;
      else if (valid_field == 0)
	{
	  PyErr_SetString (PyExc_TypeError,
			   _("Invalid lookup for a field not contained in "
			     "the value."));

	  return NULL;
	}

      is_base_class = get_field_flag (key, "is_base_class");
      if (is_base_class < 0)
	return NULL;
      else if (is_base_class > 0)
	{
	  base_class_type = get_field_type (key);
	  if (base_class_type == NULL)
	    return NULL;
	}
      else
	{
	  gdbpy_ref<> name_obj (PyObject_GetAttrString (key, "name"));

	  if (name_obj == NULL)
	    return NULL;

	  if (name_obj != Py_None)
	    {
	      field = python_string_to_host_string (name_obj.get ());
	      if (field == NULL)
		return NULL;
	    }
	  else
	    {
	      if (!PyObject_HasAttrString (key, "bitpos"))
		{
		  PyErr_SetString (PyExc_AttributeError,
				   _("gdb.Field object has no name and no "
                                     "'bitpos' attribute."));

		  return NULL;
		}
	      gdbpy_ref<> bitpos_obj (PyObject_GetAttrString (key, "bitpos"));
	      if (bitpos_obj == NULL)
		return NULL;
	      if (!gdb_py_int_as_long (bitpos_obj.get (), &bitpos))
		return NULL;

	      field_type = get_field_type (key);
	      if (field_type == NULL)
		return NULL;
	    }
	}
    }

  TRY
    {
      struct value *tmp = self_value->value;
      struct value *res_val = NULL;
      scoped_value_mark free_values;

      if (field)
	res_val = value_struct_elt (&tmp, NULL, field.get (), NULL,
				    "struct/class/union");
      else if (bitpos >= 0)
	res_val = value_struct_elt_bitpos (&tmp, bitpos, field_type,
					   "struct/class/union");
      else if (base_class_type != NULL)
	{
	  struct type *val_type;

	  val_type = check_typedef (value_type (tmp));
	  if (TYPE_CODE (val_type) == TYPE_CODE_PTR)
	    res_val = value_cast (lookup_pointer_type (base_class_type), tmp);
	  else if (TYPE_CODE (val_type) == TYPE_CODE_REF)
	    res_val = value_cast (lookup_lvalue_reference_type (base_class_type),
	                          tmp);
	  else if (TYPE_CODE (val_type) == TYPE_CODE_RVALUE_REF)
	    res_val = value_cast (lookup_rvalue_reference_type (base_class_type),
	                          tmp);
	  else
	    res_val = value_cast (base_class_type, tmp);
	}
      else
	{
	  /* Assume we are attempting an array access, and let the
	     value code throw an exception if the index has an invalid
	     type.  */
	  struct value *idx = convert_value_from_python (key);

	  if (idx != NULL)
	    {
	      /* Check the value's type is something that can be accessed via
		 a subscript.  */
	      struct type *type;

	      tmp = coerce_ref (tmp);
	      type = check_typedef (value_type (tmp));
	      if (TYPE_CODE (type) != TYPE_CODE_ARRAY
		  && TYPE_CODE (type) != TYPE_CODE_PTR)
		  error (_("Cannot subscript requested type."));
	      else
		res_val = value_subscript (tmp, value_as_long (idx));
	    }
	}

      if (res_val)
	result = value_to_value_object (res_val);
    }
  CATCH (ex, RETURN_MASK_ALL)
    {
      except = ex;
    }
  END_CATCH

  GDB_PY_HANDLE_EXCEPTION (except);

  return result;
}

static int
valpy_setitem (PyObject *self, PyObject *key, PyObject *value)
{
  PyErr_Format (PyExc_NotImplementedError,
		_("Setting of struct elements is not currently supported."));
  return -1;
}

/* Called by the Python interpreter to perform an inferior function
   call on the value.  Returns NULL on error, with a python exception set.  */
static PyObject *
valpy_call (PyObject *self, PyObject *args, PyObject *keywords)
{
  Py_ssize_t args_count;
  struct value *function = ((value_object *) self)->value;
  struct value **vargs = NULL;
  struct type *ftype = NULL;
  PyObject *result = NULL;

  TRY
    {
      ftype = check_typedef (value_type (function));
    }
  CATCH (except, RETURN_MASK_ALL)
    {
      GDB_PY_HANDLE_EXCEPTION (except);
    }
  END_CATCH

  if (TYPE_CODE (ftype) != TYPE_CODE_FUNC)
    {
      PyErr_SetString (PyExc_RuntimeError,
		       _("Value is not callable (not TYPE_CODE_FUNC)."));
      return NULL;
    }

  if (! PyTuple_Check (args))
    {
      PyErr_SetString (PyExc_TypeError,
		       _("Inferior arguments must be provided in a tuple."));
      return NULL;
    }

  args_count = PyTuple_Size (args);
  if (args_count > 0)
    {
      int i;

      vargs = XALLOCAVEC (struct value *, args_count);
      for (i = 0; i < args_count; i++)
	{
	  PyObject *item = PyTuple_GetItem (args, i);

	  if (item == NULL)
	    return NULL;

	  vargs[i] = convert_value_from_python (item);
	  if (vargs[i] == NULL)
	    return NULL;
	}
    }

  TRY
    {
      scoped_value_mark free_values;

      value *return_value
	= call_function_by_hand (function, NULL,
				 gdb::make_array_view (vargs, args_count));
      result = value_to_value_object (return_value);
    }
  CATCH (except, RETURN_MASK_ALL)
    {
      GDB_PY_HANDLE_EXCEPTION (except);
    }
  END_CATCH

  return result;
}

/* Called by the Python interpreter to obtain string representation
   of the object.  */
static PyObject *
valpy_str (PyObject *self)
{
  struct value_print_options opts;

  get_user_print_options (&opts);
  opts.deref_ref = 0;

  string_file stb;

  TRY
    {
      common_val_print (((value_object *) self)->value, &stb, 0,
			&opts, python_language);
    }
  CATCH (except, RETURN_MASK_ALL)
    {
      GDB_PY_HANDLE_EXCEPTION (except);
    }
  END_CATCH

  return PyUnicode_Decode (stb.c_str (), stb.size (), host_charset (), NULL);
}

/* Implements gdb.Value.is_optimized_out.  */
static PyObject *
valpy_get_is_optimized_out (PyObject *self, void *closure)
{
  struct value *value = ((value_object *) self)->value;
  int opt = 0;

  TRY
    {
      opt = value_optimized_out (value);
    }
  CATCH (except, RETURN_MASK_ALL)
    {
      GDB_PY_HANDLE_EXCEPTION (except);
    }
  END_CATCH

  if (opt)
    Py_RETURN_TRUE;

  Py_RETURN_FALSE;
}

/* Implements gdb.Value.is_lazy.  */
static PyObject *
valpy_get_is_lazy (PyObject *self, void *closure)
{
  struct value *value = ((value_object *) self)->value;
  int opt = 0;

  TRY
    {
      opt = value_lazy (value);
    }
  CATCH (except, RETURN_MASK_ALL)
    {
      GDB_PY_HANDLE_EXCEPTION (except);
    }
  END_CATCH

  if (opt)
    Py_RETURN_TRUE;

  Py_RETURN_FALSE;
}

/* Implements gdb.Value.fetch_lazy ().  */
static PyObject *
valpy_fetch_lazy (PyObject *self, PyObject *args)
{
  struct value *value = ((value_object *) self)->value;

  TRY
    {
      if (value_lazy (value))
	value_fetch_lazy (value);
    }
  CATCH (except, RETURN_MASK_ALL)
    {
      GDB_PY_HANDLE_EXCEPTION (except);
    }
  END_CATCH

  Py_RETURN_NONE;
}

/* Calculate and return the address of the PyObject as the value of
   the builtin __hash__ call.  */
static Py_hash_t
valpy_hash (PyObject *self)
{
  return (intptr_t) self;
}

enum valpy_opcode
{
  VALPY_ADD,
  VALPY_SUB,
  VALPY_MUL,
  VALPY_DIV,
  VALPY_REM,
  VALPY_POW,
  VALPY_LSH,
  VALPY_RSH,
  VALPY_BITAND,
  VALPY_BITOR,
  VALPY_BITXOR
};

/* If TYPE is a reference, return the target; otherwise return TYPE.  */
#define STRIP_REFERENCE(TYPE) \
  (TYPE_IS_REFERENCE (TYPE) ? (TYPE_TARGET_TYPE (TYPE)) : (TYPE))

/* Helper for valpy_binop.  Returns a value object which is the result
   of applying the operation specified by OPCODE to the given
   arguments.  Throws a GDB exception on error.  */

static PyObject *
valpy_binop_throw (enum valpy_opcode opcode, PyObject *self, PyObject *other)
{
  PyObject *result = NULL;

  struct value *arg1, *arg2;
  struct value *res_val = NULL;
  enum exp_opcode op = OP_NULL;
  int handled = 0;

  scoped_value_mark free_values;

  /* If the gdb.Value object is the second operand, then it will be
     passed to us as the OTHER argument, and SELF will be an entirely
     different kind of object, altogether.  Because of this, we can't
     assume self is a gdb.Value object and need to convert it from
     python as well.  */
  arg1 = convert_value_from_python (self);
  if (arg1 == NULL)
    return NULL;

  arg2 = convert_value_from_python (other);
  if (arg2 == NULL)
    return NULL;

  switch (opcode)
    {
    case VALPY_ADD:
      {
	struct type *ltype = value_type (arg1);
	struct type *rtype = value_type (arg2);

	ltype = check_typedef (ltype);
	ltype = STRIP_REFERENCE (ltype);
	rtype = check_typedef (rtype);
	rtype = STRIP_REFERENCE (rtype);

	handled = 1;
	if (TYPE_CODE (ltype) == TYPE_CODE_PTR
	    && is_integral_type (rtype))
	  res_val = value_ptradd (arg1, value_as_long (arg2));
	else if (TYPE_CODE (rtype) == TYPE_CODE_PTR
		 && is_integral_type (ltype))
	  res_val = value_ptradd (arg2, value_as_long (arg1));
	else
	  {
	    handled = 0;
	    op = BINOP_ADD;
	  }
      }
      break;
    case VALPY_SUB:
      {
	struct type *ltype = value_type (arg1);
	struct type *rtype = value_type (arg2);

	ltype = check_typedef (ltype);
	ltype = STRIP_REFERENCE (ltype);
	rtype = check_typedef (rtype);
	rtype = STRIP_REFERENCE (rtype);

	handled = 1;
	if (TYPE_CODE (ltype) == TYPE_CODE_PTR
	    && TYPE_CODE (rtype) == TYPE_CODE_PTR)
	  /* A ptrdiff_t for the target would be preferable here.  */
	  res_val = value_from_longest (builtin_type_pyint,
					value_ptrdiff (arg1, arg2));
	else if (TYPE_CODE (ltype) == TYPE_CODE_PTR
		 && is_integral_type (rtype))
	  res_val = value_ptradd (arg1, - value_as_long (arg2));
	else
	  {
	    handled = 0;
	    op = BINOP_SUB;
	  }
      }
      break;
    case VALPY_MUL:
      op = BINOP_MUL;
      break;
    case VALPY_DIV:
      op = BINOP_DIV;
      break;
    case VALPY_REM:
      op = BINOP_REM;
      break;
    case VALPY_POW:
      op = BINOP_EXP;
      break;
    case VALPY_LSH:
      op = BINOP_LSH;
      break;
    case VALPY_RSH:
      op = BINOP_RSH;
      break;
    case VALPY_BITAND:
      op = BINOP_BITWISE_AND;
      break;
    case VALPY_BITOR:
      op = BINOP_BITWISE_IOR;
      break;
    case VALPY_BITXOR:
      op = BINOP_BITWISE_XOR;
      break;
    }

  if (!handled)
    {
      if (binop_user_defined_p (op, arg1, arg2))
	res_val = value_x_binop (arg1, arg2, op, OP_NULL, EVAL_NORMAL);
      else
	res_val = value_binop (arg1, arg2, op);
    }

  if (res_val)
    result = value_to_value_object (res_val);

  return result;
}

/* Returns a value object which is the result of applying the operation
   specified by OPCODE to the given arguments.  Returns NULL on error, with
   a python exception set.  */
static PyObject *
valpy_binop (enum valpy_opcode opcode, PyObject *self, PyObject *other)
{
  PyObject *result = NULL;

  TRY
    {
      result = valpy_binop_throw (opcode, self, other);
    }
  CATCH (except, RETURN_MASK_ALL)
    {
      GDB_PY_HANDLE_EXCEPTION (except);
    }
  END_CATCH

  return result;
}

static PyObject *
valpy_add (PyObject *self, PyObject *other)
{
  return valpy_binop (VALPY_ADD, self, other);
}

static PyObject *
valpy_subtract (PyObject *self, PyObject *other)
{
  return valpy_binop (VALPY_SUB, self, other);
}

static PyObject *
valpy_multiply (PyObject *self, PyObject *other)
{
  return valpy_binop (VALPY_MUL, self, other);
}

static PyObject *
valpy_divide (PyObject *self, PyObject *other)
{
  return valpy_binop (VALPY_DIV, self, other);
}

static PyObject *
valpy_remainder (PyObject *self, PyObject *other)
{
  return valpy_binop (VALPY_REM, self, other);
}

static PyObject *
valpy_power (PyObject *self, PyObject *other, PyObject *unused)
{
  /* We don't support the ternary form of pow.  I don't know how to express
     that, so let's just throw NotImplementedError to at least do something
     about it.  */
  if (unused != Py_None)
    {
      PyErr_SetString (PyExc_NotImplementedError,
		       "Invalid operation on gdb.Value.");
      return NULL;
    }

  return valpy_binop (VALPY_POW, self, other);
}

static PyObject *
valpy_negative (PyObject *self)
{
  PyObject *result = NULL;

  TRY
    {
      /* Perhaps overkill, but consistency has some virtue.  */
      scoped_value_mark free_values;
      struct value *val;

      val = value_neg (((value_object *) self)->value);
      result = value_to_value_object (val);
    }
  CATCH (except, RETURN_MASK_ALL)
    {
      GDB_PY_HANDLE_EXCEPTION (except);
    }
  END_CATCH

  return result;
}

static PyObject *
valpy_positive (PyObject *self)
{
  return value_to_value_object (((value_object *) self)->value);
}

static PyObject *
valpy_absolute (PyObject *self)
{
  struct value *value = ((value_object *) self)->value;
  int isabs = 1;

  TRY
    {
      scoped_value_mark free_values;

      if (value_less (value, value_zero (value_type (value), not_lval)))
	isabs = 0;
    }
  CATCH (except, RETURN_MASK_ALL)
    {
      GDB_PY_HANDLE_EXCEPTION (except);
    }
  END_CATCH

  if (isabs)
    return valpy_positive (self);
  else
    return valpy_negative (self);
}

/* Implements boolean evaluation of gdb.Value.  */
static int
valpy_nonzero (PyObject *self)
{
  struct gdb_exception except = exception_none;
  value_object *self_value = (value_object *) self;
  struct type *type;
  int nonzero = 0; /* Appease GCC warning.  */

  TRY
    {
      type = check_typedef (value_type (self_value->value));

      if (is_integral_type (type) || TYPE_CODE (type) == TYPE_CODE_PTR)
	nonzero = !!value_as_long (self_value->value);
      else if (is_floating_value (self_value->value))
	nonzero = !target_float_is_zero (value_contents (self_value->value),
					 type);
      else
	/* All other values are True.  */
	nonzero = 1;
    }
  CATCH (ex, RETURN_MASK_ALL)
    {
      except = ex;
    }
  END_CATCH

  /* This is not documented in the Python documentation, but if this
     function fails, return -1 as slot_nb_nonzero does (the default
     Python nonzero function).  */
  GDB_PY_SET_HANDLE_EXCEPTION (except);

  return nonzero;
}

/* Implements ~ for value objects.  */
static PyObject *
valpy_invert (PyObject *self)
{
  struct value *val = NULL;

  TRY
    {
      val = value_complement (((value_object *) self)->value);
    }
  CATCH (except, RETURN_MASK_ALL)
    {
      GDB_PY_HANDLE_EXCEPTION (except);
    }
  END_CATCH

  return value_to_value_object (val);
}

/* Implements left shift for value objects.  */
static PyObject *
valpy_lsh (PyObject *self, PyObject *other)
{
  return valpy_binop (VALPY_LSH, self, other);
}

/* Implements right shift for value objects.  */
static PyObject *
valpy_rsh (PyObject *self, PyObject *other)
{
  return valpy_binop (VALPY_RSH, self, other);
}

/* Implements bitwise and for value objects.  */
static PyObject *
valpy_and (PyObject *self, PyObject *other)
{
  return valpy_binop (VALPY_BITAND, self, other);
}

/* Implements bitwise or for value objects.  */
static PyObject *
valpy_or (PyObject *self, PyObject *other)
{
  return valpy_binop (VALPY_BITOR, self, other);
}

/* Implements bitwise xor for value objects.  */
static PyObject *
valpy_xor (PyObject *self, PyObject *other)
{
  return valpy_binop (VALPY_BITXOR, self, other);
}

/* Helper for valpy_richcompare.  Implements comparison operations for
   value objects.  Returns true/false on success.  Returns -1 with a
   Python exception set if a Python error is detected.  Throws a GDB
   exception on other errors (memory error, etc.).  */

static int
valpy_richcompare_throw (PyObject *self, PyObject *other, int op)
{
  int result;
  struct value *value_other;
  struct value *value_self;

  scoped_value_mark free_values;

  value_other = convert_value_from_python (other);
  if (value_other == NULL)
    return -1;

  value_self = ((value_object *) self)->value;

  switch (op)
    {
    case Py_LT:
      result = value_less (value_self, value_other);
      break;
    case Py_LE:
      result = value_less (value_self, value_other)
	|| value_equal (value_self, value_other);
      break;
    case Py_EQ:
      result = value_equal (value_self, value_other);
      break;
    case Py_NE:
      result = !value_equal (value_self, value_other);
      break;
    case Py_GT:
      result = value_less (value_other, value_self);
      break;
    case Py_GE:
      result = (value_less (value_other, value_self)
		|| value_equal (value_self, value_other));
      break;
    default:
      /* Can't happen.  */
      PyErr_SetString (PyExc_NotImplementedError,
		       _("Invalid operation on gdb.Value."));
      result = -1;
      break;
    }

  return result;
}

/* Implements comparison operations for value objects.  Returns NULL on error,
   with a python exception set.  */
static PyObject *
valpy_richcompare (PyObject *self, PyObject *other, int op)
{
  int result = 0;

  if (other == Py_None)
    /* Comparing with None is special.  From what I can tell, in Python
       None is smaller than anything else.  */
    switch (op) {
      case Py_LT:
      case Py_LE:
      case Py_EQ:
	Py_RETURN_FALSE;
      case Py_NE:
      case Py_GT:
      case Py_GE:
	Py_RETURN_TRUE;
      default:
	/* Can't happen.  */
	PyErr_SetString (PyExc_NotImplementedError,
			 _("Invalid operation on gdb.Value."));
	return NULL;
    }

  TRY
    {
      result = valpy_richcompare_throw (self, other, op);
    }
  CATCH (except, RETURN_MASK_ALL)
    {
      GDB_PY_HANDLE_EXCEPTION (except);
    }
  END_CATCH

  /* In this case, the Python exception has already been set.  */
  if (result < 0)
    return NULL;

  if (result == 1)
    Py_RETURN_TRUE;

  Py_RETURN_FALSE;
}

#ifndef IS_PY3K
/* Implements conversion to int.  */
static PyObject *
valpy_int (PyObject *self)
{
  struct value *value = ((value_object *) self)->value;
  struct type *type = value_type (value);
  LONGEST l = 0;

  TRY
    {
      if (is_floating_value (value))
	{
	  type = builtin_type_pylong;
	  value = value_cast (type, value);
	}

      if (!is_integral_type (type)
	  && TYPE_CODE (type) != TYPE_CODE_PTR)
	error (_("Cannot convert value to int."));

      l = value_as_long (value);
    }
  CATCH (except, RETURN_MASK_ALL)
    {
      GDB_PY_HANDLE_EXCEPTION (except);
    }
  END_CATCH

  if (TYPE_UNSIGNED (type))
    return gdb_py_object_from_ulongest (l).release ();
  else
    return gdb_py_object_from_longest (l).release ();
}
#endif

/* Implements conversion to long.  */
static PyObject *
valpy_long (PyObject *self)
{
  struct value *value = ((value_object *) self)->value;
  struct type *type = value_type (value);
  LONGEST l = 0;

  TRY
    {
      if (is_floating_value (value))
	{
	  type = builtin_type_pylong;
	  value = value_cast (type, value);
	}

      type = check_typedef (type);

      if (!is_integral_type (type)
	  && TYPE_CODE (type) != TYPE_CODE_PTR)
	error (_("Cannot convert value to long."));

      l = value_as_long (value);
    }
  CATCH (except, RETURN_MASK_ALL)
    {
      GDB_PY_HANDLE_EXCEPTION (except);
    }
  END_CATCH

  if (TYPE_UNSIGNED (type))
    return gdb_py_long_from_ulongest (l);
  else
    return gdb_py_long_from_longest (l);
}

/* Implements conversion to float.  */
static PyObject *
valpy_float (PyObject *self)
{
  struct value *value = ((value_object *) self)->value;
  struct type *type = value_type (value);
  double d = 0;

  TRY
    {
      type = check_typedef (type);

      if (TYPE_CODE (type) == TYPE_CODE_FLT && is_floating_value (value))
	d = target_float_to_host_double (value_contents (value), type);
      else if (TYPE_CODE (type) == TYPE_CODE_INT)
	{
	  /* Note that valpy_long accepts TYPE_CODE_PTR and some
	     others here here -- but casting a pointer or bool to a
	     float seems wrong.  */
	  d = value_as_long (value);
	}
      else
	error (_("Cannot convert value to float."));
    }
  CATCH (except, RETURN_MASK_ALL)
    {
      GDB_PY_HANDLE_EXCEPTION (except);
    }
  END_CATCH

  return PyFloat_FromDouble (d);
}

/* Returns an object for a value which is released from the all_values chain,
   so its lifetime is not bound to the execution of a command.  */
PyObject *
value_to_value_object (struct value *val)
{
  value_object *val_obj;

  val_obj = PyObject_New (value_object, &value_object_type);
  if (val_obj != NULL)
    {
      val_obj->value = release_value (val).release ();
      val_obj->address = NULL;
      val_obj->type = NULL;
      val_obj->dynamic_type = NULL;
      note_value (val_obj);
    }

  return (PyObject *) val_obj;
}

/* Returns a borrowed reference to the struct value corresponding to
   the given value object.  */
struct value *
value_object_to_value (PyObject *self)
{
  value_object *real;

  if (! PyObject_TypeCheck (self, &value_object_type))
    return NULL;
  real = (value_object *) self;
  return real->value;
}

/* Try to convert a Python value to a gdb value.  If the value cannot
   be converted, set a Python exception and return NULL.  Returns a
   reference to a new value on the all_values chain.  */

struct value *
convert_value_from_python (PyObject *obj)
{
  struct value *value = NULL; /* -Wall */
  int cmp;

  gdb_assert (obj != NULL);

  TRY
    {
      if (PyBool_Check (obj))
	{
	  cmp = PyObject_IsTrue (obj);
	  if (cmp >= 0)
	    value = value_from_longest (builtin_type_pybool, cmp);
	}
      /* Make a long logic check first.  In Python 3.x, internally,
	 all integers are represented as longs.  In Python 2.x, there
	 is still a differentiation internally between a PyInt and a
	 PyLong.  Explicitly do this long check conversion first. In
	 GDB, for Python 3.x, we #ifdef PyInt = PyLong.  This check has
	 to be done first to ensure we do not lose information in the
	 conversion process.  */
      else if (PyLong_Check (obj))
	{
	  LONGEST l = PyLong_AsLongLong (obj);

	  if (PyErr_Occurred ())
	    {
	      /* If the error was an overflow, we can try converting to
	         ULONGEST instead.  */
	      if (PyErr_ExceptionMatches (PyExc_OverflowError))
		{
		  gdbpy_err_fetch fetched_error;
		  gdbpy_ref<> zero (PyInt_FromLong (0));

		  /* Check whether obj is positive.  */
		  if (PyObject_RichCompareBool (obj, zero.get (), Py_GT) > 0)
		    {
		      ULONGEST ul;

		      ul = PyLong_AsUnsignedLongLong (obj);
		      if (! PyErr_Occurred ())
			value = value_from_ulongest (builtin_type_upylong, ul);
		    }
		  else
		    {
		      /* There's nothing we can do.  */
		      fetched_error.restore ();
		    }
		}
	    }
	  else
	    value = value_from_longest (builtin_type_pylong, l);
	}
#if PY_MAJOR_VERSION == 2
      else if (PyInt_Check (obj))
	{
	  long l = PyInt_AsLong (obj);

	  if (! PyErr_Occurred ())
	    value = value_from_longest (builtin_type_pyint, l);
	}
#endif
      else if (PyFloat_Check (obj))
	{
	  double d = PyFloat_AsDouble (obj);

	  if (! PyErr_Occurred ())
	    {
	      value = allocate_value (builtin_type_pyfloat);
	      target_float_from_host_double (value_contents_raw (value),
					     value_type (value), d);
	    }
	}
      else if (gdbpy_is_string (obj))
	{
	  gdb::unique_xmalloc_ptr<char> s
	    = python_string_to_target_string (obj);
	  if (s != NULL)
	    value = value_cstring (s.get (), strlen (s.get ()),
				   builtin_type_pychar);
	}
      else if (PyObject_TypeCheck (obj, &value_object_type))
	value = value_copy (((value_object *) obj)->value);
      else if (gdbpy_is_lazy_string (obj))
	{
	  PyObject *result;

	  result = PyObject_CallMethodObjArgs (obj, gdbpy_value_cst,  NULL);
	  value = value_copy (((value_object *) result)->value);
	}
      else
#ifdef IS_PY3K
	PyErr_Format (PyExc_TypeError,
		      _("Could not convert Python object: %S."), obj);
#else
	PyErr_Format (PyExc_TypeError,
		      _("Could not convert Python object: %s."),
		      PyString_AsString (PyObject_Str (obj)));
#endif
    }
  CATCH (except, RETURN_MASK_ALL)
    {
      gdbpy_convert_exception (except);
      return NULL;
    }
  END_CATCH

  return value;
}

/* Returns value object in the ARGth position in GDB's history.  */
PyObject *
gdbpy_history (PyObject *self, PyObject *args)
{
  int i;
  struct value *res_val = NULL;	  /* Initialize to appease gcc warning.  */

  if (!PyArg_ParseTuple (args, "i", &i))
    return NULL;

  TRY
    {
      res_val = access_value_history (i);
    }
  CATCH (except, RETURN_MASK_ALL)
    {
      GDB_PY_HANDLE_EXCEPTION (except);
    }
  END_CATCH

  return value_to_value_object (res_val);
}

/* Return the value of a convenience variable.  */
PyObject *
gdbpy_convenience_variable (PyObject *self, PyObject *args)
{
  const char *varname;
  struct value *res_val = NULL;

  if (!PyArg_ParseTuple (args, "s", &varname))
    return NULL;

  TRY
    {
      struct internalvar *var = lookup_only_internalvar (varname);

      if (var != NULL)
	{
	  res_val = value_of_internalvar (python_gdbarch, var);
	  if (TYPE_CODE (value_type (res_val)) == TYPE_CODE_VOID)
	    res_val = NULL;
	}
    }
  CATCH (except, RETURN_MASK_ALL)
    {
      GDB_PY_HANDLE_EXCEPTION (except);
    }
  END_CATCH

  if (res_val == NULL)
    Py_RETURN_NONE;

  return value_to_value_object (res_val);
}

/* Set the value of a convenience variable.  */
PyObject *
gdbpy_set_convenience_variable (PyObject *self, PyObject *args)
{
  const char *varname;
  PyObject *value_obj;
  struct value *value = NULL;

  if (!PyArg_ParseTuple (args, "sO", &varname, &value_obj))
    return NULL;

  /* None means to clear the variable.  */
  if (value_obj != Py_None)
    {
      value = convert_value_from_python (value_obj);
      if (value == NULL)
	return NULL;
    }

  TRY
    {
      if (value == NULL)
	{
	  struct internalvar *var = lookup_only_internalvar (varname);

	  if (var != NULL)
	    clear_internalvar (var);
	}
      else
	{
	  struct internalvar *var = lookup_internalvar (varname);

	  set_internalvar (var, value);
	}
    }
  CATCH (except, RETURN_MASK_ALL)
    {
      GDB_PY_HANDLE_EXCEPTION (except);
    }
  END_CATCH

  Py_RETURN_NONE;
}

/* Returns 1 in OBJ is a gdb.Value object, 0 otherwise.  */

int
gdbpy_is_value_object (PyObject *obj)
{
  return PyObject_TypeCheck (obj, &value_object_type);
}

int
gdbpy_initialize_values (void)
{
  if (PyType_Ready (&value_object_type) < 0)
    return -1;

  return gdb_pymodule_addobject (gdb_module, "Value",
				 (PyObject *) &value_object_type);
}

static gdb_PyGetSetDef value_object_getset[] = {
  { "address", valpy_get_address, NULL, "The address of the value.",
    NULL },
  { "is_optimized_out", valpy_get_is_optimized_out, NULL,
    "Boolean telling whether the value is optimized "
    "out (i.e., not available).",
    NULL },
  { "type", valpy_get_type, NULL, "Type of the value.", NULL },
  { "dynamic_type", valpy_get_dynamic_type, NULL,
    "Dynamic type of the value.", NULL },
  { "is_lazy", valpy_get_is_lazy, NULL,
    "Boolean telling whether the value is lazy (not fetched yet\n\
from the inferior).  A lazy value is fetched when needed, or when\n\
the \"fetch_lazy()\" method is called.", NULL },
  {NULL}  /* Sentinel */
};

static PyMethodDef value_object_methods[] = {
  { "cast", valpy_cast, METH_VARARGS, "Cast the value to the supplied type." },
  { "dynamic_cast", valpy_dynamic_cast, METH_VARARGS,
    "dynamic_cast (gdb.Type) -> gdb.Value\n\
Cast the value to the supplied type, as if by the C++ dynamic_cast operator."
  },
  { "reinterpret_cast", valpy_reinterpret_cast, METH_VARARGS,
    "reinterpret_cast (gdb.Type) -> gdb.Value\n\
Cast the value to the supplied type, as if by the C++\n\
reinterpret_cast operator."
  },
  { "dereference", valpy_dereference, METH_NOARGS, "Dereferences the value." },
  { "referenced_value", valpy_referenced_value, METH_NOARGS,
    "Return the value referenced by a TYPE_CODE_REF or TYPE_CODE_PTR value." },
  { "reference_value", valpy_lvalue_reference_value, METH_NOARGS,
    "Return a value of type TYPE_CODE_REF referencing this value." },
  { "rvalue_reference_value", valpy_rvalue_reference_value, METH_NOARGS,
    "Return a value of type TYPE_CODE_RVALUE_REF referencing this value." },
  { "const_value", valpy_const_value, METH_NOARGS,
    "Return a 'const' qualied version of the same value." },
  { "lazy_string", (PyCFunction) valpy_lazy_string,
    METH_VARARGS | METH_KEYWORDS,
    "lazy_string ([encoding]  [, length]) -> lazy_string\n\
Return a lazy string representation of the value." },
  { "string", (PyCFunction) valpy_string, METH_VARARGS | METH_KEYWORDS,
    "string ([encoding] [, errors] [, length]) -> string\n\
Return Unicode string representation of the value." },
  { "fetch_lazy", valpy_fetch_lazy, METH_NOARGS,
    "Fetches the value from the inferior, if it was lazy." },
  {NULL}  /* Sentinel */
};

static PyNumberMethods value_object_as_number = {
  valpy_add,
  valpy_subtract,
  valpy_multiply,
#ifndef IS_PY3K
  valpy_divide,
#endif
  valpy_remainder,
  NULL,			      /* nb_divmod */
  valpy_power,		      /* nb_power */
  valpy_negative,	      /* nb_negative */
  valpy_positive,	      /* nb_positive */
  valpy_absolute,	      /* nb_absolute */
  valpy_nonzero,	      /* nb_nonzero */
  valpy_invert,		      /* nb_invert */
  valpy_lsh,		      /* nb_lshift */
  valpy_rsh,		      /* nb_rshift */
  valpy_and,		      /* nb_and */
  valpy_xor,		      /* nb_xor */
  valpy_or,		      /* nb_or */
#ifdef IS_PY3K
  valpy_long,		      /* nb_int */
  NULL,			      /* reserved */
#else
  NULL,			      /* nb_coerce */
  valpy_int,		      /* nb_int */
  valpy_long,		      /* nb_long */
#endif
  valpy_float,		      /* nb_float */
#ifndef IS_PY3K
  NULL,			      /* nb_oct */
  NULL,                       /* nb_hex */
#endif
  NULL,                       /* nb_inplace_add */
  NULL,                       /* nb_inplace_subtract */
  NULL,                       /* nb_inplace_multiply */
#ifndef IS_PY3K
  NULL,                       /* nb_inplace_divide */
#endif
  NULL,                       /* nb_inplace_remainder */
  NULL,                       /* nb_inplace_power */
  NULL,                       /* nb_inplace_lshift */
  NULL,                       /* nb_inplace_rshift */
  NULL,                       /* nb_inplace_and */
  NULL,                       /* nb_inplace_xor */
  NULL,                       /* nb_inplace_or */
  NULL,                       /* nb_floor_divide */
  valpy_divide,               /* nb_true_divide */
  NULL,			      /* nb_inplace_floor_divide */
  NULL,			      /* nb_inplace_true_divide */
#ifndef HAVE_LIBPYTHON2_4
  /* This was added in Python 2.5.  */
  valpy_long,		      /* nb_index */
#endif /* HAVE_LIBPYTHON2_4 */
};

static PyMappingMethods value_object_as_mapping = {
  valpy_length,
  valpy_getitem,
  valpy_setitem
};

PyTypeObject value_object_type = {
  PyVarObject_HEAD_INIT (NULL, 0)
  "gdb.Value",			  /*tp_name*/
  sizeof (value_object),	  /*tp_basicsize*/
  0,				  /*tp_itemsize*/
  valpy_dealloc,		  /*tp_dealloc*/
  0,				  /*tp_print*/
  0,				  /*tp_getattr*/
  0,				  /*tp_setattr*/
  0,				  /*tp_compare*/
  0,				  /*tp_repr*/
  &value_object_as_number,	  /*tp_as_number*/
  0,				  /*tp_as_sequence*/
  &value_object_as_mapping,	  /*tp_as_mapping*/
  valpy_hash,		          /*tp_hash*/
  valpy_call,	                  /*tp_call*/
  valpy_str,			  /*tp_str*/
  0,				  /*tp_getattro*/
  0,				  /*tp_setattro*/
  0,				  /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES
  | Py_TPFLAGS_BASETYPE,	  /*tp_flags*/
  "GDB value object",		  /* tp_doc */
  0,				  /* tp_traverse */
  0,				  /* tp_clear */
  valpy_richcompare,		  /* tp_richcompare */
  0,				  /* tp_weaklistoffset */
  0,				  /* tp_iter */
  0,				  /* tp_iternext */
  value_object_methods,		  /* tp_methods */
  0,				  /* tp_members */
  value_object_getset,		  /* tp_getset */
  0,				  /* tp_base */
  0,				  /* tp_dict */
  0,				  /* tp_descr_get */
  0,				  /* tp_descr_set */
  0,				  /* tp_dictoffset */
  0,				  /* tp_init */
  0,				  /* tp_alloc */
  valpy_new			  /* tp_new */
};

redpajama_set_name: RedPajamaGithub


Although Tomb Raider: Definitive Edition game will be released only in a week in Europe, but its developers can't wait so long to show us how their updated project will look like. And that's why today they have published Tomb Raider: Definitive Edition launch trailer.
Today we would also like to please the fans of popular Tomb Raider game series, presenting them a new fan-film based on this action-adventure. Thus, an interesting Tomb Raider fan-film, created by a group of cinematography's fans called CanCinema, has recently appeared in the network.


Choose your favorite shoes comment and add its code to your Myspace profile.
Dress-up your profile page all hours, everyday with these cool Friendster and MySpace Comments!
Many thousands to choose from in many different categories, including "Shoes Comments". Simply follow the links on the left side of every Groovy Machine page or beneath the last thumbnail on most pages to find just the right comment for you or a friend.


We asked you guys on facebook what your favorite dish to eat at Saltys, and you guys really seemed to have a few common favorites!
Home / blog / My favorite dish at Salty's Pub & Bistro in Clifton Park , NY is __________ (fill in the blank).
Clifton Park has expressed their feelings on our facebook page….
We LOVE when you express your love to us Clifton Park, NY!


We also carry a range of Super white globes from $45.00 a pair, and also replacement globes for cars including 300 ZX and Skylines. They are a much brighter and white in colour, similar to the Xenon lights that come standard on the late model R33 GTR and the R34's, instead of yellowish dull factory globes.
They are twice as bright whilst drawing the same power, and it is like driving in daylight.
Can use for high and low beam. A great extra for the performance driver.


The Talented Mr Fox is the brainchild of the highly acclaimed Matt Whiley, who is a mixologist and drinks consultant advising advises clients on every aspect of designing, running and managing a bar. He also creates his own spirits, cordials, syrups, bitters and cocktails.
Matt's achievements and reputation have led him to be named in The Evening Standard's 'The Progress 1000' which lists the top 1000 most influential Londoners. His groundbreaking work has impacted the cocktail industry globally, having co-founded Fluid Movement and five award winning bars across London (Purl, Worship Street Whistling Shop, Talented Mr Fox & Peg + Patriot) He is also the founder of boutique liquor brand Moonshine Kid and distils his own Dog's Nose Hop Gin. His new bar, Scout, opened in Shoreditch in April 2017.
Recently he created and coordinated a groundbreaking Line Up Bartender Edition cocktail-and-food matching event at The Typing Room in London's East End. Matt is a drinks consultant to, among others, Fera at Claridges, Restaurant Story, Hoppers, Shotgun BBQ, The Marksman, Yosma, Bone Daddies Group, Rök Smokehouse, Straight & Narrow and Bird of Smithfield. He has also done product development work for Highland Park Whisky, Facebook, ITV, Converse and British Airways.
The Peg + Patriot bar has been nominated as the most creative bar in the 2016 Time Out Bar Awards and was in Time Out's top 10 Bars in London in 2015.


text:
'use strict';

var dangerousStyleValue = require('./dangerousStyleValue');

if (__DEV__) {
  var hyphenateStyleName = require('fbjs/lib/hyphenateStyleName');

  var warnValidStyle = require('./warnValidStyle');
}

/**
 * Operations for dealing with CSS properties.
 */
var CSSPropertyOperations = {
  /**
   * This creates a string that is expected to be equivalent to the style
   * attribute generated by server-side rendering. It by-passes warnings and
   * security checks so it's not safe to use this value for anything other than
   * comparison. It is only used in DEV for SSR validation.
   */
  createDangerousStringForStyles: function(styles) {
    if (__DEV__) {
      var serialized = '';
      var delimiter = '';
      for (var styleName in styles) {
        if (!styles.hasOwnProperty(styleName)) {
          continue;
        }
        var styleValue = styles[styleName];
        if (styleValue != null) {
          var isCustomProperty = styleName.indexOf('--') === 0;
          serialized += delimiter + hyphenateStyleName(styleName) + ':';
          serialized += dangerousStyleValue(
            styleName,
            styleValue,
            isCustomProperty,
          );

          delimiter = ';';
        }
      }
      return serialized || null;
    }
  },

  /**
   * Sets the value for multiple styles on a node.  If a value is specified as
   * '' (empty string), the corresponding style property will be unset.
   *
   * @param {DOMElement} node
   * @param {object} styles
   */
  setValueForStyles: function(node, styles, getStack) {
    var style = node.style;
    for (var styleName in styles) {
      if (!styles.hasOwnProperty(styleName)) {
        continue;
      }
      var isCustomProperty = styleName.indexOf('--') === 0;
      if (__DEV__) {
        if (!isCustomProperty) {
          warnValidStyle(styleName, styles[styleName], getStack);
        }
      }
      var styleValue = dangerousStyleValue(
        styleName,
        styles[styleName],
        isCustomProperty,
      );
      if (styleName === 'float') {
        styleName = 'cssFloat';
      }
      if (isCustomProperty) {
        style.setProperty(styleName, styleValue);
      } else {
        style[styleName] = styleValue;
      }
    }
  },
};

module.exports = CSSPropertyOperations;


Are you one of those people that's addicted to checking their stats and follower count of their social media accounts on their phone every five minutes? I plead guilty! The Lametric Time device brings a more convenient way to continuously check up on your Instagram, Facebook or YouTube followers. It's a smart desktop clock display that hooks up to the internet to show a live counter of your fans and following from your favorite apps.
What is the Lametric Time?
Originally a smart clock display, this smart LED block connects to several of your favorite apps and social networks to display the single metric you care about. Next to setting it up with your YouTube, Instagram or Twitter follower count you can have the Lametric show incoming earnings on Paypal, a news feed of your choosing or any custom messages and LED icons you want to put up for display. The possibilities are near endless.
You'll just have to plug in the Lametric time, connect it to Wifi and use the associated app to set up the connections and messages. You'll never have to take out your phone again for checking the info that matters.
The Lametric Time also has some onboard speakers, to play notification sounds and radio. Yes, this device can still be a regular clock radio if you want to.
Where can I buy the Lametric Wifi Clock?
The Lametric smart LED clock is a great product for social media lovers and influencers, storefronts or small startup companies that want to visually celebrate success in the offices.
You can buy the product on https://lametric.com/ or Amazon via the link below.
Always get precise time and show your difference with thousands of clock faces. NOTE: Kindly refer the user manual before usage of the product.
The Lametric Wifi Smart clock is a very cleverly designed device, but it's not the only one of its kind out there. There are a couple of alternatives we found for you if you're keen on having a hardware social media counter.
The Smiirl is a more expensive social following counter, but it has a traditional split-flap mechanism instead of LED, which puts it +10 hipster over the Lametric. It will probably blend better in store interiors. You'll have to get one for each social network you want to connect to though.


text:
Colouring my left sleeve
Sometimes you can spend a few hours being tattooed and there doesn't seem much to show for it. Jo Harrison just worked on colouring in the heavily line piece and as she dotted around doing background work the changes superficially didn't seem very dramatic. Most of the work was on the back of my arm, which normally I can hardly see.
For some reason I struggled on this occasion. I had as usual used some numbing cream, but it didn't seem to have much effect. Normally I find it does. Anyhow, I survived the 3 and half hours session though felt rather sore, which is surprising given that the arm is one of the easiest areas to tattoo.
I live in Bristol and Jo's studio is in Birmingham, so I get the train which takes one and a half hours station to station, which means I have to go to the train toilet and start putting on the ointment and then the shrink wrap as I can't do this before I leave the house as it would be too early. I am not very good at it in these confined circumstances.
As things stand, my next appointment isn't until 3rd October, so there is an awfully long time for this work to heal.
Tight lacing - an extreme body modification
My mind is focussed on just one kind of extreme body modification - heavy tattooing. My body appearance has changed drastically in the past five years.
But what are other people's body modifications of choice? One is a practice known as "tight lacing", in which the users of corsets embark on reducing their waist sizes to as small at 17 or 18 inches, if they can.
It's not something that grabs me but Lacie here (www.staylace.com) has dedicated herself to the practice. There are others like her who take it very seriously. It's a fetish and not necessarily permanent. If you give up regularly wearing this special kind of corset then you will eventually revert to normal.
I have no plans to embark on this myself, but before I pass any judgement must reflect that what I am doing to myself is even more extreme. The images here are truly eye catching. I have never knowingly met anyone who is into tight lacing yet there is a big community out there who do it.
Maybe,…
Professional photos of my tattooed body - contains full frontal nudity
These photos were taken by Susanna Ahvalo from Finland and were shot in Vilnius. Susanna is a professional photographer and there is nothing pornographic about her work.
I am always happy to have some professional photos taken of my tattooed body. Had they been taken later this month you would have seen my left leg with its new tattoos. Ah well, I can't have everything.
Natasha Kai and sporting tattoos
There are all so many sports stars now with lots of ink. I sometimes wonder when they get it all done given their rigorous training schedules and the need to be at the peak of fitness. Natasha above has a great many tattoos for a young woman whose main engagement is being one of the very best footballers in the world. She was a member of the USA's world champion team.
Much more common are tattooed footballer players, best known being David Beckham but there are many others you see with full sleeves, for example.
When Djibril Cisse (above) moved to QPR a few weeks ago his tattoos were very much in evidence. These young men, with so much money to spare, spend a lot of cash on being highly fashionable. Some impressive work on show here.
More on the tattoo exhibition at the National Mari...

redpajama_set_name: RedPajamaCommonCrawl


text:
Quick links... News Weather Sports Community KATC Investigates About Elections Contests
Opelousas teen no longer staying with parents after found living in shed
The Department of Children and Family Services says the teen, who was found living out of a shed with no air condition, is no longer with his parents.
The new information comes a day after KATC asked for comments from the department on the status of the child's living arrangement. Wednesday, the Sheriff's Office told KATC that the teen was still living with his parents after the incident.
"When detectives arrived, we looked at the scene and we did call child protection," Eddie Thibodeaux with the Sheriff's Office said. "They also responded to the scene and looked at the area. They decided to let the child stay at the home."
DCFS says this is not the case.
According to a spokesperson for the Children and Family Services Department, the teen is now living with another relative.
The teen's parents were arrested after complaints that the child was living in a shed outside the home with no working air condition. Read more here
Download our new KATC apps


Whether you are dreaming of being SAs next Top Designer, simply looking for a new and exciting skill or design hobby, or want to enhance your existing sewing or design skills, look no further, �berGlam is ready to instruct you in the art of creating dazzling clothing and accessories.
We are based in Fairland, Gauteng and we offer full time and part time courses in fashion design. This includes sewing, patternmaking, accessories and fashion illustration. Our courses are flexible and specifically aimed at individuals who are eager to learn about fashion design and sewing without the stress of exams and overdue projects.
�berGlam offers a relaxed and friendly, yet professional atmosphere. Although we mainly offer adult courses and most of our students are in their 20s and 30s, we also have students in their teens and even in their 60s, and welcome anyone with a passion and desire to learn.
If youre a practicing designer or current design student, you can also benefit from our classes and courses as we offer a relaxed atmosphere where you can get practical assistance and ask questions, consult with peers, learn new skills and solve issues regarding client orders, design difficulties and design projects without any pressure.
We keep our weekly classes small and intimate and we work with each individual at their own level and pace to ensure maximum learning and personal attention. We welcome beginners, working professionals, homemakers, mothers, grandmothers, children, practicing designers, as well as part time and full time students. Our foreign students from various countries around the globe also bring an interesting mix to our classes.
To view a full list of all courses presented by Uber Glam click below.


text:
Home › News › People
Maybelline New York announces Jourdan Dunn as newest spokesmodel
NEW YORK, USA - Maybelline New York announced today that London bred beauty Jourdan Dunn is their newest spokesmodel. Jourdan will be joining an elite group of Maybelline models which includes Christy Turlington, Emily DiDonato and a host of others.
"Jourdan's look, style and positive energy are perfect for the Maybelline New York brand," said Jerome Bruhat, Global Brand President of Maybelline New York. "She truly reflects Maybelline's vision of global beauty." Jourdan was first discovered by a model scout while out with friends. She was signed soon after and made her runway debut during the 2007 Fall New York Fashion Week. As a featured model in British Vogue, labeled as a "new star" and named "Top 10 Newcomer" by style.com later that same year, Jourdan was on the road to success very early in her career. "It is an honor to be a spokesperson for such an iconic brand," said Jourdan. Jourdan has since lit up the runways for Prada, Christian Dior, Chanel, Alexander McQueen, Oscar de la Renta, Miu Miu, Balenciaga, Calvin Klein, Ralph Lauren, Louis Vuitton, Tom Ford, Marc Jacobs, Alexander Wang, Burberry, Lanvin, Hermes, Givenchy, Valentino, Jean-Paul Gaultier, and Balmain to name a few. She has appeared in the American, British, Paris, Italian, Japanese and Russian editions of Vogue. She has graced the pages of notable fashion magazines W, Numero, Allure, i-D, V, POP, and Dazed & Confused. She has been a part of various campaigns for ck Calvin Klein, CK1 fragrance, Yves Saint Laurent, Burberry, Burberry Beauty, Gap, DKNY, H&M, Express, Aldo, Banana Republic, Tommy Hilfiger, Rag & Bone, Topshop, John Galliano and Benetton among others.
Vivienne Foundation launches following Westwood's death
Italian actress Gina Lollobrigida dies at 95
WGSN and Stylus founder Marc Worth dies
Original supermodel Tatjana Patitz dies aged 56
Brunello Cucinelli issues epistle celebrating youth for the Epiphany
Vivienne Westwood remembered
Vivienne Westwood, Britain's provocative dame of fashion, dead at 81
Zendaya named the most fashionable celebrity of 2022


text:
Q: HTML 5 drop down menu Sorry I'm back again with another question.  I'm trying to convert my html page into html5 by removing some of the
 tags with
, , etc.  The drop down menu isn't working anymore - big gaps are appearing between the drop down bars.  Would someone mind having a look? Thanks in advance.

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Home Page</title>
<link rel="stylesheet" href="css.css"/>

    Home

    HTML5

            Tutorial 1

            Tutorial 2

            Tutorial 3

    CSS3

            Tutorial 1

            Tutorial 2

            Tutorial 3

    Links

    Contact

Home Page

This is a test paragraph. .

Home

HTML5

CSS3

Links

Contact

Copyright blach blach blach!

and the CSS is:
@charset "utf-8";
/* CSS Document */
#container{
    width:800px;
    background-color:#00FF00;
    border:1px solid black;
    height:1000px;
    z-index:-9;
    margin:auto;
}

#logo{

    background-color:#FF0033;
    border:#000 1px;
    width:800px;
    height:200px;
    overflow:hidden;

}

nav {

    background-color:#FFF;
    border:#000 1px;
    width:800px;
    height:30px;

}

section{

    background-color:#6F3;
    border:#000 1px;
    width:780px;
    height:400px;
    margin:10px;
}

footer{

    background-color:#FF0;
    border:#000 1px;
    width:800px;
    height:100px;
}

.navbar {
/*border-right: 1px solid #54879D;*/
  height: 40px;
margin:    0 0 0 0;
padding: 0;

}

.navbar li {
background-color: #366B82;
float: left;
font: bold 12px/1.2em Arial,Verdana,Helvetica;
height: auto;
list-style: none outside none;
margin: 20 0;
padding: 0;
text-align: center;
width: 160px;
}

.navbar a {
/*  border-left: 1px solid #54879D;*/
border-right: 1px solid #1F5065;
color: #FFFFFF;
display: block;
padding: 10px 10px;
text-decoration: none;
}

.navbar li:hover, a:hover {
background-color: #54879D;
}

.navbar li ul {
display: none;
height: auto;
margin: 0;
padding: 0;
position:absolute;
}

.navbar li:hover ul {
display: block;
}

.navbar li ul li {
background-color: #54879D;
float:none;
}

.navbar li ul li a {
border-color: #74A3B7 #1F5065 #1F5065;
border-left: 1px solid #1F5065;
border-right: 1px solid #1F5065;
border-style: solid;
border-width: 1px;

}
.navbar li ul li a:hover {
background-color: #366B82;
}

.lowernav{
height: 20px;
border: 1px solid black;
padding: 0;
width: 350px;
margin: auto;
}

.lowernav li {
float: left;
list-style: none;
margin: 0 0;
padding: 0;
width:20%;

}

.lowernav a {
border-right:1px solid #ffffff;
padding: 0 10px;
text-decoration: none;
display: block;
text-align: center;

}

.lowernav a:hover {
color: red;
background-color:transparent;

}

#copyright{
text-align:center;
}

A: Like this
demo
css
@charset "utf-8";
@charset "utf-8";
/* CSS Document */
* {
    margin: 0;
    padding: 0;
}
html, body {
    margin: 0;
    padding: 0;
}
#container {
    width: 800px;
    background-color: #00FF00;
    border: 1px solid black;
    z-index: -9;
    margin: auto;
}
#logo {
    background-color: #FF0033;
    border: #000 1px;
    width: 800px;
    height: 200px;
    overflow: hidden;
}
nav {
    background-color: #FFF;
    border: #000 1px;
    width: 800px;
    height: 30px;
}
section {
    background-color: #6F3;
    border: #000 1px;
    width: 780px;
    height: 400px;
    margin: 10px;
}
footer {
    background-color: #FF0;
    border: #000 1px;
    width: 800px;
    height: 100px;
}
.navbar {
    /*border-right: 1px solid #54879D;*/
    height: 40px;
    margin: 0 0 0 0;
    padding: 0;
}
.navbar ul {
    margin: 0;
    padding: 0;
}
.navbar li {
    background-color: #366B82;
    float: left;
    font: bold 12px/1.2em Arial, Verdana, Helvetica;
    height: auto;
    list-style: none outside none;
    margin: 20 0;
    padding: 0;
    text-align: center;
    width: 160px;
}
.navbar a {
    /*  border-left: 1px solid #54879D;*/
    border-right: 1px solid #1F5065;
    color: #FFFFFF;
    display: block;
    padding: 10px 10px;
    text-decoration: none;
}
.navbar li:hover, a:hover {
    background-color: #54879D;
}
.navbar li ul {
    display: none;
    height: auto;
    margin: 0;
    padding: 0;
    position: absolute;
}
.navbar li:hover ul {
    display: block;
}
.navbar li ul li {
    background-color: #54879D;
    float: none;
}
.navbar li ul li a {
    border-color: #74A3B7 #1F5065 #1F5065;
    border-left: 1px solid #1F5065;
    border-right: 1px solid #1F5065;
    border-style: solid;
    border-width: 1px;
}
.navbar li ul li a:hover {
    background-color: #366B82;
}
.lowernav {
    height: 20px;
    border: 1px solid black;
    padding: 0;
    width: 350px;
    margin: auto;
}
.lowernav li {
    float: left;
    list-style: none;
    margin: 0 0;
    padding: 0;
    width: 20%;
}
.lowernav a {
    border-right: 1px solid #ffffff;
    padding: 0 10px;
    text-decoration: none;
    display: block;
    text-align: center;
}
.lowernav a:hover {
    color: red;
    background-color: transparent;
}
#copyright {
    text-align: center;
}
footer p {
    margin: 0;
    padding: 0;
}/* CSS Document */

A: Remove the line
margin: 20 0;

from
.navbar li

redpajama_set_name: RedPajamaStackExchange


text:
On 1813 December 17 (Born)
On 1878 August 8 (Died)
John was from Wales, a son of William and Elizabeth Thomas Harris. He crossed the Atlantic on the ship Ellen Maria in 1851. On the ship manifest his occupation is given as "miner." In his autobiography he says that he crossed the plains in the Jesse Crosby Company; Crosby was president of the Atkins Company of 1853. John was re-baptized at Salt Lake City on 17 September 1853 and received a Patriarchal Blessing on 11 November this same year. He labored on Public Works off and on in 1853, 1854, 1855. He was a member of the 37th Quorum of Seventy of which Jesse W. Crosby was a president. At the time of the 1856 Utah Territorial census he was living in Cedar City.
Traveled in William Atkinson Company
1853 May 18 – September 10 (Age 39) Pioneers in Company
On 1853 May 18
1878 August 8 (Age 64)
John Harris (1813 - 1878) Profile
1856 Utah census, Iron County
1856 Utah census, Iron County.
Saints By Sea - BYU
"John Harris. ID: 41078", Saints By Sea - BYU.
Utah, FamilySearch, Early Church Information File, 1830-1900
Utah, FamilySearch, Early Church Information File, 1830-1900.
Jesse W. Crosby Company report
Jesse W. Crosby Company report, August.
"Report of the 37th Quorum," Journal History
"Report of the 37th Quorum," Journal History, 12 January 1854.


text:
The LSS has seven executive members elected by the student body yearly in the Winter term, each overseeing a distinct portfolio. Read more about your team below, and do not hesitate to reach out with any questions or comments.
President - Ellen Williams
Ellen is a true maritimer, a crazy cat lady and devoted coffee drinker.
Before attending law school, Ellen worked at the Saskatchewan Legislature as a senior staffer for the Attorney General and Minister of Justice. She sat on numerous non-profit boards including the Canadian Red Cross Emergency Response Team, Regina Cat Rescue, YWCA Women of Distinction, Canadian Diabetes Association and Regina Symphony Orchestra. She also spent a year as a linebacker in the WWCFL with the Regina Riot.
Ellen is a proud alumnus of Mount Allison University where she completed her Bachelor of Arts with a major in Political Science, and the University of Saskatchewan where she completed a Master of Arts in Political Science.
Ellen became involved with the LSS in her first year, when she was appointed Chair of the Board of Directors. As President, Ellen's focus is student first scheduling. It's important that Weldonites can balance academics while having the opportunity to take part in pro bono opportunities! As the first 1L elected President in modern history, Ellen looks forward to representing the needs of students.
Email Ellen
Vice President Executive - Daniel Roth
Daniel comes to the east coast from Edmonton, AB, and is excited to now call Halifax home long-term! Daniel graduated from the University of Alberta School of Business with a Bachelor of Commerce and a Certificate in Business Leadership. During that time, he went on exchange to the UK, did a study tour to China, and interned on the board of the Edmonton Symphony Orchestra and Francis Winspear Centre for Music. Daniel also served as an executive member of his undergraduate faculty association and debated competitively. Daniel worked in project management on the business services side of a global law firm prior to starting law school.
As VP Executive, Daniel is responsible for ensuring good governance on the LSS, and for overseeing day-to-day Society operations. Returning for a second year as VP Executive, Daniel is excited to work with both the new and returning members of the LSS executive team to continue bettering student life at Schulich. If you have questions about lockers, the LSS Constitution or anything else Society-related, feel free to reach out. If you have any suggestions for improvements to how the LSS provides services, or which services it provides, Daniel is always happy to hear from you!
Email Daniel
Vice President Academic - Nicole Kelly
Nicole was born and raised in London, Ontario and has an undergraduate and Master's degree in Molecular Biology and Genetics from the University of Guelph. She spent the last year travelling around Southeast Asia and the US and looks forward to continuing her travels in Nova Scotia!
In 2018-2019, Nicole was the 1L Executive Member for the LSS, and the 1L Representative on the Board of Directors for Section A.
Email Nicole
Vice President Finance - Nick Foran
Nick was born and raised in Halifax, NS. He is an alumnus of Dalhousie University, where he received a Bachelor of Arts in German and Italian Studies. Following his convocation in 2012, he attended Saint Mary's University for a year to study linguistics. He was sworn into the Canadian Armed Forces in 2010, and received his commission in 2011. He worked with the CAF and the Department of National Defence prior to beginning studies at the Schulich School of Law. He continues to serve as a member of the Reserve Force. Nick is an amateur photographer, and enjoys reading and video games. He currently lives in Bedford with his wife, Kelsey.
The VP Finance is responsible for managing the budget of the Society. They maintain the general ledger and other financial documents, and prepare audits for the DSU. Nick had some experience in finance prior to entering law school, and wanted to put his skills to use to better serve the Weldon community. He likes to work behind the scenes to enable events to occur.
Vice President External - Meghan Faught
Meghan was born and raised in Ontario in small towns ranging from Thunder Bay to Tara. She completed her undergraduate degree at the University of Waterloo with a Bachelor of Arts and Business, majoring in history. After graduating, she felt the call of the ocean and moved to Tofino, BC where she spent 8 blissful months surfing, running in the rainforest, and eating her weight in tacos. Academia called her out to the East Coast where she completed her Master's in Environmental Policy at Memorial University, where she focused her research on global eco-certification schemes. The love of learning, challenging herself, and helping others brought her to law school, and into the role of VP External.
The VP External is responsible for representing the interests of the Law Student Society and its members to external organizations, and keeps law students informed about external events. VP External also serves as the Society representative to the Dalhousie Student Union, organizes the annual Library Food Drive, and sits on the Dalhousie Law Alumni Association Board of Directors.
Email Meghan
Vice President Student Life - Cydney Kane
Cydney is a life-long Halifax resident and an alumna of Mount Allison University, where she graduated with a Bachelor of Science, but spent most of her time doing extra-curriculars. Her professional experience includes work in both the public and private sectors, primarily in documentation, software testing, communications and project work. On weekends, she teaches dance to children.
In her time at Schulich, she has represented students on the faculty's Appointments Committee, worked with Pro Bono, and volunteered with several student societies, conferences, and events. She volunteers with the Record Suspension & Vital Statistics Clinic hosted by the Elizabeth Fry Society of Mainland Nova Scotia, and leads a fundraising project to sponsor criminal record suspension application fees for marginalized women. To date, this project has raised more than $4200.
Cydney's portfolio as VP Student Life includes overseeing Schulich's many student societies, handling communications and social media, and planning events for students.
Email Cydney
1L Executive Member
Alyssa grew up just outside of Ottawa, Ontario. She studied at Carleton University, graduating with a double major in Law and English. She has tried her hand at theater, improv, the trombone, basketball, volleyball, and hockey. During her time in Halifax, she hopes to balance tourism with law studies.
Alyssa is also the Board of Directors representative for Section A.
Email 1L Exec


Information about s.c. Cookies .
Here on Coolsnille.SE we have built a s.c. Cookie.
This one is right now under construction so it can later on remember what language you've chosen.
A cookie is a text file that's stored on your computer to remember info etc.
In Windows XP you'll find all cookies under C:\Documents and Settings\Your_Username\Cookies.
If you do not accept cookies you can block them in your web explorers settings.
NOTE! If you block cookies it'll affect more sites than just Coolsnille.SE, pages like communities, forums etc. Will not work properly.
After 2003-06-12 it's not allowed to have a cookie without informing the visitors.
Swedish Law (2003:389) about electronic communication.


text:
Home » About » Structure and Organisation
The Permanent Organs of the Association of Caribbean States are:
The Ministerial Council, and
The Secretariat.
The Ministerial Council
The Ministerial Council is made up of the Ministers and/or representatives of the Member States, and is the main organ for policy-making and direction of the Association. The Ministerial Council oversees the functioning of the Association and the Secretariat and holds its Ordinary Meeting during the last two weeks of January of every year.
The Executive Board
The Executive Board of the Ministerial Council consists of a Chairman, two Vice Chairman and a Rapporteur, who are appointed during the meeting of the Ministerial Council and perform their functions until the end of the next meeting of the Council. This appointment is carried out on the basis of geographic and linguistic rotation among the groups that make up the Association, with each of the groups deciding internally the country that will fill that post.
The Executive Board provides guidance and ensures follow-up of and coordination in the implementation of the Association's Work Programme. The Executive Board meets on a biannual basis in the periods between the Intersessional Meetings and the Ordinary Meetings of the Ministerial Council.
The Intersessional Meeting
In an effort to maintain communication and coordination between Member States and the Secretariat, the Association also convenes an annual Intersessional Meeting, which is chaired by the representatives of the countries on the Executive Board of the Ministerial Council, and is open to participation by all Members.
This Intersessional Meeting is held at least six months after the Ordinary Meeting of the Ministerial Council and among its numerous tasks, reviews the progress made in the Association's Work Programme; assesses the work of the Special Committees; and evaluates the operations of the Secretariat.
The Special Committees
The Ministerial Council has established the following Special Committees, to assist in the implementation of its objectives:
The Special Committee on Trade Development and External Economic Relations;
The Special Committee on Transport;
The Special Committee on Sustainable Tourism;
The Special Committee on Disaster Risk Reduction;
The Special Committee on Budget and Administration
The ACS Secretariat, headquartered in Port of Spain, Trinidad and Tobago, is supported by 32 full time members of staff, most of whom are bilingual, or trilingual.
Since the official languages of the Association are English, French and Spanish, all documents are prepared and distributed in the three official languages and interpretation is provided at all meetings of the organisation.
Led by the Secretary General, the Secretariat, assists the Ministerial Council and Special Committees in the development and implementation of their policies and programmes. In order to fulfil this role, it is called upon to:
Maintain political relations with members and maintain contact with other sub-regional, regional and international organisations;
Mobilise funds for projects;
Service the meetings of the Ministerial Council and the Special Committees and take appropriate action issues arising at those meetings;
Disseminate information to Member States, Associate Members and to other relevant entities; and
Manage the finances and ensure the smooth running of the Association.


text:
Category Archives: DRM
The DRM Handbook Revision 4
Many thanks to SWLing Post contributor, Ed, who notes that the latest version of the DRM Handbook is available for download.
Click here to download the DRM Handbook Rev 4 (PDF).
This entry was posted in Digital Modes, DRM, News and tagged Digital Radio Mondiale, DRM on March 21, 2019 by Thomas.
Chairman of DRM Consortium looks at the current state of shortwave
(Source: Radio World via Maichael Black)
Note that the excerpt below is only a portion of the full article. Read the full piece at Radio World.
Does Shortwave Have a Future?
by RUXANDRA OBREJA
When is the last time you heard a shortwave radio transmission? And why should you put up with possible crackly audio and some interference when we have now internet, satellites, FM and all forms of digital radio?
[…]Shortwave is just short of a miracle, actually. When it is beamed at an angle, it hits the ionosphere. A mirror around the Earth and then it falls like a ball at great distances, beyond the horizon. Thus these transmissions reach listeners over large areas, continents and beyond. Two or three high-power transmitters can potentially cover the entire world.
Shortwave is used not just by international radio stations or radio amateurs but is also essential for aviation, marine, diplomatic and emergency purposes. Shortwave signals are not restricted or controlled by the receiving countries and, as frequencies change in winter and summer, they need to be coordinated internationally.
[…]Digital Radio Mondiale was originally invented to offer medium (AM) and large coverage (HF) and the advantages of the good audio quality and extra multimedia services that can take shortwave into the 21st century. Maybe DRM was ahead of its time. The phasing in of digital broadcasts internationally was not in tandem with the production and sale of receivers, which remains a regional and national business. Since its birth DRM has proven that it is a suitable option for shortwave offering an good digital quality of audio and even short live video at great distance without fading and crackly sound.
Now, at last, there are DRM receivers capable of receiving shortwave, there are broadcasts and interested broadcasters. Quietly and surely shortwave is being re-examined and appreciated for the quality of broadcasts and its potential as a "crisis radio" too. It can become crucial in emergencies when local and regional radio stations, satellite and internet may be off the air due to damage. Broadband is getting cheaper but is limited, 5G will come but not just yet, digital shortwave is here.[…]
Click here to read the full article at Radio World.
This entry was posted in Digital Modes, DRM, News and tagged Digital Radio Mondiale, DRM, DRM Consortium, Michael Black, Radio World, Ruxandra Obreja, shortwave on February 23, 2019 by Thomas.
Radio World: "China Makes Its DRM Move"
Screen Shot from a China National Radio DRM test (Source: DRM.org)
(Source: Radio World via Michael Bird)
The nation becomes world's leading Digital Radio Mondiale shortwave broadcaster in just one year
Hans Johnson
BEIJING — It appears as if China has jumped into Digital Radio Mondiale shortwave broadcasting with both feet. Some DRM infrastructure has been in place for over a decade, but up until recently had only been sporadically tested.
Just over a year ago, China had no regular DRM presence. Today, it is the world's largest DRM shortwave broadcaster. China operates the most DRM transmitters in this band and has the most extensive schedule.
The initial broadcasts started in early 2018 from Beijing. Services continued to rollout over the year via various transmitter sites, often on the country's periphery.
A DRM shortwave transmitter in Beijing targets north China almost 24 hours a day. A second Beijing transmitter targets east China for eight hours a day.
Another transmitter in Ürümqi in the country's west targets central and east China for 14 hours a day, while a transmitter in Qiqihar, Heilongjiang province (the Manchurian plain), is on more than 11 hours a day and reaches south and southwest China. Dongfang on Hainan Island province is on eight hours a day on two frequencies for both north and southeast China. Finally, the DRM shortwave transmitter located in Kunming in the Yunnan province is on eight hours daily for south China. There is now a DRM network providing nationwide coverage.
By comparison All India Radio has 11.5 hours a day of shortwave time coming from a single transmitter. The Indian broadcaster has as many as three more DRM-capable shortwave transmitters but they are not on air at present. India does operate 38 AM (medium wave) transmitters for its domestic network, however.[…]
Click here to continue reading the full article at Radio World.
This entry was posted in Broadcasters, Digital Modes, DRM, News and tagged China National Radio, CNR, Digital Radio Mondiale, DRM, Michael Bird, Radio World Magazine on February 12, 2019 by Thomas.
India, DRM, and FM white spaces
(Source: Broadcast and Cable Sat)
Digital Radio Receivers – Availability At An Affordable Price
by Yogender Pal (Chairman, DRM India Chapter)
[…]Transmissions in FM band in India, by AIR as well as private broadcasters, are still in analogue mode only. Aware of the advantages of digital radio broadcasting, the Telecom Regulatory Authority of India, the regulator for all the broadcast services too, has recommended to allow private broadcasters to broadcast in the digital white spaces available in the FM band (VHF band II). This recommendation is under consideration of the Ministry of Information and Broadcasting. The Ministry held a meeting on the issue on August 30, 2018. All stakeholders (public and private) were in favor of digital broadcasting in FM band and suggested that the ministry makes public a regulatory policy as soon as possible. Cellphone manufacturers also gave their support provided no additional costs were involved.
A digital receiver is required to receive digital radio broadcasts as analogue receivers cannot decode the digital signals.
One of the welcome features of the current roll-out of DRM digital radio in India has been the early and overwhelming commitment of the car industry. Most of the leading car manufacturers in India have either already incorporated DRM receivers in their cars or are in the process of incorporating them. Hyundai has built-in DRM radios in all its models except one. Maruti Suzuki has also incorporated DRM receivers in 6 models and all their models are soon expected to have built-in DRM receivers. Mahindra has also installed DRM in its TUV model. It is encouraging that the roll-out of DRM equipped cars is growing rapidly. At present the number is understood to have surpassed the 10 lakh mark. Indian car manufacturers are not charging extra from consumers for line-fit DRM radio sets.
In parallel, efforts are being made by a large number of Indian and foreign receiver manufacturers to provide standalone DRM receivers. Communications Systems is the first Indian radio manufacturer to domestically develop and produce a DRM receiver (AV-1401). Inntot Technologies, a young start-up enterprise, has developed a software-based DRM receiver based on a generic processor. This is likely to be much cheaper. GeekSynergy, another start-up company, is also working on the development of a highly affordable DRM receiver.
Gospell Digital Technology located in China has presented a very well-reviewed DRM Receiver, GR216, which is already in production. Gospell is developing a DRM receiver dongle, GR-227 too, which can be plugged in the existing audio systems in the automobiles on USB ports or Aux input to receive DRM digital signals. Titus SDR, a Panamanian based company, has developed a multi-standard and software-based digital radio receiver. Starwaves has also developed a prototype DRM receiver.
Standalone DRM digital efforts remain relatively expensive at present. Like with any new technology higher volumes will bring down the cost of the receivers. AIR may thus offer content with additional audio services, innovative advanced features such as journaline advanced text, emergency warnings, and traffic information so that listeners see value in buying a digital receiver.
An app for DRM digital reception in mobile phones in FM band has been already developed. Demonstrations have been made on the reception of DRM digital signals in the existing mobile phones by plugging a dongle. External dongle would not be required in the new mobile phones; however, the industry wants to see the publicized policy of the government before making the necessary adjustments for working of the app.
Most of the standalone receivers can receive DRM (in addition to analogue) in AM bands; and its software can also be upgraded to receive DRM in FM band. As announced by Director General recently, AIR may start digital radio broadcasting in FM band. Government may also accept TRAI recommendations and announce a roadmap for digital radio broadcasting in FM band by private broadcasters so that the industry (cellphones, automobile, and standalone receiver manufacturers) gets confidence and starts mass production of receivers.[…]
Read the full article at Broadcast and Cable Sat online.
Many thanks to Ed for the tip!
This entry was posted in Digital Modes, DRM, Mediumwave, News, Shortwave Radio and tagged AIR, All India Radio, All India Radio DRM, Digital Radio Mondiale, DRM on January 20, 2019 by Thomas.
A new portable DRM/DAB receiver by Starwaves GmbH
Many thanks to SWLing Post contributor, Mangosman, who notes:
There is a new digital receiver available. It can receive DRM in all bands from low, medium, high and band 1 & 2 VHF, as well as DAB+ and analog AM and FM.
It cannot receive HD radio because Xpedia charge licensing fees on every receiver and the market is restricted to USA and Mexico.
https://www.alibaba.com/product-detail/DRM-DAB-Digital-Radio-Receiver_11547499.html
Thank you for the tip! It appears this receiver is a product of STARWAVES GmbH, Germany/Switzerland, although I assume it's manufactured in China based on the bulk order costs.
I've reached out to the manufacturer for more details as there are few specifics and no specifications on the Alibaba page.
There are also no details about this radio on the Starwaves website.
If/when we receive more information about this radio, we'll share it here on the SWLing Post. Stay tuned!
Do you enjoy the SWLing Post?
Please consider supporting us via Patreon or our Coffee Fund!
Your support makes articles like this one possible. Thank you!
This entry was posted in Digital Modes, DRM, New Products, News, Portable Radio, Shortwave Radio, Software Defined Radio and tagged DAB+, Digital Radio Mondiale, DRM, DRM receiver, Mangosman, shortwave, Starwaves, Starwaves GmbH on January 19, 2019 by Thomas.


text:
Q: Destructuring when have duplicate keywords Destructuring maps, for example with {:keys [x y]} m, cannot be done in function paramters when there are going to be many maps (say m0, m1) of the same type. Here doing so would result in x and y being shadowed. So instead this is what I am doing for the point type:
(defn intersection [point0
                    point1]
  (let [x0 (:x point0)
        y0 (:y point0)
        x1 (:x point1)
        y1 (:y point1)]))

What is a cleaner (more idiomatic) way of achieving the above? I want a point to always have the keys :x and :y, rather than resorting to the first point having keys :x0 and :y0, and the second having :x1 and :y1.
same type = "consistent names in the input maps"

A: If I assume you are asking to have consistent names in the input maps, so every points has the keys :x and :y: then you can use the other syntax for map destructuring:
{name key-to-use ...}

the :keys form is a shortcut for this form.
If the points are passed as their own arguments:
user> (def p1 {:x 0  :y 1})
#'user/p1
user> (def p2 {:x -3  :y -8})
#'user/p2

user> (defn example [{x0 :x y0 :y} {x1 :x y1 :y}]
        [x0 x1 y0 y1])
#'user/example
user> (example p1 p2)
[0 -3 1 -8]

If you are passing a list of points then you can nest map and list destructuring
user> (defn example [[{x0 :x y0 :y} {x1 :x y1 :y}]]
        [x0 x1 y0 y1])
#'user/example
user> (example [p1 p2])
[0 -3 1 -8]

A: You can choose which names is bound to a key:
(let [{x1 :x y1 :y} m1
      {x2 :x y2 :y} m2]
  (foo x1 y1 x2 y2))

See also the following example from Destructuring in Clojure:
(def my-map {:a "A" :b "B" :c 3 :d 4})
(let [{a :a, x :x, :or {x "Not found!"}, :as all} my-map]
  (println "I got" a "from" all)
  (println "Where is x?" x))
;= I got A from {:a "A" :b "B" :c 3 :d 4}
;= Where is x? Not found!


94-96 points Robert Parker: "The 2002 Shiraz Reiver is aged in 100% French oak, of which 70% is new. Sweet floral, black, and blue fruit aromas soar from the glass of this black/purple-colored 2002. Extremely full-bodied, deep, and chewy, with tremendous purity as well as texture, it is a remarkably well-balanced behemoth from South Australia that should age effortlessly for 15+ years. Barrel samples of three 2002s revealed tremendous potential in what appears to be the finest efforts Mitolo has yet produced."