Skip to content
New issue

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

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

Already on GitHub? # to your account

【NAPI】在 class binding 的方法中,能否支持直接透传递当前类的 shared_ptr<CtxValue> 指针? #3919

Open
JimmyVV opened this issue Jun 19, 2024 · 3 comments
Assignees
Labels
stale: 30d No interaction in the last 30 days

Comments

@JimmyVV
Copy link

JimmyVV commented Jun 19, 2024

Is your feature request related to a problem? Please describe.
现在遇到一个问题,通过一个类方法去创建另外一个类时,子对象需要有个属性指像创建对象。

但现在的设计下,没有办法做到

let mediaElemenet = new MediaElement();
mediaElement.maxSize = 2000;
let context = mediaElement.getContext();

context.element.maxSize;

Describe the solution you'd like
这里希望在方法中,能够有办法获得当前实例对象的指针。

FunctionDefine<MediaElement> addPath;
        addPath.name = "addPath";
        addPath.callback = [weak_scope](MediaElement *thiz,
                                        size_t argument_count,
                             const std::shared_ptr<CtxValue> arguments[],
                             std::shared_ptr<CtxValue> &exception) -> std::shared_ptr<CtxValue> {
            auto scope = weak_scope.lock();
            if (!scope) {
                return nullptr;
            }
            auto context = scope->GetContext();
            if (argument_count == 0) {
                exception = context->CreateException("Path2D::addPath need to have at least 1 argument");
                return nullptr;
            }
            auto context_class = scope->GetJavascriptClass("MediaContext");
           // @note: 能否有全局方法实现?
            std::shared_ptr<CtxValue> argv[] = {
                // thiz->Holder()
            };
            auto context = context->NewInstance(context_class, 1, argv, nullptr);
            return context;
        };

Describe alternatives you've considered

Additional context

Copy link

hippy-service bot commented Aug 18, 2024

Pay attention 🛎️ !!
There has been no activity on this issue for 2 months, so I will label it stalled.
It will be automatically closed in 60 days if no more activity. Feel free to leave a comment if you have any questions.

@hippy-service hippy-service bot added the stale: 30d No interaction in the last 30 days label Aug 18, 2024
@JimmyVV
Copy link
Author

JimmyVV commented Aug 18, 2024 via email

@hippy-service hippy-service bot removed the stale: 30d No interaction in the last 30 days label Aug 19, 2024
Copy link

hippy-service bot commented Oct 18, 2024

Pay attention 🛎️ !!
There has been no activity on this issue for 2 months, so I will label it stalled.
It will be automatically closed in 60 days if no more activity. Feel free to leave a comment if you have any questions.

@hippy-service hippy-service bot added the stale: 30d No interaction in the last 30 days label Oct 18, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
stale: 30d No interaction in the last 30 days
Projects
None yet
Development

No branches or pull requests

2 participants