29 June 2021, 11:04 | #81 |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
|
Aaaarrrgh!
Maybe this is a tiny detail which is worth documenting for potential plugin authors? There is no way you would expect that init()is called with register arguments. Also the example code shows a standard static void init(APTR userData). At least the plugin structure should have an entry like void (*init)(register __a0 APTR userData)to make that clear - or even better using the portable __REG__macro from clib/compiler-specific.h. The best solution, in my opinion, would be to just use standard arguments on the stack and avoid any trouble with compiler-specific register arguments. |
29 June 2021, 13:10 | #82 |
Camilla, AmigaOS Dev.
Join Date: Mar 2020
Location: Frederiksberg
Posts: 327
|
But this is the definition of the function i call:
/* Now the real data comes */ void (*init)(APTR userData); In my understanding this implies standard arguments, so I'm completely surprised it passes via a0 as that is not what i tried to do |
29 June 2021, 13:11 | #83 |
Camilla, AmigaOS Dev.
Join Date: Mar 2020
Location: Frederiksberg
Posts: 327
|
ARghh from my makefile:
params=r |
29 June 2021, 14:45 | #84 |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
|
Det var ikke så godt!
As TextEdit was already released with OS3.2, I guess the interface will not change again and has to be documented with register arguments? |
29 June 2021, 14:50 | #85 |
Camilla, AmigaOS Dev.
Join Date: Mar 2020
Location: Frederiksberg
Posts: 327
|
I have specifically not released api info officially. No one should publish plugins before there is an official api.
The whole purpose of doing it like this is so I can get feedback So I have no problem with changing it for 3.2.1 |
29 June 2021, 14:51 | #86 |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
|
|
29 June 2021, 14:53 | #87 |
Camilla, AmigaOS Dev.
Join Date: Mar 2020
Location: Frederiksberg
Posts: 327
|
he should just be aware that he needs to do it for all the settings gui functions too
And obviously be prepared for a rebuild when 3.2.1 is out |
29 June 2021, 15:08 | #88 |
bye
Join Date: Jun 2016
Location: Some / Where
Posts: 680
|
|
29 June 2021, 15:43 | #89 |
Registered User
Join Date: Dec 2010
Location: Athens/Greece
Age: 53
Posts: 719
|
It might be beneficial to keep the params=r in the makefile and declare the plugin functions prefixed with __stdargs ?
|
29 June 2021, 17:31 | #90 | ||
Registered User
Join Date: May 2017
Location: Belgium
Age: 50
Posts: 334
|
Quote:
Here's my init()function: Code:
static void init(__reg("a0") APTR userData) { struct Filetype *fType = (struct Filetype *)userData; struct Hook *hook = NULL; if(!openLibs()) { terminate(fType); return; } hook = (struct Hook *)AllocVec(sizeof(struct Hook), MEMF_CLEAR); hook->h_Entry = (ULONG (*)()) highlightBlock; hook->h_SubEntry = NULL; hook->h_Data = 1234567; fType->highlighterHook = hook; // any number or pointer of our choosing // does this have to be equal to hook->h_Data? fType->pluginData = (ULONG)1234567; fType->name = "ExampleName"; fType->typeName = "ExampleTypeName"; fType->autoFileTypes = "ExampleAFT"; // example? eg (*.s;*.i)? fType->terminate = terminate; fType->settingsTitle = settingsTitle; fType->settingsGadget = settingsGadget; fType->processGadgetUp = processGadgetUp; fType->setSettingsFromGUI = setSettingsFromGUI; fType->setGUIFromSettings = setGUIFromSettings; fType->applySettings = applySettings; fType->saveSettings = saveHighlightSettings; fType->loadSettings = loadHighlightSettings; fType->disposeGadgets = disposeGadgets; } highlightBlock(): Code:
ULONG __saveds highlightBlock(__reg("a0") struct Hook *h, __reg("a2") VOID *o, __reg("a1") VOID *msg) { struct HighlightMessage *hm = (struct HighlightMessage *)msg; STRPTR text = hm->Text; UWORD state = hm->StatusOfPrevBlock; UWORD start = 0; UWORD end = strlen(text); // if line is longer than 10 chars we paint the entire line with color 3 if (end > 10) HighlightSetFormat(o, start, end, (3<<8)|TBSTYLE_SETCOLOR); return (ULONG)state + 1L; } Quote:
Also, a little more explanation would be welcome, but I'm sure you already knew that. Eg, does fType->pluginData need to be equal to hook->h_Data? How to specify the file types this highlighting automatically applies to (eg, .s and .i files)? I'll be more than happy to do that when the time comes! |
||
29 June 2021, 17:36 | #91 |
Registered User
Join Date: Dec 2010
Location: Athens/Greece
Age: 53
Posts: 719
|
Well done for the working plugin.
Just curious here, does it work if you remove __saveds from highlightBlock? |
29 June 2021, 17:40 | #92 |
Registered User
Join Date: May 2017
Location: Belgium
Age: 50
Posts: 334
|
|
29 June 2021, 17:41 | #93 |
Registered User
Join Date: Dec 2010
Location: Athens/Greece
Age: 53
Posts: 719
|
It should work. You are not referencing any plugin variables, just locals (or parameter's passed).
Anyways __saveds is there if you need to access any global plugin variable(s) I guess. |
29 June 2021, 17:45 | #94 |
Registered User
Join Date: May 2017
Location: Belgium
Age: 50
Posts: 334
|
Ok, thanks for elaborating on this. TBH, I only have a vague idea what these qualifiers really mean ATM..
|
29 June 2021, 18:48 | #95 |
Camilla, AmigaOS Dev.
Join Date: Mar 2020
Location: Frederiksberg
Posts: 327
|
|
29 June 2021, 19:36 | #96 | |
Camilla, AmigaOS Dev.
Join Date: Mar 2020
Location: Frederiksberg
Posts: 327
|
Quote:
the fType->autoFileTypes is the one that specieds the file to automatically apply to: for you that would be: "asm\ni" This refers to asm and i defticons typenames As for a more elaborate example, I'll have to see if it can be released, but apart from getting approval, I'm also not that proud of how the default plugins are coded. They do their job but were never intended to be top of the line - so using them as examples for others to learn from is maybe not so great. This means I should spend more time on making an example. Time I'd like to spend on other things too. We'll see |
|
29 June 2021, 20:17 | #97 | ||
Registered User
Join Date: May 2017
Location: Belgium
Age: 50
Posts: 334
|
Quote:
Quote:
|
||
29 June 2021, 20:31 | #98 | |
bye
Join Date: Jun 2016
Location: Some / Where
Posts: 680
|
Quote:
__saveds is not useful here - it's simply stupid. And refering to the task's userdata pointer: How many plugins can store it's a4 register in the same location? And what happens if the main program uses that field too?? No baserel stuff in these plugins! And if the same plugin is used by many instances: use only the allocated memory - pointer to stored in fType->pluginData - for everything. No global stuff. none at all. Last edited by bebbo; 29 June 2021 at 20:39. |
|
29 June 2021, 22:13 | #99 | |||
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
|
At least it is not necessary, as long as the plugin is not compiled with small data.
Quote:
Quote:
Quote:
|
|||
29 June 2021, 22:36 | #100 | |
Camilla, AmigaOS Dev.
Join Date: Mar 2020
Location: Frederiksberg
Posts: 327
|
Quote:
A new instance of TextEdit will load the plugins again. The default plugins use global vars for storing library bases as well as the settings for the plugin. (colors, softstyle for the various types) The hook stores a pointer to the statemachine in it's data member, which is allocated and generated on init |
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
AmigaOS 3.2 TextEdit - black text on black background? | Warty | support.Apps | 7 | 08 June 2021 17:30 |
gedit asm syntax highlighting plugin? | grond | Coders. Asm / Hardware | 0 | 19 May 2020 13:06 |
VBCC assembler linking syntax? | NovaCoder | Coders. General | 2 | 20 May 2011 03:04 |
CLI Syntax | Greaser | New to Emulation or Amiga scene | 1 | 08 October 2006 10:14 |
SynTax Disks (old) | andreas | request.Old Rare Games | 1 | 19 July 2003 04:02 |
|
|