Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android ZAP generator produces bad code when command has nullable structure as an argument #13787

Closed
Morozov-5F opened this issue Jan 20, 2022 · 2 comments
Labels

Comments

@Morozov-5F
Copy link
Contributor

Problem

Door Lock cluster has command Clear Credential which has Nullable structure as an argument. Generator for CHIPClusters-JNI.cpp does not behave well in that case and produces clearly wrong code which uses undeclared parameters:

JNI_METHOD(void, DoorLockCluster, clearCredential)
(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject credentialType, jobject credentialIndex, jobject timedInvokeTimeoutMs)
{
    chip::DeviceLayer::StackLock lock;
    CHIP_ERROR err = CHIP_NO_ERROR;
    DoorLockCluster * cppCluster;

    chip::app::Clusters::DoorLock::Commands::ClearCredential::Type request;

    request.credential = credential == nullptr
        ? chip::app::DataModel::Nullable<chip::app::Clusters::DoorLock::Structs::DlCredential::Type>()
        : chip::app::DataModel::Nullable<chip::app::Clusters::DoorLock::Structs::DlCredential::Type>(credentialValue);

    // And so on . . .

It seems to me that the generator creates a new function with parameters that correspond to the structure field, however the code expects to have a pointer to structure as an argument.

Proposed Solution

I'm not sure how to fix this. Maybe for such cases we don't need to expand structure fields into the individual parameters but leave the structure as a whole?

@austinh0
Copy link
Contributor

#13609 reworks the codegen for structs, is it fixed in that PR?

@Morozov-5F
Copy link
Contributor Author

Yep, #13609 fixes that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants