Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
obj
*.o
*.app
2 changes: 1 addition & 1 deletion Examples/Gui/CurrencyConverter/fake.m
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
/* This is a dummy C file to keep GNUmakefile happy */
main() {}
int main() {}
22 changes: 11 additions & 11 deletions Examples/Gui/FirstApp/FirstApp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,17 @@

# You can drag all Foundation and AppKit Classes at once or ....
require 'Foundation'
require 'AppKit'
# require 'AppKit'

#... get only those you need one by one
#Rigs.import("NSApplication")
#Rigs.import("NSGraphicsContext")
#Rigs.import("NSWindow")
#Rigs.import("NSButton")
#Rigs.import("NSProcessInfo")
#Rigs.import("NSMenu")
#Rigs.import("NSSelector")
#Rigs.import("NSString")
Rigs.import("NSApplication")
Rigs.import("NSGraphicsContext")
Rigs.import("NSWindow")
Rigs.import("NSButton")
Rigs.import("NSProcessInfo")
Rigs.import("NSMenu")
Rigs.import("NSSelector")
Rigs.import("NSString")

$STRING_AUTOCONVERT = true
$SELECTOR_AUTOCONVERT = false
Expand Down Expand Up @@ -111,8 +111,8 @@ def createWindow
rect = NSRect.new(0, 0, 400, 200)

@window = NSWindow.alloc
@window = @window.initWithContentRect_styleMask_backing_defer \
(rect, styleMask, NSBackingStoreRetained, false)
@window = @window.initWithContentRect_styleMask_backing_defer(
rect, styleMask, NSBackingStoreRetained, false)

@window.setTitle("Test window with one giant button!")
@window.setContentView (button)
Expand Down
2 changes: 1 addition & 1 deletion Examples/Gui/FirstApp/fake.m
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
/* This is a dummy C file to keep GNUmakefile happy */
main() {}
int main() {}
20 changes: 20 additions & 0 deletions Ruby/rigs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,26 @@

end

%w[
NSCharacterConversionException
NSDestinationInvalidException
NSGenericException
NSInternalInconsistencyException
NSInvalidArgumentException
NSInvalidReceivePortException
NSInvalidSendPortException
NSMallocException
NSObjectInaccessibleException
NSObjectNotAvailableException
NSOldStyleException
NSPortReceiveException
NSPortSendException
NSPortTimeoutException
NSRangeException
].each do |exception_name|
Object.const_set(exception_name, Class.new(RuntimeError)) unless Object.const_defined?(exception_name)
end




Expand Down
6 changes: 5 additions & 1 deletion Source/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ RUBY_ARCH_DIR := $(shell ruby -rrbconfig -e 'print RbConfig::CONFIG["archdir"]')

RUBY_SITE_ARCH_DIR := $(shell ruby -rrbconfig -e 'print RbConfig::CONFIG["sitearchdir"]')

ADDITIONAL_INCLUDE_DIRS = -I$(RUBY_ARCH_DIR)
RUBY_HDR_DIR := $(shell ruby -rrbconfig -e 'print RbConfig::CONFIG["rubyhdrdir"]')

RUBY_ARCH_HDR_DIR := $(shell ruby -rrbconfig -e 'print RbConfig::CONFIG["rubyarchhdrdir"]')

ADDITIONAL_INCLUDE_DIRS = -I$(RUBY_HDR_DIR) -I$(RUBY_ARCH_HDR_DIR) -I$(RUBY_ARCH_DIR)
ADDITIONAL_OBJCFLAGS = -Wall -g -DVERSION=\"$(VERSION)\"

$(LIBRARY_NAME)_OBJC_FILES = $(wildcard *.m)
Expand Down
62 changes: 13 additions & 49 deletions Source/ObjcRuntimeUtilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@
#ifndef __ObjcRuntimeUtilities_h_GNUSTEP_RUBY_INCLUDE
#define __ObjcRuntimeUtilities_h_GNUSTEP_RUBY_INCLUDE

#include <objc/objc-api.h>
#include <objc/encoding.h>
#include <Foundation/Foundation.h>
#import <Foundation/Foundation.h>
#import <GNUstepBase/GSObjCRuntime.h>

/*
* This code is by no means tidied to Java.
Expand Down Expand Up @@ -85,50 +84,29 @@ BOOL ObjcUtilities_new_class (const char *name, const char *superclassName,

Adding new methods to a class

Quick HOWTO:
A. alloc a MethodList using ObjcUtilities_alloc_method_list.
B. insert the methods you want to register in the MethodList using
ObjcUtilities_insert_method_in_list.
To get the objective-C runtime type for a method, you may want to use
ObjcUtilities_build_runtime_Objc_signature
C. register your method list with the objective-C runtime using
ObjcUtilities_register_method_list.
To get the Objective-C runtime type for a method, you may want to use
ObjcUtilities_build_runtime_Objc_signature before adding the method with
ObjcUtilities_add_method.
*/

/*
* ObjcUtilities_alloc_method_list:
* ObjcUtilities_add_method:
*
* Allocate a MethodList capable of containing `count' methods.
* A pointer to the allocated list is returned.
* Add a method definition to a class. `class' is the class to modify,
* `name' is the selector name, `types' is the Objective-C run-time
* signature of the method, and `imp' is the implementation.
*
*/

MethodList *ObjcUtilities_alloc_method_list (int count);

/*
* ObjcUtilities_insert_method_in_list:
*
* Insert a method definition in a MethodList. `ml' is a pointer to
* the MethodList. `index' is the index of the method to add. `name'
* is the name of the method; `types' is the objective-C run-time
* signature of the method (see below for a facility to create this
* automatically), `imp' is the IMP (ie, the actual implementation of
* the method). `imp' must be a pointer to a function taking the
* correct arguments and returning the correct type; cast it to an IMP
* then before calling this function.
*/

void ObjcUtilities_insert_method_in_list (MethodList *ml,
int index, const char *name,
const char *types, IMP imp);
BOOL ObjcUtilities_add_method (Class class, const char *name,
const char *types, IMP imp);

/*
* ObjcUtilities_build_runtime_Objc_signature:
*
* This method creates a runtime objc signature which can be used
* to describe type for a selector *on this machine* (you need this
* signature for example to insert a method description in a method list,
* using the ObjcUtilities_insert_method_in_list function above).
* signature for example to add a method to a class.
*
* It takes as argument a 'naive' objc signature, in the form of
* a string obtained by concatenating the following strings:
Expand All @@ -148,24 +126,10 @@ void ObjcUtilities_insert_method_in_list (MethodList *ml,
*
* On my machine, ObjcUtilities_build_runtime_Objc_signature ("i@:@")
* returns "i12@0:4@8", which I can then use as selector type when
* creating entries in MethodList.
* adding a method to a class.
*
*/

const char *ObjcUtilities_build_runtime_Objc_signature (const char *);

/*
* ObjcUtilities_register_method_list:
*
* Add the list `ml' of methods to an existing Class `class'.
* They are registered as instance methods.
* To add class methods, you simply need to pass the meta class
* [(Class)class->class_pointer] instead of the class.
*
* *Never* release or modify a method list after registering it with
* *the objective-C runtime.
*/

void ObjcUtilities_register_method_list (Class class, MethodList *ml);

#endif /* __ObjcRuntimeUtilitis_h_GNUSTEP_RUBY_INCLUDE */
Loading