zoukankan      html  css  js  c++  java
  • reactnative调研

    /**
      * This function parses the exported methods inside RCTBridgeModules and
      * generates an array of arrays of RCTModuleMethod objects, keyed
      * by module index.
      */
      static RCTSparseArray *RCTExportedMethodsByModuleID(void)
      {
      static RCTSparseArray *methodsByModuleID;
      static dispatch_once_t onceToken;
      dispatch_once(&onceToken, ^{
       
      Dl_info info;
      dladdr(&RCTExportedMethodsByModuleID, &info);
       
      #ifdef __LP64__
      typedef uint64_t RCTExportValue;
      typedef struct section_64 RCTExportSection;
      #define RCTGetSectByNameFromHeader getsectbynamefromheader_64
      #else
      typedef uint32_t RCTExportValue;
      typedef struct section RCTExportSection;
      #define RCTGetSectByNameFromHeader getsectbynamefromheader
      #endif
       
      const RCTExportValue mach_header = (RCTExportValue)info.dli_fbase;
      const RCTExportSection *section = RCTGetSectByNameFromHeader((void *)mach_header, "__DATA", "RCTExport");
       
      if (section == NULL) {
      return;
      }
       
      NSArray *classes = RCTBridgeModuleClassesByModuleID();
      NSMutableDictionary *methodsByModuleClassName = [NSMutableDictionary dictionaryWithCapacity:[classes count]];
       
      for (RCTExportValue addr = section->offset;
      addr < section->offset + section->size;
      addr += sizeof(const char **) * 2) {
       
      // Get data entry
      const char **entries = (const char **)(mach_header + addr);
       
      // Create method
      RCTModuleMethod *moduleMethod =
      [[RCTModuleMethod alloc] initWithMethodName:@(entries[0])
      JSMethodName:strlen(entries[1]) ? @(entries[1]) : nil];
       
      // Cache method
      NSArray *methods = methodsByModuleClassName[moduleMethod.moduleClassName];
      methodsByModuleClassName[moduleMethod.moduleClassName] =
      methods ? [methods arrayByAddingObject:moduleMethod] : @[moduleMethod];
      }
       
      methodsByModuleID = [[RCTSparseArray alloc] initWithCapacity:[classes count]];
      [classes enumerateObjectsUsingBlock:^(Class moduleClass, NSUInteger moduleID, BOOL *stop) {
      methodsByModuleID[moduleID] = methodsByModuleClassName[NSStringFromClass(moduleClass)];
      }];
      });
       
      return methodsByModuleID;
      }
  • 相关阅读:
    K短路 (A*算法) [Usaco2008 Mar]牛跑步&[Sdoi2010]魔法猪学院
    [Noi2015]软件包管理器 BZOJ4196
    [SDOI2011]染色 BZOJ2243 树链剖分+线段树
    序列操作 BZOJ2962 线段树
    斜率优化入门学习+总结 Apio2011特别行动队&Apio2014序列分割&HZOI2008玩具装箱&ZJOI2007仓库建设&小P的牧场&防御准备&Sdoi2016征途
    BZOJ1854: [Scoi2010]游戏 二分图
    BZOJ3613: [Heoi2014]南园满地堆轻絮
    BZOJ4590: [Shoi2015]自动刷题机
    [JSOI2008]星球大战starwar BZOJ1015
    Rmq Problem/mex BZOJ3339 BZOJ3585
  • 原文地址:https://www.cnblogs.com/feng9exe/p/6694705.html
Copyright © 2011-2022 走看看