added debugging log to 1.0 runtime, a small fix objcrtltest

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@764 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
skalogryz
2009-04-06 09:31:20 +00:00
parent 5a274d364c
commit cf995dd2cb
2 changed files with 28 additions and 4 deletions

View File

@ -7,6 +7,7 @@
headers included with XCode 3.1.2 headers included with XCode 3.1.2
The original copyright note of is kept on each include file The original copyright note of is kept on each include file
} }
{$DEFINE DEBUG}
unit objcrtl10; unit objcrtl10;
@ -521,10 +522,31 @@ end;
function class_addMethod10(cls:_Class; name:SEL; _imp:IMP; types:pchar):BOOL; cdecl; function class_addMethod10(cls:_Class; name:SEL; _imp:IMP; types:pchar):BOOL; cdecl;
begin begin
if not Assigned(cls) or not Assigned(name) or not Assigned(_imp) or not Assigned(types) then begin if not Assigned(cls) or not Assigned(name) or not Assigned(_imp) or not Assigned(types) then begin
{$IFDEF DEBUG}
write('* Bad params?: cls = ', Integer(cls));
write(' name = ', PChar(name));
write(' imp = ', Integer(_imp));
writeln(' type = ', types);
{$ENDIF}
Result := false; Result := false;
Exit; Exit;
end; end;
{$IFDEF DEBUG}
write('* method list = ', Integer(_Class1(cls)^.methodLists));
if Assigned (TClassMethod1Reg(_Class1(cls)^.methodLists)) then
writeln(', ', TClassMethod1Reg(_Class1(cls)^.methodLists).ClassName)
else
writeln;
try
{$ENDIF}
TClassMethod1Reg(_Class1(cls)^.methodLists).AddMethod(name, _imp, types); TClassMethod1Reg(_Class1(cls)^.methodLists).AddMethod(name, _imp, types);
{$IFDEF DEBUG}
writeln('"',PChar(name), '" added successfully');
except
writeln('* exception while adding method');
end;
{$ENDIF}
Result := true; Result := true;
end; end;

View File

@ -54,7 +54,7 @@ const
newMethod4Enc = 'f@:'; newMethod4Enc = 'f@:';
newMethod5 = 'getSmallRecord'; newMethod5 = 'getSmallRecord';
newMethod5Enc = '{TSmallRecord=ccc}@:'; newMethod5Enc = '{TSmallRecord=cccc{TSubStructure=cccc}}@:';
varName = 'myvar'; varName = 'myvar';
@ -105,11 +105,13 @@ begin
class_addMethod(cl, selector(newMethod1), @imp_newMethod1, newMethod1Enc) and class_addMethod(cl, selector(newMethod1), @imp_newMethod1, newMethod1Enc) and
class_addMethod(cl, selector(newMethod2), @imp_newMethod2, newMethod2Enc) and class_addMethod(cl, selector(newMethod2), @imp_newMethod2, newMethod2Enc) and
class_addMethod(cl, selector(newMethod3), @imp_newMethod3, newMethod3Enc) and class_addMethod(cl, selector(newMethod3), @imp_newMethod3, newMethod3Enc) and
class_addMethod(cl, selector(newMethod4), @imp_newMethod4, newMethod4Enc); class_addMethod(cl, selector(newMethod4), @imp_newMethod4, newMethod4Enc) and
class_addMethod(cl, selector(newMethod5), @imp_getSmallRec, newMethod5Enc); class_addMethod(cl, selector(newMethod5), @imp_getSmallRec, newMethod5Enc);
if not b then writeln('failed to add/override some method(s)'); if not b then
writeln('failed to add/override some method(s)');
class_addIvar(cl, varName, sizeof(TObject), 1, _C_PASOBJ); if not class_addIvar(cl, varName, sizeof(TObject), 1, _C_PASOBJ) then
writeln('failed to add variable ', varName);
objc_registerClassPair(cl); objc_registerClassPair(cl);
end; end;