• Dear Cerberus X User!

    As we prepare to transition the forum ownership from Mike to Phil (TripleHead GmbH), we need your explicit consent to transfer your user data in accordance with our amended Terms and Rules in order to be compliant with data protection laws.

    Important: If you accept the amended Terms and Rules, you agree to the transfer of your user data to the future forum owner!

    Please read the new Terms and Rules below, check the box to agree, and click "Accept" to continue enjoying your Cerberus X Forum experience. The deadline for consent is April 5, 2024.

    Do not accept the amended Terms and Rules if you do not wish your personal data to be transferred to the future forum owner!

    Accepting ensures:

    - Continued access to your account with a short break for the actual transfer.

    - Retention of your data under the same terms.

    Without consent:

    - You don't have further access to your forum user account.

    - Your account and personal data will be deleted after April 5, 2024.

    - Public posts remain, but usernames indicating real identity will be anonymized. If you disagree with a fictitious name you have the option to contact us so we can find a name that is acceptable to you.

    We hope to keep you in our community and see you on the forum soon!

    All the best

    Your Cerberus X Team

Tutorial This method to inject native code will blow your mind

Holzchopf

Well-known member
3rd Party Module Dev
Tutorial Author
Joined
Jul 31, 2017
Messages
500
Something in the mak/audiotest example caught my eye:

Code:
Extern
Global UserAgent:String="navigator.userAgent"
Public

If UserAgent.Contains( "MSIE " ) ...

So I thought: How..?

The answer is pretty easy: Whatever you define as a global in the extern block will be treated as such - doesn't really matter if it's a variable or a class member or method or whatever. I mean, how could the CX transpiler even possibly know this?

This means you can for example define an extern global "document.getElementById('GameConsole').value" for your HTML5 target which in JS is not only a variable but much more a method call plus a member access - but luckily, CX doesn't really care.

It gets weirder:
You can also define an external global that's basically just a function call. But how to get CX to invoke that? Easy: Just fake some assignment or property access and prevent it from happening by starting a comment in the external declaration! That way, what follows the variable access in CX will simply be ignored in JS. E.G:
Code:
Extern
' finish string with ;// so whatever follows the invoke in .cxs gets ignored in .js
Global jshack_target_refer:String = "var target = document.getElementById('CubicBezierFunction'); if(!target) target = document.getElementById('GameConsole');//"
Global jshack_target_value:String = "target.innerHTML"
Public

            ' what's behind jshack_target_refer doesn't matter
            ' since it's commented out by extern global declaration
            ' it just has to look "normal" to CX's trans
            jshack_target_refer.Length()
            jshack_target_value = "newtext"

(I guess you can tell already this is exactly what I do in the Cubic Bézier Ease App)

Yes: it's ugly, it's target-dependent, it's a hack. But on the plus side it's ugly, target-dependent and a hack which is pretty cool (you have to admit).

Pretty sure stuff like this could work for other targets too. E.g. for getting a variable/class pointer in C or calling any platform specific system function.
 
Back
Top Bottom