Exemplo n.º 1
0
char *block_copyIMPTypeEncoding_np(void*block)
{
	char *buffer = strdup(block_getType_np(block));
	if (NULL == buffer) { return NULL; }
	char *replace = buffer;
	// Skip the return type
	replace += lengthOfTypeEncoding(replace);
	while (isdigit(*replace)) { replace++; }
	// The first argument type should be @? (block), and we need to transform
	// it to @, so we have to delete the ?.  Assert here because this isn't a
	// block encoding at all if the first argument is not a block, and since we
	// got it from block_getType_np(), this means something is badly wrong.
	assert('@' == *replace);
	replace++;
	assert('?' == *replace);
	// Use strlen(replace) not replace+1, because we want to copy the NULL
	// terminator as well.
	memmove(replace, replace+1, strlen(replace));
	// The next argument should be an object, and we want to replace it with a
	// selector
	while (isdigit(*replace)) { replace++; }
	if ('@' != *replace)
	{
		free(buffer);
		return NULL;
	}
	*replace = ':';
	return buffer;
}
Exemplo n.º 2
0
void
method_getReturnType(Method method, char *dst, size_t dst_len)
{
  if (0 == method)
    {
      if (dst_len > 0)
	{
          dst[0] = '\0';
	}
    }
  else
    {
      //TODO: Coped and pasted code.  Factor it out.
      const char *types = method->method_types;
      size_t length = lengthOfTypeEncoding(types);

      if (length < dst_len)
	{
	  memcpy(dst, types, length);
	  dst[length] = '\0';
	}
      else if (dst_len > 0)
	{
	  memcpy(dst, types, dst_len);
	}
    }
}
Exemplo n.º 3
0
static char *
copyTypeEncoding(const char *types)
{
  size_t length = lengthOfTypeEncoding(types);
  char *copy = malloc(length + 1);

  memcpy(copy, types, length);
  copy[length] = '\0';
  return copy;
}
Exemplo n.º 4
0
void
method_getArgumentType(Method method,
 unsigned int index, char *dst, size_t dst_len)
{
  const char *types;
  size_t length;

  types = findParameterStart(method->method_types, index);
  if (NULL == types)
    {
      strncpy(dst, "", dst_len);
      return;
    }
  length = lengthOfTypeEncoding(types);
  if (length < dst_len)
    {
      memcpy(dst, types, length);
      dst[length] = '\0';
    }
  else
    {
      memcpy(dst, types, dst_len);
    }
}