[#83328] tcltklib and not init'ing tk — aakhter@... (Aamer Akhter)

Hello,

13 messages 2003/10/01

[#83391] mixing in class methods — "Mark J. Reed" <markjreed@...>

Okay, probably a dumb question, but: is there any way to define

22 messages 2003/10/01
[#83392] Re: mixing in class methods — Ryan Pavlik <rpav@...> 2003/10/01

On Thu, 2 Oct 2003 06:02:32 +0900

[#83397] Re: mixing in class methods — Gavin Sinclair <gsinclair@...> 2003/10/01

On Thursday, October 2, 2003, 7:08:00 AM, Ryan wrote:

[#83399] Re: mixing in class methods — "Mark J. Reed" <markjreed@...> 2003/10/02

On Thu, Oct 02, 2003 at 07:37:25AM +0900, Gavin Sinclair wrote:

[#83404] Re: mixing in class methods — "Gavin Sinclair" <gsinclair@...> 2003/10/02

> On Thu, Oct 02, 2003 at 07:37:25AM +0900, Gavin Sinclair wrote:

[#83416] C or C++? — "Joe Cheng" <code@...>

I'd like to start writing Ruby extensions. Does it make a difference

32 messages 2003/10/02
[#83435] Re: C or C++? — "Aleksei Guzev" <aleksei.guzev@...> 2003/10/02

[#83448] xml in Ruby — paul vudmaska <paul_vudmaska@...> 2003/10/02

The biggest problem i have with Ruby is the sleepness

[#83455] Re: xml in Ruby — Chad Fowler <chad@...> 2003/10/02

On Thu, 2 Oct 2003, paul vudmaska wrote:

[#83464] Re: xml in Ruby or no xml it's just a question — paul vudmaska <paul_vudmaska@...> 2003/10/02

>>--------

[#83470] Re: xml in Ruby — paul vudmaska <paul_vudmaska@...>

>>>

15 messages 2003/10/02

[#83551] xml + ruby — paul vudmaska <paul_vudmaska@...>

>>---------

20 messages 2003/10/03
[#83562] Re: xml + ruby — Austin Ziegler <austin@...> 2003/10/03

On Fri, 3 Oct 2003 16:11:46 +0900, paul vudmaska wrote:

[#83554] hash of hashes — Paul Argentoff <argentoff@...>

Hi all.

18 messages 2003/10/03

[#83675] fox-tool - interactive gui builder for fxruby — henon <user@...>

hi fellows,

15 messages 2003/10/05

[#83730] Re: Enumerable#inject is surprising me... — "Weirich, James" <James.Weirich@...>

> Does it surprise you?

17 messages 2003/10/06
[#83732] Re: Enumerable#inject is surprising me... — nobu.nokada@... 2003/10/07

Hi,

[#83801] Extension Language for a Text Editor — Nikolai Weibull <ruby-talk@...>

OK. So I'm going to write a text editor for my masters' thesis. The

35 messages 2003/10/08
[#83803] Re: Extension Language for a Text Editor — Ryan Pavlik <rpav@...> 2003/10/08

On Thu, 9 Oct 2003 05:06:32 +0900

[#83806] Re: Extension Language for a Text Editor — Nikolai Weibull <ruby-talk@...> 2003/10/08

* Ryan Pavlik <rpav@mephle.com> [Oct, 08 2003 22:30]:

[#83812] Re: Extension Language for a Text Editor — Ryan Pavlik <rpav@...> 2003/10/08

On Thu, 9 Oct 2003 06:09:29 +0900

[#83955] Re: Extension Language for a Text Editor — Nikolai Weibull <ruby-talk@...> 2003/10/09

* Ryan Pavlik <rpav@mephle.com> [Oct, 09 2003 09:10]:

[#84169] General Ruby Programming questions — Simon Kitching <simon@...>

21 messages 2003/10/15
[#84170] Re: General Ruby Programming questions — Florian Gross <flgr@...> 2003/10/15

Simon Kitching wrote:

[#84172] Re: General Ruby Programming questions — Simon Kitching <simon@...> 2003/10/15

Hi Florian..

[#84331] Re: Email Harvesting — Greg Vaughn <gvaughn@...>

Ryan Dlugosz said:

17 messages 2003/10/21
[#84335] Re: Email Harvesting — Hugh Sasse Staff Elec Eng <hgs@...> 2003/10/21

On Wed, 22 Oct 2003, Greg Vaughn wrote:

[#84343] Re: Email Harvesting — Ruben Vandeginste <Ruben.Vandeginste@...> 2003/10/22

On Wed, 22 Oct 2003 08:35:32 +0900, Hugh Sasse Staff Elec Eng

[#84341] Ruby-oriented Linux distro? — Hal Fulton <hal9000@...>

There's been some talk of something like this in the past.

15 messages 2003/10/22
[#84348] Re: Ruby-oriented Linux distro? — Gavin Sinclair <gsinclair@...> 2003/10/22

On Wednesday, October 22, 2003, 6:01:16 PM, Hal wrote:

[#84351] Re: Ruby-oriented Linux distro? — Andrew Walrond <andrew@...> 2003/10/22

On Wednesday 22 Oct 2003 11:02 am, Gavin Sinclair wrote:

[#84420] Struggling with variable arguments to block — "Gavin Sinclair" <gsinclair@...>

Hi -talk,

18 messages 2003/10/24
[#84428] Re: Struggling with variable arguments to block — matz@... (Yukihiro Matsumoto) 2003/10/24

Hi,

[#84604] ruby-dev summary 21637-21729 — Takaaki Tateishi <ttate@...>

Hello,

21 messages 2003/10/30
[#84787] Re: ruby-dev summary 21637-21729 — Paul Brannan <pbrannan@...> 2003/11/06

On Fri, Oct 31, 2003 at 07:01:28AM +0900, Takaaki Tateishi wrote:

[#84789] Re: ruby-dev summary 21637-21729 — matz@... (Yukihiro Matsumoto) 2003/11/06

Hi,

[#84792] Re: ruby-dev summary 21637-21729 — Paul Brannan <pbrannan@...> 2003/11/06

On Thu, Nov 06, 2003 at 11:17:59PM +0900, Yukihiro Matsumoto wrote:

[#84794] Re: ruby-dev summary 21637-21729 — matz@... (Yukihiro Matsumoto) 2003/11/06

Hi,

Re: tcltklib and not init'ing tk

From: Aamer Akhter <aakhter@...>
Date: 2003-10-02 01:43:30 UTC
List: ruby-talk #83405
The following changes appear to work fine. All you need to do (for not
starting tk) is to give a non-nil value to the third arg in new:

irb(main):003:0> ip1 = TclTkIp.new("bobo",nil,1)
tcltklib: Tcl_CreateInterp
tcltklib: Tcl_Init
tcltklib: tknoload set
tcltklib: Tcl_CreateObjCommand("ruby")
=> #<TclTkIp:0x1a3678>
irb(main):004:0> ip1 = TclTkIp.new("bobo",nil,nil)
tcltklib: Tcl_CreateInterp
tcltklib: Tcl_Init
tcltklib: Tk_Init
tcltklib: Tcl_StaticPackage("Tk")
tcltklib: Tcl_CreateObjCommand("ruby")



*** bak/tcltklib.c    Wed Oct  1 21:13:43 2003
--- tcltklib.c    Wed Oct  1 21:30:28 2003
***************
*** 642,662 ****
      return Data_Wrap_Struct(self, 0, ip_free, 0);
  }
  
  static VALUE
  ip_init(argc, argv, self)
      int   argc;
      VALUE *argv;
      VALUE self;
  {
      struct tcltkip *ptr;    /* tcltkip data struct */
!     VALUE argv0, opts;
      int cnt;
  
      /* create object */
      Data_Get_Struct(self, struct tcltkip, ptr);
      ptr = ALLOC(struct tcltkip);
      DATA_PTR(self) = ptr;
      ptr->return_value = 0;
  
      /* from Tk_Main() */
      DUMP1("Tcl_CreateInterp");
--- 642,662 ----
      return Data_Wrap_Struct(self, 0, ip_free, 0);
  }
  
  static VALUE
  ip_init(argc, argv, self)
      int   argc;
      VALUE *argv;
      VALUE self;
  {
      struct tcltkip *ptr;    /* tcltkip data struct */
!     VALUE argv0, opts, tknoload;
      int cnt;
  
      /* create object */
      Data_Get_Struct(self, struct tcltkip, ptr);
      ptr = ALLOC(struct tcltkip);
      DATA_PTR(self) = ptr;
      ptr->return_value = 0;
  
      /* from Tk_Main() */
      DUMP1("Tcl_CreateInterp");
***************
*** 664,711 ****
      Tcl_Preserve((ClientData)ptr->ip);
      current_interp = ptr->ip;
  
      /* from Tcl_AppInit() */
      DUMP1("Tcl_Init");
      if (Tcl_Init(ptr->ip) == TCL_ERROR) {
      rb_raise(rb_eRuntimeError, "%s", ptr->ip->result);
      }
  
      /* set variables */
!     cnt = rb_scan_args(argc, argv, "02", &argv0, &opts);
      switch(cnt) {
      case 2:
      /* options */
!     Tcl_SetVar(ptr->ip, "argv", StringValuePtr(opts), 0);
      case 1:
      /* argv0 */
      if (argv0 != Qnil) {
          Tcl_SetVar(ptr->ip, "argv0", StringValuePtr(argv0), 0);
      }
      case 0:
      /* no args */
      ;
      }
  
      /* from Tcl_AppInit() */
      DUMP1("Tk_Init");
      if (Tk_Init(ptr->ip) == TCL_ERROR) {
      rb_raise(rb_eRuntimeError, "%s", ptr->ip->result);
      }
      DUMP1("Tcl_StaticPackage(\"Tk\")");
  #if TCL_MAJOR_VERSION >= 8
      Tcl_StaticPackage(ptr->ip, "Tk", Tk_Init, Tk_SafeInit);
  #else
      Tcl_StaticPackage(ptr->ip, "Tk", Tk_Init,
                (Tcl_PackageInitProc *) NULL);
  #endif
! 
      /* add ruby command to the interpreter */
  #if TCL_MAJOR_VERSION >= 8
      DUMP1("Tcl_CreateObjCommand(\"ruby\")");
      Tcl_CreateObjCommand(ptr->ip, "ruby", ip_ruby, (ClientData)NULL,
               (Tcl_CmdDeleteProc *)NULL);
  #else
      DUMP1("Tcl_CreateCommand(\"ruby\")");
      Tcl_CreateCommand(ptr->ip, "ruby", ip_ruby, (ClientData)NULL,
                (Tcl_CmdDeleteProc *)NULL);
  #endif
--- 664,720 ----
      Tcl_Preserve((ClientData)ptr->ip);
      current_interp = ptr->ip;
  
      /* from Tcl_AppInit() */
      DUMP1("Tcl_Init");
      if (Tcl_Init(ptr->ip) == TCL_ERROR) {
      rb_raise(rb_eRuntimeError, "%s", ptr->ip->result);
      }
  
      /* set variables */
!     cnt = rb_scan_args(argc, argv, "03", &argv0, &opts, &tknoload);
      switch(cnt) {
+     case 3:
+         /* do we load tk or not */
      case 2:
      /* options */
!     if (opts != Qnil) {
!         Tcl_SetVar(ptr->ip, "argv", StringValuePtr(opts), 0);
!     }
      case 1:
      /* argv0 */
      if (argv0 != Qnil) {
          Tcl_SetVar(ptr->ip, "argv0", StringValuePtr(argv0), 0);
      }
      case 0:
      /* no args */
      ;
      }
  
      /* from Tcl_AppInit() */
+     if ( tknoload == Qnil ) {
      DUMP1("Tk_Init");
      if (Tk_Init(ptr->ip) == TCL_ERROR) {
      rb_raise(rb_eRuntimeError, "%s", ptr->ip->result);
      }
      DUMP1("Tcl_StaticPackage(\"Tk\")");
  #if TCL_MAJOR_VERSION >= 8
      Tcl_StaticPackage(ptr->ip, "Tk", Tk_Init, Tk_SafeInit);
  #else
      Tcl_StaticPackage(ptr->ip, "Tk", Tk_Init,
                (Tcl_PackageInitProc *) NULL);
  #endif
!     } else {
!     DUMP1("tknoload set");
!     }
!     
!     
      /* add ruby command to the interpreter */
  #if TCL_MAJOR_VERSION >= 8
      DUMP1("Tcl_CreateObjCommand(\"ruby\")");
      Tcl_CreateObjCommand(ptr->ip, "ruby", ip_ruby, (ClientData)NULL,
               (Tcl_CmdDeleteProc *)NULL);
  #else
      DUMP1("Tcl_CreateCommand(\"ruby\")");
      Tcl_CreateCommand(ptr->ip, "ruby", ip_ruby, (ClientData)NULL,
                (Tcl_CmdDeleteProc *)NULL);
  #endif


How do I go about getting this code reviewed and into ruby proper? I would
appreciate any corrections or better ideas for the above.

Thanks.

Aamer Akhter
cisco Systems


In This Thread