Generated header file

Hi,

When creating a darwin static library what is the purpose of the generated header file ?

Am I meant to be able to consume that in objc ?

For example

// Header generated by RemObjects Elements for Cocoa 

#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>

#import <objc/NSObject.h>
#import <Foundation/Foundation.h>

@class SomeClass;

@interface SomeClass: NSObject

- (String * _Null_unspecified)someMethod:(Void);

@property (assign) Boolean someProperty;

@end

Shouldn’t the method be declared as -(NSString*) someMethod;

Cheers,
John

Globals and [Cocoa] classes, yes. and later [Swift] ones. Island classes of course Onjective-C he’s no idea what to do with; this should not show up in the header (if they do let me known that’s a bug; funnily I just thought about verifying this myself, just yesterday)…

Hard do say without more info. if they use NSString, then yes. if they use Island String, they probably shouldn’t be epxosed at all.

This is my test solution.

DifferentOutput.zip (3.2 MB)

For a start the generated output doesn’t seem right because Im trying to use a header file in an xcode watch os project and I needed to change the output from

- (String * _Null_unspecified)someMethod:(Void);

to

-(NSString*) someMethod;

to build in xcode.

If I have a cocoa class ie a class marked with the Cocoa attribute should a String be generated as NSString or do I have to do that myself ?

OxyLibrary is a multi target, dynamic is dynamic and Static is a static library.

The model off the class has nothing to do with it. What “String” means depends on your uses clause and default object model.

In an Island project with default object model of Island (the default), “String” will be an IslandString (RemObjects.Elements.System.String).

In a Toffee project, a ToffeeV2 or an Island project with default object model set to “Cocoa”, it will be CocoaString, ie Foundation.NSString.

Classes in one model can take and return classes from another, so in

  [Cocoa]
  SomeClass = public class
  public
    property someProperty:Boolean;
    method someMethod:String;
    begin
      exit 'HelloWorld';
    end;

someMethod will return Ann IslandString, not an NSString. As such, it will be callable but useless for Objective-C, as Objective-C cannot handle the result pointer (and does indeed not know what “String” is.

So String will be whatever String is, no matter what object type you’re in. its just a type name. You could define “type String = public Boolean” further up, and now String is “DynamicLibrary.String”, which is an alias to Boolean ;).


As an aside, this part seems like an unrelated bug:

Logged as bugs://E25601. for the bad void in the method sig.

I got some more complex header files building in xcode. I noticed there are some things I have to change

I had to change int32 to int, Double to double, single to float and the place of pointers seems wrong ie NSDate *something should be NSDate* something

Spacing shouldn’t matter for where the asterisk goes, though convention IIRC is to have it with the name, not the type?

bugs://E25601 was closed as fixed.

1 Like

Logged as bugs://E25605. (for int, double etc)

bugs://E25605 was closed as fixed.

I think I fixed this but if you notice something else, let me know.

1 Like

Thanks. I regenerated a header file and the only issue I had was string. I had a number of places where it used PlatformString and others where it used String. There are also places where it misses the *

I just went through and changed everything to NSString * Im not really sure what the best strategy is because my library compiles for .net, island and toffee.

It seems to handle List<> properly that is changed to NSMutableArray. In header file generation can PlatformString be changed to NSString ?

i’d really need some concrete examples/test case. If List gets emitted properly as NSMutableArray, i’d expect ll mapped types to be…

Ok I’ll do a testcase

1 Like

ToffeeWatchLibrary 2.zip (288.2 KB)

This

  Another = public class
  end;
  
  Something = public class
  private
  protected
  public
    property interval:String;
    property collection:List<Another>;
  end;

It ends up in the watch header file as

@interface Something: NSObject


@property (strong) /* mapped */ PlatformString interval;
@property (assign) /* mapped */ NSMutableArray * _Null_unspecified collection;

@end

Based on it using NSMutableArray, I would expect PlatformString to emit whatever its mapped to ?

Logged as bugs://E25633.

bugs://E25633 was closed as fixed.