コード例 #1
0
ファイル: protocol.c プロジェクト: DarkPlayer/cctools-port
struct objc_method_description
protocol_getMethodDescription(Protocol *p,
                              SEL aSel,
                              BOOL isRequiredMethod,
                              BOOL isInstanceMethod)
{
	struct objc_method_description d = {0,0};
	struct objc_method_description_list *list =
		get_method_list(p, isRequiredMethod, isInstanceMethod);
	if (NULL == list)
	{
		return d;
	}
	// TODO: We could make this much more efficient if
	for (int i=0 ; i<list->count ; i++)
	{
		SEL s = sel_registerTypedName_np(list->methods[i].name, 0);
		if (sel_isEqual(s, aSel))
		{
			d.name = s;
			d.types = list->methods[i].types;
			break;
		}
	}
	return d;
}
コード例 #2
0
ファイル: class.c プロジェクト: Strongc/WinObjC
static void call_method(Class cls, const char* method) {
    struct objc_method_list* ml;
    SEL selector;
    unsigned int i;

    selector = sel_registerName(method);

    for (ml = object_getClass((id)cls)->methodlist; ml != NULL; ml = ml->next)
        for (i = 0; i < ml->count; i++)
            if (sel_isEqual((SEL)&ml->methods[i].sel, selector))
                ((void (*)(id, SEL))ml->methods[i].imp)((id)cls, selector);
}
コード例 #3
0
ファイル: class.c プロジェクト: Strongc/WinObjC
static BOOL has_load(Class cls) {
    struct objc_method_list* ml;
    SEL selector;
    unsigned int i;

    selector = sel_registerName("load");

    for (ml = object_getClass((id)cls)->methodlist; ml != NULL; ml = ml->next)
        for (i = 0; i < ml->count; i++)
            if (sel_isEqual((SEL)&ml->methods[i].sel, selector))
                return YES;

    return NO;
}
コード例 #4
0
/**
 * Looks up the instance method in a specific class, without recursing into
 * superclasses.
 */
static Method class_getInstanceMethodNonrecursive(Class aClass, SEL aSelector)
{
	for (struct objc_method_list *methods = aClass->methods;
		methods != NULL ; methods = methods->next)
	{
		for (int i=0 ; i<methods->count ; i++)
		{
			Method method = &methods->methods[i];
			if (sel_isEqual(method->selector, aSelector))
			{
				return method;
			}
		}
	}
	return NULL;
}
コード例 #5
0
ファイル: protocols.c プロジェクト: WildHunter/gcc
struct objc_method_description protocol_getMethodDescription (Protocol *protocol, 
							      SEL selector,
							      BOOL requiredMethod,
							      BOOL instanceMethod)
{
  struct objc_method_description no_result = { NULL, NULL };
  struct objc_method_description_list *methods;
  int i;

  /* TODO: New ABI.  */
  /* The current ABI does not have any information on optional protocol methods.  */
  if (! requiredMethod)
    return no_result;

  /* Check that it is a Protocol object before casting it to (struct
     objc_protocol *).  */
  if (protocol->class_pointer != objc_lookUpClass ("Protocol"))
    return no_result;

  if (instanceMethod)
    methods = ((struct objc_protocol *)protocol)->instance_methods;
  else
    methods = ((struct objc_protocol *)protocol)->class_methods;

  if (methods)
    {
      for (i = 0; i < methods->count; i++)
	{
	  if (sel_isEqual (methods->list[i].name, selector))
	    return methods->list[i];
	  /*
	  if (strcmp (sel_getName (methods->list[i].name), selector_name) == 0)
	    return methods->list[i];
	  */
	}
    }

  return no_result;
}