Ejemplo n.º 1
0
static ply_renderer_backend_t *
create_backend (const char *device_name,
                ply_terminal_t *terminal)
{
  ply_renderer_backend_t *backend;

  backend = calloc (1, sizeof (ply_renderer_backend_t));

  if (device_name != NULL)
    backend->device_name = strdup (device_name);
  else
    backend->device_name = strdup ("/dev/dri/card0");

  ply_trace ("creating renderer backend for device %s", backend->device_name);

  backend->device_fd = -1;

  backend->loop = ply_event_loop_get_default ();
  backend->heads = ply_list_new ();
  backend->input_source.key_buffer = ply_buffer_new ();
  backend->terminal = terminal;

  return backend;
}
Ejemplo n.º 2
0
static script_op_t *script_parse_for (script_scan_t *scan)
{
  script_scan_token_t *curtoken = script_scan_get_current_token (scan);

  if (!script_scan_token_is_identifier_of_value (curtoken, "for")) return NULL;
  script_debug_location_t location_for = curtoken->location;
  curtoken = script_scan_get_next_token (scan);
  if (!script_scan_token_is_symbol_of_value (curtoken, '('))
    {
      script_parse_error (&curtoken->location,
                          "Expected a '(' at the start of a condition block");
      return NULL;
    }
  curtoken = script_scan_get_next_token (scan);
  script_debug_location_t location_first = curtoken->location;

  script_exp_t *first = script_parse_exp (scan);
  if (!first)
    {
      script_parse_error (&curtoken->location, "Expected a valid first expression");
      return NULL;
    }
  curtoken = script_scan_get_current_token (scan);
  if (!script_scan_token_is_symbol_of_value (curtoken, ';'))
    {
      script_parse_error (&curtoken->location,
                          "Expected a ';' after the first 'for' expression");
      return NULL;
    }
  script_scan_get_next_token (scan);

  script_exp_t *cond = script_parse_exp (scan);
  if (!cond)
    {
      script_parse_error (&curtoken->location, "Expected a valid condition expression");
      return NULL;
    }
  curtoken = script_scan_get_current_token (scan);
  if (!script_scan_token_is_symbol_of_value (curtoken, ';'))
    {
      script_parse_error (&curtoken->location, "Expected a ';' after the 'for' condition");
      return NULL;
    }
  script_scan_get_next_token (scan);
  script_debug_location_t location_last = curtoken->location;

  script_exp_t *last = script_parse_exp (scan);
  if (!last)
    {
      script_parse_error (&curtoken->location, "Expected a valid last expression");
      return NULL;
    }
  curtoken = script_scan_get_current_token (scan);
  if (!script_scan_token_is_symbol_of_value (curtoken, ')'))
    {
      script_parse_error (&curtoken->location, "Expected a ')' at the end of a for block");
      return NULL;
    }
  script_scan_get_next_token (scan);
  script_op_t *op_body = script_parse_op (scan);

  script_op_t *op_first = script_parse_new_op_exp (first, &location_first);
  script_op_t *op_last = script_parse_new_op_exp (last, &location_last);
  script_op_t *op_for = script_parse_new_op_cond (SCRIPT_OP_TYPE_FOR, cond, op_body, op_last, &location_for);

  ply_list_t *op_list = ply_list_new ();
  ply_list_append_data (op_list, op_first);
  ply_list_append_data (op_list, op_for);

  script_op_t *op_block = script_parse_new_op_block (op_list, &location_for);

  return op_block;
}
Ejemplo n.º 3
0
static script_exp_t *script_parse_exp_pi (script_scan_t *scan)
{
  script_exp_t *exp = script_parse_exp_tm (scan);
  script_scan_token_t *curtoken = script_scan_get_current_token (scan);

  while (true)
    {
      script_debug_location_t location = curtoken->location;
      if (!script_scan_token_is_symbol (curtoken)) break;
      if (script_scan_token_is_symbol_of_value (curtoken, '('))
        {
          ply_list_t *parameters = ply_list_new ();
          script_scan_get_next_token (scan);
          while (true)
            {
              if (script_scan_token_is_symbol_of_value (curtoken, ')')) break;
              script_exp_t *parameter = script_parse_exp (scan);

              ply_list_append_data (parameters, parameter);

              curtoken = script_scan_get_current_token (scan);
              if (script_scan_token_is_symbol_of_value (curtoken, ')')) break;
              if (!script_scan_token_is_symbol_of_value (curtoken, ','))
                {
                  script_parse_error (&curtoken->location,
                    "Function parameters should be separated with a ',' and terminated with a ')'");
                  return NULL;
                }
              curtoken = script_scan_get_next_token (scan);
            }
          script_scan_get_next_token (scan);
          exp = script_parse_new_exp_function_exe (exp, parameters, &location);
          continue;
        }
      script_exp_t *key;

      if (script_scan_token_is_symbol_of_value (curtoken, '.'))
        {
          script_scan_get_next_token (scan);
          if (script_scan_token_is_identifier (curtoken))
            {
              key = script_parse_new_exp_string (curtoken->data.string, &curtoken->location);
            }
          else
            {
              script_parse_error (&curtoken->location,
                "A dot based hash index must be an identifier");
              return NULL;
            }
          curtoken = script_scan_get_next_token (scan);
        }
      else if (script_scan_token_is_symbol_of_value (curtoken, '['))
        {
          script_scan_get_next_token (scan);
          key = script_parse_exp (scan);
          if (!key)
            {
              script_parse_error (&curtoken->location,
                "Expected a valid index expression");
              return NULL;
            }
          curtoken = script_scan_get_current_token (scan);
          if (!script_scan_token_is_symbol_of_value (curtoken, ']'))
            {
              script_parse_error (&curtoken->location,
                "Expected a ']' to terminate the index expression");
              return NULL;
            }
          curtoken = script_scan_get_next_token (scan);
        }
      else break;
      exp = script_parse_new_exp_dual (SCRIPT_EXP_TYPE_HASH, exp, key, &location);
    }
  return exp;
}
Ejemplo n.º 4
0
static script_exp_t *script_parse_exp_tm (script_scan_t *scan)
{
  script_scan_token_t *curtoken = script_scan_get_current_token (scan);
  script_exp_t *exp = NULL;

  if (script_scan_token_is_integer (curtoken))
    {
      exp = script_parse_new_exp_number (curtoken->data.integer, &curtoken->location);
      script_scan_get_next_token (scan);
      return exp;
    }
  if (script_scan_token_is_float (curtoken))
    {
      exp = script_parse_new_exp_number (curtoken->data.floatpoint, &curtoken->location);
      script_scan_get_next_token (scan);
      return exp;
    }
  if (script_scan_token_is_identifier (curtoken))
    {
      if (script_scan_token_is_identifier_of_value (curtoken, "NULL"))
        exp = script_parse_new_exp(SCRIPT_EXP_TYPE_TERM_NULL, &curtoken->location);
      else if (script_scan_token_is_identifier_of_value (curtoken, "INFINITY"))
        exp = script_parse_new_exp_number (INFINITY, &curtoken->location);
      else if (script_scan_token_is_identifier_of_value (curtoken, "NAN"))
        exp = script_parse_new_exp_number (NAN, &curtoken->location);
      else if (script_scan_token_is_identifier_of_value (curtoken, "global"))
        exp = script_parse_new_exp(SCRIPT_EXP_TYPE_TERM_GLOBAL, &curtoken->location);
      else if (script_scan_token_is_identifier_of_value (curtoken, "local"))
        exp = script_parse_new_exp(SCRIPT_EXP_TYPE_TERM_LOCAL, &curtoken->location);
      else if (script_scan_token_is_identifier_of_value (curtoken, "this"))
        exp = script_parse_new_exp(SCRIPT_EXP_TYPE_TERM_THIS, &curtoken->location);
      else if (script_scan_token_is_identifier_of_value (curtoken, "fun"))
        {
          script_debug_location_t location = curtoken->location;
          script_scan_get_next_token (scan);
          exp = script_parse_new_exp_function_def (script_parse_function_def (scan), &location);
          return exp;
        }
      else
        {
          exp = script_parse_new_exp_var (curtoken->data.string, &curtoken->location);
        }
      curtoken = script_scan_get_next_token (scan);
      return exp;
    }
  if (script_scan_token_is_string (curtoken))
    {
      exp = script_parse_new_exp_string (curtoken->data.string, &curtoken->location);
      script_scan_get_next_token (scan);
      return exp;
    }
  
  if (script_scan_token_is_symbol_of_value (curtoken, '['))
    {
      ply_list_t *parameters = ply_list_new ();
      script_debug_location_t location = curtoken->location;
      script_scan_get_next_token (scan);
      while (true)
        {
          if (script_scan_token_is_symbol_of_value (curtoken, ']')) break;
          script_exp_t *parameter = script_parse_exp (scan);

          ply_list_append_data (parameters, parameter);

          curtoken = script_scan_get_current_token (scan);
          if (script_scan_token_is_symbol_of_value (curtoken, ']')) break;
          if (!script_scan_token_is_symbol_of_value (curtoken, ','))
            {
              script_parse_error (&curtoken->location,
                "Set parameters should be separated with a ',' and terminated with a ']'");
              return NULL;
            }
          curtoken = script_scan_get_next_token (scan);
        }
      script_scan_get_next_token (scan);
      exp = script_parse_new_exp_set (parameters, &location);
      return exp;
    }
  if (script_scan_token_is_symbol_of_value (curtoken, '('))
    {
      script_scan_get_next_token (scan);
      exp = script_parse_exp (scan);
      curtoken = script_scan_get_current_token (scan);
      if (!exp)
        {
          script_parse_error (&curtoken->location,
            "Expected valid contents of bracketed expression");
          return NULL;
        }
      if (!script_scan_token_is_symbol_of_value (curtoken, ')'))
        {
          script_parse_error (&curtoken->location,
            "Expected bracketed block to be terminated with a ')'");
          return NULL;
        }
      script_scan_get_next_token (scan);
      return exp;
    }
  return NULL;
}
Ejemplo n.º 5
0
static ply_boot_splash_plugin_t *
create_plugin (ply_key_file_t *key_file)
{
  ply_boot_splash_plugin_t *plugin;
  char *image_dir, *image_path;
  char *alignment;
  char *transition;
  char *transition_duration;
  char *color;

  srand ((int) ply_get_timestamp ());
  plugin = calloc (1, sizeof (ply_boot_splash_plugin_t));

  image_dir = ply_key_file_get_value (key_file, "two-step", "ImageDir");

  asprintf (&image_path, "%s/lock.png", image_dir);
  plugin->lock_image = ply_image_new (image_path);
  free (image_path);

  asprintf (&image_path, "%s/box.png", image_dir);
  plugin->box_image = ply_image_new (image_path);
  free (image_path);

  asprintf (&image_path, "%s/corner-image.png", image_dir);
  plugin->corner_image = ply_image_new (image_path);
  free (image_path);

  plugin->animation_dir = image_dir;

  alignment = ply_key_file_get_value (key_file, "two-step", "HorizontalAlignment");
  if (alignment != NULL)
    plugin->animation_horizontal_alignment = strtod (alignment, NULL);
  else
    plugin->animation_horizontal_alignment = .5;
  free (alignment);

  alignment = ply_key_file_get_value (key_file, "two-step", "VerticalAlignment");
  if (alignment != NULL)
    plugin->animation_vertical_alignment = strtod (alignment, NULL);
  else
    plugin->animation_vertical_alignment = .5;
  free (alignment);

  plugin->transition = PLY_PROGRESS_ANIMATION_TRANSITION_NONE;
  transition = ply_key_file_get_value (key_file, "two-step", "Transition");
  if (transition != NULL)
    {
      if (strcmp (transition, "fade-over") == 0)
        plugin->transition = PLY_PROGRESS_ANIMATION_TRANSITION_FADE_OVER;
      else if (strcmp (transition, "cross-fade") == 0)
        plugin->transition = PLY_PROGRESS_ANIMATION_TRANSITION_CROSS_FADE;
      else if (strcmp (transition, "merge-fade") == 0)
        plugin->transition = PLY_PROGRESS_ANIMATION_TRANSITION_MERGE_FADE;
    }
  free (transition);

  transition_duration = ply_key_file_get_value (key_file, "two-step", "TransitionDuration");
  if (transition_duration != NULL)
    plugin->transition_duration = strtod (transition_duration, NULL);
  else
    plugin->transition_duration = 0.0;
  free (transition_duration);

  color = ply_key_file_get_value (key_file, "two-step", "BackgroundStartColor");

  if (color != NULL)
    plugin->background_start_color = strtol (color, NULL, 0);
  else
    plugin->background_start_color = PLYMOUTH_BACKGROUND_START_COLOR;

  free (color);

  color = ply_key_file_get_value (key_file, "two-step", "BackgroundEndColor");

  if (color != NULL)
    plugin->background_end_color = strtol (color, NULL, 0);
  else
    plugin->background_end_color = PLYMOUTH_BACKGROUND_END_COLOR;

  free (color);

  plugin->views = ply_list_new ();

  return plugin;
}