[Rubycocoa-devel 771] Re: RubyCocoa 1.0 initialize/load API final spec (draft)

Back to archive index

Fujimoto Hisa hisa****@fobj*****
Tue Feb 27 09:24:41 JST 2007


On 2007/02/27, at 5:40, Laurent Sansonetti wrote:

> Hi Hisa-sensei,
>
> This looks correct to me. Thanks for the detailed work, this might
> help my company providing better documentation.

Thanks!
I forgot description about the load path. So add the following:

Each of four api for initialization/loader adds
`PATH_TO_RUBYCOCOA_FRAMEWORK/Resources/ruby' to the load path
($LOAD_PATH), after initialization of RubyCocoa and before
load/evaluate a ruby program. So you should/can load RubyCocoa library
completely by:

   require "osx/cocoa"     # or "osx/foundation"

in early part of your ruby program.

Additionally, the path to the bundle resource directory
`PATH_TO_BUNDLE/Resources' is added to the load path by the loader API
except RBRubyCocoaInit. So you can load your ruby programs.


> Laurent
>
> On Feb 26, 2007, at 1:56 PM, Fujimoto Hisa wrote:
>
>> hi guys
>>
>> I've committed implementation of the following initialize/load API
>> spec for the RubyCocoa 1.0. Would you satisfactorily come to this  
>> API?
>> I hope it's enough for you. Could you tell us if you have  
>> something of
>> comment/idea about this. Notice we should freeze the api spec soon
>> maybe.
>>
>> thanks
>> --
>> hisa
>>
>> url for the original written by Japanese (my native language):
>> http://www.fobj.com/hisa/d/20070226.html#p01
>>
>> Summary for Initialize/Loading API (OBjective-C side)
>> -----------------------------------------------------
>>
>>   * RBBundleInit      -- Ruby program loader for a bundle
>>   * RBApplicationInit -- Ruby program loader for a command/ 
>> application
>>   * RBRubyCocoaInit   -- initialize only RubyCocoa (for  
>> compatibility)
>>   * RBApplicationMain -- Ruby program loader for command/application
>> (for compatibility)
>>
>>
>> Summary for Initialize/Loading API (Ruby side)
>> ----------------------------------------------
>>
>>   * OSX.init_for_bundle   -- utility for initialize Ruby program
>>   * OSX.require_framework -- loading framework
>>
>>
>> RBBundleInit -- Ruby program loader for a bundle
>> ------------------------------------------------
>>
>>   #import <RubyCocoa/RubyCocoa.h>
>>   int RBBundleInit (const char* path_to_ruby_program,
>>                     Class       objc_class,
>>                     id          additional_param);
>>
>> Initialize Ruby and RubyCocoa, and then load Ruby program. Return  
>> 0 if
>> success loading. The Ruby program is evaluated under the bundle which
>> is related with the objc_class; the mainBundle may be seleccted when
>> the objc_class is nil. The additional_param is for arbitrary
>> usage. It's passed for a block argument of OSX.init_for_bundle (later
>> mention).
>>
>> usage example:
>>
>>   @implementation MyBundle
>>   + (void) load() {
>>     RBBundleInit("my_ruby_loader.rb", self, nil);
>>   }
>>   @end
>>
>>
>> RBApplicationInit -- Ruby program loader for a command/application
>> ------------------------------------------------------------------
>>
>>   #import <RubyCocoa/RubyCocoa.h>
>>   int RBApplicationInit (const char* path_to_ruby_program,
>>                          int         argc,
>>                          const char* argv[],
>>                          id          additional_param);
>>
>> This API is almost same as RBBundleInit. The Ruby program is  
>> evaluated
>> under the mainBundle. The value of the argv[0] is set in $0 (global
>> variable of Ruby). The array of values between argv[1] to argv 
>> [argc-1]
>> is set in ARGV.
>>
>> usage example:
>>
>>   int main(int argc, const char* argv[]) {
>>     RBApplicationInit("my_ruby_loader.rb", argc, argv, nil);
>>     return NSApplicationMain(argc, argv);
>>   }
>>
>>
>> RBRubyCocoaInit (for compatibility)
>> -----------------------------------
>>
>>   #import <RubyCocoa/RubyCocoa.h>
>>   void RBRubyCocoaInit();
>>
>> Initialize RubyCocoa on assuming that initialization for ruby is
>> done. This API is for compatibility. Using this may be rare.
>>
>>
>> RBApplicationMain (for compatibility)
>> -------------------------------------
>>
>>   #import <RubyCocoa/RubyCocoa.h>
>>   int
>>   RBApplicationMain (const char* path_to_ruby_program,
>>                      int         argc,
>>                      const char* argv[]);
>>
>> Initialize Ruby and RubyCocoa, and then load Ruby program. Return 0
>> always. The Ruby program is evaluated under the mainBundle. argc and
>> argv are parsed by the parser same as the ruby command named
>> ruby_options. This API is for compatibility. The spec will be changed
>> in the future.
>>
>>
>> OSX.init_for_bundle   -- utility for initialize Ruby program
>> ------------------------------------------------------------
>>
>>   require 'osx/cocoa'
>>   OSX.init_for_bundle { |bundle, additional_param, logger| ... }
>>
>> Run the ruby program in the given block. When using this method in  
>> the
>> Ruby program which is passed for RBBundleInit or RBApplicationInit,
>> related bundle and additional_param passed as the block arguments.
>> the logger is the simple logger for NSLog which has two methods:
>>
>>   logger.info(fmt, *args)
>>   logger.error(err)
>>
>> usage example:
>>
>>   require 'osx/cocoa'
>>   OSX.init_for_bundle do |bundle, param, logger|
>>     require 'MyController'
>>     OSX::NSBundle.
>>       objc_send :loadNibNamed, 'MyView.nib',
>>                 :owner,        MyController.alloc.init
>>     logger.info("done.")
>>   end
>>
>>
>> OSX.require_framework -- loading framework
>> ------------------------------------------
>>
>>   require 'osx/cocoa'
>>   OSX.require_framework FRAMEWORK
>>
>> _______________________________________________
>> Rubycocoa-devel mailing list
>> Rubyc****@lists*****
>> http://lists.sourceforge.jp/mailman/listinfo/rubycocoa-devel
>
> _______________________________________________
> Rubycocoa-devel mailing list
> Rubyc****@lists*****
> http://lists.sourceforge.jp/mailman/listinfo/rubycocoa-devel




More information about the Rubycocoa-devel mailing list
Back to archive index