代码之家  ›  专栏  ›  技术社区  ›  avpaderno

如何将应用程序类链接到F-Script

  •  2
  • avpaderno  · 技术社区  · 15 年前

    我想创建一个命令行应用程序,它接受执行的脚本F-script,并且可以访问应用程序公开的一些类。

    我该怎么做?

    附言 :我指的是 F-Script ,不是 FScript .

    1 回复  |  直到 13 年前
        1
  •  0
  •   avpaderno    15 年前

    查看FScript.app的代码(据报道它链接到大多数核心框架),我发现了以下方法:

    - (void)loadSystemFrameworks  // Contributed by Cedric Luthi
    {
      NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    
      NSMutableArray *systemFrameworksPaths = [NSMutableArray arrayWithObject:@"/System/Library/Frameworks"];
    
      if ([[NSUserDefaults standardUserDefaults] boolForKey:@"FScriptLoadPrivateSystemFrameworks"])
        [systemFrameworksPaths addObject:@"/System/Library/PrivateFrameworks"];
    
      for (NSString *systemFrameworksPath in systemFrameworksPaths)
      {
        for (NSString *framework in [[NSFileManager defaultManager] contentsOfDirectoryAtPath:systemFrameworksPath error:NULL])
        {
          NSBundle *frameworkBundle = [NSBundle bundleWithPath:[systemFrameworksPath stringByAppendingPathComponent:framework]];
          if ([frameworkBundle preflightAndReturnError:nil])
            [frameworkBundle load];
        }
      }
    
      [pool drain];
    }
    

    我认为链接到从应用程序定义的类就足以加载包含这些类的包。

    推荐文章