NSMutableDictionary
with a set of keys defined by
- * a Java enumeration. Also provides convenience methods for converting between
- * Java and Cocoa types for the values.
- * @param NSObject
that the value associated with key
will be coerced to
- * @return the value associated with the key coerced as into type
- * @param value
- * @param the type of the Java enum
- * @param nativeEnum the class of the Java enum
- * @param value the native value to resolve
- * @return the corresponding Java enum value
- * @throws IllegalArgumentException if value
does not correspond to any
- * value in the Java enum
- */
- public static & NativeEnum>> E fromNative(Class nativeEnum, NSObject value) {
- try {
- @SuppressWarnings("unchecked")
- E[] enumValues = (E[]) nativeEnum.getDeclaredMethod("values").invoke(null);
- for (E e : enumValues) {
- if ( e.getNativeValue().equals(value) ) {
- return e;
- }
- }
- } catch (Exception ex) {
- throw new IllegalArgumentException("Unknown value " + value + " for " + nativeEnum.getSimpleName(), ex);
- }
- throw new IllegalArgumentException("Unknown value " + value + " for " + nativeEnum.getSimpleName());
- }
- };
-}
-
diff --git a/rococoa/rococoa-contrib/src/main/java/org/rococoa/contrib/appkit/NSInvocationOperation.java b/rococoa/rococoa-contrib/src/main/java/org/rococoa/contrib/appkit/NSInvocationOperation.java
deleted file mode 100644
index 3d8e9147..00000000
--- a/rococoa/rococoa-contrib/src/main/java/org/rococoa/contrib/appkit/NSInvocationOperation.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 2007, 2008, 2009 Duncan McGregor
- *
- * This file is part of Rococoa, a library to allow Java to talk to Cocoa.
- *
- * Rococoa is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Rococoa is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Rococoa. If not, see .
- */
-
-package org.rococoa.contrib.appkit;
-
-import org.rococoa.ID;
-import org.rococoa.ObjCClass;
-import org.rococoa.Rococoa;
-import org.rococoa.Selector;
-
-/** NSInvocationOperation from Cocoa.
- *
- */
-public abstract class NSInvocationOperation extends NSOperation {
- public static final _Class CLASS = Rococoa.createClass(NSInvocationOperation.class.getSimpleName(), _Class.class); //$NON-NLS-1$
- public interface _Class extends ObjCClass {
- public NSInvocationOperation alloc();
- }
-
- public abstract NSInvocationOperation initWithTarget_selector_object(ID target, Selector sel, ID arg);
-
- public abstract ID result();
-}
\ No newline at end of file
diff --git a/rococoa/rococoa-contrib/src/main/java/org/rococoa/contrib/appkit/NSOperation.java b/rococoa/rococoa-contrib/src/main/java/org/rococoa/contrib/appkit/NSOperation.java
deleted file mode 100644
index fe2e5991..00000000
--- a/rococoa/rococoa-contrib/src/main/java/org/rococoa/contrib/appkit/NSOperation.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright 2007, 2008, 2009 Duncan McGregor
- *
- * This file is part of Rococoa, a library to allow Java to talk to Cocoa.
- *
- * Rococoa is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Rococoa is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Rococoa. If not, see .
- */
-
-package org.rococoa.contrib.appkit;
-
-import org.rococoa.ObjCClass;
-import org.rococoa.Rococoa;
-import org.rococoa.cocoa.foundation.NSObject;
-
-/** NSOperation from Cocoa.
- *
- */
-public abstract class NSOperation extends NSObject {
- public static final _Class CLASS = Rococoa.createClass(NSOperation.class.getSimpleName(), _Class.class); //$NON-NLS-1$
- public interface _Class extends ObjCClass {
- public NSOperation alloc();
- }
-
- public abstract NSOperation init();
- public abstract void start();
- public abstract void main();
-
- public abstract void cancel();
- public abstract void waitUntilFinished();
-
- public abstract boolean isCancelled();
- public abstract boolean isExecuting();
- public abstract boolean isFinished();
- public abstract boolean isConcurrent();
- public abstract boolean isReady();
-}
diff --git a/rococoa/rococoa-contrib/src/main/java/org/rococoa/contrib/appkit/NSOperationQueue.java b/rococoa/rococoa-contrib/src/main/java/org/rococoa/contrib/appkit/NSOperationQueue.java
deleted file mode 100644
index cf3d3c1d..00000000
--- a/rococoa/rococoa-contrib/src/main/java/org/rococoa/contrib/appkit/NSOperationQueue.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright 2007, 2008, 2009 Duncan McGregor
- *
- * This file is part of Rococoa, a library to allow Java to talk to Cocoa.
- *
- * Rococoa is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Rococoa is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Rococoa. If not, see .
- */
-package org.rococoa.contrib.appkit;
-
-import org.rococoa.ObjCClass;
-import org.rococoa.Rococoa;
-import org.rococoa.cocoa.foundation.NSArray;
-import org.rococoa.cocoa.foundation.NSInteger;
-import org.rococoa.cocoa.foundation.NSObject;
-import org.rococoa.cocoa.foundation.NSUInteger;
-
-/** NSOperationQueue from Cocoa;
- *
- */
-public abstract class NSOperationQueue extends NSObject {
- public static final _Class CLASS = Rococoa.createClass(NSOperationQueue.class.getSimpleName(), _Class.class); //$NON-NLS-1$
- public static final int NSOperationQueueDefaultMaxConcurrentOperationCount = -1;
- public interface _Class extends ObjCClass {
- public NSOperationQueue alloc();
- public NSOperationQueue currentQueue();
- public NSOperationQueue mainQueue();
- }
-
- public abstract NSOperationQueue init();
- public abstract void addOperation(NSOperation operation);
- public abstract void addOperations_waitUntilFinished(NSArray ops, boolean wait);
- public abstract void cancelAllOperations();
- public abstract boolean isSuspended();
- public abstract NSInteger maxConcurrentOperationCount();
- public abstract String name();
- public abstract NSUInteger operationCount();
- public abstract NSArray operations();
- public abstract void setMaxConcurrentOperationCount(NSInteger count);
- public abstract void setName(String name);
- public abstract void setSuspended(boolean suspend);
- public abstract void waitUntilAllOperationsAreFinished();
-}
diff --git a/rococoa/rococoa-contrib/src/main/java/org/rococoa/contrib/appkit/NSSpeechDictionary.java b/rococoa/rococoa-contrib/src/main/java/org/rococoa/contrib/appkit/NSSpeechDictionary.java
deleted file mode 100755
index 5acfb1ff..00000000
--- a/rococoa/rococoa-contrib/src/main/java/org/rococoa/contrib/appkit/NSSpeechDictionary.java
+++ /dev/null
@@ -1,199 +0,0 @@
-/*
- * Copyright 2007, 2008, 2009 Duncan McGregor
- *
- * This file is part of Rococoa, a library to allow Java to talk to Cocoa.
- *
- * Rococoa is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Rococoa is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Rococoa. If not, see .
- */
-
-package org.rococoa.contrib.appkit;
-
-import org.rococoa.contrib.AbstractPropertyDictionary;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Date;
-import java.util.List;
-import java.util.Locale;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import org.rococoa.contrib.NativeEnum;
-import org.rococoa.Rococoa;
-
-import org.rococoa.cocoa.foundation.NSMutableArray;
-import org.rococoa.cocoa.foundation.NSMutableDictionary;
-import org.rococoa.cocoa.foundation.NSString;
-import static org.rococoa.contrib.appkit.NSSpeechDictionary.SpeechDictionaryProperty.*;
-
-/** NSVoice encapsulates the properties of a speech synthesis dictionary, and can be
- * used with NSSpeechSynthesizer to change the way words are pronounced.
- * Dictionaries contain lists of entries that define how a given word or abbreviation
- * should be pronounced.
- * This class is a Rococoa enhancment designed to make it easier to work with
- * speech dictionaries, there is no actual class with this name in Cocoa.
- */
-public class NSSpeechDictionary extends AbstractPropertyDictionary {
- /** Used to parse Locale strings, to convert Locales between Cocoa and Java*/
- private static final Pattern LOCALE_SPLITTER = Pattern.compile("([a-z]{2})_([A-Z]{2})_?([a-zA-Z1-9]*)");
- /** Defines the properties of a speech dictionary*/
- public enum SpeechDictionaryProperty implements NativeEnum {
- LocaleIdentifier,
- ModificationDate,
- Pronunciations,
- Abbreviations;
- private final NSString value = NSString.getGlobalString(NSSpeechDictionary.class.getSimpleName() + name());
- public NSString getNativeValue() {
- return value;
- }
- }
-
- /** Construct a new empty speech dictionary*/
- public NSSpeechDictionary() {
- super(SpeechDictionaryProperty.values().length);
- }
-
- /** Construct a new SpecchDictionary from existing data
- * @param data used to initialize the speech dictionary, must contain valid keys and values for a speech dictionary
- */
- public NSSpeechDictionary(final NSMutableDictionary data) {
- super(data);
- }
-
- /** Get the Locale associated with this dictionary
- * @return the dictionary's Locale
- */
- public Locale getLocaleIdentifier() {
- String locale = getString(LocaleIdentifier);
- Matcher m = LOCALE_SPLITTER.matcher(locale);
- if ( m.matches() ) {
- if ( m.group(2) == null ) {
- throw new IllegalStateException("Could not parse locale: " + locale + " not enough fields.");
- }
- return m.group(3) != null ? new Locale(m.group(1), m.group(2), m.group(3)) : new Locale(m.group(1), m.group(2));
- } else {
- throw new IllegalStateException("Could not parse locale, does not follow expected format: " + locale);
- }
- }
-
- public void setLocaleIdentifier(Locale localeIdentifier) {
- setString(LocaleIdentifier, localeIdentifier.toString());
- }
-
- public Date getModificationDate() {
- return getDate(ModificationDate);
- }
-
- public void setModificationDate(Date modificationDate) {
- setDate(ModificationDate, modificationDate);
- }
-
- public List getPronunciations() {
- NSMutableArray pronounciations = getValueAsType(Pronunciations, NSMutableArray.class);
- List result = new ArrayList(pronounciations.count());
- for (int i=0; i < pronounciations.count(); i++) {
- result.add(new Entry(Rococoa.cast(pronounciations.objectAtIndex(i), NSMutableDictionary.class)));
- }
- return Collections.unmodifiableList(result);
- }
-
- public void setPronunciations(List pronounciations) {
- NSMutableArray pronounciationDicts = NSMutableArray.CLASS.arrayWithCapacity(pronounciations.size());
- for (Entry e : pronounciations) {
- pronounciationDicts.addObject(e.getData());
- }
- setValue(Pronunciations, pronounciationDicts);
- }
-
- public void addPronounciation(Entry pronounciation) {
- NSMutableArray pronounciations = getValueAsType(Pronunciations, NSMutableArray.class);
- if ( pronounciations == null ) {
- pronounciations = NSMutableArray.CLASS.arrayWithCapacity(1);
- }
- pronounciations.addObject(pronounciation.getData());
- setValue(Pronunciations, pronounciations);
- }
-
- public List getAbbreviations() {
- NSMutableArray abbreviations = getValueAsType(Abbreviations, NSMutableArray.class);
- List result = new ArrayList(abbreviations.count());
- for (int i=0; i < abbreviations.count(); i++) {
- result.add(new Entry(Rococoa.cast(abbreviations.objectAtIndex(i), NSMutableDictionary.class)));
- }
- return Collections.unmodifiableList(result);
- }
-
- public void setAbbreviations(List abbreviations) {
- NSMutableArray abbreviationDicts = NSMutableArray.CLASS.arrayWithCapacity(abbreviations.size());
- for (Entry e : abbreviations) {
- abbreviationDicts.addObject(e.getData());
- }
- setValue(Abbreviations, abbreviationDicts);
- }
-
- public void addAbbreviation(Entry abbreviation) {
- NSMutableArray abbreviations = getValueAsType(Abbreviations, NSMutableArray.class);
- if ( abbreviations == null ) {
- abbreviations = NSMutableArray.CLASS.arrayWithCapacity(1);
- }
- abbreviations.addObject(abbreviation.getData());
- setValue(Abbreviations, abbreviations);
- }
-
- @Override
- public String toString() {
- return "[NSSpeechDictionary: " + getData() + ']';
- }
-
- /** Represents a dictionary entry.
- * Maps a spelling of a word to the associated phonemes that should be used to pronounce it.
- */
- public static class Entry extends AbstractPropertyDictionary {
- /**The properties associated with a dictionary entry*/
- public enum DictionaryEntryProperty implements NativeEnum{
- Spelling,
- Phonemes;
- private final NSString value = NSString.getGlobalString(NSSpeechDictionary.class.getSimpleName() + "Entry" + name());
- public NSString getNativeValue() {
- return value;
- }
- }
- public Entry() {
- super(DictionaryEntryProperty.values().length);
- }
- public Entry(final NSMutableDictionary data) {
- super(data);
- }
- public Entry(final String spelling, final String phonemes) {
- this(NSMutableDictionary.dictionaryWithObjectsAndKeys(
- NSString.stringWithString(phonemes), DictionaryEntryProperty.Phonemes.getNativeValue(),
- NSString.stringWithString(spelling), DictionaryEntryProperty.Spelling.getNativeValue(),
- null)
- );
- }
- public String getSpelling() {
- return getString(DictionaryEntryProperty.Spelling);
- }
-
- public void setSpelling(String entrySpelling) {
- setString(DictionaryEntryProperty.Spelling, entrySpelling);
- }
-
- public String getPhonemes() {
- return getString(DictionaryEntryProperty.Phonemes);
- }
-
- public void setPhonemes(String entryPhonemes) {
- setString(DictionaryEntryProperty.Phonemes, entryPhonemes);
- }
- }
-}
diff --git a/rococoa/rococoa-contrib/src/main/java/org/rococoa/contrib/appkit/NSSpeechSynthesizer.java b/rococoa/rococoa-contrib/src/main/java/org/rococoa/contrib/appkit/NSSpeechSynthesizer.java
deleted file mode 100755
index f5b164c4..00000000
--- a/rococoa/rococoa-contrib/src/main/java/org/rococoa/contrib/appkit/NSSpeechSynthesizer.java
+++ /dev/null
@@ -1,690 +0,0 @@
-/*
- * Copyright 2007, 2008, 2009 Duncan McGregor
- *
- * This file is part of Rococoa, a library to allow Java to talk to Cocoa.
- *
- * Rococoa is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Rococoa is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Rococoa. If not, see .
- */
-
-package org.rococoa.contrib.appkit;
-
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.List;
-
-
-import org.rococoa.contrib.AbstractPropertyDictionary;
-import org.rococoa.ID;
-import org.rococoa.ObjCClass;
-import org.rococoa.ObjCObject;
-import org.rococoa.ObjCObjectByReference;
-import org.rococoa.contrib.NativeEnum;
-import org.rococoa.Rococoa;
-import org.rococoa.cocoa.foundation.NSArray;
-import org.rococoa.cocoa.foundation.NSDictionary;
-import org.rococoa.cocoa.foundation.NSError;
-import org.rococoa.cocoa.foundation.NSMutableDictionary;
-import org.rococoa.cocoa.foundation.NSNumber;
-import org.rococoa.cocoa.foundation.NSObject;
-import org.rococoa.cocoa.foundation.NSRange;
-import org.rococoa.cocoa.foundation.NSString;
-import org.rococoa.cocoa.foundation.NSUInteger;
-import org.rococoa.cocoa.foundation.NSURL;
-//import org.rococoa.RunOnMainThread;
-
-/** Provides access to Cocoa NSSpeechSynthesizer.
- * Methods have been wrapped to take and return natural Java types.
- * Convenience methods and wrapper classes have been implemented for property and NSDictionary based datastructures.
- */
-//@RunOnMainThread
-public abstract class NSSpeechSynthesizer extends NSObject {
- /** Defines the properties associated with a speech synthesizer. Getters and setters have been provided for most of these,
- * so using the properties directly will not usually be necessary.
- * @see NSSpeechSynthesizer#getProperty(org.rococoa.contrib.appkit.NSSpeechSynthesizer.SpeechProperty)
- * @see NSSpeechSynthesizer#setProperty(org.rococoa.contrib.appkit.NSSpeechSynthesizer.SpeechProperty, org.rococoa.NSObject)
- */
- public enum SpeechProperty implements NativeEnum {
- StatusProperty,
- ErrorsProperty,
- InputModeProperty,
- CharacterModeProperty,
- NumberModeProperty,
- RateProperty,
- PitchBaseProperty,
- PitchModProperty,
- VolumeProperty,
- SynthesizerInfoProperty,
- RecentSyncProperty,
- PhonemeSymbolsProperty,
- CurrentVoiceProperty,
- CommandDelimiterProperty,
- ResetProperty,
- OutputToFileURLProperty;
- private final NSString value = NSString.getGlobalString("NSSpeech" + name());
- public NSString getNativeValue() {
- return value;
- }
-
- @Override
- public String toString() {
- return super.toString() + " (" + getNativeValue() + ')';
- }
-
- }
- /**Represents the Objective C class for NSSpeechSynthesizer*/
- public static final _Class CLASS = Rococoa.createClass("NSSpeechSynthesizer", _Class.class);
- /** Synthesizers have an associated delegate. This is the Objective C delegate object acting as the delegate*/
- private ObjCObject delegateProxy = null;
- /** Synthesizers have an associated delegate. This is the Java object provided by the user of this class
- that allows Java code to receive delegate related callbacks.*/
- private NSSpeechSynthesizerDelegate delegate = null;
-
- /** Represents the Objective C class of the speech synthesizer*/
- public static abstract class _Class implements ObjCClass {
- public _Class() {}
- public abstract NSSpeechSynthesizer alloc();
- public abstract NSDictionary attributesForVoice(String voiceIdentifier);
-
- public abstract NSArray availableVoices();
- public abstract String defaultVoice();
- public abstract boolean isAnyApplicationSpeaking();
- }
-
- /** Interface to be implemented by Java objects that want to be informed about events reported to the speech syntheszier's delegate*/
- public interface NSSpeechSynthesizerDelegate {
- public void speechSynthesizer_didEncounterErrorAtIndex_ofString_message(NSSpeechSynthesizer sender, Integer characterIndex, String text, String errorMessage);
- public void speechSynthesizer_didEncounterSyncMessage(NSSpeechSynthesizer sender, String syncFlag);
- public void speechSynthesizer_didFinishSpeaking(NSSpeechSynthesizer sender, boolean success);
- public void speechSynthesizer_willSpeakPhoneme(NSSpeechSynthesizer sender, short phonemeOpcode);
- public void speechSynthesizer_willSpeakWord_ofString(NSSpeechSynthesizer sender, NSRange wordToSpeak, String text);
- }
-
- /** Construct a new synthesizer that speaks with a specified voice.
- * @param voiceIdentifer the identifier of the voice to use
- * @return the newly created synthesizer
- * @throws IllegalArgumentException if the identifier is invalid or the voice indicated is not installed
- */
- public static NSSpeechSynthesizer synthesizerWithVoiceIdentifier(String voiceIdentifer) throws IllegalArgumentException {
- return CLASS.alloc().initWithVoice(voiceIdentifer);
- }
-
- /** Construct a new synthesizer that speaks with a specified voice.
- * @param voice the voice to use, or null to use the defalt voice
- * @return the newly created synthesizer
- * @throws IllegalArgumentException if the voice is invalid or not installed
- */
- public static NSSpeechSynthesizer synthesizerWithVoice(NSVoice voice) {
- return synthesizerWithVoiceIdentifier(voice == null ? null : voice.getIdentifier());
- }
-
- /** Determine the default voice for this computer, set in system preferences
- * @return the system default voice
- */
- public static NSVoice defaultVoice() {
- return new NSVoice(CLASS.attributesForVoice(CLASS.defaultVoice()));
- }
-
- /** Get a list of all available voices
- * @return a list of available voices
- */
- public static List availableVoices() {
- NSArray availableVoices = CLASS.availableVoices();
- List result = new ArrayList(availableVoices.count());
- for (int i=0; i < availableVoices.count(); i++) {
- result.add(new NSVoice(CLASS.attributesForVoice(availableVoices.objectAtIndex(i).toString())));
- }
- return result;
- }
-
- /** Determine whether any application is currently generating speech through
- * the default output channel at present.
- * @return true if the default speech output channel is in use
- */
- public static boolean isAnyApplicationSpeaking() {
- return CLASS.isAnyApplicationSpeaking();
- }
-
- /** Set the delegate that will receive events when speech is generated.
- * @param delegate the delegate to set, replacing any existing one
- */
- public synchronized void setDelegate(final NSSpeechSynthesizerDelegate delegate) {
- if ( delegate != null ) {
- this.delegate = delegate;
- delegateProxy = Rococoa.proxy(delegate);
- setDelegate(this.delegateProxy.id());
- }
- }
-
- /** Get the current delegate
- * @return the delegate
- */
- public synchronized NSSpeechSynthesizerDelegate getDelegate() {
- return delegate;
- }
-
- /** Convert a phoneme opcode to human readable form
- * @param opcode the phoneme code to convert
- * @return the corresponding readable string
- */
- public String opcodeToPhoneme(short opcode) {
- for(NSSpeechPhonemeInfo info : getPhonemeInfo()) {
- if (info.getOpcode() == opcode) {
- return info.getSymbol();
- }
- }
- return "?";
- }
-
- /** Create a sync point that can be embeded in speech, to trigger a
- * synchronization callback.
- * @param marker the marker number for the sync point
- * @return a sync point marker that can be embeded in a string to be spoken
- */
- public static String createSyncPoint(int marker) {
- return String.format("[[sync 0x%h]]", marker);
- }
-
- /** Get the value of a synthesizer property.
- * @param property the property whose value should be retrieved
- * @return the value asociated with the property
- * @throws IllegalArgumentException if an error occurs while reading the property
- */
- public NSObject getProperty(SpeechProperty property) throws IllegalArgumentException {
- ObjCObjectByReference errorPtr = new ObjCObjectByReference();
- NSObject result = objectForProperty_error(property.getNativeValue(), errorPtr);
- NSError error = errorPtr.getValueAs(NSError.class);
- //objectForProperty:error isn't well documented, so be very conservative
- if ( result != null && !result.id().isNull() && (error == null || error.id().isNull() || error.code().intValue() == 0) ) {
- return result;
- } else {
- throw new IllegalArgumentException("Could not get property: " + property + ", error: " + error.localizedDescription());
- }
- }
-
- /** Set the value of a synthesizer property.
- * @param property the property whose value will be set
- * @param value the value to set
- * @throws IllegalArgumentException if an error occurs while setting the property
- */
- public void setProperty(SpeechProperty property, NSObject value) throws IllegalArgumentException {
- ObjCObjectByReference errorPtr = new ObjCObjectByReference();
- if ( !setObject_forProperty_error(value, property.getNativeValue(), errorPtr) ) {
- NSError error = errorPtr.getValueAs(NSError.class);
- throw new IllegalArgumentException("Could not set property: " + property + " to value " + value + ", error: " + error.localizedDescription());
- }
- }
-
- /** Add a speech dictionary to those in use with this synthesizer
- * @param dictionary the dictionary to add
- */
- public void addSpeechDictionary(NSSpeechDictionary dictionary) {
- addSpeechDictionary(dictionary.getData());
- }
-
-
- /** Describes boundaries between speech units*/
- public static final class NSSpeechBoundary extends NSUInteger {
- private static final long serialVersionUID = 0;
- public static final NSSpeechBoundary ImmediateBoundary = new NSSpeechBoundary(0);
- public static final NSSpeechBoundary WordBoundary = new NSSpeechBoundary(1);
- public static final NSSpeechBoundary SentenceBoundary = new NSSpeechBoundary(2);
- public NSSpeechBoundary() {} //required by the plumbing
- private NSSpeechBoundary(int ordinal) {
- super(ordinal);
- }
- }
-
- /** Get the status of the synthesizer
- * @return the current status of the synthesizer
- */
- public NSSpeechStatus getStatus() {
- return new NSSpeechStatus(Rococoa.cast(getProperty(SpeechProperty.StatusProperty), NSMutableDictionary.class));
- }
-
- //read-only
- /** Describes the current status of the synthesizer*/
- public static class NSSpeechStatus extends AbstractPropertyDictionary {
- public enum StatusProperty implements NativeEnum {
- OutputBusy,
- OutputPaused,
- NumberOfCharactersLeft,
- PhonemeCode;
- private final NSString value = NSString.getGlobalString(NSSpeechStatus.class.getSimpleName() + name());
- public NSString getNativeValue() {
- return value;
- }
- }
-
- public NSSpeechStatus() {
- super(StatusProperty.values().length);
- }
-
- public NSSpeechStatus(final NSMutableDictionary data) {
- super(data);
- }
-
- public boolean isOutputBusy() {
- return getBoolean(StatusProperty.OutputBusy);
- }
-
- public boolean isOutputPaused() {
- return getBoolean(StatusProperty.OutputPaused);
- }
-
- public int getNumberOfCharactersLeft() {
- return getInt(StatusProperty.NumberOfCharactersLeft);
- }
-
- public short getPhonemeCode() {
- return getShort(StatusProperty.PhonemeCode);
- }
- }
-
- /** Get the latest error that occurred in the synthesizer
- * @return the latest error to occur
- */
- public NSSpeechError getError() {
- return new NSSpeechError(Rococoa.cast(getProperty(SpeechProperty.ErrorsProperty), NSMutableDictionary.class));
- }
-
- //read-only
- /** Describes an error that occurred*/
- public static class NSSpeechError extends AbstractPropertyDictionary {
- public enum ErrorProperty implements NativeEnum {
- Count,
- OldestCode,
- OldestCharacterOffset,
- NewestCode,
- NewestCharacterOffset;
- private final NSString value = NSString.getGlobalString(NSSpeechError.class.getSimpleName() + name());
- public NSString getNativeValue() {
- return value;
- }
- }
-
- public NSSpeechError() {
- super(ErrorProperty.values().length);
- }
-
- public NSSpeechError(final NSMutableDictionary data) {
- super(data);
- }
-
- public int getErrorCount() {
- return getInt(ErrorProperty.Count);
- }
-
- public int getOldestCode() {
- return getInt(ErrorProperty.OldestCode);
- }
- public int getOldestCharacterOffset() {
- return getInt(ErrorProperty.OldestCharacterOffset);
- }
- public int getNewestCode() {
- return getInt(ErrorProperty.NewestCode);
- }
- public int getNewestCharacterOffset() {
- return getInt(ErrorProperty.NewestCharacterOffset);
- }
-
- }
-
- /** Describes the modes a synthesizer can operate in.*/
- public enum NSSpeechMode implements NativeEnum {
- Text,
- Phoneme,
- Normal,
- Literal;
- private final NSString value = NSString.getGlobalString(this.getClass().getSimpleName() + name());
- public NSString getNativeValue() {
- return value;
- }
- }
-
- /** Get the current input mode, whether the synthesizer is currently expecting regular text input or raw phonemes.
- * @return either NSSpeechMode.Text
or NSSpeechMode.Phoneme
depending on the current mode
- */
- public NSSpeechMode getInputMode() {
- return NativeEnum.Resolver.fromNative(NSSpeechMode.class, getProperty(SpeechProperty.InputModeProperty));
- }
-
- /** Set the current input mode, whether the synthesizer is currently expecting regular text input or raw phonemes.
- * @param mode either NSSpeechMode.Text
or NSSpeechMode.Phoneme
depending on the desired mode
- */
- public void setInputMode(NSSpeechMode mode) {
- setProperty(SpeechProperty.InputModeProperty, mode.getNativeValue());
- }
-
- /** Get the current character mode, whether the synthesizer is currently speaking strings normally or speaking each character literally.
- * @return either NSSpeechMode.Normal
or NSSpeechMode.Literal
depending on the current mode
- */
- public NSSpeechMode getCharacterMode() {
- return NativeEnum.Resolver.fromNative(NSSpeechMode.class, getProperty(SpeechProperty.CharacterModeProperty));
- }
-
- /** Set the current character mode, whether the synthesizer is currently speaking strings normally or speaking each character literally.
- * @param mode either NSSpeechMode.Normal
or NSSpeechMode.Literal
depending on the desired mode
- */
- public void setCharacterMode(NSSpeechMode mode) {
- setProperty(SpeechProperty.CharacterModeProperty, mode.getNativeValue());
- }
-
- /** Get the current number mode, whether the synthesizer is currently speaking numbers normally or speaking each digit literally.
- * @return either NSSpeechMode.Normal
or NSSpeechMode.Literal
depending on the current mode
- */
- public NSSpeechMode getNumberMode() {
- return NativeEnum.Resolver.fromNative(NSSpeechMode.class, getProperty(SpeechProperty.NumberModeProperty));
- }
-
- /** Set the current number mode, whether the synthesizer is currently speaking numbers normally or speaking each digit literally.
- * @param mode either NSSpeechMode.Normal
or NSSpeechMode.Literal
depending on the desired mode
- */
- public void setNumberMode(NSSpeechMode mode) {
- setProperty(SpeechProperty.NumberModeProperty, mode.getNativeValue());
- }
-
- /** Get identifying information about this synthesizer
- * @return information that identifies this synthesizer
- */
- public NSSpeechSynthesizerInfo getSynthesizerInfo() {
- return new NSSpeechSynthesizerInfo(Rococoa.cast(getProperty(SpeechProperty.SynthesizerInfoProperty), NSMutableDictionary.class));
- }
-
- //read-only
- /** Describes identifying information about the synthesizer*/
- public static class NSSpeechSynthesizerInfo extends AbstractPropertyDictionary {
- public enum SpeechSynthesizerInfoProperty implements NativeEnum {
- Identifier,
- Version;
- private final NSString value = NSString.getGlobalString(NSSpeechSynthesizerInfo.class.getSimpleName() + name());
- public NSString getNativeValue() {
- return value;
- }
- }
- public NSSpeechSynthesizerInfo() {
- super(SpeechSynthesizerInfoProperty.values().length);
- }
- public NSSpeechSynthesizerInfo(final NSMutableDictionary data) {
- super(data);
- }
- public String getSynthesizerIdentifier() {
- return getString(SpeechSynthesizerInfoProperty.Identifier);
- }
- public String getSynthesizerVersion() {
- return getString(SpeechSynthesizerInfoProperty.Version);
- }
- }
-
- /** Get the baseline pitch for the synthesizer
- * @return the baseline pitch
- */
- public float getPitchBase() {
- return Rococoa.cast(getProperty(SpeechProperty.PitchBaseProperty), NSNumber.class).floatValue();
- }
-
- /** Set the baseline pitch for the synthesizer
- * @param baselinePitch the baseline pitch to use
- */
- public void setPitchBase(float baselinePitch) {
- setProperty(SpeechProperty.PitchBaseProperty, NSNumber.CLASS.numberWithFloat(baselinePitch));
- }
-
- /** Get the pitch modulation for the synthesizer
- * @return the pitch modulation
- */
- public float getPitchMod() {
- return Rococoa.cast(getProperty(SpeechProperty.PitchModProperty), NSNumber.class).floatValue();
- }
-
- /** Set the pitch modulation for the synthesizer
- * @param modulation the pitch modulation to use
- */
- public void setPitchMod(float modulation) {
- if ( modulation < 0.0f || modulation > 127.0f) {
- throw new IllegalArgumentException("Pitch modulation must be in the range 0.0 - 127.0");
- }
- setProperty(SpeechProperty.PitchModProperty, NSNumber.CLASS.numberWithFloat(modulation));
- }
-
- /** Get a list of phonemes the synthesizer uses
- * @return information about the phonemes the synthesizer uses
- */
- public List getPhonemeInfo() {
- NSArray infos = Rococoa.cast(getProperty(SpeechProperty.PhonemeSymbolsProperty), NSArray.class);
- List result = new ArrayList(infos.count());
- for(int i=0; i < infos.count(); i++) {
- NSDictionary phonemeInfo = Rococoa.cast(infos.objectAtIndex(i), NSDictionary.class);
- result.add(new NSSpeechPhonemeInfo(NSMutableDictionary.dictionaryWithDictionary(phonemeInfo)));
- }
- return result;
- }
-
- //read-only
- /** Describes information about phonemes the synthesizer uses*/
- public static class NSSpeechPhonemeInfo extends AbstractPropertyDictionary {
- public enum PhonemeInfoProperty implements NativeEnum {
- Opcode,
- Symbol,
- Example,
- HiliteStart,
- HiliteEnd;
- private final NSString value = NSString.getGlobalString(NSSpeechPhonemeInfo.class.getSimpleName() + name());
- public NSString getNativeValue() {
- return value;
- }
- }
-
- public NSSpeechPhonemeInfo() {
- super(PhonemeInfoProperty.values().length);
- }
-
- public NSSpeechPhonemeInfo(final NSMutableDictionary data) {
- super(data);
- }
-
- public short getOpcode() {
- return getShort(PhonemeInfoProperty.Opcode);
- }
-
- public String getSymbol() {
- return getString(PhonemeInfoProperty.Symbol);
- }
-
- public String getExample() {
- return getString(PhonemeInfoProperty.Example);
- }
-
- public int getHiliteStart() {
- return getInt(PhonemeInfoProperty.HiliteStart);
- }
-
- public int getHiliteEnd() {
- return getInt(PhonemeInfoProperty.HiliteEnd);
- }
-
- @Override
- public String toString() {
- return getData().toString();
- }
- }
-
- /** Get the most recent sync point encountered when speaking
- * @return the identifying number of the most recent sync point
- */
- public int getRecentSync() {
- return Rococoa.cast(getProperty(SpeechProperty.RecentSyncProperty), NSNumber.class).intValue();
- }
-
- /** Set the voice to use
- * @param voice the new voice to use
- * @return true if the voice change was successful
- */
- public boolean setVoice(NSVoice voice) {
- //CurrentVocieProperty basically takes a map with 2 keys, creator and id like an old school VoiceSpec spec (see SpeechSynthesis.h)
- //setProperty(SpeechProperty.CurrentVoiceProperty, dictionary of creator and id would go here );
- //this is much less painful - we'd have to call the C API, and why do it the hard way? If someone needs to, they can always
- //call setProperty() for themselves.
- return setVoice(voice.getIdentifier());
- }
-
- /** Get the current voice in use
- * @return the voice in use
- */
- public NSVoice getVoice() {
- return new NSVoice(CLASS.attributesForVoice(voice()));
- }
-
- /** Set the command delimiter to use
- * @param delimiters the delimiters to use when embedding commands in speech
- */
- public void setCommandDelimiter(NSSpeechCommand delimiters) {
- setProperty(SpeechProperty.CommandDelimiterProperty, delimiters.getData());
- }
-
- //write-only
- /** Desribes how to set the delimiters used to embed commands in text to be spoken*/
- public static class NSSpeechCommand extends AbstractPropertyDictionary {
- public enum CommandDelimiterProperty implements NativeEnum{
- Prefix,
- Suffix;
- private final NSString value = NSString.getGlobalString(NSSpeechCommand.class.getSimpleName() + name());
- public NSString getNativeValue() {
- return value;
- }
- }
-
- public NSSpeechCommand() {
- super(CommandDelimiterProperty.values().length);
- }
-
- public NSSpeechCommand(final NSMutableDictionary data) {
- super(data);
- }
-
- public NSSpeechCommand(String prefix, String suffix) {
- this();
- setCommandPrefix(prefix);
- setCommandSuffix(suffix);
- }
-
- public String getCommandPrefix() {
- return getString(CommandDelimiterProperty.Prefix);
- }
- public void setCommandPrefix(String prefix) {
- setString(CommandDelimiterProperty.Prefix, prefix);
- }
-
- public String getCommandSuffix() {
- return getString(CommandDelimiterProperty.Suffix);
- }
- public void setCommandSuffix(String suffix) {
- setString(CommandDelimiterProperty.Suffix, suffix);
- }
- }
-
- /** Reset the synthesizer to the default settings*/
- public void reset() {
- setProperty(SpeechProperty.ResetProperty, null);
- }
- //pass null for computer speakers
- /** Set the synthesizer to send output to a file instead of the default output channel
- * @param uri a file URI to send output to, pass null to switch back to the computer speakers
- */
- public void setOutputToFileURL(URI uri) {
- setProperty(SpeechProperty.OutputToFileURLProperty, uri != null ? NSURL.CLASS.URLWithString(uri.toString()) : null);
- }
-
- /** Speak the given string to a file
- * @param text the text to speak
- * @param uri a file URI indicating where to send output to
- * @return true if the synthesis began successfully
- */
- public boolean startSpeakingStringToURL(String text, URI uri) {
- return startSpeakingString_toURL(NSString.stringWithString(text), NSURL.CLASS.URLWithString(uri.toString()));
- }
-
- //Those methods that will simply be called directly are public, the rest are 'package' - wrapper methods can be found above.
- abstract void addSpeechDictionary(NSDictionary speechDictionary);
- /** Resume speaking if output was paused*/
- public abstract void continueSpeaking();
- abstract ID delegate();
- abstract NSSpeechSynthesizer initWithVoice(String voiceIdentifier);
- /** Determine whether the current application is speaking using the default output channel
- * @return true if the current application is speaking
- */
- public abstract boolean isSpeaking();
- abstract NSObject objectForProperty_error(NSString speechProperty, ObjCObjectByReference out_error);
- abstract boolean setObject_forProperty_error(NSObject object, NSString speechProperty, ObjCObjectByReference out_error);
- /** Pause speech at the indicated boundary
- * @param boundary the place to stop speech
- */
- public abstract void pauseSpeakingAtBoundary(NSSpeechBoundary boundary);
- /** Convert text to phonemes.
- * @param text the text to convert
- * @return the corresponding phonemes
- */
- public abstract String phonemesFromText(String text);
- /** Get the current rate of speech
- * @return the current rate of speech
- */
- public abstract float rate();
- abstract void setDelegate(ID delegate);
- /** Set the current rate of speech
- * @param rate the rate to use
- */
- public abstract void setRate(float rate);
- /** Set whether the feedback window should be used
- * @param useFeedbackWindow pass true to enable the feedback window
- */
- public abstract void setUsesFeedbackWindow(boolean useFeedbackWindow);
- /** Set the voice to use, should be called when the synthesizer is not currently speaking
- * @param voiceIdentifier the identifier of the voice to use
- * @return true if the voice change was successful
- */
- public abstract boolean setVoice(String voiceIdentifier);
- /** Set the volume
- * @param volume the volume to use
- */
- public abstract void setVolume(float volume);
- /** Start speaking the given string through the default system speech channel
- * @param text the text to speak
- * @return true if synthesis starts successfully
- */
- public abstract boolean startSpeakingString(String text);
- abstract boolean startSpeakingString_toURL(NSString text, NSURL url);
- /** Stop this synthesizer from speaking*/
- public abstract void stopSpeaking();
- /** Stop this synthesizer from speaking when it reaches the indicated place.
- * @param boundary the place to stop speaking
- */
- public abstract void stopSpeakingAtBoundary(NSSpeechBoundary boundary);
- /** Get whether the feedback window is enabled
- * @return true if the feedback window is enabled
- */
- public abstract boolean usesFeedbackWindow();
- abstract String voice();
- /** Get the identifier of the current voice
- * @return the identifier of the current voice
- */
- public String getVoiceIdentifier() {
- return voice();
- }
- abstract float volume();
- /** Get the current volume
- * @return the current volume
- */
- public float getVolume() {
- return volume();
- }
-}
diff --git a/rococoa/rococoa-contrib/src/main/java/org/rococoa/contrib/appkit/NSVoice.java b/rococoa/rococoa-contrib/src/main/java/org/rococoa/contrib/appkit/NSVoice.java
deleted file mode 100755
index e88b2097..00000000
--- a/rococoa/rococoa-contrib/src/main/java/org/rococoa/contrib/appkit/NSVoice.java
+++ /dev/null
@@ -1,208 +0,0 @@
-/*
- * Copyright 2007, 2008, 2009 Duncan McGregor
- *
- * This file is part of Rococoa, a library to allow Java to talk to Cocoa.
- *
- * Rococoa is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Rococoa is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Rococoa. If not, see .
- */
-
-package org.rococoa.contrib.appkit;
-
-import org.rococoa.cocoa.foundation.NSArray;
-import org.rococoa.cocoa.foundation.NSDictionary;
-import org.rococoa.cocoa.foundation.NSMutableDictionary;
-import org.rococoa.cocoa.foundation.NSString;
-import org.rococoa.contrib.AbstractPropertyDictionary;
-import org.rococoa.contrib.NativeEnum;
-
-import static org.rococoa.contrib.appkit.NSVoice.VoiceProperty.Age;
-import static org.rococoa.contrib.appkit.NSVoice.VoiceProperty.DemoText;
-import static org.rococoa.contrib.appkit.NSVoice.VoiceProperty.Gender;
-import static org.rococoa.contrib.appkit.NSVoice.VoiceProperty.Identifier;
-import static org.rococoa.contrib.appkit.NSVoice.VoiceProperty.IndividuallySpokenCharacters;
-import static org.rococoa.contrib.appkit.NSVoice.VoiceProperty.Language;
-import static org.rococoa.contrib.appkit.NSVoice.VoiceProperty.LocaleIdentifier;
-import static org.rococoa.contrib.appkit.NSVoice.VoiceProperty.Name;
-import static org.rococoa.contrib.appkit.NSVoice.VoiceProperty.SupportedCharacters;
-
-/** NSVoice encapsulates the properties of a speech synthesis voice, and can be
- * used with NSSpeechSynthesizer to change the voice used to spreak.
- * This class is a Rococoa enhancment designed to make it easier to work with
- * voices, there is no actual class with this name in Cocoa.
- */
-public class NSVoice extends AbstractPropertyDictionary {
- //No way of knowing which voices a user has installed, so just expose the known ids
- public static final String ALEX = "com.apple.speech.synthesis.voice.Alex";
- public static final String ALICE = "com.apple.speech.synthesis.voice.alice";
- public static final String ALVA = "com.apple.speech.synthesis.voice.alva";
- public static final String AMELIE = "com.apple.speech.synthesis.voice.amelie";
- public static final String ANNA = "com.apple.speech.synthesis.voice.anna";
- public static final String CARMIT = "com.apple.speech.synthesis.voice.carmit";
- public static final String DAMAYANTI = "com.apple.speech.synthesis.voice.damayanti";
- public static final String DANIEL = "com.apple.speech.synthesis.voice.daniel";
- public static final String DIEGO = "com.apple.speech.synthesis.voice.diego";
- public static final String ELLEN = "com.apple.speech.synthesis.voice.ellen";
- public static final String FIONA = "com.apple.speech.synthesis.voice.fiona";
- public static final String FRED = "com.apple.speech.synthesis.voice.Fred";
- public static final String IOANA = "com.apple.speech.synthesis.voice.ioana";
- public static final String JOANA = "com.apple.speech.synthesis.voice.joana";
- public static final String JORGE = "com.apple.speech.synthesis.voice.jorge";
- public static final String JUAN = "com.apple.speech.synthesis.voice.juan";
- public static final String KANYA = "com.apple.speech.synthesis.voice.kanya";
- public static final String KAREN = "com.apple.speech.synthesis.voice.karen";
- public static final String KYOKO = "com.apple.speech.synthesis.voice.kyoko.premium";
- public static final String LAURA = "com.apple.speech.synthesis.voice.laura";
- public static final String LEKHA = "com.apple.speech.synthesis.voice.lekha";
- public static final String LUCA = "com.apple.speech.synthesis.voice.luca";
- public static final String LUCIANA = "com.apple.speech.synthesis.voice.luciana";
- public static final String MAGED = "com.apple.speech.synthesis.voice.maged";
- public static final String MARISKA = "com.apple.speech.synthesis.voice.mariska";
- public static final String MEI_JIA = "com.apple.speech.synthesis.voice.mei-jia";
- public static final String MELINA = "com.apple.speech.synthesis.voice.melina";
- public static final String MILENA = "com.apple.speech.synthesis.voice.milena";
- public static final String MOIRA = "com.apple.speech.synthesis.voice.moira";
- public static final String MONICA = "com.apple.speech.synthesis.voice.monica";
- public static final String NORA = "com.apple.speech.synthesis.voice.nora";
- public static final String PAULINA = "com.apple.speech.synthesis.voice.paulina";
- public static final String RISHI = "com.apple.speech.synthesis.voice.rishi";
- public static final String SAMANTHA = "com.apple.speech.synthesis.voice.samantha";
- public static final String SARA = "com.apple.speech.synthesis.voice.sara";
- public static final String SATU = "com.apple.speech.synthesis.voice.satu";
- public static final String SIN_JI = "com.apple.speech.synthesis.voice.sin-ji";
- public static final String TESSA = "com.apple.speech.synthesis.voice.tessa";
- public static final String THOMAS = "com.apple.speech.synthesis.voice.thomas";
- public static final String TING_TING = "com.apple.speech.synthesis.voice.ting-ting";
- public static final String VEENA = "com.apple.speech.synthesis.voice.veena";
- public static final String VICTORIA = "com.apple.speech.synthesis.voice.Victoria";
- public static final String XANDER = "com.apple.speech.synthesis.voice.xander";
- public static final String YELDA = "com.apple.speech.synthesis.voice.yelda";
- public static final String YUNA = "com.apple.speech.synthesis.voice.yuna";
- public static final String YURI = "com.apple.speech.synthesis.voice.yuri";
- public static final String ZOSIA = "com.apple.speech.synthesis.voice.zosia";
- public static final String ZUZANA = "com.apple.speech.synthesis.voice.zuzana";
-
- /** Defines the properties of a voice*/
- public enum VoiceProperty implements NativeEnum {
- Name,
- Identifier,
- Age,
- Gender,
- DemoText,
- LocaleIdentifier,
- SupportedCharacters,
- IndividuallySpokenCharacters,
- Language;
- private final NSString value = NSString.getGlobalString(NSVoice.class.getSimpleName() + name());
- public NSString getNativeValue() {
- return value;
- }
- }
-
- /** Construct a new voice using the given identifier
- * @param voiceIdentifier the voice to lookup
- * @throws IllegalArgumentException if the voice identified by voiceIdentifier
is not installed
- */
- public NSVoice (String voiceIdentifier) throws IllegalArgumentException {
- super(NSMutableDictionary.dictionaryWithDictionary(
- checkData(voiceIdentifier, NSSpeechSynthesizer.CLASS.attributesForVoice(voiceIdentifier))));
- }
-
- NSVoice() {
- super(VoiceProperty.values().length);
- }
-
- NSVoice(final NSMutableDictionary data) {
- super(checkData(null, data));
- }
-
- NSVoice(NSDictionary data) {
- super(checkData(null, data));
- }
-
- private static NSDictionary checkData(String identifier, NSDictionary data) {
- if (data == null || data.count() == 0) {
- throw new IllegalArgumentException("Invalid voice data" +
- identifier == null ? "." : ", unknown identifier: " + identifier );
- } else {
- return data;
- }
- }
-
- public String getName() {
- return getString(Name);
- }
-
- public String getIdentifier() {
- return getString(Identifier);
- }
-
- public int getAge() {
- return getInt(Age);
- }
-
- public VoiceGender getGender() {
- return getEnum(VoiceGender.class, Gender);
- }
-
- public String getDemoText() {
- return getString(DemoText);
- }
-
- public String getLocaleIdentifier() {
- return getString(LocaleIdentifier);
- }
-
- public NSArray getSupportedCharacters() {
- return getValueAsType(SupportedCharacters, NSArray.class);
- }
-
- public NSArray getIndividuallySpokenCharacters() {
- return getValueAsType(IndividuallySpokenCharacters, NSArray.class);
- }
-
- @Deprecated
- public String getLanguage() {
- return getString(Language);
- }
-
- @Override
- public String toString() {
- return "[NSVoice: " + getData() + ']';
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof NSVoice) {
- return getIdentifier().equals(((NSVoice) obj).getIdentifier());
- }
- return false;
- }
-
- @Override
- public int hashCode() {
- return getIdentifier().hashCode();
- }
-
- /** An enumeration representing possible genders for voices*/
- public enum VoiceGender implements NativeEnum {
- Neuter,
- Male,
- Female;
- private final NSString value = NSString.getGlobalString("NS" + getClass().getSimpleName() + name());
- public NSString getNativeValue() {
- return value;
- }
- }
-
-}
diff --git a/rococoa/rococoa-contrib/src/main/java/org/rococoa/contrib/dispatch/GCDExecutorService.java b/rococoa/rococoa-contrib/src/main/java/org/rococoa/contrib/dispatch/GCDExecutorService.java
deleted file mode 100644
index f446c377..00000000
--- a/rococoa/rococoa-contrib/src/main/java/org/rococoa/contrib/dispatch/GCDExecutorService.java
+++ /dev/null
@@ -1,289 +0,0 @@
-/*
- * Copyright 2007, 2008, 2009 Duncan McGregor
- *
- * This file is part of Rococoa, a library to allow Java to talk to Cocoa.
- *
- * Rococoa is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Rococoa is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Rococoa. If not, see .
- */
-
-package org.rococoa.contrib.dispatch;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.AbstractExecutorService;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.FutureTask;
-import java.util.concurrent.RejectedExecutionException;
-import java.util.concurrent.RunnableFuture;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.locks.Condition;
-import java.util.concurrent.locks.ReentrantLock;
-
-import org.rococoa.Foundation;
-import org.rococoa.ID;
-import org.rococoa.ObjCObject;
-import org.rococoa.Rococoa;
-import org.rococoa.Selector;
-import org.rococoa.cocoa.foundation.NSArray;
-import org.rococoa.cocoa.foundation.NSAutoreleasePool;
-import org.rococoa.contrib.appkit.NSInvocationOperation;
-import org.rococoa.contrib.appkit.NSOperation;
-import org.rococoa.contrib.appkit.NSOperationQueue;
-
-/** GCDExecutorService runs tasks by passing them to Grand Central Dispatch.
- * Presently, every GCDExecutorService
creates its own
- * NSOperationQueue
underneath.
- * @author Andrew Thompson (lordpixel@mac.com)
- */
-public class GCDExecutorService extends AbstractExecutorService {
- /**An Object-C selector representing a run() method*/
- private static final Selector RUN_SELECTOR = Foundation.selector("run");
- /**A permission meaning one thread can modify another*/
- private static final RuntimePermission shutdownPerm = new RuntimePermission("modifyThread");
- /**Represents the states this ExecutorService can be in*/
- private enum State { RUNNING, SHUTDOWN, TERMINATED }
- /**The underlying operation queue used to schedule tasks*/
- private final NSOperationQueue queue;
- /**The current state of this ExecutorService*/
- private volatile State state = State.RUNNING;
- /**A lock used to manage the state of the ExecutorService during the shutdown process*/
- private final ReentrantLock shutdownLock = new ReentrantLock();
- /**A signal condition used during the shutdown process*/
- private final Condition shutdownCondition = shutdownLock.newCondition();
- /**A Map used both to retain proxies for running tasks - so they are not collected - and to
- * support the shutdownNow() method*/
- private final Map> tasks = new ConcurrentHashMap>();
-
- /** Construct a new instance of the code ExecutorService
, with its own underlying NSOperationQueue
*/
- public GCDExecutorService() {
- queue = NSOperationQueue.CLASS.alloc().init();
- }
-
- public void shutdown() {
- SecurityManager sm = System.getSecurityManager();
- if ( sm != null ) {
- sm.checkPermission(shutdownPerm);
- }
- try {
- shutdownLock.lock();
- state = State.SHUTDOWN;
- terminateIfDone(queue.operationCount().intValue() == 0);
- } finally {
- shutdownLock.unlock();
- }
- }
-
- public List shutdownNow() {
- SecurityManager sm = System.getSecurityManager();
- if ( sm != null ) {
- sm.checkPermission(shutdownPerm);
- }
- return doWithAutoreleasePool(new Callable>() {
- public List call() {
- try {
- shutdownLock.lock();
- state = State.SHUTDOWN;
- NSArray queuedTasks = queue.operations();
- List result = new ArrayList(queuedTasks.count());
- for (int i = 0; i < queuedTasks.count(); i++) {
- NSOperation o = Rococoa.cast(queuedTasks.objectAtIndex(i), NSOperation.class);
- InvocationFutureTask> task = tasks.get(o.id());
- if ( task != null && !(o.isFinished() || o.isCancelled()) ) {
- result.add(task.getOriginalRunnable());
- }
- }
- queue.cancelAllOperations();
- tasks.clear();
- terminateIfDone(queue.operationCount().intValue() == 0);
- return result;
- } finally {
- shutdownLock.unlock();
- }
- }
- });
- }
-
- public boolean isShutdown() {
- return state != State.RUNNING;
- }
-
- public boolean isTerminated() {
- return state == State.TERMINATED;
- }
-
- public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException {
- long wait = unit.toNanos(timeout);
- shutdownLock.lock();
- try {
- while ( !isTerminated() ) {
- if ( wait <= 0) {
- return false;
- }
- wait = shutdownCondition.awaitNanos(wait);
- terminateIfDone(queue.operationCount().intValue() == 0);
- }
- return true;
- } finally {
- shutdownLock.unlock();
- }
- }
-
- public void execute(Runnable command) {
- if ( command == null ) {
- throw new NullPointerException("Tasks may not be null");
- }
- try {
- shutdownLock.lock();
- if ( state != State.RUNNING ) {
- throw new RejectedExecutionException("Executor is not running");
- } else {
- InvocationFutureTask> task = command instanceof InvocationFutureTask> ?
- (InvocationFutureTask>) command :
- (InvocationFutureTask>) newTaskFor(command, null);
- queue.addOperation(task.getInvocationOperation());
- }
- } finally {
- shutdownLock.unlock();
- }
- }
-
- @Override
- protected RunnableFuture newTaskFor(Runnable runnable, T value) {
- return new InvocationFutureTask(runnable, value);
- }
-
- @Override
- protected RunnableFuture newTaskFor(Callable callable) {
- return super.newTaskFor(callable);
- }
-
- /** A future task that creates an NSInvocationOperation to run the Runnable
- * or Callable it is created with.
- * @param the type of the result of the task
- */
- private class InvocationFutureTask extends FutureTask {
- /** The NSInvocationOperation that will be enqueued and executed*/
- private final NSInvocationOperation invocation;
- /** A reference to the Java proxy object created to allow Objective C
- * to callback methods on this class. It must be held because a crash
- * will occur if the Java proxy is collected and Objective-C attempts
- * to use it.
- */
- private final ObjCObject proxy;
- /**The original runnable submitted by the caller of the ExecutorService, when a method
- * that takes a Runnable is used. Conversely, if a Callable is submitted for execution
- * then this is simply set to this
.
- * This is ultimately for the shutdownNow() method - we try to return the original
- * submitted objects whenever possible.
- */
- private final Runnable originalRunnable;
-
- /** Create an new invocation based future task to run the given Runnable
- * @param r the Runnable
to run
- * @param result the result to return when the Runnable
completes
- */
- public InvocationFutureTask(Runnable r, V result) {
- super(r, result);
- originalRunnable = r;
- proxy = Rococoa.proxy(this);
- invocation = createInvocation(proxy);
- tasks.put(invocation.id(), this);
- }
-
- /** Create an new invocation based future task to run the given Callable
- * @param callable the Callable
to run
- */
- public InvocationFutureTask(Callable callable){
- super(callable);
- originalRunnable = this;
- proxy = Rococoa.proxy(this);
- invocation = createInvocation(proxy);
- tasks.put(invocation.id(), this);
- }
- private NSInvocationOperation createInvocation(final ObjCObject toInvoke) {
- return doWithAutoreleasePool(new Callable () {
- public NSInvocationOperation call() {
- NSInvocationOperation result = NSInvocationOperation.CLASS.alloc();
- //when the NSOperationQueue executes the NSInvocationOperation, run() is
- //called on this object.
- result = result.initWithTarget_selector_object(toInvoke.id(), RUN_SELECTOR, null);
- return result;
- }
- });
- }
- /** Get the NSInvocationOperation
created to run this task.
- * @return the invocation operation that will be used to run this tak
- */
- public NSInvocationOperation getInvocationOperation() {
- return invocation;
- }
- /** Get the original Runnable
used to create this task,
- * will simply return this
if the task was creaed with a
- * Callable
instead.
- * @return the original Runnable
- */
- public Runnable getOriginalRunnable () {
- return originalRunnable;
- }
- @Override
- public void run() {
- try {
- super.run();
- } finally {
- tasks.remove(invocation.id());
- if ( state == GCDExecutorService.State.SHUTDOWN ) {
- //i.e. this is the last item on the queue
- terminateIfDone(queue.operationCount().intValue() <= 1);
- }
- }
- }
- }
-
- /** If the ExecutorService has been shutdown and the work queue is empty,
- * transition to the TERMINATED
state.
- * @param queueEmpty pass true if the queue is currently empty.
- */
- private void terminateIfDone(boolean queueEmpty) {
- try {
- shutdownLock.lock();
- if ( state == State.SHUTDOWN && queueEmpty ) {
- shutdownCondition.signalAll();
- queue.setSuspended(true);
- state = State.TERMINATED;
- }
- } finally {
- shutdownLock.unlock();
- }
- }
-
- /** Perform some code with an autorelease pool in place.
- *
- * @param the type returned when callable
is run
- * @param callable the Callable code to run with a pool in place
- * @return the result of running the Callable
- */
- private static R doWithAutoreleasePool(Callable callable) {
- NSAutoreleasePool pool = null;
- try {
- pool = NSAutoreleasePool.new_();
- return callable.call();
- } catch (Exception e) {
- throw e instanceof RuntimeException ? ((RuntimeException)e) : new RuntimeException(e);
- } finally {
- if ( pool != null ) pool.drain();
- }
- }
-}
diff --git a/rococoa/rococoa-contrib/src/main/java/org/rococoa/contrib/growl/Growl.java b/rococoa/rococoa-contrib/src/main/java/org/rococoa/contrib/growl/Growl.java
deleted file mode 100644
index d7ae5ae4..00000000
--- a/rococoa/rococoa-contrib/src/main/java/org/rococoa/contrib/growl/Growl.java
+++ /dev/null
@@ -1,444 +0,0 @@
-/*
- * Copyright 2007, 2008, 2009 Duncan McGregor
- *
- * This file is part of Rococoa, a library to allow Java to talk to Cocoa.
- *
- * Rococoa is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Rococoa is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Rococoa. If not, see .
- */
-
-package org.rococoa.contrib.growl;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.rococoa.cocoa.NSApplication;
-import org.rococoa.cocoa.NSDistributedNotificationCenter;
-import org.rococoa.cocoa.foundation.NSArray;
-import org.rococoa.cocoa.foundation.NSDictionary;
-import org.rococoa.cocoa.foundation.NSImage;
-import org.rococoa.cocoa.foundation.NSMutableDictionary;
-import org.rococoa.cocoa.foundation.NSNumber;
-import org.rococoa.cocoa.foundation.NSObject;
-import org.rococoa.cocoa.foundation.NSString;
-
-/**
- * A class that encapsulates the work of talking to Growl.
- *
- * @author Karl Adam (original code using CocoaJavaBridge)
- * @author Harald Kuhr (port to Rococoa).
- * @author last modified by $Author: haraldk$
- * @version $Id: Growl.java,v 1.0 Mar 26, 2009 12:24:28 PM haraldk Exp$
- */
-public final class Growl {
- // TODO: Consider allowing Icon/(Buffered)Image to be passed instead of NSImage
- // TODO: Consider using Map instead of NSDictionary
-
- // defines
- /** The name of the growl registration notification for DNC. */
- public static final String GROWL_APP_REGISTRATION = "GrowlApplicationRegistrationNotification";
-
- // Ticket Defines
- /** Ticket key for the application name. */
- public static final String GROWL_APP_NAME = "ApplicationName";
- /** Ticket key for the application icon. */
- public static final String GROWL_APP_ICON = "ApplicationIcon";
- /** Ticket key for the default notifactions. */
- public static final String GROWL_NOTIFICATIONS_DEFAULT = "DefaultNotifications";
- /** Ticket key for all notifactions. */
- public static final String GROWL_NOTIFICATIONS_ALL = "AllNotifications";
-
- // Notification Defines
- /** The name of the growl notification for DNC. */
- public static final String GROWL_NOTIFICATION = "GrowlNotification";
- /** Notification key for the name. */
- public static final String GROWL_NOTIFICATION_NAME = "NotificationName";
- /** Notification key for the title. */
- public static final String GROWL_NOTIFICATION_TITLE = "NotificationTitle";
- /** Notification key for the description. */
- public static final String GROWL_NOTIFICATION_DESCRIPTION = "NotificationDescription";
- /** Notification key for the icon. */
- public static final String GROWL_NOTIFICATION_ICON = "NotificationIcon";
- /** Notification key for the application icon. */
- public static final String GROWL_NOTIFICATION_APP_ICON = "NotificationAppIcon";
- /** Notification key for the sticky flag. */
- public static final String GROWL_NOTIFICATION_STICKY = "NotificationSticky";
- /** Notification key for the identifier. */
- public static final String GROWL_NOTIFICATION_IDENTIFIER = "GrowlNotificationIdentifier";
-
- // Actual instance data
- // We should only register once
- private boolean registered;
- // "Application" Name
- private String appName;
- // "application" Icon
- private NSImage appImage;
- // All notifications
- private List allNotes;
- // Default enabled notifications
- private List defNotes;
-
- // The notification center
- private final NSDistributedNotificationCenter theCenter;
-
- private static NSArray toNSArray(final List strings) {
- if (strings == null) {
- return null;
- }
-
- return toNSArray(strings.toArray(new String[strings.size()]));
- }
-
- private static NSArray toNSArray(final String... strings) {
- if (strings == null) {
- return null;
- }
-
- NSObject[] types = new NSObject[strings.length];
- for (int i = 0; i < strings.length; i++) {
- types[i] = NSString.stringWithString(strings[i]);
-
- }
-
- return NSArray.CLASS.arrayWithObjects(types);
- }
-
-// private static NSDictionary toNSDictionary(final Map, ?> map) {
-// NSDictionary dictionary = NSDictionary.dictionaryWithObjects_forKeys(objects, keys);
-// return dictionary;
-// }
-//
-// private static NSImage toNSImage(final Image image) {
-// return null;
-// }
-
- //************ Constructors **************//
- /**
- * Convenience method to contruct a growl instance, defers to Growl(String
- * inAppName, NSData inImageData, NSArray inAllNotes, NSArray inDefNotes,
- * boolean registerNow) with empty arrays for your notifications.
- *
- * @param inAppName The Name of your "application"
- * @param inImage The NSImage Icon for your Application
- */
- public Growl(String inAppName, NSImage inImage) {
- this(inAppName, inImage, null, null, false);
- }
-
- /**
- * Convenience method to contruct a growl instance, defers to Growl(String
- * inAppName, NSData inImageData, NSArray inAllNotes, NSArray inDefNotes,
- * boolean registerNow) with the arrays passed here and empty Data for the icon.
- *
- * @param inAppName The Name of your "Application"
- * @param inAllNotes A String Array with the name of all your notifications
- * @param inDefNotes A String Array with the na,es of the Notifications on
- * by default
- */
- public Growl(String inAppName, List inAllNotes, List inDefNotes) {
- this(inAppName, null, inAllNotes, inDefNotes, false);
- }
-
- /**
- * Convenience method to contruct a growl instance, defers to Growl(String
- * inAppName, NSData inImageData, NSArray inAllNotes, NSArray inDefNotes,
- * boolean registerNow) with empty arrays for your notifications.
- *
- * @param inAppName The Name of your "Application"
- * @param inImage Your "Application"'s icon, or {@code null} to use your application's default application icon.
- * @param inAllNotes The NSArray of Strings of all your Notifications
- * @param inDefNotes The NSArray of Strings of your default Notifications
- * @param registerNow Since we have all the necessary info we can go ahead
- * and register
- */
- public Growl(String inAppName, NSImage inImage, List inAllNotes, List inDefNotes, boolean registerNow) {
- if (inAppName == null) {
- throw new IllegalArgumentException("Application name may not be null");
- }
-
- appName = inAppName;
- appImage = inImage != null ? inImage : NSApplication.NSApp.applicationIconImage();
-
- setAllowedNotifications(inAllNotes);
- setDefaultNotifications(inDefNotes);
-
- theCenter = NSDistributedNotificationCenter.defaultCenter();
-
- if (registerNow) {
- register();
- }
- }
-
- //************ Commonly Used Methods **************//
-
- // TODO: What's the point of this return value? It's always true...
-
- /**
- * Register all our notifications with Growl, this should only be called once.
- *
- * @return true
.
- */
- public final boolean register() {
- if (!registered) {
- // Construct our dictionary
- // Make the arrays of objects then keys
- NSArray objects = NSArray.CLASS.arrayWithObjects(
- NSString.stringWithString(appName),
- toNSArray(allNotes),
- toNSArray(defNotes),
- appImage != null ? appImage.TIFFRepresentation() : null
- );
-
- NSArray keys = NSArray.CLASS.arrayWithObjects(
- NSString.stringWithString(GROWL_APP_NAME),
- NSString.stringWithString(GROWL_NOTIFICATIONS_ALL),
- NSString.stringWithString(GROWL_NOTIFICATIONS_DEFAULT),
- appImage != null ? NSString.stringWithString(GROWL_APP_ICON) : null
- );
-
- // Make the Dictionary
- NSDictionary regDict = NSDictionary.dictionaryWithObjects_forKeys(objects, keys);
-
- theCenter.postNotification(
- GROWL_APP_REGISTRATION, // notificationName
- null, // anObject
- regDict, // userInfoDictionary
- true // deliverImmediately
- );
-
- registered = true;
- }
-
- return true;
- }
-
- /**
- * The fun part is actually sending those notifications we worked so hard for
- * so here we let growl know about things we think the user would like, and growl
- * decides if that is the case.
- *
- * @param inNotificationName The name of one of the notifications we told growl
- * about.
- * @param inIcon The NSImage for the icon for this notification, can be null
- * @param inTitle The Title of our Notification as Growl will show it
- * @param inDescription The Description of our Notification as Growl will
- * display it
- * @param inExtraInfo Growl is flexible and allows Display Plugins to do as they
- * please with thier own special keys and values, you may use
- * them here. These may be ignored by either the user's
- * preferences or the current Display Plugin. This can be null
- * @param inSticky Whether the Growl notification should be sticky
- * @param inIdentifier Notification identifier for coalescing. This can be null.
- * @throws IllegalArgumentException When a notification is not known
- */
- public void postNotification(String inNotificationName, NSImage inIcon, String inTitle, String inDescription,
- NSDictionary inExtraInfo, boolean inSticky, String inIdentifier) {
- NSMutableDictionary noteDict = NSMutableDictionary.dictionaryWithCapacity(0);
-
- if (!allNotes.contains(inNotificationName)) {
- throw new IllegalArgumentException("Undefined Notification attempted: " + inNotificationName);
- }
-
- noteDict.setValue_forKey(NSString.stringWithString(inNotificationName), GROWL_NOTIFICATION_NAME);
- noteDict.setValue_forKey(inTitle != null ? NSString.stringWithString(inTitle) : null, GROWL_NOTIFICATION_TITLE);
- noteDict.setValue_forKey(inDescription != null ? NSString.stringWithString(inDescription) : null, GROWL_NOTIFICATION_DESCRIPTION);
- noteDict.setValue_forKey(NSString.stringWithString(appName), GROWL_APP_NAME);
- if (inIcon != null) {
- noteDict.setValue_forKey(inIcon.TIFFRepresentation(), GROWL_NOTIFICATION_ICON);
- }
-
- if (inSticky) {
- noteDict.setValue_forKey(NSNumber.CLASS.numberWithInt(1), GROWL_NOTIFICATION_STICKY);
- }
-
- if (inIdentifier != null) {
- noteDict.setValue_forKey(NSString.stringWithString(inIdentifier), GROWL_NOTIFICATION_IDENTIFIER);
- }
-
- if (inExtraInfo != null) {
- noteDict.addEntriesFromDictionary(inExtraInfo);
- }
-
- theCenter.postNotification(GROWL_NOTIFICATION, null, noteDict, true);
- }
-
- /**
- * Convenience method that defers to postNotificationGrowlOf(String inNotificationName,
- * NSData inIconData, String inTitle, String inDescription,
- * NSDictionary inExtraInfo, boolean inSticky, String inIdentifier).
- * This is primarily for compatibility with older code
- *
- * @param inNotificationName The name of one of the notifications we told growl
- * about.
- * @param inIcon The NSData for the icon for this notification, can be null
- * @param inTitle The Title of our Notification as Growl will show it
- * @param inDescription The Description of our Notification as Growl will
- * display it
- * @param inExtraInfo Growl is flexible and allows Display Plugins to do as
- * they please with their own special keys and values, you
- * may use them here. These may be ignored by either the
- * user's preferences or the current Display Plugin. This
- * can be null.
- * @param inSticky Whether the Growl notification should be sticky.
- * @throws IllegalArgumentException When a notification is not known
- */
- public void postNotification(String inNotificationName, NSImage inIcon, String inTitle, String inDescription,
- NSDictionary inExtraInfo, boolean inSticky) {
- postNotification(inNotificationName, inIcon, inTitle, inDescription, inExtraInfo, inSticky, null);
- }
-
-
- /**
- * Convenience method that defers to postNotificationGrowlOf(String inNotificationName,
- * NSData inIconData, String inTitle, String inDescription,
- * NSDictionary inExtraInfo, boolean inSticky, String inIdentifier).
- * This is primarily for compatibility with older code
- *
- * @param inNotificationName The name of one of the notifications we told growl
- * about.
- * @param inIcon The NSData for the icon for this notification, can be null
- * @param inTitle The Title of our Notification as Growl will show it
- * @param inDescription The Description of our Notification as Growl will
- * display it
- * @param inExtraInfo Growl is flexible and allows Display Plugins to do as
- * they please with their own special keys and values, you
- * may use them here. These may be ignored by either the
- * user's preferences or the current Display Plugin. This
- * can be null.
- * @throws IllegalArgumentException When a notification is not known
- */
- public void postNotification(String inNotificationName, NSImage inIcon, String inTitle, String inDescription,
- NSDictionary inExtraInfo) {
- postNotification(inNotificationName, inIcon, inTitle, inDescription, inExtraInfo, false, null);
- }
-
- /**
- * Convenienve method that defers to postNotificationGrowlOf(String inNotificationName,
- * NSData inIconData, String inTitle, String inDescription,
- * NSDictionary inExtraInfo, boolean inSticky, String inIdentifier) with
- * null
passed for icon, extraInfo and identifier arguments
- *
- * @param inNotificationName The name of one of the notifications we told growl
- * about.
- * @param inTitle The Title of our Notification as Growl will show it
- * @param inDescription The Description of our Notification as Growl will
- * display it
- * @throws IllegalArgumentException When a notification is not known
- */
- public void postNotification(String inNotificationName, String inTitle, String inDescription) {
- postNotification(inNotificationName, null, inTitle, inDescription, null, false, null);
- }
-
- /**
- * Convenience method that defers to postNotificationGrowlOf(String inNotificationName,
- * NSData inIconData, String inTitle, String inDescription,
- * NSDictionary inExtraInfo, boolean inSticky)
- * with null
passed for icon and extraInfo arguments.
- *
- * @param inNotificationName The name of one of the notifications we told growl
- * about.
- * @param inTitle The Title of our Notification as Growl will show it
- * @param inDescription The Description of our Notification as Growl will
- * display it
- * @param inSticky Whether our notification should be sticky
- * @throws IllegalArgumentException When a notification is not known
- */
- public void postNotification(String inNotificationName, String inTitle, String inDescription, boolean inSticky) {
- postNotification(inNotificationName, null, inTitle, inDescription, null, inSticky, null);
- }
-
-
- //************ Accessors **************//
-
- /**
- * Accessor for The currently set "Application" Name
- *
- * @return String Application Name
- */
- public String applicationName() {
- return appName;
- }
-
- /**
- * Accessor for the Array of allowed Notifications returned an NSArray
- *
- * @return the array of allowed notifications.
- */
- public List allowedNotifications() {
- return allNotes;
- }
-
- /**
- * Accessor for the Array of default Notifications returned as an NSArray
- *
- * @return the array of default notifications.
- */
- public List defaultNotifications() {
- return defNotes;
- }
-
- //************ Mutators **************//
-
- /**
- * Sets The name of the Application talking to growl
- *
- * @param inAppName The Application Name
- * @throws IllegalStateException if already registered
- */
- public void setApplicationName(final String inAppName) {
- if (registered) {
- throw new IllegalStateException("Already registered");
- }
-
- appName = inAppName;
- }
-
- /**
- * Set the list of allowed Notifications
- *
- * @param inAllNotes The array of allowed Notifications
- * @throws IllegalStateException if already registered
- */
- public void setAllowedNotifications(final List inAllNotes) {
- if (registered) {
- throw new IllegalStateException("Already registered");
- }
-
- allNotes = Collections.unmodifiableList(new ArrayList(inAllNotes));
- }
-
-
- /**
- * Set the list of Default Notfiications
- *
- * @param inDefNotes The default Notifications
- * @throws IllegalArgumentException when an element of the array is not in the
- * allowedNotifications
- * @throws IllegalStateException if already registered
- */
- public void setDefaultNotifications(final List inDefNotes) {
- if (registered) {
- throw new IllegalStateException("Already registered");
- }
-
- for (String inDefNote : inDefNotes) {
- if (!allNotes.contains(inDefNote)) {
- // TODO: This check is not done in the constructor
- throw new IllegalArgumentException("Array Element not in Allowed Notifications");
- }
- }
-
- defNotes = Collections.unmodifiableList(new ArrayList(inDefNotes));
- }
-}
diff --git a/rococoa/rococoa-contrib/src/test/java/org/rococoa/contrib/appkit/NSOperationQueueTest.java b/rococoa/rococoa-contrib/src/test/java/org/rococoa/contrib/appkit/NSOperationQueueTest.java
deleted file mode 100644
index b881dc03..00000000
--- a/rococoa/rococoa-contrib/src/test/java/org/rococoa/contrib/appkit/NSOperationQueueTest.java
+++ /dev/null
@@ -1,200 +0,0 @@
-/*
- * Copyright 2007, 2008, 2009 Duncan McGregor
- *
- * This file is part of Rococoa, a library to allow Java to talk to Cocoa.
- *
- * Rococoa is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Rococoa is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Rococoa. If not, see .
- */
-
-package org.rococoa.contrib.appkit;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.junit.Before;
-import org.junit.Test;
-import org.rococoa.Foundation;
-import org.rococoa.ObjCObject;
-import static org.junit.Assert.*;
-import org.rococoa.Rococoa;
-import org.rococoa.cocoa.foundation.NSArray;
-import org.rococoa.cocoa.foundation.NSInteger;
-import org.rococoa.test.RococoaTestCase;
-
-/** Test case for mapping of NSOperationQueue.
- *
- */
-public class NSOperationQueueTest extends RococoaTestCase {
- NSOperationQueue fixture;
-
- public NSOperationQueueTest() {
- }
-
-
- @Before
- public void setUp() {
- fixture = NSOperationQueue.CLASS.alloc().init();
- }
-
- private static class RunnableHolder {
- final boolean[] results;
- final ObjCObject[] runnables;
- final NSInvocationOperation[] ops;
- public RunnableHolder(int numItems) {
- this.results = new boolean[numItems];
- runnables = new ObjCObject[numItems];
- ops = new NSInvocationOperation[numItems];
- for(int i=0; i < ops.length; i++) {
- final int j = i;
- Runnable r = new Runnable() {
- public void run() {
- synchronized(results) {
- results[j] = true;
- }
- }
- };
- ops[i] = NSInvocationOperation.CLASS.alloc();
- runnables[i] = Rococoa.proxy(r);
- ops[i].initWithTarget_selector_object(runnables[i].id(), Foundation.selector("run"), null);
- }
- }
- public void addOperations(NSOperationQueue queue) {
- for(NSOperation op : ops) {
- queue.addOperation(op);
- }
- }
- public void addOperationsAndWait(NSOperationQueue queue, boolean wait) {
- queue.addOperations_waitUntilFinished(NSArray.CLASS.arrayWithObjects(ops), wait);
- }
- public void checkResults() {
- List incomplete = new ArrayList(results.length);
- synchronized(results) {
- for(int i=0; i < results.length; i++) {
- if (!results[i]) incomplete.add(i);
- }
- }
- assertEquals("Failed for items: " + incomplete, 0, incomplete.size());
- }
- public int firstFailure() {
- synchronized(results) {
- for(int i=0; i < results.length; i++) {
- if (!results[i]) return i;
- }
- return results.length -1;
- }
- }
- }
-
- /**
- * Test of addOperation method, of class NSOperationQueue.
- */
- @Test
- public void testAddOperation() throws InterruptedException {
- RunnableHolder runnables = new RunnableHolder(250);
- runnables.addOperations(fixture);
- fixture.waitUntilAllOperationsAreFinished();
- assertEquals(0, fixture.operationCount().intValue());
- runnables.checkResults();
- }
-
- /**
- * Test of addOperations_waitUntilFinished method, of class NSOperationQueue.
- */
- @Test
- public void testAddOperations_waitUntilFinished() {
- RunnableHolder runnables = new RunnableHolder(250);
- runnables.addOperationsAndWait(fixture, true);
- assertEquals(0, fixture.operationCount().intValue());
- runnables.checkResults();
-
- //without waiting
- runnables = new RunnableHolder(250);
- runnables.addOperationsAndWait(fixture, false);
- fixture.waitUntilAllOperationsAreFinished();
- assertEquals(0, fixture.operationCount().intValue());
- runnables.checkResults();
- }
- /**
- * Test of cancelAllOperations method, of class NSOperationQueue.
- */
- @Test
- public void testCancelAllOperations() {
- int numItems = 250;
- RunnableHolder runnables = new RunnableHolder(numItems);
- runnables.addOperations(fixture);
- fixture.cancelAllOperations();
- fixture.waitUntilAllOperationsAreFinished();
- assertEquals(0, fixture.operationCount().intValue());
- int firstFailure = runnables.firstFailure();
- assertTrue("Not all should pass: " + firstFailure, 0 < firstFailure && firstFailure < numItems );
- assertTrue(runnables.ops[firstFailure].isCancelled()||runnables.ops[firstFailure].isReady());
- }
-
- /**
- * Test of isSuspended method, of class NSOperationQueue.
- */
- @Test
- public void testIsSuspended() {
- assertFalse(fixture.isSuspended());
- fixture.setSuspended(true);
- assertTrue(fixture.isSuspended());
- fixture.setSuspended(false);
- assertFalse(fixture.isSuspended());
- }
-
- /**
- * Test of maxConcurrentOperationCount method, of class NSOperationQueue.
- */
- @Test
- public void testMaxConcurrentOperationCount() {
- assertEquals(NSOperationQueue.NSOperationQueueDefaultMaxConcurrentOperationCount, fixture.maxConcurrentOperationCount().intValue());
- fixture.setMaxConcurrentOperationCount(new NSInteger(5));
- assertEquals(new NSInteger(5), fixture.maxConcurrentOperationCount());
- }
-
- /**
- * Test of name method, of class NSOperationQueue.
- */
- @Test
- public void testName() {
- assertNotSame("foo", fixture.name());
- fixture.setName("foo");
- assertEquals("foo", fixture.name());
- }
-
- /**
- * Test of operationCount method, of class NSOperationQueue.
- */
- @Test
- public void testOperationCount() {
- int numItems = 250;
- RunnableHolder runnables = new RunnableHolder(numItems);
- runnables.addOperations(fixture);
- assertTrue(fixture.operationCount().intValue() > 0);
- fixture.waitUntilAllOperationsAreFinished();
- assertEquals(0, fixture.operationCount().intValue());
- }
-
- /**
- * Test of operations method, of class NSOperationQueue.
- */
- @Test
- public void testOperations() {
- int numItems = 250;
- RunnableHolder runnables = new RunnableHolder(numItems);
- runnables.addOperations(fixture);
- assertTrue("Should have some operations", fixture.operations().count() > 0);
- fixture.waitUntilAllOperationsAreFinished();
- assertTrue("Should have completed all operations", fixture.operations().count() == 0);
- }
-}
\ No newline at end of file
diff --git a/rococoa/rococoa-contrib/src/test/java/org/rococoa/contrib/appkit/NSSpeechSynthesizerTest.java b/rococoa/rococoa-contrib/src/test/java/org/rococoa/contrib/appkit/NSSpeechSynthesizerTest.java
deleted file mode 100644
index b23090ee..00000000
--- a/rococoa/rococoa-contrib/src/test/java/org/rococoa/contrib/appkit/NSSpeechSynthesizerTest.java
+++ /dev/null
@@ -1,583 +0,0 @@
-/*
- * Copyright 2007, 2008, 2009 Duncan McGregor
- *
- * This file is part of Rococoa, a library to allow Java to talk to Cocoa.
- *
- * Rococoa is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Rococoa is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Rococoa. If not, see .
- */
-
-package org.rococoa.contrib.appkit;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.rococoa.cocoa.foundation.NSAutoreleasePool;
-import org.rococoa.cocoa.foundation.NSRange;
-import org.rococoa.contrib.appkit.NSSpeechSynthesizer.NSSpeechStatus;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.util.*;
-
-import static org.junit.Assert.*;
-/**
- * Exercise the speech synthesizer.
- */
-@Ignore
-public class NSSpeechSynthesizerTest {
- private static final int TIME_TO_WAIT = 5000;
- private NSAutoreleasePool pool;
-
- @Before
- public void preSetup() {
- pool = NSAutoreleasePool.new_();
- }
-
- @After
- public void postTeardown() {
- pool.drain();
- }
-
- @Test
- public void testDefaultVoice() {
- assertNotNull(NSSpeechSynthesizer.CLASS.defaultVoice()); //System preference, so no way of knowing actual value
- assertNotNull(NSSpeechSynthesizer.defaultVoice().getName());
- assertNotNull(NSSpeechSynthesizer.synthesizerWithVoice(null));
- assertEquals(NSSpeechSynthesizer.defaultVoice(), NSSpeechSynthesizer.synthesizerWithVoice(null).getVoice());
- }
-
- @Test
- public void testAvailableVoices() {
- assertEquals(NSSpeechSynthesizer.CLASS.availableVoices().count(), NSSpeechSynthesizer.availableVoices().size());
- assertTrue(NSSpeechSynthesizer.availableVoices().size() > 0);
- assertNotNull(NSSpeechSynthesizer.availableVoices().get(0).getName());
- assertTrue(NSSpeechSynthesizer.availableVoices().get(0).getName().length() > 0);
- }
-
- @Test
- public void testAddGetSpeechDictionary() {
- //first, let's teach the synth to talk like its from Newcastle (sort of)
- NSSpeechDictionary dict = new NSSpeechDictionary();
- dict.setLocaleIdentifier(Locale.US);
- Date now = new Date();
- dict.setModificationDate(now);
- assertEquals(Locale.US, dict.getLocaleIdentifier());
- assertEquals(now, dict.getModificationDate());
- dict.addPronounciation(new NSSpeechDictionary.Entry("about", "AXbUWt")); //en_GB_geordie!
- NSSpeechSynthesizer ss = NSSpeechSynthesizer.synthesizerWithVoice(null);
- SynthesizerDelegate sd = new SynthesizerDelegate(ss);
- ss.setDelegate(sd);
- ss.addSpeechDictionary(dict);
- ss.startSpeakingString("about");
- sd.waitForSpeechDone(TIME_TO_WAIT, true);
- String[] expected = new String[]{"%", "AX", "b", "UW", "t", "%"};
- assertEquals(Arrays.asList(expected), sd.getPhonemesSpoken());
-
- //Normally the synth falls into the SQL = 'S' 'Q' 'L' camp
- sd.reset();
- ss.startSpeakingString("SQL");
- sd.waitForSpeechDone(TIME_TO_WAIT, true);
- expected = new String[]{"%", "EH", "s", "k", "y", "UW", "EH", "l", "%"};
- assertEquals(Arrays.asList(expected), sd.getPhonemesSpoken());
-
- //but we can make it say 'sequel' instead...
- dict.setModificationDate(new Date());
- dict.addAbbreviation(new NSSpeechDictionary.Entry("SQL", "sIYkwAXl"));
- ss.addSpeechDictionary(dict);
-
- sd.reset();
- ss.startSpeakingString("SQL");
- sd.waitForSpeechDone(TIME_TO_WAIT, true);
- expected = new String[]{"%", "s", "IY", "k", "w", "AX", "l", "%"};
- assertEquals(Arrays.asList(expected), sd.getPhonemesSpoken());
- }
-
- @Test
- public void testStartSpeakingString() throws InterruptedException {
- NSSpeechSynthesizer ss = NSSpeechSynthesizer.synthesizerWithVoice(null);
- SynthesizerDelegate sd = new SynthesizerDelegate(ss);
- ss.startSpeakingString("Hello world");
- sd.waitForSpeechDone(TIME_TO_WAIT, true);
- }
-
- @Test
- public void testIsSpeaking() throws InterruptedException {
- NSSpeechSynthesizer ss = NSSpeechSynthesizer.synthesizerWithVoice(null);
- SynthesizerDelegate sd = new SynthesizerDelegate(ss);
- assertTrue(!ss.isSpeaking());
- ss.startSpeakingString("Hello world");
- assertTrue(ss.isSpeaking());
- sd.waitForSpeechDone(TIME_TO_WAIT, true);
- }
-
- @Test
- public void testIsAnyApplicationSpeaking() throws InterruptedException {
- NSSpeechSynthesizer ss = NSSpeechSynthesizer.synthesizerWithVoice(null);
- SynthesizerDelegate sd = new SynthesizerDelegate(ss);
- ss.setDelegate(sd);
- assertTrue(!NSSpeechSynthesizer.isAnyApplicationSpeaking());
- ss.startSpeakingString("Hello world");
- assertTrue(NSSpeechSynthesizer.isAnyApplicationSpeaking());
- sd.waitForSpeechDone(TIME_TO_WAIT, true);
- }
-
- @Test
- public void testDidFinishSpeaking() {
- NSSpeechSynthesizer ss = NSSpeechSynthesizer.synthesizerWithVoice(null);
- SynthesizerDelegate sd = new SynthesizerDelegate(ss);
- ss.setDelegate(sd);
- ss.startSpeakingString("hello doctor");
- sd.waitForSpeechDone(TIME_TO_WAIT, true);
- }
-
- @Test
- public void testWillSpeakWord() {
- NSSpeechSynthesizer ss = NSSpeechSynthesizer.synthesizerWithVoice(null);
- SynthesizerDelegate sd = new SynthesizerDelegate(ss);
- ss.setDelegate(sd);
- String toSpeak = "hello doctor name";
- ss.startSpeakingString(toSpeak);
- sd.waitForSpeechDone(5000, true);
- assertEquals(Arrays.asList(toSpeak.split(" ")), sd.getWordsSpoken());
- }
-
- @Test
- public void testWillSpeakPhoneme() {
- NSSpeechSynthesizer ss = NSSpeechSynthesizer.synthesizerWithVoice(null);
- SynthesizerDelegate sd = new SynthesizerDelegate(ss);
- ss.setDelegate(sd);
- String toSpeak = "blue daisy";
- ss.startSpeakingString(toSpeak);
- sd.waitForSpeechDone(TIME_TO_WAIT, true);
- //every so often some of the phonemes get flipped around, which isn't important to this test
- List expected = new ArrayList(Arrays.asList(new String[]{"%", "b", "l", "UW", "d", "EY", "z", "IY", "%"}));
- Collections.sort(expected);
- List actual = new ArrayList(sd.getPhonemesSpoken());
- Collections.sort(actual);
- assertEquals(expected, actual);
- }
-
- @Test
- public void testStopSpeakingAtBoundary() throws InterruptedException {
- NSSpeechSynthesizer ss = NSSpeechSynthesizer.synthesizerWithVoice(null);
- SynthesizerDelegate sd = new SynthesizerDelegate(ss);
- ss.setDelegate(sd);
- String toSpeak = "Hello are you receiving me now? I really hope someone is!";
- ss.startSpeakingString(toSpeak);
- Thread.sleep(50);
- ss.stopSpeakingAtBoundary(NSSpeechSynthesizer.NSSpeechBoundary.WordBoundary);
- sd.waitForSpeechDone(TIME_TO_WAIT, false);
- //don't want test case to be too timing dependent
- assertTrue("Expected less than 3 words but got: " + sd.getWordsSpoken(), sd.getWordsSpoken().size() < 3);
- assertTrue("Expected at least one word but got: " + sd.getWordsSpoken(), sd.getWordsSpoken().size() >= 1);
-
- //near as I can tell, SentenceBoundary just doesn't work!
- sd.reset();
- ss.startSpeakingString(toSpeak);
- sd.waitForNextWord(TIME_TO_WAIT);
- ss.stopSpeakingAtBoundary(NSSpeechSynthesizer.NSSpeechBoundary.SentenceBoundary);
- sd.waitForWord(TIME_TO_WAIT, "now");
- sd.waitForSpeechDone(TIME_TO_WAIT, false);
- assertTrue("Expected 6 word sentence but got: " + sd.getWordsSpoken(), sd.getWordsSpoken().size() == 6);
-
- sd.reset();
- ss.startSpeakingString(toSpeak);
- sd.waitForWord(TIME_TO_WAIT, "are");
- ss.stopSpeakingAtBoundary(NSSpeechSynthesizer.NSSpeechBoundary.ImmediateBoundary);
- sd.waitForSpeechDone(TIME_TO_WAIT, false);
- assertTrue("Expected less than 3 words but got: " + sd.getWordsSpoken(), sd.getWordsSpoken().size() < 3);
- assertTrue("Expected at least one word but got: " + sd.getWordsSpoken(), sd.getWordsSpoken().size() >= 0);
- }
-
- @Test
- public void testGetStatus() {
- NSSpeechSynthesizer ss = NSSpeechSynthesizer.synthesizerWithVoice(null);
- SynthesizerDelegate sd = new SynthesizerDelegate(ss);
- NSSpeechStatus status = ss.getStatus();
- assertEquals(status.isOutputBusy(), ss.isSpeaking());
- assertFalse(status.isOutputPaused());
- assertEquals("Should have no characters left", 0, status.getNumberOfCharactersLeft());
- assertEquals(0, status.getPhonemeCode());
-
- ss.startSpeakingString("Status check");
- status = ss.getStatus();
- assertEquals(status.isOutputBusy(), ss.isSpeaking());
- assertFalse(status.isOutputPaused());
- assertTrue("Should have characters left", status.getNumberOfCharactersLeft() > 0);
- //assertTrue("Opcode should not be zero", status.getPhonemeCode() != 0); always zero... seems to have word granularity
- sd.waitForSpeechDone(TIME_TO_WAIT, true);
- }
-
- @Test
- public void testPauseSpeakingAtBoundary() throws InterruptedException {
- NSSpeechSynthesizer ss = NSSpeechSynthesizer.synthesizerWithVoice(null);
- SynthesizerDelegate sd = new SynthesizerDelegate(ss);
- ss.startSpeakingString("Status check number two");
- sd.waitForNextWord(1000);
- ss.pauseSpeakingAtBoundary(NSSpeechSynthesizer.NSSpeechBoundary.WordBoundary);
- Thread.sleep(1000); //this API is very asynchronous ... need to sleep before polling status
- NSSpeechStatus status = ss.getStatus();
- assertFalse("Output should not be busy", status.isOutputBusy());
- assertTrue("Output should be paused", status.isOutputPaused());
- assertEquals("Check number of characters left failed", 16, status.getNumberOfCharactersLeft());
- ss.continueSpeaking();
- sd.waitForNextWord(2500);
- ss.pauseSpeakingAtBoundary(NSSpeechSynthesizer.NSSpeechBoundary.ImmediateBoundary);
- Thread.sleep(TIME_TO_WAIT);
- status = ss.getStatus();
- assertFalse("Output should not be busy", status.isOutputBusy());
- assertTrue("Output should be paused", status.isOutputPaused());
- assertEquals("Check number of characters left failed", 10, status.getNumberOfCharactersLeft());
- ss.continueSpeaking();
- sd.waitForSpeechDone(TIME_TO_WAIT, true);
- }
-
- @Test
- public void testPauseSpeakingAtSentenceBoundary() throws InterruptedException {
- NSSpeechSynthesizer ss = NSSpeechSynthesizer.synthesizerWithVoice(null);
- SynthesizerDelegate sd = new SynthesizerDelegate(ss);
- ss.startSpeakingString("This is the way the world ends. Not with a bang.");
- sd.waitForNextWord(1000);
- ss.pauseSpeakingAtBoundary(NSSpeechSynthesizer.NSSpeechBoundary.SentenceBoundary);
- sd.waitForWord(10000, "ends"); //this tells you the word is _about_ to be spoken
- Thread.sleep(750); //so we need to wait a bit more
- NSSpeechStatus status = ss.getStatus();
- assertFalse("Output should not be busy", status.isOutputBusy());
- assertTrue("Output should be paused", status.isOutputPaused());
- //often returns 22, which is just before 'ends'. There's a heck of a lag, basically, in the getStatus interface
- assertTrue("Check number of characters left failed", status.getNumberOfCharactersLeft() >= 16);
- ss.continueSpeaking();
- sd.waitForSpeechDone(5000, true);
- }
-
- @Test
- public void testGetError() throws InterruptedException {
- NSSpeechSynthesizer ss = NSSpeechSynthesizer.synthesizerWithVoice(null);
- SynthesizerDelegate sd = new SynthesizerDelegate(ss);
- ss.startSpeakingString("Try this one [[pbas foobar]] two three");
- sd.waitForWord(1000, "three");
- assertTrue("Should have error position", sd.position > 0);
- assertTrue("Should have error message", sd.errorMessage != null);
-
- NSSpeechSynthesizer.NSSpeechError error = ss.getError();
- assertTrue("Should find error", error.getErrorCount() > 0);
- assertTrue("Should have error position", error.getNewestCharacterOffset() > 0);
- assertTrue("Should have error code", error.getNewestCode() != 0);
- sd.waitForSpeechDone(5000, true);
- }
-
- @Test
- public void testInputMode() {
- NSSpeechSynthesizer ss = NSSpeechSynthesizer.synthesizerWithVoice(null);
- assertEquals(NSSpeechSynthesizer.NSSpeechMode.Text, ss.getInputMode());
- ss.setInputMode(NSSpeechSynthesizer.NSSpeechMode.Text);
- assertEquals("Should be text in, phonemes out", "_d1AOg.", ss.phonemesFromText("dog"));
- ss.setInputMode(NSSpeechSynthesizer.NSSpeechMode.Phoneme);
- assertEquals(NSSpeechSynthesizer.NSSpeechMode.Phoneme, ss.getInputMode());
- assertEquals("Should be phonemes in, phonemes out", "_d1AOg.", ss.phonemesFromText("_d1AOg."));
- }
-
- @Test
- public void testCharacterMode() {
- NSSpeechSynthesizer ss = NSSpeechSynthesizer.synthesizerWithVoice(null);
- assertEquals(NSSpeechSynthesizer.NSSpeechMode.Normal, ss.getCharacterMode());
- ss.setCharacterMode(NSSpeechSynthesizer.NSSpeechMode.Normal);
- assertEquals("Should say dog", "_d1AOg.", ss.phonemesFromText("dog"));
- ss.setCharacterMode(NSSpeechSynthesizer.NSSpeechMode.Literal);
- assertEquals(NSSpeechSynthesizer.NSSpeechMode.Literal, ss.getCharacterMode());
- assertEquals("Should say d o g", "_d1IY ~2OW _J1IY.", ss.phonemesFromText("dog"));
- }
-
- @Test
- public void testNumberMode() {
- NSSpeechSynthesizer ss = NSSpeechSynthesizer.synthesizerWithVoice(null);
- assertEquals(NSSpeechSynthesizer.NSSpeechMode.Normal, ss.getNumberMode());
- ss.setNumberMode(NSSpeechSynthesizer.NSSpeechMode.Normal);
- assertEquals("Should say twelve", "_tw1EHlv.", ss.phonemesFromText("12"));
- ss.setNumberMode(NSSpeechSynthesizer.NSSpeechMode.Literal);
- assertEquals(NSSpeechSynthesizer.NSSpeechMode.Literal, ss.getNumberMode());
- assertEquals("Should say one two", "_w1UXn _t1UW.", ss.phonemesFromText("12"));
- }
-
- @Test
- public void testSynthesizerInfo() {
- NSSpeechSynthesizer ss = NSSpeechSynthesizer.synthesizerWithVoice(null);
- NSSpeechSynthesizer.NSSpeechSynthesizerInfo ssi = ss.getSynthesizerInfo();
- assertTrue(ssi.getSynthesizerIdentifier() != null);
- assertTrue(ssi.getSynthesizerVersion() != null);
- }
-
- @Test
- public void testPitchBase() {
- NSSpeechSynthesizer ss = NSSpeechSynthesizer.synthesizerWithVoice(null);
- float pitchBase = ss.getPitchBase();
- assertTrue(pitchBase > 0.0f);
- ss.setPitchBase(pitchBase * 1.5f);
- assertEquals(pitchBase * 1.5f, ss.getPitchBase(), 0.001);
- }
-
- @Test
- public void testPitchMod() {
- NSSpeechSynthesizer ss = NSSpeechSynthesizer.synthesizerWithVoice(null);
- float pitchMod = ss.getPitchMod();
- assertTrue(pitchMod > 0.0f);
- ss.setPitchMod(pitchMod * 0.9f);
- assertEquals(pitchMod * 0.9f, ss.getPitchMod(), 0.001);
- try {
- ss.setPitchMod(-1.0f);
- fail("Should have thrown IllegalArgumentException");
- } catch (IllegalArgumentException iae) {
- }
- try {
- ss.setPitchMod(127.1f);
- fail("Should have thrown IllegalArgumentException");
- } catch (IllegalArgumentException iae) {
- }
- }
-
- @Test
- public void testPhonemeInfo() {
- NSSpeechSynthesizer ss = NSSpeechSynthesizer.synthesizerWithVoice(null);
- List spis = ss.getPhonemeInfo();
- assertTrue(spis.size() > 5);
- NSSpeechSynthesizer.NSSpeechPhonemeInfo spi = spis.get(4);
- assertTrue(spi.getExample() != null);
- assertTrue(spi.getSymbol() != null);
- assertTrue(spi.getHiliteEnd() >= 0);
- assertTrue(spi.getHiliteStart() >= 0);
- assertTrue(spi.getOpcode() != 0);
-
- }
-
- @Test
- public void testRecentSyncAndCallback() throws InterruptedException {
- NSSpeechSynthesizer ss = NSSpeechSynthesizer.synthesizerWithVoice(null);
- SynthesizerDelegate sd = new SynthesizerDelegate(ss);
- ss.startSpeakingString("I see no " + NSSpeechSynthesizer.createSyncPoint('A') + " ships sailing");
- sd.waitForWord(2500, "sailing");
- assertEquals("Should have synch with A", "A", sd.synchMark);
- sd.waitForSpeechDone(3000, true);
- assertEquals("Should be able to get recent sync", 'A', ss.getRecentSync());
- }
-
- @Test
- public void testVoice() {
- NSSpeechSynthesizer ss = NSSpeechSynthesizer.synthesizerWithVoice(null);
- NSVoice defaultVoice = NSSpeechSynthesizer.defaultVoice();
- assertEquals(defaultVoice, ss.getVoice());
- assertEquals(defaultVoice.getIdentifier(), ss.voice());
- ss.setVoice(NSVoice.SAMANTHA);
- assertEquals(NSVoice.SAMANTHA, ss.voice());
- assertEquals(new NSVoice(NSVoice.SAMANTHA), ss.getVoice());
- ss.setVoice(NSVoice.ALEX);
- assertEquals(new NSVoice(NSVoice.ALEX), ss.getVoice());
- ss = NSSpeechSynthesizer.synthesizerWithVoice(new NSVoice(NSVoice.FRED));
- assertEquals(new NSVoice(NSVoice.FRED), ss.getVoice());
- }
-
-
- @Test
- public void testCommandDelimiter() {
- NSSpeechSynthesizer ss = NSSpeechSynthesizer.synthesizerWithVoice(null);
- SynthesizerDelegate sd = new SynthesizerDelegate(ss);
-
- // this raises a question - NSSpeechCommand - should it encapsulate the available commands and
- //offer factory methods? e.g. NSSpeechCommand.createSyncPoint above has a bug, in the sense that it doesn't know what the
- //current delimiters actually are... actually, since there's no API to GET the current delimiters, in the general case it can't
- //work - the caller would always have to pass them in - still could maybe work as a factory still, just more complex
- //something like NSSpeechCommand.createSync(String prefix, String suffix, String syncPoint) ?
-
- ss.setCommandDelimiter(new NSSpeechSynthesizer.NSSpeechCommand("{", "}"));
- ss.startSpeakingString("I see no {sync 0x42} ships sailing");
- sd.waitForWord(2500, "sailing");
- assertEquals("Should have synch with B", "B", sd.synchMark);
- sd.waitForSpeechDone(3000, true);
-
- }
-
- @Test
- public void testReset() {
- NSSpeechSynthesizer ss = NSSpeechSynthesizer.synthesizerWithVoice(null);
- float pitchBase = ss.getPitchBase();
- assertTrue(pitchBase > 0.0f);
- ss.setPitchBase(pitchBase + 1.0f);
- assertEquals(pitchBase + 1.0f, ss.getPitchBase(), 0.001);
- ss.reset();
- assertEquals(pitchBase, ss.getPitchBase(), 0.001);
- }
-
- //pass null for computer speakers
- @Test
- public void testSetOutputToFileURL() throws IOException {
- File helloWorld = null;
- FileInputStream fis = null;
- try {
- helloWorld = File.createTempFile("helloworld", ".aiff");
- helloWorld.deleteOnExit();
- NSSpeechSynthesizer ss = NSSpeechSynthesizer.synthesizerWithVoice(null);
- SynthesizerDelegate sd = new SynthesizerDelegate(ss);
- ss.setOutputToFileURL(helloWorld.toURI());
- ss.startSpeakingString("Hello World");
- sd.waitForSpeechDone(5000, true);
- assertTrue(helloWorld.exists());
- fis = new FileInputStream(helloWorld);
- assertTrue("Should have some bytes", fis.available() > 0);
- } finally {
- if (fis != null) {
- fis.close();
- }
- if (helloWorld != null) {
- helloWorld.delete();
- }
- }
- }
-
- @Test
- public void testStartSpeakingStringToURL() throws IOException {
- File helloWorld = null;
- FileInputStream fis = null;
- try {
- helloWorld = File.createTempFile("helloworld", ".aiff");
- helloWorld.deleteOnExit();
- NSSpeechSynthesizer ss = NSSpeechSynthesizer.synthesizerWithVoice(null);
- SynthesizerDelegate sd = new SynthesizerDelegate(ss);
- ss.startSpeakingStringToURL("Hello World", helloWorld.toURI());
- sd.waitForSpeechDone(5000, true);
- assertTrue(helloWorld.exists());
- fis = new FileInputStream(helloWorld);
- assertTrue("Should have some bytes", fis.available() > 0);
- } finally {
- if (fis != null) {
- fis.close();
- }
- if (helloWorld != null) {
- helloWorld.delete();
- }
- }
- }
-
- private static class SynthesizerDelegate implements NSSpeechSynthesizer.NSSpeechSynthesizerDelegate {
-
- private volatile boolean success = false;
- private List wordsSpoken = new ArrayList();
- private List phonemesSpoken = new ArrayList();
- private String wordWaitingFor;
- private int position = -1;
- private String synchMark;
- private String errorMessage;
- private static final Object speechDoneMonitor = new Object();
- private static final Object waitForSpeechWordMonitor = new Object();
-
- SynthesizerDelegate(NSSpeechSynthesizer ss) {
- ss.setDelegate(this);
- }
-
- public void reset() {
- success = false;
- wordsSpoken.clear();
- phonemesSpoken.clear();
- wordWaitingFor = null;
- position = -1;
- errorMessage = null;
- synchMark = null;
- }
-
- public boolean isSuccess() {
- return success;
- }
-
- public List getWordsSpoken() {
- return wordsSpoken;
- }
-
- public List getPhonemesSpoken() {
- return phonemesSpoken;
- }
-
- public void speechSynthesizer_didFinishSpeaking(NSSpeechSynthesizer sender, final boolean success) {
- this.success = success;
- synchronized (speechDoneMonitor) {
- speechDoneMonitor.notify();
- }
- }
-
- public void waitForSpeechDone(long interval, boolean stoppedNormally) {
- synchronized (speechDoneMonitor) {
- try {
- speechDoneMonitor.wait(interval);
- assertEquals("Success flag check failed", stoppedNormally, isSuccess());
- } catch (InterruptedException ex) {
- fail("Should have been notified in " + getCallerName() + " but interrupted out: " + ex);
- }
- }
- }
-
- public void waitForNextWord(long interval) {
- synchronized (waitForSpeechWordMonitor) {
- try {
- waitForSpeechWordMonitor.wait(interval);
- } catch (InterruptedException ex) {
- fail("Should have been notified in " + getCallerName() + " but interrupted out: " + ex);
- }
- }
- }
-
- public void waitForWord(long interval, final String word) {
- synchronized (waitForSpeechWordMonitor) {
- wordWaitingFor = word;
- try {
- waitForSpeechWordMonitor.wait(interval);
- } catch (InterruptedException ex) {
- fail("Should have been notified in " + getCallerName() + " but interrupted out: " + ex);
- }
- }
- }
-
- private String getCallerName() {
- for (StackTraceElement ste : Thread.currentThread().getStackTrace()) {
- if (ste.getMethodName().startsWith("test")) {
- return ste.getMethodName();
- }
- }
- return "Unknown method";
- }
-
- public void speechSynthesizer_didEncounterErrorAtIndex_ofString_message(NSSpeechSynthesizer sender, Integer characterIndex, String text, String errorMessage) {
- position = characterIndex;
- this.errorMessage = errorMessage;
- //System.out.println(errorMessage);
- //System.out.println("In callback: " + sender.getError());
- }
-
- public void speechSynthesizer_didEncounterSyncMessage(NSSpeechSynthesizer sender, String synchMark) {
- this.synchMark = synchMark;
- // System.out.println("In callback, sync: " + sender.getRecentSync());
- }
-
- public synchronized void speechSynthesizer_willSpeakPhoneme(NSSpeechSynthesizer sender, short phonemeOpcode) {
- phonemesSpoken.add(sender.opcodeToPhoneme(phonemeOpcode));
- }
-
- public void speechSynthesizer_willSpeakWord_ofString(NSSpeechSynthesizer sender, NSRange wordToSpeak, String text) {
- wordsSpoken.add(text.substring((int) wordToSpeak.getLocation(), (int) wordToSpeak.getEndLocation()));
- if (wordWaitingFor == null || wordsSpoken.get(wordsSpoken.size() - 1).equals(wordWaitingFor)) {
- synchronized (waitForSpeechWordMonitor) {
- waitForSpeechWordMonitor.notify();
- }
- }
- }
- }
-}
diff --git a/rococoa/rococoa-contrib/src/test/java/org/rococoa/contrib/appkit/NSVoiceTest.java b/rococoa/rococoa-contrib/src/test/java/org/rococoa/contrib/appkit/NSVoiceTest.java
deleted file mode 100644
index db721086..00000000
--- a/rococoa/rococoa-contrib/src/test/java/org/rococoa/contrib/appkit/NSVoiceTest.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright 2007, 2008, 2009 Duncan McGregor
- *
- * This file is part of Rococoa, a library to allow Java to talk to Cocoa.
- *
- * Rococoa is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Rococoa is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Rococoa. If not, see .
- */
-package org.rococoa.contrib.appkit;
-
-import java.util.Locale;
-
-import org.junit.Ignore;
-import org.junit.Test;
-import org.rococoa.cocoa.foundation.NSArray;
-import org.rococoa.contrib.appkit.NSVoice.VoiceGender;
-import org.rococoa.test.RococoaTestCase;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-/**
- * Simple tests for functionality of the voice class
- */
-public class NSVoiceTest extends RococoaTestCase {
-
- @Test
- @Ignore
- @SuppressWarnings("deprecation")
- public void testAttributesForVoice() {
- NSVoice voice = new NSVoice(NSVoice.VICTORIA);
- assertEquals(35, voice.getAge());
- assertEquals("Isn't it nice to have a computer that will talk to you?", voice.getDemoText());
- assertEquals(VoiceGender.Female, voice.getGender());
- assertEquals(NSVoice.VICTORIA, voice.getIdentifier());
- assertEquals(Locale.US.toString(), voice.getLocaleIdentifier());
- assertEquals("en-US", voice.getLanguage()); //deprecated method, but we test it anyway
- assertEquals("Victoria", voice.getName());
- NSArray supportedChars = voice.getSupportedCharacters();
- assertNotNull(supportedChars);
- assertTrue(supportedChars.count() > 0);
- NSArray individuallySpokenChars = voice.getIndividuallySpokenCharacters();
- assertNotNull(individuallySpokenChars);
- assertTrue(individuallySpokenChars.count() > 0);
- }
-
- @Test(expected=IllegalArgumentException.class)
- @Ignore
- public void testBadIdentifier() {
- String badId = "This voice does not exist";
- try {
- new NSVoice(badId);
- } catch (IllegalArgumentException e) {
- assertTrue(e.getMessage().indexOf(badId) > 0);
- throw e;
- }
- }
-}
diff --git a/rococoa/rococoa-contrib/src/test/java/org/rococoa/contrib/dispatch/GCDExecutorServiceTest.java b/rococoa/rococoa-contrib/src/test/java/org/rococoa/contrib/dispatch/GCDExecutorServiceTest.java
deleted file mode 100644
index 94450dc5..00000000
--- a/rococoa/rococoa-contrib/src/test/java/org/rococoa/contrib/dispatch/GCDExecutorServiceTest.java
+++ /dev/null
@@ -1,187 +0,0 @@
-/*
- * Copyright 2007, 2008, 2009 Duncan McGregor
- *
- * This file is part of Rococoa, a library to allow Java to talk to Cocoa.
- *
- * Rococoa is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Rococoa is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Rococoa. If not, see .
- */
-
-package org.rococoa.contrib.dispatch;
-
-import java.util.List;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Future;
-import java.util.concurrent.RejectedExecutionException;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import static org.junit.Assert.*;
-
-/** Test the API of the GCDExecutorService.
- * @author Andrew Thompson (lordpixel@mac.com)
- */
-public class GCDExecutorServiceTest {
- /**The GCD Executor to test*/
- ExecutorService fixture;
- public GCDExecutorServiceTest() {
- }
-
- @BeforeClass
- public static void setupLogging() {
- }
-
- @Before
- public void setUp() {
- fixture = new GCDExecutorService();
- }
-
- /**
- * Test of shutdown method, of class GCDExecutorService.
- */
- @Test(expected=RejectedExecutionException.class)
- public void testShutdown() {
- fixture.shutdown();
- assertTrue(fixture.isShutdown());
- assertTrue(fixture.isTerminated());
- fixture.execute(new Runnable() {
- public void run() {}
- });
- }
-
- @Test
- public void testShutdown_TasksFinish() throws InterruptedException {
- final boolean[] finished = { false };
- fixture.execute(new Runnable() {
- public void run() {
- finished[0] = true;
- }
- });
- fixture.shutdown();
- assertTrue(fixture.isShutdown());
- Thread.sleep(100);
- List unrun = fixture.shutdownNow();
- assertTrue( finished[0] + ", " + unrun, finished[0] && unrun.size() == 0 );
- }
-
- /**
- * Test of shutdownNow method, of class GCDExecutorService.
- */
- @Test
- public void testShutdownNow() throws InterruptedException {
- Object lock = new Object();
- int count = 100;
- queueUpSomeTasks(lock, count);
- List outstandingTasks = fixture.shutdownNow();
- assertEquals(count, outstandingTasks.size());
- assertTrue(fixture.isShutdown());
- synchronized(lock) {
- lock.notifyAll();
- }
- assertTrue(fixture.awaitTermination(10, TimeUnit.SECONDS));
- }
-
- private void queueUpSomeTasks(final Object lock, int count) {
- for (int i=0; i < count; i++) {
- fixture.execute(new Runnable() {
- public void run() {
- try {
- synchronized(lock) {
- lock.wait();
- }
- } catch (InterruptedException ie) {
-
- }
- }
- });
- }
- }
-
- /**
- * Test of isShutdown method, of class GCDExecutorService.
- */
- @Test
- public void testIsShutdown() {
- fixture.shutdown();
- assertTrue(fixture.isShutdown());
- }
-
- /**
- * Test of awaitTermination method, of class GCDExecutorService.
- */
- @Test
- public void testAwaitTermination() throws Exception {
- int count=100;
- Object lock = new Object();
- queueUpSomeTasks(lock, count);
- List outstandingTasks = fixture.shutdownNow();
- assertEquals(count, outstandingTasks.size());
- assertTrue(fixture.isShutdown());
- synchronized(lock) {
- lock.notifyAll();
- }
- assertTrue(fixture.awaitTermination(5, TimeUnit.SECONDS));
- assertTrue(fixture.isTerminated());
- }
-
- /**
- * Test of execute method, of class GCDExecutorService.
- */
- @Test
- public void testExecute() throws InterruptedException {
- final boolean[] done = { false };
- fixture.execute(new Runnable() {
- public void run() {
- done[0]=true;
- }
- });
- Thread.sleep(1000);
- assertTrue(done[0]);
- }
-
- @Test
- public void testSubmit_Callable() throws InterruptedException, ExecutionException {
- Future result = fixture.submit(new Callable () {
- public Boolean call() {
- return true;
- }
- });
- assertTrue(result.get());
- }
- @Test
- public void testSubmit_Runnable() throws InterruptedException, ExecutionException, TimeoutException {
- final boolean[] runCheck = { false };
- Future> result = fixture.submit(new Runnable () {
- public void run() {
- runCheck[0] = true;
- }
- });
- assertEquals(null, result.get());
- assertTrue(runCheck[0]);
- }
- @Test
- public void testSubmit_Runnable_WithResult() throws InterruptedException, ExecutionException, TimeoutException {
- final boolean[] runCheck = { false };
- Future result = fixture.submit(new Runnable () {
- public void run() {
- runCheck[0] = true;
- }
- }, 42);
- assertEquals(Integer.valueOf(42), result.get());
- assertTrue(runCheck[0]);
- }
-}
diff --git a/rococoa/rococoa-core/dylib/pom.xml b/rococoa/rococoa-core/dylib/pom.xml
deleted file mode 100644
index 17baeac1..00000000
--- a/rococoa/rococoa-core/dylib/pom.xml
+++ /dev/null
@@ -1,86 +0,0 @@
-
-
- 4.0.0
- librococoa
- Rococoa Core Native Library
- https://github.com/iterate-ch/rococoa
-
- org.rococoa
- rococoa-parent
- ../../pom.xml
- 0.10.1-SNAPSHOT
-
-
-
-
- maven-antrun-plugin
-
-
- build-native
- compile
-
- run
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- build-native-clean
- clean
-
- run
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- org.codehaus.mojo
- build-helper-maven-plugin
-
-
- test-compile
-
- attach-artifact
-
-
-
-
- dylib
- ${project.basedir}/../build/Release/librococoa.dylib
-
-
- dylib
- test
- ${project.basedir}/../build/Release/librococoa-test.dylib
-
-
-
-
-
-
-
-
-
diff --git a/rococoa/rococoa-core/pom.xml b/rococoa/rococoa-core/pom.xml
deleted file mode 100644
index f87744b0..00000000
--- a/rococoa/rococoa-core/pom.xml
+++ /dev/null
@@ -1,58 +0,0 @@
-
-
- 4.0.0
- rococoa-core
- jar
- Rococoa Core
- https://github.com/iterate-ch/rococoa
-
- org.rococoa
- rococoa-parent
- 0.10.1-SNAPSHOT
-
-
-
- net.java.dev.jna
- jna
-
-
- net.bytebuddy
- byte-buddy
-
-
- org.rococoa
- librococoa
- dylib
-
-
- org.rococoa
- librococoa
- test
- dylib
- test
-
-
-
-
-
- maven-jar-plugin
-
-
-
- test-jar
-
-
-
-
-
- maven-surefire-plugin
-
- once
-
-
-
- maven-assembly-plugin
-
-
-
-
diff --git a/rococoa/rococoa-core/rococoa.xcodeproj/project.pbxproj b/rococoa/rococoa-core/rococoa.xcodeproj/project.pbxproj
deleted file mode 100644
index 0bf36a3d..00000000
--- a/rococoa/rococoa-core/rococoa.xcodeproj/project.pbxproj
+++ /dev/null
@@ -1,476 +0,0 @@
-// !$*UTF8*$!
-{
- archiveVersion = 1;
- classes = {
- };
- objectVersion = 55;
- objects = {
-
-/* Begin PBXBuildFile section */
- 47E7801E2555A8E400D21DBB /* test.h in Headers */ = {isa = PBXBuildFile; fileRef = AECF4DC90D042C5F00B44D6E /* test.h */; };
- 47E780212555A8E400D21DBB /* test.m in Sources */ = {isa = PBXBuildFile; fileRef = AECF4DCA0D042C5F00B44D6E /* test.m */; };
- 47E780252555A8E400D21DBB /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 08FB779EFE84155DC02AAC07 /* Foundation.framework */; };
- 47E7803A2555A90D00D21DBB /* librococoa-test.dylib in CopyFiles */ = {isa = PBXBuildFile; fileRef = 47E7802B2555A8E400D21DBB /* librococoa-test.dylib */; };
- 47E7803E2555A95C00D21DBB /* librococoa.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = AED079210CEC69DC00542DAC /* librococoa.dylib */; };
- AE1E31B20CFB1D1900508B04 /* ProxyForJava.h in Headers */ = {isa = PBXBuildFile; fileRef = AE1E31AE0CFB1D1900508B04 /* ProxyForJava.h */; };
- AE1E31B30CFB1D1900508B04 /* ProxyForJava.m in Sources */ = {isa = PBXBuildFile; fileRef = AE1E31AF0CFB1D1900508B04 /* ProxyForJava.m */; };
- AEA357FC0CEDFBDF00AE7D09 /* Rococoa.m in Sources */ = {isa = PBXBuildFile; fileRef = AEA357790CECA01400AE7D09 /* Rococoa.m */; };
- AEAEF7770D0EAEE700DA270B /* librococoa.dylib in CopyFiles */ = {isa = PBXBuildFile; fileRef = AED079210CEC69DC00542DAC /* librococoa.dylib */; };
- AED079230CEC6A0A00542DAC /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 08FB779EFE84155DC02AAC07 /* Foundation.framework */; };
-/* End PBXBuildFile section */
-
-/* Begin PBXContainerItemProxy section */
- 47E780382555A8FB00D21DBB /* PBXContainerItemProxy */ = {
- isa = PBXContainerItemProxy;
- containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */;
- proxyType = 1;
- remoteGlobalIDString = AED079200CEC69DC00542DAC;
- remoteInfo = librococoa;
- };
-/* End PBXContainerItemProxy section */
-
-/* Begin PBXCopyFilesBuildPhase section */
- 47E780262555A8E400D21DBB /* CopyFiles */ = {
- isa = PBXCopyFilesBuildPhase;
- buildActionMask = 2147483647;
- dstPath = ../..;
- dstSubfolderSpec = 16;
- files = (
- 47E7803A2555A90D00D21DBB /* librococoa-test.dylib in CopyFiles */,
- );
- runOnlyForDeploymentPostprocessing = 0;
- };
- AEAEF7750D0EAED000DA270B /* CopyFiles */ = {
- isa = PBXCopyFilesBuildPhase;
- buildActionMask = 2147483647;
- dstPath = ../..;
- dstSubfolderSpec = 16;
- files = (
- AEAEF7770D0EAEE700DA270B /* librococoa.dylib in CopyFiles */,
- );
- runOnlyForDeploymentPostprocessing = 0;
- };
-/* End PBXCopyFilesBuildPhase section */
-
-/* Begin PBXFileReference section */
- 08FB779EFE84155DC02AAC07 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = ""; };
- 47E7802B2555A8E400D21DBB /* librococoa-test.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = "librococoa-test.dylib"; sourceTree = BUILT_PRODUCTS_DIR; };
- AE1E31AE0CFB1D1900508B04 /* ProxyForJava.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProxyForJava.h; sourceTree = ""; };
- AE1E31AF0CFB1D1900508B04 /* ProxyForJava.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ProxyForJava.m; sourceTree = ""; };
- AEA357770CECA01400AE7D09 /* scratch.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = scratch.m; sourceTree = ""; };
- AEA357780CECA01400AE7D09 /* Rococoa.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = Rococoa.h; sourceTree = ""; };
- AEA357790CECA01400AE7D09 /* Rococoa.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = Rococoa.m; sourceTree = ""; };
- AECF4DC90D042C5F00B44D6E /* test.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = test.h; sourceTree = ""; };
- AECF4DCA0D042C5F00B44D6E /* test.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = test.m; sourceTree = ""; };
- AED079210CEC69DC00542DAC /* librococoa.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = librococoa.dylib; sourceTree = BUILT_PRODUCTS_DIR; };
- C6859EA3029092ED04C91782 /* rococoa.1 */ = {isa = PBXFileReference; lastKnownFileType = text.man; path = rococoa.1; sourceTree = ""; };
-/* End PBXFileReference section */
-
-/* Begin PBXFrameworksBuildPhase section */
- 47E780242555A8E400D21DBB /* Frameworks */ = {
- isa = PBXFrameworksBuildPhase;
- buildActionMask = 2147483647;
- files = (
- 47E7803E2555A95C00D21DBB /* librococoa.dylib in Frameworks */,
- 47E780252555A8E400D21DBB /* Foundation.framework in Frameworks */,
- );
- runOnlyForDeploymentPostprocessing = 0;
- };
- AED0791F0CEC69DC00542DAC /* Frameworks */ = {
- isa = PBXFrameworksBuildPhase;
- buildActionMask = 2147483647;
- files = (
- AED079230CEC6A0A00542DAC /* Foundation.framework in Frameworks */,
- );
- runOnlyForDeploymentPostprocessing = 0;
- };
-/* End PBXFrameworksBuildPhase section */
-
-/* Begin PBXGroup section */
- 08FB7794FE84155DC02AAC07 /* rococoa */ = {
- isa = PBXGroup;
- children = (
- 08FB7795FE84155DC02AAC07 /* Source */,
- C6859EA2029092E104C91782 /* Documentation */,
- 08FB779DFE84155DC02AAC07 /* External Frameworks and Libraries */,
- 1AB674ADFE9D54B511CA2CBB /* Products */,
- 47E7803D2555A95C00D21DBB /* Frameworks */,
- );
- name = rococoa;
- sourceTree = "";
- };
- 08FB7795FE84155DC02AAC07 /* Source */ = {
- isa = PBXGroup;
- children = (
- AEA357760CECA01400AE7D09 /* native */,
- );
- name = Source;
- sourceTree = "";
- };
- 08FB779DFE84155DC02AAC07 /* External Frameworks and Libraries */ = {
- isa = PBXGroup;
- children = (
- 08FB779EFE84155DC02AAC07 /* Foundation.framework */,
- );
- name = "External Frameworks and Libraries";
- sourceTree = "";
- };
- 1AB674ADFE9D54B511CA2CBB /* Products */ = {
- isa = PBXGroup;
- children = (
- AED079210CEC69DC00542DAC /* librococoa.dylib */,
- 47E7802B2555A8E400D21DBB /* librococoa-test.dylib */,
- );
- name = Products;
- sourceTree = "";
- };
- 47E7803D2555A95C00D21DBB /* Frameworks */ = {
- isa = PBXGroup;
- children = (
- );
- name = Frameworks;
- sourceTree = "";
- };
- AEA357760CECA01400AE7D09 /* native */ = {
- isa = PBXGroup;
- children = (
- AE1E31AE0CFB1D1900508B04 /* ProxyForJava.h */,
- AE1E31AF0CFB1D1900508B04 /* ProxyForJava.m */,
- AECF4DC90D042C5F00B44D6E /* test.h */,
- AECF4DCA0D042C5F00B44D6E /* test.m */,
- AEA357770CECA01400AE7D09 /* scratch.m */,
- AEA357780CECA01400AE7D09 /* Rococoa.h */,
- AEA357790CECA01400AE7D09 /* Rococoa.m */,
- );
- name = native;
- path = src/main/native;
- sourceTree = "";
- };
- C6859EA2029092E104C91782 /* Documentation */ = {
- isa = PBXGroup;
- children = (
- C6859EA3029092ED04C91782 /* rococoa.1 */,
- );
- name = Documentation;
- sourceTree = "";
- };
-/* End PBXGroup section */
-
-/* Begin PBXHeadersBuildPhase section */
- 47E7801D2555A8E400D21DBB /* Headers */ = {
- isa = PBXHeadersBuildPhase;
- buildActionMask = 2147483647;
- files = (
- 47E7801E2555A8E400D21DBB /* test.h in Headers */,
- );
- runOnlyForDeploymentPostprocessing = 0;
- };
- AED0791D0CEC69DC00542DAC /* Headers */ = {
- isa = PBXHeadersBuildPhase;
- buildActionMask = 2147483647;
- files = (
- AE1E31B20CFB1D1900508B04 /* ProxyForJava.h in Headers */,
- );
- runOnlyForDeploymentPostprocessing = 0;
- };
-/* End PBXHeadersBuildPhase section */
-
-/* Begin PBXNativeTarget section */
- 47E7801C2555A8E400D21DBB /* librococoa-test */ = {
- isa = PBXNativeTarget;
- buildConfigurationList = 47E780282555A8E400D21DBB /* Build configuration list for PBXNativeTarget "librococoa-test" */;
- buildPhases = (
- 47E7801D2555A8E400D21DBB /* Headers */,
- 47E780202555A8E400D21DBB /* Sources */,
- 47E780242555A8E400D21DBB /* Frameworks */,
- 47E780262555A8E400D21DBB /* CopyFiles */,
- );
- buildRules = (
- );
- dependencies = (
- 47E780392555A8FB00D21DBB /* PBXTargetDependency */,
- );
- name = "librococoa-test";
- productName = rococoalib;
- productReference = 47E7802B2555A8E400D21DBB /* librococoa-test.dylib */;
- productType = "com.apple.product-type.library.dynamic";
- };
- AED079200CEC69DC00542DAC /* librococoa */ = {
- isa = PBXNativeTarget;
- buildConfigurationList = AED079A10CEC6A3800542DAC /* Build configuration list for PBXNativeTarget "librococoa" */;
- buildPhases = (
- AED0791D0CEC69DC00542DAC /* Headers */,
- AED0791E0CEC69DC00542DAC /* Sources */,
- AED0791F0CEC69DC00542DAC /* Frameworks */,
- AEAEF7750D0EAED000DA270B /* CopyFiles */,
- );
- buildRules = (
- );
- dependencies = (
- );
- name = librococoa;
- productName = rococoalib;
- productReference = AED079210CEC69DC00542DAC /* librococoa.dylib */;
- productType = "com.apple.product-type.library.dynamic";
- };
-/* End PBXNativeTarget section */
-
-/* Begin PBXProject section */
- 08FB7793FE84155DC02AAC07 /* Project object */ = {
- isa = PBXProject;
- attributes = {
- LastUpgradeCheck = 1210;
- };
- buildConfigurationList = 1DEB927808733DD40010E9CD /* Build configuration list for PBXProject "rococoa" */;
- compatibilityVersion = "Xcode 13.0";
- developmentRegion = en;
- hasScannedForEncodings = 1;
- knownRegions = (
- en,
- Base,
- );
- mainGroup = 08FB7794FE84155DC02AAC07 /* rococoa */;
- projectDirPath = "";
- projectRoot = "";
- targets = (
- AED079200CEC69DC00542DAC /* librococoa */,
- 47E7801C2555A8E400D21DBB /* librococoa-test */,
- );
- };
-/* End PBXProject section */
-
-/* Begin PBXSourcesBuildPhase section */
- 47E780202555A8E400D21DBB /* Sources */ = {
- isa = PBXSourcesBuildPhase;
- buildActionMask = 2147483647;
- files = (
- 47E780212555A8E400D21DBB /* test.m in Sources */,
- );
- runOnlyForDeploymentPostprocessing = 0;
- };
- AED0791E0CEC69DC00542DAC /* Sources */ = {
- isa = PBXSourcesBuildPhase;
- buildActionMask = 2147483647;
- files = (
- AEA357FC0CEDFBDF00AE7D09 /* Rococoa.m in Sources */,
- AE1E31B30CFB1D1900508B04 /* ProxyForJava.m in Sources */,
- );
- runOnlyForDeploymentPostprocessing = 0;
- };
-/* End PBXSourcesBuildPhase section */
-
-/* Begin PBXTargetDependency section */
- 47E780392555A8FB00D21DBB /* PBXTargetDependency */ = {
- isa = PBXTargetDependency;
- target = AED079200CEC69DC00542DAC /* librococoa */;
- targetProxy = 47E780382555A8FB00D21DBB /* PBXContainerItemProxy */;
- };
-/* End PBXTargetDependency section */
-
-/* Begin XCBuildConfiguration section */
- 1DEB927908733DD40010E9CD /* Debug */ = {
- isa = XCBuildConfiguration;
- buildSettings = {
- ALWAYS_SEARCH_USER_PATHS = NO;
- CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
- CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
- CLANG_WARN_BOOL_CONVERSION = YES;
- CLANG_WARN_COMMA = YES;
- CLANG_WARN_CONSTANT_CONVERSION = YES;
- CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
- CLANG_WARN_EMPTY_BODY = YES;
- CLANG_WARN_ENUM_CONVERSION = YES;
- CLANG_WARN_INFINITE_RECURSION = YES;
- CLANG_WARN_INT_CONVERSION = YES;
- CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
- CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
- CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
- CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
- CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
- CLANG_WARN_STRICT_PROTOTYPES = YES;
- CLANG_WARN_SUSPICIOUS_MOVE = YES;
- CLANG_WARN_UNREACHABLE_CODE = YES;
- CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
- ENABLE_STRICT_OBJC_MSGSEND = YES;
- ENABLE_TESTABILITY = YES;
- GCC_NO_COMMON_BLOCKS = YES;
- GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
- GCC_WARN_ABOUT_RETURN_TYPE = YES;
- GCC_WARN_UNDECLARED_SELECTOR = YES;
- GCC_WARN_UNINITIALIZED_AUTOS = YES;
- GCC_WARN_UNUSED_FUNCTION = YES;
- GCC_WARN_UNUSED_VARIABLE = YES;
- MACOSX_DEPLOYMENT_TARGET = 10.13;
- ONLY_ACTIVE_ARCH = YES;
- };
- name = Debug;
- };
- 1DEB927A08733DD40010E9CD /* Release */ = {
- isa = XCBuildConfiguration;
- buildSettings = {
- ALWAYS_SEARCH_USER_PATHS = NO;
- CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
- CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
- CLANG_WARN_BOOL_CONVERSION = YES;
- CLANG_WARN_COMMA = YES;
- CLANG_WARN_CONSTANT_CONVERSION = YES;
- CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
- CLANG_WARN_EMPTY_BODY = YES;
- CLANG_WARN_ENUM_CONVERSION = YES;
- CLANG_WARN_INFINITE_RECURSION = YES;
- CLANG_WARN_INT_CONVERSION = YES;
- CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
- CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
- CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
- CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
- CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
- CLANG_WARN_STRICT_PROTOTYPES = YES;
- CLANG_WARN_SUSPICIOUS_MOVE = YES;
- CLANG_WARN_UNREACHABLE_CODE = YES;
- CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
- ENABLE_STRICT_OBJC_MSGSEND = YES;
- GCC_NO_COMMON_BLOCKS = YES;
- GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
- GCC_WARN_ABOUT_RETURN_TYPE = YES;
- GCC_WARN_UNDECLARED_SELECTOR = YES;
- GCC_WARN_UNINITIALIZED_AUTOS = YES;
- GCC_WARN_UNUSED_FUNCTION = YES;
- GCC_WARN_UNUSED_VARIABLE = YES;
- MACOSX_DEPLOYMENT_TARGET = 10.13;
- };
- name = Release;
- };
- 47E780292555A8E400D21DBB /* Debug */ = {
- isa = XCBuildConfiguration;
- buildSettings = {
- CLANG_ENABLE_OBJC_WEAK = YES;
- COPY_PHASE_STRIP = NO;
- DYLIB_COMPATIBILITY_VERSION = 1;
- DYLIB_CURRENT_VERSION = 1;
- GCC_DYNAMIC_NO_PIC = NO;
- GCC_GENERATE_DEBUGGING_SYMBOLS = YES;
- GCC_MODEL_TUNING = G5;
- GCC_OPTIMIZATION_LEVEL = 0;
- GCC_PRECOMPILE_PREFIX_HEADER = YES;
- GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/AppKit.framework/Headers/AppKit.h";
- INSTALL_PATH = /usr/local/lib;
- OTHER_LDFLAGS = (
- "-framework",
- Foundation,
- "-framework",
- AppKit,
- );
- PRODUCT_NAME = "$(TARGET_NAME)";
- ZERO_LINK = YES;
- };
- name = Debug;
- };
- 47E7802A2555A8E400D21DBB /* Release */ = {
- isa = XCBuildConfiguration;
- buildSettings = {
- CLANG_ENABLE_OBJC_WEAK = YES;
- COPY_PHASE_STRIP = YES;
- DYLIB_COMPATIBILITY_VERSION = 1;
- DYLIB_CURRENT_VERSION = 1;
- GCC_DYNAMIC_NO_PIC = NO;
- GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
- GCC_MODEL_TUNING = G5;
- GCC_PRECOMPILE_PREFIX_HEADER = YES;
- GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/AppKit.framework/Headers/AppKit.h";
- INSTALL_PATH = /usr/local/lib;
- OTHER_LDFLAGS = (
- "-framework",
- Foundation,
- "-framework",
- AppKit,
- );
- PRODUCT_NAME = "$(TARGET_NAME)";
- ZERO_LINK = NO;
- };
- name = Release;
- };
- AED079A20CEC6A3800542DAC /* Debug */ = {
- isa = XCBuildConfiguration;
- buildSettings = {
- ALWAYS_SEARCH_USER_PATHS = NO;
- CLANG_ENABLE_OBJC_WEAK = YES;
- COPY_PHASE_STRIP = NO;
- DYLIB_COMPATIBILITY_VERSION = 1;
- DYLIB_CURRENT_VERSION = 1;
- GCC_DYNAMIC_NO_PIC = NO;
- GCC_GENERATE_DEBUGGING_SYMBOLS = YES;
- GCC_MODEL_TUNING = G5;
- GCC_OPTIMIZATION_LEVEL = 0;
- GCC_PRECOMPILE_PREFIX_HEADER = YES;
- GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/AppKit.framework/Headers/AppKit.h";
- INSTALL_PATH = "@loader_path";
- OTHER_LDFLAGS = (
- "-framework",
- Foundation,
- "-framework",
- AppKit,
- );
- PRODUCT_NAME = librococoa;
- ZERO_LINK = YES;
- };
- name = Debug;
- };
- AED079A30CEC6A3800542DAC /* Release */ = {
- isa = XCBuildConfiguration;
- buildSettings = {
- ALWAYS_SEARCH_USER_PATHS = NO;
- CLANG_ENABLE_OBJC_WEAK = YES;
- COPY_PHASE_STRIP = YES;
- DYLIB_COMPATIBILITY_VERSION = 1;
- DYLIB_CURRENT_VERSION = 1;
- GCC_DYNAMIC_NO_PIC = NO;
- GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
- GCC_MODEL_TUNING = G5;
- GCC_PRECOMPILE_PREFIX_HEADER = YES;
- GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/AppKit.framework/Headers/AppKit.h";
- INSTALL_PATH = "@loader_path";
- OTHER_LDFLAGS = (
- "-framework",
- Foundation,
- "-framework",
- AppKit,
- );
- PRODUCT_NAME = librococoa;
- ZERO_LINK = NO;
- };
- name = Release;
- };
-/* End XCBuildConfiguration section */
-
-/* Begin XCConfigurationList section */
- 1DEB927808733DD40010E9CD /* Build configuration list for PBXProject "rococoa" */ = {
- isa = XCConfigurationList;
- buildConfigurations = (
- 1DEB927908733DD40010E9CD /* Debug */,
- 1DEB927A08733DD40010E9CD /* Release */,
- );
- defaultConfigurationIsVisible = 0;
- defaultConfigurationName = Release;
- };
- 47E780282555A8E400D21DBB /* Build configuration list for PBXNativeTarget "librococoa-test" */ = {
- isa = XCConfigurationList;
- buildConfigurations = (
- 47E780292555A8E400D21DBB /* Debug */,
- 47E7802A2555A8E400D21DBB /* Release */,
- );
- defaultConfigurationIsVisible = 0;
- defaultConfigurationName = Release;
- };
- AED079A10CEC6A3800542DAC /* Build configuration list for PBXNativeTarget "librococoa" */ = {
- isa = XCConfigurationList;
- buildConfigurations = (
- AED079A20CEC6A3800542DAC /* Debug */,
- AED079A30CEC6A3800542DAC /* Release */,
- );
- defaultConfigurationIsVisible = 0;
- defaultConfigurationName = Release;
- };
-/* End XCConfigurationList section */
- };
- rootObject = 08FB7793FE84155DC02AAC07 /* Project object */;
-}
diff --git a/rococoa/rococoa-core/src/main/assembly/dist.xml b/rococoa/rococoa-core/src/main/assembly/dist.xml
deleted file mode 100644
index 2e4b10c0..00000000
--- a/rococoa/rococoa-core/src/main/assembly/dist.xml
+++ /dev/null
@@ -1,46 +0,0 @@
-
- src
-
- tar.gz
- zip
-
-
-
- bin
-
- *.dylib
-
-
-
- target
- dist
-
- *.jar
-
-
-
- target
- lib
-
- *.jar
-
-
-
- src
-
-
- src/main/doc
- /
-
- *
-
-
-
-
-
- lib
- false
- runtime
-
-
-
\ No newline at end of file
diff --git a/rococoa/rococoa-core/src/main/java/org/rococoa/AlreadyRetained.java b/rococoa/rococoa-core/src/main/java/org/rococoa/AlreadyRetained.java
deleted file mode 100644
index a9829661..00000000
--- a/rococoa/rococoa-core/src/main/java/org/rococoa/AlreadyRetained.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright 2007, 2008, 2009 Duncan McGregor
- *
- * This file is part of Rococoa, a library to allow Java to talk to Cocoa.
- *
- * Rococoa is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Rococoa is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Rococoa. If not, see .
- */
-
-package org.rococoa;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.METHOD)
-public @interface AlreadyRetained {
-}
diff --git a/rococoa/rococoa-core/src/main/java/org/rococoa/Foundation.java b/rococoa/rococoa-core/src/main/java/org/rococoa/Foundation.java
deleted file mode 100644
index 5d373854..00000000
--- a/rococoa/rococoa-core/src/main/java/org/rococoa/Foundation.java
+++ /dev/null
@@ -1,284 +0,0 @@
-/*
- * Copyright 2007, 2008 Duncan McGregor
- *
- * This file is part of Rococoa, a library to allow Java to talk to Cocoa.
- *
- * Rococoa is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Rococoa is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Rococoa. If not, see .
- */
-
-package org.rococoa;
-
-import com.sun.jna.Library;
-import com.sun.jna.Native;
-import org.rococoa.cocoa.CFIndex;
-import org.rococoa.internal.*;
-
-import java.lang.reflect.Method;
-import java.nio.charset.StandardCharsets;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.Callable;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-
-/**
- * The core of Rococoa - statics to handle selectors and messaging at a function call level.
- *
- * Marshalling of Java types to C types is handled by JNA. Marshalling of Java
- * type to Objective-C types is handled by RococoaTypeMapper.
- *
- * Not to be confused with the Mac Foundation or Core Foundation frameworks, most
- * users shouldn't need to access this class directly.
- *
- * @author duncan
- */
-public abstract class Foundation {
-
- private static final Logger logging = Logger.getLogger("org.rococoa.foundation");
-
- private static final FoundationLibrary foundationLibrary;
- private static final MsgSendLibrary messageSendLibrary;
- private static final RococoaLibrary rococoaLibrary;
-
- private static final Map selectorCache = new HashMap<>();
-
- static {
- logging.finest("Initializing Foundation");
-
- // Set JNA to convert java.lang.String to char* using UTF-8, and match that with
- // the way we tell CF to interpret our char*
- // May be removed if we use toStringViaUTF16
- System.setProperty("jna.encoding", "UTF8");
-
- Map messageSendLibraryOptions = new HashMap<>(1);
- messageSendLibraryOptions.put(Library.OPTION_INVOCATION_MAPPER, new MsgSendInvocationMapper());
- messageSendLibrary = Native.load("Foundation", MsgSendLibrary.class, messageSendLibraryOptions);
-
- foundationLibrary = Native.load("Foundation", FoundationLibrary.class);
- rococoaLibrary = Native.load("rococoa", RococoaLibrary.class);
- logging.finest("exit initializing Foundation");
- }
-
- private Foundation() {
- //
- }
-
- public static void nsLog(String format, Object thing) {
- ID formatAsCFString = cfString(format);
- try {
- foundationLibrary.NSLog(formatAsCFString, thing);
- } finally {
- cfRelease(formatAsCFString);
- }
- }
-
- /**
- * Return a CFString as an ID, toll-free bridged to NSString.
- *
- * Note that the returned string must be freed with {@link #cfRelease(ID)}.
- */
- public static ID cfString(String s) {
- // Use a byte[] rather than letting jna do the String -> char* marshalling itself.
- // Turns out about 10% quicker for long strings.
- byte[] utf16Bytes = s.getBytes(StandardCharsets.UTF_16LE);
- return foundationLibrary.CFStringCreateWithBytes(null, utf16Bytes,
- utf16Bytes.length,
- StringEncoding.kCFStringEncodingUTF16LE.value, (byte) 0);
- }
-
- /**
- * Retain the NSObject with id
- */
- public static ID cfRetain(ID id) {
- if (logging.isLoggable(Level.FINEST)) {
- logging.finest(String.format("calling cfRetain(%s)", id));
- }
- return foundationLibrary.CFRetain(id);
- }
-
- /**
- * Release the NSObject with id
- */
- public static void cfRelease(ID id) {
- if (logging.isLoggable(Level.FINEST)) {
- logging.finest(String.format("calling cfRelease(%s)", id));
- }
- foundationLibrary.CFRelease(id);
- }
-
- public static CFIndex cfGetRetainCount(ID cfTypeRef) {
- return foundationLibrary.CFGetRetainCount(cfTypeRef);
- }
-
- public static String toString(ID cfString) {
- return toStringViaUTF8(cfString);
- }
-
- /* Experimental */
- static String toStringViaUTF16(ID cfString) {
- int lengthInChars = foundationLibrary.CFStringGetLength(cfString);
- int potentialLengthInBytes = 3 * lengthInChars + 1; // UTF16 fully escaped 16 bit chars, plus nul
-
- byte[] buffer = new byte[potentialLengthInBytes];
- byte ok = foundationLibrary.CFStringGetCString(cfString, buffer, buffer.length, StringEncoding.kCFStringEncodingUTF16LE.value);
- if (ok == 0) {
- throw new RococoaException("Could not convert string");
- }
- return new String(buffer, StandardCharsets.UTF_16LE).substring(0, lengthInChars);
- }
-
- static String toStringViaUTF8(ID cfString) {
- int lengthInChars = foundationLibrary.CFStringGetLength(cfString);
- int potentialLengthInBytes = 3 * lengthInChars + 1; // UTF8 fully escaped 16 bit chars, plus nul
-
- byte[] buffer = new byte[potentialLengthInBytes];
- byte ok = foundationLibrary.CFStringGetCString(cfString, buffer, buffer.length, StringEncoding.kCFStringEncodingUTF8.value);
- if (ok == 0) {
- throw new RococoaException("Could not convert string");
- }
- return Native.toString(buffer);
- }
-
- /**
- * Get the ID of the NSClass with className
- */
- public static ID getClass(String className) {
- if (logging.isLoggable(Level.FINEST)) {
- logging.finest(String.format("calling objc_getClass(%s)", className));
- }
- ID classID = foundationLibrary.objc_getClass(className);
- if (classID.isNull()) {
- throw new RococoaException(new ClassNotFoundException(className));
- }
- return classID;
- }
-
- public static Selector selector(String selectorName) {
- Selector cached = selectorCache.get(selectorName);
- if (cached != null) {
- return cached;
- }
- Selector result = foundationLibrary.sel_registerName(selectorName).initName(selectorName);
- selectorCache.put(selectorName, result);
- return result;
- }
-
- @SuppressWarnings("unchecked")
- public static T send(ID receiver, String selectorName, Class returnType, Object... args) {
- return send(receiver, selectorName, returnType, null, args);
- }
-
- @SuppressWarnings("unchecked")
- public static T send(ID receiver, String selectorName, Class returnType, Method method, Object... args) {
- return send(receiver, selector(selectorName), returnType, method, args);
- }
-
- @SuppressWarnings("unchecked")
- public static T send(ID receiver, Selector selector, Class returnType, Object... args) {
- return send(receiver, selector, returnType, null, args);
- }
-
- /**
- * Send message with selector to receiver, passing args, expecting returnType.
- *
- * Note that you are responsible for memory management if returnType is ID.
- *
- * @param returnType Expected return type mapping
- * @param method Used to determine if variadic function call is required
- * @param args Arguments including ID and selector
- */
- @SuppressWarnings("unchecked")
- public static T send(ID receiver, Selector selector, Class returnType, Method method, Object... args) {
- if (logging.isLoggable(Level.FINEST)) {
- logging.finest(String.format("sending (%s) %s.%s(%s)",
- returnType.getSimpleName(), receiver, selector.getName(), new VarArgsUnpacker(args)));
- }
- if (method != null && method.isVarArgs()) {
- return (T) messageSendLibrary.syntheticSendVarArgsMessage(returnType, receiver, selector, args);
- }
- return (T) messageSendLibrary.syntheticSendMessage(returnType, receiver, selector, args);
- }
-
- /**
- * Convenience as this happens a lot in tests.
- *
- * Note that you are responsible for memory management for the returned ID
- */
- public static ID sendReturnsID(ID receiver, String selectorName, Object... args) {
- return send(receiver, selector(selectorName), ID.class, args);
- }
-
- /**
- * Convenience as this happens a lot in tests.
- */
- public static void sendReturnsVoid(ID receiver, String selectorName, Object... args) {
- send(receiver, selector(selectorName), void.class, args);
- }
-
- public static boolean isMainThread() {
- return MainThreadUtils.isMainThread();
- }
-
- /**
- * Return the result of calling callable on the main Cococoa thread.
- */
- public static T callOnMainThread(final Callable callable) {
- return MainThreadUtils.callOnMainThread(rococoaLibrary, callable);
- }
-
- /**
- * Run runnable on the main Cococoa thread, waiting for completion.
- */
- public static void runOnMainThread(final Runnable runnable) {
- MainThreadUtils.runOnMainThread(rococoaLibrary, runnable, true);
- }
-
- /**
- * Run runnable on the main Cococoa thread, optionally waiting for completion.
- */
- public static void runOnMainThread(Runnable runnable, boolean waitUntilDone) {
- MainThreadUtils.runOnMainThread(rococoaLibrary, runnable, waitUntilDone);
- }
-
- /**
- * Create an Objective-C object which delegates to callbacks when methods
- * are invoked on it.
- *
- * Object is created with alloc, so is owned by the caller.
- */
- public static ID newOCProxy(OCInvocationCallbacks callbacks) {
- return rococoaLibrary.proxyForJavaObject(
- callbacks.selectorInvokedCallback,
- callbacks.methodSignatureCallback);
- }
-
- public static boolean selectorNameMeansWeOwnReturnedObject(String selectorName) {
- // From Memory Management Programming Guide for Cocoa
- // This is the fundamental rule:
- // You take ownership of an object if you create it using a method whose
- // name begins with 'alloc' or 'new' or contains 'copy' (for example,
- // alloc, newObject, or mutableCopy), or if you send it a retain
- // message. You are responsible for relinquishing ownership of objects
- // you own using release or autorelease. Any other time you receive an
- // object, you must not release it.
-
- // Note that this does not appear to be an infallible rule - see
- // https://rococoa.dev.java.net/servlets/ReadMsg?list=dev&msgNo=71
- return selectorName.startsWith("alloc") ||
- selectorName.startsWith("new") ||
- selectorName.toLowerCase().contains("copy");
- }
-
-}
diff --git a/rococoa/rococoa-core/src/main/java/org/rococoa/ID.java b/rococoa/rococoa-core/src/main/java/org/rococoa/ID.java
deleted file mode 100644
index 611bcd03..00000000
--- a/rococoa/rococoa-core/src/main/java/org/rococoa/ID.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright 2007, 2008 Duncan McGregor
- *
- * This file is part of Rococoa, a library to allow Java to talk to Cocoa.
- *
- * Rococoa is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Rococoa is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Rococoa. If not, see .
- */
-
-package org.rococoa;
-
-import com.sun.jna.Native;
-import com.sun.jna.NativeLibrary;
-import com.sun.jna.NativeLong;
-
-
-/**
- * Represents an Objective-C ID.
- *
- * This extends NativeLong for efficiency, but you should really think of it
- * as opaque.
- *
- * Technically, this should be {@link Native#POINTER_SIZE} not {@link Native#LONG_SIZE},
- * but as they are both 32 on 32-bit and 64 on 64-bit we'll gloss over that. Ideally
- * it would be Pointer, but they have no protected constructors.
- *
- */
-public class ID extends NativeLong {
-
- public static ID fromLong(long value) {
- return new ID(value);
- }
-
- // Public for JNA
- public ID() {
- super();
- };
-
- protected ID(long value) {
- super(value);
- }
-
- protected ID(ID anotherID) {
- this(anotherID.longValue());
- }
-
- @Override
- public String toString() {
- return String.format("[ID 0x%x]", longValue()); //$NON-NLS-1$
- }
-
- public boolean isNull() {
- return longValue() == 0;
- }
-
- public static ID getGlobal(String libraryName, String globalVarName) {
- return new ID(NativeLibrary.getInstance(libraryName).getGlobalVariableAddress(globalVarName).getNativeLong(0).longValue());
- }
-}
diff --git a/rococoa/rococoa-core/src/main/java/org/rococoa/IDByReference.java b/rococoa/rococoa-core/src/main/java/org/rococoa/IDByReference.java
deleted file mode 100644
index 01ce82a0..00000000
--- a/rococoa/rococoa-core/src/main/java/org/rococoa/IDByReference.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright 2007, 2008 Duncan McGregor
- *
- * This file is part of Rococoa, a library to allow Java to talk to Cocoa.
- *
- * Rococoa is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Rococoa is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Rococoa. If not, see .
- */
-
-package org.rococoa;
-
-import com.sun.jna.NativeLong;
-import com.sun.jna.ptr.ByReference;
-
-/**
- * Used when we need to pass an ID to be filled in by called code.
- *
- */
-public class IDByReference extends ByReference {
-
- public IDByReference() {
- this(ID.fromLong(0));
- }
-
- public IDByReference(ID value) {
- super(NativeLong.SIZE);
- setValue(value);
- }
-
- public void setValue(ID value) {
- getPointer().setNativeLong(0, value);
- }
-
- public ID getValue() {
- return ID.fromLong(getPointer().getNativeLong(0).longValue());
- }
-}
-
diff --git a/rococoa/rococoa-core/src/main/java/org/rococoa/ObjCClass.java b/rococoa/rococoa-core/src/main/java/org/rococoa/ObjCClass.java
deleted file mode 100644
index 137bcb04..00000000
--- a/rococoa/rococoa-core/src/main/java/org/rococoa/ObjCClass.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright 2007, 2008 Duncan McGregor
- *
- * This file is part of Rococoa, a library to allow Java to talk to Cocoa.
- *
- * Rococoa is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Rococoa is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Rococoa. If not, see .
- */
-
-package org.rococoa;
-
-
-
-/**
- * Marker interface that an OCObject represents a Class.
- *
- * Note that in Objective-C Class is a struct, so there are no methods to call.
- *
- * @author duncan
- *
- */
-public interface ObjCClass extends ObjCObject {
-
- public static final _Class CLASS = new _Class();
-
- public static class _Class {
- public ObjCClass classWithName(String className) {
- return Rococoa.createClass(className, ObjCClass.class);
- }
- }
-
-}
diff --git a/rococoa/rococoa-core/src/main/java/org/rococoa/ObjCObject.java b/rococoa/rococoa-core/src/main/java/org/rococoa/ObjCObject.java
deleted file mode 100644
index 6c61bf8a..00000000
--- a/rococoa/rococoa-core/src/main/java/org/rococoa/ObjCObject.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright 2007, 2008 Duncan McGregor
- *
- * This file is part of Rococoa, a library to allow Java to talk to Cocoa.
- *
- * Rococoa is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Rococoa is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Rococoa. If not, see .
- */
-
-package org.rococoa;
-
-public interface ObjCObject {
-
- ID id();
-
-}
diff --git a/rococoa/rococoa-core/src/main/java/org/rococoa/ObjCObjectByReference.java b/rococoa/rococoa-core/src/main/java/org/rococoa/ObjCObjectByReference.java
deleted file mode 100644
index dd50cc78..00000000
--- a/rococoa/rococoa-core/src/main/java/org/rococoa/ObjCObjectByReference.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright 2007, 2008 Duncan McGregor
- *
- * This file is part of Rococoa, a library to allow Java to talk to Cocoa.
- *
- * Rococoa is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Rococoa is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Rococoa. If not, see .
- */
-
-package org.rococoa;
-
-import com.sun.jna.NativeLong;
-import com.sun.jna.ptr.ByReference;
-
-/**
- * Used to retrieve an NSObject as an out param.
- *
- * @author duncan
- *
- */
-public class ObjCObjectByReference extends ByReference {
-
- private ObjCObject object;
-
- public ObjCObjectByReference() {
- super(NativeLong.SIZE);
- }
-
- public T getValueAs(Class javaClass) {
- return Rococoa.cast(object, javaClass);
- }
-
- public void setObject(ObjCObject object) {
- this.object = object;
- }
-}
diff --git a/rococoa/rococoa-core/src/main/java/org/rococoa/ReleaseInFinalize.java b/rococoa/rococoa-core/src/main/java/org/rococoa/ReleaseInFinalize.java
deleted file mode 100644
index 8fc06e10..00000000
--- a/rococoa/rococoa-core/src/main/java/org/rococoa/ReleaseInFinalize.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright 2007, 2008 Duncan McGregor
- *
- * This file is part of Rococoa, a library to allow Java to talk to Cocoa.
- *
- * Rococoa is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Rococoa is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Rococoa. If not, see .
- */
-
-package org.rococoa;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Marker to allow us to disable CFRelease'ing an id when its Java proxy is finalized.
- *
- * Only NSAutoreleasePool applies at the time of writing.
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.TYPE)
-public @interface ReleaseInFinalize {
- boolean value();
-}
diff --git a/rococoa/rococoa-core/src/main/java/org/rococoa/ReturnType.java b/rococoa/rococoa-core/src/main/java/org/rococoa/ReturnType.java
deleted file mode 100644
index c168df7b..00000000
--- a/rococoa/rococoa-core/src/main/java/org/rococoa/ReturnType.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright 2007, 2008 Duncan McGregor
- *
- * This file is part of Rococoa, a library to allow Java to talk to Cocoa.
- *
- * Rococoa is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Rococoa is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Rococoa. If not, see .
- */
-
-package org.rococoa;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Annotation to specify or disambiguate the return type of a method.
- *
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.METHOD)
-public @interface ReturnType {
-
- Class> value();
-
-}
diff --git a/rococoa/rococoa-core/src/main/java/org/rococoa/Rococoa.java b/rococoa/rococoa-core/src/main/java/org/rococoa/Rococoa.java
deleted file mode 100644
index e7281b96..00000000
--- a/rococoa/rococoa-core/src/main/java/org/rococoa/Rococoa.java
+++ /dev/null
@@ -1,250 +0,0 @@
-/*
- * Copyright 2007, 2008 Duncan McGregor
- *
- * This file is part of Rococoa, a library to allow Java to talk to Cocoa.
- *
- * Rococoa is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Rococoa is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Rococoa. If not, see .
- */
-
-package org.rococoa;
-
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-
-import net.bytebuddy.ByteBuddy;
-import net.bytebuddy.TypeCache;
-import net.bytebuddy.description.modifier.Visibility;
-import net.bytebuddy.dynamic.scaffold.subclass.ConstructorStrategy;
-import net.bytebuddy.implementation.InvocationHandlerAdapter;
-import org.rococoa.cocoa.CFIndex;
-import org.rococoa.internal.*;
-
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import static net.bytebuddy.implementation.FieldAccessor.*;
-import static net.bytebuddy.implementation.MethodCall.*;
-import static net.bytebuddy.matcher.ElementMatchers.*;
-
-/**
- * Static factory for creating Java wrappers for Objective-C instances, and Objective-C
- * wrappers for Java instances. START HERE.
- *
- * @author duncan
- *
- */
-public abstract class Rococoa {
-
- private static final Logger logging = Logger.getLogger("org.rococoa.proxy");
-
- /**
- * Create a Java NSClass representing the Objective-C class with ocClassName
- */
- public static T createClass(String ocClassName, Class type) {
- return wrap(Foundation.getClass(ocClassName), type, false);
- }
-
- /**
- * Create a Java NSObject representing an instance of the Objective-C class
- * ocClassName. The Objective-C instance is created by calling the static
- * factory method named ocMethodName, passing args.
- */
- public static T create(String ocClassName, Class javaClass, String ocMethodName, Object... args) {
- return create(ocClassName, javaClass, null, ocMethodName, args);
- }
-
- public static T create(String ocClassName, Class javaClass, Method method, String ocMethodName, Object... args) {
- boolean weOwnObject = Foundation.selectorNameMeansWeOwnReturnedObject(ocMethodName);
-
- // If we don't own the object we know that it has been autorelease'd
- // But we need to own these objects, so that they are not dealloc'd when
- // the pool is release'd. So we retain them.
- // Objects that we own (because they were created with 'alloc' or 'new')
- // have not been autorelease'd, so we don't retain them.
- boolean retain = !weOwnObject;
- return create(ocClassName, javaClass, method, ocMethodName, retain, args);
- }
-
- /**
- * Create a Java NSObject representing an instance of the Objective-C class
- * ocClassName, created with the class method +new
.
- */
- public static T create(String ocClassName, Class javaClass) {
- return create(ocClassName, javaClass, "new");
- }
-
- private static T create(String ocClassName, Class javaClass, Method method,
- String ocFactoryName,
- boolean retain,
- Object... args) {
- if (logging.isLoggable(Level.FINEST)) {
- logging.finest(String.format("creating [%s (%s)].%s(%s)",
- ocClassName, javaClass.getName(), ocFactoryName, new VarArgsUnpacker(args)));
- }
- ID ocClass = Foundation.getClass(ocClassName);
- ID ocInstance = Foundation.send(ocClass, ocFactoryName, ID.class, method, args);
- CFIndex initialRetainCount = Foundation.cfGetRetainCount(ocInstance);
- T result = wrap(ocInstance, javaClass, retain);
- checkRetainCount(ocInstance, retain ? initialRetainCount.intValue() + 1 : initialRetainCount.intValue());
- return result;
- }
-
- /**
- * Create a Java NSObject wrapping an existing Objective-C instance, represented
- * by id.
- *
- * The NSObject is retained, and released when the object is GC'd.
- */
- public static T wrap(ID id, Class javaClass) {
- return wrap(id, javaClass, true);
- }
-
- /**
- * Create a Java NSObject down-casting an existing NSObject to a more derived
- * type.
- */
- public static T cast(ObjCObject object, Class desiredType) {
- if (object == null) {
- return null;
- }
- return wrap(object.id(), desiredType, true);
- }
-
- public static T wrap(ID id, Class javaClass, boolean retain) {
- if (id == null || id.isNull()) {
- return null;
- }
- // Why would we not want to retain? Well if we are wrapping a Core Foundation
- // created object, or one created with new (alloc init), it will not
- // have been autorelease'd.
- ObjCObjectInvocationHandler invocationHandler = new ObjCObjectInvocationHandler(id, javaClass, retain);
- return createProxy(javaClass, invocationHandler);
- }
-
- /**
- * Return the ID of a new Objective-C object that will forward messages to
- * javaObject.
- *
- * Keep hold of the ID all the time that methods may be invoked on the Obj-C
- * object, otherwise the callbacks may be GC'd, with amusing consequences.
- *
- * @deprecated because the OC proxy object is never released.
- * Use {@link Rococoa#proxy} instead.
- */
- @Deprecated
- public static ID wrap(Object javaObject) {
- OCInvocationCallbacks callbacks = new OCInvocationCallbacks(javaObject);
- ID idOfOCProxy = Foundation.newOCProxy(callbacks);
- // idOfOCProxy is owned by us, and we have to release it at some stage
- return new ProxyID(idOfOCProxy, callbacks);
- }
-
- /**
- * Return a new Objective-C object that will forward messages to javaObject,
- * for use in delegates, notifications etc.
- *
- * You need to keep a reference to the returned value for as long as it is
- * active. When it is GC'd, it will release the Objective-C proxy.
- */
- public static ObjCObject proxy(Object javaObject) {
- return proxy(javaObject, ObjCObject.class);
- }
-
- public static T proxy(Object javaObject, Class javaType) {
- ID proxyID = wrap(javaObject);
- // we own the proxyID, so by wrapping it as NSObject, we can arrange for
- // it to be release'd when the NSObject is finalized
- return wrap(proxyID, javaType, false);
- }
-
- private static final TypeCache> typeCache = new TypeCache<>();
- private static final String i15r = "invocationHandler";
-
- /**
- * Create a java.lang.reflect.Proxy or cglib proxy of type, which forwards
- * invocations to invocationHandler.
- */
- @SuppressWarnings("unchecked")
- private static T createProxy(final Class type, ObjCObjectInvocationHandler invocationHandler) {
- if (type.isInterface()) {
- return (T) Proxy.newProxyInstance(
- invocationHandler.getClass().getClassLoader(),
- new Class[] {type}, invocationHandler);
- } else {
- ClassLoader classLoader = type.getClassLoader();
-
- Class> proxyClass =
- typeCache.findOrInsert(classLoader, type, () ->
- new ByteBuddy()
- .subclass(type, ConstructorStrategy.Default.NO_CONSTRUCTORS)
- .name(type.getName() + "$$ByRococoa")
- .defineField(i15r, ObjCObjectInvocationHandler.class)
- .defineConstructor(Visibility.PUBLIC)
- .withParameter(ObjCObjectInvocationHandler.class, i15r)
- .intercept(
- // Invoke superclass default constructor explicitly
- invoke(type.getConstructor())
- .andThen(ofField(i15r).setsArgumentAt(0))
- )
- .method(
- isAbstract()
- .or(is(ObjCObjectInvocationHandler.OBJECT_EQUALS))
- .or(is(ObjCObjectInvocationHandler.OBJECT_TOSTRING))
- .or(is(ObjCObjectInvocationHandler.OCOBJECT_ID))
- )
- .intercept(InvocationHandlerAdapter.toField(i15r))
- .make()
- .load(classLoader)
- .getLoaded()
- );
-
- try {
- return ((Class extends T>) proxyClass)
- .getConstructor(ObjCObjectInvocationHandler.class)
- .newInstance(invocationHandler);
- } catch (ReflectiveOperationException e) {
- throw new RococoaException(e);
- }
- }
- }
-
- // Public only because JNA doesn't call setAccessible to access ctor.
- public static class ProxyID extends ID {
- // used to prevent callbacks being GC'd as long as we hang onto this ID
- @SuppressWarnings("unused")
- private OCInvocationCallbacks callbacks;
-
- public ProxyID() {
- // required by jna
- }
-
- public ProxyID(ID anotherID, OCInvocationCallbacks callbacks) {
- super(anotherID);
- this.callbacks = callbacks;
- }
- }
-
- private static void checkRetainCount(ID ocInstance, int expected) {
- CFIndex retainCount = Foundation.cfGetRetainCount(ocInstance);
- if (retainCount.intValue() != expected) {
- logging.warning("Created an object which had a retain count of " + retainCount + " not " + expected);
- }
- }
-
- /**
- * Enforce static factory-ness.
- */
- private Rococoa() {
- }
-}
diff --git a/rococoa/rococoa-core/src/main/java/org/rococoa/RococoaException.java b/rococoa/rococoa-core/src/main/java/org/rococoa/RococoaException.java
deleted file mode 100644
index 6e817d6c..00000000
--- a/rococoa/rococoa-core/src/main/java/org/rococoa/RococoaException.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 2007, 2008, 2009 Duncan McGregor
- *
- * This file is part of Rococoa, a library to allow Java to talk to Cocoa.
- *
- * Rococoa is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Rococoa is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Rococoa. If not, see .
- */
-
-package org.rococoa;
-
-@SuppressWarnings("serial")
-public class RococoaException extends RuntimeException {
-
- public RococoaException() {
- }
-
- public RococoaException(String message) {
- super(message);
- }
-
- public RococoaException(Throwable cause) {
- super(cause);
- }
-
- public RococoaException(String message, Throwable cause) {
- super(message, cause);
- }
-
-}
diff --git a/rococoa/rococoa-core/src/main/java/org/rococoa/RunOnMainThread.java b/rococoa/rococoa-core/src/main/java/org/rococoa/RunOnMainThread.java
deleted file mode 100644
index 89c2fa1e..00000000
--- a/rococoa/rococoa-core/src/main/java/org/rococoa/RunOnMainThread.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright 2007, 2008 Duncan McGregor
- *
- * This file is part of Rococoa, a library to allow Java to talk to Cocoa.
- *
- * Rococoa is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Rococoa is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Rococoa. If not, see .
- */
-
-package org.rococoa;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Marker that the methods of an NSObject should be invoked on the main Cocoa thread.
- *
- * @author duncan
- *
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target({ElementType.TYPE, ElementType.METHOD})
-public @interface RunOnMainThread {
-
-}
diff --git a/rococoa/rococoa-core/src/main/java/org/rococoa/Selector.java b/rococoa/rococoa-core/src/main/java/org/rococoa/Selector.java
deleted file mode 100644
index 22e42658..00000000
--- a/rococoa/rococoa-core/src/main/java/org/rococoa/Selector.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright 2007, 2008 Duncan McGregor
- *
- * This file is part of Rococoa, a library to allow Java to talk to Cocoa.
- *
- * Rococoa is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Rococoa is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Rococoa. If not, see .
- */
-
-package org.rococoa;
-
-import com.sun.jna.NativeLong;
-
-public class Selector extends NativeLong {
-
- private String name;
-
- public Selector() {
- this("undefined selector", 0);
- };
-
- public Selector(String name, long value) {
- super(value);
- this.name = name;
- }
-
- // used for setting name once we have got one from OC
- Selector initName(String name) {
- this.name = name;
- return this;
- }
-
- public String getName() {
- return name;
- }
-
- @Override
- public String toString() {
- return String.format("[Selector %s]", name);
- }
-
-}
diff --git a/rococoa/rococoa-core/src/main/java/org/rococoa/StringEncoding.java b/rococoa/rococoa-core/src/main/java/org/rococoa/StringEncoding.java
deleted file mode 100644
index c8c19e14..00000000
--- a/rococoa/rococoa-core/src/main/java/org/rococoa/StringEncoding.java
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- * Copyright 2007, 2008, 2009 Duncan McGregor
- *
- * This file is part of Rococoa, a library to allow Java to talk to Cocoa.
- *
- * Rococoa is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Rococoa is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Rococoa. If not, see .
- */
-
-package org.rococoa;
-
-public enum StringEncoding {
-
- // This set is CFStringBuiltInEncodings
- kCFStringEncodingMacRoman(0),
- kCFStringEncodingWindowsLatin1(0x0500), /* ANSI codepage 1252 */
- kCFStringEncodingISOLatin1(0x0201), /* ISO 8859-1 */
- kCFStringEncodingNextStepLatin(0x0B01), /* NextStep encoding*/
- kCFStringEncodingASCII(0x0600), /* 0..127 (in creating CFString, values greater than 0x7F are treated as corresponding Unicode value) */
- kCFStringEncodingUnicode(0x0100), /* kTextEncodingUnicodeDefault + kTextEncodingDefaultFormat (aka kUnicode16BitFormat) */
- kCFStringEncodingUTF8(0x08000100), /* kTextEncodingUnicodeDefault + kUnicodeUTF8Format */
- kCFStringEncodingNonLossyASCII(0x0BFF), /* 7bit Unicode variants used by Cocoa & Java */
- kCFStringEncodingUTF16(0x0100), /* kTextEncodingUnicodeDefault + kUnicodeUTF16Format (alias of kCFStringEncodingUnicode) */
- kCFStringEncodingUTF16BE(0x10000100), /* kTextEncodingUnicodeDefault + kUnicodeUTF16BEFormat */
- kCFStringEncodingUTF16LE(0x14000100), /* kTextEncodingUnicodeDefault + kUnicodeUTF16LEFormat */
- kCFStringEncodingUTF32(0x0c000100), /* kTextEncodingUnicodeDefault + kUnicodeUTF32Format */
- kCFStringEncodingUTF32BE(0x18000100), /* kTextEncodingUnicodeDefault + kUnicodeUTF32BEFormat */
- kCFStringEncodingUTF32LE(0x1c000100), /* kTextEncodingUnicodeDefault + kUnicodeUTF32LEFormat */
-
- // Others are from CFStringEncodingExt.h
- kCFStringEncodingMacJapanese(1),
- kCFStringEncodingMacChineseTrad(2),
- kCFStringEncodingMacKorean(3),
- kCFStringEncodingMacArabic(4),
- kCFStringEncodingMacHebrew(5),
- kCFStringEncodingMacGreek(6),
- kCFStringEncodingMacCyrillic(7),
- kCFStringEncodingMacDevanagari(9),
- kCFStringEncodingMacGurmukhi(10),
- kCFStringEncodingMacGujarati(11),
- kCFStringEncodingMacOriya(12),
- kCFStringEncodingMacBengali(13),
- kCFStringEncodingMacTamil(14),
- kCFStringEncodingMacTelugu(15),
- kCFStringEncodingMacKannada(16),
- kCFStringEncodingMacMalayalam(17),
- kCFStringEncodingMacSinhalese(18),
- kCFStringEncodingMacBurmese(19),
- kCFStringEncodingMacKhmer(20),
- kCFStringEncodingMacThai(21),
- kCFStringEncodingMacLaotian(22),
- kCFStringEncodingMacGeorgian(23),
- kCFStringEncodingMacArmenian(24),
- kCFStringEncodingMacChineseSimp(25),
- kCFStringEncodingMacTibetan(26),
- kCFStringEncodingMacMongolian(27),
- kCFStringEncodingMacEthiopic(28),
- kCFStringEncodingMacCentralEurRoman(29),
- kCFStringEncodingMacVietnamese(30),
- kCFStringEncodingMacExtArabic(31),
- kCFStringEncodingMacSymbol(33),
- kCFStringEncodingMacDingbats(34),
- kCFStringEncodingMacTurkish(35),
- kCFStringEncodingMacCroatian(36),
- kCFStringEncodingMacIcelandic(37),
- kCFStringEncodingMacRomanian(38),
- kCFStringEncodingMacCeltic(39),
- kCFStringEncodingMacGaelic(40),
- kCFStringEncodingMacFarsi(0x8C),
- kCFStringEncodingMacUkrainian(0x98),
- kCFStringEncodingMacInuit(0xEC),
- kCFStringEncodingMacVT100(0xFC),
- kCFStringEncodingMacHFS(0xFF),
- kCFStringEncodingISOLatin2(0x0202),
- kCFStringEncodingISOLatin3(0x0203),
- kCFStringEncodingISOLatin4(0x0204),
- kCFStringEncodingISOLatinCyrillic(0x0205),
- kCFStringEncodingISOLatinArabic(0x0206),
- kCFStringEncodingISOLatinGreek(0x0207),
- kCFStringEncodingISOLatinHebrew(0x0208),
- kCFStringEncodingISOLatin5(0x0209),
- kCFStringEncodingISOLatin6(0x020A),
- kCFStringEncodingISOLatinThai(0x020B),
- kCFStringEncodingISOLatin7(0x020D),
- kCFStringEncodingISOLatin8(0x020E),
- kCFStringEncodingISOLatin9(0x020F),
- kCFStringEncodingISOLatin10(0x0210),
- kCFStringEncodingDOSLatinUS(0x0400),
- kCFStringEncodingDOSGreek(0x0405),
- kCFStringEncodingDOSBalticRim(0x0406),
- kCFStringEncodingDOSLatin1(0x0410),
- kCFStringEncodingDOSGreek1(0x0411),
- kCFStringEncodingDOSLatin2(0x0412),
- kCFStringEncodingDOSCyrillic(0x0413),
- kCFStringEncodingDOSTurkish(0x0414),
- kCFStringEncodingDOSPortuguese(0x0415),
- kCFStringEncodingDOSIcelandic(0x0416),
- kCFStringEncodingDOSHebrew(0x0417),
- kCFStringEncodingDOSCanadianFrench(0x0418),
- kCFStringEncodingDOSArabic(0x0419),
- kCFStringEncodingDOSNordic(0x041A),
- kCFStringEncodingDOSRussian(0x041B),
- kCFStringEncodingDOSGreek2(0x041C),
- kCFStringEncodingDOSThai(0x041D),
- kCFStringEncodingDOSJapanese(0x0420),
- kCFStringEncodingDOSChineseSimplif(0x0421),
- kCFStringEncodingDOSKorean(0x0422),
- kCFStringEncodingDOSChineseTrad(0x0423),
- kCFStringEncodingWindowsLatin2(0x0501),
- kCFStringEncodingWindowsCyrillic(0x0502),
- kCFStringEncodingWindowsGreek(0x0503),
- kCFStringEncodingWindowsLatin5(0x0504),
- kCFStringEncodingWindowsHebrew(0x0505),
- kCFStringEncodingWindowsArabic(0x0506),
- kCFStringEncodingWindowsBalticRim(0x0507),
- kCFStringEncodingWindowsVietnamese(0x0508),
- kCFStringEncodingWindowsKoreanJohab(0x0510),
- kCFStringEncodingANSEL(0x0601),
- kCFStringEncodingJIS_X0201_76(0x0620),
- kCFStringEncodingJIS_X0208_83(0x0621),
- kCFStringEncodingJIS_X0208_90(0x0622),
- kCFStringEncodingJIS_X0212_90(0x0623),
- kCFStringEncodingJIS_C6226_78(0x0624),
- kCFStringEncodingShiftJIS_X0213_00(0x0628),
- kCFStringEncodingShiftJIS_X0213_MenKuTen(0x0629),
- kCFStringEncodingGB_2312_80(0x0630),
- kCFStringEncodingGBK_95(0x0631),
- kCFStringEncodingGB_18030_2000(0x0632),
- kCFStringEncodingKSC_5601_87(0x0640),
- kCFStringEncodingKSC_5601_92_Johab(0x0641),
- kCFStringEncodingCNS_11643_92_P1(0x0651),
- kCFStringEncodingCNS_11643_92_P2(0x0652),
- kCFStringEncodingCNS_11643_92_P3(0x0653),
- kCFStringEncodingISO_2022_JP(0x0820),
- kCFStringEncodingISO_2022_JP_2(0x0821),
- kCFStringEncodingISO_2022_JP_1(0x0822),
- kCFStringEncodingISO_2022_JP_3(0x0823),
- kCFStringEncodingISO_2022_CN(0x0830),
- kCFStringEncodingISO_2022_CN_EXT(0x0831),
- kCFStringEncodingISO_2022_KR(0x0840),
- kCFStringEncodingEUC_JP(0x0920),
- kCFStringEncodingEUC_CN(0x0930),
- kCFStringEncodingEUC_TW(0x0931),
- kCFStringEncodingEUC_KR(0x0940),
- kCFStringEncodingShiftJIS(0x0A01),
- kCFStringEncodingKOI8_R(0x0A02),
- kCFStringEncodingBig5(0x0A03),
- kCFStringEncodingMacRomanLatin1(0x0A04),
- kCFStringEncodingHZ_GB_2312(0x0A05),
- kCFStringEncodingBig5_HKSCS_1999(0x0A06),
- kCFStringEncodingVISCII(0x0A07),
- kCFStringEncodingKOI8_U(0x0A08),
- kCFStringEncodingBig5_E(0x0A09),
- kCFStringEncodingNextStepJapanese(0x0B02),
- kCFStringEncodingEBCDIC_US(0x0C01),
- kCFStringEncodingEBCDIC_CP037(0x0C0);
-
- public final int value;
-
- private StringEncoding(int value) {
- this.value = value;
- }
-
-}
diff --git a/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/CFIndex.java b/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/CFIndex.java
deleted file mode 100644
index f8d16ac6..00000000
--- a/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/CFIndex.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright 2007, 2008 Duncan McGregor
- *
- * This file is part of Rococoa, a library to allow Java to talk to Cocoa.
- *
- * Rococoa is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Rococoa is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Rococoa. If not, see .
- */
-
-package org.rococoa.cocoa;
-
-import com.sun.jna.NativeLong;
-
-/**
- *
- * @author pixel
- */
-public class CFIndex extends NativeLong {
- private static final long serialVersionUID = 0;
-}
diff --git a/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/CFRange.java b/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/CFRange.java
deleted file mode 100644
index b2021102..00000000
--- a/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/CFRange.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright 2007, 2008 Duncan McGregor
- *
- * This file is part of Rococoa, a library to allow Java to talk to Cocoa.
- *
- * Rococoa is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Rococoa is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Rococoa. If not, see .
- */
-
-package org.rococoa.cocoa;
-
-import java.util.Arrays;
-import java.util.List;
-
-import com.sun.jna.Structure;
-
-/**
- * @author pixel
- */
-public class CFRange extends Structure implements Structure.ByValue {
- public CFIndex location;
- public CFIndex length;
-
- public CFRange() {
- }
-
- public CFRange(final CFIndex location, final CFIndex length) {
- this.location = location;
- this.length = length;
- }
-
- public long getLength() {
- return length.longValue();
- }
-
- public long getLocation() {
- return location.longValue();
- }
-
- public long getEndLocation() {
- return getLocation() + getLength();
- }
-
- @Override
- protected List getFieldOrder() {
- return Arrays.asList("location", "length");
- }
-}
diff --git a/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/CGFloat.java b/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/CGFloat.java
deleted file mode 100644
index cd2ba863..00000000
--- a/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/CGFloat.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Copyright 2007, 2008, 2009 Duncan McGregor
- *
- * This file is part of Rococoa, a library to allow Java to talk to Cocoa.
- *
- * Rococoa is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Rococoa is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Rococoa. If not, see .
- */
-
-package org.rococoa.cocoa;
-
-import com.sun.jna.FromNativeContext;
-import com.sun.jna.Native;
-import com.sun.jna.NativeMapped;
-
-/**
- * CGFloat
- *
- * @author Harald Kuhr
- * @author duncan
- */
-public class CGFloat extends Number implements NativeMapped {
- // Inspired by JNA NativeLong and IntegerType
- public static final int SIZE = Native.LONG_SIZE;
-
- private final double value;
-
- public CGFloat() {
- value = 0;
- }
-
- public CGFloat(double d) {
- value = d;
- }
-
- @Override
- public int intValue() {
- return (int) value;
- }
-
- @Override
- public long longValue() {
- return (long) value;
- }
-
- @Override
- public float floatValue() {
- return (float) value;
- }
-
- @Override
- public double doubleValue() {
- return value;
- }
-
- @Override
- public int hashCode() {
- // From Double.hashCode
- long bits = Double.doubleToLongBits(value);
- return (int)(bits ^ (bits >>> 32));
- }
-
- @Override
- public boolean equals(Object other) {
- // Modified Double.equals
- return (other instanceof CGFloat) && (Double.doubleToLongBits(((CGFloat) other).value) == Double.doubleToLongBits(value));
- }
-
- @Override
- public String toString() {
- return String.valueOf(value);
- }
-
- // Native mapping
- public Object fromNative(Object o, FromNativeContext fromNativeContext) {
- switch (SIZE) {
- case 4:
- return new CGFloat((Float) o);
- case 8:
- return new CGFloat((Double) o);
- default:
- throw new Error("Unknown Native.LONG_SIZE: " + SIZE);
- }
- }
-
- public Object toNative() {
- switch (SIZE) {
- case 4:
- return floatValue();
- case 8:
- return doubleValue();
- default:
- throw new Error("Unknown Native.LONG_SIZE: " + SIZE);
- }
- }
-
- public Class> nativeType() {
- switch (SIZE) {
- case 4:
- return Float.class;
- case 8:
- return Double.class;
- default:
- throw new Error("Unknown Native.LONG_SIZE: " + SIZE);
- }
- }
-}
diff --git a/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSArray.java b/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSArray.java
deleted file mode 100755
index d58f80a4..00000000
--- a/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSArray.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright 2007, 2008 Duncan McGregor
- *
- * This file is part of Rococoa, a library to allow Java to talk to Cocoa.
- *
- * Rococoa is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Rococoa is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Rococoa. If not, see .
- */
-
-package org.rococoa.cocoa.foundation;
-
-import org.rococoa.ObjCClass;
-import org.rococoa.Rococoa;
-
-public abstract class NSArray extends NSObject {
-
- public static final _Class CLASS = Rococoa.createClass("NSArray", _Class.class); //$NON-NLS-1$
- public interface _Class extends ObjCClass {
- NSArray arrayWithObject(NSObject anObject);
- /**
- * @param objects Contents and then a trailing null
- */
- NSArray arrayWithObjects(NSObject...objects);
- }
-
- public abstract int count();
-
- public abstract NSObject lastObject();
- public abstract NSObject objectAtIndex(int zeroOffsetIndex);
-
-}
diff --git a/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSAutoreleasePool.java b/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSAutoreleasePool.java
deleted file mode 100644
index 5d3f50f0..00000000
--- a/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSAutoreleasePool.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright 2007, 2008, 2009 Duncan McGregor
- *
- * This file is part of Rococoa, a library to allow Java to talk to Cocoa.
- *
- * Rococoa is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Rococoa is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Rococoa. If not, see .
- */
-
-package org.rococoa.cocoa.foundation;
-
-import org.rococoa.ReleaseInFinalize;
-import org.rococoa.Rococoa;
-
-public @ReleaseInFinalize(false) abstract class NSAutoreleasePool extends NSObject {
-
- public static NSAutoreleasePool new_() {
- return Rococoa.create("NSAutoreleasePool", NSAutoreleasePool.class);
- }
-
- public abstract void addObject(NSObject object);
-
- public abstract void drain();
-
-}
diff --git a/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSData.java b/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSData.java
deleted file mode 100644
index 1609909e..00000000
--- a/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSData.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright 2007, 2008 Duncan McGregor
- *
- * This file is part of Rococoa, a library to allow Java to talk to Cocoa.
- *
- * Rococoa is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Rococoa is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Rococoa. If not, see .
- */
-
-package org.rococoa.cocoa.foundation;
-
-import org.rococoa.ObjCClass;
-import org.rococoa.Rococoa;
-
-public abstract class NSData extends NSObject {
- public static final _Class CLASS = Rococoa.createClass("NSData", _Class.class); //$NON-NLS-1$
- public interface _Class extends ObjCClass {
- NSData dataWithBytes_length(byte[] bytes, int length);
- }
-
- public abstract int length();
- public abstract void getBytes(byte[] bytes);
- public abstract void getBytes_length(byte[] bytes, int length);
-
-}
diff --git a/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSDate.java b/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSDate.java
deleted file mode 100644
index 59152e99..00000000
--- a/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSDate.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright 2007, 2008, 2009 Duncan McGregor
- *
- * This file is part of Rococoa, a library to allow Java to talk to Cocoa.
- *
- * Rococoa is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Rococoa is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Rococoa. If not, see .
- */
-
-package org.rococoa.cocoa.foundation;
-
-import org.rococoa.ObjCClass;
-import org.rococoa.Rococoa;
-
-
-public abstract class NSDate extends NSObject {
- public static final _Class CLASS = Rococoa.createClass("NSDate", _Class.class); //$NON-NLS-1$
- public interface _Class extends ObjCClass {
- NSDate dateWithTimeIntervalSince1970(double d);
- }
-
- public abstract double timeIntervalSince1970();
-
- public abstract String description();
-}
\ No newline at end of file
diff --git a/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSDictionary.java b/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSDictionary.java
deleted file mode 100755
index acce2780..00000000
--- a/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSDictionary.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright 2007, 2008 Duncan McGregor
- *
- * This file is part of Rococoa, a library to allow Java to talk to Cocoa.
- *
- * Rococoa is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Rococoa is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Rococoa. If not, see .
- */
-
-package org.rococoa.cocoa.foundation;
-
-import org.rococoa.ID;
-import org.rococoa.ObjCClass;
-import org.rococoa.Rococoa;
-
-public abstract class NSDictionary extends NSObject {
- public static final _Class CLASS = Rococoa.createClass("NSDictionary", _Class.class); //$NON-NLS-1$
-
- public interface _Class extends ObjCClass {
- NSDictionary dictionaryWithObjects_forKeys(NSArray objects, NSArray keys);
- NSDictionary dictionaryWithObjectsAndKeys(NSObject...objects);
- }
-
- public static NSDictionary dictionaryWithObjects_forKeys(NSArray objects, NSArray keys) {
- return CLASS.dictionaryWithObjects_forKeys(objects, keys);
- }
-
- public static NSDictionary dictionaryWithObjectsAndKeys(NSObject...objects) {
- return CLASS.dictionaryWithObjectsAndKeys(objects);
- }
-
- public abstract ID objectForKey(ID key);
- public abstract NSObject objectForKey(NSObject key);
- public abstract NSObject objectForKey(String key);
- public abstract int count();
-}
diff --git a/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSError.java b/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSError.java
deleted file mode 100644
index 1f25c0a3..00000000
--- a/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSError.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright 2007, 2008 Duncan McGregor
- *
- * This file is part of Rococoa, a library to allow Java to talk to Cocoa.
- *
- * Rococoa is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Rococoa is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Rococoa. If not, see .
- */
-
-package org.rococoa.cocoa.foundation;
-
-import org.rococoa.ObjCClass;
-import org.rococoa.Rococoa;
-
-public abstract class NSError extends NSObject {
-
- public static final _Class CLASS = Rococoa.createClass("NSError", _Class.class); //$NON-NLS-1$
-
- public interface _Class extends ObjCClass {
- NSError alloc();
- NSError errorWithDomain_code_userInfo(String domain, NSInteger code, NSDictionary userInfo);
- }
-
- public abstract NSError initWithDomain_code_userInfo(String domain, NSInteger code, NSDictionary userInfo);
-
- public abstract NSInteger code();
-
- public abstract String domain();
-
- public abstract String localizedDescription();
- public abstract String localizedRecoverySuggestion();
- public abstract NSArray localizedRecoveryOptions();
- public abstract String localizedFailureReason();
-
- public abstract NSObject recoveryAttempter();
-
- public abstract NSDictionary userInfo();
-}
diff --git a/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSImage.java b/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSImage.java
deleted file mode 100644
index 17d3c3e6..00000000
--- a/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSImage.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright 2007, 2008 Duncan McGregor
- *
- * This file is part of Rococoa, a library to allow Java to talk to Cocoa.
- *
- * Rococoa is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Rococoa is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Rococoa. If not, see .
- */
-
-package org.rococoa.cocoa.foundation;
-
-
-
-public abstract class NSImage extends NSObject {
-
- public abstract void setScalesWhenResized(boolean scaleWhenResizing);
-
- public abstract void setSize(NSSize size);
-
- public abstract NSData TIFFRepresentation();
-
-}
diff --git a/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSIndexSet.java b/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSIndexSet.java
deleted file mode 100644
index 6b405f47..00000000
--- a/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSIndexSet.java
+++ /dev/null
@@ -1,187 +0,0 @@
-package org.rococoa.cocoa.foundation;
-
-/**
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java, Rococoa, or JNA.
- */
-public abstract class NSIndexSet extends org.rococoa.cocoa.foundation.NSObject implements org.rococoa.ObjCObject {
- /**
- * Original signature : +(id)indexSet
- * native declaration : NSIndexSet.h:51
- */
- public static org.rococoa.cocoa.foundation.NSIndexSet indexSet() {
- return getNSClass().indexSet();
- }
-
- /**
- * Original signature : +(id)indexSetWithIndex:(NSUInteger)
- * native declaration : NSIndexSet.h:52
- */
- public static org.rococoa.cocoa.foundation.NSIndexSet indexSetWithIndex(org.rococoa.cocoa.foundation.NSUInteger value) {
- return getNSClass().indexSetWithIndex(value);
- }
-
- /**
- * Original signature : -(id)init
- * native declaration : NSIndexSet.h:55
- */
- public abstract org.rococoa.cocoa.foundation.NSIndexSet init();
-
- /**
- * Factory method
- *
- * @see #init()
- */
- public static org.rococoa.cocoa.foundation.NSIndexSet create() {
- return getNSClass().alloc().init();
- }
-
- /**
- * Original signature : -(id)initWithIndex:(NSUInteger)
- * native declaration : NSIndexSet.h:56
- */
- public abstract org.rococoa.cocoa.foundation.NSIndexSet initWithIndex(org.rococoa.cocoa.foundation.NSUInteger value);
-
- /**
- * Factory method
- *
- * @see #initWithIndex(org.rococoa.cocoa.foundation.NSUInteger)
- */
- public static org.rococoa.cocoa.foundation.NSIndexSet createWithIndex(org.rococoa.cocoa.foundation.NSUInteger value) {
- return getNSClass().alloc().initWithIndex(value);
- }
- /**
- * native declaration : NSIndexSet.h:57
- * Conversion Error : /**
- * * designated initializer
- * * Original signature : -(id)initWithIndexesInRange:()
- * * /
- * - (id)initWithIndexesInRange:(null)range; (Argument range cannot be converted)
- */
- /**
- * designated initializer
- * Original signature : -(id)initWithIndexSet:(NSIndexSet*)
- * native declaration : NSIndexSet.h:58
- */
- public abstract org.rococoa.cocoa.foundation.NSIndexSet initWithIndexSet(org.rococoa.cocoa.foundation.NSIndexSet indexSet);
-
- /**
- * Factory method
- *
- * @see #initWithIndexSet(org.rococoa.cocoa.foundation.NSIndexSet)
- */
- public static org.rococoa.cocoa.foundation.NSIndexSet createWithIndexSet(org.rococoa.cocoa.foundation.NSIndexSet indexSet) {
- return getNSClass().alloc().initWithIndexSet(indexSet);
- }
-
- /**
- * Original signature : -(BOOL)isEqualToIndexSet:(NSIndexSet*)
- * native declaration : NSIndexSet.h:60
- */
- public abstract boolean isEqualToIndexSet(org.rococoa.cocoa.foundation.NSIndexSet indexSet);
-
- /**
- * Original signature : -(NSUInteger)count
- * native declaration : NSIndexSet.h:62
- */
- public abstract org.rococoa.cocoa.foundation.NSUInteger count();
-
- /**
- * The following six methods will return NSNotFound if there is no index in the set satisfying the query.
- * Original signature : -(NSUInteger)firstIndex
- * native declaration : NSIndexSet.h:66
- */
- public abstract org.rococoa.cocoa.foundation.NSUInteger firstIndex();
-
- /**
- * Original signature : -(NSUInteger)lastIndex
- * native declaration : NSIndexSet.h:67
- */
- public abstract org.rococoa.cocoa.foundation.NSUInteger lastIndex();
-
- /**
- * Original signature : -(NSUInteger)indexGreaterThanIndex:(NSUInteger)
- * native declaration : NSIndexSet.h:68
- */
- public abstract org.rococoa.cocoa.foundation.NSUInteger indexGreaterThanIndex(org.rococoa.cocoa.foundation.NSUInteger value);
-
- /**
- * Original signature : -(NSUInteger)indexLessThanIndex:(NSUInteger)
- * native declaration : NSIndexSet.h:69
- */
- public abstract org.rococoa.cocoa.foundation.NSUInteger indexLessThanIndex(org.rococoa.cocoa.foundation.NSUInteger value);
-
- /**
- * Original signature : -(NSUInteger)indexGreaterThanOrEqualToIndex:(NSUInteger)
- * native declaration : NSIndexSet.h:70
- */
- public abstract org.rococoa.cocoa.foundation.NSUInteger indexGreaterThanOrEqualToIndex(org.rococoa.cocoa.foundation.NSUInteger value);
-
- /**
- * Original signature : -(NSUInteger)indexLessThanOrEqualToIndex:(NSUInteger)
- * native declaration : NSIndexSet.h:71
- */
- public abstract org.rococoa.cocoa.foundation.NSUInteger indexLessThanOrEqualToIndex(org.rococoa.cocoa.foundation.NSUInteger value);
- /**
- * native declaration : NSIndexSet.h:75
- * Conversion Error : /**
- * * Fills up to bufferSize indexes in the specified range into the buffer and returns the number of indexes actually placed in the buffer; also modifies the optional range passed in by pointer to be "positioned" after the last index filled into the buffer.Example: if the index set contains the indexes 0, 2, 4, ..., 98, 100, for a buffer of size 10 and the range (20, 80) the buffer would contain 20, 22, ..., 38 and the range would be modified to (40, 60).
- * * Original signature : -(NSUInteger)getIndexes:(NSUInteger*) maxCount:(NSUInteger) inIndexRange:()
- * * /
- * - (NSUInteger)getIndexes:(NSUInteger*)indexBuffer maxCount:(NSUInteger)bufferSize inIndexRange:(null)range; (Argument range cannot be converted)
- */
- /**
- * native declaration : NSIndexSet.h:78
- * Conversion Error : /// Original signature : -(NSUInteger)countOfIndexesInRange:()
- * - (NSUInteger)countOfIndexesInRange:(null)range; (Argument range cannot be converted)
- */
- /**
- * Original signature : -(BOOL)containsIndex:(NSUInteger)
- * native declaration : NSIndexSet.h:81
- */
- public abstract boolean containsIndex(org.rococoa.cocoa.foundation.NSUInteger value);
- /**
- * native declaration : NSIndexSet.h:82
- * Conversion Error : /// Original signature : -(BOOL)containsIndexesInRange:()
- * - (BOOL)containsIndexesInRange:(null)range; (Argument range cannot be converted)
- */
- /**
- * Original signature : -(BOOL)containsIndexes:(NSIndexSet*)
- * native declaration : NSIndexSet.h:83
- */
- public abstract boolean containsIndexes(org.rococoa.cocoa.foundation.NSIndexSet indexSet);
-
- public static abstract class _class_ extends org.rococoa.cocoa.foundation.NSObject._class_ {
- /**
- * Original signature : +(id)indexSet
- * native declaration : NSIndexSet.h:51
- */
- public abstract org.rococoa.cocoa.foundation.NSIndexSet indexSet();
-
- /**
- * Original signature : +(id)indexSetWithIndex:(NSUInteger)
- * native declaration : NSIndexSet.h:52
- */
- public abstract org.rococoa.cocoa.foundation.NSIndexSet indexSetWithIndex(org.rococoa.cocoa.foundation.NSUInteger value);
-
- /**
- * native declaration : NSIndexSet.h:53
- * Conversion Error : /// Original signature : +(id)indexSetWithIndexesInRange:()
- * + (id)indexSetWithIndexesInRange:(null)range; (Argument range cannot be converted)
- */
- /// native declaration : NSIndexSet.h
- public abstract org.rococoa.cocoa.foundation.NSIndexSet alloc();
-
- /// native declaration : NSIndexSet.h
- public abstract org.rococoa.cocoa.foundation.NSIndexSet new_();
- }
-
- public static _class_ getNSClass() {
- if (_NSCLASS_ == null)
- _NSCLASS_ = org.rococoa.Rococoa.createClass("NSIndexSet", _class_.class);
- return _NSCLASS_;
- }
-
- private static _class_ _NSCLASS_;
-}
diff --git a/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSInteger.java b/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSInteger.java
deleted file mode 100644
index f93f0c90..00000000
--- a/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSInteger.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 2007, 2008 Duncan McGregor
- *
- * This file is part of Rococoa, a library to allow Java to talk to Cocoa.
- *
- * Rococoa is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Rococoa is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Rococoa. If not, see .
- */
-
-package org.rococoa.cocoa.foundation;
-
-import com.sun.jna.NativeLong;
-
-/**
- *
- * @author pixel
- */
-public class NSInteger extends NativeLong {
- private static final long serialVersionUID = 0;
-
- public NSInteger() {
- }
- public NSInteger(long value) {
- super(value);
- }
- public NSInteger(NativeLong nativeLong) {
- super(nativeLong.longValue());
- }
-}
diff --git a/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSIntegerByReference.java b/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSIntegerByReference.java
deleted file mode 100644
index 5aa5ede4..00000000
--- a/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSIntegerByReference.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright 2007, 2008, 2009 Duncan McGregor
- *
- * This file is part of Rococoa, a library to allow Java to talk to Cocoa.
- *
- * Rococoa is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Rococoa is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Rococoa. If not, see .
- */
-
-package org.rococoa.cocoa.foundation;
-
-import com.sun.jna.ptr.NativeLongByReference;
-
-public class NSIntegerByReference extends NativeLongByReference {
-
- public NSIntegerByReference() {
- this(new NSInteger(0L));
- }
-
- public NSIntegerByReference(NSInteger value) {
- super(value);
- }
-
- public void setValue(NSInteger value) {
- getPointer().setNativeLong(0, value);
- }
-
- public NSInteger getValue() {
- return new NSInteger(getPointer().getNativeLong(0));
- }
-
-}
diff --git a/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSInvocation.java b/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSInvocation.java
deleted file mode 100644
index c88928d9..00000000
--- a/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSInvocation.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright 2007, 2008 Duncan McGregor
- *
- * This file is part of Rococoa, a library to allow Java to talk to Cocoa.
- *
- * Rococoa is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Rococoa is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Rococoa. If not, see .
- */
-
-package org.rococoa.cocoa.foundation;
-
-
-import com.sun.jna.Memory;
-import com.sun.jna.Pointer;
-
-public abstract class NSInvocation extends NSObject {
-
- public abstract NSMethodSignature methodSignature();
- public abstract void getArgument_atIndex(Pointer receiver, int index);
- public abstract void setReturnValue(Memory buffer);
-}
diff --git a/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSMethodSignature.java b/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSMethodSignature.java
deleted file mode 100644
index 1ce2a1d9..00000000
--- a/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSMethodSignature.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright 2007, 2008 Duncan McGregor
- *
- * This file is part of Rococoa, a library to allow Java to talk to Cocoa.
- *
- * Rococoa is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Rococoa is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Rococoa. If not, see .
- */
-
-package org.rococoa.cocoa.foundation;
-
-import org.rococoa.ReturnType;
-
-import com.sun.jna.Pointer;
-
-public abstract class NSMethodSignature extends NSObject {
-
- public abstract int numberOfArguments();
-
- public abstract @ReturnType(Pointer.class) String getArgumentTypeAtIndex(int index);
- public abstract @ReturnType(Pointer.class) String methodReturnType();
-
-}
diff --git a/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSMutableArray.java b/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSMutableArray.java
deleted file mode 100644
index 0425549a..00000000
--- a/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSMutableArray.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright 2007, 2008 Duncan McGregor
- *
- * This file is part of Rococoa, a library to allow Java to talk to Cocoa.
- *
- * Rococoa is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Rococoa is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Rococoa. If not, see .
- */
-
-package org.rococoa.cocoa.foundation;
-
-import org.rococoa.ObjCClass;
-import org.rococoa.Rococoa;
-
-public abstract class NSMutableArray extends NSObject {
-
- public static final _Class CLASS = Rococoa.createClass("NSMutableArray", _Class.class); //$NON-NLS-1$
- public interface _Class extends ObjCClass {
- NSMutableArray arrayWithCapacity(int numItems);
- }
-
- public abstract int count();
- public abstract void addObject(NSObject anObject);
- public abstract void addObject(String string);
-
- public abstract NSObject objectAtIndex(int index);
-}
diff --git a/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSMutableDictionary.java b/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSMutableDictionary.java
deleted file mode 100755
index 4d29ec9c..00000000
--- a/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSMutableDictionary.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright 2007, 2008 Duncan McGregor
- *
- * This file is part of Rococoa, a library to allow Java to talk to Cocoa.
- *
- * Rococoa is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Rococoa is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Rococoa. If not, see .
- */
-
-package org.rococoa.cocoa.foundation;
-
-import org.rococoa.ObjCClass;
-import org.rococoa.Rococoa;
-
-/**
- * @author Duncan McGregor
- * @author Paul Loy (added addEntriesFromDictionary for Growl contrib)
- *
- */
-public abstract class NSMutableDictionary extends NSDictionary {
-
- public static final _Class CLASS = Rococoa.createClass("NSMutableDictionary", _Class.class); //$NON-NLS-1$
-
- public interface _Class extends ObjCClass {
- NSMutableDictionary dictionaryWithCapacity(int numItems);
- NSMutableDictionary dictionaryWithObjects_forKeys(NSArray objects, NSArray keys);
- NSMutableDictionary dictionaryWithObjectsAndKeys(NSObject...objects);
- NSMutableDictionary dictionaryWithDictionary(NSDictionary dict);
- }
-
- public static NSMutableDictionary dictionaryWithCapacity(int numItems) {
- return CLASS.dictionaryWithCapacity(numItems);
- }
-
- public static NSMutableDictionary dictionaryWithObjects_forKeys(NSArray objects, NSArray keys) {
- return CLASS.dictionaryWithObjects_forKeys(objects, keys);
- }
-
- public static NSMutableDictionary dictionaryWithObjectsAndKeys(NSObject...objects) {
- return CLASS.dictionaryWithObjectsAndKeys(objects);
- }
-
- public static NSMutableDictionary dictionaryWithDictionary(NSDictionary dictionary) {
- return CLASS.dictionaryWithDictionary(dictionary);
- }
-
- public abstract void setValue_forKey(NSObject object, NSObject key);
-
- public abstract void setValue_forKey(NSObject object, String key);
-
- public abstract void addEntriesFromDictionary(NSDictionary dictionary);
-
-}
diff --git a/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSMutableIndexSet.java b/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSMutableIndexSet.java
deleted file mode 100644
index ea84d83a..00000000
--- a/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSMutableIndexSet.java
+++ /dev/null
@@ -1,80 +0,0 @@
-package org.rococoa.cocoa.foundation;
-
-/**
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java, Rococoa, or JNA.
- */
-public abstract class NSMutableIndexSet extends org.rococoa.cocoa.foundation.NSIndexSet {
- /**
- * Original signature : -(void)addIndexes:(NSIndexSet*)
- * native declaration : NSIndexSet.h:109
- */
- public abstract void addIndexes(org.rococoa.cocoa.foundation.NSIndexSet indexSet);
-
- /**
- * Original signature : -(void)removeIndexes:(NSIndexSet*)
- * native declaration : NSIndexSet.h:110
- */
- public abstract void removeIndexes(org.rococoa.cocoa.foundation.NSIndexSet indexSet);
-
- /**
- * Original signature : -(void)removeAllIndexes
- * native declaration : NSIndexSet.h:111
- */
- public abstract void removeAllIndexes();
-
- /**
- * Original signature : -(void)addIndex:(NSUInteger)
- * native declaration : NSIndexSet.h:112
- */
- public abstract void addIndex(org.rococoa.cocoa.foundation.NSUInteger value);
-
- /**
- * Original signature : -(void)removeIndex:(NSUInteger)
- * native declaration : NSIndexSet.h:113
- */
- public abstract void removeIndex(org.rococoa.cocoa.foundation.NSUInteger value);
- /**
- * native declaration : NSIndexSet.h:114
- * Conversion Error : /// Original signature : -(void)addIndexesInRange:()
- * - (void)addIndexesInRange:(null)range; (Argument range cannot be converted)
- */
- /**
- * native declaration : NSIndexSet.h:115
- * Conversion Error : /// Original signature : -(void)removeIndexesInRange:()
- * - (void)removeIndexesInRange:(null)range; (Argument range cannot be converted)
- */
- /**
- * For a positive delta, shifts the indexes in [index, INT_MAX] to the right, thereby inserting an "empty space" [index, delta], for a negative delta, shifts the indexes in [index, INT_MAX] to the left, thereby deleting the indexes in the range [index - delta, delta].
- * Original signature : -(void)shiftIndexesStartingAtIndex:(NSUInteger) by:(NSInteger)
- * native declaration : NSIndexSet.h:119
- */
- public abstract void shiftIndexesStartingAtIndex_by(org.rococoa.cocoa.foundation.NSUInteger index, org.rococoa.cocoa.foundation.NSInteger delta);
-
- /// native declaration : NSIndexSet.h
- public static org.rococoa.cocoa.foundation.NSMutableIndexSet alloc() {
- return getNSClass().alloc();
- }
-
- /// native declaration : NSIndexSet.h
- public static org.rococoa.cocoa.foundation.NSMutableIndexSet new_() {
- return getNSClass().new_();
- }
-
- public static abstract class _class_ extends org.rococoa.cocoa.foundation.NSIndexSet._class_ {
- /// native declaration : NSIndexSet.h
- public abstract org.rococoa.cocoa.foundation.NSMutableIndexSet alloc();
-
- /// native declaration : NSIndexSet.h
- public abstract org.rococoa.cocoa.foundation.NSMutableIndexSet new_();
- }
-
- public static _class_ getNSClass() {
- if (_NSCLASS_ == null)
- _NSCLASS_ = org.rococoa.Rococoa.createClass("NSMutableIndexSet", _class_.class);
- return _NSCLASS_;
- }
-
- private static _class_ _NSCLASS_;
-}
diff --git a/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSNotification.java b/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSNotification.java
deleted file mode 100644
index 85f60ec6..00000000
--- a/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSNotification.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright 2007, 2008 Duncan McGregor
- *
- * This file is part of Rococoa, a library to allow Java to talk to Cocoa.
- *
- * Rococoa is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Rococoa is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Rococoa. If not, see .
- */
-
-package org.rococoa.cocoa.foundation;
-
-import org.rococoa.ObjCClass;
-import org.rococoa.Rococoa;
-
-
-public abstract class NSNotification extends NSObject {
- public static final _Class CLASS = Rococoa.createClass("NSNotification", _Class.class); //$NON-NLS-1$
- public interface _Class extends ObjCClass {
- NSNotification notificationWithName_object(String notificationName, NSObject object);
- }
-
-}
diff --git a/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSNotificationCenter.java b/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSNotificationCenter.java
deleted file mode 100644
index f33fd57a..00000000
--- a/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSNotificationCenter.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright 2007, 2008 Duncan McGregor
- *
- * This file is part of Rococoa, a library to allow Java to talk to Cocoa.
- *
- * Rococoa is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Rococoa is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Rococoa. If not, see .
- */
-
-package org.rococoa.cocoa.foundation;
-
-import org.rococoa.ID;
-import org.rococoa.ObjCClass;
-import org.rococoa.Rococoa;
-import org.rococoa.Selector;
-
-
-public abstract class NSNotificationCenter extends NSObject {
- public static final _Class CLASS = Rococoa.createClass("NSNotificationCenter", _Class.class); //$NON-NLS-1$
- public interface _Class extends ObjCClass {
- NSNotificationCenter defaultCenter();
- }
-
- public abstract void addObserver_selector_name_object(ID notificationObserver,
- Selector notificationSelector,
- String notificationName,
- NSObject notificationSender);
-
- public abstract void removeObserver(ID notificationObserver);
-
- public abstract void postNotification(NSNotification notification);
-
-}
diff --git a/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSNumber.java b/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSNumber.java
deleted file mode 100644
index 8b7edf6a..00000000
--- a/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSNumber.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright 2007, 2008, 2009 Duncan McGregor
- *
- * This file is part of Rococoa, a library to allow Java to talk to Cocoa.
- *
- * Rococoa is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Rococoa is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Rococoa. If not, see .
- */
-
-package org.rococoa.cocoa.foundation;
-
-import org.rococoa.ObjCClass;
-import org.rococoa.Rococoa;
-
-
-public abstract class NSNumber extends NSObject {
- public static final _Class CLASS = Rococoa.createClass("NSNumber", _Class.class); //$NON-NLS-1$
- public interface _Class extends ObjCClass {
- NSNumber numberWithBool(boolean value);
- NSNumber numberWithInt(int value);
- NSNumber numberWithDouble(double e);
- NSNumber numberWithLong(long value);
- NSNumber numberWithFloat(float value);
- }
-
- public abstract short shortValue();
- public abstract int intValue();
- public abstract long longValue();
- public abstract float floatValue();
- public abstract double doubleValue();
- public abstract int compare(NSNumber another);
-}
\ No newline at end of file
diff --git a/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSObject.java b/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSObject.java
deleted file mode 100644
index e563d4eb..00000000
--- a/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSObject.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright 2007, 2008 Duncan McGregor
- *
- * This file is part of Rococoa, a library to allow Java to talk to Cocoa.
- *
- * Rococoa is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Rococoa is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Rococoa. If not, see .
- */
-
-package org.rococoa.cocoa.foundation;
-
-import org.rococoa.ID;
-import org.rococoa.ObjCClass;
-import org.rococoa.ObjCObject;
-import org.rococoa.Rococoa;
-
-public abstract class NSObject implements ObjCObject {
- public static _class_ CLASS = Rococoa.createClass("NSObject", _class_.class);
-
- public static abstract class _class_ implements ObjCClass {
- public abstract NSObject alloc();
- }
-
- public abstract NSObject retain();
- public abstract void release();
- public abstract NSUInteger retainCount();
-
- public abstract boolean isKindOfClass(ObjCClass nsClass);
- public abstract boolean isKindOfClass(ID nsClass);
-
- public abstract String description();
-
-}
diff --git a/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSPoint.java b/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSPoint.java
deleted file mode 100644
index 9b86a49b..00000000
--- a/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSPoint.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright 2007, 2008 Duncan McGregor
- *
- * This file is part of Rococoa, a library to allow Java to talk to Cocoa.
- *
- * Rococoa is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Rococoa is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Rococoa. If not, see .
- */
-
-package org.rococoa.cocoa.foundation;
-
-import org.rococoa.cocoa.CGFloat;
-
-import java.awt.geom.Point2D;
-import java.util.Arrays;
-import java.util.List;
-
-import com.sun.jna.Structure;
-
-/**
- * @author Harald Kuhr
- */
-public class NSPoint extends Structure implements Structure.ByValue {
- public CGFloat x;
- public CGFloat y;
-
- public NSPoint() {
- this(0, 0);
- }
-
- public NSPoint(double x, double y) {
- this.x = new CGFloat(x);
- this.y = new CGFloat(y);
- }
-
- public NSPoint(Point2D point) {
- this(point.getX(), point.getY());
- }
-
- public Point2D getPoint() {
- return new Point2D.Double(x.doubleValue(), y.doubleValue());
- }
-
- protected List getFieldOrder() {
- return Arrays.asList("x", "y");
- }
-}
\ No newline at end of file
diff --git a/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSRange.java b/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSRange.java
deleted file mode 100644
index 11848a05..00000000
--- a/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSRange.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright 2007, 2008 Duncan McGregor
- *
- * This file is part of Rococoa, a library to allow Java to talk to Cocoa.
- *
- * Rococoa is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Rococoa is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Rococoa. If not, see .
- */
-
-package org.rococoa.cocoa.foundation;
-
-import org.rococoa.cocoa.CFIndex;
-import org.rococoa.cocoa.CFRange;
-
-
-/**
- *
- * @author pixel
- */
-public class NSRange extends CFRange {
- public NSRange() {}
- public NSRange(final CFIndex location, final CFIndex length) {
- super(location, length);
- }
-}
diff --git a/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSRect.java b/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSRect.java
deleted file mode 100644
index 510533fb..00000000
--- a/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSRect.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright 2007, 2008 Duncan McGregor
- *
- * This file is part of Rococoa, a library to allow Java to talk to Cocoa.
- *
- * Rococoa is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Rococoa is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Rococoa. If not, see .
- */
-
-package org.rococoa.cocoa.foundation;
-
-import java.awt.geom.Dimension2D;
-import java.awt.geom.Point2D;
-import java.awt.geom.Rectangle2D;
-import java.util.Arrays;
-import java.util.List;
-
-import com.sun.jna.Structure;
-
-/**
- * @author Harald Kuhr
- */
-public class NSRect extends Structure implements Structure.ByValue {
- public NSPoint origin;
- public NSSize size;
-
- public NSRect() {
- this(new NSPoint(0, 0), new NSSize());
- }
-
- public NSRect(NSPoint origin, NSSize size) {
- this.origin = origin;
- this.size = size;
- }
-
- public NSRect(Point2D origin, Dimension2D size) {
- this.origin = new NSPoint(origin);
- this.size = new NSSize(size);
- }
-
- public NSRect(Rectangle2D rect) {
- this.origin = new NSPoint(rect.getX(), rect.getY());
- this.size = new NSSize(rect.getWidth(), rect.getHeight());
- }
-
- public NSRect(double w, double h) {
- this.origin = new NSPoint(0, 0);
- this.size = new NSSize(w, h);
- }
-
- public Rectangle2D getBounds() {
- return new Rectangle2D.Double(origin.x.doubleValue(), origin.y.doubleValue(), size.width.doubleValue(), size.height.doubleValue());
- }
-
- @Override
- protected List getFieldOrder() {
- return Arrays.asList("origin", "size");
- }
-}
\ No newline at end of file
diff --git a/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSSize.java b/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSSize.java
deleted file mode 100644
index 55b5937b..00000000
--- a/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSSize.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright 2007, 2008 Duncan McGregor
- *
- * This file is part of Rococoa, a library to allow Java to talk to Cocoa.
- *
- * Rococoa is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Rococoa is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Rococoa. If not, see .
- */
-
-package org.rococoa.cocoa.foundation;
-
-import org.rococoa.cocoa.CGFloat;
-
-import java.awt.geom.Dimension2D;
-import java.util.Arrays;
-import java.util.List;
-
-import com.sun.jna.Structure;
-
-public class NSSize extends Structure implements Structure.ByValue {
- public CGFloat width;
- public CGFloat height;
-
- public NSSize() {
- this(0, 0);
- }
-
- public NSSize(double width, double height) {
- this.width = new CGFloat(width);
- this.height = new CGFloat(height);
- }
-
- public NSSize(Dimension2D pSize) {
- this(pSize.getWidth(), pSize.getHeight());
- }
-
- @Override
- protected List getFieldOrder() {
- return Arrays.asList("width", "height");
- }
-}
diff --git a/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSString.java b/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSString.java
deleted file mode 100644
index 1dac0134..00000000
--- a/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSString.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright 2007, 2008, 2009 Duncan McGregor
- *
- * This file is part of Rococoa, a library to allow Java to talk to Cocoa.
- *
- * Rococoa is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Rococoa is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Rococoa. If not, see .
- */
-
-package org.rococoa.cocoa.foundation;
-
-import org.rococoa.Foundation;
-import org.rococoa.ID;
-import org.rococoa.ObjCClass;
-import org.rococoa.Rococoa;
-
-public abstract class NSString extends NSObject {
-
- public static _Class CLASS = Rococoa.createClass("NSString", _Class.class); //$NON-NLS-1$
-
- public interface _Class extends ObjCClass {
- NSString stringWithString(String string);
- NSString stringWithFormat(String string, NSObject...objects);
- }
-
- public static NSString stringWithString(String string) {
- return CLASS.stringWithString(string);
- }
-
- public abstract boolean isEqualToString(String string);
-
- public abstract NSString substringFromIndex(int anIndex);
-
- public abstract NSString lowercaseString();
-
- @Override
- public String toString() {
- return Foundation.toString(id());
- }
-
- // TODO - move to Rococoa
- public static NSString getGlobalString(String libraryName, String globalVarName) {
- return Rococoa.wrap(ID.getGlobal(libraryName, globalVarName), NSString.class);
- }
-
- // TODO - move to Rococoa
- public static NSString getGlobalString(String globalVarName) {
- return getGlobalString("AppKit", globalVarName);
- }
-}
diff --git a/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSUInteger.java b/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSUInteger.java
deleted file mode 100644
index b1771734..00000000
--- a/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSUInteger.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 2007, 2008 Duncan McGregor
- *
- * This file is part of Rococoa, a library to allow Java to talk to Cocoa.
- *
- * Rococoa is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Rococoa is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Rococoa. If not, see .
- */
-
-package org.rococoa.cocoa.foundation;
-
-import com.sun.jna.NativeLong;
-
-/**
- *
- * @author pixel
- */
-public class NSUInteger extends NativeLong {
- private static final long serialVersionUID = 0;
-
- public NSUInteger() {
-
- }
- public NSUInteger(long value) {
- super(value);
- }
- public NSUInteger(NativeLong nativeLong) {
- super(nativeLong.longValue());
- }
-}
diff --git a/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSUIntegerByReference.java b/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSUIntegerByReference.java
deleted file mode 100644
index f41785d6..00000000
--- a/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSUIntegerByReference.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright 2007, 2008, 2009 Duncan McGregor
- *
- * This file is part of Rococoa, a library to allow Java to talk to Cocoa.
- *
- * Rococoa is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Rococoa is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Rococoa. If not, see .
- */
-
-package org.rococoa.cocoa.foundation;
-
-import com.sun.jna.ptr.NativeLongByReference;
-
-public class NSUIntegerByReference extends NativeLongByReference {
-
- public NSUIntegerByReference() {
- this(new NSUInteger(0L));
- }
-
- public NSUIntegerByReference(NSUInteger value) {
- super(value);
- }
-
- public void setValue(NSUInteger value) {
- getPointer().setNativeLong(0, value);
- }
-
- public NSUInteger getValue() {
- return new NSUInteger(getPointer().getNativeLong(0));
- }
-
-}
diff --git a/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSURL.java b/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSURL.java
deleted file mode 100644
index 9a31c71b..00000000
--- a/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSURL.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright 2007, 2008 Duncan McGregor
- *
- * This file is part of Rococoa, a library to allow Java to talk to Cocoa.
- *
- * Rococoa is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Rococoa is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Rococoa. If not, see .
- */
-
-package org.rococoa.cocoa.foundation;
-
-import org.rococoa.ObjCClass;
-import org.rococoa.Rococoa;
-
-public abstract class NSURL extends NSObject {
- public static final _Class CLASS = Rococoa.createClass("NSURL", _Class.class); //$NON-NLS-1$
- public interface _Class extends ObjCClass {
- NSURL URLWithString(String value);
- NSURL fileURLWithPath(String path);
- }
- public abstract NSURL absoluteURL();
- public abstract String path();
-}
diff --git a/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSValue.java b/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSValue.java
deleted file mode 100755
index 8960b36e..00000000
--- a/rococoa/rococoa-core/src/main/java/org/rococoa/cocoa/foundation/NSValue.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright 2007, 2008 Duncan McGregor
- *
- * This file is part of Rococoa, a library to allow Java to talk to Cocoa.
- *
- * Rococoa is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Rococoa is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Rococoa. If not, see .
- */
-
-package org.rococoa.cocoa.foundation;
-
-import org.rococoa.ObjCClass;
-import org.rococoa.Rococoa;
-
-import com.sun.jna.Structure;
-
-public abstract class NSValue extends NSObject {
-
- public static final _Class CLASS = Rococoa.createClass("NSValue", _Class.class); //$NON-NLS-1$
- public interface _Class extends ObjCClass {
- NSValue valueWithSize(NSSize size);
- }
-
- public static NSValue valueWithSize(NSSize size) {
- return CLASS.valueWithSize(size);
- }
-
- public abstract NSSize sizeValue();
- public abstract void getValue(Structure p);
-
-}
diff --git a/rococoa/rococoa-core/src/main/java/org/rococoa/internal/AutoreleaseBatcher.java b/rococoa/rococoa-core/src/main/java/org/rococoa/internal/AutoreleaseBatcher.java
deleted file mode 100644
index 1f65127f..00000000
--- a/rococoa/rococoa-core/src/main/java/org/rococoa/internal/AutoreleaseBatcher.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright 2007, 2008, 2009 Duncan McGregor
- *
- * This file is part of Rococoa, a library to allow Java to talk to Cocoa.
- *
- * Rococoa is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Rococoa is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Rococoa. If not, see .
- */
-
-package org.rococoa.internal;
-import org.rococoa.cocoa.foundation.NSAutoreleasePool;
-
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Used by NSObjectInvocationHandler to make sure that there is an NSAutoreleasePool
- * available when NSObject's are finalized, but not pay the price of creating one
- * per call.
- *
- * Take care, this is tested but unproven code (2009/08).
- *
- * @author duncan
- *
- */
-public class AutoreleaseBatcher extends OperationBatcher {
-
- private static final Logger logging = Logger.getLogger("org.rococoa");
-
- private static final ThreadLocal threadLocal = new ThreadLocal();
-
- private NSAutoreleasePool pool;
-
- public static AutoreleaseBatcher forThread(int batchSize) {
- if (threadLocal.get() == null) {
- threadLocal.set(new AutoreleaseBatcher(batchSize));
- }
- return threadLocal.get();
- }
-
- public AutoreleaseBatcher(int batchSize) {
- super(batchSize);
- }
-
- @Override
- protected void operation() {
- if (logging.isLoggable(Level.FINE)) {
- logging.fine("Draining autorelease pool");
- }
- pool.drain();
- }
-
- @Override
- protected void reset() {
- pool = NSAutoreleasePool.new_();
- }
-
-}
diff --git a/rococoa/rococoa-core/src/main/java/org/rococoa/internal/BoolConverter.java b/rococoa/rococoa-core/src/main/java/org/rococoa/internal/BoolConverter.java
deleted file mode 100644
index e8c73d4e..00000000
--- a/rococoa/rococoa-core/src/main/java/org/rococoa/internal/BoolConverter.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright 2007-2010 Duncan McGregor
- *
- * This file is part of Rococoa, a library to allow Java to talk to Cocoa.
- *
- * Rococoa is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Rococoa is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Rococoa. If not, see .
- */
-
-package org.rococoa.internal;
-
-import com.sun.jna.FromNativeContext;
-import com.sun.jna.FromNativeConverter;
-import com.sun.jna.ToNativeContext;
-import com.sun.jna.ToNativeConverter;
-
-/**
- * Converts {@code java.lang.Boolean} to native by mapping to {@code java.lang.Integer} as defined by:
- *
- * #define YES (BOOL) 1
- * #define NO (BOOL) 0
- *
- *
- * @author Harald Kuhr
- * @author last modified by $Author: haraldk$
- * @version $Id: BoolConverter.java,v 1.0 Feb 19, 2010 8:44:39 PM haraldk Exp$
- */
-public class BoolConverter implements ToNativeConverter, FromNativeConverter {
-
- public Object toNative(final Object value, final ToNativeContext context) {
- return ((Boolean) value) ? 1 : 0;
- }
-
- public Object fromNative(final Object value, final FromNativeContext context) {
- return ((Byte) value).intValue() == 1;
- }
-
- public Class nativeType() {
- return byte.class;
- }
-}
diff --git a/rococoa/rococoa-core/src/main/java/org/rococoa/internal/FoundationLibrary.java b/rococoa/rococoa-core/src/main/java/org/rococoa/internal/FoundationLibrary.java
deleted file mode 100644
index f2bfcebb..00000000
--- a/rococoa/rococoa-core/src/main/java/org/rococoa/internal/FoundationLibrary.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright 2007, 2008, 2009 Duncan McGregor
- *
- * This file is part of Rococoa, a library to allow Java to talk to Cocoa.
- *
- * Rococoa is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Rococoa is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Rococoa. If not, see .
- */
-
-package org.rococoa.internal;
-
-
-import org.rococoa.ID;
-import org.rococoa.Selector;
-
-import com.sun.jna.Library;
-import org.rococoa.cocoa.CFIndex;
-
-/**
- * JNA Library for plain C calls, standard JNA marshalling applies to these
- */
-public interface FoundationLibrary extends Library {
-
- void NSLog(ID pString, Object thing);
-
- ID CFStringCreateWithCString(ID allocator, String string, int encoding);
- ID CFStringCreateWithBytes(ID allocator, byte[] bytes, int byteCount, int encoding, byte isExternalRepresentation);
- String CFStringGetCStringPtr(ID string, int encoding);
- byte CFStringGetCString(ID theString, byte[] buffer, int bufferSize, int encoding);
- int CFStringGetLength(ID theString);
-
- ID CFRetain(ID cfTypeRef);
- void CFRelease(ID cfTypeRef);
- CFIndex CFGetRetainCount(ID cfTypeRef);
-
- ID objc_getClass(String className);
- ID class_createInstance(ID pClass, int extraBytes);
- Selector sel_registerName(String selectorName);
-}
\ No newline at end of file
diff --git a/rococoa/rococoa-core/src/main/java/org/rococoa/internal/MainThreadUtils.java b/rococoa/rococoa-core/src/main/java/org/rococoa/internal/MainThreadUtils.java
deleted file mode 100644
index b3d57c3a..00000000
--- a/rococoa/rococoa-core/src/main/java/org/rococoa/internal/MainThreadUtils.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Copyright 2007, 2008, 2009 Duncan McGregor
- *
- * This file is part of Rococoa, a library to allow Java to talk to Cocoa.
- *
- * Rococoa is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Rococoa is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Rococoa. If not, see .
- */
-
-package org.rococoa.internal;
-
-import java.util.HashSet;
-import java.util.Set;
-import java.util.concurrent.Callable;
-
-import org.rococoa.Foundation;
-import org.rococoa.ID;
-import org.rococoa.RococoaException;
-import org.rococoa.Selector;
-
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Exists just to tidy up Foundation.
- *
- * @author duncan
- *
- */
-public abstract class MainThreadUtils {
- private static final Logger logging = Logger.getLogger("org.rococoa.foundation");
-
- private static final ID idNSThreadClass = Foundation.getClass("NSThread");
- private static final Selector isMainThreadSelector = Foundation.selector("isMainThread");
-
- private static final ThreadLocal isMainThreadThreadLocal = new ThreadLocal() {
- @Override
- protected Boolean initialValue() {
- return nsThreadSaysIsMainThread();
- }
- };
-
- private MainThreadUtils() {
- //
- }
-
- // References to callbacks that must live longer than the method invocation because they are called asynchronously
- private static final Set asynchronousCallbacks = new HashSet();
-
- /**
- * Return the result of calling callable on the main Cococoa thread.
- */
- @SuppressWarnings("unchecked")
- public static T callOnMainThread(RococoaLibrary rococoaLibrary, final Callable callable) {
- final Object[] result = new Object[1];
- final Throwable[] thrown = new Throwable[1];
- RococoaLibrary.VoidCallback callback = new RococoaLibrary.VoidCallback() {
- public void callback() {
- try {
- result[0] = callable.call();
- } catch (Throwable t) {
- thrown[0] = t;
- }
- }};
-
- rococoaLibrary.callOnMainThread(callback, true);
- rethrow(thrown[0]);
- return (T) result[0];
- }
-
- /**
- * @param runnable Run runnable on the main Cocoa thread.
- * @param waitUntilDone A Boolean that specifies whether the current thread blocks until after
- * the specified selector is performed on the receiver on the main thread.
- */
- public static void runOnMainThread(RococoaLibrary rococoaLibrary, final Runnable runnable, final boolean waitUntilDone) {
- final Throwable[] thrown = new Throwable[1];
- RococoaLibrary.VoidCallback callback = new RococoaLibrary.VoidCallback() {
- public void callback() {
- try {
- runnable.run();
- } catch (Throwable t) {
- if (waitUntilDone) {
- thrown[0] = t;
- }
- else {
- logging.log(Level.SEVERE, "Lost exception on main thread", t);
- }
- } finally {
- if (!waitUntilDone) {
- asynchronousCallbacks.remove(this);
- }
- }
- }};
-
- if (!waitUntilDone) {
- asynchronousCallbacks.add(callback);
- }
- rococoaLibrary.callOnMainThread(callback, waitUntilDone);
- rethrow(thrown[0]);
- }
-
- public static boolean isMainThread() {
- return isMainThreadThreadLocal.get();
- }
-
- private static boolean nsThreadSaysIsMainThread() {
- return Foundation.send(idNSThreadClass, isMainThreadSelector, boolean.class);
- }
-
- private static void rethrow(Throwable t) {
- if (t == null) {
- return;
- }
- if (t instanceof Error) {
- throw (Error) t;
- }
- if (t instanceof RuntimeException) {
- throw (RuntimeException) t;
- }
- throw new RococoaException(t);
- }
-}
diff --git a/rococoa/rococoa-core/src/main/java/org/rococoa/internal/MethodFunctionPair.java b/rococoa/rococoa-core/src/main/java/org/rococoa/internal/MethodFunctionPair.java
deleted file mode 100644
index a2d594fd..00000000
--- a/rococoa/rococoa-core/src/main/java/org/rococoa/internal/MethodFunctionPair.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright 2007, 2008, 2009 Duncan McGregor
- *
- * This file is part of Rococoa, a library to allow Java to talk to Cocoa.
- *
- * Rococoa is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Rococoa is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Rococoa. If not, see .
- */
-
-package org.rococoa.internal;
-
-import com.sun.jna.Function;
-
-import java.lang.reflect.Method;
-
-public class MethodFunctionPair {
-
- public final Method method;
- public final Function function;
-
- public MethodFunctionPair(Method method, Function function) {
- this.method = method;
- this.function = function;
- }
-}
\ No newline at end of file
diff --git a/rococoa/rococoa-core/src/main/java/org/rococoa/internal/MsgSendHandler.java b/rococoa/rococoa-core/src/main/java/org/rococoa/internal/MsgSendHandler.java
deleted file mode 100644
index b92521a1..00000000
--- a/rococoa/rococoa-core/src/main/java/org/rococoa/internal/MsgSendHandler.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * Copyright 2007, 2008 Duncan McGregor
- *
- * This file is part of Rococoa, a library to allow Java to talk to Cocoa.
- *
- * Rococoa is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Rococoa is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Rococoa. If not, see .
- */
-
-package org.rococoa.internal;
-
-import com.sun.jna.Library;
-import com.sun.jna.NativeLibrary;
-import com.sun.jna.NativeLong;
-import com.sun.jna.Structure;
-import org.rococoa.ID;
-import org.rococoa.RococoaException;
-import org.rococoa.Selector;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Very special case InvocationHandler that invokes the correct message dispatch
- * function for different return types.
- *
- * Either objc_msgSend or objc_msgSend_stret should be called, depending on the
- * return type. The latter is usually for struct by value, but the former is
- * used for small structs on Intel! Oh and the call has to be mangled in all
- * cases as the result is returned on the stack, but is different sizes
- * depending on its type. Luckily jna and libffi take care of the details -
- * provided they know what the return type is.
- *
- * This InvocationHandler is passed the return type as the first arg to the method call that it
- * intercepts, it uses it to determine which function to call, and removes it before
- * calling invoking.
- *
- * @author duncan
- * @see "http://www.cocoabuilder.com/archive/message/cocoa/2006/6/25/166236"
- * @see "http://developer.apple.com/mac/library/documentation/DeveloperTools/Conceptual/LowLevelABI/Mac_OS_X_ABI_Function_Calls.pdf"
- * @see "http://www.sealiesoftware.com/blog/archive/2008/10/30/objc_explain_objc_msgSend_stret.html"
- *
- * Note also that there is a objc_msgSend_fret that is used supposed to be for
- * floating point return types, but that I haven't (yet) had to use.
- * @see "http://www.sealiesoftware.com/blog/archive/2008/11/16/objc_explain_objc_msgSend_fpret.html"
- */
-class MsgSendHandler implements InvocationHandler {
-
- /**
- * @see com.sun.jna.Function#OPTION_INVOKING_METHOD
- */
- private final String OPTION_INVOKING_METHOD = "invoking-method";
-
- private final static int I386_STRET_CUTOFF = 9;
- private final static int IA64_STRET_CUTOFF = 17;
-
- private final static int STRET_CUTOFF = NativeLong.SIZE == 8 ? IA64_STRET_CUTOFF : I386_STRET_CUTOFF;
-
- public final static boolean AARCH64 = System.getProperty("os.arch").trim().equalsIgnoreCase("aarch64");
- public final static boolean PPC = System.getProperty("os.arch").trim().equalsIgnoreCase("ppc");
-
- private final static Method OBJC_MSGSEND;
- private final static Method OBJC_MSGSEND_VAR_ARGS;
- private final static Method OBJC_MSGSEND_STRET;
-
- static {
- try {
- OBJC_MSGSEND = MsgSendLibrary.class.getDeclaredMethod("objc_msgSend",
- ID.class, Selector.class, Object[].class);
- OBJC_MSGSEND_VAR_ARGS = MsgSendLibrary.class.getDeclaredMethod("objc_msgSend",
- ID.class, Selector.class, Object.class, Object[].class);
- OBJC_MSGSEND_STRET = MsgSendLibrary.class.getDeclaredMethod("objc_msgSend_stret",
- ID.class, Selector.class, Object[].class);
- } catch (NoSuchMethodException x) {
- throw new RococoaException(x);
- }
- }
-
- private final MethodFunctionPair objc_msgSend_stret_Pair;
- private final MethodFunctionPair objc_msgSend_varArgs_Pair;
- private final MethodFunctionPair objc_msgSend_Pair;
-
- private final RococoaTypeMapper rococoaTypeMapper = new RococoaTypeMapper();
-
- public MsgSendHandler(final NativeLibrary lib) {
- this.objc_msgSend_Pair = new MethodFunctionPair(AARCH64 ? null : OBJC_MSGSEND,
- lib.getFunction("objc_msgSend"));
- this.objc_msgSend_varArgs_Pair = new MethodFunctionPair(OBJC_MSGSEND_VAR_ARGS,
- lib.getFunction("objc_msgSend"));
- this.objc_msgSend_stret_Pair = new MethodFunctionPair(OBJC_MSGSEND_STRET,
- AARCH64 ? null : lib.getFunction("objc_msgSend_stret"));
- }
-
- public Object invoke(final Object proxy, final Method method, final Object[] args) {
- Class> returnTypeForThisCall = (Class>) args[0];
- MethodFunctionPair invocation = this.invocationFor(returnTypeForThisCall, MsgSendInvocationMapper.SYNTHETIC_SEND_VARARGS_MSG.equals(method));
- Map options = new HashMap<>(Collections.singletonMap(Library.OPTION_TYPE_MAPPER, rococoaTypeMapper));
- options.put(OPTION_INVOKING_METHOD, invocation.method);
- return invocation.function.invoke(returnTypeForThisCall, Arrays.copyOfRange(args, 1, args.length), options);
- }
-
- private MethodFunctionPair invocationFor(Class> returnTypeForThisCall, boolean varArgs) {
- if (AARCH64) {
- if (varArgs) {
- return objc_msgSend_varArgs_Pair;
- }
- return objc_msgSend_Pair;
- }
- boolean isStruct = Structure.class.isAssignableFrom(returnTypeForThisCall);
- boolean isStructByValue = isStruct && Structure.ByValue.class.isAssignableFrom(returnTypeForThisCall);
- if (!isStructByValue) {
- return objc_msgSend_Pair;
- }
- try {
- if (PPC) {
- // on ppc32 structs never return in registers
- return objc_msgSend_stret_Pair;
- }
- // on i386 structs with sizeof exactly equal to 1, 2, 4, or 8 return in registers
- Structure prototype = (Structure) returnTypeForThisCall.getDeclaredConstructor().newInstance();
- return prototype.size() < STRET_CUTOFF ? objc_msgSend_Pair : objc_msgSend_stret_Pair;
- } catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
- throw new RococoaException(e);
- }
- }
-}
diff --git a/rococoa/rococoa-core/src/main/java/org/rococoa/internal/MsgSendInvocationMapper.java b/rococoa/rococoa-core/src/main/java/org/rococoa/internal/MsgSendInvocationMapper.java
deleted file mode 100644
index c330537f..00000000
--- a/rococoa/rococoa-core/src/main/java/org/rococoa/internal/MsgSendInvocationMapper.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright 2007, 2008, 2009 Duncan McGregor
- *
- * This file is part of Rococoa, a library to allow Java to talk to Cocoa.
- *
- * Rococoa is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Rococoa is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Rococoa. If not, see .
- */
-
-package org.rococoa.internal;
-
-import com.sun.jna.InvocationMapper;
-import com.sun.jna.NativeLibrary;
-import org.rococoa.ID;
-import org.rococoa.RococoaException;
-import org.rococoa.Selector;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-
-/**
- * A JNA InvocationMapper that maps calls to syntheticSendMessage to a MsgSendHandler.
- *
- * This allows us to dispatch all calls to syntheticSendMessage and have MsgSendHandler
- * call objc_msgSend or objc_msgSend_stret as appropriate, casting the return
- * type appropriately.
- *
- * @author duncan
- */
-public class MsgSendInvocationMapper implements InvocationMapper {
-
- public final static Method SYNTHETIC_SEND_MSG;
- public final static Method SYNTHETIC_SEND_VARARGS_MSG;
-
- static {
- try {
- SYNTHETIC_SEND_MSG = MsgSendLibrary.class.getDeclaredMethod("syntheticSendMessage",
- Class.class, ID.class, Selector.class, Object[].class);
- } catch (Exception e) {
- throw new RococoaException("Error retrieving method");
- }
- try {
- SYNTHETIC_SEND_VARARGS_MSG = MsgSendLibrary.class.getDeclaredMethod("syntheticSendVarArgsMessage",
- Class.class, ID.class, Selector.class, Object[].class);
- } catch (Exception e) {
- throw new RococoaException("Error retrieving method");
- }
- }
-
- public InvocationHandler getInvocationHandler(NativeLibrary lib, Method m) {
- if (m.equals(SYNTHETIC_SEND_MSG) || m.equals(SYNTHETIC_SEND_VARARGS_MSG)) {
- // Have to late bind this, as it's the only time we get to see lib.
- // Not too bad as the results are cached.
- return new MsgSendHandler(lib);
- }
- return null; // default handler
- }
-}
\ No newline at end of file
diff --git a/rococoa/rococoa-core/src/main/java/org/rococoa/internal/MsgSendLibrary.java b/rococoa/rococoa-core/src/main/java/org/rococoa/internal/MsgSendLibrary.java
deleted file mode 100644
index 16ee497b..00000000
--- a/rococoa/rococoa-core/src/main/java/org/rococoa/internal/MsgSendLibrary.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright 2007, 2008, 2009 Duncan McGregor
- *
- * This file is part of Rococoa, a library to allow Java to talk to Cocoa.
- *
- * Rococoa is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Rococoa is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Rococoa. If not, see .
- */
-
-package org.rococoa.internal;
-
-
-import org.rococoa.ID;
-import org.rococoa.Selector;
-
-import com.sun.jna.Library;
-import com.sun.jna.Structure;
-
-/**
- * JNA Library for special message send calls, called and marshalled specially.
- */
-public interface MsgSendLibrary extends Library {
- // This doesn't exist in the library, but is synthesised by msgSendHandler
- Object syntheticSendMessage(Class> returnType, ID receiver, Selector selector, Object... args);
- Object syntheticSendVarArgsMessage(Class> returnType, ID receiver, Selector selector, Object... args);
-
- // We don't call these directly, but through syntheticSendMessage
- Object objc_msgSend(ID receiver, Selector selector, Object... args);
- Object objc_msgSend(ID receiver, Selector selector, Object arg, Object... args);
- Structure objc_msgSend_stret(ID receiver, Selector selector, Object... args);
-}
\ No newline at end of file
diff --git a/rococoa/rococoa-core/src/main/java/org/rococoa/internal/NSInvocationMapper.java b/rococoa/rococoa-core/src/main/java/org/rococoa/internal/NSInvocationMapper.java
deleted file mode 100644
index 72f06e49..00000000
--- a/rococoa/rococoa-core/src/main/java/org/rococoa/internal/NSInvocationMapper.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright 2007, 2008, 2009 Duncan McGregor
- *
- * This file is part of Rococoa, a library to allow Java to talk to Cocoa.
- *
- * Rococoa is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Rococoa is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Rococoa. If not, see .
- */
-
-package org.rococoa.internal;
-
-
-import com.sun.jna.Native;
-import org.rococoa.cocoa.foundation.NSInvocation;
-
-import com.sun.jna.Memory;
-
-/**
- * Maps to and from bytes in an NSInvocation to Java types.
- *
- * @author duncan
- *
- */
-public abstract class NSInvocationMapper {
-
- protected final Class> type;
- protected final String typeString;
-
- protected NSInvocationMapper(String typeString, Class> type) {
- this.type = type;
- this.typeString = typeString;
- }
-
- public String typeString() {
- return typeString;
- }
-
- public Object readArgumentFrom(NSInvocation invocation, int index, Class> type) {
- Memory buffer = new Memory(Native.LONG_SIZE); // big enough for long or double
- invocation.getArgument_atIndex(buffer, index);
- return readFrom(buffer, type);
- }
-
- protected Object readFrom(Memory buffer, Class> type) {
- throw new Error("Should be overridden or bypassed");
- }
-
- public abstract Memory bufferForResult(Object methodCallResult);
-
-}
diff --git a/rococoa/rococoa-core/src/main/java/org/rococoa/internal/NSInvocationMapperLookup.java b/rococoa/rococoa-core/src/main/java/org/rococoa/internal/NSInvocationMapperLookup.java
deleted file mode 100644
index fa23a09e..00000000
--- a/rococoa/rococoa-core/src/main/java/org/rococoa/internal/NSInvocationMapperLookup.java
+++ /dev/null
@@ -1,364 +0,0 @@
-/*
- * Copyright 2007, 2008, 2009 Duncan McGregor
- *
- * This file is part of Rococoa, a library to allow Java to talk to Cocoa.
- *
- * Rococoa is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Rococoa is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Rococoa. If not, see .
- */
-
-package org.rococoa.internal;
-
-import com.sun.jna.Memory;
-import com.sun.jna.Native;
-import com.sun.jna.NativeLong;
-import com.sun.jna.Structure;
-import org.rococoa.Foundation;
-import org.rococoa.ID;
-import org.rococoa.ObjCObject;
-import org.rococoa.Rococoa;
-import org.rococoa.cocoa.CGFloat;
-import org.rococoa.cocoa.foundation.NSInteger;
-import org.rococoa.cocoa.foundation.NSUInteger;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Look up how to map from and from NSInvocation and Java objects.
- *
- * @author duncan
- */
-public final class NSInvocationMapperLookup {
- private static final int NATIVE_POINTER_SIZE = Native.POINTER_SIZE;
- private static final int NATIVE_LONG_SIZE = Native.LONG_SIZE;
-
- private static final String NATIVE_LONG_ENCODING = NATIVE_LONG_SIZE == 4 ? "l" : "q";
- private static final String NSINTEGER_ENCODING = NATIVE_LONG_SIZE == 4 ? "i" : "q";
- private static final String NSUINTEGER_ENCODING = NATIVE_LONG_SIZE == 4 ? "I" : "Q";
- private static final String CGFLOAT_ENCODING = NATIVE_LONG_SIZE == 4 ? "f" : "d";
-
- private static final Map, NSInvocationMapper> classToMapperLookup = new HashMap, NSInvocationMapper>();
-
- private NSInvocationMapperLookup() {
- //
- }
-
- public static NSInvocationMapper mapperForType(Class> type) {
- // first check if we have a direct hit in the classToMapperLookup
- NSInvocationMapper directMatch = classToMapperLookup.get(type);
- if (directMatch != null) {
- return directMatch;
- }
- // Now if it is any subclass of NSObject, then the generic mapper will do
- if (OCOBJECT.type.isAssignableFrom(type)) {
- return OCOBJECT;
- }
- // Now if it is any subclass of NSObject, then the generic mapper will do
- if (NATIVE_LONG.type.isAssignableFrom(type)) {
- return NATIVE_LONG;
- }
- // finally if it's a structure (that wasn't found in classToMapperLookup)
- // create a mapper for the actual type and add it for next time
- if (Structure.class.isAssignableFrom(type)) {
- NSInvocationStructureMapper result = new NSInvocationStructureMapper(type);
- addToLookup(result);
- return result;
- }
- return null;
- }
-
- public static String stringForType(Class> type) {
- return mapperForType(type).typeString();
- }
-
- static {
- addToLookup(new NSInvocationMapper("v", void.class) {
- @Override
- public Object readFrom(Memory buffer, Class> type) {
- throw new IllegalStateException("Should not have to read void");
- }
-
- @Override
- public Memory bufferForResult(Object methodCallResult) {
- return new Memory(0);
- }
- });
- addToLookup(new NSInvocationMapper("c", boolean.class) {
- // Cocoa BOOL is defined as signed char
- @Override
- public Object readFrom(Memory buffer, Class> type) {
- byte character = buffer.getByte(0);
- return character == 0 ? java.lang.Boolean.FALSE : java.lang.Boolean.TRUE;
- }
-
- @Override
- public Memory bufferForResult(Object methodCallResult) {
- Memory result = new Memory(1);
- result.setByte(0, ((Boolean) methodCallResult) ? (byte) 1 : (byte) 0);
- return result;
- }
- });
- addToLookup(new NSInvocationMapper("c", byte.class) {
- @Override
- public Object readFrom(Memory buffer, Class> type) {
- return buffer.getByte(0);
- }
-
- @Override
- public Memory bufferForResult(Object methodCallResult) {
- Memory result = new Memory(1);
- result.setByte(0, ((Byte) methodCallResult).byteValue());
- return result;
- }
- });
- addToLookup(new NSInvocationMapper("s", char.class) {
- @Override
- public Object readFrom(Memory buffer, Class> type) {
- throw new UnsupportedOperationException("Don't yet support char, while I think what to do");
- // TODO - think what to do
- }
-
- @Override
- public Memory bufferForResult(Object methodCallResult) {
- throw new UnsupportedOperationException("Don't yet support char, while I think what to do");
- // TODO - think what to do
- }
- });
- addToLookup(new NSInvocationMapper("s", short.class) {
- @Override
- public Object readFrom(Memory buffer, Class> type) {
- return buffer.getShort(0);
- }
-
- @Override
- public Memory bufferForResult(Object methodCallResult) {
- Memory result = new Memory(2);
- result.setShort(0, ((Short) methodCallResult));
- return result;
- }
- });
- addToLookup(new NSInvocationMapper("i", int.class) {
- @Override
- public Object readFrom(Memory buffer, Class> type) {
- return buffer.getInt(0);
- }
-
- @Override
- public Memory bufferForResult(Object methodCallResult) {
- Memory result = new Memory(4);
- result.setInt(0, ((Integer) methodCallResult));
- return result;
- }
- });
- addToLookup(new NSInvocationMapper("q", long.class) {
- @Override
- public Object readFrom(Memory buffer, Class> type) {
- return buffer.getLong(0);
- }
-
- @Override
- public Memory bufferForResult(Object methodCallResult) {
- Memory result = new Memory(8);
- result.setLong(0, (Long) methodCallResult);
- return result;
- }
-
- ;
- });
- addToLookup(new NSInvocationMapper("f", float.class) {
- @Override
- public Object readFrom(Memory buffer, Class> type) {
- return buffer.getFloat(0);
- }
-
- @Override
- public Memory bufferForResult(Object methodCallResult) {
- Memory result = new Memory(4);
- result.setFloat(0, ((Float) methodCallResult));
- return result;
- }
- });
- addToLookup(new NSInvocationMapper("d", double.class) {
- @Override
- public Object readFrom(Memory buffer, Class> type) {
- return buffer.getDouble(0);
- }
-
- @Override
- public Memory bufferForResult(Object methodCallResult) {
- Memory result = new Memory(8);
- result.setDouble(0, ((Double) methodCallResult));
- return result;
- }
- });
- addToLookup(new NSInvocationMapper("@", ID.class) {
- @Override
- public Object readFrom(Memory buffer, Class> type) {
- ID id = ID.fromLong(buffer.getNativeLong(0).longValue());
- if (id.isNull()) {
- return null;
- }
- return id;
- }
-
- @Override
- public Memory bufferForResult(Object methodCallResult) {
- Memory result = new Memory(NATIVE_POINTER_SIZE);
- result.setNativeLong(0, ((ID) methodCallResult));
- return result;
- }
- });
- addToLookup(new NSInvocationMapper("@", String.class) {
- @Override
- public Object readFrom(Memory buffer, Class> type) {
- ID id = ID.fromLong(buffer.getNativeLong(0).longValue());
- if (id.isNull()) {
- return null;
- }
- return Foundation.toString(id);
- }
-
- @Override
- public Memory bufferForResult(Object methodCallResult) {
- Memory buffer = new Memory(NATIVE_POINTER_SIZE);
- ID idString = Foundation.cfString((String) methodCallResult);
- Foundation.sendReturnsID(idString, "autorelease");
- buffer.setNativeLong(0, idString);
- return buffer;
- }
- });
- addToLookup(new NSInvocationMapper(NSINTEGER_ENCODING, NSInteger.class) {
- @Override
- public Object readFrom(Memory buffer, Class> type) {
- return new NSInteger(buffer.getNativeLong(0));
- }
-
- @Override
- public Memory bufferForResult(Object methodCallResult) {
- Memory result = new Memory(NATIVE_LONG_SIZE);
- result.setNativeLong(0, ((NativeLong) methodCallResult));
- return result;
- }
- });
- addToLookup(new NSInvocationMapper(NSUINTEGER_ENCODING, NSUInteger.class) {
- @Override
- public Object readFrom(Memory buffer, Class> type) {
- return new NSUInteger(buffer.getNativeLong(0));
- }
-
- @Override
- public Memory bufferForResult(Object methodCallResult) {
- Memory result = new Memory(NATIVE_LONG_SIZE);
- result.setNativeLong(0, ((NativeLong) methodCallResult));
- return result;
- }
- });
- addToLookup(new NSInvocationMapper(CGFLOAT_ENCODING, CGFloat.class) {
- @Override
- public Object readFrom(Memory buffer, Class> type) {
- if (NATIVE_LONG_SIZE == 4) {
- return new CGFloat(buffer.getFloat(0));
- }
- if (NATIVE_LONG_SIZE == 8) {
- return new CGFloat(buffer.getDouble(0));
- }
- throw new IllegalStateException();
- }
-
- @Override
- public Memory bufferForResult(Object methodCallResult) {
- Memory result = new Memory(NATIVE_LONG_SIZE);
- if (NATIVE_LONG_SIZE == 4) {
- result.setFloat(0, ((CGFloat) methodCallResult).floatValue());
- }
- if (NATIVE_LONG_SIZE == 8) {
- result.setDouble(0, ((CGFloat) methodCallResult).doubleValue());
- }
- return result;
- }
- });
- }
-
- static final NSInvocationMapper OCOBJECT = new NSInvocationMapper("@", ObjCObject.class) {
- @SuppressWarnings("unchecked")
- @Override
- public Object readFrom(Memory buffer, Class> type) {
- ID id = ID.fromLong(buffer.getNativeLong(0).longValue());
- if (id.isNull()) {
- return null;
- }
- return Rococoa.wrap(id, (Class extends ObjCObject>) type);
- }
-
- @Override
- public Memory bufferForResult(Object methodCallResult) {
- Memory buffer = new Memory(NATIVE_POINTER_SIZE);
- buffer.setNativeLong(0, ((ObjCObject) methodCallResult).id());
- return buffer;
- }
- };
-
- static final NSInvocationMapper NATIVE_LONG = new NSInvocationMapper(NATIVE_LONG_ENCODING, NativeLong.class) {
- @Override
- public Object readFrom(Memory buffer, Class> type) {
- return buffer.getNativeLong(0);
- }
-
- @Override
- public Memory bufferForResult(Object methodCallResult) {
- Memory result = new Memory(NATIVE_LONG_SIZE);
- result.setNativeLong(0, ((NativeLong) methodCallResult));
- return result;
- }
- };
-
- private static void addToLookup(NSInvocationMapper mapper) {
- Class> type = mapper.type;
- classToMapperLookup.put(type, mapper);
- if (type.isPrimitive()) {
- classToMapperLookup.put(boxTypeFor(type), mapper);
- }
- }
-
- private static Class> boxTypeFor(Class> type) {
- if (type == void.class) {
- return null;
- }
- if (type == boolean.class) {
- return Boolean.class;
- }
- if (type == byte.class) {
- return Byte.class;
- }
- if (type == short.class) {
- return Short.class;
- }
- if (type == char.class) {
- return Character.class;
- }
- if (type == int.class) {
- return Integer.class;
- }
- if (type == long.class) {
- return Long.class;
- }
- if (type == float.class) {
- return Float.class;
- }
- if (type == double.class) {
- return Double.class;
- }
- throw new IllegalArgumentException("Not a primitive class " + type);
- }
-}
diff --git a/rococoa/rococoa-core/src/main/java/org/rococoa/internal/NSInvocationStructureMapper.java b/rococoa/rococoa-core/src/main/java/org/rococoa/internal/NSInvocationStructureMapper.java
deleted file mode 100644
index 8cd765c5..00000000
--- a/rococoa/rococoa-core/src/main/java/org/rococoa/internal/NSInvocationStructureMapper.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * Copyright 2007, 2008, 2009 Duncan McGregor
- *
- * This file is part of Rococoa, a library to allow Java to talk to Cocoa.
- *
- * Rococoa is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Rococoa is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Rococoa. If not, see .
- */
-
-package org.rococoa.internal;
-
-import com.sun.jna.Memory;
-import com.sun.jna.Native;
-import com.sun.jna.Pointer;
-import com.sun.jna.Structure;
-import org.rococoa.RococoaException;
-import org.rococoa.cocoa.foundation.NSInvocation;
-
-import java.lang.reflect.Field;
-import java.nio.ByteBuffer;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-class NSInvocationStructureMapper extends NSInvocationMapper {
-
- @SuppressWarnings("unchecked")
- public NSInvocationStructureMapper(Class> type) {
- super(encodeStruct((Class extends Structure>) type), type);
- }
-
- private static String encodeStruct(Class extends Structure> clas) {
- StringBuilder result = new StringBuilder();
- if (!(Structure.ByValue.class.isAssignableFrom(clas))) {
- result.append('^'); // pointer to
- }
- result.append('{').append(clas.getSimpleName()).append('=');
- for (Field f : collectStructFields(clas, new ArrayList<>())) {
- result.append(NSInvocationMapperLookup.stringForType(f.getType()));
- }
- return result.append('}').toString();
- }
-
- @SuppressWarnings("unchecked")
- private static List collectStructFields(Class extends Structure> clas, List list) {
- if (clas == Structure.class) {
- return list;
- }
- Collections.addAll(list, clas.getDeclaredFields());
- return collectStructFields((Class extends Structure>) clas.getSuperclass(), list);
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public Object readArgumentFrom(NSInvocation invocation, int index, Class> type) {
- if (Structure.ByValue.class.isAssignableFrom(type)) {
- return readStructureByValue(invocation, index, (Class extends Structure>) type);
- } else {
- return readStructureByReference(invocation, index, (Class extends Structure>) type);
- }
- }
-
- @Override
- public Memory bufferForResult(Object methodCallResult) {
- if (methodCallResult instanceof Structure.ByValue) {
- return bufferForStructureByValue((Structure) methodCallResult);
- } else {
- return bufferForStructureByReference((Structure) methodCallResult);
- }
- }
-
- private Structure readStructureByValue(NSInvocation invocation, int index,
- Class extends Structure> type) {
- Structure result = newInstance(type);
- Memory buffer = new Memory(result.size());
- invocation.getArgument_atIndex(buffer, index);
- return copyBufferToStructure(buffer, result);
- }
-
- private Structure readStructureByReference(NSInvocation invocation, int index,
- Class extends Structure> type) {
- Memory buffer = new Memory(Native.POINTER_SIZE);
- invocation.getArgument_atIndex(buffer, index);
- Pointer pointerToResult = buffer.getPointer(0);
- Structure result = newInstance(type);
- return copyBufferToStructure(pointerToResult, result);
- }
-
- @SuppressWarnings("unchecked")
- private T newInstance(Class> clas) {
- try {
- return (T) clas.newInstance();
- } catch (Exception e) {
- throw new RococoaException("Could not instantiate " + clas, e);
- }
- }
-
- private Structure copyBufferToStructure(Pointer buffer, Structure structure) {
- int byteCount = structure.size();
- memcpy(structure.getPointer(), buffer, byteCount);
- structure.read();
- return structure;
- }
-
- private Memory bufferForStructureByValue(Structure methodCallResult) {
- methodCallResult.write();
- int byteCount = methodCallResult.size();
- Memory buffer = new Memory(byteCount);
- memcpy(buffer, methodCallResult.getPointer(), byteCount);
- return buffer;
- }
-
- private Memory bufferForStructureByReference(Structure methodCallResult) {
- methodCallResult.write();
- Memory buffer = new Memory(Native.POINTER_SIZE);
- buffer.setPointer(0, methodCallResult.getPointer());
- return buffer;
- }
-
- private void memcpy(Pointer dest, Pointer src, int byteCount) {
- memcpyViaByteBuffer(dest, src, byteCount);
- }
-
- @SuppressWarnings("unused") // kept as naive implementation
- private void memcpyViaArray(Pointer dest, Pointer src, int byteCount) {
- byte[] structBytes = new byte[byteCount];
- src.read(0, structBytes, 0, byteCount);
- dest.write(0, structBytes, 0, byteCount);
- }
-
- private void memcpyViaByteBuffer(Pointer dest, Pointer src, int byteCount) {
- ByteBuffer destBuffer = dest.getByteBuffer(0, byteCount);
- ByteBuffer srcBuffer = src.getByteBuffer(0, byteCount);
- destBuffer.put(srcBuffer);
- }
-}
\ No newline at end of file
diff --git a/rococoa/rococoa-core/src/main/java/org/rococoa/internal/OCInvocationCallbacks.java b/rococoa/rococoa-core/src/main/java/org/rococoa/internal/OCInvocationCallbacks.java
deleted file mode 100644
index 67c6bcdf..00000000
--- a/rococoa/rococoa-core/src/main/java/org/rococoa/internal/OCInvocationCallbacks.java
+++ /dev/null
@@ -1,274 +0,0 @@
-/*
- * Copyright 2007, 2008 Duncan McGregor
- *
- * This file is part of Rococoa, a library to allow Java to talk to Cocoa.
- *
- * Rococoa is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Rococoa is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Rococoa. If not, see .
- */
-
-package org.rococoa.internal;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-
-import org.rococoa.ID;
-import org.rococoa.Rococoa;
-import org.rococoa.RococoaException;
-import org.rococoa.cocoa.foundation.NSInvocation;
-import org.rococoa.cocoa.foundation.NSMethodSignature;
-
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import com.sun.jna.Memory;
-
-/**
- * Holds the callbacks called when a method is invoked on an Objective-C proxy
- * for a Java object.
- *
- * When a message is sent to an OC object first it is sent
- * methodSignatureForSelector: Our Obj-C proxy forwards this to
- * methodSignatureCallback; we build a method signature string in Java
- * corresponding to the Java method and return it.
- *
- * The object is then sent forwardInvocation: passing an NSInvocation. It
- * forwards this to selectorInvokedCallback, which we use to invoke the method
- * on the Java Object.
- *
- * @author duncan
- *
- */
-public class OCInvocationCallbacks {
-
- private static final Logger logging = Logger.getLogger("org.rococoa.callback");
-
- private final Object javaObject;
-
- /**
- * Called when method is about to be invoked on OC proxy and needs a method signature as String
- *
- * @see "http://www.cocoadev.com/index.pl?NSMethodSignature"
- */
- public final RococoaLibrary.MethodSignatureCallback methodSignatureCallback =
- new RococoaLibrary.MethodSignatureCallback() {
- public String callback(String selectorName) {
- if (logging.isLoggable(Level.FINEST)) {
- logging.finest(String.format("callback wanting methodSignature for selector %s", selectorName));
- }
- return methodSignatureForSelector(selectorName);
- }
- };
-
- /**
- * Called when method has been invoked on OC proxy and needs to be forwarded to javaObject
- */
- public final RococoaLibrary.SelectorInvokedCallback selectorInvokedCallback =
- new RococoaLibrary.SelectorInvokedCallback() {
- public void callback(String selectorName, ID nsInvocation) {
- if (logging.isLoggable(Level.FINEST)) {
- logging.finest(String.format("callback invoking %s on %s", selectorName, javaObject));
- }
- callMethod(javaObject, selectorName, Rococoa.wrap(nsInvocation, NSInvocation.class));
- }
- };
-
- public OCInvocationCallbacks(Object javaObject) {
- this.javaObject = javaObject;
- }
-
- protected String methodSignatureForSelector(String selectorName) {
- Method method = methodForSelector(selectorName);
- return method == null ?
- null :
- ocMethodSignatureAsString(method);
- }
-
- protected Method methodForSelector(String selectorName) {
- if (null == selectorName) {
- logging.severe("methodForSelector called with null selectorName");
- return null;
- }
- int parameterCount = countColons(selectorName);
- String methodName = methodNameForSelector(selectorName);
- try {
- Method[] methods = javaObject.getClass().getMethods();
- for (Method method : methods) {
- if (method.getName().equals(methodName) && method.getParameterTypes().length == parameterCount) {
- boolean match = true;
- if(null == stringForType(method.getReturnType())) {
- match = false;
- }
- if(match) {
- for (Class> parameterType : method.getParameterTypes()) {
- if(null == stringForType(parameterType)) {
- match = false;
- break;
- }
- }
- }
- if(match) {
- return method;
- }
- }
- }
- logging.fine("No method " + methodName + " for selector:" + selectorName);
- return null;
- } catch (Exception e) {
- logging.log(Level.SEVERE, "Exception finding methodForSelector", e);
- return null;
- }
- }
-
- /**
- * @see "http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/Articles/chapter_13_section_9.html"
- */
- protected String ocMethodSignatureAsString(Method method) {
- StringBuilder result = new StringBuilder();
- result.append(stringForType(method.getReturnType()));
- result.append("@:"); // self and cmd - id and selector
- for (Class> parameterType : method.getParameterTypes()) {
- result.append(stringForType(parameterType));
- }
- return result.toString();
- }
-
- private void callMethod(Object o, String selectorName, NSInvocation invocation) {
- try {
- Method method = methodForSelector(selectorName);
-
- NSMethodSignature nsMethodSignature = invocation.methodSignature();
- String typeToReturnToObjC = nsMethodSignature.methodReturnType();
-
- if (nsMethodSignature.numberOfArguments() - method.getParameterTypes().length != 2) { // self, _cmd
- throw new NoSuchMethodException(String.format(
- "Number of arguments mismatch for invocation of selector %s (%s arguments supplied), method %s expects %s",
- selectorName, nsMethodSignature.numberOfArguments(), method.getName(), method.getParameterTypes().length));
- }
- if (typeToReturnToObjC.equals("v") && method.getReturnType() != void.class) {
- throw new NoSuchMethodException(String.format(
- "Selector %s expects void return, but method %s returns %s",
- selectorName, method.getName(), method.getReturnType()));
- }
- if (method.getReturnType() == void.class && !(typeToReturnToObjC.equals("v"))) {
- throw new NoSuchMethodException(String.format(
- "Method %s returns void, but selector %s expects %s",
- method.getName(), selectorName, typeToReturnToObjC));
- }
- Object[] marshalledArgs = argsForFrom(method, invocation, nsMethodSignature);
- method.setAccessible(true); // needed if implementation is an anonymous subclass of Object
- Object result = method.invoke(o, marshalledArgs);
- putResultIntoInvocation(invocation, typeToReturnToObjC, result);
- } catch (InvocationTargetException e) {
- logging.log(Level.SEVERE, "Exception calling method for selector " + selectorName, e);
- throw new RococoaException("Exception calling method for selector " + selectorName, e.getCause());
- } catch (Exception e) {
- logging.log(Level.SEVERE, "Exception calling method for selector " + selectorName, e);
- throw new RococoaException("Exception calling method for selector " + selectorName, e);
- }
- }
-
- private String methodNameForSelector(String selectorName) {
- String candidate = selectorName.replaceAll(":", "_");
- return candidate.endsWith("_") ?
- candidate.substring(0, candidate.length() - 1) :
- candidate;
- }
-
- private Object[] argsForFrom(Method method, NSInvocation invocation, NSMethodSignature nsMethodSignature) {
- Class>[] parameterTypes = method.getParameterTypes();
- Object[] result = new Object[parameterTypes.length];
- for (int i = 0; i < result.length; i++) {
- int indexAccountingForSelfAndCmd = 2 + i;
- result[i] = javaObjectForOCArgument(invocation,
- indexAccountingForSelfAndCmd,
- nsMethodSignature.getArgumentTypeAtIndex(indexAccountingForSelfAndCmd),
- parameterTypes[i]);
- }
- return result;
- }
-
- /**
- * At this point we have an NSInvocation, which has the arguments to the
- * call in it. We know the type of the argument, and the type of the
- * parameter expected by the Java method. [1]
- * Our mission is to get the value of the argument from the NSInvocation
- * and return a Java object of the desired type.
- */
- private Object javaObjectForOCArgument(NSInvocation invocation,
- int indexInInvocation, String objCArgumentTypeAsString, Class> javaParameterType) {
- NSInvocationMapper mapper = NSInvocationMapperLookup.mapperForType(javaParameterType);
- if (mapper == null) {
- throw new IllegalStateException(
- String.format("Don't (yet) know how to marshall argument Objective-C type %s as %s",
- objCArgumentTypeAsString, javaParameterType));
- }
- return mapper.readArgumentFrom(invocation, indexInInvocation, javaParameterType);
- }
-
- private void putResultIntoInvocation(NSInvocation invocation, String typeToReturnToObjC, Object result) {
- if (typeToReturnToObjC.equals("v")) {
- if (result != null) {
- throw new IllegalStateException("Java method returned a result, but expected void");// void
- }
- return;
- }
- if (null == result) {
- return;
- }
- Memory buffer = bufferForReturn(result);
- if (buffer == null) {
- throw new IllegalStateException(
- String.format("Don't (yet) know how to marshall result %s as Objective-C type %s", result, typeToReturnToObjC));
- }
- invocation.setReturnValue(buffer);
- }
-
- private Memory bufferForReturn(Object methodCallResult) {
- NSInvocationMapper mapper = NSInvocationMapperLookup.mapperForType(methodCallResult.getClass());
- return mapper == null ? null : mapper.bufferForResult(methodCallResult);
- }
-
- private int countColons(String selectorName) {
- int result = 0;
- for (int i = 0; i < selectorName.length(); i++) {
- if (selectorName.charAt(i) == ':') {
- result++;
- }
- }
- return result;
- }
-
- private String stringForType(Class> clas) {
- NSInvocationMapper result = NSInvocationMapperLookup.mapperForType(clas);
- if (result == null) {
- logging.warning("Unable to give Objective-C type string for Java type " + clas);
- return null;
- }
- return result.typeString();
- }
-
- /*
- * [1] - http://en.wikipedia.org/wiki/Parameter_(computer_science)
- * Although parameters are also commonly referred to as arguments,
- * arguments are more properly thought of as the actual values or references
- * assigned to the parameter variables when the subroutine is called at
- * runtime. When discussing code that is calling into a subroutine, any
- * values or references passed into the subroutine are the arguments, and
- * the place in the code where these values or references are given is the
- * parameter list. When discussing the code inside the subroutine
- * definition, the variables in the subroutine's parameter list are the
- * parameters, while the values of the parameters at runtime are the
- * arguments.
- */
-}
\ No newline at end of file
diff --git a/rococoa/rococoa-core/src/main/java/org/rococoa/internal/ObjCObjectByReferenceTypeConverter.java b/rococoa/rococoa-core/src/main/java/org/rococoa/internal/ObjCObjectByReferenceTypeConverter.java
deleted file mode 100644
index 8a1355b4..00000000
--- a/rococoa/rococoa-core/src/main/java/org/rococoa/internal/ObjCObjectByReferenceTypeConverter.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright 2007, 2008, 2009 Duncan McGregor
- *
- * This file is part of Rococoa, a library to allow Java to talk to Cocoa.
- *
- * Rococoa is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Rococoa is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Rococoa. If not, see .
- */
-
-/**
- *
- */
-package org.rococoa.internal;
-
-import org.rococoa.IDByReference;
-import org.rococoa.ObjCObject;
-
-import com.sun.jna.FromNativeContext;
-import com.sun.jna.ToNativeContext;
-import com.sun.jna.TypeConverter;
-
-/**
- * Work in progress. I think that this needs a bit of JNA help to get off the ground.
- */
-class ObjCObjectByReferenceTypeConverter implements TypeConverter {
-
- public Object fromNative(Object nativeValue, FromNativeContext context) {
- throw new UnsupportedOperationException();
- }
-
- public Class> nativeType() {
- return IDByReference.class;
- }
-
- public Object toNative(Object value, ToNativeContext context) {
- if (value == null) {
- return null;
- }
- return new IDByReference();
- }
-
-
-// // x'd until ObjectByReferenceConverter installed
-// public void xtestPassNSObjectByReference() {
-// // currently only out, not in-out
-// NSObjectByReference reference = new NSObjectByReference();
-// ToNativeConverter toNative = typeMapper.getToNativeConverter(reference.getClass());
-// // argument passing is based on actual type
-//
-// assertEquals(IDByReference.class, toNative.nativeType());
-//
-// IDByReference nativeValue = (IDByReference) toNative.toNative(reference, null);
-// assertEquals(0, nativeValue.getValue().intValue());
-//
-// // called code will set id
-// //NSNumber number = NSNumber.CLASS.numberWithInt(42);
-//
-// // TODO - can't make this work without jna support
-// nativeValue.getPointer().setInt(number.id().intValue(), 0);
-//
-// // which our reference should see
-//
-//
-// assertEquals(null, toNative.toNative(null, null));
-//
-// }
-
-}
\ No newline at end of file
diff --git a/rococoa/rococoa-core/src/main/java/org/rococoa/internal/ObjCObjectInvocationHandler.java b/rococoa/rococoa-core/src/main/java/org/rococoa/internal/ObjCObjectInvocationHandler.java
deleted file mode 100644
index 22e164fb..00000000
--- a/rococoa/rococoa-core/src/main/java/org/rococoa/internal/ObjCObjectInvocationHandler.java
+++ /dev/null
@@ -1,323 +0,0 @@
-/*
- * Copyright 2007, 2008 Duncan McGregor
- *
- * This file is part of Rococoa, a library to allow Java to talk to Cocoa.
- *
- * Rococoa is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Rococoa is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Rococoa. If not, see .
- */
-
-package org.rococoa.internal;
-
-import com.sun.jna.Pointer;
-import org.rococoa.*;
-import org.rococoa.cocoa.CFIndex;
-
-import java.lang.reflect.AnnotatedElement;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.concurrent.Callable;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Listens to invocations of methods on a Java NSObject, and forwards them to
- * its Objective-C counterpart.
- *
- * @author duncan
- */
-public class ObjCObjectInvocationHandler implements InvocationHandler {
-
- private static final int FINALIZE_AUTORELEASE_BATCH_SIZE = 1000;
-
- private static final Logger logging = Logger.getLogger("org.rococoa.proxy");
-
- public static final Method OBJECT_TOSTRING;
- public static final Method OBJECT_HASHCODE;
- public static final Method OBJECT_EQUALS;
- public static final Method OCOBJECT_ID;
-
- static {
- try {
- OBJECT_TOSTRING = Object.class.getMethod("toString");
- OBJECT_HASHCODE = Object.class.getMethod("hashCode");
- OBJECT_EQUALS = Object.class.getMethod("equals", Object.class);
- OCOBJECT_ID = ObjCObject.class.getMethod("id");
- } catch (NoSuchMethodException x) {
- throw new RococoaException("Error retrieving method", x);
- }
- }
-
- private ID ocInstance;
- private final String javaClassName;
- private final boolean invokeAllMethodsOnMainThread;
- private final boolean releaseOnFinalize;
- private volatile boolean finalized;
-
- public ObjCObjectInvocationHandler(final ID ocInstance, Class extends ObjCObject> javaClass, boolean retain) {
- this.ocInstance = ocInstance;
- javaClassName = javaClass.getSimpleName();
- invokeAllMethodsOnMainThread = shouldInvokeMethodsOnMainThread(javaClass);
- releaseOnFinalize = shouldReleaseInFinalize(javaClass);
-
- if (logging.isLoggable(Level.FINEST)) {
- CFIndex retainCount = Foundation.cfGetRetainCount(ocInstance);
- logging.finest(String.format("Creating ObjCObjectInvocationHandler for id %s, javaclass %s. retain = %s, retainCount = %s",
- ocInstance, javaClass, retain, retainCount.intValue()));
- }
-
- if (ocInstance.isNull()) {
- throw new NullPointerException();
- }
-
- if (retain) {
- if (callAcrossToMainThread()) {
- Foundation.runOnMainThread(() -> Foundation.cfRetain(ocInstance));
- } else {
- Foundation.cfRetain(ocInstance);
- }
- }
- }
-
- private boolean shouldReleaseInFinalize(Class extends ObjCObject> javaClass) {
- // Almost everything should be released in finalize, except wrappers for
- // NSAutoreleasePool.
- ReleaseInFinalize annotation = javaClass.getAnnotation(ReleaseInFinalize.class);
- if (annotation == null) {
- return true;
- }
- return annotation.value();
- }
-
- @Override
- protected void finalize() throws Throwable {
- if (finalized || !releaseOnFinalize) {
- return;
- }
- try {
- if (callAcrossToMainThread()) {
- Foundation.runOnMainThread(() -> release());
- } else {
- AutoreleaseBatcher autoreleaseBatcher = AutoreleaseBatcher.forThread(FINALIZE_AUTORELEASE_BATCH_SIZE);
- release();
- autoreleaseBatcher.operate();
- }
- super.finalize();
- } finally {
- finalized = true;
- }
- super.finalize();
- }
-
- // must be run on appropriate thread
- private void release() {
- if (ocInstance.isNull()) {
- return;
- }
- if (logging.isLoggable(Level.FINEST)) {
- CFIndex retainCount = Foundation.cfGetRetainCount(ocInstance);
- logging.finest(String.format("finalizing [%s %s], releasing with retain count = %s",
- javaClassName, ocInstance, retainCount.intValue()));
- }
- Foundation.cfRelease(ocInstance);
- }
-
- /**
- * Callback from java.lang.reflect proxy
- */
- public Object invoke(Object proxy, Method method, Object[] args) throws Exception {
- if (logging.isLoggable(Level.FINEST)) {
- logging.finest(String.format("invoking [%s %s].%s(%s)",
- javaClassName, ocInstance, method.getName(), new VarArgsUnpacker(args)));
- }
- if (isSpecialMethod(method)) {
- return invokeSpecialMethod(method, args);
- }
- return invokeCocoa(method, args);
- }
-
- private boolean isSpecialMethod(Method method) {
- return (OBJECT_TOSTRING.equals(method) ||
- OBJECT_EQUALS.equals(method) ||
- OCOBJECT_ID.equals(method));
- }
-
- private Object invokeSpecialMethod(final Method method, final Object[] args) {
- if (OBJECT_TOSTRING.equals(method)) {
- return invokeDescription();
- }
- if (OBJECT_EQUALS.equals(method)) {
- if (args[0] == null) {
- return false;
- }
- if (args[0] instanceof ObjCObject) {
- return invokeIsEqual(((ObjCObject) args[0]).id());
- }
- return false;
- }
- if (OCOBJECT_ID.equals(method)) {
- return ocInstance;
- }
- throw new IllegalArgumentException("Not a special method " + method);
- }
-
- private Object invokeDescription() {
- return sendOnThisOrMainThread(null, ocInstance, "description", String.class);
- }
-
- private Object invokeIsEqual(final ID another) {
- return sendOnThisOrMainThread(null, ocInstance, "isEqual:", Boolean.class, another);
- }
-
- protected Object invokeCocoa(final Method method, Object[] args) {
- String selectorName = selectorNameFor(method);
- Class> returnType = returnTypeFor(method);
- Object[] marshalledArgs = marshallArgsFor(args);
-
- Object result = sendOnThisOrMainThread(method, ocInstance, selectorName, returnType, marshalledArgs);
- if (method.getName().startsWith("init")) {
- handleInitMethod(result);
- }
- fillInReferences(args, marshalledArgs);
-
- if (result instanceof Pointer && method.getReturnType().equals(String.class)) {
- // special case for return char*
- return ((Pointer) result).getString(0);
- }
- if (result instanceof ID) {
- if (((ID) result).isNull()) {
- return null;
- }
- }
- return result;
- }
-
- private void handleInitMethod(Object result) {
- // Normally init methods return self, but on error they may return nil.
- // In this case the ObjC object for which this is the handler is considered
- // freed and should not be released when we are finalized.
- if (result != null) {
- return;
- }
- ocInstance = ID.fromLong(0);
- }
-
- private Object sendOnThisOrMainThread(Method method, final ID id, final String selectorName, final Class> returnType, final Object... args) {
- if (callAcrossToMainThreadFor(method)) {
- return Foundation.callOnMainThread(
- (Callable
-
-So for methods returning id or int I call objc_msgSendSuper, casting the result
-to the known return type of the method. So far so good.
-
-Now to return structs I have to call objc_msgSend_stret. This is
-complicated (not that the previous reference mentions this), because, from
-objc-runtime.h:
-
-
-/* Struct-returning Messaging Primitives (prototypes)
- *
- * For historical reasons, the prototypes for the struct-returning
- * messengers are unusual. The portable, correct way to call these functions
- * is to cast them to your desired return type first.
- *
- * For example, `NSRect result = [myNSView frame]` could be written as:
- * NSRect (*msgSend_stret_fn)(id, SEL, ...) = (NSRect(*)(id, SEL, ...))objc_msgSend_stret;
- * NSRect result = (*msgSend_stret_fn)(myNSView, @selector(frame));
- * or, without the function pointer:
- * NSRect result = (*(NSRect(*)(id, SEL, ...))objc_msgSend_stret)(myNSView, @selector(frame));
- *
- * BE WARNED that these prototypes have changed in the past and will change
- * in the future. Code that uses a cast like the example above will be
- * unaffected.
- */
-
-
-What I think this means is that despite the prototype saying that the
-function returns void and takes void*, in reality it doesn't take void* at all,
-does return a struct by value on
-the stack, and your calling code had better clean it up. In C the way to make
-this happen is to cast the function pointer to a pointer to a function that does
-return the correct struct by value, thus tricking the compiler into generating
-the correct cleanup code.
-
-If you don't have a C compiler handy to do this for you, this is going to be
-tricky. Luckily Rococoa uses JNA, which
-in turns uses libffi, which is very
-close to having a C compiler to hand at runtime. Armed with a description of the
-structure being returned, libffi sorts out the call stack after the call.
-
-It turns out that libffi doesn't only help with objc_msgSend_stret. It surprised
-me early on with Rococoa that I could call objc_msgSend as if it returned Java long,
-and everything worked OK. This didn't make sense, as a long is larger that an id
-by some 32 bits. Now, not documented in objc-runtime.h, but in the
-
-Universal Binary Programming Guidelines, Second Edition it says that you
-should pull the cast function pointer stunt with objc_msgSend as well.
-
-If your application directly calls the Objective-C runtime function objc_msgSend,
-you should always cast to the appropriate return value. For instance, for a method
-that returns a BOOL data type, the following code executes properly on a PPC Macintosh
-but might not on an Intel-based Macintosh computer:
-
-
-BOOL isEqual = objc_msgSend(string, @selector("isEqual:"), otherString);
-
-
-To ensure that the code does executes properly on an Intel-based Macintosh computer,
-you would change the code to the following:
-
-
-BOOL isEqual = ((BOOL (*)(id, SEL, id))objc_msgSend)(object, @selector("isEqual:"), otherString);
-
-
-So our long test is passing because the we are calling objc_msgSend through libffi,
-telling it that the function returns 64 bits. Libffi obligingly fixes up the stack
-as if 64 bits were returned, which it turns out they were, as objc_msgSend has
-played the same game of hack the stack as objc_msgSend_stret. Or at least that
-is my interpretation. I can't find any reference that says that this is actually
-what happens when returning a long. (Also, returning a long does not work this way on PPC.)
-
-Just when I thought that I understood the rules, I tried calling a method that
-returns NSSize. This is a struct, so objc_msgSend_stret applies. Except that it
-doesn't. A bit of Googling yielded
-this,
-which says:
-
-This fails because the struct type is NSPoint. In the i386 function
-call ABI, sufficiently small structs like NSPoint are returned in
-registers instead of in memory. In this case, you need to use
-objc_msgSend() (cast to return NSPoint). objc_msgSend_stret() only
-works for structs returned in memory. The PPC ABI returns eight-byte
-structs in memory, so objc_msgSend_stret() is the correct call there.
-
-Ooh, another special case, not even hinted at in the docs seen so far.
-The post includes a link to the
-
-Mac OS X ABI Function Call Guide which is dense, and doesn't describe when
-to use objc_msgSend or objc_msgSend_stret. It does say that 8 byte structs are
-returned in registers in IA-32 and memory for PPC-32, which I guess hints at the
-differentiation.
-
-Finally, we have double objc_msgSend_fpret(id self, SEL op, ...)
.
-The
-Objective-C 2.0 Runtime Reference says:
-
-On the i386 platform, the ABI for functions returning a floating-point value
-is incompatible with that for functions returning an integral type. On the i386
-platform, therefore, you must use objc_msgSend_fpret for functions that for
-functions returning non-integral type. For float or long double return types,
-cast the function to an appropriate function pointer type first.
-This function is not used on the PPC or PPC64 platforms.
-
-But Rococoa has been happily passing test which return float and double from
-objC_msgSend on Intel, as I didn't know about this function. In fact, the only use I've yet found for
-objc_msgSend_fpret is allowing me to interpret the stret in objc_msgSend_stret
-as STructRET!
-
-Outstanding Questions
-
-
-- Am I right so far, or am have I got the wrong end of the stick?
-
-- If both objc_msgSend_stret and objc_msgSend hack the stack to return different sized
-return values, why are there 2 functions?
-
-- Should I call objc_msgSend_stret when returning longs on PPC?
-
-- Do I really need to call objc_msgSend_fpret for floating point on Intel?
-
-- Is there a comprehensive reference to this subject that I'm missing?
-
-
-And Some Answers
-
-Pending a re-write of this page, some very helpful answers can be found on the
-
-Cocoa-dev Mailing List.
-
-
\ No newline at end of file
diff --git a/www/rococoa-acknowledgements.html b/www/rococoa-acknowledgements.html
deleted file mode 100644
index 150102f9..00000000
--- a/www/rococoa-acknowledgements.html
+++ /dev/null
@@ -1,32 +0,0 @@
-
-
-Rococoa Acknowledgements
-
-
-
-
-
-Rococoa Acknowledgements
-
-Rococoa owes much to the following people and organisations
-
-
-- JNA does all the heavy
-lifting of calling into Cocoa and marshaling parameters. Timothy Wall
-also added pass struct by value and other extension points
-to make our life simpler.
-- Paul Loy was the alpha guinea-pig.
-
-- Simon Taylor, Gareth Sylvester-Bradley and Dion Crannitch for Objective-C
-help.
-- Richard Care, Matt Bowers, Andy Collins and Morgan David let it go.
-- Apple Inc produced Quicktime,
-Java on Mac OS, the Cocoa-Java Bridge and Quicktime for Java, then killed
-at least 2 of them.
-
-
-If you know Java and Cocoa your name could be on this list!
-Get involved!
-
-
-
\ No newline at end of file
diff --git a/www/rococoa-building.html b/www/rococoa-building.html
deleted file mode 100644
index 40fd6609..00000000
--- a/www/rococoa-building.html
+++ /dev/null
@@ -1,85 +0,0 @@
-
-
-Building Rococoa
-
-
-
-
-
-
-Building Rococoa
-
-Prequisites
-
-
-- Maven 2
-- XCode 3.0
-
-
-
I build on an early MacBook Pro, running 10.5.2. I haven't yet tried building on PPC. Early
-builds were on Tiger, but I haven't gone back to check that it still does.
-
-Command-line Build Steps
-
-
-mkdir rococoa
-
-svn checkout https://rococoa.dev.java.net/svn/rococoa/trunk/rococoa . --username username
-
-- The JNA library is not packaged for Maven. Acquire jna.jar (currently v3.0.1), either from
-http://jna.dev.java.net
-or from the lib directory of a prebuilt Rococoa distribution. Install it into the
-Maven repository with
-
-mvn install:install-file -DgroupId=net.java.dev -DartifactId=jna \
- -Dversion=3.0.1 -Dpackaging=jar -Dfile=/path/to/file
-
--
-Build and test with
-
mvn test
-If all is successful, you should have a screenful of output, culminating in
-
-Results :
-[surefire] Tests run: 58, Failures: 0, Errors: 0
-
-[INFO] ------------------------------------------------------------------------
-[INFO] BUILD SUCCESSFUL
-[INFO] ------------------------------------------------------------------------
-[INFO] Total time: 1 minute 46 seconds
-[INFO] Finished at: Fri Feb 22 11:39:09 GMT 2008
-[INFO] Final Memory: 5M/10M
-[INFO] ------------------------------------------------------------------------
-
-For some reason the native compile step takes an age to fire up xcodebuild on
-my Leopard MacBook, but then XCode itself takes an age to start as well. Your
-mileage may vary.
-
-
-Other interesting Maven goals include
-
-mvn clean
-mvn site
generate javadoc and stuff
-mvn package
to build the distribution.
-
-
-Developing using Eclipse and XCode
-
-To generate an Eclipse project for the Maven build
-
-mvn eclipse:eclipse
-
-This will generate the .classpath and .project files for an Eclipse project,
-that you can import into a workspace. The dependent libraries will be specified
-relative to a Classpath Variable M2_REPO
. This should be set (
-Eclipse/Preferences.../Java/Build Path/Classpath Variables
) to
-~/.m2/repository
.
-
-If all is well the tests in rococoa/src/test/java
should pass when
-run with Eclipse's JUnit test runner.
-
-
-
-
-
-
-
diff --git a/www/rococoa-help-wanted.html b/www/rococoa-help-wanted.html
deleted file mode 100644
index 23aa3b96..00000000
--- a/www/rococoa-help-wanted.html
+++ /dev/null
@@ -1,40 +0,0 @@
-
-
-Rococoa Needs Help
-
-
-
-
-
-Rococoa Needs Help
-
-Review
-
-I'm a Java hacker, and know very little Objective-C. Actually, I now know
-more about the internals than I could possibly want to, but I'm really not
-fluent in the ways of Cocoa.
-
-I'd really appreciate a review by someone who does know Objective-C, and
-ideally some Java, to see if there are any issues that I haven't thought
-about
-
-If you're really a Objective-C wizard, maybe you could look over
-Returning values from objc_msgSend etc
-and answer the questions there.
-
-Development
-
-If you'd like to help with development, that would be great too.
-
-Contrib
-
-Whilst writing Java wrappers for Cocoa classes isn't hard, it would be nice
-if there was more available out of the box. If you've wrapped an Objective-C
-class we don't have, or extended an available one, please send them back.
-
-In all cases,
-posting
-to the user or dev mailing list is probably the best way to get attention
-
-
-
\ No newline at end of file
diff --git a/www/rococoa-howto.html b/www/rococoa-howto.html
deleted file mode 100644
index 4a2f8ff9..00000000
--- a/www/rococoa-howto.html
+++ /dev/null
@@ -1,85 +0,0 @@
-
-
-Rococoa How To
-
-
-
-
-
-
-Rococoa How To
-
-Download
-
-Download your choice of archive from
-here.
-
-
Link
-
-Unarchive your download. Add dist/rococoa-n.n.n.jar
and
-the jars in lib
to your classpath.
-
-Add bin
to your java.library.path
.
-
-
-Create a Java class representation of an Objective-C class
-
-For now, see the Whistlestop Tour.
-
-
Create an Objective-C instance
-
-For now, see the Whistlestop Tour.
-
-
Call methods on an Objective-C object
-
-For now, see the Whistlestop Tour.
-
-
Manage Memory
-
-See Memory Management.
-
-
Call methods with more than one parameter
-
-Call methods that have the name of a Java keyword
-
-Not define Objective-C classes
-
-Simplify factory methods
-
-Add Java behaviour to Rococoa wrappers
-
-Pass structures to methods
-
-Return structures from methods
-
-Debug
-
-Log calls
-
-Call static Mac functions
-
-Get more help
-
-See more examples
-
-Use Quicktime
-
-
-
-Build Rococoa
-
-See Building Rococoa.
-
-See what's going on
-
-Turn the log level up : org.rococoa.level=FINEST
.
-This will log all message sending through Rococoa.
-
-Help
-
-See Help Wanted.
-
-
-
-
-
diff --git a/www/rococoa-limitations.html b/www/rococoa-limitations.html
deleted file mode 100644
index 19565146..00000000
--- a/www/rococoa-limitations.html
+++ /dev/null
@@ -1,28 +0,0 @@
-
-
-Rococoa Limitations
-
-
-
-
-
-Rococoa Limitations
-
-For a complete list of logged defects and issues, apply
-here.
-
-Cannot return long from Objective-C methods on PPC
-
-
-
-Cannot return small structs (except NSSize) on Intel
-
-
-
-Callbacks from Objective-C currently naff
-
-JavaProxyTest
shows how it's currently done, even the names of
-classes let you know that it's not done right.
-
-
-
\ No newline at end of file
diff --git a/www/rococoa-memory.html b/www/rococoa-memory.html
deleted file mode 100644
index ec887875..00000000
--- a/www/rococoa-memory.html
+++ /dev/null
@@ -1,73 +0,0 @@
-
-
-Rococoa Memory Management
-
-
-
-
-
-
-Rococoa Memory Management
-
-While Java has garbage collection, Objective-C memory management (prior to v2)
-is based around manual reference counting.
-
-
-Essentially, objects have a reference count, 1 when first created, and
-incremented by calling - (id)retain
. On calling - (void)release
-the count is decremented, and if it has fallen to 0, the object's memory is reclaimed.
-
-Conventionally, newly created objects are put into an autorelease pool, which
-retain
s them, and when the pool itself is reclaimed, all of its
-objects are release
d. If an object should live longer
-than the current pool, then client code should retain
the object
-itself, and release when done with.
-
-Rococoa automatically retain
s Objective-C objects wrapped by the
-Java NSObject, and release
s them when the Java NSObject is garbage
-collected. So why am I bothering you with all this detail? Because you need an
-autorelease pool in the first place.
-
-At the moment the way Rococoa creates a pool is through
-ID Foundation.createPool()
, releasing it with
-void Foundation.releasePool(ID pool)
. It's your job to make sure that
-there is a current pool before you invoke any Objective-C methods which need to
-allocate from it. For example, RococoaTestCase says
-
-
- public void runBare() throws Throwable {
- pool = Foundation.createPool();
- try {
- super.runBare();
- } finally {
- Foundation.releasePool(pool);
- }
- }
-
-
-thus giving each test run its own pool.
-
-Helpfully, if you forget to create a pool, the Objective-C runtime will gently
-chastise you on stderr with messages like
-*** _NSAutoreleaseNoPool(): Object 0x1222a0 of class NSCFString autoreleased with no pool in place - just leaking
-
-Note that while a pool is required during allocation, objects can outlive
-their pool, and will if you keep a reference to a Java NSObject.
-
-I plan to replace those nasty calls to Foundation with a Java NSAutoreleasePool
-which you can just hang onto by reference. But the current system works, and it's
-best to be conservative about memory, as accessing an already disposed object
-will crash your app. Actually I'm pretty sure that there's at least one bug hiding in there
-already - a small prize to anyone who finds it.
-
-Finally, note that if your code has been called by the Cocoa event thread (as
-a result of a native button press for example) then Cocoa will already have
-arranged a pool for you, and will dispose of it once the event is done.
-
-Really finally, I've no idea how this all relates to Objective-C garbage collection,
-introduced in v2, and am hoping that someone will be able to tell me.
-
-
-
-
-
diff --git a/www/rococoa-quicktime.html b/www/rococoa-quicktime.html
deleted file mode 100644
index 6c3549e3..00000000
--- a/www/rococoa-quicktime.html
+++ /dev/null
@@ -1,66 +0,0 @@
-
-
-Quicktime and Rococoa
-
-
-
-
-
-Quicktime and Rococoa
-
-Rococoa was written to allow the use of the
-QTKit framework
-from Java. It's by no means finished, but it is functional.
-
-The package org.rococoa.quicktime
contains the work so far on
-wrapping QTKit. An example of using the code to play a Quicktime Movie can be
-found in PlayMovieExample
.
-
-
-public class PlayMovieExample {
-
- static final File FILE = new File("testdata/DrWho.mov");
-
- static {
- // load library
- @SuppressWarnings("unused")
- QTKit instance = QTKit.instance;
- }
-
- public static void main(String[] args) {
- QTMovieView movieView = QTMovieView.CLASS.create();
- movieView.setControllerVisible(true);
- movieView.setPreservesAspectRatio(true);
-
- MovieComponent component = new MovieComponent(movieView);
- JFrame frame = new JFrame();
- frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- frame.getContentPane().add(component);
-
- QTMovie movie = QTMovie.movieWithFile_error(FILE.getPath(), null);
- movieView.setMovie(movie);
- movie.gotoBeginning();
- frame.pack();
- frame.setVisible(true);
- }
-
-}
-
-
-QTMovieTest
gives other examples.
-
-One of the complications involved in using QTKit from Java is that all access
-to QTKit must be on the Cocoa event thread, which is not the same as the
-AWT event thread. The QTMovieView
and QTMovie
classes are
-annotated with @RunOnMainThread
- Rococoa dispatches
-all method calls to such classes on the Cocoa event thread. If you plan to extend
-the QTKit coverage your classes may need to be similarly annotated.
-
-You may notice the absence of calls to Foundation.createPool()
-in the code above. I'm still trying to get my head around this. Because the method
-calls are all dispatched on the Cocoa event thread, and Cocoa conveniently creates
-an autorelease pool for event handling code, the calls themselves are in the
-context of a pool. I don't believe that this is the case for parameters that you
-pass in though, so bear with my while I think it through.
-
-
\ No newline at end of file
diff --git a/www/rococoa-whistlestop.html b/www/rococoa-whistlestop.html
deleted file mode 100644
index 0ce1ae40..00000000
--- a/www/rococoa-whistlestop.html
+++ /dev/null
@@ -1,288 +0,0 @@
-
-
-Rococoa Whistlestop Tour
-
-
-
-
-
-Rococoa Whistlestop Tour
-
-First download and unzip the latest release. Add
-dist/rococoa-n.n.n.jar
and the jars in lib
to
-your classpath. Add bin/librococoa.dylib
to your
-java.library.path
(the easiest way to do this is to drop it into
-the directory from which you run code).
-
-I'm about to gloss over some memory management issues. Please don't
-ship code based on Rococoa without getting at least as far as
-that section.
-
-Now choose a Cocoa class you'd like to represent in Java. Let's say
-NSMutableArray. Create a Java interface called NSMutableArray, extending
-org.rococoa.NSObject
.
-
-
-public interface NSMutableArray extends NSObject {
-}
-
-
-To create an NSMutableArray in Objective-C we would call the class (static)
-method + (id)arrayWithCapacity:(NSUInteger) numItems
. We don't have
-any way to add static methods to a Java interface, so add a nested class and add
-the desired method to that.
-
-
-public interface NSMutableArray extends NSObject {
-
- public interface _Class extends NSClass {
- NSMutableArray arrayWithCapacity(int numItems);
- }
-}
-
-
-The nested class name _Class
is just a convention. The method
-name should be the same as the Objective-C name, and primitive arguments just
-map to their obvious Java equivalents. The id
returned we know
-represents an instance of NSMutableArray, so we may as well say so.
-
-Now we need an instance of this inner class to call our method. Rococoa will
-create this for us, if we tell it the name of the Objective-C class that we are
-wrapping, and the type of the wrapper. I call these statics
-CLASS
.
-
-
-public interface NSMutableArray extends NSObject {
-
- public static final _Class CLASS = Rococoa.createClass("NSMutableArray", _Class.class);
-
- public interface _Class extends NSClass {
- NSMutableArray arrayWithCapacity(int numItems);
- }
-}
-
-
-Now everything is in place to create an instance, let's do that and call the
-NSObject method - (NSString *)description
, mapped in NSObject.java
-as String description()
.
-
-
-public class NSMutableArrayTest extends RococoaTestCase {
-
- public void test() {
- NSMutableArray array = NSMutableArray.CLASS.arrayWithCapacity(3);
- assertEquals("(\n)", array.description());
- }
-}
-
-
-OK, so it's not much of a description, but if it works, you've created an
-Objective-C object and called a method on it. Let's add some more interesting
-operations.
-
-Provided that it is implemented in Objective-C, adding an operation is simply
-a question of adding to our Java interface. So in the parent of NSMutableArray,
-NSArray, we find - (NSUInteger)count
. We can add that to our
-interface and then call it.
-
-
-public interface NSMutableArray extends NSObject {
-
- public static final _Class CLASS = Rococoa.createClass("NSMutableArray", Class.class);
- public interface _Class extends NSClass {
- NSMutableArray arrayWithCapacity(int numItems);
- }
-
- int count();
-}
-
-public class NSMutableArrayTest extends RococoaTestCase {
-
- public void test() {
- NSMutableArray array = NSMutableArray.CLASS.arrayWithCapacity(3);
- assertEquals("(\n)", array.description());
-
- assertEquals(0, array.count());
- }
-}
-
-
-Hmmm, pretty boring, but necessary if we're going to test -
-(void)addObject:(id)anObject
.
-
-That (id)
parameter is Objective-C's way of saying any NSObject,
-so the corresponding Java code is:
-
-
-public interface NSMutableArray extends NSObject {
-
- public static final _Class CLASS = Rococoa.createClass("NSMutableArray", _Class.class);
- public interface _Class extends NSClass {
- NSMutableArray arrayWithCapacity(int numItems);
- }
-
- int count();
-
- void addObject(NSObject anObject);
-}.
-
-
-The only NSObject subclass that we've seen so far is our NSMutableArray (OK,
-_Class is as well, smarty-pants), and adding an array to an array is too
-hardcore, so for our test be glad that Rococoa has already implemented some of
-NSString, and a factory method NSString stringWithString(java.lang.String
-string)
.
-
-
-public class NSMutableArrayTest extends RococoaTestCase {
-
- public void test() {
- NSMutableArray array = NSMutableArray.CLASS.arrayWithCapacity(3);
- assertEquals(0, array.count());
-
- NSString aString = NSString.stringWithString("Hello"));
- array.addObject(aString);
- assertEquals(1, array.count());
- assertEquals("(\n Hello\n)", array.description());
- }
-}
-
-
-As passing strings around is pretty fundamental, Rococoa marsalls them
-specially. If you declare a parameter as java.lang.String, Rococoa will create
-the NSString for you.
-
-
-public interface NSMutableArray extends NSObject {
-
- public static final _Class CLASS = Rococoa.createClass("NSMutableArray", _Class.class);
- public interface _Class extends NSClass {
- NSMutableArray arrayWithCapacity(int numItems);
- }
-
- int count();
- void addObject(NSObject anObject);
-
- void addObject(String string);
-
-}
-
-public class NSMutableArrayTest extends RococoaTestCase {
-
- public void test() {
- NSMutableArray array = NSMutableArray.CLASS.arrayWithCapacity(3);
- assertEquals(0, array.count());
- array.addObject(NSString.stringWithString("Hello"));
-
- array.addObject("Goodbye");
- assertEquals(2, array.count());
- assertEquals("(\n Hello,\n Goodbye\n)",
- array.description());
- }
-}
-
-
-The same is true for returning strings.
-
-
-public interface NSMutableArray extends NSObject {
-
- public static final _Class CLASS = Rococoa.createClass("NSMutableArray", _Class.class);
- public interface _Class extends NSClass {
- NSMutableArray arrayWithCapacity(int numItems);
- }
-
- int count();
- void addObject(NSObject anObject);
- void addObject(String string);
-
- String objectAtIndex(int index);
-
-}
-
-public class NSMutableArrayTest extends RococoaTestCase {
-
- public void test() {
- NSMutableArray array = NSMutableArray.CLASS.arrayWithCapacity(3);
- assertEquals(0, array.count());
- array.addObject(NSString.stringWithString("Hello"));
- array.addObject("Goodbye");
- assertEquals(2, array.count());
-
- String first = array.objectAtIndex(0);
- assertEquals("Hello", first);
- assertEquals("Goodbye", array.objectAtIndex(1));
- }
-}
-
-
-Of course we can't overload String objectAtIndex(int index)
and
-add the more generic NSObject objectAtIndex(int index)
. Let's go
-back to returning NSObject.
-
-
-public interface NSMutableArray extends NSObject {
-
- public static final _Class CLASS = Rococoa.createClass("NSMutableArray", _Class.class);
- public interface _Class extends NSClass {
- NSMutableArray arrayWithCapacity(int numItems);
- }
-
- int count();
- void addObject(NSObject anObject);
- void addObject(String string);
-
- NSObject objectAtIndex(int index);
-}
-
-
-Now we can compare with an NSString.
-
-
-public class NSMutableArrayTest extends RococoaTestCase {
-
- public void test() {
- NSMutableArray array = NSMutableArray.CLASS.arrayWithCapacity(3);
- assertEquals(0, array.count());
- array.addObject(NSString.stringWithString("Hello"));
- array.addObject("Goodbye");
- assertEquals(2, array.count());
-
- NSObject first = array.objectAtIndex(0);
- assertEquals(NSString.stringWithString("Hello"), first);
- }
-}
-
-
-Alternatively we can downcast to NSString using Rococoa.cast(NSObject
-object, Class desiredType)
.
-
-
-public class NSMutableArrayTest extends RococoaTestCase {
-
- public void test() {
- NSMutableArray array = NSMutableArray.CLASS.arrayWithCapacity(3);
- assertEquals(0, array.count());
- array.addObject(NSString.stringWithString("Hello"));
- array.addObject("Goodbye");
- assertEquals(2, array.count());
-
- NSObject first = array.objectAtIndex(0);
- assertEquals(NSString.stringWithString("Hello"), first);
-
- NSString firstAsString = Rococoa.cast(first, NSString.class);
- assertEquals("Hello", firstAsString.toString());
- assertEquals("Goodbye",
- Rococoa.cast(array.objectAtIndex(1), NSString.class).toString());
-
- }
-}
-
-
-That's the end of our quick tour. I thought there were too many apostrophes,
-but if that hasn't put you off, please see the How
-To for more information.
-
-
-
-
diff --git a/www/rococoa-wiki.html b/www/rococoa-wiki.html
deleted file mode 100644
index 7dd49a5a..00000000
--- a/www/rococoa-wiki.html
+++ /dev/null
@@ -1,40 +0,0 @@
-
-
-Rococoa Wiki
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/www/rococoa.css b/www/rococoa.css
deleted file mode 100644
index e219d316..00000000
--- a/www/rococoa.css
+++ /dev/null
@@ -1,17 +0,0 @@
-.new {
- font-weight: bold;
-}
-pre.block {
- background-color: LightGoldenRodYellow;
- white-space: pre;
- font-family: courier;
- font-size: 90%;
-}
-code {
- white-space: pre;
- font-family: courier;
- font-size: 90%;
-}
-q {
- font-style: italic;
-}
\ No newline at end of file
pFad - Phonifier reborn
Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: