* Added missing UndefinedClasses.inc to /uikit

* Changed the PHP variable which was causing the parser to not produce iphone headers
  * Added /utils/iphone directory which is the last safe version of the parser. This is because future versions of the parser will likely break the iphone parsing ability before it can be fully restored.

git-svn-id: trunk@14454 -
This commit is contained in:
josef 2009-12-20 14:29:12 +00:00
parent ca6eabd55d
commit b99a49d982
7 changed files with 5026 additions and 2 deletions

5
.gitattributes vendored
View File

@ -1329,6 +1329,7 @@ packages/cocoaint/src/foundation/NSZone.inc svneol=native#text/plain
packages/cocoaint/src/iPhoneAll.pas svneol=native#text/plain
packages/cocoaint/src/patches/NSBundle.patch svneol=native#text/plain
packages/cocoaint/src/uikit/UIKit.inc svneol=native#text/plain
packages/cocoaint/src/uikit/UndefinedClasses.inc svneol=native#text/plain
packages/cocoaint/src/webkit/DOMAbstractView.inc svneol=native#text/plain
packages/cocoaint/src/webkit/DOMAttr.inc svneol=native#text/plain
packages/cocoaint/src/webkit/DOMCDATASection.inc svneol=native#text/plain
@ -1481,6 +1482,10 @@ packages/cocoaint/utils/Make[!!-~]Cocoa[!!-~]Headers.txt svneol=native#text/plai
packages/cocoaint/utils/Make[!!-~]iPhone[!!-~]Headers.txt svneol=native#text/plain
packages/cocoaint/utils/Using[!!-~]Installer[!!-~]Script.txt svneol=native#text/plain
packages/cocoaint/utils/install_objp.sh svneol=native#text/plain
packages/cocoaint/utils/iphone/iPhone[!!-~]Parser.txt svneol=native#text/plain
packages/cocoaint/utils/iphone/objp_parser.php svneol=native#text/plain
packages/cocoaint/utils/iphone/parser.php svneol=native#text/plain
packages/cocoaint/utils/iphone/pascocoa_parser.php svneol=native#text/plain
packages/cocoaint/utils/objp_parser.php svneol=native#text/plain
packages/cocoaint/utils/parser.php svneol=native#text/plain
packages/cocoaint/utils/pascocoa_parser.php svneol=native#text/plain

View File

@ -0,0 +1,13 @@
{ Private instance variables from UITextField.h }
UITextFieldBorderView = id;
UITextFieldBackgroundView = id;
UITextFieldLabel = id;
UITextFieldAtomBackgroundView = id;
{ Private instance variables from UITextView.h }
WebFrame = id;
WebCoreFrameBridge = id;
DOMHTMLElement = id;
UIDelayedAction = id;
UIWebDocumentView = id;

View File

@ -0,0 +1 @@
This is the latest version of the iphone parser archived here so that future changes (to the Objective Pascal syntax) don't affect the iphone parsing ability.

View File

@ -0,0 +1,560 @@
<?php
class TObjPParser extends TPasCocoaParser {
var $objc_id = "id"; // Default type for generic objects
var $objc_id_real = "id"; // The real type of generic objects (id)
var $sel_string = "SEL";
var $trailing_underscore = true;
var $print_header_references = false;
// ignore these classes when testing for ivar size
var $ignore_class_ivar_comparison = array( "NSNibOutletConnector", "NSNibConnector", "NSNibControlConnector", "NSPredicateEditorRowTemplate", "NSSegmentedCell",
"NSSimpleHorizontalTypesetter", "NSInvocation", "NSPointerFunctions", "NSConstantString");
var $reserved_keywords = array( "const", "object", "string", "array", "var", "set", "interface", "classname", "unit",
"self", "type", "raise", "property", "to", "for", "with", "function", "procedure", "result",
"pointer", "create", "new", "dispose", "label", "packed", "record", "char", "class", "implementation",
// identifiers from NSObject
"zone",
);
var $replace_types = array( "void"=>"Pointer", "BOOL"=>"Boolean", "long"=>"clong", "int"=>"cint",
"unsigned long"=>"culong", "unsigned short"=>"cushort", "void *"=>"Pointer", "unsigned int"=>"cuint",
"Class"=>"Pobjc_class", "uint"=>"cuint",
"uint8_t"=>"byte", "signed int"=>"cint", "const char"=>"char", "const void"=>"Pointer",
"const uint8_t"=>"byte", "unsigned"=>"cuint", "int32_t"=>"longint", "float"=>"single",
"unsigned long long"=>"culonglong", "int64_t"=>"clonglong", "uint32_t"=>"cardinal", "uint16_t"=>"word",
"unsigned char"=>"char", "short"=>"cshort", "double"=>"double", "long long"=>"clonglong",
// ??? new in instance var parser: (add to main section eventually)
"signed char"=>"char", "uint64_t"=>"qword",
// work-arounds - the type replacement needs regex to handle with spaces I guess
"void*"=>"Pointer",
// macros
"IBAction"=>"void", "IBOutlet"=>"",
// special pointers
"const id *"=>"NSObjectArrayOfObjectsPtr", "Protocol *"=>"Protocol", "NSObject *"=>"NSObject",
"const char *"=>"PChar", "const void *"=>"Pointer", "unsigned char *"=>"Pointer", "char *"=>"PChar",
"unsigned *"=>"Pointer", "unichar *"=>"PWideChar", "const unichar *"=>"PWideChar",
);
// These methods require that the last parameter append a trailing underscore (if $trailing_underscore is on)
var $trailing_underscore_methods = array("- (void)copy:(id)sender;", "- (void)setNeedsDisplay:(BOOL)flag;");
// We use direct Cocoa classes now always
var $toll_free_bridge = array();
var $ignore_methods = array("observationInfo");
// Converts an Objective-c method name to Pascal
function ConvertObjcMethodName ($method) {
$params = explode(":", $method);
$name = "";
if (count($params) > 1) {
foreach ($params as $value) {
if (eregi("([a-zA-Z0-9]+)$", $value, $captures)) $name .= $captures[1]."_";
}
} else {
if (eregi("([a-zA-Z0-9]+)(;)*$", $params[0], $captures)) $name .= $captures[1]."_";
}
// clean it up
if ($this->trailing_underscore) {
if (!in_array($method, $this->trailing_underscore_methods)) $name = trim($name, "_");
}
$name = $this->ReplaceObjcType($name);
return $name;
}
// We use direct objc classes now so we don't need to replace them with references like in PasCocoa
function ReplaceNSTypesWithRef ($string) {
return $string;
}
// Converts an Objective-C method to Pascal format
function ConvertObjcMethodToPascal ($class, $source, $parts, $protected_keywords, $has_params) {
// remove deprecated macros from method source
$source = eregi_replace("[[:space:]]*DEPRECATED_IN_MAC_OS_X_VERSION_[0-9]+_[0-9]+_AND_LATER", "", $source);
// replace "hinted" params comment with hinted type
if ($this->replace_hinted_params) {
// param string
if (eregi("(/\*[[:space:]]*(.*)[[:space:]]*\*/)", $parts[4], $captures)) {
// ??? change the parameter to the hinted type
//$parts[4] = eregi_replace("(/\*.*\*/)", $captures[2], $parts[4]);
//$parts[4] = trim($parts[4], " ");
}
// return type
if (eregi("(/\*[[:space:]]*(.*)[[:space:]]*\*/)", $parts[2], $captures)) $parts[2] = $captures[2];
//print_r($parts);
} else { // remmove comments from params and return type
$parts[4] = eregi_replace("(/\*.*\*/)", "", $parts[4]);
$parts[4] = trim($parts[4], " ");
$parts[2] = eregi_replace("(/\*.*\*/)", "", $parts[2]);
$parts[2] = trim($parts[2], " ");
}
$return_type_clean = $parts[2];
// perform preformatting before attempting to protect keywords
$parts[2] = $this->FormatObjcType($parts[2], $modifiers);
$parts[4] = $this->FormatObjcParams($parts[4]);
// protect keywords in the parameter and return type
if (count($protected_keywords) > 0) {
foreach ($protected_keywords as $keyword) {
$parts[4] = istr_replace_word($keyword, $keyword."_", $parts[4]);
$parts[2] = istr_replace_word($keyword, $keyword."_", $parts[2]);
}
}
if ($has_params) {
$name = $this->ConvertObjcMethodName($source);
// merge default protected keywords for the class/category
if ($this->default_protected["*"]) $protected_keywords = array_merge($this->default_protected["*"], $protected_keywords);
if ($this->default_protected[$class]) $protected_keywords = array_merge($this->default_protected[$class], $protected_keywords);
$param_array = $this->ConvertObjcParamsToPascal($parts[4], $protected_keywords, $variable_arguments);
$params = "(".$param_array["string"].")";
$params_with_modifiers = "(".$param_array["string_with_modifiers"].")";
} else {
$params = "";
$params_with_modifiers = "";
$name = $parts[3];
$param_array = null;
$variable_arguments = false;
}
// protect method name from keywords
if ($this->IsKeywordReserved($name)) $name .= "_";
// replace objc type
$return_type = $this->ConvertReturnType($return_type_clean);
$virtual = "";
$class_prefix = "";
// determine the type based on return value
if (ereg($this->regex_procedure_type, $return_type_clean)) {
$kind = "procedure";
} else {
$kind = "function";
}
// determine if this is a class method
if ($parts[1] == "+") {
$class_prefix = "class ";
// These methods probably return the an allocated instance of the class, a typical convenience method.
// ??? Ack! $class may be the category or protocol name
//if ($return_type == $this->objc_id) $return_type = $class;
}
// Replace SEL with the string equivalent
if ($this->register_selectors) {
$params_with_modifiers = str_replace_word("SEL", $this->sel_string, $params_with_modifiers);
}
// make method templates
if ($kind != "function") {
if ($variable_arguments) $modifier .= " varargs;";
$method = "$class_prefix$kind $name$params_with_modifiers;$modifier$virtual";
$method_template = "[KIND] [PREFIX]$name"."[PARAMS];$modifier";
} else {
if ($variable_arguments) $return_type = "$return_type; varargs";
$method = $class_prefix."function $name$params_with_modifiers: $return_type;$modifier$virtual";
$method_template = "[KIND] [PREFIX]$name"."[PARAMS]: [RETURN];$modifier";
$method_template_function = "function [PREFIX]$name"."[PARAMS]: [RETURN];$modifier";
}
$method_template_procedure = "procedure [PREFIX]$name"."[PARAMS];$modifier";
$method_template_function = "function [PREFIX]$name"."[PARAMS]: [RETURN];$modifier";
// ??? DEBUGGING
//print("$method\n");
// build structure
$struct["def"] = $method;
$struct["template"] = $method_template;
$struct["template_function"] = $method_template_function;
$struct["template_procedure"] = $method_template_procedure;
$struct["objc_method"] = $this->CopyObjcMethodName($source);
$struct["class_prefix"] = $class_prefix;
//$struct["def_objc"] = eregi("(.*);", $source, $captures[1]);
if ($return_type == "void") $return_type = "";
$struct["return"] = $return_type;
if (in_array($return_type, $this->cocoa_classes)) $struct["returns_wrapper"] = true;
$struct["param_string_clean"] = trim($params, "()");
$struct["param_string_clean_with_modifiers"] = trim($params_with_modifiers, "()");
$struct["param_string"] = $params;
$struct["param_string_with_modifiers"] = $params_with_modifiers;
$struct["param_array"] = $param_array["pairs"];
$struct["param_list"] = $param_array["list"];
$struct["class"] = $class;
$struct["name"] = $name;
$struct["kind"] = $kind;
if ($struct["param_array"] != null) $struct["has_params"] = true;
// FPC bug work around
if (strlen($name) > $this->maximum_method_length) {
$struct["can_override"] = false;
print(" # WARNING: method $name can't override because the name is too long\n");
$this->warning_count ++;
}
return $struct;
}
function InsertPatches ($header) {
$path = "$this->root/patches/".$header["name_clean"].".patch";
if ($handle = @fopen($path, "r")) {
$text = ReadTextFile($path);
$this->PrintOutput(0, $text);
fclose($handle);
}
}
function HeaderContainsPatch ($header) {
if ($handle = @fopen("$this->root/patches/".$header["name_clean"].".patch", "r")) {
fclose($handle);
return true;
}
}
// Prints all classes from the header in Objective-P FPC format
function PrintHeader ($header) {
global $version;
$this->output = fopen($header["path"], "w+");
$this->PrintOutput(0, "{ Parsed from ".ucfirst($header["framework"]).".framework ".$header["name"]." }");
$date = date("D M j G:i:s T Y");
$this->PrintOutput(0, "{ Version $version - $date }");
$this->PrintOutput(0, "");
$macro = strtoupper(substr($header["name"], 0, (strripos($header["name"], "."))));
/*
if ($header["classes"]) {
$this->PrintOutput(0, "{\$ifdef HEADER}");
$this->PrintOutput(0, "{\$ifndef $macro"."_PAS_H}");
$this->PrintOutput(0, "{\$define $macro"."_PAS_H}");
$this->PrintOutput(0, "type");
foreach ($header["classes"] as $class) {
// Make a pointer to each class
$this->PrintOutput(1, $class["name"]."Pointer = Pointer;");
}
$this->PrintOutput(0, "");
$this->PrintOutput(0, "{\$endif}");
$this->PrintOutput(0, "{\$endif}");
}
*/
$this->PrintOutput(0, "");
$this->PrintOutput(0, "{\$ifdef TYPES}");
$this->PrintOutput(0, "{\$ifndef $macro"."_PAS_T}");
$this->PrintOutput(0, "{\$define $macro"."_PAS_T}");
$this->PrintTypes($header);
$this->PrintOutput(0, "");
$this->PrintOutput(0, "{\$endif}");
$this->PrintOutput(0, "{\$endif}");
$this->PrintOutput(0, "");
$this->PrintOutput(0, "{\$ifdef RECORDS}");
$this->PrintOutput(0, "{\$ifndef $macro"."_PAS_R}");
$this->PrintOutput(0, "{\$define $macro"."_PAS_R}");
// Records from types
$this->PrintRecords($header);
$this->PrintOutput(0, "");
$this->PrintOutput(0, "{\$endif}");
$this->PrintOutput(0, "{\$endif}");
$this->PrintOutput(0, "");
$this->PrintOutput(0, "{\$ifdef FUNCTIONS}");
$this->PrintOutput(0, "{\$ifndef $macro"."_PAS_F}");
$this->PrintOutput(0, "{\$define $macro"."_PAS_F}");
$this->PrintFunctions($header);
$this->PrintOutput(0, "");
$this->PrintOutput(0, "{\$endif}");
$this->PrintOutput(0, "{\$endif}");
$this->PrintOutput(0, "");
$this->PrintOutput(0, "{\$ifdef EXTERNAL_SYMBOLS}");
$this->PrintOutput(0, "{\$ifndef $macro"."_PAS_S}");
$this->PrintOutput(0, "{\$define $macro"."_PAS_S}");
$this->PrintExternalSymbols($header);
$this->PrintOutput(0, "");
$this->PrintOutput(0, "{\$endif}");
$this->PrintOutput(0, "{\$endif}");
// insert user patches
if ($this->HeaderContainsPatch($header)) {
$this->PrintOutput(0, "");
$this->PrintOutput(0, "{\$ifdef USER_PATCHES}");
//$this->PrintOutput(0, "{\$ifndef $macro"."_PAS_PATCH}");
//$this->PrintOutput(0, "{\$define $macro"."_PAS_PATCH}");
$this->InsertPatches($header);
$this->PrintOutput(0, "");
//$this->PrintOutput(0, "{\$endif}");
$this->PrintOutput(0, "{\$endif}");
}
if (($header["classes"]) || ($header["protocols"])) {
$this->PrintOutput(0, "");
$this->PrintOutput(0, "{\$ifdef FORWARD}");
if ($header["protocols"]) {
foreach ($header["protocols"] as $protocol) $this->PrintOutput(1, $protocol["name"]."$this->protocol_suffix = objcprotocol;");
}
if ($header["classes"]) {
foreach ($header["classes"] as $class) {
$this->PrintOutput(1, $class["name"]." = objcclass;");
$this->PrintOutput(1, $class["name"]."Pointer = ^".$class["name"].";");
}
}
$this->PrintOutput(0, "");
$this->PrintOutput(0, "{\$endif}");
}
if ($header["classes"]) {
$this->PrintOutput(0, "");
$this->PrintOutput(0, "{\$ifdef CLASSES}");
$this->PrintOutput(0, "{\$ifndef $macro"."_PAS_C}");
$this->PrintOutput(0, "{\$define $macro"."_PAS_C}");
foreach ($header["classes"] as $class) {
//if (in_array($class["name"], $this->cocoa_classes))
$this->PrintClass($class);
}
$this->PrintOutput(0, "");
$this->PrintOutput(0, "{\$endif}");
$this->PrintOutput(0, "{\$endif}");
}
if ($header["protocols"]) {
$this->PrintOutput(0, "{\$ifdef PROTOCOLS}");
$this->PrintOutput(0, "{\$ifndef $macro"."_PAS_P}");
$this->PrintOutput(0, "{\$define $macro"."_PAS_P}");
foreach ($header["protocols"] as $protocol) {
$this->PrintOutput(1, "");
$this->PrintOutput(0, "{ ".$protocol["name"]." Protocol }");
$this->PrintOutput(1, $protocol["name"]."$this->protocol_suffix = objcprotocol");
// print methods
if ($protocol["methods"]) {
foreach ($protocol["methods"] as $name => $method) {
$this->PrintOutput(2, $method["def"]." message '".$method["objc_method"]."';");
}
}
$this->PrintOutput(1, "end; external name '".$protocol["name"]."';");
}
$this->PrintOutput(0, "{\$endif}");
$this->PrintOutput(0, "{\$endif}");
}
}
function PrintClass ($class) {
$this->PrintOutput(0, "");
$this->PrintOutput(0, "{ ".$class["name"]." }");
//print_r($class["methods"]);
// print super class or protocol which the class conforms to
if ($class["conforms"]) {
$this->PrintOutput(1, $class["name"]." = objcclass(".$class["super"].", ".$class["conforms"].")");
} elseif ($class["super"]) {
$this->PrintOutput(1, $class["name"]." = objcclass(".$class["super"].")");
}
// print instance variables
if ($class["ivars"]) {
$this->PrintOutput(1, "private");
foreach ($class["ivars"] as $ivar) {
$this->PrintOutput(2, $ivar);
}
}
// print alloc method for the class
$this->PrintOutput(2, "");
$this->PrintOutput(1, "public");
$this->PrintOutput(2, "class function alloc: ".$class["name"]."; message 'alloc';");
// print class-level methods
if ($class["methods"]) {
$this->PrintOutput(0, "");
foreach ($class["methods"] as $method) {
$this->PrintOutput(2, $method["def"]." message '".$method["objc_method"]."';");
}
}
// print category-level methods
if (count($class["categories"]) > 0) {
foreach ($class["categories"] as $name => $category) {
$this->PrintOutput(0, "");
$this->PrintOutput(2, "{ Category: $name }");
if ($category["methods"]) {
foreach ($category["methods"] as $method) {
$this->PrintOutput(2, $method["def"]." message '".$method["objc_method"]."';");
}
}
}
}
$this->PrintOutput(1, "end; external;");
}
function PrintDelegateReference ($valid_categories) {
global $version;
$date = date("D M j G:i:s T Y");
$this->PrintOutput(0, "{ Version $version - $date }");
$this->PrintOutput(0, "");
ksort($this->delegate_methods);
$this->PrintOutput(0, "unit $this->master_delegate_file;");
$this->PrintOutput(0, "interface");
$this->PrintOutput(0, "");
$this->PrintOutput(0, "{ Copy and paste these delegate methods into your real classes. }");
// implemented methods
foreach ($this->delegate_methods as $category => $selectors) {
if (in_array($category, $this->ignore_categories)) continue;
// make sure the category is valid
$valid = false;
foreach ($valid_categories as $pattern) {
if (eregi($pattern, $category)) {
$valid = true;
break;
}
}
if (!$valid) continue;
$this->PrintOutput(0, "");
$this->PrintOutput(0, "type");
$this->PrintOutput(1, "$category = objccategory (NSObject)");
//$this->PrintOutput(1, "public");
foreach ($selectors as $selector) {
// FPC long name bug work-around
if (strlen($selector["name_pascal"]) > $this->maximum_method_length) continue;
if ($selector["kind"] == "procedure") {
$this->PrintOutput(2, $selector["kind"]." ".$selector["name_pascal"].$selector["param_string"].";"." message '".$selector["name"]."';");
} else {
$this->PrintOutput(2, $selector["kind"]." ".$selector["name_pascal"].$selector["param_string"].": ".$selector["method"]["return"].";"." message '".$selector["name"]."';");
}
}
$this->PrintOutput(1, "end;");
}
}
function PrintIvarSizeComparison ($path) {
$count = 0;
$block = true;
$block_count = 1;
$limit = 2000;
$handle = fopen($path, "w+");
if (!$handle) die("Bad path to size comparison output program!");
fwrite($handle, "{\$mode objfpc}\n");
fwrite($handle, "{\$modeswitch objectivec1}\n");
fwrite($handle, "program IvarSize;\n");
fwrite($handle, "uses\n");
fwrite($handle, " objp,objcrtl,objcrtlmacosx;\n");
// print derived classes
foreach ($this->cocoa_classes as $class) {
if (in_array($class, $this->ignore_class_ivar_comparison)) continue;
if ($previous == $class) continue;
fwrite($handle, "type\n");
fwrite($handle, " TDerived$class = objcclass ($class)\n");
fwrite($handle, " extrabyte: byte;\n");
fwrite($handle, "end;\n");
$previous = $class;
}
// print procedures
foreach ($this->cocoa_classes as $class) {
if (in_array($class, $this->ignore_class_ivar_comparison)) continue;
if ($previous == $class) continue;
if ($count == 0) {
fwrite($handle, "\n");
fwrite($handle, "procedure PrintGlue$block_count;\n");
fwrite($handle, "begin\n");
$block_count ++;
}
$count ++;
fwrite($handle, " if class_getInstanceSize(TDerived$class) <> (class_getInstanceSize($class)+1) then\n");
fwrite($handle, " writeln('size of $class is wrong: ',class_getInstanceSize(TDerived$class),' <> ',class_getInstanceSize($class)+1);\n");
if ($count == $limit) {
fwrite($handle, "end;\n");
$count = 0;
}
$previous = $class;
}
if ($count < $limit) {
fwrite($handle, "end;\n");
$block_count --;
}
fwrite($handle, "begin\n");
for ($i=1; $i < $block_count + 1; $i++) {
fwrite($handle, " PrintGlue$i;\n");
}
fwrite($handle, "end.\n");
}
}
?>

View File

@ -0,0 +1,283 @@
<?php
$version = "FrameworkParser: 1.3. PasCocoa 0.3, Objective-P 0.4";
require("pascocoa_parser.php");
require("objp_parser.php");
/**
* Cocoa framework parser for PasCocoa
*
* @author Ryan Joseph
**/
// These files have duplicates in AppKit and Foundation so we ignore the foundation versions and everything is merged into AppKit
$duplicate_headers = array("foundation/NSAttributedString.inc", "foundation/NSAffineTransform.inc");
// Print only these files
$only_files = null;
$options = array();
function HandleCommandLineOptions ($argv) {
global $options;
global $root_path;
global $ignore_headers;
global $only_files;
// defaults
$options["framework_path"] = "/System/Library/Frameworks";
foreach ($argv as $option) {
$pair = explode("=", $option);
$key = trim($pair[0], "-");
$value = $pair[1];
switch ($key) {
case 'root':
$root_path = trim($value, "\"");
break;
case 'header':
$where = explode("/", trim($value, "\""));
$options[$key]["framework"] = ucfirst($where[0]);
$options[$key]["name"] = $where[1];
break;
case 'framework_path':
$options["framework_path"] = trim($value, "\"");
break;
case 'all':
$options[$key] = true;
break;
case 'objp':
$options[$key] = true;
break;
case 'encodings':
$options[$key] = true;
break;
case 'delegates':
$options[$key] = true;
break;
case 'noprint':
$options[$key] = true;
break;
case 'show':
$options[$key] = true;
break;
case 'reference':
$options[$key] = true;
break;
case 'iphone':
$options[$key] = true;
break;
case 'cocoa':
$options[$key] = true;
break;
case 'webkit':
$options[$key] = true;
break;
case 'ignore':
$ignore_headers = explode(",", trim($value, "\""));
break;
case 'only':
$only_files = explode(",", trim($value, "\""));
break;
case 'frameworks':
$options[$key] = explode(",", trim($value, "\""));
break;
default:
//print("unknown switch $key\n");
break;
}
}
}
// ??? TESTING
$testing = false;
if ($testing) {
$GLOBALS["argv"][] = "-webkit";
$GLOBALS["argv"][] = "-root=/Developer/ObjectivePascal";
$GLOBALS["argv"][] = "-delegates";
//$GLOBALS["argv"][] = "-reference";
//$GLOBALS["argv"][] = "-all";
$GLOBALS["argv"][] = "-noprint";
//$GLOBALS["argv"][] = "-show";
//$GLOBALS["argv"][] = "-only=\"UIWindow.h\"";
//$GLOBALS["argv"][] = "-frameworks=\"appkit,foundation\"";
//$GLOBALS["argv"][] = "-framework_path=\"/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.2.1.sdk/System/Library/Frameworks\"";
//$GLOBALS["argv"][] = "-header=\"uikit/UIView.h\"";
//$GLOBALS["argv"][] = "-framework_path=\"/System/Library/Frameworks\"";
//$GLOBALS["argv"][] = "-header=\"webkit/DOMDocument.h\"";
//$GLOBALS["argv"][] = "-framework_path=\"/System/Library/Frameworks\"";
//$GLOBALS["argv"][] = "-header=\"foundation/NSBundle.h\"";
//$GLOBALS["argv"][] = "-header=\"appkit/NSBundle.h\"";
$GLOBALS["argv"][] = "-ignore=\"NSGeometry.h,NSRange.h\"";
$GLOBALS["argv"][] = "-objp";
// Objective-P
/* Notes for master compile (-all):
CocoaAll.pas:
Compiling /Developer/ObjectivePascal/CocoaAll.pas
1) NSWorkspace.inc(35,46) Error: Duplicate identifier "NSWorkspaceLaunchAllowingClassicStartup"
2) NSClassDescription.inc(60,55) Error: Duplicate identifier "description"
3) NSScriptObjectSpecifiers.inc(194,44) Error: Duplicate identifier "classDescription"
4) NSScriptSuiteRegistry.inc(75,40) Error: Duplicate identifier "classDescription"
5) NSControl.inc(136,15) Error: Mismatch between number of declared parameters and number of colons in message string.
6) NSWorkspace.inc(135,189) Error: Duplicate identifier "description"
7) NSMenuItemCell.inc(64,9) Error: Duplicate identifier "reserved"
8) NSRuleEditor.inc(127,15) Error: Mismatch between number of declared parameters and number of colons in message string.
9) NSObjCRuntime.inc(79,24) Fatal: Syntax error, "identifier" expected but ":" found
Fatal: Compilation aborted
1) NSWorkspace.h has a duplicate NSWorkspaceLaunchAllowingClassicStartup constant
2) NSObjcRuntime.h contains a bad external function:
function __attribute__(: (format(__NSString__; : 1; : 2))): void NSLog(NSStringRef *format, ...); cdecl; external name '__attribute__';
procedure NSLog(fmt:NSString); cdecl; varargs; external;
3) NSMenuItemCell.h has a duplicate (case sensitive name not allowed in Pascal) field that must be changed by hand.
4) These methods have problems in the params. This is a Objc convention where an absent type is always "id"
- (void)performClick:sender;
- (void)setDelegate:delegate;
NSControl.inc(136,15) Error: Mismatch between number of declared parameters and number of colons in message string.
NSRuleEditor.inc(124,15) Error: Mismatch between number of declared parameters and number of colons in message string.
5) NSInteger types are wrong in NSObjcRuntime (should be long)
NSInteger = clong;
NSUInteger = culong;
NSNotFound = high(NSInteger);
6) Many description and classDescription identifiers are not protected in name space and cause errors
iPhoneAll.pas
1) UIAccelerometer: FPC bug causes methods with a single character message to fail. Remove the 3 methods affected
UIAccelerometer.inc(67,49) Error: Illegal expression after message directive
2) There's no way to know that UITextInputTraits is actually UITextInputTraitsProtocol due to name changes for Pascal syntax
UITextField.inc(91,32) Error: Identifier not found "UITextInputTraits"
WebKit.pas
1) Extra duplicate type in DOMObject.inc
DOMObjectInternal = Pointer;
DOMObjectInternal = DOMObjectInternal;
2) DOMDocument has method with reserved keyword name "implementation"
function implementation: DOMImplementation; message 'implementation';
3) DOMEvent has method with reserved keyword name "type"
function type: NSString; message 'type';
* reserved keywords are not protected in method names. This is messing up WebKit parsing badly
- General notes:
1) NSObject.h is parsed for the merged category methods that should be inserted manually into the real root class
2) NSRange.h was ignored because it contains custom code and can be maintained by hand very easily
3) NSGeometry.h was ignored because it contains many parsing errors and custom code, do this by hand for now.
4) All instance variables are placed into "private" for now. There are a very small number of classes that have public ivar's.
*/
//$GLOBALS["argv"][] = "-show";
}
if (count($GLOBALS["argv"]) == 1) {
print("Cocoa Framework Parser ($version) usage:\n");
print("php parser.php [switches]\n\n");
print("switches:\n\n");
print(" -all print all headers (.h) from AppKit/Foundation frameworks\n");
print(" -header=\"foundation/NSObject.h\" prints a single header from system frameworks\n");
print(" -root sets the root path of the pascocoa directory\n");
print(" -framework_path sets the root path of the frameworks directory (defaults to /System/Library/Frameworks)\n");
print(" -show prints output to screen instead of file\n");
print(" -ignore=\"NSObject.h,NSArray.h\" ignores the list of headers during parsing (-all only, no spaces)\n");
print(" -only=\"NSObject.h,NSArray.h\" only prints these files (-all only, no spaces)\n");
print(" -noprint parses but does not print (-all only)\n");
print(" -encodings prints Pascal type encoding glue for GenerateTypeEncodings.p (-all only)\n");
print(" -delegates prints NSDelegateController.inc to foundation (-all only)\n");
print(" -objp prints classes in FPC Objective-P dialect\n");
print(" -iphone one-time parse for iPhone headers\n");
print(" -cocoa one-time parse for Cocoa (AppKit/Foundation) headers\n");
print(" -frameworks=\"appkit,foundation\" list of supported frameworks to parse\n");
print("\n\n");
}
// get the command line options
if (count($GLOBALS["argv"]) > 1) {
HandleCommandLineOptions($GLOBALS["argv"]);
//print_r($options);
}
// Make the output directory
if ($options["out"]) {
@mkdir($root_path, 0777);
@mkdir($root_path."/foundation", 0777);
@mkdir($root_path."/appkit", 0777);
// @mkdir($root_path."/webkit", 0777);
@mkdir($root_path."/uikit", 0777);
// @mkdir($root_path."/reference", 0777);
}
// setup -iphone options
if ($options["iphone"]) {
$options["all"] = true;
$options["objp"] = true;
$options["frameworks"] = array("uikit");
}
// setup -cocoa options
if ($options["cocoa"]) {
$options["all"] = true;
$options["objp"] = true;
$options["frameworks"] = array("appkit","foundation");
$ignore_headers = array("NSGeometry.h","NSRange.h");
}
if ($options["webkit"]) {
$options["all"] = true;
$options["objp"] = true;
$options["frameworks"] = array("webkit");
}
// create the parser instance
if ($options["objp"]) {
$parser = new TObjPParser ($root_path, "", $options["frameworks"], $options["show"]);
} else {
$parser = new TPasCocoaParser ($root_path, "", $options["frameworks"], $options["show"]);
}
// Process single headers
if ($options["header"] && !$options["all"]) {
$path = $options["framework_path"]."/".$options["header"]["framework"].".framework/Headers/".$options["header"]["name"];
print("* Processing $path...\n");
$parser->ProcessFile($path, true);
}
//$parser->PrintIvarSizeComparison("/Users/ryanjoseph/Desktop/objp/IvarSize.p");
//exit;
// Process all headers
if ($options["all"]) {
$parser->ParseCocoaFrameworks($ignore_headers, null);
if (!$options["noprint"]) $parser->PrintAllHeaders("", $duplicate_headers, $only_files, $options["reference"]);
if ($options["delegates"]) $parser->ParseDelegateClasses();
if ($options["encodings"]) $parser->PrintTypeEncodingGlue();
}
?>

File diff suppressed because it is too large Load Diff

View File

@ -109,7 +109,7 @@ function HandleCommandLineOptions ($argv) {
}
// ??? TESTING
$testing = true;
$testing = false;
if ($testing) {
$GLOBALS["argv"][] = "-webkit";
@ -236,7 +236,6 @@ if ($options["out"]) {
// setup -iphone options
if ($options["iphone"]) {
if (!$root_path) $root_path .= "/units/i386-darwin/cocoaint/src";
$options["all"] = true;
$options["objp"] = true;
$options["frameworks"] = array("uikit");