コード例 #1
0
ファイル: runtime.c プロジェクト: jsj2008/gnustep-base
int
objc_getClassList(Class * buffer, int bufferLen)
{
  int count = 0;

  if (buffer == NULL)
    {
      void *state = NULL;
      while (Nil != objc_next_class(&state))
	{
	  count++;
	}
    }
  else
    {
      Class nextClass;
      void *state = NULL;

      while (Nil != (nextClass = objc_next_class(&state)) && bufferLen > 0)
	{
	  count++;
	  bufferLen--;
	  *(buffer++) = nextClass;
	}
    }
  return count;
}
コード例 #2
0
ファイル: runtime.c プロジェクト: jsj2008/gnustep-base
Protocol *
objc_getProtocol(const char *name)
{
  Protocol *p = NULL;
  Class cls;
  void *iterator = NULL;

  /* Protocols are not centrally registered in the GNU runtime.
   * So we just find the first match we can.
   */

  while (p == NULL && (cls = objc_next_class(&iterator)))
    {
      struct objc_protocol_list *pcllist = cls->protocols;
      size_t i;

      while (p == NULL && pcllist != NULL)
	{
	  for (i = 0; i < pcllist->count; i++)
	    {
	      if (strcmp(pcllist->list[i]->protocol_name, name) == 0)
		{
		  p = (Protocol*)pcllist->list[i];
		  break;
		}
	    }
	  pcllist = pcllist->next;
	}
    }

  return p;
}
コード例 #3
0
static void objc_updateDtableForClassContainingMethod(Method m)
{
	Class nextClass = Nil;
	void *state = NULL;
	SEL sel = method_getName(m);
	while (Nil != (nextClass = objc_next_class(&state)))
	{
		if (class_getInstanceMethodNonrecursive(nextClass, sel) == m)
		{
			objc_update_dtable_for_class(nextClass);
			return;
		}
	}
}