<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">Hi,<div><br></div><div>I’ve created a javascript class in native code (i.e. JSClassCreate, JSObjectMakeConstructor etc.) and want to subclass this class in javascript.</div><div><br></div><div>So pretty much:</div><div><br></div><div><div style="margin: 0px; font-size: 11px; font-family: Menlo; color: rgb(112, 61, 170);"><span style="color: rgb(0, 0, 0);"> </span>JSClassDefinition<span style="color: rgb(0, 0, 0);"> classDef = </span>kJSClassDefinitionEmpty<span style="color: rgb(0, 0, 0);">;</span></div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"> classDef.<span style="color: rgb(112, 61, 170);">className</span> = <span style="color: rgb(209, 47, 27);">"TestClass"</span>;</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"> classDef.<span style="color: rgb(112, 61, 170);">getProperty</span> = <span style="color: rgb(49, 89, 93);">class_getProperty</span>;</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"> classDef.<span style="color: rgb(112, 61, 170);">setProperty</span> = <span style="color: rgb(49, 89, 93);">class_setProperty</span>;</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; min-height: 13px;"> <span style="color: rgb(112, 61, 170);">JSClassRef</span> classRef = <span style="color: rgb(61, 29, 129);">JSClassCreate</span>(&classDef);</div></div><div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"> <span style="color: rgb(112, 61, 170);">JSObjectRef</span> constructor = JSObjectMakeConstructor(ctx, gClassRef, class_constructor);</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"> <span style="color: rgb(61, 29, 129);">JSObjectSetProperty</span>(ctx, <span style="color: rgb(61, 29, 129);">JSContextGetGlobalObject</span>(ctx), <span style="color: rgb(79, 129, 135);">JsString</span>(<span style="color: rgb(209, 47, 27);">"TestClass"</span>), constructor, <span style="color: rgb(39, 42, 216);">0</span>, <span style="color: rgb(187, 44, 162);">NULL</span>);</div></div><div><br></div><div>class_constructor does:</div><div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"> <span style="color: rgb(187, 44, 162);">return</span> <span style="color: rgb(61, 29, 129);">JSObjectMake</span>(ctx, classRef, <span style="color: rgb(187, 44, 162);">NULL</span>);</div></div><div><br></div><div>This works, so I can do</div><div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"> <span style="color: rgb(187, 44, 162);">var</span> test = <span style="color: rgb(187, 44, 162);">new</span> TestClass();</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"> test.field = <span style="color: rgb(39, 42, 216);">1</span>;</div></div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"><br></div><div>and both class_constructor and class_setProperty is called.</div><div><br></div><div>Now I’m trying to subclass the TestClass:</div><div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"> <span style="color: rgb(187, 44, 162);">function</span> SubClass()</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"> {</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"> TestClass.apply(<span style="color: rgb(187, 44, 162);">this</span>, arguments);</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"> }</div></div><div><br></div><div>here it already got the problem that TestClass - being a constructor - does not have .bind() or .apply().</div><div><br></div><div>Does someone know how to get this working?</div><div><br></div><div>Thank you very much,</div><div><br></div><div>Mo</div></body></html>