Compiling TMS WEB Core Projects with the DCC

Regarding this blog post, I would like to share other problems that I have come across when DCC compile enabled.

I started a new project so that I wanted to retry this option. I see that these types are declared in multiple units like below. This causes compilation errors with DCC. After dropping a few components on the datamodule things get impossible to compile.

  JSValue = type Variant;
  TJSObject = type TObject;
  TJSArray = type TObject;

Do you have more details as I do not really understand what exactly you do.
I added a datamodule, added DB related components on it and I can still compile with DCC.
Do you add code like
JSValue = type Variant yourself?
If so, I'm not sure how you expect this to work. It doesn't compile with pas2js either.

I should upload a demonstration because me eigher not got this problem adding a datamodule with few xdata components after reading your comment.

I think it is a case with my project. Because this project has a datamodule with a few xdata components, but what is different I am trying to figure out. I will upload here.

In my apps I very much depend on such code below:

var
  JO: TJSObject;
begin
  JO := TJSObject(AJSValue);  //AJSValue is of type JSValue

But DCC gives invalid typecast, all is fine with Pas2JS compiler.
Thanks

That is a construct that is indeed possible with pas2js but for which unfortunately we do not see an easy equivalent for DCC.
You can put such code within a block {$IFDEF PAS2JS} {$ENDIF}

Thanks, OK isolated into a utility function. In case anyone interested:

function CastToJSObject(Value: JSValue): TJSObject;
begin
  {$IFDEF WEBLIB}
  Result := TJSObject(Value);
  {$ELSE}
  Result := nil;
  {$ENDIF}
end;

function CastToJSArray(Value: JSValue): TJSArray;
begin
  {$IFDEF WEBLIB}
  Result := TJSArray(Value);
  {$ELSE}
  Result := nil;
  {$ENDIF}
end;

1 Like

This topic was automatically closed 60 minutes after the last reply. New replies are no longer allowed.